@camstack/addon-admin-ui 1.2.477 → 1.2.478

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.
Files changed (52) hide show
  1. package/dist/assets/{Addons-CbHidHOJ.js → Addons-DAuTfOiO.js} +1 -1
  2. package/dist/assets/{AdminSectionedPage-DtiHBXGC.js → AdminSectionedPage-BByl6Zss.js} +1 -1
  3. package/dist/assets/{AiProfiles-7FToWDqj.js → AiProfiles-Cvu3UHy2.js} +1 -1
  4. package/dist/assets/{BrokerForm-D5-q8F_8.js → BrokerForm-D6ln7R0A.js} +1 -1
  5. package/dist/assets/{Build-DwW5kYsa.js → Build-C0J5ce6Z.js} +1 -1
  6. package/dist/assets/{Calendars-BhMRY6EV.js → Calendars-G5xKjOn2.js} +1 -1
  7. package/dist/assets/{Cluster-z11q6anB.js → Cluster-w5Kcsast.js} +1 -1
  8. package/dist/assets/{CompositionBlockEditor-CElNVsCR.js → CompositionBlockEditor-BsmLsHO7.js} +1 -1
  9. package/dist/assets/{CompositionEditorPage-NzgZB76B.js → CompositionEditorPage-AIRu6m_i.js} +1 -1
  10. package/dist/assets/{Data-D_U-HkwO.js → Data-r1IoElgA.js} +1 -1
  11. package/dist/assets/{DeviceDetail-D89wXQHP.js → DeviceDetail-Dz6PV7rK.js} +1 -1
  12. package/dist/assets/{DeviceDoActionFields-Bj4gX0r-.js → DeviceDoActionFields-gklZW8H7.js} +1 -1
  13. package/dist/assets/{Devices-BnhDZU3y.js → Devices-z5XqFK0f.js} +1 -1
  14. package/dist/assets/{HelperWizard-CrXHYd19.js → HelperWizard-B5Evcb8G.js} +1 -1
  15. package/dist/assets/{History-BsJBR2zt.js → History-DLllXIdk.js} +1 -1
  16. package/dist/assets/{Identity-B_6I_sCY.js → Identity-gwaZ5bXU.js} +1 -1
  17. package/dist/assets/{IntegrationDetail-B9L7AfYy.js → IntegrationDetail-P1tm0l2J.js} +1 -1
  18. package/dist/assets/{IntegrationHub-CSaA690G.js → IntegrationHub-Dv8jClEP.js} +1 -1
  19. package/dist/assets/{Integrations-B-KtSB_m.js → Integrations-B9RbWg-F.js} +1 -1
  20. package/dist/assets/Integrations-BLXg84-0.js +1 -0
  21. package/dist/assets/{Library-3dGkOQB5.js → Library-BXbZKXfl.js} +1 -1
  22. package/dist/assets/{Locations-Bh5GRDCv.js → Locations-CjHnNjAh.js} +1 -1
  23. package/dist/assets/{Logs-diqSxXEc.js → Logs-D7ADXC_5.js} +1 -1
  24. package/dist/assets/{MyAccess-BqulMSGv.js → MyAccess-id2Dmf9N.js} +1 -1
  25. package/dist/assets/{Network-C8Gpb2Vn.js → Network-BS9VI_eu.js} +1 -1
  26. package/dist/assets/{NodeAddonsSettingsPanel-Dq6sGWkR.js → NodeAddonsSettingsPanel-GEn1r68w.js} +1 -1
  27. package/dist/assets/{Notifications-C5w5t75z.js → Notifications-CIXn3wxj.js} +1 -1
  28. package/dist/assets/{Pipeline-CjumfHMc.js → Pipeline-B6AdA9Ua.js} +1 -1
  29. package/dist/assets/{Recordings-DE76fgEt.js → Recordings-2Ej5v6LZ.js} +1 -1
  30. package/dist/assets/{ScanNetworkModal-DXzDOpxk.js → ScanNetworkModal-CJoDRy24.js} +1 -1
  31. package/dist/assets/{SessionsList-Ca-zN1Fi.js → SessionsList-CMV9rDkY.js} +1 -1
  32. package/dist/assets/{Showroom-B9HZ38O5.js → Showroom-eCnhoQBD.js} +1 -1
  33. package/dist/assets/{System-CHEbMPI_.js → System-AxGI_wdI.js} +1 -1
  34. package/dist/assets/{Terminal-CWFZuQLg.js → Terminal-Br0QNfMN.js} +1 -1
  35. package/dist/assets/{assignment-candidates-BcnFMc1B.js → assignment-candidates-BMhC6h3l.js} +1 -1
  36. package/dist/assets/{board-model-gmvqxkjB.js → board-model--9Jw6SCm.js} +1 -1
  37. package/dist/assets/{device-integration-icon-0oWIIjcP.js → device-integration-icon-DEZs4Umq.js} +1 -1
  38. package/dist/assets/{format-CIO4xeN9.js → format-fYneBFV6.js} +1 -1
  39. package/dist/assets/i18n-D0o08mg-.js +1 -0
  40. package/dist/assets/{index-D4ZlWCxy.css → index-D4id__eL.css} +1 -1
  41. package/dist/assets/index-XXQ5yMw_.js +4 -0
  42. package/dist/assets/{linked-devices-model-BoOq02QT.js → linked-devices-model-DMEJU3bE.js} +1 -1
  43. package/dist/assets/{location-owned-usage-IF2k-L3A.js → location-owned-usage-8xhfNE7j.js} +1 -1
  44. package/dist/assets/{mf-entry-bootstrap-0-f45a46c2.js → mf-entry-bootstrap-0-dcdd32c2.js} +1 -1
  45. package/dist/assets/{step-inspector-model-CyqFN-LU.js → step-inspector-model-CI19RBoT.js} +1 -1
  46. package/dist/assets/{useNodeUrlSelection-DGV2ltbG.js → useNodeUrlSelection-DWbo46bM.js} +1 -1
  47. package/dist/index.html +4 -4
  48. package/dist/server/addon.js +1 -1
  49. package/package.json +1 -1
  50. package/dist/assets/Integrations-CMW4LOX-.js +0 -1
  51. package/dist/assets/i18n-xhwARoF0.js +0 -1
  52. package/dist/assets/index-C3uCLHv0.js +0 -4
@@ -1 +1 @@
1
- import{t as e}from"./i18n-xhwARoF0.js";import{t}from"./assignment-candidates-BcnFMc1B.js";function n(e){return e.slot===`linked-devices`}function r(t){if(t.status===`error`)return{kind:`unknown`,reason:t.error?.message??e.t(`helpers.customize.requestFailed`)};if(t.status===`pending`||t.data===void 0)return{kind:`pending`};for(let e of t.data)if(e.state===`ok`&&e.slot===`linked-devices`&&n(e.value))return{kind:`present`,slot:e,value:e.value};let r=t.data.find(e=>e.state===`unreachable`);return r!==void 0&&r.state===`unreachable`?{kind:`unknown`,reason:r.reason}:{kind:`absent`}}function i(e,t){let n=t.trackedDeviceIds??[],r=e=>t=>({deviceId:t.deviceId,name:t.name,health:t.health,implied:e,tracked:n.includes(t.deviceId)});return[...e.sources.map(r(!1)),...(e.impliedSources??[]).map(r(!0))]}function a(e,t){let n=new Set([...e.sources,...e.impliedSources??[]].map(e=>e.deviceId));return(t.trackedDeviceIds??[]).filter(e=>!n.has(e))}function o(e,t){return{...e,deviceIds:[...e.deviceIds,...t.filter(t=>!e.deviceIds.includes(t))]}}function s(e,t){return{...e,deviceIds:e.deviceIds.filter(e=>e!==t),...e.trackedDeviceIds===void 0?{}:{trackedDeviceIds:e.trackedDeviceIds.filter(e=>e!==t)}}}function c(e,t,n){let r=e.trackedDeviceIds??[],i=n?[...r.filter(e=>e!==t),t]:r.filter(e=>e!==t);return{...e,trackedDeviceIds:i}}function l(e,n,r){return e.flatMap(e=>{let i=n.get(e.deviceId);return r.has(e.deviceId)||i===void 0?[]:[{deviceId:e.deviceId,ref:{addonId:i.addonId,stableId:i.stableId},name:e.parentName===null?e.name:`${e.parentName} · ${e.name}`,detail:t(i.integration,e.location),meta:e.type,caps:[],value:null}]})}export{o as a,a as i,i as n,c as o,r,s,l as t};
1
+ import{t as e}from"./i18n-D0o08mg-.js";import{t}from"./assignment-candidates-BMhC6h3l.js";function n(e){return e.slot===`linked-devices`}function r(t){if(t.status===`error`)return{kind:`unknown`,reason:t.error?.message??e.t(`helpers.customize.requestFailed`)};if(t.status===`pending`||t.data===void 0)return{kind:`pending`};for(let e of t.data)if(e.state===`ok`&&e.slot===`linked-devices`&&n(e.value))return{kind:`present`,slot:e,value:e.value};let r=t.data.find(e=>e.state===`unreachable`);return r!==void 0&&r.state===`unreachable`?{kind:`unknown`,reason:r.reason}:{kind:`absent`}}function i(e,t){let n=t.trackedDeviceIds??[],r=e=>t=>({deviceId:t.deviceId,name:t.name,health:t.health,implied:e,tracked:n.includes(t.deviceId)});return[...e.sources.map(r(!1)),...(e.impliedSources??[]).map(r(!0))]}function a(e,t){let n=new Set([...e.sources,...e.impliedSources??[]].map(e=>e.deviceId));return(t.trackedDeviceIds??[]).filter(e=>!n.has(e))}function o(e,t){return{...e,deviceIds:[...e.deviceIds,...t.filter(t=>!e.deviceIds.includes(t))]}}function s(e,t){return{...e,deviceIds:e.deviceIds.filter(e=>e!==t),...e.trackedDeviceIds===void 0?{}:{trackedDeviceIds:e.trackedDeviceIds.filter(e=>e!==t)}}}function c(e,t,n){let r=e.trackedDeviceIds??[],i=n?[...r.filter(e=>e!==t),t]:r.filter(e=>e!==t);return{...e,trackedDeviceIds:i}}function l(e,n,r){return e.flatMap(e=>{let i=n.get(e.deviceId);return r.has(e.deviceId)||i===void 0?[]:[{deviceId:e.deviceId,ref:{addonId:i.addonId,stableId:i.stableId},name:e.parentName===null?e.name:`${e.parentName} · ${e.name}`,detail:t(i.integration,e.location),meta:e.type,caps:[],value:null}]})}export{o as a,a as i,i as n,c as o,r,s,l as t};
@@ -1 +1 @@
1
- import{C as e,K as t,R as n,S as r,V as i,Y as a,et as o,o as s}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{D as c,En as l,Fn as u,It as d,Sr as f,dt as p,kn as m,or as h,ot as g,xi as _,yi as v,zr as y}from"./player-overlays-Dbv95cvz.js";import{ia as b}from"./client-DvJxGh2F.js";import{t as x}from"./archive-Brq5E-qM.js";import{t as S}from"./eraser-Bs0PJaPY.js";import{t as C}from"./hard-drive-download-iRJR_Xj9.js";import{Jl as ee,Kr as w,Sn as T,Wr as E,_r as D,bt as te,hr as ne,mi as O,mr as re,ou as ie,pr as ae,vr as k,yr as A}from"./src-DntJrWmU.js";import{t as j}from"./i18n-xhwARoF0.js";import{t as M}from"./useTranslation-BJr-n0es.js";import{P as oe,lr as se}from"./index-C3uCLHv0.js";import{t as N}from"./format-size-DIxKXxtj.js";o();function P(e){let t=e.trim().toLowerCase();return t.length===0?``:t.replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``)}function F(e,t){let n=P(t);return`${e}:${n.length>0?n:`default`}`}var I=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`]),L=[`recordings`,`data`,`mnt`,`media`,`Volumes`];function R(e){let t=L.findIndex(t=>t===`recordings`?e.startsWith(t):e===t);return t===-1?L.length:t}function ce(e){return e.filter(e=>!e.name.startsWith(`.`)&&!I.has(e.name)).toSorted((e,t)=>{let n=R(e.name)-R(t.name);return n===0?e.name.localeCompare(t.name):n}).map(e=>e.path)}function le({nodeId:t,value:o,onChange:s}){let{t:c}=M(),l=g().trpcClient,[u,d]=a([]),[f,p]=a(o),[m,h]=a(null),[_,v]=a(null),[y,b]=a(``),x=n(async(e,n)=>{v(null);try{let r=await l.filesystemBrowse.browse.query({nodeId:t,path:e});h(r),p(r.path),n&&s(r.path)}catch(e){v(e instanceof Error?e.message:`browse failed`)}},[l,t,s]);i(()=>{p(o),(async()=>{let e=await l.filesystemBrowse.browse.query({nodeId:t,path:`/`}).then(e=>e).catch(()=>null);if(e){d(ce(e.entries)),await x(o.startsWith(`/`)?o:`/`,!1);return}try{let e=await l.filesystemBrowse.listAllowedRoots.query({nodeId:t});d(e),await x(o&&e.some(e=>o.startsWith(e))?o:e[0]??``,!1)}catch(e){d([]),h(null),v(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 S=async()=>{if(!(!y.trim()||!m)){v(null);try{let e=`${m.path.replace(/\/+$/,``)}/${y.trim()}`;await l.filesystemBrowse.createDir.mutate({nodeId:t,path:e}),b(``),await x(m.path,!0)}catch(e){v(e instanceof Error?e.message:`create failed`)}}},C=e=>`${(e/1e9).toFixed(1)} GB`;return e(`div`,{className:`space-y-2 rounded border border-border p-2`,children:[r(`div`,{className:`flex flex-wrap gap-1`,children:u.map(e=>r(`button`,{onClick:()=>void x(e,!0),className:`rounded border border-border px-2 py-0.5 text-[10px] font-mono hover:border-primary/40`,children:e},e))}),r(`input`,{value:f,onChange:e=>{p(e.target.value),s(e.target.value)},placeholder:`/absolute/path`,className:`w-full rounded border border-border bg-background px-2 py-1 text-[11px] font-mono`}),m&&r(`div`,{className:`text-[10px] text-foreground-subtle`,children:c(`storage.pathBrowser.free`,{free:C(m.freeBytes),total:C(m.totalBytes)})}),r(`div`,{className:`max-h-40 space-y-0.5 overflow-y-auto`,children:m?.entries.map(t=>e(`button`,{onClick:()=>void x(t.path,!0),className:`block w-full truncate rounded px-2 py-1 text-left text-xs hover:bg-primary/5`,children:[`📁 `,t.name]},t.path))}),e(`div`,{className:`flex gap-1`,children:[r(`input`,{value:y,onChange:e=>b(e.target.value),placeholder:c(`storage.pathBrowser.newFolder`,`new folder`),className:`flex-1 rounded border border-border bg-background px-2 py-1 text-xs`}),r(`button`,{onClick:()=>void S(),className:`rounded border border-border px-2 py-1 text-xs hover:border-primary/40`,children:c(`storage.pathBrowser.create`,`Create`)})]}),_&&r(`div`,{className:`text-[10px] text-red-400`,children:_})]})}o();function z({initialType:n,onClose:i,onCreated:o}){let{t:c}=M(),l=s(),u=g().trpcClient,[d,f]=a(`picker`),[p,m]=a(n),[_,y]=a(null),[b,x]=a({}),[S,C]=a(``),[w,T]=a(null),[E,D]=a(!1),[O,j]=a(`hub`),[N,P]=a(null),[I,L]=a(!1),R=e=>x(t=>({...t,basePath:e})),ce=typeof b.basePath==`string`?b.basePath:``,z=ee(),B=t(()=>{let e=z.data;return Array.isArray(e)?e:[]},[z.data]),V=z.isLoading,H=ie({onSuccess:()=>{l.invalidateQueries({queryKey:[[`storage`,`listLocations`]]}),o()}}),U=t(()=>w!==null&&w.length>0?w:F(p,S),[p,S,w]),ue=async()=>{if(_){L(!0),P(null);try{P(await(e=>u.storage.testConfig.query(e))({providerId:_.providerId,config:b}))}catch(e){P({ok:!1,error:e instanceof Error?e.message:String(e)})}finally{L(!1)}}};return r(ae,{open:!0,onOpenChange:e=>!e&&i(),children:e(ne,{width:`md`,placement:`sheet-on-mobile`,scroll:`body`,children:[e(k,{children:[r(A,{children:{picker:`Add Location — Pick provider`,config:`Add Location — ${_?.displayName??``}`,naming:`Add Location — Name`}[d]}),e(`p`,{className:`text-xs text-foreground-subtle`,children:[c(`storage.addLocationWizard.type`,`Type:`),` `,r(`span`,{className:`font-mono`,children:p})]})]}),e(re,{children:[d===`picker`&&e(`div`,{className:`space-y-2`,children:[V&&r(`div`,{className:`text-xs text-foreground-subtle animate-pulse`,children:c(`storage.addLocationWizard.loadingProviders`,`Loading providers…`)}),!V&&B.length===0&&r(`div`,{className:`rounded border border-border bg-background px-3 py-4 text-center text-xs text-foreground-subtle`,children:r(se,{i18nKey:`storage.addLocationWizard.noProvider`,values:{type:p},components:{code:r(`code`,{className:`font-mono`})}})}),B.map(t=>e(`button`,{onClick:()=>{y(t),f(`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:[e(`div`,{className:`flex-1 min-w-0`,children:[r(`p`,{className:`text-xs font-semibold text-foreground`,children:t.displayName}),r(`p`,{className:`text-[10px] text-foreground-subtle font-mono mt-0.5 truncate`,children:t.providerId})]}),r(v,{className:`h-4 w-4 text-foreground-subtle flex-shrink-0`})]},t.providerId))]}),d===`config`&&_&&e(`div`,{className:`space-y-3`,children:[r(oe,{schema:_.configSchema,values:b,onChange:x}),_.nodeLocal&&e(`div`,{className:`space-y-2`,children:[r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:c(`storage.addLocationWizard.node`,`Node`)}),r(te,{selectedNodeId:O,onSelect:j,alwaysShow:!0}),r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:c(`storage.addLocationWizard.path`,`Path`)}),r(le,{nodeId:O,value:ce,onChange:R})]}),N&&r(`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?c(`storage.addLocationWizard.connectionOk`,`Connection OK.`):c(`storage.addLocationWizard.testFailed`,`Test failed: {{value1}}`,{value1:N.error??`unknown error`})}),e(`div`,{className:`flex items-center justify-between pt-1`,children:[r(`button`,{onClick:()=>f(`picker`),className:`rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground`,children:c(`common.back`,`Back`)}),e(`div`,{className:`flex items-center gap-2`,children:[r(`button`,{onClick:()=>{ue()},disabled:I,className:`rounded border border-border px-3 py-1.5 text-xs text-foreground hover:bg-primary/10 disabled:opacity-50`,children:I?c(`storage.addLocationWizard.testing`,`Testing…`):c(`storage.addLocationWizard.testConnection`,`Test connection`)}),r(`button`,{onClick:()=>f(`naming`),className:`rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90`,children:c(`common.next`,`Next`)})]})]})]}),d===`naming`&&_&&e(`div`,{className:`space-y-3`,children:[e(`div`,{className:`space-y-1`,children:[r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:c(`storage.addLocationWizard.displayName`,`Display name`)}),r(`input`,{type:`text`,value:S,onChange:e=>C(e.target.value),placeholder:c(`storage.addLocationWizard.on`,`{{type}} on {{displayName}}`,{type:p,displayName:_.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`})]}),e(`div`,{className:`space-y-1`,children:[e(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:[c(`storage.addLocationWizard.idLabel`),` `,r(`span`,{className:`lowercase tracking-normal text-foreground-subtle`,children:c(`storage.addLocationWizard.autoDerivedOverrideIfNeeded`,`— auto-derived; override if needed`)})]}),r(`input`,{type:`text`,value:U,onChange:e=>T(e.target.value),placeholder:F(p,S),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`}),e(`p`,{className:`text-[10px] text-foreground-subtle`,children:[c(`storage.addLocationWizard.format`,`Format:`),` `,r(`code`,{className:`font-mono`,children:c(`storage.addLocationWizard.typeSlug`,`<type>:<slug>`)}),`. Lowercase letters, digits, and hyphens only.`]})]}),e(`label`,{className:`flex items-start gap-2 rounded border border-border bg-background px-3 py-2 cursor-pointer hover:bg-primary/5`,children:[r(`input`,{type:`checkbox`,checked:E,onChange:e=>D(e.target.checked),className:`accent-primary mt-0.5`}),e(`div`,{className:`space-y-0.5`,children:[r(`div`,{className:`text-xs font-medium text-foreground`,children:c(`storage.addLocationWizard.enableImmediately`,`Enable immediately`)}),r(`div`,{className:`text-[10px] text-foreground-subtle`,children:c(`storage.addLocationWizard.aDisabledLocationReceivesNo`,`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&&r(`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)}),e(`div`,{className:`flex items-center justify-between pt-1`,children:[r(`button`,{onClick:()=>f(`config`),className:`rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground`,children:c(`common.back`,`Back`)}),e(`div`,{className:`flex items-center gap-2`,children:[r(`button`,{onClick:()=>{m(n),y(null),x({}),C(``),T(null),D(!1),P(null),f(`picker`)},className:`rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground`,children:c(`common.reset`,`Reset`)}),e(`button`,{onClick:()=>{_&&H.mutate({id:U,type:p,displayName:S.trim(),providerId:_.providerId,config:b,enabled:E,nodeId:_.nodeLocal?O:void 0})},disabled:H.isPending||S.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?r(h,{className:`h-3.5 w-3.5 animate-spin`}):null,H.isPending?c(`storage.addLocationWizard.saving`,`Saving…`):c(`common.save`,`Save`)]})]})]})]})]})]})})}function B(e){return b(e)}function V(e){return e===`active`}var H=[{mode:`active`,get label(){return j.t(`helpers.locationMode.activeLabel`)},get consequence(){return j.t(`helpers.locationMode.activeConsequence`)},requiresConfirmation:!1},{mode:`readonly`,get label(){return j.t(`helpers.locationMode.readonlyLabel`)},get consequence(){return j.t(`helpers.locationMode.readonlyConsequence`)},requiresConfirmation:!1},{mode:`drain`,get label(){return j.t(`helpers.locationMode.drainLabel`)},get consequence(){return j.t(`helpers.locationMode.drainConsequence`)},requiresConfirmation:!1},{mode:`disabled`,get label(){return j.t(`helpers.locationMode.disabledLabel`)},get consequence(){return j.t(`helpers.locationMode.disabledConsequence`)},requiresConfirmation:!0}];function U(e){return H.find(t=>t.mode===e)??H[0]}function ue(e){return U(e).requiresConfirmation}var de=`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 V(n)||!V(B(e))||t.some(t=>t.id!==e.id&&V(B(t)))?{blocked:!1,reason:``}:{blocked:!0,reason:de}}function fe(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 pe(e,t,n){return!(n===`single`||t.length<=1||V(B(e))&&t.filter(e=>V(B(e))).length<=1)}function me(e){return e===`active`?{enabled:!0,readOnly:!1}:e===`readonly`?{enabled:!1,readOnly:!1}:{enabled:!1,readOnly:!0}}function he(e,t){let n={...t.config??e.config};t.mode!==void 0&&(me(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:me(t.mode).enabled}}var ge=1024**3;function G(e){return typeof e==`number`&&Number.isFinite(e)?e:null}function _e(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 ve(e,t){return G(e[t===`gb`?`minFreeGb`:`minFreePercent`])}function ye(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 be(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 xe(e,t,n=10){if(e.unit===`gb`&&e.value!==null)return e.value*ge;let r=e.value??n;return t===null||t<=0?null:t*Math.min(100,Math.max(0,r))/100}function Se(e){return e===`gb`?j.t(`helpers.locationProtection.unitGb`):j.t(`helpers.locationProtection.unitPercent`)}function Ce(e,t=10){let n=e.value===null?j.t(`helpers.locationProtection.targetDefault`,{percent:String(t)}):e.unit===`gb`?j.t(`helpers.locationProtection.targetGb`,{value:String(e.value)}):j.t(`helpers.locationProtection.targetPercent`,{value:String(e.value)});return j.t(`helpers.locationProtection.helpText`,{target:n,percent:String(t)})}function we(e){return G(e.maxUsedGb)}function Te(e,t){let n=G(e.maxUsedGb);return n===null||n<0?null:{bytes:n*ge,reason:t===`drain`?`drain`:`legacy`}}o();function Ee({config:t,defaultPercent:n=10,onChange:i}){let{t:o}=M(),[s,c]=a(()=>_e(t).unit),l=ve(t,s),u={unit:s,value:l},d=we(t),f=e=>{c(e),i(ye(t,{unit:e,value:null}))},p=e=>{i(ye(t,{unit:s,value:be(e,s)}))};return e(`div`,{className:`space-y-1`,children:[r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:o(`storage.protectionPolicyField.protectedFreeSpace`,`Protected free space`)}),e(`div`,{className:`flex items-center gap-2`,children:[e(`select`,{"aria-label":o(`storage.protectionPolicyField.protectionUnit`,`Protection unit`),value:s,onChange:e=>{f(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:[r(`option`,{value:`percent`,children:o(`storage.protectionPolicyField.ofTheVolume`,`% of the volume`)}),r(`option`,{value:`gb`,children:o(`storage.protectionPolicyField.gbOfFreeSpace`,`GB of free space`)})]}),r(`input`,{type:`number`,"aria-label":Se(s),min:0,max:s===`percent`?100:void 0,value:l===null?``:l,placeholder:s===`percent`?String(n):o(`common.defaultWord`),onChange:e=>{p(e.target.value)},className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`})]}),r(`p`,{className:`text-[10px] text-foreground-subtle`,children:Ce(u,n)}),d!==null&&r(`p`,{className:`text-[10px] text-foreground-subtle italic`,children:o(`storage.protectionPolicyField.legacyMax`,{gb:d})})]})}o();function De({location:n,onClose:i,onSaved:o}){let{t:c}=M(),l=s(),u=g().trpcClient,[d,f]=a({...n.config}),[p,m]=a(n.displayName),[_,v]=a(null),[y,b]=a(!1),x=ee(),S=t(()=>{let e=x.data;return Array.isArray(e)?e.find(e=>e.providerId===n.providerId)??null:null},[x.data,n.providerId]),C=ie({onSuccess:()=>{l.invalidateQueries({queryKey:[[`storage`,`listLocations`]]}),o()}}),T=S?.shouldSaveDiskSpace===!0,E=S?.nodeLocal===!0,[O,j]=a(typeof n.nodeId==`string`?n.nodeId:`hub`),N=typeof d.basePath==`string`?d.basePath:``,P=e=>f(t=>({...t,basePath:e})),F=S?.minFreePercent??10,I=async()=>{b(!0),v(null);try{v(await(e=>u.storage.testConfig.query(e))({providerId:n.providerId,locationId:n.id,config:d}))}catch(e){v({ok:!1,error:e instanceof Error?e.message:String(e)})}finally{b(!1)}};return r(ae,{open:!0,onOpenChange:e=>!e&&i(),children:e(ne,{width:`md`,placement:`sheet-on-mobile`,scroll:`body`,children:[e(k,{children:[r(A,{children:c(`storage.editLocationModal.title`,{name:n.displayName})}),e(`p`,{className:`text-xs text-foreground-subtle`,children:[r(`span`,{className:`font-mono`,children:n.id}),` ·`,` `,S?.displayName??n.providerId]})]}),e(re,{className:`space-y-3`,children:[e(`div`,{className:`space-y-1`,children:[r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:c(`storage.editLocationModal.displayName`,`Display name`)}),r(`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`})]}),S&&r(oe,{schema:S.configSchema,values:d,onChange:f}),E&&e(`div`,{className:`space-y-2`,children:[r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:c(`storage.editLocationModal.node`,`Node`)}),r(te,{selectedNodeId:O,onSelect:j,alwaysShow:!0}),r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:c(`storage.editLocationModal.path`,`Path`)}),r(le,{nodeId:O,value:N,onChange:P})]}),T&&r(Ee,{config:d,defaultPercent:F,onChange:f}),!S&&!x.isLoading&&r(`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:r(se,{i18nKey:`storage.editLocationModal.providerGone`,values:{id:n.providerId},components:{code:r(`code`,{className:`font-mono`})}})}),_&&r(`div`,{className:`rounded border px-3 py-2 text-[11px] ${_.ok?`border-success/30 bg-success/5 text-success`:`border-danger/30 bg-danger/5 text-danger`}`,children:_.ok?c(`storage.editLocationModal.connectionOk`,`Connection OK.`):c(`storage.editLocationModal.testFailed`,`Test failed: {{value1}}`,{value1:_.error??`unknown error`})}),C.isError&&r(`div`,{className:`rounded border border-danger/30 bg-danger/5 text-danger px-3 py-2 text-[11px]`,children:C.error instanceof Error?C.error.message:String(C.error)})]}),e(D,{className:`justify-between`,children:[r(w,{variant:`outline`,size:`sm`,onClick:i,children:c(`common.cancel`,`Cancel`)}),e(`div`,{className:`flex items-center gap-2`,children:[r(w,{variant:`outline`,size:`sm`,onClick:()=>{I()},disabled:y||!S,children:y?c(`storage.editLocationModal.testing`,`Testing…`):c(`storage.editLocationModal.testConnection`,`Test connection`)}),e(w,{size:`sm`,onClick:()=>{C.mutate(he(n,{displayName:p.trim(),config:d,nodeId:E?O:n.nodeId}))},disabled:C.isPending||p.trim().length===0,children:[C.isPending?r(h,{className:`h-3.5 w-3.5 animate-spin`}):null,C.isPending?c(`storage.editLocationModal.saving`,`Saving…`):c(`common.save`,`Save`)]})]})]})]})})}function Oe(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function K(e){return typeof e==`number`&&Number.isFinite(e)?e:null}function ke(e){if(!Oe(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 Ae(e){let t=new Map;if(!Array.isArray(e))return t;for(let n of e){let e=ke(n);e!==null&&t.set(e.locationId,e)}return t}function je(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 Me(e,t){return e?t===void 0?{kind:`unreported`}:t.drained||t.bytesRemaining<=0?{kind:`drained`}:{kind:`draining`,bytesRemaining:t.bytesRemaining,drainedFraction:je(t),estimatedEmptyAtMs:t.estimatedEmptyAtMs}:{kind:`idle`}}function Ne(e){return e.mode===`drain`?!0:e.config.readOnly===!0}function Pe(e){return`${(e/1024**3).toFixed(e>=100*1024**3?0:1)} GB`}function Fe(e){return new Date(e).toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`})}function Ie({drain:t}){let{t:n}=M();if(t.kind===`idle`)return null;if(t.kind===`unreported`)return r(`span`,{"data-testid":`drain-unreported`,className:`text-[10px] text-foreground-subtle`,title:n(`storage.drainProgressLine.thisLocationIsDrainingThe`,`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:n(`storage.drainProgressLine.drainingRemainingNotReportedYet`,`Draining · remaining not reported yet`)});if(t.kind===`drained`)return r(`span`,{"data-testid":`drain-done`,className:`text-[10px] text-success`,title:n(`storage.drainProgressLine.everythingThatWasHereHas`,`Everything that was here has been moved. The location is still in drain mode — it receives no new writes until you change that.`),children:n(`storage.drainProgressLine.drainedNothingLeftToMove`,`Drained · nothing left to move`)});let i=t.drainedFraction===null?null:Math.round(t.drainedFraction*100);return e(`span`,{"data-testid":`drain-progress`,className:`flex items-center gap-1.5 text-[10px] text-foreground-subtle tabular-nums`,children:[i!==null&&r(`span`,{"data-testid":`drain-bar`,className:`inline-block h-1 w-10 rounded-full bg-border overflow-hidden`,role:`progressbar`,"aria-label":n(`storage.drainProgressLine.drainProgress`,`Drain progress`),"aria-valuenow":i,"aria-valuemin":0,"aria-valuemax":100,children:r(`span`,{className:`block h-full bg-warning`,style:{width:`${i}%`}})}),e(`span`,{children:[n(`storage.drainProgressLine.left`,{size:Pe(t.bytesRemaining)}),i!==null&&` · ${n(`storage.drainProgressLine.moved`,{percent:i})}`]}),t.estimatedEmptyAtMs===null?r(`span`,{"data-testid":`drain-eta-absent`,title:n(`storage.drainProgressLine.theDrainIsPacedBy`,`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:n(`storage.drainProgressLine.emptyTimeNotKnownYet`,`· empty time not known yet`)}):e(`span`,{"data-testid":`drain-eta`,children:[`·`,` `,n(`storage.drainProgressLine.empty`,{when:Fe(t.estimatedEmptyAtMs)})]})]})}var Le=[`ok`,`warn`,`critical`];function Re(e){return e>=.95?`critical`:e>=.85?`warn`:`ok`}function ze(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=ze((n-t)/n);return{fraction:r,severity:Re(r),recordingsFraction:ze(e.usedBytes/n),freeBytes:t,totalBytes:n}}function Be(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||Le.indexOf(e.severity)>Le.indexOf(a))&&(a=e.severity)}return{knownVolumes:t,unknownVolumes:n,totalBytes:r,freeBytes:i,severity:a}}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 Ve(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:N(n.ownedBytes);return{kind:`unknown`,owned:e,summary:e===null?j.t(`helpers.locationCapacityBar.unknownSummary`):j.t(`helpers.locationCapacityBar.unknownSummaryOwned`,{size:e})}}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?Re(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:N(r),freeTotal:N(a),freeTotalPercent:X(a/r),used:N(p),usedPercent:X(p/r),free:N(u),freePercent:X(u/r),reserve:s===0?null:j.t(`helpers.locationCapacityBar.reserveKept`,{size:N(s)}),owned:f===null||_===null?null:j.t(`helpers.locationCapacityBar.ownedOfRecordings`,{size:N(f),percent:X(_)}),cap:v===null?null:v.reason===`drain`?j.t(`helpers.locationCapacityBar.capDrain`,{size:N(v.bytes)}):j.t(`helpers.locationCapacityBar.capCap`,{size:N(v.bytes)})},S=[j.t(`helpers.locationCapacityBar.summaryFree`,{free:x.freeTotal,total:x.total,percent:x.freeTotalPercent}),x.owned===null?null:j.t(`helpers.locationCapacityBar.summaryOwned`,{owned:x.owned}),x.reserve===null?null:l?j.t(`helpers.locationCapacityBar.summaryReserveShort`,{reserve:x.reserve}):x.reserve,x.cap===null?null:b?j.t(`helpers.locationCapacityBar.summaryCapBelow`,{cap:x.cap}):x.cap].filter(e=>e!==null).join(` · `),C=[];return c>0&&C.push({segment:`reserve`,label:j.t(`helpers.locationCapacityBar.legendKeptFree`),value:N(s),alarming:l}),x.owned!==null&&C.push({segment:`owned`,label:j.t(`helpers.locationCapacityBar.legendCamstack`),value:x.owned,alarming:!1}),C.push({segment:`used`,label:f===null?j.t(`helpers.locationCapacityBar.legendUsed`):j.t(`helpers.locationCapacityBar.legendOtherData`),value:`${x.used} (${x.usedPercent})`,alarming:g===`critical`}),C.push({segment:`free`,label:j.t(`helpers.locationCapacityBar.legendFree`),value:`${x.free} (${x.freePercent})`,alarming:l}),v!==null&&C.push({segment:`cap`,label:v.reason===`drain`?j.t(`helpers.locationCapacityBar.legendDrainTarget`):j.t(`helpers.locationCapacityBar.legendCap`),value:j.t(`helpers.locationCapacityBar.legendCapValue`,{size:N(v.bytes)}),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 He={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 Ue(e,t){return e===`used`?He[t]:Z[e]}function We({location:t,ownedBytes:n}){let{t:i}=M(),a=t.capacity??null,o=xe(_e(t.config),a?.totalBytes??null),s=Ve({totalBytes:a?.totalBytes??null,availableBytes:a?.availableBytes??null},o,{ownedBytes:n??null,cap:Te(t.config,B(t))});return s.kind===`unknown`?r(`div`,{className:`text-[10px] text-foreground-subtle italic`,title:s.summary,children:s.owned===null?i(`storage.locationCapacityBar.capacityUnknown`,`Capacity unknown`):i(`storage.locationCapacityBar.capacityUnknownCamstackHolds`,`Capacity unknown · CamStack holds {{owned}}`,{owned:s.owned})}):e(`div`,{className:`mt-1 space-y-1`,title:s.summary,children:[e(`div`,{className:`relative flex h-2 w-full max-w-md overflow-hidden rounded-full bg-border`,children:[s.segments.reservePercent>0&&r(`div`,{className:Z.reserve,style:{width:`${String(s.segments.reservePercent)}%`}}),s.segments.ownedPercent!==null&&r(`div`,{className:Z.owned,style:{width:`${String(s.segments.ownedPercent)}%`}}),r(`div`,{className:He[s.severity],style:{width:`${String(s.segments.usedPercent)}%`}}),r(`div`,{className:Z.free,style:{width:`${String(s.segments.freePercent)}%`}}),s.segments.capPercent!==null&&r(`div`,{className:`absolute inset-y-0 w-px ${s.capBelowOwned?`bg-danger`:Z.cap}`,style:{left:`${String(s.segments.capPercent)}%`}})]}),r(`ul`,{className:`flex flex-wrap items-center gap-x-3 gap-y-0.5`,children:s.legend.map(t=>e(`li`,{className:`flex items-center gap-1`,children:[r(`span`,{"aria-hidden":`true`,className:`inline-block h-2 w-2 shrink-0 rounded-sm ${Ue(t.segment,s.severity)}`}),e(`span`,{className:`text-[10px] tabular-nums ${t.alarming?`text-danger`:`text-foreground-subtle`}`,children:[t.label,` `,t.value]})]},t.segment))})]})}var Ge={eventMedia:[`events`],recordingsLow:[`low`],recordings:[`high`,`mid`]},Ke={eventMedia:`pipeline-analytics`,recordingsLow:`recorder`,recordings:`recorder`},qe=`storage.discardLocation`,Je=`storage.discardLocationStatus`,Ye=`storage.discardLocationCancel`;function Xe(e){return Ge[e]??null}function Ze(e){return Ke[e]??null}function Qe(e){return!V(B(e))}function $e(e,t){return Xe(e.type)===null||!Qe(e)?!1:t.some(t=>t.id!==e.id&&V(B(t)))}var et=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 tt(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`||!et.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 nt(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}o();var rt=2e3;function it({location:e,siblings:t}){return $e(e,t)?r(at,{location:e}):null}function at({location:t}){let{t:n}=M(),o=E(),s=O(),c=Ze(t.type),[l,u]=a(null),[d,f]=a(null),[m,g]=a(!1);if(i(()=>{if(c===null)return;let e=!1,t=async()=>{try{let t=await s.mutateAsync({addonId:c,action:Je,input:{}});if(e)return;u(tt(t))}catch{}};t();let n=setInterval(()=>void t(),rt);return()=>{e=!0,clearInterval(n)}},[c,t.id]),c===null)return null;let _=l!==null&&l.locationId===t.id,v=_&&l.running,y=_&&l.phase!==`idle`,b=async()=>{if(await o({title:n(`storage.locationDiscardControl.discardLeftoversOn`,`Discard leftovers on "{{displayName}}"?`,{displayName:t.displayName}),message:n(`storage.locationDiscardControl.permanentlyDeletesLeftoverFilesAnd`,`Permanently deletes leftover files and records on this location. Other locations are not affected. This cannot be undone and may take hours.`),confirmLabel:n(`storage.locationDiscardControl.discardLeftovers`,`Discard leftovers`),variant:`danger`})){f(null),g(!0);try{await s.mutateAsync({addonId:c,action:qe,input:{locationId:t.id}}),u(tt(await s.mutateAsync({addonId:c,action:Je,input:{}})))}catch(e){f(e instanceof Error?e.message:String(e))}finally{g(!1)}}},x=async()=>{try{await s.mutateAsync({addonId:c,action:Ye,input:{}})}catch(e){f(e instanceof Error?e.message:String(e))}};return e(`div`,{className:`flex flex-col gap-1 min-w-[9rem] max-w-[16rem]`,children:[v?e(`button`,{type:`button`,onClick:()=>void x(),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:[r(p,{className:`h-3 w-3`}),n(`common.cancel`,`Cancel`)]}):e(`button`,{type:`button`,onClick:()=>void b(),disabled:m,title:n(`storage.locationDiscardControl.permanentlyDeleteLeftoverFilesOn`,`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:[m?r(h,{className:`h-3 w-3 animate-spin`}):r(S,{className:`h-3 w-3`}),n(`storage.locationDiscardControl.discardLeftovers`,`Discard leftovers`)]}),y&&l!==null&&e(`div`,{className:`space-y-0.5`,children:[r(`div`,{className:`h-1 rounded bg-border overflow-hidden`,children:r(`div`,{className:`h-full bg-primary transition-[width] duration-300`,style:{width:`${nt(l)}%`}})}),e(`p`,{className:`text-[10px] text-foreground-subtle leading-tight`,children:[l.phase,l.camerasTotal>0?` · ${n(`storage.locationDiscardControl.camsProgress`,{done:l.camerasDone,total:l.camerasTotal})}`:``,l.dbRowsDeleted>0?` · ${n(`storage.locationDiscardControl.rowsDeleted`,{count:l.dbRowsDeleted})}`:``,l.detail?` · ${l.detail}`:``]})]}),(d||_&&l?.error)&&r(`p`,{className:`text-[10px] text-danger leading-tight`,children:d??l?.error})]})}o();var ot={active:l,readonly:x,drain:C,disabled:y},st={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 ct({mode:t,open:n,onToggle:i}){let{t:a}=M(),o=U(t),s=ot[t];return e(`button`,{type:`button`,"aria-expanded":n,"aria-label":a(`storage.locationModeSelector.locationState`,`Location state`),onClick:i,title:o.consequence,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium border ${st[t]}`,children:[r(s,{className:`h-3 w-3`}),o.label,r(_,{className:`h-3 w-3 ${n?`rotate-180`:``}`})]})}function lt({mode:t,blockedReasons:n,onSelect:a,onDismiss:o}){let{t:s}=M();return i(()=>{let e=e=>{e.key===`Escape`&&o()};return window.addEventListener(`keydown`,e),()=>{window.removeEventListener(`keydown`,e)}},[o]),e(`div`,{className:`w-full basis-full rounded-lg border border-border bg-background p-1`,role:`group`,"aria-label":s(`storage.locationModeSelector.locationStateChoices`,`Location state choices`),children:[e(`div`,{className:`flex items-center justify-between px-2 py-1`,children:[r(`span`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:s(`storage.locationModeSelector.locationState`,`Location state`)}),r(`button`,{type:`button`,"aria-label":s(`storage.locationModeSelector.closeLocationStateChoices`,`Close location state choices`),onClick:o,className:`text-foreground-subtle hover:text-foreground`,children:r(p,{className:`h-3 w-3`})})]}),H.map(i=>{let c=n[i.mode],l=c!==``,u=ot[i.mode],d=i.mode===t;return e(`button`,{type:`button`,role:`radio`,"aria-checked":d,"aria-label":i.label,disabled:l,onClick:()=>{l||(o(),d||a(i.mode))},className:`flex w-full flex-col items-start gap-0.5 rounded px-2 py-1.5 text-left ${l?`cursor-not-allowed opacity-60`:d?`bg-primary/10`:`hover:bg-primary/5`}`,children:[e(`span`,{className:`flex items-center gap-1.5 text-[11px] font-medium text-foreground`,children:[r(u,{className:`h-3 w-3`}),i.label,d&&r(`span`,{className:`text-[9px] uppercase text-primary`,children:s(`common.current`)})]}),r(`span`,{className:`text-[10px] leading-snug text-foreground-subtle`,children:i.consequence}),l&&r(`span`,{className:`text-[10px] leading-snug text-warning`,children:c})]},i.mode)})]})}o();function ut(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 dt({location:t,onEdit:n,onDelete:i,onSetMode:o,blockedReasons:s,canDelete:c,siblings:l=[],drain:f,ownedBytes:p}){let{t:m}=M(),[h,g]=a(!1),_=ut(t.config),v=B(t);return e(`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:[e(`div`,{className:`flex items-start gap-2 min-w-0 flex-1 basis-72`,children:[r(`div`,{className:`shrink-0 sm:w-32`,"data-testid":`location-badge-slot`,children:r(`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:t.providerId})}),e(`div`,{className:`min-w-0 flex-1`,children:[r(`div`,{className:`text-xs font-medium text-foreground truncate`,children:t.displayName}),_&&r(`div`,{className:`text-[10px] text-foreground-subtle truncate font-mono`,children:_}),r(We,{location:t,ownedBytes:p??null}),f!==void 0&&r(Ie,{drain:f})]})]}),e(`div`,{className:`flex flex-wrap items-center gap-1 shrink-0`,children:[r(it,{location:t,siblings:l}),r(ct,{mode:v,open:h,onToggle:()=>{g(e=>!e)}}),e(`button`,{onClick:()=>n(t),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:[r(u,{className:`h-3 w-3`}),m(`common.edit`,`Edit`)]}),c&&r(`button`,{onClick:()=>i(t),className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-danger hover:bg-danger/10`,title:m(`storage.locationCard.deleteLocation`,`Delete location`),children:r(d,{className:`h-3 w-3`})})]}),h&&r(lt,{mode:v,blockedReasons:s,onSelect:e=>o(t,e),onDismiss:()=>{g(!1)}})]})}o();function ft({type:n,displayName:i,description:a,cardinality:o,locations:s,onAdd:l,onEdit:u,onDelete:d,onSetMode:p,ownedBytesById:h,drainById:g}){let{t:_}=M(),v=t(()=>{let e=[...s];return e.sort((e,t)=>{let n=V(B(e));return n===V(B(t))?e.displayName.localeCompare(t.displayName):n?-1:1}),e},[s]);return e(T,{headingId:`storage-location-${n}`,title:i,icon:f,testId:`storage-location-group-${n}`,actions:o===`multi`?e(w,{size:`sm`,type:`button`,onClick:()=>l(n),children:[r(m,{className:`h-3 w-3`}),_(`common.add`,`Add`)]}):void 0,children:[e(`div`,{className:`${c} space-y-2`,children:[e(`div`,{className:`space-y-0.5`,children:[r(`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:n}),a!==void 0&&a!==``&&r(`p`,{className:`text-[11px] leading-relaxed text-foreground-subtle`,children:a}),o===`single`&&r(`p`,{className:`text-[10px] text-foreground-subtle italic`,children:_(`storage.locationGroup.singleOneLocationPerType`,`Single — one location per type. Edit the existing entry; it can't be split.`)})]}),v.length===0&&r(`div`,{className:`py-2 text-center text-[11px] text-foreground-subtle italic`,children:o===`multi`?_(`storage.locationGroup.noLocationRegisteredClickAdd`,`No location registered. Click "Add" to register one.`):_(`storage.locationGroup.noLocationRegisteredYetShould`,`No location registered yet — should be auto-seeded at next boot.`)})]}),v.length>0&&r(`div`,{className:`border-t border-border`,children:v.map(e=>r(dt,{location:e,cardinality:o,canDelete:pe(e,v,o),onEdit:u,onDelete:d,onSetMode:p,blockedReasons:fe(e,v),ownedBytes:h?.get(e.id)??null,drain:Me(Ne(e),g?.get(e.id)),siblings:v},e.id))})]})}var pt=[`recordings`,`recordingsLow`];function mt(e){return e.locationIds!==void 0&&e.locationIds.length>0?e.locationIds:e.locationId===null?[]:[e.locationId]}function ht(e,t){if(t===void 0||!pt.includes(e.type))return null;let n=t.find(t=>mt(t).includes(e.id));return n===void 0||!Number.isFinite(n.usedBytes)||n.usedBytes<0?null:n.usedBytes}function gt(e,t){let n=new Map;for(let r of e){let e=ht(r,t);e!==null&&n.set(r.id,e)}return n}export{Ae as a,U as c,Be as i,ue as l,ft as n,De as o,q as r,he as s,gt as t,z as u};
1
+ import{C as e,K as t,R as n,S as r,V as i,Y as a,et as o,o as s}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{D as c,En as l,Fn as u,It as d,Sr as f,dt as p,kn as m,or as h,ot as g,xi as _,yi as v,zr as y}from"./player-overlays-Dbv95cvz.js";import{ia as b}from"./client-DvJxGh2F.js";import{t as x}from"./archive-Brq5E-qM.js";import{t as S}from"./eraser-Bs0PJaPY.js";import{t as C}from"./hard-drive-download-iRJR_Xj9.js";import{Jl as ee,Kr as w,Sn as T,Wr as E,_r as D,bt as te,hr as ne,mi as O,mr as re,ou as ie,pr as ae,vr as k,yr as A}from"./src-DntJrWmU.js";import{t as j}from"./i18n-D0o08mg-.js";import{t as M}from"./useTranslation-BJr-n0es.js";import{P as oe,lr as se}from"./index-XXQ5yMw_.js";import{t as N}from"./format-size-DIxKXxtj.js";o();function P(e){let t=e.trim().toLowerCase();return t.length===0?``:t.replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``)}function F(e,t){let n=P(t);return`${e}:${n.length>0?n:`default`}`}var I=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`]),L=[`recordings`,`data`,`mnt`,`media`,`Volumes`];function R(e){let t=L.findIndex(t=>t===`recordings`?e.startsWith(t):e===t);return t===-1?L.length:t}function ce(e){return e.filter(e=>!e.name.startsWith(`.`)&&!I.has(e.name)).toSorted((e,t)=>{let n=R(e.name)-R(t.name);return n===0?e.name.localeCompare(t.name):n}).map(e=>e.path)}function le({nodeId:t,value:o,onChange:s}){let{t:c}=M(),l=g().trpcClient,[u,d]=a([]),[f,p]=a(o),[m,h]=a(null),[_,v]=a(null),[y,b]=a(``),x=n(async(e,n)=>{v(null);try{let r=await l.filesystemBrowse.browse.query({nodeId:t,path:e});h(r),p(r.path),n&&s(r.path)}catch(e){v(e instanceof Error?e.message:`browse failed`)}},[l,t,s]);i(()=>{p(o),(async()=>{let e=await l.filesystemBrowse.browse.query({nodeId:t,path:`/`}).then(e=>e).catch(()=>null);if(e){d(ce(e.entries)),await x(o.startsWith(`/`)?o:`/`,!1);return}try{let e=await l.filesystemBrowse.listAllowedRoots.query({nodeId:t});d(e),await x(o&&e.some(e=>o.startsWith(e))?o:e[0]??``,!1)}catch(e){d([]),h(null),v(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 S=async()=>{if(!(!y.trim()||!m)){v(null);try{let e=`${m.path.replace(/\/+$/,``)}/${y.trim()}`;await l.filesystemBrowse.createDir.mutate({nodeId:t,path:e}),b(``),await x(m.path,!0)}catch(e){v(e instanceof Error?e.message:`create failed`)}}},C=e=>`${(e/1e9).toFixed(1)} GB`;return e(`div`,{className:`space-y-2 rounded border border-border p-2`,children:[r(`div`,{className:`flex flex-wrap gap-1`,children:u.map(e=>r(`button`,{onClick:()=>void x(e,!0),className:`rounded border border-border px-2 py-0.5 text-[10px] font-mono hover:border-primary/40`,children:e},e))}),r(`input`,{value:f,onChange:e=>{p(e.target.value),s(e.target.value)},placeholder:`/absolute/path`,className:`w-full rounded border border-border bg-background px-2 py-1 text-[11px] font-mono`}),m&&r(`div`,{className:`text-[10px] text-foreground-subtle`,children:c(`storage.pathBrowser.free`,{free:C(m.freeBytes),total:C(m.totalBytes)})}),r(`div`,{className:`max-h-40 space-y-0.5 overflow-y-auto`,children:m?.entries.map(t=>e(`button`,{onClick:()=>void x(t.path,!0),className:`block w-full truncate rounded px-2 py-1 text-left text-xs hover:bg-primary/5`,children:[`📁 `,t.name]},t.path))}),e(`div`,{className:`flex gap-1`,children:[r(`input`,{value:y,onChange:e=>b(e.target.value),placeholder:c(`storage.pathBrowser.newFolder`,`new folder`),className:`flex-1 rounded border border-border bg-background px-2 py-1 text-xs`}),r(`button`,{onClick:()=>void S(),className:`rounded border border-border px-2 py-1 text-xs hover:border-primary/40`,children:c(`storage.pathBrowser.create`,`Create`)})]}),_&&r(`div`,{className:`text-[10px] text-red-400`,children:_})]})}o();function z({initialType:n,onClose:i,onCreated:o}){let{t:c}=M(),l=s(),u=g().trpcClient,[d,f]=a(`picker`),[p,m]=a(n),[_,y]=a(null),[b,x]=a({}),[S,C]=a(``),[w,T]=a(null),[E,D]=a(!1),[O,j]=a(`hub`),[N,P]=a(null),[I,L]=a(!1),R=e=>x(t=>({...t,basePath:e})),ce=typeof b.basePath==`string`?b.basePath:``,z=ee(),B=t(()=>{let e=z.data;return Array.isArray(e)?e:[]},[z.data]),V=z.isLoading,H=ie({onSuccess:()=>{l.invalidateQueries({queryKey:[[`storage`,`listLocations`]]}),o()}}),U=t(()=>w!==null&&w.length>0?w:F(p,S),[p,S,w]),ue=async()=>{if(_){L(!0),P(null);try{P(await(e=>u.storage.testConfig.query(e))({providerId:_.providerId,config:b}))}catch(e){P({ok:!1,error:e instanceof Error?e.message:String(e)})}finally{L(!1)}}};return r(ae,{open:!0,onOpenChange:e=>!e&&i(),children:e(ne,{width:`md`,placement:`sheet-on-mobile`,scroll:`body`,children:[e(k,{children:[r(A,{children:{picker:`Add Location — Pick provider`,config:`Add Location — ${_?.displayName??``}`,naming:`Add Location — Name`}[d]}),e(`p`,{className:`text-xs text-foreground-subtle`,children:[c(`storage.addLocationWizard.type`,`Type:`),` `,r(`span`,{className:`font-mono`,children:p})]})]}),e(re,{children:[d===`picker`&&e(`div`,{className:`space-y-2`,children:[V&&r(`div`,{className:`text-xs text-foreground-subtle animate-pulse`,children:c(`storage.addLocationWizard.loadingProviders`,`Loading providers…`)}),!V&&B.length===0&&r(`div`,{className:`rounded border border-border bg-background px-3 py-4 text-center text-xs text-foreground-subtle`,children:r(se,{i18nKey:`storage.addLocationWizard.noProvider`,values:{type:p},components:{code:r(`code`,{className:`font-mono`})}})}),B.map(t=>e(`button`,{onClick:()=>{y(t),f(`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:[e(`div`,{className:`flex-1 min-w-0`,children:[r(`p`,{className:`text-xs font-semibold text-foreground`,children:t.displayName}),r(`p`,{className:`text-[10px] text-foreground-subtle font-mono mt-0.5 truncate`,children:t.providerId})]}),r(v,{className:`h-4 w-4 text-foreground-subtle flex-shrink-0`})]},t.providerId))]}),d===`config`&&_&&e(`div`,{className:`space-y-3`,children:[r(oe,{schema:_.configSchema,values:b,onChange:x}),_.nodeLocal&&e(`div`,{className:`space-y-2`,children:[r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:c(`storage.addLocationWizard.node`,`Node`)}),r(te,{selectedNodeId:O,onSelect:j,alwaysShow:!0}),r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:c(`storage.addLocationWizard.path`,`Path`)}),r(le,{nodeId:O,value:ce,onChange:R})]}),N&&r(`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?c(`storage.addLocationWizard.connectionOk`,`Connection OK.`):c(`storage.addLocationWizard.testFailed`,`Test failed: {{value1}}`,{value1:N.error??`unknown error`})}),e(`div`,{className:`flex items-center justify-between pt-1`,children:[r(`button`,{onClick:()=>f(`picker`),className:`rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground`,children:c(`common.back`,`Back`)}),e(`div`,{className:`flex items-center gap-2`,children:[r(`button`,{onClick:()=>{ue()},disabled:I,className:`rounded border border-border px-3 py-1.5 text-xs text-foreground hover:bg-primary/10 disabled:opacity-50`,children:I?c(`storage.addLocationWizard.testing`,`Testing…`):c(`storage.addLocationWizard.testConnection`,`Test connection`)}),r(`button`,{onClick:()=>f(`naming`),className:`rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90`,children:c(`common.next`,`Next`)})]})]})]}),d===`naming`&&_&&e(`div`,{className:`space-y-3`,children:[e(`div`,{className:`space-y-1`,children:[r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:c(`storage.addLocationWizard.displayName`,`Display name`)}),r(`input`,{type:`text`,value:S,onChange:e=>C(e.target.value),placeholder:c(`storage.addLocationWizard.on`,`{{type}} on {{displayName}}`,{type:p,displayName:_.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`})]}),e(`div`,{className:`space-y-1`,children:[e(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:[c(`storage.addLocationWizard.idLabel`),` `,r(`span`,{className:`lowercase tracking-normal text-foreground-subtle`,children:c(`storage.addLocationWizard.autoDerivedOverrideIfNeeded`,`— auto-derived; override if needed`)})]}),r(`input`,{type:`text`,value:U,onChange:e=>T(e.target.value),placeholder:F(p,S),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`}),e(`p`,{className:`text-[10px] text-foreground-subtle`,children:[c(`storage.addLocationWizard.format`,`Format:`),` `,r(`code`,{className:`font-mono`,children:c(`storage.addLocationWizard.typeSlug`,`<type>:<slug>`)}),`. Lowercase letters, digits, and hyphens only.`]})]}),e(`label`,{className:`flex items-start gap-2 rounded border border-border bg-background px-3 py-2 cursor-pointer hover:bg-primary/5`,children:[r(`input`,{type:`checkbox`,checked:E,onChange:e=>D(e.target.checked),className:`accent-primary mt-0.5`}),e(`div`,{className:`space-y-0.5`,children:[r(`div`,{className:`text-xs font-medium text-foreground`,children:c(`storage.addLocationWizard.enableImmediately`,`Enable immediately`)}),r(`div`,{className:`text-[10px] text-foreground-subtle`,children:c(`storage.addLocationWizard.aDisabledLocationReceivesNo`,`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&&r(`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)}),e(`div`,{className:`flex items-center justify-between pt-1`,children:[r(`button`,{onClick:()=>f(`config`),className:`rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground`,children:c(`common.back`,`Back`)}),e(`div`,{className:`flex items-center gap-2`,children:[r(`button`,{onClick:()=>{m(n),y(null),x({}),C(``),T(null),D(!1),P(null),f(`picker`)},className:`rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground`,children:c(`common.reset`,`Reset`)}),e(`button`,{onClick:()=>{_&&H.mutate({id:U,type:p,displayName:S.trim(),providerId:_.providerId,config:b,enabled:E,nodeId:_.nodeLocal?O:void 0})},disabled:H.isPending||S.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?r(h,{className:`h-3.5 w-3.5 animate-spin`}):null,H.isPending?c(`storage.addLocationWizard.saving`,`Saving…`):c(`common.save`,`Save`)]})]})]})]})]})]})})}function B(e){return b(e)}function V(e){return e===`active`}var H=[{mode:`active`,get label(){return j.t(`helpers.locationMode.activeLabel`)},get consequence(){return j.t(`helpers.locationMode.activeConsequence`)},requiresConfirmation:!1},{mode:`readonly`,get label(){return j.t(`helpers.locationMode.readonlyLabel`)},get consequence(){return j.t(`helpers.locationMode.readonlyConsequence`)},requiresConfirmation:!1},{mode:`drain`,get label(){return j.t(`helpers.locationMode.drainLabel`)},get consequence(){return j.t(`helpers.locationMode.drainConsequence`)},requiresConfirmation:!1},{mode:`disabled`,get label(){return j.t(`helpers.locationMode.disabledLabel`)},get consequence(){return j.t(`helpers.locationMode.disabledConsequence`)},requiresConfirmation:!0}];function U(e){return H.find(t=>t.mode===e)??H[0]}function ue(e){return U(e).requiresConfirmation}var de=`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 V(n)||!V(B(e))||t.some(t=>t.id!==e.id&&V(B(t)))?{blocked:!1,reason:``}:{blocked:!0,reason:de}}function fe(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 pe(e,t,n){return!(n===`single`||t.length<=1||V(B(e))&&t.filter(e=>V(B(e))).length<=1)}function me(e){return e===`active`?{enabled:!0,readOnly:!1}:e===`readonly`?{enabled:!1,readOnly:!1}:{enabled:!1,readOnly:!0}}function he(e,t){let n={...t.config??e.config};t.mode!==void 0&&(me(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:me(t.mode).enabled}}var ge=1024**3;function G(e){return typeof e==`number`&&Number.isFinite(e)?e:null}function _e(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 ve(e,t){return G(e[t===`gb`?`minFreeGb`:`minFreePercent`])}function ye(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 be(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 xe(e,t,n=10){if(e.unit===`gb`&&e.value!==null)return e.value*ge;let r=e.value??n;return t===null||t<=0?null:t*Math.min(100,Math.max(0,r))/100}function Se(e){return e===`gb`?j.t(`helpers.locationProtection.unitGb`):j.t(`helpers.locationProtection.unitPercent`)}function Ce(e,t=10){let n=e.value===null?j.t(`helpers.locationProtection.targetDefault`,{percent:String(t)}):e.unit===`gb`?j.t(`helpers.locationProtection.targetGb`,{value:String(e.value)}):j.t(`helpers.locationProtection.targetPercent`,{value:String(e.value)});return j.t(`helpers.locationProtection.helpText`,{target:n,percent:String(t)})}function we(e){return G(e.maxUsedGb)}function Te(e,t){let n=G(e.maxUsedGb);return n===null||n<0?null:{bytes:n*ge,reason:t===`drain`?`drain`:`legacy`}}o();function Ee({config:t,defaultPercent:n=10,onChange:i}){let{t:o}=M(),[s,c]=a(()=>_e(t).unit),l=ve(t,s),u={unit:s,value:l},d=we(t),f=e=>{c(e),i(ye(t,{unit:e,value:null}))},p=e=>{i(ye(t,{unit:s,value:be(e,s)}))};return e(`div`,{className:`space-y-1`,children:[r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:o(`storage.protectionPolicyField.protectedFreeSpace`,`Protected free space`)}),e(`div`,{className:`flex items-center gap-2`,children:[e(`select`,{"aria-label":o(`storage.protectionPolicyField.protectionUnit`,`Protection unit`),value:s,onChange:e=>{f(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:[r(`option`,{value:`percent`,children:o(`storage.protectionPolicyField.ofTheVolume`,`% of the volume`)}),r(`option`,{value:`gb`,children:o(`storage.protectionPolicyField.gbOfFreeSpace`,`GB of free space`)})]}),r(`input`,{type:`number`,"aria-label":Se(s),min:0,max:s===`percent`?100:void 0,value:l===null?``:l,placeholder:s===`percent`?String(n):o(`common.defaultWord`),onChange:e=>{p(e.target.value)},className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`})]}),r(`p`,{className:`text-[10px] text-foreground-subtle`,children:Ce(u,n)}),d!==null&&r(`p`,{className:`text-[10px] text-foreground-subtle italic`,children:o(`storage.protectionPolicyField.legacyMax`,{gb:d})})]})}o();function De({location:n,onClose:i,onSaved:o}){let{t:c}=M(),l=s(),u=g().trpcClient,[d,f]=a({...n.config}),[p,m]=a(n.displayName),[_,v]=a(null),[y,b]=a(!1),x=ee(),S=t(()=>{let e=x.data;return Array.isArray(e)?e.find(e=>e.providerId===n.providerId)??null:null},[x.data,n.providerId]),C=ie({onSuccess:()=>{l.invalidateQueries({queryKey:[[`storage`,`listLocations`]]}),o()}}),T=S?.shouldSaveDiskSpace===!0,E=S?.nodeLocal===!0,[O,j]=a(typeof n.nodeId==`string`?n.nodeId:`hub`),N=typeof d.basePath==`string`?d.basePath:``,P=e=>f(t=>({...t,basePath:e})),F=S?.minFreePercent??10,I=async()=>{b(!0),v(null);try{v(await(e=>u.storage.testConfig.query(e))({providerId:n.providerId,locationId:n.id,config:d}))}catch(e){v({ok:!1,error:e instanceof Error?e.message:String(e)})}finally{b(!1)}};return r(ae,{open:!0,onOpenChange:e=>!e&&i(),children:e(ne,{width:`md`,placement:`sheet-on-mobile`,scroll:`body`,children:[e(k,{children:[r(A,{children:c(`storage.editLocationModal.title`,{name:n.displayName})}),e(`p`,{className:`text-xs text-foreground-subtle`,children:[r(`span`,{className:`font-mono`,children:n.id}),` ·`,` `,S?.displayName??n.providerId]})]}),e(re,{className:`space-y-3`,children:[e(`div`,{className:`space-y-1`,children:[r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:c(`storage.editLocationModal.displayName`,`Display name`)}),r(`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`})]}),S&&r(oe,{schema:S.configSchema,values:d,onChange:f}),E&&e(`div`,{className:`space-y-2`,children:[r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:c(`storage.editLocationModal.node`,`Node`)}),r(te,{selectedNodeId:O,onSelect:j,alwaysShow:!0}),r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:c(`storage.editLocationModal.path`,`Path`)}),r(le,{nodeId:O,value:N,onChange:P})]}),T&&r(Ee,{config:d,defaultPercent:F,onChange:f}),!S&&!x.isLoading&&r(`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:r(se,{i18nKey:`storage.editLocationModal.providerGone`,values:{id:n.providerId},components:{code:r(`code`,{className:`font-mono`})}})}),_&&r(`div`,{className:`rounded border px-3 py-2 text-[11px] ${_.ok?`border-success/30 bg-success/5 text-success`:`border-danger/30 bg-danger/5 text-danger`}`,children:_.ok?c(`storage.editLocationModal.connectionOk`,`Connection OK.`):c(`storage.editLocationModal.testFailed`,`Test failed: {{value1}}`,{value1:_.error??`unknown error`})}),C.isError&&r(`div`,{className:`rounded border border-danger/30 bg-danger/5 text-danger px-3 py-2 text-[11px]`,children:C.error instanceof Error?C.error.message:String(C.error)})]}),e(D,{className:`justify-between`,children:[r(w,{variant:`outline`,size:`sm`,onClick:i,children:c(`common.cancel`,`Cancel`)}),e(`div`,{className:`flex items-center gap-2`,children:[r(w,{variant:`outline`,size:`sm`,onClick:()=>{I()},disabled:y||!S,children:y?c(`storage.editLocationModal.testing`,`Testing…`):c(`storage.editLocationModal.testConnection`,`Test connection`)}),e(w,{size:`sm`,onClick:()=>{C.mutate(he(n,{displayName:p.trim(),config:d,nodeId:E?O:n.nodeId}))},disabled:C.isPending||p.trim().length===0,children:[C.isPending?r(h,{className:`h-3.5 w-3.5 animate-spin`}):null,C.isPending?c(`storage.editLocationModal.saving`,`Saving…`):c(`common.save`,`Save`)]})]})]})]})})}function Oe(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function K(e){return typeof e==`number`&&Number.isFinite(e)?e:null}function ke(e){if(!Oe(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 Ae(e){let t=new Map;if(!Array.isArray(e))return t;for(let n of e){let e=ke(n);e!==null&&t.set(e.locationId,e)}return t}function je(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 Me(e,t){return e?t===void 0?{kind:`unreported`}:t.drained||t.bytesRemaining<=0?{kind:`drained`}:{kind:`draining`,bytesRemaining:t.bytesRemaining,drainedFraction:je(t),estimatedEmptyAtMs:t.estimatedEmptyAtMs}:{kind:`idle`}}function Ne(e){return e.mode===`drain`?!0:e.config.readOnly===!0}function Pe(e){return`${(e/1024**3).toFixed(e>=100*1024**3?0:1)} GB`}function Fe(e){return new Date(e).toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`})}function Ie({drain:t}){let{t:n}=M();if(t.kind===`idle`)return null;if(t.kind===`unreported`)return r(`span`,{"data-testid":`drain-unreported`,className:`text-[10px] text-foreground-subtle`,title:n(`storage.drainProgressLine.thisLocationIsDrainingThe`,`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:n(`storage.drainProgressLine.drainingRemainingNotReportedYet`,`Draining · remaining not reported yet`)});if(t.kind===`drained`)return r(`span`,{"data-testid":`drain-done`,className:`text-[10px] text-success`,title:n(`storage.drainProgressLine.everythingThatWasHereHas`,`Everything that was here has been moved. The location is still in drain mode — it receives no new writes until you change that.`),children:n(`storage.drainProgressLine.drainedNothingLeftToMove`,`Drained · nothing left to move`)});let i=t.drainedFraction===null?null:Math.round(t.drainedFraction*100);return e(`span`,{"data-testid":`drain-progress`,className:`flex items-center gap-1.5 text-[10px] text-foreground-subtle tabular-nums`,children:[i!==null&&r(`span`,{"data-testid":`drain-bar`,className:`inline-block h-1 w-10 rounded-full bg-border overflow-hidden`,role:`progressbar`,"aria-label":n(`storage.drainProgressLine.drainProgress`,`Drain progress`),"aria-valuenow":i,"aria-valuemin":0,"aria-valuemax":100,children:r(`span`,{className:`block h-full bg-warning`,style:{width:`${i}%`}})}),e(`span`,{children:[n(`storage.drainProgressLine.left`,{size:Pe(t.bytesRemaining)}),i!==null&&` · ${n(`storage.drainProgressLine.moved`,{percent:i})}`]}),t.estimatedEmptyAtMs===null?r(`span`,{"data-testid":`drain-eta-absent`,title:n(`storage.drainProgressLine.theDrainIsPacedBy`,`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:n(`storage.drainProgressLine.emptyTimeNotKnownYet`,`· empty time not known yet`)}):e(`span`,{"data-testid":`drain-eta`,children:[`·`,` `,n(`storage.drainProgressLine.empty`,{when:Fe(t.estimatedEmptyAtMs)})]})]})}var Le=[`ok`,`warn`,`critical`];function Re(e){return e>=.95?`critical`:e>=.85?`warn`:`ok`}function ze(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=ze((n-t)/n);return{fraction:r,severity:Re(r),recordingsFraction:ze(e.usedBytes/n),freeBytes:t,totalBytes:n}}function Be(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||Le.indexOf(e.severity)>Le.indexOf(a))&&(a=e.severity)}return{knownVolumes:t,unknownVolumes:n,totalBytes:r,freeBytes:i,severity:a}}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 Ve(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:N(n.ownedBytes);return{kind:`unknown`,owned:e,summary:e===null?j.t(`helpers.locationCapacityBar.unknownSummary`):j.t(`helpers.locationCapacityBar.unknownSummaryOwned`,{size:e})}}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?Re(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:N(r),freeTotal:N(a),freeTotalPercent:X(a/r),used:N(p),usedPercent:X(p/r),free:N(u),freePercent:X(u/r),reserve:s===0?null:j.t(`helpers.locationCapacityBar.reserveKept`,{size:N(s)}),owned:f===null||_===null?null:j.t(`helpers.locationCapacityBar.ownedOfRecordings`,{size:N(f),percent:X(_)}),cap:v===null?null:v.reason===`drain`?j.t(`helpers.locationCapacityBar.capDrain`,{size:N(v.bytes)}):j.t(`helpers.locationCapacityBar.capCap`,{size:N(v.bytes)})},S=[j.t(`helpers.locationCapacityBar.summaryFree`,{free:x.freeTotal,total:x.total,percent:x.freeTotalPercent}),x.owned===null?null:j.t(`helpers.locationCapacityBar.summaryOwned`,{owned:x.owned}),x.reserve===null?null:l?j.t(`helpers.locationCapacityBar.summaryReserveShort`,{reserve:x.reserve}):x.reserve,x.cap===null?null:b?j.t(`helpers.locationCapacityBar.summaryCapBelow`,{cap:x.cap}):x.cap].filter(e=>e!==null).join(` · `),C=[];return c>0&&C.push({segment:`reserve`,label:j.t(`helpers.locationCapacityBar.legendKeptFree`),value:N(s),alarming:l}),x.owned!==null&&C.push({segment:`owned`,label:j.t(`helpers.locationCapacityBar.legendCamstack`),value:x.owned,alarming:!1}),C.push({segment:`used`,label:f===null?j.t(`helpers.locationCapacityBar.legendUsed`):j.t(`helpers.locationCapacityBar.legendOtherData`),value:`${x.used} (${x.usedPercent})`,alarming:g===`critical`}),C.push({segment:`free`,label:j.t(`helpers.locationCapacityBar.legendFree`),value:`${x.free} (${x.freePercent})`,alarming:l}),v!==null&&C.push({segment:`cap`,label:v.reason===`drain`?j.t(`helpers.locationCapacityBar.legendDrainTarget`):j.t(`helpers.locationCapacityBar.legendCap`),value:j.t(`helpers.locationCapacityBar.legendCapValue`,{size:N(v.bytes)}),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 He={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 Ue(e,t){return e===`used`?He[t]:Z[e]}function We({location:t,ownedBytes:n}){let{t:i}=M(),a=t.capacity??null,o=xe(_e(t.config),a?.totalBytes??null),s=Ve({totalBytes:a?.totalBytes??null,availableBytes:a?.availableBytes??null},o,{ownedBytes:n??null,cap:Te(t.config,B(t))});return s.kind===`unknown`?r(`div`,{className:`text-[10px] text-foreground-subtle italic`,title:s.summary,children:s.owned===null?i(`storage.locationCapacityBar.capacityUnknown`,`Capacity unknown`):i(`storage.locationCapacityBar.capacityUnknownCamstackHolds`,`Capacity unknown · CamStack holds {{owned}}`,{owned:s.owned})}):e(`div`,{className:`mt-1 space-y-1`,title:s.summary,children:[e(`div`,{className:`relative flex h-2 w-full max-w-md overflow-hidden rounded-full bg-border`,children:[s.segments.reservePercent>0&&r(`div`,{className:Z.reserve,style:{width:`${String(s.segments.reservePercent)}%`}}),s.segments.ownedPercent!==null&&r(`div`,{className:Z.owned,style:{width:`${String(s.segments.ownedPercent)}%`}}),r(`div`,{className:He[s.severity],style:{width:`${String(s.segments.usedPercent)}%`}}),r(`div`,{className:Z.free,style:{width:`${String(s.segments.freePercent)}%`}}),s.segments.capPercent!==null&&r(`div`,{className:`absolute inset-y-0 w-px ${s.capBelowOwned?`bg-danger`:Z.cap}`,style:{left:`${String(s.segments.capPercent)}%`}})]}),r(`ul`,{className:`flex flex-wrap items-center gap-x-3 gap-y-0.5`,children:s.legend.map(t=>e(`li`,{className:`flex items-center gap-1`,children:[r(`span`,{"aria-hidden":`true`,className:`inline-block h-2 w-2 shrink-0 rounded-sm ${Ue(t.segment,s.severity)}`}),e(`span`,{className:`text-[10px] tabular-nums ${t.alarming?`text-danger`:`text-foreground-subtle`}`,children:[t.label,` `,t.value]})]},t.segment))})]})}var Ge={eventMedia:[`events`],recordingsLow:[`low`],recordings:[`high`,`mid`]},Ke={eventMedia:`pipeline-analytics`,recordingsLow:`recorder`,recordings:`recorder`},qe=`storage.discardLocation`,Je=`storage.discardLocationStatus`,Ye=`storage.discardLocationCancel`;function Xe(e){return Ge[e]??null}function Ze(e){return Ke[e]??null}function Qe(e){return!V(B(e))}function $e(e,t){return Xe(e.type)===null||!Qe(e)?!1:t.some(t=>t.id!==e.id&&V(B(t)))}var et=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 tt(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`||!et.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 nt(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}o();var rt=2e3;function it({location:e,siblings:t}){return $e(e,t)?r(at,{location:e}):null}function at({location:t}){let{t:n}=M(),o=E(),s=O(),c=Ze(t.type),[l,u]=a(null),[d,f]=a(null),[m,g]=a(!1);if(i(()=>{if(c===null)return;let e=!1,t=async()=>{try{let t=await s.mutateAsync({addonId:c,action:Je,input:{}});if(e)return;u(tt(t))}catch{}};t();let n=setInterval(()=>void t(),rt);return()=>{e=!0,clearInterval(n)}},[c,t.id]),c===null)return null;let _=l!==null&&l.locationId===t.id,v=_&&l.running,y=_&&l.phase!==`idle`,b=async()=>{if(await o({title:n(`storage.locationDiscardControl.discardLeftoversOn`,`Discard leftovers on "{{displayName}}"?`,{displayName:t.displayName}),message:n(`storage.locationDiscardControl.permanentlyDeletesLeftoverFilesAnd`,`Permanently deletes leftover files and records on this location. Other locations are not affected. This cannot be undone and may take hours.`),confirmLabel:n(`storage.locationDiscardControl.discardLeftovers`,`Discard leftovers`),variant:`danger`})){f(null),g(!0);try{await s.mutateAsync({addonId:c,action:qe,input:{locationId:t.id}}),u(tt(await s.mutateAsync({addonId:c,action:Je,input:{}})))}catch(e){f(e instanceof Error?e.message:String(e))}finally{g(!1)}}},x=async()=>{try{await s.mutateAsync({addonId:c,action:Ye,input:{}})}catch(e){f(e instanceof Error?e.message:String(e))}};return e(`div`,{className:`flex flex-col gap-1 min-w-[9rem] max-w-[16rem]`,children:[v?e(`button`,{type:`button`,onClick:()=>void x(),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:[r(p,{className:`h-3 w-3`}),n(`common.cancel`,`Cancel`)]}):e(`button`,{type:`button`,onClick:()=>void b(),disabled:m,title:n(`storage.locationDiscardControl.permanentlyDeleteLeftoverFilesOn`,`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:[m?r(h,{className:`h-3 w-3 animate-spin`}):r(S,{className:`h-3 w-3`}),n(`storage.locationDiscardControl.discardLeftovers`,`Discard leftovers`)]}),y&&l!==null&&e(`div`,{className:`space-y-0.5`,children:[r(`div`,{className:`h-1 rounded bg-border overflow-hidden`,children:r(`div`,{className:`h-full bg-primary transition-[width] duration-300`,style:{width:`${nt(l)}%`}})}),e(`p`,{className:`text-[10px] text-foreground-subtle leading-tight`,children:[l.phase,l.camerasTotal>0?` · ${n(`storage.locationDiscardControl.camsProgress`,{done:l.camerasDone,total:l.camerasTotal})}`:``,l.dbRowsDeleted>0?` · ${n(`storage.locationDiscardControl.rowsDeleted`,{count:l.dbRowsDeleted})}`:``,l.detail?` · ${l.detail}`:``]})]}),(d||_&&l?.error)&&r(`p`,{className:`text-[10px] text-danger leading-tight`,children:d??l?.error})]})}o();var ot={active:l,readonly:x,drain:C,disabled:y},st={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 ct({mode:t,open:n,onToggle:i}){let{t:a}=M(),o=U(t),s=ot[t];return e(`button`,{type:`button`,"aria-expanded":n,"aria-label":a(`storage.locationModeSelector.locationState`,`Location state`),onClick:i,title:o.consequence,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium border ${st[t]}`,children:[r(s,{className:`h-3 w-3`}),o.label,r(_,{className:`h-3 w-3 ${n?`rotate-180`:``}`})]})}function lt({mode:t,blockedReasons:n,onSelect:a,onDismiss:o}){let{t:s}=M();return i(()=>{let e=e=>{e.key===`Escape`&&o()};return window.addEventListener(`keydown`,e),()=>{window.removeEventListener(`keydown`,e)}},[o]),e(`div`,{className:`w-full basis-full rounded-lg border border-border bg-background p-1`,role:`group`,"aria-label":s(`storage.locationModeSelector.locationStateChoices`,`Location state choices`),children:[e(`div`,{className:`flex items-center justify-between px-2 py-1`,children:[r(`span`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:s(`storage.locationModeSelector.locationState`,`Location state`)}),r(`button`,{type:`button`,"aria-label":s(`storage.locationModeSelector.closeLocationStateChoices`,`Close location state choices`),onClick:o,className:`text-foreground-subtle hover:text-foreground`,children:r(p,{className:`h-3 w-3`})})]}),H.map(i=>{let c=n[i.mode],l=c!==``,u=ot[i.mode],d=i.mode===t;return e(`button`,{type:`button`,role:`radio`,"aria-checked":d,"aria-label":i.label,disabled:l,onClick:()=>{l||(o(),d||a(i.mode))},className:`flex w-full flex-col items-start gap-0.5 rounded px-2 py-1.5 text-left ${l?`cursor-not-allowed opacity-60`:d?`bg-primary/10`:`hover:bg-primary/5`}`,children:[e(`span`,{className:`flex items-center gap-1.5 text-[11px] font-medium text-foreground`,children:[r(u,{className:`h-3 w-3`}),i.label,d&&r(`span`,{className:`text-[9px] uppercase text-primary`,children:s(`common.current`)})]}),r(`span`,{className:`text-[10px] leading-snug text-foreground-subtle`,children:i.consequence}),l&&r(`span`,{className:`text-[10px] leading-snug text-warning`,children:c})]},i.mode)})]})}o();function ut(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 dt({location:t,onEdit:n,onDelete:i,onSetMode:o,blockedReasons:s,canDelete:c,siblings:l=[],drain:f,ownedBytes:p}){let{t:m}=M(),[h,g]=a(!1),_=ut(t.config),v=B(t);return e(`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:[e(`div`,{className:`flex items-start gap-2 min-w-0 flex-1 basis-72`,children:[r(`div`,{className:`shrink-0 sm:w-32`,"data-testid":`location-badge-slot`,children:r(`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:t.providerId})}),e(`div`,{className:`min-w-0 flex-1`,children:[r(`div`,{className:`text-xs font-medium text-foreground truncate`,children:t.displayName}),_&&r(`div`,{className:`text-[10px] text-foreground-subtle truncate font-mono`,children:_}),r(We,{location:t,ownedBytes:p??null}),f!==void 0&&r(Ie,{drain:f})]})]}),e(`div`,{className:`flex flex-wrap items-center gap-1 shrink-0`,children:[r(it,{location:t,siblings:l}),r(ct,{mode:v,open:h,onToggle:()=>{g(e=>!e)}}),e(`button`,{onClick:()=>n(t),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:[r(u,{className:`h-3 w-3`}),m(`common.edit`,`Edit`)]}),c&&r(`button`,{onClick:()=>i(t),className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-danger hover:bg-danger/10`,title:m(`storage.locationCard.deleteLocation`,`Delete location`),children:r(d,{className:`h-3 w-3`})})]}),h&&r(lt,{mode:v,blockedReasons:s,onSelect:e=>o(t,e),onDismiss:()=>{g(!1)}})]})}o();function ft({type:n,displayName:i,description:a,cardinality:o,locations:s,onAdd:l,onEdit:u,onDelete:d,onSetMode:p,ownedBytesById:h,drainById:g}){let{t:_}=M(),v=t(()=>{let e=[...s];return e.sort((e,t)=>{let n=V(B(e));return n===V(B(t))?e.displayName.localeCompare(t.displayName):n?-1:1}),e},[s]);return e(T,{headingId:`storage-location-${n}`,title:i,icon:f,testId:`storage-location-group-${n}`,actions:o===`multi`?e(w,{size:`sm`,type:`button`,onClick:()=>l(n),children:[r(m,{className:`h-3 w-3`}),_(`common.add`,`Add`)]}):void 0,children:[e(`div`,{className:`${c} space-y-2`,children:[e(`div`,{className:`space-y-0.5`,children:[r(`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:n}),a!==void 0&&a!==``&&r(`p`,{className:`text-[11px] leading-relaxed text-foreground-subtle`,children:a}),o===`single`&&r(`p`,{className:`text-[10px] text-foreground-subtle italic`,children:_(`storage.locationGroup.singleOneLocationPerType`,`Single — one location per type. Edit the existing entry; it can't be split.`)})]}),v.length===0&&r(`div`,{className:`py-2 text-center text-[11px] text-foreground-subtle italic`,children:o===`multi`?_(`storage.locationGroup.noLocationRegisteredClickAdd`,`No location registered. Click "Add" to register one.`):_(`storage.locationGroup.noLocationRegisteredYetShould`,`No location registered yet — should be auto-seeded at next boot.`)})]}),v.length>0&&r(`div`,{className:`border-t border-border`,children:v.map(e=>r(dt,{location:e,cardinality:o,canDelete:pe(e,v,o),onEdit:u,onDelete:d,onSetMode:p,blockedReasons:fe(e,v),ownedBytes:h?.get(e.id)??null,drain:Me(Ne(e),g?.get(e.id)),siblings:v},e.id))})]})}var pt=[`recordings`,`recordingsLow`];function mt(e){return e.locationIds!==void 0&&e.locationIds.length>0?e.locationIds:e.locationId===null?[]:[e.locationId]}function ht(e,t){if(t===void 0||!pt.includes(e.type))return null;let n=t.find(t=>mt(t).includes(e.id));return n===void 0||!Number.isFinite(n.usedBytes)||n.usedBytes<0?null:n.usedBytes}function gt(e,t){let n=new Map;for(let r of e){let e=ht(r,t);e!==null&&n.set(r.id,e)}return n}export{Ae as a,U as c,Be as i,ue as l,ft as n,De as o,q as r,he as s,gt as t,z as u};
@@ -16,4 +16,4 @@ const __mfImport = (src) =>
16
16
  await __mfHostInit.__tla;
17
17
  const { initHost } = __mfHostInit;
18
18
  await initHost();
19
- })().then(() => __mfImport("./index-C3uCLHv0.js"));
19
+ })().then(() => __mfImport("./index-XXQ5yMw_.js"));
@@ -1 +1 @@
1
- import{K as e,R as t,et as n}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{Hi as r,Ui as i,fr as a,gr as o,xa as s}from"./client-DvJxGh2F.js";import{$n as c,Qn as l,ar as u,nr as d,or as f,tr as p}from"./src-DntJrWmU.js";import{t as m}from"./i18n-xhwARoF0.js";import{mr as h}from"./index-C3uCLHv0.js";n();var g=`step`,_=[g,`acc`];function v(e,t){return`${e}/${t}`}function y(e,t,n){let r=n.step!==null&&e.includes(n.step),i=n.acc!==null&&t.includes(n.acc);return{stepId:r?n.step:null,acceleratorId:i?n.acc:null,staleStepId:n.step!==null&&n.step!==``&&!r&&e.length>0?n.step:null}}var b=`armed:`;function x(e){return e.assignment.reasons.detection?.startsWith(b)===!0}function S(e){let{assignment:t,detection:n}=e;return n!==null&&n.provisioning.state===`failed`||t.detectionNodeId===null&&n===null&&!x(e)?`error`:n!==null&&n.phase===`active`?`healthy`:`idle`}function ee(e){let t=[],n=[],{assignment:r,detection:i,broker:a}=e;i!==null&&i.provisioning.state===`failed`&&t.push({code:`provisioning-failed`,severity:`error`,message:i.provisioning.error!==void 0&&i.provisioning.error.length>0?m.t(`helpers.cameraCardModel.provisioningFailedWith`,{error:i.provisioning.error}):m.t(`helpers.cameraCardModel.provisioningFailed`)}),i!==null&&i.phase===`active`&&i.actualFps===0&&t.push({code:`detection-black-hole`,severity:`error`,message:m.t(`helpers.cameraCardModel.blackHole`)}),r.detectionNodeId===null&&i===null&&!x(e)&&n.push({code:`unassigned`,severity:`warning`,message:m.t(`helpers.cameraCardModel.unassigned`)});let o=e.degraded??[];if(o.length>0){let e=[...new Set(o.map(e=>e.stage))].join(`, `);n.push({code:`status-unreadable`,severity:`warning`,message:m.t(`helpers.cameraCardModel.statusUnreadable`,{stages:e})})}n.push(...C(e.cameraSensors));for(let e of a?.profiles??[])e.status===`streaming`&&e.inFps===0&&n.push({code:`broker-stalled`,severity:`warning`,message:m.t(`helpers.cameraCardModel.brokerStalled`,{profile:e.profile})});return[...t,...n]}function te(e){return e.state===`unreadable`&&o.state===`unreadable`&&e.reason===o.reason}function ne(e){switch(e.state){case`ready`:return null;case`missing`:return{code:`camera-sensor-missing`,severity:`warning`,message:m.t(`helpers.cameraCardModel.sensorMissing`,{addonId:e.addonId,stableId:e.stableId})};case`offline`:return{code:`camera-sensor-offline`,severity:`warning`,message:m.t(`helpers.cameraCardModel.sensorOffline`,{name:e.name,deviceId:e.deviceId,reason:e.reason})};case`unsupported`:return{code:`camera-sensor-unsupported`,severity:`warning`,message:m.t(`helpers.cameraCardModel.sensorUnsupported`,{name:e.name,deviceId:e.deviceId,reason:e.reason})};case`unreadable`:return{code:`camera-sensor-unreadable`,severity:`warning`,message:m.t(`helpers.cameraCardModel.sensorUnreadable`,{addonId:e.addonId,stableId:e.stableId,reason:e.reason})}}}function C(e){if(e===void 0||e.state===`not-configured`)return[];if(e.state===`unreadable`)return te(e)?[]:[{code:`camera-sensors-unreadable`,severity:`warning`,message:m.t(`helpers.cameraCardModel.sensorsUnreadable`,{reason:e.reason})}];let t=e.sensors.flatMap(e=>{let t=ne(e);return t===null?[]:[t]}),n=e.notForwarded===void 0?t:[w(e.notForwarded),...t];return e.notEnforced===void 0?n:[{code:`camera-sensors-not-enforced`,severity:`warning`,message:m.t(`helpers.cameraCardModel.notEnforced`)},...n]}function w(e){return{code:`camera-sensors-not-forwarded`,severity:`warning`,message:e===`onboard-not-listed`?m.t(`helpers.cameraCardModel.notForwardedOnboard`):m.t(`helpers.cameraCardModel.notForwardedNoDetection`)}}function T(e){return e===void 0?m.t(`helpers.cameraCardModel.summaryUnavailable`):e.state===`not-configured`?m.t(`helpers.cameraCardModel.summaryNone`):e.state===`unreadable`?m.t(`helpers.cameraCardModel.summaryUnknown`,{reason:e.reason}):e.sensors.map(D).join(`, `)}function E(e){return e.mode===`in-addition`?``:` · ${e.mode}`}function D(e){return`${O(e)}${E(e)}`}function O(e){switch(e.state){case`ready`:return`${e.name} (#${e.deviceId})`;case`offline`:return`${e.name} (#${e.deviceId}) — ${e.reason}`;case`unsupported`:return m.t(`helpers.cameraCardModel.summaryUnsupported`,{name:e.name,deviceId:e.deviceId});case`missing`:case`unreadable`:return`${e.addonId}/${e.stableId} — ${e.state}`}}function k(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function A(e){return typeof e==`string`&&e.length>0?e:null}function j(e){return typeof e==`number`&&Number.isFinite(e)?e:null}function M(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function N(e,t){return e==null?!1:JSON.stringify(e)!==JSON.stringify(t??null)}var P={detectionMode:null,detectionStreamProfile:null,detectionFps:null,motionSources:[],motionFps:null,motionCooldownMs:null,motionStreamProfile:null,audioMode:null,pipelineNodeId:null,decoderNodeId:null,audioNodeId:null,overriddenKeys:new Set};function F(e){if(!k(e)||!Array.isArray(e.sections))return P;let t=s(e),n=e=>{let n=t.get(e);if(n!==void 0)return n.value??n.default},r=new Set;for(let[e,n]of t)N(n.value,n.default)&&r.add(e);return{detectionMode:A(n(`detectionMode`)),detectionStreamProfile:A(n(`detectionStreamProfile`)),detectionFps:j(n(`detectionFps`)),motionSources:M(n(`motionSources`)),motionFps:j(n(`motionFps`)),motionCooldownMs:j(n(`motionCooldownMs`)),motionStreamProfile:A(n(`motionStreamProfile`)),audioMode:A(n(`audioMode`)),pipelineNodeId:A(n(`pipelineNodeId`)),decoderNodeId:A(n(`decoderNodeId`)),audioNodeId:A(n(`audioNodeId`)),overriddenKeys:r}}function I(e,t=0){let n=[];for(let r of e)n.push({addonId:r.addonId,modelId:r.modelId??null,enabled:r.enabled,depth:t}),r.children!==void 0&&r.children.length>0&&n.push(...I(r.children,t+1));return n}function L(n,r){let[i,a]=h(),o=i.get(g),s=i.get(`acc`),c=e(()=>y(n,r,{step:o,acc:s}),[n,r,o,s]),l=t(e=>{a(t=>{let n=new URLSearchParams(t);return e(n),n},{replace:!0})},[a]);return{selection:c,open:t(e=>l(t=>{t.set(g,e.stepId),e.acceleratorId===void 0?t.delete(`acc`):t.set(`acc`,e.acceleratorId)}),[l]),close:t(()=>l(e=>{e.delete(g),e.delete(`acc`)}),[l])}}function R(e,t){for(let n of e?.slots??[])for(let e of n.addons)if(e.id===t)return e;return null}function z(e){return e.split(`.`)[0]??e}function B(e,t,n){return{id:v(e,n.key),nodeId:e,deviceKey:n.key,device:n,label:`${z(t)} · ${u(n)}`,shortLabel:`${z(t)} · ${f(n)}`,nodeLabel:z(t),disabled:!n.enabled}}function V(e,t,n,r=!1){return n.filter(e=>r||e.enabled).map(n=>B(e,t,n))}function H(e,t,n){return{modelId:p({catalog:e,device:t.device,base:n.nodePin}),source:n.nodePin===void 0?`default`:`node`}}function U(e,t){let n=R(e,`object-detection`);if(n===null)return;let r=p({catalog:n,device:t.device,base:t.device.steps?.[`object-detection`]?.modelId});if(r===void 0)return;let i=n.models.find(e=>e.id===r);return{modelId:r,name:i?.name??r,supplies:i?.suppliesSteps??[]}}function W(e,t,n){return!r(e)||n===void 0?!1:i(e,t,n.supplies).effective}function G(e,t){return e!==null&&d(e.models,t.device.format)}function K(e){return G(e.addon,e.acc)?e.clusterModelId===void 0?{kind:`enabled`,modelId:e.model.modelId??`Auto`,...e.rootName===void 0?{}:{suppliedByRoot:e.rootName},...e.jumpTo===void 0?{}:{jumpTo:e.jumpTo}}:{kind:`enabled`,modelId:e.clusterModelId,clusterWide:!0}:e.gatedOn?e.jumpTo===void 0?{kind:`skip`}:{kind:`skip`,jumpTo:e.jumpTo}:{kind:`na`}}function q(e){if(e===null)return[];let t=(e.configSchema??[]).flatMap(e=>`label`in e&&typeof e.label==`string`?[e.label]:[]),n=a(e.id).map(e=>e.label);return[...new Set([...t,...n])]}function J(e){return e.flatMap(e=>[{node:e,depth:0},...J(e.children).map(e=>({node:e.node,depth:e.depth+1}))])}function Y(e){return c(e)}function X(e){return{nodeFields:Y(e),acceleratorFields:Z(e)}}function Z(e){return e.flatMap(e=>{if(e.type===`group`){let t=Z(e.fields);return t.length>0?[{...e,fields:[...t]}]:[]}return l(e)?[e]:[]})}function Q(e){return e.some(e=>e.type===`group`?Q(e.fields):l(e))}function $(e,t){return e.flatMap(e=>{let n=$(e.children,t);return t.has(e.addonId)||n.length>0?[{...e,children:n}]:[]})}export{F as _,J as a,_ as b,U as c,q as d,H as f,ee as g,T as h,R as i,G as l,L as m,K as n,Q as o,W as p,$ as r,V as s,Y as t,X as u,I as v,S as y};
1
+ import{K as e,R as t,et as n}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{Hi as r,Ui as i,fr as a,gr as o,xa as s}from"./client-DvJxGh2F.js";import{$n as c,Qn as l,ar as u,nr as d,or as f,tr as p}from"./src-DntJrWmU.js";import{t as m}from"./i18n-D0o08mg-.js";import{mr as h}from"./index-XXQ5yMw_.js";n();var g=`step`,_=[g,`acc`];function v(e,t){return`${e}/${t}`}function y(e,t,n){let r=n.step!==null&&e.includes(n.step),i=n.acc!==null&&t.includes(n.acc);return{stepId:r?n.step:null,acceleratorId:i?n.acc:null,staleStepId:n.step!==null&&n.step!==``&&!r&&e.length>0?n.step:null}}var b=`armed:`;function x(e){return e.assignment.reasons.detection?.startsWith(b)===!0}function S(e){let{assignment:t,detection:n}=e;return n!==null&&n.provisioning.state===`failed`||t.detectionNodeId===null&&n===null&&!x(e)?`error`:n!==null&&n.phase===`active`?`healthy`:`idle`}function ee(e){let t=[],n=[],{assignment:r,detection:i,broker:a}=e;i!==null&&i.provisioning.state===`failed`&&t.push({code:`provisioning-failed`,severity:`error`,message:i.provisioning.error!==void 0&&i.provisioning.error.length>0?m.t(`helpers.cameraCardModel.provisioningFailedWith`,{error:i.provisioning.error}):m.t(`helpers.cameraCardModel.provisioningFailed`)}),i!==null&&i.phase===`active`&&i.actualFps===0&&t.push({code:`detection-black-hole`,severity:`error`,message:m.t(`helpers.cameraCardModel.blackHole`)}),r.detectionNodeId===null&&i===null&&!x(e)&&n.push({code:`unassigned`,severity:`warning`,message:m.t(`helpers.cameraCardModel.unassigned`)});let o=e.degraded??[];if(o.length>0){let e=[...new Set(o.map(e=>e.stage))].join(`, `);n.push({code:`status-unreadable`,severity:`warning`,message:m.t(`helpers.cameraCardModel.statusUnreadable`,{stages:e})})}n.push(...C(e.cameraSensors));for(let e of a?.profiles??[])e.status===`streaming`&&e.inFps===0&&n.push({code:`broker-stalled`,severity:`warning`,message:m.t(`helpers.cameraCardModel.brokerStalled`,{profile:e.profile})});return[...t,...n]}function te(e){return e.state===`unreadable`&&o.state===`unreadable`&&e.reason===o.reason}function ne(e){switch(e.state){case`ready`:return null;case`missing`:return{code:`camera-sensor-missing`,severity:`warning`,message:m.t(`helpers.cameraCardModel.sensorMissing`,{addonId:e.addonId,stableId:e.stableId})};case`offline`:return{code:`camera-sensor-offline`,severity:`warning`,message:m.t(`helpers.cameraCardModel.sensorOffline`,{name:e.name,deviceId:e.deviceId,reason:e.reason})};case`unsupported`:return{code:`camera-sensor-unsupported`,severity:`warning`,message:m.t(`helpers.cameraCardModel.sensorUnsupported`,{name:e.name,deviceId:e.deviceId,reason:e.reason})};case`unreadable`:return{code:`camera-sensor-unreadable`,severity:`warning`,message:m.t(`helpers.cameraCardModel.sensorUnreadable`,{addonId:e.addonId,stableId:e.stableId,reason:e.reason})}}}function C(e){if(e===void 0||e.state===`not-configured`)return[];if(e.state===`unreadable`)return te(e)?[]:[{code:`camera-sensors-unreadable`,severity:`warning`,message:m.t(`helpers.cameraCardModel.sensorsUnreadable`,{reason:e.reason})}];let t=e.sensors.flatMap(e=>{let t=ne(e);return t===null?[]:[t]}),n=e.notForwarded===void 0?t:[w(e.notForwarded),...t];return e.notEnforced===void 0?n:[{code:`camera-sensors-not-enforced`,severity:`warning`,message:m.t(`helpers.cameraCardModel.notEnforced`)},...n]}function w(e){return{code:`camera-sensors-not-forwarded`,severity:`warning`,message:e===`onboard-not-listed`?m.t(`helpers.cameraCardModel.notForwardedOnboard`):m.t(`helpers.cameraCardModel.notForwardedNoDetection`)}}function T(e){return e===void 0?m.t(`helpers.cameraCardModel.summaryUnavailable`):e.state===`not-configured`?m.t(`helpers.cameraCardModel.summaryNone`):e.state===`unreadable`?m.t(`helpers.cameraCardModel.summaryUnknown`,{reason:e.reason}):e.sensors.map(D).join(`, `)}function E(e){return e.mode===`in-addition`?``:` · ${e.mode}`}function D(e){return`${O(e)}${E(e)}`}function O(e){switch(e.state){case`ready`:return`${e.name} (#${e.deviceId})`;case`offline`:return`${e.name} (#${e.deviceId}) — ${e.reason}`;case`unsupported`:return m.t(`helpers.cameraCardModel.summaryUnsupported`,{name:e.name,deviceId:e.deviceId});case`missing`:case`unreadable`:return`${e.addonId}/${e.stableId} — ${e.state}`}}function k(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function A(e){return typeof e==`string`&&e.length>0?e:null}function j(e){return typeof e==`number`&&Number.isFinite(e)?e:null}function M(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function N(e,t){return e==null?!1:JSON.stringify(e)!==JSON.stringify(t??null)}var P={detectionMode:null,detectionStreamProfile:null,detectionFps:null,motionSources:[],motionFps:null,motionCooldownMs:null,motionStreamProfile:null,audioMode:null,pipelineNodeId:null,decoderNodeId:null,audioNodeId:null,overriddenKeys:new Set};function F(e){if(!k(e)||!Array.isArray(e.sections))return P;let t=s(e),n=e=>{let n=t.get(e);if(n!==void 0)return n.value??n.default},r=new Set;for(let[e,n]of t)N(n.value,n.default)&&r.add(e);return{detectionMode:A(n(`detectionMode`)),detectionStreamProfile:A(n(`detectionStreamProfile`)),detectionFps:j(n(`detectionFps`)),motionSources:M(n(`motionSources`)),motionFps:j(n(`motionFps`)),motionCooldownMs:j(n(`motionCooldownMs`)),motionStreamProfile:A(n(`motionStreamProfile`)),audioMode:A(n(`audioMode`)),pipelineNodeId:A(n(`pipelineNodeId`)),decoderNodeId:A(n(`decoderNodeId`)),audioNodeId:A(n(`audioNodeId`)),overriddenKeys:r}}function I(e,t=0){let n=[];for(let r of e)n.push({addonId:r.addonId,modelId:r.modelId??null,enabled:r.enabled,depth:t}),r.children!==void 0&&r.children.length>0&&n.push(...I(r.children,t+1));return n}function L(n,r){let[i,a]=h(),o=i.get(g),s=i.get(`acc`),c=e(()=>y(n,r,{step:o,acc:s}),[n,r,o,s]),l=t(e=>{a(t=>{let n=new URLSearchParams(t);return e(n),n},{replace:!0})},[a]);return{selection:c,open:t(e=>l(t=>{t.set(g,e.stepId),e.acceleratorId===void 0?t.delete(`acc`):t.set(`acc`,e.acceleratorId)}),[l]),close:t(()=>l(e=>{e.delete(g),e.delete(`acc`)}),[l])}}function R(e,t){for(let n of e?.slots??[])for(let e of n.addons)if(e.id===t)return e;return null}function z(e){return e.split(`.`)[0]??e}function B(e,t,n){return{id:v(e,n.key),nodeId:e,deviceKey:n.key,device:n,label:`${z(t)} · ${u(n)}`,shortLabel:`${z(t)} · ${f(n)}`,nodeLabel:z(t),disabled:!n.enabled}}function V(e,t,n,r=!1){return n.filter(e=>r||e.enabled).map(n=>B(e,t,n))}function H(e,t,n){return{modelId:p({catalog:e,device:t.device,base:n.nodePin}),source:n.nodePin===void 0?`default`:`node`}}function U(e,t){let n=R(e,`object-detection`);if(n===null)return;let r=p({catalog:n,device:t.device,base:t.device.steps?.[`object-detection`]?.modelId});if(r===void 0)return;let i=n.models.find(e=>e.id===r);return{modelId:r,name:i?.name??r,supplies:i?.suppliesSteps??[]}}function W(e,t,n){return!r(e)||n===void 0?!1:i(e,t,n.supplies).effective}function G(e,t){return e!==null&&d(e.models,t.device.format)}function K(e){return G(e.addon,e.acc)?e.clusterModelId===void 0?{kind:`enabled`,modelId:e.model.modelId??`Auto`,...e.rootName===void 0?{}:{suppliedByRoot:e.rootName},...e.jumpTo===void 0?{}:{jumpTo:e.jumpTo}}:{kind:`enabled`,modelId:e.clusterModelId,clusterWide:!0}:e.gatedOn?e.jumpTo===void 0?{kind:`skip`}:{kind:`skip`,jumpTo:e.jumpTo}:{kind:`na`}}function q(e){if(e===null)return[];let t=(e.configSchema??[]).flatMap(e=>`label`in e&&typeof e.label==`string`?[e.label]:[]),n=a(e.id).map(e=>e.label);return[...new Set([...t,...n])]}function J(e){return e.flatMap(e=>[{node:e,depth:0},...J(e.children).map(e=>({node:e.node,depth:e.depth+1}))])}function Y(e){return c(e)}function X(e){return{nodeFields:Y(e),acceleratorFields:Z(e)}}function Z(e){return e.flatMap(e=>{if(e.type===`group`){let t=Z(e.fields);return t.length>0?[{...e,fields:[...t]}]:[]}return l(e)?[e]:[]})}function Q(e){return e.some(e=>e.type===`group`?Q(e.fields):l(e))}function $(e,t){return e.flatMap(e=>{let n=$(e.children,t);return t.has(e.addonId)||n.length>0?[{...e,children:n}]:[]})}export{F as _,J as a,_ as b,U as c,q as d,H as f,ee as g,T as h,R as i,G as l,L as m,K as n,Q as o,W as p,$ as r,V as s,Y as t,X as u,I as v,S as y};
@@ -1 +1 @@
1
- import{C as e,K as t,R as n,S as r,et as i}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{Nt as a}from"./player-overlays-Dbv95cvz.js";import{lr as o,mr as s}from"./index-C3uCLHv0.js";function c({staleNodeId:t,shownNodeName:n}){return t===null?null:e(`div`,{role:`status`,className:`flex items-start gap-2 rounded-md border border-warning/30 bg-warning/5 px-3 py-2 text-[11px] text-foreground-subtle`,children:[r(a,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-warning`}),r(`span`,{children:r(o,{i18nKey:`shared.staleNodeNotice.notice`,values:{id:t,name:n},components:{b:r(`span`,{className:`font-medium text-foreground`})}})})]})}i();var l=`node`;function u(e){return[...e].toSorted((e,t)=>e.isHub===t.isHub?e.isOnline===t.isOnline?e.name.localeCompare(t.name):e.isOnline?-1:1:e.isHub?-1:1)}function d(e,t){let n=u(e),r=n[0]??null;if(r===null)return{node:null,outcome:`empty`,staleNodeId:null};if(t===null||t.length===0)return{node:r,outcome:`default`,staleNodeId:null};let i=n.find(e=>e.id===t);return i===void 0?{node:r,outcome:`stale`,staleNodeId:t}:{node:i,outcome:`requested`,staleNodeId:null}}function f(e){let[r,i]=s(),a=r.get(l);return{selection:t(()=>d(e,a),[e,a]),selectNode:n(e=>{let t=new URLSearchParams(r);t.set(l,e),i(t,{replace:!0})},[r,i]),requestedNodeId:a}}export{c as n,f as t};
1
+ import{C as e,K as t,R as n,S as r,et as i}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{Nt as a}from"./player-overlays-Dbv95cvz.js";import{lr as o,mr as s}from"./index-XXQ5yMw_.js";function c({staleNodeId:t,shownNodeName:n}){return t===null?null:e(`div`,{role:`status`,className:`flex items-start gap-2 rounded-md border border-warning/30 bg-warning/5 px-3 py-2 text-[11px] text-foreground-subtle`,children:[r(a,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-warning`}),r(`span`,{children:r(o,{i18nKey:`shared.staleNodeNotice.notice`,values:{id:t,name:n},components:{b:r(`span`,{className:`font-medium text-foreground`})}})})]})}i();var l=`node`;function u(e){return[...e].toSorted((e,t)=>e.isHub===t.isHub?e.isOnline===t.isOnline?e.name.localeCompare(t.name):e.isOnline?-1:1:e.isHub?-1:1)}function d(e,t){let n=u(e),r=n[0]??null;if(r===null)return{node:null,outcome:`empty`,staleNodeId:null};if(t===null||t.length===0)return{node:r,outcome:`default`,staleNodeId:null};let i=n.find(e=>e.id===t);return i===void 0?{node:r,outcome:`stale`,staleNodeId:t}:{node:i,outcome:`requested`,staleNodeId:null}}function f(e){let[r,i]=s(),a=r.get(l);return{selection:t(()=>d(e,a),[e,a]),selectNode:n(e=>{let t=new URLSearchParams(r);t.set(l,e),i(t,{replace:!0})},[r,i]),requestedNodeId:a}}export{c as n,f as t};
package/dist/index.html CHANGED
@@ -136,18 +136,18 @@
136
136
  })
137
137
  })()
138
138
  </script>
139
- <script type="module" crossorigin src="./assets/mf-entry-bootstrap-0-f45a46c2.js"></script>
139
+ <script type="module" crossorigin src="./assets/mf-entry-bootstrap-0-dcdd32c2.js"></script>
140
140
  <link rel="modulepreload" crossorigin href="./assets/__vite-browser-external-BlMfPwfH.js">
141
141
  <link rel="modulepreload" crossorigin href="./assets/client-DvJxGh2F.js">
142
142
  <link rel="modulepreload" crossorigin href="./assets/player-overlays-Dbv95cvz.js">
143
143
  <link rel="modulepreload" crossorigin href="./assets/src-DntJrWmU.js">
144
144
  <link rel="modulepreload" crossorigin href="./assets/useTranslation-BJr-n0es.js">
145
- <link rel="modulepreload" crossorigin href="./assets/i18n-xhwARoF0.js">
145
+ <link rel="modulepreload" crossorigin href="./assets/i18n-D0o08mg-.js">
146
146
  <link rel="modulepreload" crossorigin href="./assets/video-D7jv0spx.js">
147
147
  <link rel="modulepreload" crossorigin href="./assets/mount-CUPf26ML.js">
148
148
  <link rel="modulepreload" crossorigin href="./assets/addon-icons-context-lrP_33gc.js">
149
- <link rel="stylesheet" crossorigin href="./assets/index-D4ZlWCxy.css">
150
- <link rel="modulepreload" crossorigin href="./assets/hostInit-DB6u6qxU.js"><link rel="modulepreload" crossorigin href="./assets/index-C3uCLHv0.js"><link rel="modulepreload" crossorigin href="./assets/remoteEntry-CVuKB7K_.js"><link rel="modulepreload" crossorigin href="./assets/_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-QiJARN9B.js"><link rel="modulepreload" crossorigin href="./assets/_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js"><link rel="modulepreload" crossorigin href="./assets/_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_trpc_mf_1_client__loadShare__.js-8kv6pj9W.js"><link rel="modulepreload" crossorigin href="./assets/_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_trpc_mf_1_react_mf_2_query__loadShare__.js-DzoL8nR8.js"><link rel="modulepreload" crossorigin href="./assets/_virtual_mf___mfe_internal__admin_ui_host__loadShare__react_mf_2_dom__loadShare__.js-BPba2g2p.js"><link rel="modulepreload" crossorigin href="./assets/_virtual_mf___mfe_internal__admin_ui_host__loadShare__react_mf_2_dom_mf_1_client__loadShare__.js-ZBKFTPET.js"></head>
149
+ <link rel="stylesheet" crossorigin href="./assets/index-D4id__eL.css">
150
+ <link rel="modulepreload" crossorigin href="./assets/hostInit-DB6u6qxU.js"><link rel="modulepreload" crossorigin href="./assets/index-XXQ5yMw_.js"><link rel="modulepreload" crossorigin href="./assets/remoteEntry-CVuKB7K_.js"><link rel="modulepreload" crossorigin href="./assets/_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-QiJARN9B.js"><link rel="modulepreload" crossorigin href="./assets/_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js"><link rel="modulepreload" crossorigin href="./assets/_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_trpc_mf_1_client__loadShare__.js-8kv6pj9W.js"><link rel="modulepreload" crossorigin href="./assets/_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_trpc_mf_1_react_mf_2_query__loadShare__.js-DzoL8nR8.js"><link rel="modulepreload" crossorigin href="./assets/_virtual_mf___mfe_internal__admin_ui_host__loadShare__react_mf_2_dom__loadShare__.js-BPba2g2p.js"><link rel="modulepreload" crossorigin href="./assets/_virtual_mf___mfe_internal__admin_ui_host__loadShare__react_mf_2_dom_mf_1_client__loadShare__.js-ZBKFTPET.js"></head>
151
151
  <body>
152
152
  <div id="root"></div>
153
153
  <!-- Lock the app shell at 1x zoom. iOS Safari ignores `user-scalable=no`
@@ -82940,7 +82940,7 @@ var AdminUIAddon = class extends BaseAddon {
82940
82940
  capability: adminUiCapability,
82941
82941
  provider: {
82942
82942
  getStaticDir: async () => ({ staticDir: resolveAdminUiDistDir() }),
82943
- getVersion: async () => ({ version: "1.2.477" })
82943
+ getVersion: async () => ({ version: "1.2.478" })
82944
82944
  }
82945
82945
  }];
82946
82946
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-admin-ui",
3
- "version": "1.2.477",
3
+ "version": "1.2.478",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Admin UI — Vite frontend build and server-side addon",
@@ -1 +0,0 @@
1
- import{C as e,J as t,K as n,R as r,S as i,V as a,Y as o,et as s,o as c,x as l}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{Cn as u,Di as d,On as f,Si as p,bn as m,dt as h,fn as g,fr as _,kn as v,or as ee,ot as y,un as b,xi as x,yi as S}from"./player-overlays-Dbv95cvz.js";import{t as te}from"./table-2-CTZnEliG.js";import{$u as C,Dr as ne,F as w,Kr as T,Mt as E,Pt as re,Ua as D,as as ie,cs as O,ed as k,fo as ae,jt as A,li as j,ot as M,r as N,sd as P,to as F,us as oe}from"./src-DntJrWmU.js";import{t as I}from"./i18n-xhwARoF0.js";import{t as L}from"./useTranslation-BJr-n0es.js";import{fr as se,mr as ce,sr as R}from"./index-C3uCLHv0.js";import{t as le}from"./AdminPage-3JxWocN3.js";import"./useEventInvalidation-CUPf26ML.js";import{t as z}from"./device-integration-icon-0oWIIjcP.js";import{n as B,r as V,t as H}from"./ScanNetworkModal-DXzDOpxk.js";s();function U({rows:t,isExpanded:r,onToggleExpand:a,onOpen:s,renderExpanded:c,searchPlaceholder:l,emptyLabel:u}){let{t:d}=L(),[f,p]=o(``),m=n(()=>{let e=f.trim().toLowerCase();return e.length===0?t:t.filter(t=>`${t.name} ${t.addonId}`.toLowerCase().includes(e))},[f,t]);return e(`div`,{className:`space-y-3`,children:[e(`div`,{className:`relative`,children:[i(g,{className:`pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-foreground-subtle`,"aria-hidden":!0}),i(C,{type:`search`,value:f,onChange:e=>p(e.target.value),placeholder:l,"aria-label":l,className:`pl-8`})]}),m.length===0?i(`p`,{className:`py-8 text-center text-xs text-foreground-subtle`,children:u}):i(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-2 sm:gap-3 lg:grid-cols-3`,children:m.map(e=>i(W,{integration:e,expanded:r(e),onToggleExpand:a,onOpen:s,renderExpanded:c},e.id))})]})}function W({integration:t,expanded:n,onToggleExpand:r,onOpen:a,renderExpanded:o}){let{t:s}=L(),c=n?s(`integrations.integrationColumns.collapse`,`Collapse`):s(`integrations.integrationColumns.expand`,`Expand`);return e(`article`,{"data-testid":`integration-card-${t.id}`,className:P(`flex min-w-0 flex-col gap-2 rounded-lg border border-border bg-surface p-3`,n&&`sm:col-span-2 lg:col-span-3`),children:[e(`div`,{className:`flex items-start gap-2`,children:[i(R,{type:t.addonId,size:`md`}),e(`div`,{className:`min-w-0 flex-1`,children:[i(`p`,{className:`truncate text-xs font-semibold text-foreground`,children:t.name}),i(`p`,{className:`truncate text-[10px] text-foreground-subtle`,children:t.addonId})]}),i(M,{status:t.status,className:`shrink-0`})]}),i(`p`,{className:`text-[11px] text-foreground-muted`,children:s(`integrations.integrationColumns.deviceCount`,{count:t.deviceCount})}),e(`div`,{className:`flex flex-wrap items-center justify-end gap-1`,children:[i(k,{type:`button`,variant:`ghost`,size:`sm`,icon:n?x:S,"aria-label":c,"aria-expanded":n,onClick:()=>r(t.addonId)}),i(T,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>a(t),children:s(`integrations.open`,`Open`)})]}),n?o(t):null]})}s();var G=`camstack.admin.integrations.view`;function K(e){return e===`table`||e===`grid`}function q(){try{return typeof window>`u`?null:window.localStorage}catch{return null}}function J(e=q()){if(e===null)return`table`;try{let t=e.getItem(G);return K(t)?t:`table`}catch{return`table`}}function Y(e,t=q()){if(t!==null)try{t.setItem(G,e)}catch{}}function ue(){let[e,t]=o(()=>J());return[e,r(e=>{t(e),Y(e)},[])]}s();function de(e=!0){a(()=>{if(!e)return;let t=document.body.style.overflow;return document.body.style.overflow=`hidden`,()=>{document.body.style.overflow=t}},[e])}s();function fe(e,t){let[n,r]=o(!1);return a(()=>{if(!e){r(!1);return}r(!1);let n=setTimeout(()=>r(!0),t);return()=>clearTimeout(n)},[e,t]),n}s();function pe({providerId:t,onImport:n,onSkip:r}){let{t:s}=L(),[c,l]=o(new Set),u=F(),f=u.data,m=u.isPending||!u.data&&!u.isError;a(()=>{t&&(u.isPending||u.data||u.mutate({addonId:t}))},[t,u]);function h(e){l(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}if(m)return e(`div`,{className:`flex flex-col items-center py-12`,children:[i(`div`,{className:`h-6 w-6 animate-spin rounded-full border-2 border-primary border-t-transparent`}),i(`p`,{className:`mt-3 text-xs text-foreground-subtle`,children:s(`integrations.searchingDevices`)})]});let g=f??[];return e(`div`,{className:`space-y-4`,children:[i(`p`,{className:`text-xs text-foreground-subtle`,children:g.length>0?s(`integrations.foundDevices`,{count:g.length}):s(`integrations.noDevicesFound`)}),g.length>0&&i(`div`,{className:`space-y-1.5 max-h-64 overflow-y-auto`,children:g.map(t=>{let n=t.stableId,r=t.suggestedName??n,a=c.has(n),o=t.alreadyOnboarded===!0;return e(`button`,{onClick:()=>{o||h(n)},disabled:o,title:o?s(`integrations.alreadyAddedHint`,{defaultValue:`Already added as "{{name}}" — re-adding would overwrite its settings.`,name:t.onboardedName??r}):void 0,className:`flex w-full items-center gap-3 rounded-lg border p-3 text-left transition-colors ${o?`border-border bg-surface opacity-60 cursor-not-allowed`:a?`border-primary/40 bg-primary/5`:`border-border bg-surface hover:border-foreground-subtle/30`}`,children:[i(`div`,{className:`flex h-5 w-5 items-center justify-center rounded border flex-shrink-0 ${a&&!o?`border-primary bg-primary`:`border-border`}`,children:a&&!o&&i(p,{className:`h-3 w-3 text-primary-foreground`})}),i(d,{className:`h-3.5 w-3.5 text-foreground-subtle flex-shrink-0`}),i(`span`,{className:`text-xs font-medium text-foreground truncate`,children:r}),o&&i(`span`,{className:`ml-auto flex-shrink-0 rounded bg-surface-muted px-1.5 py-0.5 text-[10px] font-medium text-foreground-subtle`,children:s(`integrations.alreadyAdded`,{defaultValue:`Already added`})})]},n)})}),e(`div`,{className:`flex items-center justify-between pt-2`,children:[i(`button`,{onClick:r,className:`rounded-lg border border-border px-3 py-1.5 text-xs text-foreground-subtle hover:text-foreground transition-colors`,children:s(`integrations.skip`)}),g.length>0&&e(`button`,{onClick:()=>n(Array.from(c)),disabled:c.size===0,className:`rounded-lg bg-primary px-4 py-1.5 text-xs font-medium text-primary-foreground shadow-sm disabled:opacity-50`,children:[s(`integrations.importSelected`),` (`,c.size,`)`]})]})]})}var X=`(hover: none) and (pointer: coarse)`;function me(){if(typeof window>`u`||typeof window.matchMedia!=`function`)return!0;try{return!window.matchMedia(X).matches}catch{return!0}}s();function he({onSelect:r,onClose:s,pendingAddonId:c=null}){let{t:l}=L(),u=se(),[d,f]=o(``),p=t(null),{data:m,isLoading:h}=O();a(()=>{h||!me()||p.current?.focus()},[h]);let _=n(()=>{let e=m??[],t=d.trim().toLowerCase();return t.length===0?e:e.filter(e=>`${e.name} ${e.description??``} ${e.addonId}`.toLowerCase().includes(t))},[m,d]);if(h)return i(`div`,{className:`grid grid-cols-2 gap-2 p-2`,children:[1,2,3,4].map(e=>i(`div`,{className:`h-24 rounded-lg bg-surface animate-pulse`},e))});let v=c!==null;return e(`div`,{className:`space-y-3`,"data-testid":`provider-picker`,children:[e(`div`,{className:`relative`,children:[i(g,{className:`pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-foreground-subtle`,"aria-hidden":!0}),i(C,{ref:p,type:`search`,value:d,onChange:e=>f(e.target.value),placeholder:l(`integrations.searchProviders`,`Search integrations…`),className:`pl-8`,"data-testid":`provider-picker-search`,"aria-label":l(`integrations.searchProviders`,`Search integrations…`)})]}),i(`div`,{className:`grid grid-cols-2 gap-2`,children:_.map(t=>{let n=t.instanceMode===`unique`&&t.existingInstances.length>0,a=c===t.addonId,o=v;return e(`button`,{type:`button`,disabled:o,"data-testid":`provider-pick-${t.addonId}`,onClick:()=>{if(!o)if(n){let e=t.existingInstances[0].id;s(),u(`/integrations/${e}`)}else r(t.addonId,t.instanceMode,t.discoveryMode,t.name,t.kind,t.brokerKind,t.mode,t.canTest)},className:`flex flex-col items-center gap-1.5 rounded-lg border border-border bg-surface px-3 py-3 text-center text-xs hover:border-primary/50 hover:bg-surface-hover transition-colors disabled:opacity-60 disabled:cursor-not-allowed disabled:hover:border-border`,children:[t.iconUrl?i(`div`,{className:`flex h-9 w-9 items-center justify-center rounded-lg flex-shrink-0`,style:{backgroundColor:`${t.color}15`},children:i(`img`,{src:t.iconUrl,alt:``,className:`h-5 w-5`})}):i(`div`,{className:`flex h-9 w-9 items-center justify-center rounded-lg flex-shrink-0`,style:{backgroundColor:`${t.color}15`},children:i(`span`,{className:`text-sm`,style:{color:t.color},children:`◉`})}),i(`p`,{className:`w-full truncate text-xs font-semibold text-foreground`,children:t.name}),t.description?i(`p`,{className:`w-full line-clamp-2 text-[10px] text-foreground-subtle`,children:t.description}):null,a?i(ee,{className:`h-4 w-4 animate-spin text-primary`}):n?e(`span`,{className:`flex items-center gap-1 text-[10px] font-medium text-foreground-subtle`,children:[i(b,{className:`h-3 w-3`}),l(`integrations.manage`)]}):null]},t.addonId)})}),_.length===0&&i(`div`,{className:`py-8 text-center text-xs text-foreground-subtle`,children:(m??[]).length===0?l(`integrations.noProviders`):l(`integrations.noProvidersMatch`,`No integrations match your search.`)})]})}s();function ge(e){let t=e=>{if(e.type===`separator`||e.type===`info`||e.type===`button`)return e;if(e.type===`group`)return{...e,fields:e.fields.map(e=>t(e))};let{value:n,...r}=e;return r};return{...e.tabs?{tabs:e.tabs}:{},sections:e.sections.map(e=>({...e,fields:e.fields.map(t)}))}}var _e=2e4;function ve({open:t,onClose:r}){let{t:s}=L(),u=se(),d=c(),[f,p]=o(`picker`),[m,g]=o(null),[_,v]=o(null),[y,b]=o(`manual`),[x,S]=o(null),[te,C]=o(``),[ne,w]=o(null),[T,E]=o(null),[re,O]=o(!1),{data:k}=j({addonId:m??``,nodeId:`hub`},{enabled:m!=null}),ae=n(()=>k?ge(k):null,[k]),A=ie({onSuccess:()=>d.invalidateQueries({queryKey:[[`integrations`]]})}),M=F(),N=M.data;a(()=>{f!==`discovery`||!_||!m||M.isPending||M.data||M.mutate({addonId:m})},[f,_,m,M]);let P=D({onSuccess:()=>d.invalidateQueries({queryKey:[[`deviceManager`]]})});function oe(e,t,n,r,i,a,o,s){if(!A.isPending){if(g(e),O(s),b(n),C(r),E(null),o===`broker`){if(!a){E(`Addon '${e}' declares mode 'broker' but no brokerKind in its manifest`);return}S(a),p(`broker`);return}if(o===`account`){p(`config`);return}I(e,r)}}async function I(e,t){try{let n=await A.mutateAsync({addonId:e,name:t,settings:{}});r(),H(),u(`/integrations/${n.id}?add=1`)}catch{}}async function ce(e){if(m)try{let t=await A.mutateAsync({addonId:m,name:e.name,settings:e.config,secretKeys:[...e.secretKeys]});v(t.id),w(t.id),y===`auto`||y===`both`?p(`discovery`):z(t.id,{openAdd:!0})}catch{}}async function R(e){if(m)try{let t=await A.mutateAsync({addonId:m,name:te,settings:{brokerId:e}});w(t.id),v(t.id),z(t.id)}catch{}}async function le(e){if(m){for(let t of e){let e=N?.find(e=>e.stableId===t);e&&await P.mutateAsync({addonId:m,candidate:e,...ne===null?{}:{integrationId:ne}})}z()}}function z(e,t){let n=e??_??m;r(),H(),n&&u(t?.openAdd===!0?`/integrations/${n}?add=1`:`/integrations/${n}`)}function H(){p(`picker`),g(null),v(null),b(`manual`),S(null),C(``),w(null),E(null),O(!1)}function U(){r(),H()}de(t);let W=A.isPending,G=fe(W,_e);if(!t)return null;let K={picker:s(`integrations.newIntegration`),config:s(`integrations.configureIntegration`),discovery:s(`integrations.importDevices`),broker:s(`integrations.connectBroker`,{defaultValue:`Connect a broker`})},q=W?m:null,J=A.error,Y=W&&!G;return e(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center`,children:[i(`div`,{className:`absolute inset-0 bg-black/60`,onClick:Y?void 0:U}),e(`div`,{className:`relative z-10 w-full max-w-lg max-h-[calc(85dvh-2*max(env(safe-area-inset-top),env(safe-area-inset-bottom)))] rounded-xl border border-border bg-background shadow-2xl flex flex-col overflow-hidden`,children:[e(`div`,{className:`flex items-center justify-between border-b border-border px-5 py-4 flex-shrink-0`,children:[i(`h2`,{className:`text-sm font-semibold text-foreground`,children:K[f]}),i(`button`,{onClick:U,disabled:Y,className:`rounded-md p-1 text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-40 disabled:cursor-not-allowed`,children:i(h,{className:`h-4 w-4`})})]}),e(`div`,{className:`px-5 py-4 flex-1 overflow-y-auto overscroll-contain`,children:[J&&!W&&i(`div`,{className:`mb-3 rounded-lg border border-destructive/40 bg-destructive/10 px-3 py-2 text-xs text-destructive`,children:J instanceof Error?J.message:String(J)}),f===`picker`&&e(l,{children:[T&&i(`div`,{className:`mb-3 rounded-lg border border-destructive/40 bg-destructive/10 px-3 py-2 text-xs text-destructive`,children:T}),i(he,{onSelect:oe,onClose:U,pendingAddonId:q})]}),f===`config`&&m&&i(B,{addonId:m,configSchema:ae??null,canTest:re,onSave:ce,onBack:()=>p(`picker`)}),f===`broker`&&x&&i(V,{kind:x,onResolved:e=>{R(e)},onBack:()=>p(`picker`)}),f===`discovery`&&_&&i(pe,{providerId:_,onImport:le,onSkip:z})]}),W&&e(`div`,{className:`absolute inset-0 z-20 flex flex-col items-center justify-center gap-2 rounded-xl bg-background/85 backdrop-blur-sm px-6 text-center`,children:[i(ee,{className:`h-6 w-6 animate-spin text-primary`}),i(`p`,{className:`text-xs font-medium text-foreground`,children:s(`integrations.creating`,{defaultValue:`Creating integration…`})}),!G&&i(`p`,{className:`text-[10px] text-foreground-subtle`,children:s(`integrations.creatingHint`,{defaultValue:`Waiting for the addon to restart and register`})}),G&&e(l,{children:[i(`p`,{className:`text-[10px] text-foreground-subtle max-w-xs`,children:s(`integrations.creatingOverdue`,{defaultValue:`This is taking longer than expected. The integration may already have been created — close this dialog and refresh to check.`})}),i(`button`,{onClick:U,className:`mt-1 rounded-md border border-border bg-surface px-3 py-1.5 text-[11px] font-medium text-foreground hover:bg-surface-hover transition-colors`,children:s(`integrations.closeAndRefresh`,{defaultValue:`Close`})})]})]})]})]})}function Z({integration:t,expanded:n,onToggleExpand:r}){let{t:a}=L();return e(`div`,{className:`flex items-center gap-2.5`,children:[i(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),r(t.addonId)},"aria-label":n?a(`integrations.integrationColumns.collapse`,`Collapse`):a(`integrations.integrationColumns.expand`,`Expand`),"aria-expanded":n,className:`flex h-5 w-5 flex-shrink-0 items-center justify-center rounded text-foreground-subtle transition-colors hover:bg-surface-hover hover:text-foreground`,children:i(n?x:S,{className:`h-3.5 w-3.5`})}),i(R,{type:t.addonId,size:`sm`}),e(`div`,{className:`flex min-w-0 flex-col`,children:[i(`span`,{className:`truncate text-xs font-semibold text-foreground`,children:t.name}),i(`span`,{className:`truncate text-[10px] text-foreground-subtle`,children:t.addonId})]})]})}function ye(e){let{isExpanded:t,onToggleExpand:n}=e;return[{key:`name`,header:I.t(`integrations.integrationColumns.integration`,`Integration`),headerClassName:`w-[55%]`,cell:e=>i(Z,{integration:e,expanded:t(e),onToggleExpand:n})},{key:`devices`,header:I.t(`integrations.integrationColumns.devices`,`Devices`),headerClassName:`w-[15%]`,cellClassName:`text-[11px] text-foreground-subtle`,cell:e=>I.t(`integrations.integrationColumns.deviceCount`,{count:e.deviceCount})},{key:`status`,header:I.t(`integrations.integrationColumns.status`,`Status`),headerClassName:`w-[15%]`,cell:e=>i(M,{status:e.status})}]}s();function be(e){if(!e.enabled)return`disabled`;switch(e.processState){case`running`:return`running`;default:return`stopped`}}var Q=`expand`;function $(){let{t}=L(),a=se(),s=y(),[c]=ce(),[d,p]=ue(),[h,g]=o(!1),ee=r(()=>g(!0),[]),b=r(()=>g(!1),[]),[x,S]=o(!1),C=r(()=>S(!0),[]),T=r(()=>S(!1),[]);N([`integrations`],[`integration.enabled`,`integration.disabled`,`integration.deleted`,`provider.started`,`provider.stopped`,`addon.installed`,`addon.uninstalled`,`addon.started`,`addon.stopped`,`addon.updated`]),N([`deviceManager`],[`device.registered`,`device.unregistered`,`device.online`,`device.offline`,`device.disabled`,`device.enabled`]);let{data:D,isLoading:ie,isError:O,refetch:k}=oe(void 0),{data:j,isLoading:M,isError:F,refetch:I}=ae({projection:`slim`}),R=n(()=>j??[],[j]),B=n(()=>D??[],[D]),V=n(()=>{let e=new Map;for(let t of R)e.set(t.id,{id:t.id,name:t.name??t.stableId??`#${String(t.id)}`});return e},[R]),W=n(()=>E(D),[D]),G=n(()=>{let e=new Map;for(let t of re(R)){let n=W(t);if(n.kind!==`resolved`)continue;let r=n.integration.id;e.set(r,(e.get(r)??0)+1)}return e},[R,W]),K=n(()=>B.map(e=>({id:e.id,addonId:e.addonId,name:e.name,enabled:e.enabled,status:be(e),deviceCount:G.get(e.id)??0})),[B,G]),q=c.get(Q),J=r(e=>{let t=new URLSearchParams(window.location.search);t.get(Q)===e?t.delete(Q):t.set(Q,e);let n=t.toString(),r=`${window.location.pathname}${n?`?${n}`:``}${window.location.hash}`;window.history.replaceState(window.history.state,``,r),window.dispatchEvent(new PopStateEvent(`popstate`))},[]),Y=r(e=>a(`/integrations/${e.id}`),[a]),de=r(e=>V.get(e)??null,[V]),fe=r(e=>a(`/devices/${String(e)}`),[a]),pe=r(e=>i(A,{context:`integration-detail`,devices:R,trpc:s.trpcClient,integrationOf:W,forceIntegrationId:e.id,urlScope:`nested`,lsKey:`integrations:nested:${e.addonId}`,resolveIntegrationIcon:z,resolveParent:de,onNavigate:fe}),[R,s.trpcClient,W,de,fe]),X=r(e=>q===e.addonId,[q]),me=n(()=>ye({isExpanded:X,onToggleExpand:J}),[X,J]),he=r(e=>`${e.name} ${e.addonId}`,[]),ge=r(e=>e.addonId,[]),_e=r(()=>{k(),I()},[k,I]),Z=O===!0||F===!0,$=!Z&&(ie||M||D===void 0||j===void 0),xe=B.length>0,Se=[{id:`table`,label:t(`integrations.viewTable`,`Table`),icon:te},{id:`grid`,label:t(`integrations.viewGrid`,`Grid`),icon:_}];return e(le,{icon:f,title:t(`nav.integrations`,`Integrations`),actions:e(l,{children:[i(w,{ariaLabel:t(`integrations.viewLabel`,`Layout`),value:d,onChange:p,options:Se,testId:`integrations-view`}),i(`button`,{onClick:_e,disabled:$,className:`flex items-center gap-1 rounded-lg border border-border bg-surface px-2.5 py-1.5 text-xs font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50`,title:t(`common.refresh`,`Refresh`),children:i(m,{className:P(`h-3.5 w-3.5`,$&&`animate-spin`)})}),e(`button`,{onClick:C,className:`flex items-center gap-1.5 rounded-lg border border-border bg-surface px-2.5 py-1.5 text-xs font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,title:t(`integrations.scanTheLocalNetworkFor`,`Scan the local network for devices`),children:[i(u,{className:`h-3.5 w-3.5`}),t(`integrations.scanNetwork`,`Scan network`)]}),e(`button`,{onClick:ee,className:`flex items-center gap-1.5 rounded-lg bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground shadow-sm`,children:[i(v,{className:`h-3.5 w-3.5`}),t(`integrations.newIntegration`,`New Integration`)]})]}),children:[Z&&i(ne,{message:t(`integrations.loadFailed`,`Integrations could not be loaded.`),onRetry:_e}),$&&i(`div`,{className:`space-y-2`,"data-testid":`integrations-pending`,children:[1,2,3].map(e=>i(`div`,{className:`h-12 rounded-lg border border-border bg-surface animate-pulse`},e))}),!Z&&!$&&!xe&&e(`div`,{className:`flex flex-col items-center py-20 text-foreground-subtle`,children:[i(`p`,{className:`text-sm`,children:t(`integrations.noIntegrationsConfigured`,`No integrations configured.`)}),i(`p`,{className:`text-xs mt-1`,children:t(`integrations.clickNewIntegrationToConnect`,`Click "New Integration" to connect cameras and devices.`)})]}),!Z&&!$&&xe&&d===`table`&&i(A,{mode:`generic`,items:K,getKey:ge,getSearchText:he,columns:me,onRowClick:Y,isExpanded:X,renderExpanded:pe,searchPlaceholder:t(`integrations.search`,{defaultValue:`Search integrations…`}),emptyLabel:t(`integrations.empty`,{defaultValue:`No integrations found.`})}),!Z&&!$&&xe&&d===`grid`&&i(U,{rows:K,isExpanded:X,onToggleExpand:J,onOpen:Y,renderExpanded:pe,searchPlaceholder:t(`integrations.search`,{defaultValue:`Search integrations…`}),emptyLabel:t(`integrations.empty`,{defaultValue:`No integrations found.`})}),i(ve,{open:h,onClose:b}),i(H,{open:x,onClose:T})]})}export{$ as IntegrationsPage};