@camstack/addon-admin-ui 1.2.305 → 1.2.307

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 (86) hide show
  1. package/dist/assets/{AddonCollectionPage-Cl_qAbsl.js → AddonCollectionPage-BlnjptJq.js} +1 -1
  2. package/dist/assets/{Addons-DbxAcT9L.js → Addons-CFLe76ry.js} +1 -1
  3. package/dist/assets/{AdminTabs-BCENPGP0.js → AdminTabs-CIbVXHF1.js} +1 -1
  4. package/dist/assets/{AiProfiles-D2Anvjja.js → AiProfiles-B7_e4-Dk.js} +1 -1
  5. package/dist/assets/{BrokerForm-tbj3TTlT.js → BrokerForm-BuBHkQxf.js} +1 -1
  6. package/dist/assets/{Build-CccOFFWX.js → Build-Blf4IzFw.js} +3 -3
  7. package/dist/assets/{Capabilities-wtdNT9TU.js → Capabilities-CyawfSVE.js} +1 -1
  8. package/dist/assets/{CapabilityBadges-Bgy4Rib6.js → CapabilityBadges-BPnLNQy-.js} +1 -1
  9. package/dist/assets/{Cluster-DdBgI4d8.js → Cluster-CQgzBal7.js} +1 -1
  10. package/dist/assets/CompositionEditor-aIa-qSTI.js +1 -0
  11. package/dist/assets/{CompositionEditorPage-Bx_9IyNG.js → CompositionEditorPage-DbDCpjhY.js} +1 -1
  12. package/dist/assets/{Data-CqobbR8Z.js → Data-Donw-7W0.js} +1 -1
  13. package/dist/assets/{DetectionIntelligence-8BtmoZVG.js → DetectionIntelligence-DWJgfejB.js} +1 -1
  14. package/dist/assets/{DeviceAggregateSection-Y5MaJwRO.js → DeviceAggregateSection-B9l-qHib.js} +1 -1
  15. package/dist/assets/{DeviceDetail-NYe65jHy.js → DeviceDetail-geCSa8CL.js} +2 -2
  16. package/dist/assets/{Devices-B82gNjqQ.js → Devices-CozxrwRE.js} +1 -1
  17. package/dist/assets/{EmbedPlayerPage-CuM-FVlc.js → EmbedPlayerPage-DDuY9-SP.js} +1 -1
  18. package/dist/assets/{Events-CkXn8wzv.js → Events-DfRnvQKn.js} +1 -1
  19. package/dist/assets/{FormBuilder-CyIFzW5E.js → FormBuilder-DKW_99f4.js} +1 -1
  20. package/dist/assets/{Identity-D9qGHb3I.js → Identity-tX_F6JNY.js} +1 -1
  21. package/dist/assets/{IntegrationDetail-CUPBR6AV.js → IntegrationDetail-D-0Jl71F.js} +1 -1
  22. package/dist/assets/{Integrations-BTa40Hen.js → Integrations-CV2oW06j.js} +1 -1
  23. package/dist/assets/{Integrations-BDEavMy3.js → Integrations-CYIKE6OT.js} +1 -1
  24. package/dist/assets/{Locations-DSFZPgLY.js → Locations-BGod9NJ4.js} +2 -2
  25. package/dist/assets/{Logs-wN20yApp.js → Logs-CRGID0ok.js} +1 -1
  26. package/dist/assets/{ModelLicenses-DIb1l17k.js → ModelLicenses-Dp1DrE1h.js} +1 -1
  27. package/dist/assets/{MotionZonesSettings-CCgybLxG.js → MotionZonesSettings-DmK_8xfo.js} +1 -1
  28. package/dist/assets/{MyAccess-DDiGeFFp.js → MyAccess-igLD1UAC.js} +1 -1
  29. package/dist/assets/{Network-D-4lFCTl.js → Network-BPpAccv0.js} +1 -1
  30. package/dist/assets/{NodeAddonsSettingsPanel-BsNVBpch.js → NodeAddonsSettingsPanel-CNhqhDLO.js} +1 -1
  31. package/dist/assets/{NodeInferenceDevices-DnSMPjX3.js → NodeInferenceDevices-_rl5f9vI.js} +1 -1
  32. package/dist/assets/Notifications-DbYW-5zD.js +1 -0
  33. package/dist/assets/{Pipeline-pMK4xnan.js → Pipeline-x0ICzCh3.js} +1 -1
  34. package/dist/assets/{Plates-CFklDEQ6.js → Plates-BKwiI_k-.js} +1 -1
  35. package/dist/assets/{PrivacyMaskSettings-Dldjr0V3.js → PrivacyMaskSettings-BfLXAC0e.js} +1 -1
  36. package/dist/assets/{ProviderIcon-CJzZF-Md.js → ProviderIcon-CuEBRor2.js} +1 -1
  37. package/dist/assets/{Recordings-B6U209AG.js → Recordings-XAFmB4XB.js} +1 -1
  38. package/dist/assets/{ScanNetworkModal-DMYLrkN_.js → ScanNetworkModal-DWW_cmMK.js} +1 -1
  39. package/dist/assets/{SceneMonitorEditor-FHItPjH6.js → SceneMonitorEditor-CaJawXbC.js} +1 -1
  40. package/dist/assets/{Scenes-blkRmI0c.js → Scenes-TX5ZEstc.js} +1 -1
  41. package/dist/assets/{Settings-a9bgvnbO.js → Settings-C2w9rTDo.js} +1 -1
  42. package/dist/assets/{Showroom-D-fGFbC3.js → Showroom-dOHNv9A4.js} +1 -1
  43. package/dist/assets/{StorageLocationsPanel-CenO9DBf.js → StorageLocationsPanel-NVC8GM9O.js} +1 -1
  44. package/dist/assets/{Terminal-KDXpPGlv.js → Terminal-CtbR0SaR.js} +1 -1
  45. package/dist/assets/{Viewer-BYmuROGj.js → Viewer-DvBANa84.js} +1 -1
  46. package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-C_VbCPrP.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-OERUpRWM.js} +1 -1
  47. package/dist/assets/{archive-CDSwYv4h.js → archive-DJeHV1ne.js} +1 -1
  48. package/dist/assets/{authed-media-BYABeaKk.js → authed-media-D-ATEmn4.js} +1 -1
  49. package/dist/assets/{boxes-CnFFfq72.js → boxes-D8b0kCFX.js} +1 -1
  50. package/dist/assets/circle-slash-eyMQBZ12.js +1 -0
  51. package/dist/assets/{debounced-invalidate-ly8jvXjB.js → debounced-invalidate-DXk1jDkb.js} +1 -1
  52. package/dist/assets/{device-integration-icon-C5G12j3k.js → device-integration-icon-46kqfkPN.js} +1 -1
  53. package/dist/assets/dist-CVJFualw.js +349 -0
  54. package/dist/assets/{dist-Cr9XqozI.js → dist-DYxjCn4p.js} +1 -1
  55. package/dist/assets/{face-bbox-DJz4o2gq.js → face-bbox-Cs-vA_dV.js} +1 -1
  56. package/dist/assets/{hard-drive-download-sG8iQV2H.js → hard-drive-download-Bm-blTzS.js} +1 -1
  57. package/dist/assets/{hostInit-C9Y27Ptm.js → hostInit-7CmiDKph.js} +1 -1
  58. package/dist/assets/{index-DZW8_yqU.js → index-DNdhQ4uM.js} +3 -3
  59. package/dist/assets/{layers-7a6NP14k.js → layers-DhuNMfQb.js} +1 -1
  60. package/dist/assets/{location-owned-usage-D7m8uVKn.js → location-owned-usage-CH7Qcnpi.js} +1 -1
  61. package/dist/assets/{mf-entry-bootstrap-0-a4207cb9.js → mf-entry-bootstrap-0-a7760dd5.js} +2 -2
  62. package/dist/assets/{player-overlays-CcX5nwSA.js → player-overlays-BgwZpgSe.js} +1 -1
  63. package/dist/assets/remoteEntry-C982rsbc.js +1 -0
  64. package/dist/assets/{send-CZnJNG3q.js → send-BFj1Ykmj.js} +1 -1
  65. package/dist/assets/{settings-2-CgM5uR-Q.js → settings-2-BfxFWE-M.js} +1 -1
  66. package/dist/assets/{square-check-big-QVLxfFC-.js → square-check-big-UoS0DKVP.js} +1 -1
  67. package/dist/assets/{src-BK-p5x7D.js → src-DRNwsLgw.js} +8 -8
  68. package/dist/assets/src-MMiLp0V-.js +349 -0
  69. package/dist/assets/{use-scenes-feed-BkMKSS4g.js → use-scenes-feed-DkXrY9Sr.js} +1 -1
  70. package/dist/assets/{use-stationary-objects-BeeWiF0v.js → use-stationary-objects-BAsDUCt8.js} +1 -1
  71. package/dist/assets/{useDevice-CWhn2X8b.js → useDevice-Bj2bv3lq.js} +1 -1
  72. package/dist/assets/useEventInvalidation-Dk3OgvD_.js +1 -0
  73. package/dist/assets/{useNodeUrlSelection-Dw4lkvT5.js → useNodeUrlSelection-C4PNrHg2.js} +1 -1
  74. package/dist/assets/user-round-BNml-2tW.js +1 -0
  75. package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-B0HL4fu0.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-BJDm2_I8.js} +2 -2
  76. package/dist/index.html +5 -5
  77. package/dist/server/addon.js +30 -75
  78. package/package.json +1 -1
  79. package/dist/assets/CompositionEditor-CloRIkP3.js +0 -1
  80. package/dist/assets/Notifications-Cjbqxus3.js +0 -1
  81. package/dist/assets/circle-slash-BdFzbR7x.js +0 -1
  82. package/dist/assets/dist-BSPBtyTE.js +0 -349
  83. package/dist/assets/remoteEntry-BDfCWrX6.js +0 -1
  84. package/dist/assets/src-BAc6gsIi.js +0 -349
  85. package/dist/assets/useEventInvalidation-CIP3wjBs.js +0 -1
  86. package/dist/assets/user-round-Yl1pAdZw.js +0 -1
@@ -1,3 +1,3 @@
1
- import{Q as e,S as t,W as n,b as r,o as i,q as a,x as o,z as s}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{_t as c,gt as l,st as u,vt as d,yt as f}from"./player-overlays-CcX5nwSA.js";import{$l as p,Ai as m,Bt as h,Ci as g,Cu as _,El as v,Fi as y,Fl as b,Fu as x,Gc as S,Gl as C,Gu as w,Ii as T,Iu as E,Jc as D,Ju as O,Kc as k,Kl as A,Li as j,Ll as M,Mi as ee,Pl as N,Qc as P,Qu as F,Ri as te,Si as ne,Sl as I,Su as L,T as R,Tu as re,Ui as ie,Ul as z,Uu as B,Xr as ae,Xu as V,Yr as oe,Zc as H,_l as U,au as W,bl as se,bn as ce,cd as le,cl as ue,dl as G,dt as K,gu as de,ji as fe,jl as pe,ju as me,ki as he,ld as ge,ll as _e,lt as ve,lu as ye,ml as be,nd as xe,ol as Se,pl as Ce,qu as we,td as Te,tl as Ee,tu as De,ud as Oe,ul as ke,ut as Ae,uu as je,v as Me,vl as Ne,vu as Pe,wi as Fe,xi as Ie,yi as Le,yu as Re,zl as ze}from"./src-BK-p5x7D.js";import{t as Be}from"./boxes-CnFFfq72.js";import{t as Ve}from"./user-round-Yl1pAdZw.js";import{Ct as He,cn as q,ln as J,sn as Y}from"./src-BAc6gsIi.js";import{d as X,l as Ue,m as We}from"./index-DZW8_yqU.js";import{t as Ge}from"./AdminPage-CiKtOLQm.js";var Ke=f(`circle-arrow-up`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m16 12-4-4-4 4`,key:`177agl`}],[`path`,{d:`M12 16V8`,key:`1sbj14`}]]);e();var qe={camera:d,hub:N,container:Be,light:W,siren:I,switch:ke,sensor:Oe,thermostat:G,climate:ge,button:E,"event-emitter":S,update:Ke,notifier:V,script:pe,automation:D,lock:De,cover:O,valve:_,humidifier:L,"water-heater":de,fan:Re,"media-player":U,"alarm-panel":v,control:se,presence:Ve,weather:me,vacuum:we,"lawn-mower":_e,image:ye,smoke:le};function Z({type:e,className:t}){return o(qe[e]??E,{"aria-hidden":`true`,className:t??`h-3.5 w-3.5 shrink-0 text-foreground-subtle`})}function Je({online:e,deviceName:t}){return o(`span`,{className:e?`inline-block h-1.5 w-1.5 shrink-0 rounded-full bg-emerald-500`:`inline-block h-1.5 w-1.5 shrink-0 rounded-full border border-foreground-subtle`,role:`img`,"aria-label":`${t}: ${e?`online`:`offline`}`,title:e?`online`:`offline`})}function Ye({name:e,description:n,busy:r,onSave:i}){let[c,l]=a(n??``);return s(()=>{l(n??``)},[n]),t(`div`,{className:`border-t border-border px-3 py-2`,children:[o(`label`,{htmlFor:`location-description-${e}`,className:`block text-[10px] font-medium uppercase tracking-wide text-foreground-subtle`,children:`What is there`}),o(`textarea`,{id:`location-description-${e}`,value:c,onChange:e=>l(e.target.value),onBlur:()=>{let e=c.trim();e!==(n??``)&&i(e.length===0?null:e)},disabled:r,rows:2,maxLength:400,placeholder:`Surfaces, boundaries, what is normally parked or stored here.`,className:`mt-1 w-full resize-y rounded border border-border bg-background px-1.5 py-1 text-[11px] text-foreground placeholder:text-foreground-subtle disabled:opacity-50`}),o(`p`,{className:`mt-0.5 text-[10px] text-foreground-subtle`,children:`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 Xe(e,t){let n=e?.find(e=>e.locationKey===t);return n===void 0||n.description.length===0?null:n.description}var Q=` none`;function Ze({name:e,zones:n,zoneKey:r,busy:i,onChange:a}){return n.length===0?null:t(`div`,{className:`flex items-center gap-2 border-t border-border px-3 py-1.5`,children:[o(`label`,{htmlFor:`location-zone-${e}`,className:`text-[10px] font-medium uppercase tracking-wide text-foreground-subtle`,children:`Zone`}),t(`select`,{id:`location-zone-${e}`,value:r??Q,disabled:i,onChange:e=>{let t=e.target.value;if(t===Q){a(null);return}let r=n.find(e=>e.zoneKey===t);r!==void 0&&a(r.label)},className:`min-w-0 flex-1 rounded border border-border bg-background px-1.5 py-0.5 text-[11px] text-foreground disabled:opacity-50`,children:[o(`option`,{value:Q,children:`— none —`}),n.map(e=>o(`option`,{value:e.zoneKey,children:e.label},e.zoneKey))]})]})}function Qe(e,t){return e.find(e=>e.locationKeys.includes(t))?.zoneKey??null}var $e={"map-pin":{icon:p,label:`Pin`},house:{icon:je,label:`Home`},"door-open":{icon:re,label:`Entrance`},sofa:{icon:Ne,label:`Living room`},utensils:{icon:Ee,label:`Kitchen`},"bed-double":{icon:F,label:`Bedroom`},bath:{icon:Te,label:`Bathroom`},briefcase:{icon:w,label:`Office`},car:{icon:B,label:`Garage`},"circle-parking":{icon:x,label:`Parking`},route:{icon:b,label:`Street`},trees:{icon:ue,label:`Garden`},umbrella:{icon:Se,label:`Terrace`},"waves-ladder":{icon:H,label:`Pool`},fence:{icon:Pe,label:`Gate`},package:{icon:A,label:`Storage`},warehouse:{icon:P,label:`Warehouse`},store:{icon:be,label:`Shop`},sun:{icon:Ce,label:`Outdoor`},radar:{icon:ze,label:`Perimeter`}},et=Y.map(e=>({id:e,...$e[e]}));function tt(e){return $e[J(e)].icon}var nt=new Map(et.map(e=>[e.id,[e.label]])),rt=new Map(et.map(e=>[e.id,e.label])),it=new Set(Y);function at(e){return it.has(e)?tt(e):void 0}function ot({name:e,icon:t,busy:n,onPick:r}){return o(R,{value:t,onPick:e=>r(e===null?null:J(e)),resolveGlyph:at,fallbackGlyph:p,clearGlyph:xe,labelFor:e=>rt.get(e),labels:{trigger:`Change the icon of ${e}`,panel:`Icon for ${e}`,close:`Close icon picker`,searchPlaceholder:`Search icons`,clear:`No icon`,noMatches:`No icon matches that`,groups:{device:`Devices`,lighting:`Lights and climate`,sensing:`Sensors and weather`,place:`Rooms and places`,life:`Vehicles, animals and people`}},only:Y,extraWords:nt,disabled:n})}function st(e,t){let n=e?.find(e=>e.locationKey===t);return n===void 0?null:J(n.icon)}function $(e){if(e==null)return null;let t=e.trim();return t.length===0?null:t.toLowerCase()}function ct(e,t){let n=$(t);return n===null?[]:e.filter(e=>$(e.location)===n)}function lt(e,t){let n=ct(e,t),r=new Set(n.map(e=>e.id));return n.filter(e=>e.parentDeviceId===null||!r.has(e.parentDeviceId))}function ut(e,t){let n=$(e.location);return n===null||new Set(t.map(e=>$(e))).has(n)?null:e.location?.trim()??null}function dt(e,t){let n=$(e.location);return n!==null&&t.has(n)}function ft(e,t){let n=new Set(t.map(e=>$(e))),r=new Set(e.filter(e=>dt(e,n)).map(e=>e.id));return e.filter(e=>!(dt(e,n)||e.parentDeviceId!==null&&r.has(e.parentDeviceId)))}function pt(e,t){return ft(e,t).filter(e=>e.parentDeviceId===null)}function mt(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 ht(e,t){return mt(e,t).length}function gt(e,t){return e.filter(e=>!e.isCamera&&e.parentDeviceId===t)}function _t(e,t){return t.map(t=>({name:t,members:lt(e,t)}))}function vt(e){return`${e.kind}:${String(e.device.id)}`}function yt(e,t,n){return e.flatMap(e=>{let r=gt(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}))]})}e();function bt({name:e,members:i,devices:s,busy:c,icon:l,description:d,onRename:f,onDelete:p,onRebuildLinks:m,onPickIcon:h,onSaveDescription:g,zones:_,zoneKey:v,onChangeZone:y}){let{t:b}=Ue(),[x,S]=a(!1),[w,T]=a(e),E=ve(i,n(()=>({searchText:e=>[e.name,...gt(s,e.id).map(e=>e.name)],facetValue:e=>e.type}),[s])),[D,O]=a(()=>new Set),A=e=>O(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),j=n(()=>yt(E.rows,s,D),[E.rows,s,D]),ee=[{key:`name`,header:b(`locations.columns.device`),notSortableReason:b(`locations.columns.noSort`),render:e=>e.kind===`member`?o(xt,{row:e,onToggle:()=>A(e.device.id)}):o(St,{row:e})},{key:`type`,header:b(`locations.columns.type`),notSortableReason:b(`locations.columns.noSort`),render:e=>o(`span`,{className:`text-[11px] text-foreground-muted`,children:e.device.type})},{key:`status`,header:b(`locations.columns.status`),notSortableReason:b(`locations.columns.noSort`),render:e=>t(`span`,{className:`flex items-center gap-1.5`,children:[o(Je,{online:e.device.online,deviceName:e.device.name}),o(`span`,{className:`text-[11px] text-foreground-muted`,children:e.device.online?`online`:`offline`})]})}],N=()=>{T(e),S(!1)},P=async()=>{let t=w.trim();if(t.length===0||t===e){N();return}await f(t),S(!1)};return t(`section`,{className:`min-w-0 rounded-md border border-border bg-surface`,children:[t(`header`,{className:`flex items-center gap-1.5 border-b border-border px-3 py-1.5`,children:[o(ot,{name:e,icon:l,busy:c,onPick:h}),x?t(r,{children:[o(`input`,{value:w,onChange:e=>T(e.target.value),onKeyDown:e=>{e.key===`Enter`&&P(),e.key===`Escape`&&N()},"aria-label":`Rename ${e}`,className:`min-w-0 flex-1 rounded border border-border bg-background px-1.5 py-0.5 text-sm font-semibold text-foreground`,autoFocus:!0}),o(`button`,{type:`button`,onClick:()=>void P(),className:`text-[11px] text-foreground-subtle hover:text-foreground`,children:`Save`}),o(`button`,{type:`button`,onClick:N,"aria-label":`Cancel rename`,className:`p-0.5 text-foreground-subtle hover:text-foreground`,children:o(k,{className:`h-3.5 w-3.5`})})]}):t(r,{children:[o(`h2`,{className:`min-w-0 flex-1 truncate text-sm font-semibold text-foreground`,children:e}),o(Me,{items:[{id:`rename`,label:`Rename`,icon:C,disabled:c,onClick:()=>{T(e),S(!0)}},{id:`rebuild-links`,label:`Rebuild linked devices`,icon:M,separatorBefore:!0,disabled:c,onClick:()=>void m()},{id:`delete`,label:`Delete`,icon:u,danger:!0,separatorBefore:!0,disabled:c,onClick:()=>void p()}],title:`Actions for ${e}`,triggerClassName:`p-1`})]})]}),o(Ze,{name:e,zones:_,zoneKey:v,busy:c,onChange:y}),o(Ye,{name:e,description:d,busy:c,onSave:g}),i.length>0&&o(`div`,{className:`border-b border-border px-3 py-1.5`,children:o(Ae,{state:E.state,facets:E.facets,labels:{searchPlaceholder:b(`locations.filter.searchPlaceholder`),searchLabel:b(`locations.room.searchLabel`,{room:e}),facetsLabel:b(`locations.filter.typesLabel`),clearLabel:b(`locations.filter.clear`)},onSearch:E.setSearch,onToggleFacet:E.toggleFacet,onClear:E.clear})}),i.length===0?o(`p`,{className:`px-3 py-3 text-[11px] text-foreground-subtle`,children:`Nothing here yet — assign a device from the table below.`}):o(K,{columns:ee,rows:j,rowKey:vt,bordered:!1,minWidthPx:360,mobileMode:`scroll`,emptyMessage:b(`locations.filter.noMatch`)})]})}function xt({row:e,onToggle:n}){let{device:r,accessories:i,open:a}=e,s=a?c:l;return t(`span`,{className:`flex items-center gap-1.5`,children:[i.length>0?t(`button`,{type:`button`,onClick:n,"aria-expanded":a,"aria-label":`${a?`Collapse`:`Expand`} ${String(i.length)} companion device(s) of ${r.name}`,className:`flex shrink-0 items-center gap-0.5 rounded p-0.5 text-foreground-subtle hover:bg-surface-hover hover:text-foreground`,children:[o(s,{className:`h-3 w-3`}),o(`span`,{className:`text-[10px] tabular-nums`,children:i.length})]}):o(`span`,{"aria-hidden":`true`,className:`w-[1.35rem] shrink-0`}),o(Z,{type:r.type}),o(X,{to:`/devices/${String(r.id)}`,className:`min-w-0 truncate text-xs text-foreground hover:underline`,children:r.name})]})}function St({row:e}){let{device:n}=e;return t(`span`,{className:`flex items-center gap-1.5 pl-6`,children:[o(`span`,{"aria-hidden":`true`,className:`text-[10px] text-foreground-subtle`,children:`└`}),o(Z,{type:n.type,className:`h-3 w-3 shrink-0 text-foreground-subtle`}),o(X,{to:`/devices/${String(n.id)}`,className:`min-w-0 truncate text-[11px] text-foreground-muted hover:underline`,children:n.name})]})}e();function Ct({zones:e,busy:n,onCreate:r,onRename:i,onDelete:s,onPickIcon:c}){let[l,d]=a(!1),[f,p]=a(``),[m,h]=a(null),[g,_]=a(``),v=async()=>{let e=f.trim();e.length!==0&&(await r(e),p(``),d(!1))},y=async e=>{let t=g.trim();h(null),!(t.length===0||t===e)&&await i(e,t)};return t(`section`,{className:`rounded-md border border-border bg-surface`,children:[t(`header`,{className:`flex items-center gap-2 border-b border-border px-3 py-1.5`,children:[o(`h2`,{className:`flex-1 text-xs font-semibold uppercase tracking-wide text-foreground-subtle`,children:`Zones`}),l?null:t(`button`,{type:`button`,onClick:()=>d(!0),disabled:n,className:`flex items-center gap-1 text-[11px] text-foreground-muted hover:text-foreground disabled:opacity-50`,children:[o(z,{className:`h-3 w-3`}),` New zone`]})]}),l&&t(`div`,{className:`flex items-center gap-1.5 border-b border-border px-3 py-1.5`,children:[o(`input`,{value:f,onChange:e=>p(e.target.value),onKeyDown:e=>{e.key===`Enter`&&v(),e.key===`Escape`&&(p(``),d(!1))},placeholder:`Zona notte`,"aria-label":`New zone name`,autoFocus:!0,className:`min-w-0 flex-1 rounded border border-border bg-background px-1.5 py-0.5 text-xs text-foreground`}),o(`button`,{type:`button`,onClick:()=>void v(),className:`text-[11px] text-foreground-subtle hover:text-foreground`,children:`Add`}),o(`button`,{type:`button`,onClick:()=>{p(``),d(!1)},"aria-label":`Cancel new zone`,className:`p-0.5 text-foreground-subtle hover:text-foreground`,children:o(k,{className:`h-3.5 w-3.5`})})]}),e.length===0?o(`p`,{className:`px-3 py-2 text-[11px] text-foreground-subtle`,children:`No zones yet. A zone groups rooms — “Zona notte” for the bedrooms — and shows up before them in the app’s camera filter.`}):o(`ul`,{className:`py-0.5`,children:e.map(e=>t(`li`,{className:`flex items-center gap-1.5 px-3 py-1`,children:[o(ot,{name:e.label,icon:e.icon,busy:n,onPick:t=>c(e.label,t)}),m===e.label?o(`input`,{value:g,onChange:e=>_(e.target.value),onKeyDown:t=>{t.key===`Enter`&&y(e.label),t.key===`Escape`&&h(null)},onBlur:()=>void y(e.label),"aria-label":`Rename ${e.label}`,autoFocus:!0,className:`min-w-0 flex-1 rounded border border-border bg-background px-1.5 py-0.5 text-xs text-foreground`}):o(`button`,{type:`button`,onClick:()=>{_(e.label),h(e.label)},disabled:n,className:`min-w-0 flex-1 truncate text-left text-xs text-foreground hover:underline disabled:opacity-50`,children:e.label}),o(`span`,{className:`shrink-0 text-[10px] tabular-nums text-foreground-subtle`,children:e.locationKeys.length===0?`empty`:`${String(e.locationKeys.length)} rooms`}),o(`button`,{type:`button`,onClick:()=>void s(e.label),disabled:n,"aria-label":`Delete ${e.label}`,title:`Delete the zone — the rooms in it are kept`,className:`shrink-0 p-0.5 text-foreground-subtle hover:text-danger disabled:opacity-50`,children:o(u,{className:`h-3.5 w-3.5`})})]},e.zoneKey))})]})}e();function wt({busy:e,onCreate:n}){let[r,i]=a(!1),[s,c]=a(``),l=()=>{c(``),i(!1)},u=async()=>{let e=s.trim();e.length!==0&&(await n(e),l())};return r?t(`form`,{className:`flex flex-wrap items-center gap-2`,onSubmit:e=>{e.preventDefault(),u()},children:[o(`input`,{value:s,onChange:e=>c(e.target.value),onKeyDown:e=>{e.key===`Escape`&&l()},placeholder:`Ingresso, Salone, Cucina…`,"aria-label":`New location name`,className:`min-w-[16rem] flex-1 rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground`,autoFocus:!0}),t(`button`,{type:`submit`,disabled:s.trim().length===0||e,className:`inline-flex items-center gap-1 rounded border border-border bg-surface px-2 py-1.5 text-xs font-medium text-foreground hover:bg-surface-hover disabled:opacity-50`,children:[o(z,{className:`h-3.5 w-3.5`}),`Add`]}),o(`button`,{type:`button`,onClick:l,"aria-label":`Cancel new location`,className:`p-1 text-foreground-subtle hover:text-foreground`,children:o(k,{className:`h-3.5 w-3.5`})})]}):t(`button`,{type:`button`,onClick:()=>i(!0),className:`inline-flex w-fit items-center gap-1 rounded border border-border bg-surface px-2 py-1.5 text-xs font-medium text-foreground hover:bg-surface-hover`,children:[o(z,{className:`h-3.5 w-3.5`}),`New location`]})}e();var Tt={searchText:e=>[e.name],facetValue:e=>e.type};function Et({rows:e,fleet:r,locations:i,busy:s,emptyMessage:c,onAssign:l}){let{t:u}=Ue(),[d,f]=a([]),[p,m]=a(``),g=ve(e,Tt),_=g.rows,v=n(()=>_.map(e=>e.id),[_]),y=n(()=>d.filter(e=>v.includes(e)),[d,v]),b=_.length>0&&y.length===_.length,x=n(()=>{let t=new Map;for(let n of e)t.set(n.id,ht(r,n.id));return t},[e,r]),S=y.reduce((e,t)=>e+(x.get(t)??0),0),C=e=>f(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]),w=()=>f(b?[]:v);return t(`section`,{className:`space-y-2`,children:[t(`header`,{className:`flex flex-wrap items-baseline gap-2`,children:[o(`h2`,{className:`text-sm font-semibold text-foreground`,children:`Not in a room`}),o(`p`,{className:`text-[11px] text-foreground-subtle`,children:`Top-level devices only — accessories move with their parent.`})]}),e.length>0&&o(Ae,{state:g.state,facets:g.facets,labels:{searchPlaceholder:u(`locations.filter.searchPlaceholder`),searchLabel:u(`locations.unassigned.searchLabel`),facetsLabel:u(`locations.filter.typesLabel`),clearLabel:u(`locations.filter.clear`)},onSearch:g.setSearch,onToggleFacet:g.toggleFacet,onClear:g.clear}),y.length>0&&t(`div`,{role:`group`,"aria-label":`Bulk assignment`,className:`flex flex-wrap items-center gap-2 rounded border border-primary/40 bg-primary/5 px-2 py-1.5`,children:[t(`span`,{className:`text-[11px] text-foreground`,children:[y.length,` selected`,S>0&&` · ${String(S)} accessories in tow`]}),t(`select`,{"aria-label":`Assign selected devices to`,value:p,onChange:e=>m(e.target.value),className:`rounded border border-border bg-background px-1.5 py-0.5 text-[11px] text-foreground`,children:[o(`option`,{value:``,children:`Assign to…`}),i.map(e=>o(`option`,{value:e,children:e},e))]}),o(`button`,{type:`button`,onClick:()=>{p.length===0||y.length===0||(l(y,p),f([]),m(``))},disabled:s||p.length===0,className:`rounded border border-border bg-surface px-2 py-0.5 text-[11px] font-medium text-foreground hover:bg-surface-hover disabled:opacity-50`,children:`Assign`}),o(`button`,{type:`button`,onClick:()=>f([]),className:`text-[11px] text-foreground-subtle hover:text-foreground`,children:`Clear`})]}),o(K,{columns:[{key:`select`,width:`w-8`,headerRender:()=>o(h,{checked:b,onChange:w,"aria-label":b?`Clear selection`:`Select all unassigned devices`}),render:e=>o(h,{checked:y.includes(e.id),onChange:()=>C(e.id),"aria-label":`Select ${e.name}`})},{key:`name`,header:`Device`,sortValue:e=>e.name.toLowerCase(),render:e=>{let n=ut(e,i);return t(`span`,{className:`flex items-center gap-1.5`,children:[o(Z,{type:e.type}),o(X,{to:`/devices/${String(e.id)}`,className:`truncate text-xs text-foreground hover:underline`,children:e.name}),n!==null&&t(`span`,{className:`rounded-full border border-warning/40 px-1.5 py-px text-[10px] text-warning`,children:[`unknown room “`,n,`”`]})]})}},{key:`type`,header:`Type`,sortValue:e=>e.type,render:e=>o(`span`,{className:`text-[11px] text-foreground-muted`,children:e.type})},{key:`status`,header:`Status`,sortValue:e=>+!!e.online,render:e=>t(`span`,{className:`flex items-center gap-1.5`,children:[o(Je,{online:e.online,deviceName:e.name}),o(`span`,{className:`text-[11px] text-foreground-muted`,children:e.online?`online`:`offline`})]})},{key:`followers`,header:`Accessories in tow`,align:`right`,sortValue:e=>x.get(e.id)??0,render:e=>o(`span`,{className:`tabular-nums text-[11px] text-foreground-muted`,children:x.get(e.id)??0})},{key:`assign`,header:`Assign to`,align:`right`,notSortableReason:`This column is a control, not a value.`,render:e=>t(`select`,{"aria-label":`Location for ${e.name}`,value:``,disabled:s||i.length===0,onChange:t=>{let n=t.target.value;n.length!==0&&l([e.id],n)},className:`max-w-[11rem] rounded border border-border bg-background px-1.5 py-0.5 text-[11px] text-foreground disabled:opacity-50`,children:[o(`option`,{value:``,children:`—`}),i.map(e=>o(`option`,{value:e,children:e},e))]})}],rows:_,rowKey:e=>e.id,minWidthPx:720,mobileMode:`scroll`,emptyMessage:g.active?u(`locations.filter.noMatch`):c})]})}function Dt(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.role!==void 0&&e.role!==null?{role:e.role}:{},name:e.name}}function Ot(e,t){let n=t.map(Dt),r=[];for(let i of t)i.isCamera&&i.location===e&&r.push({deviceId:i.id,name:i.name,ids:He({selfId:i.id,selfLocation:i.location,candidates:n})});return{entries:r}}var kt=`device-manager:linked-devices`;function At(e){return{deviceId:e.deviceId,slotRef:kt,value:{slot:`linked-devices`,deviceIds:[...e.ids]}}}e();function jt(){let e=i(),r=ce(),{data:a,isLoading:s}=g(),{data:c}=ne(),{data:l}=Ie(),{data:u}=Fe(),{data:d,isLoading:f}=Le({projection:`slim`}),h=()=>{e.invalidateQueries({queryKey:[[`deviceManager`,`listLocations`]]}),e.invalidateQueries({queryKey:[[`deviceManager`,`listAll`]]}),e.invalidateQueries({queryKey:[[`deviceManager`,`listLocationIcons`]]}),e.invalidateQueries({queryKey:[[`deviceManager`,`listLocationDescriptions`]]}),e.invalidateQueries({queryKey:[[`deviceManager`,`listSiteZones`]]})},_=ae({onSuccess:h}),v=he({onSuccess:h}),b=y({onSuccess:h}),x=fe({onSuccess:h}),S=j({onSuccess:h}),C=T({onSuccess:h}),w=ie({onSuccess:h}),E=m({onSuccess:h}),D=ee({onSuccess:h}),O=te({onSuccess:h}),k=oe(),A=n(()=>(d??[]).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})),[d]),M=a??[],N=n(()=>_t(A,M),[A,M]),[P,F]=We(),I=P.get(`room`),L=I!==null&&N.some(e=>e.name===I)?I:N[0]?.name??null,R=N.find(e=>e.name===L)??null,re=e=>{F(t=>{let n=new URLSearchParams(t);return n.set(`room`,e),n},{replace:!0})},z=n(()=>pt(A,M),[A,M]),B=s||f,V=b.isPending||v.isPending||_.isPending||S.isPending,H=async e=>{await _.mutateAsync({name:e})},U=async(e,t)=>{let n=t.trim();n.length===0||n===e||await x.mutateAsync({from:e,to:n})},W=async e=>{let t=Ot(e,A);if(t.entries.length===0){await r({title:`Rebuild linked devices`,message:`No camera is assigned to “${e}”.`,confirmLabel:`OK`});return}if(!await r({title:`Rebuild linked devices`,message:`Replace the linked-device list of every camera in “${e}” with what the room contains?\n\n${t.entries.map(e=>`• ${e.name}: ${String(e.ids.length)} device(s)`).join(`
1
+ import{Q as e,S as t,W as n,b as r,o as i,q as a,x as o,z as s}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{_t as c,gt as l,st as u,vt as d,yt as f}from"./player-overlays-BgwZpgSe.js";import{$l as p,Ai as m,Bt as h,Ci as g,Cu as _,El as v,Fi as y,Fl as b,Fu as x,Gc as S,Gl as C,Gu as w,Ii as T,Iu as E,Jc as D,Ju as O,Kc as k,Kl as A,Li as j,Ll as M,Mi as ee,Pl as N,Qc as P,Qu as F,Ri as te,Si as ne,Sl as I,Su as L,T as R,Tu as re,Ui as ie,Ul as z,Uu as B,Xr as ae,Xu as V,Yr as oe,Zc as H,_l as U,au as W,bl as se,bn as ce,cd as le,cl as ue,dl as G,dt as K,gu as de,ji as fe,jl as pe,ju as me,ki as he,ld as ge,ll as _e,lt as ve,lu as ye,ml as be,nd as xe,ol as Se,pl as Ce,qu as we,td as Te,tl as Ee,tu as De,ud as Oe,ul as ke,ut as Ae,uu as je,v as Me,vl as Ne,vu as Pe,wi as Fe,xi as Ie,yi as Le,yu as Re,zl as ze}from"./src-DRNwsLgw.js";import{t as Be}from"./boxes-D8b0kCFX.js";import{t as Ve}from"./user-round-BNml-2tW.js";import{cn as q,ln as J,un as Y,wt as He}from"./src-MMiLp0V-.js";import{d as X,l as Ue,m as We}from"./index-DNdhQ4uM.js";import{t as Ge}from"./AdminPage-CiKtOLQm.js";var Ke=f(`circle-arrow-up`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m16 12-4-4-4 4`,key:`177agl`}],[`path`,{d:`M12 16V8`,key:`1sbj14`}]]);e();var qe={camera:d,hub:N,container:Be,light:W,siren:I,switch:ke,sensor:Oe,thermostat:G,climate:ge,button:E,"event-emitter":S,update:Ke,notifier:V,script:pe,automation:D,lock:De,cover:O,valve:_,humidifier:L,"water-heater":de,fan:Re,"media-player":U,"alarm-panel":v,control:se,presence:Ve,weather:me,vacuum:we,"lawn-mower":_e,image:ye,smoke:le};function Z({type:e,className:t}){return o(qe[e]??E,{"aria-hidden":`true`,className:t??`h-3.5 w-3.5 shrink-0 text-foreground-subtle`})}function Je({online:e,deviceName:t}){return o(`span`,{className:e?`inline-block h-1.5 w-1.5 shrink-0 rounded-full bg-emerald-500`:`inline-block h-1.5 w-1.5 shrink-0 rounded-full border border-foreground-subtle`,role:`img`,"aria-label":`${t}: ${e?`online`:`offline`}`,title:e?`online`:`offline`})}function Ye({name:e,description:n,busy:r,onSave:i}){let[c,l]=a(n??``);return s(()=>{l(n??``)},[n]),t(`div`,{className:`border-t border-border px-3 py-2`,children:[o(`label`,{htmlFor:`location-description-${e}`,className:`block text-[10px] font-medium uppercase tracking-wide text-foreground-subtle`,children:`What is there`}),o(`textarea`,{id:`location-description-${e}`,value:c,onChange:e=>l(e.target.value),onBlur:()=>{let e=c.trim();e!==(n??``)&&i(e.length===0?null:e)},disabled:r,rows:2,maxLength:400,placeholder:`Surfaces, boundaries, what is normally parked or stored here.`,className:`mt-1 w-full resize-y rounded border border-border bg-background px-1.5 py-1 text-[11px] text-foreground placeholder:text-foreground-subtle disabled:opacity-50`}),o(`p`,{className:`mt-0.5 text-[10px] text-foreground-subtle`,children:`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 Xe(e,t){let n=e?.find(e=>e.locationKey===t);return n===void 0||n.description.length===0?null:n.description}var Q=` none`;function Ze({name:e,zones:n,zoneKey:r,busy:i,onChange:a}){return n.length===0?null:t(`div`,{className:`flex items-center gap-2 border-t border-border px-3 py-1.5`,children:[o(`label`,{htmlFor:`location-zone-${e}`,className:`text-[10px] font-medium uppercase tracking-wide text-foreground-subtle`,children:`Zone`}),t(`select`,{id:`location-zone-${e}`,value:r??Q,disabled:i,onChange:e=>{let t=e.target.value;if(t===Q){a(null);return}let r=n.find(e=>e.zoneKey===t);r!==void 0&&a(r.label)},className:`min-w-0 flex-1 rounded border border-border bg-background px-1.5 py-0.5 text-[11px] text-foreground disabled:opacity-50`,children:[o(`option`,{value:Q,children:`— none —`}),n.map(e=>o(`option`,{value:e.zoneKey,children:e.label},e.zoneKey))]})]})}function Qe(e,t){return e.find(e=>e.locationKeys.includes(t))?.zoneKey??null}var $e={"map-pin":{icon:p,label:`Pin`},house:{icon:je,label:`Home`},"door-open":{icon:re,label:`Entrance`},sofa:{icon:Ne,label:`Living room`},utensils:{icon:Ee,label:`Kitchen`},"bed-double":{icon:F,label:`Bedroom`},bath:{icon:Te,label:`Bathroom`},briefcase:{icon:w,label:`Office`},car:{icon:B,label:`Garage`},"circle-parking":{icon:x,label:`Parking`},route:{icon:b,label:`Street`},trees:{icon:ue,label:`Garden`},umbrella:{icon:Se,label:`Terrace`},"waves-ladder":{icon:H,label:`Pool`},fence:{icon:Pe,label:`Gate`},package:{icon:A,label:`Storage`},warehouse:{icon:P,label:`Warehouse`},store:{icon:be,label:`Shop`},sun:{icon:Ce,label:`Outdoor`},radar:{icon:ze,label:`Perimeter`}},et=q.map(e=>({id:e,...$e[e]}));function tt(e){return $e[Y(e)].icon}var nt=new Map(et.map(e=>[e.id,[e.label]])),rt=new Map(et.map(e=>[e.id,e.label])),it=new Set(q);function at(e){return it.has(e)?tt(e):void 0}function ot({name:e,icon:t,busy:n,onPick:r}){return o(R,{value:t,onPick:e=>r(e===null?null:Y(e)),resolveGlyph:at,fallbackGlyph:p,clearGlyph:xe,labelFor:e=>rt.get(e),labels:{trigger:`Change the icon of ${e}`,panel:`Icon for ${e}`,close:`Close icon picker`,searchPlaceholder:`Search icons`,clear:`No icon`,noMatches:`No icon matches that`,groups:{device:`Devices`,lighting:`Lights and climate`,sensing:`Sensors and weather`,place:`Rooms and places`,life:`Vehicles, animals and people`}},only:q,extraWords:nt,disabled:n})}function st(e,t){let n=e?.find(e=>e.locationKey===t);return n===void 0?null:Y(n.icon)}function $(e){if(e==null)return null;let t=e.trim();return t.length===0?null:t.toLowerCase()}function ct(e,t){let n=$(t);return n===null?[]:e.filter(e=>$(e.location)===n)}function lt(e,t){let n=ct(e,t),r=new Set(n.map(e=>e.id));return n.filter(e=>e.parentDeviceId===null||!r.has(e.parentDeviceId))}function ut(e,t){let n=$(e.location);return n===null||new Set(t.map(e=>$(e))).has(n)?null:e.location?.trim()??null}function dt(e,t){let n=$(e.location);return n!==null&&t.has(n)}function ft(e,t){let n=new Set(t.map(e=>$(e))),r=new Set(e.filter(e=>dt(e,n)).map(e=>e.id));return e.filter(e=>!(dt(e,n)||e.parentDeviceId!==null&&r.has(e.parentDeviceId)))}function pt(e,t){return ft(e,t).filter(e=>e.parentDeviceId===null)}function mt(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 ht(e,t){return mt(e,t).length}function gt(e,t){return e.filter(e=>!e.isCamera&&e.parentDeviceId===t)}function _t(e,t){return t.map(t=>({name:t,members:lt(e,t)}))}function vt(e){return`${e.kind}:${String(e.device.id)}`}function yt(e,t,n){return e.flatMap(e=>{let r=gt(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}))]})}e();function bt({name:e,members:i,devices:s,busy:c,icon:l,description:d,onRename:f,onDelete:p,onRebuildLinks:m,onPickIcon:h,onSaveDescription:g,zones:_,zoneKey:v,onChangeZone:y}){let{t:b}=Ue(),[x,S]=a(!1),[w,T]=a(e),E=ve(i,n(()=>({searchText:e=>[e.name,...gt(s,e.id).map(e=>e.name)],facetValue:e=>e.type}),[s])),[D,O]=a(()=>new Set),A=e=>O(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),j=n(()=>yt(E.rows,s,D),[E.rows,s,D]),ee=[{key:`name`,header:b(`locations.columns.device`),notSortableReason:b(`locations.columns.noSort`),render:e=>e.kind===`member`?o(xt,{row:e,onToggle:()=>A(e.device.id)}):o(St,{row:e})},{key:`type`,header:b(`locations.columns.type`),notSortableReason:b(`locations.columns.noSort`),render:e=>o(`span`,{className:`text-[11px] text-foreground-muted`,children:e.device.type})},{key:`status`,header:b(`locations.columns.status`),notSortableReason:b(`locations.columns.noSort`),render:e=>t(`span`,{className:`flex items-center gap-1.5`,children:[o(Je,{online:e.device.online,deviceName:e.device.name}),o(`span`,{className:`text-[11px] text-foreground-muted`,children:e.device.online?`online`:`offline`})]})}],N=()=>{T(e),S(!1)},P=async()=>{let t=w.trim();if(t.length===0||t===e){N();return}await f(t),S(!1)};return t(`section`,{className:`min-w-0 rounded-md border border-border bg-surface`,children:[t(`header`,{className:`flex items-center gap-1.5 border-b border-border px-3 py-1.5`,children:[o(ot,{name:e,icon:l,busy:c,onPick:h}),x?t(r,{children:[o(`input`,{value:w,onChange:e=>T(e.target.value),onKeyDown:e=>{e.key===`Enter`&&P(),e.key===`Escape`&&N()},"aria-label":`Rename ${e}`,className:`min-w-0 flex-1 rounded border border-border bg-background px-1.5 py-0.5 text-sm font-semibold text-foreground`,autoFocus:!0}),o(`button`,{type:`button`,onClick:()=>void P(),className:`text-[11px] text-foreground-subtle hover:text-foreground`,children:`Save`}),o(`button`,{type:`button`,onClick:N,"aria-label":`Cancel rename`,className:`p-0.5 text-foreground-subtle hover:text-foreground`,children:o(k,{className:`h-3.5 w-3.5`})})]}):t(r,{children:[o(`h2`,{className:`min-w-0 flex-1 truncate text-sm font-semibold text-foreground`,children:e}),o(Me,{items:[{id:`rename`,label:`Rename`,icon:C,disabled:c,onClick:()=>{T(e),S(!0)}},{id:`rebuild-links`,label:`Rebuild linked devices`,icon:M,separatorBefore:!0,disabled:c,onClick:()=>void m()},{id:`delete`,label:`Delete`,icon:u,danger:!0,separatorBefore:!0,disabled:c,onClick:()=>void p()}],title:`Actions for ${e}`,triggerClassName:`p-1`})]})]}),o(Ze,{name:e,zones:_,zoneKey:v,busy:c,onChange:y}),o(Ye,{name:e,description:d,busy:c,onSave:g}),i.length>0&&o(`div`,{className:`border-b border-border px-3 py-1.5`,children:o(Ae,{state:E.state,facets:E.facets,labels:{searchPlaceholder:b(`locations.filter.searchPlaceholder`),searchLabel:b(`locations.room.searchLabel`,{room:e}),facetsLabel:b(`locations.filter.typesLabel`),clearLabel:b(`locations.filter.clear`)},onSearch:E.setSearch,onToggleFacet:E.toggleFacet,onClear:E.clear})}),i.length===0?o(`p`,{className:`px-3 py-3 text-[11px] text-foreground-subtle`,children:`Nothing here yet — assign a device from the table below.`}):o(K,{columns:ee,rows:j,rowKey:vt,bordered:!1,minWidthPx:360,mobileMode:`scroll`,emptyMessage:b(`locations.filter.noMatch`)})]})}function xt({row:e,onToggle:n}){let{device:r,accessories:i,open:a}=e,s=a?c:l;return t(`span`,{className:`flex items-center gap-1.5`,children:[i.length>0?t(`button`,{type:`button`,onClick:n,"aria-expanded":a,"aria-label":`${a?`Collapse`:`Expand`} ${String(i.length)} companion device(s) of ${r.name}`,className:`flex shrink-0 items-center gap-0.5 rounded p-0.5 text-foreground-subtle hover:bg-surface-hover hover:text-foreground`,children:[o(s,{className:`h-3 w-3`}),o(`span`,{className:`text-[10px] tabular-nums`,children:i.length})]}):o(`span`,{"aria-hidden":`true`,className:`w-[1.35rem] shrink-0`}),o(Z,{type:r.type}),o(X,{to:`/devices/${String(r.id)}`,className:`min-w-0 truncate text-xs text-foreground hover:underline`,children:r.name})]})}function St({row:e}){let{device:n}=e;return t(`span`,{className:`flex items-center gap-1.5 pl-6`,children:[o(`span`,{"aria-hidden":`true`,className:`text-[10px] text-foreground-subtle`,children:`└`}),o(Z,{type:n.type,className:`h-3 w-3 shrink-0 text-foreground-subtle`}),o(X,{to:`/devices/${String(n.id)}`,className:`min-w-0 truncate text-[11px] text-foreground-muted hover:underline`,children:n.name})]})}e();function Ct({zones:e,busy:n,onCreate:r,onRename:i,onDelete:s,onPickIcon:c}){let[l,d]=a(!1),[f,p]=a(``),[m,h]=a(null),[g,_]=a(``),v=async()=>{let e=f.trim();e.length!==0&&(await r(e),p(``),d(!1))},y=async e=>{let t=g.trim();h(null),!(t.length===0||t===e)&&await i(e,t)};return t(`section`,{className:`rounded-md border border-border bg-surface`,children:[t(`header`,{className:`flex items-center gap-2 border-b border-border px-3 py-1.5`,children:[o(`h2`,{className:`flex-1 text-xs font-semibold uppercase tracking-wide text-foreground-subtle`,children:`Zones`}),l?null:t(`button`,{type:`button`,onClick:()=>d(!0),disabled:n,className:`flex items-center gap-1 text-[11px] text-foreground-muted hover:text-foreground disabled:opacity-50`,children:[o(z,{className:`h-3 w-3`}),` New zone`]})]}),l&&t(`div`,{className:`flex items-center gap-1.5 border-b border-border px-3 py-1.5`,children:[o(`input`,{value:f,onChange:e=>p(e.target.value),onKeyDown:e=>{e.key===`Enter`&&v(),e.key===`Escape`&&(p(``),d(!1))},placeholder:`Zona notte`,"aria-label":`New zone name`,autoFocus:!0,className:`min-w-0 flex-1 rounded border border-border bg-background px-1.5 py-0.5 text-xs text-foreground`}),o(`button`,{type:`button`,onClick:()=>void v(),className:`text-[11px] text-foreground-subtle hover:text-foreground`,children:`Add`}),o(`button`,{type:`button`,onClick:()=>{p(``),d(!1)},"aria-label":`Cancel new zone`,className:`p-0.5 text-foreground-subtle hover:text-foreground`,children:o(k,{className:`h-3.5 w-3.5`})})]}),e.length===0?o(`p`,{className:`px-3 py-2 text-[11px] text-foreground-subtle`,children:`No zones yet. A zone groups rooms — “Zona notte” for the bedrooms — and shows up before them in the app’s camera filter.`}):o(`ul`,{className:`py-0.5`,children:e.map(e=>t(`li`,{className:`flex items-center gap-1.5 px-3 py-1`,children:[o(ot,{name:e.label,icon:e.icon,busy:n,onPick:t=>c(e.label,t)}),m===e.label?o(`input`,{value:g,onChange:e=>_(e.target.value),onKeyDown:t=>{t.key===`Enter`&&y(e.label),t.key===`Escape`&&h(null)},onBlur:()=>void y(e.label),"aria-label":`Rename ${e.label}`,autoFocus:!0,className:`min-w-0 flex-1 rounded border border-border bg-background px-1.5 py-0.5 text-xs text-foreground`}):o(`button`,{type:`button`,onClick:()=>{_(e.label),h(e.label)},disabled:n,className:`min-w-0 flex-1 truncate text-left text-xs text-foreground hover:underline disabled:opacity-50`,children:e.label}),o(`span`,{className:`shrink-0 text-[10px] tabular-nums text-foreground-subtle`,children:e.locationKeys.length===0?`empty`:`${String(e.locationKeys.length)} rooms`}),o(`button`,{type:`button`,onClick:()=>void s(e.label),disabled:n,"aria-label":`Delete ${e.label}`,title:`Delete the zone — the rooms in it are kept`,className:`shrink-0 p-0.5 text-foreground-subtle hover:text-danger disabled:opacity-50`,children:o(u,{className:`h-3.5 w-3.5`})})]},e.zoneKey))})]})}e();function wt({busy:e,onCreate:n}){let[r,i]=a(!1),[s,c]=a(``),l=()=>{c(``),i(!1)},u=async()=>{let e=s.trim();e.length!==0&&(await n(e),l())};return r?t(`form`,{className:`flex flex-wrap items-center gap-2`,onSubmit:e=>{e.preventDefault(),u()},children:[o(`input`,{value:s,onChange:e=>c(e.target.value),onKeyDown:e=>{e.key===`Escape`&&l()},placeholder:`Ingresso, Salone, Cucina…`,"aria-label":`New location name`,className:`min-w-[16rem] flex-1 rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground`,autoFocus:!0}),t(`button`,{type:`submit`,disabled:s.trim().length===0||e,className:`inline-flex items-center gap-1 rounded border border-border bg-surface px-2 py-1.5 text-xs font-medium text-foreground hover:bg-surface-hover disabled:opacity-50`,children:[o(z,{className:`h-3.5 w-3.5`}),`Add`]}),o(`button`,{type:`button`,onClick:l,"aria-label":`Cancel new location`,className:`p-1 text-foreground-subtle hover:text-foreground`,children:o(k,{className:`h-3.5 w-3.5`})})]}):t(`button`,{type:`button`,onClick:()=>i(!0),className:`inline-flex w-fit items-center gap-1 rounded border border-border bg-surface px-2 py-1.5 text-xs font-medium text-foreground hover:bg-surface-hover`,children:[o(z,{className:`h-3.5 w-3.5`}),`New location`]})}e();var Tt={searchText:e=>[e.name],facetValue:e=>e.type};function Et({rows:e,fleet:r,locations:i,busy:s,emptyMessage:c,onAssign:l}){let{t:u}=Ue(),[d,f]=a([]),[p,m]=a(``),g=ve(e,Tt),_=g.rows,v=n(()=>_.map(e=>e.id),[_]),y=n(()=>d.filter(e=>v.includes(e)),[d,v]),b=_.length>0&&y.length===_.length,x=n(()=>{let t=new Map;for(let n of e)t.set(n.id,ht(r,n.id));return t},[e,r]),S=y.reduce((e,t)=>e+(x.get(t)??0),0),C=e=>f(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]),w=()=>f(b?[]:v);return t(`section`,{className:`space-y-2`,children:[t(`header`,{className:`flex flex-wrap items-baseline gap-2`,children:[o(`h2`,{className:`text-sm font-semibold text-foreground`,children:`Not in a room`}),o(`p`,{className:`text-[11px] text-foreground-subtle`,children:`Top-level devices only — accessories move with their parent.`})]}),e.length>0&&o(Ae,{state:g.state,facets:g.facets,labels:{searchPlaceholder:u(`locations.filter.searchPlaceholder`),searchLabel:u(`locations.unassigned.searchLabel`),facetsLabel:u(`locations.filter.typesLabel`),clearLabel:u(`locations.filter.clear`)},onSearch:g.setSearch,onToggleFacet:g.toggleFacet,onClear:g.clear}),y.length>0&&t(`div`,{role:`group`,"aria-label":`Bulk assignment`,className:`flex flex-wrap items-center gap-2 rounded border border-primary/40 bg-primary/5 px-2 py-1.5`,children:[t(`span`,{className:`text-[11px] text-foreground`,children:[y.length,` selected`,S>0&&` · ${String(S)} accessories in tow`]}),t(`select`,{"aria-label":`Assign selected devices to`,value:p,onChange:e=>m(e.target.value),className:`rounded border border-border bg-background px-1.5 py-0.5 text-[11px] text-foreground`,children:[o(`option`,{value:``,children:`Assign to…`}),i.map(e=>o(`option`,{value:e,children:e},e))]}),o(`button`,{type:`button`,onClick:()=>{p.length===0||y.length===0||(l(y,p),f([]),m(``))},disabled:s||p.length===0,className:`rounded border border-border bg-surface px-2 py-0.5 text-[11px] font-medium text-foreground hover:bg-surface-hover disabled:opacity-50`,children:`Assign`}),o(`button`,{type:`button`,onClick:()=>f([]),className:`text-[11px] text-foreground-subtle hover:text-foreground`,children:`Clear`})]}),o(K,{columns:[{key:`select`,width:`w-8`,headerRender:()=>o(h,{checked:b,onChange:w,"aria-label":b?`Clear selection`:`Select all unassigned devices`}),render:e=>o(h,{checked:y.includes(e.id),onChange:()=>C(e.id),"aria-label":`Select ${e.name}`})},{key:`name`,header:`Device`,sortValue:e=>e.name.toLowerCase(),render:e=>{let n=ut(e,i);return t(`span`,{className:`flex items-center gap-1.5`,children:[o(Z,{type:e.type}),o(X,{to:`/devices/${String(e.id)}`,className:`truncate text-xs text-foreground hover:underline`,children:e.name}),n!==null&&t(`span`,{className:`rounded-full border border-warning/40 px-1.5 py-px text-[10px] text-warning`,children:[`unknown room “`,n,`”`]})]})}},{key:`type`,header:`Type`,sortValue:e=>e.type,render:e=>o(`span`,{className:`text-[11px] text-foreground-muted`,children:e.type})},{key:`status`,header:`Status`,sortValue:e=>+!!e.online,render:e=>t(`span`,{className:`flex items-center gap-1.5`,children:[o(Je,{online:e.online,deviceName:e.name}),o(`span`,{className:`text-[11px] text-foreground-muted`,children:e.online?`online`:`offline`})]})},{key:`followers`,header:`Accessories in tow`,align:`right`,sortValue:e=>x.get(e.id)??0,render:e=>o(`span`,{className:`tabular-nums text-[11px] text-foreground-muted`,children:x.get(e.id)??0})},{key:`assign`,header:`Assign to`,align:`right`,notSortableReason:`This column is a control, not a value.`,render:e=>t(`select`,{"aria-label":`Location for ${e.name}`,value:``,disabled:s||i.length===0,onChange:t=>{let n=t.target.value;n.length!==0&&l([e.id],n)},className:`max-w-[11rem] rounded border border-border bg-background px-1.5 py-0.5 text-[11px] text-foreground disabled:opacity-50`,children:[o(`option`,{value:``,children:`—`}),i.map(e=>o(`option`,{value:e,children:e},e))]})}],rows:_,rowKey:e=>e.id,minWidthPx:720,mobileMode:`scroll`,emptyMessage:g.active?u(`locations.filter.noMatch`):c})]})}function Dt(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.role!==void 0&&e.role!==null?{role:e.role}:{},name:e.name}}function Ot(e,t){let n=t.map(Dt),r=[];for(let i of t)i.isCamera&&i.location===e&&r.push({deviceId:i.id,name:i.name,ids:He({selfId:i.id,selfLocation:i.location,candidates:n})});return{entries:r}}var kt=`device-manager:linked-devices`;function At(e){return{deviceId:e.deviceId,slotRef:kt,value:{slot:`linked-devices`,deviceIds:[...e.ids]}}}e();function jt(){let e=i(),r=ce(),{data:a,isLoading:s}=g(),{data:c}=ne(),{data:l}=Ie(),{data:u}=Fe(),{data:d,isLoading:f}=Le({projection:`slim`}),h=()=>{e.invalidateQueries({queryKey:[[`deviceManager`,`listLocations`]]}),e.invalidateQueries({queryKey:[[`deviceManager`,`listAll`]]}),e.invalidateQueries({queryKey:[[`deviceManager`,`listLocationIcons`]]}),e.invalidateQueries({queryKey:[[`deviceManager`,`listLocationDescriptions`]]}),e.invalidateQueries({queryKey:[[`deviceManager`,`listSiteZones`]]})},_=ae({onSuccess:h}),v=he({onSuccess:h}),b=y({onSuccess:h}),x=fe({onSuccess:h}),S=j({onSuccess:h}),C=T({onSuccess:h}),w=ie({onSuccess:h}),E=m({onSuccess:h}),D=ee({onSuccess:h}),O=te({onSuccess:h}),k=oe(),A=n(()=>(d??[]).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})),[d]),M=a??[],N=n(()=>_t(A,M),[A,M]),[P,F]=We(),I=P.get(`room`),L=I!==null&&N.some(e=>e.name===I)?I:N[0]?.name??null,R=N.find(e=>e.name===L)??null,re=e=>{F(t=>{let n=new URLSearchParams(t);return n.set(`room`,e),n},{replace:!0})},z=n(()=>pt(A,M),[A,M]),B=s||f,V=b.isPending||v.isPending||_.isPending||S.isPending,H=async e=>{await _.mutateAsync({name:e})},U=async(e,t)=>{let n=t.trim();n.length===0||n===e||await x.mutateAsync({from:e,to:n})},W=async e=>{let t=Ot(e,A);if(t.entries.length===0){await r({title:`Rebuild linked devices`,message:`No camera is assigned to “${e}”.`,confirmLabel:`OK`});return}if(!await r({title:`Rebuild linked devices`,message:`Replace the linked-device list of every camera in “${e}” with what the room contains?\n\n${t.entries.map(e=>`• ${e.name}: ${String(e.ids.length)} device(s)`).join(`
2
2
  `)}\n\nAnything linked by hand that is not in this room is lost.`,confirmLabel:`Rebuild`,variant:`danger`}))return;let n=[];for(let e of t.entries)try{await k.mutateAsync(At(e))}catch(t){n.push(`• ${e.name}: ${t instanceof Error?t.message:String(t)}`)}h(),n.length>0&&await r({title:`Rebuild linked devices`,message:`Not rebuilt:\n\n${n.join(`
3
- `)}`,confirmLabel:`OK`})},se=async(e,t)=>{await r({title:`Delete location`,message:`Delete the location “${e}”?${t>0?` ${String(t)} device(s) will become unassigned.`:``}`,confirmLabel:`Delete`,variant:`danger`})&&await v.mutateAsync({name:e,cascade:!0})},le=async(e,t)=>{await S.mutateAsync({location:e,icon:t})},ue=async(e,t)=>{await C.mutateAsync({location:e,description:t})},G=u??[],K=async(e,t)=>{await O.mutateAsync({location:e,zone:t})};return t(Ge,{icon:p,title:`Locations`,subtitle:`Rooms and areas of the site. Assign any device here — storage disks are under Data → Storage.`,children:[o(wt,{busy:_.isPending,onCreate:H}),o(Ct,{zones:G,busy:V,onCreate:e=>w.mutateAsync({name:e}),onRename:(e,t)=>D.mutateAsync({from:e,to:t}),onDelete:e=>E.mutateAsync({name:e}),onPickIcon:(e,t)=>w.mutateAsync({name:e,icon:t})}),B&&o(`p`,{className:`text-xs text-foreground-subtle`,children:`Loading locations and devices…`}),N.length>0&&o(`div`,{role:`tablist`,"aria-label":`Locations`,className:`-mx-1 flex gap-1 overflow-x-auto px-1 pb-1`,children:N.map(e=>{let n=e.name===L,r=tt(st(c,q(e.name)));return t(`button`,{type:`button`,role:`tab`,"aria-selected":n,onClick:()=>re(e.name),className:n?`shrink-0 whitespace-nowrap rounded-full border border-primary bg-primary/10 px-3 py-1 text-xs text-foreground`:`shrink-0 whitespace-nowrap rounded-full border border-border px-3 py-1 text-xs text-foreground-muted hover:bg-surface-hover`,children:[o(r,{className:`mr-1 inline h-3.5 w-3.5 align-text-bottom`}),e.name,` `,o(`span`,{className:`text-foreground-subtle tabular-nums`,children:e.members.length})]},e.name)})}),R!==null&&o(bt,{name:R.name,members:R.members,devices:A,busy:V,icon:st(c,q(R.name)),onPickIcon:e=>le(R.name,e),description:Xe(l,q(R.name)),onSaveDescription:e=>ue(R.name,e),zones:G,zoneKey:Qe(G,q(R.name)),onChangeZone:e=>K(R.name,e),onRename:e=>U(R.name,e),onDelete:()=>se(R.name,ct(A,R.name).length),onRebuildLinks:()=>W(R.name)},R.name),M.length===0&&!B&&o(`p`,{className:`text-xs text-foreground-subtle`,children:`No locations yet. Add Ingresso, Salone, Cucina…`}),o(Et,{rows:z,fleet:A,locations:M,busy:V,emptyMessage:B?`Loading…`:`Every top-level device has a room.`,onAssign:(e,t)=>{for(let n of e)b.mutate({deviceId:n,location:t})}})]})}export{jt as LocationsPage};
3
+ `)}`,confirmLabel:`OK`})},se=async(e,t)=>{await r({title:`Delete location`,message:`Delete the location “${e}”?${t>0?` ${String(t)} device(s) will become unassigned.`:``}`,confirmLabel:`Delete`,variant:`danger`})&&await v.mutateAsync({name:e,cascade:!0})},le=async(e,t)=>{await S.mutateAsync({location:e,icon:t})},ue=async(e,t)=>{await C.mutateAsync({location:e,description:t})},G=u??[],K=async(e,t)=>{await O.mutateAsync({location:e,zone:t})};return t(Ge,{icon:p,title:`Locations`,subtitle:`Rooms and areas of the site. Assign any device here — storage disks are under Data → Storage.`,children:[o(wt,{busy:_.isPending,onCreate:H}),o(Ct,{zones:G,busy:V,onCreate:e=>w.mutateAsync({name:e}),onRename:(e,t)=>D.mutateAsync({from:e,to:t}),onDelete:e=>E.mutateAsync({name:e}),onPickIcon:(e,t)=>w.mutateAsync({name:e,icon:t})}),B&&o(`p`,{className:`text-xs text-foreground-subtle`,children:`Loading locations and devices…`}),N.length>0&&o(`div`,{role:`tablist`,"aria-label":`Locations`,className:`-mx-1 flex gap-1 overflow-x-auto px-1 pb-1`,children:N.map(e=>{let n=e.name===L,r=tt(st(c,J(e.name)));return t(`button`,{type:`button`,role:`tab`,"aria-selected":n,onClick:()=>re(e.name),className:n?`shrink-0 whitespace-nowrap rounded-full border border-primary bg-primary/10 px-3 py-1 text-xs text-foreground`:`shrink-0 whitespace-nowrap rounded-full border border-border px-3 py-1 text-xs text-foreground-muted hover:bg-surface-hover`,children:[o(r,{className:`mr-1 inline h-3.5 w-3.5 align-text-bottom`}),e.name,` `,o(`span`,{className:`text-foreground-subtle tabular-nums`,children:e.members.length})]},e.name)})}),R!==null&&o(bt,{name:R.name,members:R.members,devices:A,busy:V,icon:st(c,J(R.name)),onPickIcon:e=>le(R.name,e),description:Xe(l,J(R.name)),onSaveDescription:e=>ue(R.name,e),zones:G,zoneKey:Qe(G,J(R.name)),onChangeZone:e=>K(R.name,e),onRename:e=>U(R.name,e),onDelete:()=>se(R.name,ct(A,R.name).length),onRebuildLinks:()=>W(R.name)},R.name),M.length===0&&!B&&o(`p`,{className:`text-xs text-foreground-subtle`,children:`No locations yet. Add Ingresso, Salone, Cucina…`}),o(Et,{rows:z,fleet:A,locations:M,busy:V,emptyMessage:B?`Loading…`:`Every top-level device has a room.`,onAssign:(e,t)=>{for(let n of e)b.mutate({deviceId:n,location:t})}})]})}export{jt as LocationsPage};
@@ -1 +1 @@
1
- import{Q as e,S as t,W as n,q as r,x as i}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{vt as a,yt as o}from"./player-overlays-CcX5nwSA.js";import{Gn as s,Hu as c,Kn as l,ic as u,jl as d,nc as f,nt as p,ru as m,ud as h,zc as g}from"./src-BK-p5x7D.js";import{t as _}from"./layers-7a6NP14k.js";import{h as v,l as y}from"./index-DZW8_yqU.js";import{t as b}from"./AdminPage-CiKtOLQm.js";import{t as x}from"./AdminTabs-BCENPGP0.js";import{t as S}from"./AddonCollectionPage-Cl_qAbsl.js";import{t as C}from"./addon-display-names-DvSEQty-.js";var w=o(`file-text`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]),T=o(`timer-reset`,[[`path`,{d:`M10 2h4`,key:`n1abiw`}],[`path`,{d:`M12 14v-4`,key:`1evpnu`}],[`path`,{d:`M4 13a8 8 0 0 1 8-7 8 8 0 1 1-5.3 14L4 17.6`,key:`1ts96g`}],[`path`,{d:`M9 17H4v5`,key:`8t5av`}]]);e();var E=5e3,D={"winston-logging":`Rotated log files on this node’s disk.`,"console-logging":`stdout / stderr of the node process.`,"loki-logging":`Pushes to a Grafana Loki instance. Off until enabled with a URL.`,"hub-forwarder":`Agent-only — forwards this node’s entries to the hub.`};function O(){let e=l({capName:`log-destination`},{refetchInterval:E}),t=s(void 0,{refetchInterval:E}),r=n(()=>C(t.data??[]),[t.data]),a=n(()=>{let e=new Map;for(let n of t.data??[]){let t=n.description,r=n.id;typeof r==`string`&&typeof t==`string`&&t.length>0&&e.set(r,t)}return e},[t.data]);return i(S,{title:`Logging`,subtitle:`Every registered log destination. Entries are fanned to all enabled destinations at once — enabling one does not disable another. Each destination's own configuration is docked under it.`,pageIcon:d,itemIcon:w,capability:`log-destination`,installButtonLabel:`Add destination`,items:n(()=>(e.data??[]).map(e=>({addonId:e.addonId,displayName:r.get(e.addonId)??e.addonId,isActive:e.isActive,caption:a.get(e.addonId)??D[e.addonId]??``})),[e.data,r,a]),isLoading:e.isLoading,emptyTitle:`No log destinations registered`,emptyDescription:`This should not happen — the console and rotated-file destinations are builtins. If the list is empty, the node is still booting.`,renderStatusBadges:e=>e.caption.length>0?i(`span`,{className:`text-[10px] text-foreground-subtle`,children:e.caption}):null})}e();var k=[12e4,3e5,6e5,18e5],A={"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 j(){let{t:e}=y(),n=f({},{refetchInterval:5e3}),a=u(),[o,s]=r(null),c=(e,t)=>{s(e),a.mutate({patch:{diagnostics:[{id:e,armMs:t}]}},{onSettled:()=>{s(null),n.refetch()}})},l=n.data?.activeWindows??[],d=n.data?.channels??[],p=n.data?.activeChannels??[],g=(e,t,r)=>{s(e),a.mutate({patch:{channels:[{channel:e,armMs:t,deviceIds:r}]}},{onSettled:()=>{s(null),n.refetch()}})};return t(b,{icon:h,title:e(`logging.diagnostics.title`,`Diagnostics`),subtitle:e(`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?t(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[i(m,{className:`h-3.5 w-3.5 animate-spin`}),e(`common.loading`,`Loading…`)]}):i(`div`,{className:`rounded-lg border border-border bg-surface divide-y divide-border`,children:l.map(e=>i(N,{window:e,busy:o===e.id,onArm:t=>c(e.id,t)},e.id))}),i(`h3`,{className:`mt-6 text-sm font-medium text-foreground`,children:e(`logging.diagnostics.channels`,`Component channels`)}),i(`p`,{className:`mb-2 max-w-3xl text-[11px] text-foreground-subtle`,children:e(`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.`)}),d.length===0?i(`p`,{className:`text-[11px] text-foreground-subtle`,children:e(`logging.diagnostics.noChannels`,`No addon on this cluster declares a log channel, or none could be reached right now.`)}):i(`div`,{className:`rounded-lg border border-border bg-surface divide-y divide-border`,children:d.map(e=>i(M,{channel:e,state:p.find(t=>t.channel===e.name),busy:o===e.name,onArm:(t,n)=>g(e.name,t,n)},e.name))})]})}function M({channel:e,state:n,busy:o,onArm:s}){let{t:c}=y(),[l,u]=r(``),d=n?.armed===!0,f=()=>{let e=l.split(/[\s,+]+/).filter(e=>/^\d+$/.test(e)).map(e=>Number(e));return e.length>0?e:null};return t(`div`,{className:`flex flex-col gap-2 p-3 lg:flex-row lg:items-center lg:justify-between`,children:[t(`div`,{className:`min-w-0`,children:[t(`div`,{className:`flex flex-wrap items-center gap-2`,children:[i(`span`,{className:`text-sm font-medium text-foreground`,children:e.name}),d?t(`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:[i(T,{className:`h-3 w-3`}),c(`logging.diagnostics.expiresIn`,`expires in {{left}}`,{left:P(n?.remainingMs??0)})]}):i(`span`,{className:`rounded border border-border px-1.5 py-0.5 text-[10px] text-foreground-subtle`,children:c(`logging.diagnostics.disarmed`,`disarmed`)}),d&&n?.deviceIds!==null&&n?.deviceIds!==void 0&&t(`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:[i(a,{className:`h-3 w-3`}),n.deviceIds.join(`, `)]}),!e.perDevice&&i(`span`,{className:`rounded border border-border px-1.5 py-0.5 text-[10px] text-foreground-subtle`,children:c(`logging.diagnostics.notPerCamera`,`not filterable per camera`)})]}),i(`p`,{className:`mt-0.5 max-w-2xl text-[11px] text-foreground-subtle`,children:e.description})]}),t(`div`,{className:`flex shrink-0 flex-wrap items-center gap-1`,children:[e.perDevice&&i(`input`,{type:`text`,inputMode:`numeric`,value:l,disabled:o,onChange:e=>u(e.target.value),placeholder:c(`logging.diagnostics.camerasPlaceholder`,`all cameras`),className:`w-28 rounded border border-border bg-surface px-2 py-1 text-[11px] text-foreground`}),k.map(e=>i(`button`,{type:`button`,disabled:o,onClick:()=>s(e,f()),className:`rounded border border-border px-2 py-1 text-[11px] text-foreground-subtle hover:text-foreground disabled:opacity-50`,children:P(e)},e)),i(`button`,{type:`button`,disabled:o||!d,onClick:()=>s(0,null),className:`rounded bg-primary px-2 py-1 text-[11px] font-medium text-primary-foreground disabled:opacity-40`,children:c(`logging.diagnostics.disarm`,`Disarm`)})]})]})}function N({window:e,busy:n,onArm:r}){let{t:a}=y();return t(`div`,{className:`flex flex-col gap-2 p-3 lg:flex-row lg:items-center lg:justify-between`,children:[t(`div`,{className:`min-w-0`,children:[t(`div`,{className:`flex items-center gap-2`,children:[i(`span`,{className:`text-sm font-medium text-foreground`,children:e.id}),e.armed?t(`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:[i(T,{className:`h-3 w-3`}),a(`logging.diagnostics.expiresIn`,`expires in {{left}}`,{left:P(e.remainingMs)})]}):i(`span`,{className:`rounded border border-border px-1.5 py-0.5 text-[10px] text-foreground-subtle`,children:a(`logging.diagnostics.disarmed`,`disarmed`)}),e.armed&&!e.persisted&&i(`span`,{className:`text-[10px] text-warning`,children:a(`logging.diagnostics.notPersisted`,`not persisted — will not survive a restart`)})]}),i(`p`,{className:`mt-0.5 max-w-2xl text-[11px] text-foreground-subtle`,children:A[e.id]??``})]}),t(`div`,{className:`flex shrink-0 flex-wrap items-center gap-1`,children:[k.map(e=>i(`button`,{type:`button`,disabled:n,onClick:()=>r(e),className:`rounded border border-border px-2 py-1 text-[11px] text-foreground-subtle hover:text-foreground disabled:opacity-50`,children:P(e)},e)),i(`button`,{type:`button`,disabled:n||!e.armed,onClick:()=>r(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 P(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`}e();var F=[`debug`,`info`,`warn`,`error`],I=``,L=``;function R(){let{t:e}=y(),[a,o]=r(I),[s,c]=r(L),{nodes:l}=g(),d=n(()=>l.map(e=>({id:e.id,label:e.name||e.id})),[l]),p=f({...a===I?{}:{scopeNodeId:a},...s===L?{}:{scopeComponent:s}},{refetchInterval:15e3}),h=u(),v=p.data,x=h.isPending||p.isFetching,S=v?.channels??[],C=(e,t)=>{h.mutate({...e.nodeId===null?{}:{scopeNodeId:e.nodeId},...e.component===null?{}:{scopeComponent:e.component},patch:{level:t}},{onSuccess:()=>void p.refetch()})};return i(b,{icon:_,title:e(`logging.levels.title`,`Levels`),subtitle:e(`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:t(`div`,{className:`flex flex-wrap items-center gap-3`,children:[t(`label`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[e(`logging.levels.scope`,`Scope`),t(`select`,{className:`rounded border border-border bg-surface px-2 py-1 text-xs text-foreground disabled:opacity-50`,value:a,disabled:s!==L,onChange:e=>o(e.target.value),children:[i(`option`,{value:I,children:e(`logging.levels.cluster`,`Cluster`)}),d.map(e=>i(`option`,{value:e.id,children:e.label},e.id))]})]}),t(`label`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[e(`logging.levels.component`,`Component`),t(`select`,{className:`rounded border border-border bg-surface px-2 py-1 text-xs text-foreground`,value:s,onChange:e=>c(e.target.value),children:[i(`option`,{value:L,children:e(`logging.levels.noComponent`,`None`)}),S.map(e=>i(`option`,{value:e.name,children:e.name},e.name))]})]})]}),children:p.isLoading||v===void 0?t(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[i(m,{className:`h-3.5 w-3.5 animate-spin`}),e(`common.loading`,`Loading…`)]}):t(`div`,{className:`space-y-3`,children:[i(B,{level:v.effective.level,source:v.effective.levelSource,persisted:v.persisted}),i(`div`,{className:`rounded-lg border border-border bg-surface divide-y divide-border`,children:v.explicit.layers.map(e=>i(V,{layer:e,inForce:e.scope===v.effective.levelSource,busy:x,onSet:t=>C(e,t),onClear:()=>C(e,null)},`${e.scope}:${e.nodeId??e.component??`cluster`}`))}),s!==L&&i(`p`,{className:`text-[11px] text-foreground-subtle`,children:S.find(e=>e.name===s)?.description??``}),i(`p`,{className:`text-[11px] text-foreground-subtle`,children:e(`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.`)}),i(z,{days:v.opsLogRetentionDays,busy:x,onSet:e=>h.mutate({patch:{opsLogRetentionDays:e}},{onSuccess:()=>void p.refetch()})})]})})}function z({days:e,busy:n,onSet:r}){let{t:a}=y();return t(`div`,{className:`rounded-lg border border-border bg-surface p-3 space-y-1`,children:[t(`label`,{className:`flex items-center justify-between gap-3`,children:[i(`span`,{className:`text-xs font-medium`,children:a(`logging.levels.opsLogRetention`,`Retention audit trail`)}),t(`span`,{className:`flex items-center gap-1.5`,children:[i(`input`,{type:`number`,min:0,max:3650,step:1,defaultValue:e,disabled:n,onBlur:t=>{let n=Number.parseInt(t.target.value,10);Number.isFinite(n)&&n!==e&&r(n)},className:`w-20 rounded border border-border bg-surface px-2 py-1 text-xs`}),i(`span`,{className:`text-[11px] text-foreground-subtle`,children:a(`common.days`,`days`)})]})]}),i(`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 B({level:e,source:n,persisted:r}){let{t:a}=y();return t(`div`,{className:`rounded-lg border border-border bg-surface p-3`,children:[t(`div`,{className:`flex items-center gap-2`,children:[i(`span`,{className:`text-xs text-foreground-subtle`,children:a(`logging.levels.effective`,`In force here`)}),i(`span`,{className:`rounded bg-primary/10 px-2 py-0.5 text-xs font-semibold text-primary`,children:e}),i(`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})})]}),!r&&i(`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 V({layer:e,inForce:n,busy:r,onSet:a,onClear:o}){let{t:s}=y();return t(`div`,{className:`flex flex-col gap-2 p-3 sm:flex-row sm:items-center sm:justify-between`,children:[t(`div`,{className:`min-w-0`,children:[t(`div`,{className:`flex items-center gap-2`,children:[i(`span`,{className:`text-sm font-medium text-foreground`,children:e.scope===`cluster`?s(`logging.levels.cluster`,`Cluster`):e.scope===`component`?e.component??``:e.nodeId??``}),n&&t(`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:[i(c,{className:`h-3 w-3`}),s(`logging.levels.inForce`,`in force`)]})]}),i(`p`,{className:`mt-0.5 text-[11px] text-foreground-subtle`,children:e.level===null?s(`logging.levels.inherits`,`inherits — nothing set at this layer`):s(`logging.levels.setHere`,`set here: {{level}}`,{level:e.level})})]}),t(`div`,{className:`flex shrink-0 items-center gap-1`,children:[F.map(t=>i(`button`,{type:`button`,disabled:r,onClick:()=>a(t),className:`rounded px-2 py-1 text-[11px] font-medium transition-colors disabled:opacity-50 ${e.level===t?`bg-primary text-primary-foreground`:`border border-border text-foreground-subtle hover:text-foreground`}`,children:t},t)),i(`button`,{type:`button`,disabled:r||e.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 H(){return i(b,{children:i(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:i(p,{limit:500,maxHeight:`max-h-[calc(100vh-310px)]`,showScope:!0,showFilters:!0})})})}function U(){return i(`div`,{className:`flex flex-col p-4`,children:i(x,{tabs:[{id:`viewer`,label:`Viewer`,icon:v,content:i(H,{})},{id:`destinations`,label:`Destinations`,icon:d,content:i(O,{})},{id:`levels`,label:`Levels`,icon:_,content:i(R,{})},{id:`diagnostics`,label:`Diagnostics`,icon:h,content:i(j,{})}]})})}export{U as LogsPage};
1
+ import{Q as e,S as t,W as n,q as r,x as i}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{vt as a,yt as o}from"./player-overlays-BgwZpgSe.js";import{Gn as s,Hu as c,Kn as l,ic as u,jl as d,nc as f,nt as p,ru as m,ud as h,zc as g}from"./src-DRNwsLgw.js";import{t as _}from"./layers-DhuNMfQb.js";import{h as v,l as y}from"./index-DNdhQ4uM.js";import{t as b}from"./AdminPage-CiKtOLQm.js";import{t as x}from"./AdminTabs-CIbVXHF1.js";import{t as S}from"./AddonCollectionPage-BlnjptJq.js";import{t as C}from"./addon-display-names-DvSEQty-.js";var w=o(`file-text`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]),T=o(`timer-reset`,[[`path`,{d:`M10 2h4`,key:`n1abiw`}],[`path`,{d:`M12 14v-4`,key:`1evpnu`}],[`path`,{d:`M4 13a8 8 0 0 1 8-7 8 8 0 1 1-5.3 14L4 17.6`,key:`1ts96g`}],[`path`,{d:`M9 17H4v5`,key:`8t5av`}]]);e();var E=5e3,D={"winston-logging":`Rotated log files on this node’s disk.`,"console-logging":`stdout / stderr of the node process.`,"loki-logging":`Pushes to a Grafana Loki instance. Off until enabled with a URL.`,"hub-forwarder":`Agent-only — forwards this node’s entries to the hub.`};function O(){let e=l({capName:`log-destination`},{refetchInterval:E}),t=s(void 0,{refetchInterval:E}),r=n(()=>C(t.data??[]),[t.data]),a=n(()=>{let e=new Map;for(let n of t.data??[]){let t=n.description,r=n.id;typeof r==`string`&&typeof t==`string`&&t.length>0&&e.set(r,t)}return e},[t.data]);return i(S,{title:`Logging`,subtitle:`Every registered log destination. Entries are fanned to all enabled destinations at once — enabling one does not disable another. Each destination's own configuration is docked under it.`,pageIcon:d,itemIcon:w,capability:`log-destination`,installButtonLabel:`Add destination`,items:n(()=>(e.data??[]).map(e=>({addonId:e.addonId,displayName:r.get(e.addonId)??e.addonId,isActive:e.isActive,caption:a.get(e.addonId)??D[e.addonId]??``})),[e.data,r,a]),isLoading:e.isLoading,emptyTitle:`No log destinations registered`,emptyDescription:`This should not happen — the console and rotated-file destinations are builtins. If the list is empty, the node is still booting.`,renderStatusBadges:e=>e.caption.length>0?i(`span`,{className:`text-[10px] text-foreground-subtle`,children:e.caption}):null})}e();var k=[12e4,3e5,6e5,18e5],A={"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 j(){let{t:e}=y(),n=f({},{refetchInterval:5e3}),a=u(),[o,s]=r(null),c=(e,t)=>{s(e),a.mutate({patch:{diagnostics:[{id:e,armMs:t}]}},{onSettled:()=>{s(null),n.refetch()}})},l=n.data?.activeWindows??[],d=n.data?.channels??[],p=n.data?.activeChannels??[],g=(e,t,r)=>{s(e),a.mutate({patch:{channels:[{channel:e,armMs:t,deviceIds:r}]}},{onSettled:()=>{s(null),n.refetch()}})};return t(b,{icon:h,title:e(`logging.diagnostics.title`,`Diagnostics`),subtitle:e(`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?t(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[i(m,{className:`h-3.5 w-3.5 animate-spin`}),e(`common.loading`,`Loading…`)]}):i(`div`,{className:`rounded-lg border border-border bg-surface divide-y divide-border`,children:l.map(e=>i(N,{window:e,busy:o===e.id,onArm:t=>c(e.id,t)},e.id))}),i(`h3`,{className:`mt-6 text-sm font-medium text-foreground`,children:e(`logging.diagnostics.channels`,`Component channels`)}),i(`p`,{className:`mb-2 max-w-3xl text-[11px] text-foreground-subtle`,children:e(`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.`)}),d.length===0?i(`p`,{className:`text-[11px] text-foreground-subtle`,children:e(`logging.diagnostics.noChannels`,`No addon on this cluster declares a log channel, or none could be reached right now.`)}):i(`div`,{className:`rounded-lg border border-border bg-surface divide-y divide-border`,children:d.map(e=>i(M,{channel:e,state:p.find(t=>t.channel===e.name),busy:o===e.name,onArm:(t,n)=>g(e.name,t,n)},e.name))})]})}function M({channel:e,state:n,busy:o,onArm:s}){let{t:c}=y(),[l,u]=r(``),d=n?.armed===!0,f=()=>{let e=l.split(/[\s,+]+/).filter(e=>/^\d+$/.test(e)).map(e=>Number(e));return e.length>0?e:null};return t(`div`,{className:`flex flex-col gap-2 p-3 lg:flex-row lg:items-center lg:justify-between`,children:[t(`div`,{className:`min-w-0`,children:[t(`div`,{className:`flex flex-wrap items-center gap-2`,children:[i(`span`,{className:`text-sm font-medium text-foreground`,children:e.name}),d?t(`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:[i(T,{className:`h-3 w-3`}),c(`logging.diagnostics.expiresIn`,`expires in {{left}}`,{left:P(n?.remainingMs??0)})]}):i(`span`,{className:`rounded border border-border px-1.5 py-0.5 text-[10px] text-foreground-subtle`,children:c(`logging.diagnostics.disarmed`,`disarmed`)}),d&&n?.deviceIds!==null&&n?.deviceIds!==void 0&&t(`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:[i(a,{className:`h-3 w-3`}),n.deviceIds.join(`, `)]}),!e.perDevice&&i(`span`,{className:`rounded border border-border px-1.5 py-0.5 text-[10px] text-foreground-subtle`,children:c(`logging.diagnostics.notPerCamera`,`not filterable per camera`)})]}),i(`p`,{className:`mt-0.5 max-w-2xl text-[11px] text-foreground-subtle`,children:e.description})]}),t(`div`,{className:`flex shrink-0 flex-wrap items-center gap-1`,children:[e.perDevice&&i(`input`,{type:`text`,inputMode:`numeric`,value:l,disabled:o,onChange:e=>u(e.target.value),placeholder:c(`logging.diagnostics.camerasPlaceholder`,`all cameras`),className:`w-28 rounded border border-border bg-surface px-2 py-1 text-[11px] text-foreground`}),k.map(e=>i(`button`,{type:`button`,disabled:o,onClick:()=>s(e,f()),className:`rounded border border-border px-2 py-1 text-[11px] text-foreground-subtle hover:text-foreground disabled:opacity-50`,children:P(e)},e)),i(`button`,{type:`button`,disabled:o||!d,onClick:()=>s(0,null),className:`rounded bg-primary px-2 py-1 text-[11px] font-medium text-primary-foreground disabled:opacity-40`,children:c(`logging.diagnostics.disarm`,`Disarm`)})]})]})}function N({window:e,busy:n,onArm:r}){let{t:a}=y();return t(`div`,{className:`flex flex-col gap-2 p-3 lg:flex-row lg:items-center lg:justify-between`,children:[t(`div`,{className:`min-w-0`,children:[t(`div`,{className:`flex items-center gap-2`,children:[i(`span`,{className:`text-sm font-medium text-foreground`,children:e.id}),e.armed?t(`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:[i(T,{className:`h-3 w-3`}),a(`logging.diagnostics.expiresIn`,`expires in {{left}}`,{left:P(e.remainingMs)})]}):i(`span`,{className:`rounded border border-border px-1.5 py-0.5 text-[10px] text-foreground-subtle`,children:a(`logging.diagnostics.disarmed`,`disarmed`)}),e.armed&&!e.persisted&&i(`span`,{className:`text-[10px] text-warning`,children:a(`logging.diagnostics.notPersisted`,`not persisted — will not survive a restart`)})]}),i(`p`,{className:`mt-0.5 max-w-2xl text-[11px] text-foreground-subtle`,children:A[e.id]??``})]}),t(`div`,{className:`flex shrink-0 flex-wrap items-center gap-1`,children:[k.map(e=>i(`button`,{type:`button`,disabled:n,onClick:()=>r(e),className:`rounded border border-border px-2 py-1 text-[11px] text-foreground-subtle hover:text-foreground disabled:opacity-50`,children:P(e)},e)),i(`button`,{type:`button`,disabled:n||!e.armed,onClick:()=>r(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 P(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`}e();var F=[`debug`,`info`,`warn`,`error`],I=``,L=``;function R(){let{t:e}=y(),[a,o]=r(I),[s,c]=r(L),{nodes:l}=g(),d=n(()=>l.map(e=>({id:e.id,label:e.name||e.id})),[l]),p=f({...a===I?{}:{scopeNodeId:a},...s===L?{}:{scopeComponent:s}},{refetchInterval:15e3}),h=u(),v=p.data,x=h.isPending||p.isFetching,S=v?.channels??[],C=(e,t)=>{h.mutate({...e.nodeId===null?{}:{scopeNodeId:e.nodeId},...e.component===null?{}:{scopeComponent:e.component},patch:{level:t}},{onSuccess:()=>void p.refetch()})};return i(b,{icon:_,title:e(`logging.levels.title`,`Levels`),subtitle:e(`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:t(`div`,{className:`flex flex-wrap items-center gap-3`,children:[t(`label`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[e(`logging.levels.scope`,`Scope`),t(`select`,{className:`rounded border border-border bg-surface px-2 py-1 text-xs text-foreground disabled:opacity-50`,value:a,disabled:s!==L,onChange:e=>o(e.target.value),children:[i(`option`,{value:I,children:e(`logging.levels.cluster`,`Cluster`)}),d.map(e=>i(`option`,{value:e.id,children:e.label},e.id))]})]}),t(`label`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[e(`logging.levels.component`,`Component`),t(`select`,{className:`rounded border border-border bg-surface px-2 py-1 text-xs text-foreground`,value:s,onChange:e=>c(e.target.value),children:[i(`option`,{value:L,children:e(`logging.levels.noComponent`,`None`)}),S.map(e=>i(`option`,{value:e.name,children:e.name},e.name))]})]})]}),children:p.isLoading||v===void 0?t(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[i(m,{className:`h-3.5 w-3.5 animate-spin`}),e(`common.loading`,`Loading…`)]}):t(`div`,{className:`space-y-3`,children:[i(B,{level:v.effective.level,source:v.effective.levelSource,persisted:v.persisted}),i(`div`,{className:`rounded-lg border border-border bg-surface divide-y divide-border`,children:v.explicit.layers.map(e=>i(V,{layer:e,inForce:e.scope===v.effective.levelSource,busy:x,onSet:t=>C(e,t),onClear:()=>C(e,null)},`${e.scope}:${e.nodeId??e.component??`cluster`}`))}),s!==L&&i(`p`,{className:`text-[11px] text-foreground-subtle`,children:S.find(e=>e.name===s)?.description??``}),i(`p`,{className:`text-[11px] text-foreground-subtle`,children:e(`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.`)}),i(z,{days:v.opsLogRetentionDays,busy:x,onSet:e=>h.mutate({patch:{opsLogRetentionDays:e}},{onSuccess:()=>void p.refetch()})})]})})}function z({days:e,busy:n,onSet:r}){let{t:a}=y();return t(`div`,{className:`rounded-lg border border-border bg-surface p-3 space-y-1`,children:[t(`label`,{className:`flex items-center justify-between gap-3`,children:[i(`span`,{className:`text-xs font-medium`,children:a(`logging.levels.opsLogRetention`,`Retention audit trail`)}),t(`span`,{className:`flex items-center gap-1.5`,children:[i(`input`,{type:`number`,min:0,max:3650,step:1,defaultValue:e,disabled:n,onBlur:t=>{let n=Number.parseInt(t.target.value,10);Number.isFinite(n)&&n!==e&&r(n)},className:`w-20 rounded border border-border bg-surface px-2 py-1 text-xs`}),i(`span`,{className:`text-[11px] text-foreground-subtle`,children:a(`common.days`,`days`)})]})]}),i(`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 B({level:e,source:n,persisted:r}){let{t:a}=y();return t(`div`,{className:`rounded-lg border border-border bg-surface p-3`,children:[t(`div`,{className:`flex items-center gap-2`,children:[i(`span`,{className:`text-xs text-foreground-subtle`,children:a(`logging.levels.effective`,`In force here`)}),i(`span`,{className:`rounded bg-primary/10 px-2 py-0.5 text-xs font-semibold text-primary`,children:e}),i(`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})})]}),!r&&i(`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 V({layer:e,inForce:n,busy:r,onSet:a,onClear:o}){let{t:s}=y();return t(`div`,{className:`flex flex-col gap-2 p-3 sm:flex-row sm:items-center sm:justify-between`,children:[t(`div`,{className:`min-w-0`,children:[t(`div`,{className:`flex items-center gap-2`,children:[i(`span`,{className:`text-sm font-medium text-foreground`,children:e.scope===`cluster`?s(`logging.levels.cluster`,`Cluster`):e.scope===`component`?e.component??``:e.nodeId??``}),n&&t(`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:[i(c,{className:`h-3 w-3`}),s(`logging.levels.inForce`,`in force`)]})]}),i(`p`,{className:`mt-0.5 text-[11px] text-foreground-subtle`,children:e.level===null?s(`logging.levels.inherits`,`inherits — nothing set at this layer`):s(`logging.levels.setHere`,`set here: {{level}}`,{level:e.level})})]}),t(`div`,{className:`flex shrink-0 items-center gap-1`,children:[F.map(t=>i(`button`,{type:`button`,disabled:r,onClick:()=>a(t),className:`rounded px-2 py-1 text-[11px] font-medium transition-colors disabled:opacity-50 ${e.level===t?`bg-primary text-primary-foreground`:`border border-border text-foreground-subtle hover:text-foreground`}`,children:t},t)),i(`button`,{type:`button`,disabled:r||e.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 H(){return i(b,{children:i(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:i(p,{limit:500,maxHeight:`max-h-[calc(100vh-310px)]`,showScope:!0,showFilters:!0})})})}function U(){return i(`div`,{className:`flex flex-col p-4`,children:i(x,{tabs:[{id:`viewer`,label:`Viewer`,icon:v,content:i(H,{})},{id:`destinations`,label:`Destinations`,icon:d,content:i(O,{})},{id:`levels`,label:`Levels`,icon:_,content:i(R,{})},{id:`diagnostics`,label:`Diagnostics`,icon:h,content:i(j,{})}]})})}export{U as LogsPage};