@camstack/addon-admin-ui 1.2.367 → 1.2.368
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{AddonAssetIcon-DpOYiFwy.js → AddonAssetIcon-DFj-ju1T.js} +1 -1
- package/dist/assets/{AddonIntegrationBody-DdNzzr-6.js → AddonIntegrationBody-FGAYdPUA.js} +1 -1
- package/dist/assets/{Addons-B0udTC2D.js → Addons-WwpkTbDd.js} +1 -1
- package/dist/assets/{AdminTabs-Bw0vLcQV.js → AdminTabs-DTp_qwRF.js} +1 -1
- package/dist/assets/{AiProfiles-DLiFaDiD.js → AiProfiles-CBco5ewR.js} +1 -1
- package/dist/assets/{BrokerForm-BOnoKZt-.js → BrokerForm-C1gCAO_i.js} +1 -1
- package/dist/assets/{Build-BJlvXVpa.js → Build-DurNKP8T.js} +1 -1
- package/dist/assets/{Calendars-CMaYwnFF.js → Calendars-CgpSaf57.js} +1 -1
- package/dist/assets/{Cluster-DLlURHMO.js → Cluster-DvhjeS7K.js} +1 -1
- package/dist/assets/ClusterStepModel-B6r5CyPs.js +1 -0
- package/dist/assets/{CompositionEditor-BGu7clTR.js → CompositionEditor-B72RWTAg.js} +1 -1
- package/dist/assets/{CompositionEditorPage-Lv4rlb7_.js → CompositionEditorPage-Czh4hLXm.js} +1 -1
- package/dist/assets/{Data-DF4tGpWD.js → Data-DXof6DOP.js} +1 -1
- package/dist/assets/{DetectionIntelligence-fSWafsKy.js → DetectionIntelligence-DOHtIjr_.js} +1 -1
- package/dist/assets/{DeviceDetail-nMeXPEtL.js → DeviceDetail-DJTOlefk.js} +1 -1
- package/dist/assets/{DeviceDoActionFields-DHRkE5xP.js → DeviceDoActionFields-CgcW2y34.js} +1 -1
- package/dist/assets/{Devices-DQBiqk6T.js → Devices-Dxdfsu2U.js} +1 -1
- package/dist/assets/{EmbedPlayerPage-C6S5WEa7.js → EmbedPlayerPage-DBDO4iGl.js} +1 -1
- package/dist/assets/{Events-CH3iXReO.js → Events-BfvAxlZU.js} +1 -1
- package/dist/assets/{Identity-CrnEnlEQ.js → Identity-CdNS5Nbo.js} +1 -1
- package/dist/assets/{IntegrationDetail-BLdUZANt.js → IntegrationDetail-v37t7dlu.js} +1 -1
- package/dist/assets/{Integrations-iPnsLoVn.js → Integrations-B46b2Fdt.js} +1 -1
- package/dist/assets/{Integrations-DIZiDn_B.js → Integrations-BhXxxG3u.js} +1 -1
- package/dist/assets/{Locations-CXQv36Yt.js → Locations-DS7U1LC0.js} +1 -1
- package/dist/assets/{Logs-DPwwQi8h.js → Logs-CEo_ltyB.js} +1 -1
- package/dist/assets/{MotionZonesSettings-CftAgxWi.js → MotionZonesSettings-CEgwXQs4.js} +1 -1
- package/dist/assets/{MyAccess-ZAW5kVD_.js → MyAccess-BPfDF0OL.js} +1 -1
- package/dist/assets/{Network-C6JvbIXt.js → Network-CsE6aS-2.js} +1 -1
- package/dist/assets/{NodeAddonsSettingsPanel-BiE-QIvS.js → NodeAddonsSettingsPanel-ud5IAMLM.js} +1 -1
- package/dist/assets/{Notifications-h9VuRiTF.js → Notifications-Dq9lhOuh.js} +1 -1
- package/dist/assets/{Plates-BvdnDkGc.js → Plates-DY7gAqtN.js} +1 -1
- package/dist/assets/{PrivacyMaskSettings-CUbD6k0L.js → PrivacyMaskSettings-3Qj6iJyr.js} +1 -1
- package/dist/assets/{Recordings-BdgobGao.js → Recordings-Cu6I48Ge.js} +1 -1
- package/dist/assets/{ScanNetworkModal-iiJJTylP.js → ScanNetworkModal-DeQVAhiv.js} +1 -1
- package/dist/assets/{SceneMonitorEditor-nRqgGlp2.js → SceneMonitorEditor-DLTybD7E.js} +1 -1
- package/dist/assets/{Scenes-DgqiTzk9.js → Scenes-yXnX2BEQ.js} +1 -1
- package/dist/assets/{SessionsList-Ba2Ozpmv.js → SessionsList-DTYAg11v.js} +1 -1
- package/dist/assets/{Showroom-iXUFZXmM.js → Showroom-DWPBOwhC.js} +1 -1
- package/dist/assets/{System-k1CqgwqI.js → System-B2dJPzzY.js} +1 -1
- package/dist/assets/{Terminal-Dv-j25I5.js → Terminal-Dw2mDFS9.js} +1 -1
- package/dist/assets/{Viewer-kmcfxFof.js → Viewer-BOmPgDRl.js} +1 -1
- package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-Ca2DwjVP.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-DtaIXYDp.js} +1 -1
- package/dist/assets/{archive-C_-iEHhW.js → archive-6pzbE4zL.js} +1 -1
- package/dist/assets/{authed-media-rH30orNX.js → authed-media-dlxPHLGt.js} +1 -1
- package/dist/assets/{boxes-Cj3enrG0.js → boxes-B9mRSNXT.js} +1 -1
- package/dist/assets/circle-slash-D3OU4sq-.js +1 -0
- package/dist/assets/client-DdTCFotl.js +357 -0
- package/dist/assets/crop-C4_qNtVc.js +1 -0
- package/dist/assets/{debounced-invalidate-CUPcL0rQ.js → debounced-invalidate-CjvnQ6zt.js} +1 -1
- package/dist/assets/{device-integration-icon-CjpZldgd.js → device-integration-icon-BRBO6DaZ.js} +1 -1
- package/dist/assets/device-picker-model-DOwpVM5h.js +1 -0
- package/dist/assets/{dist-B3-nKFP1.js → dist-BPTn9PvV.js} +1 -1
- package/dist/assets/dist-CJxcey0N.js +357 -0
- package/dist/assets/{face-bbox-CqIiQdVy.js → face-bbox-CPsQ49nP.js} +1 -1
- package/dist/assets/{hard-drive-download-B1qrAMQ7.js → hard-drive-download-CUKF7GIe.js} +1 -1
- package/dist/assets/{history-Ixgo2o2a.js → history-BR0cgtxK.js} +1 -1
- package/dist/assets/{hostInit-Cgl65BZF.js → hostInit-D7PExcI5.js} +1 -1
- package/dist/assets/{index-Bq3Mrl-l.js → index-BhXNFlQG.js} +3 -3
- package/dist/assets/{layers-JboEX-t3.js → layers-BEphtFOD.js} +1 -1
- package/dist/assets/{location-owned-usage-DAWlSLDx.js → location-owned-usage-BHS4BUrZ.js} +1 -1
- package/dist/assets/{mf-entry-bootstrap-0-5f4030f8.js → mf-entry-bootstrap-0-f35db814.js} +2 -2
- package/dist/assets/{monitor-smartphone-DEvaCEpt.js → monitor-smartphone-DbkPiYT_.js} +1 -1
- package/dist/assets/mount-DOwpVM5h.js +1 -0
- package/dist/assets/{notification-schedule-field-mbJZiR_t.js → notification-schedule-field-DQOVzLdk.js} +1 -1
- package/dist/assets/{octagon-alert-CQuofVwc.js → octagon-alert-DI2r29y1.js} +1 -1
- package/dist/assets/{player-overlays-OREckyXS.js → player-overlays-CVsVEZkx.js} +1 -1
- package/dist/assets/remoteEntry-8sPAjus8.js +1 -0
- package/dist/assets/{send-CuHij6pJ.js → send-CsS0XJlB.js} +1 -1
- package/dist/assets/{settings-2-BQZcFYTR.js → settings-2-CyVUMXY7.js} +1 -1
- package/dist/assets/{src-CEnvJotZ.js → src-DBOD88Il.js} +3 -3
- package/dist/assets/{use-scenes-feed-1Od0TZaA.js → use-scenes-feed-B3khNWlP.js} +1 -1
- package/dist/assets/{use-stationary-objects-DqVVD1DW.js → use-stationary-objects-DONRHYCH.js} +1 -1
- package/dist/assets/useEventInvalidation-DOwpVM5h.js +1 -0
- package/dist/assets/{useNodeUrlSelection-C3vDpTz0.js → useNodeUrlSelection-CqbePEmt.js} +1 -1
- package/dist/assets/user-round-DIYdKGlH.js +1 -0
- package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-CjZzajvR.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-Cns_eCdr.js} +2 -2
- package/dist/index.html +7 -7
- package/dist/server/addon.js +13 -2
- package/package.json +1 -1
- package/dist/assets/ClusterStepModel-DUqB59eQ.js +0 -1
- package/dist/assets/circle-slash-B9leNw8c.js +0 -1
- package/dist/assets/client-1c3e-nOc.js +0 -357
- package/dist/assets/crop-Cz85GIsX.js +0 -1
- package/dist/assets/device-picker-model-qjRcMIFg.js +0 -1
- package/dist/assets/dist-Dp0Vbww8.js +0 -357
- package/dist/assets/mount-qjRcMIFg.js +0 -1
- package/dist/assets/remoteEntry-DAkePvGv.js +0 -1
- package/dist/assets/useEventInvalidation-qjRcMIFg.js +0 -1
- package/dist/assets/user-round-BmFyUIzE.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{vt as e}from"./player-overlays-
|
|
1
|
+
import{vt as e}from"./player-overlays-CVsVEZkx.js";var t=e(`layers`,[[`path`,{d:`M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z`,key:`zw3jo`}],[`path`,{d:`M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12`,key:`1wduqc`}],[`path`,{d:`M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17`,key:`kqbvx6`}]]);export{t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{I as e,Q as t,S as n,W as r,o as i,q as a,x as o,z as s}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{at as c,gt as l,ht as u,mt as d,st as f,vt as p}from"./player-overlays-OREckyXS.js";import{Ad as m,Cn as h,Ed as g,Gn as _,Hd as v,I as y,Od as b,Pn as x,Tn as S,bn as C,ju as w,pr as T,sl as ee,wn as te,xn as ne,yl as re,yn as ie}from"./src-CEnvJotZ.js";import{t as E}from"./archive-C_-iEHhW.js";import{t as D}from"./hard-drive-download-B1qrAMQ7.js";import{Zr as O}from"./client-1c3e-nOc.js";import{I as ae}from"./index-Bq3Mrl-l.js";import{t as k}from"./format-size-DIxKXxtj.js";var A=p(`eraser`,[[`path`,{d:`M21 21H8a2 2 0 0 1-1.42-.587l-3.994-3.999a2 2 0 0 1 0-2.828l10-10a2 2 0 0 1 2.829 0l5.999 6a2 2 0 0 1 0 2.828L12.834 21`,key:`g5wo59`}],[`path`,{d:`m5.082 11.09 8.828 8.828`,key:`1wx5vj`}]]);t();function j(e){let t=e.trim().toLowerCase();return t.length===0?``:t.replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``)}function M(e,t){let n=j(t);return`${e}:${n.length>0?n:`default`}`}var N=new Set([`proc`,`sys`,`dev`,`run`,`boot`,`lost+found`,`snap`,`bin`,`sbin`,`lib`,`lib32`,`lib64`,`libx32`,`usr`,`etc`,`var`,`opt`,`tmp`,`srv`,`root`,`System`,`Library`,`Applications`,`cores`,`private`]),P=[`recordings`,`data`,`mnt`,`media`,`Volumes`];function F(e){let t=P.findIndex(t=>t===`recordings`?e.startsWith(t):e===t);return t===-1?P.length:t}function I(e){return e.filter(e=>!e.name.startsWith(`.`)&&!N.has(e.name)).toSorted((e,t)=>{let n=F(e.name)-F(t.name);return n===0?e.name.localeCompare(t.name):n}).map(e=>e.path)}function oe({nodeId:t,value:r,onChange:i}){let l=c().trpcClient,[u,d]=a([]),[f,p]=a(r),[m,h]=a(null),[g,_]=a(null),[v,y]=a(``),b=e(async(e,n)=>{_(null);try{let r=await l.filesystemBrowse.browse.query({nodeId:t,path:e});h(r),p(r.path),n&&i(r.path)}catch(e){_(e instanceof Error?e.message:`browse failed`)}},[l,t,i]);s(()=>{p(r),(async()=>{let e=await l.filesystemBrowse.browse.query({nodeId:t,path:`/`}).then(e=>e).catch(()=>null);if(e){d(I(e.entries)),await b(r.startsWith(`/`)?r:`/`,!1);return}try{let e=await l.filesystemBrowse.listAllowedRoots.query({nodeId:t});d(e),await b(r&&e.some(e=>r.startsWith(e))?r:e[0]??``,!1)}catch(e){d([]),h(null),_(e instanceof Error&&/not available on node/i.test(e.message)?`This node can't be browsed remotely. Enter the path manually.`:e instanceof Error?e.message:`browse unavailable`)}})()},[t]);let x=async()=>{if(!(!v.trim()||!m)){_(null);try{let e=`${m.path.replace(/\/+$/,``)}/${v.trim()}`;await l.filesystemBrowse.createDir.mutate({nodeId:t,path:e}),y(``),await b(m.path,!0)}catch(e){_(e instanceof Error?e.message:`create failed`)}}},S=e=>`${(e/1e9).toFixed(1)} GB`;return n(`div`,{className:`space-y-2 rounded border border-border p-2`,children:[o(`div`,{className:`flex flex-wrap gap-1`,children:u.map(e=>o(`button`,{onClick:()=>void b(e,!0),className:`rounded border border-border px-2 py-0.5 text-[10px] font-mono hover:border-primary/40`,children:e},e))}),o(`input`,{value:f,onChange:e=>{p(e.target.value),i(e.target.value)},placeholder:`/absolute/path`,className:`w-full rounded border border-border bg-background px-2 py-1 text-[11px] font-mono`}),m&&n(`div`,{className:`text-[10px] text-foreground-subtle`,children:[S(m.freeBytes),` free / `,S(m.totalBytes)]}),o(`div`,{className:`max-h-40 space-y-0.5 overflow-y-auto`,children:m?.entries.map(e=>n(`button`,{onClick:()=>void b(e.path,!0),className:`block w-full truncate rounded px-2 py-1 text-left text-xs hover:bg-primary/5`,children:[`📁 `,e.name]},e.path))}),n(`div`,{className:`flex gap-1`,children:[o(`input`,{value:v,onChange:e=>y(e.target.value),placeholder:`new folder`,className:`flex-1 rounded border border-border bg-background px-2 py-1 text-xs`}),o(`button`,{onClick:()=>void x(),className:`rounded border border-border px-2 py-1 text-xs hover:border-primary/40`,children:`Create`})]}),g&&o(`div`,{className:`text-[10px] text-red-400`,children:g})]})}t();function L({initialType:e,onClose:t,onCreated:s}){let l=i(),d=c().trpcClient,[f,p]=a(`picker`),[m,h]=a(e),[g,_]=a(null),[b,x]=a({}),[w,T]=a(``),[E,D]=a(null),[O,k]=a(!1),[A,j]=a(`hub`),[N,P]=a(null),[F,I]=a(!1),L=e=>x(t=>({...t,basePath:e})),R=typeof b.basePath==`string`?b.basePath:``,z=ee(),B=r(()=>{let e=z.data;return Array.isArray(e)?e:[]},[z.data]),V=z.isLoading,H=re({onSuccess:()=>{l.invalidateQueries({queryKey:[[`storage`,`listLocations`]]}),s()}}),U=r(()=>E!==null&&E.length>0?E:M(m,w),[m,w,E]),W=async()=>{if(g){I(!0),P(null);try{P(await(e=>d.storage.testConfig.query(e))({providerId:g.providerId,config:b}))}catch(e){P({ok:!1,error:e instanceof Error?e.message:String(e)})}finally{I(!1)}}};return o(ie,{open:!0,onOpenChange:e=>!e&&t(),children:n(ne,{width:`md`,placement:`sheet-on-mobile`,scroll:`body`,children:[n(te,{children:[o(S,{children:{picker:`Add Location — Pick provider`,config:`Add Location — ${g?.displayName??``}`,naming:`Add Location — Name`}[f]}),n(`p`,{className:`text-xs text-foreground-subtle`,children:[`Type: `,o(`span`,{className:`font-mono`,children:m})]})]}),n(C,{children:[f===`picker`&&n(`div`,{className:`space-y-2`,children:[V&&o(`div`,{className:`text-xs text-foreground-subtle animate-pulse`,children:`Loading providers…`}),!V&&B.length===0&&n(`div`,{className:`rounded border border-border bg-background px-3 py-4 text-center text-xs text-foreground-subtle`,children:[`No storage-provider supports type "`,m,`". Install a compatible addon (e.g.`,` `,o(`code`,{className:`font-mono`,children:`remote-storage`}),`) to enable it.`]}),B.map(e=>n(`button`,{onClick:()=>{_(e),p(`config`)},className:`flex w-full items-center gap-3 rounded-lg border border-border bg-background p-3 text-left hover:border-primary/40 hover:bg-primary/5 transition-colors`,children:[n(`div`,{className:`flex-1 min-w-0`,children:[o(`p`,{className:`text-xs font-semibold text-foreground`,children:e.displayName}),o(`p`,{className:`text-[10px] text-foreground-subtle font-mono mt-0.5 truncate`,children:e.providerId})]}),o(u,{className:`h-4 w-4 text-foreground-subtle flex-shrink-0`})]},e.providerId))]}),f===`config`&&g&&n(`div`,{className:`space-y-3`,children:[o(ae,{schema:g.configSchema,values:b,onChange:x}),g.nodeLocal&&n(`div`,{className:`space-y-2`,children:[o(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Node`}),o(y,{selectedNodeId:A,onSelect:j,alwaysShow:!0}),o(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Path`}),o(oe,{nodeId:A,value:R,onChange:L})]}),N&&o(`div`,{className:`rounded border px-3 py-2 text-[11px] ${N.ok?`border-success/30 bg-success/5 text-success`:`border-danger/30 bg-danger/5 text-danger`}`,children:N.ok?`Connection OK.`:`Test failed: ${N.error??`unknown error`}`}),n(`div`,{className:`flex items-center justify-between pt-1`,children:[o(`button`,{onClick:()=>p(`picker`),className:`rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground`,children:`Back`}),n(`div`,{className:`flex items-center gap-2`,children:[o(`button`,{onClick:()=>{W()},disabled:F,className:`rounded border border-border px-3 py-1.5 text-xs text-foreground hover:bg-primary/10 disabled:opacity-50`,children:F?`Testing…`:`Test connection`}),o(`button`,{onClick:()=>p(`naming`),className:`rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90`,children:`Next`})]})]})]}),f===`naming`&&g&&n(`div`,{className:`space-y-3`,children:[n(`div`,{className:`space-y-1`,children:[o(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Display name`}),o(`input`,{type:`text`,value:w,onChange:e=>T(e.target.value),placeholder:`${m} on ${g.displayName}`,className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`})]}),n(`div`,{className:`space-y-1`,children:[n(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:[`Id`,` `,o(`span`,{className:`lowercase tracking-normal text-foreground-subtle`,children:`— auto-derived; override if needed`})]}),o(`input`,{type:`text`,value:U,onChange:e=>D(e.target.value),placeholder:M(m,w),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground font-mono focus:outline-none focus:ring-1 focus:ring-primary`}),n(`p`,{className:`text-[10px] text-foreground-subtle`,children:[`Format: `,o(`code`,{className:`font-mono`,children:`<type>:<slug>`}),`. Lowercase letters, digits, and hyphens only.`]})]}),n(`label`,{className:`flex items-start gap-2 rounded border border-border bg-background px-3 py-2 cursor-pointer hover:bg-primary/5`,children:[o(`input`,{type:`checkbox`,checked:O,onChange:e=>k(e.target.checked),className:`accent-primary mt-0.5`}),n(`div`,{className:`space-y-0.5`,children:[o(`div`,{className:`text-xs font-medium text-foreground`,children:`Enable immediately`}),o(`div`,{className:`text-[10px] text-foreground-subtle`,children:`A disabled location receives no writes until enabled — reads and age-based retention still work, nothing new lands here. Leave this off to register the disk now and start using it later.`})]})]}),H.isError&&o(`div`,{className:`rounded border border-danger/30 bg-danger/5 text-danger px-3 py-2 text-[11px]`,children:H.error instanceof Error?H.error.message:String(H.error)}),n(`div`,{className:`flex items-center justify-between pt-1`,children:[o(`button`,{onClick:()=>p(`config`),className:`rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground`,children:`Back`}),n(`div`,{className:`flex items-center gap-2`,children:[o(`button`,{onClick:()=>{h(e),_(null),x({}),T(``),D(null),k(!1),P(null),p(`picker`)},className:`rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground`,children:`Reset`}),n(`button`,{onClick:()=>{g&&H.mutate({id:U,type:m,displayName:w.trim(),providerId:g.providerId,config:b,enabled:O,nodeId:g.nodeLocal?A:void 0})},disabled:H.isPending||w.trim().length===0,className:`inline-flex items-center gap-1.5 rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50`,children:[H.isPending?o(v,{className:`h-3.5 w-3.5 animate-spin`}):null,H.isPending?`Saving…`:`Save`]})]})]})]})]})]})})}function R(e){return O(e)}function z(e){return e===`active`}var B=[{mode:`active`,label:`Active`,consequence:`New data is written here, and the oldest is deleted when the disk fills up.`,requiresConfirmation:!1},{mode:`readonly`,label:`Read-only`,consequence:`Nothing new is written and nothing is ever deleted. A frozen archive that stays on the timeline.`,requiresConfirmation:!1},{mode:`drain`,label:`Drain`,consequence:`Nothing new is written. The oldest data here is deleted, a little at a time, until this location is empty.`,requiresConfirmation:!1},{mode:`disabled`,label:`Disabled`,consequence:`Nothing is written and nothing is read: the footage stored here disappears from the timeline until you turn it back on. Nothing is deleted.`,requiresConfirmation:!0}];function V(e){return B.find(t=>t.mode===e)??B[0]}function H(e){return V(e).requiresConfirmation}var U=`Blocked: this is the last location of its type still accepting writes — new data would have nowhere to go.`;function W(e,t,n){return z(n)||!z(R(e))||t.some(t=>t.id!==e.id&&z(R(t)))?{blocked:!1,reason:``}:{blocked:!0,reason:U}}function se(e,t){return{active:W(e,t,`active`).reason,readonly:W(e,t,`readonly`).reason,drain:W(e,t,`drain`).reason,disabled:W(e,t,`disabled`).reason}}function ce(e,t,n){return!(n===`single`||t.length<=1||z(R(e))&&t.filter(e=>z(R(e))).length<=1)}function le(e){return e===`active`?{enabled:!0,readOnly:!1}:e===`readonly`?{enabled:!1,readOnly:!1}:{enabled:!1,readOnly:!0}}function ue(e,t){let n={...t.config??e.config};t.mode!==void 0&&(le(t.mode).readOnly?n.readOnly=!0:delete n.readOnly);let r={id:e.id,type:e.type,displayName:t.displayName??e.displayName,providerId:e.providerId,config:n,isSystem:e.isSystem},i=t.nodeId??e.nodeId,a=i===void 0?r:{...r,nodeId:i};return t.mode===void 0?e.enabled===void 0?a:{...a,enabled:e.enabled}:{...a,mode:t.mode,enabled:le(t.mode).enabled}}var de=1024**3;function G(e){return typeof e==`number`&&Number.isFinite(e)?e:null}function fe(e){let t=G(e.minFreeGb);if(t!==null)return{unit:`gb`,value:t};let n=G(e.minFreePercent);return n===null?{unit:`percent`,value:null}:{unit:`percent`,value:n}}function pe(e,t){return G(e[t===`gb`?`minFreeGb`:`minFreePercent`])}function me(e,t){let n={...e};return delete n.minFreePercent,delete n.minFreeGb,t.value===null?n:t.unit===`gb`?{...n,minFreeGb:t.value}:{...n,minFreePercent:t.value}}function he(e,t){let n=e.trim();if(n===``)return null;let r=Number(n);return Number.isFinite(r)?t===`percent`?Math.min(100,Math.max(0,r)):Math.max(0,r):null}function ge(e,t,n=10){if(e.unit===`gb`&&e.value!==null)return e.value*de;let r=e.value??n;return t===null||t<=0?null:t*Math.min(100,Math.max(0,r))/100}function _e(e){return e===`gb`?`GB to keep free`:`% of the volume to keep free`}function ve(e,t=10){return`CamStack keeps ${e.value===null?`${String(t)}% of the volume (the default)`:e.unit===`gb`?`${String(e.value)} GB`:`${String(e.value)}% of the volume`} free on this disk. As it fills up, the OLDEST data stored here is deleted to hold that much free space; if it cannot be held any more, new data goes to another location of the same type instead of filling the disk. Leave the value empty for the default (${String(t)}%).`}function ye(e){return G(e.maxUsedGb)}function be(e,t){let n=G(e.maxUsedGb);return n===null||n<0?null:{bytes:n*de,reason:t===`drain`?`drain`:`legacy`}}t();function xe({config:e,defaultPercent:t=10,onChange:r}){let[i,s]=a(()=>fe(e).unit),c=pe(e,i),l={unit:i,value:c},u=ye(e),d=t=>{s(t),r(me(e,{unit:t,value:null}))},f=t=>{r(me(e,{unit:i,value:he(t,i)}))};return n(`div`,{className:`space-y-1`,children:[o(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Protected free space`}),n(`div`,{className:`flex items-center gap-2`,children:[n(`select`,{"aria-label":`Protection unit`,value:i,onChange:e=>{d(e.target.value===`gb`?`gb`:`percent`)},className:`rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`,children:[o(`option`,{value:`percent`,children:`% of the volume`}),o(`option`,{value:`gb`,children:`GB of free space`})]}),o(`input`,{type:`number`,"aria-label":_e(i),min:0,max:i===`percent`?100:void 0,value:c===null?``:c,placeholder:i===`percent`?String(t):`default`,onChange:e=>{f(e.target.value)},className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`})]}),o(`p`,{className:`text-[10px] text-foreground-subtle`,children:ve(l,t)}),u!==null&&n(`p`,{className:`text-[10px] text-foreground-subtle italic`,children:[`This location also stores a maximum used size of `,u,` GB. That limit is managed by the system now and is no longer editable here; it is kept as it is.`]})]})}t();function Se({location:e,onClose:t,onSaved:s}){let l=i(),u=c().trpcClient,[d,f]=a({...e.config}),[p,m]=a(e.displayName),[g,_]=a(null),[b,w]=a(!1),T=ee(),E=r(()=>{let t=T.data;return Array.isArray(t)?t.find(t=>t.providerId===e.providerId)??null:null},[T.data,e.providerId]),D=re({onSuccess:()=>{l.invalidateQueries({queryKey:[[`storage`,`listLocations`]]}),s()}}),O=E?.shouldSaveDiskSpace===!0,k=E?.nodeLocal===!0,[A,j]=a(typeof e.nodeId==`string`?e.nodeId:`hub`),M=typeof d.basePath==`string`?d.basePath:``,N=e=>f(t=>({...t,basePath:e})),P=E?.minFreePercent??10,F=async()=>{w(!0),_(null);try{_(await(e=>u.storage.testConfig.query(e))({providerId:e.providerId,locationId:e.id,config:d}))}catch(e){_({ok:!1,error:e instanceof Error?e.message:String(e)})}finally{w(!1)}};return o(ie,{open:!0,onOpenChange:e=>!e&&t(),children:n(ne,{width:`md`,placement:`sheet-on-mobile`,scroll:`body`,children:[n(te,{children:[n(S,{children:[`Edit `,e.displayName]}),n(`p`,{className:`text-xs text-foreground-subtle`,children:[o(`span`,{className:`font-mono`,children:e.id}),` ·`,` `,E?.displayName??e.providerId]})]}),n(C,{className:`space-y-3`,children:[n(`div`,{className:`space-y-1`,children:[o(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Display name`}),o(`input`,{type:`text`,value:p,onChange:e=>m(e.target.value),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`})]}),E&&o(ae,{schema:E.configSchema,values:d,onChange:f}),k&&n(`div`,{className:`space-y-2`,children:[o(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Node`}),o(y,{selectedNodeId:A,onSelect:j,alwaysShow:!0}),o(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Path`}),o(oe,{nodeId:A,value:M,onChange:N})]}),O&&o(xe,{config:d,defaultPercent:P,onChange:f}),!E&&!T.isLoading&&n(`div`,{className:`rounded border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-[11px] text-amber-700 dark:text-amber-300`,children:[`Provider `,o(`code`,{className:`font-mono`,children:e.providerId}),` is no longer registered. Field schema unavailable; raw config is preserved on save.`]}),g&&o(`div`,{className:`rounded border px-3 py-2 text-[11px] ${g.ok?`border-success/30 bg-success/5 text-success`:`border-danger/30 bg-danger/5 text-danger`}`,children:g.ok?`Connection OK.`:`Test failed: ${g.error??`unknown error`}`}),D.isError&&o(`div`,{className:`rounded border border-danger/30 bg-danger/5 text-danger px-3 py-2 text-[11px]`,children:D.error instanceof Error?D.error.message:String(D.error)})]}),n(h,{className:`justify-between`,children:[o(x,{variant:`outline`,size:`sm`,onClick:t,children:`Cancel`}),n(`div`,{className:`flex items-center gap-2`,children:[o(x,{variant:`outline`,size:`sm`,onClick:()=>{F()},disabled:b||!E,children:b?`Testing…`:`Test connection`}),n(x,{size:`sm`,onClick:()=>{D.mutate(ue(e,{displayName:p.trim(),config:d,nodeId:k?A:e.nodeId}))},disabled:D.isPending||p.trim().length===0,children:[D.isPending?o(v,{className:`h-3.5 w-3.5 animate-spin`}):null,D.isPending?`Saving…`:`Save`]})]})]})]})})}function Ce(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function K(e){return typeof e==`number`&&Number.isFinite(e)?e:null}function we(e){if(!Ce(e))return null;let t=e.locationId;if(typeof t!=`string`||t.length===0)return null;let n=K(e.startedAtMs),r=K(e.startBytes),i=K(e.bytesRemaining);return n===null||r===null||i===null||typeof e.drained!=`boolean`?null:{locationId:t,startedAtMs:n,startBytes:r,bytesRemaining:i,drained:e.drained,estimatedEmptyAtMs:K(e.estimatedEmptyAtMs)}}function Te(e){let t=new Map;if(!Array.isArray(e))return t;for(let n of e){let e=we(n);e!==null&&t.set(e.locationId,e)}return t}function Ee(e){if(e.startBytes<=0||e.bytesRemaining>e.startBytes)return null;let t=e.startBytes-e.bytesRemaining;return Math.min(1,Math.max(0,t/e.startBytes))}function De(e,t){return e?t===void 0?{kind:`unreported`}:t.drained||t.bytesRemaining<=0?{kind:`drained`}:{kind:`draining`,bytesRemaining:t.bytesRemaining,drainedFraction:Ee(t),estimatedEmptyAtMs:t.estimatedEmptyAtMs}:{kind:`idle`}}function Oe(e){return e.mode===`drain`?!0:e.config.readOnly===!0}function ke(e){return`${(e/1024**3).toFixed(e>=100*1024**3?0:1)} GB`}function Ae(e){return new Date(e).toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`})}function je({drain:e}){if(e.kind===`idle`)return null;if(e.kind===`unreported`)return o(`span`,{"data-testid":`drain-unreported`,className:`text-[10px] text-foreground-subtle`,title:`This location is draining. The hub has not reported how much is left yet — either the drain has just been set, or this hub predates the drain-progress report.`,children:`Draining · remaining not reported yet`});if(e.kind===`drained`)return o(`span`,{"data-testid":`drain-done`,className:`text-[10px] text-success`,title:`Everything that was here has been moved. The location is still in drain mode — it receives no new writes until you change that.`,children:`Drained · nothing left to move`});let t=e.drainedFraction===null?null:Math.round(e.drainedFraction*100);return n(`span`,{"data-testid":`drain-progress`,className:`flex items-center gap-1.5 text-[10px] text-foreground-subtle tabular-nums`,children:[t!==null&&o(`span`,{"data-testid":`drain-bar`,className:`inline-block h-1 w-10 rounded-full bg-border overflow-hidden`,role:`progressbar`,"aria-label":`Drain progress`,"aria-valuenow":t,"aria-valuemin":0,"aria-valuemax":100,children:o(`span`,{className:`block h-full bg-warning`,style:{width:`${t}%`}})}),n(`span`,{children:[ke(e.bytesRemaining),` left`,t!==null&&` · ${t}% moved`]}),e.estimatedEmptyAtMs===null?o(`span`,{"data-testid":`drain-eta-absent`,title:`The drain is paced by how fast this class of data is still growing, and that has not been observed yet. There is no date to give.`,children:`· empty time not known yet`}):n(`span`,{"data-testid":`drain-eta`,children:[`· empty `,Ae(e.estimatedEmptyAtMs)]})]})}var Me=[`ok`,`warn`,`critical`];function Ne(e){return e>=.95?`critical`:e>=.85?`warn`:`ok`}function Pe(e){return Math.min(1,Math.max(0,e))}function q(e){let{availableBytes:t,totalBytes:n}=e;if(n===null||n<=0||t===null)return null;let r=Pe((n-t)/n);return{fraction:r,severity:Ne(r),recordingsFraction:Pe(e.usedBytes/n),freeBytes:t,totalBytes:n}}function Fe(e){if(e.length===0)return null;let t=0,n=0,r=0,i=0,a=null;for(let o of e){let e=q(o);if(e===null){n+=1;continue}t+=1,r+=e.totalBytes,i+=e.freeBytes,(a===null||Me.indexOf(e.severity)>Me.indexOf(a))&&(a=e.severity)}return{knownVolumes:t,unknownVolumes:n,totalBytes:r,freeBytes:i,severity:a}}var Ie=`Capacity unknown — nothing measured this volume from here. A remote share, a location on another node, or a mount that did not answer.`;function J(e){return Math.min(1,Math.max(0,e))}function Y(e){return Math.round(J(e)*1e3)/10}function X(e){return`${String(Math.round(J(e)*100))}%`}function Le(e,t,n={}){let{totalBytes:r,availableBytes:i}=e;if(r===null||r<=0||i===null){let e=n.ownedBytes===void 0||n.ownedBytes===null||!Number.isFinite(n.ownedBytes)||n.ownedBytes<0?null:k(n.ownedBytes);return{kind:`unknown`,owned:e,summary:e===null?Ie:`${Ie} CamStack holds ${e} here.`}}let a=Math.min(Math.max(i,0),r),o=r-a,s=t===null||t<=0?0:t,c=Math.min(s,a),l=s>a,u=a-c,d=n.ownedBytes,f=d==null||!Number.isFinite(d)||d<0?null:Math.min(d,o),p=o-(f??0),m=q({usedBytes:f??o,availableBytes:a,totalBytes:r}),h=m===null?J(o/r):m.fraction,g=m===null?Ne(h):m.severity,_=f===null?null:m===null?J(f/r):m.recordingsFraction,v=n.cap??null,y=v===null?null:J((c+v.bytes)/r),b=v!==null&&f!==null&&f>v.bytes,x={total:k(r),freeTotal:k(a),freeTotalPercent:X(a/r),used:k(p),usedPercent:X(p/r),free:k(u),freePercent:X(u/r),reserve:s===0?null:`${k(s)} kept free`,owned:f===null||_===null?null:`${k(f)} of recordings (${X(_)})`,cap:v===null?null:v.reason===`drain`?`${k(v.bytes)} drain target (managed by CamStack)`:`${k(v.bytes)} cap (managed by CamStack)`},S=[`${x.freeTotal} free of ${x.total} (${x.freeTotalPercent} free)`,x.owned===null?null:`CamStack holds ${x.owned}`,x.reserve===null?null:l?`${x.reserve} — less free than that right now, the oldest data here is being deleted`:x.reserve,x.cap===null?null:b?`${x.cap} — already below what is stored here, the oldest is being deleted`:x.cap].filter(e=>e!==null).join(` · `),C=[];return c>0&&C.push({segment:`reserve`,label:`Kept free`,value:k(s),alarming:l}),x.owned!==null&&C.push({segment:`owned`,label:`CamStack`,value:x.owned,alarming:!1}),C.push({segment:`used`,label:f===null?`Used`:`Other data`,value:`${x.used} (${x.usedPercent})`,alarming:g===`critical`}),C.push({segment:`free`,label:`Free`,value:`${x.free} (${x.freePercent})`,alarming:l}),v!==null&&C.push({segment:`cap`,label:v.reason===`drain`?`Drain target`:`Cap`,value:`${k(v.bytes)} · managed by CamStack`,alarming:b}),{kind:`known`,severity:g,legend:C,segments:{reservePercent:Y(c/r),ownedPercent:f===null?null:Y(f/r),usedPercent:Y(p/r),freePercent:Y(u/r),capPercent:y===null?null:Y(y)},labels:x,reserveExceedsFree:l,capBelowOwned:b,summary:S}}var Re={ok:`bg-primary`,warn:`bg-amber-500`,critical:`bg-danger`},Z={reserve:`bg-danger/40`,owned:`bg-foreground/50`,free:`bg-border`,cap:`bg-foreground`};function ze(e,t){return e===`used`?Re[t]:Z[e]}function Be({location:e,ownedBytes:t}){let r=e.capacity??null,i=ge(fe(e.config),r?.totalBytes??null),a=Le({totalBytes:r?.totalBytes??null,availableBytes:r?.availableBytes??null},i,{ownedBytes:t??null,cap:be(e.config,R(e))});return a.kind===`unknown`?o(`div`,{className:`text-[10px] text-foreground-subtle italic`,title:a.summary,children:a.owned===null?`Capacity unknown`:`Capacity unknown · CamStack holds ${a.owned}`}):n(`div`,{className:`mt-1 space-y-1`,title:a.summary,children:[n(`div`,{className:`relative flex h-2 w-full max-w-md overflow-hidden rounded-full bg-border`,children:[a.segments.reservePercent>0&&o(`div`,{className:Z.reserve,style:{width:`${String(a.segments.reservePercent)}%`}}),a.segments.ownedPercent!==null&&o(`div`,{className:Z.owned,style:{width:`${String(a.segments.ownedPercent)}%`}}),o(`div`,{className:Re[a.severity],style:{width:`${String(a.segments.usedPercent)}%`}}),o(`div`,{className:Z.free,style:{width:`${String(a.segments.freePercent)}%`}}),a.segments.capPercent!==null&&o(`div`,{className:`absolute inset-y-0 w-px ${a.capBelowOwned?`bg-danger`:Z.cap}`,style:{left:`${String(a.segments.capPercent)}%`}})]}),o(`ul`,{className:`flex flex-wrap items-center gap-x-3 gap-y-0.5`,children:a.legend.map(e=>n(`li`,{className:`flex items-center gap-1`,children:[o(`span`,{"aria-hidden":`true`,className:`inline-block h-2 w-2 shrink-0 rounded-sm ${ze(e.segment,a.severity)}`}),n(`span`,{className:`text-[10px] tabular-nums ${e.alarming?`text-danger`:`text-foreground-subtle`}`,children:[e.label,` `,e.value]})]},e.segment))})]})}var Ve={eventMedia:[`events`],recordingsLow:[`low`],recordings:[`high`,`mid`]},He={eventMedia:`pipeline-analytics`,recordingsLow:`recorder`,recordings:`recorder`},Ue=`storage.discardLocation`,We=`storage.discardLocationStatus`,Ge=`storage.discardLocationCancel`;function Ke(e){return Ve[e]??null}function qe(e){return He[e]??null}function Je(e){return!z(R(e))}function Ye(e,t){return Ke(e.type)===null||!Je(e)?!1:t.some(t=>t.id!==e.id&&z(R(t)))}var Xe=new Set([`idle`,`scanning`,`wiping-fs`,`wiping-db`,`cascading`,`complete`,`cancelled`,`error`]);function Q(e){return typeof e==`number`&&Number.isFinite(e)?e:null}function $(e){return typeof e==`string`?e:null}function Ze(e){if(typeof e!=`object`||!e)return null;let t=e;if(typeof t.running!=`boolean`)return null;let n=t.phase;if(typeof n!=`string`||!Xe.has(n))return null;let r=Q(t.camerasTotal),i=Q(t.camerasDone),a=Q(t.foldersRemoved),o=Q(t.dbRowsDeleted),s=Q(t.ownersCascaded);return r===null||i===null||a===null||o===null||s===null?null:{running:t.running,locationId:$(t.locationId),jobId:$(t.jobId),phase:n,camerasTotal:r,camerasDone:i,foldersRemoved:a,dbRowsDeleted:o,ownersCascaded:s,detail:$(t.detail)??``,startedAtMs:Q(t.startedAtMs),finishedAtMs:Q(t.finishedAtMs),error:$(t.error)}}function Qe(e){if(e.phase===`complete`)return 100;if(e.phase===`cancelled`||e.phase===`error`||e.phase===`idle`)return e.camerasTotal>0?Math.min(99,Math.round(e.camerasDone/e.camerasTotal*100)):0;if(e.camerasTotal>0){let t=e.camerasDone/e.camerasTotal*85;return e.phase===`wiping-db`?Math.min(95,Math.round(t+8)):e.phase===`cascading`?Math.min(99,Math.round(t+12)):Math.min(85,Math.round(t))}return e.phase===`scanning`?2:5}t();var $e=2e3;function et({location:e,siblings:t}){return Ye(e,t)?o(tt,{location:e}):null}function tt({location:e}){let t=_(),r=T(),i=qe(e.type),[c,l]=a(null),[u,d]=a(null),[f,p]=a(!1);if(s(()=>{if(i===null)return;let e=!1,t=async()=>{try{let t=await r.mutateAsync({addonId:i,action:We,input:{}});if(e)return;l(Ze(t))}catch{}};t();let n=setInterval(()=>void t(),$e);return()=>{e=!0,clearInterval(n)}},[i,e.id]),i===null)return null;let m=c!==null&&c.locationId===e.id,h=m&&c.running,g=m&&c.phase!==`idle`,y=async()=>{if(await t({title:`Discard leftovers on "${e.displayName}"?`,message:`Permanently deletes leftover files and records on this location. Other locations are not affected. This cannot be undone and may take hours.`,confirmLabel:`Discard leftovers`,variant:`danger`})){d(null),p(!0);try{await r.mutateAsync({addonId:i,action:Ue,input:{locationId:e.id}}),l(Ze(await r.mutateAsync({addonId:i,action:We,input:{}})))}catch(e){d(e instanceof Error?e.message:String(e))}finally{p(!1)}}},b=async()=>{try{await r.mutateAsync({addonId:i,action:Ge,input:{}})}catch(e){d(e instanceof Error?e.message:String(e))}};return n(`div`,{className:`flex flex-col gap-1 min-w-[9rem] max-w-[16rem]`,children:[h?n(`button`,{type:`button`,onClick:()=>void b(),className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-danger border border-danger/40 hover:bg-danger/10`,children:[o(w,{className:`h-3 w-3`}),`Cancel`]}):n(`button`,{type:`button`,onClick:()=>void y(),disabled:f,title:`Permanently delete leftover files on this location. Other locations are not affected.`,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-danger border border-danger/40 hover:bg-danger/10 disabled:opacity-50`,children:[f?o(v,{className:`h-3 w-3 animate-spin`}):o(A,{className:`h-3 w-3`}),`Discard leftovers`]}),g&&c!==null&&n(`div`,{className:`space-y-0.5`,children:[o(`div`,{className:`h-1 rounded bg-border overflow-hidden`,children:o(`div`,{className:`h-full bg-primary transition-[width] duration-300`,style:{width:`${Qe(c)}%`}})}),n(`p`,{className:`text-[10px] text-foreground-subtle leading-tight`,children:[c.phase,c.camerasTotal>0?` · ${c.camerasDone}/${c.camerasTotal} cam`:``,c.dbRowsDeleted>0?` · ${c.dbRowsDeleted} rows`:``,c.detail?` · ${c.detail}`:``]})]}),(u||m&&c?.error)&&o(`p`,{className:`text-[10px] text-danger leading-tight`,children:u??c?.error})]})}t();var nt={active:g,readonly:E,drain:D,disabled:d},rt={active:`border-success/30 text-success hover:bg-success/10`,readonly:`border-border text-foreground-subtle hover:text-foreground hover:bg-primary/10`,drain:`border-warning/40 text-warning hover:bg-warning/10`,disabled:`border-danger/40 text-danger hover:bg-danger/10`};function it({mode:e,open:t,onToggle:r}){let i=V(e),a=nt[e];return n(`button`,{type:`button`,"aria-expanded":t,"aria-label":`Location state`,onClick:r,title:i.consequence,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium border ${rt[e]}`,children:[o(a,{className:`h-3 w-3`}),i.label,o(l,{className:`h-3 w-3 ${t?`rotate-180`:``}`})]})}function at({mode:e,blockedReasons:t,onSelect:r,onDismiss:i}){return s(()=>{let e=e=>{e.key===`Escape`&&i()};return window.addEventListener(`keydown`,e),()=>{window.removeEventListener(`keydown`,e)}},[i]),n(`div`,{className:`w-full basis-full rounded-lg border border-border bg-background p-1`,role:`group`,"aria-label":`Location state choices`,children:[n(`div`,{className:`flex items-center justify-between px-2 py-1`,children:[o(`span`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Location state`}),o(`button`,{type:`button`,"aria-label":`Close location state choices`,onClick:i,className:`text-foreground-subtle hover:text-foreground`,children:o(w,{className:`h-3 w-3`})})]}),B.map(a=>{let s=t[a.mode],c=s!==``,l=nt[a.mode],u=a.mode===e;return n(`button`,{type:`button`,role:`radio`,"aria-checked":u,"aria-label":a.label,disabled:c,onClick:()=>{c||(i(),u||r(a.mode))},className:`flex w-full flex-col items-start gap-0.5 rounded px-2 py-1.5 text-left ${c?`cursor-not-allowed opacity-60`:u?`bg-primary/10`:`hover:bg-primary/5`}`,children:[n(`span`,{className:`flex items-center gap-1.5 text-[11px] font-medium text-foreground`,children:[o(l,{className:`h-3 w-3`}),a.label,u&&o(`span`,{className:`text-[9px] uppercase text-primary`,children:`current`})]}),o(`span`,{className:`text-[10px] leading-snug text-foreground-subtle`,children:a.consequence}),c&&o(`span`,{className:`text-[10px] leading-snug text-warning`,children:s})]},a.mode)})]})}t();function ot(e){let t=e.basePath;if(typeof t==`string`&&t.length>0)return t;let n=Object.keys(e);return n.length===0?``:n.join(`, `)}function st({location:e,onEdit:t,onDelete:r,onSetMode:i,blockedReasons:s,canDelete:c,siblings:l=[],drain:u,ownedBytes:d}){let[p,h]=a(!1),g=ot(e.config),_=R(e);return n(`div`,{className:`flex flex-wrap items-start gap-x-3 gap-y-2 px-3 py-2 border-t border-border first:border-t-0 hover:bg-primary/5`,children:[n(`div`,{className:`flex items-start gap-2 min-w-0 flex-1 basis-72`,children:[o(`div`,{className:`shrink-0 sm:w-32`,"data-testid":`location-badge-slot`,children:o(`span`,{className:`inline-block text-[10px] uppercase tracking-wide text-foreground-subtle bg-background border border-border rounded px-1.5 py-0.5 font-mono`,children:e.providerId})}),n(`div`,{className:`min-w-0 flex-1`,children:[o(`div`,{className:`text-xs font-medium text-foreground truncate`,children:e.displayName}),g&&o(`div`,{className:`text-[10px] text-foreground-subtle truncate font-mono`,children:g}),o(Be,{location:e,ownedBytes:d??null}),u!==void 0&&o(je,{drain:u})]})]}),n(`div`,{className:`flex flex-wrap items-center gap-1 shrink-0`,children:[o(et,{location:e,siblings:l}),o(it,{mode:_,open:p,onToggle:()=>{h(e=>!e)}}),n(`button`,{onClick:()=>t(e),className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-foreground-subtle border border-border hover:text-foreground hover:bg-primary/10`,children:[o(m,{className:`h-3 w-3`}),`Edit`]}),c&&o(`button`,{onClick:()=>r(e),className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-danger hover:bg-danger/10`,title:`Delete location`,children:o(f,{className:`h-3 w-3`})})]}),p&&o(at,{mode:_,blockedReasons:s,onSelect:t=>i(e,t),onDismiss:()=>{h(!1)}})]})}t();function ct({type:e,displayName:t,description:i,cardinality:a,locations:s,onAdd:c,onEdit:l,onDelete:u,onSetMode:d,ownedBytesById:f,drainById:p}){let m=r(()=>{let e=[...s];return e.sort((e,t)=>{let n=z(R(e));return n===z(R(t))?e.displayName.localeCompare(t.displayName):n?-1:1}),e},[s]);return n(`div`,{className:`rounded-lg border border-border bg-surface`,children:[n(`div`,{className:`flex items-start justify-between border-b border-border px-3 py-2`,children:[n(`div`,{className:`space-y-0.5`,children:[n(`div`,{className:`flex items-center gap-2`,children:[o(`span`,{className:`text-sm font-semibold text-foreground capitalize`,children:t}),o(`span`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle bg-background border border-border rounded px-1.5 py-0.5 font-mono`,children:e})]}),i&&o(`p`,{className:`text-[11px] text-foreground-subtle`,children:i}),a===`single`&&o(`p`,{className:`text-[10px] text-foreground-subtle italic`,children:`Single — one location per type. Edit the existing entry; it can't be split.`})]}),a===`multi`&&n(`button`,{onClick:()=>c(e),className:`inline-flex items-center gap-1 rounded bg-primary px-2 py-1 text-[11px] font-medium text-primary-foreground hover:bg-primary/90`,children:[o(b,{className:`h-3 w-3`}),`Add`]})]}),m.length===0?o(`div`,{className:`px-3 py-4 text-center text-[11px] text-foreground-subtle italic`,children:a===`multi`?`No location registered. Click "Add" to register one.`:`No location registered yet — should be auto-seeded at next boot.`}):o(`div`,{children:m.map(e=>o(st,{location:e,cardinality:a,canDelete:ce(e,m,a),onEdit:l,onDelete:u,onSetMode:d,blockedReasons:se(e,m),ownedBytes:f?.get(e.id)??null,drain:De(Oe(e),p?.get(e.id)),siblings:m},e.id))})]})}var lt=[`recordings`,`recordingsLow`];function ut(e){return e.locationIds!==void 0&&e.locationIds.length>0?e.locationIds:e.locationId===null?[]:[e.locationId]}function dt(e,t){if(t===void 0||!lt.includes(e.type))return null;let n=t.find(t=>ut(t).includes(e.id));return n===void 0||!Number.isFinite(n.usedBytes)||n.usedBytes<0?null:n.usedBytes}function ft(e,t){let n=new Map;for(let r of e){let e=dt(r,t);e!==null&&n.set(r.id,e)}return n}export{Te as a,V as c,Fe as i,H as l,ct as n,Se as o,q as r,ue as s,ft as t,L as u};
|
|
1
|
+
import{I as e,Q as t,S as n,W as r,o as i,q as a,x as o,z as s}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{at as c,gt as l,ht as u,mt as d,st as f,vt as p}from"./player-overlays-CVsVEZkx.js";import{Ad as m,Cn as h,Ed as g,Gn as _,Hd as v,I as y,Od as b,Pn as x,Tn as S,bn as C,ju as w,pr as T,sl as ee,wn as te,xn as ne,yl as re,yn as ie}from"./src-DBOD88Il.js";import{t as E}from"./archive-6pzbE4zL.js";import{t as D}from"./hard-drive-download-CUKF7GIe.js";import{Zr as O}from"./client-DdTCFotl.js";import{I as ae}from"./index-BhXNFlQG.js";import{t as k}from"./format-size-DIxKXxtj.js";var A=p(`eraser`,[[`path`,{d:`M21 21H8a2 2 0 0 1-1.42-.587l-3.994-3.999a2 2 0 0 1 0-2.828l10-10a2 2 0 0 1 2.829 0l5.999 6a2 2 0 0 1 0 2.828L12.834 21`,key:`g5wo59`}],[`path`,{d:`m5.082 11.09 8.828 8.828`,key:`1wx5vj`}]]);t();function j(e){let t=e.trim().toLowerCase();return t.length===0?``:t.replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``)}function M(e,t){let n=j(t);return`${e}:${n.length>0?n:`default`}`}var N=new Set([`proc`,`sys`,`dev`,`run`,`boot`,`lost+found`,`snap`,`bin`,`sbin`,`lib`,`lib32`,`lib64`,`libx32`,`usr`,`etc`,`var`,`opt`,`tmp`,`srv`,`root`,`System`,`Library`,`Applications`,`cores`,`private`]),P=[`recordings`,`data`,`mnt`,`media`,`Volumes`];function F(e){let t=P.findIndex(t=>t===`recordings`?e.startsWith(t):e===t);return t===-1?P.length:t}function I(e){return e.filter(e=>!e.name.startsWith(`.`)&&!N.has(e.name)).toSorted((e,t)=>{let n=F(e.name)-F(t.name);return n===0?e.name.localeCompare(t.name):n}).map(e=>e.path)}function oe({nodeId:t,value:r,onChange:i}){let l=c().trpcClient,[u,d]=a([]),[f,p]=a(r),[m,h]=a(null),[g,_]=a(null),[v,y]=a(``),b=e(async(e,n)=>{_(null);try{let r=await l.filesystemBrowse.browse.query({nodeId:t,path:e});h(r),p(r.path),n&&i(r.path)}catch(e){_(e instanceof Error?e.message:`browse failed`)}},[l,t,i]);s(()=>{p(r),(async()=>{let e=await l.filesystemBrowse.browse.query({nodeId:t,path:`/`}).then(e=>e).catch(()=>null);if(e){d(I(e.entries)),await b(r.startsWith(`/`)?r:`/`,!1);return}try{let e=await l.filesystemBrowse.listAllowedRoots.query({nodeId:t});d(e),await b(r&&e.some(e=>r.startsWith(e))?r:e[0]??``,!1)}catch(e){d([]),h(null),_(e instanceof Error&&/not available on node/i.test(e.message)?`This node can't be browsed remotely. Enter the path manually.`:e instanceof Error?e.message:`browse unavailable`)}})()},[t]);let x=async()=>{if(!(!v.trim()||!m)){_(null);try{let e=`${m.path.replace(/\/+$/,``)}/${v.trim()}`;await l.filesystemBrowse.createDir.mutate({nodeId:t,path:e}),y(``),await b(m.path,!0)}catch(e){_(e instanceof Error?e.message:`create failed`)}}},S=e=>`${(e/1e9).toFixed(1)} GB`;return n(`div`,{className:`space-y-2 rounded border border-border p-2`,children:[o(`div`,{className:`flex flex-wrap gap-1`,children:u.map(e=>o(`button`,{onClick:()=>void b(e,!0),className:`rounded border border-border px-2 py-0.5 text-[10px] font-mono hover:border-primary/40`,children:e},e))}),o(`input`,{value:f,onChange:e=>{p(e.target.value),i(e.target.value)},placeholder:`/absolute/path`,className:`w-full rounded border border-border bg-background px-2 py-1 text-[11px] font-mono`}),m&&n(`div`,{className:`text-[10px] text-foreground-subtle`,children:[S(m.freeBytes),` free / `,S(m.totalBytes)]}),o(`div`,{className:`max-h-40 space-y-0.5 overflow-y-auto`,children:m?.entries.map(e=>n(`button`,{onClick:()=>void b(e.path,!0),className:`block w-full truncate rounded px-2 py-1 text-left text-xs hover:bg-primary/5`,children:[`📁 `,e.name]},e.path))}),n(`div`,{className:`flex gap-1`,children:[o(`input`,{value:v,onChange:e=>y(e.target.value),placeholder:`new folder`,className:`flex-1 rounded border border-border bg-background px-2 py-1 text-xs`}),o(`button`,{onClick:()=>void x(),className:`rounded border border-border px-2 py-1 text-xs hover:border-primary/40`,children:`Create`})]}),g&&o(`div`,{className:`text-[10px] text-red-400`,children:g})]})}t();function L({initialType:e,onClose:t,onCreated:s}){let l=i(),d=c().trpcClient,[f,p]=a(`picker`),[m,h]=a(e),[g,_]=a(null),[b,x]=a({}),[w,T]=a(``),[E,D]=a(null),[O,k]=a(!1),[A,j]=a(`hub`),[N,P]=a(null),[F,I]=a(!1),L=e=>x(t=>({...t,basePath:e})),R=typeof b.basePath==`string`?b.basePath:``,z=ee(),B=r(()=>{let e=z.data;return Array.isArray(e)?e:[]},[z.data]),V=z.isLoading,H=re({onSuccess:()=>{l.invalidateQueries({queryKey:[[`storage`,`listLocations`]]}),s()}}),U=r(()=>E!==null&&E.length>0?E:M(m,w),[m,w,E]),W=async()=>{if(g){I(!0),P(null);try{P(await(e=>d.storage.testConfig.query(e))({providerId:g.providerId,config:b}))}catch(e){P({ok:!1,error:e instanceof Error?e.message:String(e)})}finally{I(!1)}}};return o(ie,{open:!0,onOpenChange:e=>!e&&t(),children:n(ne,{width:`md`,placement:`sheet-on-mobile`,scroll:`body`,children:[n(te,{children:[o(S,{children:{picker:`Add Location — Pick provider`,config:`Add Location — ${g?.displayName??``}`,naming:`Add Location — Name`}[f]}),n(`p`,{className:`text-xs text-foreground-subtle`,children:[`Type: `,o(`span`,{className:`font-mono`,children:m})]})]}),n(C,{children:[f===`picker`&&n(`div`,{className:`space-y-2`,children:[V&&o(`div`,{className:`text-xs text-foreground-subtle animate-pulse`,children:`Loading providers…`}),!V&&B.length===0&&n(`div`,{className:`rounded border border-border bg-background px-3 py-4 text-center text-xs text-foreground-subtle`,children:[`No storage-provider supports type "`,m,`". Install a compatible addon (e.g.`,` `,o(`code`,{className:`font-mono`,children:`remote-storage`}),`) to enable it.`]}),B.map(e=>n(`button`,{onClick:()=>{_(e),p(`config`)},className:`flex w-full items-center gap-3 rounded-lg border border-border bg-background p-3 text-left hover:border-primary/40 hover:bg-primary/5 transition-colors`,children:[n(`div`,{className:`flex-1 min-w-0`,children:[o(`p`,{className:`text-xs font-semibold text-foreground`,children:e.displayName}),o(`p`,{className:`text-[10px] text-foreground-subtle font-mono mt-0.5 truncate`,children:e.providerId})]}),o(u,{className:`h-4 w-4 text-foreground-subtle flex-shrink-0`})]},e.providerId))]}),f===`config`&&g&&n(`div`,{className:`space-y-3`,children:[o(ae,{schema:g.configSchema,values:b,onChange:x}),g.nodeLocal&&n(`div`,{className:`space-y-2`,children:[o(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Node`}),o(y,{selectedNodeId:A,onSelect:j,alwaysShow:!0}),o(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Path`}),o(oe,{nodeId:A,value:R,onChange:L})]}),N&&o(`div`,{className:`rounded border px-3 py-2 text-[11px] ${N.ok?`border-success/30 bg-success/5 text-success`:`border-danger/30 bg-danger/5 text-danger`}`,children:N.ok?`Connection OK.`:`Test failed: ${N.error??`unknown error`}`}),n(`div`,{className:`flex items-center justify-between pt-1`,children:[o(`button`,{onClick:()=>p(`picker`),className:`rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground`,children:`Back`}),n(`div`,{className:`flex items-center gap-2`,children:[o(`button`,{onClick:()=>{W()},disabled:F,className:`rounded border border-border px-3 py-1.5 text-xs text-foreground hover:bg-primary/10 disabled:opacity-50`,children:F?`Testing…`:`Test connection`}),o(`button`,{onClick:()=>p(`naming`),className:`rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90`,children:`Next`})]})]})]}),f===`naming`&&g&&n(`div`,{className:`space-y-3`,children:[n(`div`,{className:`space-y-1`,children:[o(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Display name`}),o(`input`,{type:`text`,value:w,onChange:e=>T(e.target.value),placeholder:`${m} on ${g.displayName}`,className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`})]}),n(`div`,{className:`space-y-1`,children:[n(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:[`Id`,` `,o(`span`,{className:`lowercase tracking-normal text-foreground-subtle`,children:`— auto-derived; override if needed`})]}),o(`input`,{type:`text`,value:U,onChange:e=>D(e.target.value),placeholder:M(m,w),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground font-mono focus:outline-none focus:ring-1 focus:ring-primary`}),n(`p`,{className:`text-[10px] text-foreground-subtle`,children:[`Format: `,o(`code`,{className:`font-mono`,children:`<type>:<slug>`}),`. Lowercase letters, digits, and hyphens only.`]})]}),n(`label`,{className:`flex items-start gap-2 rounded border border-border bg-background px-3 py-2 cursor-pointer hover:bg-primary/5`,children:[o(`input`,{type:`checkbox`,checked:O,onChange:e=>k(e.target.checked),className:`accent-primary mt-0.5`}),n(`div`,{className:`space-y-0.5`,children:[o(`div`,{className:`text-xs font-medium text-foreground`,children:`Enable immediately`}),o(`div`,{className:`text-[10px] text-foreground-subtle`,children:`A disabled location receives no writes until enabled — reads and age-based retention still work, nothing new lands here. Leave this off to register the disk now and start using it later.`})]})]}),H.isError&&o(`div`,{className:`rounded border border-danger/30 bg-danger/5 text-danger px-3 py-2 text-[11px]`,children:H.error instanceof Error?H.error.message:String(H.error)}),n(`div`,{className:`flex items-center justify-between pt-1`,children:[o(`button`,{onClick:()=>p(`config`),className:`rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground`,children:`Back`}),n(`div`,{className:`flex items-center gap-2`,children:[o(`button`,{onClick:()=>{h(e),_(null),x({}),T(``),D(null),k(!1),P(null),p(`picker`)},className:`rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground`,children:`Reset`}),n(`button`,{onClick:()=>{g&&H.mutate({id:U,type:m,displayName:w.trim(),providerId:g.providerId,config:b,enabled:O,nodeId:g.nodeLocal?A:void 0})},disabled:H.isPending||w.trim().length===0,className:`inline-flex items-center gap-1.5 rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50`,children:[H.isPending?o(v,{className:`h-3.5 w-3.5 animate-spin`}):null,H.isPending?`Saving…`:`Save`]})]})]})]})]})]})})}function R(e){return O(e)}function z(e){return e===`active`}var B=[{mode:`active`,label:`Active`,consequence:`New data is written here, and the oldest is deleted when the disk fills up.`,requiresConfirmation:!1},{mode:`readonly`,label:`Read-only`,consequence:`Nothing new is written and nothing is ever deleted. A frozen archive that stays on the timeline.`,requiresConfirmation:!1},{mode:`drain`,label:`Drain`,consequence:`Nothing new is written. The oldest data here is deleted, a little at a time, until this location is empty.`,requiresConfirmation:!1},{mode:`disabled`,label:`Disabled`,consequence:`Nothing is written and nothing is read: the footage stored here disappears from the timeline until you turn it back on. Nothing is deleted.`,requiresConfirmation:!0}];function V(e){return B.find(t=>t.mode===e)??B[0]}function H(e){return V(e).requiresConfirmation}var U=`Blocked: this is the last location of its type still accepting writes — new data would have nowhere to go.`;function W(e,t,n){return z(n)||!z(R(e))||t.some(t=>t.id!==e.id&&z(R(t)))?{blocked:!1,reason:``}:{blocked:!0,reason:U}}function se(e,t){return{active:W(e,t,`active`).reason,readonly:W(e,t,`readonly`).reason,drain:W(e,t,`drain`).reason,disabled:W(e,t,`disabled`).reason}}function ce(e,t,n){return!(n===`single`||t.length<=1||z(R(e))&&t.filter(e=>z(R(e))).length<=1)}function le(e){return e===`active`?{enabled:!0,readOnly:!1}:e===`readonly`?{enabled:!1,readOnly:!1}:{enabled:!1,readOnly:!0}}function ue(e,t){let n={...t.config??e.config};t.mode!==void 0&&(le(t.mode).readOnly?n.readOnly=!0:delete n.readOnly);let r={id:e.id,type:e.type,displayName:t.displayName??e.displayName,providerId:e.providerId,config:n,isSystem:e.isSystem},i=t.nodeId??e.nodeId,a=i===void 0?r:{...r,nodeId:i};return t.mode===void 0?e.enabled===void 0?a:{...a,enabled:e.enabled}:{...a,mode:t.mode,enabled:le(t.mode).enabled}}var de=1024**3;function G(e){return typeof e==`number`&&Number.isFinite(e)?e:null}function fe(e){let t=G(e.minFreeGb);if(t!==null)return{unit:`gb`,value:t};let n=G(e.minFreePercent);return n===null?{unit:`percent`,value:null}:{unit:`percent`,value:n}}function pe(e,t){return G(e[t===`gb`?`minFreeGb`:`minFreePercent`])}function me(e,t){let n={...e};return delete n.minFreePercent,delete n.minFreeGb,t.value===null?n:t.unit===`gb`?{...n,minFreeGb:t.value}:{...n,minFreePercent:t.value}}function he(e,t){let n=e.trim();if(n===``)return null;let r=Number(n);return Number.isFinite(r)?t===`percent`?Math.min(100,Math.max(0,r)):Math.max(0,r):null}function ge(e,t,n=10){if(e.unit===`gb`&&e.value!==null)return e.value*de;let r=e.value??n;return t===null||t<=0?null:t*Math.min(100,Math.max(0,r))/100}function _e(e){return e===`gb`?`GB to keep free`:`% of the volume to keep free`}function ve(e,t=10){return`CamStack keeps ${e.value===null?`${String(t)}% of the volume (the default)`:e.unit===`gb`?`${String(e.value)} GB`:`${String(e.value)}% of the volume`} free on this disk. As it fills up, the OLDEST data stored here is deleted to hold that much free space; if it cannot be held any more, new data goes to another location of the same type instead of filling the disk. Leave the value empty for the default (${String(t)}%).`}function ye(e){return G(e.maxUsedGb)}function be(e,t){let n=G(e.maxUsedGb);return n===null||n<0?null:{bytes:n*de,reason:t===`drain`?`drain`:`legacy`}}t();function xe({config:e,defaultPercent:t=10,onChange:r}){let[i,s]=a(()=>fe(e).unit),c=pe(e,i),l={unit:i,value:c},u=ye(e),d=t=>{s(t),r(me(e,{unit:t,value:null}))},f=t=>{r(me(e,{unit:i,value:he(t,i)}))};return n(`div`,{className:`space-y-1`,children:[o(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Protected free space`}),n(`div`,{className:`flex items-center gap-2`,children:[n(`select`,{"aria-label":`Protection unit`,value:i,onChange:e=>{d(e.target.value===`gb`?`gb`:`percent`)},className:`rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`,children:[o(`option`,{value:`percent`,children:`% of the volume`}),o(`option`,{value:`gb`,children:`GB of free space`})]}),o(`input`,{type:`number`,"aria-label":_e(i),min:0,max:i===`percent`?100:void 0,value:c===null?``:c,placeholder:i===`percent`?String(t):`default`,onChange:e=>{f(e.target.value)},className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`})]}),o(`p`,{className:`text-[10px] text-foreground-subtle`,children:ve(l,t)}),u!==null&&n(`p`,{className:`text-[10px] text-foreground-subtle italic`,children:[`This location also stores a maximum used size of `,u,` GB. That limit is managed by the system now and is no longer editable here; it is kept as it is.`]})]})}t();function Se({location:e,onClose:t,onSaved:s}){let l=i(),u=c().trpcClient,[d,f]=a({...e.config}),[p,m]=a(e.displayName),[g,_]=a(null),[b,w]=a(!1),T=ee(),E=r(()=>{let t=T.data;return Array.isArray(t)?t.find(t=>t.providerId===e.providerId)??null:null},[T.data,e.providerId]),D=re({onSuccess:()=>{l.invalidateQueries({queryKey:[[`storage`,`listLocations`]]}),s()}}),O=E?.shouldSaveDiskSpace===!0,k=E?.nodeLocal===!0,[A,j]=a(typeof e.nodeId==`string`?e.nodeId:`hub`),M=typeof d.basePath==`string`?d.basePath:``,N=e=>f(t=>({...t,basePath:e})),P=E?.minFreePercent??10,F=async()=>{w(!0),_(null);try{_(await(e=>u.storage.testConfig.query(e))({providerId:e.providerId,locationId:e.id,config:d}))}catch(e){_({ok:!1,error:e instanceof Error?e.message:String(e)})}finally{w(!1)}};return o(ie,{open:!0,onOpenChange:e=>!e&&t(),children:n(ne,{width:`md`,placement:`sheet-on-mobile`,scroll:`body`,children:[n(te,{children:[n(S,{children:[`Edit `,e.displayName]}),n(`p`,{className:`text-xs text-foreground-subtle`,children:[o(`span`,{className:`font-mono`,children:e.id}),` ·`,` `,E?.displayName??e.providerId]})]}),n(C,{className:`space-y-3`,children:[n(`div`,{className:`space-y-1`,children:[o(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Display name`}),o(`input`,{type:`text`,value:p,onChange:e=>m(e.target.value),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`})]}),E&&o(ae,{schema:E.configSchema,values:d,onChange:f}),k&&n(`div`,{className:`space-y-2`,children:[o(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Node`}),o(y,{selectedNodeId:A,onSelect:j,alwaysShow:!0}),o(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Path`}),o(oe,{nodeId:A,value:M,onChange:N})]}),O&&o(xe,{config:d,defaultPercent:P,onChange:f}),!E&&!T.isLoading&&n(`div`,{className:`rounded border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-[11px] text-amber-700 dark:text-amber-300`,children:[`Provider `,o(`code`,{className:`font-mono`,children:e.providerId}),` is no longer registered. Field schema unavailable; raw config is preserved on save.`]}),g&&o(`div`,{className:`rounded border px-3 py-2 text-[11px] ${g.ok?`border-success/30 bg-success/5 text-success`:`border-danger/30 bg-danger/5 text-danger`}`,children:g.ok?`Connection OK.`:`Test failed: ${g.error??`unknown error`}`}),D.isError&&o(`div`,{className:`rounded border border-danger/30 bg-danger/5 text-danger px-3 py-2 text-[11px]`,children:D.error instanceof Error?D.error.message:String(D.error)})]}),n(h,{className:`justify-between`,children:[o(x,{variant:`outline`,size:`sm`,onClick:t,children:`Cancel`}),n(`div`,{className:`flex items-center gap-2`,children:[o(x,{variant:`outline`,size:`sm`,onClick:()=>{F()},disabled:b||!E,children:b?`Testing…`:`Test connection`}),n(x,{size:`sm`,onClick:()=>{D.mutate(ue(e,{displayName:p.trim(),config:d,nodeId:k?A:e.nodeId}))},disabled:D.isPending||p.trim().length===0,children:[D.isPending?o(v,{className:`h-3.5 w-3.5 animate-spin`}):null,D.isPending?`Saving…`:`Save`]})]})]})]})})}function Ce(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function K(e){return typeof e==`number`&&Number.isFinite(e)?e:null}function we(e){if(!Ce(e))return null;let t=e.locationId;if(typeof t!=`string`||t.length===0)return null;let n=K(e.startedAtMs),r=K(e.startBytes),i=K(e.bytesRemaining);return n===null||r===null||i===null||typeof e.drained!=`boolean`?null:{locationId:t,startedAtMs:n,startBytes:r,bytesRemaining:i,drained:e.drained,estimatedEmptyAtMs:K(e.estimatedEmptyAtMs)}}function Te(e){let t=new Map;if(!Array.isArray(e))return t;for(let n of e){let e=we(n);e!==null&&t.set(e.locationId,e)}return t}function Ee(e){if(e.startBytes<=0||e.bytesRemaining>e.startBytes)return null;let t=e.startBytes-e.bytesRemaining;return Math.min(1,Math.max(0,t/e.startBytes))}function De(e,t){return e?t===void 0?{kind:`unreported`}:t.drained||t.bytesRemaining<=0?{kind:`drained`}:{kind:`draining`,bytesRemaining:t.bytesRemaining,drainedFraction:Ee(t),estimatedEmptyAtMs:t.estimatedEmptyAtMs}:{kind:`idle`}}function Oe(e){return e.mode===`drain`?!0:e.config.readOnly===!0}function ke(e){return`${(e/1024**3).toFixed(e>=100*1024**3?0:1)} GB`}function Ae(e){return new Date(e).toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`})}function je({drain:e}){if(e.kind===`idle`)return null;if(e.kind===`unreported`)return o(`span`,{"data-testid":`drain-unreported`,className:`text-[10px] text-foreground-subtle`,title:`This location is draining. The hub has not reported how much is left yet — either the drain has just been set, or this hub predates the drain-progress report.`,children:`Draining · remaining not reported yet`});if(e.kind===`drained`)return o(`span`,{"data-testid":`drain-done`,className:`text-[10px] text-success`,title:`Everything that was here has been moved. The location is still in drain mode — it receives no new writes until you change that.`,children:`Drained · nothing left to move`});let t=e.drainedFraction===null?null:Math.round(e.drainedFraction*100);return n(`span`,{"data-testid":`drain-progress`,className:`flex items-center gap-1.5 text-[10px] text-foreground-subtle tabular-nums`,children:[t!==null&&o(`span`,{"data-testid":`drain-bar`,className:`inline-block h-1 w-10 rounded-full bg-border overflow-hidden`,role:`progressbar`,"aria-label":`Drain progress`,"aria-valuenow":t,"aria-valuemin":0,"aria-valuemax":100,children:o(`span`,{className:`block h-full bg-warning`,style:{width:`${t}%`}})}),n(`span`,{children:[ke(e.bytesRemaining),` left`,t!==null&&` · ${t}% moved`]}),e.estimatedEmptyAtMs===null?o(`span`,{"data-testid":`drain-eta-absent`,title:`The drain is paced by how fast this class of data is still growing, and that has not been observed yet. There is no date to give.`,children:`· empty time not known yet`}):n(`span`,{"data-testid":`drain-eta`,children:[`· empty `,Ae(e.estimatedEmptyAtMs)]})]})}var Me=[`ok`,`warn`,`critical`];function Ne(e){return e>=.95?`critical`:e>=.85?`warn`:`ok`}function Pe(e){return Math.min(1,Math.max(0,e))}function q(e){let{availableBytes:t,totalBytes:n}=e;if(n===null||n<=0||t===null)return null;let r=Pe((n-t)/n);return{fraction:r,severity:Ne(r),recordingsFraction:Pe(e.usedBytes/n),freeBytes:t,totalBytes:n}}function Fe(e){if(e.length===0)return null;let t=0,n=0,r=0,i=0,a=null;for(let o of e){let e=q(o);if(e===null){n+=1;continue}t+=1,r+=e.totalBytes,i+=e.freeBytes,(a===null||Me.indexOf(e.severity)>Me.indexOf(a))&&(a=e.severity)}return{knownVolumes:t,unknownVolumes:n,totalBytes:r,freeBytes:i,severity:a}}var Ie=`Capacity unknown — nothing measured this volume from here. A remote share, a location on another node, or a mount that did not answer.`;function J(e){return Math.min(1,Math.max(0,e))}function Y(e){return Math.round(J(e)*1e3)/10}function X(e){return`${String(Math.round(J(e)*100))}%`}function Le(e,t,n={}){let{totalBytes:r,availableBytes:i}=e;if(r===null||r<=0||i===null){let e=n.ownedBytes===void 0||n.ownedBytes===null||!Number.isFinite(n.ownedBytes)||n.ownedBytes<0?null:k(n.ownedBytes);return{kind:`unknown`,owned:e,summary:e===null?Ie:`${Ie} CamStack holds ${e} here.`}}let a=Math.min(Math.max(i,0),r),o=r-a,s=t===null||t<=0?0:t,c=Math.min(s,a),l=s>a,u=a-c,d=n.ownedBytes,f=d==null||!Number.isFinite(d)||d<0?null:Math.min(d,o),p=o-(f??0),m=q({usedBytes:f??o,availableBytes:a,totalBytes:r}),h=m===null?J(o/r):m.fraction,g=m===null?Ne(h):m.severity,_=f===null?null:m===null?J(f/r):m.recordingsFraction,v=n.cap??null,y=v===null?null:J((c+v.bytes)/r),b=v!==null&&f!==null&&f>v.bytes,x={total:k(r),freeTotal:k(a),freeTotalPercent:X(a/r),used:k(p),usedPercent:X(p/r),free:k(u),freePercent:X(u/r),reserve:s===0?null:`${k(s)} kept free`,owned:f===null||_===null?null:`${k(f)} of recordings (${X(_)})`,cap:v===null?null:v.reason===`drain`?`${k(v.bytes)} drain target (managed by CamStack)`:`${k(v.bytes)} cap (managed by CamStack)`},S=[`${x.freeTotal} free of ${x.total} (${x.freeTotalPercent} free)`,x.owned===null?null:`CamStack holds ${x.owned}`,x.reserve===null?null:l?`${x.reserve} — less free than that right now, the oldest data here is being deleted`:x.reserve,x.cap===null?null:b?`${x.cap} — already below what is stored here, the oldest is being deleted`:x.cap].filter(e=>e!==null).join(` · `),C=[];return c>0&&C.push({segment:`reserve`,label:`Kept free`,value:k(s),alarming:l}),x.owned!==null&&C.push({segment:`owned`,label:`CamStack`,value:x.owned,alarming:!1}),C.push({segment:`used`,label:f===null?`Used`:`Other data`,value:`${x.used} (${x.usedPercent})`,alarming:g===`critical`}),C.push({segment:`free`,label:`Free`,value:`${x.free} (${x.freePercent})`,alarming:l}),v!==null&&C.push({segment:`cap`,label:v.reason===`drain`?`Drain target`:`Cap`,value:`${k(v.bytes)} · managed by CamStack`,alarming:b}),{kind:`known`,severity:g,legend:C,segments:{reservePercent:Y(c/r),ownedPercent:f===null?null:Y(f/r),usedPercent:Y(p/r),freePercent:Y(u/r),capPercent:y===null?null:Y(y)},labels:x,reserveExceedsFree:l,capBelowOwned:b,summary:S}}var Re={ok:`bg-primary`,warn:`bg-amber-500`,critical:`bg-danger`},Z={reserve:`bg-danger/40`,owned:`bg-foreground/50`,free:`bg-border`,cap:`bg-foreground`};function ze(e,t){return e===`used`?Re[t]:Z[e]}function Be({location:e,ownedBytes:t}){let r=e.capacity??null,i=ge(fe(e.config),r?.totalBytes??null),a=Le({totalBytes:r?.totalBytes??null,availableBytes:r?.availableBytes??null},i,{ownedBytes:t??null,cap:be(e.config,R(e))});return a.kind===`unknown`?o(`div`,{className:`text-[10px] text-foreground-subtle italic`,title:a.summary,children:a.owned===null?`Capacity unknown`:`Capacity unknown · CamStack holds ${a.owned}`}):n(`div`,{className:`mt-1 space-y-1`,title:a.summary,children:[n(`div`,{className:`relative flex h-2 w-full max-w-md overflow-hidden rounded-full bg-border`,children:[a.segments.reservePercent>0&&o(`div`,{className:Z.reserve,style:{width:`${String(a.segments.reservePercent)}%`}}),a.segments.ownedPercent!==null&&o(`div`,{className:Z.owned,style:{width:`${String(a.segments.ownedPercent)}%`}}),o(`div`,{className:Re[a.severity],style:{width:`${String(a.segments.usedPercent)}%`}}),o(`div`,{className:Z.free,style:{width:`${String(a.segments.freePercent)}%`}}),a.segments.capPercent!==null&&o(`div`,{className:`absolute inset-y-0 w-px ${a.capBelowOwned?`bg-danger`:Z.cap}`,style:{left:`${String(a.segments.capPercent)}%`}})]}),o(`ul`,{className:`flex flex-wrap items-center gap-x-3 gap-y-0.5`,children:a.legend.map(e=>n(`li`,{className:`flex items-center gap-1`,children:[o(`span`,{"aria-hidden":`true`,className:`inline-block h-2 w-2 shrink-0 rounded-sm ${ze(e.segment,a.severity)}`}),n(`span`,{className:`text-[10px] tabular-nums ${e.alarming?`text-danger`:`text-foreground-subtle`}`,children:[e.label,` `,e.value]})]},e.segment))})]})}var Ve={eventMedia:[`events`],recordingsLow:[`low`],recordings:[`high`,`mid`]},He={eventMedia:`pipeline-analytics`,recordingsLow:`recorder`,recordings:`recorder`},Ue=`storage.discardLocation`,We=`storage.discardLocationStatus`,Ge=`storage.discardLocationCancel`;function Ke(e){return Ve[e]??null}function qe(e){return He[e]??null}function Je(e){return!z(R(e))}function Ye(e,t){return Ke(e.type)===null||!Je(e)?!1:t.some(t=>t.id!==e.id&&z(R(t)))}var Xe=new Set([`idle`,`scanning`,`wiping-fs`,`wiping-db`,`cascading`,`complete`,`cancelled`,`error`]);function Q(e){return typeof e==`number`&&Number.isFinite(e)?e:null}function $(e){return typeof e==`string`?e:null}function Ze(e){if(typeof e!=`object`||!e)return null;let t=e;if(typeof t.running!=`boolean`)return null;let n=t.phase;if(typeof n!=`string`||!Xe.has(n))return null;let r=Q(t.camerasTotal),i=Q(t.camerasDone),a=Q(t.foldersRemoved),o=Q(t.dbRowsDeleted),s=Q(t.ownersCascaded);return r===null||i===null||a===null||o===null||s===null?null:{running:t.running,locationId:$(t.locationId),jobId:$(t.jobId),phase:n,camerasTotal:r,camerasDone:i,foldersRemoved:a,dbRowsDeleted:o,ownersCascaded:s,detail:$(t.detail)??``,startedAtMs:Q(t.startedAtMs),finishedAtMs:Q(t.finishedAtMs),error:$(t.error)}}function Qe(e){if(e.phase===`complete`)return 100;if(e.phase===`cancelled`||e.phase===`error`||e.phase===`idle`)return e.camerasTotal>0?Math.min(99,Math.round(e.camerasDone/e.camerasTotal*100)):0;if(e.camerasTotal>0){let t=e.camerasDone/e.camerasTotal*85;return e.phase===`wiping-db`?Math.min(95,Math.round(t+8)):e.phase===`cascading`?Math.min(99,Math.round(t+12)):Math.min(85,Math.round(t))}return e.phase===`scanning`?2:5}t();var $e=2e3;function et({location:e,siblings:t}){return Ye(e,t)?o(tt,{location:e}):null}function tt({location:e}){let t=_(),r=T(),i=qe(e.type),[c,l]=a(null),[u,d]=a(null),[f,p]=a(!1);if(s(()=>{if(i===null)return;let e=!1,t=async()=>{try{let t=await r.mutateAsync({addonId:i,action:We,input:{}});if(e)return;l(Ze(t))}catch{}};t();let n=setInterval(()=>void t(),$e);return()=>{e=!0,clearInterval(n)}},[i,e.id]),i===null)return null;let m=c!==null&&c.locationId===e.id,h=m&&c.running,g=m&&c.phase!==`idle`,y=async()=>{if(await t({title:`Discard leftovers on "${e.displayName}"?`,message:`Permanently deletes leftover files and records on this location. Other locations are not affected. This cannot be undone and may take hours.`,confirmLabel:`Discard leftovers`,variant:`danger`})){d(null),p(!0);try{await r.mutateAsync({addonId:i,action:Ue,input:{locationId:e.id}}),l(Ze(await r.mutateAsync({addonId:i,action:We,input:{}})))}catch(e){d(e instanceof Error?e.message:String(e))}finally{p(!1)}}},b=async()=>{try{await r.mutateAsync({addonId:i,action:Ge,input:{}})}catch(e){d(e instanceof Error?e.message:String(e))}};return n(`div`,{className:`flex flex-col gap-1 min-w-[9rem] max-w-[16rem]`,children:[h?n(`button`,{type:`button`,onClick:()=>void b(),className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-danger border border-danger/40 hover:bg-danger/10`,children:[o(w,{className:`h-3 w-3`}),`Cancel`]}):n(`button`,{type:`button`,onClick:()=>void y(),disabled:f,title:`Permanently delete leftover files on this location. Other locations are not affected.`,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-danger border border-danger/40 hover:bg-danger/10 disabled:opacity-50`,children:[f?o(v,{className:`h-3 w-3 animate-spin`}):o(A,{className:`h-3 w-3`}),`Discard leftovers`]}),g&&c!==null&&n(`div`,{className:`space-y-0.5`,children:[o(`div`,{className:`h-1 rounded bg-border overflow-hidden`,children:o(`div`,{className:`h-full bg-primary transition-[width] duration-300`,style:{width:`${Qe(c)}%`}})}),n(`p`,{className:`text-[10px] text-foreground-subtle leading-tight`,children:[c.phase,c.camerasTotal>0?` · ${c.camerasDone}/${c.camerasTotal} cam`:``,c.dbRowsDeleted>0?` · ${c.dbRowsDeleted} rows`:``,c.detail?` · ${c.detail}`:``]})]}),(u||m&&c?.error)&&o(`p`,{className:`text-[10px] text-danger leading-tight`,children:u??c?.error})]})}t();var nt={active:g,readonly:E,drain:D,disabled:d},rt={active:`border-success/30 text-success hover:bg-success/10`,readonly:`border-border text-foreground-subtle hover:text-foreground hover:bg-primary/10`,drain:`border-warning/40 text-warning hover:bg-warning/10`,disabled:`border-danger/40 text-danger hover:bg-danger/10`};function it({mode:e,open:t,onToggle:r}){let i=V(e),a=nt[e];return n(`button`,{type:`button`,"aria-expanded":t,"aria-label":`Location state`,onClick:r,title:i.consequence,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium border ${rt[e]}`,children:[o(a,{className:`h-3 w-3`}),i.label,o(l,{className:`h-3 w-3 ${t?`rotate-180`:``}`})]})}function at({mode:e,blockedReasons:t,onSelect:r,onDismiss:i}){return s(()=>{let e=e=>{e.key===`Escape`&&i()};return window.addEventListener(`keydown`,e),()=>{window.removeEventListener(`keydown`,e)}},[i]),n(`div`,{className:`w-full basis-full rounded-lg border border-border bg-background p-1`,role:`group`,"aria-label":`Location state choices`,children:[n(`div`,{className:`flex items-center justify-between px-2 py-1`,children:[o(`span`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Location state`}),o(`button`,{type:`button`,"aria-label":`Close location state choices`,onClick:i,className:`text-foreground-subtle hover:text-foreground`,children:o(w,{className:`h-3 w-3`})})]}),B.map(a=>{let s=t[a.mode],c=s!==``,l=nt[a.mode],u=a.mode===e;return n(`button`,{type:`button`,role:`radio`,"aria-checked":u,"aria-label":a.label,disabled:c,onClick:()=>{c||(i(),u||r(a.mode))},className:`flex w-full flex-col items-start gap-0.5 rounded px-2 py-1.5 text-left ${c?`cursor-not-allowed opacity-60`:u?`bg-primary/10`:`hover:bg-primary/5`}`,children:[n(`span`,{className:`flex items-center gap-1.5 text-[11px] font-medium text-foreground`,children:[o(l,{className:`h-3 w-3`}),a.label,u&&o(`span`,{className:`text-[9px] uppercase text-primary`,children:`current`})]}),o(`span`,{className:`text-[10px] leading-snug text-foreground-subtle`,children:a.consequence}),c&&o(`span`,{className:`text-[10px] leading-snug text-warning`,children:s})]},a.mode)})]})}t();function ot(e){let t=e.basePath;if(typeof t==`string`&&t.length>0)return t;let n=Object.keys(e);return n.length===0?``:n.join(`, `)}function st({location:e,onEdit:t,onDelete:r,onSetMode:i,blockedReasons:s,canDelete:c,siblings:l=[],drain:u,ownedBytes:d}){let[p,h]=a(!1),g=ot(e.config),_=R(e);return n(`div`,{className:`flex flex-wrap items-start gap-x-3 gap-y-2 px-3 py-2 border-t border-border first:border-t-0 hover:bg-primary/5`,children:[n(`div`,{className:`flex items-start gap-2 min-w-0 flex-1 basis-72`,children:[o(`div`,{className:`shrink-0 sm:w-32`,"data-testid":`location-badge-slot`,children:o(`span`,{className:`inline-block text-[10px] uppercase tracking-wide text-foreground-subtle bg-background border border-border rounded px-1.5 py-0.5 font-mono`,children:e.providerId})}),n(`div`,{className:`min-w-0 flex-1`,children:[o(`div`,{className:`text-xs font-medium text-foreground truncate`,children:e.displayName}),g&&o(`div`,{className:`text-[10px] text-foreground-subtle truncate font-mono`,children:g}),o(Be,{location:e,ownedBytes:d??null}),u!==void 0&&o(je,{drain:u})]})]}),n(`div`,{className:`flex flex-wrap items-center gap-1 shrink-0`,children:[o(et,{location:e,siblings:l}),o(it,{mode:_,open:p,onToggle:()=>{h(e=>!e)}}),n(`button`,{onClick:()=>t(e),className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-foreground-subtle border border-border hover:text-foreground hover:bg-primary/10`,children:[o(m,{className:`h-3 w-3`}),`Edit`]}),c&&o(`button`,{onClick:()=>r(e),className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-danger hover:bg-danger/10`,title:`Delete location`,children:o(f,{className:`h-3 w-3`})})]}),p&&o(at,{mode:_,blockedReasons:s,onSelect:t=>i(e,t),onDismiss:()=>{h(!1)}})]})}t();function ct({type:e,displayName:t,description:i,cardinality:a,locations:s,onAdd:c,onEdit:l,onDelete:u,onSetMode:d,ownedBytesById:f,drainById:p}){let m=r(()=>{let e=[...s];return e.sort((e,t)=>{let n=z(R(e));return n===z(R(t))?e.displayName.localeCompare(t.displayName):n?-1:1}),e},[s]);return n(`div`,{className:`rounded-lg border border-border bg-surface`,children:[n(`div`,{className:`flex items-start justify-between border-b border-border px-3 py-2`,children:[n(`div`,{className:`space-y-0.5`,children:[n(`div`,{className:`flex items-center gap-2`,children:[o(`span`,{className:`text-sm font-semibold text-foreground capitalize`,children:t}),o(`span`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle bg-background border border-border rounded px-1.5 py-0.5 font-mono`,children:e})]}),i&&o(`p`,{className:`text-[11px] text-foreground-subtle`,children:i}),a===`single`&&o(`p`,{className:`text-[10px] text-foreground-subtle italic`,children:`Single — one location per type. Edit the existing entry; it can't be split.`})]}),a===`multi`&&n(`button`,{onClick:()=>c(e),className:`inline-flex items-center gap-1 rounded bg-primary px-2 py-1 text-[11px] font-medium text-primary-foreground hover:bg-primary/90`,children:[o(b,{className:`h-3 w-3`}),`Add`]})]}),m.length===0?o(`div`,{className:`px-3 py-4 text-center text-[11px] text-foreground-subtle italic`,children:a===`multi`?`No location registered. Click "Add" to register one.`:`No location registered yet — should be auto-seeded at next boot.`}):o(`div`,{children:m.map(e=>o(st,{location:e,cardinality:a,canDelete:ce(e,m,a),onEdit:l,onDelete:u,onSetMode:d,blockedReasons:se(e,m),ownedBytes:f?.get(e.id)??null,drain:De(Oe(e),p?.get(e.id)),siblings:m},e.id))})]})}var lt=[`recordings`,`recordingsLow`];function ut(e){return e.locationIds!==void 0&&e.locationIds.length>0?e.locationIds:e.locationId===null?[]:[e.locationId]}function dt(e,t){if(t===void 0||!lt.includes(e.type))return null;let n=t.find(t=>ut(t).includes(e.id));return n===void 0||!Number.isFinite(n.usedBytes)||n.usedBytes<0?null:n.usedBytes}function ft(e,t){let n=new Map;for(let r of e){let e=dt(r,t);e!==null&&n.set(r.id,e)}return n}export{Te as a,V as c,Fe as i,H as l,ct as n,Se as o,q as r,ue as s,ft as t,L as u};
|
|
@@ -12,8 +12,8 @@ const __mfImport = (src) =>
|
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
(async () => {
|
|
15
|
-
const __mfHostInit = await __mfImport("./hostInit-
|
|
15
|
+
const __mfHostInit = await __mfImport("./hostInit-D7PExcI5.js");
|
|
16
16
|
await __mfHostInit.__tla;
|
|
17
17
|
const { initHost } = __mfHostInit;
|
|
18
18
|
await initHost();
|
|
19
|
-
})().then(() => __mfImport("./index-
|
|
19
|
+
})().then(() => __mfImport("./index-BhXNFlQG.js"));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{vt as e}from"./player-overlays-
|
|
1
|
+
import{vt as e}from"./player-overlays-CVsVEZkx.js";var t=e(`monitor-smartphone`,[[`path`,{d:`M18 8V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h8`,key:`10dyio`}],[`path`,{d:`M10 19v-3.96 3.15`,key:`1irgej`}],[`path`,{d:`M7 19h5`,key:`qswx4l`}],[`rect`,{width:`6`,height:`10`,x:`16`,y:`12`,rx:`2`,key:`1egngj`}]]);export{t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./src-DBOD88Il.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Q as e,S as t,W as n,b as r,i,q as a,x as o}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{at as s,st as c}from"./player-overlays-OREckyXS.js";import{Ha as l,Lc as u,Nn as d,Od as f,Xn as p,Zf as m,d as h,hd as g,ju as ee,pu as _,zc as te}from"./src-CEnvJotZ.js";import{At as ne,Ct as re,Dt as ie,Er as ae,Et as oe,F as se,G as ce,I as le,K as ue,Ln as de,M as fe,N as pe,O as me,Ot as he,P as ge,R as _e,Rn as ve,St as ye,Tt as v,ct as y,dt as be,et as xe,ft as Se,gt as Ce,ht as we,it as Te,jt as Ee,kt as De,lt as b,nt as Oe,pt as ke,rt as x,st as S,tt as Ae,vt as C,wt as w,yt as je}from"./client-1c3e-nOc.js";import{t as T}from"./useTranslation-Bc5yH9V9.js";e();function E(e){return t=>Object.prototype.hasOwnProperty.call(e,t)}var Me=E({devices:!0}),Ne=E({classes:!0,classesExclude:!0,labelEquals:!0,identities:!0,identitiesExclude:!0,eventTypeTokens:!0,sensorKinds:!0}),Pe=E({minConfidence:!0,minImportance:!0,minLabelConfidence:!0}),Fe=E({minDwellSeconds:!0}),Ie=E({source:!0}),Le=E({crossing:!0}),Re=E({packagePhase:!0}),ze=E({sensorTransition:!0}),Be=E({plates:!0}),Ve=E({occupancy:!0}),He=E({audio:!0}),Ue=E({systemEvent:!0}),We=E({deviceState:!0}),Ge=E({scene:!0});function Ke(e,t){let n=e[t];return Array.isArray(n)?n:[]}function qe(e,t){let n=e[t];return typeof n==`number`?n:void 0}function D(e,t){let r=s().trpcClient,a=i({queries:e.map(e=>({queryKey:[[`nc-pickers`,`zones`],{deviceId:e}],staleTime:3e4,queryFn:async()=>({deviceId:e,zones:(await r.zones.listZones.query({deviceId:e})).map(e=>({id:e.id,name:e.name}))})}))});return n(()=>{let e=[],n=new Set;for(let r of a){if(!r.data)continue;let i=t.find(e=>e.id===r.data.deviceId)?.name;for(let t of r.data.zones)n.has(t.id)||(n.add(t.id),e.push({value:t.id,label:t.name,...i===void 0?{}:{hint:i}}))}return{options:e,loading:a.some(e=>e.isLoading),failed:a.some(e=>e.isError)}},[a,t])}function Je(e){let t=s().trpcClient,r=i({queries:e.map(e=>({queryKey:[[`nc-pickers`,`event-kinds`],{deviceId:e}],staleTime:6e4,queryFn:async()=>(await t.pipelineAnalytics.listEventKinds.query({deviceId:e})).map(e=>({kind:e.kind,label:e.label}))}))});return n(()=>{let e=new Map;for(let t of r)for(let n of t.data??[])e.has(n.kind)||e.set(n.kind,n.label);let t=[...e.entries()].map(([e,t])=>({value:e,label:t}));return t.sort((e,t)=>e.label.localeCompare(t.label)),{options:t,loading:r.some(e=>e.isLoading)}},[r])}function Ye(){let e=l();return n(()=>({options:(e.data??[]).map(e=>({value:e.id,label:e.name})),loading:e.isLoading,failed:e.isError===!0}),[e.data,e.isLoading,e.isError])}function Xe(){let e=u({limit:200}),t=te();return n(()=>{let n=new Set;for(let e of t.data??[])e.name.trim().length>0&&n.add(e.name);let r=new Set;for(let t of e.data??[])t.text.trim().length>0&&r.add(t.text);return[...[...n].sort(),...[...r].sort()]},[e.data,t.data])}function O({options:e,value:r,onChange:i,loading:s,emptyHint:c,placeholder:l,noFreeText:u=!1}){let[d,f]=a(``),p=n(()=>new Set(e.map(e=>e.value)),[e]),m=n(()=>new Set(r),[r]),h=r.filter(e=>!p.has(e)),g=e=>{i(m.has(e)?r.filter(t=>t!==e):[...r,e])},ee=()=>{let e=d.trim();e.length===0||r.includes(e)||(i([...r,e]),f(``))};return t(`div`,{className:`mt-1 space-y-1.5`,children:[h.length>0&&o(`div`,{className:`flex flex-wrap gap-1`,children:h.map(e=>t(`button`,{type:`button`,onClick:()=>i(r.filter(t=>t!==e)),className:`inline-flex items-center gap-1 rounded border border-border px-1.5 py-0.5 text-[10px] text-foreground hover:bg-surface-hover`,title:`Custom value — click to remove`,children:[e,` ×`]},e))}),e.length>0?o(`div`,{className:`max-h-40 overflow-y-auto rounded-md border border-border divide-y divide-border`,children:e.map(e=>t(`label`,{className:`flex items-center gap-2.5 px-3 py-1.5 text-xs text-foreground cursor-pointer hover:bg-surface-hover`,children:[o(`input`,{type:`checkbox`,checked:m.has(e.value),onChange:()=>g(e.value),className:`accent-primary`}),o(`span`,{className:`flex-1 truncate`,children:e.label}),e.hint!==void 0&&o(`span`,{className:`text-[10px] text-foreground-subtle`,children:e.hint})]},e.value))}):o(`p`,{className:`text-[10px] text-foreground-subtle`,children:s===!0?`Loading…`:c}),!u&&o(`input`,{value:d,onChange:e=>f(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),ee())},placeholder:l,className:`w-full rounded-md border border-border bg-background px-2 py-1 text-xs text-foreground placeholder:text-foreground-subtle`})]})}var k=[{value:`immediate`,label:`Immediate`,hint:`Fires on the first matching detection of a track (lowest latency).`},{value:`track-end`,label:`Track end`,hint:`Evaluates the finalised track record when it closes.`},{value:`device-event`,label:`Device event`,hint:`Doorbell press, sensor state change, or an occupancy edge on a linked device.`},{value:`package-event`,label:`Package event`,hint:`A parcel delivery or pick-up.`},{value:`system-event`,label:`System event`,hint:`The installation itself: a camera or stream going offline, a node leaving the cluster, an addon or server update becoming available.`}],A=`Immediate, grouped`,Ze=k.flatMap(e=>e.value===`immediate`?[e,{value:`immediate-grouped`,label:A,hint:`Waits for subjects to be recognised, then sends one message with a mosaic, one picture per subject.`}]:[e]);function Qe(e){return e.groupingSec!==void 0&&S(e)?`immediate-grouped`:e.delivery}function $e(e){let t=(e.delivery===`immediate`||e.delivery===`track-end`)&&S({delivery:`immediate`,conditions:e.conditions});return Ze.filter(e=>e.value!==`immediate-grouped`||t)}function et(e){return Ze.find(t=>t.value===e)?.value}function tt(e,t=A){return Qe(e)===`immediate-grouped`?`${t} · ${String(e.groupingSec)} s`:rt(e.delivery)}function nt(e){if(e.trim().length===0)return;let t=Number(e);return Number.isFinite(t)&&t>=0?Math.trunc(t):void 0}function rt(e){return k.find(t=>t.value===e)?.label??e}function it(e){return k.some(t=>t.value===e)}var at=[{key:`all`,label:`All rules`,blurb:`Every notification rule — event-driven and scheduled producers. Tabs filter this same list; pick the type under New rule when creating from here.`,newRuleLabel:`New rule`,emptyHint:`No rules yet. Click "New rule" and pick a kind (Detection, Summary, Calendar events, …).`,creatable:!0},{key:`detection`,label:`Detections`,blurb:`Rules driven by what the cameras SEE — detections, tracks and package events. Doorbell presses and other sensor changes have their own section now (operator ruling, 2026-10-01).`,newRuleLabel:`New detection rule`,emptyHint:`No detection rules yet. Click "New detection rule" to author one.`,creatable:!0},{key:`sensor`,label:`Sensors`,blurb:`Rules driven by a device or sensor CHANGING STATE — a doorbell press, a linked sensor opening or closing. The picture is one snapshot of the camera the sensor is attributed to; there is no media choice to make.`,newRuleLabel:`New sensor rule`,emptyHint:`No sensor rules yet. Click "New sensor rule" to be told when a doorbell is pressed or a linked sensor changes.`,creatable:!0},{key:`audio`,label:`Sound`,blurb:`Rules on what the cameras HEAR: a sustained window of sound loud enough, or classified as one of the sounds you name. A sound rule is an immediate rule carrying the sound condition — it fires only on a confirmed sampling window, never on a picture.`,newRuleLabel:`New sound rule`,emptyHint:`No sound rules yet. Click "New sound rule" — it opens on the sound condition already filled in with a level threshold, so you only have to name the sounds and the targets.`,creatable:!0},{key:`occupancy`,label:`Occupancy`,blurb:`Rules on how many objects are in a camera frame or a zone, and for how long: "the driveway became occupied", "the garden emptied". An occupancy rule is a device-event rule carrying the occupancy condition.`,newRuleLabel:`New occupancy rule`,emptyHint:`No occupancy rules yet. Click "New occupancy rule" — it opens on the occupancy condition; pick the camera on the Devices tab, then the zone and the count.`,creatable:!0},{key:`device-events`,label:`Device events`,blurb:`Rules about your devices: offline or back, switched off or on, a stream dropping, a battery or consumable running low, a camera detecting nothing. These carry no image.`,newRuleLabel:`New device-event rule`,emptyHint:`No device-event rules yet. Click "New device-event rule" to be told when a device drops, a battery runs low or a camera goes blind.`,creatable:!0},{key:`system`,label:`System events`,blurb:`Rules about the installation itself: a node leaving the cluster, an addon crash-looping, an update available or installed, a backup or export finishing. These carry no image and are not tied to a detection.`,newRuleLabel:`New system rule`,emptyHint:`No system rules yet. Click "New system rule" to be told when a node leaves, an update lands or a backup finishes.`,creatable:!0},{key:`alarm`,label:`Alarm`,blurb:`Rules about the alarm panel: arming, armed, triggered, disarmed, and the refusals in between.`,newRuleLabel:`New alarm rule`,emptyHint:`No alarm rules yet. Click "New alarm rule" to be told when the alarm arms, goes off or is disarmed.`,creatable:!0},{key:`mixed`,label:`To recreate`,blurb:`System rules authored before the three families existed. Each mixes families and keeps firing as it is, but it cannot be edited: recreate it as one rule per family (Device events, System events, Alarm). Open none of them: Delete each once its replacements exist.`,newRuleLabel:`New rule`,emptyHint:`Nothing to recreate.`,creatable:!1}];function ot(e){return b(y(e)).editable}function st(e){return Te(ct(e))}function ct(e){switch(e){case`device-events`:case`system`:case`alarm`:case`mixed`:return e;default:return}}var lt=new Map([[0,`No cooldown`],[60,`1 minute`],[3600,`1 hour`]]),ut=86400;function dt(e){let t=lt.get(e);return t===void 0?e%3600==0?`${e/3600} hours`:e%60==0?`${e/60} minutes`:`${e} seconds`:t}function ft(e){if(e.trim().length===0)return;let t=Number(e);return Number.isFinite(t)&&t>=0?Math.trunc(t):void 0}var pt=[{value:`rule-device`,label:`Per device`},{value:`rule`,label:`Whole rule (one window for every device)`}];function mt(e){return pt.find(t=>t.value===e)?.value}var ht=[{value:`per-class`,label:`Separate windows per class (default)`},{value:`shared`,label:`Shared across classes`}];function gt(e){return ht.find(t=>t.value===e)?.value}var _t=[{value:`best`,label:`Best available image`,description:`The best subject crop available when the notification is sent.`},{value:`best-matching`,label:`Best matching image`,description:`The image that explains why the rule fired — the face crop for an identity rule, the plate crop for a plate rule; falls back to the best image otherwise.`},{value:`keyFrame`,label:`Key frame`,description:`The clean full scene frame with no subject box.`},{value:`none`,label:`No attachment`,description:`Send the notification with no image.`}];function vt(e){return _t.find(t=>t.value===e)?.value}var j=[{value:``,label:`Automatic`},{value:`cropped`,label:`Cropped on the subject`},{value:`full`,label:`Full frame`},{value:`boxed`,label:`Full frame with boxes`}];function yt(e){let t=j.find(t=>t.value===e)?.value;return t===``?void 0:t}var M=[{value:``,label:`Mosaic of every linked camera (default)`},{value:`mosaic`,label:`Mosaic of every linked camera`},{value:`each`,label:`One image per camera (first camera where only one is allowed)`}];function bt(e){let t=M.find(t=>t.value===e)?.value;return t===``?void 0:t}var N=[{value:``,label:`Lowest available`},{value:`low`,label:`Low`},{value:`mid`,label:`Medium`},{value:`high`,label:`High`}];function xt(e){let t=N.find(t=>t.value===e)?.value;return t===``?void 0:t}var St=[{value:`any`,label:`Any source`},{value:`pipeline`,label:`Pipeline`},{value:`onboard`,label:`Onboard (camera)`},{value:`sensor`,label:`Sensor`}],Ct=[{value:`delivered`,label:`Delivered`},{value:`picked-up`,label:`Picked up`},{value:`both`,label:`Both`}],wt=[{value:``,label:`It triggers and when it clears`},{value:`raised`,label:`Only when it triggers`},{value:`cleared`,label:`Only when it clears`}];function Tt(e){return e===`raised`||e===`cleared`?e:void 0}function P(e,t){return e===`sensorTransition`?ue(t.sensorKinds):!0}var Et=[{value:`enter`,label:`Entering`},{value:`exit`,label:`Leaving`},{value:`any`,label:`Entering or leaving`}],Dt=`enter`;function F(e){return e===`exit`||e===`any`?e:void 0}var Ot=[{value:1,label:`1 — Min`},{value:2,label:`2 — Low`},{value:3,label:`3 — Default`},{value:4,label:`4 — High`},{value:5,label:`5 — Max`}];function kt(e,t){return e.options&&e.options.length>0?e.options:t}var At=[{value:``,label:`Default (2×)`},{value:`1`,label:`1× — real time`},{value:`2`,label:`2×`},{value:`3`,label:`3×`},{value:`4`,label:`4×`},{value:`6`,label:`6×`},{value:`8`,label:`8×`}];function jt(e){if(e===``)return;let t=Number(e);return Number.isFinite(t)&&t>=1&&t<=8?t:void 0}var Mt=new Map(Object.entries({"device-offline":`Device offline`,"device-online":`Device online`,"device-disabled":`Device switched off`,"device-enabled":`Device switched on`,"stream-offline":`Stream offline`,"stream-online":`Stream online`,"device-battery-low":`Battery low`,"device-battery-normal":`Battery back to normal`,"device-consumable-low":`Consumable low`,"device-consumable-normal":`Consumable back to normal`,"device-tank-low":`Tank low (water, detergent)`,"device-tank-full":`Tank full (dirty water, dust)`,"device-tank-normal":`Tank back to normal`,"detection-blind":`Camera detecting nothing`,"node-offline":`Node offline`,"node-online":`Node online`,"node-restarting":`Node restarting`,"node-updating":`Node updating (restart imminent)`,"node-inference-unavailable":`Node has no usable inference device`,"addon-crash-loop":`Addon stopped after repeated crashes`,"addon-update-available":`Addon update available`,"addon-updated":`Addons updated`,"server-update-available":`Server update available`,"server-updated":`Server updated`,"wrapper-update-available":`Container / app update available`,"export-completed":`Export completed`,"backup-completed":`Backup completed`,"alarm-arm-refused":`Alarm arm refused (something is open)`,"alarm-check-failed":`Alarm check failed (armed anyway)`,"alarm-arming":`Alarm arming (exit delay)`,"alarm-armed":`Alarm armed`,"alarm-pending":`Alarm entry delay started`,"alarm-triggered":`Alarm triggered`,"alarm-rearmed":`Alarm re-armed after siren`,"alarm-sensor-bypass":`Alarm sensor bypass`,"alarm-disarmed":`Alarm disarmed`}));function Nt(e){return Mt.get(e)}var Pt={"device-state":`A device the hub can no longer reach, or that came back. Switched off / on is a device an operator turned off or back on — not a fault, a choice.`,streams:`A stream that stopped or came back.`,battery:`A battery below the cluster threshold, and (optionally) its return to normal. Devices with a binary low-battery indicator are judged by the indicator, not by the percentage.`,consumables:`A consumable — filter, brush, bag — at or below this rule’s threshold, or that the device reports as due for replacement, and (optionally) its return to normal after a change. A device that only says "replace" is judged by that, not by a percentage.`,tanks:`A robot vacuum tank the device reports as running low (clean water, detergent) or full (dirty water, dust bin), and (optionally) its return to normal once refilled or emptied.`,"detection-blind":`A camera that is running and being analysed, but detects nothing — up, and producing no work.`,nodes:`An agent or worker node joining or leaving the cluster, or an online node whose inference devices all went away.`,addons:`An addon the hub has stopped restarting after repeated crashes.`,"addon-updates":`A newer version of an addon, or an addon update that just finished.`,updates:`A newer version of the server itself, or of the container / app the node runs inside, is available — or a server update just finished.`,"backups-exports":`A scheduled or manual backup of the hub finished, or a footage export finished rendering.`,alarm:`The alarm panel refusing to arm, arming, armed, counting down to a siren, going off, re-arming, excluding an open sensor, or being disarmed.`},I=Ce.map(e=>({id:e.id,family:e.family,label:e.label,hint:Pt[e.id]??``,kinds:e.kinds.flatMap(e=>{let t=Nt(e);return t===void 0?[]:[{value:e,label:t}]})}));function L(e){return I.filter(t=>t.family===e)}function R(e){let t=be(e).conditions.systemEvent;return t===void 0?{kinds:(L(e)[0]?.kinds??[]).map(e=>e.value)}:{...t,kinds:[...t.kinds]}}var z=I.flatMap(e=>e.kinds);function B(e){return z.find(t=>t.value===e)?.label??e}function Ft(e){return{devices:C(e,`deviceIds`),deviceTypes:C(e,`deviceTypes`),nodes:C(e,`nodeIds`),packages:C(e,`packageNames`),consumableThreshold:C(e,`consumableLowPercent`)}}function V(e,t){let n=we[e],r=Ft(t);return{devices:n.includes(`deviceIds`)&&r.devices,excludeDevices:n.includes(`excludeDeviceIds`)&&r.devices,deviceTypes:n.includes(`deviceTypes`)&&r.deviceTypes,nodes:n.includes(`nodeIds`)&&r.nodes,packages:n.includes(`packageNames`)&&r.packages,consumableThreshold:n.includes(`consumableLowPercent`)&&r.consumableThreshold}}var It=Object.values(ae).map(e=>({value:e,label:H(e)})).toSorted((e,t)=>e.label.localeCompare(t.label));function H(e){let t=e.replaceAll(`-`,` `);return t.charAt(0).toUpperCase()+t.slice(1)}function Lt(e,t,n){if(!L(n).some(e=>e.kinds.some(e=>e.value===t)))return e;let r=e?.kinds??[];return r.length===1&&r[0]===t?e:Bt(e,r.includes(t)?r.filter(e=>e!==t):z.filter(e=>e.value===t||r.includes(e.value)).map(e=>e.value),n)}function Rt(e,t){return t===void 0?void 0:Bt(t,t.kinds,e)}function zt(e,t){let n=e?.kinds??[];if(n.length===0)return;let r=U(t,`deviceIds`,e?.deviceIds),i=U(t,`excludeDeviceIds`,e?.excludeDeviceIds),a=U(t,`deviceTypes`,e?.deviceTypes),o=U(t,`nodeIds`,e?.nodeIds),s=U(t,`packageNames`,e?.packageNames),c=Object.prototype.hasOwnProperty.call(t,`consumableLowPercent`)?t.consumableLowPercent:e?.consumableLowPercent;return{kinds:[...n],...r===void 0?{}:{deviceIds:[...r]},...i===void 0?{}:{excludeDeviceIds:[...i]},...a===void 0?{}:{deviceTypes:[...a]},...o===void 0?{}:{nodeIds:[...o]},...s===void 0?{}:{packageNames:[...s]},...c===void 0?{}:{consumableLowPercent:c}}}function U(e,t,n){let r=Object.prototype.hasOwnProperty.call(e,t)?e[t]:n;return r!==void 0&&r.length===0?void 0:r}function Bt(e,t,n){let r=V(n,t),i=r.devices?e?.deviceIds:void 0,a=r.excludeDevices?e?.excludeDeviceIds:void 0,o=r.deviceTypes?e?.deviceTypes:void 0,s=r.nodes?e?.nodeIds:void 0,c=r.packages?e?.packageNames:void 0,l=r.consumableThreshold?e?.consumableLowPercent:void 0;return{kinds:[...t],...i&&i.length>0?{deviceIds:[...i]}:{},...a&&a.length>0?{excludeDeviceIds:[...a]}:{},...o&&o.length>0?{deviceTypes:[...o]}:{},...s&&s.length>0?{nodeIds:[...s]}:{},...c&&c.length>0?{packageNames:[...c]}:{},...l===void 0?{}:{consumableLowPercent:l}}}var Vt=95;function Ht(e){let t=e.trim();if(t===``)return{kind:`clear`};let n=Number(t);return Number.isInteger(n)&&n>=1&&n<=Vt?{kind:`set`,value:n}:{kind:`invalid`}}function Ut(e,t=2){if(e===void 0||e.length===0)return`No event selected`;let n=e.slice(0,t).map(B).join(`, `),r=e.length-Math.min(t,e.length);return r>0?`${n} +${r}`:n}function Wt(e){if(e===void 0)return`—`;let t=[],n=e.deviceIds?.length??0,r=e.deviceTypes?.length??0,i=e.nodeIds?.length??0,a=e.packageNames?.length??0,o=e.excludeDeviceIds?.length??0;r>0&&t.push(e.deviceTypes?.map(H).join(`, `)??``),n>0&&t.push(`${n} device${n===1?``:`s`}`),i>0&&t.push(`${i} node${i===1?``:`s`}`),a>0&&t.push(`${a} package${a===1?``:`s`}`);let s=o>0?`except ${o} device${o===1?``:`s`}`:null,c=e.consumableLowPercent===void 0?[]:[`consumables at ${e.consumableLowPercent}%`];return t.length===0?[s===null?`Everything`:`Everything ${s}`,...c].join(` · `):[...t,...s===null?[]:[s],...c].join(` · `)}function Gt(e){return e===void 0||(e.deviceTypes?.length??0)===0?!1:e.kinds.some(e=>de.includes(e))}var Kt=[`all`,`only`,`except`];function qt(e,t){return(e??[]).length>0?`only`:(t??[]).length>0?`except`:`all`}function W(e,t){let n=[...e??[]],r=[...t??[]];return{mode:qt(n,r),include:n,exclude:r,legacyBoth:n.length>0&&r.length>0}}function Jt(e,t){return{...e,mode:t}}function Yt(e){switch(e.mode){case`only`:return e.include;case`except`:return e.exclude;case`all`:return[]}}function Xt(e,t){switch(e.mode){case`only`:return{...e,include:[...t]};case`except`:return{...e,exclude:[...t]};case`all`:return e}}function Zt(e){return e.mode===`only`&&e.legacyBoth?e.exclude:[]}function Qt(e){return{...e,exclude:[],legacyBoth:!1}}function G(e){switch(e.mode){case`all`:return{};case`except`:return e.exclude.length>0?{exclude:[...e.exclude]}:{};case`only`:{let t=Zt(e);return{...e.include.length>0?{include:[...e.include]}:{},...t.length>0?{exclude:[...t]}:{}}}}}function $t(e){let t=G(e),n=t.include??[],r=t.exclude??[];return[...e.include.filter(e=>!n.includes(e)),...e.exclude.filter(e=>!r.includes(e))]}var K=[`onActivation`,`onDeactivation`,`onTrigger`,`onTriggerOff`],q={onActivation:{title:`On activation`,hint:`Runs when the rule is turned on.`},onDeactivation:{title:`On deactivation`,hint:`Runs when the rule is turned off.`},onTrigger:{title:`On trigger`,hint:`Runs on a positive / raised match.`},onTriggerOff:{title:`On trigger off`,hint:`Runs on a clear / leave match. Delivery types without a clear edge never fire this.`}},en={onActivation:[],onDeactivation:[],onTrigger:[],onTriggerOff:[],buttons:[]};function tn(e){return e===void 0?en:{onActivation:[...e.onActivation??[]],onDeactivation:[...e.onDeactivation??[]],onTrigger:[...e.onTrigger??[]],onTriggerOff:[...e.onTriggerOff??[]],buttons:[...e.buttons??[]]}}function J(e){let t=e.buttons.filter(e=>e.id.trim()!==``&&e.label.trim()!==``&&e.sequenceId.trim()!==``),n={onActivation:e.onActivation,onDeactivation:e.onDeactivation,onTrigger:e.onTrigger,onTriggerOff:e.onTriggerOff};if(!(!K.some(e=>n[e].length>0)&&t.length===0))return{...n.onActivation.length>0?{onActivation:[...n.onActivation]}:{},...n.onDeactivation.length>0?{onDeactivation:[...n.onDeactivation]}:{},...n.onTrigger.length>0?{onTrigger:[...n.onTrigger]}:{},...n.onTriggerOff.length>0?{onTriggerOff:[...n.onTriggerOff]}:{},...t.length>0?{buttons:t}:{}}}function nn(e,t){let n=[];for(let r of K){let i=e[r];i.length>4&&n.push({kind:`too-many`,message:`${q[r].title} has more than 4 bindings.`});for(let e of i)e.kind===`sequence`&&!t.has(e.sequenceId)&&n.push({kind:`unknown-sequence`,message:`${q[r].title} points at a sequence that does not exist.`})}let r=new Set;for(let i of e.buttons){let e=i.id.trim();e!==``&&(r.has(e)&&n.push({kind:`duplicate-button`,message:`Two buttons share the id "${e}". The id is what the audit line names when one is tapped.`}),r.add(e),t.has(i.sequenceId.trim())||n.push({kind:`unknown-sequence`,message:`"${i.label||e}" points at a sequence that does not exist. It would never appear on a notification.`}))}return n}function rn(e,t){return{id:`action-${String(e+1)}`,label:`Action`,sequenceId:t}}function an(){return{kind:`do`,action:{kind:`cap`,deviceId:0,cap:``,method:``}}}function on(e){return{kind:`sequence`,sequenceId:e}}function sn(){return{kind:`wait`,seconds:5}}var cn=[{value:`acknowledge`,label:`Acknowledge`},{value:`dismiss`,label:`Dismiss`},{value:`silence`,label:`Silence`},{value:`snooze`,label:`Snooze`},{value:`view`,label:`View`},{value:`play`,label:`Play`},{value:`camera`,label:`Camera`},{value:`open`,label:`Open`},{value:`close`,label:`Close`},{value:`unlock`,label:`Unlock`},{value:`lock`,label:`Lock`},{value:`disarm`,label:`Disarm`},{value:`arm`,label:`Arm`},{value:`arm-home`,label:`Arm — home`},{value:`arm-away`,label:`Arm — away`},{value:`arm-night`,label:`Arm — night`},{value:`light`,label:`Light`},{value:`alert`,label:`Alert`}],ln=[10,30,60],un=[5,10,15,30,60,120,240,480];function dn(e){return e>=60&&e%60==0?`${e/60} h`:`${e} min`}var fn=new Set([`alarm-arm-refused`,`alarm-check-failed`,`alarm-arming`,`alarm-armed`,`alarm-pending`,`alarm-triggered`,`alarm-rearmed`,`alarm-sensor-bypass`,`alarm-disarmed`]),pn=`alarm-panel`;function mn(e,t){for(let t of e.systemEvent?.kinds??[])if(fn.has(t))return!0;for(let e of t)if(e.kind===`cap`&&e.cap===pn)return!0;return!1}function hn(e,t){let n=new Map(t.map(e=>[e.id,e])),r=[];for(let t of[`onActivation`,`onDeactivation`,`onTrigger`,`onTriggerOff`])for(let i of e[t])if(i.kind===`do`)r.push(i.action);else{let e=n.get(i.sequenceId);e!==void 0&&r.push(...e.actions)}for(let t of e.buttons){let e=n.get(t.sequenceId);e!==void 0&&r.push(...e.actions)}return r}function gn(e){let{devices:t,devicesExclude:n,classes:r,classesExclude:i,...a}=e;return{conditions:a,deviceScope:W(t,n),classScope:W(r,i)}}function _n(e){let t=G(e.deviceScope),n=G(e.classScope);return{...e.conditions,...t.include===void 0?{}:{devices:[...t.include]},...t.exclude===void 0?{}:{devicesExclude:[...t.exclude]},...n.include===void 0?{}:{classes:[...n.include]},...n.exclude===void 0?{}:{classesExclude:[...n.exclude]}}}function vn(e){return e.deviceScope.mode===`only`?e.deviceScope.include:[]}function yn(e,t,n){let r=y(n);return e.some(e=>e.id===t&&Ae(e,n.delivery,r))}function bn(e=`immediate`,t={}){return{name:``,enabled:!0,delivery:e,targetIds:[],targetUsers:[],targetParams:{},priority:3,mediaAttach:`best`,mediaZoneCrop:!1,mediaFrame:void 0,mediaGif:!1,mediaClip:!1,mediaProfile:void 0,mediaClipSpeed:void 0,mediaLinkedCameras:void 0,templateTitle:``,templateBody:``,...gn(t),schedule:void 0,systemEventDelivery:void 0,snoozeAllowGlobal:!1,groupingSec:void 0,snoozeOptions:void 0,actions:en,cooldownSec:30,cooldownScope:`rule-device`,cooldownGranularity:void 0}}function xn(e){let t={};for(let n of e.targets)n.params&&Object.keys(n.params).length>0&&(t[n.targetId]=n.params);return{name:e.name,enabled:e.enabled,delivery:e.delivery,targetIds:e.targets.map(e=>e.targetId),targetUsers:e.targetUsers??[],targetParams:t,priority:e.priority,mediaAttach:e.media.attach,mediaZoneCrop:e.media.zoneCrop===!0,mediaFrame:e.media.frame,mediaGif:e.media.gif===!0,mediaClip:e.media.clip===!0,mediaProfile:e.media.profile,mediaClipSpeed:e.media.clipSpeed,mediaLinkedCameras:e.media.linkedCameras,templateTitle:e.template?.title??``,templateBody:e.template?.body??``,...gn(e.conditions),schedule:e.schedule,systemEventDelivery:e.systemEventDelivery,snoozeAllowGlobal:e.snoozeAllowGlobal===!0,groupingSec:e.groupingSec,snoozeOptions:e.snoozeOptions,actions:tn(e.actions),cooldownSec:e.throttle.cooldownSec,cooldownScope:e.throttle.scope,cooldownGranularity:e.throttle.granularity}}function Sn(e,t){let n=[];if(On(e)){let r=e.groupingSec;r!==void 0&&(!Number.isInteger(r)||r<5||r>60)&&n.push(`The grouping window is a whole number of seconds between 5 and 60.`);let i=t?.confirm;i?.enabled===!0&&i.expect!==void 0&&!kn(i.expect)&&n.push(`This rule’s AI confirm expects more than one subject, but a grouped message judges one picture per subject, so it would never send. Remove the confirm expectation (viewer or API), or choose Immediate.`)}if(v(e.conditions.audio)&&n.push(`This sound rule names neither a sound nor a level threshold, so it can never fire — every sample would count as a hit and the engine refuses it rather than notifying on silence. Pick at least one sound, or add a level.`),(!Number.isInteger(e.cooldownSec)||e.cooldownSec<0||e.cooldownSec>86400)&&n.push(`The cooldown is a whole number of seconds between 0 and ${String(ut)} (24 hours). 0 means every match is delivered.`),Y(e))for(let t of le({delivery:e.delivery,conditions:e.conditions,...e.systemEventDelivery===void 0?{}:{systemEventDelivery:e.systemEventDelivery},...J(e.actions)===void 0?{}:{actions:J(e.actions)}}))n.push(fe(t));return n}function Cn(e){let t=e.systemEventDelivery;if(t===void 0)return{};if(!x(e.delivery))return t.mode===`summary`?{systemEventDelivery:{mode:`instant`}}:{};if(t.mode===`summary`&&se(t.schedule)===null){let e=ge(t.schedule);if(e!==null&&e.times.length>0)return{systemEventDelivery:{...t,schedule:pe(e.times,t.schedule.timezone)}}}return{systemEventDelivery:t}}function wn(e){if(!Y(e))return null;if(!_e(e.templateBody))return`This body names none of the summary ({{summaryText}} or a section variable) — the hub appends {{summaryText}} to it when it sends.`;let t=e.templateBody;return(e.systemEventDelivery?.mode===`summary`?e.systemEventDelivery.split:void 0)===`section`&&t.trim().length>0&&!/\{\{\s*summaryText\s*\}\}/.test(t)?`Sent one per category: this body names no {{summaryText}}, so on every other category’s notification the hub appends {{summaryText}} (that category’s lines).`:null}function Y(e){return x(e.delivery)&&e.systemEventDelivery?.mode===`summary`}function Tn(e,t,n=new Set){return Sn(e,t).length===0&&it(e.delivery)&&(!x(e.delivery)||Nn(e)>0)&&y(e)!==`mixed`&&e.name.trim().length>0&&(e.targetIds.length>0||e.targetUsers.length>0)&&nn(e.actions,n).length===0}function En(e,t){let n=jn(e.conditions,t);return x(t)&&(n.systemEvent?.kinds.length??0)===0?{...e,delivery:t,conditions:{...n,systemEvent:R(`device-events`)}}:{...e,delivery:t,conditions:n}}function Dn(e,t){return t===`immediate-grouped`?{...En(e,`immediate`),groupingSec:e.groupingSec??20}:{...En(e,t),groupingSec:void 0}}function On(e){return e.groupingSec!==void 0&&S(e)}function kn(e){switch(e.op){case`>`:return 1>e.count;case`<=`:return 1<=e.count;case`<`:return 1<e.count;case`==`:return e.count===1;default:return 1>=e.count}}var An=new Set([`immediate`,`track-end`,`package-event`]);function jn(e,t){if(e.source!==`pipeline`||An.has(t))return e;let{source:n,...r}=e;return r}function Mn(e,t){return ke(e.conditions.systemEvent)===t?e:{...e,conditions:{...e.conditions,systemEvent:R(t)}}}function Nn(e){return e.conditions.systemEvent?.kinds.length??0}function X(e,t){return e.appliesTo.includes(t)}var Pn={source:`any`};function Fn(e,t){if(t==null)return!0;if(Array.isArray(t))return t.length===0;if(typeof t==`string`)return t.length===0||Pn[e]===t;if(typeof t==`number`)return!Number.isFinite(t);if(typeof t==`object`){if(`ids`in t){let e=t.ids;return!Array.isArray(e)||e.length===0}if(`values`in t){let e=t.values;return!Array.isArray(e)||e.length===0}return!1}return!1}var In=ve.filter(e=>e.id===`audio`);function Ln(e){if(e.length===0)return e;let t=new Set(e.map(e=>e.id)),n=In.filter(e=>!t.has(e.id));return n.length===0?e:[...e,...n]}function Rn(e,t,n,r=y({delivery:t,conditions:e})){let i=n.length===0?null:new Set(n.filter(e=>e.id!==`schedule`&&Ae(e,t,r)).map(e=>e.id)),a={};for(let[t,n]of Object.entries(e))i!==null&&!i.has(t)||P(t,e)&&(Fn(t,n)||(a[t]=n));return a}function zn(e,t){if(e===void 0)return{};let n=Rt(e,t.systemEvent);return n===void 0?{}:{systemEvent:n}}function Bn(e){return e!==void 0&&e.windows.length>0}function Vn(e){let t={...e.clipPreRollSec===void 0?{}:{clipPreRollSec:e.clipPreRollSec},...e.clipPostRollSec===void 0?{}:{clipPostRollSec:e.clipPostRollSec}};return Object.keys(t).length>0?t:void 0}function Hn(e){let t=Vn(e.media);return{...e.confirm===void 0?{}:{confirm:e.confirm},...t===void 0?{}:{media:t}}}function Un(e,t,n=[]){let r=e.templateTitle.trim(),i=e.templateBody.trim(),a=r.length>0||i.length>0?{...r.length>0?{title:r}:{},...i.length>0?{body:i}:{}}:void 0,o=J(e.actions),s=y(e),c=b(s),l=Se(s),u=n.length===0?!0:n.some(t=>t.id===`schedule`&&X(t,e.delivery)),d=!Y(e)&&u&&Bn(e.schedule)?e.schedule:void 0,f=n.length===0?!0:n.some(t=>t.id===`devices`&&X(t,e.delivery)),p=n.length===0?!0:n.some(t=>t.id===`devicesExclude`&&X(t,e.delivery)),{devices:m,devicesExclude:h,...g}=_n(e);return{name:e.name.trim(),enabled:e.enabled,delivery:e.delivery,conditions:{...Rn(g,e.delivery,n,s),...f&&m!==void 0?{devices:m}:{},...p&&h!==void 0?{devicesExclude:h}:{},...zn(l,e.conditions)},...d?{schedule:d}:{},...Cn(e),targets:e.targetIds.map(t=>{let n=e.targetParams[t];return n&&Object.keys(n).length>0?{targetId:t,params:n}:{targetId:t}}),...e.targetUsers.length>0?{targetUsers:[...e.targetUsers]}:{},media:c.carriesMedia?{attach:e.mediaAttach,...c.carriesSubjectCrop&&e.mediaZoneCrop?{zoneCrop:!0}:{},...c.carriesSubjectCrop&&e.mediaFrame!==void 0?{frame:e.mediaFrame}:{},...e.mediaGif?{gif:!0}:{},...e.mediaClip?{clip:!0}:{},...e.mediaProfile===void 0?{}:{profile:e.mediaProfile},...e.mediaClipSpeed===void 0?{}:{clipSpeed:e.mediaClipSpeed},...s===`sensor`&&e.mediaAttach!==`none`&&e.mediaLinkedCameras!==void 0?{linkedCameras:e.mediaLinkedCameras}:{},...(e.mediaGif||e.mediaClip)&&t?.media?.clipPreRollSec!==void 0?{clipPreRollSec:t.media.clipPreRollSec}:{},...(e.mediaGif||e.mediaClip)&&t?.media?.clipPostRollSec!==void 0?{clipPostRollSec:t.media.clipPostRollSec}:{}}:{attach:`none`},throttle:{cooldownSec:e.cooldownSec,scope:e.cooldownScope,...e.cooldownGranularity===void 0?{}:{granularity:e.cooldownGranularity}},priority:e.priority,...a?{template:a}:{},...e.snoozeAllowGlobal?{snoozeAllowGlobal:!0}:{},...On(e)?{groupingSec:e.groupingSec}:{},...e.snoozeOptions===void 0?{}:{snoozeOptions:[...e.snoozeOptions]},...t?.confirm===void 0?{}:{confirm:t.confirm},...o===void 0?{}:{actions:o}}}function Wn(e,t){let n=Un(e,void 0,t);return[`template`,`schedule`,`targetUsers`,`snoozeOptions`,`snoozeAllowGlobal`,`groupingSec`,`actions`].filter(e=>n[e]===void 0)}var Gn=[{key:`rule`,label:`Rule`,fields:[`name`,`enabled`,`delivery`,`groupingSec`,`targetIds`,`targetUsers`,`targetParams`]},{key:`devices`,label:`Devices`,fields:[`deviceScope`]},{key:`conditions`,label:`Conditions`,fields:[`conditions`,`classScope`,`schedule`,`systemEventDelivery`]},{key:`notification`,label:`Notification`,fields:[`priority`,`mediaAttach`,`mediaFrame`,`mediaZoneCrop`,`mediaGif`,`mediaClip`,`mediaProfile`,`mediaClipSpeed`,`mediaLinkedCameras`,`templateTitle`,`templateBody`]},{key:`actions`,label:`Actions`,fields:[`actions`]},{key:`advanced`,label:`Advanced`,fields:[`snoozeAllowGlobal`,`snoozeOptions`,`cooldownSec`,`cooldownScope`,`cooldownGranularity`]}];function Kn(e,t={}){let n=y({delivery:e,conditions:t}),r=b(n),i=Gn.map(e=>e.key===`conditions`?{...e,label:r.label}:e);return Te(n)?i.filter(e=>e.key!==`devices`):i}function qn(e){if(e.audio!==void 0)return`Sound`;if(e.occupancy!==void 0)return`Occupancy`}function Jn(e){let t=y(e),n=Oe(_n(e),t);return t===`sensor`&&e.conditions.sensorTransition!==void 0&&!P(`sensorTransition`,e.conditions)?[...n,{conditionId:`sensorTransition`,reason:ce}]:n}var Yn=`rule`;function Xn(e){return Gn.find(t=>t.key===e)?.key}function Zn(e){return e?.toLowerCase().startsWith(`it`)===!0?`it`:`en`}function Qn(){let{i18n:e}=T(),t=Zn(e.language);return e=>me(e,t)}e();var $n=`block text-[11px] font-medium text-foreground`,Z=`text-[10px] text-foreground-subtle mt-0.5`;function er({cameras:e,fleet:t,value:n,onChange:r,emptyMeansAll:i=!1,savedHadDevices:a=!1}){return o(h,{devices:e,listState:t.state,fleet:t,value:n,onChange:r,emptyMeansAll:i,savedHadDevices:a})}function tr({value:e,placeholder:n,onChange:r}){let[i,s]=a(``),c=()=>{let t=i.trim();if(t.length===0||e.includes(t)){s(``);return}r([...e,t]),s(``)},l=t=>r(e.filter(e=>e!==t));return t(`div`,{className:`mt-1 space-y-1.5`,children:[e.length>0&&o(`div`,{className:`flex flex-wrap gap-1`,children:e.map(e=>t(`span`,{className:`inline-flex items-center gap-1 rounded bg-surface-hover px-1.5 py-0.5 text-[11px] text-foreground`,children:[e,o(`button`,{type:`button`,onClick:()=>l(e),"aria-label":`remove ${e}`,className:`text-foreground-subtle hover:text-danger`,children:o(ee,{className:`h-3 w-3`})})]},e))}),o(_,{value:i,placeholder:n,onChange:e=>s(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),c())},onBlur:c})]})}function nr({picker:e,value:r,onChange:i}){let a=n(()=>je(e),[e]),s=n(()=>new Set(r),[r]),c=r.filter(e=>!a.has(e)),l=e=>{i(s.has(e)?r.filter(t=>t!==e):[...r,e])};return t(`div`,{className:`space-y-2`,children:[c.length>0&&o(`div`,{className:`flex flex-wrap gap-1`,children:c.map(e=>t(`button`,{type:`button`,onClick:()=>i(r.filter(t=>t!==e)),className:`inline-flex items-center gap-1 rounded border border-border px-1.5 py-0.5 text-[10px] text-foreground hover:bg-surface-hover`,title:`Custom value — click to remove`,children:[e,` ×`]},e))}),e.groups.map(e=>t(`div`,{children:[o(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-muted mb-1`,children:e.fallbackLabel}),o(`div`,{className:`flex flex-wrap gap-1`,children:e.options.map(e=>{let t=s.has(e.value);return o(`button`,{type:`button`,"aria-pressed":t,onClick:()=>l(e.value),className:t?`rounded border border-primary bg-primary/15 px-1.5 py-0.5 text-[10px] text-foreground`:`rounded border border-border px-1.5 py-0.5 text-[10px] text-foreground hover:bg-surface-hover`,children:e.label},e.value)})})]},e.key))]})}function rr({value:e,min:n,max:r,step:i,onChange:a}){return t(`div`,{className:`mt-1 flex items-center gap-2`,children:[o(_,{type:`number`,value:e??``,min:n,max:r,step:i,className:`max-w-[8rem]`,onChange:e=>{let t=e.target.value;if(t===``){a(void 0);return}let n=Number(t);a(Number.isFinite(n)?n:void 0)}}),e!==void 0&&r!==void 0&&o(`input`,{type:`range`,min:n,max:r,step:i,value:e,onChange:e=>a(Number(e.target.value)),className:`flex-1 accent-primary`,"aria-label":`value`})]})}function ir({value:e,onChange:n,options:r}){let{t:i}=T(),a=ar(r??[]),s=a.length>0?a:Et;return t(`div`,{className:`mt-1 space-y-1`,children:[o(d,{value:e??`enter`,options:s.map(e=>({value:e.value,label:i(`notificationRules.crossing.${e.value}`,e.label)})),onChange:e=>n(F(e.target.value))}),o(`p`,{className:Z,children:i(`notificationRules.crossing.hint`,`Which way the subject crosses the zone.`)})]})}function ar(e){let t=[];for(let n of e){let e=n.value===``||n.value===`enter`?Dt:F(n.value);e===void 0||t.some(t=>t.value===e)||t.push({value:e,label:n.label})}return t}function or({deviceIds:e,cameras:t,value:n,onChange:r}){let{options:i,loading:a}=D(e,t);return o(O,{options:i,value:n,onChange:r,loading:a,noFreeText:!0,emptyHint:e.length===0?`Select cameras first — a rule can only use zones those cameras actually have.`:`The selected cameras have no zones. Draw one in the camera’s zone editor first.`,placeholder:``})}function sr({deviceIds:e,value:t,onChange:n}){let{options:r,loading:i}=Je(e);return o(O,{options:r,value:t,onChange:n,loading:i,emptyHint:e.length===0?`Select cameras above to pick their event kinds — or type a token.`:`No event kinds reported for the selected cameras — type a token.`,placeholder:`Event token…`})}var cr=[{value:`became-occupied`,label:`Became occupied`},{value:`became-free`,label:`Became free`},{value:`>=`,label:`Count ≥`},{value:`<=`,label:`Count ≤`}];function lr(e,t){let n=e.map(e=>({value:e.value,label:e.label}));return t===void 0||t===``||n.some(e=>e.value===t)?n:[...n,{value:t,label:`${t} — sub-type, never counts (always 0)`}]}function ur({deviceIds:e,cameras:n,classOptions:r,value:i,onChange:a}){let{options:s,loading:c}=D(e,n),l=i??xe,u=e=>a({...l,...e}),f=l.op===`became-occupied`||l.op===`became-free`,p=lr(r,l.className);return t(`div`,{className:`mt-1 space-y-1.5`,children:[t(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[o(`div`,{className:`min-w-[10rem]`,children:o(d,{value:l.zoneId??``,options:[{value:``,label:c?`Loading zones…`:`— whole frame —`},...s.map(e=>({value:e.value,label:e.label}))],onChange:e=>u({zoneId:e.target.value===``?void 0:e.target.value})})}),o(`div`,{className:`min-w-[9rem]`,children:o(d,{value:l.className??``,options:[{value:``,label:`— any class —`},...p],onChange:e=>u({className:e.target.value===``?void 0:e.target.value})})}),o(`div`,{className:`min-w-[9rem]`,children:o(d,{value:l.op,options:cr.map(e=>({value:e.value,label:e.label})),onChange:e=>{let t=cr.find(t=>t.value===e.target.value);t&&u({op:t.value})}})})]}),t(`div`,{className:`flex flex-wrap items-center gap-3 text-xs text-foreground-subtle`,children:[t(`label`,{className:`flex items-center gap-1`,children:[f?`Threshold`:`Count`,o(_,{type:`number`,min:0,className:`w-16`,value:String(l.count),onChange:e=>u({count:Math.max(0,Number(e.target.value)||0)})})]}),t(`label`,{className:`flex items-center gap-1`,children:[`Hold for`,o(_,{type:`number`,min:0,max:3600,className:`w-16`,value:String(l.sustainSeconds),onChange:e=>u({sustainSeconds:Math.min(3600,Math.max(0,Number(e.target.value)||0))})}),`s`]}),i===void 0?null:o(`button`,{type:`button`,onClick:()=>a(void 0),className:`underline hover:text-foreground`,children:`Clear`})]}),e.length===0&&o(`p`,{className:`text-[11px] text-warning`,children:`No camera picked on the Devices tab: this watches EVERY camera's occupancy, and no zone can be offered until you choose one — a zone id belongs to a camera.`}),o(`p`,{className:`text-[11px] text-foreground-subtle`,children:`Counts confirmed tracked objects from zone analytics. The change must hold for the sustain window before it fires; with no snapshot for the camera or zone the rule never fires.`})]})}var dr=[{value:`label`,label:`Sounds — fires at once`,Icon:g},{value:`level`,label:`Volume — over a window`,Icon:m}];function fr({taxonomy:e,value:n,onChange:i}){let a=he(n),s=e=>i(ne(n,e)),{choices:c,unknownLabels:l}=oe(e,a.labels),u=ie(n)??`label`;return t(`div`,{className:`mt-1 space-y-2`,children:[t(`div`,{className:`flex flex-wrap items-center gap-1`,children:[dr.map(e=>o(`button`,{type:`button`,"aria-pressed":u===e.value,onClick:()=>s({mode:e.value}),className:`rounded border px-2 py-0.5 text-[11px] ${u===e.value?`border-primary bg-primary/15 text-foreground`:`border-border text-foreground-subtle hover:bg-surface-hover`}`,children:t(`span`,{className:`inline-flex items-center gap-1`,children:[o(e.Icon,{className:`h-3 w-3`}),e.label]})},e.value)),n===void 0?null:o(`button`,{type:`button`,onClick:()=>i(void 0),className:`ml-1 text-xs text-foreground-subtle underline hover:text-foreground`,children:`Clear`})]}),u===`label`?t(r,{children:[o(`div`,{className:`flex flex-wrap gap-1`,children:c.map(e=>{let n=De(a.labels,e.value),r=e.unknown?`border-dashed border-warning text-warning`:n?`border-primary bg-primary/15 text-foreground`:`border-border text-foreground hover:bg-surface-hover`;return o(`button`,{type:`button`,"aria-pressed":n,title:e.unknown?`Stored by the rule — not offered by this hub`:void 0,onClick:()=>s({labels:Ee(a.labels,e.value)}),className:`rounded border px-1.5 py-0.5 text-[10px] ${r}`,children:t(`span`,{className:`inline-flex items-center gap-1`,children:[o(p,{iconId:e.iconId,size:12}),e.label]})},e.value)})}),l.length>0&&t(`p`,{className:`text-[10px] text-warning`,children:[`Kept from the rule, unknown to this hub: `,l.join(`, `)]}),t(`div`,{className:`flex flex-wrap items-center gap-3 text-xs text-foreground-subtle`,children:[t(`label`,{className:`flex items-center gap-1`,children:[`Confirm after`,o(_,{type:`number`,min:1,max:20,step:1,className:`w-16`,value:String(a.confirmHits??2),onChange:e=>s({confirmHits:Number(e.target.value)})}),`frames`]}),t(`label`,{className:`flex items-center gap-1`,children:[`within`,o(_,{type:`number`,min:1,max:60,step:1,className:`w-16`,value:String(a.confirmWindowSec??5),onChange:e=>s({confirmWindowSec:Number(e.target.value)})}),`s`]})]}),t(`p`,{className:`text-[11px] text-foreground-subtle`,children:[`Fires when that many labelled frames land inside the window (default`,` `,2,` in `,5,` s). A single-frame false positive never reaches 2; a real episode usually labels two or three frames. The rule's cooldown is the other throttle.`]})]}):t(r,{children:[o(`div`,{className:`flex flex-wrap items-center gap-3 text-xs text-foreground-subtle`,children:t(`label`,{className:`flex items-center gap-1`,children:[`Louder than`,o(_,{type:`number`,min:ye,max:0,step:3,className:`w-20`,value:String(a.dbThreshold??re),onChange:e=>s({dbThreshold:Number(e.target.value)})}),`dBFS`]})}),t(`div`,{className:`flex flex-wrap items-center gap-3 text-xs text-foreground-subtle`,children:[t(`label`,{className:`flex items-center gap-1`,children:[`Hits`,o(_,{type:`number`,min:1,max:100,step:5,className:`w-16`,value:String(a.hitPercent),onChange:e=>s({hitPercent:Number(e.target.value)})}),`% (default `,w.hitPercent,`)`]}),t(`label`,{className:`flex items-center gap-1`,children:[`over`,o(_,{type:`number`,min:1,max:300,step:5,className:`w-16`,value:String(a.samplingSeconds),onChange:e=>s({samplingSeconds:Number(e.target.value)})}),`s (default `,w.samplingSeconds,`)`]})]}),t(`p`,{className:`text-[11px] text-foreground-subtle`,children:[`dBFS is negative-going: 0 is full scale, `,ye,` is silence — so a HIGHER number is a narrower filter. Measured on this hub, a baby crying reads `,`−`,`55 to `,`−`,`26 dBFS, so a floor above `,`−`,`55 excludes most of it. The window must be FULL before it can match.`]})]}),v(n)?o(`p`,{className:`text-[11px] text-warning`,children:`With neither a sound nor a level threshold this can never match — every sample would be a hit, so the engine refuses it rather than notifying on silence.`}):null]})}function pr({value:e,onChange:n}){let r=e?.values??[],i=e?.maxDistance??1,a=e=>n(e.length>0?{values:e,maxDistance:i}:void 0),s=e=>n(r.length>0?{values:r,maxDistance:e}:void 0),c=Xe().filter(e=>!r.includes(e));return t(`div`,{className:`mt-1 space-y-1.5`,children:[o(tr,{value:r,placeholder:`Plate text…`,onChange:a}),c.length>0&&t(`div`,{className:`flex flex-wrap items-center gap-1`,children:[o(`span`,{className:`text-[10px] text-foreground-subtle`,children:`Seen:`}),c.slice(0,12).map(e=>o(`button`,{type:`button`,onClick:()=>a([...r,e]),className:`rounded border border-border px-1.5 py-0.5 text-[10px] text-foreground-subtle hover:bg-surface-hover hover:text-foreground`,children:e},e))]}),t(`label`,{className:`flex items-center gap-2 text-[11px] text-foreground-subtle`,children:[`Max distance`,o(_,{type:`number`,min:0,max:3,step:1,value:i,className:`max-w-[5rem]`,onChange:e=>{let t=Number(e.target.value);s(Number.isFinite(t)?Math.max(0,Math.min(3,t)):1)}})]})]})}function mr({gateable:e,value:n,onChange:r}){let i=Qn(),a=e.find(e=>e.id===n?.deviceId),s=new Set(n?.states??[]),c=e=>{let t=Number(e);if(!Number.isFinite(t)||t===0)return r(void 0);r({deviceId:t,states:[]})},l=e=>{if(n===void 0)return;let t=new Set(s);t.has(e)?t.delete(e):t.add(e),r(t.size===0?void 0:{deviceId:n.deviceId,states:[...t]})};return t(`div`,{className:`mt-1 space-y-2`,children:[o(d,{value:n===void 0?``:String(n.deviceId),options:[{value:``,label:`— no device gate —`},...e.map(e=>({value:String(e.id),label:e.name}))],onChange:e=>c(e.target.value)}),a!==void 0&&o(`div`,{className:`flex flex-wrap gap-1.5`,children:a.states.map(e=>o(`button`,{type:`button`,onClick:()=>l(e),className:s.has(e)?`rounded-md border border-primary bg-primary/10 px-2 py-0.5 text-[11px] text-primary`:`rounded-md border border-border px-2 py-0.5 text-[11px] text-foreground-subtle`,children:i(e)},e))}),a!==void 0&&a.states.length===0&&o(`p`,{className:`text-[10px] text-foreground-subtle mt-0.5`,children:`This device reports no state the gate can read, so it cannot arm a rule.`}),n!==void 0&&o(`p`,{className:`text-[10px] text-foreground-subtle mt-0.5`,children:`The rule is silent while the device is in any other state — including when its state cannot be read at all.`})]})}function hr(e,t){let n=t(e.verdict);return e.latched?`${n} · ${t(`latched`)}`:n}function gr({scenes:e,value:n,onChange:r}){let{t:i}=T(),a=Qn(),s=e.find(e=>e.sceneId===n?.sceneId),c=t=>{if(t===``)return r(void 0);let i=e.find(e=>e.sceneId===t);if(i===void 0)return r(void 0);r({sceneId:t,deviceId:i.deviceId,requiredState:n?.requiredState??`diverged`,...n?.latched===void 0?{}:{latched:n.latched}})},l=e=>{n!==void 0&&r({...n,requiredState:e===`matched`?`matched`:`diverged`})},u=e=>{if(n!==void 0){if(e===``){let{latched:e,...t}=n;return r(t)}r({...n,latched:e===`latched`})}};return e.length===0?o(`p`,{className:Z,children:i(`notificationRules.scene.none`,`No scenes yet — create one on the Scenes page.`)}):t(`div`,{className:`mt-1 space-y-2`,children:[o(d,{value:n?.sceneId??``,options:[{value:``,label:i(`notificationRules.scene.noGate`,`— no scene gate —`)},...e.map(e=>({value:e.sceneId,label:`${e.cameraName} · ${e.label} — ${hr(e,a)}`}))],onChange:e=>c(e.target.value)}),n!==void 0&&t(`div`,{className:`flex flex-wrap items-center gap-2`,children:[t(`label`,{className:`flex items-center gap-2 text-[11px] text-foreground-subtle`,children:[i(`notificationRules.scene.onlyWhile`,`Only while it is`),o(d,{value:n.requiredState,options:[{value:`diverged`,label:a(`diverged`)},{value:`matched`,label:a(`matched`)}],onChange:e=>l(e.target.value)})]}),t(`label`,{className:`flex items-center gap-2 text-[11px] text-foreground-subtle`,children:[i(`notificationRules.scene.read`,`Read`),o(d,{value:n.latched===void 0?``:n.latched?`latched`:`live`,options:[{value:``,label:s===void 0?i(`notificationRules.scene.readOwn`,`The scene's own setting`):`${i(`notificationRules.scene.readOwn`,`The scene's own setting`)} (${a(s.emit)})`},{value:`latched`,label:a(`latched`)},{value:`live`,label:a(`live`)}],onChange:e=>u(e.target.value)})]})]}),s!==void 0&&t(`p`,{className:`text-[10px] text-foreground-subtle mt-0.5`,children:[i(`notificationRules.scene.rightNow`,`Right now:`),` `,hr(s,a)]}),n!==void 0&&s===void 0&&o(`p`,{className:`text-[10px] text-foreground-subtle mt-0.5`,children:i(`notificationRules.scene.missing`,`This scene no longer exists — pick another or remove the gate.`)})]})}var Q={days:[0,1,2,3,4,5,6],minute:480},_r=[{value:1,label:`Mon`},{value:2,label:`Tue`},{value:3,label:`Wed`},{value:4,label:`Thu`},{value:5,label:`Fri`},{value:6,label:`Sat`},{value:0,label:`Sun`}];function vr(e){let t=Math.floor(e/60),n=e%60;return`${String(t).padStart(2,`0`)}:${String(n).padStart(2,`0`)}`}function yr(e){let[t,n]=e.split(`:`),r=Number(t)*60+Number(n);return Number.isFinite(r)?Math.max(0,Math.min(1439,r)):0}function br(e){if(typeof e!=`object`||!e||!(`data`in e))return;let t=e.data;if(!(typeof t!=`object`||!t||!(`code`in t)))return typeof t.code==`string`?t.code:void 0}function xr(e){let t=Object.entries(e).map(([e,t])=>`${e} ${String(t)}`);return t.length>0?`Left out by this rule's filters or a camera mute: ${t.join(`, `)}.`:null}function Sr(e,t,n,r=`rule`){if(e===`error`)return br(n)===`NOT_FOUND`?{lines:[`This hub does not serve summary rules yet — update @camstack/server first. A rule saved now would be stored without its summary, and stay instant.`]}:{lines:[`The preview could not be read: ${n instanceof Error?n.message:String(n)}`]};if(e!==`success`||t===void 0)return null;let i=[];if(r===`section`&&t.split===void 0&&i.push(`This hub does not send per-category summaries yet — update @camstack/server first. Until then it sends one message.`),t.empty)i.push(`Nothing to report right now — no notification would be sent.`);else if(t.split===`section`&&t.rows!==void 0){let e=t.rows.length;i.push(`${String(e)} notification${e===1?``:`s`} would be sent now, one per category:`);for(let e of t.rows)i.push(`${e.title}\n${e.text}`)}else i.push(`${String(t.count)} item(s) would be sent now:\n${t.text}`);let a=xr(t.dropped);return a!==null&&i.push(a),t.excludedGroups.includes(`backups-exports`)&&i.push(`Backups and exports are completed jobs, not a state — they are not in a summary.`),{lines:i}}function Cr(e,t){return{...e,schedule:t}}function wr(e,t){let{split:n,...r}=e;return t===`section`?{...r,split:t}:r}function $(e){return vr(e)}function Tr(e){return yr(e)}function Er(){return{days:[1,2,3,4,5],startMinute:540,endMinute:1080}}function Dr(e){return{days:[...Q.days],minute:e}}var Or=`Always active — add a window to restrict when the rule fires.`;function kr({value:e,onChange:t,mode:n=`windows`,defaultMinute:r=Q.minute,emptyHint:i}){return n===`times`?o(jr,{value:e,onChange:t,defaultMinute:r}):o(Ar,{value:e,onChange:t,emptyHint:i??Or})}function Ar({value:e,onChange:n,emptyHint:r}){let i=e?.windows??[],a=e?.invert??!1,s=(t,r)=>{if(t.length===0){n(void 0);return}n({windows:t,...r?{invert:!0}:{},...e?.timezone?{timezone:e.timezone}:{}})},c=()=>s([...i,Er()],a),l=e=>s(i.filter((t,n)=>n!==e),a),u=(e,t)=>s(i.map((n,r)=>r===e?t:n),a);return t(`div`,{className:`mt-1 space-y-2`,"data-testid":`schedule-field-windows`,children:[i.length===0?o(`p`,{className:Z,children:r}):i.map((e,t)=>o(Mr,{window:e,onChange:e=>u(t,e),onRemove:()=>l(t)},t)),t(`div`,{className:`flex items-center gap-3`,children:[t(`button`,{type:`button`,onClick:c,className:`flex items-center gap-1 rounded-md bg-surface-hover px-2 py-1 text-[11px] text-foreground-subtle hover:text-foreground`,children:[o(f,{className:`h-3 w-3`}),` Add window`]}),i.length>0&&t(`label`,{className:`flex items-center gap-1.5 text-[11px] text-foreground-subtle`,children:[o(`input`,{type:`checkbox`,checked:a,onChange:e=>s([...i],e.target.checked),className:`accent-primary`}),`Active outside the windows`]})]})]})}function jr({value:e,onChange:n,defaultMinute:r}){let i=e?.timezone,a=e===void 0?{times:[],approximated:!1}:ge(e);if(a===null)return t(`div`,{className:`mt-1 space-y-2`,"data-testid":`schedule-field-times-fallback`,children:[o(`p`,{className:Z,children:`Inverted schedule — shown as bands. Clear the invert flag (or the windows) to author punctual times.`}),o(Ar,{value:e,onChange:n,emptyHint:Or})]});let s=a.times,c=e=>{if(e.length===0){n(void 0);return}n(pe(e,i))};return t(`div`,{className:`mt-1 space-y-2`,"data-testid":`schedule-field-times`,children:[a.approximated&&o(`p`,{className:`text-[10px] text-foreground-subtle mt-0.5`,"data-testid":`schedule-field-times-approximated`,children:`Shown as send-at times from each window's end (when the summary fires). Edit or save to store them as punctual one-minute windows.`}),s.length===0?o(`p`,{className:Z,children:`No times yet — add one to send on those days at that clock time.`}):s.map((e,t)=>o(Nr,{time:e,index:t,onChange:e=>c(s.map((n,r)=>r===t?e:n)),onRemove:s.length>1?()=>c(s.filter((e,n)=>n!==t)):void 0},t)),t(`button`,{type:`button`,onClick:()=>c([...s,Dr(r)]),className:`flex items-center gap-1 rounded-md bg-surface-hover px-2 py-1 text-[11px] text-foreground-subtle hover:text-foreground`,"data-testid":`schedule-field-add-time`,children:[o(f,{className:`h-3 w-3`}),` Add a time`]})]})}function Mr({window:e,onChange:n,onRemove:r}){return t(`div`,{className:`space-y-1.5 rounded-md border border-border p-2`,children:[t(`div`,{className:`flex items-center gap-2 text-xs`,children:[o(`input`,{type:`time`,value:$(e.startMinute),onChange:t=>n({...e,startMinute:Tr(t.target.value)}),className:`rounded-md border border-border bg-background px-1 py-0.5`}),o(`span`,{className:`text-foreground-subtle`,children:`→`}),o(`input`,{type:`time`,value:$(e.endMinute),onChange:t=>n({...e,endMinute:Tr(t.target.value)}),className:`rounded-md border border-border bg-background px-1 py-0.5`}),o(`span`,{className:`flex-1`}),o(`button`,{type:`button`,onClick:r,"aria-label":`Remove window`,className:`text-foreground-subtle hover:text-danger`,children:o(c,{className:`h-3.5 w-3.5`})})]}),o(Pr,{days:e.days,onToggle:t=>{let r=e.days.includes(t)?e.days.filter(e=>e!==t):[...e.days,t];r.length!==0&&n({...e,days:r})}})]})}function Nr({time:e,index:n,onChange:r,onRemove:i}){return t(`div`,{className:`space-y-1.5 rounded-md border border-border p-2`,children:[t(`div`,{className:`flex items-center gap-2 text-xs`,children:[o(`span`,{className:`text-foreground-subtle`,children:`At`}),o(`input`,{type:`time`,value:vr(e.minute),onChange:t=>r({...e,minute:yr(t.target.value)}),className:`rounded-md border border-border bg-background px-1 py-0.5`,"data-testid":`schedule-field-time-${String(n)}`}),o(`span`,{className:`flex-1`}),i!==void 0&&o(`button`,{type:`button`,onClick:i,"aria-label":`Remove time`,className:`text-foreground-subtle hover:text-danger`,children:o(c,{className:`h-3.5 w-3.5`})})]}),o(Pr,{days:e.days,onToggle:t=>{let n=e.days.includes(t)?e.days.filter(e=>e!==t):[...e.days,t];n.length!==0&&r({...e,days:n})}})]})}function Pr({days:e,onToggle:t}){return o(`div`,{className:`flex flex-wrap gap-1`,children:_r.map(n=>o(`button`,{type:`button`,onClick:()=>t(n.value),className:`rounded px-1.5 py-0.5 text-[10px] ${e.includes(n.value)?`bg-primary text-primary-foreground`:`bg-surface-hover text-foreground-subtle`}`,children:n.label},n.value))})}export{Kt as $,O as $t,un as A,at as At,yn as B,st as Bt,Xn as C,pt as Ct,Hn as D,_t as Dt,Un as E,M as Et,hn as F,Qe as Ft,K as G,mt as Gt,dn as H,jt as Ht,Tn as I,$e as It,rn as J,bt as Jt,q as K,et as Kt,mn as L,kt as Lt,Mn as M,St as Mt,bn as N,P as Nt,Ln as O,Ct as Ot,vn as P,dt as Pt,nn as Q,tt as Qt,Y as R,it as Rt,Jn as S,ut as St,Wn as T,A as Tt,wn as U,ft as Ut,xn as V,xt as Vt,cn as W,gt as Wt,on as X,yt as Xt,an as Y,vt as Yt,sn as Z,Tt as Zt,tr as _,Ke as _n,B as _t,wr as a,We as an,Yt as at,Yn as b,At as bt,er as c,Ve as cn,Vt as ct,Z as d,Ge as dn,Ht as dt,Ye as en,G as et,$n as f,ze as fn,zt as ft,gr as g,qe as gn,L as gt,pr as h,Ue as hn,V as ht,Cr as i,Me as in,Zt as it,Dn as j,wt as jt,ln as k,Ot as kt,mr as l,Re as ln,It as lt,ur as m,Ne as mn,Wt as mt,Q as n,He as nn,$t as nt,fr as o,Pe as on,Xt as ot,rr as p,Ie as pn,Ut as pt,J as q,nt as qt,Sr as r,Le as rn,W as rt,ir as s,Fe as sn,Jt as st,kr as t,D as tn,Qt as tt,sr as u,Be as un,Gt as ut,nr as v,Lt as vt,Kn as w,j as wt,qn as x,ht as xt,or as y,N as yt,Sn as z,ot as zt};
|
|
1
|
+
import{Q as e,S as t,W as n,b as r,i,q as a,x as o}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{at as s,st as c}from"./player-overlays-CVsVEZkx.js";import{Ha as l,Lc as u,Nn as d,Od as f,Xn as p,Zf as m,d as h,hd as g,ju as ee,pu as _,zc as te}from"./src-DBOD88Il.js";import{At as ne,Ct as re,Dt as ie,Er as ae,Et as oe,F as se,G as ce,I as le,K as ue,Ln as de,M as fe,N as pe,O as me,Ot as he,P as ge,R as _e,Rn as ve,St as ye,Tt as v,ct as y,dt as be,et as xe,ft as Se,gt as Ce,ht as we,it as Te,jt as Ee,kt as De,lt as b,nt as Oe,pt as ke,rt as x,st as S,tt as Ae,vt as C,wt as w,yt as je}from"./client-DdTCFotl.js";import{t as T}from"./useTranslation-Bc5yH9V9.js";e();function E(e){return t=>Object.prototype.hasOwnProperty.call(e,t)}var Me=E({devices:!0}),Ne=E({classes:!0,classesExclude:!0,labelEquals:!0,identities:!0,identitiesExclude:!0,eventTypeTokens:!0,sensorKinds:!0}),Pe=E({minConfidence:!0,minImportance:!0,minLabelConfidence:!0}),Fe=E({minDwellSeconds:!0}),Ie=E({source:!0}),Le=E({crossing:!0}),Re=E({packagePhase:!0}),ze=E({sensorTransition:!0}),Be=E({plates:!0}),Ve=E({occupancy:!0}),He=E({audio:!0}),Ue=E({systemEvent:!0}),We=E({deviceState:!0}),Ge=E({scene:!0});function Ke(e,t){let n=e[t];return Array.isArray(n)?n:[]}function qe(e,t){let n=e[t];return typeof n==`number`?n:void 0}function D(e,t){let r=s().trpcClient,a=i({queries:e.map(e=>({queryKey:[[`nc-pickers`,`zones`],{deviceId:e}],staleTime:3e4,queryFn:async()=>({deviceId:e,zones:(await r.zones.listZones.query({deviceId:e})).map(e=>({id:e.id,name:e.name}))})}))});return n(()=>{let e=[],n=new Set;for(let r of a){if(!r.data)continue;let i=t.find(e=>e.id===r.data.deviceId)?.name;for(let t of r.data.zones)n.has(t.id)||(n.add(t.id),e.push({value:t.id,label:t.name,...i===void 0?{}:{hint:i}}))}return{options:e,loading:a.some(e=>e.isLoading),failed:a.some(e=>e.isError)}},[a,t])}function Je(e){let t=s().trpcClient,r=i({queries:e.map(e=>({queryKey:[[`nc-pickers`,`event-kinds`],{deviceId:e}],staleTime:6e4,queryFn:async()=>(await t.pipelineAnalytics.listEventKinds.query({deviceId:e})).map(e=>({kind:e.kind,label:e.label}))}))});return n(()=>{let e=new Map;for(let t of r)for(let n of t.data??[])e.has(n.kind)||e.set(n.kind,n.label);let t=[...e.entries()].map(([e,t])=>({value:e,label:t}));return t.sort((e,t)=>e.label.localeCompare(t.label)),{options:t,loading:r.some(e=>e.isLoading)}},[r])}function Ye(){let e=l();return n(()=>({options:(e.data??[]).map(e=>({value:e.id,label:e.name})),loading:e.isLoading,failed:e.isError===!0}),[e.data,e.isLoading,e.isError])}function Xe(){let e=u({limit:200}),t=te();return n(()=>{let n=new Set;for(let e of t.data??[])e.name.trim().length>0&&n.add(e.name);let r=new Set;for(let t of e.data??[])t.text.trim().length>0&&r.add(t.text);return[...[...n].sort(),...[...r].sort()]},[e.data,t.data])}function O({options:e,value:r,onChange:i,loading:s,emptyHint:c,placeholder:l,noFreeText:u=!1}){let[d,f]=a(``),p=n(()=>new Set(e.map(e=>e.value)),[e]),m=n(()=>new Set(r),[r]),h=r.filter(e=>!p.has(e)),g=e=>{i(m.has(e)?r.filter(t=>t!==e):[...r,e])},ee=()=>{let e=d.trim();e.length===0||r.includes(e)||(i([...r,e]),f(``))};return t(`div`,{className:`mt-1 space-y-1.5`,children:[h.length>0&&o(`div`,{className:`flex flex-wrap gap-1`,children:h.map(e=>t(`button`,{type:`button`,onClick:()=>i(r.filter(t=>t!==e)),className:`inline-flex items-center gap-1 rounded border border-border px-1.5 py-0.5 text-[10px] text-foreground hover:bg-surface-hover`,title:`Custom value — click to remove`,children:[e,` ×`]},e))}),e.length>0?o(`div`,{className:`max-h-40 overflow-y-auto rounded-md border border-border divide-y divide-border`,children:e.map(e=>t(`label`,{className:`flex items-center gap-2.5 px-3 py-1.5 text-xs text-foreground cursor-pointer hover:bg-surface-hover`,children:[o(`input`,{type:`checkbox`,checked:m.has(e.value),onChange:()=>g(e.value),className:`accent-primary`}),o(`span`,{className:`flex-1 truncate`,children:e.label}),e.hint!==void 0&&o(`span`,{className:`text-[10px] text-foreground-subtle`,children:e.hint})]},e.value))}):o(`p`,{className:`text-[10px] text-foreground-subtle`,children:s===!0?`Loading…`:c}),!u&&o(`input`,{value:d,onChange:e=>f(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),ee())},placeholder:l,className:`w-full rounded-md border border-border bg-background px-2 py-1 text-xs text-foreground placeholder:text-foreground-subtle`})]})}var k=[{value:`immediate`,label:`Immediate`,hint:`Fires on the first matching detection of a track (lowest latency).`},{value:`track-end`,label:`Track end`,hint:`Evaluates the finalised track record when it closes.`},{value:`device-event`,label:`Device event`,hint:`Doorbell press, sensor state change, or an occupancy edge on a linked device.`},{value:`package-event`,label:`Package event`,hint:`A parcel delivery or pick-up.`},{value:`system-event`,label:`System event`,hint:`The installation itself: a camera or stream going offline, a node leaving the cluster, an addon or server update becoming available.`}],A=`Immediate, grouped`,Ze=k.flatMap(e=>e.value===`immediate`?[e,{value:`immediate-grouped`,label:A,hint:`Waits for subjects to be recognised, then sends one message with a mosaic, one picture per subject.`}]:[e]);function Qe(e){return e.groupingSec!==void 0&&S(e)?`immediate-grouped`:e.delivery}function $e(e){let t=(e.delivery===`immediate`||e.delivery===`track-end`)&&S({delivery:`immediate`,conditions:e.conditions});return Ze.filter(e=>e.value!==`immediate-grouped`||t)}function et(e){return Ze.find(t=>t.value===e)?.value}function tt(e,t=A){return Qe(e)===`immediate-grouped`?`${t} · ${String(e.groupingSec)} s`:rt(e.delivery)}function nt(e){if(e.trim().length===0)return;let t=Number(e);return Number.isFinite(t)&&t>=0?Math.trunc(t):void 0}function rt(e){return k.find(t=>t.value===e)?.label??e}function it(e){return k.some(t=>t.value===e)}var at=[{key:`all`,label:`All rules`,blurb:`Every notification rule — event-driven and scheduled producers. Tabs filter this same list; pick the type under New rule when creating from here.`,newRuleLabel:`New rule`,emptyHint:`No rules yet. Click "New rule" and pick a kind (Detection, Summary, Calendar events, …).`,creatable:!0},{key:`detection`,label:`Detections`,blurb:`Rules driven by what the cameras SEE — detections, tracks and package events. Doorbell presses and other sensor changes have their own section now (operator ruling, 2026-10-01).`,newRuleLabel:`New detection rule`,emptyHint:`No detection rules yet. Click "New detection rule" to author one.`,creatable:!0},{key:`sensor`,label:`Sensors`,blurb:`Rules driven by a device or sensor CHANGING STATE — a doorbell press, a linked sensor opening or closing. The picture is one snapshot of the camera the sensor is attributed to; there is no media choice to make.`,newRuleLabel:`New sensor rule`,emptyHint:`No sensor rules yet. Click "New sensor rule" to be told when a doorbell is pressed or a linked sensor changes.`,creatable:!0},{key:`audio`,label:`Sound`,blurb:`Rules on what the cameras HEAR: a sustained window of sound loud enough, or classified as one of the sounds you name. A sound rule is an immediate rule carrying the sound condition — it fires only on a confirmed sampling window, never on a picture.`,newRuleLabel:`New sound rule`,emptyHint:`No sound rules yet. Click "New sound rule" — it opens on the sound condition already filled in with a level threshold, so you only have to name the sounds and the targets.`,creatable:!0},{key:`occupancy`,label:`Occupancy`,blurb:`Rules on how many objects are in a camera frame or a zone, and for how long: "the driveway became occupied", "the garden emptied". An occupancy rule is a device-event rule carrying the occupancy condition.`,newRuleLabel:`New occupancy rule`,emptyHint:`No occupancy rules yet. Click "New occupancy rule" — it opens on the occupancy condition; pick the camera on the Devices tab, then the zone and the count.`,creatable:!0},{key:`device-events`,label:`Device events`,blurb:`Rules about your devices: offline or back, switched off or on, a stream dropping, a battery or consumable running low, a camera detecting nothing. These carry no image.`,newRuleLabel:`New device-event rule`,emptyHint:`No device-event rules yet. Click "New device-event rule" to be told when a device drops, a battery runs low or a camera goes blind.`,creatable:!0},{key:`system`,label:`System events`,blurb:`Rules about the installation itself: a node leaving the cluster, an addon crash-looping, an update available or installed, a backup or export finishing. These carry no image and are not tied to a detection.`,newRuleLabel:`New system rule`,emptyHint:`No system rules yet. Click "New system rule" to be told when a node leaves, an update lands or a backup finishes.`,creatable:!0},{key:`alarm`,label:`Alarm`,blurb:`Rules about the alarm panel: arming, armed, triggered, disarmed, and the refusals in between.`,newRuleLabel:`New alarm rule`,emptyHint:`No alarm rules yet. Click "New alarm rule" to be told when the alarm arms, goes off or is disarmed.`,creatable:!0},{key:`mixed`,label:`To recreate`,blurb:`System rules authored before the three families existed. Each mixes families and keeps firing as it is, but it cannot be edited: recreate it as one rule per family (Device events, System events, Alarm). Open none of them: Delete each once its replacements exist.`,newRuleLabel:`New rule`,emptyHint:`Nothing to recreate.`,creatable:!1}];function ot(e){return b(y(e)).editable}function st(e){return Te(ct(e))}function ct(e){switch(e){case`device-events`:case`system`:case`alarm`:case`mixed`:return e;default:return}}var lt=new Map([[0,`No cooldown`],[60,`1 minute`],[3600,`1 hour`]]),ut=86400;function dt(e){let t=lt.get(e);return t===void 0?e%3600==0?`${e/3600} hours`:e%60==0?`${e/60} minutes`:`${e} seconds`:t}function ft(e){if(e.trim().length===0)return;let t=Number(e);return Number.isFinite(t)&&t>=0?Math.trunc(t):void 0}var pt=[{value:`rule-device`,label:`Per device`},{value:`rule`,label:`Whole rule (one window for every device)`}];function mt(e){return pt.find(t=>t.value===e)?.value}var ht=[{value:`per-class`,label:`Separate windows per class (default)`},{value:`shared`,label:`Shared across classes`}];function gt(e){return ht.find(t=>t.value===e)?.value}var _t=[{value:`best`,label:`Best available image`,description:`The best subject crop available when the notification is sent.`},{value:`best-matching`,label:`Best matching image`,description:`The image that explains why the rule fired — the face crop for an identity rule, the plate crop for a plate rule; falls back to the best image otherwise.`},{value:`keyFrame`,label:`Key frame`,description:`The clean full scene frame with no subject box.`},{value:`none`,label:`No attachment`,description:`Send the notification with no image.`}];function vt(e){return _t.find(t=>t.value===e)?.value}var j=[{value:``,label:`Automatic`},{value:`cropped`,label:`Cropped on the subject`},{value:`full`,label:`Full frame`},{value:`boxed`,label:`Full frame with boxes`}];function yt(e){let t=j.find(t=>t.value===e)?.value;return t===``?void 0:t}var M=[{value:``,label:`Mosaic of every linked camera (default)`},{value:`mosaic`,label:`Mosaic of every linked camera`},{value:`each`,label:`One image per camera (first camera where only one is allowed)`}];function bt(e){let t=M.find(t=>t.value===e)?.value;return t===``?void 0:t}var N=[{value:``,label:`Lowest available`},{value:`low`,label:`Low`},{value:`mid`,label:`Medium`},{value:`high`,label:`High`}];function xt(e){let t=N.find(t=>t.value===e)?.value;return t===``?void 0:t}var St=[{value:`any`,label:`Any source`},{value:`pipeline`,label:`Pipeline`},{value:`onboard`,label:`Onboard (camera)`},{value:`sensor`,label:`Sensor`}],Ct=[{value:`delivered`,label:`Delivered`},{value:`picked-up`,label:`Picked up`},{value:`both`,label:`Both`}],wt=[{value:``,label:`It triggers and when it clears`},{value:`raised`,label:`Only when it triggers`},{value:`cleared`,label:`Only when it clears`}];function Tt(e){return e===`raised`||e===`cleared`?e:void 0}function P(e,t){return e===`sensorTransition`?ue(t.sensorKinds):!0}var Et=[{value:`enter`,label:`Entering`},{value:`exit`,label:`Leaving`},{value:`any`,label:`Entering or leaving`}],Dt=`enter`;function F(e){return e===`exit`||e===`any`?e:void 0}var Ot=[{value:1,label:`1 — Min`},{value:2,label:`2 — Low`},{value:3,label:`3 — Default`},{value:4,label:`4 — High`},{value:5,label:`5 — Max`}];function kt(e,t){return e.options&&e.options.length>0?e.options:t}var At=[{value:``,label:`Default (2×)`},{value:`1`,label:`1× — real time`},{value:`2`,label:`2×`},{value:`3`,label:`3×`},{value:`4`,label:`4×`},{value:`6`,label:`6×`},{value:`8`,label:`8×`}];function jt(e){if(e===``)return;let t=Number(e);return Number.isFinite(t)&&t>=1&&t<=8?t:void 0}var Mt=new Map(Object.entries({"device-offline":`Device offline`,"device-online":`Device online`,"device-disabled":`Device switched off`,"device-enabled":`Device switched on`,"stream-offline":`Stream offline`,"stream-online":`Stream online`,"device-battery-low":`Battery low`,"device-battery-normal":`Battery back to normal`,"device-consumable-low":`Consumable low`,"device-consumable-normal":`Consumable back to normal`,"device-tank-low":`Tank low (water, detergent)`,"device-tank-full":`Tank full (dirty water, dust)`,"device-tank-normal":`Tank back to normal`,"detection-blind":`Camera detecting nothing`,"node-offline":`Node offline`,"node-online":`Node online`,"node-restarting":`Node restarting`,"node-updating":`Node updating (restart imminent)`,"node-inference-unavailable":`Node has no usable inference device`,"addon-crash-loop":`Addon stopped after repeated crashes`,"addon-update-available":`Addon update available`,"addon-updated":`Addons updated`,"server-update-available":`Server update available`,"server-updated":`Server updated`,"wrapper-update-available":`Container / app update available`,"export-completed":`Export completed`,"backup-completed":`Backup completed`,"alarm-arm-refused":`Alarm arm refused (something is open)`,"alarm-check-failed":`Alarm check failed (armed anyway)`,"alarm-arming":`Alarm arming (exit delay)`,"alarm-armed":`Alarm armed`,"alarm-pending":`Alarm entry delay started`,"alarm-triggered":`Alarm triggered`,"alarm-rearmed":`Alarm re-armed after siren`,"alarm-sensor-bypass":`Alarm sensor bypass`,"alarm-disarmed":`Alarm disarmed`}));function Nt(e){return Mt.get(e)}var Pt={"device-state":`A device the hub can no longer reach, or that came back. Switched off / on is a device an operator turned off or back on — not a fault, a choice.`,streams:`A stream that stopped or came back.`,battery:`A battery below the cluster threshold, and (optionally) its return to normal. Devices with a binary low-battery indicator are judged by the indicator, not by the percentage.`,consumables:`A consumable — filter, brush, bag — at or below this rule’s threshold, or that the device reports as due for replacement, and (optionally) its return to normal after a change. A device that only says "replace" is judged by that, not by a percentage.`,tanks:`A robot vacuum tank the device reports as running low (clean water, detergent) or full (dirty water, dust bin), and (optionally) its return to normal once refilled or emptied.`,"detection-blind":`A camera that is running and being analysed, but detects nothing — up, and producing no work.`,nodes:`An agent or worker node joining or leaving the cluster, or an online node whose inference devices all went away.`,addons:`An addon the hub has stopped restarting after repeated crashes.`,"addon-updates":`A newer version of an addon, or an addon update that just finished.`,updates:`A newer version of the server itself, or of the container / app the node runs inside, is available — or a server update just finished.`,"backups-exports":`A scheduled or manual backup of the hub finished, or a footage export finished rendering.`,alarm:`The alarm panel refusing to arm, arming, armed, counting down to a siren, going off, re-arming, excluding an open sensor, or being disarmed.`},I=Ce.map(e=>({id:e.id,family:e.family,label:e.label,hint:Pt[e.id]??``,kinds:e.kinds.flatMap(e=>{let t=Nt(e);return t===void 0?[]:[{value:e,label:t}]})}));function L(e){return I.filter(t=>t.family===e)}function R(e){let t=be(e).conditions.systemEvent;return t===void 0?{kinds:(L(e)[0]?.kinds??[]).map(e=>e.value)}:{...t,kinds:[...t.kinds]}}var z=I.flatMap(e=>e.kinds);function B(e){return z.find(t=>t.value===e)?.label??e}function Ft(e){return{devices:C(e,`deviceIds`),deviceTypes:C(e,`deviceTypes`),nodes:C(e,`nodeIds`),packages:C(e,`packageNames`),consumableThreshold:C(e,`consumableLowPercent`)}}function V(e,t){let n=we[e],r=Ft(t);return{devices:n.includes(`deviceIds`)&&r.devices,excludeDevices:n.includes(`excludeDeviceIds`)&&r.devices,deviceTypes:n.includes(`deviceTypes`)&&r.deviceTypes,nodes:n.includes(`nodeIds`)&&r.nodes,packages:n.includes(`packageNames`)&&r.packages,consumableThreshold:n.includes(`consumableLowPercent`)&&r.consumableThreshold}}var It=Object.values(ae).map(e=>({value:e,label:H(e)})).toSorted((e,t)=>e.label.localeCompare(t.label));function H(e){let t=e.replaceAll(`-`,` `);return t.charAt(0).toUpperCase()+t.slice(1)}function Lt(e,t,n){if(!L(n).some(e=>e.kinds.some(e=>e.value===t)))return e;let r=e?.kinds??[];return r.length===1&&r[0]===t?e:Bt(e,r.includes(t)?r.filter(e=>e!==t):z.filter(e=>e.value===t||r.includes(e.value)).map(e=>e.value),n)}function Rt(e,t){return t===void 0?void 0:Bt(t,t.kinds,e)}function zt(e,t){let n=e?.kinds??[];if(n.length===0)return;let r=U(t,`deviceIds`,e?.deviceIds),i=U(t,`excludeDeviceIds`,e?.excludeDeviceIds),a=U(t,`deviceTypes`,e?.deviceTypes),o=U(t,`nodeIds`,e?.nodeIds),s=U(t,`packageNames`,e?.packageNames),c=Object.prototype.hasOwnProperty.call(t,`consumableLowPercent`)?t.consumableLowPercent:e?.consumableLowPercent;return{kinds:[...n],...r===void 0?{}:{deviceIds:[...r]},...i===void 0?{}:{excludeDeviceIds:[...i]},...a===void 0?{}:{deviceTypes:[...a]},...o===void 0?{}:{nodeIds:[...o]},...s===void 0?{}:{packageNames:[...s]},...c===void 0?{}:{consumableLowPercent:c}}}function U(e,t,n){let r=Object.prototype.hasOwnProperty.call(e,t)?e[t]:n;return r!==void 0&&r.length===0?void 0:r}function Bt(e,t,n){let r=V(n,t),i=r.devices?e?.deviceIds:void 0,a=r.excludeDevices?e?.excludeDeviceIds:void 0,o=r.deviceTypes?e?.deviceTypes:void 0,s=r.nodes?e?.nodeIds:void 0,c=r.packages?e?.packageNames:void 0,l=r.consumableThreshold?e?.consumableLowPercent:void 0;return{kinds:[...t],...i&&i.length>0?{deviceIds:[...i]}:{},...a&&a.length>0?{excludeDeviceIds:[...a]}:{},...o&&o.length>0?{deviceTypes:[...o]}:{},...s&&s.length>0?{nodeIds:[...s]}:{},...c&&c.length>0?{packageNames:[...c]}:{},...l===void 0?{}:{consumableLowPercent:l}}}var Vt=95;function Ht(e){let t=e.trim();if(t===``)return{kind:`clear`};let n=Number(t);return Number.isInteger(n)&&n>=1&&n<=Vt?{kind:`set`,value:n}:{kind:`invalid`}}function Ut(e,t=2){if(e===void 0||e.length===0)return`No event selected`;let n=e.slice(0,t).map(B).join(`, `),r=e.length-Math.min(t,e.length);return r>0?`${n} +${r}`:n}function Wt(e){if(e===void 0)return`—`;let t=[],n=e.deviceIds?.length??0,r=e.deviceTypes?.length??0,i=e.nodeIds?.length??0,a=e.packageNames?.length??0,o=e.excludeDeviceIds?.length??0;r>0&&t.push(e.deviceTypes?.map(H).join(`, `)??``),n>0&&t.push(`${n} device${n===1?``:`s`}`),i>0&&t.push(`${i} node${i===1?``:`s`}`),a>0&&t.push(`${a} package${a===1?``:`s`}`);let s=o>0?`except ${o} device${o===1?``:`s`}`:null,c=e.consumableLowPercent===void 0?[]:[`consumables at ${e.consumableLowPercent}%`];return t.length===0?[s===null?`Everything`:`Everything ${s}`,...c].join(` · `):[...t,...s===null?[]:[s],...c].join(` · `)}function Gt(e){return e===void 0||(e.deviceTypes?.length??0)===0?!1:e.kinds.some(e=>de.includes(e))}var Kt=[`all`,`only`,`except`];function qt(e,t){return(e??[]).length>0?`only`:(t??[]).length>0?`except`:`all`}function W(e,t){let n=[...e??[]],r=[...t??[]];return{mode:qt(n,r),include:n,exclude:r,legacyBoth:n.length>0&&r.length>0}}function Jt(e,t){return{...e,mode:t}}function Yt(e){switch(e.mode){case`only`:return e.include;case`except`:return e.exclude;case`all`:return[]}}function Xt(e,t){switch(e.mode){case`only`:return{...e,include:[...t]};case`except`:return{...e,exclude:[...t]};case`all`:return e}}function Zt(e){return e.mode===`only`&&e.legacyBoth?e.exclude:[]}function Qt(e){return{...e,exclude:[],legacyBoth:!1}}function G(e){switch(e.mode){case`all`:return{};case`except`:return e.exclude.length>0?{exclude:[...e.exclude]}:{};case`only`:{let t=Zt(e);return{...e.include.length>0?{include:[...e.include]}:{},...t.length>0?{exclude:[...t]}:{}}}}}function $t(e){let t=G(e),n=t.include??[],r=t.exclude??[];return[...e.include.filter(e=>!n.includes(e)),...e.exclude.filter(e=>!r.includes(e))]}var K=[`onActivation`,`onDeactivation`,`onTrigger`,`onTriggerOff`],q={onActivation:{title:`On activation`,hint:`Runs when the rule is turned on.`},onDeactivation:{title:`On deactivation`,hint:`Runs when the rule is turned off.`},onTrigger:{title:`On trigger`,hint:`Runs on a positive / raised match.`},onTriggerOff:{title:`On trigger off`,hint:`Runs on a clear / leave match. Delivery types without a clear edge never fire this.`}},en={onActivation:[],onDeactivation:[],onTrigger:[],onTriggerOff:[],buttons:[]};function tn(e){return e===void 0?en:{onActivation:[...e.onActivation??[]],onDeactivation:[...e.onDeactivation??[]],onTrigger:[...e.onTrigger??[]],onTriggerOff:[...e.onTriggerOff??[]],buttons:[...e.buttons??[]]}}function J(e){let t=e.buttons.filter(e=>e.id.trim()!==``&&e.label.trim()!==``&&e.sequenceId.trim()!==``),n={onActivation:e.onActivation,onDeactivation:e.onDeactivation,onTrigger:e.onTrigger,onTriggerOff:e.onTriggerOff};if(!(!K.some(e=>n[e].length>0)&&t.length===0))return{...n.onActivation.length>0?{onActivation:[...n.onActivation]}:{},...n.onDeactivation.length>0?{onDeactivation:[...n.onDeactivation]}:{},...n.onTrigger.length>0?{onTrigger:[...n.onTrigger]}:{},...n.onTriggerOff.length>0?{onTriggerOff:[...n.onTriggerOff]}:{},...t.length>0?{buttons:t}:{}}}function nn(e,t){let n=[];for(let r of K){let i=e[r];i.length>4&&n.push({kind:`too-many`,message:`${q[r].title} has more than 4 bindings.`});for(let e of i)e.kind===`sequence`&&!t.has(e.sequenceId)&&n.push({kind:`unknown-sequence`,message:`${q[r].title} points at a sequence that does not exist.`})}let r=new Set;for(let i of e.buttons){let e=i.id.trim();e!==``&&(r.has(e)&&n.push({kind:`duplicate-button`,message:`Two buttons share the id "${e}". The id is what the audit line names when one is tapped.`}),r.add(e),t.has(i.sequenceId.trim())||n.push({kind:`unknown-sequence`,message:`"${i.label||e}" points at a sequence that does not exist. It would never appear on a notification.`}))}return n}function rn(e,t){return{id:`action-${String(e+1)}`,label:`Action`,sequenceId:t}}function an(){return{kind:`do`,action:{kind:`cap`,deviceId:0,cap:``,method:``}}}function on(e){return{kind:`sequence`,sequenceId:e}}function sn(){return{kind:`wait`,seconds:5}}var cn=[{value:`acknowledge`,label:`Acknowledge`},{value:`dismiss`,label:`Dismiss`},{value:`silence`,label:`Silence`},{value:`snooze`,label:`Snooze`},{value:`view`,label:`View`},{value:`play`,label:`Play`},{value:`camera`,label:`Camera`},{value:`open`,label:`Open`},{value:`close`,label:`Close`},{value:`unlock`,label:`Unlock`},{value:`lock`,label:`Lock`},{value:`disarm`,label:`Disarm`},{value:`arm`,label:`Arm`},{value:`arm-home`,label:`Arm — home`},{value:`arm-away`,label:`Arm — away`},{value:`arm-night`,label:`Arm — night`},{value:`light`,label:`Light`},{value:`alert`,label:`Alert`}],ln=[10,30,60],un=[5,10,15,30,60,120,240,480];function dn(e){return e>=60&&e%60==0?`${e/60} h`:`${e} min`}var fn=new Set([`alarm-arm-refused`,`alarm-check-failed`,`alarm-arming`,`alarm-armed`,`alarm-pending`,`alarm-triggered`,`alarm-rearmed`,`alarm-sensor-bypass`,`alarm-disarmed`]),pn=`alarm-panel`;function mn(e,t){for(let t of e.systemEvent?.kinds??[])if(fn.has(t))return!0;for(let e of t)if(e.kind===`cap`&&e.cap===pn)return!0;return!1}function hn(e,t){let n=new Map(t.map(e=>[e.id,e])),r=[];for(let t of[`onActivation`,`onDeactivation`,`onTrigger`,`onTriggerOff`])for(let i of e[t])if(i.kind===`do`)r.push(i.action);else{let e=n.get(i.sequenceId);e!==void 0&&r.push(...e.actions)}for(let t of e.buttons){let e=n.get(t.sequenceId);e!==void 0&&r.push(...e.actions)}return r}function gn(e){let{devices:t,devicesExclude:n,classes:r,classesExclude:i,...a}=e;return{conditions:a,deviceScope:W(t,n),classScope:W(r,i)}}function _n(e){let t=G(e.deviceScope),n=G(e.classScope);return{...e.conditions,...t.include===void 0?{}:{devices:[...t.include]},...t.exclude===void 0?{}:{devicesExclude:[...t.exclude]},...n.include===void 0?{}:{classes:[...n.include]},...n.exclude===void 0?{}:{classesExclude:[...n.exclude]}}}function vn(e){return e.deviceScope.mode===`only`?e.deviceScope.include:[]}function yn(e,t,n){let r=y(n);return e.some(e=>e.id===t&&Ae(e,n.delivery,r))}function bn(e=`immediate`,t={}){return{name:``,enabled:!0,delivery:e,targetIds:[],targetUsers:[],targetParams:{},priority:3,mediaAttach:`best`,mediaZoneCrop:!1,mediaFrame:void 0,mediaGif:!1,mediaClip:!1,mediaProfile:void 0,mediaClipSpeed:void 0,mediaLinkedCameras:void 0,templateTitle:``,templateBody:``,...gn(t),schedule:void 0,systemEventDelivery:void 0,snoozeAllowGlobal:!1,groupingSec:void 0,snoozeOptions:void 0,actions:en,cooldownSec:30,cooldownScope:`rule-device`,cooldownGranularity:void 0}}function xn(e){let t={};for(let n of e.targets)n.params&&Object.keys(n.params).length>0&&(t[n.targetId]=n.params);return{name:e.name,enabled:e.enabled,delivery:e.delivery,targetIds:e.targets.map(e=>e.targetId),targetUsers:e.targetUsers??[],targetParams:t,priority:e.priority,mediaAttach:e.media.attach,mediaZoneCrop:e.media.zoneCrop===!0,mediaFrame:e.media.frame,mediaGif:e.media.gif===!0,mediaClip:e.media.clip===!0,mediaProfile:e.media.profile,mediaClipSpeed:e.media.clipSpeed,mediaLinkedCameras:e.media.linkedCameras,templateTitle:e.template?.title??``,templateBody:e.template?.body??``,...gn(e.conditions),schedule:e.schedule,systemEventDelivery:e.systemEventDelivery,snoozeAllowGlobal:e.snoozeAllowGlobal===!0,groupingSec:e.groupingSec,snoozeOptions:e.snoozeOptions,actions:tn(e.actions),cooldownSec:e.throttle.cooldownSec,cooldownScope:e.throttle.scope,cooldownGranularity:e.throttle.granularity}}function Sn(e,t){let n=[];if(On(e)){let r=e.groupingSec;r!==void 0&&(!Number.isInteger(r)||r<5||r>60)&&n.push(`The grouping window is a whole number of seconds between 5 and 60.`);let i=t?.confirm;i?.enabled===!0&&i.expect!==void 0&&!kn(i.expect)&&n.push(`This rule’s AI confirm expects more than one subject, but a grouped message judges one picture per subject, so it would never send. Remove the confirm expectation (viewer or API), or choose Immediate.`)}if(v(e.conditions.audio)&&n.push(`This sound rule names neither a sound nor a level threshold, so it can never fire — every sample would count as a hit and the engine refuses it rather than notifying on silence. Pick at least one sound, or add a level.`),(!Number.isInteger(e.cooldownSec)||e.cooldownSec<0||e.cooldownSec>86400)&&n.push(`The cooldown is a whole number of seconds between 0 and ${String(ut)} (24 hours). 0 means every match is delivered.`),Y(e))for(let t of le({delivery:e.delivery,conditions:e.conditions,...e.systemEventDelivery===void 0?{}:{systemEventDelivery:e.systemEventDelivery},...J(e.actions)===void 0?{}:{actions:J(e.actions)}}))n.push(fe(t));return n}function Cn(e){let t=e.systemEventDelivery;if(t===void 0)return{};if(!x(e.delivery))return t.mode===`summary`?{systemEventDelivery:{mode:`instant`}}:{};if(t.mode===`summary`&&se(t.schedule)===null){let e=ge(t.schedule);if(e!==null&&e.times.length>0)return{systemEventDelivery:{...t,schedule:pe(e.times,t.schedule.timezone)}}}return{systemEventDelivery:t}}function wn(e){if(!Y(e))return null;if(!_e(e.templateBody))return`This body names none of the summary ({{summaryText}} or a section variable) — the hub appends {{summaryText}} to it when it sends.`;let t=e.templateBody;return(e.systemEventDelivery?.mode===`summary`?e.systemEventDelivery.split:void 0)===`section`&&t.trim().length>0&&!/\{\{\s*summaryText\s*\}\}/.test(t)?`Sent one per category: this body names no {{summaryText}}, so on every other category’s notification the hub appends {{summaryText}} (that category’s lines).`:null}function Y(e){return x(e.delivery)&&e.systemEventDelivery?.mode===`summary`}function Tn(e,t,n=new Set){return Sn(e,t).length===0&&it(e.delivery)&&(!x(e.delivery)||Nn(e)>0)&&y(e)!==`mixed`&&e.name.trim().length>0&&(e.targetIds.length>0||e.targetUsers.length>0)&&nn(e.actions,n).length===0}function En(e,t){let n=jn(e.conditions,t);return x(t)&&(n.systemEvent?.kinds.length??0)===0?{...e,delivery:t,conditions:{...n,systemEvent:R(`device-events`)}}:{...e,delivery:t,conditions:n}}function Dn(e,t){return t===`immediate-grouped`?{...En(e,`immediate`),groupingSec:e.groupingSec??20}:{...En(e,t),groupingSec:void 0}}function On(e){return e.groupingSec!==void 0&&S(e)}function kn(e){switch(e.op){case`>`:return 1>e.count;case`<=`:return 1<=e.count;case`<`:return 1<e.count;case`==`:return e.count===1;default:return 1>=e.count}}var An=new Set([`immediate`,`track-end`,`package-event`]);function jn(e,t){if(e.source!==`pipeline`||An.has(t))return e;let{source:n,...r}=e;return r}function Mn(e,t){return ke(e.conditions.systemEvent)===t?e:{...e,conditions:{...e.conditions,systemEvent:R(t)}}}function Nn(e){return e.conditions.systemEvent?.kinds.length??0}function X(e,t){return e.appliesTo.includes(t)}var Pn={source:`any`};function Fn(e,t){if(t==null)return!0;if(Array.isArray(t))return t.length===0;if(typeof t==`string`)return t.length===0||Pn[e]===t;if(typeof t==`number`)return!Number.isFinite(t);if(typeof t==`object`){if(`ids`in t){let e=t.ids;return!Array.isArray(e)||e.length===0}if(`values`in t){let e=t.values;return!Array.isArray(e)||e.length===0}return!1}return!1}var In=ve.filter(e=>e.id===`audio`);function Ln(e){if(e.length===0)return e;let t=new Set(e.map(e=>e.id)),n=In.filter(e=>!t.has(e.id));return n.length===0?e:[...e,...n]}function Rn(e,t,n,r=y({delivery:t,conditions:e})){let i=n.length===0?null:new Set(n.filter(e=>e.id!==`schedule`&&Ae(e,t,r)).map(e=>e.id)),a={};for(let[t,n]of Object.entries(e))i!==null&&!i.has(t)||P(t,e)&&(Fn(t,n)||(a[t]=n));return a}function zn(e,t){if(e===void 0)return{};let n=Rt(e,t.systemEvent);return n===void 0?{}:{systemEvent:n}}function Bn(e){return e!==void 0&&e.windows.length>0}function Vn(e){let t={...e.clipPreRollSec===void 0?{}:{clipPreRollSec:e.clipPreRollSec},...e.clipPostRollSec===void 0?{}:{clipPostRollSec:e.clipPostRollSec}};return Object.keys(t).length>0?t:void 0}function Hn(e){let t=Vn(e.media);return{...e.confirm===void 0?{}:{confirm:e.confirm},...t===void 0?{}:{media:t}}}function Un(e,t,n=[]){let r=e.templateTitle.trim(),i=e.templateBody.trim(),a=r.length>0||i.length>0?{...r.length>0?{title:r}:{},...i.length>0?{body:i}:{}}:void 0,o=J(e.actions),s=y(e),c=b(s),l=Se(s),u=n.length===0?!0:n.some(t=>t.id===`schedule`&&X(t,e.delivery)),d=!Y(e)&&u&&Bn(e.schedule)?e.schedule:void 0,f=n.length===0?!0:n.some(t=>t.id===`devices`&&X(t,e.delivery)),p=n.length===0?!0:n.some(t=>t.id===`devicesExclude`&&X(t,e.delivery)),{devices:m,devicesExclude:h,...g}=_n(e);return{name:e.name.trim(),enabled:e.enabled,delivery:e.delivery,conditions:{...Rn(g,e.delivery,n,s),...f&&m!==void 0?{devices:m}:{},...p&&h!==void 0?{devicesExclude:h}:{},...zn(l,e.conditions)},...d?{schedule:d}:{},...Cn(e),targets:e.targetIds.map(t=>{let n=e.targetParams[t];return n&&Object.keys(n).length>0?{targetId:t,params:n}:{targetId:t}}),...e.targetUsers.length>0?{targetUsers:[...e.targetUsers]}:{},media:c.carriesMedia?{attach:e.mediaAttach,...c.carriesSubjectCrop&&e.mediaZoneCrop?{zoneCrop:!0}:{},...c.carriesSubjectCrop&&e.mediaFrame!==void 0?{frame:e.mediaFrame}:{},...e.mediaGif?{gif:!0}:{},...e.mediaClip?{clip:!0}:{},...e.mediaProfile===void 0?{}:{profile:e.mediaProfile},...e.mediaClipSpeed===void 0?{}:{clipSpeed:e.mediaClipSpeed},...s===`sensor`&&e.mediaAttach!==`none`&&e.mediaLinkedCameras!==void 0?{linkedCameras:e.mediaLinkedCameras}:{},...(e.mediaGif||e.mediaClip)&&t?.media?.clipPreRollSec!==void 0?{clipPreRollSec:t.media.clipPreRollSec}:{},...(e.mediaGif||e.mediaClip)&&t?.media?.clipPostRollSec!==void 0?{clipPostRollSec:t.media.clipPostRollSec}:{}}:{attach:`none`},throttle:{cooldownSec:e.cooldownSec,scope:e.cooldownScope,...e.cooldownGranularity===void 0?{}:{granularity:e.cooldownGranularity}},priority:e.priority,...a?{template:a}:{},...e.snoozeAllowGlobal?{snoozeAllowGlobal:!0}:{},...On(e)?{groupingSec:e.groupingSec}:{},...e.snoozeOptions===void 0?{}:{snoozeOptions:[...e.snoozeOptions]},...t?.confirm===void 0?{}:{confirm:t.confirm},...o===void 0?{}:{actions:o}}}function Wn(e,t){let n=Un(e,void 0,t);return[`template`,`schedule`,`targetUsers`,`snoozeOptions`,`snoozeAllowGlobal`,`groupingSec`,`actions`].filter(e=>n[e]===void 0)}var Gn=[{key:`rule`,label:`Rule`,fields:[`name`,`enabled`,`delivery`,`groupingSec`,`targetIds`,`targetUsers`,`targetParams`]},{key:`devices`,label:`Devices`,fields:[`deviceScope`]},{key:`conditions`,label:`Conditions`,fields:[`conditions`,`classScope`,`schedule`,`systemEventDelivery`]},{key:`notification`,label:`Notification`,fields:[`priority`,`mediaAttach`,`mediaFrame`,`mediaZoneCrop`,`mediaGif`,`mediaClip`,`mediaProfile`,`mediaClipSpeed`,`mediaLinkedCameras`,`templateTitle`,`templateBody`]},{key:`actions`,label:`Actions`,fields:[`actions`]},{key:`advanced`,label:`Advanced`,fields:[`snoozeAllowGlobal`,`snoozeOptions`,`cooldownSec`,`cooldownScope`,`cooldownGranularity`]}];function Kn(e,t={}){let n=y({delivery:e,conditions:t}),r=b(n),i=Gn.map(e=>e.key===`conditions`?{...e,label:r.label}:e);return Te(n)?i.filter(e=>e.key!==`devices`):i}function qn(e){if(e.audio!==void 0)return`Sound`;if(e.occupancy!==void 0)return`Occupancy`}function Jn(e){let t=y(e),n=Oe(_n(e),t);return t===`sensor`&&e.conditions.sensorTransition!==void 0&&!P(`sensorTransition`,e.conditions)?[...n,{conditionId:`sensorTransition`,reason:ce}]:n}var Yn=`rule`;function Xn(e){return Gn.find(t=>t.key===e)?.key}function Zn(e){return e?.toLowerCase().startsWith(`it`)===!0?`it`:`en`}function Qn(){let{i18n:e}=T(),t=Zn(e.language);return e=>me(e,t)}e();var $n=`block text-[11px] font-medium text-foreground`,Z=`text-[10px] text-foreground-subtle mt-0.5`;function er({cameras:e,fleet:t,value:n,onChange:r,emptyMeansAll:i=!1,savedHadDevices:a=!1}){return o(h,{devices:e,listState:t.state,fleet:t,value:n,onChange:r,emptyMeansAll:i,savedHadDevices:a})}function tr({value:e,placeholder:n,onChange:r}){let[i,s]=a(``),c=()=>{let t=i.trim();if(t.length===0||e.includes(t)){s(``);return}r([...e,t]),s(``)},l=t=>r(e.filter(e=>e!==t));return t(`div`,{className:`mt-1 space-y-1.5`,children:[e.length>0&&o(`div`,{className:`flex flex-wrap gap-1`,children:e.map(e=>t(`span`,{className:`inline-flex items-center gap-1 rounded bg-surface-hover px-1.5 py-0.5 text-[11px] text-foreground`,children:[e,o(`button`,{type:`button`,onClick:()=>l(e),"aria-label":`remove ${e}`,className:`text-foreground-subtle hover:text-danger`,children:o(ee,{className:`h-3 w-3`})})]},e))}),o(_,{value:i,placeholder:n,onChange:e=>s(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),c())},onBlur:c})]})}function nr({picker:e,value:r,onChange:i}){let a=n(()=>je(e),[e]),s=n(()=>new Set(r),[r]),c=r.filter(e=>!a.has(e)),l=e=>{i(s.has(e)?r.filter(t=>t!==e):[...r,e])};return t(`div`,{className:`space-y-2`,children:[c.length>0&&o(`div`,{className:`flex flex-wrap gap-1`,children:c.map(e=>t(`button`,{type:`button`,onClick:()=>i(r.filter(t=>t!==e)),className:`inline-flex items-center gap-1 rounded border border-border px-1.5 py-0.5 text-[10px] text-foreground hover:bg-surface-hover`,title:`Custom value — click to remove`,children:[e,` ×`]},e))}),e.groups.map(e=>t(`div`,{children:[o(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-muted mb-1`,children:e.fallbackLabel}),o(`div`,{className:`flex flex-wrap gap-1`,children:e.options.map(e=>{let t=s.has(e.value);return o(`button`,{type:`button`,"aria-pressed":t,onClick:()=>l(e.value),className:t?`rounded border border-primary bg-primary/15 px-1.5 py-0.5 text-[10px] text-foreground`:`rounded border border-border px-1.5 py-0.5 text-[10px] text-foreground hover:bg-surface-hover`,children:e.label},e.value)})})]},e.key))]})}function rr({value:e,min:n,max:r,step:i,onChange:a}){return t(`div`,{className:`mt-1 flex items-center gap-2`,children:[o(_,{type:`number`,value:e??``,min:n,max:r,step:i,className:`max-w-[8rem]`,onChange:e=>{let t=e.target.value;if(t===``){a(void 0);return}let n=Number(t);a(Number.isFinite(n)?n:void 0)}}),e!==void 0&&r!==void 0&&o(`input`,{type:`range`,min:n,max:r,step:i,value:e,onChange:e=>a(Number(e.target.value)),className:`flex-1 accent-primary`,"aria-label":`value`})]})}function ir({value:e,onChange:n,options:r}){let{t:i}=T(),a=ar(r??[]),s=a.length>0?a:Et;return t(`div`,{className:`mt-1 space-y-1`,children:[o(d,{value:e??`enter`,options:s.map(e=>({value:e.value,label:i(`notificationRules.crossing.${e.value}`,e.label)})),onChange:e=>n(F(e.target.value))}),o(`p`,{className:Z,children:i(`notificationRules.crossing.hint`,`Which way the subject crosses the zone.`)})]})}function ar(e){let t=[];for(let n of e){let e=n.value===``||n.value===`enter`?Dt:F(n.value);e===void 0||t.some(t=>t.value===e)||t.push({value:e,label:n.label})}return t}function or({deviceIds:e,cameras:t,value:n,onChange:r}){let{options:i,loading:a}=D(e,t);return o(O,{options:i,value:n,onChange:r,loading:a,noFreeText:!0,emptyHint:e.length===0?`Select cameras first — a rule can only use zones those cameras actually have.`:`The selected cameras have no zones. Draw one in the camera’s zone editor first.`,placeholder:``})}function sr({deviceIds:e,value:t,onChange:n}){let{options:r,loading:i}=Je(e);return o(O,{options:r,value:t,onChange:n,loading:i,emptyHint:e.length===0?`Select cameras above to pick their event kinds — or type a token.`:`No event kinds reported for the selected cameras — type a token.`,placeholder:`Event token…`})}var cr=[{value:`became-occupied`,label:`Became occupied`},{value:`became-free`,label:`Became free`},{value:`>=`,label:`Count ≥`},{value:`<=`,label:`Count ≤`}];function lr(e,t){let n=e.map(e=>({value:e.value,label:e.label}));return t===void 0||t===``||n.some(e=>e.value===t)?n:[...n,{value:t,label:`${t} — sub-type, never counts (always 0)`}]}function ur({deviceIds:e,cameras:n,classOptions:r,value:i,onChange:a}){let{options:s,loading:c}=D(e,n),l=i??xe,u=e=>a({...l,...e}),f=l.op===`became-occupied`||l.op===`became-free`,p=lr(r,l.className);return t(`div`,{className:`mt-1 space-y-1.5`,children:[t(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[o(`div`,{className:`min-w-[10rem]`,children:o(d,{value:l.zoneId??``,options:[{value:``,label:c?`Loading zones…`:`— whole frame —`},...s.map(e=>({value:e.value,label:e.label}))],onChange:e=>u({zoneId:e.target.value===``?void 0:e.target.value})})}),o(`div`,{className:`min-w-[9rem]`,children:o(d,{value:l.className??``,options:[{value:``,label:`— any class —`},...p],onChange:e=>u({className:e.target.value===``?void 0:e.target.value})})}),o(`div`,{className:`min-w-[9rem]`,children:o(d,{value:l.op,options:cr.map(e=>({value:e.value,label:e.label})),onChange:e=>{let t=cr.find(t=>t.value===e.target.value);t&&u({op:t.value})}})})]}),t(`div`,{className:`flex flex-wrap items-center gap-3 text-xs text-foreground-subtle`,children:[t(`label`,{className:`flex items-center gap-1`,children:[f?`Threshold`:`Count`,o(_,{type:`number`,min:0,className:`w-16`,value:String(l.count),onChange:e=>u({count:Math.max(0,Number(e.target.value)||0)})})]}),t(`label`,{className:`flex items-center gap-1`,children:[`Hold for`,o(_,{type:`number`,min:0,max:3600,className:`w-16`,value:String(l.sustainSeconds),onChange:e=>u({sustainSeconds:Math.min(3600,Math.max(0,Number(e.target.value)||0))})}),`s`]}),i===void 0?null:o(`button`,{type:`button`,onClick:()=>a(void 0),className:`underline hover:text-foreground`,children:`Clear`})]}),e.length===0&&o(`p`,{className:`text-[11px] text-warning`,children:`No camera picked on the Devices tab: this watches EVERY camera's occupancy, and no zone can be offered until you choose one — a zone id belongs to a camera.`}),o(`p`,{className:`text-[11px] text-foreground-subtle`,children:`Counts confirmed tracked objects from zone analytics. The change must hold for the sustain window before it fires; with no snapshot for the camera or zone the rule never fires.`})]})}var dr=[{value:`label`,label:`Sounds — fires at once`,Icon:g},{value:`level`,label:`Volume — over a window`,Icon:m}];function fr({taxonomy:e,value:n,onChange:i}){let a=he(n),s=e=>i(ne(n,e)),{choices:c,unknownLabels:l}=oe(e,a.labels),u=ie(n)??`label`;return t(`div`,{className:`mt-1 space-y-2`,children:[t(`div`,{className:`flex flex-wrap items-center gap-1`,children:[dr.map(e=>o(`button`,{type:`button`,"aria-pressed":u===e.value,onClick:()=>s({mode:e.value}),className:`rounded border px-2 py-0.5 text-[11px] ${u===e.value?`border-primary bg-primary/15 text-foreground`:`border-border text-foreground-subtle hover:bg-surface-hover`}`,children:t(`span`,{className:`inline-flex items-center gap-1`,children:[o(e.Icon,{className:`h-3 w-3`}),e.label]})},e.value)),n===void 0?null:o(`button`,{type:`button`,onClick:()=>i(void 0),className:`ml-1 text-xs text-foreground-subtle underline hover:text-foreground`,children:`Clear`})]}),u===`label`?t(r,{children:[o(`div`,{className:`flex flex-wrap gap-1`,children:c.map(e=>{let n=De(a.labels,e.value),r=e.unknown?`border-dashed border-warning text-warning`:n?`border-primary bg-primary/15 text-foreground`:`border-border text-foreground hover:bg-surface-hover`;return o(`button`,{type:`button`,"aria-pressed":n,title:e.unknown?`Stored by the rule — not offered by this hub`:void 0,onClick:()=>s({labels:Ee(a.labels,e.value)}),className:`rounded border px-1.5 py-0.5 text-[10px] ${r}`,children:t(`span`,{className:`inline-flex items-center gap-1`,children:[o(p,{iconId:e.iconId,size:12}),e.label]})},e.value)})}),l.length>0&&t(`p`,{className:`text-[10px] text-warning`,children:[`Kept from the rule, unknown to this hub: `,l.join(`, `)]}),t(`div`,{className:`flex flex-wrap items-center gap-3 text-xs text-foreground-subtle`,children:[t(`label`,{className:`flex items-center gap-1`,children:[`Confirm after`,o(_,{type:`number`,min:1,max:20,step:1,className:`w-16`,value:String(a.confirmHits??2),onChange:e=>s({confirmHits:Number(e.target.value)})}),`frames`]}),t(`label`,{className:`flex items-center gap-1`,children:[`within`,o(_,{type:`number`,min:1,max:60,step:1,className:`w-16`,value:String(a.confirmWindowSec??5),onChange:e=>s({confirmWindowSec:Number(e.target.value)})}),`s`]})]}),t(`p`,{className:`text-[11px] text-foreground-subtle`,children:[`Fires when that many labelled frames land inside the window (default`,` `,2,` in `,5,` s). A single-frame false positive never reaches 2; a real episode usually labels two or three frames. The rule's cooldown is the other throttle.`]})]}):t(r,{children:[o(`div`,{className:`flex flex-wrap items-center gap-3 text-xs text-foreground-subtle`,children:t(`label`,{className:`flex items-center gap-1`,children:[`Louder than`,o(_,{type:`number`,min:ye,max:0,step:3,className:`w-20`,value:String(a.dbThreshold??re),onChange:e=>s({dbThreshold:Number(e.target.value)})}),`dBFS`]})}),t(`div`,{className:`flex flex-wrap items-center gap-3 text-xs text-foreground-subtle`,children:[t(`label`,{className:`flex items-center gap-1`,children:[`Hits`,o(_,{type:`number`,min:1,max:100,step:5,className:`w-16`,value:String(a.hitPercent),onChange:e=>s({hitPercent:Number(e.target.value)})}),`% (default `,w.hitPercent,`)`]}),t(`label`,{className:`flex items-center gap-1`,children:[`over`,o(_,{type:`number`,min:1,max:300,step:5,className:`w-16`,value:String(a.samplingSeconds),onChange:e=>s({samplingSeconds:Number(e.target.value)})}),`s (default `,w.samplingSeconds,`)`]})]}),t(`p`,{className:`text-[11px] text-foreground-subtle`,children:[`dBFS is negative-going: 0 is full scale, `,ye,` is silence — so a HIGHER number is a narrower filter. Measured on this hub, a baby crying reads `,`−`,`55 to `,`−`,`26 dBFS, so a floor above `,`−`,`55 excludes most of it. The window must be FULL before it can match.`]})]}),v(n)?o(`p`,{className:`text-[11px] text-warning`,children:`With neither a sound nor a level threshold this can never match — every sample would be a hit, so the engine refuses it rather than notifying on silence.`}):null]})}function pr({value:e,onChange:n}){let r=e?.values??[],i=e?.maxDistance??1,a=e=>n(e.length>0?{values:e,maxDistance:i}:void 0),s=e=>n(r.length>0?{values:r,maxDistance:e}:void 0),c=Xe().filter(e=>!r.includes(e));return t(`div`,{className:`mt-1 space-y-1.5`,children:[o(tr,{value:r,placeholder:`Plate text…`,onChange:a}),c.length>0&&t(`div`,{className:`flex flex-wrap items-center gap-1`,children:[o(`span`,{className:`text-[10px] text-foreground-subtle`,children:`Seen:`}),c.slice(0,12).map(e=>o(`button`,{type:`button`,onClick:()=>a([...r,e]),className:`rounded border border-border px-1.5 py-0.5 text-[10px] text-foreground-subtle hover:bg-surface-hover hover:text-foreground`,children:e},e))]}),t(`label`,{className:`flex items-center gap-2 text-[11px] text-foreground-subtle`,children:[`Max distance`,o(_,{type:`number`,min:0,max:3,step:1,value:i,className:`max-w-[5rem]`,onChange:e=>{let t=Number(e.target.value);s(Number.isFinite(t)?Math.max(0,Math.min(3,t)):1)}})]})]})}function mr({gateable:e,value:n,onChange:r}){let i=Qn(),a=e.find(e=>e.id===n?.deviceId),s=new Set(n?.states??[]),c=e=>{let t=Number(e);if(!Number.isFinite(t)||t===0)return r(void 0);r({deviceId:t,states:[]})},l=e=>{if(n===void 0)return;let t=new Set(s);t.has(e)?t.delete(e):t.add(e),r(t.size===0?void 0:{deviceId:n.deviceId,states:[...t]})};return t(`div`,{className:`mt-1 space-y-2`,children:[o(d,{value:n===void 0?``:String(n.deviceId),options:[{value:``,label:`— no device gate —`},...e.map(e=>({value:String(e.id),label:e.name}))],onChange:e=>c(e.target.value)}),a!==void 0&&o(`div`,{className:`flex flex-wrap gap-1.5`,children:a.states.map(e=>o(`button`,{type:`button`,onClick:()=>l(e),className:s.has(e)?`rounded-md border border-primary bg-primary/10 px-2 py-0.5 text-[11px] text-primary`:`rounded-md border border-border px-2 py-0.5 text-[11px] text-foreground-subtle`,children:i(e)},e))}),a!==void 0&&a.states.length===0&&o(`p`,{className:`text-[10px] text-foreground-subtle mt-0.5`,children:`This device reports no state the gate can read, so it cannot arm a rule.`}),n!==void 0&&o(`p`,{className:`text-[10px] text-foreground-subtle mt-0.5`,children:`The rule is silent while the device is in any other state — including when its state cannot be read at all.`})]})}function hr(e,t){let n=t(e.verdict);return e.latched?`${n} · ${t(`latched`)}`:n}function gr({scenes:e,value:n,onChange:r}){let{t:i}=T(),a=Qn(),s=e.find(e=>e.sceneId===n?.sceneId),c=t=>{if(t===``)return r(void 0);let i=e.find(e=>e.sceneId===t);if(i===void 0)return r(void 0);r({sceneId:t,deviceId:i.deviceId,requiredState:n?.requiredState??`diverged`,...n?.latched===void 0?{}:{latched:n.latched}})},l=e=>{n!==void 0&&r({...n,requiredState:e===`matched`?`matched`:`diverged`})},u=e=>{if(n!==void 0){if(e===``){let{latched:e,...t}=n;return r(t)}r({...n,latched:e===`latched`})}};return e.length===0?o(`p`,{className:Z,children:i(`notificationRules.scene.none`,`No scenes yet — create one on the Scenes page.`)}):t(`div`,{className:`mt-1 space-y-2`,children:[o(d,{value:n?.sceneId??``,options:[{value:``,label:i(`notificationRules.scene.noGate`,`— no scene gate —`)},...e.map(e=>({value:e.sceneId,label:`${e.cameraName} · ${e.label} — ${hr(e,a)}`}))],onChange:e=>c(e.target.value)}),n!==void 0&&t(`div`,{className:`flex flex-wrap items-center gap-2`,children:[t(`label`,{className:`flex items-center gap-2 text-[11px] text-foreground-subtle`,children:[i(`notificationRules.scene.onlyWhile`,`Only while it is`),o(d,{value:n.requiredState,options:[{value:`diverged`,label:a(`diverged`)},{value:`matched`,label:a(`matched`)}],onChange:e=>l(e.target.value)})]}),t(`label`,{className:`flex items-center gap-2 text-[11px] text-foreground-subtle`,children:[i(`notificationRules.scene.read`,`Read`),o(d,{value:n.latched===void 0?``:n.latched?`latched`:`live`,options:[{value:``,label:s===void 0?i(`notificationRules.scene.readOwn`,`The scene's own setting`):`${i(`notificationRules.scene.readOwn`,`The scene's own setting`)} (${a(s.emit)})`},{value:`latched`,label:a(`latched`)},{value:`live`,label:a(`live`)}],onChange:e=>u(e.target.value)})]})]}),s!==void 0&&t(`p`,{className:`text-[10px] text-foreground-subtle mt-0.5`,children:[i(`notificationRules.scene.rightNow`,`Right now:`),` `,hr(s,a)]}),n!==void 0&&s===void 0&&o(`p`,{className:`text-[10px] text-foreground-subtle mt-0.5`,children:i(`notificationRules.scene.missing`,`This scene no longer exists — pick another or remove the gate.`)})]})}var Q={days:[0,1,2,3,4,5,6],minute:480},_r=[{value:1,label:`Mon`},{value:2,label:`Tue`},{value:3,label:`Wed`},{value:4,label:`Thu`},{value:5,label:`Fri`},{value:6,label:`Sat`},{value:0,label:`Sun`}];function vr(e){let t=Math.floor(e/60),n=e%60;return`${String(t).padStart(2,`0`)}:${String(n).padStart(2,`0`)}`}function yr(e){let[t,n]=e.split(`:`),r=Number(t)*60+Number(n);return Number.isFinite(r)?Math.max(0,Math.min(1439,r)):0}function br(e){if(typeof e!=`object`||!e||!(`data`in e))return;let t=e.data;if(!(typeof t!=`object`||!t||!(`code`in t)))return typeof t.code==`string`?t.code:void 0}function xr(e){let t=Object.entries(e).map(([e,t])=>`${e} ${String(t)}`);return t.length>0?`Left out by this rule's filters or a camera mute: ${t.join(`, `)}.`:null}function Sr(e,t,n,r=`rule`){if(e===`error`)return br(n)===`NOT_FOUND`?{lines:[`This hub does not serve summary rules yet — update @camstack/server first. A rule saved now would be stored without its summary, and stay instant.`]}:{lines:[`The preview could not be read: ${n instanceof Error?n.message:String(n)}`]};if(e!==`success`||t===void 0)return null;let i=[];if(r===`section`&&t.split===void 0&&i.push(`This hub does not send per-category summaries yet — update @camstack/server first. Until then it sends one message.`),t.empty)i.push(`Nothing to report right now — no notification would be sent.`);else if(t.split===`section`&&t.rows!==void 0){let e=t.rows.length;i.push(`${String(e)} notification${e===1?``:`s`} would be sent now, one per category:`);for(let e of t.rows)i.push(`${e.title}\n${e.text}`)}else i.push(`${String(t.count)} item(s) would be sent now:\n${t.text}`);let a=xr(t.dropped);return a!==null&&i.push(a),t.excludedGroups.includes(`backups-exports`)&&i.push(`Backups and exports are completed jobs, not a state — they are not in a summary.`),{lines:i}}function Cr(e,t){return{...e,schedule:t}}function wr(e,t){let{split:n,...r}=e;return t===`section`?{...r,split:t}:r}function $(e){return vr(e)}function Tr(e){return yr(e)}function Er(){return{days:[1,2,3,4,5],startMinute:540,endMinute:1080}}function Dr(e){return{days:[...Q.days],minute:e}}var Or=`Always active — add a window to restrict when the rule fires.`;function kr({value:e,onChange:t,mode:n=`windows`,defaultMinute:r=Q.minute,emptyHint:i}){return n===`times`?o(jr,{value:e,onChange:t,defaultMinute:r}):o(Ar,{value:e,onChange:t,emptyHint:i??Or})}function Ar({value:e,onChange:n,emptyHint:r}){let i=e?.windows??[],a=e?.invert??!1,s=(t,r)=>{if(t.length===0){n(void 0);return}n({windows:t,...r?{invert:!0}:{},...e?.timezone?{timezone:e.timezone}:{}})},c=()=>s([...i,Er()],a),l=e=>s(i.filter((t,n)=>n!==e),a),u=(e,t)=>s(i.map((n,r)=>r===e?t:n),a);return t(`div`,{className:`mt-1 space-y-2`,"data-testid":`schedule-field-windows`,children:[i.length===0?o(`p`,{className:Z,children:r}):i.map((e,t)=>o(Mr,{window:e,onChange:e=>u(t,e),onRemove:()=>l(t)},t)),t(`div`,{className:`flex items-center gap-3`,children:[t(`button`,{type:`button`,onClick:c,className:`flex items-center gap-1 rounded-md bg-surface-hover px-2 py-1 text-[11px] text-foreground-subtle hover:text-foreground`,children:[o(f,{className:`h-3 w-3`}),` Add window`]}),i.length>0&&t(`label`,{className:`flex items-center gap-1.5 text-[11px] text-foreground-subtle`,children:[o(`input`,{type:`checkbox`,checked:a,onChange:e=>s([...i],e.target.checked),className:`accent-primary`}),`Active outside the windows`]})]})]})}function jr({value:e,onChange:n,defaultMinute:r}){let i=e?.timezone,a=e===void 0?{times:[],approximated:!1}:ge(e);if(a===null)return t(`div`,{className:`mt-1 space-y-2`,"data-testid":`schedule-field-times-fallback`,children:[o(`p`,{className:Z,children:`Inverted schedule — shown as bands. Clear the invert flag (or the windows) to author punctual times.`}),o(Ar,{value:e,onChange:n,emptyHint:Or})]});let s=a.times,c=e=>{if(e.length===0){n(void 0);return}n(pe(e,i))};return t(`div`,{className:`mt-1 space-y-2`,"data-testid":`schedule-field-times`,children:[a.approximated&&o(`p`,{className:`text-[10px] text-foreground-subtle mt-0.5`,"data-testid":`schedule-field-times-approximated`,children:`Shown as send-at times from each window's end (when the summary fires). Edit or save to store them as punctual one-minute windows.`}),s.length===0?o(`p`,{className:Z,children:`No times yet — add one to send on those days at that clock time.`}):s.map((e,t)=>o(Nr,{time:e,index:t,onChange:e=>c(s.map((n,r)=>r===t?e:n)),onRemove:s.length>1?()=>c(s.filter((e,n)=>n!==t)):void 0},t)),t(`button`,{type:`button`,onClick:()=>c([...s,Dr(r)]),className:`flex items-center gap-1 rounded-md bg-surface-hover px-2 py-1 text-[11px] text-foreground-subtle hover:text-foreground`,"data-testid":`schedule-field-add-time`,children:[o(f,{className:`h-3 w-3`}),` Add a time`]})]})}function Mr({window:e,onChange:n,onRemove:r}){return t(`div`,{className:`space-y-1.5 rounded-md border border-border p-2`,children:[t(`div`,{className:`flex items-center gap-2 text-xs`,children:[o(`input`,{type:`time`,value:$(e.startMinute),onChange:t=>n({...e,startMinute:Tr(t.target.value)}),className:`rounded-md border border-border bg-background px-1 py-0.5`}),o(`span`,{className:`text-foreground-subtle`,children:`→`}),o(`input`,{type:`time`,value:$(e.endMinute),onChange:t=>n({...e,endMinute:Tr(t.target.value)}),className:`rounded-md border border-border bg-background px-1 py-0.5`}),o(`span`,{className:`flex-1`}),o(`button`,{type:`button`,onClick:r,"aria-label":`Remove window`,className:`text-foreground-subtle hover:text-danger`,children:o(c,{className:`h-3.5 w-3.5`})})]}),o(Pr,{days:e.days,onToggle:t=>{let r=e.days.includes(t)?e.days.filter(e=>e!==t):[...e.days,t];r.length!==0&&n({...e,days:r})}})]})}function Nr({time:e,index:n,onChange:r,onRemove:i}){return t(`div`,{className:`space-y-1.5 rounded-md border border-border p-2`,children:[t(`div`,{className:`flex items-center gap-2 text-xs`,children:[o(`span`,{className:`text-foreground-subtle`,children:`At`}),o(`input`,{type:`time`,value:vr(e.minute),onChange:t=>r({...e,minute:yr(t.target.value)}),className:`rounded-md border border-border bg-background px-1 py-0.5`,"data-testid":`schedule-field-time-${String(n)}`}),o(`span`,{className:`flex-1`}),i!==void 0&&o(`button`,{type:`button`,onClick:i,"aria-label":`Remove time`,className:`text-foreground-subtle hover:text-danger`,children:o(c,{className:`h-3.5 w-3.5`})})]}),o(Pr,{days:e.days,onToggle:t=>{let n=e.days.includes(t)?e.days.filter(e=>e!==t):[...e.days,t];n.length!==0&&r({...e,days:n})}})]})}function Pr({days:e,onToggle:t}){return o(`div`,{className:`flex flex-wrap gap-1`,children:_r.map(n=>o(`button`,{type:`button`,onClick:()=>t(n.value),className:`rounded px-1.5 py-0.5 text-[10px] ${e.includes(n.value)?`bg-primary text-primary-foreground`:`bg-surface-hover text-foreground-subtle`}`,children:n.label},n.value))})}export{Kt as $,O as $t,un as A,at as At,yn as B,st as Bt,Xn as C,pt as Ct,Hn as D,_t as Dt,Un as E,M as Et,hn as F,Qe as Ft,K as G,mt as Gt,dn as H,jt as Ht,Tn as I,$e as It,rn as J,bt as Jt,q as K,et as Kt,mn as L,kt as Lt,Mn as M,St as Mt,bn as N,P as Nt,Ln as O,Ct as Ot,vn as P,dt as Pt,nn as Q,tt as Qt,Y as R,it as Rt,Jn as S,ut as St,Wn as T,A as Tt,wn as U,ft as Ut,xn as V,xt as Vt,cn as W,gt as Wt,on as X,yt as Xt,an as Y,vt as Yt,sn as Z,Tt as Zt,tr as _,Ke as _n,B as _t,wr as a,We as an,Yt as at,Yn as b,At as bt,er as c,Ve as cn,Vt as ct,Z as d,Ge as dn,Ht as dt,Ye as en,G as et,$n as f,ze as fn,zt as ft,gr as g,qe as gn,L as gt,pr as h,Ue as hn,V as ht,Cr as i,Me as in,Zt as it,Dn as j,wt as jt,ln as k,Ot as kt,mr as l,Re as ln,It as lt,ur as m,Ne as mn,Wt as mt,Q as n,He as nn,$t as nt,fr as o,Pe as on,Xt as ot,rr as p,Ie as pn,Ut as pt,J as q,nt as qt,Sr as r,Le as rn,W as rt,ir as s,Fe as sn,Jt as st,kr as t,D as tn,Qt as tt,sr as u,Be as un,Gt as ut,nr as v,Lt as vt,Kn as w,j as wt,qn as x,ht as xt,or as y,N as yt,Sn as z,ot as zt};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{vt as e}from"./player-overlays-
|
|
1
|
+
import{vt as e}from"./player-overlays-CVsVEZkx.js";var t=e(`octagon-alert`,[[`path`,{d:`M12 16h.01`,key:`1drbdi`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M15.312 2a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586l-4.688-4.688A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2z`,key:`1fd625`}]]);export{t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{D as e,I as t,J as n,L as r,O as i,Q as a,S as o,W as s,b as c,k as l,q as u,x as d,z as f}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{It as p}from"./client-1c3e-nOc.js";a();var m=(...e)=>e.filter((e,t,n)=>!!e&&e.trim()!==``&&n.indexOf(e)===t).join(` `).trim(),h=e=>e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase(),ee=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,n)=>n?n.toUpperCase():t.toLowerCase()),g=e=>{let t=ee(e);return t.charAt(0).toUpperCase()+t.slice(1)},_={xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`},v=e=>{for(let t in e)if(t.startsWith(`aria-`)||t===`role`||t===`title`)return!0;return!1},te=l(({color:e=`currentColor`,size:t=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:a=``,children:o,iconNode:s,...c},l)=>i(`svg`,{ref:l,..._,width:t,height:t,stroke:e,strokeWidth:r?Number(n)*24/Number(t):n,className:m(`lucide`,a),...!o&&!v(c)&&{"aria-hidden":`true`},...c},[...s.map(([e,t])=>i(e,t)),...Array.isArray(o)?o:[o]]));a();var y=(e,t)=>{let n=l(({className:n,...r},a)=>i(te,{ref:a,iconNode:t,className:m(`lucide-${h(g(e))}`,`lucide-${e}`,n),...r}));return n.displayName=g(e),n},ne=y(`camera`,[[`path`,{d:`M13.997 4a2 2 0 0 1 1.76 1.05l.486.9A2 2 0 0 0 18.003 7H20a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h1.997a2 2 0 0 0 1.759-1.048l.489-.904A2 2 0 0 1 10.004 4z`,key:`18u6gg`}],[`circle`,{cx:`12`,cy:`13`,r:`3`,key:`1vg3eu`}]]),b=y(`chevron-down`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),x=y(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),S=y(`eye-off`,[[`path`,{d:`M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49`,key:`ct8e1f`}],[`path`,{d:`M14.084 14.158a3 3 0 0 1-4.242-4.242`,key:`151rxh`}],[`path`,{d:`M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143`,key:`13bj9a`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),C=y(`grid-2x2`,[[`path`,{d:`M12 3v18`,key:`108xh3`}],[`path`,{d:`M3 12h18`,key:`1i2n21`}],[`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,key:`h1oib`}]]),w=y(`image-off`,[[`line`,{x1:`2`,x2:`22`,y1:`2`,y2:`22`,key:`a6p6uj`}],[`path`,{d:`M10.41 10.41a2 2 0 1 1-2.83-2.83`,key:`1bzlo9`}],[`line`,{x1:`13.5`,x2:`6`,y1:`13.5`,y2:`21`,key:`1q0aeu`}],[`line`,{x1:`18`,x2:`21`,y1:`12`,y2:`15`,key:`5mozeu`}],[`path`,{d:`M3.59 3.59A1.99 1.99 0 0 0 3 5v14a2 2 0 0 0 2 2h14c.55 0 1.052-.22 1.41-.59`,key:`mmje98`}],[`path`,{d:`M21 15V5a2 2 0 0 0-2-2H9`,key:`43el77`}]]),T=y(`mic-off`,[[`path`,{d:`M12 19v3`,key:`npa21l`}],[`path`,{d:`M15 9.34V5a3 3 0 0 0-5.68-1.33`,key:`1gzdoj`}],[`path`,{d:`M16.95 16.95A7 7 0 0 1 5 12v-2`,key:`cqa7eg`}],[`path`,{d:`M18.89 13.23A7 7 0 0 0 19 12v-2`,key:`16hl24`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M9 9v3a3 3 0 0 0 5.12 2.12`,key:`r2i35w`}]]),E=y(`mic`,[[`path`,{d:`M12 19v3`,key:`npa21l`}],[`path`,{d:`M19 10v2a7 7 0 0 1-14 0v-2`,key:`1vc78b`}],[`rect`,{x:`9`,y:`2`,width:`6`,height:`13`,rx:`3`,key:`s6n7sd`}]]),D=y(`rotate-ccw`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]),re=y(`square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]),ie=y(`trash-2`,[[`path`,{d:`M10 11v6`,key:`nco0om`}],[`path`,{d:`M14 11v6`,key:`outv1u`}],[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]]);a();function O(t,n){if(typeof globalThis>`u`)return e(n);let r=globalThis.__camstackSharedContexts,i=r??new Map;r||(globalThis.__camstackSharedContexts=i);let a=i.get(t);if(a)return a;let o=e(n);return i.set(t,o),o}a();var k=O(`camstack:system`,null);function ae({system:e,children:t}){return d(k.Provider,{value:e,children:t})}function oe(){let e=r(k);if(!e)throw Error(`useSystem(): no <SystemProvider> in tree`);return e}function se(){return r(k)}var ce=`camstack-mount`,le=/^\/(?:[A-Za-z0-9_\-.]+\/)*$/,A=null;function j(e){if(e==null||e===``)return null;let t=e.endsWith(`/`)?e:`${e}/`;return!le.test(t)||t.includes(`/../`)||t.includes(`/./`)?null:t}function M(){if(typeof document>`u`)return`/`;let e=j(document.querySelector(`meta[name="${ce}"]`)?.getAttribute(`content`));if(e!==null)return e;if(document.querySelector(`base[href]`)!==null)try{let e=new URL(document.baseURI);if(e.origin===window.location.origin){let t=j(e.pathname);if(t!==null)return t}}catch{}return`/`}function N(){return A===null&&(A=M()),A}function P(){return N().replace(/\/$/,``)}function F(e){return/^[a-z][a-z0-9+.-]*:/i.test(e)||e.startsWith(`//`)}function I(e){if(F(e))return e;let t=N(),n=e.replace(/^\/+/,``);return t!==`/`&&(e===P()||e.startsWith(t))?e:`${t}${n}`}function L(){return`${typeof window<`u`?window.location.origin:``}${P()}`}function R(e){return F(e)?e:`${L()}${I(e).slice(P().length)}`}function z(e){return R(e).replace(/^http/,`ws`)}function B(){A=null}a();function V({title:e,icon:t,headerRight:n,collapsible:r=!1,defaultOpen:i=!0,bodyClassName:a=`p-3`,children:s}){let[l,f]=u(i),p=!r||l,m=o(c,{children:[o(`span`,{className:`flex items-center gap-2 text-xs font-semibold uppercase tracking-wider text-foreground`,children:[t,e]}),r?d(l?b:x,{className:`h-3.5 w-3.5 text-foreground-subtle`}):n]}),h=`px-4 py-2 flex items-center justify-between ${p?`border-b border-border`:``}`;return o(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[r?d(`button`,{type:`button`,onClick:()=>f(e=>!e),className:`w-full text-left ${h}`,children:m}):d(`div`,{className:h,children:m}),p?d(`div`,{className:a,children:s}):null]})}function H({label:e,icon:t,children:n,footer:r}){return o(`div`,{className:`rounded-md border border-border/60 bg-background/40 px-3 py-2`,children:[o(`div`,{className:`mb-1 flex items-center gap-1.5 text-[11px] uppercase tracking-wider text-foreground-subtle`,children:[t,e]}),d(`div`,{className:`text-sm font-medium text-foreground`,children:n}),r?d(`div`,{className:`mt-0.5 text-[10px] text-foreground-subtle`,children:r}):null]})}a();var U=`capability.binding-changed`;function W(e,t){let[n,r]=u(null);return f(()=>{if(t===null){r(null);return}let n=!1,i=async()=>{try{let i=await e.deviceManager.getBindings.query({deviceId:t});n||r(i)}catch{n||r(e=>e)}};i();let a=e.live?.onEvent.subscribe({category:U},{onData:e=>{let n=e.data?.source;if(!n){i();return}n.type===`device`&&n.id===t&&i()}});return()=>{n=!0,a?.unsubscribe()}},[e,t]),s(()=>n?p(e,n):null,[e,n])}function G(e){let r=t(t=>e?e.subscribe(()=>t()):()=>void 0,[e]),i=t(()=>e?.value,[e]);return n(r,i,i)}function ue(e,t,n){let r=W(e,t);return G(r?n(r.state):void 0)}a();var K=`/addon/snapshot/media`;function de(e,n={}){let{width:r,baseUrl:i}=n,[a,o]=u(0);return{src:s(()=>{if(e===null||e<=0)return null;let t=i===void 0?P():i.replace(/\/+$/,``),n=new URLSearchParams;r!==void 0&&Number.isInteger(r)&&r>0&&n.set(`w`,String(r)),a>0&&(n.set(`force`,`1`),n.set(`r`,String(a)));let o=n.toString();return`${t}${K}/${String(e)}.jpg${o.length>0?`?${o}`:``}`},[e,r,i,a]),loading:!1,refresh:t(()=>{o(e=>e+1)},[])}}function fe(e){if(typeof e!=`object`||!e)return null;let t=Reflect.get(e,`data`);if(typeof t==`object`&&t){let e=Reflect.get(t,`capRouteReason`);if(typeof e==`string`)return e}return null}function pe(e){let t=fe(e);return t===null?(e instanceof Error?e.message:String(e)).includes(`provider not available`):t===`no-provider`||t===`node-offline`}var me=`rounded-lg border border-border bg-surface overflow-hidden`,he=`border-b border-border px-3 sm:px-4 py-1.5 sm:py-2`,ge=`p-2 sm:p-3 lg:p-4`,_e=`space-y-3 sm:space-y-4`,ve=`gap-2 sm:gap-3`,ye=`px-3 sm:px-4 py-1.5 sm:py-2`,be=`grid grid-cols-2 sm:grid-cols-2 lg:grid-cols-4`,xe=`grid grid-cols-1 lg:grid-cols-2`,Se=`flex flex-col-reverse md:flex-row`,Ce=`w-full md:w-44 lg:w-52 md:flex-shrink-0 border-b md:border-b-0 md:border-l border-border`,we=`sm`,Te=`flex min-w-0 flex-col gap-0.5 py-1.5 sm:flex-row sm:items-center`,Ee=`min-w-0 text-[11px] leading-tight text-foreground-subtle sm:w-32 sm:shrink-0 sm:pr-2`,De=`flex w-full min-w-0 items-center gap-1 sm:flex-1`,Oe=`min-w-0 break-all text-xs text-foreground sm:truncate`,ke=`text-[10px] sm:text-[11px] font-semibold text-foreground uppercase tracking-wider`,Ae=`text-[11px] sm:text-xs text-foreground`,je=`text-[10px] text-foreground-subtle`,Me=`text-[11px] sm:text-xs font-medium text-foreground`,Ne=`text-base sm:text-lg font-semibold leading-tight text-foreground`,Pe=`inline-flex items-center justify-center gap-1 rounded border border-border bg-surface px-1.5 py-0.5 sm:px-2 sm:py-1 text-[10px] sm:text-[11px] font-medium text-foreground hover:bg-surface-hover transition-colors disabled:opacity-40`,Fe=`inline-flex items-center justify-center gap-1 rounded border border-primary/40 bg-primary/15 px-1.5 py-0.5 sm:px-2 sm:py-1 text-[10px] sm:text-[11px] font-medium text-primary hover:bg-primary/25 transition-colors disabled:opacity-40`,Ie=`inline-flex items-center justify-center gap-1 rounded border border-danger/40 bg-danger/10 px-1.5 py-0.5 sm:px-2 sm:py-1 text-[10px] sm:text-[11px] font-medium text-danger hover:bg-danger/20 transition-colors disabled:opacity-40`,Le=`inline-flex items-center justify-center gap-1 rounded border border-warning/40 bg-warning/10 px-1.5 py-0.5 sm:px-2 sm:py-1 text-[10px] sm:text-[11px] font-medium text-warning hover:bg-warning/20 transition-colors disabled:opacity-40`,Re=`w-full rounded border border-border bg-background px-1.5 py-0.5 sm:px-2 sm:py-1 text-[11px] sm:text-xs text-foreground focus:border-primary focus:ring-1 focus:ring-primary/30 outline-none`,ze=`inline-flex items-center gap-1 rounded-full border px-1.5 py-0.5 text-[10px] font-medium transition-colors`,Be=`border-primary/50 bg-primary/15 text-primary`,Ve=`border-border bg-surface text-foreground-subtle hover:bg-surface-hover`,q=[`day`,`ir`],He={day:`Daylight`,ir:`Night (IR)`,night:`Night`,dawn:`Dawn`,dusk:`Dusk`};function J(e){return He[e]??e}function Ue(e){let t=new Set(e.coveredConditions),n=q.map(e=>`${J(e)} ${t.has(e)?`✓`:`✗`}`),r=[...t].filter(e=>!q.some(t=>t===e));for(let e of r)n.push(`${J(e)} ✓`);let i=q.filter(e=>!t.has(e));if(i.length===0)return n.join(` · `);if(t.size===0)return`${n.join(` · `)} — nothing captured yet, so this scene is not watching.`;let a=i.map(e=>J(e).toLowerCase()).join(` and `);return e.onUncoveredCondition===`judge-anyway`?`${n.join(` · `)} — ${a} judged against the references you do have.`:`${n.join(` · `)} — optional; checks in ${a} are skipped.`}function We(e){if(e.suspendedCondition===null)return null;let t=J(e.suspendedCondition).toLowerCase();return`Paused — nothing was captured in ${t}, so checks are on hold until the light changes back. Capture ${t} if you want it watched around the clock.`}var Ge={"no-reference-for-condition":`can’t tell — nothing has been captured for this scene yet. Press “Capture daylight” to photograph what normal looks like.`,"view-shifted":`can’t tell — the camera view has moved since the reference was captured. Re-capture it.`,"no-vision-profile":`can’t tell — the vision model is unreachable, so the change is on hold.`,"encoder-model-changed":`can’t tell — the embedding model changed, so the stored references are unreadable. Re-capture them.`,"no-snapshot":`can’t tell — this camera did not return a frame.`};function Ke(e,t){if(e.states.length===0)return`Not armed yet — capture the initial state to start watching.`;if(e.verdict===`unknown`)return e.unavailable===null?`can’t tell right now.`:Ge[e.unavailable];let n=e.verdict===`diverged`?e.divergedAt:e.armedAt,r=n===null?``:` for ${Z(Math.max(0,t-n))}`;if(e.latched)return e.verdict===`diverged`?`CHANGED${r} — press Reset when you have dealt with it.`:`Back to normal, but still flagged as changed${r}. Press Reset to clear it.`;let i=We(e);return i===null?e.verdict===`diverged`?`CHANGED${r}`:`Normal${r}`:i}function qe(e){return e.states.length===0?{text:`Not armed`,tone:`unknown`}:e.latched?{text:`Changed`,tone:`alarm`}:e.suspendedCondition===null?e.verdict===`unknown`?{text:`Can’t tell`,tone:`unknown`}:e.verdict===`diverged`?{text:`Changed`,tone:`alarm`}:{text:`Normal`,tone:`ok`}:{text:`Paused`,tone:`unknown`}}var Y=.4;function X(e){return e.width*e.height>Y}function Z(e){let t=Math.floor(e/1e3);if(t<60)return`${t}s`;let n=Math.floor(t/60);if(n<60)return`${n}m`;let r=Math.floor(n/60);return r<48?`${r}h`:`${Math.floor(r/24)}d`}a();var Q=O(`camstack:player-overlays-state`,null),$=O(`camstack:player-overlays-actions`,null);function Je({children:e}){let[n,r]=u(()=>new Map),[i,a]=u(()=>new Map),o=t(e=>{r(t=>{let n=new Map(t);return n.set(e.id,e),n})},[]),c=t(e=>{r(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n})},[]),l=t(e=>{a(t=>{let n=new Map(t);return n.set(e.id,e),n})},[]),f=t(e=>{a(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n})},[]),p=s(()=>({layers:n,buttons:i}),[n,i]),m=s(()=>({setLayer:o,removeLayer:c,setButton:l,removeButton:f}),[o,c,l,f]);return d(Q.Provider,{value:p,children:d($.Provider,{value:m,children:e})})}function Ye(){let e=r(Q);return s(()=>e?[...e.layers.values()].toSorted((e,t)=>e.order-t.order):[],[e])}function Xe(){let e=r(Q);return s(()=>e?[...e.buttons.values()].toSorted((e,t)=>e.order-t.order):[],[e])}function Ze(e){let t=r($);f(()=>{if(!(!t||!e))return t.setLayer(e),()=>t.removeLayer(e.id)},[t,e])}function Qe(e){let t=r($);f(()=>{if(!(!t||!e))return t.setButton(e),()=>t.removeButton(e.id)},[t,e])}export{z as $,Ee as A,ke as B,be as C,me as D,ge as E,Ce as F,W as G,pe as H,_e as I,H as J,ue as K,Ae as L,De as M,Oe as N,he as O,Se as P,R as Q,je as R,xe as S,ye as T,K as U,Me as V,de as W,L as X,V as Y,I as Z,Le as _,ne as _t,Xe as a,oe as at,Ve as b,qe as c,re as ct,X as d,T as dt,N as et,Ke as f,w as ft,Fe as g,b as gt,Ie as h,x as ht,Qe as i,se as it,we as j,Te as k,Ue as l,D as lt,Pe as m,S as mt,Ze as n,P as nt,Y as o,O as ot,J as p,C as pt,G as q,Ye as r,ae as rt,q as s,ie as st,Je as t,B as tt,Z as u,E as ut,Be as v,y as vt,Re as w,ve as x,ze as y,Ne as z};
|
|
1
|
+
import{D as e,I as t,J as n,L as r,O as i,Q as a,S as o,W as s,b as c,k as l,q as u,x as d,z as f}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{It as p}from"./client-DdTCFotl.js";a();var m=(...e)=>e.filter((e,t,n)=>!!e&&e.trim()!==``&&n.indexOf(e)===t).join(` `).trim(),h=e=>e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase(),ee=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,n)=>n?n.toUpperCase():t.toLowerCase()),g=e=>{let t=ee(e);return t.charAt(0).toUpperCase()+t.slice(1)},_={xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`},v=e=>{for(let t in e)if(t.startsWith(`aria-`)||t===`role`||t===`title`)return!0;return!1},te=l(({color:e=`currentColor`,size:t=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:a=``,children:o,iconNode:s,...c},l)=>i(`svg`,{ref:l,..._,width:t,height:t,stroke:e,strokeWidth:r?Number(n)*24/Number(t):n,className:m(`lucide`,a),...!o&&!v(c)&&{"aria-hidden":`true`},...c},[...s.map(([e,t])=>i(e,t)),...Array.isArray(o)?o:[o]]));a();var y=(e,t)=>{let n=l(({className:n,...r},a)=>i(te,{ref:a,iconNode:t,className:m(`lucide-${h(g(e))}`,`lucide-${e}`,n),...r}));return n.displayName=g(e),n},ne=y(`camera`,[[`path`,{d:`M13.997 4a2 2 0 0 1 1.76 1.05l.486.9A2 2 0 0 0 18.003 7H20a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h1.997a2 2 0 0 0 1.759-1.048l.489-.904A2 2 0 0 1 10.004 4z`,key:`18u6gg`}],[`circle`,{cx:`12`,cy:`13`,r:`3`,key:`1vg3eu`}]]),b=y(`chevron-down`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),x=y(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),S=y(`eye-off`,[[`path`,{d:`M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49`,key:`ct8e1f`}],[`path`,{d:`M14.084 14.158a3 3 0 0 1-4.242-4.242`,key:`151rxh`}],[`path`,{d:`M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143`,key:`13bj9a`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),C=y(`grid-2x2`,[[`path`,{d:`M12 3v18`,key:`108xh3`}],[`path`,{d:`M3 12h18`,key:`1i2n21`}],[`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,key:`h1oib`}]]),w=y(`image-off`,[[`line`,{x1:`2`,x2:`22`,y1:`2`,y2:`22`,key:`a6p6uj`}],[`path`,{d:`M10.41 10.41a2 2 0 1 1-2.83-2.83`,key:`1bzlo9`}],[`line`,{x1:`13.5`,x2:`6`,y1:`13.5`,y2:`21`,key:`1q0aeu`}],[`line`,{x1:`18`,x2:`21`,y1:`12`,y2:`15`,key:`5mozeu`}],[`path`,{d:`M3.59 3.59A1.99 1.99 0 0 0 3 5v14a2 2 0 0 0 2 2h14c.55 0 1.052-.22 1.41-.59`,key:`mmje98`}],[`path`,{d:`M21 15V5a2 2 0 0 0-2-2H9`,key:`43el77`}]]),T=y(`mic-off`,[[`path`,{d:`M12 19v3`,key:`npa21l`}],[`path`,{d:`M15 9.34V5a3 3 0 0 0-5.68-1.33`,key:`1gzdoj`}],[`path`,{d:`M16.95 16.95A7 7 0 0 1 5 12v-2`,key:`cqa7eg`}],[`path`,{d:`M18.89 13.23A7 7 0 0 0 19 12v-2`,key:`16hl24`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M9 9v3a3 3 0 0 0 5.12 2.12`,key:`r2i35w`}]]),E=y(`mic`,[[`path`,{d:`M12 19v3`,key:`npa21l`}],[`path`,{d:`M19 10v2a7 7 0 0 1-14 0v-2`,key:`1vc78b`}],[`rect`,{x:`9`,y:`2`,width:`6`,height:`13`,rx:`3`,key:`s6n7sd`}]]),D=y(`rotate-ccw`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]),re=y(`square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]),ie=y(`trash-2`,[[`path`,{d:`M10 11v6`,key:`nco0om`}],[`path`,{d:`M14 11v6`,key:`outv1u`}],[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]]);a();function O(t,n){if(typeof globalThis>`u`)return e(n);let r=globalThis.__camstackSharedContexts,i=r??new Map;r||(globalThis.__camstackSharedContexts=i);let a=i.get(t);if(a)return a;let o=e(n);return i.set(t,o),o}a();var k=O(`camstack:system`,null);function ae({system:e,children:t}){return d(k.Provider,{value:e,children:t})}function oe(){let e=r(k);if(!e)throw Error(`useSystem(): no <SystemProvider> in tree`);return e}function se(){return r(k)}var ce=`camstack-mount`,le=/^\/(?:[A-Za-z0-9_\-.]+\/)*$/,A=null;function j(e){if(e==null||e===``)return null;let t=e.endsWith(`/`)?e:`${e}/`;return!le.test(t)||t.includes(`/../`)||t.includes(`/./`)?null:t}function M(){if(typeof document>`u`)return`/`;let e=j(document.querySelector(`meta[name="${ce}"]`)?.getAttribute(`content`));if(e!==null)return e;if(document.querySelector(`base[href]`)!==null)try{let e=new URL(document.baseURI);if(e.origin===window.location.origin){let t=j(e.pathname);if(t!==null)return t}}catch{}return`/`}function N(){return A===null&&(A=M()),A}function P(){return N().replace(/\/$/,``)}function F(e){return/^[a-z][a-z0-9+.-]*:/i.test(e)||e.startsWith(`//`)}function I(e){if(F(e))return e;let t=N(),n=e.replace(/^\/+/,``);return t!==`/`&&(e===P()||e.startsWith(t))?e:`${t}${n}`}function L(){return`${typeof window<`u`?window.location.origin:``}${P()}`}function R(e){return F(e)?e:`${L()}${I(e).slice(P().length)}`}function z(e){return R(e).replace(/^http/,`ws`)}function B(){A=null}a();function V({title:e,icon:t,headerRight:n,collapsible:r=!1,defaultOpen:i=!0,bodyClassName:a=`p-3`,children:s}){let[l,f]=u(i),p=!r||l,m=o(c,{children:[o(`span`,{className:`flex items-center gap-2 text-xs font-semibold uppercase tracking-wider text-foreground`,children:[t,e]}),r?d(l?b:x,{className:`h-3.5 w-3.5 text-foreground-subtle`}):n]}),h=`px-4 py-2 flex items-center justify-between ${p?`border-b border-border`:``}`;return o(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[r?d(`button`,{type:`button`,onClick:()=>f(e=>!e),className:`w-full text-left ${h}`,children:m}):d(`div`,{className:h,children:m}),p?d(`div`,{className:a,children:s}):null]})}function H({label:e,icon:t,children:n,footer:r}){return o(`div`,{className:`rounded-md border border-border/60 bg-background/40 px-3 py-2`,children:[o(`div`,{className:`mb-1 flex items-center gap-1.5 text-[11px] uppercase tracking-wider text-foreground-subtle`,children:[t,e]}),d(`div`,{className:`text-sm font-medium text-foreground`,children:n}),r?d(`div`,{className:`mt-0.5 text-[10px] text-foreground-subtle`,children:r}):null]})}a();var U=`capability.binding-changed`;function W(e,t){let[n,r]=u(null);return f(()=>{if(t===null){r(null);return}let n=!1,i=async()=>{try{let i=await e.deviceManager.getBindings.query({deviceId:t});n||r(i)}catch{n||r(e=>e)}};i();let a=e.live?.onEvent.subscribe({category:U},{onData:e=>{let n=e.data?.source;if(!n){i();return}n.type===`device`&&n.id===t&&i()}});return()=>{n=!0,a?.unsubscribe()}},[e,t]),s(()=>n?p(e,n):null,[e,n])}function G(e){let r=t(t=>e?e.subscribe(()=>t()):()=>void 0,[e]),i=t(()=>e?.value,[e]);return n(r,i,i)}function ue(e,t,n){let r=W(e,t);return G(r?n(r.state):void 0)}a();var K=`/addon/snapshot/media`;function de(e,n={}){let{width:r,baseUrl:i}=n,[a,o]=u(0);return{src:s(()=>{if(e===null||e<=0)return null;let t=i===void 0?P():i.replace(/\/+$/,``),n=new URLSearchParams;r!==void 0&&Number.isInteger(r)&&r>0&&n.set(`w`,String(r)),a>0&&(n.set(`force`,`1`),n.set(`r`,String(a)));let o=n.toString();return`${t}${K}/${String(e)}.jpg${o.length>0?`?${o}`:``}`},[e,r,i,a]),loading:!1,refresh:t(()=>{o(e=>e+1)},[])}}function fe(e){if(typeof e!=`object`||!e)return null;let t=Reflect.get(e,`data`);if(typeof t==`object`&&t){let e=Reflect.get(t,`capRouteReason`);if(typeof e==`string`)return e}return null}function pe(e){let t=fe(e);return t===null?(e instanceof Error?e.message:String(e)).includes(`provider not available`):t===`no-provider`||t===`node-offline`}var me=`rounded-lg border border-border bg-surface overflow-hidden`,he=`border-b border-border px-3 sm:px-4 py-1.5 sm:py-2`,ge=`p-2 sm:p-3 lg:p-4`,_e=`space-y-3 sm:space-y-4`,ve=`gap-2 sm:gap-3`,ye=`px-3 sm:px-4 py-1.5 sm:py-2`,be=`grid grid-cols-2 sm:grid-cols-2 lg:grid-cols-4`,xe=`grid grid-cols-1 lg:grid-cols-2`,Se=`flex flex-col-reverse md:flex-row`,Ce=`w-full md:w-44 lg:w-52 md:flex-shrink-0 border-b md:border-b-0 md:border-l border-border`,we=`sm`,Te=`flex min-w-0 flex-col gap-0.5 py-1.5 sm:flex-row sm:items-center`,Ee=`min-w-0 text-[11px] leading-tight text-foreground-subtle sm:w-32 sm:shrink-0 sm:pr-2`,De=`flex w-full min-w-0 items-center gap-1 sm:flex-1`,Oe=`min-w-0 break-all text-xs text-foreground sm:truncate`,ke=`text-[10px] sm:text-[11px] font-semibold text-foreground uppercase tracking-wider`,Ae=`text-[11px] sm:text-xs text-foreground`,je=`text-[10px] text-foreground-subtle`,Me=`text-[11px] sm:text-xs font-medium text-foreground`,Ne=`text-base sm:text-lg font-semibold leading-tight text-foreground`,Pe=`inline-flex items-center justify-center gap-1 rounded border border-border bg-surface px-1.5 py-0.5 sm:px-2 sm:py-1 text-[10px] sm:text-[11px] font-medium text-foreground hover:bg-surface-hover transition-colors disabled:opacity-40`,Fe=`inline-flex items-center justify-center gap-1 rounded border border-primary/40 bg-primary/15 px-1.5 py-0.5 sm:px-2 sm:py-1 text-[10px] sm:text-[11px] font-medium text-primary hover:bg-primary/25 transition-colors disabled:opacity-40`,Ie=`inline-flex items-center justify-center gap-1 rounded border border-danger/40 bg-danger/10 px-1.5 py-0.5 sm:px-2 sm:py-1 text-[10px] sm:text-[11px] font-medium text-danger hover:bg-danger/20 transition-colors disabled:opacity-40`,Le=`inline-flex items-center justify-center gap-1 rounded border border-warning/40 bg-warning/10 px-1.5 py-0.5 sm:px-2 sm:py-1 text-[10px] sm:text-[11px] font-medium text-warning hover:bg-warning/20 transition-colors disabled:opacity-40`,Re=`w-full rounded border border-border bg-background px-1.5 py-0.5 sm:px-2 sm:py-1 text-[11px] sm:text-xs text-foreground focus:border-primary focus:ring-1 focus:ring-primary/30 outline-none`,ze=`inline-flex items-center gap-1 rounded-full border px-1.5 py-0.5 text-[10px] font-medium transition-colors`,Be=`border-primary/50 bg-primary/15 text-primary`,Ve=`border-border bg-surface text-foreground-subtle hover:bg-surface-hover`,q=[`day`,`ir`],He={day:`Daylight`,ir:`Night (IR)`,night:`Night`,dawn:`Dawn`,dusk:`Dusk`};function J(e){return He[e]??e}function Ue(e){let t=new Set(e.coveredConditions),n=q.map(e=>`${J(e)} ${t.has(e)?`✓`:`✗`}`),r=[...t].filter(e=>!q.some(t=>t===e));for(let e of r)n.push(`${J(e)} ✓`);let i=q.filter(e=>!t.has(e));if(i.length===0)return n.join(` · `);if(t.size===0)return`${n.join(` · `)} — nothing captured yet, so this scene is not watching.`;let a=i.map(e=>J(e).toLowerCase()).join(` and `);return e.onUncoveredCondition===`judge-anyway`?`${n.join(` · `)} — ${a} judged against the references you do have.`:`${n.join(` · `)} — optional; checks in ${a} are skipped.`}function We(e){if(e.suspendedCondition===null)return null;let t=J(e.suspendedCondition).toLowerCase();return`Paused — nothing was captured in ${t}, so checks are on hold until the light changes back. Capture ${t} if you want it watched around the clock.`}var Ge={"no-reference-for-condition":`can’t tell — nothing has been captured for this scene yet. Press “Capture daylight” to photograph what normal looks like.`,"view-shifted":`can’t tell — the camera view has moved since the reference was captured. Re-capture it.`,"no-vision-profile":`can’t tell — the vision model is unreachable, so the change is on hold.`,"encoder-model-changed":`can’t tell — the embedding model changed, so the stored references are unreadable. Re-capture them.`,"no-snapshot":`can’t tell — this camera did not return a frame.`};function Ke(e,t){if(e.states.length===0)return`Not armed yet — capture the initial state to start watching.`;if(e.verdict===`unknown`)return e.unavailable===null?`can’t tell right now.`:Ge[e.unavailable];let n=e.verdict===`diverged`?e.divergedAt:e.armedAt,r=n===null?``:` for ${Z(Math.max(0,t-n))}`;if(e.latched)return e.verdict===`diverged`?`CHANGED${r} — press Reset when you have dealt with it.`:`Back to normal, but still flagged as changed${r}. Press Reset to clear it.`;let i=We(e);return i===null?e.verdict===`diverged`?`CHANGED${r}`:`Normal${r}`:i}function qe(e){return e.states.length===0?{text:`Not armed`,tone:`unknown`}:e.latched?{text:`Changed`,tone:`alarm`}:e.suspendedCondition===null?e.verdict===`unknown`?{text:`Can’t tell`,tone:`unknown`}:e.verdict===`diverged`?{text:`Changed`,tone:`alarm`}:{text:`Normal`,tone:`ok`}:{text:`Paused`,tone:`unknown`}}var Y=.4;function X(e){return e.width*e.height>Y}function Z(e){let t=Math.floor(e/1e3);if(t<60)return`${t}s`;let n=Math.floor(t/60);if(n<60)return`${n}m`;let r=Math.floor(n/60);return r<48?`${r}h`:`${Math.floor(r/24)}d`}a();var Q=O(`camstack:player-overlays-state`,null),$=O(`camstack:player-overlays-actions`,null);function Je({children:e}){let[n,r]=u(()=>new Map),[i,a]=u(()=>new Map),o=t(e=>{r(t=>{let n=new Map(t);return n.set(e.id,e),n})},[]),c=t(e=>{r(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n})},[]),l=t(e=>{a(t=>{let n=new Map(t);return n.set(e.id,e),n})},[]),f=t(e=>{a(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n})},[]),p=s(()=>({layers:n,buttons:i}),[n,i]),m=s(()=>({setLayer:o,removeLayer:c,setButton:l,removeButton:f}),[o,c,l,f]);return d(Q.Provider,{value:p,children:d($.Provider,{value:m,children:e})})}function Ye(){let e=r(Q);return s(()=>e?[...e.layers.values()].toSorted((e,t)=>e.order-t.order):[],[e])}function Xe(){let e=r(Q);return s(()=>e?[...e.buttons.values()].toSorted((e,t)=>e.order-t.order):[],[e])}function Ze(e){let t=r($);f(()=>{if(!(!t||!e))return t.setLayer(e),()=>t.removeLayer(e.id)},[t,e])}function Qe(e){let t=r($);f(()=>{if(!(!t||!e))return t.setButton(e),()=>t.removeButton(e.id)},[t,e])}export{z as $,Ee as A,ke as B,be as C,me as D,ge as E,Ce as F,W as G,pe as H,_e as I,H as J,ue as K,Ae as L,De as M,Oe as N,he as O,Se as P,R as Q,je as R,xe as S,ye as T,K as U,Me as V,de as W,L as X,V as Y,I as Z,Le as _,ne as _t,Xe as a,oe as at,Ve as b,qe as c,re as ct,X as d,T as dt,N as et,Ke as f,w as ft,Fe as g,b as gt,Ie as h,x as ht,Qe as i,se as it,we as j,Te as k,Ue as l,D as lt,Pe as m,S as mt,Ze as n,P as nt,Y as o,O as ot,J as p,C as pt,G as q,Ye as r,ae as rt,q as s,ie as st,Je as t,B as tt,Z as u,E as ut,Be as v,y as vt,Re as w,ve as x,ze as y,Ne as z};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e,t}from"./virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-Cns_eCdr.js";export{t as get,e as init};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{vt as e}from"./player-overlays-
|
|
1
|
+
import{vt as e}from"./player-overlays-CVsVEZkx.js";var t=e(`send`,[[`path`,{d:`M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z`,key:`1ffxy3`}],[`path`,{d:`m21.854 2.147-10.94 10.939`,key:`12cjpa`}]]);export{t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{vt as e}from"./player-overlays-
|
|
1
|
+
import{vt as e}from"./player-overlays-CVsVEZkx.js";var t=e(`settings-2`,[[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`path`,{d:`M19 7h-9`,key:`6i9tg`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]);export{t};
|