@camstack/addon-admin-ui 1.2.258 → 1.2.260

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 (97) hide show
  1. package/dist/assets/{AddonCollectionPage-BX0XnPQb.js → AddonCollectionPage-CS0TnWg9.js} +1 -1
  2. package/dist/assets/Addons-C30etjze.js +1 -0
  3. package/dist/assets/{AdminTabs-CSovnIie.js → AdminTabs-FTjDtV3h.js} +1 -1
  4. package/dist/assets/AiProfiles-mbAsm8w-.js +3 -0
  5. package/dist/assets/{BrokerForm-zK_8Dcox.js → BrokerForm-Q6_-XEV6.js} +1 -1
  6. package/dist/assets/Build-DEIHGbUT.js +32 -0
  7. package/dist/assets/{Capabilities-DZdGmm1p.js → Capabilities-BBNd5xr5.js} +1 -1
  8. package/dist/assets/{CapabilityBadges-dLW1TjJs.js → CapabilityBadges-CrEM9xUa.js} +1 -1
  9. package/dist/assets/Cluster-Bzkxl6x3.js +11 -0
  10. package/dist/assets/{Data-cuCuoZJZ.js → Data-TtTvLPLA.js} +1 -1
  11. package/dist/assets/DetectionIntelligence-DfTa4lpL.js +1 -0
  12. package/dist/assets/{DeviceAggregateSection-BgIHM0MP.js → DeviceAggregateSection-f6elW-hA.js} +1 -1
  13. package/dist/assets/DeviceDetail-2sfyugFO.js +2 -0
  14. package/dist/assets/{Devices-Ch6FOfuB.js → Devices-Co8wNAQR.js} +1 -1
  15. package/dist/assets/{EmbedPlayerPage-BErA2z2-.js → EmbedPlayerPage-C-PGfe8W.js} +1 -1
  16. package/dist/assets/Events-BoiEuALN.js +1 -0
  17. package/dist/assets/{FormBuilder-jIqGNdKD.js → FormBuilder-B3mdR0Gk.js} +1 -1
  18. package/dist/assets/Identity-CYZ21kQd.js +1 -0
  19. package/dist/assets/IntegrationDetail-DkvBX9o8.js +1 -0
  20. package/dist/assets/Integrations-CZio9vzA.js +1 -0
  21. package/dist/assets/Integrations-CxQSQ9fW.js +1 -0
  22. package/dist/assets/Locations-D0BRCdcK.js +2 -0
  23. package/dist/assets/{Logs-BM6XTKrt.js → Logs-zkWqa-Zv.js} +1 -1
  24. package/dist/assets/{MotionZonesSettings-CQX7yV3y.js → MotionZonesSettings-DPp47_Em.js} +1 -1
  25. package/dist/assets/{MyAccess-CJbXiIW5.js → MyAccess-BISLeGOK.js} +1 -1
  26. package/dist/assets/{Network-DPbXs8WB.js → Network-CopgOYrO.js} +1 -1
  27. package/dist/assets/{NodeAddonsSettingsPanel-D1mmPw8E.js → NodeAddonsSettingsPanel-B5y6dSOO.js} +1 -1
  28. package/dist/assets/{NodeInferenceDevices-BZT90g18.js → NodeInferenceDevices-MUCKntIr.js} +1 -1
  29. package/dist/assets/Notifications-C-euUn8Y.js +1 -0
  30. package/dist/assets/Pipeline-CRvLk6_r.js +1 -0
  31. package/dist/assets/Plates-ChoLztf-.js +1 -0
  32. package/dist/assets/{PrivacyMaskSettings-BAmYAzaT.js → PrivacyMaskSettings-Bt6X63Rt.js} +1 -1
  33. package/dist/assets/{ProviderIcon-DCDpuWgi.js → ProviderIcon-D9PLOXMZ.js} +1 -1
  34. package/dist/assets/Recordings-TgH0kxt8.js +1 -0
  35. package/dist/assets/{ScanNetworkModal-Cz8wK3Sf.js → ScanNetworkModal-lEnThbrW.js} +1 -1
  36. package/dist/assets/{SceneMonitorEditor-DxBU0nwK.js → SceneMonitorEditor-Coey7DkB.js} +1 -1
  37. package/dist/assets/{Scenes--ADmPstY.js → Scenes-DCGaMi0H.js} +1 -1
  38. package/dist/assets/{Settings-C9a74W-U.js → Settings-Cya6w94r.js} +1 -1
  39. package/dist/assets/{Showroom-JqyYWh5s.js → Showroom-CEIjIU3D.js} +1 -1
  40. package/dist/assets/{StorageLocationsPanel-Ch5YTeaG.js → StorageLocationsPanel-dpSl2bc_.js} +1 -1
  41. package/dist/assets/{Terminal-WhJmXhAV.js → Terminal-DYbduyac.js} +5 -5
  42. package/dist/assets/{Viewer-BUVuTunJ.js → Viewer-BCs5TInB.js} +1 -1
  43. package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-D3L9YkaA.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-BAEaiPOS.js} +1 -1
  44. package/dist/assets/{archive-BBd9Y5og.js → archive-BDAG8ZtC.js} +1 -1
  45. package/dist/assets/{authed-media-Cp17W-pc.js → authed-media-BgHAN7mo.js} +1 -1
  46. package/dist/assets/{boxes-B2dkI7tE.js → boxes-CGA7dQAX.js} +1 -1
  47. package/dist/assets/circle-slash-xqjuzvya.js +1 -0
  48. package/dist/assets/{debounced-invalidate-CL0RRPMu.js → debounced-invalidate-DUhUAjlV.js} +1 -1
  49. package/dist/assets/{dist-C9Mb2vEn.js → dist-CIB8yuhW.js} +1 -1
  50. package/dist/assets/dist-Cxb_X-h6.js +349 -0
  51. package/dist/assets/{face-bbox-CRCCB2nD.js → face-bbox-q-9rvLF7.js} +1 -1
  52. package/dist/assets/{hard-drive-download-CIHN2VkD.js → hard-drive-download-DXfQNx7b.js} +1 -1
  53. package/dist/assets/{hostInit-BsyyQBn2.js → hostInit-DHzuQRJh.js} +1 -1
  54. package/dist/assets/index-Dx7jiq4X.js +4 -0
  55. package/dist/assets/{layers-cSbXjXdl.js → layers-D-Qb89PK.js} +1 -1
  56. package/dist/assets/{location-owned-usage-BT2pmQo5.js → location-owned-usage-C-JLRZgq.js} +1 -1
  57. package/dist/assets/{mf-entry-bootstrap-0-0e59474f.js → mf-entry-bootstrap-0-19449b84.js} +2 -2
  58. package/dist/assets/{player-overlays-B82OVd2b.js → player-overlays-BHhXtyqA.js} +1 -1
  59. package/dist/assets/remoteEntry-BnoRpCyV.js +1 -0
  60. package/dist/assets/{send-BUidPUKy.js → send-DtWddy40.js} +1 -1
  61. package/dist/assets/{settings-2-CoiJ1-tg.js → settings-2-a-fUhkjD.js} +1 -1
  62. package/dist/assets/{square-check-big-BeLRKn52.js → square-check-big-DBadJoiu.js} +1 -1
  63. package/dist/assets/src-D1KVMjXF.js +67 -0
  64. package/dist/assets/src-DJhS86y-.js +349 -0
  65. package/dist/assets/{use-scenes-feed-BOjzOiOU.js → use-scenes-feed-Cgbz38uA.js} +1 -1
  66. package/dist/assets/{use-stationary-objects-Bd9Ou1yp.js → use-stationary-objects-NIqG_ma3.js} +1 -1
  67. package/dist/assets/useEventInvalidation-DE-QGHTV.js +1 -0
  68. package/dist/assets/{useNodeUrlSelection-GaFsaq3Y.js → useNodeUrlSelection-CjOpKTO_.js} +1 -1
  69. package/dist/assets/user-round-BFvKN2vL.js +1 -0
  70. package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-ta66_Q-u.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-CXmVBdRr.js} +2 -2
  71. package/dist/index.html +5 -5
  72. package/dist/server/addon.js +243 -21
  73. package/package.json +1 -1
  74. package/dist/assets/Addons-BDOOkMuS.js +0 -1
  75. package/dist/assets/AiProfiles-E5IAsm2S.js +0 -3
  76. package/dist/assets/Build-BtjCenWS.js +0 -32
  77. package/dist/assets/Cluster-BbNceUht.js +0 -11
  78. package/dist/assets/DetectionIntelligence-G7lCcALp.js +0 -1
  79. package/dist/assets/DeviceDetail-BdOqOqTl.js +0 -2
  80. package/dist/assets/Events-CgOvlHhY.js +0 -1
  81. package/dist/assets/Identity-BWdkMiVS.js +0 -1
  82. package/dist/assets/IntegrationDetail-BIjcJOw8.js +0 -1
  83. package/dist/assets/Integrations-5qB154Mm.js +0 -1
  84. package/dist/assets/Integrations-CR7lMMFk.js +0 -1
  85. package/dist/assets/Locations-BCTsz8p1.js +0 -1
  86. package/dist/assets/Notifications-Df8BJ8WO.js +0 -1
  87. package/dist/assets/Pipeline-DAOklLn2.js +0 -1
  88. package/dist/assets/Plates-CQi1FcSU.js +0 -1
  89. package/dist/assets/Recordings-CqoxOlE1.js +0 -1
  90. package/dist/assets/circle-slash-Beg_P0an.js +0 -1
  91. package/dist/assets/dist-B8NLJMCh.js +0 -349
  92. package/dist/assets/index-BpiZqZOx.js +0 -4
  93. package/dist/assets/remoteEntry-Boe6tAc9.js +0 -1
  94. package/dist/assets/src-8XVcukAG.js +0 -349
  95. package/dist/assets/src-jk2FdB5v.js +0 -67
  96. package/dist/assets/useEventInvalidation-WjkWP5Gl.js +0 -1
  97. package/dist/assets/user-round-C782gYyr.js +0 -1
@@ -1 +0,0 @@
1
- import{Q as e,S as t,W as n,b as r,o as i,q as a,x as o}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{st as s}from"./player-overlays-B82OVd2b.js";import{Bn as c,Cr as l,Dr as u,Ec as d,Er as f,Il as p,Nl as m,Nr as h,Or as g,Sl as _,T as v,Tr as y,br as b,hn as x,kc as S,sl as C,vl as w,wl as T,wr as E,xl as D,xr as ee}from"./src-jk2FdB5v.js";import{Ct as O,U as k,bt as A}from"./src-8XVcukAG.js";import{a as j}from"./index-BpiZqZOx.js";import{t as M}from"./AdminPage-CiKtOLQm.js";import{t as N}from"./AdminTabs-CSovnIie.js";import{t as P}from"./BrokerForm-zK_8Dcox.js";import{t as F}from"./useBodyScrollLock-BDocajQE.js";import{t as I}from"./AddonCollectionPage-BX0XnPQb.js";e();var L={"home-assistant":`Home Assistant`,mqtt:`MQTT`};function R(e){return L[e]??e}function z(e){return Array.isArray(e)?e.filter(e=>typeof e==`object`&&!!e&&typeof e.addonId==`string`&&Array.isArray(e.kinds)):[]}var B={connected:`bg-emerald-500/15 text-emerald-700 dark:text-emerald-300`,connecting:`bg-amber-500/15 text-amber-700 dark:text-amber-300`,disconnected:`bg-foreground-subtle/15 text-foreground-subtle`,"auth-failed":`bg-danger/15 text-danger`,unreachable:`bg-danger/15 text-danger`,error:`bg-danger/15 text-danger`};function V({status:e}){return o(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium ${B[e]}`,children:e})}function H(e){return Array.isArray(e)?e.filter(e=>typeof e==`object`&&!!e&&typeof e.id==`string`):[]}function U({title:e,subtitle:n,onClose:r,children:i}){return F(),o(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-background/80 backdrop-blur-sm`,onClick:r,children:t(`div`,{className:`w-full max-w-md rounded-xl border border-border bg-surface shadow-2xl`,onClick:e=>e.stopPropagation(),children:[t(`div`,{className:`flex items-start justify-between border-b border-border px-4 py-3`,children:[t(`div`,{className:`space-y-0.5`,children:[o(`h2`,{className:`text-sm font-semibold text-foreground`,children:e}),n&&o(`p`,{className:`text-xs text-foreground-subtle`,children:n})]}),o(`button`,{onClick:r,className:`text-foreground-subtle hover:text-foreground`,children:o(d,{className:`h-4 w-4`})})]}),o(`div`,{className:`p-4 max-h-[70vh] overflow-y-auto overscroll-contain`,children:i})]})})}function W({kinds:e,onClose:n,onDone:s}){let c=i(),l=e=>`${e.addonId??``}::${e.kind}`,[u,d]=a(e[0]?l(e[0]):``),[f,p]=a(``),[m,h]=a(!1),[g,_]=a(``),v=e.find(e=>l(e)===u)??e[0],y=v?.kind??``,x=v?.addonId,S=b({onSuccess:()=>{c.invalidateQueries({queryKey:[[`broker`,`list`]]}),s()}}),C=e=>{if(!y||f.trim().length===0)return;let t=m?g.trim():``;m&&t===``||S.mutate({kind:y,name:f.trim(),settings:e,...t===``?{}:{id:t},...x===void 0?{}:{addonId:x}})};return o(U,{title:`Add broker`,subtitle:`Register a message broker for exporters and automations.`,onClose:S.isPending?()=>{}:n,children:t(`div`,{className:`space-y-3`,children:[t(`div`,{className:`space-y-1`,children:[o(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Kind`}),o(`select`,{value:u,onChange:e=>d(e.target.value),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`,children:e.map(e=>o(`option`,{value:l(e),children:e.label},l(e)))})]}),t(`div`,{className:`space-y-1`,children:[o(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Name`}),o(`input`,{type:`text`,value:f,onChange:e=>p(e.target.value),placeholder:`My Home Assistant`,className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`})]}),t(`div`,{className:`space-y-1 rounded border border-border px-3 py-2`,children:[t(`label`,{className:`flex items-center gap-2 text-[11px] text-foreground`,children:[o(`input`,{type:`checkbox`,checked:m,onChange:e=>h(e.target.checked)}),`Restore a broker that was removed, under its original id`]}),m&&t(r,{children:[o(`input`,{type:`text`,value:g,onChange:e=>_(e.target.value),placeholder:`ha_004`,className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`}),o(`p`,{className:`text-[10px] text-foreground-subtle`,children:`Devices remember the broker id they were discovered under, so restoring the original id reconnects them instead of needing re-discovery. An id that is still in use is refused.`})]})]}),S.isError&&o(`div`,{className:`rounded border border-danger/30 bg-danger/5 text-danger px-3 py-2 text-[11px]`,children:S.error instanceof Error?S.error.message:String(S.error)}),y&&o(P,{kind:y,...x===void 0?{}:{addonId:x},onSubmit:C,onCancel:n,submitLabel:S.isPending?`Adding…`:`Add broker`,disabled:S.isPending}),f.trim().length===0&&o(`p`,{className:`text-[10px] text-foreground-subtle`,children:`Enter a name before saving.`}),m&&g.trim().length===0&&o(`p`,{className:`text-[10px] text-foreground-subtle`,children:`Enter the original id, or clear the checkbox to create a new broker.`})]})})}function G({broker:e,onClose:r,onDone:a}){let s=i(),c=ee({id:e.id,addonId:e.addonId}),l=u({onSuccess:()=>{s.invalidateQueries({queryKey:[[`broker`,`list`]]}),s.invalidateQueries({queryKey:[[`broker`,`getSettings`],{input:{id:e.id,addonId:e.addonId}}]}),a()}}),d=n(()=>{let e=c.data;return e&&typeof e==`object`?{...e}:{}},[c.data]);return o(U,{title:`Edit ${e.name}`,subtitle:`${R(e.kind)} · ${e.id}`,onClose:l.isPending?()=>{}:r,children:c.isLoading?t(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[o(p,{className:`h-3.5 w-3.5 animate-spin`}),` Loading settings…`]}):c.isError?t(`div`,{className:`space-y-3`,children:[t(`div`,{className:`rounded border border-danger/30 bg-danger/5 text-danger px-3 py-2 text-[11px]`,children:[`Failed to load settings:`,` `,c.error instanceof Error?c.error.message:`Unknown error`]}),o(`div`,{className:`flex justify-end`,children:o(`button`,{type:`button`,onClick:r,className:`rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground`,children:`Close`})})]}):t(`div`,{className:`space-y-3`,children:[l.isError&&o(`div`,{className:`rounded border border-danger/30 bg-danger/5 text-danger px-3 py-2 text-[11px]`,children:l.error instanceof Error?l.error.message:String(l.error)}),o(P,{kind:e.kind,addonId:e.addonId,initialValues:d,onSubmit:t=>{l.mutate({id:e.id,settings:t,addonId:e.addonId})},onCancel:r,submitLabel:l.isPending?`Saving…`:`Save`,disabled:l.isPending})]})})}function K({broker:e,onEdit:n}){let r=i(),c=x(),[l,u]=a(null),d=g({onSuccess:e=>u(e.ok?{ok:!0}:{ok:!1,error:e.error}),onError:e=>u({ok:!1,error:e instanceof Error?e.message:String(e)})}),m=f({onSuccess:()=>{r.invalidateQueries({queryKey:[[`broker`,`list`]]})}}),h=async()=>{await c({title:`Delete broker`,message:`Delete broker "${e.name}"? Integrations that depend on it will stop working.`,confirmLabel:`Delete`,variant:`danger`})&&m.mutate({id:e.id,addonId:e.addonId})};return t(`tr`,{className:`border-b border-border last:border-0`,children:[o(`td`,{className:`px-3 py-2 text-xs text-foreground font-medium`,children:e.name}),o(`td`,{className:`px-3 py-2 text-xs text-foreground-subtle`,children:R(e.kind)}),t(`td`,{className:`px-3 py-2`,children:[o(V,{status:e.status}),l&&o(`span`,{className:`ml-2 text-[10px] ${l.ok?`text-success`:`text-danger`}`,children:l.ok?`OK`:l.error??`failed`})]}),o(`td`,{className:`px-3 py-2`,children:t(`div`,{className:`flex items-center justify-end gap-1.5`,children:[t(`button`,{type:`button`,onClick:()=>d.mutate({id:e.id,addonId:e.addonId}),disabled:d.isPending,title:`Test connection`,className:`inline-flex items-center gap-1 rounded border border-border px-2 py-1 text-[11px] text-foreground hover:bg-primary/10 disabled:opacity-50`,children:[d.isPending?o(p,{className:`h-3 w-3 animate-spin`}):o(S,{className:`h-3 w-3`}),`Test`]}),t(`button`,{type:`button`,onClick:()=>n(e),title:`Edit`,className:`inline-flex items-center gap-1 rounded border border-border px-2 py-1 text-[11px] text-foreground hover:bg-primary/10`,children:[o(T,{className:`h-3 w-3`}),` Edit`]}),t(`button`,{type:`button`,onClick:()=>{h()},disabled:m.isPending,title:`Delete`,className:`inline-flex items-center gap-1 rounded border border-danger/40 px-2 py-1 text-[11px] text-danger hover:bg-danger/10 disabled:opacity-50`,children:[m.isPending?o(p,{className:`h-3 w-3 animate-spin`}):o(s,{className:`h-3 w-3`}),`Delete`]})]})})]})}function q(){let e=E({}),r=y(),i=n(()=>H(e.data),[e.data]),[s,c]=a(!1),[l,u]=a(null),d=n(()=>{let e=new Map;for(let t of z(r.data))for(let n of t.kinds)e.set(`${t.addonId}::${n.kind}`,{addonId:t.addonId,kind:n.kind,label:n.label});for(let t of i)[...e.values()].some(e=>e.kind===t.kind)||e.set(`::${t.kind}`,{kind:t.kind,label:R(t.kind)});return[...e.values()]},[i,r.data]);return t(`div`,{className:`space-y-3`,children:[o(`div`,{className:`flex items-center justify-end`,children:t(`button`,{type:`button`,onClick:()=>c(!0),disabled:d.length===0,title:d.length===0?`No broker providers available`:void 0,className:`inline-flex items-center gap-1.5 rounded-lg bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50 disabled:cursor-not-allowed`,children:[o(_,{className:`h-3.5 w-3.5`}),` Add broker`]})}),o(`div`,{className:`rounded-lg border border-border bg-surface overflow-x-auto`,children:t(`table`,{className:`w-full min-w-[36rem] border-collapse`,children:[o(`thead`,{children:t(`tr`,{className:`border-b border-border bg-background/50`,children:[o(`th`,{className:`px-3 py-2 text-left text-[10px] font-semibold uppercase tracking-wider text-foreground-subtle`,children:`Name`}),o(`th`,{className:`px-3 py-2 text-left text-[10px] font-semibold uppercase tracking-wider text-foreground-subtle`,children:`Kind`}),o(`th`,{className:`px-3 py-2 text-left text-[10px] font-semibold uppercase tracking-wider text-foreground-subtle`,children:`Status`}),o(`th`,{className:`px-3 py-2 text-right text-[10px] font-semibold uppercase tracking-wider text-foreground-subtle`,children:`Actions`})]})}),t(`tbody`,{children:[e.isLoading&&o(`tr`,{children:t(`td`,{colSpan:4,className:`px-3 py-6 text-center text-xs text-foreground-subtle`,children:[o(p,{className:`inline h-4 w-4 animate-spin`}),` Loading brokers…`]})}),e.isError&&o(`tr`,{children:t(`td`,{colSpan:4,className:`px-3 py-4 text-center text-xs text-danger`,children:[`Failed to load brokers:`,` `,e.error instanceof Error?e.error.message:`Unknown error`]})}),!e.isLoading&&!e.isError&&i.length===0&&o(`tr`,{children:o(`td`,{colSpan:4,className:`px-3 py-6 text-center text-xs text-foreground-subtle`,children:`No brokers registered yet. Add one to publish device events for downstream automations.`})}),i.map(e=>o(K,{broker:e,onEdit:u},e.id))]})]})}),s&&o(W,{kinds:d,onClose:()=>c(!1),onDone:()=>c(!1)}),l&&o(G,{broker:l,onClose:()=>u(null),onDone:()=>u(null)})]})}var J=[{kind:`device-export`,tabId:`device-export`,title:`Device export`,subtitle:`Outbound exporters that publish CamStack devices to other ecosystems (HomeAssistant, HomeKit, Alexa, …).`,icon:C,emptyTitle:`No device-export providers installed`,emptyDescription:`Install an export addon (e.g. @camstack/addon-export-ha-mqtt) to surface your CamStack devices in HomeAssistant, HomeKit, …`,addLabel:`Add export`},{kind:`email`,tabId:`email`,title:`Email providers`,subtitle:`Outbound email relays used for magic-link login, notifications, and alerts (SMTP today, future SendGrid, …).`,icon:m,emptyTitle:`No email providers installed`,emptyDescription:`Install an email-provider addon (e.g. @camstack/addon-smtp) so the hub can deliver magic-link logins and notifications.`,addLabel:`Add email provider`},{kind:`broker`,tabId:`broker`,title:`Brokers`,subtitle:`Message brokers consumed by exporters and downstream automations (MQTT today, future Kafka, …).`,icon:w,emptyTitle:`No brokers installed`,emptyDescription:`Install a broker addon (e.g. @camstack/addon-mqtt-broker) to publish device events for downstream automations.`,addLabel:`Add broker`}];function Y(e){if(typeof e==`string`)return e;if(e&&typeof e==`object`){let t=e.name;if(typeof t==`string`)return t}return null}function X(e){let t=e,n=t?.manifest;if(!n?.id)return null;let r=[];for(let e of n.capabilities??[]){let t=Y(e);t!==null&&r.push(t)}let i=n.packageDisplayName??n.name??n.id,a=t?.process?.state??null;return{addonId:n.id,displayName:i,isActive:a===`running`,packageName:n.packageName??`@camstack/addon-${n.id}`,capNames:r,processState:a}}function Z(e,t){let n=new Set(t);return e.filter(e=>e.capNames.some(e=>n.has(e)))}function Q(e){for(let[t,n]of Object.entries(k))if(n===e)return t;return null}function te(e){return e===`running`?{label:`Running`,className:`bg-emerald-500/15 text-emerald-700 dark:text-emerald-300`}:e===`crashed`||e===`failed`?{label:e===`failed`?`Failed`:`Crashed`,className:`bg-danger/15 text-danger`}:e===`stopped`||e===`disabled`?{label:`Stopped`,className:`bg-foreground-subtle/15 text-foreground-subtle`}:{label:e??`Unknown`,className:`bg-foreground-subtle/15 text-foreground-subtle`}}function $({label:e,className:t}){return o(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium ${t}`,children:e})}function ne({addonId:e}){let{data:t,isLoading:n}=l({addonId:e},{refetchInterval:1e4,retry:!1});if(n||!t)return null;let r=O.safeParse(t);if(!r.success)return null;let i=r.data;return o($,{label:`${i.brokerCount} broker${i.brokerCount===1?``:`s`}${i.connectedCount>0?` • ${i.connectedCount} connected`:``}`,className:`bg-primary/10 text-primary`})}function re({addonId:e}){let{data:t,isLoading:n}=h({addonId:e},{refetchInterval:1e4,retry:!1});if(n||!t)return null;let r=A.safeParse(t);if(!r.success)return null;let i=r.data,a=i.linkState===`linked`?`bg-emerald-500/15 text-emerald-700 dark:text-emerald-300`:i.linkState===`error`?`bg-danger/15 text-danger`:`bg-foreground-subtle/15 text-foreground-subtle`;return o($,{label:`${i.linkState} • ${i.exposedDeviceCount} exposed`,className:a})}function ie({kind:e,addonId:t}){return e===`broker`?o(ne,{addonId:t}):e===`device-export`?o(re,{addonId:t}):null}function ae({descriptor:e,rows:n,isLoading:i}){let a=Q(e.kind),s=e.kind===`device-export`,c=j();return o(I,{title:e.title,subtitle:e.subtitle,pageIcon:e.icon,itemIcon:e.icon,capability:a??e.kind,installButtonLabel:e.addLabel,items:n,isLoading:i,emptyTitle:e.emptyTitle,emptyDescription:e.emptyDescription,renderStatusBadges:n=>{let i=te(n.processState);return t(r,{children:[o($,{label:i.label,className:i.className}),o(ie,{kind:e.kind,addonId:n.addonId})]})},renderExpandedPanel:s?e=>o(v,{addonId:e.addonId,onOpenDevice:e=>c(`/devices/${e}`)}):void 0,showChrome:!0})}function oe(){let e=c(void 0,{refetchInterval:1e4}),t=(e.data??[]).map(X).filter(e=>e!==null);return o(M,{icon:D,title:`External systems`,subtitle:`External systems this hub talks to — device exporters, email relays, and message brokers. Settings, Logs and Events are docked under every provider.`,children:o(N,{tabs:J.map(n=>{let r=Object.entries(k).filter(([,e])=>e===n.kind).map(([e])=>e),i=n.kind===`broker`?o(q,{}):o(ae,{descriptor:n,rows:Z(t,r),isLoading:e.isLoading});return{id:n.tabId,label:n.title,icon:n.icon,content:i}})})})}export{oe as IntegrationsPage};
@@ -1 +0,0 @@
1
- import{I as e,Q as t,S as n,W as r,b as i,o as a,q as o,x as s,z as c}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 l,at as u,gt as d,ht as f}from"./player-overlays-B82OVd2b.js";import{D as p,E as m,Ec as h,Fr as ee,Il as te,Ki as g,Kr as _,On as ne,Sl as v,Su as y,Tn as re,Ui as ie,Yi as b,_l as x,cl as S,r as C,ri as w,xl as T,yl as E}from"./src-jk2FdB5v.js";import{t as D}from"./ProviderIcon-DCDpuWgi.js";import{a as O,n as k,s as A}from"./index-BpiZqZOx.js";import{t as ae}from"./AdminPage-CiKtOLQm.js";import"./useEventInvalidation-WjkWP5Gl.js";import{t as j}from"./StatusBadge-CeptlsPG.js";import{n as oe,r as M,t as N}from"./ScanNetworkModal-Cz8wK3Sf.js";import{t as P}from"./useBodyScrollLock-BDocajQE.js";t();function F(e,t){let[n,r]=o(!1);return c(()=>{if(!e){r(!1);return}r(!1);let n=setTimeout(()=>r(!0),t);return()=>clearTimeout(n)},[e,t]),n}t();function I({providerId:e,onImport:t,onSkip:r}){let{t:i}=k(),[a,u]=o(new Set),d=_(),f=d.data,p=d.isPending||!d.data&&!d.isError;c(()=>{e&&(d.isPending||d.data||d.mutate({addonId:e}))},[e,d]);function m(e){u(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}if(p)return n(`div`,{className:`flex flex-col items-center py-12`,children:[s(`div`,{className:`h-6 w-6 animate-spin rounded-full border-2 border-primary border-t-transparent`}),s(`p`,{className:`mt-3 text-xs text-foreground-subtle`,children:i(`integrations.searchingDevices`)})]});let h=f??[];return n(`div`,{className:`space-y-4`,children:[s(`p`,{className:`text-xs text-foreground-subtle`,children:h.length>0?i(`integrations.foundDevices`,{count:h.length}):i(`integrations.noDevicesFound`)}),h.length>0&&s(`div`,{className:`space-y-1.5 max-h-64 overflow-y-auto`,children:h.map(e=>{let t=e.stableId,r=e.suggestedName??t,o=a.has(t),c=e.alreadyOnboarded===!0;return n(`button`,{onClick:()=>{c||m(t)},disabled:c,title:c?i(`integrations.alreadyAddedHint`,{defaultValue:`Already added as "{{name}}" — re-adding would overwrite its settings.`,name:e.onboardedName??r}):void 0,className:`flex w-full items-center gap-3 rounded-lg border p-3 text-left transition-colors ${c?`border-border bg-surface opacity-60 cursor-not-allowed`:o?`border-primary/40 bg-primary/5`:`border-border bg-surface hover:border-foreground-subtle/30`}`,children:[s(`div`,{className:`flex h-5 w-5 items-center justify-center rounded border flex-shrink-0 ${o&&!c?`border-primary bg-primary`:`border-border`}`,children:o&&!c&&s(y,{className:`h-3 w-3 text-primary-foreground`})}),s(l,{className:`h-3.5 w-3.5 text-foreground-subtle flex-shrink-0`}),s(`span`,{className:`text-xs font-medium text-foreground truncate`,children:r}),c&&s(`span`,{className:`ml-auto flex-shrink-0 rounded bg-surface-muted px-1.5 py-0.5 text-[10px] font-medium text-foreground-subtle`,children:i(`integrations.alreadyAdded`,{defaultValue:`Already added`})})]},t)})}),n(`div`,{className:`flex items-center justify-between pt-2`,children:[s(`button`,{onClick:r,className:`rounded-lg border border-border px-3 py-1.5 text-xs text-foreground-subtle hover:text-foreground transition-colors`,children:i(`integrations.skip`)}),h.length>0&&n(`button`,{onClick:()=>t(Array.from(a)),disabled:a.size===0,className:`rounded-lg bg-primary px-4 py-1.5 text-xs font-medium text-primary-foreground shadow-sm disabled:opacity-50`,children:[i(`integrations.importSelected`),` (`,a.size,`)`]})]})]})}function L({onSelect:e,onClose:t,pendingAddonId:r=null}){let{t:i}=k(),a=O(),{data:o,isLoading:c}=g();if(c)return s(`div`,{className:`space-y-2 p-2`,children:[1,2,3].map(e=>s(`div`,{className:`h-14 rounded-lg bg-surface animate-pulse`},e))});let l=r!==null;return n(`div`,{className:`space-y-2`,children:[(o??[]).map(o=>{let c=o.instanceMode===`unique`&&o.existingInstances.length>0,u=r===o.addonId,d=l;return n(`button`,{disabled:d,onClick:()=>{if(!d)if(c){let e=o.existingInstances[0].id;t(),a(`/integrations/${e}`)}else e(o.addonId,o.instanceMode,o.discoveryMode,o.name,o.kind,o.brokerKind,o.mode,o.canTest)},className:`flex w-full items-center gap-3 rounded-lg border border-border bg-surface p-3 text-left hover:border-foreground-subtle/30 transition-colors disabled:opacity-60 disabled:cursor-not-allowed disabled:hover:border-border`,children:[o.iconUrl?s(`div`,{className:`flex h-9 w-9 items-center justify-center rounded-lg flex-shrink-0`,style:{backgroundColor:`${o.color}15`},children:s(`img`,{src:o.iconUrl,alt:``,className:`h-5 w-5`})}):s(`div`,{className:`flex h-9 w-9 items-center justify-center rounded-lg flex-shrink-0`,style:{backgroundColor:`${o.color}15`},children:s(`span`,{className:`text-sm`,style:{color:o.color},children:`◉`})}),n(`div`,{className:`flex-1 min-w-0`,children:[s(`p`,{className:`text-xs font-semibold text-foreground`,children:o.name}),o.description&&s(`p`,{className:`text-[10px] text-foreground-subtle mt-0.5 truncate`,children:o.description})]}),u?s(te,{className:`h-4 w-4 animate-spin text-primary flex-shrink-0`}):c?n(`span`,{className:`flex items-center gap-1 text-[10px] font-medium text-foreground-subtle`,children:[s(S,{className:`h-3 w-3`}),i(`integrations.manage`)]}):s(f,{className:`h-4 w-4 text-foreground-subtle flex-shrink-0`})]},o.addonId)}),(o??[]).length===0&&s(`div`,{className:`py-8 text-center text-xs text-foreground-subtle`,children:i(`integrations.noProviders`)})]})}t();function se(e){let t=e=>{if(e.type===`separator`||e.type===`info`||e.type===`button`)return e;if(e.type===`group`)return{...e,fields:e.fields.map(e=>t(e))};let{value:n,...r}=e;return r};return{...e.tabs?{tabs:e.tabs}:{},sections:e.sections.map(e=>({...e,fields:e.fields.map(t)}))}}var R=2e4;function ce({open:e,onClose:t}){let{t:l}=k(),u=O(),d=a(),[f,p]=o(`picker`),[m,g]=o(null),[v,y]=o(null),[re,b]=o(`manual`),[x,S]=o(null),[C,w]=o(``),[T,E]=o(null),[D,A]=o(null),[ae,j]=o(!1),{data:N}=ne({addonId:m??``,nodeId:`hub`},{enabled:m!=null}),ce=r(()=>N?se(N):null,[N]),z=ie({onSuccess:()=>d.invalidateQueries({queryKey:[[`integrations`]]})}),B=_(),le=B.data;c(()=>{f!==`discovery`||!v||!m||B.isPending||B.data||B.mutate({addonId:m})},[f,v,m,B]);let V=ee({onSuccess:()=>d.invalidateQueries({queryKey:[[`deviceManager`]]})});function H(e,t,n,r,i,a,o,s){if(!z.isPending){if(g(e),j(s),b(n),w(r),A(null),o===`broker`){if(!a){A(`Addon '${e}' declares mode 'broker' but no brokerKind in its manifest`);return}S(a),p(`broker`);return}if(o===`account`){p(`config`);return}U(e,r)}}async function U(e,n){try{let r=await z.mutateAsync({addonId:e,name:n,settings:{}});t(),q(),u(`/integrations/${r.id}?add=1`)}catch{}}async function W(e){if(m)try{let t=await z.mutateAsync({addonId:m,name:e.name,settings:e.config});y(t.id),re===`auto`||re===`both`?p(`discovery`):K(t.id)}catch{}}async function G(e){if(m)try{let t=await z.mutateAsync({addonId:m,name:C,settings:{brokerId:e}});E(t.id),y(t.id),K(t.id)}catch{}}async function ue(e){if(m){for(let t of e){let e=le?.find(e=>e.stableId===t);e&&await V.mutateAsync({addonId:m,candidate:e,...T===null?{}:{integrationId:T}})}K()}}function K(e){let n=e??v??m;t(),q(),n&&u(`/integrations/${n}`)}function q(){p(`picker`),g(null),y(null),b(`manual`),S(null),w(``),E(null),A(null),j(!1)}function J(){t(),q()}P(e);let Y=z.isPending,X=F(Y,R);if(!e)return null;let Z={picker:l(`integrations.newIntegration`),config:l(`integrations.configureIntegration`),discovery:l(`integrations.importDevices`),broker:l(`integrations.connectBroker`,{defaultValue:`Connect a broker`})},Q=Y?m:null,$=z.error,de=Y&&!X;return n(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center`,children:[s(`div`,{className:`absolute inset-0 bg-black/60`,onClick:de?void 0:J}),n(`div`,{className:`relative z-10 w-full max-w-lg max-h-[calc(85dvh-2*max(env(safe-area-inset-top),env(safe-area-inset-bottom)))] rounded-xl border border-border bg-background shadow-2xl flex flex-col overflow-hidden`,children:[n(`div`,{className:`flex items-center justify-between border-b border-border px-5 py-4 flex-shrink-0`,children:[s(`h2`,{className:`text-sm font-semibold text-foreground`,children:Z[f]}),s(`button`,{onClick:J,disabled:de,className:`rounded-md p-1 text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-40 disabled:cursor-not-allowed`,children:s(h,{className:`h-4 w-4`})})]}),n(`div`,{className:`px-5 py-4 flex-1 overflow-y-auto overscroll-contain`,children:[$&&!Y&&s(`div`,{className:`mb-3 rounded-lg border border-destructive/40 bg-destructive/10 px-3 py-2 text-xs text-destructive`,children:$ instanceof Error?$.message:String($)}),f===`picker`&&n(i,{children:[D&&s(`div`,{className:`mb-3 rounded-lg border border-destructive/40 bg-destructive/10 px-3 py-2 text-xs text-destructive`,children:D}),s(L,{onSelect:H,onClose:J,pendingAddonId:Q})]}),f===`config`&&m&&s(oe,{addonId:m,configSchema:ce??null,canTest:ae,onSave:W,onBack:()=>p(`picker`)}),f===`broker`&&x&&s(M,{kind:x,onResolved:e=>{G(e)},onBack:()=>p(`picker`)}),f===`discovery`&&v&&s(I,{providerId:v,onImport:ue,onSkip:K})]}),Y&&n(`div`,{className:`absolute inset-0 z-20 flex flex-col items-center justify-center gap-2 rounded-xl bg-background/85 backdrop-blur-sm px-6 text-center`,children:[s(te,{className:`h-6 w-6 animate-spin text-primary`}),s(`p`,{className:`text-xs font-medium text-foreground`,children:l(`integrations.creating`,{defaultValue:`Creating integration…`})}),!X&&s(`p`,{className:`text-[10px] text-foreground-subtle`,children:l(`integrations.creatingHint`,{defaultValue:`Waiting for the addon to restart and register`})}),X&&n(i,{children:[s(`p`,{className:`text-[10px] text-foreground-subtle max-w-xs`,children:l(`integrations.creatingOverdue`,{defaultValue:`This is taking longer than expected. The integration may already have been created — close this dialog and refresh to check.`})}),s(`button`,{onClick:J,className:`mt-1 rounded-md border border-border bg-surface px-3 py-1.5 text-[11px] font-medium text-foreground hover:bg-surface-hover transition-colors`,children:l(`integrations.closeAndRefresh`,{defaultValue:`Close`})})]})]})]})]})}function z({integration:e,expanded:t,onToggleExpand:r}){return n(`div`,{className:`flex items-center gap-2.5`,children:[s(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),r(e.addonId)},"aria-label":t?`Collapse`:`Expand`,"aria-expanded":t,className:`flex h-5 w-5 flex-shrink-0 items-center justify-center rounded text-foreground-subtle transition-colors hover:bg-surface-hover hover:text-foreground`,children:s(t?d:f,{className:`h-3.5 w-3.5`})}),s(D,{type:e.addonId,size:`sm`}),n(`div`,{className:`flex min-w-0 flex-col`,children:[s(`span`,{className:`truncate text-xs font-semibold text-foreground`,children:e.name}),s(`span`,{className:`truncate text-[10px] text-foreground-subtle`,children:e.addonId})]})]})}function B(e){let{isExpanded:t,onToggleExpand:n}=e;return[{key:`name`,header:`Integration`,headerClassName:`w-[55%]`,cell:e=>s(z,{integration:e,expanded:t(e),onToggleExpand:n})},{key:`devices`,header:`Devices`,headerClassName:`w-[15%]`,cellClassName:`text-[11px] text-foreground-subtle`,cell:e=>`${e.deviceCount} device${e.deviceCount===1?``:`s`}`},{key:`status`,header:`Status`,headerClassName:`w-[15%]`,cell:e=>s(j,{status:e.status})}]}t();function le(e){if(!e.enabled)return`disabled`;switch(e.processState){case`running`:return`running`;default:return`stopped`}}var V=`expand`;function H(){let{t}=k(),a=O(),c=u(),[l]=A(),[d,f]=o(!1),h=e(()=>f(!0),[]),ee=e(()=>f(!1),[]),[te,g]=o(!1),_=e(()=>g(!0),[]),ne=e(()=>g(!1),[]);C([`integrations`],[`integration.enabled`,`integration.disabled`,`integration.deleted`,`provider.started`,`provider.stopped`,`addon.installed`,`addon.uninstalled`,`addon.started`,`addon.stopped`,`addon.updated`]),C([`deviceManager`],[`device.registered`,`device.unregistered`,`device.online`,`device.offline`,`device.disabled`,`device.enabled`]);let{data:y,isLoading:ie,refetch:S}=b(void 0),{data:j,isLoading:oe,refetch:M}=w({projection:`slim`}),P=r(()=>j??[],[j]),F=r(()=>y??[],[y]),I=r(()=>{let e=new Map;for(let t of P)e.set(t.id,{id:t.id,name:t.name??t.stableId??`#${String(t.id)}`});return e},[P]),L=r(()=>{let e=new Map;for(let t of p(P)){let n=t.addonId??``;n&&e.set(n,(e.get(n)??0)+1)}return e},[P]),se=r(()=>F.map(e=>({id:e.id,addonId:e.addonId,name:e.name,enabled:e.enabled,status:le(e),deviceCount:L.get(e.addonId)??0})),[F,L]),R=l.get(V),z=e(e=>{let t=new URLSearchParams(window.location.search);t.get(V)===e?t.delete(V):t.set(V,e);let n=t.toString(),r=`${window.location.pathname}${n?`?${n}`:``}${window.location.hash}`;window.history.replaceState(window.history.state,``,r),window.dispatchEvent(new PopStateEvent(`popstate`))},[]),H=e(e=>a(`/integrations/${e.id}`),[a]),U=e(e=>I.get(e)??null,[I]),W=e(e=>s(D,{type:e,size:`sm`}),[]),G=e(e=>a(`/devices/${String(e)}`),[a]),ue=e(e=>s(m,{context:`integration-detail`,devices:P,trpc:c.trpcClient,forceAddon:e.addonId,urlScope:`nested`,lsKey:`integrations:nested:${e.addonId}`,resolveIntegrationIcon:W,resolveParent:U,onNavigate:G}),[P,c.trpcClient,W,U,G]),K=e(e=>R===e.addonId,[R]),q=r(()=>B({isExpanded:K,onToggleExpand:z}),[K,z]),J=e(e=>`${e.name} ${e.addonId}`,[]),Y=e(e=>e.addonId,[]),X=e(()=>{S(),M()},[S,M]),Z=ie||oe,Q=F.length>0;return n(ae,{icon:T,title:t(`nav.integrations`,`Integrations`),actions:n(i,{children:[s(`button`,{onClick:X,disabled:Z,className:`flex items-center gap-1 rounded-lg border border-border bg-surface px-2.5 py-1.5 text-xs font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50`,title:`Refresh`,children:s(x,{className:re(`h-3.5 w-3.5`,Z&&`animate-spin`)})}),n(`button`,{onClick:_,className:`flex items-center gap-1.5 rounded-lg border border-border bg-surface px-2.5 py-1.5 text-xs font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,title:`Scan the local network for devices`,children:[s(E,{className:`h-3.5 w-3.5`}),`Scan network`]}),n(`button`,{onClick:h,className:`flex items-center gap-1.5 rounded-lg bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground shadow-sm`,children:[s(v,{className:`h-3.5 w-3.5`}),`New Integration`]})]}),children:[Z&&s(`div`,{className:`space-y-2`,children:[1,2,3].map(e=>s(`div`,{className:`h-12 rounded-lg border border-border bg-surface animate-pulse`},e))}),!Z&&!Q&&n(`div`,{className:`flex flex-col items-center py-20 text-foreground-subtle`,children:[s(`p`,{className:`text-sm`,children:`No integrations configured.`}),s(`p`,{className:`text-xs mt-1`,children:`Click "New Integration" to connect cameras and devices.`})]}),!Z&&Q&&s(m,{mode:`generic`,items:se,getKey:Y,getSearchText:J,columns:q,onRowClick:H,isExpanded:K,renderExpanded:ue,searchPlaceholder:t(`integrations.search`,{defaultValue:`Search integrations…`}),emptyLabel:t(`integrations.empty`,{defaultValue:`No integrations found.`})}),s(ce,{open:d,onClose:ee}),s(N,{open:te,onClose:ne})]})}export{H as IntegrationsPage};
@@ -1 +0,0 @@
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,ht as u,st as d,vt as f}from"./player-overlays-B82OVd2b.js";import{Au as p,Bc as m,Cu as h,Du as g,Ec as _,Ei as v,Fc as y,Fu as b,Gc as x,Hc as S,Hl as C,Hu as w,Jc as T,Lt as E,Mc as D,Ml as O,Mu as k,Oc as A,Ou as j,Pl as M,Pr as ee,Pu as N,Qc as P,Ql as te,Rl as F,Si as ne,Sl as I,Tc as L,Tl as R,Tu as z,Uc as re,Ul as ie,Uu as B,Vu as V,Wc as ae,Yl as oe,Zc as se,Zl as ce,ai as le,au as ue,bi as de,ci as fe,ct as H,dl as pe,du as me,el as he,gi as ge,gu as U,hi as _e,hl as ve,hn as ye,hu as be,jc as xe,mi as Se,ml as Ce,nl as we,nu as Te,oi as Ee,ol as De,ot as W,pi as Oe,qc as ke,ri as Ae,ru as je,si as Me,st as G,v as Ne,w as Pe,wl as Fe,xi as Ie,yi as Le,yl as Re}from"./src-jk2FdB5v.js";import{t as ze}from"./boxes-B2dkI7tE.js";import{t as Be}from"./user-round-C782gYyr.js";import{_t as K,vt as q,yt as J}from"./src-8XVcukAG.js";import{i as Y,n as X,s as Ve}from"./index-BpiZqZOx.js";import{t as He}from"./AdminPage-CiKtOLQm.js";var Ue=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 We={camera:c,hub:Ce,container:ze,light:F,siren:we,switch:ae,sensor:B,thermostat:x,climate:w,button:U,"event-emitter":L,update:Ue,notifier:p,script:pe,automation:A,lock:M,cover:j,valve:je,humidifier:Te,"water-heater":oe,fan:te,"media-player":se,"alarm-panel":De,control:he,presence:Be,weather:me,vacuum:g,"lawn-mower":re,image:C,smoke:V};function Z({type:e,className:t}){return o(We[e]??U,{"aria-hidden":`true`,className:t??`h-3.5 w-3.5 shrink-0 text-foreground-subtle`})}function Ge({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 Ke({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 qe(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 Je({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 Ye(e,t){return e.find(e=>e.locationKeys.includes(t))?.zoneKey??null}var Xe={"map-pin":{icon:O,label:`Pin`},house:{icon:ie,label:`Home`},"door-open":{icon:ue,label:`Entrance`},sofa:{icon:P,label:`Living room`},utensils:{icon:y,label:`Kitchen`},"bed-double":{icon:k,label:`Bedroom`},bath:{icon:N,label:`Bathroom`},briefcase:{icon:z,label:`Office`},car:{icon:h,label:`Garage`},"circle-parking":{icon:be,label:`Parking`},route:{icon:ve,label:`Street`},trees:{icon:S,label:`Garden`},umbrella:{icon:m,label:`Terrace`},"waves-ladder":{icon:xe,label:`Pool`},fence:{icon:ce,label:`Gate`},package:{icon:R,label:`Storage`},warehouse:{icon:D,label:`Warehouse`},store:{icon:T,label:`Shop`},sun:{icon:ke,label:`Outdoor`},radar:{icon:Re,label:`Perimeter`}},Ze=K.map(e=>({id:e,...Xe[e]}));function Qe(e){return Xe[J(e)].icon}var $e=new Map(Ze.map(e=>[e.id,[e.label]])),et=new Map(Ze.map(e=>[e.id,e.label])),tt=new Set(K);function nt(e){return tt.has(e)?Qe(e):void 0}function rt({name:e,icon:t,busy:n,onPick:r}){return o(Pe,{value:t,onPick:e=>r(e===null?null:J(e)),resolveGlyph:nt,fallbackGlyph:O,clearGlyph:b,labelFor:e=>et.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:K,extraWords:$e,disabled:n})}function it(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 at(e,t){let n=$(t);return n===null?[]:e.filter(e=>$(e.location)===n)}function ot(e,t){let n=at(e,t),r=new Set(n.map(e=>e.id));return n.filter(e=>e.parentDeviceId===null||!r.has(e.parentDeviceId))}function st(e,t){let n=$(e.location);return n===null||new Set(t.map(e=>$(e))).has(n)?null:e.location?.trim()??null}function ct(e,t){let n=$(e.location);return n!==null&&t.has(n)}function lt(e,t){let n=new Set(t.map(e=>$(e))),r=new Set(e.filter(e=>ct(e,n)).map(e=>e.id));return e.filter(e=>!(ct(e,n)||e.parentDeviceId!==null&&r.has(e.parentDeviceId)))}function ut(e,t){return lt(e,t).filter(e=>e.parentDeviceId===null)}function dt(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 ft(e,t){return dt(e,t).length}function pt(e,t){return e.filter(e=>!e.isCamera&&e.parentDeviceId===t)}function mt(e,t){return t.map(t=>({name:t,members:ot(e,t)}))}function ht(e){return`${e.kind}:${String(e.device.id)}`}function gt(e,t,n){return e.flatMap(e=>{let r=pt(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 _t({name:e,members:i,devices:s,busy:c,icon:l,description:u,onRename:f,onDelete:p,onPickIcon:m,onSaveDescription:h,zones:g,zoneKey:v,onChangeZone:y}){let{t:b}=X(),[x,S]=a(!1),[C,w]=a(e),T=W(i,n(()=>({searchText:e=>[e.name,...pt(s,e.id).map(e=>e.name)],facetValue:e=>e.type}),[s])),[E,D]=a(()=>new Set),O=e=>D(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),k=n(()=>gt(T.rows,s,E),[T.rows,s,E]),A=[{key:`name`,header:b(`locations.columns.device`),notSortableReason:b(`locations.columns.noSort`),render:e=>e.kind===`member`?o(vt,{row:e,onToggle:()=>O(e.device.id)}):o(yt,{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(Ge,{online:e.device.online,deviceName:e.device.name}),o(`span`,{className:`text-[11px] text-foreground-muted`,children:e.device.online?`online`:`offline`})]})}],j=()=>{w(e),S(!1)},M=async()=>{let t=C.trim();if(t.length===0||t===e){j();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(rt,{name:e,icon:l,busy:c,onPick:m}),x?t(r,{children:[o(`input`,{value:C,onChange:e=>w(e.target.value),onKeyDown:e=>{e.key===`Enter`&&M(),e.key===`Escape`&&j()},"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 M(),className:`text-[11px] text-foreground-subtle hover:text-foreground`,children:`Save`}),o(`button`,{type:`button`,onClick:j,"aria-label":`Cancel rename`,className:`p-0.5 text-foreground-subtle hover:text-foreground`,children:o(_,{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(Ne,{items:[{id:`rename`,label:`Rename`,icon:Fe,disabled:c,onClick:()=>{w(e),S(!0)}},{id:`delete`,label:`Delete`,icon:d,danger:!0,separatorBefore:!0,disabled:c,onClick:()=>void p()}],title:`Actions for ${e}`,triggerClassName:`p-1`})]})]}),o(Je,{name:e,zones:g,zoneKey:v,busy:c,onChange:y}),o(Ke,{name:e,description:u,busy:c,onSave:h}),i.length>0&&o(`div`,{className:`border-b border-border px-3 py-1.5`,children:o(G,{state:T.state,facets:T.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:T.setSearch,onToggleFacet:T.toggleFacet,onClear:T.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(H,{columns:A,rows:k,rowKey:ht,bordered:!1,minWidthPx:360,mobileMode:`scroll`,emptyMessage:b(`locations.filter.noMatch`)})]})}function vt({row:e,onToggle:n}){let{device:r,accessories:i,open:a}=e,s=a?l:u;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(Y,{to:`/devices/${String(r.id)}`,className:`min-w-0 truncate text-xs text-foreground hover:underline`,children:r.name})]})}function yt({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(Y,{to:`/devices/${String(n.id)}`,className:`min-w-0 truncate text-[11px] text-foreground-muted hover:underline`,children:n.name})]})}e();function bt({zones:e,busy:n,onCreate:r,onRename:i,onDelete:s,onPickIcon:c}){let[l,u]=a(!1),[f,p]=a(``),[m,h]=a(null),[g,v]=a(``),y=async()=>{let e=f.trim();e.length!==0&&(await r(e),p(``),u(!1))},b=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:()=>u(!0),disabled:n,className:`flex items-center gap-1 text-[11px] text-foreground-muted hover:text-foreground disabled:opacity-50`,children:[o(I,{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`&&y(),e.key===`Escape`&&(p(``),u(!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 y(),className:`text-[11px] text-foreground-subtle hover:text-foreground`,children:`Add`}),o(`button`,{type:`button`,onClick:()=>{p(``),u(!1)},"aria-label":`Cancel new zone`,className:`p-0.5 text-foreground-subtle hover:text-foreground`,children:o(_,{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(rt,{name:e.label,icon:e.icon,busy:n,onPick:t=>c(e.label,t)}),m===e.label?o(`input`,{value:g,onChange:e=>v(e.target.value),onKeyDown:t=>{t.key===`Enter`&&b(e.label),t.key===`Escape`&&h(null)},onBlur:()=>void b(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:()=>{v(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(d,{className:`h-3.5 w-3.5`})})]},e.zoneKey))})]})}e();function xt({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(I,{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(_,{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(I,{className:`h-3.5 w-3.5`}),`New location`]})}e();var St={searchText:e=>[e.name],facetValue:e=>e.type};function Ct({rows:e,fleet:r,locations:i,busy:s,emptyMessage:c,onAssign:l}){let{t:u}=X(),[d,f]=a([]),[p,m]=a(``),h=W(e,St),g=h.rows,_=n(()=>g.map(e=>e.id),[g]),v=n(()=>d.filter(e=>_.includes(e)),[d,_]),y=g.length>0&&v.length===g.length,b=n(()=>{let t=new Map;for(let n of e)t.set(n.id,ft(r,n.id));return t},[e,r]),x=v.reduce((e,t)=>e+(b.get(t)??0),0),S=e=>f(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]),C=()=>f(y?[]:_);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(G,{state:h.state,facets:h.facets,labels:{searchPlaceholder:u(`locations.filter.searchPlaceholder`),searchLabel:u(`locations.unassigned.searchLabel`),facetsLabel:u(`locations.filter.typesLabel`),clearLabel:u(`locations.filter.clear`)},onSearch:h.setSearch,onToggleFacet:h.toggleFacet,onClear:h.clear}),v.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:[v.length,` selected`,x>0&&` · ${String(x)} 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||v.length===0||(l(v,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(H,{columns:[{key:`select`,width:`w-8`,headerRender:()=>o(E,{checked:y,onChange:C,"aria-label":y?`Clear selection`:`Select all unassigned devices`}),render:e=>o(E,{checked:v.includes(e.id),onChange:()=>S(e.id),"aria-label":`Select ${e.name}`})},{key:`name`,header:`Device`,sortValue:e=>e.name.toLowerCase(),render:e=>{let n=st(e,i);return t(`span`,{className:`flex items-center gap-1.5`,children:[o(Z,{type:e.type}),o(Y,{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(Ge,{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=>b.get(e.id)??0,render:e=>o(`span`,{className:`tabular-nums text-[11px] text-foreground-muted`,children:b.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:g,rowKey:e=>e.id,minWidthPx:720,mobileMode:`scroll`,emptyMessage:h.active?u(`locations.filter.noMatch`):c})]})}e();function wt(){let e=i(),r=ye(),{data:a,isLoading:s}=Me(),{data:c}=Ee(),{data:l}=le(),{data:u}=fe(),{data:d,isLoading:f}=Ae({projection:`slim`}),p=()=>{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`]]})},m=ee({onSuccess:p}),h=Oe({onSuccess:p}),g=Le({onSuccess:p}),_=_e({onSuccess:p}),y=Ie({onSuccess:p}),b=de({onSuccess:p}),x=v({onSuccess:p}),S=Se({onSuccess:p}),C=ge({onSuccess:p}),w=ne({onSuccess:p}),T=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})),[d]),E=a??[],D=n(()=>mt(T,E),[T,E]),[k,A]=Ve(),j=k.get(`room`),M=j!==null&&D.some(e=>e.name===j)?j:D[0]?.name??null,N=D.find(e=>e.name===M)??null,P=e=>{A(t=>{let n=new URLSearchParams(t);return n.set(`room`,e),n},{replace:!0})},te=n(()=>ut(T,E),[T,E]),F=s||f,I=g.isPending||h.isPending||m.isPending||y.isPending,L=async e=>{await m.mutateAsync({name:e})},R=async(e,t)=>{let n=t.trim();n.length===0||n===e||await _.mutateAsync({from:e,to:n})},z=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 h.mutateAsync({name:e,cascade:!0})},re=async(e,t)=>{await y.mutateAsync({location:e,icon:t})},ie=async(e,t)=>{await b.mutateAsync({location:e,description:t})},B=u??[],V=async(e,t)=>{await w.mutateAsync({location:e,zone:t})};return t(He,{icon:O,title:`Locations`,subtitle:`Rooms and areas of the site. Assign any device here — storage disks are under Data → Storage.`,children:[o(xt,{busy:m.isPending,onCreate:L}),o(bt,{zones:B,busy:I,onCreate:e=>x.mutateAsync({name:e}),onRename:(e,t)=>C.mutateAsync({from:e,to:t}),onDelete:e=>S.mutateAsync({name:e}),onPickIcon:(e,t)=>x.mutateAsync({name:e,icon:t})}),F&&o(`p`,{className:`text-xs text-foreground-subtle`,children:`Loading locations and devices…`}),D.length>0&&o(`div`,{role:`tablist`,"aria-label":`Locations`,className:`-mx-1 flex gap-1 overflow-x-auto px-1 pb-1`,children:D.map(e=>{let n=e.name===M,r=Qe(it(c,q(e.name)));return t(`button`,{type:`button`,role:`tab`,"aria-selected":n,onClick:()=>P(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)})}),N!==null&&o(_t,{name:N.name,members:N.members,devices:T,busy:I,icon:it(c,q(N.name)),onPickIcon:e=>re(N.name,e),description:qe(l,q(N.name)),onSaveDescription:e=>ie(N.name,e),zones:B,zoneKey:Ye(B,q(N.name)),onChangeZone:e=>V(N.name,e),onRename:e=>R(N.name,e),onDelete:()=>z(N.name,at(T,N.name).length)},N.name),E.length===0&&!F&&o(`p`,{className:`text-xs text-foreground-subtle`,children:`No locations yet. Add Ingresso, Salone, Cucina…`}),o(Ct,{rows:te,fleet:T,locations:E,busy:I,emptyMessage:F?`Loading…`:`Every top-level device has a room.`,onAssign:(e,t)=>{for(let n of e)g.mutate({deviceId:n,location:t})}})]})}export{wt as LocationsPage};