@camstack/addon-admin-ui 1.2.673 → 1.2.674

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 (100) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/assets/Addons-WMvBsvOk.js +5 -0
  3. package/dist/assets/{AdminPage-bLxyruUe.js → AdminPage-DehTB98c.js} +1 -1
  4. package/dist/assets/{AdminSectionedPage-vnoSnjIu.js → AdminSectionedPage-CYs3O4rx.js} +1 -1
  5. package/dist/assets/AiProfiles-zANvp6C7.js +3 -0
  6. package/dist/assets/{BootstrapSettingsForm-CpvlarTT.js → BootstrapSettingsForm-iu9cN56V.js} +1 -1
  7. package/dist/assets/{Build-BVHmf4sa.js → Build-CH8Jteos.js} +5 -5
  8. package/dist/assets/{Calendars-WPgNTXpb.js → Calendars-CG458gUz.js} +1 -1
  9. package/dist/assets/{CameraGrids-DNVLT_g-.js → CameraGrids-C9eCm8pP.js} +1 -1
  10. package/dist/assets/Cluster-kvsDgCgK.js +1 -0
  11. package/dist/assets/{CompositionBlockEditor-CfazE3Js.js → CompositionBlockEditor-CAs5rsS4.js} +2 -2
  12. package/dist/assets/{CompositionEditorPage-xZt9xNnb.js → CompositionEditorPage-BtUl4zjW.js} +1 -1
  13. package/dist/assets/{Data-CX-UI9DM.js → Data-C36JAFvC.js} +2 -2
  14. package/dist/assets/DeviceDetail-xBqlnA0-.js +2 -0
  15. package/dist/assets/{Devices-KEps1UGm.js → Devices-C0mp1gTu.js} +1 -1
  16. package/dist/assets/{EmbedDevicePage-CXvRePXD.js → EmbedDevicePage-D62p-Zwh.js} +1 -1
  17. package/dist/assets/{EmbedPlayerPage-DOewSiDm.js → EmbedPlayerPage-xCU6XWiZ.js} +1 -1
  18. package/dist/assets/History-B44RiyKy.js +1 -0
  19. package/dist/assets/{Identity-DEvMFJ8U.js → Identity-DbbKhxh3.js} +1 -1
  20. package/dist/assets/{InstancesTable-Cn1INVUs.js → InstancesTable-C0K85iGC.js} +1 -1
  21. package/dist/assets/IntegrationDetail-nq8eT4Rx.js +1 -0
  22. package/dist/assets/{Integrations-BNPsvsDG.js → Integrations-4XOMicYb.js} +2 -2
  23. package/dist/assets/{Integrations-DZ4d7yCu.js → Integrations-BKdCwZuR.js} +1 -1
  24. package/dist/assets/{Library-DCLUmh7t.js → Library-C5ay31n5.js} +1 -1
  25. package/dist/assets/Locations-D6wRB0nm.js +3 -0
  26. package/dist/assets/Logs-uJBwN087.js +1 -0
  27. package/dist/assets/{MaskShapeCanvas-BXQi3-T2.js → MaskShapeCanvas-CFBpV69I.js} +1 -1
  28. package/dist/assets/{MotionZonesSettings-ucz7NSTu.js → MotionZonesSettings-DiSDXz6Y.js} +1 -1
  29. package/dist/assets/{MyAccess-CBlNgEUN.js → MyAccess-CIlYcBGS.js} +1 -1
  30. package/dist/assets/{Network-0wPLfJ0h.js → Network-Dd0YsxUn.js} +1 -1
  31. package/dist/assets/{NodeAddonsSettingsPanel-Bk2zvhh-.js → NodeAddonsSettingsPanel-Dy-TKm1m.js} +1 -1
  32. package/dist/assets/{Notifications-BFiv-KUA.js → Notifications-VK8H0w3p.js} +1 -1
  33. package/dist/assets/{Pipeline-CWjfmglV.js → Pipeline-CpT4cIkd.js} +1 -1
  34. package/dist/assets/{PrivacyMaskSettings-BpKQjnTN.js → PrivacyMaskSettings-ivXhDvTd.js} +1 -1
  35. package/dist/assets/Recordings-BelCDd0K.js +1 -0
  36. package/dist/assets/{SceneMonitorEditor-B4x-j-jS.js → SceneMonitorEditor-DD9HUOxa.js} +1 -1
  37. package/dist/assets/ServerShell-BJ88JJQy.js +1 -0
  38. package/dist/assets/SessionsList-VpzJYCXO.js +2 -0
  39. package/dist/assets/{Showroom-B1RoJ593.js → Showroom-DprVm7lJ.js} +1 -1
  40. package/dist/assets/{StorageLocationsTable-BU2R2YDl.js → StorageLocationsTable-YyNaWUFC.js} +1 -1
  41. package/dist/assets/{System-9dHx6EzL.js → System-B8OfL298.js} +1 -1
  42. package/dist/assets/Terminal-B9DUjbO_.js +3 -0
  43. package/dist/assets/{Terminal-B_CcltGA.js → TerminalPanel-C5GUokHS.js} +3 -5
  44. package/dist/assets/{TrainingProviders-BAaea0d6.js → TrainingProviders-Dgifcyme.js} +1 -1
  45. package/dist/assets/{Viewer-DrgoA7AH.js → Viewer-CgYVNuka.js} +1 -1
  46. package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-CoNgx8LV.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-BSOO0i6X.js} +1 -1
  47. package/dist/assets/{action-draft-DwvVnv-7.js → action-draft-TjsRaaWY.js} +1 -1
  48. package/dist/assets/{ai-page.helpers-C7D3n8iP.js → ai-page.helpers-B01d73HY.js} +1 -1
  49. package/dist/assets/{assignment-candidates-BSCyf2de.js → assignment-candidates-b1r8iss9.js} +1 -1
  50. package/dist/assets/{authed-media-CfvJyG-Y.js → authed-media-C2ovg6GX.js} +1 -1
  51. package/dist/assets/{board-model-8UGMkm1I.js → board-model-C-1eQ0ae.js} +1 -1
  52. package/dist/assets/{client-CBrsD14Q.js → client-BHqWRcyk.js} +42 -42
  53. package/dist/assets/{command-vocab-DPH9ECZa.js → command-vocab-C7U9oyDW.js} +1 -1
  54. package/dist/assets/{device-detail-K5TWmBwE.js → device-detail-B7BuTwl5.js} +1 -1
  55. package/dist/assets/{device-integration-icon-W3dt9ax1.js → device-integration-icon-D2MLKEPf.js} +1 -1
  56. package/dist/assets/device-picker-model-CVw4WHYD.js +1 -0
  57. package/dist/assets/{dist-Ch4acd_Z.js → dist-DVJk2a2H.js} +7 -7
  58. package/dist/assets/{dist-EQkuFJsn.js → dist-DuuRIDwa.js} +1 -1
  59. package/dist/assets/{format-CX-wK907.js → format-DfOVHXCT.js} +1 -1
  60. package/dist/assets/{hostInit-Di5WwrRQ.js → hostInit-rTXCJjRz.js} +1 -1
  61. package/dist/assets/i18n-1k63HMS1.js +1 -0
  62. package/dist/assets/{icons-2Ody3esI.js → icons-CWZ5ezxN.js} +1 -1
  63. package/dist/assets/index-CWyWRkhx.css +2 -0
  64. package/dist/assets/{index-1bBrNxAK.js → index-DrSk7mpa.js} +3 -3
  65. package/dist/assets/{linked-devices-model-BbPIMVq4.js → linked-devices-model-CSdyOaOL.js} +1 -1
  66. package/dist/assets/{mf-entry-bootstrap-0-80086b95.js → mf-entry-bootstrap-0-c1456dc1.js} +2 -2
  67. package/dist/assets/mount-CVw4WHYD.js +1 -0
  68. package/dist/assets/{notification-rule-status-B61HDyRa.js → notification-rule-status-Nsg84Ad6.js} +1 -1
  69. package/dist/assets/{player-overlays-VrMHBBfa.js → player-overlays-ioSNjktV.js} +1 -1
  70. package/dist/assets/remoteEntry-L_UHhLDG.js +1 -0
  71. package/dist/assets/{src-bJ4Hy4Cl.js → src-BdsfPiRP.js} +15 -15
  72. package/dist/assets/{sso-popup-FSdroU2W.js → sso-popup-n86tgOtV.js} +1 -1
  73. package/dist/assets/{step-inspector-model-15-9NhxK.js → step-inspector-model-DDQdb6QN.js} +1 -1
  74. package/dist/assets/{use-scenes-feed-O_MsB8FF.js → use-scenes-feed-CGfxNDwj.js} +1 -1
  75. package/dist/assets/{use-stationary-objects-JZ23WYEp.js → use-stationary-objects-CAqaioV8.js} +1 -1
  76. package/dist/assets/{useAdminDeviceRemoval-DCRpnpY6.js → useAdminDeviceRemoval-DVcdNDpy.js} +1 -1
  77. package/dist/assets/useEventInvalidation-CVw4WHYD.js +1 -0
  78. package/dist/assets/{useNodeUrlSelection-DAnBV8Yi.js → useNodeUrlSelection-Bqv1g0bX.js} +1 -1
  79. package/dist/assets/{useTemplateSave-C4_bd2To.js → useTemplateSave-Cp-jK8Nf.js} +1 -1
  80. package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-DguMkCB-.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-CS-o-uvR.js} +2 -2
  81. package/dist/index.html +9 -9
  82. package/dist/server/addon.js +26 -4
  83. package/package.json +2 -2
  84. package/dist/assets/Addons-Dl4Ed0w_.js +0 -5
  85. package/dist/assets/AiProfiles-CUcDrrtc.js +0 -3
  86. package/dist/assets/Cluster-DXnmd3TJ.js +0 -1
  87. package/dist/assets/DeviceDetail-bLQrVZ1A.js +0 -2
  88. package/dist/assets/History-DDdKnfJ2.js +0 -1
  89. package/dist/assets/IntegrationDetail-CeDutRAR.js +0 -1
  90. package/dist/assets/Locations-ejPYyz4D.js +0 -3
  91. package/dist/assets/Logs-BS4JYpzd.js +0 -1
  92. package/dist/assets/Recordings-B_JPtd9_.js +0 -1
  93. package/dist/assets/SessionsList-DMqcS-nT.js +0 -2
  94. package/dist/assets/device-picker-model-BG-DzgSt.js +0 -1
  95. package/dist/assets/i18n-BFxrpjSx.js +0 -1
  96. package/dist/assets/index-CcsmeMTw.css +0 -2
  97. package/dist/assets/mount-BG-DzgSt.js +0 -1
  98. package/dist/assets/remoteEntry-BusdFyUc.js +0 -1
  99. package/dist/assets/useEventInvalidation-BG-DzgSt.js +0 -1
  100. /package/dist/assets/{Terminal-kHJ-D0s7.css → TerminalPanel-kHJ-D0s7.css} +0 -0
@@ -1 +0,0 @@
1
- import{C as e,K as t,S as n,Y as r,et as i,i as a,x as o}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{Fr as s,Hn as c,Jn as l,Jr as u,Za as d,ct as f,en as p,ta as m,ut as h,vt as g,wt as _}from"./player-overlays-VrMHBBfa.js";import{ii as v,js as y}from"./client-CBrsD14Q.js";import{Ai as b,Ar as x,Ca as S,Cn as C,Cp as w,Da as T,Fi as E,Gi as D,Ni as O,Ns as k,Or as A,Pi as ee,Sn as j,Sp as M,Ud as te,Ui as ne,Wf as N,_n as re,an as ie,ba as ae,bn as oe,br as se,cn as ce,dn as P,en as le,fa as F,fn as ue,gn as de,ha as I,in as fe,ji as pe,jr as L,ki as me,ma as R,mn as he,nn as ge,os as _e,pn as ve,sn as ye,ss as be,tn as xe,un as z,vn as Se,wn as Ce,xn as we,xr as Te,yn as Ee}from"./src-bJ4Hy4Cl.js";import{t as B}from"./useTranslation-BJr-n0es.js";import{hi as De}from"./index-1bBrNxAK.js";import{t as Oe}from"./AdminPage-bLxyruUe.js";i();function V(e,t){return e.scope===``?e.displayName:`${e.displayName} · ${t?.(e)??e.scope}`}function ke(e,t,n){let r=[];for(let{device:t,series:i}of e)for(let e of i){let i={subject:{kind:`device`,deviceId:t.id},key:e.key,scope:e.scope};r.push({id:P(i),ref:i,info:e,subjectName:t.name,location:t.location??``,nodeId:``,metric:V(e,n)})}for(let{node:e,series:i}of t)for(let t of i){let i={subject:{kind:`node`,nodeId:e.id},key:t.key,scope:t.scope};r.push({id:P(i),ref:i,info:t,subjectName:e.name,location:``,nodeId:e.id,metric:V(t,n)})}return r}function Ae(e){return[e.subjectName,e.location,e.metric,e.info.key,e.info.unit??``,e.nodeId].join(` `)}function H(e,t,n){if(e.ref.subject.kind!==`device`||t===null)return e.subjectName;let r=t.byId.get(e.ref.subject.deviceId);return r===void 0?e.subjectName:ae(r,`compact`,t,n)}var je=[`energy`,`temperatures`,`nodes`,`storage`],Me=new Set([`cap:temperature-sensor.temperature`,`cap:climate-control.currentTemp`]),U=[`addon:metrics-native/node-cpu-percent`,`addon:metrics-native/node-memory-percent`],Ne=`addon:storage-orchestrator/location-used-percent`;function Pe(e,t){let n=(e,n)=>{let r=t.filter(e);return z((n?[...r].sort(n):r).map(e=>e.ref))};switch(e){case`energy`:return n(e=>e.ref.subject.kind===`device`&&e.info.key===`derived:energy.kwh`);case`temperatures`:return n(e=>e.ref.subject.kind===`device`&&Me.has(e.info.key)&&e.info.scope===``,(e,t)=>e.location.localeCompare(t.location)||e.subjectName.localeCompare(t.subjectName));case`nodes`:return n(e=>e.ref.subject.kind===`node`&&U.includes(e.info.key)&&e.info.scope===``,(e,t)=>U.indexOf(e.info.key)-U.indexOf(t.info.key)||e.subjectName.localeCompare(t.subjectName));case`storage`:return n(e=>e.ref.subject.kind===`node`&&e.info.key===Ne)}}function Fe(e,t){let n=new Map(t.map(e=>[e.id,e])),r=[],i=[],a=[],o=[];for(let t of z(e)){let e=n.get(P(t));if(e===void 0){o.push(t);continue}e.info.key===`derived:energy.kwh`?a.push(e):e.info.kind===`boolean`||e.info.kind===`enum`?i.push(e):r.push(e)}return{lines:r,states:i,energy:a,missing:o}}function W(e){return e.subject.kind===`device`?{deviceId:e.subject.deviceId,key:e.key,scope:e.scope}:{forNodeId:e.subject.nodeId,key:e.key,scope:e.scope}}var G=`history-page`;function Ie({part:r,window:i}){let{t:a}=B(),o=d(),s=T(),c=S(),l=e=>`${H(e,s,c)} · ${e.metric}`,u=t(()=>[...r.lines,...r.states,...r.energy],[r]),f=fe(t(()=>u.map(e=>W(e.ref)),[u]),i,!1),p=e=>f.status===`ok`?f.data.current.get(ge(W(e.ref))):void 0,h=e=>{let t=p(e);return t?.ok?t.result:void 0};if(u.length===0)return n(D,{icon:m,title:a(`history.page.emptyTitle`,`Pick series to compare`),description:a(`history.page.emptyHint`,`Choose up to 24 series on the left, or start from a panel above.`)});if(f.status===`error`)return n(F,{title:a(`history.page.readFailed`,`History could not be read`),message:f.error});let g=f.status===`pending`,_=u.map(e=>({c:e,e:p(e)})).filter(e=>e.e?.ok===!1),v=r.lines.map((e,t)=>{let n=h(e),r=re(e.info,n,i.from);return{id:e.id,label:l(e),unit:e.info.unit,colorIndex:t,points:r.points,gapMs:r.gapMs,interpolation:r.held&&n?.resolution===`raw`?`step`:`linear`}}),y=r.states.map((e,t)=>{let n=Se(e.info,h(e),i.from,i.to),r=he(e.info.key,o);return{id:e.id,label:l(e),kind:e.info.kind===`boolean`?`boolean`:`enum`,colorIndex:e.info.kind===`boolean`?t:0,states:n.states,segments:n.segments,totals:n.totals,stateLabel:e.info.kind===`boolean`?e=>e===`true`?r.on:r.off:void 0}}),b=r.energy.map(e=>({c:e,...de(h(e))})),x=b[0]?.bucketMs??36e5,w=[...new Set(b.flatMap(e=>e.buckets.map(e=>e.t)))].sort((e,t)=>e-t).map(e=>({t:e,values:b.map(t=>t.buckets.find(t=>t.t===e)?.values[0]??null)}));return e(`div`,{className:`space-y-5 min-w-0`,children:[_.length>0&&n(F,{title:a(`history.page.someFailed`,`Some series could not be read`),message:_.map(e=>`${l(e.c)}: ${e.e.error}`).join(` · `)}),v.length>0&&n(C,{title:a(`history.page.lines`,`Measurements`),series:v,range:i,height:260,syncKey:G,pending:g}),b.length>0&&n(ne,{title:a(`history.page.energy`,`Energy`),layers:b.map((e,t)=>({id:e.c.id,label:H(e.c,s,c),colorIndex:t})),buckets:w,bucketMs:x,range:i,unit:`kWh`,showTotal:!0,height:160,syncKey:G,pending:g}),y.length>0&&n(Ce,{title:y.length===1?y[0]?.label??``:a(`history.page.states`,`States`),rows:y,range:i,syncKey:G,pending:g})]})}function Le(e,t){let n=[];for(let r=0;r<e.length;r+=t)n.push(e.slice(r,r+t));return n}async function Re(e,t){let n=[];for(let r of Le(e,50))try{let{results:e}=await t(r),i=new Map(e.map(e=>[e.seriesId,e]));for(let e of r)n.push(i.get(e)??{seriesId:e,ok:!1,reason:`not-found`})}catch(e){let t=e instanceof Error?e.message:String(e);for(let e of r)n.push({seriesId:e,ok:!1,reason:`request-failed`,message:t})}return n}function K(e){return e.raw+e[`5m`]+e[`1h`]+e[`1d`]}function ze(e){return e.reduce((e,t)=>t.ok?{...e,deleted:e.deleted+1,points:e.points+K(t.deleted)}:{...e,refused:e.refused+1},{deleted:0,refused:0,points:0})}function Be(e,t){let n=new Map(e.map(e=>[e.seriesId,e]));return t.flatMap(e=>{let t=n.get(e.seriesId);return t===void 0?[]:[{series:t,outcome:e}]})}var q=e=>new Date(e).toLocaleDateString(void 0,{dateStyle:`short`});function J(e,t,n){let r=t.get(e.deviceId);return r===void 0?e.reason===`device-gone`?n(`history.orphans.deviceRemoved`,`#{{id}} (removed)`,{id:e.deviceId}):n(`history.orphans.deviceId`,`#{{id}}`,{id:e.deviceId}):r}function Y(e){let t=e.displayName??e.key;return e.scope===``?t:`${t} · ${e.scope}`}function X(t,r,i){return{key:`series`,header:i(`history.orphans.colSeries`,`Series`),render:a=>{let o=t(a);return e(`div`,{className:`min-w-0 max-w-[16rem]`,children:[n(`div`,{className:`truncate text-foreground`,title:o.key,children:Y(o)}),n(`div`,{className:`truncate text-[10px] text-foreground-subtle`,children:J(o,r,i)})]})},sortValue:e=>`${J(t(e),r,i)} ${Y(t(e))}`}}var Ve=[`raw`,`5m`,`1h`,`1d`];function He(e,t){return e===`raw`?t(`history.orphans.colRaw`,`Raw points`):e===`5m`?t(`history.orphans.col5m`,`5 min`):e===`1h`?t(`history.orphans.col1h`,`1 h`):t(`history.orphans.col1d`,`1 day`)}function Ue(t,r){return[X(e=>e,t,r),{key:`reason`,header:r(`history.orphans.colReason`,`Reason`),render:t=>e(`div`,{className:`flex flex-col items-start gap-0.5`,children:[n(R,{variant:t.reason===`device-gone`?`warning`:`neutral`,className:`text-[10px]`,children:t.reason===`device-gone`?r(`history.orphans.deviceGone`,`Device removed`):r(`history.orphans.undeclared`,`No longer declared`)}),t.missingSince!==null&&n(`span`,{className:`text-[10px] text-foreground-subtle`,children:r(`history.orphans.since`,`since {{date}}`,{date:q(t.missingSince)})})]}),sortValue:e=>e.reason},{key:`span`,header:r(`history.orphans.colSpan`,`Recorded`),render:t=>e(`span`,{className:`tabular-nums text-foreground-muted`,children:[q(t.firstTs),` → `,q(t.lastTs)]}),sortValue:e=>e.lastTs},...Ve.map(e=>({key:`rows-${e}`,header:He(e,r),align:`right`,render:t=>n(`span`,{className:`tabular-nums text-foreground-muted`,children:t.rows[e].toLocaleString()}),sortValue:t=>t.rows[e]}))]}function We(e,t){if(e.ok)return n(R,{variant:`success`,className:`text-[10px]`,children:t(`history.orphans.deleted`,{count:K(e.deleted),points:K(e.deleted).toLocaleString(),defaultValue_one:`Deleted · {{points}} point`,defaultValue_other:`Deleted · {{points}} points`})});let r=e.reason===`request-failed`?t(`history.orphans.requestFailed`,`Not sent: {{message}}`,{message:e.message}):e.reason===`not-orphan`?t(`history.orphans.refusedNotOrphan`,`Kept: no longer orphan`):e.reason===`not-found`?t(`history.orphans.refusedNotFound`,`Already gone`):t(`history.orphans.refusedFailed`,`The hub could not delete it`);return n(R,{variant:e.reason===`not-found`?`neutral`:`warning`,className:`text-[10px]`,children:r})}function Ge(e,t){return[X(e=>e.series,e,t),{key:`result`,header:t(`history.orphans.colResult`,`Result`),render:e=>We(e.outcome,t),sortValue:e=>+!e.outcome.ok}]}i();function Ke({open:i,onClose:a,list:o,deviceNames:c,onDelete:u,onRefresh:d,refreshing:m}){let{t:h}=B(),g=f(),[_,v]=r(new Set),[y,S]=r(!1),[C,w]=r([]),T=t(()=>Ue(c,h),[c,h]),D=t(()=>Ge(c,h),[c,h]),k=t(()=>new Set(o.series.map(e=>String(e.seriesId))),[o.series]),A=[..._].filter(e=>k.has(e)).map(Number),j=ze(C.map(e=>e.outcome)),M=async()=>{if(await g({title:h(`history.orphans.confirmTitle`,{count:A.length,defaultValue_one:`Delete {{count}} series`,defaultValue_other:`Delete {{count}} series`}),message:h(`history.orphans.confirmMessage`,`Every recorded point of these series is removed from the hub. This cannot be undone.`),confirmLabel:h(`history.orphans.confirmLabel`,`Delete`),variant:`danger`})){S(!0);try{let e=await Re(A,u);w(Be(o.series,e)),v(new Set)}finally{S(!1),d()}}};return n(me,{open:i,onOpenChange:e=>!e&&a(),children:e(pe,{width:`xl`,placement:`sheet-on-mobile`,scroll:`body`,"data-testid":`orphan-series-dialog`,children:[n(ee,{children:n(E,{children:h(`history.orphans.title`,`Series no longer linked to a device`)})}),e(b,{className:`space-y-3`,children:[n(`p`,{className:`text-xs text-foreground-muted`,children:h(`history.orphans.intro`,`Nothing records into these series any more: their device was removed, or no capability declares them now. Select the ones to delete.`)}),o.truncated&&e(`div`,{className:`flex flex-wrap items-center gap-2`,"data-testid":`orphan-truncated`,children:[n(`p`,{className:`text-xs text-warning`,children:h(`history.orphans.truncated`,`More series are unlinked than are listed here. Delete these, then load the rest.`)}),e(N,{size:`sm`,variant:`outline`,onClick:d,disabled:m,children:[n(l,{className:`h-3 w-3`,"aria-hidden":!0}),h(`history.orphans.loadAgain`,`Load again`)]})]}),C.length>0&&e(`div`,{className:`space-y-2`,"data-testid":`orphan-outcomes`,children:[n(`p`,{className:`text-xs text-foreground`,"aria-live":`polite`,children:h(`history.orphans.summary`,{count:j.deleted,refused:j.refused,points:j.points.toLocaleString(),defaultValue_one:`{{count}} series deleted ({{points}} points), {{refused}} kept.`,defaultValue_other:`{{count}} series deleted ({{points}} points), {{refused}} kept.`})}),n(x,{columns:D,rows:C,rowKey:e=>String(e.series.seriesId),minWidthPx:420,maxBodyHeight:`max-h-[60vh]`,emptyMessage:``})]}),n(x,{columns:T,rows:o.series,rowKey:e=>String(e.seriesId),minWidthPx:760,maxBodyHeight:L,defaultSort:{columnKey:`series`,dir:`asc`},emptyMessage:h(`history.orphans.empty`,`Every series is linked to a device.`),selection:{selected:_,onChange:v,rowLabel:e=>`${Y(e)} — ${J(e,c,h)}`,pageLabel:h(`history.orphans.selectAll`,`Select every listed series`)}})]}),e(O,{children:[n(`span`,{className:`mr-auto text-[11px] tabular-nums text-foreground`,"aria-live":`polite`,children:h(`history.orphans.selected`,{count:A.length,defaultValue_one:`{{count}} selected`,defaultValue_other:`{{count}} selected`})}),n(N,{variant:`ghost`,size:`sm`,onClick:a,children:h(`history.orphans.close`,`Close`)}),e(N,{variant:`danger`,size:`sm`,disabled:A.length===0||y,onClick:()=>void M(),children:[y?n(s,{className:`h-3 w-3 animate-spin`,"aria-hidden":!0}):n(p,{className:`h-3 w-3`,"aria-hidden":!0}),h(`history.orphans.deleteSelected`,`Delete selected`)]})]})]})})}i();var Z=5*6e4;function qe({enabled:i}){let{t:a}=B(),[s,c]=r(!1),l=be({},{enabled:i,staleTime:Z}),u=k({projection:`slim`},{enabled:i}),d=_e(),f=t(()=>new Map((u.data??[]).map(e=>[e.id,e.name])),[u.data]),p=e=>d.mutateAsync({seriesIds:[...e]});if(!i||l.status===`pending`)return null;if(l.status===`error`)return n(F,{variant:`warning`,title:a(`history.orphans.checkFailedTitle`,`Could not check for unlinked series`),message:l.error.message,onRetry:()=>void l.refetch()});let m=l.data;if(m.series.length===0&&!s)return null;let h=m.series.length;return e(o,{children:[h>0&&n(F,{variant:`warning`,message:m.truncated?a(`history.orphans.noticeMore`,{count:h,defaultValue_one:`More than {{count}} series are no longer linked to a device.`,defaultValue_other:`More than {{count}} series are no longer linked to a device.`}):a(`history.orphans.notice`,{count:h,defaultValue_one:`{{count}} series is no longer linked to a device.`,defaultValue_other:`{{count}} series are no longer linked to a device.`}),action:n(N,{size:`sm`,variant:`outline`,onClick:()=>c(!0),children:a(`history.orphans.review`,`Review`)})}),n(Ke,{open:s,onClose:()=>c(!1),list:m,deviceNames:f,onDelete:p,onRefresh:()=>void l.refetch(),refreshing:l.isFetching})]})}i();var Q=`device`,Je=`node`;function Ye({catalog:r,selected:i,onChange:a,loading:o}){let{t:s}=B(),c=T(),l=S(),u=e=>H(e,c,l),d=se(r,{searchText:e=>[Ae(e)],facetGroups:[{id:`subject`,value:e=>e.ref.subject.kind===`device`?Q:Je},{id:`room`,value:e=>e.location},{id:`unit`,value:e=>e.info.unit??``}]}),f=t(()=>[{key:`metric`,header:s(`history.picker.series`,`Series`),render:t=>e(`div`,{className:`min-w-0`,children:[n(`div`,{className:`truncate text-foreground`,children:t.metric}),n(`div`,{className:`truncate text-[10px] text-foreground-subtle`,children:t.location===``?u(t):`${u(t)} · ${t.location}`})]}),sortValue:e=>`${e.subjectName} ${e.metric}`},{key:`unit`,header:s(`history.picker.unit`,`Unit`),render:e=>n(`span`,{className:`text-foreground-muted`,children:e.info.unit??`—`}),sortValue:e=>e.info.unit??``}],[s,c,l]),p=i.size>=24;return e(`div`,{className:`space-y-2 min-w-0`,children:[n(Te,{state:d.state,facets:[],groups:[{...d.groups.find(e=>e.id===`subject`)??{id:`subject`,facets:[],selected:[]},label:s(`history.picker.subject`,`Source`),facetLabel:e=>e===Q?s(`history.picker.devices`,`Devices`):s(`history.picker.nodes`,`Nodes`)},{...d.groups.find(e=>e.id===`room`)??{id:`room`,facets:[],selected:[]},label:s(`history.picker.room`,`Room`),facetLabel:e=>e===``?s(`history.picker.noRoom`,`No room`):e},{...d.groups.find(e=>e.id===`unit`)??{id:`unit`,facets:[],selected:[]},label:s(`history.picker.metricType`,`Unit`),facetLabel:e=>e===``?s(`history.picker.noUnit`,`States & counts`):e}],labels:{searchPlaceholder:s(`history.picker.search`,`Search device, room, metric or node…`),searchLabel:s(`history.picker.searchLabel`,`Search series`),facetsLabel:s(`history.picker.facets`,`Filters`),clearLabel:s(`history.picker.clear`,`Clear`)},onSearch:d.setSearch,onToggleFacet:d.toggleFacet,onToggleGroupFacet:d.toggleGroupFacet,onClear:d.clear}),n(`p`,{className:`text-[10px] text-foreground-subtle`,"aria-live":`polite`,children:s(`history.picker.count`,`{{count}} of {{max}} selected`,{count:i.size,max:24})}),n(x,{columns:f,rows:d.rows,rowKey:e=>e.id,maxBodyHeight:L,pageSize:50,defaultSort:{columnKey:`metric`,dir:`asc`},emptyMessage:o?s(`history.picker.loading`,`Reading the series of every device…`):d.active?s(`history.picker.emptyFiltered`,`No series match these filters.`):s(`history.picker.empty`,`Nothing is recorded yet.`),selection:{selected:i,onChange:e=>{let t=[...e].filter(e=>i.has(e)),n=[...e].filter(e=>!i.has(e));a(new Set([...t,...n].slice(0,24)))},isSelectable:e=>i.has(e.id)||!p,rowLabel:e=>`${u(e)} · ${e.metric}`,pageLabel:s(`history.picker.selectPage`,`Select every series on this page`)}})]})}i();var Xe=new Set([y.Container]),$=5*6e4;function Ze(){let{t:r}=B(),i=M(`device-history`),[a,o]=De(),s=t(()=>z(a.getAll(`s`).flatMap(e=>{let t=ye(e);return t===null?[]:[t]})),[a]),l=a.get(`window`),d=we(l)?l:`7d`,p=Ee(a.get(`range`)),g=(e,t,n)=>{let r=new URLSearchParams;for(let t of z(e))r.append(`s`,ce(t));t!==`7d`&&r.set(`window`,t);let i=n===void 0?a.get(`range`):n;t===`custom`&&i&&r.set(`range`,i),o(r,{replace:!0})},v=Qe(i===`present`),y=j(d,Date.now(),p),b=j(d,xe(Date.now(),y.to-y.from),p),x=t(()=>Fe(s,v.candidates),[s,v.candidates]),S=t(()=>new Set(s.map(P)),[s]),C=le(),w=h(),T=f(),E=async()=>{let e=await w({title:r(`history.page.saveTitle`,`Save as panel`),label:r(`history.page.saveName`,`Panel name`),confirmLabel:r(`history.page.save`,`Save`)});e===null||e.trim()===``||await C.update(t=>ue(t,{id:`panel-${Date.now().toString(36)}`,name:e.trim().slice(0,80),window:d,selection:[...s]}))},O=async(e,t)=>{await T({title:r(`history.page.deleteTitle`,`Delete panel`),message:r(`history.page.deleteMessage`,`The panel "{{name}}" is removed from your account.`,{name:t}),confirmLabel:r(`history.page.delete`,`Delete`),variant:`danger`})&&await C.update(t=>ve(t,e))},k=e=>e===`energy`?r(`history.panels.energy`,`Total energy`):e===`temperatures`?r(`history.panels.temperatures`,`Temperatures by room`):e===`nodes`?r(`history.panels.nodes`,`Cluster nodes`):r(`history.panels.storage`,`Storage locations`);return n(Oe,{icon:m,title:r(`history.page.title`,`History`),subtitle:r(`history.page.subtitle`,`What devices, nodes and storage recorded over time, side by side.`),actions:i===`present`?e(N,{size:`sm`,variant:`outline`,onClick:()=>void E(),disabled:s.length===0||!C.writable,children:[n(c,{className:`h-3.5 w-3.5`,"aria-hidden":`true`}),r(`history.page.saveTitle`,`Save as panel`)]}):void 0,children:i===`pending`?n(I,{className:`h-64 w-full`}):i===`unknown`?n(F,{title:r(`history.page.presenceUnknownTitle`,`Could not reach the hub`),message:r(`history.page.presenceUnknown`,`The hub did not say whether device history is installed. Try again in a moment.`)}):i===`absent`?n(D,{icon:u,title:r(`history.page.absentTitle`,`Device history is not running on this hub`),description:r(`history.page.absent`,`Nothing is recorded until the device-history system addon is enabled.`)}):e(`div`,{className:`space-y-3 sm:space-y-4`,children:[n(qe,{enabled:i===`present`}),e(`div`,{className:`flex flex-wrap items-center gap-2`,role:`group`,"aria-label":r(`history.page.panels`,`Panels`),children:[je.map(e=>n(N,{size:`sm`,variant:`outline`,disabled:v.status!==`ok`,onClick:()=>g(Pe(e,v.candidates),d),children:k(e)},e)),C.value.panels.map(t=>e(`span`,{className:`inline-flex items-center`,children:[n(N,{size:`sm`,variant:`secondary`,onClick:()=>g(t.selection,t.window,null),children:t.name}),n(N,{size:`sm`,variant:`ghost`,"aria-label":r(`history.page.deleteNamed`,`Delete panel {{name}}`,{name:t.name}),onClick:()=>void O(t.id,t.name),disabled:!C.writable,children:n(_,{className:`h-3.5 w-3.5`,"aria-hidden":`true`})})]},t.id))]}),e(`div`,{className:`grid grid-cols-1 gap-3 sm:gap-4 xl:grid-cols-5`,children:[n(`div`,{className:`min-w-0 xl:col-span-2`,children:n(A,{headingId:`history-picker`,title:r(`history.picker.title`,`Series`),children:n(`div`,{className:`p-2 sm:p-3`,children:v.status===`error`?n(F,{message:v.error}):n(Ye,{catalog:v.candidates,loading:v.status===`pending`,selected:S,onChange:e=>{let t=s.filter(t=>e.has(P(t))),n=v.candidates.filter(t=>e.has(t.id)&&!S.has(t.id)).map(e=>e.ref);g([...t,...n],d)}})})})}),n(`div`,{className:`min-w-0 xl:col-span-3`,children:n(A,{headingId:`history-overlay`,title:r(`history.page.overlay`,`Overlay`),actions:s.length>0?n(N,{size:`sm`,variant:`ghost`,onClick:()=>g([],d),children:r(`history.page.clear`,`Clear`)}):void 0,children:e(`div`,{className:`p-2 sm:p-3 space-y-3 min-w-0`,children:[n(ie,{value:d,onChange:e=>g(s,e),custom:p,onCustomChange:e=>g(s,`custom`,oe(e))}),v.status===`pending`&&s.length>0?n(I,{className:`h-64 w-full`}):n(Ie,{part:x,window:b}),x.missing.length>0&&v.status===`ok`&&n(`p`,{className:`text-[11px] text-foreground-subtle`,children:r(`history.page.missing`,{count:x.missing.length,defaultValue_one:`{{count}} selected series is no longer recorded.`,defaultValue_other:`{{count}} selected series are no longer recorded.`})})]})})})]})]})})}function Qe(e){let{t:n}=B(),r=n(`history.picker.wholeFrame`,`Whole frame`),i=g().trpcClient,o=k({projection:`slim`},{enabled:e}),{nodes:s}=w(),c=t(()=>(o.data??[]).filter(e=>!Xe.has(String(e.type))),[o.data]),l=a({queries:c.map(t=>({queryKey:[`device-history`,`listSeries`,t.id],queryFn:()=>i.deviceHistory.listSeries.query({deviceId:t.id}),enabled:e,staleTime:$}))}),u=a({queries:s.map(t=>({queryKey:[`device-history`,`listNodeSeries`,t.id],queryFn:()=>i.deviceHistory.listNodeSeries.query({forNodeId:t.id}),enabled:e,staleTime:$}))}),d=te({},{enabled:e,staleTime:$}),f=t(()=>new Map((d?.data??[]).map(e=>[e.id,e.displayName])),[d?.data]),p=l.map(e=>e.data),m=u.map(e=>e.data),h=t(()=>ke(c.flatMap((e,t)=>{let n=p[t];return n===void 0?[]:[{device:{id:e.id,name:e.name,location:e.location??null},series:n}]}),s.flatMap((e,t)=>{let n=m[t];return n===void 0?[]:[{node:{id:e.id,name:e.name},series:n}]}),e=>{if(e.key!==`addon:pipeline-analytics/occupancy`)return f.get(e.scope)??e.scope;let{zoneId:t,className:n}=v(e.scope),i=t===``?r:t;return n===void 0?i:`${i} · ${n}`}),[c,s,f,[...l,...u].map(e=>e.dataUpdatedAt).join(`,`),r]);return o.status===`error`?{status:`error`,error:o.error.message,candidates:[]}:{status:o.status===`pending`||l.some(e=>e.isPending)||u.some(e=>e.isPending)?`pending`:`ok`,error:``,candidates:h}}export{Ze as HistoryPage};
@@ -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,a as s,et as c,o as l,x as u}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{Bn as d,Fa as f,Fn as p,Fr as m,Jn as h,Kn as g,Li as _,Ot as v,Qi as y,Ua as b,Ui as x,Xt as S,Za as C,Zn as w,ea as T,en as E,mi as D,pi as O,rr as ee,vt as k,yi as A}from"./player-overlays-VrMHBBfa.js";import{js as j}from"./client-CBrsD14Q.js";import{t as M}from"./chevron-down-CBb-F8DT.js";import{t as N}from"./search-x-C5ra3Aft.js";import{Ai as P,At as F,Bc as te,Cr as I,Cs as L,Fc as R,Fi as z,Fo as B,Hc as V,Io as H,Is as U,Jr as W,Kr as G,Mc as ne,Ni as K,Nr as re,Ns as ie,Os as q,Pi as ae,Qf as J,Rc as Y,Ss as oe,Ts as se,Us as X,Vc as ce,Wf as Z,Ws as Q,Yr as le,_p as ue,bp as de,cc as fe,ds as pe,ei as me,fa as he,fs as ge,gs as _e,i as ve,ji as ye,ki as be,lr as xe,ls as Se,ms as Ce,no as we,oa as Te,ps as Ee,qr as De,r as Oe,ri as ke,us as Ae,vs as je,vt as Me,xt as Ne,ys as Pe,yt as Fe,zc as Ie}from"./src-bJ4Hy4Cl.js";import{t as $}from"./useTranslation-BJr-n0es.js";import{J as Le,Mt as Re,X as ze,Y as Be,bt as Ve,ct as He,dt as Ue,ft as We,hi as Ge,li as Ke,lt as qe,mi as Je,nt as Ye,pi as Xe,ut as Ze}from"./index-1bBrNxAK.js";import{t as Qe}from"./useAdminDeviceRemoval-DCRpnpY6.js";import{t as $e}from"./device-integration-icon-W3dt9ax1.js";c();function et(e){let t=[];for(let n of e)n.type===`probe`&&t.push(n.key),n.type===`group`&&`fields`in n&&t.push(...et(n.fields));return t}function tt(e,t,i){let[a,s]=o(`idle`),[c,l]=o({}),u=n(()=>{let t=[];for(let n of e.sections)t.push(...et(n.fields));return t},[e]),d=u.length>0&&i!==void 0,f=r(e=>{l(t=>{if(!t[e])return t;let n={...t};return delete n[e],n})},[]);return{testAllStatus:a,hasProbeFields:d,probeResults:c,handleTestAll:r(async()=>{if(!i)return;let e=u.filter(e=>{let n=t[e];return n!=null&&String(n).trim()!==``});if(e.length===0)return;s(`testing`);let n={};for(let t of e)n[t]={status:`probing`};l(n);let r=await Promise.allSettled(e.map(async e=>{try{return{key:e,result:await i(e,t[e])}}catch(t){return{key:e,result:{status:`error`,error:t instanceof Error?t.message:String(t)}}}})),a={};for(let e of r)if(e.status===`fulfilled`){let{key:t,result:n}=e.value;a[t]={status:n.status===`ok`?`ok`:`error`,result:n}}l(a),s(`idle`)},[i,u,t]),clearProbeResult:f}}c();function nt(e){let t=[];for(let n of e)`required`in n&&n.required===!0&&`key`in n&&n.key&&t.push(n.key),n.type===`group`&&`fields`in n&&t.push(...nt(n.fields));return t}function rt(e){return e==null?!0:typeof e==`string`?e.trim()===``:!1}function it(e,t={}){for(let n of e){if(n.type===`group`&&`fields`in n){it(n.fields,t);continue}`key`in n&&n.key&&`default`in n&&n.default!==void 0&&(t[n.key]=n.default)}return t}function at(){return typeof crypto<`u`&&typeof crypto.randomUUID==`function`?`probe-${crypto.randomUUID()}`:`probe-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function ot(e,t){let n=X({addonId:e,integrationId:t}),r=n.data?.deviceType??null,i=q({addonId:e,integrationId:t,type:r??j.Camera},{enabled:n.isSuccess&&r!==null});return n.isError?`unavailable`:n.isLoading?`loading`:r===null||i.isError?`unavailable`:i.isLoading||!i.isSuccess?`loading`:((i.data??null)?.sections??[]).some(e=>e.fields.length>0)?`available`:`unavailable`}function st({integrationId:t,addonId:s,onClose:c}){let{t:f}=$(),p=l(),[h,g]=o({}),[_,y]=o(!1),[b,x]=o(null),[C,w]=o(at),T=X({addonId:s,integrationId:t},{enabled:!0}),E=T.data?.deviceType??null,D=q({addonId:s,integrationId:t,type:E??j.Camera},{enabled:T.isSuccess&&E!==null}),O=D.data??null;a(()=>{g(O?it(O.sections.flatMap(e=>e.fields)):{}),w(at()),y(!1),x(null)},[!0,t,O]);let ee=n(()=>({...h,_probeRequestId:C}),[h,C]),k=je({onSuccess:()=>{p.invalidateQueries({queryKey:[[`deviceManager`]]})}}),A=fe(),N=r(async(e,t)=>{y(!0);let n=await A.mutateAsync({addonId:s,type:E??j.Camera,key:e,value:t,formValues:ee});return n.status===`ok`&&n.suggestedValues&&g(e=>{let t=!1,r={...e};for(let[i,a]of Object.entries(n.suggestedValues??{}))rt(e[i])&&!rt(a)&&(r[i]=a,t=!0);return t?r:e}),n},[A,s,ee,E]),{testAllStatus:F,hasProbeFields:te,probeResults:I,handleTestAll:L,clearProbeResult:R}=tt(O??{sections:[]},h,N);async function z(e){x(null);try{await k.mutateAsync({addonId:s,type:E??j.Camera,config:h,integrationId:t}),e?g(O?it(O.sections.flatMap(e=>e.fields)):{}):c()}catch(e){x(e instanceof Error?e.message:String(e))}}let B=nt((O?.sections??[]).flatMap(e=>e.fields)).filter(e=>rt(h[e])),V=B.length===0,H=T.isLoading||E!==null&&D.isLoading,U=T.isError||T.isSuccess&&E===null||D.isError||D.isSuccess&&O===null;return e(u,{children:[i(P,{className:`space-y-3`,children:H?i(`div`,{className:`flex items-center justify-center py-8`,children:i(m,{className:`h-5 w-5 animate-spin text-primary`})}):U?e(`div`,{className:`flex items-start gap-3 rounded-lg border border-danger/40 bg-danger/10 px-4 py-3`,children:[i(S,{className:`h-4 w-4 text-danger mt-0.5 shrink-0`}),e(`div`,{className:`space-y-1`,children:[i(`p`,{className:`text-xs font-medium text-danger`,children:f(`integrations.addDeviceDialog.providerUnavailable`,`Provider unavailable`)}),i(`p`,{className:`text-xs text-foreground-subtle`,children:i(Ke,{i18nKey:`integrations.addDeviceDialog.notReady`,values:{addonId:s},components:{mono:i(`span`,{className:`font-mono`})}})})]})]}):i(Re,{schema:O,values:h,onChange:g,onTestField:N,probeResults:I,onClearProbe:R})}),!U&&!H&&e(`div`,{className:`border-t border-border bg-surface/50 shrink-0`,children:[e(Z,{variant:`unstyled`,type:`button`,onClick:()=>y(e=>!e),className:`flex w-full items-center justify-between px-3 py-2 text-[11px] text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,children:[e(`span`,{className:`flex items-center gap-2`,children:[i(d,{className:`h-3.5 w-3.5`}),f(`integrations.addDeviceDialog.testLogs`,`Test logs`),i(`span`,{className:`font-mono text-[9px] opacity-60`,children:C.slice(0,14)})]}),i(M,{className:`h-3.5 w-3.5 transition-transform ${_?`rotate-180`:``}`})]}),_&&i(`div`,{className:`border-t border-border max-h-64 overflow-hidden`,children:i(xe,{addonId:s,requestId:C,limit:50,maxHeight:`max-h-64`,showFilters:!1,showScope:!1,className:`border-0 rounded-none`})})]}),!U&&!H&&(b||B.length>0)&&i(`div`,{className:`border-t border-danger/30 bg-danger/5 px-3 py-2 shrink-0`,children:e(`div`,{className:`flex items-start gap-2`,children:[i(S,{className:`h-3.5 w-3.5 text-danger mt-0.5 shrink-0`}),i(`p`,{className:`text-[11px] text-danger`,children:b||f(`integrations.addDeviceDialog.required`,`Required: {{value1}}`,{value1:B.join(`, `)})})]})}),e(K,{className:`justify-between`,children:[e(`div`,{className:`flex items-center gap-2`,children:[i(Z,{variant:`unstyled`,onClick:c,className:`rounded-lg border border-border px-3 py-1.5 text-xs text-foreground-subtle hover:text-foreground transition-colors`,children:f(`integrations.cancel`)}),!U&&te&&e(Z,{variant:`unstyled`,type:`button`,onClick:L,disabled:F===`testing`,className:`inline-flex items-center gap-1.5 rounded-lg border border-border px-3 py-1.5 text-xs font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50`,children:[F===`testing`?i(m,{className:`h-3.5 w-3.5 animate-spin`}):i(v,{className:`h-3.5 w-3.5`}),f(`integrations.addDeviceDialog.testAll`,`Test All`)]})]}),e(`div`,{className:`flex items-center gap-2`,children:[i(Z,{variant:`unstyled`,onClick:()=>z(!0),disabled:U||!V||k.isPending,className:`rounded-lg border border-border px-3 py-1.5 text-xs text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50`,children:f(`integrations.saveAndNew`)}),i(Z,{variant:`unstyled`,onClick:()=>z(!1),disabled:U||!V||k.isPending,className:`rounded-lg bg-primary px-4 py-1.5 text-xs font-medium text-primary-foreground shadow-sm disabled:opacity-50`,children:k.isPending?f(`integrations.saving`):f(`integrations.save`)})]})]})]})}var ct=1500;function lt({addonId:t,integrationId:n,jobId:r,onFinished:a}){let{t:o}=$(),s=Ae(),c=(Ee({addonId:t,integrationId:n},{refetchInterval:e=>(e.state.data??[]).some(e=>e.state===`running`)?ct:!1}).data??[]).find(e=>e.jobId===r);if(!c)return null;let l=c.state===`running`,u=c.processed,d=c.total>0?Math.round(u/c.total*100):0;!l&&c.finishedAt!==null&&a();let f=[`${u}/${c.total} ${o(`integrations.adoptJobProcessed`,{defaultValue:`processed`})}`];c.adopted>0&&f.push(`${c.adopted} ${o(`integrations.adoptJobAdded`,{defaultValue:`added`})}`),c.alreadyAdopted>0&&f.push(`${c.alreadyAdopted} ${o(`integrations.adoptJobSkipped`,{defaultValue:`already there`})}`),c.failed>0&&f.push(`${c.failed} ${o(`integrations.adoptJobFailed`,{defaultValue:`failed`})}`);let p=f.join(` · `);return e(`div`,{className:`border-t border-border px-5 py-3 shrink-0 space-y-2`,children:[e(`div`,{className:`flex items-center gap-2`,children:[l?i(m,{className:`h-3.5 w-3.5 animate-spin text-primary shrink-0`}):c.failed>0?i(S,{className:`h-3.5 w-3.5 text-destructive shrink-0`}):c.state===`cancelled`?i(_,{className:`h-3.5 w-3.5 text-foreground-subtle shrink-0`}):i(x,{className:`h-3.5 w-3.5 text-primary shrink-0`}),i(`p`,{className:`text-[11px] text-foreground`,children:p}),l&&i(Z,{variant:`unstyled`,onClick:()=>s.mutate({jobId:r}),className:`ml-auto rounded-lg border border-border px-2 py-1 text-[11px] text-foreground-subtle hover:text-foreground transition-colors`,children:o(`integrations.adoptJobCancel`,{defaultValue:`Stop`})})]}),i(`div`,{className:`h-1 w-full rounded-full bg-border overflow-hidden`,children:i(`div`,{className:`h-full bg-primary transition-all`,style:{width:`${d}%`},role:`progressbar`,"aria-valuenow":d,"aria-valuemin":0,"aria-valuemax":100})}),c.results.filter(e=>e.outcome===`failed`).slice(0,5).map(t=>e(`p`,{className:`text-[11px] text-destructive`,children:[t.childNativeId,`: `,t.error]},t.childNativeId))]})}function ut(e){let t=e.map(e=>({...e,stableId:e.childNativeId})),n=new Map(e.map(e=>[e.childNativeId,e])),r=(e,t,i)=>e.flatMap(e=>{let a=n.get(e.candidate.childNativeId);return a===void 0?[]:[{candidate:a,depth:t,...i===void 0?{}:{parentName:i}},...r(e.children,t+1,a.name)]});return r(Be(t),0)}function dt(e){let t=e.metadata?.model,n=e.childNativeId.split(`:`).pop()??``;return[typeof t==`string`?t:``,n].filter(e=>e.length>0).join(` · `)}function ft(e){let t=e.metadata;return[e.name,e.childNativeId,t.model,t.manufacturer,t.integration,t.externalLocation].filter(e=>typeof e==`string`&&e.length>0).join(` `)}c();var pt=`devices`;function mt(e){return{id:pt,label:e(`integrations.adoptDevicesModal.defaultFilter`),isDefault:!0}}var ht=2e4,gt=100;function _t({addonId:s,integrationId:c,onClose:d}){let f=C(),{t:p}=$(),h=l(),[_,v]=o(new Set),[y,x]=o(new Set),[w,E]=o(new Map),[D,O]=o(null),{data:ee}=te(),k=(ee??[]).find(e=>e.addonId===s)?.supportsLocationImport??!1,[A,j]=o(!0),M=pe({addonId:s,integrationId:c}).data?.filters,N=M&&M.length>0?M:[mt(p)],[P,F]=o(N.find(e=>e.isDefault)?.id??(N.some(e=>e.id===pt)?pt:N[0].id)),I=P!==pt,L=Ce(),R=ge({addonId:s,integrationId:c,page:1,pageSize:ht,filter:P}),z=R.refetch,B=L.mutate,V=r(()=>{B({addonId:s,integrationId:c},{onSettled:()=>{z()}})},[B,s,c,z]),H=t(null);a(()=>{let e=`${s}::${c}`;H.current===e||R.isLoading||(H.current=e,(R.data?.candidates.length??0)===0&&V())},[s,c,R.isLoading,R.data,V]);let U=L.isPending,W=L.isError?L.error instanceof Error?L.error.message:String(L.error):null,G=typeof L.data?.lastError==`string`&&L.data.lastError.length>0?L.data.lastError:null,ne=R.data?.candidates??[],re=n(()=>ut(ne),[ne]),ie=n(()=>new Map(re.map(e=>[e.candidate.childNativeId,e.depth])),[re]),q=n(()=>new Map(re.map(e=>[e.candidate.childNativeId,e.parentName])),[re]),ae=R.isError?R.error instanceof Error?R.error.message:String(R.error):null,J=_e(),[Y,oe]=o(null),se=r(e=>{e.alreadyAdopted||v(t=>{let n=new Set(t);return n.has(e.childNativeId)?n.delete(e.childNativeId):n.add(e.childNativeId),n})},[]),X=r(e=>{x(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),ce=r((e,t)=>{E(n=>{let r=new Map(n),i=r.get(e)?.hiddenChildIds??new Set,a=new Set(i);return a.has(t)?a.delete(t):a.add(t),a.size===0?r.delete(e):r.set(e,{hiddenChildIds:a}),r})},[]),Q=r(e=>{let t={};for(let n of e){let e=w.get(n);e&&e.hiddenChildIds.size>0&&(t[n]={hiddenChildIds:[...e.hiddenChildIds]})}return Object.keys(t).length>0?t:void 0},[w]),le=r(async()=>{O(null);let e=[..._];if(e.length!==0)try{let t=Q(e),{jobId:n}=await J.mutateAsync({addonId:s,integrationId:c,filter:P,childNativeIds:e,...t?{perCandidate:t}:{},...k?{importLocations:A}:{}});oe(n),v(new Set),E(new Map)}catch(e){O(e instanceof Error?e.message:String(e))}},[_,Q,J,s,c,P,k,A]),fe=t(null),me=r(()=>{Y===null||fe.current===Y||(fe.current=Y,z(),h.invalidateQueries({queryKey:[[`integrations`]]}),h.invalidateQueries({queryKey:[[`deviceManager`]]}))},[Y,z,h]),he=r(e=>{F(e),v(new Set),x(new Set),E(new Map),O(null)},[]),ve=_.size,ye=Y!==null&&ve===0&&!J.isPending;return e(u,{children:[k&&e(`label`,{className:`flex items-center gap-1.5 cursor-pointer text-[11px] text-foreground-subtle hover:text-foreground transition-colors`,children:[i(b,{checked:A,onChange:e=>j(e.target.checked),className:`accent-primary`}),p(`integrations.importLocations`,{defaultValue:`Import locations from the integration`})]}),e(`div`,{className:`flex-1 min-h-0 flex flex-col gap-2 overflow-hidden`,children:[(W??ae??G)&&ne.length===0&&i(`div`,{className:`rounded-lg border border-danger/30 bg-danger/5 px-4 py-3 shrink-0`,children:e(`div`,{className:`flex items-start gap-2`,children:[i(S,{className:`h-3.5 w-3.5 text-danger mt-0.5 shrink-0`}),e(`div`,{className:`min-w-0`,children:[i(`p`,{className:`text-xs font-medium text-danger`,children:p(`integrations.adoptRefreshFailed`,{defaultValue:`Could not discover devices.`})}),i(`p`,{className:`text-[11px] text-danger/90 mt-0.5`,children:W??ae??G})]})]})}),N.length>1&&i(vt,{filters:N,activeFilter:P,onSelect:he}),i(`div`,{className:`flex-1 min-h-0`,children:i(Me,{mode:`generic`,items:re.map(e=>e.candidate),pageSize:gt,getKey:e=>e.childNativeId,getSearchText:ft,getFilterType:e=>e.type,filterOptions:ue(f),filterLabel:p(`integrations.adoptColType`,{defaultValue:`Type`}),isLoading:R.isLoading||U&&ne.length===0,searchPlaceholder:p(`integrations.adoptSearch`,{defaultValue:`Search candidates…`}),emptyLabel:(W??ae??G)&&ne.length===0?``:p(`integrations.adoptNoCandidates`,{defaultValue:`No candidate devices found.`}),toolbar:e(Z,{variant:`unstyled`,type:`button`,onClick:V,disabled:U,title:p(`integrations.adoptRefreshTitle`,{defaultValue:`Re-scan Home Assistant for devices`}),className:`inline-flex items-center gap-1.5 rounded-lg border border-border bg-surface px-2.5 py-1.5 text-xs text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-60 shrink-0`,children:[i(g,{className:`h-3.5 w-3.5 ${U?`animate-spin`:``}`}),p(`integrations.adoptRefresh`,{defaultValue:`Refresh`})]}),columns:[{key:`name`,header:p(`integrations.adoptColName`,{defaultValue:`Name`}),headerClassName:`w-full sm:w-[55%]`,cellClassName:`max-w-0`,cell:e=>i(yt,{candidate:e,depth:ie.get(e.childNativeId)??0,...q.get(e.childNativeId)===void 0?{}:{containerName:q.get(e.childNativeId)},expandable:!I,expanded:y.has(e.childNativeId),onToggleExpand:()=>X(e.childNativeId),adoptedLabel:p(`integrations.adoptAlready`,{defaultValue:`Adopted`}),typeLabel:de(e.type,f).label})},{key:`type`,header:p(`integrations.adoptColType`,{defaultValue:`Type`}),headerClassName:`w-[30%] hidden sm:table-cell`,cellClassName:`hidden sm:table-cell`,cell:t=>{let n=de(t.type,f),r=n.icon;return e(`span`,{className:`inline-flex items-center gap-1.5 text-[10px] text-foreground-subtle`,children:[i(r,{className:`h-3.5 w-3.5 shrink-0`}),n.label]})}},{key:`select`,header:``,headerClassName:`w-10 sm:w-[15%] text-right`,cellClassName:`text-right`,cell:e=>i(`div`,{className:`flex items-center justify-end`,children:i(Z,{variant:`unstyled`,onClick:()=>se(e),disabled:e.alreadyAdopted,"aria-label":_.has(e.childNativeId)?p(`integrations.adoptDevicesModal.deselect`,`Deselect`):p(`integrations.adoptDevicesModal.select`,`Select`),className:`inline-flex h-5 w-5 items-center justify-center rounded border ${_.has(e.childNativeId)?`border-primary bg-primary`:`border-border`} ${e.alreadyAdopted?`cursor-not-allowed opacity-50`:``}`,children:_.has(e.childNativeId)&&i(T,{className:`h-3 w-3 text-primary-foreground`})})})}],isExpanded:e=>!I&&y.has(e.childNativeId),renderExpanded:I?void 0:e=>i(bt,{candidate:e,hiddenChildIds:w.get(e.childNativeId)?.hiddenChildIds??new Set,onToggleChildHidden:t=>ce(e.childNativeId,t)}),rowClassName:e=>e.alreadyAdopted?`opacity-60`:_.has(e.childNativeId)?`bg-primary/5`:``})})]}),D&&i(`div`,{className:`border-t border-danger/30 bg-danger/5 px-3 py-2 shrink-0`,children:e(`div`,{className:`flex items-start gap-2`,children:[i(S,{className:`h-3.5 w-3.5 text-danger mt-0.5 shrink-0`}),i(`p`,{className:`text-[11px] text-danger`,children:D})]})}),Y!==null&&i(lt,{addonId:s,integrationId:c,jobId:Y,onFinished:me}),e(K,{children:[i(Z,{variant:`outline`,size:`sm`,onClick:d,children:p(`integrations.cancel`,{defaultValue:`Cancel`})}),e(Z,{variant:`primary`,size:`sm`,onClick:ye?d:le,disabled:!ye&&(ve===0||J.isPending),children:[J.isPending&&i(m,{className:`h-3.5 w-3.5 animate-spin`}),ye?p(`integrations.close`,{defaultValue:`Close`}):p(`integrations.addSelected`,{defaultValue:`Add selected`}),!ye&&ve>0?` (${ve})`:``]})]})]})}function vt({filters:e,activeFilter:t,onSelect:n}){let{t:r}=$();return i(`div`,{role:`tablist`,"aria-label":r(`integrations.adoptDevicesModal.discoveryGranularity`,`Discovery granularity`),className:`inline-flex shrink-0 self-start rounded-lg border border-border bg-surface p-0.5`,children:e.map(e=>{let r=e.id===t;return i(Z,{variant:`unstyled`,type:`button`,role:`tab`,"aria-selected":r,onClick:()=>n(e.id),className:`rounded-md px-3 py-1 text-xs font-medium transition-colors ${r?`bg-primary text-primary-foreground shadow-sm`:`text-foreground-subtle hover:text-foreground hover:bg-surface-hover`}`,children:e.label},e.id)})})}function yt({candidate:t,depth:n,containerName:r,expandable:a,expanded:o,onToggleExpand:s,adoptedLabel:c,typeLabel:l}){let{t:u}=$(),d=(t.children??[]).length,f=dt(t);return e(`div`,{className:`flex items-center gap-2.5 min-w-0 ${n>0?`pl-5`:``}`,children:[a&&d>0?e(Z,{variant:`unstyled`,type:`button`,onClick:s,"aria-label":o?u(`integrations.adoptDevicesModal.collapse`,`Collapse`):u(`integrations.adoptDevicesModal.expand`,`Expand`),"aria-expanded":o,className:`flex h-5 flex-shrink-0 items-center justify-center gap-0.5 rounded px-0.5 text-[10px] text-foreground-subtle transition-colors hover:bg-surface-hover hover:text-foreground`,children:[i(o?M:y,{className:`h-3.5 w-3.5`}),d]}):a?i(`span`,{className:`h-5 w-5 flex-shrink-0`,"aria-hidden":`true`}):null,e(`div`,{className:`min-w-0 flex-1`,children:[i(`div`,{className:`truncate text-xs font-medium text-foreground`,"data-testid":`candidate-name`,children:t.name}),f.length>0&&i(`div`,{className:`truncate text-[10px] text-foreground-subtle`,"data-testid":`candidate-subtitle`,children:f}),r!==void 0&&i(`div`,{className:`truncate text-[10px] text-foreground-subtle`,"data-testid":`candidate-container`,children:u(`integrations.adoptDevicesModal.inContainer`,`in {{name}}`,{name:r})}),i(`div`,{className:`truncate text-[10px] text-foreground-subtle sm:hidden`,children:l})]}),t.alreadyAdopted&&i(`span`,{className:`rounded-full bg-success/10 px-2 py-0.5 text-[9px] font-medium text-success shrink-0`,children:c})]})}function bt({candidate:t,hiddenChildIds:n,onToggleChildHidden:r}){let{t:a}=$(),o=t.children??[];return o.length===0?null:i(`div`,{className:`space-y-1 py-1`,children:o.map(t=>{let o=n.has(t.childNativeId),s=t.capabilities??[];return e(`div`,{className:`flex items-center gap-2 rounded px-2 py-1 ${o?`opacity-50`:``}`,children:[i(`span`,{className:`text-[11px] text-foreground truncate flex-1 min-w-0`,children:t.name}),s.length>0&&i(`span`,{className:`text-[9px] text-foreground-subtle truncate`,children:s.join(`, `)}),i(Z,{variant:`unstyled`,onClick:()=>r(t.childNativeId),"aria-label":o?a(`integrations.adoptDevicesModal.showChild`,`Show child`):a(`integrations.adoptDevicesModal.hideChild`,`Hide child`),title:o?a(`integrations.adoptDevicesModal.showAfterAdopt`,`Show after adopt`):a(`integrations.adoptDevicesModal.hideAfterAdopt`,`Hide after adopt`),className:`flex h-5 w-5 items-center justify-center rounded text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors flex-shrink-0`,children:i(o?D:O,{className:`h-3 w-3`})})]},t.childNativeId)})})}function xt(e){let t=e.host;return typeof t==`string`&&t.length>0?t.toLowerCase():null}function St(e){return e===null?[]:[`host:${e}`]}function Ct(e){let t=[],n=new Map,r=(e,r)=>{let i=e.map(e=>n.get(e)).find(e=>e!==void 0),a=i??r();i===void 0&&t.push(a);for(let t of e)a.ids.add(t),n.set(t,a);return a},i=(e,t)=>{e.sources.includes(t)||e.sources.push(t)};for(let t of e.adoption){let e=r([t.childNativeId],()=>({key:t.childNativeId,ids:new Set,name:t.name,address:null,sources:[],hit:null,adoptionId:t.childNativeId,proposalId:null,alreadyAdded:!1,addedName:null,needsParams:[],parentId:t.parentStableId??null}));i(e,`adoption`),e.adoptionId=t.childNativeId,t.alreadyAdopted===!0&&(e.alreadyAdded=!0)}let a=(t,n,a)=>{let o=xt(t.prefilledConfig),s=r([t.stableId,...St(o)],()=>({key:t.stableId,ids:new Set,name:t.suggestedName,address:o,sources:[],hit:null,adoptionId:null,proposalId:null,alreadyAdded:!1,addedName:null,needsParams:[],parentId:null}));i(s,n),(s.hit===null||n===`scan`)&&(s.hit=t),s.name=t.suggestedName,s.address=o??s.address,a!==null&&(s.proposalId=a),s.parentId=t.parentStableId??s.parentId,s.needsParams=t.needsParams??s.needsParams,(t.alreadyOnboarded===!0||t.onboardedDeviceId!==void 0||e.existingStableIds.has(t.stableId))&&(s.alreadyAdded=!0,s.addedName=t.onboardedName??s.addedName)};for(let t of e.scan)a(t,`scan`,null);for(let t of e.proposals)a(t.candidate,`proposal`,t.id);for(let n of t)[...n.ids].some(t=>e.existingStableIds.has(t))&&(n.alreadyAdded=!0);return t.map(e=>{let t=e.parentId===null?void 0:n.get(e.parentId);return{key:e.key,name:e.name,address:e.address,sources:e.sources,hit:e.hit,adoptionId:e.adoptionId,proposalId:e.proposalId,alreadyAdded:e.alreadyAdded,addedName:e.addedName,needsParams:e.needsParams,parentKey:t!==void 0&&t!==e?t.key:null}})}c();var wt=500;function Tt(e){return e instanceof Error?e.message:String(e)}function Et(e,t){let n={};for(let t of e?.sections??[])for(let e of t.fields)`key`in e&&e.key&&`default`in e&&e.default!==void 0&&(n[e.key]=e.default);return{...n,...t}}function Dt({addonId:t,integrationId:a,onClose:s,onSetupIntegration:c,alongsideAdoption:d=!1}){let{t:f}=$(),p=l(),h=Q({addonId:t}).data??null,[g,_]=o({}),v=oe(),y=U({}),b=ge({addonId:t,integrationId:a,page:1,pageSize:wt},{retry:!1}),{data:x}=ie({projection:`slim`}),S=Se(),C=_e(),[T,E]=o(new Set),[D,O]=o(new Set),[ee,k]=o(null),[A,j]=o(null),M=n(()=>{let e=(b.data?.candidates??[]).map(e=>({childNativeId:e.childNativeId,name:e.name,alreadyAdopted:e.alreadyAdopted,parentStableId:e.parentStableId})),n=(y.data?.proposals??[]).filter(e=>e.addonId===t).map(e=>({id:e.id,candidate:e.candidate}));return Ct({adoption:e,scan:v.data?.candidates??[],proposals:n,existingStableIds:new Set((x??[]).map(e=>e.stableId))})},[b.data,y.data,v.data,x,t]),N=e=>e.hit!==null&&(e.needsParams.length>0||e.hit.setupIntegration===!0),F=n(()=>d?M.filter(e=>!e.sources.includes(`adoption`)||N(e)):M,[M,d]),te=d?M.filter(e=>e.sources.includes(`adoption`)&&e.hit!==null&&!F.includes(e)).length:0,I=r(e=>{let t=new Map(F.map(e=>[e.key,e])),n=0,r=e;for(;r?.parentKey!=null&&n<8&&(r=t.get(r.parentKey),r!==void 0);)n+=1;return n},[F]),L=r(()=>{k(null),v.mutate({addonId:t,params:g})},[v,t,g]),R=r(async(e,t)=>{E(t=>new Set(t).add(e)),k(null);try{await t(),O(t=>new Set(t).add(e)),p.invalidateQueries({queryKey:[[`deviceManager`]]}),p.invalidateQueries({queryKey:[[`integrations`]]})}catch(e){k(Tt(e))}finally{E(t=>{let n=new Set(t);return n.delete(e),n})}},[p]),z=r(async(e,n)=>{let r=e.hit;if(r!==null){let i=ze(t,r);if(i!==null){c?.(i),s();return}await R(e.key,async()=>{await S.mutateAsync({addonId:t,integrationId:a,candidate:{...r,prefilledConfig:{...r.prefilledConfig,...n}}}),j(null)});return}if(e.adoptionId!==null){let n=e.adoptionId;await R(e.key,async()=>{await C.mutateAsync({addonId:t,integrationId:a,childNativeIds:[n]})})}},[S,C,t,a,s,c,R]),B=r(e=>{if(e.needsParams.length>0&&e.hit!==null){k(null),j(e);return}z(e)},[z]);if(A!==null&&A.hit!==null)return i(At,{addonId:t,integrationId:a,row:A,found:A.hit.prefilledConfig,busy:T.has(A.key),error:ee,embedded:d,onBack:()=>j(null),onSubmit:e=>void z(A,e)});let V=F.length===0,H=e(u,{children:[i(Le,{}),h&&i(Re,{schema:h,values:g,onChange:_}),e(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[e(`p`,{className:`text-xs text-foreground-subtle`,children:[v.isPending?f(`integrations.addDeviceModal.scanning`,`Scanning the local network…`):F.length>0?f(`integrations.addDeviceModal.found`,{defaultValue_one:`{{count}} device found`,defaultValue_other:`{{count}} devices found`,count:F.length}):``,!v.isPending&&te>0?` · ${f(`integrations.addDeviceModal.alsoAdopted`,{defaultValue_one:`{{count}} also in the adoption list`,defaultValue_other:`{{count}} also in the adoption list`,count:te})}`:``]}),e(Z,{variant:`outline`,size:`sm`,onClick:L,disabled:v.isPending,children:[v.isPending?i(m,{className:`h-3.5 w-3.5 animate-spin`}):i(w,{className:`h-3.5 w-3.5`}),f(`integrations.addDeviceModal.scanNow`,`Scan now`)]})]}),v.isError&&i(Ot,{text:f(`integrations.addDeviceModal.scanFailed`,`The scan failed. Try again.`)}),ee!==null&&i(Ot,{text:ee}),V&&!v.isPending&&i(`p`,{className:`py-6 text-center text-xs text-foreground-subtle`,children:v.data?f(`integrations.addDeviceModal.nothingFound`,`No devices responded to the scan.`):f(`integrations.addDeviceModal.scanHint`,`Scan the network to find devices to add.`)}),i(`div`,{className:d?`max-h-48 space-y-1.5 overflow-y-auto`:`space-y-1.5`,"data-testid":`network-candidates`,children:F.map(e=>i(kt,{row:e,depth:I(e),busy:T.has(e.key),added:D.has(e.key),onPick:B},e.key))})]});return d?i(`div`,{className:`shrink-0 space-y-3 border-b border-border pb-3`,children:H}):e(u,{children:[i(P,{className:`space-y-3`,children:H}),i(K,{children:i(Z,{variant:`outline`,size:`sm`,onClick:s,children:f(`integrations.close`,`Close`)})})]})}function Ot({text:t}){return e(`div`,{className:`flex items-start gap-2 rounded-lg border border-danger/40 bg-danger/10 px-3 py-2`,children:[i(S,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-danger`}),i(`p`,{className:`text-xs text-danger`,children:t})]})}function kt({row:t,depth:n,busy:r,added:a,onPick:o}){let{t:s}=$(),c=t.alreadyAdded||a,l=t.hit!==null&&ze(``,t.hit)!==null,u=t.hit?.selectable!==!1,d=t.needsParams.length>0;return e(`div`,{className:`flex items-center gap-3 rounded-lg border border-border bg-surface px-3 py-2 ${n>0?`ml-4`:``}`,"data-testid":`network-row-${t.key}`,children:[e(`div`,{className:`min-w-0 flex-1`,children:[i(`p`,{className:`truncate text-xs font-medium text-foreground`,children:t.name}),t.address!==null&&i(`p`,{className:`truncate font-mono text-[10px] text-foreground-subtle`,children:t.address}),c&&t.addedName!==null&&i(`p`,{className:`truncate text-[10px] text-foreground-subtle`,children:t.addedName})]}),c?e(`span`,{className:`flex items-center gap-1 text-[11px] text-foreground-subtle`,children:[i(T,{className:`h-3.5 w-3.5`}),t.alreadyAdded?s(`integrations.scanNetworkModal.alreadyAdded`,`Already added`):s(`integrations.scanNetworkModal.added`,`Added`)]}):u?e(Z,{size:`sm`,variant:l||d?`outline`:`primary`,onClick:()=>o(t),disabled:r,children:[r?i(m,{className:`h-3.5 w-3.5 animate-spin`}):l||d?null:i(A,{className:`h-3.5 w-3.5`}),l?s(`integrations.scanNetworkModal.setUp`,`Set up`):d?s(`integrations.addDeviceModal.enterDetails`,`Enter details`):s(`common.add`,`Add`)]}):null]})}function At({addonId:t,integrationId:n,row:r,found:a,busy:s,error:c,onBack:l,onSubmit:d,embedded:p}){let{t:h}=$(),g=X({addonId:t,integrationId:n}),_=g.data?.deviceType??null,v=q({addonId:t,integrationId:n,type:_??j.Camera},{enabled:g.isSuccess&&_!==null}),y=v.data??null,[b,x]=o(null),S=b??Et(y,a),C=g.error??v.error,w=g.isSuccess&&_===null,T=y!==null,E=T?i(Re,{schema:y,values:S,onChange:x}):C?i(Ot,{text:Tt(C)}):w?i(`p`,{className:`text-xs text-foreground-muted`,children:h(`integrations.addDeviceModal.noCreationType`,`This integration cannot create a device from this candidate.`)}):i(m,{className:`mx-auto h-5 w-5 animate-spin text-primary`}),D=e(u,{children:[e(Z,{variant:`ghost`,size:`sm`,onClick:l,children:[i(f,{className:`h-3.5 w-3.5`}),h(`integrations.addDeviceModal.back`,`Back to the list`)]}),i(`p`,{className:`text-xs font-medium text-foreground`,children:r.name}),E,c!==null&&i(Ot,{text:c})]}),O=e(u,{children:[i(Z,{variant:`outline`,size:`sm`,onClick:l,children:h(`integrations.cancel`,`Cancel`)}),e(Z,{variant:`primary`,size:`sm`,onClick:()=>d(S),disabled:s||!T,children:[s&&i(m,{className:`h-3.5 w-3.5 animate-spin`}),h(`common.add`,`Add`)]})]});return p?e(`div`,{className:`shrink-0 space-y-3 border-b border-border pb-3`,children:[D,i(`div`,{className:`flex justify-end gap-2`,children:O})]}):e(u,{children:[i(P,{className:`space-y-3`,children:D}),i(K,{children:O})]})}c();function jt(e){return e===`manual`?`manual`:e===`pairing`?`pairing`:`network`}function Mt({addonId:t,integrationId:n,kind:r,canScan:a,onClose:s,pairing:c,onSetupIntegration:l}){let{t:d}=$(),f=ot(t,n),p=r===`device-adoption`&&a===null,h=r===`device-adoption`||a===!0,g=f===`available`,[_,v]=o(null),y=_??(c===void 0?h?`network`:`manual`:`pairing`),b=[h,g,c!==void 0].filter(Boolean).length,x=p?i(P,{children:i(m,{className:`mx-auto h-5 w-5 animate-spin text-primary`})}):r===`device-adoption`?e(u,{children:[a===!0&&i(Dt,{addonId:t,integrationId:n,onClose:s,alongsideAdoption:!0,...l?{onSetupIntegration:l}:{}}),i(_t,{addonId:t,integrationId:n,onClose:s})]}):i(Dt,{addonId:t,integrationId:n,onClose:s,...l?{onSetupIntegration:l}:{}}),S=i(st,{integrationId:n,addonId:t,onClose:s});return i(be,{open:!0,onOpenChange:e=>{e||s()},children:e(ye,{width:`xl`,placement:`sheet-on-mobile`,scroll:`body`,className:r===`device-adoption`?`md:h-[85vh]`:void 0,children:[i(ae,{children:i(z,{children:d(`integrations.addDevice`,`Add device`)})}),b>1?e(G,{value:y,onValueChange:e=>v(jt(e)),children:[e(W,{children:[h&&i(le,{value:`network`,children:d(`integrations.addDeviceModal.tabNetwork`,`Found on the network`)}),g&&i(le,{value:`manual`,children:d(`integrations.addDeviceModal.tabManual`,`Enter parameters`)}),c!==void 0&&i(le,{value:`pairing`,children:c.label})]}),h&&i(De,{value:`network`,children:x}),g&&i(De,{value:`manual`,children:S}),c!==void 0&&i(`div`,{role:`tabpanel`,id:`tabpanel-pairing`,hidden:y!==`pairing`,className:`pt-3`,children:c.render({onPaired:()=>v(`network`)})})]}):c!==void 0&&!h&&!g?c.render({onPaired:()=>v(`network`)}):h?x:g?S:f===`loading`?i(P,{children:i(m,{className:`mx-auto h-5 w-5 animate-spin text-primary`})}):i(P,{children:i(`p`,{className:`py-6 text-center text-xs text-foreground-subtle`,children:d(`integrations.addDeviceModal.nothingToAdd`,`This integration has no way to add a device from here.`)})})]})})}c();var Nt=`matter`,Pt=[`discovering`,`pase`,`commissioning`,`done`];function Ft(e){return!(typeof e!=`object`||!e||!(`phase`in e)||typeof e.phase!=`string`)}function It(e,t){return e===`code-expired`||t?.includes(`matter-commission:code-expired`)?{key:`integrations.addMatter.failure.expired`,defaultValue:`The pairing code expired. Share the device again and paste the new code.`}:e===`device-not-found`||t?.includes(`matter-commission:device-not-found`)?{key:`integrations.addMatter.failure.notFound`,defaultValue:`No Matter device with that code was found on the network.`}:e===`wrong-code`||t?.includes(`matter-commission:wrong-code`)?{key:`integrations.addMatter.failure.wrongCode`,defaultValue:`The pairing code was rejected.`}:e===`invalid-code`||t?.includes(`invalid pairing code`)?{key:`integrations.addMatter.failure.invalid`,defaultValue:`Enter an 11-digit or 21-digit manual code, or a code that starts with MT:.`}:{key:`integrations.addMatter.failure.unknown`,defaultValue:t??`Commissioning failed.`}}function Lt({onClose:t,onCommissioned:n}){let{t:r}=$(),s=ve({kind:Nt}),[c,l]=o(null),d=Oe(s.data??[],c),f=d.length,p=c??d[0]?.id??null,h=H(),[g,_]=o(``),[v,y]=o({phase:`idle`,failure:null,message:null}),b=v.phase===`discovering`||v.phase===`pase`||v.phase===`commissioning`,x=B({brokerId:p??``,key:`commission`},{enabled:p!==null&&b,refetchInterval:b?400:!1});a(()=>{b&&Ft(x.data)&&x.data.phase!==`idle`&&y({phase:x.data.phase,failure:typeof x.data.failure==`string`?x.data.failure:null,message:typeof x.data.message==`string`?x.data.message:null})},[b,x.data]);let S=()=>{p!==null&&(y({phase:`discovering`,failure:null,message:null}),h.mutate({brokerId:p,target:{action:`commissionNode`},payload:{pairingCode:g.trim()}},{onSuccess:()=>y({phase:`done`,failure:null,message:null}),onError:e=>{let t=e instanceof Error?e.message:`Commissioning failed.`;y({phase:`failed`,failure:t.includes(`matter-commission:`)?t.split(`matter-commission:`)[1]?.split(`:`)[0]??`unknown`:t.includes(`invalid pairing code`)?`invalid-code`:`unknown`,message:t})}}))},C=v.phase===`failed`?It(v.failure,v.message):null,w=C===null?null:r(C.key,{defaultValue:C.defaultValue}),T=(s.isSuccess===!0||s.data!==void 0)&&p===null;return e(u,{children:[e(P,{className:`space-y-4`,children:[i(`p`,{className:`text-xs text-foreground-subtle`,children:r(`integrations.addMatter.help`,{defaultValue:`In Home Assistant, open the device and choose Share device. Paste the numeric code or the MT: code here. The device stays in Home Assistant.`})}),(T||f>1)&&!b&&v.phase!==`done`&&e(`div`,{className:`space-y-1.5`,children:[i(ke,{children:r(`integrations.addMatter.broker`,{defaultValue:`Matter fabric`})}),i(Ue,{kind:Nt,value:p,onChange:l})]}),!T&&e(`div`,{className:`space-y-1.5`,children:[i(ke,{htmlFor:`matter-pairing-code`,children:r(`integrations.addMatter.code`,{defaultValue:`Pairing code`})}),i(J,{id:`matter-pairing-code`,value:g,autoComplete:`off`,spellCheck:!1,placeholder:`34970112332`,disabled:b||v.phase===`done`,onChange:e=>_(e.target.value)})]}),v.phase!==`idle`&&i(`ol`,{className:`space-y-1`,"aria-label":r(`integrations.addMatter.progress`,{defaultValue:`Commissioning progress`}),children:Pt.map(t=>{let n=v.phase===t;return e(`li`,{className:`text-xs ${n?`text-foreground font-medium`:`text-foreground-subtle`}`,children:[n&&b?i(m,{className:`mr-1 inline h-3 w-3 animate-spin`}):null,r(`integrations.addMatter.phase.${t}`,{defaultValue:t===`discovering`?`Discovering`:t===`pase`?`PASE`:t===`commissioning`?`Commissioning`:`Done`})]},t)})}),w!==null&&i(he,{message:w})]}),e(K,{children:[i(Z,{variant:`ghost`,size:`sm`,onClick:t,children:r(`common.close`,{defaultValue:`Close`})}),v.phase===`done`?i(Z,{size:`sm`,onClick:n,children:r(`integrations.adoptDevices`,{defaultValue:`Adopt devices`})}):i(Z,{size:`sm`,disabled:b||T||g.trim().length===0,onClick:S,children:b?r(`integrations.addMatter.working`,{defaultValue:`Adding…`}):r(`integrations.addMatter.submit`,{defaultValue:`Add device`})})]})]})}function Rt({addonId:t,integrationId:n,name:r,onClose:a,onSaved:o}){let{t:c}=$(),l=k(),u=s({queryKey:[`integration-instance-describe`,t],queryFn:()=>l.trpcClient.integrationInstances.describe.query({addonId:t})}),d=s({queryKey:[`integration-instance`,t,n],queryFn:()=>l.trpcClient.integrationInstances.getInstance.query({addonId:t,id:n})});if(u.isSuccess&&d.isSuccess&&d.data!==null)return i(We,{addonId:t,providerName:r,description:u.data,instance:d.data,onClose:a,onSaved:()=>o()});let f=u.isError||d.isError||d.isSuccess&&!d.data;return i(be,{open:!0,onOpenChange:e=>!e&&a(),children:e(ye,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,children:[i(ae,{children:e(z,{children:[c(`integrations.editConfig`,{defaultValue:`Edit configuration`}),` — `,r]})}),i(P,{children:f?i(`p`,{className:`text-[11px] text-danger`,children:c(`integrations.loadFailed`,{defaultValue:`Could not load this integration.`})}):e(`div`,{className:`flex items-center gap-2 text-[11px] text-foreground-subtle`,children:[i(m,{className:`h-3 w-3 animate-spin`}),c(`integrations.loading`,{defaultValue:`Loading…`})]})})]})})}c();function zt(){let{addonId:e=``}=Je();return i(Vt,{addonId:e})}function Bt(){return e(`div`,{className:`p-4`,children:[i(`div`,{className:`h-16 rounded-lg bg-surface animate-pulse mb-4`}),i(`div`,{className:`h-40 rounded-lg bg-surface animate-pulse`})]})}function Vt({addonId:t}){let{t:c}=$(),u=l(),g=Xe(),[_,v]=Ge(),y=k(),[b,x]=o(!1),S=r(e=>{x(!1),g(`/integrations`,{state:{integrationSeed:e}})},[g]),[C,w]=o(!1),[T,D]=o(!1),{data:O}=ce(void 0),A=n(()=>(O??[]).filter(e=>e.addonId===t),[O,t]),j=Ze(_.get(`instance`),A)??``,M=r(e=>{v(t=>{let n=new URLSearchParams(t);return n.set(He,e),n},{replace:!0})},[v]),B=n(()=>A.map(e=>({value:e.id,label:e.name})),[A]),{data:H,isLoading:U}=Ie({id:j},{enabled:!!j}),{data:W,isSuccess:G}=te(),K=n(()=>{let e=H?.addonId;return!e||!G?null:(W??[]).find(t=>t.addonId===e)?.kind===`device-adoption`?`device-adoption`:`device-provider`},[W,H?.addonId,G]),{data:q,isPending:J}=L({}),oe=n(()=>J?null:(q?.providers??[]).some(e=>e.addonId===H?.addonId),[J,q,H?.addonId]),X=K!==null,Q=H?.info?.fixed===!0,le=n(()=>{let e=H?.addonId;return!e||!G?null:(W??[]).find(t=>t.addonId===e)?.brokerKind??null},[W,H?.addonId,G])===`matter`,ue=X?c(`integrations.addDevice`,`Add device`):c(`integrations.addDeviceLoading`,{defaultValue:`Loading…`}),de=n(()=>{let e=H?.addonId;return!e||!G?null:(W??[]).find(t=>t.addonId===e)?.mode??null},[W,H?.addonId,G]);a(()=>{_.get(`add`)===`1`&&X&&(x(!0),v(e=>{let t=new URLSearchParams(e);return t.delete(`add`),t},{replace:!0}))},[_,X,v]);let{data:fe}=s({queryKey:[`integration-instance-form`,H?.addonId,H?.id],enabled:!!H?.addonId&&!!H?.id,queryFn:()=>y.trpcClient.integrationInstances.instanceFormSchema.query({addonId:H?.addonId??``,id:H?.id??``})}),pe=fe!=null&&Array.isArray(fe.sections)&&fe.sections.some(e=>e.fields.length>0),{data:he}=ie({projection:`slim`},{refetchInterval:3e4}),ge=[[`integrations`,`get`],{input:{id:j},type:`query`}],_e={onMutate:async e=>{await u.cancelQueries({queryKey:ge});let t=u.getQueryData(ge);return t!=null&&u.setQueryData(ge,{...t,enabled:e.enabled}),{previous:t}},onError:(e,t,n)=>{let r=n;r?.previous!=null&&u.setQueryData(ge,r.previous)},onSettled:()=>{u.invalidateQueries({queryKey:[[`integrations`]]}),u.invalidateQueries({queryKey:[[`deviceManager`]]})}},ve=R(_e),Se=V(_e),Ce={isPending:ve.isPending||Se.isPending,mutate:e=>Q&&H?.processState!==`running`?Se.mutate({id:e.id,enabled:e.enabled}):ve.mutate(e)},Ee=H?.switchUnknown===!0,De=Ve(H?.processState),Oe=Ee||!Q&&De,ke={onSuccess:()=>{u.invalidateQueries({queryKey:[[`integrations`]]}),u.invalidateQueries({queryKey:[[`deviceManager`]]}),g(A.length>1?qe(t):`/integrations`)}},Ae=ne(ke),je=Y(ke),Le=H?.processState===`running`,Re={isPending:Ae.isPending||je.isPending,mutateAsync:async e=>{Le?await Ae.mutateAsync(e):await je.mutateAsync({id:e.id})}},ze=we({onSuccess:()=>{u.invalidateQueries({queryKey:[[`integrations`]]}),u.invalidateQueries({queryKey:[[`deviceManager`]]})}}),Be=Qe(),Ue=Pe({onSuccess:()=>{u.invalidateQueries({queryKey:[[`deviceManager`]]})}}),We=se({onSuccess:()=>{u.invalidateQueries({queryKey:[[`deviceManager`]]})}}),Ke=n(()=>he??[],[he]),Je=n(()=>F(Ke),[Ke]),Ye=r(e=>Je.get(e)??null,[Je]),et=n(()=>Fe(O),[O]),tt=r(e=>g(`/devices/${String(e)}`),[g]),nt=n(()=>Ke.filter(e=>{let t=et(e);return t.kind===`resolved`&&t.integration.id===j}),[Ke,j,et]),rt=n(()=>O===void 0?null:Ne(nt).length,[O,nt])??`…`;if(U||O===void 0)return i(Bt,{});let it=(W??[]).find(e=>e.addonId===t)?.name??H?.name??t,at=Oe&&De?c(`providerInstances.addonNotRunning`,`{{addon}} is not running: start it first`,{addon:it}):null;return H?e(`div`,{className:`p-4 space-y-4 overflow-x-hidden`,children:[i(re,{items:[{label:c(`integrationDetail.integrations`,`Integrations`),onClick:()=>g(`/integrations`)},{label:it}]}),e(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[e(`div`,{className:`flex items-center gap-3 min-w-0`,children:[i(Ht,{addonId:H.addonId}),e(`div`,{className:`min-w-0`,children:[i(`h1`,{className:`text-lg font-semibold text-foreground truncate`,children:it}),e(`p`,{className:`text-[11px] text-foreground-subtle mt-0.5 truncate`,children:[rt,` `,c(`integrations.devices`)]})]})]}),e(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[!Q&&e(Z,{variant:`unstyled`,onClick:()=>{x(!0)},disabled:!X,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 disabled:opacity-50 disabled:cursor-not-allowed`,title:ue,children:[i(ee,{className:`h-3.5 w-3.5`}),ue]}),e(`div`,{className:`flex flex-col items-end gap-1`,children:[e(`div`,{className:`inline-flex items-center gap-2 rounded-lg border px-3 py-1.5 transition-colors ${Ce.isPending?`opacity-60`:``} ${H.enabled&&!Ee?`border-success/30 bg-success/5`:`border-border bg-surface`}`,title:at??c(`integrations.toggleHint`,{defaultValue:`Click to toggle`}),children:[i(me,{checked:H.enabled&&!Ee,onCheckedChange:e=>Ce.mutate({id:j,addonId:H?.addonId,enabled:e}),disabled:Ce.isPending||Oe,"aria-label":Ee?c(`integrationDetail.switchUnknown`,`Unknown`):H.enabled?c(`integrationDetail.disableIntegration`,`Disable integration`):c(`integrationDetail.enableIntegration`,`Enable integration`)}),i(`span`,{className:`text-[11px] font-medium ${H.enabled&&!Ee?`text-success`:`text-foreground-subtle`}`,children:Ee?c(`integrationDetail.switchUnknown`,`Unknown`):H.enabled?c(`integrationDetail.enabled`,`Enabled`):c(`integrationDetail.disabled`,`Disabled`)}),Ce.isPending&&i(m,{className:`h-3 w-3 animate-spin text-foreground-subtle`})]}),at!==null&&i(`span`,{className:`text-[11px] text-foreground-subtle`,children:at})]}),de!==`standalone`&&(pe||K===`device-adoption`)&&e(Z,{variant:`unstyled`,onClick:()=>w(!0),className:`flex items-center gap-1.5 rounded-lg border border-border bg-surface px-3 py-1.5 text-[11px] text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,children:[i(p,{className:`h-3 w-3`}),c(`integrations.config`)]}),e(Z,{variant:`unstyled`,onClick:()=>D(!0),className:`flex items-center gap-1.5 rounded-lg border border-border bg-surface px-3 py-1.5 text-[11px] text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,title:c(`integrations.logs`,{defaultValue:`View logs`}),children:[i(d,{className:`h-3 w-3`}),c(`integrations.logs`,{defaultValue:`Logs`})]}),i(I,{label:c(`integrationDetail.restart`,`Restart`),icon:h,title:c(`integrationDetail.restart2`,`Restart "{{name}}"?`,{name:H.name}),description:c(`integrationDetail.restartingTheAddonWillBriefly`,`Restarting the addon will briefly disconnect every device backed by it ({{topLevelCountLabel}} active). Streams will reconnect automatically.`,{topLevelCountLabel:rt}),confirmLabel:c(`integrationDetail.restart`,`Restart`),triggerVariant:`outline`,confirmVariant:`danger`,disabled:ze.isPending,action:()=>ze.mutateAsync({addonId:H.addonId})}),!Q&&j&&i(I,{label:c(`integrations.delete`,{defaultValue:`Delete`}),icon:E,title:c(`integrations.deleteTitle`,{defaultValue:`Delete integration?`}),description:c(`integrations.deleteWarning`,{defaultValue:`This removes the integration "{{name}}" and its {{count}} device(s). The addon will restart. This cannot be undone.`,name:H.name,count:rt}),confirmLabel:c(`integrations.confirmDelete`,{defaultValue:`Delete integration`}),triggerVariant:`outline`,confirmVariant:`danger`,className:`border-danger bg-danger/10 text-danger hover:bg-danger hover:text-background`,disabled:Re.isPending,action:()=>Re.mutateAsync({addonId:t,id:j})})]})]}),A.length>1&&i(`div`,{className:`max-w-sm`,children:i(Te,{mode:`single`,singleDisplay:`field`,label:c(`integrationDetail.instances`,`Integration`),options:B,value:j,onChange:M,testId:`integration-instance-picker`,optionTestIdPrefix:`integration-instance`})}),i(Me,{context:`integration-detail`,devices:Ke,trpc:y.trpcClient,integrationOf:et,forceIntegrationId:j,urlScope:`root`,lsKey:`integration-detail:${H.addonId}`,resolveIntegrationIcon:$e,resolveParent:Ye,onNavigate:tt,rowOperation:Be.rowOperation,batchActions:{remove:Be.remove,disable:Ue.mutate,enable:We.mutate},...Q?{}:{onDeleteDevice:e=>Be.remove({deviceId:e.id})}}),b&&j&&K!==null&&i(Mt,{addonId:H.addonId,integrationId:j,kind:K,canScan:oe,onSetupIntegration:S,...le?{pairing:{label:c(`integrations.addMatter.tab`,`Pairing code`),render:({onPaired:e})=>i(Lt,{onClose:()=>x(!1),onCommissioned:e})}}:{},onClose:()=>x(!1)}),C&&j&&i(Rt,{addonId:H.addonId,integrationId:j,name:H.name,onClose:()=>w(!1),onSaved:()=>{u.invalidateQueries()}}),T&&i(be,{open:!0,onOpenChange:e=>!e&&D(!1),children:e(ye,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,className:`md:max-w-5xl md:h-[80vh]`,children:[i(ae,{className:`mb-0`,children:e(z,{className:`flex items-center gap-2 min-w-0`,children:[i(d,{className:`h-4 w-4 text-primary shrink-0`}),i(`span`,{className:`truncate`,children:H.name}),e(`span`,{className:`text-[10px] text-foreground-subtle font-mono truncate font-normal`,children:[H.addonId,j?` · ${j}`:``]})]})}),i(P,{className:`min-h-0 overflow-hidden p-0`,children:i(xe,{addonId:H.addonId,limit:200,maxHeight:`max-h-full`,showScope:!1,className:`h-full border-0 rounded-none`})})]})})]}):e(`div`,{className:`flex flex-col items-center justify-center py-20 px-6 text-center gap-4`,children:[i(`div`,{className:`flex h-12 w-12 items-center justify-center rounded-full bg-foreground-subtle/10`,children:i(N,{className:`h-6 w-6 text-foreground-subtle`})}),e(`div`,{className:`space-y-1 max-w-sm`,children:[i(`h2`,{className:`text-sm font-semibold text-foreground`,children:c(`integrations.integrationNotFound`,{defaultValue:`Integration not found`})}),i(`p`,{className:`text-[11px] text-foreground-subtle`,children:c(`integrations.integrationNotFoundHint`,{defaultValue:`The integration "{{id}}" does not exist. It may have been deleted, or the URL may be wrong.`,id:t})})]}),e(Z,{variant:`unstyled`,onClick:()=>g(`/integrations`),className:`inline-flex items-center gap-1.5 rounded-lg border border-border bg-surface px-3 py-1.5 text-[11px] font-medium text-foreground hover:bg-surface-hover transition-colors`,children:[i(f,{className:`h-3 w-3`}),c(`integrations.backToList`,{defaultValue:`Back to integrations`})]})]})}function Ht({addonId:e}){let t=Ye(e),[n,r]=o(!1);return!t||n?null:i(`img`,{src:t,alt:``,className:`h-8 w-8 rounded-lg shrink-0`,onError:()=>r(!0)})}export{zt as IntegrationDetailPage};
@@ -1,3 +0,0 @@
1
- import{C as e,K as t,S as n,V as r,Y as i,et as a,o,x 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{Jn as c,O as l,Oa as u,Qi as d,Rr as f,Ua as p,V as m,ct as h,dt as g,en as _,k as v,kr as y,lr as b,rr as x,wt as S,z as C}from"./player-overlays-VrMHBBfa.js";import{Pn as w,gs as T,ms as E}from"./client-CBrsD14Q.js";import{t as D}from"./chevron-down-CBb-F8DT.js";import{$f as O,$s as k,A,Ai as j,Ar as M,Ca as N,Da as P,Fi as F,Js as ee,Ks as te,Ls as ne,Ni as I,Ns as re,Pi as L,Qf as R,Qs as ie,Rs as ae,Tn as z,Vs as oe,Wf as B,Xi as V,Ys as se,as as ce,ba as H,br as le,cs as ue,ec as de,ep as U,is as fe,ji as pe,ki as W,ma as G,ni as me,oa as he,oc as ge,qs as _e,ri as ve,rs as ye,tc as be,vp as xe,xa as K,xr as Se,zs as Ce}from"./src-bJ4Hy4Cl.js";import{t as q}from"./i18n-BFxrpjSx.js";import{t as J}from"./useTranslation-BJr-n0es.js";import{h as we,hi as Te,pi as Ee,ui as Y}from"./index-1bBrNxAK.js";import{t as De}from"./AdminSectionedPage-vnoSnjIu.js";import{c as X,n as Oe,r as ke}from"./linked-devices-model-BbPIMVq4.js";a();function Z(e){return{id:e.id,name:e.name,type:e.type,stableId:e.stableId??``,parentDeviceId:e.parentDeviceId,location:e.location,...e.role!==void 0&&e.role!==null?{role:e.role}:{},...e.primaryChildEntityId!==void 0&&e.primaryChildEntityId!==null?{primaryChildEntityId:e.primaryChildEntityId}:{},...e.primaryChildPreference!==void 0&&e.primaryChildPreference!==null?{primaryChildPreference:e.primaryChildPreference}:{}}}function Q(e){if(e==null)return null;let t=e.trim();return t.length===0?null:t.toLowerCase()}function Ae(e,t){let n=Q(t);return n===null?[]:e.filter(e=>Q(e.location)===n)}function je(e,t){let n=Ae(e,t),r=new Set(n.map(e=>e.id));return n.filter(e=>e.parentDeviceId===null||!r.has(e.parentDeviceId))}function Me(e,t){let n=Q(e.location);return n===null||new Set(t.map(e=>Q(e))).has(n)?null:e.location?.trim()??null}function Ne(e,t){let n=Q(e.location);return n!==null&&t.has(n)}function Pe(e,t){let n=new Set(t.map(e=>Q(e))),r=new Set(e.filter(e=>Ne(e,n)).map(e=>e.id));return e.filter(e=>!(Ne(e,n)||e.parentDeviceId!==null&&r.has(e.parentDeviceId)))}function Fe(e,t){return Pe(e,t).filter(e=>e.parentDeviceId===null)}function Ie(e,t){let n=new Map;for(let t of e){if(t.parentDeviceId===null)continue;let e=n.get(t.parentDeviceId);e?e.push(t):n.set(t.parentDeviceId,[t])}let r=[],i=new Set([t]),a=[t];for(;a.length>0;){let e=[];for(let t of a)for(let a of n.get(t)??[])i.has(a.id)||(i.add(a.id),r.push(a),e.push(a.id));a=e}return r}function Le(e,t){return Ie(e,t).length}function Re(e,t){return e.filter(e=>!e.isCamera&&e.parentDeviceId===t)}function ze(e,t){return t.map(t=>({name:t,members:je(e,t)}))}function $({type:e,role:t,className:r}){return n(xe(e,t),{"aria-hidden":`true`,className:r??`h-3.5 w-3.5 shrink-0 text-foreground-subtle`})}function Be({device:t}){let r=K(Z(t),`compact`);if(t.online)return n(`span`,{"aria-hidden":`true`,className:`inline-block h-1.5 w-1.5 shrink-0 rounded-full bg-success`,"data-status":`online`});let i=q.t(`common.offline`);return e(`span`,{className:`flex items-center gap-1.5`,children:[n(`span`,{className:`inline-block h-1.5 w-1.5 shrink-0 rounded-full border border-foreground-subtle`,"data-status":`offline`,role:`img`,"aria-label":q.t(`locations.deviceGlyphs.aria`,{name:r,state:i}),title:i}),n(`span`,{className:`text-xs text-foreground-muted`,children:i})]})}function Ve({open:t,title:a,items:o,listState:s,lockedIds:c,lockedNote:l,suggestions:u=null,busy:d=!1,onConfirm:f,onClose:p}){let{t:m}=J(),[h,g]=i([]);r(()=>{t||g([])},[t]);let _=new Map(o.map(e=>[e.id,e.name])),v=(u?.ids??[]).filter(e=>_.has(e)&&!c.includes(e)),y=e=>g(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]);return n(W,{open:t,onOpenChange:e=>e?void 0:p(),children:e(pe,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,"aria-label":a,children:[n(L,{children:n(F,{children:a})}),e(j,{className:`flex flex-col gap-3 p-2 sm:p-4`,children:[t&&u!==null&&v.length>0&&e(`section`,{"aria-label":u.heading,className:`flex flex-col gap-1`,children:[n(`h3`,{className:`text-[10px] sm:text-[11px] font-semibold text-foreground uppercase tracking-wider`,children:u.heading}),n(`div`,{className:`flex flex-wrap gap-1`,children:v.map(e=>n(`button`,{type:`button`,"aria-pressed":h.includes(e),className:`inline-flex items-center gap-1 rounded-full border px-1.5 py-0.5 text-[10px] font-medium transition-colors ${h.includes(e)?`border-primary/50 bg-primary/15 text-primary`:`border-border bg-surface text-foreground-subtle hover:bg-surface-hover`}`,onClick:()=>y(e),children:_.get(e)},e))})]}),t&&n(A,{devices:o,listState:s,value:h,onChange:e=>g(e),noun:`device`,emptyLabel:m(`locations.addDialog.nonePicked`),showAll:!0,lockedIds:c,lockedNote:l,testId:`quick-add-picker`})]}),e(I,{children:[n(B,{variant:`ghost`,onClick:p,children:m(`locations.addDialog.cancel`)}),n(B,{disabled:h.length===0||d,onClick:()=>f(h),children:m(`locations.addDialog.confirm`,{count:h.length})})]})]})})}a();function He({room:e,cameras:r,fleet:i}){let{t:a}=J(),o=t(()=>new Map(i.map(e=>[e.id,e])),[i]);return e===null?n(`p`,{className:`text-xs text-foreground-subtle`,children:a(`locations.links.noRoom`)}):n(`div`,{className:`flex flex-col gap-3`,"data-testid":`camera-links-section`,children:r.length===0?n(`p`,{className:`text-xs text-foreground-subtle`,"data-testid":`camera-links-empty`,children:a(`locations.links.noCameras`,{room:e})}):r.map(e=>n(We,{camera:e,byId:o},e.id))})}function Ue(e){return{id:e.deviceId,name:e.name,type:e.type,location:e.location}}function We({camera:t,byId:r}){let{t:a}=J(),s=K(Z(t),`full`),c=o(),u=Ee(),[d,p]=i(!1),[m,h]=i(null),g=fe({deviceId:t.id}),_=ke({status:g.status,data:g.data,error:g.error===null||g.error===void 0?null:g.error}),y=ce(),b=_.kind===`present`?_:null,x=ye({deviceId:t.id,slotRef:b?.slot.slotRef??``},{enabled:d&&b!==null}),S=b===null?[]:Oe(b.slot,b.value),C=S.map(e=>e.deviceId),w=(x.data?.candidates??[]).map(Ue),T=new Set(w.map(e=>e.id)),E=C.filter(e=>!T.has(e)).map(e=>{let t=r.get(e);return{id:e,name:t?.name??`#${String(e)}`,...t===void 0?{}:{type:t.type,location:t.location}}}),D=[...w,...E],O=(x.data?.candidates??[]).filter(e=>e.suggested).map(e=>e.deviceId),k=async e=>{if(b!==null){h(null);try{await y.mutateAsync({deviceId:t.id,slotRef:b.slot.slotRef,value:X(b.value,e)}),await g.refetch(),await c.invalidateQueries({queryKey:[[`deviceManager`]]}),p(!1)}catch(e){h(e instanceof Error?e.message:String(e))}}},A=[{key:`device`,header:a(`locations.columns.device`),notSortableReason:a(`locations.columns.noSort`),render:t=>{let i=r.get(t.deviceId),o=t.name??i?.name??`#${String(t.deviceId)}`;return e(`span`,{className:`flex items-center gap-1.5`,children:[i!==void 0&&n($,{type:i.type,role:i.role}),n(Y,{to:`/devices/${String(t.deviceId)}`,className:`min-w-0 truncate text-xs text-foreground hover:underline`,children:i===void 0?o:n(V,{device:Z(i),form:`compact`})}),t.implied&&n(`span`,{className:`text-[10px] text-foreground-subtle`,children:a(`locations.links.implied`)})]})}},{key:`type`,header:a(`locations.columns.type`),notSortableReason:a(`locations.columns.noSort`),render:e=>n(`span`,{className:`text-xs text-foreground-muted`,children:r.get(e.deviceId)?.type??`—`})},{key:`status`,header:a(`locations.columns.status`),notSortableReason:a(`locations.columns.noSort`),render:e=>{let t=r.get(e.deviceId);return t===void 0?n(`span`,{className:`text-xs text-foreground-subtle`,children:`—`}):n(Be,{device:t})}}];return e(`section`,{className:`min-w-0 ${l}`,"data-testid":`camera-links-${String(t.id)}`,children:[e(`header`,{className:`${v} flex min-h-9 items-center gap-1.5`,children:[n($,{type:t.type,role:t.role}),n(`h2`,{className:`min-w-0 flex-1 truncate text-sm font-semibold text-foreground`,children:n(V,{device:Z(t),form:`full`})}),e(B,{variant:`ghost`,size:`sm`,onClick:()=>u(we(t.id)),children:[n(f,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),a(`locations.links.edit`)]}),n(B,{variant:`outline`,size:`sm`,disabled:b===null,onClick:()=>p(!0),"aria-label":a(`locations.links.addNamed`,{camera:s}),children:a(`locations.room.add`)})]}),_.kind===`pending`&&n(`p`,{role:`status`,className:`px-3 py-3 text-xs text-foreground-subtle sm:px-4`,children:a(`locations.links.loading`)}),_.kind===`unknown`&&n(`p`,{role:`alert`,className:`px-3 py-3 text-xs text-warning sm:px-4`,children:a(`locations.links.unreadable`,{reason:_.reason})}),_.kind===`absent`&&n(`p`,{className:`px-3 py-3 text-xs text-foreground-subtle sm:px-4`,children:a(`locations.links.unsupported`)}),m!==null&&n(`p`,{role:`alert`,className:`px-3 pt-2 text-xs text-danger break-words sm:px-4`,children:m}),b!==null&&(S.length===0?n(`p`,{className:`px-3 py-3 text-xs text-foreground-subtle sm:px-4`,children:a(`locations.links.none`)}):n(M,{columns:A,rows:S,rowKey:e=>String(e.deviceId),bordered:!1,minWidthPx:360})),n(Ve,{open:d,title:a(`locations.links.pickTitle`,{camera:s}),items:D,listState:x.status===`error`?`failed`:x.data===void 0?`pending`:`answered`,lockedIds:C,lockedNote:a(`locations.links.alreadyLinked`),suggestions:t.location===null?null:{heading:a(`locations.links.suggested`,{room:t.location}),ids:O},busy:y.isPending,onConfirm:e=>void k(e),onClose:()=>p(!1)})]})}a();function Ge({name:t,description:a,busy:o,onSave:s}){let{t:c}=J(),[l,u]=i(a??``);return r(()=>{u(a??``)},[a]),e(`div`,{className:`border-t border-border px-3 py-2 sm:px-4`,children:[n(ve,{htmlFor:`location-description-${t}`,className:`block`,children:c(`locations.locationDescriptionField.whatIsThere`,`What is there`)}),n(me,{id:`location-description-${t}`,value:l,onChange:e=>u(e.target.value),onBlur:()=>{let e=l.trim();e!==(a??``)&&s(e.length===0?null:e)},disabled:o,rows:2,maxLength:400,placeholder:c(`locations.locationDescriptionField.surfacesBoundariesWhatIsNormally`,`Surfaces, boundaries, what is normally parked or stored here.`),className:`mt-1 w-full resize-y rounded-md border border-border bg-surface px-2.5 py-1.5 text-xs text-foreground placeholder:text-foreground-subtle focus:outline-none focus:ring-1 focus:ring-inset focus:ring-primary disabled:cursor-not-allowed disabled:opacity-50`}),n(`p`,{className:`mt-1 ${C}`,children:c(`locations.locationDescriptionField.givenToTheAiWith`,`Given to the AI with the pictures, so it knows what it is looking at. Describe the PLACE, not what happens in it — events change, the ground does not.`)})]})}function Ke(e,t){let n=e?.find(e=>e.locationKey===t);return n===void 0||n.description.length===0?null:n.description}var qe=` none`;function Je({name:t,zones:r,zoneKey:i,busy:a,onChange:o}){let{t:s}=J();if(r.length===0)return null;let c=[{value:qe,label:s(`locations.locationZoneField.none`,`— none —`)},...r.map(e=>({value:e.zoneKey,label:e.label}))];return e(`div`,{className:`flex items-center gap-2 border-t border-border px-3 py-1.5 sm:px-4 sm:py-2`,children:[n(ve,{htmlFor:`location-zone-${t}`,children:s(`locations.locationZoneField.zone`,`Zone`)}),n(g,{id:`location-zone-${t}`,value:i??qe,disabled:a,onChange:e=>{let t=e.target.value;if(t===qe){o(null);return}let n=r.find(e=>e.zoneKey===t);n!==void 0&&o(n.label)},options:c})]})}function Ye(e,t){return e.find(e=>e.locationKeys.includes(t))?.zoneKey??null}function Xe({name:e,icon:t,busy:r,onPick:i}){return n(U,{value:t,onPick:i,fallbackGlyph:y,clearGlyph:u,labels:{trigger:`Change the icon of ${e}`,panel:`Icon for ${e}`,searchPlaceholder:`Search icons`,clear:`No icon`,noMatches:`No icon matches that`},disabled:r})}function Ze(e,t){let n=e?.find(e=>e.locationKey===t);return n===void 0?null:T(n.icon)??`map-pin`}function Qe(e){return`${e.kind}:${String(e.device.id)}`}function $e(e,t,n){return e.flatMap(e=>{let r=Re(t,e.id),i=n.has(e.id),a={kind:`member`,device:e,accessories:r,open:i};return!i||r.length===0?[a]:[a,...r.map(t=>({kind:`accessory`,device:t,parent:e}))]})}a();function et({name:r,members:a,devices:o,busy:u,icon:d,description:f,onRename:p,onDelete:m,onRebuildLinks:h,onAddDevices:g,onPickIcon:y,onSaveDescription:x,zones:C,zoneKey:w,onChangeZone:T}){let{t:E}=J(),[D,k]=i(!1),[A,j]=i(r),N=le(a,t(()=>({searchText:e=>[e.name,...Re(o,e.id).map(e=>e.name)],facetValue:e=>e.type}),[o])),[P,F]=i(()=>new Set),ee=e=>F(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),te=t(()=>$e(N.rows,o,P),[N.rows,o,P]),ne=[{key:`name`,header:E(`locations.columns.device`),notSortableReason:E(`locations.columns.noSort`),render:e=>e.kind===`member`?n(tt,{row:e,onToggle:()=>ee(e.device.id)}):n(nt,{row:e})},{key:`type`,header:E(`locations.columns.type`),notSortableReason:E(`locations.columns.noSort`),render:e=>n(`span`,{className:`text-xs text-foreground-muted`,children:e.device.type})},{key:`status`,header:E(`locations.columns.status`),notSortableReason:E(`locations.columns.noSort`),render:e=>n(Be,{device:e.device})}],I=()=>{j(r),k(!1)},re=async()=>{let e=A.trim();if(e.length===0||e===r){I();return}await p(e),k(!1)},L=[{id:`rename`,label:E(`locations.locationCard.rename`,`Rename`),icon:b,disabled:u,onClick:()=>{j(r),k(!0)}},{id:`rebuild-links`,label:E(`locations.locationCard.rebuildLinkedDevices`,`Rebuild linked devices`),icon:c,separatorBefore:!0,disabled:u,onClick:()=>void h()},{id:`delete`,label:E(`common.delete`,`Delete`),icon:_,danger:!0,separatorBefore:!0,disabled:u,onClick:()=>void m()}];return e(`section`,{className:`min-w-0 ${l}`,children:[e(`header`,{className:`${v} flex min-h-9 items-center gap-1.5`,children:[n(Xe,{name:r,icon:d,busy:u,onPick:y}),D?e(s,{children:[n(R,{value:A,onChange:e=>j(e.target.value),onKeyDown:e=>{e.key===`Enter`&&re(),e.key===`Escape`&&I()},"aria-label":E(`locations.locationCard.rename2`,`Rename {{name}}`,{name:r}),className:`min-w-0 flex-1`,autoFocus:!0}),n(B,{type:`button`,size:`sm`,onClick:()=>void re(),children:E(`common.save`,`Save`)}),n(O,{type:`button`,variant:`ghost`,icon:S,onClick:I,"aria-label":E(`locations.locationCard.cancelRename`,`Cancel rename`)})]}):e(s,{children:[n(`h2`,{className:`min-w-0 flex-1 truncate text-sm font-semibold text-foreground`,children:r}),n(B,{type:`button`,variant:`outline`,size:`sm`,disabled:u,onClick:g,"aria-label":E(`locations.room.addTo`,{room:r}),children:E(`locations.room.add`)}),n(z,{items:L,title:E(`locations.locationCard.actionsFor`,`Actions for {{name}}`,{name:r}),triggerClassName:`p-1`})]})]}),n(Je,{name:r,zones:C,zoneKey:w,busy:u,onChange:T}),n(Ge,{name:r,description:f,busy:u,onSave:x}),a.length>0&&n(`div`,{className:`border-b border-border px-3 py-1.5 sm:px-4 sm:py-2`,children:n(Se,{state:N.state,facets:N.facets,labels:{searchPlaceholder:E(`locations.filter.searchPlaceholder`),searchLabel:E(`locations.room.searchLabel`,{room:r}),facetsLabel:E(`locations.filter.typesLabel`),clearLabel:E(`locations.filter.clear`)},onSearch:N.setSearch,onToggleFacet:N.toggleFacet,onClear:N.clear})}),a.length===0?n(`p`,{className:`px-3 py-3 text-xs text-foreground-subtle sm:px-4`,children:E(`locations.locationCard.nothingHereYetAssignA`,`Nothing here yet — assign a device from the table below.`)}):n(M,{columns:ne,rows:te,rowKey:Qe,bordered:!1,minWidthPx:360,emptyMessage:E(`locations.filter.noMatch`)})]})}function tt({row:t,onToggle:r}){let{t:i}=J(),{device:a,accessories:o,open:s}=t,c=K(Z(a),`compact`),l=s?D:d;return e(`span`,{className:`flex items-center gap-1.5`,children:[o.length>0?e(B,{type:`button`,variant:`ghost`,onClick:r,"aria-expanded":s,"aria-label":i(s?`locations.locationCard.collapseAccessories`:`locations.locationCard.expandAccessories`,{count:o.length,name:c}),className:`h-auto shrink-0 gap-0.5 p-0.5 text-foreground-subtle hover:text-foreground`,children:[n(l,{className:`h-3 w-3`}),n(`span`,{className:`text-[10px] tabular-nums`,children:o.length})]}):n(`span`,{"aria-hidden":`true`,className:`w-[1.35rem] shrink-0`}),n($,{type:a.type,role:a.role}),n(Y,{to:`/devices/${String(a.id)}`,className:`min-w-0 truncate text-xs text-foreground hover:underline`,children:n(V,{device:Z(a),form:`compact`})})]})}function nt({row:t}){let{device:r,parent:i}=t;return e(`span`,{className:`flex items-center gap-1.5 pl-6`,children:[n(`span`,{"aria-hidden":`true`,className:`text-[10px] text-foreground-subtle`,children:`└`}),n($,{type:r.type,role:r.role,className:`h-3 w-3 shrink-0 text-foreground-subtle`}),n(Y,{to:`/devices/${String(r.id)}`,className:`min-w-0 truncate text-xs text-foreground-muted hover:underline`,children:n(V,{device:Z(r),form:`nested`,parent:Z(i)})})]})}a();function rt({zones:e,busy:t,onRename:r,onDelete:a,onPickIcon:o}){let{t:s}=J(),[c,l]=i(null),[u,d]=i(``),f=async e=>{let t=u.trim();l(null),!(t.length===0||t===e)&&await r(e,t)};return n(M,{columns:[{key:`icon`,header:s(`locations.siteZonesPanel.icon`,`Icon`),width:`w-12`,notSortableReason:`An icon has no order`,render:e=>n(Xe,{name:e.label,icon:e.icon,busy:t,onPick:t=>o(e.label,t)})},{key:`name`,header:s(`locations.siteZonesPanel.zone`,`Zone`),sortValue:e=>e.label.toLowerCase(),render:e=>c===e.label?n(R,{value:u,onChange:e=>d(e.target.value),onKeyDown:t=>{t.key===`Enter`&&f(e.label),t.key===`Escape`&&l(null)},onBlur:()=>void f(e.label),"aria-label":s(`locations.siteZonesPanel.rename`,`Rename {{label}}`,{label:e.label}),autoFocus:!0}):n(B,{type:`button`,variant:`ghost`,size:`sm`,className:`px-0`,onClick:()=>{d(e.label),l(e.label)},disabled:t,title:s(`locations.siteZonesPanel.renameTheZone`,`Rename the zone`),children:e.label})},{key:`rooms`,header:s(`locations.siteZonesPanel.rooms`,`Rooms`),align:`right`,sortValue:e=>e.locationKeys.length,render:e=>n(`span`,{className:`tabular-nums text-foreground-subtle`,children:e.locationKeys.length===0?s(`common.empty`):s(`common.rooms`,{count:e.locationKeys.length})})},{key:`actions`,header:s(`locations.siteZonesPanel.actions`,`Actions`),align:`right`,notSortableReason:`Actions have no order`,render:e=>n(B,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>void a(e.label),disabled:t,"aria-label":s(`locations.siteZonesPanel.delete`,`Delete {{label}}`,{label:e.label}),title:s(`locations.siteZonesPanel.deleteTheZoneTheRooms`,`Delete the zone — the rooms in it are kept`),children:n(_,{className:`h-3.5 w-3.5`})})}],rows:e,rowKey:e=>e.zoneKey,emptyMessage:s(`locations.siteZonesPanel.noZonesYetAZone`,`No zones yet. A zone groups rooms — “Night zone” for the bedrooms — and shows up before them in the app’s camera filter.`)})}a();function it({busy:t,onCreate:r}){let{t:a}=J(),[o,s]=i(!1),[c,l]=i(``),u=()=>{l(``),s(!1)},d=async()=>{let e=c.trim();e.length!==0&&(await r(e),u())};return o?e(`form`,{className:`flex flex-wrap items-center gap-2`,onSubmit:e=>{e.preventDefault(),d()},children:[n(R,{value:c,onChange:e=>l(e.target.value),onKeyDown:e=>{e.key===`Escape`&&u()},placeholder:a(`locations.newLocationButton.frontDoorHallKitchen`,`Front door, Hall, Kitchen…`),"aria-label":a(`locations.newLocationButton.newLocationName`,`New location name`),className:`min-w-[12rem] flex-1`,autoFocus:!0}),e(B,{size:`sm`,type:`submit`,disabled:c.trim().length===0||t,children:[n(x,{className:`h-3.5 w-3.5`}),a(`common.add`,`Add`)]}),n(B,{size:`sm`,variant:`ghost`,type:`button`,onClick:u,"aria-label":a(`locations.newLocationButton.cancelNewLocation`,`Cancel new location`),children:n(S,{className:`h-3.5 w-3.5`})})]}):e(B,{size:`sm`,type:`button`,onClick:()=>s(!0),"data-testid":`new-location-button`,children:[n(x,{className:`h-3.5 w-3.5`}),a(`locations.newLocationButton.newLocation`,`New location`)]})}a();function at({busy:t,onCreate:r}){let{t:a}=J(),[o,s]=i(!1),[c,l]=i(``),u=()=>{l(``),s(!1)},d=async()=>{let e=c.trim();e.length!==0&&(await r(e),u())};return o?e(`form`,{className:`flex flex-wrap items-center gap-2`,onSubmit:e=>{e.preventDefault(),d()},children:[n(R,{value:c,onChange:e=>l(e.target.value),onKeyDown:e=>{e.key===`Escape`&&u()},placeholder:a(`locations.newZoneButton.zonaGiornoZonaNotte`,`Zona giorno, Night zone…`),"aria-label":a(`locations.newZoneButton.newZoneName`,`New zone name`),className:`min-w-[12rem] flex-1`,autoFocus:!0}),e(B,{size:`sm`,type:`submit`,disabled:c.trim().length===0||t,children:[n(x,{className:`h-3.5 w-3.5`}),a(`common.add`,`Add`)]}),n(B,{size:`sm`,variant:`ghost`,type:`button`,onClick:u,"aria-label":a(`locations.newZoneButton.cancelNewZone`,`Cancel new zone`),children:n(S,{className:`h-3.5 w-3.5`})})]}):e(B,{size:`sm`,type:`button`,onClick:()=>s(!0),"data-testid":`new-zone-button`,children:[n(x,{className:`h-3.5 w-3.5`}),a(`locations.newZoneButton.newZone`,`New zone`)]})}a();function ot(e,t,n,r){let i=e.map(e=>({value:e.name,label:`${e.name} · ${String(e.count)}`}));return t===void 0?i:[...i,{value:n,label:`${r} · ${String(t)}`}]}function st({rooms:e,unassignedCount:r,value:i,unassignedValue:a,onChange:o}){let{t:s}=J(),c=t(()=>ot(e,r,a,s(`locations.roomPicker.unassigned`)),[e,r,a,s]);return n(`div`,{className:`max-w-sm`,"data-testid":`room-select`,children:n(he,{mode:`single`,singleDisplay:`field`,label:s(`locations.roomPicker.label`),placeholder:s(`locations.roomPicker.placeholder`),options:c,value:i,onChange:o,searchable:!0,testId:`room-select-control`,optionTestIdPrefix:`room-option`})})}a();var ct={searchText:e=>[e.name],facetValue:e=>e.type};function lt({rows:r,fleet:a,locations:o,busy:s,emptyMessage:c,onAssign:l}){let{t:u}=J(),d=P(),f=N(),h=e=>d===null?e.name:H(Z(e),`compact`,d,f),[_,v]=i([]),[y,b]=i(``),x=le(r,ct),S=x.rows,w=t(()=>S.map(e=>e.id),[S]),T=t(()=>_.filter(e=>w.includes(e)),[_,w]),E=S.length>0&&T.length===S.length,D=t(()=>{let e=new Map;for(let t of r)e.set(t.id,Le(a,t.id));return e},[r,a]),O=T.reduce((e,t)=>e+(D.get(t)??0),0),k=e=>v(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]),A=()=>v(E?[]:w),j=()=>{y.length===0||T.length===0||(l(T,y),v([]),b(``))},F=o.map(e=>({value:e,label:e})),ee=[{key:`select`,width:`w-8`,headerRender:()=>n(p,{checked:E,onChange:A,"aria-label":E?u(`locations.unassignedTable.clearSelection`,`Clear selection`):u(`locations.unassignedTable.selectAllUnassignedDevices`,`Select all unassigned devices`)}),render:e=>n(p,{checked:T.includes(e.id),onChange:()=>k(e.id),"aria-label":u(`locations.unassignedTable.select`,`Select {{name}}`,{name:h(e)})})},{key:`name`,header:u(`locations.unassignedTable.device`,`Device`),sortValue:e=>e.name.toLowerCase(),render:t=>{let r=Me(t,o);return e(`span`,{className:`flex items-center gap-1.5`,children:[n($,{type:t.type,role:t.role}),n(Y,{to:`/devices/${String(t.id)}`,className:`truncate text-xs text-foreground hover:underline`,children:n(V,{device:Z(t),form:`compact`})}),r!==null&&n(G,{variant:`warning`,children:u(`locations.unassignedTable.unknownRoom`,{room:r})})]})}},{key:`type`,header:u(`locations.unassignedTable.type`,`Type`),sortValue:e=>e.type,render:e=>n(`span`,{className:`text-xs text-foreground-muted`,children:e.type})},{key:`status`,header:u(`locations.unassignedTable.status`,`Status`),sortValue:e=>+!!e.online,render:e=>n(Be,{device:e})},{key:`followers`,header:u(`locations.unassignedTable.accessoriesInTowCount`,`Accessories in tow`),align:`right`,sortValue:e=>D.get(e.id)??0,render:e=>n(`span`,{className:`tabular-nums text-xs text-foreground-muted`,children:D.get(e.id)??0})},{key:`assign`,header:u(`locations.unassignedTable.assignTo`,`Assign to`),align:`right`,notSortableReason:`This column is a control, not a value.`,render:e=>n(g,{"aria-label":u(`locations.unassignedTable.locationFor`,`Location for {{name}}`,{name:h(e)}),value:``,disabled:s||o.length===0,onChange:t=>{let n=t.target.value;n.length!==0&&l([e.id],n)},className:`max-w-[11rem]`,options:[{value:``,label:`—`},...F]})}];return e(`section`,{className:`space-y-2`,children:[e(`header`,{className:`flex flex-wrap items-baseline gap-2`,children:[n(`h2`,{className:m,children:u(`locations.unassignedTable.notInARoom`,`Not in a room`)}),n(`p`,{className:C,children:u(`locations.unassignedTable.topLevelDevicesOnlyAccessories`,`Top-level devices only — accessories move with their parent.`)})]}),r.length>0&&n(Se,{state:x.state,facets:x.facets,labels:{searchPlaceholder:u(`locations.filter.searchPlaceholder`),searchLabel:u(`locations.unassigned.searchLabel`),facetsLabel:u(`locations.filter.typesLabel`),clearLabel:u(`locations.filter.clear`)},onSearch:x.setSearch,onToggleFacet:x.toggleFacet,onClear:x.clear}),T.length>0&&e(`div`,{role:`group`,"aria-label":u(`locations.unassignedTable.bulkAssignment`,`Bulk assignment`),className:`flex flex-wrap items-center gap-2 rounded border border-primary/40 bg-primary/5 px-2 py-1.5`,children:[e(`span`,{className:`text-xs text-foreground`,children:[u(`locations.unassignedTable.selected`,{count:T.length}),O>0&&` · ${u(`locations.unassignedTable.accessoriesInTowCount`,{count:O})}`]}),n(g,{"aria-label":u(`locations.unassignedTable.assignSelectedDevicesTo`,`Assign selected devices to`),value:y,onChange:e=>b(e.target.value),className:`w-auto min-w-[10rem]`,options:[{value:``,label:u(`locations.unassignedTable.assignTo2`,`Assign to…`)},...F]}),n(B,{type:`button`,size:`sm`,onClick:j,disabled:s||y.length===0,children:u(`locations.unassignedTable.assign`,`Assign`)}),n(B,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>v([]),children:u(`locations.unassignedTable.clear`,`Clear`)})]}),n(M,{columns:ee,rows:S,rowKey:e=>e.id,minWidthPx:720,emptyMessage:x.active?u(`locations.filter.noMatch`):c})]})}function ut(e){return{id:e.id,parentDeviceId:e.parentDeviceId,location:e.location,type:e.type,stableId:e.stableId??``,...e.primaryChildEntityId===void 0?{}:{primaryChildEntityId:e.primaryChildEntityId},...e.primaryChildPreference===void 0?{}:{primaryChildPreference:e.primaryChildPreference},...e.role!==void 0&&e.role!==null?{role:e.role}:{},name:e.name}}function dt(e,t){let n=t.map(ut),r=[];for(let i of t)i.isCamera&&i.location===e&&r.push({deviceId:i.id,name:i.name,ids:w({selfId:i.id,selfLocation:i.location,candidates:n})});return{entries:r}}var ft=`device-manager:linked-devices`;function pt(e){return{deviceId:e.deviceId,slotRef:ft,value:{slot:`linked-devices`,deviceIds:[...e.ids]}}}a();var mt=`__unassigned__`;function ht(){let{t:r}=J(),a=o(),s=h(),{data:c,isLoading:l}=Ce(),{data:u}=ae(),{data:d}=ne(),{data:f}=oe(),{data:p,isLoading:m}=re({projection:`slim`}),g=()=>{a.invalidateQueries({queryKey:[[`deviceManager`,`listLocations`]]}),a.invalidateQueries({queryKey:[[`deviceManager`,`listAll`]]}),a.invalidateQueries({queryKey:[[`deviceManager`,`listLocationIcons`]]}),a.invalidateQueries({queryKey:[[`deviceManager`,`listLocationDescriptions`]]}),a.invalidateQueries({queryKey:[[`deviceManager`,`listSiteZones`]]})},_=ue({onSuccess:g}),v=te({onSuccess:g}),b=ie({onSuccess:g}),x=ee({onSuccess:g}),S=de({onSuccess:g}),C=k({onSuccess:g}),w=ge({onSuccess:g}),T=_e({onSuccess:g}),D=se({onSuccess:g}),O=be({onSuccess:g}),A=ce(),j=t(()=>(p??[]).map(e=>({id:e.id,name:e.name,location:e.location??null,type:String(e.type),isCamera:e.isCamera,parentDeviceId:e.parentDeviceId,online:e.online,role:e.role??null,stableId:e.stableId,primaryChildEntityId:e.primaryChildEntityId??null,primaryChildPreference:e.primaryChildPreference??null})),[p]),M=c??[],N=t(()=>ze(j,M),[j,M]),[P,F]=Te(),I=P.get(`tab`),L=I===`zones`||I===`camera-links`?I:`locations`,R=P.get(`room`),z=t(()=>Fe(j,M),[j,M]),B=R===mt,V=B?null:R!==null&&N.some(e=>e.name===R)?R:N[0]?.name??null,H=V===null?null:N.find(e=>e.name===V)??null,le=B?mt:V??`__unassigned__`,U=V??N[0]?.name??null,fe=t(()=>N.map(e=>({name:e.name,count:e.members.length})),[N]),pe=e=>{F(t=>{let n=new URLSearchParams(t);return n.set(`room`,e),n},{replace:!0})},W=l||m,G=b.isPending||v.isPending||_.isPending||S.isPending,me=async e=>{await _.mutateAsync({name:e})},he=async(e,t)=>{let n=t.trim();n.length===0||n===e||await x.mutateAsync({from:e,to:n})},ve=async e=>{let t=dt(e,j);if(t.entries.length===0){await s({title:r(`locations.rebuildLinkedDevices`,`Rebuild linked devices`),message:r(`locations.noCameraIsAssignedTo`,`No camera is assigned to “{{room}}”.`,{room:e}),confirmLabel:`OK`});return}let n=t.entries.map(e=>r(`locations.rebuildEntry`,{name:e.name,count:e.ids.length})).join(`
2
- `);if(!await s({title:r(`locations.rebuildLinkedDevices`,`Rebuild linked devices`),message:r(`locations.replaceTheLinkedDeviceList`,`Replace the linked-device list of every camera in “{{room}}” with what the room contains? {{lines}} Anything linked by hand that is not in this room is lost.`,{room:e,lines:n}),confirmLabel:r(`locations.rebuild`,`Rebuild`),variant:`danger`}))return;let i=[];for(let e of t.entries)try{await A.mutateAsync(pt(e))}catch(t){i.push(`• ${e.name}: ${t instanceof Error?t.message:String(t)}`)}g(),i.length>0&&await s({title:r(`locations.rebuildLinkedDevices`,`Rebuild linked devices`),message:r(`locations.notRebuilt`,`Not rebuilt: {{value1}}`,{value1:i.join(`
3
- `)}),confirmLabel:`OK`})},ye=async(e,t)=>{let n=t>0?` ${String(t)} device(s) will become unassigned.`:``;await s({title:r(`locations.deleteLocation`,`Delete location`),message:r(`locations.deleteTheLocation`,`Delete the location “{{name}}”?{{extra}}`,{name:e,extra:n}),confirmLabel:r(`common.delete`,`Delete`),variant:`danger`})&&await v.mutateAsync({name:e,cascade:!0})},xe=async e=>{await s({title:r(`locations.deleteZone`,`Delete zone`),message:r(`locations.deleteTheZoneTheRooms`,`Delete the zone “{{name}}”? The rooms in it are kept.`,{name:e}),confirmLabel:r(`common.delete`,`Delete`),variant:`danger`})&&await T.mutateAsync({name:e})},K=async(e,t)=>{await S.mutateAsync({location:e,icon:t})},Se=async(e,t)=>{await C.mutateAsync({location:e,description:t})},q=f??[],we=async(e,t)=>{await O.mutateAsync({location:e,zone:t})},Ee=(e,t)=>{for(let n of e)b.mutate({deviceId:n,location:t})},[Y,X]=i(null),Oe=t(()=>j.filter(e=>e.parentDeviceId===null).map(e=>({id:e.id,name:e.name,type:e.type,location:e.location})),[j]),ke=n(st,{rooms:fe,...L===`locations`?{unassignedCount:z.length}:{},value:L===`locations`?le:U??``,unassignedValue:mt,onChange:pe}),Z=e(`div`,{className:`flex flex-col gap-3`,"data-testid":`locations-section`,children:[W&&n(`p`,{className:`text-xs text-foreground-subtle`,children:r(`locations.loadingLocationsAndDevices`,`Loading locations and devices…`)}),ke,B||H===null?n(lt,{rows:z,fleet:j,locations:M,busy:G,emptyMessage:W?r(`common.loading`,`Loading…`):r(`locations.everyTopLevelDeviceHas`,`Every top-level device has a room.`),onAssign:Ee}):n(et,{name:H.name,members:H.members,devices:j,busy:G,icon:Ze(u,E(H.name)),onPickIcon:e=>K(H.name,e),description:Ke(d,E(H.name)),onSaveDescription:e=>Se(H.name,e),zones:q,zoneKey:Ye(q,E(H.name)),onChangeZone:e=>we(H.name,e),onRename:e=>he(H.name,e),onDelete:()=>ye(H.name,Ae(j,H.name).length),onRebuildLinks:()=>ve(H.name),onAddDevices:()=>X(H.name)},H.name),M.length===0&&!W&&n(`p`,{className:`text-xs text-foreground-subtle`,children:r(`locations.noLocationsYetAddFrontDoor`,`No locations yet. Add Front door, Hall, Kitchen…`)}),n(Ve,{open:Y!==null,title:r(`locations.room.addDialogTitle`,{room:Y??``}),items:Oe,listState:m?`pending`:`answered`,lockedIds:Y===null?[]:(N.find(e=>e.name===Y)?.members??[]).map(e=>e.id),lockedNote:r(`locations.room.alreadyHere`),suggestions:{heading:r(`locations.room.suggestedUnassigned`),ids:z.map(e=>e.id)},busy:b.isPending,onConfirm:e=>{Y!==null&&Ee(e,Y),X(null)},onClose:()=>X(null)})]}),Q=e(`div`,{className:`flex flex-col gap-3`,"data-testid":`camera-links-tab`,children:[ke,n(He,{room:U,cameras:U===null?[]:Ae(j,U).filter(e=>e.isCamera),fleet:j})]});return n(De,{icon:y,title:r(`locations.locations`,`Locations`),subtitle:r(`locations.roomsAndAreasOfThe`,`Rooms and areas of the site. Assign any device here — storage disks are under Data → Storage.`),defaultSection:`locations`,sectionsLabel:`Locations sections`,actions:L===`zones`?n(at,{busy:w.isPending,onCreate:e=>w.mutateAsync({name:e})}):n(it,{busy:_.isPending,onCreate:me}),sections:[{id:`locations`,label:r(`locations.locations`,`Locations`),content:Z},{id:`camera-links`,label:r(`locations.cameraLinks`,`Camera links`),content:Q},{id:`zones`,label:r(`locations.zones`,`Zones`),content:n(rt,{zones:q,busy:G,onRename:(e,t)=>D.mutateAsync({from:e,to:t}),onDelete:xe,onPickIcon:(e,t)=>w.mutateAsync({name:e,icon:t})})}]})}export{ht as LocationsPage};
@@ -1 +0,0 @@
1
- import{C as e,K as t,R as n,S as r,V as i,Y as a,et as o}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{Bn as s,Fr as c,Ha as l,Ua as u,aa as d,dt as f,ea as p,pi as m,pn as h}from"./player-overlays-VrMHBBfa.js";import{Xs as g,js as _}from"./client-CBrsD14Q.js";import{t as v}from"./layers-BH9u1mrE.js";import{t as y}from"./timer-reset-5221y6Jb.js";import{Cp as b,Li as x,Or as S,Qf as C,Ri as w,Wf as T,la as E,lf as D,lr as O,of as k,rf as A}from"./src-bJ4Hy4Cl.js";import{t as j}from"./useTranslation-BJr-n0es.js";import{b as M,o as N,s as P}from"./index-1bBrNxAK.js";import{t as F}from"./AdminSectionedPage-vnoSnjIu.js";import{t as I}from"./AdminPage-bLxyruUe.js";import{t as L}from"./InstancesTable-Cn1INVUs.js";function R(){let{t:e}=j();return r(L,{functionCap:`log-destination`,icon:s,title:e(`system.logging.destinations`,`Destinations`),subtitle:e(`system.logging.everyRegisteredLogDestinationEntries`,`Every registered log destination. Entries are fanned to all enabled destinations at once — enabling one does not disable another.`),emptyTitle:e(`system.logging.noLogDestinationsRegistered`,`No log destinations registered`),emptyDescription:e(`system.logging.thisShouldNotHappenThe`,`This should not happen — the console and rotated-file destinations are builtins. If the list is empty, the node is still booting.`),addLabel:e(`system.logging.addDestination`,`Add destination`),install:{capability:`log-destination`,label:e(`system.logging.installDestination`,`Install a destination`)}})}o();var z=[12e4,3e5,6e5,18e5],B={"request-census":`Counts every tRPC call by TRANSPORT PLANE — http, ws, mesh — and by procedure, caller, address and user-agent. Subscriptions are counted apart from calls, so a long-lived stream cannot pass for a storm. Arm it, then restart: the deadline is persisted, so the window is still running when clients reconnect.`};function V(){let{t}=j(),n=k({},{refetchInterval:5e3}),i=D(),[o,s]=a(null),u=(e,t)=>{s(e),i.mutate({patch:{diagnostics:[{id:e,armMs:t}]}},{onSettled:()=>{s(null),n.refetch()}})},d=n.data?.activeWindows??[],f=(n.data?.channels??[]).filter(e=>e.kind!==`debug`),p=n.data?.activeChannels??[],m=(e,t,r)=>{s(e),i.mutate({patch:{channels:[{channel:e,armMs:t,deviceIds:r}]}},{onSettled:()=>{s(null),n.refetch()}})};return e(I,{embedded:!0,icon:l,title:t(`logging.diagnostics.title`,`Diagnostics`),subtitle:t(`logging.diagnostics.subtitle`,`Diagnostics are armed for a window, never switched on. Each carries a deadline and expires by itself — one left running is an incident of its own.`),children:[n.isLoading?e(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[r(c,{className:`h-3.5 w-3.5 animate-spin`}),t(`common.loading`,`Loading…`)]}):r(`div`,{className:`rounded-lg border border-border bg-surface divide-y divide-border`,children:d.map(e=>r(U,{window:e,busy:o===e.id,onArm:t=>u(e.id,t)},e.id))}),r(`h3`,{className:`mt-6 text-sm font-medium text-foreground`,children:t(`logging.diagnostics.channels`,`Component channels`)}),r(`p`,{className:`mb-2 max-w-3xl text-[11px] text-foreground-subtle`,children:t(`logging.diagnostics.channelsSubtitle`,`Declared by the addons that own them — this list is not maintained by hand. Arming a channel opens a window with a deadline; it closes by itself.`)}),f.length===0?r(`p`,{className:`text-[11px] text-foreground-subtle`,children:t(`logging.diagnostics.noChannels`,`No addon on this cluster declares a log channel, or none could be reached right now.`)}):r(`div`,{className:`rounded-lg border border-border bg-surface divide-y divide-border`,children:f.map(e=>r(H,{channel:e,state:p.find(t=>t.channel===e.name),busy:o===e.name,onArm:(t,n)=>m(e.name,t,n)},e.name))})]})}function H({channel:t,state:n,busy:i,onArm:o}){let{t:s}=j(),[c,l]=a(``),u=n?.armed===!0,f=()=>{let e=c.split(/[\s,+]+/).filter(e=>/^\d+$/.test(e)).map(e=>Number(e));return e.length>0?e:null};return e(`div`,{className:`flex flex-col gap-2 p-3 lg:flex-row lg:items-center lg:justify-between`,children:[e(`div`,{className:`min-w-0`,children:[e(`div`,{className:`flex flex-wrap items-center gap-2`,children:[r(`span`,{className:`text-sm font-medium text-foreground`,children:t.name}),u?e(`span`,{className:`inline-flex items-center gap-1 rounded bg-warning/10 px-1.5 py-0.5 text-[10px] font-semibold text-warning`,children:[r(y,{className:`h-3 w-3`}),s(`logging.diagnostics.expiresIn`,`expires in {{left}}`,{left:W(n?.remainingMs??0)})]}):r(`span`,{className:`rounded border border-border px-1.5 py-0.5 text-[10px] text-foreground-subtle`,children:s(`logging.diagnostics.disarmed`,`disarmed`)}),u&&n?.deviceIds!==null&&n?.deviceIds!==void 0&&e(`span`,{className:`inline-flex items-center gap-1 rounded bg-primary/10 px-1.5 py-0.5 text-[10px] font-semibold text-primary`,children:[r(d,{className:`h-3 w-3`}),n.deviceIds.join(`, `)]}),!t.perDevice&&r(`span`,{className:`rounded border border-border px-1.5 py-0.5 text-[10px] text-foreground-subtle`,children:s(`logging.diagnostics.notPerCamera`,`not filterable per camera`)})]}),r(`p`,{className:`mt-0.5 max-w-2xl text-[11px] text-foreground-subtle`,children:t.description})]}),e(`div`,{className:`flex shrink-0 flex-wrap items-center gap-1`,children:[t.perDevice&&r(C,{type:`text`,inputMode:`numeric`,value:c,disabled:i,onChange:e=>l(e.target.value),placeholder:s(`logging.diagnostics.camerasPlaceholder`,`all cameras`),className:`w-28 rounded border border-border bg-surface px-2 py-1 text-[11px] text-foreground`}),z.map(e=>r(T,{variant:`unstyled`,type:`button`,disabled:i,onClick:()=>o(e,f()),className:`rounded border border-border px-2 py-1 text-[11px] text-foreground-subtle hover:text-foreground disabled:opacity-50`,children:W(e)},e)),r(T,{variant:`unstyled`,type:`button`,disabled:i||!u,onClick:()=>o(0,null),className:`rounded bg-primary px-2 py-1 text-[11px] font-medium text-primary-foreground disabled:opacity-40`,children:s(`logging.diagnostics.disarm`,`Disarm`)})]})]})}function U({window:t,busy:n,onArm:i}){let{t:a}=j();return e(`div`,{className:`flex flex-col gap-2 p-3 lg:flex-row lg:items-center lg:justify-between`,children:[e(`div`,{className:`min-w-0`,children:[e(`div`,{className:`flex items-center gap-2`,children:[r(`span`,{className:`text-sm font-medium text-foreground`,children:t.id}),t.armed?e(`span`,{className:`inline-flex items-center gap-1 rounded bg-warning/10 px-1.5 py-0.5 text-[10px] font-semibold text-warning`,children:[r(y,{className:`h-3 w-3`}),a(`logging.diagnostics.expiresIn`,`expires in {{left}}`,{left:W(t.remainingMs)})]}):r(`span`,{className:`rounded border border-border px-1.5 py-0.5 text-[10px] text-foreground-subtle`,children:a(`logging.diagnostics.disarmed`,`disarmed`)}),t.armed&&!t.persisted&&r(`span`,{className:`text-[10px] text-warning`,children:a(`logging.diagnostics.notPersisted`,`not persisted — will not survive a restart`)})]}),r(`p`,{className:`mt-0.5 max-w-2xl text-[11px] text-foreground-subtle`,children:B[t.id]??``})]}),e(`div`,{className:`flex shrink-0 flex-wrap items-center gap-1`,children:[z.map(e=>r(T,{variant:`unstyled`,type:`button`,disabled:n,onClick:()=>i(e),className:`rounded border border-border px-2 py-1 text-[11px] text-foreground-subtle hover:text-foreground disabled:opacity-50`,children:W(e)},e)),r(T,{variant:`unstyled`,type:`button`,disabled:n||!t.armed,onClick:()=>i(0),className:`rounded bg-primary px-2 py-1 text-[11px] font-medium text-primary-foreground disabled:opacity-40`,children:a(`logging.diagnostics.disarm`,`Disarm`)})]})]})}function W(e){let t=Math.max(0,Math.round(e/1e3)),n=Math.floor(t/60),r=t%60;return n===0?`${r}s`:r===0?`${n}m`:`${n}m ${r}s`}o();var G=[`debug`,`info`,`warn`,`error`],K=``,q=``;function J(){let{t:n}=j(),[i,o]=a(K),[s,l]=a(q),{nodes:u}=b(),d=t(()=>u.map(e=>({id:e.id,label:e.name||e.id})),[u]),p=k({...i===K?{}:{scopeNodeId:i},...s===q?{}:{scopeComponent:s}},{refetchInterval:15e3}),m=D(),h=p.data,g=m.isPending||p.isFetching,_=(h?.channels??[]).filter(e=>e.kind!==`debug`),y=(e,t)=>{m.mutate({...e.nodeId===null?{}:{scopeNodeId:e.nodeId},...e.component===null?{}:{scopeComponent:e.component},patch:{level:t}},{onSuccess:()=>void p.refetch()})};return r(I,{embedded:!0,icon:v,title:n(`logging.levels.title`,`Levels`),subtitle:n(`logging.levels.subtitle`,`Cluster → node, most specific wins. The floor gates what reaches the log destinations; the in-memory viewer keeps every line either way.`),actions:e(`div`,{className:`flex flex-wrap items-center gap-3`,children:[e(`label`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[n(`logging.levels.scope`,`Scope`),e(f,{wrapperClassName:`inline-block w-auto`,value:i,disabled:s!==q,onChange:e=>o(e.target.value),children:[r(`option`,{value:K,children:n(`logging.levels.cluster`,`Cluster`)}),d.map(e=>r(`option`,{value:e.id,children:e.label},e.id))]})]}),e(`label`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[n(`logging.levels.component`,`Component`),e(f,{wrapperClassName:`inline-block w-auto`,value:s,onChange:e=>l(e.target.value),children:[r(`option`,{value:q,children:n(`logging.levels.noComponent`,`None`)}),_.map(e=>r(`option`,{value:e.name,children:e.name},e.name))]})]})]}),children:p.isLoading||h===void 0?e(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[r(c,{className:`h-3.5 w-3.5 animate-spin`}),n(`common.loading`,`Loading…`)]}):e(`div`,{className:`space-y-3`,children:[r(X,{level:h.effective.level,source:h.effective.levelSource,persisted:h.persisted}),r(`div`,{className:`rounded-lg border border-border bg-surface divide-y divide-border`,children:h.explicit.layers.map(e=>r(Z,{layer:e,inForce:e.scope===h.effective.levelSource,busy:g,onSet:t=>y(e,t),onClear:()=>y(e,null)},`${e.scope}:${e.nodeId??e.component??`cluster`}`))}),s!==q&&r(`p`,{className:`text-[11px] text-foreground-subtle`,children:_.find(e=>e.name===s)?.description??``}),r(`p`,{className:`text-[11px] text-foreground-subtle`,children:n(`logging.levels.componentNote`,`A component is a log channel an addon declared. Its level is cluster-wide and beats both the node and the cluster layer.`)}),r(Y,{days:h.opsLogRetentionDays,busy:g,onSet:e=>m.mutate({patch:{opsLogRetentionDays:e}},{onSuccess:()=>void p.refetch()})})]})})}function Y({days:t,busy:n,onSet:i}){let{t:a}=j();return e(`div`,{className:`rounded-lg border border-border bg-surface p-3 space-y-1`,children:[e(`label`,{className:`flex items-center justify-between gap-3`,children:[r(`span`,{className:`text-xs font-medium`,children:a(`logging.levels.opsLogRetention`,`Retention audit trail`)}),e(`span`,{className:`flex items-center gap-1.5`,children:[r(C,{type:`number`,min:0,max:3650,step:1,defaultValue:t,disabled:n,onBlur:e=>{let n=Number.parseInt(e.target.value,10);Number.isFinite(n)&&n!==t&&i(n)},className:`w-20 rounded border border-border bg-surface px-2 py-1 text-xs`}),r(`span`,{className:`text-[11px] text-foreground-subtle`,children:a(`common.days`,`days`)})]})]}),r(`p`,{className:`text-[11px] text-foreground-subtle`,children:a(`logging.levels.opsLogRetentionNote`,`How long the record of what retention deleted is kept. Cluster-wide, and deliberately longer than any camera window — it is the history of the sweep, not of the camera, and it is what makes a storage leak explainable after the fact. 0 keeps it forever.`)})]})}function X({level:t,source:n,persisted:i}){let{t:a}=j();return e(`div`,{className:`rounded-lg border border-border bg-surface p-3`,children:[e(`div`,{className:`flex items-center gap-2`,children:[r(`span`,{className:`text-xs text-foreground-subtle`,children:a(`logging.levels.effective`,`In force here`)}),r(`span`,{className:`rounded bg-primary/10 px-2 py-0.5 text-xs font-semibold text-primary`,children:t}),r(`span`,{className:`text-[11px] text-foreground-subtle`,children:n==="default"?a(`logging.levels.fromDefault`,`nothing is set anywhere — this is the default`):a(`logging.levels.fromLayer`,`decided by the {{source}} layer`,{source:n})})]}),!i&&r(`p`,{className:`mt-1 text-[11px] text-warning`,children:a(`logging.levels.notPersisted`,`The settings store could not be read or written — what you see is live, but it would not survive a restart.`)})]})}function Z({layer:t,inForce:n,busy:i,onSet:a,onClear:o}){let{t:s}=j();return e(`div`,{className:`flex flex-col gap-2 p-3 sm:flex-row sm:items-center sm:justify-between`,children:[e(`div`,{className:`min-w-0`,children:[e(`div`,{className:`flex items-center gap-2`,children:[r(`span`,{className:`text-sm font-medium text-foreground`,children:t.scope===`cluster`?s(`logging.levels.cluster`,`Cluster`):t.scope===`component`?t.component??``:t.nodeId??``}),n&&e(`span`,{className:`inline-flex items-center gap-1 rounded bg-primary/10 px-1.5 py-0.5 text-[10px] font-semibold text-primary`,children:[r(p,{className:`h-3 w-3`}),s(`logging.levels.inForce`,`in force`)]})]}),r(`p`,{className:`mt-0.5 text-[11px] text-foreground-subtle`,children:t.level===null?s(`logging.levels.inherits`,`inherits — nothing set at this layer`):s(`logging.levels.setHere`,`set here: {{level}}`,{level:t.level})})]}),e(`div`,{className:`flex shrink-0 items-center gap-1`,children:[G.map(e=>r(T,{variant:`unstyled`,type:`button`,disabled:i,onClick:()=>a(e),className:`rounded px-2 py-1 text-[11px] font-medium transition-colors disabled:opacity-50 ${t.level===e?`bg-primary text-primary-foreground`:`border border-border text-foreground-subtle hover:text-foreground`}`,children:e},e)),r(T,{variant:`unstyled`,type:`button`,disabled:i||t.level===null,onClick:o,className:`rounded border border-border px-2 py-1 text-[11px] text-foreground-subtle hover:text-foreground disabled:opacity-40`,children:s(`logging.levels.clear`,`Clear`)})]})]})}function Q(e){let t=Math.max(0,Math.round(e/1e3)),n=Math.floor(t/60),r=t%60;return n===0?`${r}s`:`${n}m ${String(r).padStart(2,`0`)}s`}function $(e,t){return{windowMs:Math.max(0,e.untilMs-t),capMs:Math.max(0,e.capAtMs-t)}}function ee(e,t){let n=new Set(e.map(e=>e.channel));return t.filter(e=>n.has(e))}o();var te=[_.Camera],ne=8,re=1e3,ie=15e3;function ae(){let{t:o}=j(),s=k({},{refetchInterval:15e3}),l=A(),[d,f]=a([]),[p,_]=a([]),[v,b]=a([]),[C,D]=a(()=>Date.now()),[M,N]=a([]),P=t(()=>(s.data?.channels??[]).filter(e=>e.kind===`debug`),[s.data]),F=n((e,t,n)=>{l.mutate({action:e,channels:t,deviceIds:n},{onSuccess:e=>{f(e.watches),N(e.lapsed)}})},[]);i(()=>{let e=setInterval(()=>D(Date.now()),re);return()=>clearInterval(e)},[]),i(()=>{F(`list`,[],[]);let e=setInterval(()=>F(`list`,[],[]),ie);return()=>clearInterval(e)},[F]);let L=ee(d,p).join(`|`);i(()=>{if(L===``)return;let e=setInterval(()=>F(`rearm`,L.split(`|`),[]),g);return()=>clearInterval(e)},[L,F]);let R=p.length>0&&v.length>0&&!l.isPending,z=[...new Set(d.flatMap(e=>e.deviceIds))],B=(e,t)=>_(n=>t?[...n,e]:n.filter(t=>t!==e));return e(I,{embedded:!0,icon:m,title:o(`logging.watch.title`,`Watch`),subtitle:o(`logging.watch.subtitle`,`Switch a debug channel on for chosen devices and read it live. A watch lasts 10 minutes, is renewed while this page stays open, and ends by itself after 60 minutes at most.`),children:[r(S,{headingId:`log-watch-setup`,title:o(`logging.watch.setup`,`Channels and devices`),children:s.isLoading?e(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[r(c,{className:`h-3.5 w-3.5 animate-spin`}),o(`common.loading`,`Loading…`)]}):P.length===0?r(`p`,{className:`text-[11px] text-foreground-subtle`,children:o(`logging.watch.noChannels`,`No addon on this cluster offers a debug channel, or none could be reached right now.`)}):e(`div`,{className:`space-y-3 p-3`,children:[r(`div`,{className:`space-y-2`,children:P.map(t=>e(`label`,{className:`flex items-start gap-2`,children:[r(u,{checked:p.includes(t.name),onChange:e=>B(t.name,e.target.checked)}),e(`span`,{className:`min-w-0`,children:[r(`span`,{className:`text-sm font-medium text-foreground`,children:t.name}),r(`span`,{className:`block text-[11px] text-foreground-subtle`,children:t.description})]})]},t.name))}),e(`div`,{className:`flex flex-col gap-1`,children:[r(`span`,{className:`text-xs font-medium text-foreground`,children:o(`logging.watch.devices`,`Devices`)}),r(E,{multiple:!0,pick:`device`,noun:`camera`,fixedTypes:te,maxItems:ne,recentKey:`log-watch-devices`,testId:`log-watch-devices`,value:w(v),onChange:e=>b(x(e))})]}),e(`div`,{className:`flex flex-wrap gap-2`,children:[r(T,{type:`button`,disabled:!R,onClick:()=>F(`start`,p,v),children:o(`logging.watch.start`,`Start watching`)}),e(T,{type:`button`,variant:`secondary`,disabled:d.length===0||l.isPending,onClick:()=>F(`stop`,d.map(e=>e.channel),[]),children:[r(h,{className:`mr-1 h-3.5 w-3.5`}),o(`logging.watch.stop`,`Stop`)]})]}),l.isError&&r(`p`,{className:`text-[11px] text-destructive`,children:l.error.message}),M.length>0&&r(`p`,{className:`text-[11px] text-warning`,children:o(`logging.watch.lapsed`,`Already ended, not renewed: {{names}}. Start again to continue.`,{names:M.join(`, `)})})]})}),d.length>0&&e(S,{headingId:`log-watch-live`,title:o(`logging.watch.live`,`Live`),children:[r(`div`,{className:`divide-y divide-border`,children:d.map(t=>{let n=$(t,C);return e(`div`,{className:`flex flex-wrap items-center gap-2 p-3`,children:[r(`span`,{className:`text-sm font-medium text-foreground`,children:t.channel}),e(`span`,{className:`inline-flex items-center gap-1 rounded bg-warning/10 px-1.5 py-0.5 text-[10px] font-semibold text-warning`,children:[r(y,{className:`h-3 w-3`}),o(`logging.watch.endsIn`,`ends in {{left}}`,{left:Q(n.windowMs)})]}),r(`span`,{className:`text-[11px] text-foreground-subtle`,children:o(`logging.watch.capIn`,`hard stop in {{left}}`,{left:Q(n.capMs)})}),e(`span`,{className:`text-[11px] text-foreground-subtle`,children:[`#`,t.deviceIds.join(`, #`)]})]},t.channel)})}),z.map(e=>r(`div`,{className:`border-t border-border`,children:r(O,{deviceId:e,limit:200,maxHeight:`max-h-80`,showScope:!0,showFilters:!1})},e))]})]})}function oe(){return r(I,{embedded:!0,children:r(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:r(O,{limit:500,maxHeight:`max-h-[calc(100vh-310px)]`,showScope:!0,showFilters:!0,showOriginFilter:!0})})})}function se(){let{t:e}=j(),t=M(`/system/logs`,{t:e,isAdmin:!0})??{icon:s,title:e(`system.logs`,`Logs`)};return r(F,{icon:t.icon,title:t.title,defaultSection:`viewer`,sectionsLabel:`${t.title} sections`,sections:[{id:`viewer`,label:e(`admin.system.logs.viewer`,`Viewer`),content:r(oe,{})},{id:P.logging.tab,label:e(`admin.system.logs.destinations`,`Destinations`),content:r(R,{}),ownedParams:N},{id:`levels`,label:e(`admin.system.logs.levels`,`Levels`),content:r(J,{})},{id:`watch`,label:e(`admin.system.logs.watch`,`Watch`),content:r(ae,{})},{id:`diagnostics`,label:e(`admin.system.logs.diagnostics`,`Diagnostics`),content:r(V,{})}]})}export{se as LogsPage};
@@ -1 +0,0 @@
1
- import{C as e,K as t,R as n,S as r,V as i,Y as a,et as o,o as s,x as c}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{Fr as l,Ha as u,Li as d,Pa as f,Ua as p,Xt as m,Y as h,Zr as g,aa as _,ct as v,di as y,dt as b,en as x,vt as S,wi as C,wt as w,yi as T}from"./player-overlays-VrMHBBfa.js";import{Ac as E}from"./client-CBrsD14Q.js";import{t as D}from"./scissors-Bbq6WhOK.js";import{$d as O,Ai as k,Ar as A,Ba as j,Cp as M,Ep as N,Eu as P,Fi as F,Gd as ee,Gi as I,Jd as te,Kd as ne,Ni as re,Ns as L,Pi as ie,Qd as ae,Qf as R,Ra as z,Sp as oe,Su as se,Ud as B,Ul as ce,Vl as le,Wd as ue,Wf as V,Xd as de,Yd as fe,Yl as pe,Zd as me,_d as he,ef as ge,fd as _e,gd as ve,hd as ye,ji as be,jr as xe,ki as Se,md as Ce,pd as we,qd as Te,ql as Ee,ta as De,vd as Oe,yd as ke}from"./src-bJ4Hy4Cl.js";import{t as H}from"./i18n-BFxrpjSx.js";import{t as U}from"./useTranslation-BJr-n0es.js";import{E as Ae,b as je,li as Me}from"./index-1bBrNxAK.js";import{t as Ne}from"./AdminSectionedPage-vnoSnjIu.js";import{n as Pe}from"./authed-media-CfvJyG-Y.js";import{t as W}from"./format-size-DIxKXxtj.js";import{n as Fe,r as Ie,t as Le}from"./StorageLocationsTable-BU2R2YDl.js";o();var Re=[{value:`all`,labelKey:`common.all`},{value:`recording`,labelKey:`recordings.activitySection.domainRecordings`},{value:`events`,labelKey:`common.events`}],ze={recording:`bg-primary/10 text-primary`,events:`bg-violet-500/10 text-violet-400`},Be={columnKey:`at`,dir:`desc`};function Ve(e){return new Date(e).toLocaleString()}function He(){let{t:n,i18n:i}=U(),[o,s]=a(`all`),{data:d,isLoading:f,isError:p}=Ce({},{refetchOnWindowFocus:!1}),{data:h,isLoading:g,isError:_}=Ee({},{refetchOnWindowFocus:!1}),{data:v}=L({isCamera:!0,projection:`slim`}),y=t(()=>{let e=new Map;for(let t of v??[])e.set(t.id,t.name);return e},[v]),b=t(()=>{let e=[...d??[],...h??[]];return(o===`all`?e:e.filter(e=>e.domain===o)).toSorted((e,t)=>t.at-e.at)},[d,h,o]),x=t(()=>{let e=[];return p&&o!==`events`&&e.push(n(`recordings.activitySection.domainRecordings`)),_&&o!==`recording`&&e.push(n(`common.events`)),e},[p,_,o,n]),S=t(()=>new Intl.ListFormat(i.language,{type:`conjunction`}).format(x),[x,i.language]),C=t(()=>[{key:`at`,header:n(`recordings.activitySection.when`,`When`),nowrap:!0,sortValue:e=>e.at,render:e=>r(`span`,{className:`text-foreground-subtle tabular-nums`,children:Ve(e.at)})},{key:`domain`,header:n(`recordings.activitySection.domain`,`Domain`),sortValue:e=>e.domain,render:e=>r(`span`,{className:`inline-flex rounded px-1.5 py-0.5 text-[10px] font-medium ${ze[e.domain]}`,children:e.domain})},{key:`op`,header:n(`recordings.activitySection.operation`,`Operation`),sortValue:e=>e.op,render:e=>r(`span`,{className:`text-foreground`,children:e.op})},{key:`reason`,header:n(`recordings.activitySection.reason`,`Reason`),sortValue:e=>e.reason,render:e=>r(`span`,{className:`text-foreground-subtle`,children:e.reason})},{key:`device`,header:n(`recordings.activitySection.camera`,`Camera`),sortValue:e=>e.deviceId===null?`cluster`:y.get(e.deviceId)??`#${String(e.deviceId)}`,render:e=>e.deviceId===null?r(`span`,{className:`text-foreground-subtle`,children:n(`common.cluster`)}):r(`span`,{className:`text-foreground`,children:y.get(e.deviceId)??`#${String(e.deviceId)}`})},{key:`items`,header:n(`recordings.activitySection.items`,`Items`),align:`right`,nowrap:!0,sortValue:e=>e.itemsAffected,render:e=>r(`span`,{className:`tabular-nums`,children:e.itemsAffected.toLocaleString()})},{key:`bytes`,header:n(`recordings.activitySection.reclaimed`,`Reclaimed`),align:`right`,nowrap:!0,sortValue:e=>e.bytesReclaimed,render:e=>r(`span`,{className:`tabular-nums`,children:e.bytesReclaimed>0?W(e.bytesReclaimed):`—`})}],[y,n]),w=f||g;return e(`div`,{className:`flex flex-col gap-4`,children:[r(`div`,{className:`flex items-center gap-1`,children:Re.map(e=>r(V,{variant:`unstyled`,onClick:()=>s(e.value),className:`rounded px-2 py-1 text-xs font-medium ${o===e.value?`bg-primary/10 text-primary`:`text-foreground-subtle hover:bg-muted`}`,children:n(e.labelKey)},e.value))}),w&&b.length===0?e(`div`,{className:`flex items-center gap-2 py-8 text-xs text-foreground-subtle`,children:[r(l,{className:`h-4 w-4 animate-spin`}),n(`recordings.activitySection.loadingActivity`,`Loading activity…`)]}):b.length===0?x.length>0?r(I,{icon:m,title:n(`recordings.activitySection.activityCouldNotBeRead`,`Activity could not be read`),description:n(`recordings.activitySection.theOpsLogDidNot`,`The {{value1}} ops log did not answer. This is not "nothing happened" — retry, or check the node that owns it.`,{value1:S})}):r(I,{icon:u,title:n(`recordings.activitySection.noActivityYet`,`No activity yet`),description:n(`recordings.activitySection.pruneDeleteAndRescanOperations`,`Prune, delete and rescan operations across recordings and events show up here.`)}):e(c,{children:[x.length>0&&e(`p`,{className:`flex items-center gap-1.5 text-[11px] text-amber-500`,children:[r(m,{className:`h-3 w-3 shrink-0`}),n(`recordings.activitySection.domainsMissing`,{count:x.length,names:S})]}),r(A,{columns:C,rows:b,rowKey:e=>e.id,minWidthPx:720,maxBodyHeight:xe,defaultSort:Be})]})]})}o();function Ue(){let{t:n}=U(),i=L({isCamera:!0,projection:`slim`}),o=t(()=>(i.data??[]).toSorted((e,t)=>e.name.localeCompare(t.name)),[i.data]),[s,c]=a(null),l=s??o[0]?.id??null;return!i.isLoading&&o.length===0?r(I,{icon:_,title:n(`recordings.cameraRecordingSettingsSection.noCameras`,`No cameras`),description:n(`recordings.cameraRecordingSettingsSection.addACameraFirst`,`Add a camera first.`)}):e(`div`,{className:`space-y-3`,children:[e(`div`,{children:[r(`h2`,{className:`text-sm font-semibold text-foreground`,children:n(`recordings.cameraRecordingSettingsSection.perCameraRecordingRetention`,`Per-camera recording & retention`)}),r(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:n(`recordings.cameraRecordingSettingsSection.recordingModeScheduleBandsAnd`,`Recording mode, schedule bands and the retention policy for one camera — the same controls as the camera's own Recording tab. Retention is one policy over footage and analytics; per-camera event deletion lives on the Events tab.`)})]}),e(`div`,{className:`flex items-center gap-2`,children:[r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:n(`recordings.cameraRecordingSettingsSection.camera`,`Camera`)}),r(b,{wrapperClassName:`inline-block w-auto`,value:l??``,onChange:e=>c(Number(e.target.value)),children:o.map(e=>r(`option`,{value:e.id,children:e.name},e.id))})]}),l!==null&&r(De,{deviceId:l,children:r(Ae,{deviceId:l,sectionFilter:e=>e.location===`top-tab`&&e.tab===`recording`})},l)]})}function G({types:e}){return r(Le,{kinds:e})}o();var K=`pipeline-analytics`,q=`pipeline-analytics`;function We(e){for(let t of e?.sections??[])for(let e of t.fields??[])if(e.key===`postProcessingNodeId`&&typeof e.value==`string`)return e.value;return`hub`}function Ge(){let{t:n}=U(),i=s(),{nodes:a}=M(),{data:o,isLoading:c}=z({addonId:K,cap:q,scope:`cluster`}),u=We(o),d=j({onSuccess:()=>{i.invalidateQueries({queryKey:[[`addonSettings`,`getScopedSettings`]]})}}),f=t(()=>{let e=a.filter(e=>e.isOnline).map(e=>e.id);return[...new Set([`hub`,u,...e])].filter(Boolean)},[a,u]);return e(`div`,{className:`flex flex-col gap-6`,children:[e(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[r(`h3`,{className:`text-sm font-semibold text-foreground`,children:n(`pipeline.clusterEventsTab.postProcessingNode`,`Post-processing node`)}),r(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:n(`pipeline.clusterEventsTab.theSingleNodeThatRuns`,`The single node that runs detection post-processing (events, media, audio & motion). Every other node stays inert — no multi-node balancing. Takes effect on addon restart.`)}),e(`div`,{className:`mt-3 flex items-center gap-2`,children:[c?r(l,{className:`h-4 w-4 animate-spin text-foreground-subtle`}):r(b,{wrapperClassName:`inline-block w-auto`,value:u,onChange:e=>{e.target.value!==u&&d.mutate({addonId:K,cap:q,scope:`cluster`,patch:{postProcessingNodeId:e.target.value}})},disabled:d.isPending,children:f.map(e=>r(`option`,{value:e,children:e===`hub`?n(`pipeline.clusterEventsTab.hubDefault`,`hub (default)`):e},e))}),d.isPending&&r(l,{className:`h-4 w-4 animate-spin text-primary`})]})]}),e(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[r(`h3`,{className:`mb-1 text-sm font-semibold text-foreground`,children:n(`pipeline.clusterEventsTab.eventsFolder`,`Events folder`)}),r(`p`,{className:`mb-3 text-[11px] text-foreground-subtle`,children:n(`pipeline.clusterEventsTab.whereEventCropsFullFrames`,`Where event crops / full frames are stored. A single folder — no collection / equal-splitting.`)}),r(G,{types:[`eventMedia`]})]})]})}o();var Ke=[[`pipelineAnalytics`]],qe=1440*60*1e3;function Je(e,t){return t.get(e)??H.t(`recordings.eventsManagementSection.removedCamera`,{id:String(e)})}var Ye=[{days:1},{days:7},{days:30},{days:90}];function Xe(){let{t:i}=U(),o=s(),c=v(),[u,d]=a(30),[f,p]=a(null),{data:m,isLoading:g}=ce({},{refetchOnWindowFocus:!1}),{data:_}=L({isCamera:!0,projection:`slim`}),y=t(()=>{let e=new Map;for(let t of _??[])e.set(t.id,t.name);return e},[_]),S=n(()=>{o.invalidateQueries({queryKey:Ke})},[o]),w=pe({onSuccess:S}),T=le(),E=n(async()=>{await c({title:i(`recordings.eventsManagementSection.pruneTitle`,{count:u}),message:i(`recordings.eventsManagementSection.permanentlyDeletesEveryEventMotion`,`Permanently deletes every event (motion / object / audio) older than the cutoff across all cameras, and their media. This cannot be undone.`),confirmLabel:i(`recordings.eventsManagementSection.pruneEvents`,`Prune events`),variant:`danger`})&&w.mutate({olderThanMs:Date.now()-u*qe,reason:`retention`})},[c,w,u,i]),O=n(async e=>{let t=Je(e.deviceId,y);if(await c({title:i(`recordings.eventsManagementSection.deleteAllEventsFor`,`Delete all events for {{label}}?`,{label:t}),message:i(`recordings.eventsManagementSection.deleteRowsMessage`,{count:e.rows,size:W(e.bytes)}),confirmLabel:i(`recordings.eventsManagementSection.deleteEvents`,`Delete events`),variant:`danger`})){p(null);try{let n=await T.mutateAsync({deviceId:e.deviceId});S();let r=n.motion+n.object+n.audio;if(r===0&&e.bytes>0){p(`0 events deleted for ${t}. Media still listed (${W(e.bytes)}) — those blobs are not event rows; use Management → Count leftovers or Disk reconcile.`);return}p(`Deleted ${String(r)} event${r===1?``:`s`} for ${t}.`)}catch(e){p(e instanceof Error?e.message:String(e))}}},[c,T,y,S,i]),k=t(()=>[{key:`camera`,header:i(`recordings.eventsManagementSection.camera`,`Camera`),render:e=>r(`span`,{className:`text-foreground`,children:Je(e.deviceId,y)})},{key:`rows`,header:i(`recordings.eventsManagementSection.events`,`Events`),align:`right`,nowrap:!0,render:e=>r(`span`,{className:`tabular-nums`,children:e.rows.toLocaleString()})},{key:`bytes`,header:i(`recordings.eventsManagementSection.media`,`Media`),align:`right`,nowrap:!0,render:e=>r(`span`,{className:`tabular-nums`,children:W(e.bytes)})},{key:`actions`,header:``,align:`right`,render:t=>e(V,{variant:`unstyled`,onClick:()=>{O(t)},disabled:T.isPending,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-danger hover:bg-danger/10 disabled:opacity-50`,title:i(`recordings.eventsManagementSection.deleteAllEventsForThis`,`Delete all events for this camera`),children:[r(x,{className:`h-3 w-3`}),i(`common.delete`,`Delete`)]})}],[y,O,T.isPending,i]);return g&&!m?e(`div`,{className:`flex items-center gap-2 py-8 text-xs text-foreground-subtle`,children:[r(l,{className:`h-4 w-4 animate-spin`}),i(`recordings.eventsManagementSection.loadingEventStoreFootprint`,`Loading event-store footprint…`)]}):m?e(`div`,{className:`flex flex-col gap-6`,children:[e(`section`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2`,children:[r(h,{label:i(`recordings.eventsManagementSection.totalEvents`,`Total events`),icon:r(C,{className:`h-3 w-3`}),footer:`across ${String(m.devices.length)} camera${m.devices.length===1?``:`s`}`,children:m.totalRows.toLocaleString()}),r(h,{label:i(`recordings.eventsManagementSection.eventMediaOnDisk`,`Event media on disk`),children:W(m.totalBytes)})]}),e(`section`,{className:`flex flex-wrap items-center gap-2 text-xs`,children:[r(`span`,{className:`text-foreground-subtle`,children:i(`recordings.eventsManagementSection.pruneEventsOlderThan`,`Prune events older than`)}),r(b,{wrapperClassName:`inline-block w-auto`,value:u,onChange:e=>d(Number(e.target.value)),children:Ye.map(e=>r(`option`,{value:e.days,children:i(`recordings.eventsManagementSection.ageDays`,{count:e.days})},e.days))}),e(V,{variant:`unstyled`,onClick:()=>{E()},disabled:w.isPending,className:`inline-flex items-center gap-1 rounded border border-border px-2 py-1 text-xs font-medium text-foreground-subtle hover:bg-warning/10 hover:text-warning disabled:opacity-50`,children:[w.isPending?r(l,{className:`h-3 w-3 animate-spin`}):r(D,{className:`h-3 w-3`}),i(`recordings.eventsManagementSection.pruneNow`,`Prune now`)]})]}),m.devices.length===0?r(I,{icon:C,title:i(`recordings.eventsManagementSection.noStoredEvents`,`No stored events`),description:i(`recordings.eventsManagementSection.noCameraHasPersistedEvents`,`No camera has persisted events yet.`)}):r(A,{columns:k,rows:[...m.devices],rowKey:e=>e.deviceId,minWidthPx:480}),f===null?null:r(`p`,{className:f.startsWith(`Deleted `)?`text-[11px] text-foreground-subtle`:`text-[11px] text-destructive`,children:f})]}):r(I,{icon:C,title:i(`recordings.eventsManagementSection.noEventData`,`No event data`),description:i(`recordings.eventsManagementSection.pipelineAnalyticsHasNotReported`,`Pipeline analytics has not reported any event-store footprint yet.`)})}function Ze(){let{t}=U();return e(`div`,{className:`flex flex-col gap-8`,children:[e(`div`,{children:[r(`h2`,{className:`text-sm font-semibold text-foreground`,children:t(`recordings.eventsSection.eventStore`,`Event store`)}),r(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:t(`recordings.eventsSection.whatTheDurableEventStore`,`What the durable event store occupies, per camera, with fleet-wide prune-by-age and delete-all-events.`)}),r(`div`,{className:`mt-3`,children:r(Xe,{})})]}),e(`div`,{children:[r(`h2`,{className:`text-sm font-semibold text-foreground`,children:t(`recordings.eventsSection.postProcessingNodeFolders`,`Post-processing node & folders`)}),r(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:t(`recordings.eventsSection.theSingleNodeThatWrites`,`The single node that writes event crops, and the storage location they land in.`)}),r(`div`,{className:`mt-3`,children:r(Ge,{})})]})]})}function Qe(e){let t=[];return e.timelapse?t.push(`timelapse ${String(e.timelapse.everyMs/1e3)}s`):(t.push(`${String(e.speed??1)}×`),e.includeAudio&&t.push(`+ audio`)),t.join(` `)}function $e(e){return new Date(e).toLocaleString(void 0,{day:`2-digit`,month:`short`,hour:`2-digit`,minute:`2-digit`})}function et(e,t){let n=Math.max(0,Math.round((t-e)/1e3)),r=Math.floor(n/3600),i=Math.floor(n%3600/60),a=n%60,o=r>0?`${String(r)}:${String(i).padStart(2,`0`)}:${String(a).padStart(2,`0`)}`:`${String(i)}:${String(a).padStart(2,`0`)}`;return`${$e(e)} · ${o}`}function tt(e,t){let n=e-t;if(n<=0)return H.t(`helpers.exportFormat.expired`);let r=Math.floor(n/6e4);if(r<60)return H.t(`helpers.exportFormat.inMinutes`,{n:String(r)});let i=Math.floor(r/60);return i<24?H.t(`helpers.exportFormat.inHours`,{n:String(i)}):H.t(`helpers.exportFormat.inDays`,{n:String(Math.floor(i/24))})}function nt(e,t,n,r){return e.map(e=>{if(e.state===`expired`||e.state===`deleted`)return e;let i=r.get(e.id);if(i)return{...e,state:`failed`,error:i.error,progressPct:null};let a=n.get(e.id);if(a)return{...e,state:`ready`,fileBytes:a.fileBytes,progressPct:100};let o=t.get(e.id);return o&&(e.state===`queued`||e.state===`rendering`)?{...e,state:`rendering`,progressPct:o.progressPct}:e})}o();var rt=[`high`,`mid`,`low`],it=[{value:1,labelKey:`recordings.newExportModal.speedRealTime`},{value:2,labelKey:null},{value:4,labelKey:null},{value:8,labelKey:null},{value:16,labelKey:null}],at=10080*60*1e3;function ot(e){let t=new Date(Date.now()-e*6e4),n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())}T${n(t.getHours())}:${n(t.getMinutes())}`}function st({onClose:n,onCreated:i}){let{t:o}=U(),s=L({isCamera:!0,projection:`slim`}),c=t(()=>(s.data??[]).toSorted((e,t)=>e.name.localeCompare(t.name)),[s.data]),[l,u]=a(``),[d,f]=a(`high`),[m,h]=a(ot(60)),[g,_]=a(ot(0)),[v,x]=a(1),[S,C]=a(!0),[w,T]=a(``),[E,D]=a(null),O=l===``?c[0]?.id??null:l,A=new Date(m).getTime(),j=new Date(g).getTime(),M=Number.isFinite(A)&&Number.isFinite(j)&&A<j,N=he({onSuccess:()=>{i(),n()},onError:e=>D(e instanceof Error?e.message:String(e))});return r(Se,{open:!0,onOpenChange:e=>!e&&n(),children:e(be,{width:`md`,placement:`sheet-on-mobile`,scroll:`body`,children:[r(ie,{children:e(F,{className:`flex items-center gap-1.5`,children:[r(y,{className:`h-3.5 w-3.5`}),o(`recordings.newExportModal.newExport`,`New export`)]})}),e(k,{className:`space-y-3`,children:[e(`div`,{className:`grid grid-cols-2 gap-3`,children:[e(`div`,{className:`space-y-1`,children:[r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:o(`recordings.newExportModal.camera`,`Camera`)}),r(b,{value:O??``,onChange:e=>u(Number(e.target.value)),className:`w-full`,children:c.map(e=>r(`option`,{value:e.id,children:e.name},e.id))})]}),e(`div`,{className:`space-y-1`,children:[r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:o(`recordings.newExportModal.profile`,`Profile`)}),r(b,{value:d,onChange:e=>f(e.target.value),className:`w-full`,children:rt.map(e=>r(`option`,{value:e,children:e},e))})]})]}),e(`div`,{className:`grid grid-cols-2 gap-3`,children:[e(`div`,{className:`space-y-1`,children:[r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:o(`recordings.newExportModal.from`,`From`)}),r(R,{type:`datetime-local`,value:m,onChange:e=>h(e.target.value),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground`})]}),e(`div`,{className:`space-y-1`,children:[r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:o(`recordings.newExportModal.to`,`To`)}),r(R,{type:`datetime-local`,value:g,onChange:e=>_(e.target.value),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground`})]})]}),e(`div`,{className:`grid grid-cols-2 gap-3`,children:[e(`div`,{className:`space-y-1`,children:[r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:o(`recordings.newExportModal.speed`,`Speed`)}),r(b,{value:v,onChange:e=>x(Number(e.target.value)),className:`w-full`,children:it.map(e=>r(`option`,{value:e.value,children:e.labelKey===null?`${e.value}×`:o(e.labelKey)},e.value))})]}),e(`div`,{className:`space-y-1`,children:[r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:o(`recordings.newExportModal.titleOptional`,`Title (optional)`)}),r(R,{type:`text`,value:w,onChange:e=>T(e.target.value),placeholder:o(`recordings.newExportModal.eGCourierAtThe`,`e.g. courier at the gate`),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground placeholder:text-foreground-subtle`})]})]}),e(`label`,{className:`flex items-center gap-2 text-xs text-foreground cursor-pointer`,children:[r(p,{checked:S,disabled:v!==1,onChange:e=>C(e.target.checked),className:`accent-primary`}),o(v===1?`recordings.newExportModal.includeAudio`:`recordings.newExportModal.includeAudioRealtimeOnly`)]}),!M&&r(`p`,{className:`text-[11px] text-danger`,children:o(`recordings.newExportModal.fromMustBeBeforeTo`,`"From" must be before "To".`)}),E&&r(`p`,{className:`text-[11px] text-danger`,children:E})]}),e(re,{children:[r(V,{variant:`outline`,size:`sm`,onClick:n,children:o(`common.cancel`,`Cancel`)}),r(V,{size:`sm`,onClick:()=>{if(O===null||!M)return;D(null);let e=w.trim();N.mutate({deviceId:O,profile:d,fromMs:A,toMs:j,options:{includeAudio:S,maxLifeMs:at,deleteAfterDownload:!1,...v===1?{}:{speed:v},...e.length>0?{title:e}:{}}})},disabled:O===null||!M||N.isPending,children:N.isPending?o(`recordings.newExportModal.queuing`,`Queuing…`):o(`recordings.newExportModal.createExport`,`Create export`)})]})]})})}o();var ct=[[`recordingExport`]],lt={queued:{cls:`bg-muted text-foreground-subtle`,labelKey:`recordings.exportsSection.queued`},rendering:{cls:`bg-primary/10 text-primary`,labelKey:`recordings.exportsSection.rendering`,spin:!0},ready:{cls:`bg-success/10 text-success`,labelKey:`recordings.exportsSection.ready`},failed:{cls:`bg-danger/10 text-danger`,labelKey:`recordings.exportsSection.failed`},expired:{cls:`bg-muted text-foreground-subtle`,labelKey:`recordings.exportsSection.expired`},deleted:{cls:`bg-muted text-foreground-subtle`,labelKey:`recordings.exportsSection.deleted`}};function ut(){let{data:e,isLoading:n}=ke({},{refetchOnWindowFocus:!1,refetchInterval:e=>(e.state.data??[]).some(e=>e.state===`queued`||e.state===`rendering`)?3e3:!1}),{map:r}=N(E.RecordingExportProgress,e=>e.exportId),{map:i}=N(E.RecordingExportCompleted,e=>e.exportId),{map:a}=N(E.RecordingExportFailed,e=>e.exportId);return{rows:t(()=>nt(e??[],r,i,a),[e,r,i,a]),isLoading:n}}function dt(e){let[t,n]=a(()=>Date.now());return i(()=>{let t=setInterval(()=>n(Date.now()),e);return()=>clearInterval(t)},[e]),t}function ft(){let{t:i}=U(),o=s(),[c,u]=a(!1),f=()=>{o.invalidateQueries({queryKey:[[`recordingExport`,`listExports`]]})},p=v(),m=S().trpcClient,h=dt(6e4),{rows:g,isLoading:_}=ut(),{data:b}=L({isCamera:!0,projection:`slim`}),C=t(()=>{let e=new Map;for(let t of b??[])e.set(t.id,t.name);return e},[b]),w=n(()=>{o.invalidateQueries({queryKey:ct})},[o]),E=ve({onSuccess:w}),D=Oe({onSuccess:w}),[O,k]=a(null),j=n(async e=>{k(e.id);try{let{url:t}=await m.recordingExport.getDownloadUrl.query({exportId:e.id}),n=await Pe(t),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`${e.options.title??e.id}.mp4`,document.body.appendChild(i),i.click(),i.remove(),URL.revokeObjectURL(r),w()}finally{k(null)}},[m,w]),M=n(async e=>{await p({title:i(`recordings.exportsSection.cancelThisExport`,`Cancel this export?`),message:i(`recordings.exportsSection.stopsTheRenderThePartial`,`Stops the render. The partial file is discarded.`),confirmLabel:i(`recordings.exportsSection.cancelExport`,`Cancel export`),variant:`danger`})&&E.mutate({exportId:e.id})},[p,E,i]),N=n(async e=>{await p({title:i(`recordings.exportsSection.deleteThisExport`,`Delete this export?`),message:i(`recordings.exportsSection.permanentlyRemovesTheRenderedFile`,`Permanently removes the rendered file and its history row.`),confirmLabel:i(`common.delete`,`Delete`),variant:`danger`})&&D.mutate({exportId:e.id})},[p,D,i]),P=t(()=>[{key:`camera`,header:i(`recordings.exportsSection.camera`,`Camera`),render:e=>r(`span`,{className:`text-foreground`,children:C.get(e.deviceId)??`#${String(e.deviceId)}`})},{key:`range`,header:i(`recordings.exportsSection.range`,`Range`),nowrap:!0,render:e=>r(`span`,{className:`tabular-nums`,children:et(e.fromMs,e.toMs)})},{key:`variant`,header:i(`recordings.exportsSection.variant`,`Variant`),render:e=>r(`span`,{className:`text-foreground-subtle`,children:Qe(e.options)})},{key:`state`,header:i(`recordings.exportsSection.state`,`State`),render:t=>{let n=lt[t.state];return e(`span`,{className:`inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] font-medium ${n.cls}`,children:[n.spin&&r(l,{className:`h-2.5 w-2.5 animate-spin`}),i(n.labelKey),t.state===`rendering`&&t.progressPct!==null&&e(`span`,{className:`tabular-nums`,children:[t.progressPct,`%`]})]})}},{key:`expiry`,header:i(`recordings.exportsSection.expires`,`Expires`),nowrap:!0,render:e=>e.state===`deleted`?r(`span`,{className:`text-foreground-subtle`,children:`—`}):r(`span`,{className:`text-foreground-subtle tabular-nums`,children:tt(e.expiresAt,h)})},{key:`size`,header:i(`recordings.exportsSection.size`,`Size`),align:`right`,nowrap:!0,render:e=>r(`span`,{className:`tabular-nums`,children:e.fileBytes===null?`—`:W(e.fileBytes)})},{key:`actions`,header:``,align:`right`,render:t=>{let n=t.state===`ready`,a=t.state===`queued`||t.state===`rendering`,o=t.state!==`deleted`;return e(`div`,{className:`flex items-center justify-end gap-1`,children:[n&&e(V,{variant:`unstyled`,onClick:()=>{j(t)},disabled:O===t.id,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-foreground-subtle hover:bg-primary/10 hover:text-foreground disabled:opacity-50`,title:i(`recordings.exportsSection.downloadMp4`,`Download MP4`),children:[O===t.id?r(l,{className:`h-3 w-3 animate-spin`}):r(T,{className:`h-3 w-3`}),i(`recordings.exportsSection.download`,`Download`)]}),a&&e(V,{variant:`unstyled`,onClick:()=>{M(t)},disabled:E.isPending,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-foreground-subtle hover:bg-amber-500/10 hover:text-amber-500 disabled:opacity-50`,title:i(`recordings.exportsSection.cancelRender`,`Cancel render`),children:[r(d,{className:`h-3 w-3`}),i(`common.cancel`,`Cancel`)]}),o&&r(V,{variant:`unstyled`,onClick:()=>{N(t)},disabled:D.isPending,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-danger hover:bg-danger/10 disabled:opacity-50`,title:i(`recordings.exportsSection.deleteExport`,`Delete export`),children:r(x,{className:`h-3 w-3`})})]})}}],[C,h,O,E.isPending,D.isPending,j,M,N,i]);return _&&g.length===0?e(`div`,{className:`flex items-center gap-2 py-8 text-xs text-foreground-subtle`,children:[r(l,{className:`h-4 w-4 animate-spin`}),i(`recordings.exportsSection.loadingExports`,`Loading exports…`)]}):e(`div`,{className:`space-y-3`,children:[r(`div`,{className:`flex justify-end`,children:e(V,{variant:`unstyled`,onClick:()=>u(!0),className:`inline-flex items-center gap-1.5 rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground`,children:[r(y,{className:`h-3.5 w-3.5`}),i(`recordings.exportsSection.newExport`,`New export`)]})}),g.length===0?r(I,{icon:y,title:i(`recordings.exportsSection.noExportsYet`,`No exports yet`),description:i(`recordings.exportsSection.createOneHereNewExport`,`Create one here (New export) or from a camera's timeline in the viewer. Rendered clips show up here to download or manage.`)}):r(A,{columns:P,rows:g,rowKey:e=>e.id,minWidthPx:720}),c&&r(st,{onClose:()=>u(!1),onCreated:f})]})}var pt=`inline-flex w-fit items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-[11px] font-medium border border-border text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50`;o();var mt=`storage-migration`,ht=new Set([`orphans`,`debug-media`,`ghost-ledger`]);function gt(e){return[`${e.orphansReclaimed} orphan rows (${W(e.orphanBytesReclaimed)})`,e.includeDebugMedia?`${e.debugMediaReclaimed} debug files (${W(e.debugMediaBytesReclaimed)})`:null,`${e.ghostsForgotten} ghost rows (${W(e.ghostBytesForgotten)})`].filter(e=>e!==null).join(` · `)}function _t(){let{t:e}=U(),t=oe(mt);return t===`pending`?null:t===`unknown`?r(`p`,{className:`py-2 text-xs text-foreground-subtle`,children:e(`recordings.cleanupSection.couldNotCheckWhetherStorage`,`Could not check whether storage cleanup is installed on this hub.`)}):t===`present`?r(vt,{}):null}function vt(){let{t}=U(),n=v(),[i,o]=a(!1),[s,c]=a(null),u=Te({},{refetchInterval:2e3}),d=u.data??null,f=d!==null&&ht.has(d.phase),m=ne(),h=ee(),g=async()=>{if(await n({title:t(`recordings.cleanupSection.runStorageCleanup`,`Run storage cleanup?`),message:i?t(`recordings.cleanupSection.reclaimsLeftoverAnalyticsRowsAnd`,`Reclaims leftover analytics rows and files, debug stills/filmstrips, and ghost footage rows on frozen locations. Safe to re-run.`):t(`recordings.cleanupSection.reclaimsLeftoverAnalyticsRowsAnd2`,`Reclaims leftover analytics rows and files, and ghost footage rows on frozen locations. Debug stills are left alone. Safe to re-run.`),confirmLabel:t(`recordings.cleanupSection.runCleanup`,`Run cleanup`),variant:`danger`})){c(null);try{await m.mutateAsync({includeDebugMedia:i}),await u.refetch()}catch(e){c(e instanceof Error?e.message:String(e))}}},_=async()=>{if(d&&await n({title:t(`recordings.cleanupSection.cancelCleanup`,`Cancel cleanup?`),message:t(`recordings.cleanupSection.stopsAfterTheCurrentStep`,`Stops after the current step. Work already done stays done.`),confirmLabel:t(`recordings.cleanupSection.cancelCleanup2`,`Cancel cleanup`),variant:`danger`}))try{await h.mutateAsync({jobId:d.jobId}),await u.refetch()}catch{}};return e(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[r(`h2`,{className:`text-sm font-semibold text-foreground`,children:t(`recordings.cleanupSection.cleanup`,`Cleanup`)}),r(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:t(`recordings.cleanupSection.onePassOverLeftoverAnalytics`,`One pass over leftover analytics (database + files) and ghost footage rows on frozen locations. Does not time out — progress updates here until it finishes.`)}),e(`label`,{className:`mt-3 flex items-start gap-2 text-[11px] text-foreground`,children:[r(p,{checked:i,disabled:f,onChange:e=>{o(e.target.checked)},className:`mt-0.5 h-3.5 w-3.5 accent-primary`}),r(`span`,{children:t(`recordings.cleanupSection.alsoRemoveDebugMediaMotion`,`Also remove debug media (motion stills and track filmstrips)`)})]}),e(`div`,{className:`mt-3 flex flex-wrap items-center gap-2`,children:[e(V,{variant:`unstyled`,type:`button`,disabled:f||m.isPending,onClick:()=>{g()},className:pt,children:[(f||m.isPending)&&r(l,{className:`h-3 w-3 animate-spin`}),r(x,{className:`h-3 w-3`}),t(`recordings.cleanupSection.runCleanup`,`Run cleanup`)]}),f&&r(V,{variant:`unstyled`,type:`button`,onClick:()=>{_()},className:`inline-flex items-center gap-1 rounded border border-border px-2 py-1 text-[10px] font-medium text-danger hover:bg-danger/10`,children:t(`common.cancel`,`Cancel`)})]}),s&&r(`p`,{className:`mt-2 text-[11px] text-danger`,children:s}),d&&e(`div`,{className:`mt-3 space-y-1 rounded-md border border-border px-2.5 py-2`,children:[e(`p`,{className:`text-xs text-foreground`,children:[t(`recordings.cleanupSection.phase`,`Phase:`),` `,r(`span`,{className:`font-medium`,children:d.phase}),f&&r(l,{className:`ml-2 inline h-3 w-3 animate-spin text-primary`})]}),d.detail&&r(`p`,{className:`text-[11px] text-foreground-subtle`,children:d.detail}),r(`p`,{className:`text-[11px] text-foreground-subtle`,children:gt(d)}),d.error&&r(`p`,{className:`text-[11px] text-danger`,children:d.error})]})]})}o();var yt=2e3;function bt(){let{t}=U(),n=v(),a=s(),o=P(),c=se(void 0,{refetchInterval:e=>e.state.data?.state===`running`?yt:!1}),u=c.data,d=u?.state===`running`,f=d||o.isPending;i(()=>{u?.state!==`done`||u.finishedAtMs===null||(a.invalidateQueries({queryKey:[[`recording`]]}),a.invalidateQueries({queryKey:[[`pipelineAnalytics`]]}))},[u?.state,u?.finishedAtMs,a]);let p=async()=>{await n({title:t(`recordings.diskReconcileSection.reconcileStorageFromDisk`,`Reconcile storage from disk?`),message:t(`recordings.diskReconcileSection.makesTheDatabaseMatchThe`,`Makes the database match the filesystem: recordings index, tracks, events and media whose files are gone. Favourited tracks without files are deleted. Snapshot-less motion/audio events are deleted. Enrolled identities stay. This cannot be undone.`),confirmLabel:t(`recordings.diskReconcileSection.reconcile`,`Reconcile`),variant:`warning`})&&(await o.mutateAsync(),await c.refetch())},m=d?u.total>0?`Reconciling ${String(u.completed)}/${String(u.total)}…`:`Reconciling…`:o.isPending?`Reconciling…`:`Reconcile from disk`;return e(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[r(`h3`,{className:`text-sm font-semibold text-foreground`,children:t(`recordings.diskReconcileSection.diskReconcile`,`Disk reconcile`)}),r(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:t(`recordings.diskReconcileSection.deletesDatabaseRowsWhoseFiles`,`Deletes database rows whose files are gone. Enrolled identities stay.`)}),e(`div`,{className:`mt-3 flex flex-col gap-2`,children:[e(V,{variant:`unstyled`,type:`button`,onClick:()=>void p(),disabled:f,className:`inline-flex w-fit items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-[11px] font-medium border border-border text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50`,children:[f?r(l,{className:`h-3.5 w-3.5 animate-spin`}):r(g,{className:`h-3.5 w-3.5`}),m]}),u?.state===`done`?e(`p`,{className:`text-[11px] text-foreground-subtle`,children:[t(`recordings.diskReconcileSection.lastRun`,`Last run:`),` `,t(`recordings.diskReconcileSection.summary`,{completed:String(u.completed),tracks:String(u.tracks),events:String(u.events),media:String(u.mediaDropped)}),u.failed.length>0?t(`recordings.diskReconcileSection.failed`,`, {{value1}} failed ({{value2}})`,{value1:String(u.failed.length),value2:u.failed.join(`, `)}):``,`.`]}):null,u?.state===`error`&&u.error!==null?e(`p`,{className:`text-[11px] text-destructive`,children:[t(`recordings.diskReconcileSection.reconcileFailed`,`Reconcile failed:`),` `,u.error]}):null]})]})}var J=1e3,Y=60*J,X=60*Y;function Z(e){return e.toLocaleString(`en-US`)}function xt(e){if(!Number.isFinite(e)||e<0)return`—`;if(e>=X){let t=Math.floor(e/X),n=Math.round(e%X/Y);return`${t.toString()}h ${n.toString()}m`}if(e>=Y){let t=Math.floor(e/Y),n=Math.round(e%Y/J);return`${t.toString()}m ${n.toString()}s`}return`${Math.max(0,Math.round(e/J)).toString()}s`}function St(e){let t=Math.max(0,e.observedAt-e.startedAt),n=e.filesTotal===null?`${Z(e.filesMoved)} files`:`${Z(e.filesMoved)} / ${Z(e.filesTotal)} files`,r=e.filesTotal===null||e.filesTotal===0?null:Math.min(1,e.filesMoved/e.filesTotal),i=t>0&&e.filesMoved>0,a=i?`${W(e.bytesMoved/t*J)}/s`:null,o=e.filesTotal===null?null:e.filesTotal-e.filesMoved,s=!i||o===null||o<=0?null:`~${xt(o*t/e.filesMoved)} left`;return{counted:n,fraction:r,moved:`${W(e.bytesMoved)} moved`,rate:a,eta:s}}function Ct(e){let t=St(e);return[t.counted,t.moved,t.rate,t.eta].filter(e=>e!==null).join(` · `)}o();var wt=`storage-migration`,Q=[{id:`recordings`,labelKey:`recordings.storageMigrationSection.classRecordings`,locationType:`recordings`},{id:`recordingsLow`,labelKey:`recordings.storageMigrationSection.classRecordingsLow`,locationType:`recordingsLow`},{id:`eventMedia`,labelKey:`recordings.storageMigrationSection.classEventMedia`,locationType:`eventMedia`}],Tt=new Set([`planning`,`sealing`,`pausing`,`moving`,`draining`,`verifying`,`repointing`,`refreshing`,`resuming`]);function Et(){let{t}=U(),n=oe(wt);return n===`pending`?e(`div`,{className:`flex items-center gap-2 py-8 text-xs text-foreground-subtle`,children:[r(l,{className:`h-4 w-4 animate-spin`}),t(`migration.storageMigrationSection.checkingWhetherStorageMigrationIs`,`Checking whether storage migration is installed…`)]}):n===`unknown`?r(I,{icon:m,title:t(`migration.storageMigrationSection.couldnTCheckWhetherStorage`,`Couldn't check whether storage migration is installed`),description:t(`migration.storageMigrationSection.theCapabilityRegistryDidNot`,`The capability registry did not answer, so this panel has nothing to report either way — it is not a statement that the capability is missing. Reload to ask again.`)}):n===`absent`?r(I,{icon:f,title:t(`migration.storageMigrationSection.storageMigrationNotInstalled`,`Storage migration not installed`),description:t(`migration.storageMigrationSection.theCapabilityRegistryAnsweredNo`,`The capability registry answered: no addon in this cluster provides storage-migration. Once one is deployed, this panel moves recordings, low-res recordings and event media to new storage locations in one coordinated, verified operation.`)}):r(Dt,{})}function Dt(){let{t:n}=U(),i=v(),{data:o}=B({}),[s,c]=a({}),[u,d]=a({}),[p,m]=a(null),[h,g]=a(null),_=t(()=>{let e=new Map;for(let t of o??[]){let n=e.get(t.type);n?n.push(t):e.set(t.type,[t])}return e},[o]),y=t(()=>{let e=new Map;for(let t of o??[]){if(t.enabled===!1)continue;let n=e.get(t.type);n?n.push(t.id):e.set(t.type,[t.id])}let t=new Map;for(let[n,r]of e)r.length===1&&t.set(n,r[0]);return t},[o]),x=ge({},{refetchInterval:2e3}),S=x.data??null,C=S!==null&&Tt.has(S.phase),T=t(()=>{let e={};for(let t of Q){let n=s[t.id];n&&(e[t.id]=n)}return Object.keys(e).length>0?e:void 0},[s]),E=t(()=>{let e={};for(let t of Q){if(!s[t.id])continue;let n=u[t.id]??y.get(t.locationType);n&&(e[t.id]=n)}return Object.keys(e).length>0?e:void 0},[s,u,y]),D=t(()=>({destinations:T??{},...E?{sources:E}:{}}),[T,E]),k=me(D,{enabled:!1,retry:!1}),A=O(),j=ue(),M=async()=>{if(!T)return;g(null);let e=await k.refetch();if(e.error){g(e.error instanceof Error?e.error.message:String(e.error));return}m(e.data??null)},N=async()=>{if(T&&await i({title:n(`migration.storageMigrationSection.startStorageMigration`,`Start storage migration?`),message:n(`migration.storageMigrationSection.copiesTheSelectedClassesFrom`,`Copies the selected classes from the chosen source to the destination, verifies, then either makes the destination the default (if the source was) or disables the source. Safe to re-run if interrupted.`),confirmLabel:n(`migration.storageMigrationSection.startMigration`,`Start migration`),variant:`danger`})){g(null);try{await A.mutateAsync(D),m(null),await x.refetch()}catch(e){g(e instanceof Error?e.message:String(e))}}},P=async()=>{if(S&&await i({title:n(`migration.storageMigrationSection.cancelMigration`,`Cancel migration?`),message:n(`migration.storageMigrationSection.stopsTheInProgressMigration`,`Stops the in-progress migration. Data already moved and verified stays at the destination; anything already repointed is not reverted.`),confirmLabel:n(`migration.storageMigrationSection.cancelMigration2`,`Cancel migration`),variant:`danger`}))try{await j.mutateAsync({jobId:S.jobId}),await x.refetch()}catch{}};return e(`div`,{className:`flex flex-col gap-6`,children:[e(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[e(`h3`,{className:`flex items-center gap-1.5 text-sm font-semibold text-foreground`,children:[r(f,{className:`h-3.5 w-3.5`}),n(`migration.storageMigrationSection.storageMigration`,`Storage migration`)]}),r(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:n(`migration.storageMigrationSection.moveRecordingsLowResRecordings`,`Move recordings, low-res recordings and/or event media from one location to another: copies via the recorder / pipeline-analytics movers, verifies, then either repoints the default (when the source was the default) or disables the source (when it was not). Skip a class with an empty destination.`)}),r(`div`,{className:`mt-3 grid grid-cols-1 gap-3 sm:grid-cols-3`,children:Q.map(t=>{let i=_.get(t.locationType)??[],a=y.get(t.locationType)??``;return e(`div`,{className:`space-y-2`,children:[r(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:n(t.labelKey)}),e(`div`,{className:`space-y-1`,children:[r(`label`,{htmlFor:`migration-from-${t.id}`,className:`text-[10px] text-foreground-subtle`,children:n(`recordings.storageMigrationSection.classFrom`,{label:n(t.labelKey)})}),r(b,{id:`migration-from-${t.id}`,value:u[t.id]??a,onChange:e=>{let n=e.target.value;d(e=>({...e,[t.id]:n}))},disabled:C,className:`w-full`,children:i.map(t=>e(`option`,{value:t.id,children:[t.displayName,t.enabled===!1?` (${n(`recordings.storageMigrationSection.readOnly`)})`:``]},t.id))})]}),e(`div`,{className:`space-y-1`,children:[r(`label`,{htmlFor:`migration-dest-${t.id}`,className:`text-[10px] text-foreground-subtle`,children:n(`recordings.storageMigrationSection.classTo`,{label:n(t.labelKey)})}),e(b,{id:`migration-dest-${t.id}`,value:s[t.id]??``,onChange:e=>{let n=e.target.value;c(e=>({...e,[t.id]:n}))},disabled:C,className:`w-full`,children:[r(`option`,{value:``,children:n(`migration.storageMigrationSection.skip`,`— skip —`)}),i.map(e=>r(`option`,{value:e.id,children:e.displayName},e.id))]})]})]},t.id)})}),h&&r(`p`,{className:`mt-2 text-[11px] text-danger`,children:h}),e(`div`,{className:`mt-3 flex items-center gap-2`,children:[e(V,{variant:`unstyled`,type:`button`,onClick:()=>{M()},disabled:!T||k.isFetching||C,className:`inline-flex items-center gap-1.5 rounded border border-border px-2.5 py-1.5 text-xs font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover disabled:opacity-50`,children:[k.isFetching&&r(l,{className:`h-3 w-3 animate-spin`}),n(`migration.storageMigrationSection.plan`,`Plan`)]}),e(V,{variant:`unstyled`,type:`button`,onClick:()=>{N()},disabled:!T||A.isPending||C,className:`inline-flex items-center gap-1.5 rounded bg-primary px-2.5 py-1.5 text-xs font-medium text-primary-foreground disabled:opacity-50`,children:[A.isPending&&r(l,{className:`h-3 w-3 animate-spin`}),n(`migration.storageMigrationSection.startMigration`,`Start migration`)]})]}),p&&r(`div`,{className:`mt-3 divide-y divide-border rounded-md border border-border`,children:p.moves.length===0?r(`p`,{className:`px-2.5 py-1.5 text-[11px] text-foreground-subtle`,children:n(`migration.storageMigrationSection.nothingToMoveSelectedDestinations`,`Nothing to move — selected destinations match the current defaults.`)}):p.moves.map(t=>e(`div`,{className:`px-2.5 py-1.5 text-[11px] text-foreground`,children:[t.storageClass,`: `,t.fromLocationId,` → `,t.toLocationId]},`${t.storageClass}-${t.toLocationId}`))}),S&&e(`div`,{className:`mt-4 border-t border-border pt-3`,children:[e(`div`,{className:`flex items-center justify-between`,children:[r(`h4`,{className:`text-xs font-semibold text-foreground`,children:n(`migration.storageMigrationSection.migrationStatus`,`Migration status`)}),C&&e(V,{variant:`unstyled`,type:`button`,onClick:()=>{P()},className:`inline-flex items-center gap-1 rounded border border-border px-2 py-1 text-[10px] font-medium text-danger hover:bg-danger/10`,children:[r(w,{className:`h-3 w-3`}),n(`common.cancel`,`Cancel`)]})]}),e(`p`,{className:`mt-1 text-xs text-foreground`,children:[n(`migration.storageMigrationSection.phase`,`Phase:`),` `,r(`span`,{className:`font-medium`,children:S.phase}),C&&r(l,{className:`ml-2 inline h-3 w-3 animate-spin text-primary`})]}),S.error&&r(`p`,{className:`mt-1 text-[11px] text-danger`,children:S.error}),S.pausedParticipants.length>0&&e(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:[n(`migration.storageMigrationSection.paused`,`Paused:`),` `,S.pausedParticipants.join(`, `)]}),r(`div`,{className:`mt-2 divide-y divide-border rounded-md border border-border`,children:S.moves.map(e=>r(Ot,{move:e},`${e.storageClass}-${e.fromLocationId}`))})]}),r(kt,{})]}),r(At,{running:C}),r(Mt,{})]})}function Ot({move:t}){let{t:n}=U(),i=t.progress===null?null:St(t.progress);return e(`div`,{className:`px-2.5 py-1.5 text-[11px]`,children:[e(`div`,{className:`flex items-center justify-between`,children:[e(`span`,{className:`text-foreground`,children:[t.storageClass,`: `,t.fromLocationId,` → `,t.toLocationId]}),e(`span`,{className:`text-foreground-subtle`,children:[t.state??n(`common.pending`),t.error?` (${t.error})`:``]})]}),t.progress!==null&&e(`div`,{className:`mt-1 space-y-1`,children:[i!==null&&i.fraction!==null&&r(`div`,{className:`h-1 w-full overflow-hidden rounded bg-border`,children:r(`div`,{className:`h-full bg-primary`,style:{width:`${(i.fraction*100).toFixed(1)}%`}})}),r(`p`,{className:`text-[10px] text-foreground-subtle`,children:Ct(t.progress)})]})]})}function kt(){let{t}=U(),{data:n}=fe({});return!n||n.length===0?null:e(`div`,{className:`mt-4 border-t border-border pt-3`,children:[r(`h4`,{className:`text-xs font-semibold text-foreground`,children:t(`migration.storageMigrationSection.migrationHistory`,`Migration history`)}),r(`div`,{className:`mt-2 divide-y divide-border rounded-md border border-border`,children:n.map(t=>e(`div`,{className:`px-2.5 py-1.5 text-[11px] text-foreground-subtle`,children:[r(`span`,{className:`font-medium text-foreground`,children:t.phase}),` · `,Object.entries(t.destinations).filter(e=>typeof e[1]==`string`).map(([e,t])=>`${e} → ${t}`).join(`, `),` · `,new Date(t.startedAt).toLocaleString()]},t.jobId))})]})}function At({running:t}){let{t:n}=U(),i=v(),o=ae({},{staleTime:1/0,refetchOnWindowFocus:!1}),s=te(),[c,l]=a(null),u=o.data??[];if(u.length===0)return null;let d=async e=>{if(await i({title:n(`migration.storageMigrationSection.drainRemaining`,`Drain remaining {{storageClass}}?`,{storageClass:e.storageClass}),message:`Moves what is still on ${e.fromLocationId} to ${e.toLocationId}. Nothing is paused and no default is changed — this is the second half of a migration, run on its own. It is resumable: cancelling leaves everything readable from both locations.`,confirmLabel:n(`migration.storageMigrationSection.drainRemaining2`,`Drain remaining`),variant:`danger`})){l(null);try{await s.mutateAsync({classes:[e.storageClass]}),await o.refetch()}catch(e){l(e instanceof Error?e.message:String(e))}}};return e(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[e(`div`,{className:`flex items-start justify-between gap-2`,children:[r(`h3`,{className:`text-sm font-semibold text-foreground`,children:n(`migration.storageMigrationSection.leftOnTheOldLocation`,`Left on the old location`)}),e(`div`,{className:`flex shrink-0 items-center gap-2`,children:[r(`span`,{className:`text-[10px] text-foreground-subtle`,children:o.dataUpdatedAt>0?n(`migration.storageMigrationSection.measured`,`Measured {{value1}}`,{value1:new Date(o.dataUpdatedAt).toLocaleTimeString()}):n(`migration.storageMigrationSection.measuredNever`,`Measured — never`)}),r(V,{variant:`unstyled`,type:`button`,onClick:()=>{o.refetch()},disabled:o.isFetching,className:`rounded border border-border px-2 py-1 text-[10px] font-medium text-foreground-subtle hover:bg-surface-hover hover:text-foreground disabled:opacity-50`,children:o.isFetching?n(`migration.storageMigrationSection.counting`,`Counting…`):n(`common.refresh`,`Refresh`)})]})]}),r(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:n(`migration.storageMigrationSection.aMigrationRepointsFirstAnd`,`A migration repoints first and drains behind. If the drain was cancelled, failed, or was interrupted by a restart, the data below is still on the source — readable, but not where the defaults now point. Draining moves it; it changes no default and pauses nothing.`)}),r(`p`,{className:`mt-1 text-[10px] text-foreground-subtle`,children:n(`migration.storageMigrationSection.thisCountIsTakenOn`,`This count is taken on demand: measuring it walks the whole media collection, so it is not refreshed on a timer. Press Refresh after a drain finishes.`)}),c&&r(`p`,{className:`mt-2 text-[11px] text-danger`,children:c}),r(`div`,{className:`mt-2 divide-y divide-border rounded-md border border-border`,children:u.map(i=>e(`div`,{className:`flex items-center justify-between gap-2 px-2.5 py-1.5 text-[11px]`,children:[e(`span`,{className:`text-foreground`,children:[i.storageClass,`: `,i.fromLocationId,` → `,i.toLocationId,r(`span`,{className:`ml-2 text-foreground-subtle`,children:jt(i)})]}),r(V,{variant:`unstyled`,type:`button`,onClick:()=>{d(i)},disabled:t||s.isPending,className:`shrink-0 rounded border border-border px-2 py-1 text-[10px] font-medium text-foreground-subtle hover:bg-surface-hover hover:text-foreground disabled:opacity-50`,children:n(`migration.storageMigrationSection.drainRemaining2`,`Drain remaining`)})]},`${i.storageClass}-${i.fromLocationId}`))})]})}function jt(e){if(e.items===null)return H.t(`recordings.storageMigrationSection.residueUnknown`);let t=e.items.toLocaleString(`en-US`);return e.bytes===null?H.t(`recordings.storageMigrationSection.residueRows`,{count:e.items,items:t}):H.t(`recordings.storageMigrationSection.residueSegments`,{count:e.items,items:t,size:W(e.bytes)})}function Mt(){let{t}=U(),{data:n}=de({},{refetchInterval:2e3}),i=(n??[]).filter(e=>e.migrationJobId===null&&e.job.state===`running`);return i.length===0?null:e(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[r(`h3`,{className:`text-sm font-semibold text-foreground`,children:t(`migration.storageMigrationSection.moversRunningOutsideAMigration`,`Movers running outside a migration`)}),r(`div`,{className:`mt-2 divide-y divide-border rounded-md border border-border`,children:i.map(t=>e(`div`,{className:`px-2.5 py-1.5 text-[11px]`,children:[e(`div`,{className:`text-foreground`,children:[t.lane,`: `,t.job.fromLocationId,` → `,t.job.toLocationId]}),r(`p`,{className:`mt-1 text-[10px] text-foreground-subtle`,children:Ct({filesMoved:t.job.filesMoved,filesTotal:t.job.filesTotal,bytesMoved:t.job.bytesMoved,startedAt:t.job.startedAt,observedAt:t.observedAt})})]},t.job.jobId))})]})}function Nt(){let{t}=U();return e(`div`,{className:`flex flex-col gap-4`,children:[r(_t,{}),r(bt,{}),e(`section`,{children:[r(`h2`,{className:`text-sm font-semibold text-foreground`,children:t(`recordings.recordingsManagementSection.moveStorage`,`Move storage`)}),r(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:t(`recordings.recordingsManagementSection.copyRecordingsLowResRecordings`,`Copy recordings, low-res recordings or event media to a new location, verify, then repoint the default. Applies to every camera.`)}),r(`div`,{className:`mt-3`,children:r(Et,{})})]})]})}o();var Pt=`recorder`,Ft=`recording`;function It(e,t,n){for(let n of e?.sections??[])for(let e of n.fields??[])if(e.key===t&&typeof e.value==`string`)return e.value;return n}function Lt(){let{t:n}=U(),i=s(),{nodes:a}=M(),{data:o,isLoading:c}=z({addonId:Pt,cap:Ft,scope:`cluster`}),u=It(o,`recordingNodeId`,`hub`),d=j({onSuccess:()=>{i.invalidateQueries({queryKey:[[`addonSettings`,`getScopedSettings`]]})}}),f=t(()=>{let e=a.filter(e=>e.isOnline).map(e=>e.id);return[...new Set([`hub`,u,...e])].filter(Boolean)},[a,u]);return e(`div`,{className:`flex flex-col gap-6`,children:[e(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[r(`h3`,{className:`text-sm font-semibold text-foreground`,children:n(`pipeline.clusterRecordingTab.recordingNode`,`Recording node`)}),r(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:n(`pipeline.clusterRecordingTab.theSingleNodeThatRecords`,`The single node that records (continuous & events) and serves playback. Every other node stays inert — no multi-node balancing. Takes effect on addon restart.`)}),e(`div`,{className:`mt-3 flex items-center gap-2`,children:[c?r(l,{className:`h-4 w-4 animate-spin text-foreground-subtle`}):r(b,{wrapperClassName:`inline-block w-auto`,value:u,onChange:e=>{e.target.value!==u&&d.mutate({addonId:Pt,cap:Ft,scope:`cluster`,patch:{recordingNodeId:e.target.value}})},disabled:d.isPending,children:f.map(e=>r(`option`,{value:e,children:e===`hub`?n(`pipeline.clusterRecordingTab.hubDefault`,`hub (default)`):e},e))}),d.isPending&&r(l,{className:`h-4 w-4 animate-spin text-primary`})]}),u!==`hub`&&r(`p`,{className:`mt-2 text-[11px] text-amber-500`,children:r(Me,{i18nKey:`pipeline.clusterRecordingTab.hubOnlyNote`,values:{node:u},components:{b:r(`span`,{className:`font-medium`})}})})]}),e(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[r(`h3`,{className:`mb-1 text-sm font-semibold text-foreground`,children:n(`pipeline.clusterRecordingTab.recordingsFolders`,`Recordings folders`)}),r(`p`,{className:`mb-3 text-[11px] text-foreground-subtle`,children:n(`pipeline.clusterRecordingTab.whereRecordingsAreStoredMulti`,`Where recordings are stored. Multi-location collections — segments are split across the locations of a type. Add a location to grow capacity; mark one default per type.`)}),r(G,{types:[`recordings`,`recordingsLow`]})]})]})}function Rt(e){return e.locationIds!==void 0&&e.locationIds.length>0?e.locationIds:e.locationId===null?[]:[e.locationId]}function zt(e,t){let n=Rt(e);return n.length===0?H.t(`helpers.cameraDisk.defaultRoot`):n.map(e=>t.get(e)??e).join(` + `)}function Bt(e,t,n){if(e.length===0)return null;let r=e[0];if(e.length===1&&r!==void 0)return{label:zt(r,t),exact:!0};if(n===null)return null;let i=e.find(e=>Rt(e).includes(n));return i===void 0?null:{label:zt(i,t),exact:!1}}o();var Vt=[[`recording`]],Ht=[{value:`retention`,labelKey:`recordings.storageSection.pruneRetention`},{value:`quota`,labelKey:`recordings.storageSection.pruneQuota`},{value:`operator`,labelKey:`recordings.storageSection.pruneOperator`}],Ut={ok:`bg-primary`,warn:`bg-amber-500`,critical:`bg-danger`},Wt={ok:`text-foreground-subtle`,warn:`text-amber-500`,critical:`text-danger`};function $(e){return`${String(Math.round(e*100))}%`}function Gt(e){return e==null?`—`:new Date(e).toLocaleString()}function Kt(e,t){let n=e.locationIds??(e.locationId===null?[]:[e.locationId]),r=n.map(e=>t.get(e)).filter(e=>e!==void 0);return r.length>0?r.join(` + `):e.root===void 0?n.length>0?n.join(` + `):H.t(`recordings.storageSection.defaultRoot`):e.root}function qt(){let{t:i}=U(),o=s(),c=v(),[u,d]=a(`retention`),{data:f,isLoading:p}=we({},{refetchOnWindowFocus:!1}),{data:m}=L({isCamera:!0,projection:`slim`}),{data:_}=B({}),y=t(()=>{let e=new Map;for(let t of m??[])e.set(t.id,t.name);return e},[m]),S=t(()=>{let e=new Map;for(let t of _??[])e.set(t.id,t.displayName);return e},[_]),C=t(()=>{let e=_??[];return e.find(e=>e.type===`recordings`&&e.enabled!==!1)?.id??e.find(e=>e.type===`recordings`)?.id??null},[_]),w=t(()=>f?.locations??[],[f?.locations]),T=t(()=>Bt(w,S,C),[w,S,C]),E=t(()=>Ie(w),[w]),O=n(()=>{o.invalidateQueries({queryKey:Vt})},[o]),k=ye({onSuccess:O}),j=_e({onSuccess:O}),M=n(async e=>{await c({title:i(`recordings.storageSection.prune`,`Prune {{label}}?`,{label:y.get(e.deviceId)??`#${String(e.deviceId)}`}),message:i(`recordings.storageSection.appliesTheRetentionPolicyNow`,`Applies the retention policy now (reason: {{reason}}). Footage beyond the policy is permanently deleted.`,{reason:u}),confirmLabel:i(`recordings.storageSection.pruneNow`,`Prune now`),variant:`danger`})&&k.mutate({deviceId:e.deviceId,reason:u})},[c,k,u,y,i]),N=n(async e=>{await c({title:i(`recordings.storageSection.deleteAllFootageFor`,`Delete all footage for {{label}}?`,{label:y.get(e.deviceId)??`#${String(e.deviceId)}`}),message:i(`recordings.storageSection.permanentlyDeletesOfRecordedFootage`,`Permanently deletes {{value1}} of recorded footage for this camera. This cannot be undone.`,{value1:W(e.usedBytes)}),confirmLabel:i(`recordings.storageSection.delete`,`Delete {{value1}}`,{value1:W(e.usedBytes)}),variant:`danger`})&&j.mutate({deviceId:e.deviceId})},[c,j,y,i]),P=t(()=>[{key:`camera`,header:i(`recordings.storageSection.camera`,`Camera`),render:e=>r(`span`,{className:`text-foreground`,children:y.get(e.deviceId)??`#${String(e.deviceId)}`})},{key:`disk`,header:i(`recordings.storageSection.disk`,`Disk`),nowrap:!0,render:()=>T===null?r(`span`,{className:`text-foreground-subtle`,children:`—`}):e(`span`,{className:T.exact?`text-foreground`:`text-foreground-subtle`,title:T.exact?i(`recordings.storageSection.theOnlyRecordingsVolumeOn`,`The only recordings volume on this node — this camera can only be here.`):i(`recordings.storageSection.theRecordingsDefaultThisNode`,`The recordings DEFAULT. This node has several recordings volumes and the per-camera placement is not reported by recording.getStorageUsage, so this is where footage lands by default rather than a per-camera fact.`),children:[T.label,!T.exact&&r(`span`,{className:`ml-1 text-foreground-subtle`,children:i(`recordings.storageSection.default`,`(default)`)})]})},{key:`used`,header:i(`recordings.storageSection.used`,`Used`),align:`right`,nowrap:!0,render:e=>r(`span`,{className:`tabular-nums`,children:W(e.usedBytes)})},{key:`oldest`,header:i(`recordings.storageSection.oldestFootage`,`Oldest footage`),align:`right`,nowrap:!0,render:e=>r(`span`,{className:`tabular-nums text-foreground-subtle`,title:i(`recordings.storageSection.theOldestSegmentTheArchive`,`The oldest segment the ARCHIVE holds for this camera — the per-camera answer to 'is retention actually holding?'.`),children:Gt(e.oldestMs)})},{key:`actions`,header:``,align:`right`,render:t=>e(`div`,{className:`flex items-center justify-end gap-1`,children:[e(V,{variant:`unstyled`,onClick:()=>{M(t)},disabled:k.isPending,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-foreground-subtle hover:bg-amber-500/10 hover:text-amber-500 disabled:opacity-50`,title:i(`recordings.storageSection.applyRetentionPolicyNow`,`Apply retention policy now`),children:[r(D,{className:`h-3 w-3`}),i(`recordings.storageSection.prune2`,`Prune`)]}),e(V,{variant:`unstyled`,onClick:()=>{N(t)},disabled:j.isPending,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-danger hover:bg-danger/10 disabled:opacity-50`,title:i(`recordings.storageSection.deleteAllFootage`,`Delete all footage`),children:[r(x,{className:`h-3 w-3`}),i(`common.delete`,`Delete`)]})]})}],[y,T,M,N,k.isPending,j.isPending,i]);if(p&&!f)return e(`div`,{className:`flex items-center gap-2 py-8 text-xs text-foreground-subtle`,children:[r(l,{className:`h-4 w-4 animate-spin`}),i(`recordings.storageSection.loadingStorageUsage`,`Loading storage usage…`)]});if(!f)return r(I,{icon:g,title:i(`recordings.storageSection.noStorageData`,`No storage data`),description:i(`recordings.storageSection.theRecordingNodeHasNot`,`The recording node has not reported any storage usage yet.`)});let F=f.devices.length;return e(`div`,{className:`flex flex-col gap-6`,children:[e(`section`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:[r(h,{label:i(`recordings.storageSection.totalUsed`,`Total used`),icon:r(g,{className:`h-3 w-3`}),footer:`${String(F)} camera${F===1?``:`s`} on ${f.nodeId}`,children:W(f.totalUsedBytes)}),E!==null&&E.severity!==null&&r(h,{label:i(`recordings.storageSection.freeOnRecordingsVolumes`,`Free on recordings volumes`),icon:r(g,{className:`h-3 w-3`}),footer:`across ${String(E.knownVolumes)} volume${E.knownVolumes===1?``:`s`} of ${W(E.totalBytes)}`+(E.unknownVolumes>0?` · ${String(E.unknownVolumes)} did not report capacity`:``),children:r(`span`,{className:`tabular-nums ${Wt[E.severity]}`,children:W(E.freeBytes)})}),w.map(t=>{let n=Fe(t),a=t.locationId??t.root??`default`;return r(h,{label:i(`recordings.storageSection.disk2`,`Disk: {{label}}`,{label:Kt(t,S)}),footer:n===null?`${W(t.usedBytes)} of recordings · volume capacity unknown`:`${W(n.freeBytes)} free of ${W(n.totalBytes)} · ${W(t.usedBytes)} recordings (${$(n.recordingsFraction)})`,children:n===null?r(`span`,{className:`tabular-nums`,children:W(t.usedBytes)}):e(`div`,{className:`flex items-center gap-2`,title:i(`recordings.storageSection.volumeFillEverythingOnThe`,`Volume fill — everything on the disk, not only recordings. Warn at 85%, critical at 95%.`),children:[r(`div`,{className:`h-2 flex-1 overflow-hidden rounded bg-muted`,children:r(`div`,{className:`h-full rounded ${Ut[n.severity]}`,style:{width:$(n.fraction)}})}),r(`span`,{className:`tabular-nums text-xs ${Wt[n.severity]}`,children:$(n.fraction)})]})},a)})]}),e(`section`,{className:`flex items-center gap-2 text-xs`,children:[r(`label`,{htmlFor:`prune-reason`,className:`text-foreground-subtle`,children:i(`recordings.storageSection.pruneReason`,`Prune reason`)}),r(b,{wrapperClassName:`inline-block w-auto`,id:`prune-reason`,value:u,onChange:e=>{let t=Ht.find(t=>t.value===e.target.value);t&&d(t.value)},children:Ht.map(e=>r(`option`,{value:e.value,children:i(e.labelKey)},e.value))})]}),F===0?r(I,{icon:g,title:f.devicesRead===`unavailable`?i(`recordings.storageSection.perCameraUsageUnavailable`,`Per-camera usage unavailable`):i(`recordings.storageSection.noRecordedFootage`,`No recorded footage`),description:f.devicesRead===`unavailable`?i(`recordings.storageSection.thisRecordingNodeHasNo`,`This recording node has no footage ledger, so it refused to answer the per-camera table rather than report what it happens to hold in memory. The disk totals above are unaffected.`):i(`recordings.storageSection.noCameraHasRecordedFootage`,`No camera has recorded footage on this node yet.`)}):r(A,{columns:P,rows:[...f.devices],rowKey:e=>e.deviceId,minWidthPx:480})]})}function Jt(){let{t}=U();return e(`div`,{className:`flex flex-col gap-8`,children:[e(`div`,{children:[r(`h2`,{className:`text-sm font-semibold text-foreground`,children:t(`recordings.recordingsStorageSection.footageOnDisk`,`Footage on disk`)}),r(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:t(`recordings.recordingsStorageSection.whatRecordedFootageOccupiesPer`,`What recorded footage occupies, per camera and per volume, with prune-by-policy and delete-all-footage.`)}),r(`div`,{className:`mt-3`,children:r(qt,{})})]}),e(`div`,{children:[r(`h2`,{className:`text-sm font-semibold text-foreground`,children:t(`recordings.recordingsStorageSection.recordingNodeFolders`,`Recording node & folders`)}),r(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:t(`recordings.recordingsStorageSection.theSingleNodeThatRecords`,`The single node that records and serves playback, and the storage locations footage is written to.`)}),r(`div`,{className:`mt-3`,children:r(Lt,{})})]})]})}function Yt(){let{t:e}=U(),t=je(`/recordings`,{t:e,isAdmin:!0})??{icon:y,title:e(`nav.recordings`,`Recordings`)};return r(Ne,{icon:t.icon,title:t.title,subtitle:e(`recordings.recordedFootageAndTheDurable`,`Recorded footage and the durable event store — what each occupies, where it is written, and the operations that move or reconcile both.`),defaultSection:`storage`,sectionsLabel:`${t.title} sections`,sections:[{id:`storage`,label:e(`recordings.recordings`,`Recordings`),content:r(Jt,{})},{id:`events`,label:e(`recordings.events`,`Events`),content:r(Ze,{})},{id:`cameras`,label:e(`recordings.cameras`,`Cameras`),content:r(Ue,{})},{id:`exports`,label:e(`recordings.export`,`Export`),content:r(ft,{})},{id:`activity`,label:e(`recordings.activity`,`Activity`),content:r(He,{})},{id:`management`,label:e(`recordings.management`,`Management`),content:r(Nt,{})}]})}export{Yt as RecordingsPage};
@@ -1,2 +0,0 @@
1
- import{C as e,K as t,S as n,V as r,Y as i,et as a}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{D as o,Fr as s,Ga as c,Mn as l,Nn as u,Ua as d,Ui as f,Za as p,ct as m,dt as h,en as g,pi as ee,ut as _,wt as v}from"./player-overlays-VrMHBBfa.js";import{js as y}from"./client-CBrsD14Q.js";import{a as b,i as x,l as S,o as C}from"./terminal-DU-tvcEm.js";import{$f as w,Ai as T,Ar as E,Fi as D,Jr as te,Kr as O,Li as ne,Ni as k,Ns as re,Op as A,Or as j,Pi as M,Qf as N,Ri as ie,Sr as P,Wf as F,X as I,Y as L,Yr as R,br as z,et as ae,fa as B,ft as V,jf as H,ji as U,jr as oe,ki as W,la as se,ma as G,ri as K,tt as ce,xr as le}from"./src-bJ4Hy4Cl.js";import{t as q}from"./i18n-BFxrpjSx.js";import{t as J}from"./useTranslation-BJr-n0es.js";import{F as ue,i as de,li as fe}from"./index-1bBrNxAK.js";a();function Y({id:t,title:r,icon:i,description:a,actions:s,tone:l=`default`,notice:u=null,onDismissNotice:d,children:f}){return n(j,{headingId:`access-${t}`,title:r,icon:i,actions:s,testId:`access-${t}`,children:e(`div`,{className:`${o} space-y-3`,children:[n(`div`,{className:c(`text-[11px] leading-relaxed`,l===`danger`?`rounded-md border border-danger/30 bg-danger/5 px-3 py-2 text-foreground`:`text-foreground-subtle`),children:a}),u!==null&&n(X,{notice:u,onDismiss:d}),f]})})}var pe={success:{icon:f,line:`border-success/30 text-foreground`,mark:`text-success`},danger:{icon:x,line:`border-danger/40 text-danger`,mark:`text-danger`}};function X({notice:t,onDismiss:r}){let{t:i}=J(),a=pe[t.tone],o=a.icon;return e(`div`,{role:t.tone===`danger`?`alert`:`status`,className:c(`flex items-start gap-2 rounded-md border bg-surface px-3 py-2 text-[11px]`,a.line),children:[n(o,{className:c(`mt-0.5 h-3.5 w-3.5 shrink-0`,a.mark),"aria-hidden":!0}),n(`span`,{className:`min-w-0 flex-1`,children:t.message}),r!==void 0&&n(w,{type:`button`,variant:`ghost`,size:`sm`,icon:v,"aria-label":i(`access.accessSection.dismiss`,`Dismiss`),onClick:r,className:`-my-1 h-5 w-5`})]})}function me(){let{data:e}=H();return t(()=>{let t=new Map;for(let n of e??[])t.set(n.id,n.username);return t},[e])}function he(e,t=null){return e===null?t:{tone:`danger`,message:e}}var ge={active:`access.credentialColumns.statusActive`,expired:`access.credentialColumns.statusExpired`,revoked:`access.credentialColumns.statusRevoked`,current:`access.credentialColumns.statusCurrent`};function _e(e){return q.t(ge[e])}var ve={active:`success`,expired:`warning`,revoked:`default`,current:`info`},ye={current:0,active:1,expired:2,revoked:3};function be(e,t){if(e===null)return t;let n=new Date(e);return Number.isNaN(n.getTime())?`—`:n.toLocaleString()}function xe({status:e}){return n(G,{variant:ve[e],className:`text-[10px]`,children:_e(e)})}function Se({row:t,action:r}){if(!r.isAvailable(t))return null;let i=r.icon,a=r.busyId===t.id;return e(F,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>r.onRun(t),disabled:r.disabled,"aria-label":q.t(`access.credentialColumns.actionOn`,{action:r.label,name:t.name}),className:r.tone===`neutral`?void 0:`text-danger hover:bg-danger/10`,children:[a?n(s,{className:`h-3 w-3 animate-spin`,"aria-hidden":!0}):n(i,{className:`h-3 w-3`,"aria-hidden":!0}),r.label]})}function Ce(t){return[{key:`name`,header:q.t(`access.credentialColumns.name`,`Name`),sortValue:e=>e.name.toLowerCase(),render:t=>e(`div`,{className:`min-w-0 max-w-[18rem]`,children:[n(`div`,{className:`truncate font-medium text-foreground`,title:t.name,children:t.name}),t.detail!==null&&n(`div`,{className:`truncate font-mono text-[10px] text-foreground-subtle`,title:t.detail,children:t.detail})]})},t.hideOwner?null:{key:`owner`,header:q.t(`access.credentialColumns.owner`,`Owner`),sortValue:e=>e.ownerName.toLowerCase(),render:e=>e.ownerName},{key:`kind`,header:q.t(`access.credentialColumns.kindScope`,`Kind / scope`),sortValue:e=>e.kind.toLowerCase(),nowrap:!1,render:t=>e(`div`,{className:`min-w-[8rem] max-w-[16rem]`,children:[n(`div`,{className:`text-foreground`,children:t.kind}),t.scope!==null&&n(`div`,{className:`line-clamp-2 text-[10px] text-foreground-subtle`,title:t.scope,children:t.scope})]})},{key:`status`,header:q.t(`access.credentialColumns.status`,`Status`),sortValue:e=>ye[e.status],render:e=>n(xe,{status:e.status})},{key:`created`,header:q.t(`access.credentialColumns.created`,`Created`),sortValue:e=>e.createdAt,render:e=>n(`span`,{className:`text-foreground-subtle`,children:be(e.createdAt,`—`)})},{key:`lastUsed`,header:q.t(`access.credentialColumns.lastUsed`,`Last used`),sortValue:e=>e.lastUsedAt,render:e=>n(`span`,{className:`text-foreground-subtle`,children:be(e.lastUsedAt,q.t(`access.credentialColumns.never`))})},{key:`expires`,header:q.t(`access.credentialColumns.expires`,`Expires`),sortValue:e=>e.expiresAt,render:e=>n(`span`,{className:`text-foreground-subtle`,children:be(e.expiresAt,t.expiresNone)})},t.action===null?null:{key:`actions`,header:``,align:`right`,notSortableReason:q.t(`access.credentialColumns.actionsHeader`),render:e=>n(`div`,{className:`flex items-center justify-end gap-1`,children:[...t.extraActions??[],t.action].map(t=>t===null?null:n(Se,{row:e,action:t},t.label))})}].filter(e=>e!==null)}a();var Z=6,we={"current-session":`access.bulk.skipCurrentSession`,"not-active":`access.bulk.skipNotActive`};function Te(e){let t=we[e];return t===void 0?e:q.t(t)}function Ee(e,t){return q.t(t.key,{count:e})}function Q(e,t){return q.t(`access.bulk.countOf`,{count:e,noun:Ee(e,t)})}function De(e){let t=new Map;for(let n of e)t.set(n.status,(t.get(n.status)??0)+1);return[...t.entries()].map(([e,t])=>q.t(`access.bulk.statusCount`,{count:t,status:_e(e).toLowerCase()})).join(`, `)}function Oe(e,t){let n=e.slice(0,Z).map(e=>`• ${e.name} — ${e.ownerName}`),r=e.length>Z?[q.t(`access.bulk.previewMore`,{count:e.length-Z})]:[];return[q.t(`access.bulk.previewIntro`,{what:Q(e.length,t),breakdown:De(e)}),``,...n,...r].join(`
2
- `)}async function ke(e,t,n){let r=String(t.length),i=await e({title:q.t(`access.bulk.confirmTitle`,{what:Q(t.length,n)}),message:Oe(t,n),label:q.t(`access.bulk.confirmLabel`,{expected:r}),placeholder:r,confirmLabel:q.t(`access.bulk.confirmButton`,{expected:r}),variant:`danger`,validate:e=>e.trim()===r?null:q.t(`access.bulk.confirmMismatch`,{expected:r,noun:Ee(2,n)})});return i!==null&&i.trim()===r}function Ae(e,t){let n=_(),r=A.auth.revokeCredentials.useMutation(),[a,o]=i(null);return{run:async i=>{if(i.length===0||!await ke(n,i,e))return!1;o(null);try{let t=await r.mutateAsync({ids:i.map(e=>e.id),confirmCount:i.length}),n=t.skipped.map(e=>Te(e.reason));return o({tone:`success`,message:n.length>0?q.t(`access.bulk.revokedSkipped`,{what:Q(t.revoked.length,e),count:n.length,reasons:[...new Set(n)].join(`, `)}):q.t(`access.bulk.revoked`,{what:Q(t.revoked.length,e)})}),!0}catch(e){return o({tone:`danger`,message:q.t(`access.bulk.revokeFailed`,{error:e instanceof Error?e.message:q.t(`access.bulk.requestFailed`)})}),!1}finally{t()}},busy:r.isPending,outcome:a,dismiss:()=>o(null)}}function je(e,t,n){let r=_(),[a,o]=i(!1),[s,c]=i(null);return{run:async i=>{if(i.length===0||!await ke(r,i,e))return!1;c(null),o(!0);let a=[],s=0;for(let e of i)try{await t(e.id),s+=1}catch(t){a.push(`${e.name}: ${t instanceof Error?t.message:q.t(`access.bulk.requestFailed`)}`)}return o(!1),n(),a.length===0?(c({tone:`success`,message:q.t(`access.bulk.revoked`,{what:Q(s,e)})}),!0):(c({tone:`danger`,message:q.t(a.length>3?`access.bulk.eachPartialMore`:`access.bulk.eachPartial`,{what:Q(s,e),count:a.length,details:a.slice(0,3).join(`; `)})}),s>0)},busy:a,outcome:s,dismiss:()=>c(null)}}a();var Me={searchText:e=>[e.name,e.detail??``,e.ownerName,e.kind,e.scope??``],facetGroups:[{id:`status`,value:e=>e.status},{id:`owner`,value:e=>e.ownerName},{id:`kind`,value:e=>e.kind}]},Ne={status:`access.credentialTable.groupStatus`,owner:`access.credentialTable.groupOwner`,kind:`access.credentialTable.groupKind`},Pe=e=>e.status!==`current`,Fe=[`active`,`current`];function Ie({rows:r,label:a,isLoading:o,loadError:c,emptyText:l,hideOwner:u=!1,expiresNone:d,action:f,extraActions:p,bulk:m,defaultStatus:h=Fe}){let{t:g}=J(),[ee]=i(()=>h.length===0?{search:``,facets:[]}:{search:``,facets:[],groups:{status:[...h]}}),_=z(r,Me,ee),[v,y]=i(()=>new Set),b=d??g(`access.credentialColumns.never`),x=t(()=>Ce({hideOwner:u,expiresNone:b,action:f??null,...p===void 0?{}:{extraActions:p}}),[u,b,f,p,g]),S=t(()=>m===void 0?()=>!1:e=>Pe(e)&&m.isSelectable(e),[m]),C=t(()=>_.rows.filter(e=>v.has(e.id)&&S(e)),[_.rows,v,S]);return o?e(`div`,{className:`flex items-center gap-2 py-4 text-xs text-foreground-subtle`,children:[n(s,{className:`h-3.5 w-3.5 animate-spin`,"aria-hidden":!0}),g(`access.credentialTable.loading`,{label:a})]}):c===null?e(`div`,{className:`space-y-3`,children:[n(le,{state:_.state,facets:_.facets,groups:_.groups.filter(e=>!(u&&e.id===`owner`)).map(e=>({...e,label:Ne[e.id]===void 0?e.id:g(Ne[e.id]),...e.id===`status`?{facetLabel:e=>_e(e)}:{}})),labels:{searchPlaceholder:g(`access.credentialTable.searchPlaceholder`,{label:a}),searchLabel:g(`access.credentialTable.searchLabel`,{label:a}),facetsLabel:g(`access.credentialTable.facetsLabel`,{label:a}),clearLabel:g(`access.credentialTable.clearFilters`)},onSearch:_.setSearch,onToggleFacet:_.toggleFacet,onToggleGroupFacet:_.toggleGroupFacet,onClear:_.clear}),m!==void 0&&n(Le,{bulk:m,shown:_.rows.filter(S),targets:C,onSelect:y}),n(E,{columns:x,rows:_.rows,rowKey:e=>e.id,minWidthPx:u?760:860,maxBodyHeight:oe,defaultSort:{columnKey:`created`,dir:`desc`},pageSize:25,paginationLabels:{navLabel:g(`access.credentialTable.pagesLabel`,{label:a}),previous:g(`access.credentialTable.previousPage`),next:g(`access.credentialTable.nextPage`),range:(e,t,n)=>g(`access.credentialTable.range`,{from:e,to:t,total:n})},emptyMessage:_.active?g(`access.credentialTable.noMatchTheFilters`,`No {{label}} match the filters.`,{label:a}):l,rowClassName:e=>e.status===`revoked`||e.status===`expired`?`opacity-70`:void 0,...m===void 0?{}:{selection:{selected:v,onChange:y,isSelectable:S,rowLabel:e=>g(`access.credentialTable.rowLabel`,{name:e.name,owner:e.ownerName}),pageLabel:g(`access.credentialTable.pageLabel`,{noun:Ee(1,m.noun)})}}})]}):n(B,{title:g(`access.credentialTable.couldNotLoad`,`Could not load {{label}}`,{label:a}),message:c})}function Le({bulk:t,shown:r,targets:i,onSelect:a}){let{t:o}=J(),{revoke:c,noun:l}=t,u=(t.quickSelect??[]).map(e=>({...e,rows:r.filter(e.match)})).filter(e=>e.rows.length>0),d=async()=>{await c.run(i)&&a(new Set)};return e(`div`,{className:`flex flex-wrap items-center gap-2`,"data-testid":`bulk-bar`,children:[r.length>0&&n(F,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>a(new Set(r.map(e=>e.id))),children:o(`access.credentialTable.selectAllShown`,{count:r.length})}),u.map(t=>e(F,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>a(new Set(t.rows.map(e=>e.id))),children:[t.label,` (`,String(t.rows.length),`)`]},t.label)),i.length>0&&e(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[n(`span`,{className:`text-[11px] tabular-nums text-foreground`,"aria-live":`polite`,children:o(`access.credentialTable.selectedLabel`,{what:Q(i.length,l)})}),e(F,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>a(new Set),children:[n(v,{className:`h-3 w-3`,"aria-hidden":!0}),o(`access.credentialTable.clearSelection`,`Clear selection`)]}),e(F,{type:`button`,variant:`danger`,size:`sm`,disabled:c.busy,onClick:()=>void d(),children:[c.busy?n(s,{className:`h-3 w-3 animate-spin`,"aria-hidden":!0}):n(g,{className:`h-3 w-3`,"aria-hidden":!0}),o(`access.credentialTable.revoke`,{what:Q(i.length,l)})]})]})]})}var Re=(e,t)=>t===null?`—`:e.get(t)??t;function ze(e,t){return e!=null&&e<=t?`expired`:`active`}function Be(e,t,n){return{id:e.id,name:n.client(e.client),detail:e.ip,ownerId:e.userId,ownerName:Re(t,e.userId),kind:n.method(e.method),scope:null,status:e.current?`current`:`active`,createdAt:e.createdAt,lastUsedAt:e.lastUsedAt,expiresAt:e.expiresAt}}function Ve(e,t){return{id:e.id,name:e.integrationId,detail:null,ownerId:e.userId,ownerName:e.username,kind:e.integrationId,scope:t,status:e.revokedAt===null?`active`:`revoked`,createdAt:e.createdAt,lastUsedAt:e.lastUsedAt,expiresAt:null}}var He=`All permissions`,Ue=`View link`,We=`Scoped`,Ge={"grid-view":`Grid`,"events-view":`Events`};function Ke(e,t){return e.map(e=>t.get(e)??`#${String(e)}`).join(`, `)}function qe(e){return e!==`*`&&e.type===`share-view`&&`grant`in e}function Je(e,t,n){return e===`*`?He:qe(e)?`${`${Ge[e.grant.kind]} view${e.grant.talk===!0?` + talk`:``}`}: ${Ke(e.grant.deviceIds,t)}`:n(e)}function Ye(e){return e.includes(`*`)?He:e.some(qe)?Ue:We}function Xe(e,t,n,r){return{id:e.id,name:e.label,detail:null,ownerId:e.subjectId,ownerName:Re(t,e.subjectId),kind:Ye(e.scopes),scope:n,status:e.revokedAt===null?ze(e.expiresAt,r):`revoked`,createdAt:e.createdAt,lastUsedAt:e.lastUsedAt,expiresAt:e.expiresAt}}function Ze(e){return`${e.provider}\u0000${e.subject}`}function Qe(e,t){return{id:Ze(e),name:e.label??e.subject,detail:e.issuer,ownerId:e.userId,ownerName:Re(t,e.userId),kind:e.provider,scope:null,status:`active`,createdAt:e.linkedAt,lastUsedAt:null,expiresAt:null}}var $e=40,et=[{test:/Electron\//,name:`CamStack desktop`},{test:/Edg(e|A|iOS)?\//,name:`Edge`},{test:/OPR\/|Opera/,name:`Opera`},{test:/Firefox\/|FxiOS\//,name:`Firefox`},{test:/Chrome\/|CriOS\//,name:`Chrome`},{test:/Version\/[\d.]+.*Safari\//,name:`Safari`}],tt=[{test:/iPhone/,name:`iPhone`},{test:/iPad/,name:`iPad`},{test:/Android/,name:`Android`},{test:/Mac OS X|Macintosh/,name:`macOS`},{test:/Windows/,name:`Windows`},{test:/CrOS/,name:`ChromeOS`},{test:/Linux/,name:`Linux`}],nt=[{test:/CFNetwork\/.*Darwin\//,name:`CamStack app on iOS`},{test:/^okhttp\//i,name:`CamStack app on Android`},{test:/^(node|undici)\b/i,name:`Script (Node.js)`},{test:/^curl\//i,name:`curl`}];function rt(e,t){return e.find(e=>e.test.test(t))?.name??null}function it(e){return e.length<=$e?e:`${e.slice(0,$e)}…`}function at(e){if(e===null||e.trim().length===0)return{label:q.t(`helpers.sessionClient.unknownDevice`),raw:null};let t=e.trim(),n=rt(nt,t);if(n!==null)return{label:n,raw:t};let r=rt(et,t),i=rt(tt,t);return r!==null&&i!==null?{label:q.t(`helpers.sessionClient.browserOnSystem`,{browser:r,system:i}),raw:t}:r===null?{label:it(t),raw:t}:{label:r,raw:t}}var ot={password:`helpers.sessionClient.method.password`,passkey:`helpers.sessionClient.method.passkey`,sso:`helpers.sessionClient.method.sso`,handoff:`helpers.sessionClient.method.handoff`,"cli-approval":`helpers.sessionClient.method.cliApproval`,exchange:`helpers.sessionClient.method.exchange`};function st(e){let t=ot[e];return t===void 0?e:q.t(t)}function ct(e){if(e==null)return`—`;let t=new Date(e);return Number.isNaN(t.getTime())?`—`:t.toLocaleString()}function lt({token:t,label:r,onClose:i}){let{t:a}=J();return n(W,{open:!0,onOpenChange:e=>!e&&i(),children:e(U,{width:`md`,scroll:`body`,children:[n(M,{children:n(D,{children:a(`auth.tokenModals.token`,`Token: {{label}}`,{label:r})})}),e(T,{className:`space-y-3`,children:[n(`div`,{className:`rounded-md border border-warning/30 bg-warning/10 px-3 py-2 text-xs text-warning`,children:a(`auth.tokenModals.copyThisTokenNowOnce`,`Copy this token now. Once you close this dialog the secret cannot be displayed again.`)}),n(`div`,{className:`select-all break-all rounded-md border border-border bg-background p-2 font-mono text-[11px] text-foreground`,children:t})]}),e(k,{children:[n(P,{value:t,label:a(`common.copy`,`Copy`),srLabel:`token`}),n(F,{type:`button`,variant:`primary`,size:`sm`,onClick:i,children:a(`auth.tokenModals.done`,`Done`)})]})]})})}var ut={token:`newToken`,scoped:`newScoped`,admin:`newAdmin`};a();var dt=80,$=86400,ft=[{value:`1`,seconds:$},{value:`7`,seconds:7*$},{value:`30`,seconds:30*$},{value:`90`,seconds:90*$},{value:`never`,seconds:`never`}],pt=[y.Camera],mt=64,ht={type:`capability`,target:``,access:[`view`,`create`]};function gt({open:a,users:o,onClose:c,onSubmit:f,submitting:m,formError:g,awaitingProof:_}){let{t:v}=J(),y=p(),{user:b}=ue(),x=b?.isAdmin===!0,C=x?null:b?.scopes??[],[w,T]=i(`scopes`),[E,D]=i(b?.id??``),[k,re]=i(``),[A,j]=i([ht]),[M,P]=i([]),[z,ae]=i(`grid-view`),[B,V]=i(!1),[H,U]=i(`30`);r(()=>{a||(T(`scopes`),D(b?.id??``),re(``),j([ht]),P([]),ae(`grid-view`),V(!1),U(`30`))},[a,b?.id]),r(()=>{w!==`view-link`&&H===`never`&&U(`30`)},[w,H]);let oe=t(()=>ft.filter(e=>e.seconds!==`never`||w===`view-link`).map(e=>({value:e.value,label:e.seconds===`never`?v(`access.createTokenModal.never`,`Never (until revoked)`):v(`access.createTokenModal.days`,{count:Number(e.value)})})),[w,v]),W=k.trim(),G=w===`scopes`?I(A,y):null,le=[...M],q=ft.find(e=>e.value===H)?.seconds??30*$,de=()=>w===`all`?[`*`]:w===`view-link`?[{type:`share-view`,grant:{kind:z,deviceIds:le,...B?{talk:!0}:{}}}]:A,Y=W.length>0&&W.length<=dt&&!m&&!_&&(w===`all`?x:w===`view-link`?le.length>0:A.length>0&&G===null),pe=()=>{if(!Y)return;let e=x&&w!==`all`&&E!==``&&E!==b?.id;f({scopes:de(),expiresIn:q,label:W,...e?{subjectId:E}:{}})},X=w===`all`,me=X?u:l;return n(ce,{open:a,onClose:c,title:v(`access.createTokenModal.createToken`,`Create token`),icon:X?u:S,error:g,width:`md`,testId:`create-token-dialog`,footer:e(F,{type:`button`,variant:X?`danger`:`primary`,size:`sm`,onClick:pe,disabled:!Y,"data-testid":`create-token-submit`,children:[m||_?n(s,{className:`h-3.5 w-3.5 animate-spin`,"aria-hidden":!0}):n(me,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),v(`access.createTokenModal.issueToken`,`Issue token`)]}),children:e(`div`,{className:`space-y-3`,children:[e(`div`,{className:`space-y-1`,children:[n(K,{children:v(`access.createTokenModal.whatItMayDo`,`What it may do`)}),n(O,{appearance:`pills`,value:w,onValueChange:e=>{(e===`scopes`||e===`view-link`||e===`all`)&&T(e)},children:e(te,{"aria-label":v(`access.createTokenModal.whatItMayDo`,`What it may do`),children:[e(R,{value:`scopes`,"data-testid":`token-reach-scopes`,children:[n(l,{className:`h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),v(`access.createTokenModal.reachScopes`,`Scopes`)]}),e(R,{value:`view-link`,"data-testid":`token-reach-view-link`,children:[n(ee,{className:`h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),v(`access.createTokenModal.reachViewLink`,`View link`)]}),x?e(R,{value:`all`,"data-testid":`token-reach-all`,children:[n(u,{className:`h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),v(`access.createTokenModal.reachAll`,`All permissions`)]}):null]})})]}),X?n(`div`,{className:`space-y-1 rounded-md border border-danger/30 bg-danger/5 px-3 py-2 text-[11px] leading-relaxed text-foreground`,"data-testid":`admin-token-warning`,children:n(`p`,{children:n(fe,{i18nKey:`auth.adminTokenNoticeShort`,components:{strong:n(`strong`,{})}})})}):null,x&&w!==`all`&&o.length>1?e(`div`,{className:`space-y-1`,children:[n(K,{htmlFor:`token-user`,children:v(`access.createTokenModal.onBehalfOfUser`,`On behalf of user`)}),n(h,{id:`token-user`,value:E,onChange:e=>D(e.target.value),options:o.map(e=>({value:e.id,label:e.username}))})]}):null,e(`div`,{className:`space-y-1`,children:[n(K,{htmlFor:`token-name`,children:v(`access.createTokenModal.label`,`Label`)}),n(N,{id:`token-name`,value:k,maxLength:dt,required:!0,onChange:e=>re(e.target.value),placeholder:w===`view-link`?`kitchen-wall`:`nightly-backup`,autoFocus:!0})]}),w===`scopes`?e(`div`,{className:`space-y-1`,children:[n(K,{children:v(`access.createTokenModal.scopes`,`Scopes`)}),n(L,{value:A,onChange:j,clampToParent:C}),G&&n(`p`,{className:`text-[10px] text-danger`,children:G}),n(`p`,{className:`text-[10px] text-foreground-subtle`,children:v(`access.createTokenModal.eachScopePicksACap`,`Each scope picks a (cap or addon) target + one or more access flavours. The token can access ONLY what's listed.`)})]}):null,w===`view-link`?e(`div`,{className:`space-y-2`,"data-testid":`token-view-link`,children:[e(`div`,{className:`space-y-1`,children:[n(K,{htmlFor:`token-view-cameras`,children:v(`access.createTokenModal.cameras`,`Cameras`)}),n(se,{id:`token-view-cameras`,multiple:!0,pick:`device`,noun:`camera`,fixedTypes:pt,maxItems:mt,recentKey:`token-view-cameras`,testId:`token-view-cameras`,value:ie(M),onChange:e=>P(ne(e))})]}),e(`div`,{className:`space-y-1`,children:[n(K,{htmlFor:`token-view-kind`,children:v(`access.createTokenModal.viewKind`,`Shows`)}),n(h,{id:`token-view-kind`,value:z,onChange:e=>ae(e.target.value===`events-view`?`events-view`:`grid-view`),options:[{value:`grid-view`,label:v(`access.createTokenModal.viewGrid`,`Live grid`)},{value:`events-view`,label:v(`access.createTokenModal.viewEvents`,`Events`)}]})]}),z===`grid-view`?e(`label`,{className:`flex items-start gap-2 text-sm text-foreground`,children:[n(d,{className:`mt-0.5`,checked:B,onChange:e=>V(e.target.checked),"data-testid":`token-view-talk`}),n(`span`,{children:v(`access.createTokenModal.talk`,`Allow talk-back on these cameras`)})]}):null]}):null,e(`div`,{className:`space-y-1`,children:[n(K,{htmlFor:`token-lifetime`,children:v(`access.createTokenModal.expires`,`Expires after`)}),n(h,{id:`token-lifetime`,value:H,onChange:e=>U(e.target.value),options:oe})]})]})})}a();var _t={key:`access.nouns.token`};function vt(e){return typeof e==`object`&&!!e&&`kind`in e}function yt(e,t){let n=e.access===void 0?``:` [${e.access.join(`, `)}]`;return e.type===`device`?`device:[${vt(e.selector)?V(e.selector,t):`?`}]${n}`:e.type===`addon-routes`?`${t(`access.tokensSection.everyAddonRoutes`,`every addon's routes`)}${n}`:`${e.type}:${e.target??``}${n}`}function bt({headerOwnsCreate:a=!1,createRequested:o=!1,onCreateConsumed:s,ownOnly:c=!1}){let{t:l}=J(),u=p(),{user:d}=ue(),f=m(),h=A.useUtils(),ee=me(),{data:_}=H(),v=t(()=>_??[],[_]),{data:y}=re({}),b=t(()=>{let e=new Map;for(let t of y??[])e.set(t.id,t.name);return e},[y]),x=A.auth.listTokens.useQuery(void 0),{requestProof:C,dialog:w}=de(`Creating a token with all permissions`),{state:T,openNew:E,close:D}=ae({newKey:ut.token}),[te,O]=i(null),[ne,k]=i(null),[j,M]=i(!1),[N,ie]=i(null),[P,I]=i(null);r(()=>{o&&(E(),s?.())},[o,E,s]);let L=()=>{h.auth.listTokens.invalidate(),h.auth.listAuthAudit.invalidate()},R=A.auth.mintToken.useMutation({onSuccess:({token:e,record:t})=>{L(),D(),k(null),M(!1),ie({token:e,label:t.label})},onError:e=>{k(`Create failed: ${e.message}`),M(!1)}}),z=A.auth.revokeToken.useMutation({onSuccess:()=>{I(null),L()},onError:e=>{I(null),O(`Revoke failed: ${e.message}`)}}),B=Ae(_t,L),V=Date.now(),U=(x.data??[]).filter(e=>!c||e.subjectId===d?.id).map(e=>Xe(e,ee,e.scopes.includes(`*`)?null:e.scopes.map(e=>Je(e,b,e=>yt(e,u))).join(`, `),V)),oe=async e=>{await f({title:l(`access.tokensSection.revoke`,`Revoke "{{name}}"?`,{name:e.name}),message:e.kind===`All permissions`?l(`access.tokensSection.everyScriptUsingItLoses`,`Every script using it loses access immediately. This cannot be undone.`):l(`access.tokensSection.stopsWorking`,`Whoever holds it loses access immediately. This cannot be undone.`),confirmLabel:l(`access.tokensSection.revoke2`,`Revoke`),variant:`danger`})&&(O(null),I(e.id),z.mutate({id:e.id}))},W=e=>{(async()=>{O(null),k(null);let t;if(e.scopes.includes(`*`)){M(!0);let e=await C();if(M(!1),e===null)return;t=e}R.mutate({scopes:[...e.scopes],expiresIn:e.expiresIn,label:e.label,...e.subjectId===void 0?{}:{subjectId:e.subjectId},...t===void 0?{}:{reauthToken:t}})})()};return e(`div`,{"data-testid":`tokens`,children:[w,n(Y,{notice:he(te,B.outcome),onDismissNotice:()=>{O(null),B.dismiss()},id:c?`my-tokens`:`tokens`,title:c?l(`access.tokensSection.myTokens`,`My tokens`):l(`access.tokensSection.tokens`,`Tokens`),icon:S,actions:a?void 0:e(F,{size:`sm`,type:`button`,"data-testid":`tokens-new`,onClick:E,children:[n(S,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),l(`system.access.newToken`,`New token`)]}),description:l(`access.tokensSection.oneFormat`,`Every token is its scopes: a few permissions for a script, all permissions for an admin script, or a view of some cameras for a share link. Revoking one stops it on its next use.`),children:n(Ie,{rows:U,label:l(`common.tokensLabel`),isLoading:x.isLoading,loadError:x.isError?x.error?.message??`Request failed`:null,emptyText:l(`access.tokensSection.noTokens`,`No tokens.`),action:{label:l(`access.tokensSection.revoke2`,`Revoke`),icon:g,isAvailable:e=>e.status===`active`,onRun:e=>void oe(e),busyId:P,disabled:B.busy||P!==null},...d?.isAdmin===!0?{bulk:{revoke:B,noun:_t,isSelectable:e=>e.status===`active`}}:{}})}),n(gt,{open:T.mode===`new`,users:v.map(e=>({id:e.id,username:e.username})),onClose:()=>{D(),k(null),M(!1)},submitting:R.isPending,formError:ne,awaitingProof:j,onSubmit:W}),N&&n(lt,{token:N.token,label:N.label,onClose:()=>ie(null)})]})}var xt=864e5,St={qr:`QR (by an admin)`,self:`Self-enrolled`},Ct={ios:`iOS`,android:`Android`,web:`Web`,other:`Other`};function wt(e){return e.status===`revoked`}function Tt(e){return e.status!==`revoked`}function Et(e,t=`—`){if(e===null)return t;let n=new Date(e);return Number.isNaN(n.getTime())?t:n.toLocaleString()}function Dt(e,t){return e===null||Number.isNaN(e)?null:Math.floor((e-t)/xt)}function Ot(e,t){let n=Dt(e,t);return n===null?`unknown`:n<0?`expired`:n<30?`soon`:`ok`}function kt(e,t){let n=Dt(e,t);return n===null?q.t(`helpers.certificateModel.unknown`):n===0?q.t(`helpers.certificateModel.today`):n>0?q.t(`helpers.certificateModel.inDays`,{count:n}):q.t(`helpers.certificateModel.daysAgo`,{count:-n})}function At(e){if(e===null)return null;let t=Date.parse(e);return Number.isNaN(t)?null:t}function jt(e){return e===null||e.length===0?`—`:e.length<=17?e:`${e.slice(0,8)}…${e.slice(-8)}`}function Mt(e){return e.length<=10?e:`${e.slice(0,10)}…`}function Nt(e){if(!e.online)return{allowed:!1,reason:q.t(`helpers.certificateModel.nodeOffline`)};if(e.isHub&&e.https.kind===`served`){if(e.https.status.mode===`uploaded`)return{allowed:!1,reason:q.t(`helpers.certificateModel.uploadedCert`)};if(e.https.status.mode===`disabled`)return{allowed:!1,reason:q.t(`helpers.certificateModel.tlsDisabled`)}}return{allowed:!0,reason:null}}var Pt={prepare:`helpers.certificateModel.stage.prepare`,issue:`helpers.certificateModel.stage.issue`,install:`helpers.certificateModel.stage.install`,reconnect:`helpers.certificateModel.stage.reconnect`,confirm:`helpers.certificateModel.stage.confirm`};function Ft(e){if(e.ok)return{tone:`success`,message:q.t(`helpers.certificateModel.renewed`,{nodeId:e.nodeId,serial:Mt(e.newSerial)})};let t=e.keptPreviousLeaf?q.t(`helpers.certificateModel.keptPrevious`):q.t(`helpers.certificateModel.maybeNoCert`);return{tone:`danger`,message:q.t(`helpers.certificateModel.renewalFailed`,{nodeId:e.nodeId,stage:q.t(Pt[e.stage]),reason:e.reason,kept:t})}}function It(e,t){let n=Math.max(0,e-t),r=Math.ceil(n/1e3),i=Math.floor(r/60),a=r%60;return{expired:n===0,label:`${String(i)}:${String(a).padStart(2,`0`)}`}}var Lt=11;function Rt(e,t){let n=e.slice(0,Lt);return t===null?n:`${n} · ${t}`}function zt(e){return{id:e.id,name:e.deviceName,detail:Rt(e.fingerprint,e.lastUsedFrom),ownerId:e.userId,ownerName:e.username??e.userId,kind:Ct[e.platform],scope:St[e.enrolledVia],status:e.status,createdAt:e.issuedAt,lastUsedAt:e.lastUsedAt,expiresAt:e.expiresAt}}function Bt(e,t){return{id:e.id,name:e.deviceName,detail:null,ownerId:null,ownerName:t,kind:Ct[e.platform],scope:null,status:e.status,createdAt:e.issuedAt,lastUsedAt:e.lastUsedAt,expiresAt:e.expiresAt}}function Vt({sessions:t,isLoading:r,loadError:i,emptyText:a,onRevoke:o,revokingId:c}){let{t:l}=J();return r?e(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[n(s,{className:`h-3.5 w-3.5 animate-spin`}),l(`auth.sessionsList.loadingSessions`,`Loading sessions…`)]}):i===null?t.length===0?n(`div`,{className:`rounded border border-dashed border-border px-3 py-4 text-xs text-foreground-subtle text-center`,children:a}):n(`ul`,{className:`divide-y divide-border rounded-md border border-border`,children:t.map(e=>n(Ht,{session:e,revoking:c===e.id,onRevoke:()=>o(e)},e.id))}):e(`div`,{className:`text-[11px] text-danger`,children:[l(`auth.sessionsList.couldNotLoadSessions`,`Could not load sessions:`),` `,i]})}function Ht({session:t,revoking:r,onRevoke:i}){let{t:a}=J(),o=at(t.client);return e(`li`,{"data-testid":`session-row`,className:`flex items-start gap-3 px-3 py-2 text-xs`,children:[n(b,{className:`h-3.5 w-3.5 mt-0.5 shrink-0 text-foreground-subtle`}),e(`div`,{className:`flex-1 min-w-0 space-y-0.5`,children:[e(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[n(`span`,{className:`font-medium text-foreground truncate`,title:o.raw??void 0,children:o.label}),t.current&&n(`span`,{className:`rounded bg-primary/10 px-1.5 py-0.5 text-[10px] font-medium text-primary`,children:a(`auth.sessionsList.thisDevice`,`This device`)})]}),e(`div`,{className:`flex flex-wrap gap-x-3 text-[11px] text-foreground-subtle`,children:[n(`span`,{children:st(t.method)}),n(`span`,{className:`font-mono`,children:t.ip??a(`auth.sessionsList.ipUnknown`,`IP unknown`)}),n(`span`,{children:a(`auth.sessionsList.lastActive`,{when:ct(t.lastUsedAt)})}),n(`span`,{children:a(`auth.sessionsList.expires`,{when:ct(t.expiresAt)})})]})]}),!t.current&&e(F,{variant:`unstyled`,onClick:i,disabled:r,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] text-danger hover:bg-danger/10 disabled:opacity-50`,children:[r?n(s,{className:`h-3 w-3 animate-spin`}):n(C,{className:`h-3 w-3`}),a(`auth.sessionsList.signOut`,`Sign out`)]})]})}export{Be as C,Y as D,je as E,he as O,Ve as S,Ae as T,at as _,Tt as a,Ze as b,kt as c,Et as d,Nt as f,ut as g,bt as h,wt as i,me as k,Ft as l,Mt as m,zt as n,It as o,jt as p,Bt as r,At as s,Vt as t,Ot as u,st as v,Ie as w,Qe as x,ct as y};
@@ -1 +0,0 @@
1
- import"./src-bJ4Hy4Cl.js";