@camstack/addon-admin-ui 1.2.462 → 1.2.464

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 (136) hide show
  1. package/dist/assets/{AddonAssetIcon-DMG19u-q.js → AddonAssetIcon-CeDKQMK8.js} +1 -1
  2. package/dist/assets/Addons-rFRq_nR3.js +4 -0
  3. package/dist/assets/{AdminPage-oFm0hhFj.js → AdminPage-DP0D1UF2.js} +1 -1
  4. package/dist/assets/{AdminSectionedPage-CXL0Cc0w.js → AdminSectionedPage-SayqOJV9.js} +1 -1
  5. package/dist/assets/AiProfiles-Ds3eZpQt.js +3 -0
  6. package/dist/assets/{BrokerForm-D-QT3T4C.js → BrokerForm-BE7pwwXD.js} +1 -1
  7. package/dist/assets/Build-C5Fd-n_g.js +40 -0
  8. package/dist/assets/Calendars-B4pCLD6a.js +1 -0
  9. package/dist/assets/{Cluster-aDWkD3jS.js → Cluster-DBi_J1Wn.js} +1 -1
  10. package/dist/assets/CompositionEditor-CMWuITR7.js +1 -0
  11. package/dist/assets/CompositionEditorPage-BdoPZcOr.js +1 -0
  12. package/dist/assets/Data-CSl5da2E.js +2 -0
  13. package/dist/assets/DeviceDetail-CYFZVwJc.js +2 -0
  14. package/dist/assets/{DeviceDoActionFields-BfsAy1hi.js → DeviceDoActionFields-DmabAA_t.js} +1 -1
  15. package/dist/assets/{Devices-CndVoeQ8.js → Devices-3UrNP22-.js} +1 -1
  16. package/dist/assets/{EmbedPlayerPage-DB6Hb_mj.js → EmbedPlayerPage-DCl9eG4I.js} +1 -1
  17. package/dist/assets/History-Da3qAsyF.js +1 -0
  18. package/dist/assets/{Identity-DBoDRsam.js → Identity-DkYAbCLL.js} +1 -1
  19. package/dist/assets/IntegrationDetail-DsnuoHtK.js +1 -0
  20. package/dist/assets/{IntegrationHub-DnBfbKWG.js → IntegrationHub-BhNtcf1l.js} +1 -1
  21. package/dist/assets/Integrations-C_Rf4dUR.js +1 -0
  22. package/dist/assets/Integrations-DwGfEuNv.js +1 -0
  23. package/dist/assets/Library-UaWRBgSL.js +1 -0
  24. package/dist/assets/Locations-BVvFwwcJ.js +3 -0
  25. package/dist/assets/{Logs-DhyhktWC.js → Logs-D3SuWdxr.js} +1 -1
  26. package/dist/assets/{MaskShapeCanvas-CBL-DJGe.js → MaskShapeCanvas-C5rdWXtR.js} +1 -1
  27. package/dist/assets/{MotionZonesSettings-8vvPxjTe.js → MotionZonesSettings-ZcLOh0c4.js} +1 -1
  28. package/dist/assets/MyAccess-BOVxwGSk.js +2 -0
  29. package/dist/assets/{Network-BVufubzK.js → Network-B9GVDhRD.js} +1 -1
  30. package/dist/assets/{NodeAddonsSettingsPanel-B2ppCOQm.js → NodeAddonsSettingsPanel-Cg_7xIUB.js} +1 -1
  31. package/dist/assets/Notifications-N583FFEv.js +1 -0
  32. package/dist/assets/Pipeline-ud0MHAwc.js +1 -0
  33. package/dist/assets/{PrivacyMaskSettings-Cp2TZg4d.js → PrivacyMaskSettings-C1yy5qkh.js} +1 -1
  34. package/dist/assets/Recordings-MsjfcehA.js +1 -0
  35. package/dist/assets/{ScanNetworkModal-DFuZaP78.js → ScanNetworkModal-BjNMs3MS.js} +1 -1
  36. package/dist/assets/{SceneMonitorEditor-B47BGXqI.js → SceneMonitorEditor-DOsfgD2_.js} +1 -1
  37. package/dist/assets/SessionsList-CTYBPqGP.js +2 -0
  38. package/dist/assets/{Showroom-B_K5Voir.js → Showroom-CBqwAnFi.js} +1 -1
  39. package/dist/assets/{System-B3QOfsQ-.js → System-Ch25Qpf4.js} +1 -1
  40. package/dist/assets/{Terminal-CepoEWPj.js → Terminal-2YmS1vyw.js} +3 -3
  41. package/dist/assets/{Viewer-9n98n7Mc.js → Viewer-Cywjrh5B.js} +1 -1
  42. package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-pwVcJ8Li.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-DtRMQaGk.js} +1 -1
  43. package/dist/assets/{addon-icons-context-CfxpJVkI.js → addon-icons-context-BmIeVEr2.js} +1 -1
  44. package/dist/assets/{archive-CkpL7nYU.js → archive-BfaqC_ow.js} +1 -1
  45. package/dist/assets/{authed-media-BtcsEMhs.js → authed-media-DEe2ThW9.js} +1 -1
  46. package/dist/assets/{bell-off-D9tHNuLX.js → bell-off-D657Qfjl.js} +1 -1
  47. package/dist/assets/{board-model-BLL_cD-z.js → board-model-DGOHIUHU.js} +1 -1
  48. package/dist/assets/{boxes-BA8-oYCX.js → boxes-BH4OlHge.js} +1 -1
  49. package/dist/assets/circle-slash-CrxEyAEa.js +1 -0
  50. package/dist/assets/client-CYW9ELYx.js +358 -0
  51. package/dist/assets/{cloud-upload-5unDJZ5Y.js → cloud-upload-CFwwCXBD.js} +1 -1
  52. package/dist/assets/crop-CHdeAwRA.js +1 -0
  53. package/dist/assets/{device-integration-icon-B_6sNK4Z.js → device-integration-icon-BnX44OAw.js} +1 -1
  54. package/dist/assets/device-picker-model-BG1JsKx5.js +1 -0
  55. package/dist/assets/dist-2_skMd0F.js +358 -0
  56. package/dist/assets/{dist-CnGggN6i.js → dist-U0zz_Qaa.js} +1 -1
  57. package/dist/assets/{eraser-BehwAkha.js → eraser-DoTYk-op.js} +1 -1
  58. package/dist/assets/{format-3n872UoD.js → format-1YmOOIUc.js} +1 -1
  59. package/dist/assets/{hard-drive-download-5P7_6z5A.js → hard-drive-download-Bkwx7erK.js} +1 -1
  60. package/dist/assets/{hostInit-DxdU_pnx.js → hostInit-CwZD0WkC.js} +1 -1
  61. package/dist/assets/i18n-B-tc0y0g.js +1 -0
  62. package/dist/assets/{icons-Clqqnzdw.js → icons-zrco2zgK.js} +1 -1
  63. package/dist/assets/index-D44jtzlM.css +2 -0
  64. package/dist/assets/index-c8zQtnFh.js +4 -0
  65. package/dist/assets/{key-Dq6CiRWE.js → key-COVAKnjX.js} +1 -1
  66. package/dist/assets/{key-round-DX4Tm3r5.js → key-round-D26RK68l.js} +1 -1
  67. package/dist/assets/{layers-M4OA6__8.js → layers-egCDUDk5.js} +1 -1
  68. package/dist/assets/{linked-devices-model-BT6sN3Jo.js → linked-devices-model-foIHeKZ-.js} +1 -1
  69. package/dist/assets/{list-ordered-USAX-4g-.js → list-ordered-BRxJMtli.js} +1 -1
  70. package/dist/assets/{location-owned-usage-CmhxgtcU.js → location-owned-usage-Cz9x2yYX.js} +1 -1
  71. package/dist/assets/{log-in-C-sFC6o8.js → log-in-CR1DP5G2.js} +1 -1
  72. package/dist/assets/{memory-stick-CNw60CfF.js → memory-stick-CdDKrQSf.js} +1 -1
  73. package/dist/assets/{message-square-plus-BHUImv1e.js → message-square-plus-CTU1aOLB.js} +1 -1
  74. package/dist/assets/{mf-entry-bootstrap-0-22898ca3.js → mf-entry-bootstrap-0-f804d6aa.js} +2 -2
  75. package/dist/assets/{mic-off-nZLVhgXn.js → mic-off-D_q6qKRd.js} +1 -1
  76. package/dist/assets/{monitor-off-CemGAHSc.js → monitor-off-CxDc2ENq.js} +1 -1
  77. package/dist/assets/{monitor-smartphone-DWtxkkEg.js → monitor-smartphone-CXWzPwhX.js} +1 -1
  78. package/dist/assets/mount-BG1JsKx5.js +1 -0
  79. package/dist/assets/{player-overlays-BIvElXhE.js → player-overlays-BH057O7U.js} +1 -1
  80. package/dist/assets/{recycle-BxIgahL6.js → recycle-CB_CwFhI.js} +1 -1
  81. package/dist/assets/remoteEntry-5jqsf3vm.js +1 -0
  82. package/dist/assets/{scan-eye-NGftRIPn.js → scan-eye-zCPN-IXA.js} +1 -1
  83. package/dist/assets/{scissors-BHv40eB0.js → scissors-8OXl9wtf.js} +1 -1
  84. package/dist/assets/{search-x-D0cw_-38.js → search-x-DTqz9u3f.js} +1 -1
  85. package/dist/assets/{send-B63foSkK.js → send-8GpK6UfW.js} +1 -1
  86. package/dist/assets/{settings-2-DX9ytL3l.js → settings-2-HzWfFtqI.js} +1 -1
  87. package/dist/assets/{speaker-BC0GjvT5.js → speaker-BkEeT7Qt.js} +1 -1
  88. package/dist/assets/src-DR_xV8BA.js +67 -0
  89. package/dist/assets/{step-inspector-model-BNiszF9a.js → step-inspector-model-UCA2LTHH.js} +1 -1
  90. package/dist/assets/{timer-reset-Emc4qthN.js → timer-reset-BAE1rlG9.js} +1 -1
  91. package/dist/assets/{ungroup-PYWFRB_O.js → ungroup-DwAY18V9.js} +1 -1
  92. package/dist/assets/{unlink-DUoBRhNd.js → unlink-CBe0geqM.js} +1 -1
  93. package/dist/assets/{usb-x_Sc1fcn.js → usb-DIvGHcpB.js} +1 -1
  94. package/dist/assets/{use-scenes-feed-BStfY5U_.js → use-scenes-feed-C8vBAMF_.js} +1 -1
  95. package/dist/assets/{use-stationary-objects-CRygyfvJ.js → use-stationary-objects-CW3x2icV.js} +1 -1
  96. package/dist/assets/useEventInvalidation-BG1JsKx5.js +1 -0
  97. package/dist/assets/{useNodeUrlSelection-CXgYDNbG.js → useNodeUrlSelection-DGKmtTIk.js} +1 -1
  98. package/dist/assets/user-round-Ku24ZXeJ.js +1 -0
  99. package/dist/assets/{user-x-CBs312Q9.js → user-x-Ti_5uOx5.js} +1 -1
  100. package/dist/assets/{video-D0GPir6r.js → video-IEto7g6S.js} +1 -1
  101. package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-DNGcxVE-.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-CjmIPZyr.js} +2 -2
  102. package/dist/index.html +10 -10
  103. package/dist/server/addon.js +470 -70
  104. package/package.json +1 -1
  105. package/dist/assets/Addons-BgJCB4KS.js +0 -4
  106. package/dist/assets/AiProfiles-BVyp59R4.js +0 -3
  107. package/dist/assets/Build-BbIlgO2k.js +0 -40
  108. package/dist/assets/Calendars-hof9Zsuo.js +0 -1
  109. package/dist/assets/CompositionEditor-DVyG_gki.js +0 -1
  110. package/dist/assets/CompositionEditorPage-7rnuVmmK.js +0 -1
  111. package/dist/assets/Data-XFdQ_CJg.js +0 -2
  112. package/dist/assets/DeviceDetail-4xoKO2Rw.js +0 -2
  113. package/dist/assets/History-DiYHtz3o.js +0 -1
  114. package/dist/assets/IntegrationDetail-Bc1sRi3k.js +0 -1
  115. package/dist/assets/Integrations-8Pi-1QTx.js +0 -1
  116. package/dist/assets/Integrations-BXourHS8.js +0 -1
  117. package/dist/assets/Library-C-ZxsOFn.js +0 -1
  118. package/dist/assets/Locations-BlixafK7.js +0 -3
  119. package/dist/assets/MyAccess-DP1ZLrmr.js +0 -2
  120. package/dist/assets/Notifications-CebO2rH3.js +0 -1
  121. package/dist/assets/Pipeline-BEX8fX4r.js +0 -1
  122. package/dist/assets/Recordings-D11aOWfh.js +0 -1
  123. package/dist/assets/SessionsList-C3EfpYvC.js +0 -2
  124. package/dist/assets/circle-slash-DF-9F9d1.js +0 -1
  125. package/dist/assets/client-CNqHea-r.js +0 -358
  126. package/dist/assets/crop-BeLqvBA7.js +0 -1
  127. package/dist/assets/device-picker-model-D7ZJEJ81.js +0 -1
  128. package/dist/assets/dist-v3iXCHPG.js +0 -358
  129. package/dist/assets/i18n-SRLxy4I7.js +0 -1
  130. package/dist/assets/index-CfXsU3sZ.js +0 -4
  131. package/dist/assets/index-DhkrLRVh.css +0 -2
  132. package/dist/assets/mount-D7ZJEJ81.js +0 -1
  133. package/dist/assets/remoteEntry-BqGZp0f4.js +0 -1
  134. package/dist/assets/src-WNMGrUfA.js +0 -67
  135. package/dist/assets/useEventInvalidation-D7ZJEJ81.js +0 -1
  136. package/dist/assets/user-round-CfdLlVdg.js +0 -1
@@ -1,3 +0,0 @@
1
- import{$ as e,B as t,G as n,J as r,S as i,b as a,o,x as s}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEHpkaJP.js";import{$i as c,Di as l,Fn as u,Gi as d,Hr as f,Ht as p,It as m,Lr as h,Mi as g,O as _,Pi as v,Pr as y,Ri as b,Rt as x,Ur as S,V as C,bn as w,cn as T,dt as E,ea as D,ei as O,en as k,fi as A,gr as j,k as M,kn as N,lr as P,pn as F,pt as I,rn as L,rr as R,ta as ee,tr as te,ur as z,ut as ne,xi as re,yi as B,z as V,zt as ie}from"./player-overlays-BIvElXhE.js";import{En as ae,Mr as oe,Pr as se}from"./client-CNqHea-r.js";import{t as ce}from"./boxes-BA8-oYCX.js";import{n as le,r as ue,t as de}from"./speaker-BC0GjvT5.js";import{t as H}from"./user-round-CfdLlVdg.js";import{Bu as fe,Da as pe,Ea as U,Fn as W,Fr as G,Hr as me,L as he,Nr as ge,Nu as K,Oa as _e,Pn as ve,Rr as ye,Ru as q,To as be,_o as xe,_t as Se,ao as Ce,bo as we,cr as Te,do as Ee,fo as De,gn as J,io as Oe,ir as ke,ja as Ae,mo as je,nr as Me,on as Ne,oo as Pe,or as Fe,po as Ie,ro as Le,rr as Re,sn as ze,sr as Be,to as Ve,vo as He,yo as Ue,zu as We}from"./src-WNMGrUfA.js";import{t as Y}from"./i18n-SRLxy4I7.js";import{t as X}from"./useTranslation-D3Is_4B6.js";import{_r as Ge,hr as Z,v as Ke,yr as qe}from"./index-CfXsU3sZ.js";import{t as Je}from"./AdminSectionedPage-CXL0Cc0w.js";import{a as Ye,n as Xe,r as Ze}from"./linked-devices-model-BT6sN3Jo.js";e();var Qe={camera:l,hub:le,container:ce,light:z,siren:L,switch:ie,sensor:ee,thermostat:p,climate:D,button:A,"event-emitter":ne,update:ue,notifier:b,script:F,automation:I,lock:R,cover:v,valve:S,humidifier:f,"water-heater":y,fan:h,"media-player":de,"alarm-panel":T,control:k,presence:H,weather:O,vacuum:g,"lawn-mower":x,image:j,smoke:c};function Q({type:e,className:t}){return s(Qe[e]??A,{"aria-hidden":`true`,className:t??`h-3.5 w-3.5 shrink-0 text-foreground-subtle`})}function $e({online:e,deviceName:t}){return s(`span`,{className:e?`inline-block h-1.5 w-1.5 shrink-0 rounded-full bg-success`:`inline-block h-1.5 w-1.5 shrink-0 rounded-full border border-foreground-subtle`,role:`img`,"aria-label":Y.t(`locations.deviceGlyphs.aria`,{name:t,state:e?Y.t(`common.online`):Y.t(`common.offline`)}),title:e?Y.t(`common.online`):Y.t(`common.offline`)})}function et({open:e,title:n,items:a,listState:o,lockedIds:c,lockedNote:l,suggestions:u=null,busy:d=!1,onConfirm:f,onClose:p}){let{t:m}=X(),[h,g]=r([]);t(()=>{e||g([])},[e]);let _=new Map(a.map(e=>[e.id,e.name])),v=(u?.ids??[]).filter(e=>_.has(e)&&!c.includes(e)),y=e=>g(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]);return s(Me,{open:e,onOpenChange:e=>e?void 0:p(),children:i(ke,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,"aria-label":n,children:[s(Be,{children:s(Te,{children:n})}),i(Re,{className:`flex flex-col gap-3 p-2 sm:p-4`,children:[e&&u!==null&&v.length>0&&i(`section`,{"aria-label":u.heading,className:`flex flex-col gap-1`,children:[s(`h3`,{className:`text-[10px] sm:text-[11px] font-semibold text-foreground uppercase tracking-wider`,children:u.heading}),s(`div`,{className:`flex flex-wrap gap-1`,children:v.map(e=>s(`button`,{type:`button`,"aria-pressed":h.includes(e),className:`inline-flex items-center gap-1 rounded-full border px-1.5 py-0.5 text-[10px] font-medium transition-colors ${h.includes(e)?`border-primary/50 bg-primary/15 text-primary`:`border-border bg-surface text-foreground-subtle hover:bg-surface-hover`}`,onClick:()=>y(e),children:_.get(e)},e))})]}),e&&s(he,{devices:a,listState:o,value:h,onChange:e=>g(e),noun:`device`,emptyLabel:m(`locations.addDialog.nonePicked`),showAll:!0,lockedIds:c,lockedNote:l,testId:`quick-add-picker`})]}),i(Fe,{children:[s(G,{variant:`ghost`,onClick:p,children:m(`locations.addDialog.cancel`)}),s(G,{disabled:h.length===0||d,onClick:()=>f(h),children:m(`locations.addDialog.confirm`,{count:h.length})})]})]})})}e();function tt({room:e,cameras:t,fleet:r}){let{t:i}=X(),a=n(()=>new Map(r.map(e=>[e.id,e])),[r]);return e===null?s(`p`,{className:`text-xs text-foreground-subtle`,children:i(`locations.links.noRoom`)}):s(`div`,{className:`flex flex-col gap-3`,"data-testid":`camera-links-section`,children:t.length===0?s(`p`,{className:`text-xs text-foreground-subtle`,"data-testid":`camera-links-empty`,children:i(`locations.links.noCameras`,{room:e})}):t.map(e=>s(rt,{camera:e,byId:a},e.id))})}function nt(e){return{id:e.deviceId,name:e.parentName===null?e.name:`${e.parentName} · ${e.name}`,type:e.type,location:e.location}}function rt({camera:e,byId:t}){let{t:n}=X(),a=o(),c=Ge(),[l,u]=r(!1),[d,f]=r(null),p=pe({deviceId:e.id}),m=Ze({status:p.status,data:p.data,error:p.error===null||p.error===void 0?null:p.error}),h=_e(),g=m.kind===`present`?m:null,v=U({deviceId:e.id,slotRef:g?.slot.slotRef??``},{enabled:l&&g!==null}),y=g===null?[]:Xe(g.slot,g.value),b=y.map(e=>e.deviceId),x=(v.data?.candidates??[]).map(nt),S=new Set(x.map(e=>e.id)),C=b.filter(e=>!S.has(e)).map(e=>{let n=t.get(e);return{id:e,name:n?.name??`#${String(e)}`,...n===void 0?{}:{type:n.type,location:n.location}}}),w=[...x,...C],T=(v.data?.candidates??[]).filter(e=>e.suggested).map(e=>e.deviceId),E=async t=>{if(g!==null){f(null);try{await h.mutateAsync({deviceId:e.id,slotRef:g.slot.slotRef,value:Ye(g.value,t)}),await p.refetch(),await a.invalidateQueries({queryKey:[[`deviceManager`]]}),u(!1)}catch(e){f(e instanceof Error?e.message:String(e))}}},D=[{key:`device`,header:n(`locations.columns.device`),notSortableReason:n(`locations.columns.noSort`),render:e=>{let r=t.get(e.deviceId),a=e.name??r?.name??`#${String(e.deviceId)}`;return i(`span`,{className:`flex items-center gap-1.5`,children:[r!==void 0&&s(Q,{type:r.type}),s(Z,{to:`/devices/${String(e.deviceId)}`,className:`min-w-0 truncate text-xs text-foreground hover:underline`,children:a}),e.implied&&s(`span`,{className:`text-[10px] text-foreground-subtle`,children:n(`locations.links.implied`)})]})}},{key:`type`,header:n(`locations.columns.type`),notSortableReason:n(`locations.columns.noSort`),render:e=>s(`span`,{className:`text-xs text-foreground-muted`,children:t.get(e.deviceId)?.type??`—`})},{key:`status`,header:n(`locations.columns.status`),notSortableReason:n(`locations.columns.noSort`),render:e=>{let r=t.get(e.deviceId);return r===void 0?s(`span`,{className:`text-xs text-foreground-subtle`,children:`—`}):i(`span`,{className:`flex items-center gap-1.5`,children:[s($e,{online:r.online,deviceName:r.name}),s(`span`,{className:`text-xs text-foreground-muted`,children:r.online?n(`common.online`):n(`common.offline`)})]})}}];return i(`section`,{className:`min-w-0 ${_}`,"data-testid":`camera-links-${String(e.id)}`,children:[i(`header`,{className:`${M} flex min-h-9 items-center gap-1.5`,children:[s(Q,{type:e.type}),s(`h2`,{className:`min-w-0 flex-1 truncate text-sm font-semibold text-foreground`,children:e.name}),i(G,{variant:`ghost`,size:`sm`,onClick:()=>c(Ke(e.id)),children:[s(P,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),n(`locations.links.edit`)]}),s(G,{variant:`outline`,size:`sm`,disabled:g===null,onClick:()=>u(!0),"aria-label":n(`locations.links.addNamed`,{camera:e.name}),children:n(`locations.room.add`)})]}),m.kind===`pending`&&s(`p`,{role:`status`,className:`px-3 py-3 text-xs text-foreground-subtle sm:px-4`,children:n(`locations.links.loading`)}),m.kind===`unknown`&&s(`p`,{role:`alert`,className:`px-3 py-3 text-xs text-warning sm:px-4`,children:n(`locations.links.unreadable`,{reason:m.reason})}),m.kind===`absent`&&s(`p`,{className:`px-3 py-3 text-xs text-foreground-subtle sm:px-4`,children:n(`locations.links.unsupported`)}),d!==null&&s(`p`,{role:`alert`,className:`px-3 pt-2 text-xs text-danger break-words sm:px-4`,children:d}),g!==null&&(y.length===0?s(`p`,{className:`px-3 py-3 text-xs text-foreground-subtle sm:px-4`,children:n(`locations.links.none`)}):s(J,{columns:D,rows:y,rowKey:e=>String(e.deviceId),bordered:!1,minWidthPx:360})),s(et,{open:l,title:n(`locations.links.pickTitle`,{camera:e.name}),items:w,listState:v.status===`error`?`failed`:v.data===void 0?`pending`:`answered`,lockedIds:b,lockedNote:n(`locations.links.alreadyLinked`),suggestions:e.location===null?null:{heading:n(`locations.links.suggested`,{room:e.location}),ids:T},busy:h.isPending,onConfirm:e=>void E(e),onClose:()=>u(!1)})]})}e();function it({name:e,description:n,busy:a,onSave:o}){let{t:c}=X(),[l,u]=r(n??``);return t(()=>{u(n??``)},[n]),i(`div`,{className:`border-t border-border px-3 py-2 sm:px-4`,children:[s(W,{htmlFor:`location-description-${e}`,className:`block`,children:c(`locations.locationDescriptionField.whatIsThere`,`What is there`)}),s(`textarea`,{id:`location-description-${e}`,value:l,onChange:e=>u(e.target.value),onBlur:()=>{let e=l.trim();e!==(n??``)&&o(e.length===0?null:e)},disabled:a,rows:2,maxLength:400,placeholder:c(`locations.locationDescriptionField.surfacesBoundariesWhatIsNormally`,`Surfaces, boundaries, what is normally parked or stored here.`),className:`mt-1 w-full resize-y rounded-md border border-border bg-surface px-2.5 py-1.5 text-xs text-foreground placeholder:text-foreground-subtle focus:outline-none focus:ring-1 focus:ring-inset focus:ring-primary disabled:cursor-not-allowed disabled:opacity-50`}),s(`p`,{className:`mt-1 ${V}`,children:c(`locations.locationDescriptionField.givenToTheAiWith`,`Given to the AI with the pictures, so it knows what it is looking at. Describe the PLACE, not what happens in it — events change, the ground does not.`)})]})}function at(e,t){let n=e?.find(e=>e.locationKey===t);return n===void 0||n.description.length===0?null:n.description}var ot=` none`;function st({name:e,zones:t,zoneKey:n,busy:r,onChange:a}){let{t:o}=X();if(t.length===0)return null;let c=[{value:ot,label:o(`locations.locationZoneField.none`,`— none —`)},...t.map(e=>({value:e.zoneKey,label:e.label}))];return i(`div`,{className:`flex items-center gap-2 border-t border-border px-3 py-1.5 sm:px-4 sm:py-2`,children:[s(W,{htmlFor:`location-zone-${e}`,children:o(`locations.locationZoneField.zone`,`Zone`)}),s(K,{id:`location-zone-${e}`,value:n??ot,disabled:r,onChange:e=>{let n=e.target.value;if(n===ot){a(null);return}let r=t.find(e=>e.zoneKey===n);r!==void 0&&a(r.label)},options:c})]})}function ct(e,t){return e.find(e=>e.locationKeys.includes(t))?.zoneKey??null}function lt({name:e,icon:t,busy:n,onPick:r}){return s(fe,{value:t,onPick:r,fallbackGlyph:te,clearGlyph:d,labels:{trigger:`Change the icon of ${e}`,panel:`Icon for ${e}`,searchPlaceholder:`Search icons`,clear:`No icon`,noMatches:`No icon matches that`},disabled:n})}function ut(e,t){let n=e?.find(e=>e.locationKey===t);return n===void 0?null:se(n.icon)??`map-pin`}function $(e){if(e==null)return null;let t=e.trim();return t.length===0?null:t.toLowerCase()}function dt(e,t){let n=$(t);return n===null?[]:e.filter(e=>$(e.location)===n)}function ft(e,t){let n=dt(e,t),r=new Set(n.map(e=>e.id));return n.filter(e=>e.parentDeviceId===null||!r.has(e.parentDeviceId))}function pt(e,t){let n=$(e.location);return n===null||new Set(t.map(e=>$(e))).has(n)?null:e.location?.trim()??null}function mt(e,t){let n=$(e.location);return n!==null&&t.has(n)}function ht(e,t){let n=new Set(t.map(e=>$(e))),r=new Set(e.filter(e=>mt(e,n)).map(e=>e.id));return e.filter(e=>!(mt(e,n)||e.parentDeviceId!==null&&r.has(e.parentDeviceId)))}function gt(e,t){return ht(e,t).filter(e=>e.parentDeviceId===null)}function _t(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 vt(e,t){return _t(e,t).length}function yt(e,t){return e.filter(e=>!e.isCamera&&e.parentDeviceId===t)}function bt(e,t){return t.map(t=>({name:t,members:ft(e,t)}))}function xt(e){return`${e.kind}:${String(e.device.id)}`}function St(e,t,n){return e.flatMap(e=>{let r=yt(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 Ct({name:e,members:t,devices:o,busy:c,icon:l,description:d,onRename:f,onDelete:p,onRebuildLinks:h,onAddDevices:g,onPickIcon:v,onSaveDescription:y,zones:b,zoneKey:x,onChangeZone:S}){let{t:C}=X(),[T,D]=r(!1),[O,k]=r(e),A=Ne(t,n(()=>({searchText:e=>[e.name,...yt(o,e.id).map(e=>e.name)],facetValue:e=>e.type}),[o])),[j,N]=r(()=>new Set),P=e=>N(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),F=n(()=>St(A.rows,o,j),[A.rows,o,j]),I=[{key:`name`,header:C(`locations.columns.device`),notSortableReason:C(`locations.columns.noSort`),render:e=>e.kind===`member`?s(wt,{row:e,onToggle:()=>P(e.device.id)}):s(Tt,{row:e})},{key:`type`,header:C(`locations.columns.type`),notSortableReason:C(`locations.columns.noSort`),render:e=>s(`span`,{className:`text-xs text-foreground-muted`,children:e.device.type})},{key:`status`,header:C(`locations.columns.status`),notSortableReason:C(`locations.columns.noSort`),render:e=>i(`span`,{className:`flex items-center gap-1.5`,children:[s($e,{online:e.device.online,deviceName:e.device.name}),s(`span`,{className:`text-xs text-foreground-muted`,children:e.device.online?C(`common.online`):C(`common.offline`)})]})}],L=()=>{k(e),D(!1)},R=async()=>{let t=O.trim();if(t.length===0||t===e){L();return}await f(t),D(!1)},ee=[{id:`rename`,label:C(`locations.locationCard.rename`,`Rename`),icon:u,disabled:c,onClick:()=>{k(e),D(!0)}},{id:`rebuild-links`,label:C(`locations.locationCard.rebuildLinkedDevices`,`Rebuild linked devices`),icon:w,separatorBefore:!0,disabled:c,onClick:()=>void h()},{id:`delete`,label:C(`common.delete`,`Delete`),icon:m,danger:!0,separatorBefore:!0,disabled:c,onClick:()=>void p()}];return i(`section`,{className:`min-w-0 ${_}`,children:[i(`header`,{className:`${M} flex min-h-9 items-center gap-1.5`,children:[s(lt,{name:e,icon:l,busy:c,onPick:v}),T?i(a,{children:[s(q,{value:O,onChange:e=>k(e.target.value),onKeyDown:e=>{e.key===`Enter`&&R(),e.key===`Escape`&&L()},"aria-label":C(`locations.locationCard.rename2`,`Rename {{name}}`,{name:e}),className:`min-w-0 flex-1`,autoFocus:!0}),s(G,{type:`button`,size:`sm`,onClick:()=>void R(),children:C(`common.save`,`Save`)}),s(We,{type:`button`,variant:`ghost`,icon:E,onClick:L,"aria-label":C(`locations.locationCard.cancelRename`,`Cancel rename`)})]}):i(a,{children:[s(`h2`,{className:`min-w-0 flex-1 truncate text-sm font-semibold text-foreground`,children:e}),s(G,{type:`button`,variant:`outline`,size:`sm`,disabled:c,onClick:g,"aria-label":C(`locations.room.addTo`,{room:e}),children:C(`locations.room.add`)}),s(Se,{items:ee,title:C(`locations.locationCard.actionsFor`,`Actions for {{name}}`,{name:e}),triggerClassName:`p-1`})]})]}),s(st,{name:e,zones:b,zoneKey:x,busy:c,onChange:S}),s(it,{name:e,description:d,busy:c,onSave:y}),t.length>0&&s(`div`,{className:`border-b border-border px-3 py-1.5 sm:px-4 sm:py-2`,children:s(ze,{state:A.state,facets:A.facets,labels:{searchPlaceholder:C(`locations.filter.searchPlaceholder`),searchLabel:C(`locations.room.searchLabel`,{room:e}),facetsLabel:C(`locations.filter.typesLabel`),clearLabel:C(`locations.filter.clear`)},onSearch:A.setSearch,onToggleFacet:A.toggleFacet,onClear:A.clear})}),t.length===0?s(`p`,{className:`px-3 py-3 text-xs text-foreground-subtle sm:px-4`,children:C(`locations.locationCard.nothingHereYetAssignA`,`Nothing here yet — assign a device from the table below.`)}):s(J,{columns:I,rows:F,rowKey:xt,bordered:!1,minWidthPx:360,emptyMessage:C(`locations.filter.noMatch`)})]})}function wt({row:e,onToggle:t}){let{t:n}=X(),{device:r,accessories:a,open:o}=e,c=o?re:B;return i(`span`,{className:`flex items-center gap-1.5`,children:[a.length>0?i(G,{type:`button`,variant:`ghost`,onClick:t,"aria-expanded":o,"aria-label":n(o?`locations.locationCard.collapseAccessories`:`locations.locationCard.expandAccessories`,{count:a.length,name:r.name}),className:`h-auto shrink-0 gap-0.5 p-0.5 text-foreground-subtle hover:text-foreground`,children:[s(c,{className:`h-3 w-3`}),s(`span`,{className:`text-[10px] tabular-nums`,children:a.length})]}):s(`span`,{"aria-hidden":`true`,className:`w-[1.35rem] shrink-0`}),s(Q,{type:r.type}),s(Z,{to:`/devices/${String(r.id)}`,className:`min-w-0 truncate text-xs text-foreground hover:underline`,children:r.name})]})}function Tt({row:e}){let{device:t}=e;return i(`span`,{className:`flex items-center gap-1.5 pl-6`,children:[s(`span`,{"aria-hidden":`true`,className:`text-[10px] text-foreground-subtle`,children:`└`}),s(Q,{type:t.type,className:`h-3 w-3 shrink-0 text-foreground-subtle`}),s(Z,{to:`/devices/${String(t.id)}`,className:`min-w-0 truncate text-xs text-foreground-muted hover:underline`,children:t.name})]})}e();function Et({zones:e,busy:t,onRename:n,onDelete:i,onPickIcon:a}){let{t:o}=X(),[c,l]=r(null),[u,d]=r(``),f=async e=>{let t=u.trim();l(null),!(t.length===0||t===e)&&await n(e,t)};return s(J,{columns:[{key:`icon`,header:o(`locations.siteZonesPanel.icon`,`Icon`),width:`w-12`,notSortableReason:`An icon has no order`,render:e=>s(lt,{name:e.label,icon:e.icon,busy:t,onPick:t=>a(e.label,t)})},{key:`name`,header:o(`locations.siteZonesPanel.zone`,`Zone`),sortValue:e=>e.label.toLowerCase(),render:e=>c===e.label?s(q,{value:u,onChange:e=>d(e.target.value),onKeyDown:t=>{t.key===`Enter`&&f(e.label),t.key===`Escape`&&l(null)},onBlur:()=>void f(e.label),"aria-label":o(`locations.siteZonesPanel.rename`,`Rename {{label}}`,{label:e.label}),autoFocus:!0}):s(G,{type:`button`,variant:`ghost`,size:`sm`,className:`px-0`,onClick:()=>{d(e.label),l(e.label)},disabled:t,title:o(`locations.siteZonesPanel.renameTheZone`,`Rename the zone`),children:e.label})},{key:`rooms`,header:o(`locations.siteZonesPanel.rooms`,`Rooms`),align:`right`,sortValue:e=>e.locationKeys.length,render:e=>s(`span`,{className:`tabular-nums text-foreground-subtle`,children:e.locationKeys.length===0?o(`common.empty`):o(`common.rooms`,{count:e.locationKeys.length})})},{key:`actions`,header:o(`locations.siteZonesPanel.actions`,`Actions`),align:`right`,notSortableReason:`Actions have no order`,render:e=>s(G,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>void i(e.label),disabled:t,"aria-label":o(`locations.siteZonesPanel.delete`,`Delete {{label}}`,{label:e.label}),title:o(`locations.siteZonesPanel.deleteTheZoneTheRooms`,`Delete the zone — the rooms in it are kept`),children:s(m,{className:`h-3.5 w-3.5`})})}],rows:e,rowKey:e=>e.zoneKey,emptyMessage:o(`locations.siteZonesPanel.noZonesYetAZone`,`No zones yet. A zone groups rooms — “Zona notte” for the bedrooms — and shows up before them in the app’s camera filter.`)})}e();function Dt({busy:e,onCreate:t}){let{t:n}=X(),[a,o]=r(!1),[c,l]=r(``),u=()=>{l(``),o(!1)},d=async()=>{let e=c.trim();e.length!==0&&(await t(e),u())};return a?i(`form`,{className:`flex flex-wrap items-center gap-2`,onSubmit:e=>{e.preventDefault(),d()},children:[s(q,{value:c,onChange:e=>l(e.target.value),onKeyDown:e=>{e.key===`Escape`&&u()},placeholder:n(`locations.newLocationButton.ingressoSaloneCucina`,`Ingresso, Salone, Cucina…`),"aria-label":n(`locations.newLocationButton.newLocationName`,`New location name`),className:`min-w-[12rem] flex-1`,autoFocus:!0}),i(G,{size:`sm`,type:`submit`,disabled:c.trim().length===0||e,children:[s(N,{className:`h-3.5 w-3.5`}),n(`common.add`,`Add`)]}),s(G,{size:`sm`,variant:`ghost`,type:`button`,onClick:u,"aria-label":n(`locations.newLocationButton.cancelNewLocation`,`Cancel new location`),children:s(E,{className:`h-3.5 w-3.5`})})]}):i(G,{size:`sm`,type:`button`,onClick:()=>o(!0),"data-testid":`new-location-button`,children:[s(N,{className:`h-3.5 w-3.5`}),n(`locations.newLocationButton.newLocation`,`New location`)]})}e();function Ot({busy:e,onCreate:t}){let{t:n}=X(),[a,o]=r(!1),[c,l]=r(``),u=()=>{l(``),o(!1)},d=async()=>{let e=c.trim();e.length!==0&&(await t(e),u())};return a?i(`form`,{className:`flex flex-wrap items-center gap-2`,onSubmit:e=>{e.preventDefault(),d()},children:[s(q,{value:c,onChange:e=>l(e.target.value),onKeyDown:e=>{e.key===`Escape`&&u()},placeholder:n(`locations.newZoneButton.zonaGiornoZonaNotte`,`Zona giorno, Zona notte…`),"aria-label":n(`locations.newZoneButton.newZoneName`,`New zone name`),className:`min-w-[12rem] flex-1`,autoFocus:!0}),i(G,{size:`sm`,type:`submit`,disabled:c.trim().length===0||e,children:[s(N,{className:`h-3.5 w-3.5`}),n(`common.add`,`Add`)]}),s(G,{size:`sm`,variant:`ghost`,type:`button`,onClick:u,"aria-label":n(`locations.newZoneButton.cancelNewZone`,`Cancel new zone`),children:s(E,{className:`h-3.5 w-3.5`})})]}):i(G,{size:`sm`,type:`button`,onClick:()=>o(!0),"data-testid":`new-zone-button`,children:[s(N,{className:`h-3.5 w-3.5`}),n(`locations.newZoneButton.newZone`,`New zone`)]})}e();function kt(e,t,n,r){let i=e.map(e=>({value:e.name,label:`${e.name} · ${String(e.count)}`}));return t===void 0?i:[...i,{value:n,label:`${r} · ${String(t)}`}]}function At({rooms:e,unassignedCount:t,value:r,unassignedValue:i,onChange:a}){let{t:o}=X(),c=n(()=>kt(e,t,i,o(`locations.roomPicker.unassigned`)),[e,t,i,o]);return s(`div`,{className:`max-w-sm`,"data-testid":`room-select`,children:s(ye,{mode:`single`,singleDisplay:`field`,label:o(`locations.roomPicker.label`),placeholder:o(`locations.roomPicker.placeholder`),options:c,value:r,onChange:a,searchable:!0,testId:`room-select-control`,optionTestIdPrefix:`room-option`})})}e();var jt={searchText:e=>[e.name],facetValue:e=>e.type};function Mt({rows:e,fleet:t,locations:a,busy:o,emptyMessage:c,onAssign:l}){let{t:u}=X(),[d,f]=r([]),[p,m]=r(``),h=Ne(e,jt),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 n=new Map;for(let r of e)n.set(r.id,vt(t,r.id));return n},[e,t]),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]),w=()=>f(y?[]:_),T=()=>{p.length===0||v.length===0||(l(v,p),f([]),m(``))},E=a.map(e=>({value:e,label:e})),D=[{key:`select`,width:`w-8`,headerRender:()=>s(ve,{checked:y,onChange:w,"aria-label":y?u(`locations.unassignedTable.clearSelection`,`Clear selection`):u(`locations.unassignedTable.selectAllUnassignedDevices`,`Select all unassigned devices`)}),render:e=>s(ve,{checked:v.includes(e.id),onChange:()=>S(e.id),"aria-label":u(`locations.unassignedTable.select`,`Select {{name}}`,{name:e.name})})},{key:`name`,header:u(`locations.unassignedTable.device`,`Device`),sortValue:e=>e.name.toLowerCase(),render:e=>{let t=pt(e,a);return i(`span`,{className:`flex items-center gap-1.5`,children:[s(Q,{type:e.type}),s(Z,{to:`/devices/${String(e.id)}`,className:`truncate text-xs text-foreground hover:underline`,children:e.name}),t!==null&&s(me,{variant:`warning`,children:u(`locations.unassignedTable.unknownRoom`,{room:t})})]})}},{key:`type`,header:u(`locations.unassignedTable.type`,`Type`),sortValue:e=>e.type,render:e=>s(`span`,{className:`text-xs text-foreground-muted`,children:e.type})},{key:`status`,header:u(`locations.unassignedTable.status`,`Status`),sortValue:e=>+!!e.online,render:e=>i(`span`,{className:`flex items-center gap-1.5`,children:[s($e,{online:e.online,deviceName:e.name}),s(`span`,{className:`text-xs text-foreground-muted`,children:e.online?u(`common.online`):u(`common.offline`)})]})},{key:`followers`,header:u(`locations.unassignedTable.accessoriesInTowCount`,`Accessories in tow`),align:`right`,sortValue:e=>b.get(e.id)??0,render:e=>s(`span`,{className:`tabular-nums text-xs text-foreground-muted`,children:b.get(e.id)??0})},{key:`assign`,header:u(`locations.unassignedTable.assignTo`,`Assign to`),align:`right`,notSortableReason:`This column is a control, not a value.`,render:e=>s(K,{"aria-label":u(`locations.unassignedTable.locationFor`,`Location for {{name}}`,{name:e.name}),value:``,disabled:o||a.length===0,onChange:t=>{let n=t.target.value;n.length!==0&&l([e.id],n)},className:`max-w-[11rem]`,options:[{value:``,label:`—`},...E]})}];return i(`section`,{className:`space-y-2`,children:[i(`header`,{className:`flex flex-wrap items-baseline gap-2`,children:[s(`h2`,{className:C,children:u(`locations.unassignedTable.notInARoom`,`Not in a room`)}),s(`p`,{className:V,children:u(`locations.unassignedTable.topLevelDevicesOnlyAccessories`,`Top-level devices only — accessories move with their parent.`)})]}),e.length>0&&s(ze,{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&&i(`div`,{role:`group`,"aria-label":u(`locations.unassignedTable.bulkAssignment`,`Bulk assignment`),className:`flex flex-wrap items-center gap-2 rounded border border-primary/40 bg-primary/5 px-2 py-1.5`,children:[i(`span`,{className:`text-xs text-foreground`,children:[u(`locations.unassignedTable.selected`,{count:v.length}),x>0&&` · ${u(`locations.unassignedTable.accessoriesInTowCount`,{count:x})}`]}),s(K,{"aria-label":u(`locations.unassignedTable.assignSelectedDevicesTo`,`Assign selected devices to`),value:p,onChange:e=>m(e.target.value),className:`w-auto min-w-[10rem]`,options:[{value:``,label:u(`locations.unassignedTable.assignTo2`,`Assign to…`)},...E]}),s(G,{type:`button`,size:`sm`,onClick:T,disabled:o||p.length===0,children:u(`locations.unassignedTable.assign`,`Assign`)}),s(G,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>f([]),children:u(`locations.unassignedTable.clear`,`Clear`)})]}),s(J,{columns:D,rows:g,rowKey:e=>e.id,minWidthPx:720,emptyMessage:h.active?u(`locations.filter.noMatch`):c})]})}function Nt(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 Pt(e,t){let n=t.map(Nt),r=[];for(let i of t)i.isCamera&&i.location===e&&r.push({deviceId:i.id,name:i.name,ids:ae({selfId:i.id,selfLocation:i.location,candidates:n})});return{entries:r}}var Ft=`device-manager:linked-devices`;function It(e){return{deviceId:e.deviceId,slotRef:Ft,value:{slot:`linked-devices`,deviceIds:[...e.ids]}}}e();var Lt=`__unassigned__`;function Rt(){let{t:e}=X(),t=o(),a=ge(),{data:c,isLoading:l}=Ce(),{data:u}=Oe(),{data:d}=Le(),{data:f}=Pe(),{data:p,isLoading:m}=Ve({projection:`slim`}),h=()=>{t.invalidateQueries({queryKey:[[`deviceManager`,`listLocations`]]}),t.invalidateQueries({queryKey:[[`deviceManager`,`listAll`]]}),t.invalidateQueries({queryKey:[[`deviceManager`,`listLocationIcons`]]}),t.invalidateQueries({queryKey:[[`deviceManager`,`listLocationDescriptions`]]}),t.invalidateQueries({queryKey:[[`deviceManager`,`listSiteZones`]]})},g=Ae({onSuccess:h}),_=Ee({onSuccess:h}),v=xe({onSuccess:h}),y=Ie({onSuccess:h}),b=Ue({onSuccess:h}),x=He({onSuccess:h}),S=be({onSuccess:h}),C=De({onSuccess:h}),w=je({onSuccess:h}),T=we({onSuccess:h}),E=_e(),D=n(()=>(p??[]).map(e=>({id:e.id,name:e.name,location:e.location??null,type:String(e.type),isCamera:e.isCamera,parentDeviceId:e.parentDeviceId,online:e.online,role:e.role??null,stableId:e.stableId,primaryChildEntityId:e.primaryChildEntityId??null})),[p]),O=c??[],k=n(()=>bt(D,O),[D,O]),[A,j]=qe(),M=A.get(`tab`),N=M===`zones`||M===`camera-links`?M:`locations`,P=A.get(`room`),F=n(()=>gt(D,O),[D,O]),I=P===Lt,L=I?null:P!==null&&k.some(e=>e.name===P)?P:k[0]?.name??null,R=L===null?null:k.find(e=>e.name===L)??null,ee=I?Lt:L??`__unassigned__`,z=L??k[0]?.name??null,ne=n(()=>k.map(e=>({name:e.name,count:e.members.length})),[k]),re=e=>{j(t=>{let n=new URLSearchParams(t);return n.set(`room`,e),n},{replace:!0})},B=l||m,V=v.isPending||_.isPending||g.isPending||b.isPending,ie=async e=>{await g.mutateAsync({name:e})},ae=async(e,t)=>{let n=t.trim();n.length===0||n===e||await y.mutateAsync({from:e,to:n})},se=async t=>{let n=Pt(t,D);if(n.entries.length===0){await a({title:e(`locations.rebuildLinkedDevices`,`Rebuild linked devices`),message:e(`locations.noCameraIsAssignedTo`,`No camera is assigned to “{{room}}”.`,{room:t}),confirmLabel:`OK`});return}let r=n.entries.map(t=>e(`locations.rebuildEntry`,{name:t.name,count:t.ids.length})).join(`
2
- `);if(!await a({title:e(`locations.rebuildLinkedDevices`,`Rebuild linked devices`),message:e(`locations.replaceTheLinkedDeviceList`,`Replace the linked-device list of every camera in “{{room}}” with what the room contains? {{lines}} Anything linked by hand that is not in this room is lost.`,{room:t,lines:r}),confirmLabel:e(`locations.rebuild`,`Rebuild`),variant:`danger`}))return;let i=[];for(let e of n.entries)try{await E.mutateAsync(It(e))}catch(t){i.push(`• ${e.name}: ${t instanceof Error?t.message:String(t)}`)}h(),i.length>0&&await a({title:e(`locations.rebuildLinkedDevices`,`Rebuild linked devices`),message:e(`locations.notRebuilt`,`Not rebuilt: {{value1}}`,{value1:i.join(`
3
- `)}),confirmLabel:`OK`})},ce=async(t,n)=>{let r=n>0?` ${String(n)} device(s) will become unassigned.`:``;await a({title:e(`locations.deleteLocation`,`Delete location`),message:e(`locations.deleteTheLocation`,`Delete the location “{{name}}”?{{extra}}`,{name:t,extra:r}),confirmLabel:e(`common.delete`,`Delete`),variant:`danger`})&&await _.mutateAsync({name:t,cascade:!0})},le=async t=>{await a({title:e(`locations.deleteZone`,`Delete zone`),message:e(`locations.deleteTheZoneTheRooms`,`Delete the zone “{{name}}”? The rooms in it are kept.`,{name:t}),confirmLabel:e(`common.delete`,`Delete`),variant:`danger`})&&await C.mutateAsync({name:t})},ue=async(e,t)=>{await b.mutateAsync({location:e,icon:t})},de=async(e,t)=>{await x.mutateAsync({location:e,description:t})},H=f??[],fe=async(e,t)=>{await T.mutateAsync({location:e,zone:t})},pe=(e,t)=>{for(let n of e)v.mutate({deviceId:n,location:t})},[U,W]=r(null),G=n(()=>D.filter(e=>e.parentDeviceId===null).map(e=>({id:e.id,name:e.name,type:e.type,location:e.location})),[D]),me=s(At,{rooms:ne,...N===`locations`?{unassignedCount:F.length}:{},value:N===`locations`?ee:z??``,unassignedValue:Lt,onChange:re}),he=i(`div`,{className:`flex flex-col gap-3`,"data-testid":`locations-section`,children:[B&&s(`p`,{className:`text-xs text-foreground-subtle`,children:e(`locations.loadingLocationsAndDevices`,`Loading locations and devices…`)}),me,I||R===null?s(Mt,{rows:F,fleet:D,locations:O,busy:V,emptyMessage:B?e(`common.loading`,`Loading…`):e(`locations.everyTopLevelDeviceHas`,`Every top-level device has a room.`),onAssign:pe}):s(Ct,{name:R.name,members:R.members,devices:D,busy:V,icon:ut(u,oe(R.name)),onPickIcon:e=>ue(R.name,e),description:at(d,oe(R.name)),onSaveDescription:e=>de(R.name,e),zones:H,zoneKey:ct(H,oe(R.name)),onChangeZone:e=>fe(R.name,e),onRename:e=>ae(R.name,e),onDelete:()=>ce(R.name,dt(D,R.name).length),onRebuildLinks:()=>se(R.name),onAddDevices:()=>W(R.name)},R.name),O.length===0&&!B&&s(`p`,{className:`text-xs text-foreground-subtle`,children:e(`locations.noLocationsYetAddIngresso`,`No locations yet. Add Ingresso, Salone, Cucina…`)}),s(et,{open:U!==null,title:e(`locations.room.addDialogTitle`,{room:U??``}),items:G,listState:m?`pending`:`answered`,lockedIds:U===null?[]:(k.find(e=>e.name===U)?.members??[]).map(e=>e.id),lockedNote:e(`locations.room.alreadyHere`),suggestions:{heading:e(`locations.room.suggestedUnassigned`),ids:F.map(e=>e.id)},busy:v.isPending,onConfirm:e=>{U!==null&&pe(e,U),W(null)},onClose:()=>W(null)})]}),K=i(`div`,{className:`flex flex-col gap-3`,"data-testid":`camera-links-tab`,children:[me,s(tt,{room:z,cameras:z===null?[]:dt(D,z).filter(e=>e.isCamera),fleet:D})]});return s(Je,{icon:te,title:e(`locations.locations`,`Locations`),subtitle:e(`locations.roomsAndAreasOfThe`,`Rooms and areas of the site. Assign any device here — storage disks are under Data → Storage.`),defaultSection:`locations`,sectionsLabel:`Locations sections`,actions:N===`zones`?s(Ot,{busy:S.isPending,onCreate:e=>S.mutateAsync({name:e})}):s(Dt,{busy:g.isPending,onCreate:ie}),sections:[{id:`locations`,label:e(`locations.locations`,`Locations`),content:he},{id:`camera-links`,label:e(`locations.cameraLinks`,`Camera links`),content:K},{id:`zones`,label:e(`locations.zones`,`Zones`),content:s(Et,{zones:H,busy:V,onRename:(e,t)=>w.mutateAsync({from:e,to:t}),onDelete:le,onPickIcon:(e,t)=>S.mutateAsync({name:e,icon:t})})}]})}export{Rt as LocationsPage};
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./browser-BHo8W_uH.js","./rolldown-runtime-Cyuzqnbw.js"])))=>i.map(i=>d[i]);
2
- import{a as e}from"./rolldown-runtime-Cyuzqnbw.js";import{t}from"./vite-preload-helper-kNaey6uv.js";import{$ as n,B as r,G as i,J as a,S as o,a as s,b as c,q as l,t as u,x as d}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEHpkaJP.js";import{$t as f,Fn as p,Gi as m,It as h,Nt as g,Q as _,Rr as v,Zr as y,hi as b,lr as x,mi as S,mr as C,or as w,ot as T,rr as E,sa as D,sn as O}from"./player-overlays-BIvElXhE.js";import{Dr as k,Er as A}from"./client-CNqHea-r.js";import{s as j}from"./video-D0GPir6r.js";import{t as ee}from"./key-round-DX4Tm3r5.js";import{t as te}from"./monitor-smartphone-DWtxkkEg.js";import{t as ne}from"./unlink-DUoBRhNd.js";import{Er as re,Fr as M,Nr as N,Nu as ie,cn as ae,er as P,gs as F,id as I,ms as oe,tr as se,wt as ce}from"./src-WNMGrUfA.js";import{t as le}from"./i18n-SRLxy4I7.js";import{t as L}from"./useTranslation-D3Is_4B6.js";import"./mount-D7ZJEJ81.js";import{C as R,S as z,b as B,gr as V,ir as H,mr as U,x as W,yr as ue}from"./index-CfXsU3sZ.js";import{t as de}from"./AdminSectionedPage-CXL0Cc0w.js";import{t as fe}from"./AdminPage-oFm0hhFj.js";import{O as pe,T as me,_ as G,a as he,h as ge,k as _e,r as ve,t as ye,v as be}from"./SessionsList-C3EfpYvC.js";n();var xe=`${A}/connect`,K={public:0,mesh:1,lan:2,"lan-ipv6":3};function Se(e){switch(e.kind){case`public`:return e.interfaceKind===`vpn`?`mesh`:`public`;case`lan-ipv4`:return`lan`;case`lan-ipv6`:return`lan-ipv6`;case`custom`:return`public`;case`loopback`:case`app-link`:return null}}function q(e){return k(e)}function Ce(e){return e.startsWith(`https://`)}function we(e){let t=e.flatMap(e=>{let t=Se(e),n=q(e.baseUrl);return t===null||n===null?[]:[{endpoint:e,tier:t,origin:n}]}).toSorted((e,t)=>K[e.tier]-K[t.tier]||Number(t.endpoint.plausible)-Number(e.endpoint.plausible)||e.endpoint.priority-t.endpoint.priority),n=new Set;return t.flatMap(({endpoint:e,tier:t,origin:r})=>n.has(r)?[]:(n.add(r),[{origin:r,label:e.label,tier:t,secure:Ce(r),plausible:e.plausible}]))}function Te(e,t,n=null){for(let r of[t,n]){if(r===null)continue;let t=q(r),n=e.find(e=>e.origin===t);if(n!==void 0)return n}return e[0]??null}function Ee(e){let t=new URL(xe);return t.searchParams.set(`hub`,e),t.toString()}var De=176,J={scheme:`https`};function Oe(){let{t:e}=L(),t=F(J),n=oe(J).data?.roles.publicEndpoint.resolved??null;return o(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[o(`div`,{className:`px-4 py-2.5 border-b border-border flex items-center gap-2`,children:[d(f,{className:`h-3.5 w-3.5 text-foreground-subtle`}),d(`div`,{className:`text-xs font-semibold text-foreground`,children:e(`connectPhone.title`)})]}),o(`div`,{className:`p-4 space-y-3`,children:[d(`p`,{className:`text-[11px] text-foreground-subtle`,children:e(`connectPhone.description`)}),t.isPending?o(`div`,{className:`flex items-center gap-2 text-[11px] text-foreground-subtle`,children:[d(w,{className:`h-3.5 w-3.5 animate-spin`}),e(`connectPhone.loading`)]}):t.isError?o(`div`,{className:`flex items-start gap-2 text-[11px] text-danger`,children:[d(g,{className:`h-3.5 w-3.5 mt-0.5 shrink-0`}),o(`div`,{className:`flex-1 min-w-0 space-y-1.5`,children:[d(`div`,{className:`break-words`,children:e(`connectPhone.error`,{message:t.error.message})}),d(M,{size:`sm`,variant:`ghost`,onClick:()=>void t.refetch(),children:e(`connectPhone.retry`)})]})]}):d(ke,{candidates:we(t.data.endpoints),preferredOrigin:n})]})]})}function ke({candidates:e,preferredOrigin:t}){let{t:n}=L(),[r,s]=a(null),c=Te(e,r,t),l=i(()=>c?Ee(c.origin):null,[c]);if(c===null||l===null)return d(`p`,{className:`text-[11px] text-foreground-subtle`,children:n(`connectPhone.empty`)});let u=e=>n(`connectPhone.tier.${e}`),f=e.map(e=>({value:e.origin,label:`${u(e.tier)} — ${e.origin}`}));return o(`div`,{className:`flex flex-col sm:flex-row gap-4`,children:[d(P,{value:l,size:De,alt:n(`connectPhone.qrAlt`),className:`self-start`}),o(`div`,{className:`flex-1 min-w-0 space-y-3`,children:[o(`label`,{className:`block space-y-1`,children:[d(`span`,{className:`text-[11px] font-medium text-foreground`,children:n(`connectPhone.addressLabel`)}),d(ie,{value:c.origin,options:f,onChange:e=>s(e.target.value)}),o(`span`,{className:`block text-[10px] text-foreground-subtle`,children:[u(c.tier),` · `,c.label]})]}),!c.secure&&d(Y,{text:n(`connectPhone.insecure`)}),!c.plausible&&d(Y,{text:n(`connectPhone.implausible`)}),o(`div`,{className:`space-y-1`,children:[d(`span`,{className:`text-[11px] font-medium text-foreground`,children:n(`connectPhone.linkLabel`)}),o(`div`,{className:`flex items-center gap-1 rounded-md border border-border bg-background px-2 py-1`,children:[d(`code`,{className:`flex-1 min-w-0 font-mono text-[11px] text-foreground break-all select-all`,children:l}),d(ae,{value:l,srLabel:n(`connectPhone.linkLabel`)})]})]}),d(`p`,{className:`text-[11px] text-foreground-subtle`,children:n(`connectPhone.signInHint`)})]})]})}function Y({text:e}){return o(`div`,{className:`flex items-start gap-2 rounded-md border border-warning/30 bg-warning/5 px-2.5 py-1.5 text-[11px] text-foreground`,children:[d(g,{className:`h-3.5 w-3.5 text-warning mt-0.5 shrink-0`}),d(`span`,{children:e})]})}n();function Ae(e){return new Date(e).toLocaleDateString()}function je(){let{t:e}=L(),t=N(),n=I.useUtils(),i=I.auth.listLinkableProviders.useQuery(),s=I.auth.listOwnExternalIdentities.useQuery(),[c,u]=a(null),[f,p]=a(()=>R(window.location.search)),m=l(null),h=G(`Linking a sign-in account`),g=l(null);r(()=>()=>g.current?.(),[]);let[v,y]=a(null);r(()=>{if(f===null)return;let e=new URL(window.location.href);e.searchParams.delete(`linked`),e.searchParams.delete(`linkError`),window.history.replaceState({},``,e.pathname+e.search+e.hash)},[f]);let C=I.auth.beginExternalLink.useMutation({onSuccess:({url:e})=>{let t=m.current;if(m.current=null,t===null||t.closed){window.location.assign(e);return}let r=e=>{y(null),p(R(`?${e}`)),n.auth.listOwnExternalIdentities.invalidate()};g.current?.(),g.current=W(t,{onReturn:e=>{e.target===`profile`&&r(e.query)},onDone:e=>{e.target===`profile`&&r(e.query)},onClosed:()=>{g.current?.(),g.current=null,n.auth.listOwnExternalIdentities.invalidate()}}),t.location.href=_(z(e))},onError:e=>{m.current?.close(),m.current=null,y(null),u(e.message)}}),T=I.auth.unlinkOwnExternalIdentity.useMutation({onSuccess:()=>void n.auth.listOwnExternalIdentities.invalidate(),onError:e=>u(e.message)}),E=i.data??[],D=s.data??[],O=v!==null&&D.some(e=>e.provider===v);if(r(()=>{!O||v===null||(y(null),p({kind:`linked`,provider:v}))},[O,v]),E.length===0&&D.length===0)return null;let k=new Set(D.map(e=>e.provider)),A=e=>E.find(t=>t.provider===e)?.label??e,j=async(n,r)=>{await t({title:e(`users.linkedSignInsSection.unlinkSignInAccount`,`Unlink sign-in account`),message:e(`users.linkedSignInsSection.stopSigningInWithThis`,`Stop signing in with this {{label}} account?`,{label:r}),confirmLabel:e(`users.linkedSignInsSection.unlink`,`Unlink`),variant:`danger`})&&(u(null),T.mutate({provider:n.provider,subject:n.subject}))};return o(`div`,{"data-testid":`linked-sign-ins`,className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[h.dialog,o(`div`,{className:`px-4 py-2.5 border-b border-border flex items-center gap-2`,children:[d(x,{className:`h-3.5 w-3.5 text-foreground-subtle`}),d(`div`,{className:`text-xs font-semibold text-foreground`,children:e(`users.linkedSignInsSection.linkedSignInAccounts`,`Linked sign-in accounts`)})]}),o(`div`,{className:`p-4 space-y-3`,children:[d(`p`,{className:`text-[11px] text-foreground-subtle`,children:e(`users.linkedSignInsSection.signInWithAnExternal`,`Sign in with an external account instead of your password. Only accounts you link here can sign you in; your two-factor authentication still applies.`)}),f?.kind===`linked`&&o(`div`,{className:`flex items-center gap-2 rounded-md border border-emerald-500/30 bg-emerald-500/5 px-3 py-2 text-xs text-foreground`,children:[d(S,{className:`h-3.5 w-3.5 text-emerald-500 shrink-0`}),e(`users.linkedSignIns.linkedNotice`,{provider:A(f.provider)})]}),(f?.kind===`error`||c)&&o(`div`,{className:`flex items-center gap-2 rounded-md border border-danger/20 bg-danger/10 px-3 py-2 text-xs text-danger`,children:[d(b,{className:`h-3.5 w-3.5 shrink-0`}),c??(f?.kind===`error`?f.message:``)]}),D.length>0&&d(`ul`,{className:`divide-y divide-border rounded-md border border-border`,children:D.map(t=>{let n=t.providerLabel??t.provider;return o(`li`,{className:`flex items-center gap-3 px-3 py-2 text-xs`,children:[o(`div`,{className:`flex-1 min-w-0`,children:[o(`div`,{className:`font-medium text-foreground truncate`,children:[n,!t.available&&d(`span`,{className:`ml-2 rounded bg-foreground-subtle/15 px-1.5 py-0.5 text-[10px] font-normal text-foreground-subtle`,children:e(`users.linkedSignInsSection.providerUnavailable`,`provider unavailable`)})]}),d(`div`,{className:`text-[11px] text-foreground-subtle truncate`,children:e(`users.linkedSignIns.linkedOn`,{label:t.label??t.subject,date:Ae(t.linkedAt)})})]}),o(`button`,{onClick:()=>void j(t,n),disabled:T.isPending,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] text-danger hover:bg-danger/10 disabled:opacity-50`,children:[d(ne,{className:`h-3 w-3`}),e(`users.linkedSignInsSection.unlink`,`Unlink`)]})]},`${t.provider}|${t.subject}`)})}),d(`div`,{className:`flex flex-wrap gap-2`,children:E.filter(e=>!k.has(e.provider)).map(t=>o(`button`,{onClick:()=>{u(null),p(null),h.requestProof().then(e=>{e!==null&&(m.current=B(null),y(m.current===null?null:t.provider),C.mutate({provider:t.provider,reauthToken:e}))})},disabled:C.isPending,className:`inline-flex items-center gap-1.5 rounded border border-border px-2.5 py-1 text-[11px] font-medium text-foreground hover:bg-surface-hover disabled:opacity-50`,children:[C.isPending&&C.variables?.provider===t.provider?d(w,{className:`h-3 w-3 animate-spin`}):d(x,{className:`h-3 w-3`}),e(`users.linkedSignIns.link`,{provider:t.label})]},t.provider))})]})]})}n();function Me({value:n,size:i=192}){let{t:s}=L(),[c,l]=a(null),[u,f]=a(null);if(r(()=>{let r=!1;return t(()=>import(`./browser-BHo8W_uH.js`).then(t=>e(t.default,1)).then(async e=>{if(r)return;let t=e.create;if(typeof t!=`function`){f(`qrcode.create() unavailable in installed version`);return}try{let e=t(n,{errorCorrectionLevel:`M`});r||l(e)}catch(e){r||f(e instanceof Error?e.message:`QR generation failed`)}}),__vite__mapDeps([0,1]),import.meta.url).catch(()=>{r||f(`qrcode library not installed`)}),()=>{r=!0}},[n]),u)return d(`div`,{className:`flex items-center justify-center text-[10px] text-foreground-subtle text-center p-4`,style:{width:i,height:i},children:s(`users.totpQrCode.qrRenderingUnavailableUseThe`,`QR rendering unavailable — use the secret below.`)});if(!c)return d(`div`,{className:`flex items-center justify-center text-[10px] text-foreground-subtle animate-pulse`,style:{width:i,height:i},children:s(`users.totpQrCode.generating`,`Generating…`)});let p=c.modules.size,m=i/p,h=[];for(let e=0;e<p;e++)for(let t=0;t<p;t++)c.modules.data[e*p+t]&&h.push(d(`rect`,{x:t*m,y:e*m,width:m,height:m,fill:`currentColor`},`${t}-${e}`));return o(`svg`,{width:i,height:i,viewBox:`0 0 ${i} ${i}`,className:`text-black`,children:[d(`rect`,{x:0,y:0,width:i,height:i,fill:`white`}),h]})}n();function Ne(){let{t:e}=L(),t=T(),[n,r]=a(``),[i,s]=a(``),[c,l]=a(``),[f,p]=a(null),m=u({mutationFn:e=>t.changeOwnPassword(e),onSuccess:()=>{p({kind:`success`,msg:`Password updated.`}),r(``),s(``),l(``)},onError:e=>{p({kind:`error`,msg:e instanceof Error?e.message:`Update failed`})}}),h=i.length>0&&c.length>0&&i!==c,g=i.length>0&&i.length<8,_=n.length>=1&&i.length>=8&&i===c;return o(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[o(`div`,{className:`px-4 py-2.5 border-b border-border flex items-center gap-2`,children:[d(ee,{className:`h-3.5 w-3.5 text-foreground-subtle`}),d(`div`,{className:`text-xs font-semibold text-foreground`,children:e(`systemPage.myAccess.changePassword`,`Change password`)})]}),o(`div`,{className:`p-4 space-y-3`,children:[d(X,{label:e(`systemPage.myAccess.currentPassword`,`Current password`),value:n,onChange:r,autoComplete:`current-password`}),d(X,{label:e(`systemPage.myAccess.newPassword`,`New password`),value:i,onChange:s,autoComplete:`new-password`,hint:e(`systemPage.myAccess.atLeast8Characters`,`At least 8 characters.`)}),d(X,{label:e(`systemPage.myAccess.confirmNewPassword`,`Confirm new password`),value:c,onChange:l,autoComplete:`new-password`}),(h||g)&&d(`div`,{className:`text-[11px] text-danger`,children:h?e(`systemPage.myAccess.passwordsDoNotMatch`,`Passwords do not match.`):e(`systemPage.myAccess.newPasswordMustBeAt`,`New password must be at least 8 characters.`)}),f&&o(`div`,{className:`text-[11px] flex items-center gap-1 ${f.kind===`success`?`text-success`:`text-danger`}`,children:[f.kind===`success`?d(S,{className:`h-3 w-3`}):d(b,{className:`h-3 w-3`}),f.msg]}),d(`div`,{className:`flex justify-end`,children:o(M,{onClick:()=>{p(null),m.mutate({currentPassword:n,newPassword:i})},disabled:!_||m.isPending,children:[m.isPending?d(w,{className:`h-3 w-3 animate-spin`}):d(E,{className:`h-3 w-3`}),e(`systemPage.myAccess.updatePassword`,`Update password`)]})})]})]})}function X({label:e,value:t,onChange:n,autoComplete:r,hint:i}){return o(`div`,{className:`space-y-1`,children:[d(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:e}),d(`input`,{type:`password`,value:t,onChange:e=>n(e.target.value),autoComplete:r,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`}),i&&d(`div`,{className:`text-[10px] text-foreground-subtle`,children:i})]})}function Pe({username:e}){let{t}=L(),n=T(),l=s({queryKey:[`auth`,`getOwnTotpStatus`],queryFn:()=>n.getOwnTotpStatus()}),p=l.data,[m,h]=a(null),[g,_]=a(``),[v,x]=a(null),[C,E]=a(!1),D=u({mutationFn:()=>n.setupOwnTotp(),onSuccess:e=>{h({secret:e.secret,otpauthUrl:e.otpauthUrl}),_(``),x(null)},onError:e=>x(e instanceof Error?e.message:`Setup failed`)}),O=u({mutationFn:e=>n.confirmOwnTotp(e),onSuccess:()=>{h(null),_(``),x(null),l.refetch()},onError:e=>x(e instanceof Error?e.message:`Confirmation failed — code did not match`)}),k=G(`Turning off two-factor authentication`),A=u({mutationFn:async()=>{let e=await k.requestProof();return e===null?null:n.disableOwnTotp({reauthToken:e})},onSuccess:()=>{x(null),l.refetch()},onError:e=>x(e instanceof Error?e.message:`Disable failed`)});r(()=>{if(!C)return;let e=setTimeout(()=>E(!1),1500);return()=>clearTimeout(e)},[C]);let j=i(()=>l.isLoading?`loading`:m?`setup_in_progress`:p?.enabled?`enrolled`:`not_enrolled`,[l.isLoading,p?.enabled,m]);return o(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[k.dialog,o(`div`,{className:`px-4 py-2.5 border-b border-border flex items-center gap-2`,children:[d(f,{className:`h-3.5 w-3.5 text-foreground-subtle`}),d(`div`,{className:`text-xs font-semibold text-foreground`,children:t(`systemPage.myAccess.twoFactorAuthentication`,`Two-factor authentication`)})]}),o(`div`,{className:`p-4 space-y-3`,children:[j===`loading`&&o(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[d(w,{className:`h-3.5 w-3.5 animate-spin`}),t(`systemPage.myAccess.checkingStatus`,`Checking status…`)]}),j===`not_enrolled`&&o(c,{children:[d(`div`,{className:`text-xs text-foreground-subtle`,children:t(`systemPage.myAccess.2faIsnTActiveOn`,`2FA isn't active on your account. Enable it to require a 6-digit code from your authenticator app at every login.`)}),d(`div`,{className:`flex justify-end`,children:o(M,{onClick:()=>{x(null),D.mutate()},disabled:D.isPending,children:[D.isPending?d(w,{className:`h-3 w-3 animate-spin`}):d(f,{className:`h-3 w-3`}),t(`systemPage.myAccess.enable2fa`,`Enable 2FA`)]})})]}),j===`setup_in_progress`&&m&&o(c,{children:[d(`div`,{className:`text-[11px] text-foreground-subtle`,children:d(U,{i18nKey:`systemPage.myAccess.scanQr`,values:{username:e},components:{mono:d(`span`,{className:`font-mono`})}})}),o(`div`,{className:`flex flex-col items-center gap-3`,children:[d(`div`,{className:`rounded-lg border border-border bg-white p-3`,children:d(Me,{value:m.otpauthUrl,size:180})}),o(`div`,{className:`w-full`,children:[d(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle mb-1`,children:t(`systemPage.myAccess.secretManualEntry`,`Secret (manual entry)`)}),o(`div`,{className:`flex items-center gap-2 rounded border border-border bg-surface-hover/30 px-2 py-1.5`,children:[d(`code`,{className:`text-[11px] font-mono text-foreground break-all flex-1`,children:m.secret}),o(M,{variant:`ghost`,onClick:()=>{m&&navigator.clipboard.writeText(m.secret).then(()=>E(!0))},children:[C?d(S,{className:`h-3 w-3 text-success`}):d(y,{className:`h-3 w-3`}),C?t(`systemPage.myAccess.copied`,`Copied`):t(`common.copy`,`Copy`)]})]})]})]}),o(`div`,{className:`space-y-1`,children:[d(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`6-digit code`}),d(`input`,{type:`text`,inputMode:`numeric`,autoComplete:`one-time-code`,placeholder:`123456`,value:g,onChange:e=>_(e.target.value.replace(/\D/g,``).slice(0,6)),className:`w-full rounded-md border border-border bg-surface px-3 py-2 text-center text-lg font-mono tracking-widest text-foreground focus:outline-none focus:ring-2 focus:ring-primary`})]}),v&&o(`div`,{className:`text-[11px] text-danger flex items-center gap-1`,children:[d(b,{className:`h-3 w-3`}),v]}),o(`div`,{className:`flex justify-end gap-2`,children:[d(M,{variant:`outline`,onClick:()=>{h(null),x(null),_(``)},children:t(`common.cancel`,`Cancel`)}),o(M,{onClick:()=>{x(null),O.mutate({code:g})},disabled:O.isPending||g.length!==6,children:[O.isPending?d(w,{className:`h-3 w-3 animate-spin`}):d(S,{className:`h-3 w-3`}),t(`common.confirm`,`Confirm`)]})]})]}),j===`enrolled`&&p&&o(c,{children:[o(`div`,{className:`rounded-md border border-success/30 bg-success/5 px-3 py-2.5 flex items-start gap-2.5`,children:[d(S,{className:`h-4 w-4 mt-0.5 text-success shrink-0`}),o(`div`,{className:`text-xs text-foreground space-y-0.5`,children:[d(`div`,{className:`font-medium`,children:t(`systemPage.myAccess.2faIsActive`,`2FA is active`)}),d(`div`,{className:`text-foreground-subtle`,children:t(`common.enrolledOn`,{when:p.confirmedAt?new Date(p.confirmedAt).toLocaleString():`—`})})]})]}),v&&o(`div`,{className:`text-[11px] text-danger flex items-center gap-1`,children:[d(b,{className:`h-3 w-3`}),v]}),d(`div`,{className:`flex justify-end`,children:o(M,{variant:`danger`,onClick:()=>{x(null),A.mutate()},disabled:A.isPending,children:[A.isPending?d(w,{className:`h-3 w-3 animate-spin`}):d(f,{className:`h-3 w-3`}),t(`systemPage.myAccess.disable2fa`,`Disable 2FA`)]})})]})]})]})}function Z(){return re(`auth-webauthn/passkey-enrollment`)?d(se,{widgetId:`auth-webauthn/passkey-enrollment`,host:`dashboard`}):null}n();function Q(e){return e.message.length>0?e.message:le.t(`auth.authAuditSection.requestFailed`)}function Fe(){let{t:e}=L(),{logout:t}=H(),n=N(),r=I.useUtils(),i=I.auth.listOwnSessions.useQuery(),[s,c]=a(null),l=I.auth.revokeOwnSession.useMutation({onSuccess:()=>void r.auth.listOwnSessions.invalidate(),onError:e=>c(`Sign out failed: ${Q(e)}`)}),u=I.auth.logout.useMutation({onSuccess:()=>t(),onError:e=>c(`Sign out failed: ${Q(e)}`)}),f=async t=>{await n({title:e(`auth.mySessionsSection.signOutThisSession`,`Sign out this session`),message:e(`auth.mySessionsSection.willHaveToSignIn`,`{{label}} will have to sign in again.`,{label:be(t.client).label}),confirmLabel:e(`auth.mySessionsSection.signOut`,`Sign out`),variant:`danger`})&&(c(null),l.mutate({id:t.id}))},p=async()=>{await n({title:e(`auth.mySessionsSection.signOutEverywhere`,`Sign out everywhere`),message:e(`auth.mySessionsSection.everySessionOfYourAccount`,`Every session of your account ends, this browser included: you will be signed out here too and every device has to sign in again.`),confirmLabel:e(`auth.mySessionsSection.signOutEverywhere`,`Sign out everywhere`),variant:`danger`})&&(c(null),u.mutate({everywhere:!0}))};return o(`div`,{"data-testid":`my-sessions`,className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[o(`div`,{className:`px-4 py-2.5 border-b border-border flex items-center gap-2`,children:[d(te,{className:`h-3.5 w-3.5 text-foreground-subtle`}),d(`div`,{className:`text-xs font-semibold text-foreground`,children:e(`auth.mySessionsSection.activeSessions`,`Active sessions`)})]}),o(`div`,{className:`p-4 space-y-3`,children:[d(`p`,{className:`text-[11px] text-foreground-subtle`,children:e(`auth.mySessionsSection.theBrowsersAndAppsSigned`,`The browsers and apps signed in to your account. Signing one out ends it at once.`)}),s!==null&&d(`div`,{className:`text-[11px] text-danger`,children:s}),d(ye,{sessions:i.data??[],isLoading:i.isLoading,loadError:i.isError?i.error?.message??e(`auth.authAuditSection.requestFailed`):null,emptyText:`No active sessions.`,onRevoke:e=>void f(e),revokingId:l.isPending?l.variables?.id??null:null}),d(`div`,{className:`flex justify-end`,children:o(`button`,{onClick:()=>void p(),disabled:u.isPending,className:`inline-flex items-center gap-1.5 rounded border border-danger/40 px-2.5 py-1 text-[11px] font-medium text-danger hover:bg-danger/10 disabled:opacity-50`,children:[u.isPending?d(w,{className:`h-3 w-3 animate-spin`}):d(j,{className:`h-3 w-3`}),e(`auth.mySessionsSection.signOutEverywhere`,`Sign out everywhere`)]})})]})]})}n();var Ie=`You`;function Le(){let{t:e}=L(),t=N(),n=I.useUtils(),r=I.auth.listOwnDeviceCredentials.useQuery(),[o,s]=a(null),c=I.auth.revokeOwnDeviceCredential.useMutation({onSuccess:e=>{e.revoked||s(`That device could not be revoked - it may already be gone.`),n.auth.listOwnDeviceCredentials.invalidate()},onError:e=>s(`Revoke failed: ${e.message}`)}),l=i(()=>(r.data??[]).map(e=>ve(e,Ie)),[r.data]),u=async n=>{await t({title:e(`certificates.myDevicesSection.revoke`,`Revoke "{{name}}"?`,{name:n.name}),message:e(`certificates.myDevicesSection.theDeviceStopsSigningIn`,`The device stops signing in at once and its open sessions end. To use it again you have to pair it anew. This cannot be undone.`),confirmLabel:e(`certificates.myDevicesSection.revoke2`,`Revoke`),variant:`danger`})&&(s(null),c.mutate({id:n.id}))},p={label:e(`certificates.myDevicesSection.revoke2`,`Revoke`),icon:m,isAvailable:he,onRun:e=>void u(e),busyId:c.isPending?c.variables?.id??null:null,disabled:c.isPending};return d(pe,{id:`my-devices`,title:e(`certificates.myDevicesSection.myDevices`,`My devices`),icon:f,description:e(`certificates.myDevicesSection.phonesThatStaySignedIn`,`Phones that stay signed in to your account with a certificate. If one is lost, revoke it here and it is signed out at once.`),notice:_e(o),onDismissNotice:()=>s(null),children:d(me,{rows:l,label:e(`certificates.devicesCard.label`),isLoading:r.isPending,loadError:r.error===null?null:r.error.message||`Request failed`,emptyText:`No devices are signed in with a certificate.`,hideOwner:!0,expiresNone:`—`,action:p})})}var $={profile:`profile`,signIn:`sign-in`,sessions:`sessions`,tokens:`tokens`},Re=[`linked`,`linkError`],ze={view:{icon:v,cls:`bg-foreground-subtle/15 text-foreground-subtle`},create:{icon:p,cls:`bg-primary/15 text-primary`},delete:{icon:h,cls:`bg-danger/15 text-danger`}};function Be(){let{t:e}=L(),{user:t,logout:n}=H(),[r]=ue(),i=e(`system.myAccess`,`My access`);if(!t)return d(fe,{icon:O,title:i,children:d(`div`,{className:`text-xs text-foreground-subtle`,children:e(`systemPage.myAccess.notSignedIn`,`Not signed in.`)})});if(Re.some(e=>r.has(e))&&!r.has(`tab`)){let e=new URLSearchParams(r);return e.set(`tab`,$.signIn),d(V,{to:`?${e.toString()}`,replace:!0})}return d(de,{icon:O,title:i,subtitle:e(`systemPage.myAccess.subtitle`,`Your account, how you sign in, where you are signed in, and your tokens.`),sectionsLabel:e(`systemPage.myAccess.sectionsLabel`,`My access sections`),defaultSection:$.profile,actions:o(M,{variant:`outline`,onClick:n,children:[d(j,{className:`h-3 w-3`}),e(`systemPage.myAccess.signOut`,`Sign out`)]}),sections:[{id:$.profile,label:e(`systemPage.myAccess.sections.profile`,`Profile`),content:d(Ve,{user:t})},{id:$.signIn,label:e(`systemPage.myAccess.sections.signIn`,`Sign-in & security`),content:o(`div`,{className:`space-y-4`,children:[d(Ne,{}),d(Pe,{username:t.username}),d(Z,{}),d(je,{})]})},{id:$.sessions,label:e(`systemPage.myAccess.sections.sessions`,`Sessions & devices`),content:o(`div`,{className:`space-y-4`,children:[d(Fe,{}),d(Le,{}),d(Oe,{})]})},{id:$.tokens,label:e(`systemPage.myAccess.sections.tokens`,`Tokens`),content:d(ge,{ownOnly:!0})}]})}function Ve({user:e}){let{t}=L(),n=e.isAdmin,r=e.scopes??[];return o(`div`,{className:`space-y-4`,children:[o(`div`,{className:`rounded-lg border border-border bg-surface px-4 py-3 flex items-center gap-3`,children:[d(`div`,{className:`flex h-10 w-10 items-center justify-center rounded-full bg-primary/10 text-primary font-semibold text-base`,children:e.username.slice(0,1).toUpperCase()}),o(`div`,{className:`flex-1 min-w-0`,children:[d(`div`,{className:`text-sm font-semibold text-foreground truncate`,children:e.username}),o(`div`,{className:`text-[11px] text-foreground-subtle`,children:[n?t(`systemPage.myAccess.administrator`,`Administrator`):t(`systemPage.myAccess.user`,`User`),` `,d(U,{i18nKey:`systemPage.myAccess.sessionId`,values:{id:e.id.slice(0,8)},components:{mono:d(`span`,{className:`font-mono`})}})]})]})]}),n&&o(`div`,{className:`rounded-lg border border-primary/30 bg-primary/5 px-4 py-3 text-xs text-foreground flex items-start gap-2.5`,children:[d(C,{className:`h-4 w-4 text-primary mt-0.5 shrink-0`}),o(`div`,{children:[d(`div`,{className:`font-semibold text-foreground`,children:t(`systemPage.myAccess.unrestrictedAccess`,`Unrestricted access`)}),d(`p`,{className:`text-foreground-subtle mt-0.5`,children:t(`systemPage.myAccess.adminSessionsBypassThePer`,`Admin sessions bypass the per-call scope check. Every protected endpoint is reachable regardless of the list below.`)})]})]}),r.length>0&&d(He,{scopes:r})]})}function He({scopes:e}){let{t}=L(),n=D();return o(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[o(`div`,{className:`px-4 py-2 border-b border-border`,children:[d(`div`,{className:`text-xs font-semibold text-foreground`,children:t(`systemPage.myAccess.grantedScopes`,`Granted scopes`)}),d(`div`,{className:`text-[10px] text-foreground-subtle`,children:t(`systemPage.myAccess.bakedIntoYourSessionToken`,`Baked into your session token at login; sign out + back in to refresh after changes.`)})]}),o(`div`,{className:`grid grid-cols-[100px_1fr_240px] gap-3 px-4 py-2 text-[10px] uppercase tracking-wide text-foreground-subtle border-b border-border`,children:[d(`div`,{children:t(`systemPage.myAccess.type`,`Type`)}),d(`div`,{children:t(`systemPage.myAccess.target`,`Target`)}),d(`div`,{children:t(`systemPage.myAccess.access`,`Access`)})]}),d(`ul`,{className:`divide-y divide-border`,children:e.map((e,r)=>o(`li`,{className:`grid grid-cols-[100px_1fr_240px] gap-3 px-4 py-2.5 items-center text-xs`,children:[d(`span`,{className:`font-mono text-foreground-subtle`,children:e.type}),d(`span`,{className:`font-mono text-foreground`,children:e.type===`device`?ce(e.selector,n):e.target}),d(`div`,{className:`flex items-center gap-1`,children:[`view`,`create`,`delete`].map(n=>{let r=e.access.includes(n),{icon:i,cls:a}=ze[n];return o(`span`,{className:`inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] font-medium ${r?a:`bg-transparent text-foreground-subtle/40 line-through`}`,title:r?t(`systemPage.myAccess.can`,`Can {{a}}`,{a:n}):t(`systemPage.myAccess.cannot`,`Cannot {{a}}`,{a:n}),children:[d(i,{className:`h-3 w-3`}),n]},n)})})]},r))})]})}export{Be as MyAccessPage};