@camstack/addon-admin-ui 1.2.701 → 1.2.703

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 (111) hide show
  1. package/CHANGELOG.md +16 -2
  2. package/dist/assets/{AccessSection-CmGUVN2c.js → AccessSection-BGohJFsQ.js} +1 -1
  3. package/dist/assets/Addons-BDlFntTI.js +5 -0
  4. package/dist/assets/{AdminPage-Dvziohv2.js → AdminPage-fCxxHmc-.js} +1 -1
  5. package/dist/assets/{AdminSectionedPage-3F0XiS4h.js → AdminSectionedPage-DDqDbMM3.js} +1 -1
  6. package/dist/assets/AiProfiles-BFi1Kn6N.js +3 -0
  7. package/dist/assets/Archive-ChqpFwH8.js +1 -0
  8. package/dist/assets/{BootstrapSettingsForm-D5_YCsD2.js → BootstrapSettingsForm-BLWj6csX.js} +1 -1
  9. package/dist/assets/{Build-DgzW58SZ.js → Build-DfHu8hDx.js} +4 -4
  10. package/dist/assets/{Calendars-BzFF94EV.js → Calendars-Cxw9P8Uq.js} +1 -1
  11. package/dist/assets/{Cluster-Chna0Sjs.js → Cluster-BwIvlnpz.js} +1 -1
  12. package/dist/assets/{CompositionBlockEditor-BUQTd-UR.js → CompositionBlockEditor-DyGQ4aIz.js} +2 -2
  13. package/dist/assets/{CompositionEditorPage-BTvOMFXc.js → CompositionEditorPage-DRISSQzb.js} +1 -1
  14. package/dist/assets/Data-B1NgedRI.js +2 -0
  15. package/dist/assets/DeviceDetail-BzGdZ7Q_.js +1 -0
  16. package/dist/assets/{Devices-DsS5GkXt.js → Devices-CdmWPr7S.js} +1 -1
  17. package/dist/assets/EmbedDevicePage-CfSj9caC.js +1 -0
  18. package/dist/assets/{EmbedPlayerPage-BD43fNk-.js → EmbedPlayerPage-DEP8gdti.js} +1 -1
  19. package/dist/assets/History-Bg9tQAqJ.js +1 -0
  20. package/dist/assets/Identity-Oyg78Wgg.js +1 -0
  21. package/dist/assets/InstancesTable-CItURWVx.js +1 -0
  22. package/dist/assets/IntegrationDetail-B05HfycS.js +1 -0
  23. package/dist/assets/{Integrations-BOc2LGfc.js → Integrations-Bpw7S0et.js} +2 -2
  24. package/dist/assets/{Integrations-BgRTT3i6.js → Integrations-wpQtKhSO.js} +1 -1
  25. package/dist/assets/Library-afeuqgc6.js +1 -0
  26. package/dist/assets/Locations-DPd9tJpI.js +3 -0
  27. package/dist/assets/{Logs-DS49QhkO.js → Logs-DSnFwEPX.js} +1 -1
  28. package/dist/assets/{MaskShapeCanvas-BwjxoZHj.js → MaskShapeCanvas-DATKwWoi.js} +1 -1
  29. package/dist/assets/{MotionZonesSettings-CgruOSjK.js → MotionZonesSettings-BrUyigty.js} +1 -1
  30. package/dist/assets/MyAccess-DTWeghN4.js +2 -0
  31. package/dist/assets/{Network-Dxm48n1Y.js → Network-CzBJb8Ro.js} +1 -1
  32. package/dist/assets/{NewExportModal-DQLl3C3Q.js → NewExportModal-DC6qeg0K.js} +1 -1
  33. package/dist/assets/NodeAddonsSettingsPanel-DwR6THxT.js +1 -0
  34. package/dist/assets/Notifications-8WkrgioY.js +1 -0
  35. package/dist/assets/{PanelContent-DnT2f8Cc.js → PanelContent-Cqel4gq_.js} +2 -2
  36. package/dist/assets/Pipeline-Dlg9wnRY.js +1 -0
  37. package/dist/assets/{PrivacyMaskSettings-B6WFh3P4.js → PrivacyMaskSettings-jcKOGH_r.js} +1 -1
  38. package/dist/assets/{SceneMonitorEditor-M-wzPHRE.js → SceneMonitorEditor-HfoxsYJf.js} +1 -1
  39. package/dist/assets/SessionsList-CIOmkBhu.js +2 -0
  40. package/dist/assets/{Showroom-BlMk46Us.js → Showroom-BgfY_eRn.js} +1 -1
  41. package/dist/assets/StorageLocationsTable-CbwL3VQY.js +1 -0
  42. package/dist/assets/System-DXC-3shW.js +2 -0
  43. package/dist/assets/TemplateEditorDialog-DXIGdBCR.js +1 -0
  44. package/dist/assets/{Terminal-BwEVkhLM.js → Terminal-Di7l31qa.js} +5 -5
  45. package/dist/assets/{TrainingProviders-CPc4S7AF.js → TrainingProviders-aXqehRmF.js} +1 -1
  46. package/dist/assets/{Viewer-B4D9Uq2-.js → Viewer-C71XpHjW.js} +1 -1
  47. package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-D6FI5YpS.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-DRUBvLQE.js} +1 -1
  48. package/dist/assets/{action-draft-BIhSMudC.js → action-draft-qcGhRMv4.js} +1 -1
  49. package/dist/assets/{ai-page.helpers-BfJpXMnt.js → ai-page.helpers-CEBa_im9.js} +1 -1
  50. package/dist/assets/{assignment-candidates-BfJhT0tz.js → assignment-candidates-DdSU1Zo6.js} +1 -1
  51. package/dist/assets/{authed-media-ChKbSmi3.js → authed-media-BZy-JJ_o.js} +1 -1
  52. package/dist/assets/{board-model-CyseSL_y.js → board-model-DIWwdMST.js} +1 -1
  53. package/dist/assets/{camera-block-model-BKFq-3HR.js → camera-block-model-Bq_R4oG5.js} +1 -1
  54. package/dist/assets/client-DLuByuRa.js +1122 -0
  55. package/dist/assets/{command-vocab-CeQ0ypHW.js → command-vocab-CvGdlD2o.js} +1 -1
  56. package/dist/assets/{device-integration-icon-BwgC8WB_.js → device-integration-icon-Dd9uw4UF.js} +1 -1
  57. package/dist/assets/device-picker-model-PIGdnO_G.js +1 -0
  58. package/dist/assets/{dist-Bgy0yfXq.js → dist-CDyYOITf.js} +1 -1
  59. package/dist/assets/dist-CFXBYJXQ.js +1122 -0
  60. package/dist/assets/{format-D9ROMB42.js → format-CrKdqqCK.js} +1 -1
  61. package/dist/assets/{hostInit-DO8vSCT5.js → hostInit-CYHcdoYA.js} +1 -1
  62. package/dist/assets/i18n-CLov6T90.js +1 -0
  63. package/dist/assets/{icons-DrHUdyj-.js → icons-BLtyw4fH.js} +1 -1
  64. package/dist/assets/index-CFJEFXwr.js +6 -0
  65. package/dist/assets/{linked-devices-model-bymuMeaF.js → linked-devices-model-BPZYWQoj.js} +1 -1
  66. package/dist/assets/{mf-entry-bootstrap-0-dc995488.js → mf-entry-bootstrap-0-129d9964.js} +2 -2
  67. package/dist/assets/mount-PIGdnO_G.js +1 -0
  68. package/dist/assets/{notification-rule-status-CyADOgAm.js → notification-rule-status-DeN2cEgy.js} +1 -1
  69. package/dist/assets/{player-overlays-D546iNTv.js → player-overlays-CgADEsQt.js} +1 -1
  70. package/dist/assets/remoteEntry-Cc7yyabb.js +1 -0
  71. package/dist/assets/src-CA2_9YJD.js +279 -0
  72. package/dist/assets/{sso-popup--gCyd56l.js → sso-popup-BXELI2t0.js} +1 -1
  73. package/dist/assets/{step-inspector-model-B_OOCp6Z.js → step-inspector-model-BFq40l6S.js} +1 -1
  74. package/dist/assets/{use-scenes-feed-D9kXSeA2.js → use-scenes-feed-DyQPnSjQ.js} +1 -1
  75. package/dist/assets/{useAdminDeviceRemoval-CF8lG06z.js → useAdminDeviceRemoval-CKwvXhAP.js} +1 -1
  76. package/dist/assets/useEventInvalidation-PIGdnO_G.js +1 -0
  77. package/dist/assets/{useNodeUrlSelection-ju70FIba.js → useNodeUrlSelection-cFOr6zMH.js} +1 -1
  78. package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-BSgZU_Z3.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-HQVwzuiB.js} +2 -2
  79. package/dist/index.html +8 -8
  80. package/dist/server/addon.js +213 -20
  81. package/package.json +2 -2
  82. package/dist/assets/Addons-CgCQDQsS.js +0 -5
  83. package/dist/assets/AiProfiles-BAdfHll3.js +0 -3
  84. package/dist/assets/Archive-tBDnGn2J.js +0 -1
  85. package/dist/assets/Data-Ge58RjOD.js +0 -2
  86. package/dist/assets/DeviceDetail-C09lWDie.js +0 -1
  87. package/dist/assets/EmbedDevicePage-BkW36-q-.js +0 -1
  88. package/dist/assets/History-D-ERNFKB.js +0 -1
  89. package/dist/assets/Identity-DXfvzQIG.js +0 -1
  90. package/dist/assets/InstancesTable-BzPfQPuA.js +0 -1
  91. package/dist/assets/IntegrationDetail-CEcOLviw.js +0 -1
  92. package/dist/assets/Library-DUI94NI6.js +0 -1
  93. package/dist/assets/Locations-DkcchiHh.js +0 -3
  94. package/dist/assets/MyAccess-TXMLevZM.js +0 -2
  95. package/dist/assets/NodeAddonsSettingsPanel-H8ruMWFP.js +0 -1
  96. package/dist/assets/Notifications-B44Sd1jg.js +0 -1
  97. package/dist/assets/Pipeline-XpW32I39.js +0 -1
  98. package/dist/assets/SessionsList-D0tv-91a.js +0 -2
  99. package/dist/assets/StorageLocationsTable-13scCxNp.js +0 -1
  100. package/dist/assets/System-CkjsA5xm.js +0 -2
  101. package/dist/assets/TemplateEditorDialog-fJjZNx16.js +0 -1
  102. package/dist/assets/client-DQzHwaNb.js +0 -1122
  103. package/dist/assets/device-detail-CFJoqbEo.js +0 -1
  104. package/dist/assets/device-picker-model-CVOfqhXA.js +0 -1
  105. package/dist/assets/dist-B6zcGpdS.js +0 -1122
  106. package/dist/assets/i18n-HSlX-YO0.js +0 -1
  107. package/dist/assets/index-BN2PojUq.js +0 -6
  108. package/dist/assets/mount-CVOfqhXA.js +0 -1
  109. package/dist/assets/remoteEntry-CeXhbAxp.js +0 -1
  110. package/dist/assets/src-C9_yKHH3.js +0 -279
  111. package/dist/assets/useEventInvalidation-CVOfqhXA.js +0 -1
@@ -1,3 +0,0 @@
1
- import{C as e,K as t,S as n,V as r,Y as i,et as a,o,x as s}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{Hr as c,Ia as l,Nr as u,O as d,Qa as f,Tt as p,V as m,Yn as h,aa as g,ct as _,ft as v,ir as y,k as b,tn as x,ur as S,z as C}from"./player-overlays-D546iNTv.js";import{Bn as w,mc as T,zs as E}from"./client-DQzHwaNb.js";import{t as D}from"./chevron-down-CBb-F8DT.js";import{An as O,Cp as k,Dr as A,Fa as j,Gi as M,Ha as N,Ia as P,Ji as F,M as I,Ra as L,Sp as R,Tc as ee,Tr as z,Ui as B,Vp as V,Wi as te,Yi as H,Zs as ne,_c as re,bc as ie,bs as ae,da as U,dc as oe,fc as se,gi as W,hi as ce,ic as le,ka as ue,mc as de,nc as fe,oc as pe,pc as me,pp as G,qi as he,rc as ge,vc as _e,ws as ve,xa as ye,xp as K,xs as be,yc as xe,ys as Se,zr as q}from"./src-C9_yKHH3.js";import{t as J}from"./i18n-HSlX-YO0.js";import{t as Y}from"./useTranslation-BJr-n0es.js";import{J as Ce,Si as we,wi as Te,yi as X}from"./index-BN2PojUq.js";import{t as Ee}from"./AdminSectionedPage-3F0XiS4h.js";import{c as De,n as Oe,r as ke}from"./linked-devices-model-bymuMeaF.js";a();function Z(e){return{id:e.id,name:e.name,type:e.type,stableId:e.stableId??``,parentDeviceId:e.parentDeviceId,location:e.location,...e.role!==void 0&&e.role!==null?{role:e.role}:{},...e.primaryChildEntityId!==void 0&&e.primaryChildEntityId!==null?{primaryChildEntityId:e.primaryChildEntityId}:{},...e.primaryChildPreference!==void 0&&e.primaryChildPreference!==null?{primaryChildPreference:e.primaryChildPreference}:{}}}function Q(e){if(e==null)return null;let t=e.trim();return t.length===0?null:t.toLowerCase()}function Ae(e,t){let n=Q(t);return n===null?[]:e.filter(e=>Q(e.location)===n)}function je(e,t){let n=Ae(e,t),r=new Set(n.map(e=>e.id));return n.filter(e=>e.parentDeviceId===null||!r.has(e.parentDeviceId))}function Me(e,t){let n=Q(e.location);return n===null||new Set(t.map(e=>Q(e))).has(n)?null:e.location?.trim()??null}function Ne(e,t){let n=Q(e.location);return n!==null&&t.has(n)}function Pe(e,t){let n=new Set(t.map(e=>Q(e))),r=new Set(e.filter(e=>Ne(e,n)).map(e=>e.id));return e.filter(e=>!(Ne(e,n)||e.parentDeviceId!==null&&r.has(e.parentDeviceId)))}function Fe(e,t){return Pe(e,t).filter(e=>e.parentDeviceId===null)}function Ie(e,t){let n=new Map;for(let t of e){if(t.parentDeviceId===null)continue;let e=n.get(t.parentDeviceId);e?e.push(t):n.set(t.parentDeviceId,[t])}let r=[],i=new Set([t]),a=[t];for(;a.length>0;){let e=[];for(let t of a)for(let a of n.get(t)??[])i.has(a.id)||(i.add(a.id),r.push(a),e.push(a.id));a=e}return r}function Le(e,t){return Ie(e,t).length}function Re(e,t){return e.filter(e=>!e.isCamera&&e.parentDeviceId===t)}function ze(e,t){return t.map(t=>({name:t,members:je(e,t)}))}function $({type:e,role:t,className:r}){return n(V(e,t),{"aria-hidden":`true`,className:r??`h-3.5 w-3.5 shrink-0 text-foreground-subtle`})}function Be({device:t}){let r=P(Z(t),`compact`);if(t.online)return n(`span`,{"aria-hidden":`true`,className:`inline-block h-1.5 w-1.5 shrink-0 rounded-full bg-success`,"data-status":`online`});let i=J.t(`common.offline`);return e(`span`,{className:`flex items-center gap-1.5`,children:[n(`span`,{className:`inline-block h-1.5 w-1.5 shrink-0 rounded-full border border-foreground-subtle`,"data-status":`offline`,role:`img`,"aria-label":J.t(`locations.deviceGlyphs.aria`,{name:r,state:i}),title:i}),n(`span`,{className:`text-xs text-foreground-muted`,children:i})]})}function Ve({open:t,title:a,items:o,listState:s,lockedIds:c,lockedNote:l,suggestions:u=null,busy:d=!1,onConfirm:f,onClose:p}){let{t:m}=Y(),[h,g]=i([]);r(()=>{t||g([])},[t]);let _=new Map(o.map(e=>[e.id,e.name])),v=(u?.ids??[]).filter(e=>_.has(e)&&!c.includes(e)),y=e=>g(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]);return n(B,{open:t,onOpenChange:e=>e?void 0:p(),children:e(M,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,"aria-label":a,children:[n(F,{children:n(H,{children:a})}),e(te,{className:`flex flex-col gap-3 p-2 sm:p-4`,children:[t&&u!==null&&v.length>0&&e(`section`,{"aria-label":u.heading,className:`flex flex-col gap-1`,children:[n(`h3`,{className:`text-[10px] sm:text-[11px] font-semibold text-foreground uppercase tracking-wider`,children:u.heading}),n(`div`,{className:`flex flex-wrap gap-1`,children:v.map(e=>n(`button`,{type:`button`,"aria-pressed":h.includes(e),className:`inline-flex items-center gap-1 rounded-full border px-1.5 py-0.5 text-[10px] font-medium transition-colors ${h.includes(e)?`border-primary/50 bg-primary/15 text-primary`:`border-border bg-surface text-foreground-subtle hover:bg-surface-hover`}`,onClick:()=>y(e),children:_.get(e)},e))})]}),t&&n(I,{devices:o,listState:s,value:h,onChange:e=>g(e),noun:`device`,emptyLabel:m(`locations.addDialog.nonePicked`),showAll:!0,lockedIds:c,lockedNote:l,testId:`quick-add-picker`})]}),e(he,{children:[n(G,{variant:`ghost`,onClick:p,children:m(`locations.addDialog.cancel`)}),n(G,{disabled:h.length===0||d,onClick:()=>f(h),children:m(`locations.addDialog.confirm`,{count:h.length})})]})]})})}a();function He({room:e,cameras:r,fleet:i}){let{t:a}=Y(),o=t(()=>new Map(i.map(e=>[e.id,e])),[i]);return e===null?n(`p`,{className:`text-xs text-foreground-subtle`,children:a(`locations.links.noRoom`)}):n(`div`,{className:`flex flex-col gap-3`,"data-testid":`camera-links-section`,children:r.length===0?n(`p`,{className:`text-xs text-foreground-subtle`,"data-testid":`camera-links-empty`,children:a(`locations.links.noCameras`,{room:e})}):r.map(e=>n(We,{camera:e,byId:o},e.id))})}function Ue(e){return{id:e.deviceId,name:e.name,type:e.type,location:e.location}}function We({camera:t,byId:r}){let{t:a}=Y(),s=P(Z(t),`full`),l=o(),u=we(),[f,p]=i(!1),[m,h]=i(null),g=ae({deviceId:t.id}),_=ke({status:g.status,data:g.data,error:g.error===null||g.error===void 0?null:g.error}),v=be(),y=_.kind===`present`?_:null,x=Se({deviceId:t.id,slotRef:y?.slot.slotRef??``},{enabled:f&&y!==null}),S=y===null?[]:Oe(y.slot,y.value),C=S.map(e=>e.deviceId),w=(x.data?.candidates??[]).map(Ue),T=new Set(w.map(e=>e.id)),E=C.filter(e=>!T.has(e)).map(e=>{let t=r.get(e);return{id:e,name:t?.name??`#${String(e)}`,...t===void 0?{}:{type:t.type,location:t.location}}}),D=[...w,...E],O=(x.data?.candidates??[]).filter(e=>e.suggested).map(e=>e.deviceId),k=async e=>{if(y!==null){h(null);try{await v.mutateAsync({deviceId:t.id,slotRef:y.slot.slotRef,value:De(y.value,e)}),await g.refetch(),await l.invalidateQueries({queryKey:[[`deviceManager`]]}),p(!1)}catch(e){h(e instanceof Error?e.message:String(e))}}},A=[{key:`device`,header:a(`locations.columns.device`),notSortableReason:a(`locations.columns.noSort`),render:t=>{let i=r.get(t.deviceId),o=t.name??i?.name??`#${String(t.deviceId)}`;return e(`span`,{className:`flex items-center gap-1.5`,children:[i!==void 0&&n($,{type:i.type,role:i.role}),n(X,{to:`/devices/${String(t.deviceId)}`,className:`min-w-0 truncate text-xs text-foreground hover:underline`,children:i===void 0?o:n(U,{device:Z(i),form:`compact`})}),t.implied&&n(`span`,{className:`text-[10px] text-foreground-subtle`,children:a(`locations.links.implied`)})]})}},{key:`type`,header:a(`locations.columns.type`),notSortableReason:a(`locations.columns.noSort`),render:e=>n(`span`,{className:`text-xs text-foreground-muted`,children:r.get(e.deviceId)?.type??`—`})},{key:`status`,header:a(`locations.columns.status`),notSortableReason:a(`locations.columns.noSort`),render:e=>{let t=r.get(e.deviceId);return t===void 0?n(`span`,{className:`text-xs text-foreground-subtle`,children:`—`}):n(Be,{device:t})}}];return e(`section`,{className:`min-w-0 ${d}`,"data-testid":`camera-links-${String(t.id)}`,children:[e(`header`,{className:`${b} flex min-h-9 items-center gap-1.5`,children:[n($,{type:t.type,role:t.role}),n(`h2`,{className:`min-w-0 flex-1 truncate text-sm font-semibold text-foreground`,children:n(U,{device:Z(t),form:`full`})}),e(G,{variant:`ghost`,size:`sm`,onClick:()=>u(Ce(t.id)),children:[n(c,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),a(`locations.links.edit`)]}),n(G,{variant:`outline`,size:`sm`,disabled:y===null,onClick:()=>p(!0),"aria-label":a(`locations.links.addNamed`,{camera:s}),children:a(`locations.room.add`)})]}),_.kind===`pending`&&n(`p`,{role:`status`,className:`px-3 py-3 text-xs text-foreground-subtle sm:px-4`,children:a(`locations.links.loading`)}),_.kind===`unknown`&&n(`p`,{role:`alert`,className:`px-3 py-3 text-xs text-warning sm:px-4`,children:a(`locations.links.unreadable`,{reason:_.reason})}),_.kind===`absent`&&n(`p`,{className:`px-3 py-3 text-xs text-foreground-subtle sm:px-4`,children:a(`locations.links.unsupported`)}),m!==null&&n(`p`,{role:`alert`,className:`px-3 pt-2 text-xs text-danger break-words sm:px-4`,children:m}),y!==null&&(S.length===0?n(`p`,{className:`px-3 py-3 text-xs text-foreground-subtle sm:px-4`,children:a(`locations.links.none`)}):n(q,{columns:A,rows:S,rowKey:e=>String(e.deviceId),bordered:!1,minWidthPx:360})),n(Ve,{open:f,title:a(`locations.links.pickTitle`,{camera:s}),items:D,listState:x.status===`error`?`failed`:x.data===void 0?`pending`:`answered`,lockedIds:C,lockedNote:a(`locations.links.alreadyLinked`),suggestions:t.location===null?null:{heading:a(`locations.links.suggested`,{room:t.location}),ids:O},busy:v.isPending,onConfirm:e=>void k(e),onClose:()=>p(!1)})]})}a();function Ge({name:t,description:a,busy:o,onSave:s}){let{t:c}=Y(),[l,u]=i(a??``);return r(()=>{u(a??``)},[a]),e(`div`,{className:`border-t border-border px-3 py-2 sm:px-4`,children:[n(W,{htmlFor:`location-description-${t}`,className:`block`,children:c(`locations.locationDescriptionField.whatIsThere`,`What is there`)}),n(ce,{id:`location-description-${t}`,value:l,onChange:e=>u(e.target.value),onBlur:()=>{let e=l.trim();e!==(a??``)&&s(e.length===0?null:e)},disabled:o,rows:2,maxLength:400,placeholder:c(`locations.locationDescriptionField.surfacesBoundariesWhatIsNormally`,`Surfaces, boundaries, what is normally parked or stored here.`),className:`mt-1 w-full resize-y rounded-md border border-border bg-surface px-2.5 py-1.5 text-xs text-foreground placeholder:text-foreground-subtle focus:outline-none focus:ring-1 focus:ring-inset focus:ring-primary disabled:cursor-not-allowed disabled:opacity-50`}),n(`p`,{className:`mt-1 ${C}`,children:c(`locations.locationDescriptionField.givenToTheAiWith`,`Given to the AI with the pictures, so it knows what it is looking at. Describe the PLACE, not what happens in it — events change, the ground does not.`)})]})}function Ke(e,t){let n=e?.find(e=>e.locationKey===t);return n===void 0||n.description.length===0?null:n.description}var qe=` none`;function Je({name:t,zones:r,zoneKey:i,busy:a,onChange:o}){let{t:s}=Y();if(r.length===0)return null;let c=[{value:qe,label:s(`locations.locationZoneField.none`,`— none —`)},...r.map(e=>({value:e.zoneKey,label:e.label}))];return e(`div`,{className:`flex items-center gap-2 border-t border-border px-3 py-1.5 sm:px-4 sm:py-2`,children:[n(W,{htmlFor:`location-zone-${t}`,children:s(`locations.locationZoneField.zone`,`Zone`)}),n(v,{id:`location-zone-${t}`,value:i??qe,disabled:a,onChange:e=>{let t=e.target.value;if(t===qe){o(null);return}let n=r.find(e=>e.zoneKey===t);n!==void 0&&o(n.label)},options:c})]})}function Ye(e,t){return e.find(e=>e.locationKeys.includes(t))?.zoneKey??null}function Xe({name:e,icon:t,busy:r,onPick:i}){return n(k,{value:t,onPick:i,fallbackGlyph:u,clearGlyph:l,labels:{trigger:`Change the icon of ${e}`,panel:`Icon for ${e}`,searchPlaceholder:`Search icons`,clear:`No icon`,noMatches:`No icon matches that`},disabled:r})}function Ze(e,t){let n=e?.find(e=>e.locationKey===t);return n===void 0?null:T(n.icon)??`map-pin`}function Qe(e){return`${e.kind}:${String(e.device.id)}`}function $e(e,t,n){return e.flatMap(e=>{let r=Re(t,e.id),i=n.has(e.id),a={kind:`member`,device:e,accessories:r,open:i};return!i||r.length===0?[a]:[a,...r.map(t=>({kind:`accessory`,device:t,parent:e}))]})}a();function et({name:r,members:a,devices:o,busy:c,icon:l,description:u,onRename:f,onDelete:m,onRebuildLinks:g,onAddDevices:_,onPickIcon:v,onSaveDescription:y,zones:C,zoneKey:w,onChangeZone:T}){let{t:E}=Y(),[D,k]=i(!1),[j,M]=i(r),N=z(a,t(()=>({searchText:e=>[e.name,...Re(o,e.id).map(e=>e.name)],facetValue:e=>e.type}),[o])),[P,F]=i(()=>new Set),I=e=>F(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),L=t(()=>$e(N.rows,o,P),[N.rows,o,P]),ee=[{key:`name`,header:E(`locations.columns.device`),notSortableReason:E(`locations.columns.noSort`),render:e=>e.kind===`member`?n(tt,{row:e,onToggle:()=>I(e.device.id)}):n(nt,{row:e})},{key:`type`,header:E(`locations.columns.type`),notSortableReason:E(`locations.columns.noSort`),render:e=>n(`span`,{className:`text-xs text-foreground-muted`,children:e.device.type})},{key:`status`,header:E(`locations.columns.status`),notSortableReason:E(`locations.columns.noSort`),render:e=>n(Be,{device:e.device})}],B=()=>{M(r),k(!1)},V=async()=>{let e=j.trim();if(e.length===0||e===r){B();return}await f(e),k(!1)},te=[{id:`rename`,label:E(`locations.locationCard.rename`,`Rename`),icon:S,disabled:c,onClick:()=>{M(r),k(!0)}},{id:`rebuild-links`,label:E(`locations.locationCard.rebuildLinkedDevices`,`Rebuild linked devices`),icon:h,separatorBefore:!0,disabled:c,onClick:()=>void g()},{id:`delete`,label:E(`common.delete`,`Delete`),icon:x,danger:!0,separatorBefore:!0,disabled:c,onClick:()=>void m()}];return e(`section`,{className:`min-w-0 ${d}`,children:[e(`header`,{className:`${b} flex min-h-9 items-center gap-1.5`,children:[n(Xe,{name:r,icon:l,busy:c,onPick:v}),D?e(s,{children:[n(K,{value:j,onChange:e=>M(e.target.value),onKeyDown:e=>{e.key===`Enter`&&V(),e.key===`Escape`&&B()},"aria-label":E(`locations.locationCard.rename2`,`Rename {{name}}`,{name:r}),className:`min-w-0 flex-1`,autoFocus:!0}),n(G,{type:`button`,size:`sm`,onClick:()=>void V(),children:E(`common.save`,`Save`)}),n(R,{type:`button`,variant:`ghost`,icon:p,onClick:B,"aria-label":E(`locations.locationCard.cancelRename`,`Cancel rename`)})]}):e(s,{children:[n(`h2`,{className:`min-w-0 flex-1 truncate text-sm font-semibold text-foreground`,children:r}),n(G,{type:`button`,variant:`outline`,size:`sm`,disabled:c,onClick:_,"aria-label":E(`locations.room.addTo`,{room:r}),children:E(`locations.room.add`)}),n(O,{items:te,title:E(`locations.locationCard.actionsFor`,`Actions for {{name}}`,{name:r}),triggerClassName:`p-1`})]})]}),n(Je,{name:r,zones:C,zoneKey:w,busy:c,onChange:T}),n(Ge,{name:r,description:u,busy:c,onSave:y}),a.length>0&&n(`div`,{className:`border-b border-border px-3 py-1.5 sm:px-4 sm:py-2`,children:n(A,{state:N.state,facets:N.facets,labels:{searchPlaceholder:E(`locations.filter.searchPlaceholder`),searchLabel:E(`locations.room.searchLabel`,{room:r}),facetsLabel:E(`locations.filter.typesLabel`),clearLabel:E(`locations.filter.clear`)},onSearch:N.setSearch,onToggleFacet:N.toggleFacet,onClear:N.clear})}),a.length===0?n(`p`,{className:`px-3 py-3 text-xs text-foreground-subtle sm:px-4`,children:E(`locations.locationCard.nothingHereYetAssignA`,`Nothing here yet — assign a device from the table below.`)}):n(q,{columns:ee,rows:L,rowKey:Qe,bordered:!1,minWidthPx:360,emptyMessage:E(`locations.filter.noMatch`)})]})}function tt({row:t,onToggle:r}){let{t:i}=Y(),{device:a,accessories:o,open:s}=t,c=P(Z(a),`compact`),l=s?D:g;return e(`span`,{className:`flex items-center gap-1.5`,children:[o.length>0?e(G,{type:`button`,variant:`ghost`,onClick:r,"aria-expanded":s,"aria-label":i(s?`locations.locationCard.collapseAccessories`:`locations.locationCard.expandAccessories`,{count:o.length,name:c}),className:`h-auto shrink-0 gap-0.5 p-0.5 text-foreground-subtle hover:text-foreground`,children:[n(l,{className:`h-3 w-3`}),n(`span`,{className:`text-[10px] tabular-nums`,children:o.length})]}):n(`span`,{"aria-hidden":`true`,className:`w-[1.35rem] shrink-0`}),n($,{type:a.type,role:a.role}),n(X,{to:`/devices/${String(a.id)}`,className:`min-w-0 truncate text-xs text-foreground hover:underline`,children:n(U,{device:Z(a),form:`compact`})})]})}function nt({row:t}){let{device:r,parent:i}=t;return e(`span`,{className:`flex items-center gap-1.5 pl-6`,children:[n(`span`,{"aria-hidden":`true`,className:`text-[10px] text-foreground-subtle`,children:`└`}),n($,{type:r.type,role:r.role,className:`h-3 w-3 shrink-0 text-foreground-subtle`}),n(X,{to:`/devices/${String(r.id)}`,className:`min-w-0 truncate text-xs text-foreground-muted hover:underline`,children:n(U,{device:Z(r),form:`nested`,parent:Z(i)})})]})}a();function rt({zones:e,busy:t,onRename:r,onDelete:a,onPickIcon:o}){let{t:s}=Y(),[c,l]=i(null),[u,d]=i(``),f=async e=>{let t=u.trim();l(null),!(t.length===0||t===e)&&await r(e,t)};return n(q,{columns:[{key:`icon`,header:s(`locations.siteZonesPanel.icon`,`Icon`),width:`w-12`,notSortableReason:`An icon has no order`,render:e=>n(Xe,{name:e.label,icon:e.icon,busy:t,onPick:t=>o(e.label,t)})},{key:`name`,header:s(`locations.siteZonesPanel.zone`,`Zone`),sortValue:e=>e.label.toLowerCase(),render:e=>c===e.label?n(K,{value:u,onChange:e=>d(e.target.value),onKeyDown:t=>{t.key===`Enter`&&f(e.label),t.key===`Escape`&&l(null)},onBlur:()=>void f(e.label),"aria-label":s(`locations.siteZonesPanel.rename`,`Rename {{label}}`,{label:e.label}),autoFocus:!0}):n(G,{type:`button`,variant:`ghost`,size:`sm`,className:`px-0`,onClick:()=>{d(e.label),l(e.label)},disabled:t,title:s(`locations.siteZonesPanel.renameTheZone`,`Rename the zone`),children:e.label})},{key:`rooms`,header:s(`locations.siteZonesPanel.rooms`,`Rooms`),align:`right`,sortValue:e=>e.locationKeys.length,render:e=>n(`span`,{className:`tabular-nums text-foreground-subtle`,children:e.locationKeys.length===0?s(`common.empty`):s(`common.rooms`,{count:e.locationKeys.length})})},{key:`actions`,header:s(`locations.siteZonesPanel.actions`,`Actions`),align:`right`,notSortableReason:`Actions have no order`,render:e=>n(G,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>void a(e.label),disabled:t,"aria-label":s(`locations.siteZonesPanel.delete`,`Delete {{label}}`,{label:e.label}),title:s(`locations.siteZonesPanel.deleteTheZoneTheRooms`,`Delete the zone — the rooms in it are kept`),children:n(x,{className:`h-3.5 w-3.5`})})}],rows:e,rowKey:e=>e.zoneKey,emptyMessage:s(`locations.siteZonesPanel.noZonesYetAZone`,`No zones yet. A zone groups rooms — “Night zone” for the bedrooms — and shows up before them in the app’s camera filter.`)})}a();function it({busy:t,onCreate:r}){let{t:a}=Y(),[o,s]=i(!1),[c,l]=i(``),u=()=>{l(``),s(!1)},d=async()=>{let e=c.trim();e.length!==0&&(await r(e),u())};return o?e(`form`,{className:`flex flex-wrap items-center gap-2`,onSubmit:e=>{e.preventDefault(),d()},children:[n(K,{value:c,onChange:e=>l(e.target.value),onKeyDown:e=>{e.key===`Escape`&&u()},placeholder:a(`locations.newLocationButton.frontDoorHallKitchen`,`Front door, Hall, Kitchen…`),"aria-label":a(`locations.newLocationButton.newLocationName`,`New location name`),className:`min-w-[12rem] flex-1`,autoFocus:!0}),e(G,{size:`sm`,type:`submit`,disabled:c.trim().length===0||t,children:[n(y,{className:`h-3.5 w-3.5`}),a(`common.add`,`Add`)]}),n(G,{size:`sm`,variant:`ghost`,type:`button`,onClick:u,"aria-label":a(`locations.newLocationButton.cancelNewLocation`,`Cancel new location`),children:n(p,{className:`h-3.5 w-3.5`})})]}):e(G,{size:`sm`,type:`button`,onClick:()=>s(!0),"data-testid":`new-location-button`,children:[n(y,{className:`h-3.5 w-3.5`}),a(`locations.newLocationButton.newLocation`,`New location`)]})}a();function at({busy:t,onCreate:r}){let{t:a}=Y(),[o,s]=i(!1),[c,l]=i(``),u=()=>{l(``),s(!1)},d=async()=>{let e=c.trim();e.length!==0&&(await r(e),u())};return o?e(`form`,{className:`flex flex-wrap items-center gap-2`,onSubmit:e=>{e.preventDefault(),d()},children:[n(K,{value:c,onChange:e=>l(e.target.value),onKeyDown:e=>{e.key===`Escape`&&u()},placeholder:a(`locations.newZoneButton.zonaGiornoZonaNotte`,`Zona giorno, Night zone…`),"aria-label":a(`locations.newZoneButton.newZoneName`,`New zone name`),className:`min-w-[12rem] flex-1`,autoFocus:!0}),e(G,{size:`sm`,type:`submit`,disabled:c.trim().length===0||t,children:[n(y,{className:`h-3.5 w-3.5`}),a(`common.add`,`Add`)]}),n(G,{size:`sm`,variant:`ghost`,type:`button`,onClick:u,"aria-label":a(`locations.newZoneButton.cancelNewZone`,`Cancel new zone`),children:n(p,{className:`h-3.5 w-3.5`})})]}):e(G,{size:`sm`,type:`button`,onClick:()=>s(!0),"data-testid":`new-zone-button`,children:[n(y,{className:`h-3.5 w-3.5`}),a(`locations.newZoneButton.newZone`,`New zone`)]})}a();function ot(e,t,n,r){let i=e.map(e=>({value:e.name,label:`${e.name} · ${String(e.count)}`}));return t===void 0?i:[...i,{value:n,label:`${r} · ${String(t)}`}]}function st({rooms:e,unassignedCount:r,value:i,unassignedValue:a,onChange:o}){let{t:s}=Y(),c=t(()=>ot(e,r,a,s(`locations.roomPicker.unassigned`)),[e,r,a,s]);return n(`div`,{className:`max-w-sm`,"data-testid":`room-select`,children:n(ye,{mode:`single`,singleDisplay:`field`,label:s(`locations.roomPicker.label`),placeholder:s(`locations.roomPicker.placeholder`),options:c,value:i,onChange:o,searchable:!0,testId:`room-select-control`,optionTestIdPrefix:`room-option`})})}a();var ct={searchText:e=>[e.name],facetValue:e=>e.type};function lt({rows:r,fleet:a,locations:o,busy:s,emptyMessage:c,onAssign:l}){let{t:u}=Y(),d=N(),p=L(),h=e=>d===null?e.name:j(Z(e),`compact`,d,p),[g,_]=i([]),[y,b]=i(``),x=z(r,ct),S=x.rows,w=t(()=>S.map(e=>e.id),[S]),T=t(()=>g.filter(e=>w.includes(e)),[g,w]),E=S.length>0&&T.length===S.length,D=t(()=>{let e=new Map;for(let t of r)e.set(t.id,Le(a,t.id));return e},[r,a]),O=T.reduce((e,t)=>e+(D.get(t)??0),0),k=e=>_(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]),M=()=>_(E?[]:w),P=()=>{y.length===0||T.length===0||(l(T,y),_([]),b(``))},F=o.map(e=>({value:e,label:e})),I=[{key:`select`,width:`w-8`,headerRender:()=>n(f,{checked:E,onChange:M,"aria-label":E?u(`locations.unassignedTable.clearSelection`,`Clear selection`):u(`locations.unassignedTable.selectAllUnassignedDevices`,`Select all unassigned devices`)}),render:e=>n(f,{checked:T.includes(e.id),onChange:()=>k(e.id),"aria-label":u(`locations.unassignedTable.select`,`Select {{name}}`,{name:h(e)})})},{key:`name`,header:u(`locations.unassignedTable.device`,`Device`),sortValue:e=>e.name.toLowerCase(),render:t=>{let r=Me(t,o);return e(`span`,{className:`flex items-center gap-1.5`,children:[n($,{type:t.type,role:t.role}),n(X,{to:`/devices/${String(t.id)}`,className:`truncate text-xs text-foreground hover:underline`,children:n(U,{device:Z(t),form:`compact`})}),r!==null&&n(ue,{variant:`warning`,children:u(`locations.unassignedTable.unknownRoom`,{room:r})})]})}},{key:`type`,header:u(`locations.unassignedTable.type`,`Type`),sortValue:e=>e.type,render:e=>n(`span`,{className:`text-xs text-foreground-muted`,children:e.type})},{key:`status`,header:u(`locations.unassignedTable.status`,`Status`),sortValue:e=>+!!e.online,render:e=>n(Be,{device:e})},{key:`followers`,header:u(`locations.unassignedTable.accessoriesInTowCount`,`Accessories in tow`),align:`right`,sortValue:e=>D.get(e.id)??0,render:e=>n(`span`,{className:`tabular-nums text-xs text-foreground-muted`,children:D.get(e.id)??0})},{key:`assign`,header:u(`locations.unassignedTable.assignTo`,`Assign to`),align:`right`,notSortableReason:`This column is a control, not a value.`,render:e=>n(v,{"aria-label":u(`locations.unassignedTable.locationFor`,`Location for {{name}}`,{name:h(e)}),value:``,disabled:s||o.length===0,onChange:t=>{let n=t.target.value;n.length!==0&&l([e.id],n)},className:`max-w-[11rem]`,options:[{value:``,label:`—`},...F]})}];return e(`section`,{className:`space-y-2`,children:[e(`header`,{className:`flex flex-wrap items-baseline gap-2`,children:[n(`h2`,{className:m,children:u(`locations.unassignedTable.notInARoom`,`Not in a room`)}),n(`p`,{className:C,children:u(`locations.unassignedTable.topLevelDevicesOnlyAccessories`,`Top-level devices only — accessories move with their parent.`)})]}),r.length>0&&n(A,{state:x.state,facets:x.facets,labels:{searchPlaceholder:u(`locations.filter.searchPlaceholder`),searchLabel:u(`locations.unassigned.searchLabel`),facetsLabel:u(`locations.filter.typesLabel`),clearLabel:u(`locations.filter.clear`)},onSearch:x.setSearch,onToggleFacet:x.toggleFacet,onClear:x.clear}),T.length>0&&e(`div`,{role:`group`,"aria-label":u(`locations.unassignedTable.bulkAssignment`,`Bulk assignment`),className:`flex flex-wrap items-center gap-2 rounded border border-primary/40 bg-primary/5 px-2 py-1.5`,children:[e(`span`,{className:`text-xs text-foreground`,children:[u(`locations.unassignedTable.selected`,{count:T.length}),O>0&&` · ${u(`locations.unassignedTable.accessoriesInTowCount`,{count:O})}`]}),n(v,{"aria-label":u(`locations.unassignedTable.assignSelectedDevicesTo`,`Assign selected devices to`),value:y,onChange:e=>b(e.target.value),className:`w-auto min-w-[10rem]`,options:[{value:``,label:u(`locations.unassignedTable.assignTo2`,`Assign to…`)},...F]}),n(G,{type:`button`,size:`sm`,onClick:P,disabled:s||y.length===0,children:u(`locations.unassignedTable.assign`,`Assign`)}),n(G,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>_([]),children:u(`locations.unassignedTable.clear`,`Clear`)})]}),n(q,{columns:I,rows:S,rowKey:e=>e.id,minWidthPx:720,emptyMessage:x.active?u(`locations.filter.noMatch`):c})]})}function ut(e){return{id:e.id,parentDeviceId:e.parentDeviceId,location:e.location,type:e.type,stableId:e.stableId??``,...e.primaryChildEntityId===void 0?{}:{primaryChildEntityId:e.primaryChildEntityId},...e.primaryChildPreference===void 0?{}:{primaryChildPreference:e.primaryChildPreference},...e.role!==void 0&&e.role!==null?{role:e.role}:{},name:e.name}}function dt(e,t){let n=t.map(ut),r=[];for(let i of t)i.isCamera&&i.location===e&&r.push({deviceId:i.id,name:i.name,ids:w({selfId:i.id,selfLocation:i.location,candidates:n})});return{entries:r}}var ft=`device-manager:linked-devices`;function pt(e){return{deviceId:e.deviceId,slotRef:ft,value:{slot:`linked-devices`,deviceIds:[...e.ids]}}}a();var mt=`__unassigned__`;function ht(){let{t:r}=Y(),a=o(),s=_(),{data:c,isLoading:l}=le(),{data:d}=ge(),{data:f}=fe(),{data:p}=pe(),{data:m,isLoading:h}=ne({projection:`slim`}),g=()=>{a.invalidateQueries({queryKey:[[`deviceManager`,`listLocations`]]}),a.invalidateQueries({queryKey:[[`deviceManager`,`listAll`]]}),a.invalidateQueries({queryKey:[[`deviceManager`,`listLocationIcons`]]}),a.invalidateQueries({queryKey:[[`deviceManager`,`listLocationDescriptions`]]}),a.invalidateQueries({queryKey:[[`deviceManager`,`listSiteZones`]]})},v=ve({onSuccess:g}),y=oe({onSuccess:g}),b=re({onSuccess:g}),x=me({onSuccess:g}),S=xe({onSuccess:g}),C=_e({onSuccess:g}),w=ee({onSuccess:g}),T=se({onSuccess:g}),D=de({onSuccess:g}),O=ie({onSuccess:g}),k=be(),A=t(()=>(m??[]).map(e=>({id:e.id,name:e.name,location:e.location??null,type:String(e.type),isCamera:e.isCamera,parentDeviceId:e.parentDeviceId,online:e.online,role:e.role??null,stableId:e.stableId,primaryChildEntityId:e.primaryChildEntityId??null,primaryChildPreference:e.primaryChildPreference??null})),[m]),j=c??[],M=t(()=>ze(A,j),[A,j]),[N,P]=Te(),F=N.get(`tab`),I=F===`zones`||F===`camera-links`?F:`locations`,L=N.get(`room`),R=t(()=>Fe(A,j),[A,j]),z=L===mt,B=z?null:L!==null&&M.some(e=>e.name===L)?L:M[0]?.name??null,V=B===null?null:M.find(e=>e.name===B)??null,te=z?mt:B??`__unassigned__`,H=B??M[0]?.name??null,ae=t(()=>M.map(e=>({name:e.name,count:e.members.length})),[M]),U=e=>{P(t=>{let n=new URLSearchParams(t);return n.set(`room`,e),n},{replace:!0})},W=l||h,ce=b.isPending||y.isPending||v.isPending||S.isPending,ue=async e=>{await v.mutateAsync({name:e})},G=async(e,t)=>{let n=t.trim();n.length===0||n===e||await x.mutateAsync({from:e,to:n})},he=async e=>{let t=dt(e,A);if(t.entries.length===0){await s({title:r(`locations.rebuildLinkedDevices`,`Rebuild linked devices`),message:r(`locations.noCameraIsAssignedTo`,`No camera is assigned to “{{room}}”.`,{room:e}),confirmLabel:`OK`});return}let n=t.entries.map(e=>r(`locations.rebuildEntry`,{name:e.name,count:e.ids.length})).join(`
2
- `);if(!await s({title:r(`locations.rebuildLinkedDevices`,`Rebuild linked devices`),message:r(`locations.replaceTheLinkedDeviceList`,`Replace the linked-device list of every camera in “{{room}}” with what the room contains? {{lines}} Anything linked by hand that is not in this room is lost.`,{room:e,lines:n}),confirmLabel:r(`locations.rebuild`,`Rebuild`),variant:`danger`}))return;let i=[];for(let e of t.entries)try{await k.mutateAsync(pt(e))}catch(t){i.push(`• ${e.name}: ${t instanceof Error?t.message:String(t)}`)}g(),i.length>0&&await s({title:r(`locations.rebuildLinkedDevices`,`Rebuild linked devices`),message:r(`locations.notRebuilt`,`Not rebuilt: {{value1}}`,{value1:i.join(`
3
- `)}),confirmLabel:`OK`})},ye=async(e,t)=>{let n=t>0?` ${String(t)} device(s) will become unassigned.`:``;await s({title:r(`locations.deleteLocation`,`Delete location`),message:r(`locations.deleteTheLocation`,`Delete the location “{{name}}”?{{extra}}`,{name:e,extra:n}),confirmLabel:r(`common.delete`,`Delete`),variant:`danger`})&&await y.mutateAsync({name:e,cascade:!0})},K=async e=>{await s({title:r(`locations.deleteZone`,`Delete zone`),message:r(`locations.deleteTheZoneTheRooms`,`Delete the zone “{{name}}”? The rooms in it are kept.`,{name:e}),confirmLabel:r(`common.delete`,`Delete`),variant:`danger`})&&await T.mutateAsync({name:e})},Se=async(e,t)=>{await S.mutateAsync({location:e,icon:t})},q=async(e,t)=>{await C.mutateAsync({location:e,description:t})},J=p??[],Ce=async(e,t)=>{await O.mutateAsync({location:e,zone:t})},we=(e,t)=>{for(let n of e)b.mutate({deviceId:n,location:t})},[X,De]=i(null),Oe=t(()=>A.filter(e=>e.parentDeviceId===null).map(e=>({id:e.id,name:e.name,type:e.type,location:e.location})),[A]),ke=n(st,{rooms:ae,...I===`locations`?{unassignedCount:R.length}:{},value:I===`locations`?te:H??``,unassignedValue:mt,onChange:U}),Z=e(`div`,{className:`flex flex-col gap-3`,"data-testid":`locations-section`,children:[W&&n(`p`,{className:`text-xs text-foreground-subtle`,children:r(`locations.loadingLocationsAndDevices`,`Loading locations and devices…`)}),ke,z||V===null?n(lt,{rows:R,fleet:A,locations:j,busy:ce,emptyMessage:W?r(`common.loading`,`Loading…`):r(`locations.everyTopLevelDeviceHas`,`Every top-level device has a room.`),onAssign:we}):n(et,{name:V.name,members:V.members,devices:A,busy:ce,icon:Ze(d,E(V.name)),onPickIcon:e=>Se(V.name,e),description:Ke(f,E(V.name)),onSaveDescription:e=>q(V.name,e),zones:J,zoneKey:Ye(J,E(V.name)),onChangeZone:e=>Ce(V.name,e),onRename:e=>G(V.name,e),onDelete:()=>ye(V.name,Ae(A,V.name).length),onRebuildLinks:()=>he(V.name),onAddDevices:()=>De(V.name)},V.name),j.length===0&&!W&&n(`p`,{className:`text-xs text-foreground-subtle`,children:r(`locations.noLocationsYetAddFrontDoor`,`No locations yet. Add Front door, Hall, Kitchen…`)}),n(Ve,{open:X!==null,title:r(`locations.room.addDialogTitle`,{room:X??``}),items:Oe,listState:h?`pending`:`answered`,lockedIds:X===null?[]:(M.find(e=>e.name===X)?.members??[]).map(e=>e.id),lockedNote:r(`locations.room.alreadyHere`),suggestions:{heading:r(`locations.room.suggestedUnassigned`),ids:R.map(e=>e.id)},busy:b.isPending,onConfirm:e=>{X!==null&&we(e,X),De(null)},onClose:()=>De(null)})]}),Q=e(`div`,{className:`flex flex-col gap-3`,"data-testid":`camera-links-tab`,children:[ke,n(He,{room:H,cameras:H===null?[]:Ae(A,H).filter(e=>e.isCamera),fleet:A})]});return n(Ee,{icon:u,title:r(`locations.locations`,`Locations`),subtitle:r(`locations.roomsAndAreasOfThe`,`Rooms and areas of the site. Assign any device here — storage disks are under Data → Storage.`),defaultSection:`locations`,sectionsLabel:`Locations sections`,actions:I===`zones`?n(at,{busy:w.isPending,onCreate:e=>w.mutateAsync({name:e})}):n(it,{busy:v.isPending,onCreate:ue}),sections:[{id:`locations`,label:r(`locations.locations`,`Locations`),content:Z},{id:`camera-links`,label:r(`locations.cameraLinks`,`Camera links`),content:Q},{id:`zones`,label:r(`locations.zones`,`Zones`),content:n(rt,{zones:J,busy:ce,onRename:(e,t)=>D.mutateAsync({from:e,to:t}),onDelete:K,onPickIcon:(e,t)=>w.mutateAsync({name:e,icon:t})})}]})}export{ht 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{C as n,J as r,K as i,S as a,V as o,Y as s,a as c,et 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-CEyXHAdg.js";import{$i as f,Cn as p,Hr as m,Ia as h,Ir as g,Mi as _,Nn as v,Q as y,Zi as b,Zt as x,_i as S,ct as C,ft as w,oo as T,qr as E,tn as D,ur as O,yt as k,zr as A}from"./player-overlays-D546iNTv.js";import{Ei as j,Ti as M}from"./client-DQzHwaNb.js";import{a as N,l as ee}from"./terminal-DZ5OZpgC.js";import{t as te}from"./monitor-smartphone-DPI9EQus.js";import{t as ne}from"./unlink-D3-IGpS8.js";import{Bi as re,Dl as ie,Or as ae,Vi as P,Zp as F,kl as oe,ma as se,mt as I,pp as L,xp as R}from"./src-C9_yKHH3.js";import{t as ce}from"./i18n-HSlX-YO0.js";import{t as z}from"./useTranslation-BJr-n0es.js";import"./mount-CVOfqhXA.js";import{c as le,i as ue,l as B,s as V}from"./sso-popup--gCyd56l.js";import{F as H,bi as U,n as W,vi as G,wi as de}from"./index-BN2PojUq.js";import{t as fe}from"./AdminSectionedPage-3F0XiS4h.js";import{t as pe}from"./AdminPage-Dvziohv2.js";import{n as me,t as he}from"./AccessSection-CmGUVN2c.js";import{_ as ge,a as _e,h as ve,r as ye,t as K,w as be}from"./SessionsList-D0tv-91a.js";l();var xe=`${M}/connect`,q={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 J(e){return j(e)}function Ce(e){return e.startsWith(`https://`)}function we(e){let t=e.flatMap(e=>{let t=Se(e),n=J(e.baseUrl);return t===null||n===null?[]:[{endpoint:e,tier:t,origin:n}]}).toSorted((e,t)=>q[e.tier]-q[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=J(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,Y={scheme:`https`};function Oe(){let{t:e}=z(),t=oe(Y),r=ie(Y).data?.roles.publicEndpoint.resolved??null;return n(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[n(`div`,{className:`px-4 py-2.5 border-b border-border flex items-center gap-2`,children:[a(p,{className:`h-3.5 w-3.5 text-foreground-subtle`}),a(`div`,{className:`text-xs font-semibold text-foreground`,children:e(`connectPhone.title`)})]}),n(`div`,{className:`p-4 space-y-3`,children:[a(`p`,{className:`text-[11px] text-foreground-subtle`,children:e(`connectPhone.description`)}),t.isPending?n(`div`,{className:`flex items-center gap-2 text-[11px] text-foreground-subtle`,children:[a(A,{className:`h-3.5 w-3.5 animate-spin`}),e(`connectPhone.loading`)]}):t.isError?n(`div`,{className:`flex items-start gap-2 text-[11px] text-danger`,children:[a(x,{className:`h-3.5 w-3.5 mt-0.5 shrink-0`}),n(`div`,{className:`flex-1 min-w-0 space-y-1.5`,children:[a(`div`,{className:`break-words`,children:e(`connectPhone.error`,{message:t.error.message})}),a(L,{size:`sm`,variant:`ghost`,onClick:()=>void t.refetch(),children:e(`connectPhone.retry`)})]})]}):a(ke,{candidates:we(t.data.endpoints),preferredOrigin:r})]})]})}function ke({candidates:e,preferredOrigin:t}){let{t:r}=z(),[o,c]=s(null),l=Te(e,o,t),u=i(()=>l?Ee(l.origin):null,[l]);if(l===null||u===null)return a(`p`,{className:`text-[11px] text-foreground-subtle`,children:r(`connectPhone.empty`)});let d=e=>r(`connectPhone.tier.${e}`),f=e.map(e=>({value:e.origin,label:`${d(e.tier)} — ${e.origin}`}));return n(`div`,{className:`flex flex-col sm:flex-row gap-4`,children:[a(re,{value:u,size:De,alt:r(`connectPhone.qrAlt`),className:`self-start`}),n(`div`,{className:`flex-1 min-w-0 space-y-3`,children:[n(`label`,{className:`block space-y-1`,children:[a(`span`,{className:`text-[11px] font-medium text-foreground`,children:r(`connectPhone.addressLabel`)}),a(w,{value:l.origin,options:f,onChange:e=>c(e.target.value)}),n(`span`,{className:`block text-[10px] text-foreground-subtle`,children:[d(l.tier),` · `,l.label]})]}),!l.secure&&a(X,{text:r(`connectPhone.insecure`)}),!l.plausible&&a(X,{text:r(`connectPhone.implausible`)}),n(`div`,{className:`space-y-1`,children:[a(`span`,{className:`text-[11px] font-medium text-foreground`,children:r(`connectPhone.linkLabel`)}),n(`div`,{className:`flex items-center gap-1 rounded-md border border-border bg-background px-2 py-1`,children:[a(`code`,{className:`flex-1 min-w-0 font-mono text-[11px] text-foreground break-all select-all`,children:u}),a(ae,{value:u,srLabel:r(`connectPhone.linkLabel`)})]})]}),a(`p`,{className:`text-[11px] text-foreground-subtle`,children:r(`connectPhone.signInHint`)})]})]})}function X({text:e}){return n(`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:[a(x,{className:`h-3.5 w-3.5 text-warning mt-0.5 shrink-0`}),a(`span`,{children:e})]})}l();function Ae(e){return new Date(e).toLocaleDateString()}function je(){let{t:e}=z(),t=C(),i=F.useUtils(),c=F.auth.listLinkableProviders.useQuery(),l=F.auth.listOwnExternalIdentities.useQuery(),[u,d]=s(null),[p,h]=s(()=>B(window.location.search)),g=r(null),_=W(`Linking a sign-in account`),v=r(null);o(()=>()=>v.current?.(),[]);let[x,S]=s(null);o(()=>{if(p===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)},[p]);let w=F.auth.beginExternalLink.useMutation({onSuccess:({url:e})=>{let t=g.current;if(g.current=null,t===null||t.closed){window.location.assign(e);return}let n=e=>{S(null),h(B(`?${e}`)),i.auth.listOwnExternalIdentities.invalidate()};v.current?.(),v.current=V(t,{onReturn:e=>{e.target===`profile`&&n(e.query)},onDone:e=>{e.target===`profile`&&n(e.query)},onClosed:()=>{v.current?.(),v.current=null,i.auth.listOwnExternalIdentities.invalidate()}}),t.location.href=y(le(e))},onError:e=>{g.current?.close(),g.current=null,S(null),d(e.message)}}),T=F.auth.unlinkOwnExternalIdentity.useMutation({onSuccess:()=>void i.auth.listOwnExternalIdentities.invalidate(),onError:e=>d(e.message)}),E=c.data??[],D=l.data??[],O=x!==null&&D.some(e=>e.provider===x);if(o(()=>{!O||x===null||(S(null),h({kind:`linked`,provider:x}))},[O,x]),E.length===0&&D.length===0)return null;let k=new Set(D.map(e=>e.provider)),j=e=>E.find(t=>t.provider===e)?.label??e,M=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`})&&(d(null),T.mutate({provider:n.provider,subject:n.subject}))};return n(`div`,{"data-testid":`linked-sign-ins`,className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[_.dialog,n(`div`,{className:`px-4 py-2.5 border-b border-border flex items-center gap-2`,children:[a(m,{className:`h-3.5 w-3.5 text-foreground-subtle`}),a(`div`,{className:`text-xs font-semibold text-foreground`,children:e(`users.linkedSignInsSection.linkedSignInAccounts`,`Linked sign-in accounts`)})]}),n(`div`,{className:`p-4 space-y-3`,children:[a(`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.`)}),p?.kind===`linked`&&n(`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:[a(b,{className:`h-3.5 w-3.5 text-emerald-500 shrink-0`}),e(`users.linkedSignIns.linkedNotice`,{provider:j(p.provider)})]}),(p?.kind===`error`||u)&&n(`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:[a(f,{className:`h-3.5 w-3.5 shrink-0`}),u??(p?.kind===`error`?p.message:``)]}),D.length>0&&a(`ul`,{className:`divide-y divide-border rounded-md border border-border`,children:D.map(t=>{let r=t.providerLabel??t.provider;return n(`li`,{className:`flex items-center gap-3 px-3 py-2 text-xs`,children:[n(`div`,{className:`flex-1 min-w-0`,children:[n(`div`,{className:`font-medium text-foreground truncate`,children:[r,!t.available&&a(`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`)})]}),a(`div`,{className:`text-[11px] text-foreground-subtle truncate`,children:e(`users.linkedSignIns.linkedOn`,{label:t.label??t.subject,date:Ae(t.linkedAt)})})]}),n(L,{variant:`unstyled`,onClick:()=>void M(t,r),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:[a(ne,{className:`h-3 w-3`}),e(`users.linkedSignInsSection.unlink`,`Unlink`)]})]},`${t.provider}|${t.subject}`)})}),a(`div`,{className:`flex flex-wrap gap-2`,children:E.filter(e=>!k.has(e.provider)).map(t=>n(L,{variant:`unstyled`,onClick:()=>{d(null),h(null),_.requestProof().then(e=>{e!==null&&(g.current=ue(null),S(g.current===null?null:t.provider),w.mutate({provider:t.provider,reauthToken:e}))})},disabled:w.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:[w.isPending&&w.variables?.provider===t.provider?a(A,{className:`h-3 w-3 animate-spin`}):a(m,{className:`h-3 w-3`}),e(`users.linkedSignIns.link`,{provider:t.label})]},t.provider))})]})]})}l();function Me({value:r,size:i=192}){let{t:c}=z(),[l,u]=s(null),[d,f]=s(null);if(o(()=>{let n=!1;return t(()=>import(`./browser-BHo8W_uH.js`).then(t=>e(t.default,1)).then(async e=>{if(n)return;let t=e.create;if(typeof t!=`function`){f(`qrcode.create() unavailable in installed version`);return}try{let e=t(r,{errorCorrectionLevel:`M`});n||u(e)}catch(e){n||f(e instanceof Error?e.message:`QR generation failed`)}}),__vite__mapDeps([0,1]),import.meta.url).catch(()=>{n||f(`qrcode library not installed`)}),()=>{n=!0}},[r]),d)return a(`div`,{className:`flex items-center justify-center text-[10px] text-foreground-subtle text-center p-4`,style:{width:i,height:i},children:c(`users.totpQrCode.qrRenderingUnavailableUseThe`,`QR rendering unavailable — use the secret below.`)});if(!l)return a(`div`,{className:`flex items-center justify-center text-[10px] text-foreground-subtle animate-pulse`,style:{width:i,height:i},children:c(`users.totpQrCode.generating`,`Generating…`)});let p=l.modules.size,m=i/p,h=[];for(let e=0;e<p;e++)for(let t=0;t<p;t++)l.modules.data[e*p+t]&&h.push(a(`rect`,{x:t*m,y:e*m,width:m,height:m,fill:`currentColor`},`${t}-${e}`));return n(`svg`,{width:i,height:i,viewBox:`0 0 ${i} ${i}`,className:`text-black`,children:[a(`rect`,{x:0,y:0,width:i,height:i,fill:`white`}),h]})}l();function Ne(){let{t:e}=z(),t=k(),[r,i]=s(``),[o,c]=s(``),[l,d]=s(``),[p,m]=s(null),h=u({mutationFn:e=>t.changeOwnPassword(e),onSuccess:()=>{m({kind:`success`,msg:`Password updated.`}),i(``),c(``),d(``)},onError:e=>{m({kind:`error`,msg:e instanceof Error?e.message:`Update failed`})}}),_=o.length>0&&l.length>0&&o!==l,v=o.length>0&&o.length<8,y=r.length>=1&&o.length>=8&&o===l;return n(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[n(`div`,{className:`px-4 py-2.5 border-b border-border flex items-center gap-2`,children:[a(ee,{className:`h-3.5 w-3.5 text-foreground-subtle`}),a(`div`,{className:`text-xs font-semibold text-foreground`,children:e(`systemPage.myAccess.changePassword`,`Change password`)})]}),n(`div`,{className:`p-4 space-y-3`,children:[a(Z,{label:e(`systemPage.myAccess.currentPassword`,`Current password`),value:r,onChange:i,autoComplete:`current-password`}),a(Z,{label:e(`systemPage.myAccess.newPassword`,`New password`),value:o,onChange:c,autoComplete:`new-password`,hint:e(`systemPage.myAccess.atLeast8Characters`,`At least 8 characters.`)}),a(Z,{label:e(`systemPage.myAccess.confirmNewPassword`,`Confirm new password`),value:l,onChange:d,autoComplete:`new-password`}),(_||v)&&a(`div`,{className:`text-[11px] text-danger`,children:_?e(`systemPage.myAccess.passwordsDoNotMatch`,`Passwords do not match.`):e(`systemPage.myAccess.newPasswordMustBeAt`,`New password must be at least 8 characters.`)}),p&&n(`div`,{className:`text-[11px] flex items-center gap-1 ${p.kind===`success`?`text-success`:`text-danger`}`,children:[p.kind===`success`?a(b,{className:`h-3 w-3`}):a(f,{className:`h-3 w-3`}),p.msg]}),a(`div`,{className:`flex justify-end`,children:n(L,{onClick:()=>{m(null),h.mutate({currentPassword:r,newPassword:o})},disabled:!y||h.isPending,children:[h.isPending?a(A,{className:`h-3 w-3 animate-spin`}):a(g,{className:`h-3 w-3`}),e(`systemPage.myAccess.updatePassword`,`Update password`)]})})]})]})}function Z({label:e,value:t,onChange:r,autoComplete:i,hint:o}){return n(`div`,{className:`space-y-1`,children:[a(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:e}),a(R,{type:`password`,value:t,onChange:e=>r(e.target.value),autoComplete:i,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&&a(`div`,{className:`text-[10px] text-foreground-subtle`,children:o})]})}function Pe({username:e}){let{t}=z(),r=k(),l=c({queryKey:[`auth`,`getOwnTotpStatus`],queryFn:()=>r.getOwnTotpStatus()}),m=l.data,[h,g]=s(null),[v,y]=s(``),[x,S]=s(null),[C,w]=s(!1),T=u({mutationFn:()=>r.setupOwnTotp(),onSuccess:e=>{g({secret:e.secret,otpauthUrl:e.otpauthUrl}),y(``),S(null)},onError:e=>S(e instanceof Error?e.message:`Setup failed`)}),E=u({mutationFn:e=>r.confirmOwnTotp(e),onSuccess:()=>{g(null),y(``),S(null),l.refetch()},onError:e=>S(e instanceof Error?e.message:`Confirmation failed — code did not match`)}),D=W(`Turning off two-factor authentication`),O=u({mutationFn:async()=>{let e=await D.requestProof();return e===null?null:r.disableOwnTotp({reauthToken:e})},onSuccess:()=>{S(null),l.refetch()},onError:e=>S(e instanceof Error?e.message:`Disable failed`)});o(()=>{if(!C)return;let e=setTimeout(()=>w(!1),1500);return()=>clearTimeout(e)},[C]);let j=i(()=>l.isLoading?`loading`:h?`setup_in_progress`:m?.enabled?`enrolled`:`not_enrolled`,[l.isLoading,m?.enabled,h]);return n(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[D.dialog,n(`div`,{className:`px-4 py-2.5 border-b border-border flex items-center gap-2`,children:[a(p,{className:`h-3.5 w-3.5 text-foreground-subtle`}),a(`div`,{className:`text-xs font-semibold text-foreground`,children:t(`systemPage.myAccess.twoFactorAuthentication`,`Two-factor authentication`)})]}),n(`div`,{className:`p-4 space-y-3`,children:[j===`loading`&&n(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[a(A,{className:`h-3.5 w-3.5 animate-spin`}),t(`systemPage.myAccess.checkingStatus`,`Checking status…`)]}),j===`not_enrolled`&&n(d,{children:[a(`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.`)}),a(`div`,{className:`flex justify-end`,children:n(L,{onClick:()=>{S(null),T.mutate()},disabled:T.isPending,children:[T.isPending?a(A,{className:`h-3 w-3 animate-spin`}):a(p,{className:`h-3 w-3`}),t(`systemPage.myAccess.enable2fa`,`Enable 2FA`)]})})]}),j===`setup_in_progress`&&h&&n(d,{children:[a(`div`,{className:`text-[11px] text-foreground-subtle`,children:a(G,{i18nKey:`systemPage.myAccess.scanQr`,values:{username:e},components:{mono:a(`span`,{className:`font-mono`})}})}),n(`div`,{className:`flex flex-col items-center gap-3`,children:[a(`div`,{className:`rounded-lg border border-border bg-white p-3`,children:a(Me,{value:h.otpauthUrl,size:180})}),n(`div`,{className:`w-full`,children:[a(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle mb-1`,children:t(`systemPage.myAccess.secretManualEntry`,`Secret (manual entry)`)}),n(`div`,{className:`flex items-center gap-2 rounded border border-border bg-surface-hover/30 px-2 py-1.5`,children:[a(`code`,{className:`text-[11px] font-mono text-foreground break-all flex-1`,children:h.secret}),n(L,{variant:`ghost`,onClick:()=>{h&&navigator.clipboard.writeText(h.secret).then(()=>w(!0))},children:[C?a(b,{className:`h-3 w-3 text-success`}):a(_,{className:`h-3 w-3`}),C?t(`systemPage.myAccess.copied`,`Copied`):t(`common.copy`,`Copy`)]})]})]})]}),n(`div`,{className:`space-y-1`,children:[a(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`6-digit code`}),a(R,{type:`text`,inputMode:`numeric`,autoComplete:`one-time-code`,placeholder:`123456`,value:v,onChange:e=>y(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`})]}),x&&n(`div`,{className:`text-[11px] text-danger flex items-center gap-1`,children:[a(f,{className:`h-3 w-3`}),x]}),n(`div`,{className:`flex justify-end gap-2`,children:[a(L,{variant:`outline`,onClick:()=>{g(null),S(null),y(``)},children:t(`common.cancel`,`Cancel`)}),n(L,{onClick:()=>{S(null),E.mutate({code:v})},disabled:E.isPending||v.length!==6,children:[E.isPending?a(A,{className:`h-3 w-3 animate-spin`}):a(b,{className:`h-3 w-3`}),t(`common.confirm`,`Confirm`)]})]})]}),j===`enrolled`&&m&&n(d,{children:[n(`div`,{className:`rounded-md border border-success/30 bg-success/5 px-3 py-2.5 flex items-start gap-2.5`,children:[a(b,{className:`h-4 w-4 mt-0.5 text-success shrink-0`}),n(`div`,{className:`text-xs text-foreground space-y-0.5`,children:[a(`div`,{className:`font-medium`,children:t(`systemPage.myAccess.2faIsActive`,`2FA is active`)}),a(`div`,{className:`text-foreground-subtle`,children:t(`common.enrolledOn`,{when:m.confirmedAt?new Date(m.confirmedAt).toLocaleString():`—`})})]})]}),x&&n(`div`,{className:`text-[11px] text-danger flex items-center gap-1`,children:[a(f,{className:`h-3 w-3`}),x]}),a(`div`,{className:`flex justify-end`,children:n(L,{variant:`danger`,onClick:()=>{S(null),O.mutate()},disabled:O.isPending,children:[O.isPending?a(A,{className:`h-3 w-3 animate-spin`}):a(p,{className:`h-3 w-3`}),t(`systemPage.myAccess.disable2fa`,`Disable 2FA`)]})})]})]})]})}function Fe(){return se(`auth-webauthn/passkey-enrollment`)?a(P,{widgetId:`auth-webauthn/passkey-enrollment`,host:`dashboard`}):null}l();function Q(e){return e.message.length>0?e.message:ce.t(`auth.authAuditSection.requestFailed`)}function Ie(){let{t:e}=z(),{logout:t}=H(),r=C(),i=F.useUtils(),o=F.auth.listOwnSessions.useQuery(),[c,l]=s(null),u=F.auth.revokeOwnSession.useMutation({onSuccess:()=>void i.auth.listOwnSessions.invalidate(),onError:e=>l(`Sign out failed: ${Q(e)}`)}),d=F.auth.logout.useMutation({onSuccess:()=>t(),onError:e=>l(`Sign out failed: ${Q(e)}`)}),f=async t=>{await r({title:e(`auth.mySessionsSection.signOutThisSession`,`Sign out this session`),message:e(`auth.mySessionsSection.willHaveToSignIn`,`{{label}} will have to sign in again.`,{label:ge(t.client).label}),confirmLabel:e(`auth.mySessionsSection.signOut`,`Sign out`),variant:`danger`})&&(l(null),u.mutate({id:t.id}))},p=async()=>{await r({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`})&&(l(null),d.mutate({everywhere:!0}))};return n(`div`,{"data-testid":`my-sessions`,className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[n(`div`,{className:`px-4 py-2.5 border-b border-border flex items-center gap-2`,children:[a(te,{className:`h-3.5 w-3.5 text-foreground-subtle`}),a(`div`,{className:`text-xs font-semibold text-foreground`,children:e(`auth.mySessionsSection.activeSessions`,`Active sessions`)})]}),n(`div`,{className:`p-4 space-y-3`,children:[a(`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.`)}),c!==null&&a(`div`,{className:`text-[11px] text-danger`,children:c}),a(K,{sessions:o.data??[],isLoading:o.isLoading,loadError:o.isError?o.error?.message??e(`auth.authAuditSection.requestFailed`):null,emptyText:`No active sessions.`,onRevoke:e=>void f(e),revokingId:u.isPending?u.variables?.id??null:null}),a(`div`,{className:`flex justify-end`,children:n(L,{variant:`unstyled`,onClick:()=>void p(),disabled:d.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:[d.isPending?a(A,{className:`h-3 w-3 animate-spin`}):a(N,{className:`h-3 w-3`}),e(`auth.mySessionsSection.signOutEverywhere`,`Sign out everywhere`)]})})]})]})}l();var Le=`You`;function Re(){let{t:e}=z(),t=C(),n=F.useUtils(),r=F.auth.listOwnDeviceCredentials.useQuery(),[o,c]=s(null),l=F.auth.revokeOwnDeviceCredential.useMutation({onSuccess:e=>{e.revoked||c(`That device could not be revoked - it may already be gone.`),n.auth.listOwnDeviceCredentials.invalidate()},onError:e=>c(`Revoke failed: ${e.message}`)}),u=i(()=>(r.data??[]).map(e=>ye(e,Le)),[r.data]),d=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`})&&(c(null),l.mutate({id:n.id}))},f={label:e(`certificates.myDevicesSection.revoke2`,`Revoke`),icon:h,isAvailable:_e,onRun:e=>void d(e),busyId:l.isPending?l.variables?.id??null:null,disabled:l.isPending};return a(he,{id:`my-devices`,title:e(`certificates.myDevicesSection.myDevices`,`My devices`),icon:p,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:me(o),onDismissNotice:()=>c(null),children:a(be,{rows:u,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:f})})}var $={profile:`profile`,signIn:`sign-in`,sessions:`sessions`,tokens:`tokens`},ze=[`linked`,`linkError`],Be={view:{icon:S,cls:`bg-foreground-subtle/15 text-foreground-subtle`},create:{icon:O,cls:`bg-primary/15 text-primary`},delete:{icon:D,cls:`bg-danger/15 text-danger`}};function Ve(){let{t:e}=z(),{user:t,logout:r}=H(),[i]=de(),o=e(`system.myAccess`,`My access`);if(!t)return a(pe,{icon:v,title:o,children:a(`div`,{className:`text-xs text-foreground-subtle`,children:e(`systemPage.myAccess.notSignedIn`,`Not signed in.`)})});if(i.get(`tab`)===`preferences`)return a(U,{to:`/system/settings`,replace:!0});if(ze.some(e=>i.has(e))&&!i.has(`tab`)){let e=new URLSearchParams(i);return e.set(`tab`,$.signIn),a(U,{to:`?${e.toString()}`,replace:!0})}return a(fe,{icon:v,title:o,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:n(L,{variant:`outline`,onClick:r,children:[a(N,{className:`h-3 w-3`}),e(`systemPage.myAccess.signOut`,`Sign out`)]}),sections:[{id:$.profile,label:e(`systemPage.myAccess.sections.profile`,`Profile`),content:a(He,{user:t})},{id:$.signIn,label:e(`systemPage.myAccess.sections.signIn`,`Sign-in & security`),content:n(`div`,{className:`space-y-4`,children:[a(Ne,{}),a(Pe,{username:t.username}),a(Fe,{}),a(je,{})]})},{id:$.sessions,label:e(`systemPage.myAccess.sections.sessions`,`Sessions & devices`),content:n(`div`,{className:`space-y-4`,children:[a(Ie,{}),a(Re,{}),a(Oe,{})]})},{id:$.tokens,label:e(`systemPage.myAccess.sections.tokens`,`Tokens`),content:a(ve,{ownOnly:!0})}]})}function He({user:e}){let{t}=z(),r=e.isAdmin,i=e.scopes??[];return n(`div`,{className:`space-y-4`,children:[n(`div`,{className:`rounded-lg border border-border bg-surface px-4 py-3 flex items-center gap-3`,children:[a(`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()}),n(`div`,{className:`flex-1 min-w-0`,children:[a(`div`,{className:`text-sm font-semibold text-foreground truncate`,children:e.username}),n(`div`,{className:`text-[11px] text-foreground-subtle`,children:[r?t(`systemPage.myAccess.administrator`,`Administrator`):t(`systemPage.myAccess.user`,`User`),` `,a(G,{i18nKey:`systemPage.myAccess.sessionId`,values:{id:e.id.slice(0,8)},components:{mono:a(`span`,{className:`font-mono`})}})]})]})]}),r&&n(`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:[a(E,{className:`h-4 w-4 text-primary mt-0.5 shrink-0`}),n(`div`,{children:[a(`div`,{className:`font-semibold text-foreground`,children:t(`systemPage.myAccess.unrestrictedAccess`,`Unrestricted access`)}),a(`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.`)})]})]}),i.length>0&&a(Ue,{scopes:i})]})}function Ue({scopes:e}){let{t}=z(),r=T();return n(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[n(`div`,{className:`px-4 py-2 border-b border-border`,children:[a(`div`,{className:`text-xs font-semibold text-foreground`,children:t(`systemPage.myAccess.grantedScopes`,`Granted scopes`)}),a(`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.`)})]}),n(`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:[a(`div`,{children:t(`systemPage.myAccess.type`,`Type`)}),a(`div`,{children:t(`systemPage.myAccess.target`,`Target`)}),a(`div`,{children:t(`systemPage.myAccess.access`,`Access`)})]}),a(`ul`,{className:`divide-y divide-border`,children:e.map((e,i)=>n(`li`,{className:`grid grid-cols-[100px_1fr_240px] gap-3 px-4 py-2.5 items-center text-xs`,children:[a(`span`,{className:`font-mono text-foreground-subtle`,children:e.type}),a(`span`,{className:`font-mono text-foreground`,children:e.type===`device`?I(e.selector,r):e.target}),a(`div`,{className:`flex items-center gap-1`,children:[`view`,`create`,`delete`].map(r=>{let i=e.access.includes(r),{icon:o,cls:s}=Be[r];return n(`span`,{className:`inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] font-medium ${i?s:`bg-transparent text-foreground-subtle/40 line-through`}`,title:i?t(`systemPage.myAccess.can`,`Can {{a}}`,{a:r}):t(`systemPage.myAccess.cannot`,`Cannot {{a}}`,{a:r}),children:[a(o,{className:`h-3 w-3`}),r]},r)})})]},i))})]})}export{Ve as MyAccessPage};
@@ -1 +0,0 @@
1
- import{C as e,J as t,K as n,R as r,S as i,V as a,W as o,Y as s,et as c,i as l,j as u,o as d,p as f,t as p}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{yt as m}from"./player-overlays-D546iNTv.js";import{$c as h,Qc as g}from"./client-DQzHwaNb.js";import{Mo as _,_s as v,at as y,do as ee,eo as te,pp as b,to as ne}from"./src-C9_yKHH3.js";import{t as re}from"./useTranslation-BJr-n0es.js";import{M as ie,N as ae,P as x,Vt as S}from"./index-BN2PojUq.js";import{n as oe,t as se}from"./settings-section-shape-DbQZZpNL.js";c();var C=u(function({addonId:e,schema:s,serverValues:c,onImmediateSave:l,onStateChange:u,onAction:d,disabled:f},p){let m=x({schema:s,serverValues:c,onImmediateSave:r(t=>l(e,t),[e,l]),onDeferredSave:r(()=>{},[])});o(p,()=>({flush:()=>{let e={};for(let t of m.pendingKeys)e[t]=m.values[t];return m.handleDiscard(m.pendingKeys),e},discard:()=>m.resetAll()}),[m]);let h=m.pendingKeys,g=h.join(`|`),_=n(()=>h.map(e=>`${e}=${JSON.stringify(m.values[e])}`).join(`,`),[h,m.values]),v=t(u);a(()=>{v.current=u},[u]),a(()=>{let t={};for(let e of h)t[e]=m.values[e];v.current({addonId:e,pendingKeys:h,pendingValues:t})},[e,g,_]);let y=n(()=>{if(d)return(t,n,r)=>d(e,t,n,r)},[e,d]);return i(S,{schema:s,values:m.values,onChange:m.handleChange,disabled:f,onAction:y})});function w(e){return`perNode`in e&&e.perNode===!0}function T(e,t){if(e.type===`group`){let n=E(e.fields,t);return n.length>0?{...e,fields:n}:null}if(e.type===`sub-tabs`){let n=e.tabs.map(e=>({...e,fields:E(e.fields,t)})).filter(e=>e.fields.length>0);return n.length>0?{...e,tabs:n}:null}return w(e)===(t===`perNode`)?e:null}function E(e,t){let n=[];for(let r of e){let e=T(r,t);e!==null&&n.push(e)}return n}function ce(e,t){let n=[];for(let r of e.sections){let e=E(r.fields,t);e.length!==0&&n.push({...r,fields:e})}return{...e,sections:n}}function D(e,t){return t===void 0?!0:t===`perNode`?e===`node`:e!==`node`}function le(e){let t=e.allowSectionIds?new Set(e.allowSectionIds):null,n=e.omitSectionIds?new Set(e.omitSectionIds):null,r=new Set,i=[];for(let a of e.declarations){if(!D(a.scope,e.fieldScope)||e.capability!==void 0&&a.cap!==e.capability)continue;let o=a.sectionIds.filter(e=>r.has(e)||(r.add(e),t!==null&&!t.has(e))?!1:n===null||!n.has(e));o.length>0&&i.push({cap:a.cap,scope:a.scope,sectionIds:o})}return i}function ue(e){let t=[],n=new Map,r={};for(let{declaration:i,form:a}of e){let e=new Set(i.sectionIds),o=a.sections.filter(t=>e.has(t.id));t.push(...o);for(let e of a.tabs??[])n.has(e.id)||n.set(e.id,e);for(let e of h({sections:o}).keys()){let t=r[e]??[];t.push({cap:i.cap,scope:i.scope}),r[e]=t}}return{form:{...n.size>0?{tabs:[...n.values()]}:{},sections:t},keyTargets:r}}function de(e,t){let n=new Map,r=[];for(let[i,a]of Object.entries(e)){let e=t[i];if(e===void 0||e.length===0){r.push(i);continue}for(let t of e){let e=`${t.cap}\u0000${t.scope}`,r=n.get(e)??{target:t,patch:{}};r.patch[i]=a,n.set(e,r)}}return{groups:[...n.values()].map(e=>({...e.target,patch:e.patch})),unowned:r}}c();function O(e,t){if(e.type===`separator`||e.type===`info`||e.type===`button`)return e;if(e.type===`group`){let n=e.fields.map(e=>O(e,t));return{...e,fields:n}}let n=e;t[e.key]=n.value;let{value:r,...i}=n;return i}function k(e,t){return{...e,fields:e.fields.map(e=>O(e,t))}}function fe(e){let t={};return{schema:{...e.tabs?{tabs:e.tabs}:{},sections:e.sections.map(e=>k(e,t))},values:t}}function A({nodeId:a,addonIds:o,level:c,deviceId:u,capability:h,omitCapabilities:b,sectionIds:x,omitSectionIds:S,fieldKeys:C,omitFieldKeys:w,hideSectionChrome:T,tabAliases:E,tabLabelOverrides:D,sectionTab:O,fieldScope:k,emptyMessage:A,extraTabs:j,schemaTabExtras:M,title:N,description:P,selfTabbed:me,activeTab:he,onActiveTabChange:ge}){let{t:F}=re(),I=d(),L=m().trpcClient,_e=ne(),ve=te(),ye=v(),be=_(),R=me===!0||!!(j&&j.length>0),[xe,Se]=s(null);if(c===`device`&&!u)throw Error(`NodeAddonsSettingsPanel: deviceId is required when level === "device"`);let z=a??`hub`,B=l({queries:o.map(e=>({queryKey:[[`addonSettings`,c===`global`?`listScopedSettings`:`getDeviceSettings`],{addonId:e,nodeId:z,deviceId:u??null,cap:h??null,omitCaps:b??null,scope:k??null,sections:[x??null,S??null]}],queryFn:async()=>{if(c===`global`){let t=await L.addonSettings.listScopedSettings.query({addonId:e,nodeId:z});if(t===null)return{addonId:e,result:null,keyTargets:{}};let n=new Set(b??[]),r=le({declarations:t.filter(e=>!n.has(e.cap)),...k===void 0?{}:{fieldScope:k},...h===void 0?{}:{capability:h},...x===void 0?{}:{allowSectionIds:x},...S===void 0?{}:{omitSectionIds:S}}),i=await Promise.all(r.map(async t=>{let n=await L.addonSettings.getScopedSettings.query({addonId:e,cap:t.cap,scope:t.scope,...t.scope===`node`?{nodeId:z}:{}});return n===null?null:{declaration:t,form:n}})),a=i.filter(e=>e!==null);if(a.length!==i.length)return{addonId:e,result:null,keyTargets:{}};let o=ue(a);return{addonId:e,result:o.form,keyTargets:o.keyTargets}}let t=await L.addonSettings.getDeviceSettings.query({addonId:e,deviceId:u,nodeId:z});return{addonId:e,result:t!==null&&k!==void 0?ce(t,k):t,keyTargets:{}}},placeholderData:f}))}),Ce=B.some(e=>e.isLoading),V=B.map(e=>{if(!e.data)return`-`;if(e.data.result===null)return`${e.data.addonId}:n`;let t=[];for(let n of e.data.result.sections){t.push(`s:${n.id}:${n.tab??`general`}`);for(let e of n.fields){if(!(`key`in e))continue;let n=`options`in e&&Array.isArray(e.options)?e.options.map(e=>e.value).join(`,`):``,r=e.value,i=r===void 0?``:typeof r==`string`?r:JSON.stringify(r);t.push(`f:${e.key}:${n}:${i}`)}}return`${e.data.addonId}:${t.join(`|`)}`}).join(`||`),H=n(()=>{let e=new Set;for(let t of B){let n=t.data?.result?.sections;if(n)for(let t of n)e.add(oe(t.tab,E))}return[...e]},[E,V+`::`+B.map(e=>(e.data?.result?.sections??[]).map(e=>e.tab??`general`).join(`,`)).join(`::`)]),U=n(()=>new Map((j??[]).map(e=>[e.id,e])),[j]),W=n(()=>{if(!R)return[];let e=[...new Set([...H,...(j??[]).map(e=>e.id),...(M??[]).map(e=>e.tabId)])],t=e=>{let t=U.get(e);if(t?.order!==void 0)return t.order;let n=g[e];return n?n.order:50};return e.toSorted((e,n)=>{let r=t(e),i=t(n);return r===i?e.localeCompare(n):r-i})},[R,H,j,U,M]),we=n(()=>{let e=new Map,t=e=>g[e]?.label??e.charAt(0).toUpperCase()+e.slice(1);for(let n of H)e.set(n,t(n));for(let n of M??[])e.has(n.tabId)||e.set(n.tabId,t(n.tabId));for(let t of j??[])e.set(t.id,t.label);for(let[t,n]of Object.entries(D??{}))e.set(t,n);return e},[H,j,M,D]),G=he===void 0?xe:he,K=R?G&&W.includes(G)?G:W[0]??null:null,Te=e=>{Se(e),ge?.(e)},Ee=K!==null&&U.has(K),q=R?K&&!Ee?K:void 0:O,{data:De}=ee(void 0),Oe=n(()=>{let e=new Map;for(let t of De??[]){let n=t.manifest?.id;if(!n)continue;let r=t.manifest?.name??t.manifest?.packageDisplayName??n;e.set(n,r)}return e},[De]),J=t(new Map),Y=n(()=>{let e=x?new Set(x):null,t=S?new Set(S):null,n=n=>!(e!==null&&!e.has(n)||t!==null&&t.has(n)),r=[];for(let e of B){if(!e.data)continue;e.data.result!==null&&J.current.set(e.data.addonId,{result:e.data.result,keyTargets:e.data.keyTargets});let t=J.current.get(e.data.addonId)??null;if(t===null)continue;let{result:i,keyTargets:a}=t,{schema:o,values:s}=fe(i),c={...C===void 0?{}:{fieldKeys:C},...w===void 0?{}:{omitFieldKeys:w},...T===void 0?{}:{hideSectionChrome:T},...E===void 0?{}:{tabAliases:E}},l=se(o.sections.filter(e=>n(e.id)),c);if(l.length===0)continue;let u={...i,sections:se(i.sections.filter(e=>n(e.id)),c)},d={...o,sections:l};r.push({addonId:e.data.addonId,schemaWithValues:u,schema:d,serverValues:s,keyTargets:a})}return r},[V,x,S,C,w,T,E]),ke=n(()=>B.flatMap(e=>c===`global`&&e.data!==void 0&&e.data.result===null&&!J.current.has(e.data.addonId)?[e.data.addonId]:[]),[V,c]),[X,Ae]=s(new Map),je=r(e=>{Ae(t=>{let n=new Map(t);return n.set(e.addonId,e),n})},[]),Z=t(new Map),Me=r(e=>t=>{t?Z.current.set(e,t):Z.current.delete(e)},[]),Q=r(async(e,t)=>{if(c!==`global`){await ve.mutateAsync({addonId:e,deviceId:u,nodeId:z,patch:t});return}let{groups:n,unowned:r}=de(t,Y.find(t=>t.addonId===e)?.keyTargets??{});if(r.length>0)throw Error(`${e}: no scoped setting declares ${r.join(`, `)}`);let i=(await Promise.allSettled(n.map(t=>_e.mutateAsync({addonId:e,cap:t.cap,scope:t.scope,...t.scope===`node`?{nodeId:z}:{},patch:t.patch})))).flatMap((e,t)=>{let r=n[t];if(e.status!==`rejected`||r===void 0)return[];let i=e.reason instanceof Error?e.reason.message:String(e.reason);return[`${r.cap}/${r.scope}: ${i}`]});if(i.length>0)throw I.invalidateQueries({queryKey:[[`addonSettings`]]}),Error(`${e}: not saved to ${i.join(`; `)}`)},[c,Y,_e,ve,I,z,u]),Ne=r(async(e,t)=>{await Q(e,t),I.invalidateQueries({queryKey:[[`addonSettings`]]})},[Q,I]),Pe=r(async(e,t,n,r)=>{let i=z;try{switch(t){case`reprobe-hwaccel`:await ye.mutateAsync({nodeId:i}),I.invalidateQueries({queryKey:[[`addonSettings`]]});return;case`reprobe-audio-engine`:await be.mutateAsync({nodeId:i}),I.invalidateQueries({queryKey:[[`addonSettings`]]});return;default:{let n=await L.addons.custom.mutate({addonId:e,action:t,input:r});return I.invalidateQueries({queryKey:[[`addonSettings`]]}),n}}}catch(n){throw console.error(`[NodeAddonsSettingsPanel] action failed`,{addonId:e,action:t,err:n}),n}},[ye,be,z,I,L]),Fe=r((e,t)=>{Ne(e,t)},[Ne]),$=p({mutationFn:async()=>{let e=[];for(let t of Y){let n=X.get(t.addonId);!n||n.pendingKeys.length===0||e.push({addonId:t.addonId,patch:n.pendingValues})}return e.length===0?{saved:[]}:{saved:await Promise.all(e.map(async({addonId:e,patch:t})=>(await Q(e,t),e)))}},onSuccess:({saved:e})=>{for(let t of e)Z.current.get(t)?.discard();I.invalidateQueries({queryKey:[[`addonSettings`]]})}}),Ie=r(()=>{for(let e of Z.current.values())e.discard()},[]),Le=n(()=>{let e=0;for(let t of Y){let n=X.get(t.addonId);n&&(e+=n.pendingKeys.length)}return e},[Y,X]),Re=n(()=>{let e=new Map;for(let t of Y){let n=X.get(t.addonId);if(!n||n.pendingKeys.length===0)continue;let r=new Set(n.pendingKeys);for(let n of t.schema.sections){let t=n.tab??`general`;for(let i of n.fields)`key`in i&&r.has(i.key)&&e.set(t,(e.get(t)??0)+1)}}return e},[Y,X]);if(Ce)return i(`div`,{className:`h-24 rounded-lg border border-border bg-surface animate-pulse`});let ze=K&&Ee?U.get(K):void 0,Be=ke.length>0?i(`div`,{className:`space-y-1 text-[11px] text-foreground-subtle`,role:`status`,children:ke.map(e=>i(`div`,{children:F(`settings.nodeAddonsSettingsPanel.addonUnavailable`,`{{name}} not available.`,{name:Oe.get(e)??e})},e))}):null;if(!R&&Y.length===0)return Be===null?i(`div`,{className:`text-[11px] text-foreground-subtle italic`,children:A??F(`settings.nodeAddonsSettingsPanel.noAddonsIn`,{scope:o.length>0?`[${o.join(`, `)}]`:F(`settings.nodeAddonsSettingsPanel.theCurrentSelection`,`the current selection`),level:c})}):Be;let Ve=$.isPending;return e(`div`,{className:`space-y-4`,children:[(N||P)&&e(`div`,{className:`border-b border-border pb-2`,children:[N&&i(`h2`,{className:`text-sm font-semibold text-foreground`,children:N}),P&&i(`p`,{className:`text-[11px] text-foreground-subtle mt-0.5`,children:P})]}),Y.length>0||R?Be:null,R&&i(ie,{tabs:W.map(e=>({id:e,label:we.get(e)??e})),activeId:K,onChange:Te,pendingByTab:Re}),$.isError&&e(`div`,{className:`rounded-md border border-red-500/40 bg-red-500/10 px-3 py-2 text-[11px] text-red-400`,children:[F(`settings.nodeAddonsSettingsPanel.saveFailed`,`Save failed:`),` `,String($.error?.message??$.error)]}),i(y,{tabKey:ze?`extra:${K??``}`:`tab:${K??``}`,children:ze?ze.content:(()=>{let t=q?Y.reduce((e,t)=>e+t.schemaWithValues.sections.filter(e=>(e.tab??`general`)===q).length,0):0,n=!!q&&t<=1,r=Y.map(e=>({...e,renderedWithValues:{...e.schemaWithValues,sections:e.schemaWithValues.sections.filter(e=>q?(e.tab??`general`)===q:!0).map(e=>n?{...e,title:``,description:void 0}:e)}})).filter(e=>e.renderedWithValues.sections.length>0).toSorted((e,t)=>{let n=e=>{let t=1/0;for(let n of e)typeof n.order==`number`&&n.order<t&&(t=n.order);return t},r=n(e.renderedWithValues.sections),i=n(t.renderedWithValues.sections);return r===i?0:r-i}),a=(M??[]).filter(e=>e.tabId===q),o=a.filter(e=>(e.placement??`before`)===`before`),s=a.filter(e=>e.placement===`after`);return r.length===0&&a.length===0?i(`div`,{className:`text-[11px] text-foreground-subtle italic`,children:A??F(`settings.nodeAddonsSettingsPanel.nothingToConfigureHereFor`,`Nothing to configure here for this node.`)}):e(`div`,{className:`space-y-6`,children:[o.map((e,t)=>i(`div`,{children:e.content},`extra-before-${t}`)),r.length>0&&i(pe,{entries:r,paneStates:X,displayNames:Oe,disabled:Ve,setPaneRef:Me,onPaneStateChange:je,onImmediateSave:Fe,onAction:Pe,inline:R||!!O}),s.map((e,t)=>i(`div`,{children:e.content},`extra-after-${t}`))]})})()}),!Ce&&i(ae,{pendingCount:Le,onSave:()=>$.mutate(),onDiscard:Ie,saving:Ve})]})}function pe({entries:t,paneStates:r,displayNames:o,disabled:c,setPaneRef:l,onPaneStateChange:u,onImmediateSave:d,onAction:f,inline:p}){let m=n(()=>[...t].toSorted((e,t)=>{let n=o.get(e.addonId)??e.addonId,r=o.get(t.addonId)??t.addonId;return n.localeCompare(r)}),[t,o]),[h,g]=s(m[0]?.addonId??``);a(()=>{m.length!==0&&(m.find(e=>e.addonId===h)||g(m[0].addonId))},[m,h]);let _=m.find(e=>e.addonId===h)??m[0];if(!_)return null;let v=n(()=>f?(e,t,n,r)=>f(e,t,n,r):void 0,[f]),y=e=>i(C,{ref:l(e.addonId),addonId:e.addonId,schema:e.renderedWithValues,serverValues:e.serverValues,onImmediateSave:d,onStateChange:u,onAction:v,disabled:c},e.addonId);return m.length===1||p?i(`div`,{className:`flex flex-col gap-4`,children:m.map(y)}):e(`div`,{className:`flex flex-col gap-3`,children:[i(`div`,{className:`flex flex-wrap items-center gap-1 border-b border-border shrink-0`,children:m.map(t=>{let n=o.get(t.addonId)??t.addonId,a=t.addonId===_.addonId,s=(r.get(t.addonId)?.pendingKeys.length??0)>0;return e(b,{variant:`unstyled`,type:`button`,onClick:()=>g(t.addonId),className:`relative px-3 py-1.5 text-xs font-medium rounded-t-md transition-colors -mb-px border-b-2 whitespace-nowrap ${a?`text-primary border-primary bg-primary/5`:`text-foreground-subtle border-transparent hover:text-foreground hover:bg-surface-hover`}`,children:[n,s&&i(`span`,{className:`ml-1.5 inline-flex h-1.5 w-1.5 rounded-full bg-amber-400`})]},t.addonId)})}),i(`div`,{className:`space-y-2`,children:m.map(e=>i(`div`,{style:e.addonId===_.addonId?void 0:{display:`none`},children:y(e)},e.addonId))})]})}export{A as t};