@camstack/addon-admin-ui 1.2.482 → 1.2.484

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 (142) hide show
  1. package/dist/assets/{AddonAssetIcon-5z0Vljts.js → AddonAssetIcon-3vq-0y-v.js} +1 -1
  2. package/dist/assets/Addons-Bk1BZHnK.js +5 -0
  3. package/dist/assets/{AdminPage-BGeHUp9l.js → AdminPage-QmLz5qjj.js} +1 -1
  4. package/dist/assets/{AdminSectionedPage-DDyHO_ip.js → AdminSectionedPage-DYCbg6TR.js} +1 -1
  5. package/dist/assets/AiProfiles-ZWSpLyRc.js +3 -0
  6. package/dist/assets/{BrokerForm-B2kpU1t2.js → BrokerForm-C0PFW-8b.js} +1 -1
  7. package/dist/assets/Build-Dnm_I3D9.js +40 -0
  8. package/dist/assets/{Calendars-iNmeiE9F.js → Calendars-DvjofwPU.js} +1 -1
  9. package/dist/assets/{Cluster-VomkBaK2.js → Cluster-CrfYNPnJ.js} +1 -1
  10. package/dist/assets/{CompositionBlockEditor-BkEr_zwe.js → CompositionBlockEditor-BcDYEyOm.js} +1 -1
  11. package/dist/assets/{CompositionEditorPage-DbJxXBa9.js → CompositionEditorPage-DpKcmhYi.js} +1 -1
  12. package/dist/assets/Data-BqyCS1VW.js +2 -0
  13. package/dist/assets/DeviceDetail-DfLnQGqY.js +2 -0
  14. package/dist/assets/{DeviceDoActionFields-CLGT6wrU.js → DeviceDoActionFields-CJj4-67I.js} +1 -1
  15. package/dist/assets/{Devices-CeNeFo6w.js → Devices-DQnrgH0r.js} +1 -1
  16. package/dist/assets/{EmbedPlayerPage-DhPeEblh.js → EmbedPlayerPage-D6aNp4TG.js} +1 -1
  17. package/dist/assets/HelperWizard-BM-npSft.js +2 -0
  18. package/dist/assets/History-DZ_p9s8N.js +1 -0
  19. package/dist/assets/Identity-B-pYFi7F.js +1 -0
  20. package/dist/assets/IntegrationDetail-CvtkeTns.js +1 -0
  21. package/dist/assets/{IntegrationHub-C0mqR6_4.js → IntegrationHub-Crv-Ut8D.js} +1 -1
  22. package/dist/assets/Integrations-BpVqgjFG.js +1 -0
  23. package/dist/assets/Integrations-tTRZOlex.js +1 -0
  24. package/dist/assets/Library-BFFl1PFs.js +1 -0
  25. package/dist/assets/Locations-sD9PMtF8.js +3 -0
  26. package/dist/assets/{Logs-Bdustfdg.js → Logs-ByKgDjzR.js} +1 -1
  27. package/dist/assets/{MaskShapeCanvas-Tcd9Y5RA.js → MaskShapeCanvas-CzHUGkc7.js} +1 -1
  28. package/dist/assets/{MotionZonesSettings-CRoT6tmj.js → MotionZonesSettings-sCDWBSMu.js} +1 -1
  29. package/dist/assets/MyAccess-_FlzEnLb.js +2 -0
  30. package/dist/assets/Network-U-uppn3V.js +1 -0
  31. package/dist/assets/NodeAddonsSettingsPanel-DOuw1uWS.js +1 -0
  32. package/dist/assets/Notifications-AkbB0Ya7.js +1 -0
  33. package/dist/assets/Pipeline-CMwJb0kX.js +1 -0
  34. package/dist/assets/{PrivacyMaskSettings-D5ozyRW7.js → PrivacyMaskSettings-DH3PZaEy.js} +1 -1
  35. package/dist/assets/Recordings-BJVAQK7Q.js +1 -0
  36. package/dist/assets/{ScanNetworkModal-tiMZttK7.js → ScanNetworkModal-qjbQd1Q4.js} +1 -1
  37. package/dist/assets/{SceneMonitorEditor-CrwhZjau.js → SceneMonitorEditor-CLWf6Z9-.js} +1 -1
  38. package/dist/assets/SessionsList-DSaSTSfg.js +2 -0
  39. package/dist/assets/{Showroom-BuzmfCLW.js → Showroom-yf_2TnT8.js} +1 -1
  40. package/dist/assets/System-BKoiOnT6.js +1 -0
  41. package/dist/assets/{Terminal-BxmZLjAl.js → Terminal-CGMRAh-D.js} +3 -3
  42. package/dist/assets/{Viewer-DKhlTfCg.js → Viewer-CTvuCeo6.js} +1 -1
  43. package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-ChRFbBue.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-DAW63rZZ.js} +1 -1
  44. package/dist/assets/{addon-icons-context-DY_rAsap.js → addon-icons-context-Bzdujcmt.js} +1 -1
  45. package/dist/assets/{archive-W1ZaOIy6.js → archive-dvL2Bchb.js} +1 -1
  46. package/dist/assets/{assignment-candidates-BpQXQnWA.js → assignment-candidates-Zc8Nwi6m.js} +1 -1
  47. package/dist/assets/{authed-media-vxjhgNZq.js → authed-media-B6hJJcft.js} +1 -1
  48. package/dist/assets/{bell-off-BpuHdEmA.js → bell-off-C3flB_OF.js} +1 -1
  49. package/dist/assets/{board-model-BpmGz42d.js → board-model-h3RS4HY8.js} +1 -1
  50. package/dist/assets/{boxes-BP6lUc_5.js → boxes-BiMbpzNh.js} +1 -1
  51. package/dist/assets/chart-column-BMpUb2lF.js +1 -0
  52. package/dist/assets/circle-slash-B8Tjloe5.js +1 -0
  53. package/dist/assets/client-Ct1F5MoE.js +358 -0
  54. package/dist/assets/{cloud-upload-ARBEZ-Y1.js → cloud-upload-CAJgV_u1.js} +1 -1
  55. package/dist/assets/crop-CS-td_0y.js +1 -0
  56. package/dist/assets/{device-integration-icon-CPDmGsoD.js → device-integration-icon-DukkUZAm.js} +1 -1
  57. package/dist/assets/device-picker-model-P-UzQOB7.js +1 -0
  58. package/dist/assets/dist-B89wGMMB.js +358 -0
  59. package/dist/assets/{dist-B2eSaq-o.js → dist-CPp8d_RN.js} +1 -1
  60. package/dist/assets/{eraser-C0EhIwNf.js → eraser-BL6nSeLQ.js} +1 -1
  61. package/dist/assets/{format-D4oZ2Oti.js → format-ChtZgmyh.js} +1 -1
  62. package/dist/assets/{hard-drive-download-CrDu4V4S.js → hard-drive-download-ysGKYLwW.js} +1 -1
  63. package/dist/assets/{hostInit-DVizgo6V.js → hostInit-CDPK_pyj.js} +1 -1
  64. package/dist/assets/i18n-DJ4egBMY.js +1 -0
  65. package/dist/assets/icons-B7uNvSe0.js +1 -0
  66. package/dist/assets/index-hKEeWkm1.js +4 -0
  67. package/dist/assets/{key-round-Dh6fcJDV.js → key-round-BDT5O9Ed.js} +1 -1
  68. package/dist/assets/{key-BSKPngWG.js → key-xS-HUgNI.js} +1 -1
  69. package/dist/assets/{layers-khG7TS-L.js → layers-BeRWYCde.js} +1 -1
  70. package/dist/assets/{linked-devices-model-Cnqr55pr.js → linked-devices-model-DOZONZiM.js} +1 -1
  71. package/dist/assets/{list-ordered-B5DA6_oa.js → list-ordered-DKzGLPr6.js} +1 -1
  72. package/dist/assets/location-owned-usage-BxmUSyXj.js +1 -0
  73. package/dist/assets/{log-in-CoYLZEi7.js → log-in-53JDrQ-P.js} +1 -1
  74. package/dist/assets/{memory-stick-MOirwg5Y.js → memory-stick-B9PVELyF.js} +1 -1
  75. package/dist/assets/{message-square-plus-CEVi2ZAP.js → message-square-plus-B32IU45x.js} +1 -1
  76. package/dist/assets/{mf-entry-bootstrap-0-be603f7b.js → mf-entry-bootstrap-0-65d35510.js} +2 -2
  77. package/dist/assets/{mic-off-Cilr4Bli.js → mic-off-B0w-1GrV.js} +1 -1
  78. package/dist/assets/{monitor-off-DLVIYtnd.js → monitor-off-Cz2SxBVE.js} +1 -1
  79. package/dist/assets/{monitor-smartphone-TMWTIuue.js → monitor-smartphone-Cqk6Z8Hg.js} +1 -1
  80. package/dist/assets/mount-P-UzQOB7.js +1 -0
  81. package/dist/assets/{player-overlays-By2E2OWX.js → player-overlays-Cs6l33cj.js} +1 -1
  82. package/dist/assets/{recycle-DSYCQWpK.js → recycle-DpB4QxbX.js} +1 -1
  83. package/dist/assets/remoteEntry-BGbchE1L.js +1 -0
  84. package/dist/assets/{scan-eye-qMn599c3.js → scan-eye-DcYrgFOu.js} +1 -1
  85. package/dist/assets/{scissors-DzKs5SeF.js → scissors-_j_D3ONm.js} +1 -1
  86. package/dist/assets/{search-x-0pY78yhl.js → search-x-9dPd-b95.js} +1 -1
  87. package/dist/assets/{send-x-DGZeSf.js → send-D42ODbS7.js} +1 -1
  88. package/dist/assets/{settings-2-CBTEttT3.js → settings-2-zgGmo4c8.js} +1 -1
  89. package/dist/assets/{speaker-EkvC7jK4.js → speaker-DIPHxIQ6.js} +1 -1
  90. package/dist/assets/src-DFzrn-CX.js +67 -0
  91. package/dist/assets/{step-inspector-model-BvwTAgYG.js → step-inspector-model-CS79liRv.js} +1 -1
  92. package/dist/assets/{table-2-Ctei20ip.js → table-2-lftK0wHb.js} +1 -1
  93. package/dist/assets/{timer-reset-CVElL395.js → timer-reset-catAE_r9.js} +1 -1
  94. package/dist/assets/{ungroup-B8d2LiRM.js → ungroup-BKImeHER.js} +1 -1
  95. package/dist/assets/{unlink-DcYhq2lS.js → unlink-Behl018w.js} +1 -1
  96. package/dist/assets/{usb-hziv0KIU.js → usb-D5kzB8kq.js} +1 -1
  97. package/dist/assets/{use-scenes-feed-16-Xn-4f.js → use-scenes-feed-CGDnep25.js} +1 -1
  98. package/dist/assets/{use-stationary-objects-Dfi4P7en.js → use-stationary-objects-D_R5OahX.js} +1 -1
  99. package/dist/assets/useEventInvalidation-P-UzQOB7.js +1 -0
  100. package/dist/assets/{useNodeUrlSelection-C6820-b7.js → useNodeUrlSelection-PBAYjRo5.js} +1 -1
  101. package/dist/assets/user-round-BJVl6LX9.js +1 -0
  102. package/dist/assets/{user-x-B7WeA-ce.js → user-x-COQ6vhb4.js} +1 -1
  103. package/dist/assets/{video-DKRf0Ic4.js → video-Byw3ItoR.js} +1 -1
  104. package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-D6C0Wijv.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-CsFmgfi4.js} +2 -2
  105. package/dist/index.html +9 -9
  106. package/dist/server/addon.js +274 -29
  107. package/package.json +1 -1
  108. package/dist/assets/Addons-CZCGnQMQ.js +0 -5
  109. package/dist/assets/AiProfiles--zkaLy_B.js +0 -3
  110. package/dist/assets/Build-rWgY-SZM.js +0 -40
  111. package/dist/assets/Data-CCEKKeDE.js +0 -2
  112. package/dist/assets/DeviceDetail-D9LiDoGw.js +0 -2
  113. package/dist/assets/HelperWizard-Uk1HvQ9Z.js +0 -2
  114. package/dist/assets/History-BSXemVAg.js +0 -1
  115. package/dist/assets/Identity-DUUQUaLn.js +0 -1
  116. package/dist/assets/IntegrationDetail-Cg5a23zE.js +0 -1
  117. package/dist/assets/Integrations-B7G_Cpwv.js +0 -1
  118. package/dist/assets/Integrations-J8r1M--P.js +0 -1
  119. package/dist/assets/Library-B32BJFM3.js +0 -1
  120. package/dist/assets/Locations-qBrWJ5eA.js +0 -3
  121. package/dist/assets/MyAccess-BkcUaVmh.js +0 -2
  122. package/dist/assets/Network-BrDFqhC5.js +0 -1
  123. package/dist/assets/NodeAddonsSettingsPanel-DsSbHT51.js +0 -1
  124. package/dist/assets/Notifications-BPK2WNL-.js +0 -1
  125. package/dist/assets/Pipeline-CNlBiPEC.js +0 -1
  126. package/dist/assets/Recordings-BrCuLKqt.js +0 -1
  127. package/dist/assets/SessionsList-fLonifFr.js +0 -2
  128. package/dist/assets/System-B5axMnbq.js +0 -1
  129. package/dist/assets/circle-slash-C9MZOlOA.js +0 -1
  130. package/dist/assets/client-COfGFdJB.js +0 -358
  131. package/dist/assets/crop-CcnscEEp.js +0 -1
  132. package/dist/assets/device-picker-model-Z8NhIJHV.js +0 -1
  133. package/dist/assets/dist-Cwk0eIEi.js +0 -358
  134. package/dist/assets/i18n-DRa6-1Ye.js +0 -1
  135. package/dist/assets/icons-DanAyxOR.js +0 -1
  136. package/dist/assets/index-BO95XcLa.js +0 -4
  137. package/dist/assets/location-owned-usage-pJJy4BTC.js +0 -1
  138. package/dist/assets/mount-Z8NhIJHV.js +0 -1
  139. package/dist/assets/remoteEntry-ClU628tf.js +0 -1
  140. package/dist/assets/src-BZ8j9Q2T.js +0 -67
  141. package/dist/assets/useEventInvalidation-Z8NhIJHV.js +0 -1
  142. package/dist/assets/user-round-BrkQjamf.js +0 -1
@@ -0,0 +1 @@
1
+ import{C as e,J as t,K as n,R as r,S as i,V as a,Y as o,et as s,o as c}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{An as l,Br as u,Ci as d,Lt as f,Pt as p,Si as m,Zi as h,bi as g,ca as _,ci as v,dn as y,dt as b,ht as x,mi as S,mn as ee,ot as C,sr as w,wn as te,xn as T,yn as E,zr as D}from"./player-overlays-Cs6l33cj.js";import{Yi as ne}from"./client-Ct1F5MoE.js";import{t as O}from"./search-x-9dPd-b95.js";import{Ao as k,At as re,Cs as A,En as ie,Er as j,Gn as M,Ii as N,Mo as P,Nt as ae,Sa as F,So as I,Un as L,Yo as R,_i as z,_o as B,_r as V,_s as H,ba as U,bd as W,bs as oe,co as G,ei as K,eo as se,fr as q,gn as ce,gr as J,gs as le,io as ue,jt as de,ld as Y,lo as fe,mo as pe,mr as me,no as he,oo as ge,or as _e,po as ve,pr as ye,ro as X,tn as be,to as xe,va as Se,vi as Ce,vr as we,vs as Te,wd as Ee,xs as De,ys as Oe}from"./src-DFzrn-CX.js";import{t as Z}from"./useTranslation-BJr-n0es.js";import{n as ke}from"./addon-icons-context-Bzdujcmt.js";import{P as Ae,hr as je,lr as Me,mr as Ne,pr as Pe}from"./index-hKEeWkm1.js";import{t as Fe}from"./device-integration-icon-DukkUZAm.js";import{i as Ie,r as Le,t as Re}from"./ScanNetworkModal-qjbQd1Q4.js";import{t as ze}from"./NodeAddonsSettingsPanel-DOuw1uWS.js";s();function Be(e){let t=[];for(let n of e)n.type===`probe`&&t.push(n.key),n.type===`group`&&`fields`in n&&t.push(...Be(n.fields));return t}function Ve(e,t,i){let[a,s]=o(`idle`),[c,l]=o({}),u=n(()=>{let t=[];for(let n of e.sections)t.push(...Be(n.fields));return t},[e]),d=u.length>0&&i!==void 0,f=r(e=>{l(t=>{if(!t[e])return t;let n={...t};return delete n[e],n})},[]);return{testAllStatus:a,hasProbeFields:d,probeResults:c,handleTestAll:r(async()=>{if(!i)return;let e=u.filter(e=>{let n=t[e];return n!=null&&String(n).trim()!==``});if(e.length===0)return;s(`testing`);let n={};for(let t of e)n[t]={status:`probing`};l(n);let r=await Promise.allSettled(e.map(async e=>{try{return{key:e,result:await i(e,t[e])}}catch(t){return{key:e,result:{status:`error`,error:t instanceof Error?t.message:String(t)}}}})),a={};for(let e of r)if(e.status===`fulfilled`){let{key:t,result:n}=e.value;a[t]={status:n.status===`ok`?`ok`:`error`,result:n}}l(a),s(`idle`)},[i,u,t]),clearProbeResult:f}}s();function Q(e){let t=[];for(let n of e)`required`in n&&n.required===!0&&`key`in n&&n.key&&t.push(n.key),n.type===`group`&&`fields`in n&&t.push(...Q(n.fields));return t}function He(e){return e==null?!0:typeof e==`string`?e.trim()===``:!1}function Ue(e,t={}){for(let n of e){if(n.type===`group`&&`fields`in n){Ue(n.fields,t);continue}`key`in n&&n.key&&`default`in n&&n.default!==void 0&&(t[n.key]=n.default)}return t}function $(){return typeof crypto<`u`&&typeof crypto.randomUUID==`function`?`probe-${crypto.randomUUID()}`:`probe-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function We({open:t,integrationId:s,addonId:l,onClose:u}){let{t:d}=Z(),f=c(),[h,g]=o({}),[_,v]=o(!1),[y,S]=o(null),[C,te]=o($),T=k({addonId:l},{enabled:t}),E=T.data?.deviceType??null,D=B({addonId:l,type:E??ne.Camera},{enabled:t&&T.isSuccess&&E!==null}),O=D.data??null;a(()=>{t&&(g(O?Ue(O.sections.flatMap(e=>e.fields)):{}),te($()),v(!1),S(null))},[t,s,O]);let re=n(()=>({...h,_probeRequestId:C}),[h,C]),A=G({onSuccess:()=>{f.invalidateQueries({queryKey:[[`deviceManager`]]})}}),ie=R(),j=r(async(e,t)=>{v(!0);let n=await ie.mutateAsync({addonId:l,type:E??ne.Camera,key:e,value:t,formValues:re});return n.status===`ok`&&n.suggestedValues&&g(e=>{let t=!1,r={...e};for(let[i,a]of Object.entries(n.suggestedValues??{}))He(e[i])&&!He(a)&&(r[i]=a,t=!0);return t?r:e}),n},[ie,l,re,E]),{testAllStatus:M,hasProbeFields:N,probeResults:P,handleTestAll:ae,clearProbeResult:F}=Ve(O??{sections:[]},h,j);async function I(e){S(null);try{await A.mutateAsync({addonId:l,type:E??ne.Camera,config:h,integrationId:s}),e?g(O?Ue(O.sections.flatMap(e=>e.fields)):{}):u()}catch(e){S(e instanceof Error?e.message:String(e))}}if(!t)return null;let L=Q((O?.sections??[]).flatMap(e=>e.fields)).filter(e=>He(h[e])),z=L.length===0,V=T.isLoading||E!==null&&D.isLoading,H=T.isError||T.isSuccess&&E===null||D.isError||D.isSuccess&&O===null;return e(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center`,children:[i(`div`,{className:`absolute inset-0 bg-black/60`,onClick:u}),e(`div`,{className:`relative z-10 flex w-full max-w-2xl flex-col max-h-[calc(90dvh-2*max(env(safe-area-inset-top),env(safe-area-inset-bottom)))] rounded-xl border border-border bg-background shadow-2xl`,children:[e(`div`,{className:`flex items-center justify-between border-b border-border px-5 py-4 shrink-0`,children:[i(`h2`,{className:`text-sm font-semibold text-foreground`,children:d(`integrations.addDevice`)}),i(`button`,{onClick:u,className:`rounded-md p-1 text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,children:i(b,{className:`h-4 w-4`})})]}),i(`div`,{className:`flex-1 min-h-0 overflow-y-auto px-5 py-4 space-y-3`,children:V?i(`div`,{className:`flex items-center justify-center py-8`,children:i(w,{className:`h-5 w-5 animate-spin text-primary`})}):H?e(`div`,{className:`flex items-start gap-3 rounded-lg border border-destructive/40 bg-destructive/10 px-4 py-3`,children:[i(p,{className:`h-4 w-4 text-destructive mt-0.5 shrink-0`}),e(`div`,{className:`space-y-1`,children:[i(`p`,{className:`text-xs font-medium text-destructive`,children:d(`integrations.addDeviceDialog.providerUnavailable`,`Provider unavailable`)}),i(`p`,{className:`text-xs text-foreground-subtle`,children:i(Me,{i18nKey:`integrations.addDeviceDialog.notReady`,values:{addonId:l},components:{mono:i(`span`,{className:`font-mono`})}})})]})]}):i(Ae,{schema:O,values:h,onChange:g,onTestField:j,probeResults:P,onClearProbe:F})}),!H&&!V&&e(`div`,{className:`border-t border-border bg-surface/50 shrink-0`,children:[e(`button`,{type:`button`,onClick:()=>v(e=>!e),className:`flex w-full items-center justify-between px-5 py-2 text-[11px] text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,children:[e(`span`,{className:`flex items-center gap-2`,children:[i(ee,{className:`h-3.5 w-3.5`}),d(`integrations.addDeviceDialog.testLogs`,`Test logs`),i(`span`,{className:`font-mono text-[9px] opacity-60`,children:C.slice(0,14)})]}),i(m,{className:`h-3.5 w-3.5 transition-transform ${_?`rotate-180`:``}`})]}),_&&i(`div`,{className:`border-t border-border max-h-64 overflow-hidden`,children:i(be,{addonId:l,requestId:C,limit:50,maxHeight:`max-h-64`,showFilters:!1,showScope:!1,className:`border-0 rounded-none`})})]}),!H&&!V&&(y||L.length>0)&&i(`div`,{className:`border-t border-destructive/30 bg-destructive/5 px-5 py-2 shrink-0`,children:e(`div`,{className:`flex items-start gap-2`,children:[i(p,{className:`h-3.5 w-3.5 text-destructive mt-0.5 shrink-0`}),i(`p`,{className:`text-[11px] text-destructive`,children:y||d(`integrations.addDeviceDialog.required`,`Required: {{value1}}`,{value1:L.join(`, `)})})]})}),e(`div`,{className:`flex items-center justify-between border-t border-border px-5 py-3 shrink-0`,children:[e(`div`,{className:`flex items-center gap-2`,children:[i(`button`,{onClick:u,className:`rounded-lg border border-border px-3 py-1.5 text-xs text-foreground-subtle hover:text-foreground transition-colors`,children:d(`integrations.cancel`)}),!H&&N&&e(`button`,{type:`button`,onClick:ae,disabled:M===`testing`,className:`inline-flex items-center gap-1.5 rounded-lg border border-border px-3 py-1.5 text-xs font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50`,children:[M===`testing`?i(w,{className:`h-3.5 w-3.5 animate-spin`}):i(x,{className:`h-3.5 w-3.5`}),d(`integrations.addDeviceDialog.testAll`,`Test All`)]})]}),e(`div`,{className:`flex items-center gap-2`,children:[i(`button`,{onClick:()=>I(!0),disabled:H||!z||A.isPending,className:`rounded-lg border border-border px-3 py-1.5 text-xs text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50`,children:d(`integrations.saveAndNew`)}),i(`button`,{onClick:()=>I(!1),disabled:H||!z||A.isPending,className:`rounded-lg bg-primary px-4 py-1.5 text-xs font-medium text-primary-foreground shadow-sm disabled:opacity-50`,children:A.isPending?d(`integrations.saving`):d(`integrations.save`)})]})]})]})]})}s();var Ge=[`discovering`,`pase`,`commissioning`,`done`];function Ke(e){return!(typeof e!=`object`||!e||!(`phase`in e)||typeof e.phase!=`string`)}function qe(e,t){return e===`code-expired`||t?.includes(`matter-commission:code-expired`)?{key:`integrations.addMatter.failure.expired`,defaultValue:`The pairing code expired. Share the device again and paste the new code.`}:e===`device-not-found`||t?.includes(`matter-commission:device-not-found`)?{key:`integrations.addMatter.failure.notFound`,defaultValue:`No Matter device with that code was found on the network.`}:e===`wrong-code`||t?.includes(`matter-commission:wrong-code`)?{key:`integrations.addMatter.failure.wrongCode`,defaultValue:`The pairing code was rejected.`}:e===`invalid-code`||t?.includes(`invalid pairing code`)?{key:`integrations.addMatter.failure.invalid`,defaultValue:`Enter an 11-digit or 21-digit manual code, or a code that starts with MT:.`}:{key:`integrations.addMatter.failure.unknown`,defaultValue:t??`Commissioning failed.`}}function Je({onClose:t,onCommissioned:n}){let{t:r}=Z(),s=U({kind:`matter`}),c=s.data?.[0]?.id??null,l=F(),[u,d]=o(``),[f,p]=o({phase:`idle`,failure:null,message:null}),m=f.phase===`discovering`||f.phase===`pase`||f.phase===`commissioning`,h=Se({brokerId:c??``,key:`commission`},{enabled:c!==null&&m,refetchInterval:m?400:!1});a(()=>{m&&Ke(h.data)&&h.data.phase!==`idle`&&p({phase:h.data.phase,failure:typeof h.data.failure==`string`?h.data.failure:null,message:typeof h.data.message==`string`?h.data.message:null})},[m,h.data]);let g=()=>{c!==null&&(p({phase:`discovering`,failure:null,message:null}),l.mutate({brokerId:c,target:{action:`commissionNode`},payload:{pairingCode:u.trim()}},{onSuccess:()=>p({phase:`done`,failure:null,message:null}),onError:e=>{let t=e instanceof Error?e.message:`Commissioning failed.`;p({phase:`failed`,failure:t.includes(`matter-commission:`)?t.split(`matter-commission:`)[1]?.split(`:`)[0]??`unknown`:t.includes(`invalid pairing code`)?`invalid-code`:`unknown`,message:t})}}))},_=f.phase===`failed`?qe(f.failure,f.message):null,v=_===null?null:r(_.key,{defaultValue:_.defaultValue}),y=(s.isSuccess===!0||s.data!==void 0)&&c===null;return i(q,{open:!0,onOpenChange:e=>!e&&t(),children:e(me,{width:`md`,placement:`sheet-on-mobile`,scroll:`body`,children:[i(V,{children:i(we,{children:r(`integrations.addMatter.title`,{defaultValue:`Add Matter device`})})}),e(ye,{className:`space-y-4`,children:[i(`p`,{className:`text-xs text-foreground-subtle`,children:r(`integrations.addMatter.help`,{defaultValue:`In Home Assistant, open the device and choose Share device. Paste the numeric code or the MT: code here. The device stays in Home Assistant.`})}),y?i(j,{message:r(`integrations.addMatter.noBroker`,{defaultValue:`Create the Matter fabric from this integration’s settings first.`})}):e(`div`,{className:`space-y-1.5`,children:[i(M,{htmlFor:`matter-pairing-code`,children:r(`integrations.addMatter.code`,{defaultValue:`Pairing code`})}),i(Y,{id:`matter-pairing-code`,value:u,autoComplete:`off`,spellCheck:!1,placeholder:`34970112332`,disabled:m||f.phase===`done`,onChange:e=>d(e.target.value)})]}),f.phase!==`idle`&&i(`ol`,{className:`space-y-1`,"aria-label":r(`integrations.addMatter.progress`,{defaultValue:`Commissioning progress`}),children:Ge.map(t=>{let n=f.phase===t;return e(`li`,{className:`text-xs ${n?`text-foreground font-medium`:`text-foreground-subtle`}`,children:[n&&m?i(w,{className:`mr-1 inline h-3 w-3 animate-spin`}):null,r(`integrations.addMatter.phase.${t}`,{defaultValue:t===`discovering`?`Discovering`:t===`pase`?`PASE`:t===`commissioning`?`Commissioning`:`Done`})]},t)})}),v!==null&&i(j,{message:v})]}),e(J,{children:[i(K,{variant:`ghost`,size:`sm`,onClick:t,children:r(`common.close`,{defaultValue:`Close`})}),f.phase===`done`?i(K,{size:`sm`,onClick:n,children:r(`integrations.adoptDevices`,{defaultValue:`Adopt devices`})}):i(K,{size:`sm`,disabled:m||y||u.trim().length===0,onClick:g,children:m?r(`integrations.addMatter.working`,{defaultValue:`Adding…`}):r(`integrations.addMatter.submit`,{defaultValue:`Add device`})})]})]})})}var Ye=1500;function Xe({addonId:t,integrationId:n,jobId:r,onFinished:a}){let{t:o}=Z(),s=se(),c=(X({addonId:t,integrationId:n},{refetchInterval:e=>(e.state.data??[]).some(e=>e.state===`running`)?Ye:!1}).data??[]).find(e=>e.jobId===r);if(!c)return null;let l=c.state===`running`,u=c.processed,d=c.total>0?Math.round(u/c.total*100):0;!l&&c.finishedAt!==null&&a();let f=[`${u}/${c.total} ${o(`integrations.adoptJobProcessed`,{defaultValue:`processed`})}`];c.adopted>0&&f.push(`${c.adopted} ${o(`integrations.adoptJobAdded`,{defaultValue:`added`})}`),c.alreadyAdopted>0&&f.push(`${c.alreadyAdopted} ${o(`integrations.adoptJobSkipped`,{defaultValue:`already there`})}`),c.failed>0&&f.push(`${c.failed} ${o(`integrations.adoptJobFailed`,{defaultValue:`failed`})}`);let m=f.join(` · `);return e(`div`,{className:`border-t border-border px-5 py-3 shrink-0 space-y-2`,children:[e(`div`,{className:`flex items-center gap-2`,children:[l?i(w,{className:`h-3.5 w-3.5 animate-spin text-primary shrink-0`}):c.failed>0?i(p,{className:`h-3.5 w-3.5 text-destructive shrink-0`}):c.state===`cancelled`?i(v,{className:`h-3.5 w-3.5 text-foreground-subtle shrink-0`}):i(S,{className:`h-3.5 w-3.5 text-primary shrink-0`}),i(`p`,{className:`text-[11px] text-foreground`,children:m}),l&&i(`button`,{onClick:()=>s.mutate({jobId:r}),className:`ml-auto rounded-lg border border-border px-2 py-1 text-[11px] text-foreground-subtle hover:text-foreground transition-colors`,children:o(`integrations.adoptJobCancel`,{defaultValue:`Stop`})})]}),i(`div`,{className:`h-1 w-full rounded-full bg-border overflow-hidden`,children:i(`div`,{className:`h-full bg-primary transition-all`,style:{width:`${d}%`},role:`progressbar`,"aria-valuenow":d,"aria-valuemin":0,"aria-valuemax":100})}),c.results.filter(e=>e.outcome===`failed`).slice(0,5).map(t=>e(`p`,{className:`text-[11px] text-destructive`,children:[t.childNativeId,`: `,t.error]},t.childNativeId))]})}function Ze(e){let t=e.metadata;return[e.name,e.childNativeId,t.model,t.manufacturer,t.integration,t.externalLocation].filter(e=>typeof e==`string`&&e.length>0).join(` `)}s();var Qe=`devices`;function $e(e){return{id:Qe,label:e(`integrations.adoptDevicesModal.defaultFilter`),isDefault:!0}}var et=2e4,tt=100;function nt({addonId:n,integrationId:s,onClose:l}){let u=_(),{t:f}=Z(),m=c(),[h,g]=o(new Set),[v,y]=o(new Set),[x,S]=o(new Map),[ee,C]=o(null),{data:te}=Te(),T=(te??[]).find(e=>e.addonId===n)?.supportsLocationImport??!1,[D,ne]=o(!0),O=xe({addonId:n,integrationId:s}).data?.filters,k=O&&O.length>0?O:[$e(f)],[A,ie]=o(k.find(e=>e.isDefault)?.id??(k.some(e=>e.id===Qe)?Qe:k[0].id)),j=A!==Qe,M=ue(),N=he({addonId:n,integrationId:s,page:1,pageSize:et,filter:A}),P=N.refetch,ae=M.mutate,F=r(()=>{ae({addonId:n,integrationId:s},{onSettled:()=>{P()}})},[ae,n,s,P]),I=t(null);a(()=>{let e=`${n}::${s}`;I.current===e||N.isLoading||(I.current=e,(N.data?.candidates.length??0)===0&&F())},[n,s,N.isLoading,N.data,F]);let L=M.isPending,R=M.isError?M.error instanceof Error?M.error.message:String(M.error):null,z=typeof M.data?.lastError==`string`&&M.data.lastError.length>0?M.data.lastError:null,B=N.data?.candidates??[],V=N.isError?N.error instanceof Error?N.error.message:String(N.error):null,H=ge(),[U,oe]=o(null),G=r(e=>{e.alreadyAdopted||g(t=>{let n=new Set(t);return n.has(e.childNativeId)?n.delete(e.childNativeId):n.add(e.childNativeId),n})},[]),K=r(e=>{y(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),se=r((e,t)=>{S(n=>{let r=new Map(n),i=r.get(e)?.hiddenChildIds??new Set,a=new Set(i);return a.has(t)?a.delete(t):a.add(t),a.size===0?r.delete(e):r.set(e,{hiddenChildIds:a}),r})},[]),q=r(e=>{let t={};for(let n of e){let e=x.get(n);e&&e.hiddenChildIds.size>0&&(t[n]={hiddenChildIds:[...e.hiddenChildIds]})}return Object.keys(t).length>0?t:void 0},[x]),ce=r(async()=>{C(null);let e=[...h];if(e.length!==0)try{let t=q(e),{jobId:r}=await H.mutateAsync({addonId:n,integrationId:s,filter:A,childNativeIds:e,...t?{perCandidate:t}:{},...T?{importLocations:D}:{}});oe(r),g(new Set),S(new Map)}catch(e){C(e instanceof Error?e.message:String(e))}},[h,q,H,n,s,A,T,D]),J=t(null),le=r(()=>{U===null||J.current===U||(J.current=U,P(),m.invalidateQueries({queryKey:[[`integrations`]]}),m.invalidateQueries({queryKey:[[`deviceManager`]]}))},[U,P,m]),de=r(e=>{ie(e),g(new Set),y(new Set),S(new Map),C(null)},[]),Y=h.size,fe=U!==null&&Y===0&&!H.isPending;return e(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center`,children:[i(`div`,{className:`absolute inset-0 bg-black/60`,onClick:l}),e(`div`,{className:`relative z-10 flex w-full max-w-3xl flex-col h-[85vh] rounded-xl border border-border bg-background shadow-2xl`,children:[e(`div`,{className:`flex items-center justify-between border-b border-border px-5 py-4 shrink-0`,children:[e(`div`,{className:`min-w-0`,children:[i(`h2`,{className:`text-sm font-semibold text-foreground`,children:f(`integrations.adoptDevices`,{defaultValue:`Adopt devices`})}),i(`p`,{className:`text-[11px] text-foreground-subtle mt-0.5`,children:f(`integrations.adoptDevicesHint`,{defaultValue:`Preview the candidate devices and add the ones you want.`})})]}),e(`div`,{className:`flex items-center gap-3 shrink-0`,children:[T&&e(`label`,{className:`flex items-center gap-1.5 cursor-pointer text-[11px] text-foreground-subtle hover:text-foreground transition-colors`,children:[i(`input`,{type:`checkbox`,checked:D,onChange:e=>ne(e.target.checked),className:`accent-primary`}),f(`integrations.importLocations`,{defaultValue:`Import locations from the integration`})]}),i(`button`,{onClick:l,className:`rounded-md p-1 text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,"aria-label":f(`common.close`,`Close`),children:i(b,{className:`h-4 w-4`})})]})]}),e(`div`,{className:`flex-1 min-h-0 px-5 py-3 flex flex-col gap-2 overflow-hidden`,children:[(R??V??z)&&B.length===0&&i(`div`,{className:`rounded-lg border border-destructive/30 bg-destructive/5 px-4 py-3 shrink-0`,children:e(`div`,{className:`flex items-start gap-2`,children:[i(p,{className:`h-3.5 w-3.5 text-destructive mt-0.5 shrink-0`}),e(`div`,{className:`min-w-0`,children:[i(`p`,{className:`text-xs font-medium text-destructive`,children:f(`integrations.adoptRefreshFailed`,{defaultValue:`Could not discover devices.`})}),i(`p`,{className:`text-[11px] text-destructive/90 mt-0.5`,children:R??V??z})]})]})}),k.length>1&&i(rt,{filters:k,activeFilter:A,onSelect:de}),i(`div`,{className:`flex-1 min-h-0`,children:i(re,{mode:`generic`,items:B,pageSize:tt,getKey:e=>e.childNativeId,getSearchText:Ze,getFilterType:e=>e.type,filterOptions:W(u),filterLabel:f(`integrations.adoptColType`,{defaultValue:`Type`}),isLoading:N.isLoading||L&&B.length===0,searchPlaceholder:f(`integrations.adoptSearch`,{defaultValue:`Search candidates…`}),emptyLabel:(R??V??z)&&B.length===0?``:f(`integrations.adoptNoCandidates`,{defaultValue:`No candidate devices found.`}),toolbar:e(`button`,{type:`button`,onClick:F,disabled:L,title:f(`integrations.adoptRefreshTitle`,{defaultValue:`Re-scan Home Assistant for devices`}),className:`inline-flex items-center gap-1.5 rounded-lg border border-border bg-surface px-2.5 py-1.5 text-xs text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-60 shrink-0`,children:[i(E,{className:`h-3.5 w-3.5 ${L?`animate-spin`:``}`}),f(`integrations.adoptRefresh`,{defaultValue:`Refresh`})]}),columns:[{key:`name`,header:f(`integrations.adoptColName`,{defaultValue:`Name`}),headerClassName:`w-[55%]`,cell:e=>i(it,{candidate:e,expandable:!j,expanded:v.has(e.childNativeId),onToggleExpand:()=>K(e.childNativeId),adoptedLabel:f(`integrations.adoptAlready`,{defaultValue:`Adopted`})})},{key:`type`,header:f(`integrations.adoptColType`,{defaultValue:`Type`}),headerClassName:`w-[30%] hidden sm:table-cell`,cellClassName:`hidden sm:table-cell`,cell:t=>{let n=Ee(t.type,u),r=n.icon;return e(`span`,{className:`inline-flex items-center gap-1.5 text-[10px] text-foreground-subtle`,children:[i(r,{className:`h-3.5 w-3.5 shrink-0`}),n.label]})}},{key:`select`,header:``,headerClassName:`w-[15%] text-right`,cellClassName:`text-right`,cell:e=>i(`div`,{className:`flex items-center justify-end`,children:i(`button`,{onClick:()=>G(e),disabled:e.alreadyAdopted,"aria-label":h.has(e.childNativeId)?f(`integrations.adoptDevicesModal.deselect`,`Deselect`):f(`integrations.adoptDevicesModal.select`,`Select`),className:`inline-flex h-5 w-5 items-center justify-center rounded border ${h.has(e.childNativeId)?`border-primary bg-primary`:`border-border`} ${e.alreadyAdopted?`cursor-not-allowed opacity-50`:``}`,children:h.has(e.childNativeId)&&i(d,{className:`h-3 w-3 text-primary-foreground`})})})}],isExpanded:e=>!j&&v.has(e.childNativeId),renderExpanded:j?void 0:e=>i(at,{candidate:e,hiddenChildIds:x.get(e.childNativeId)?.hiddenChildIds??new Set,onToggleChildHidden:t=>se(e.childNativeId,t)}),rowClassName:e=>e.alreadyAdopted?`opacity-60`:h.has(e.childNativeId)?`bg-primary/5`:``})})]}),ee&&i(`div`,{className:`border-t border-destructive/30 bg-destructive/5 px-5 py-2 shrink-0`,children:e(`div`,{className:`flex items-start gap-2`,children:[i(p,{className:`h-3.5 w-3.5 text-destructive mt-0.5 shrink-0`}),i(`p`,{className:`text-[11px] text-destructive`,children:ee})]})}),U!==null&&i(Xe,{addonId:n,integrationId:s,jobId:U,onFinished:le}),e(`div`,{className:`flex items-center justify-between border-t border-border px-5 py-3 shrink-0`,children:[i(`div`,{}),e(`div`,{className:`flex items-center gap-2`,children:[i(`button`,{onClick:l,className:`rounded-lg border border-border px-3 py-1.5 text-xs text-foreground-subtle hover:text-foreground transition-colors`,children:f(`integrations.cancel`,{defaultValue:`Cancel`})}),e(`button`,{onClick:fe?l:ce,disabled:!fe&&(Y===0||H.isPending),className:`inline-flex items-center gap-1.5 rounded-lg bg-primary px-4 py-1.5 text-xs font-medium text-primary-foreground shadow-sm disabled:opacity-50 disabled:cursor-not-allowed`,children:[H.isPending&&i(w,{className:`h-3.5 w-3.5 animate-spin`}),fe?f(`integrations.close`,{defaultValue:`Close`}):f(`integrations.addSelected`,{defaultValue:`Add selected`}),!fe&&Y>0?` (${Y})`:``]})]})]})]})]})}function rt({filters:e,activeFilter:t,onSelect:n}){let{t:r}=Z();return i(`div`,{role:`tablist`,"aria-label":r(`integrations.adoptDevicesModal.discoveryGranularity`,`Discovery granularity`),className:`inline-flex shrink-0 self-start rounded-lg border border-border bg-surface p-0.5`,children:e.map(e=>{let r=e.id===t;return i(`button`,{type:`button`,role:`tab`,"aria-selected":r,onClick:()=>n(e.id),className:`rounded-md px-3 py-1 text-xs font-medium transition-colors ${r?`bg-primary text-primary-foreground shadow-sm`:`text-foreground-subtle hover:text-foreground hover:bg-surface-hover`}`,children:e.label},e.id)})})}function it({candidate:t,expandable:n,expanded:r,onToggleExpand:a,adoptedLabel:o}){let{t:s}=Z(),c=(t.children??[]).length;return e(`div`,{className:`flex items-center gap-2.5 min-w-0`,children:[n&&c>0?e(`button`,{type:`button`,onClick:a,"aria-label":r?s(`integrations.adoptDevicesModal.collapse`,`Collapse`):s(`integrations.adoptDevicesModal.expand`,`Expand`),"aria-expanded":r,className:`flex h-5 flex-shrink-0 items-center justify-center gap-0.5 rounded px-0.5 text-[10px] text-foreground-subtle transition-colors hover:bg-surface-hover hover:text-foreground`,children:[i(r?m:g,{className:`h-3.5 w-3.5`}),c]}):i(`span`,{className:`flex h-5 w-5 flex-shrink-0 items-center justify-center text-foreground-subtle/40`,children:`—`}),i(`span`,{className:`truncate text-xs font-medium text-foreground`,children:t.name}),t.alreadyAdopted&&i(`span`,{className:`rounded-full bg-success/10 px-2 py-0.5 text-[9px] font-medium text-success shrink-0`,children:o})]})}function at({candidate:t,hiddenChildIds:n,onToggleChildHidden:r}){let{t:a}=Z(),o=t.children??[];return o.length===0?null:i(`div`,{className:`space-y-1 py-1`,children:o.map(t=>{let o=n.has(t.childNativeId),s=t.capabilities??[];return e(`div`,{className:`flex items-center gap-2 rounded px-2 py-1 ${o?`opacity-50`:``}`,children:[i(`span`,{className:`text-[11px] text-foreground truncate flex-1 min-w-0`,children:t.name}),s.length>0&&i(`span`,{className:`text-[9px] text-foreground-subtle truncate`,children:s.join(`, `)}),i(`button`,{onClick:()=>r(t.childNativeId),"aria-label":o?a(`integrations.adoptDevicesModal.showChild`,`Show child`):a(`integrations.adoptDevicesModal.hideChild`,`Hide child`),title:o?a(`integrations.adoptDevicesModal.showAfterAdopt`,`Show after adopt`):a(`integrations.adoptDevicesModal.hideAfterAdopt`,`Hide after adopt`),className:`flex h-5 w-5 items-center justify-center rounded text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors flex-shrink-0`,children:i(o?u:D,{className:`h-3 w-3`})})]},t.childNativeId)})})}s();function ot(e){let t=[];for(let n of e){if(n.type===`group`){t.push(...ot(n.fields));continue}`key`in n&&typeof n.key==`string`&&t.push(n.key)}return t}function st(e,t){if(!e)return{};let n=new Set(e.sections.flatMap(e=>ot(e.fields))),r={};for(let e of n)Object.prototype.hasOwnProperty.call(t,e)&&(r[e]=t[e]);return r}function ct(e){return{...e.tabs?{tabs:e.tabs}:{},sections:e.sections.map(e=>({...e,fields:e.fields.map(e=>{if(`value`in e){let{value:t,...n}=e;return n}return e})}))}}function lt({integrationId:t,addonId:r,name:a,kind:o,mode:s,brokerKind:l,canTest:u=!1,trpc:d,onClose:f}){let{t:p}=Z(),m=c(),{data:h,isLoading:g}=Oe({id:t},{enabled:s===`account`||s===`broker`}),_=n(()=>{let e=h?.brokerId;return typeof e==`string`?e:null},[h]),{data:v,isLoading:y}=z({addonId:r,nodeId:`hub`},{enabled:s===`account`}),b=n(()=>v?ct(v):null,[v]),x=De(),S=(e,n)=>{x.mutate({id:t,settings:e,...n?{secretKeys:[...n]}:{}},{onSuccess:()=>{m.invalidateQueries(),f()}})};return i(q,{open:!0,onOpenChange:e=>!e&&f(),children:e(me,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,children:[i(V,{children:e(we,{children:[p(`integrations.editConfig`,{defaultValue:`Edit configuration`}),` — `,a]})}),i(ye,{children:s===`broker`?l?e(`div`,{className:`space-y-3`,children:[i(`p`,{className:`text-[11px] text-foreground-subtle`,children:p(`integrations.relinkBrokerHelp`,{defaultValue:`Choose the broker this integration connects through. Picking a different broker re-points it and restarts the addon.`})}),_&&e(`p`,{className:`text-[11px] text-foreground`,children:[p(`integrations.currentBroker`,{defaultValue:`Current broker`}),`:`,` `,i(`span`,{className:`font-mono text-foreground-subtle`,children:_})]}),x.isPending?e(`div`,{className:`flex items-center gap-2 text-[11px] text-foreground-subtle`,children:[i(w,{className:`h-3 w-3 animate-spin`}),p(`integrations.saving`,{defaultValue:`Saving…`})]}):i(Ie,{kind:l,onResolved:e=>{S({brokerId:e})},onBack:f}),x.isError&&i(`p`,{className:`text-[11px] text-danger`,children:p(`integrations.relinkFailed`,{defaultValue:`Failed to update broker link.`})})]}):i(`p`,{className:`text-[11px] text-danger`,children:p(`integrations.noBrokerKind`,{defaultValue:`This integration declares device-adoption but its addon manifest has no brokerKind.`})}):s===`account`?g||y?e(`div`,{className:`flex items-center gap-2 text-[11px] text-foreground-subtle`,children:[i(w,{className:`h-3 w-3 animate-spin`}),p(`integrations.loading`,{defaultValue:`Loading…`})]}):i(Le,{addonId:r,configSchema:b,canTest:u,initialName:a,initialConfig:st(b,h??{}),submitLabel:p(`integrations.save`,{defaultValue:`Save`}),hideName:!0,onSave:({config:e,secretKeys:t})=>S(e,t),onBack:f}):i(_e,{trpc:d,addonId:r,nodeId:`hub`,title:a})})]})})}function ut(e){return e==null?!1:e.sections.some(e=>e.fields.length>0)}s();function dt(){let{t}=Z(),{integrationId:s}=Ne(),u=c(),d=Pe(),[p,m]=je(),g=C(),[_,v]=o(!1),[b,x]=o(!1),[S,E]=o(!1),D=r(e=>{E(!1),d(`/integrations`,{state:{integrationSeed:e}})},[d]),[ne,k]=o(!1),[j,M]=o(!1),{data:F,isLoading:R}=H({id:s??``},{enabled:!!s}),{data:B}=z({addonId:F?.addonId??``,nodeId:`hub`},{enabled:!!F?.addonId}),{data:U,isSuccess:W}=Te(),G=n(()=>{let e=F?.addonId;return!e||!W?null:(U??[]).find(t=>t.addonId===e)?.kind===`device-adoption`?`device-adoption`:`device-provider`},[U,F?.addonId,W]),{data:K}=ve({}),se=n(()=>(K?.providers??[]).some(e=>e.addonId===F?.addonId),[K,F?.addonId]),J=G!==null,ue=F?.info?.fixed===!0,Y=n(()=>{let e=F?.addonId;return!e||!W?null:(U??[]).find(t=>t.addonId===e)?.brokerKind??null},[U,F?.addonId,W]),he=Y===`matter`,ge=J?he?t(`integrations.addMatter.title`,{defaultValue:`Add Matter device`}):G===`device-adoption`?t(`integrations.adoptDevices`,{defaultValue:`Adopt devices`}):t(`integrations.addDevice`):t(`integrations.addDeviceLoading`,{defaultValue:`Loading…`}),_e=n(()=>{let e=F?.addonId;return!e||!W?!1:(U??[]).find(t=>t.addonId===e)?.canTest===!0},[U,F?.addonId,W]),X=n(()=>{let e=F?.addonId;return!e||!W?null:(U??[]).find(t=>t.addonId===e)?.mode??null},[U,F?.addonId,W]);a(()=>{p.get(`add`)===`1`&&J&&(x(!1),v(!0),m(e=>{let t=new URLSearchParams(e);return t.delete(`add`),t},{replace:!0}))},[p,J,m]);let xe=B!=null&&Array.isArray(B.sections)&&B.sections.some(e=>e.fields.length>0),{data:Se}=Ce({addonId:F?.addonId??``,nodeId:`hub`},{enabled:!!F?.addonId&&X!==`account`}),Ee=X!==null&&X!==`account`&&ut(Se),De=n(()=>F?.addonId?[F.addonId]:[],[F?.addonId]),{data:Oe}=I({projection:`slim`},{refetchInterval:3e4}),ke=[[`integrations`,`get`],{input:{id:s??``},type:`query`}],Ae=A({onMutate:async e=>{await u.cancelQueries({queryKey:ke});let t=u.getQueryData(ke);return t!=null&&u.setQueryData(ke,{...t,enabled:e.enabled}),{previous:t}},onError:(e,t,n)=>{let r=n;r?.previous!=null&&u.setQueryData(ke,r.previous)},onSettled:()=>{u.invalidateQueries({queryKey:[[`integrations`]]}),u.invalidateQueries({queryKey:[[`deviceManager`]]})}}),Me=le({onSuccess:()=>{u.invalidateQueries({queryKey:[[`integrations`]]}),u.invalidateQueries({queryKey:[[`deviceManager`]]}),d(`/integrations`)}}),Ie=N({onSuccess:()=>{u.invalidateQueries({queryKey:[[`integrations`]]}),u.invalidateQueries({queryKey:[[`deviceManager`]]})}}),Le=P({onSuccess:()=>{u.invalidateQueries({queryKey:[[`deviceManager`]]})}}),Be=fe({onSuccess:()=>{u.invalidateQueries({queryKey:[[`deviceManager`]]})}}),Ve=pe({onSuccess:()=>{u.invalidateQueries({queryKey:[[`deviceManager`]]})}}),Q=n(()=>Oe??[],[Oe]),He=n(()=>{let e=new Map;for(let t of Q)e.set(t.id,{id:t.id,name:t.name??t.stableId??`#${String(t.id)}`});return e},[Q]),Ue=r(e=>He.get(e)??null,[He]),{data:$}=oe(void 0),Ge=n(()=>de($),[$]),Ke=r(e=>d(`/devices/${String(e)}`),[d]),qe=n(()=>{let e=F?.id;return e?Q.filter(t=>{let n=Ge(t);return n.kind===`resolved`&&n.integration.id===e}):[]},[Q,F?.id,Ge]),Ye=n(()=>$===void 0?null:ae(qe).length,[$,qe])??`…`;return R?e(`div`,{className:`p-4`,children:[i(`div`,{className:`h-16 rounded-lg bg-surface animate-pulse mb-4`}),i(`div`,{className:`h-40 rounded-lg bg-surface animate-pulse`})]}):F?e(`div`,{className:`p-4 space-y-4 overflow-x-hidden`,children:[i(ie,{items:[{label:t(`integrationDetail.integrations`,`Integrations`),onClick:()=>d(`/integrations`)},{label:F.name}]}),e(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[e(`div`,{className:`flex items-center gap-3 min-w-0`,children:[i(ft,{addonId:F.addonId}),e(`div`,{className:`min-w-0`,children:[i(`h1`,{className:`text-lg font-semibold text-foreground truncate`,children:F.name}),e(`p`,{className:`text-[11px] text-foreground-subtle mt-0.5 truncate`,children:[F.addonId,` · `,Ye,` `,t(`integrations.devices`)]})]})]}),e(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[se&&e(`button`,{onClick:()=>E(!0),className:`flex items-center gap-1.5 rounded-lg border border-border bg-surface px-2.5 py-1.5 text-xs font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,title:t(`integrationDetail.scanTheNetworkForDevices`,`Scan the network for devices (incl. a different subnet)`),children:[i(te,{className:`h-3.5 w-3.5`}),t(`integrationDetail.scanNetwork`,`Scan network`)]}),!ue&&e(`button`,{onClick:()=>{x(!1),v(!0)},disabled:!J,className:`flex items-center gap-1.5 rounded-lg bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground shadow-sm disabled:opacity-50 disabled:cursor-not-allowed`,title:ge,children:[i(l,{className:`h-3.5 w-3.5`}),ge]}),e(`div`,{className:`inline-flex items-center gap-2 rounded-lg border px-3 py-1.5 transition-colors ${Ae.isPending?`opacity-60`:``} ${F.enabled?`border-success/30 bg-success/5`:`border-border bg-surface`}`,title:t(`integrations.toggleHint`,{defaultValue:`Click to toggle`}),children:[i(L,{checked:F.enabled,onCheckedChange:e=>Ae.mutate({id:s,enabled:e}),disabled:Ae.isPending,"aria-label":F.enabled?t(`integrationDetail.disableIntegration`,`Disable integration`):t(`integrationDetail.enableIntegration`,`Enable integration`)}),i(`span`,{className:`text-[11px] font-medium ${F.enabled?`text-success`:`text-foreground-subtle`}`,children:F.enabled?t(`integrationDetail.enabled`,`Enabled`):t(`integrationDetail.disabled`,`Disabled`)}),Ae.isPending&&i(w,{className:`h-3 w-3 animate-spin text-foreground-subtle`})]}),X!==`standalone`&&(xe||G===`device-adoption`)&&e(`button`,{onClick:()=>k(!0),className:`flex items-center gap-1.5 rounded-lg border border-border bg-surface px-3 py-1.5 text-[11px] text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,children:[i(y,{className:`h-3 w-3`}),t(`integrations.config`)]}),e(`button`,{onClick:()=>M(!0),className:`flex items-center gap-1.5 rounded-lg border border-border bg-surface px-3 py-1.5 text-[11px] text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,title:t(`integrations.logs`,{defaultValue:`View logs`}),children:[i(ee,{className:`h-3 w-3`}),t(`integrations.logs`,{defaultValue:`Logs`})]}),i(ce,{label:t(`integrationDetail.restart`,`Restart`),icon:T,title:t(`integrationDetail.restart2`,`Restart "{{name}}"?`,{name:F.name}),description:t(`integrationDetail.restartingTheAddonWillBriefly`,`Restarting the addon will briefly disconnect every device backed by it ({{topLevelCountLabel}} active). Streams will reconnect automatically.`,{topLevelCountLabel:Ye}),confirmLabel:t(`integrationDetail.restart`,`Restart`),triggerVariant:`outline`,confirmVariant:`danger`,disabled:Ie.isPending,action:()=>Ie.mutateAsync({addonId:F.addonId})}),!ue&&s&&i(ce,{label:t(`integrations.delete`,{defaultValue:`Delete`}),icon:f,title:t(`integrations.deleteTitle`,{defaultValue:`Delete integration?`}),description:t(`integrations.deleteWarning`,{defaultValue:`This removes the integration "{{name}}" and its {{count}} device(s). The addon will restart. This cannot be undone.`,name:F.name,count:Ye}),confirmLabel:t(`integrations.confirmDelete`,{defaultValue:`Delete integration`}),triggerVariant:`outline`,confirmVariant:`danger`,className:`border-danger bg-danger/10 text-danger hover:bg-danger hover:text-background`,disabled:Me.isPending,action:()=>Me.mutateAsync({id:s})})]})]}),Ee&&i(ze,{nodeId:null,addonIds:De,level:`global`,surface:`integration`,title:t(`integrations.settings`,{defaultValue:`Settings`})}),i(re,{context:`integration-detail`,devices:Q,trpc:g.trpcClient,integrationOf:Ge,forceIntegrationId:F.id,urlScope:`root`,lsKey:`integration-detail:${F.addonId}`,resolveIntegrationIcon:Fe,resolveParent:Ue,onNavigate:Ke,batchActions:{remove:Le.mutate,disable:Be.mutate,enable:Ve.mutate},...ue?{}:{onDeleteDevice:e=>Le.mutate({deviceId:e.id})}}),_&&s&&he&&!b&&i(Je,{onClose:()=>v(!1),onCommissioned:()=>x(!0)}),_&&s&&G===`device-adoption`&&(!he||b)&&i(nt,{addonId:F.addonId,integrationId:s,onClose:()=>{v(!1),x(!1)}}),_&&s&&G===`device-provider`&&i(We,{open:_,integrationId:s,addonId:F.addonId,onClose:()=>v(!1)}),S&&F&&i(Re,{open:S,scope:{addonId:F.addonId,label:F.name},onClose:()=>E(!1),onSetupIntegration:D}),ne&&s&&G!==null&&X!==null&&i(lt,{integrationId:s,addonId:F.addonId,name:F.name,kind:G,mode:X,brokerKind:Y,canTest:_e,trpc:g.trpcClient,onClose:()=>k(!1)}),j&&i(q,{open:!0,onOpenChange:e=>!e&&M(!1),children:e(me,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,className:`md:max-w-5xl md:h-[80vh]`,children:[i(V,{className:`mb-0`,children:e(we,{className:`flex items-center gap-2 min-w-0`,children:[i(ee,{className:`h-4 w-4 text-primary shrink-0`}),i(`span`,{className:`truncate`,children:F.name}),e(`span`,{className:`text-[10px] text-foreground-subtle font-mono truncate font-normal`,children:[F.addonId,s?` · ${s}`:``]})]})}),i(ye,{className:`min-h-0 overflow-hidden p-0`,children:i(be,{addonId:F.addonId,limit:200,maxHeight:`max-h-full`,showScope:!1,className:`h-full border-0 rounded-none`})})]})})]}):e(`div`,{className:`flex flex-col items-center justify-center py-20 px-6 text-center gap-4`,children:[i(`div`,{className:`flex h-12 w-12 items-center justify-center rounded-full bg-foreground-subtle/10`,children:i(O,{className:`h-6 w-6 text-foreground-subtle`})}),e(`div`,{className:`space-y-1 max-w-sm`,children:[i(`h2`,{className:`text-sm font-semibold text-foreground`,children:t(`integrations.integrationNotFound`,{defaultValue:`Integration not found`})}),i(`p`,{className:`text-[11px] text-foreground-subtle`,children:t(`integrations.integrationNotFoundHint`,{defaultValue:`The integration "{{id}}" does not exist. It may have been deleted, or the URL may be wrong.`,id:s??``})})]}),e(`button`,{onClick:()=>d(`/integrations`),className:`inline-flex items-center gap-1.5 rounded-lg border border-border bg-surface px-3 py-1.5 text-[11px] font-medium text-foreground hover:bg-surface-hover transition-colors`,children:[i(h,{className:`h-3 w-3`}),t(`integrations.backToList`,{defaultValue:`Back to integrations`})]})]})}function ft({addonId:e}){let t=ke(e),[n,r]=o(!1);return!t||n?null:i(`img`,{src:t,alt:``,className:`h-8 w-8 rounded-lg shrink-0`,onError:()=>r(!0)})}export{dt as IntegrationDetailPage};
@@ -1 +1 @@
1
- import{C as e,J as t,K as n,S as r,V as i,Y as a,et as o,k as s,o as c,x as l,z as u}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{An as d,Li as f,Nt as p,V as m,Yt as h,bn as g,kn as _,lr as v,or as y,pn as b}from"./player-overlays-By2E2OWX.js";import{Mr as x}from"./client-COfGFdJB.js";import{t as S}from"./settings-2-CBTEttT3.js";import{$r as ee,Dr as C,Kr as w,Oi as T,Or as E,Pi as D,Sn as O,Sr as k,_n as A,nn as te,tn as ne}from"./src-BZ8j9Q2T.js";import{t as j}from"./useTranslation-BJr-n0es.js";import{c as re,d as M,dr as N,gr as P,o as F,r as I,s as L,u as R,ur as z}from"./index-BO95XcLa.js";import{t as B}from"./AdminPage-BGeHUp9l.js";import{t as V}from"./NodeAddonsSettingsPanel-DsSbHT51.js";import{t as H}from"./AddonAssetIcon-5z0Vljts.js";o();function U(e){let{ids:t,answered:r,legacyGroupParam:i=null,groupFirst:a}=e,[o]=P(),s=o.get(F),c=i===null?null:o.get(i),l=o.get(L),u=n(()=>R({ids:t,requested:s,answered:r,legacyGroup:c,...a===void 0?{}:{groupFirst:a}}),[t,s,r,c,a]),d=n(()=>(e,t)=>`?${M(o,e,i,t??null).toString()}`,[o,i]);return{...u,requestedSection:l,hrefFor:d}}var W=[[[`addons`,`listCapabilityProviders`]],[[`addons`,`list`]]],G=`text-[10px]`;function K({isActive:e}){let{t}=j();return r(ee,{variant:e?`success`:`default`,className:G,children:e?t(`integrationHub.addonControls.enabled`,`Enabled`):t(`integrationHub.addonControls.disabled`,`Disabled`)})}function q({capName:t,addonId:n,isActive:i}){let{t:a}=j(),o=c(),s=D({onSuccess:()=>{for(let e of W)o.invalidateQueries({queryKey:e})}}),l=s.isPending;return e(w,{size:`sm`,variant:i?`secondary`:`primary`,disabled:l,onClick:()=>s.mutate({capName:t,addonId:n,enabled:!i}),children:[l?r(y,{className:`h-3 w-3 animate-spin`}):r(i?h:d,{className:`h-3 w-3`}),i?a(`common.disable`,`Disable`):a(`common.enable`,`Enable`)]})}function ie({addonId:e,displayName:t}){let{t:n}=j(),i=c(),a=T({onSuccess:()=>{for(let e of W)i.invalidateQueries({queryKey:e})}});return r(A,{label:n(`integrationHub.addonControls.restart`,`Restart`),icon:g,size:`sm`,title:n(`integrationHub.addonControls.restart2`,`Restart "{{displayName}}"?`,{displayName:t}),description:n(`integrationHub.addonControls.restartingTheAddonBouncesIts`,`Restarting the addon bounces its subprocess — the provider will briefly drop and reconnect automatically.`),confirmLabel:n(`integrationHub.addonControls.restart`,`Restart`),triggerVariant:`ghost`,confirmVariant:`danger`,disabled:a.isPending,action:()=>a.mutateAsync({addonId:e})})}o();var J=600,Y=s(null);function X({id:n,title:i,icon:a,actions:o,framed:s=!1,children:c}){let{t:d}=j(),f=u(Y),p=t(null),h=`integration-section-${n}`;ae(p,f,n);let g=e(l,{children:[f===null?null:r(N,{to:f.sectionHref(n),"aria-label":d(`integrationHub.integrationSection.linkTo`,`Link to {{title}}`,{title:i}),title:d(`integrationHub.integrationSection.linkTo`,`Link to {{title}}`,{title:i}),className:`rounded p-0.5 text-foreground-subtle/60 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40`,children:r(v,{className:`h-3 w-3`,"aria-hidden":!0})}),o]});return s?r(`div`,{ref:p,className:`scroll-mt-4`,children:r(O,{headingId:h,title:i,icon:a,actions:g,children:c})}):e(`section`,{ref:p,"aria-labelledby":h,className:`scroll-mt-4 space-y-2`,children:[e(`header`,{className:`flex min-h-7 flex-wrap items-center gap-2 px-0.5`,children:[a!==void 0&&r(a,{className:`h-3.5 w-3.5 shrink-0 text-foreground-subtle`,"aria-hidden":!0}),r(`h2`,{id:h,className:`${m} min-w-0 flex-1`,children:i}),g]}),c]})}function ae(e,t,n){let r=t?.requestedSection===n,a=t?.integrationId;i(()=>{if(!r)return;let t=()=>e.current?.scrollIntoView?.({block:`start`});t();let n=!1,i=()=>{n=!0},a=[`wheel`,`touchmove`,`keydown`];for(let e of a)window.addEventListener(e,i,{once:!0,passive:!0});let o=window.setTimeout(()=>{n||t()},J);return()=>{window.clearTimeout(o);for(let e of a)window.removeEventListener(e,i)}},[r,a,e])}o();var Z=`max-h-72`;function oe({addonId:t,displayName:n,capName:i,isActive:a,badges:o,primaryAction:s,error:c=null,lead:l,panels:u=[],settingsContent:d}){let{t:f}=j(),p=u.filter(e=>e.placement!==`end`),m=u.filter(e=>e.placement===`end`);return e(`div`,{className:`flex flex-col gap-4`,children:[r(se,{addonId:t,displayName:n,capName:i,isActive:a,badges:o,primaryAction:s}),c!==null&&r(C,{message:c}),l,r(Q,{panels:p}),r(X,{id:re,title:f(`integrationHub.addonIntegrationBody.settings`,`Settings`),icon:S,children:d===void 0?r(V,{nodeId:`hub`,addonIds:[t],level:`global`,capability:i}):d}),r(le,{addonId:t}),r(Q,{panels:m})]})}function Q({panels:e}){return r(l,{children:e.map(e=>r(X,{id:e.id,title:e.title,icon:e.icon,children:e.content},e.id))})}function se({addonId:t,displayName:n,capName:i,isActive:a,badges:o,primaryAction:s}){return e(`div`,{className:`flex flex-wrap items-center justify-between gap-2 rounded-lg border border-border bg-surface px-2 py-1.5 sm:px-3`,"data-testid":`integration-status-strip`,children:[e(`div`,{className:`flex min-w-0 flex-wrap items-center gap-1.5`,children:[r(K,{isActive:a}),o,r(`span`,{className:`break-all font-mono text-[11px] text-foreground-subtle`,children:t})]}),e(`div`,{className:`flex flex-wrap items-center justify-end gap-1`,children:[s,r(q,{capName:i,addonId:t,isActive:a}),r(ie,{addonId:t,displayName:n})]})]})}var ce=[{kind:`logs`,labelKey:`common.logs`,icon:b},{kind:`events`,labelKey:`common.events`,icon:f}];function le({addonId:t}){let{t:n}=j(),[i,o]=a(`logs`);return r(X,{id:I,title:n(`integrationHub.addonIntegrationBody.activity`,`Activity`),framed:!0,actions:r(`div`,{role:`group`,"aria-label":n(`integrationHub.addonIntegrationBody.activityStream`,`Activity stream`),className:`flex items-center gap-1`,children:ce.map(({kind:t,labelKey:a,icon:s})=>e(`button`,{type:`button`,"aria-pressed":i===t,onClick:()=>o(t),className:`inline-flex items-center gap-1 rounded px-2 py-0.5 text-[11px] font-medium transition-colors ${i===t?`bg-primary/10 text-primary`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,children:[r(s,{className:`h-3 w-3`,"aria-hidden":!0}),n(a)]},t))}),children:i===`logs`?r(te,{addonId:t,maxHeight:Z,showFilters:!1}):r(ne,{addonId:t,category:`addon.*`,maxHeight:Z})})}var ue=`inline-flex min-w-0 max-w-full items-center gap-1.5 rounded-full border py-1 pl-1 pr-2.5 text-xs transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40`,de=`border-primary bg-primary/10 text-primary font-medium`,fe=`border-border bg-surface text-foreground-subtle hover:bg-surface-hover hover:text-foreground`,pe={ok:`bg-success`,off:`bg-foreground-subtle/60`,error:`bg-danger`,unknown:`border border-foreground-subtle bg-transparent`};function $({label:t,groups:n,selectedId:i,hrefFor:a}){let o=n.length>1;return r(`nav`,{"aria-label":t,className:o?`flex flex-col gap-2 sm:grid sm:grid-cols-[max-content_minmax(0,1fr)] sm:items-start sm:gap-x-3`:`flex flex-col`,children:n.map(t=>e(`div`,{role:`group`,"aria-label":t.label,className:o?`flex min-w-0 flex-col gap-1 sm:col-span-2 sm:grid sm:grid-cols-subgrid sm:items-start`:`min-w-0`,children:[o&&r(`span`,{className:`text-[10px] font-semibold uppercase tracking-wider text-foreground-subtle sm:pt-2`,children:t.label}),e(`div`,{className:`flex min-w-0 flex-wrap items-center gap-1.5`,children:[t.entries.map(e=>r(me,{entry:e,current:e.id===i,href:a(e.id)},e.id)),t.install&&e(N,{to:x(t.install.capability),className:`inline-flex min-w-0 max-w-full items-center gap-1.5 rounded-full border py-1 pl-1 pr-2.5 text-xs transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40 border-dashed border-border pl-2 text-foreground-subtle hover:border-primary/50 hover:text-foreground`,children:[r(_,{className:`h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),r(`span`,{className:`truncate`,children:t.install.label})]})]})]},t.id))})}function me({entry:t,current:n,href:i}){let a=t.state===`ok`;return e(N,{to:i,"aria-current":n?`true`:void 0,className:`${ue} ${n?de:fe}`,"data-testid":`integration-pill-${t.id}`,children:[r(H,{addonId:t.id,fallback:t.fallbackIcon,tileClassName:``,size:`sm`}),r(`span`,{className:`truncate`,children:t.name}),t.showState!==!1&&r(he,{entry:t,quiet:a})]})}function he({entry:t,quiet:n}){return e(l,{children:[r(`span`,{className:`h-1.5 w-1.5 shrink-0 rounded-full ${pe[t.state]}`,"aria-hidden":!0}),r(`span`,{className:n?`sr-only`:`shrink-0 text-[10px] font-normal text-foreground-subtle`,children:t.stateLabel})]})}o();function ge({icon:t,title:i,subtitle:a,groups:o,isLoading:s,emptyTitle:c,emptyDescription:u,legacyGroupParam:d,trailing:f,embedded:p=!1}){let{t:m}=j(),h=n(()=>o.flatMap(e=>e.entries),[o]),g=n(()=>h.map(e=>e.id),[h]),_=n(()=>{let e={};for(let t of o){let n=t.entries[0];n!==void 0&&(e[t.id]=n.id)}return e},[o]),v=U({ids:g,answered:!s,legacyGroupParam:d??null,groupFirst:_}),y=h.find(e=>e.id===v.selectedId)??null,b=n(()=>y===null?null:{integrationId:y.id,requestedSection:v.requestedSection,sectionHref:e=>v.hrefFor(y.id,e)},[y,v]),x=s?null:r($,{label:m(`integrationHub.integrationHub.integrations`,`{{title}} integrations`,{title:i}),groups:o,selectedId:v.selectedId,hrefFor:e=>v.hrefFor(e)}),S=s?r(k,{children:r(`div`,{className:`p-6 text-sm text-foreground-subtle`,children:m(`common.loading`,`Loading…`)})}):e(l,{children:[v.staleId!==null&&r(ve,{staleId:v.staleId,shownName:y?.name??null}),y!==null&&b!==null?r(Y.Provider,{value:b,children:r(`div`,{role:`region`,"aria-label":y.name,"data-testid":`integration-body`,children:y.render()},y.id)}):r(_e,{groups:o,title:c,description:u}),f]});return p?e(`div`,{className:`space-y-3`,"data-testid":`integration-hub-embedded`,children:[x,S]}):r(B,{icon:t,title:i,subtitle:a,nav:x,children:S})}function _e({groups:t,title:n,description:i}){let a=t.find(e=>e.install!==void 0)?.install;return r(k,{children:r(E,{title:n,description:i,action:a?r(N,{to:x(a.capability),children:e(w,{variant:`primary`,size:`sm`,children:[r(_,{className:`mr-1 h-3.5 w-3.5`}),a.label]})}):void 0})})}function ve({staleId:t,shownName:n}){let{t:i}=j();return e(`div`,{role:`status`,className:`flex items-start gap-2 rounded-md border border-warning/30 bg-warning/5 px-3 py-2 text-[11px] text-foreground-subtle`,children:[r(p,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-warning`,"aria-hidden":!0}),e(`span`,{children:[r(z,{i18nKey:`integrationHub.staleIntegration.notice`,values:{id:t},components:{mono:r(`span`,{className:`font-mono text-foreground`})}}),n!==null&&e(l,{children:[` `,r(z,{i18nKey:`integrationHub.staleIntegration.showing`,values:{name:n},components:{b:r(`span`,{className:`font-medium text-foreground`})}})]})]})]})}export{U as i,oe as n,G as r,ge as t};
1
+ import{C as e,J as t,K as n,S as r,V as i,Y as a,et as o,k as s,o as c,x as l,z as u}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{An as d,Pt as f,Ri as p,V as m,Xt as h,jn as g,mn as _,sr as v,ur as y,xn as b}from"./player-overlays-Cs6l33cj.js";import{Nr as x}from"./client-Ct1F5MoE.js";import{t as S}from"./settings-2-zgGmo4c8.js";import{Dr as C,Er as ee,Hi as te,Ii as w,ei as T,en as E,gn as D,si as O,tn as k,xn as ne,xr as A}from"./src-DFzrn-CX.js";import{t as j}from"./useTranslation-BJr-n0es.js";import{c as re,d as M,hr as N,lr as P,o as F,r as I,s as L,u as R,ur as z}from"./index-hKEeWkm1.js";import{t as B}from"./AdminPage-QmLz5qjj.js";import{t as V}from"./NodeAddonsSettingsPanel-DOuw1uWS.js";import{t as H}from"./AddonAssetIcon-3vq-0y-v.js";o();function U(e){let{ids:t,answered:r,legacyGroupParam:i=null,groupFirst:a}=e,[o]=N(),s=o.get(F),c=i===null?null:o.get(i),l=o.get(L),u=n(()=>R({ids:t,requested:s,answered:r,legacyGroup:c,...a===void 0?{}:{groupFirst:a}}),[t,s,r,c,a]),d=n(()=>(e,t)=>`?${M(o,e,i,t??null).toString()}`,[o,i]);return{...u,requestedSection:l,hrefFor:d}}var W=[[[`addons`,`listCapabilityProviders`]],[[`addons`,`list`]]],G=`text-[10px]`;function K({isActive:e}){let{t}=j();return r(O,{variant:e?`success`:`default`,className:G,children:e?t(`integrationHub.addonControls.enabled`,`Enabled`):t(`integrationHub.addonControls.disabled`,`Disabled`)})}function q({capName:t,addonId:n,isActive:i}){let{t:a}=j(),o=c(),s=te({onSuccess:()=>{for(let e of W)o.invalidateQueries({queryKey:e})}}),l=s.isPending;return e(T,{size:`sm`,variant:i?`secondary`:`primary`,disabled:l,onClick:()=>s.mutate({capName:t,addonId:n,enabled:!i}),children:[l?r(v,{className:`h-3 w-3 animate-spin`}):r(i?h:g,{className:`h-3 w-3`}),i?a(`common.disable`,`Disable`):a(`common.enable`,`Enable`)]})}function ie({addonId:e,displayName:t}){let{t:n}=j(),i=c(),a=w({onSuccess:()=>{for(let e of W)i.invalidateQueries({queryKey:e})}});return r(D,{label:n(`integrationHub.addonControls.restart`,`Restart`),icon:b,size:`sm`,title:n(`integrationHub.addonControls.restart2`,`Restart "{{displayName}}"?`,{displayName:t}),description:n(`integrationHub.addonControls.restartingTheAddonBouncesIts`,`Restarting the addon bounces its subprocess — the provider will briefly drop and reconnect automatically.`),confirmLabel:n(`integrationHub.addonControls.restart`,`Restart`),triggerVariant:`ghost`,confirmVariant:`danger`,disabled:a.isPending,action:()=>a.mutateAsync({addonId:e})})}o();var J=600,Y=s(null);function X({id:n,title:i,icon:a,actions:o,framed:s=!1,children:c}){let{t:d}=j(),f=u(Y),p=t(null),h=`integration-section-${n}`;ae(p,f,n);let g=e(l,{children:[f===null?null:r(z,{to:f.sectionHref(n),"aria-label":d(`integrationHub.integrationSection.linkTo`,`Link to {{title}}`,{title:i}),title:d(`integrationHub.integrationSection.linkTo`,`Link to {{title}}`,{title:i}),className:`rounded p-0.5 text-foreground-subtle/60 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40`,children:r(y,{className:`h-3 w-3`,"aria-hidden":!0})}),o]});return s?r(`div`,{ref:p,className:`scroll-mt-4`,children:r(ne,{headingId:h,title:i,icon:a,actions:g,children:c})}):e(`section`,{ref:p,"aria-labelledby":h,className:`scroll-mt-4 space-y-2`,children:[e(`header`,{className:`flex min-h-7 flex-wrap items-center gap-2 px-0.5`,children:[a!==void 0&&r(a,{className:`h-3.5 w-3.5 shrink-0 text-foreground-subtle`,"aria-hidden":!0}),r(`h2`,{id:h,className:`${m} min-w-0 flex-1`,children:i}),g]}),c]})}function ae(e,t,n){let r=t?.requestedSection===n,a=t?.integrationId;i(()=>{if(!r)return;let t=()=>e.current?.scrollIntoView?.({block:`start`});t();let n=!1,i=()=>{n=!0},a=[`wheel`,`touchmove`,`keydown`];for(let e of a)window.addEventListener(e,i,{once:!0,passive:!0});let o=window.setTimeout(()=>{n||t()},J);return()=>{window.clearTimeout(o);for(let e of a)window.removeEventListener(e,i)}},[r,a,e])}o();var Z=`max-h-72`;function oe({addonId:t,displayName:n,capName:i,isActive:a,badges:o,primaryAction:s,error:c=null,lead:l,panels:u=[],settingsContent:d}){let{t:f}=j(),p=u.filter(e=>e.placement!==`end`),m=u.filter(e=>e.placement===`end`);return e(`div`,{className:`flex flex-col gap-4`,children:[r(se,{addonId:t,displayName:n,capName:i,isActive:a,badges:o,primaryAction:s}),c!==null&&r(ee,{message:c}),l,r(Q,{panels:p}),r(X,{id:re,title:f(`integrationHub.addonIntegrationBody.settings`,`Settings`),icon:S,children:d===void 0?r(V,{nodeId:`hub`,addonIds:[t],level:`global`,capability:i}):d}),r(le,{addonId:t}),r(Q,{panels:m})]})}function Q({panels:e}){return r(l,{children:e.map(e=>r(X,{id:e.id,title:e.title,icon:e.icon,children:e.content},e.id))})}function se({addonId:t,displayName:n,capName:i,isActive:a,badges:o,primaryAction:s}){return e(`div`,{className:`flex flex-wrap items-center justify-between gap-2 rounded-lg border border-border bg-surface px-2 py-1.5 sm:px-3`,"data-testid":`integration-status-strip`,children:[e(`div`,{className:`flex min-w-0 flex-wrap items-center gap-1.5`,children:[r(K,{isActive:a}),o,r(`span`,{className:`break-all font-mono text-[11px] text-foreground-subtle`,children:t})]}),e(`div`,{className:`flex flex-wrap items-center justify-end gap-1`,children:[s,r(q,{capName:i,addonId:t,isActive:a}),r(ie,{addonId:t,displayName:n})]})]})}var ce=[{kind:`logs`,labelKey:`common.logs`,icon:_},{kind:`events`,labelKey:`common.events`,icon:p}];function le({addonId:t}){let{t:n}=j(),[i,o]=a(`logs`);return r(X,{id:I,title:n(`integrationHub.addonIntegrationBody.activity`,`Activity`),framed:!0,actions:r(`div`,{role:`group`,"aria-label":n(`integrationHub.addonIntegrationBody.activityStream`,`Activity stream`),className:`flex items-center gap-1`,children:ce.map(({kind:t,labelKey:a,icon:s})=>e(`button`,{type:`button`,"aria-pressed":i===t,onClick:()=>o(t),className:`inline-flex items-center gap-1 rounded px-2 py-0.5 text-[11px] font-medium transition-colors ${i===t?`bg-primary/10 text-primary`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,children:[r(s,{className:`h-3 w-3`,"aria-hidden":!0}),n(a)]},t))}),children:i===`logs`?r(k,{addonId:t,maxHeight:Z,showFilters:!1}):r(E,{addonId:t,category:`addon.*`,maxHeight:Z})})}var ue=`inline-flex min-w-0 max-w-full items-center gap-1.5 rounded-full border py-1 pl-1 pr-2.5 text-xs transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40`,de=`border-primary bg-primary/10 text-primary font-medium`,fe=`border-border bg-surface text-foreground-subtle hover:bg-surface-hover hover:text-foreground`,pe={ok:`bg-success`,off:`bg-foreground-subtle/60`,error:`bg-danger`,unknown:`border border-foreground-subtle bg-transparent`};function $({label:t,groups:n,selectedId:i,hrefFor:a}){let o=n.length>1;return r(`nav`,{"aria-label":t,className:o?`flex flex-col gap-2 sm:grid sm:grid-cols-[max-content_minmax(0,1fr)] sm:items-start sm:gap-x-3`:`flex flex-col`,children:n.map(t=>e(`div`,{role:`group`,"aria-label":t.label,className:o?`flex min-w-0 flex-col gap-1 sm:col-span-2 sm:grid sm:grid-cols-subgrid sm:items-start`:`min-w-0`,children:[o&&r(`span`,{className:`text-[10px] font-semibold uppercase tracking-wider text-foreground-subtle sm:pt-2`,children:t.label}),e(`div`,{className:`flex min-w-0 flex-wrap items-center gap-1.5`,children:[t.entries.map(e=>r(me,{entry:e,current:e.id===i,href:a(e.id)},e.id)),t.install&&e(z,{to:x(t.install.capability),className:`inline-flex min-w-0 max-w-full items-center gap-1.5 rounded-full border py-1 pl-1 pr-2.5 text-xs transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40 border-dashed border-border pl-2 text-foreground-subtle hover:border-primary/50 hover:text-foreground`,children:[r(d,{className:`h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),r(`span`,{className:`truncate`,children:t.install.label})]})]})]},t.id))})}function me({entry:t,current:n,href:i}){let a=t.state===`ok`;return e(z,{to:i,"aria-current":n?`true`:void 0,className:`${ue} ${n?de:fe}`,"data-testid":`integration-pill-${t.id}`,children:[r(H,{addonId:t.id,fallback:t.fallbackIcon,tileClassName:``,size:`sm`}),r(`span`,{className:`truncate`,children:t.name}),t.showState!==!1&&r(he,{entry:t,quiet:a})]})}function he({entry:t,quiet:n}){return e(l,{children:[r(`span`,{className:`h-1.5 w-1.5 shrink-0 rounded-full ${pe[t.state]}`,"aria-hidden":!0}),r(`span`,{className:n?`sr-only`:`shrink-0 text-[10px] font-normal text-foreground-subtle`,children:t.stateLabel})]})}o();function ge({icon:t,title:i,subtitle:a,groups:o,isLoading:s,emptyTitle:c,emptyDescription:u,legacyGroupParam:d,trailing:f,embedded:p=!1}){let{t:m}=j(),h=n(()=>o.flatMap(e=>e.entries),[o]),g=n(()=>h.map(e=>e.id),[h]),_=n(()=>{let e={};for(let t of o){let n=t.entries[0];n!==void 0&&(e[t.id]=n.id)}return e},[o]),v=U({ids:g,answered:!s,legacyGroupParam:d??null,groupFirst:_}),y=h.find(e=>e.id===v.selectedId)??null,b=n(()=>y===null?null:{integrationId:y.id,requestedSection:v.requestedSection,sectionHref:e=>v.hrefFor(y.id,e)},[y,v]),x=s?null:r($,{label:m(`integrationHub.integrationHub.integrations`,`{{title}} integrations`,{title:i}),groups:o,selectedId:v.selectedId,hrefFor:e=>v.hrefFor(e)}),S=s?r(A,{children:r(`div`,{className:`p-6 text-sm text-foreground-subtle`,children:m(`common.loading`,`Loading…`)})}):e(l,{children:[v.staleId!==null&&r(ve,{staleId:v.staleId,shownName:y?.name??null}),y!==null&&b!==null?r(Y.Provider,{value:b,children:r(`div`,{role:`region`,"aria-label":y.name,"data-testid":`integration-body`,children:y.render()},y.id)}):r(_e,{groups:o,title:c,description:u}),f]});return p?e(`div`,{className:`space-y-3`,"data-testid":`integration-hub-embedded`,children:[x,S]}):r(B,{icon:t,title:i,subtitle:a,nav:x,children:S})}function _e({groups:t,title:n,description:i}){let a=t.find(e=>e.install!==void 0)?.install;return r(A,{children:r(C,{title:n,description:i,action:a?r(z,{to:x(a.capability),children:e(T,{variant:`primary`,size:`sm`,children:[r(d,{className:`mr-1 h-3.5 w-3.5`}),a.label]})}):void 0})})}function ve({staleId:t,shownName:n}){let{t:i}=j();return e(`div`,{role:`status`,className:`flex items-start gap-2 rounded-md border border-warning/30 bg-warning/5 px-3 py-2 text-[11px] text-foreground-subtle`,children:[r(f,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-warning`,"aria-hidden":!0}),e(`span`,{children:[r(P,{i18nKey:`integrationHub.staleIntegration.notice`,values:{id:t},components:{mono:r(`span`,{className:`font-mono text-foreground`})}}),n!==null&&e(l,{children:[` `,r(P,{i18nKey:`integrationHub.staleIntegration.showing`,values:{name:n},components:{b:r(`span`,{className:`font-medium text-foreground`})}})]})]})]})}export{U as i,oe as n,G as r,ge as t};
@@ -0,0 +1 @@
1
+ import{C as e,J as t,K as n,R as r,S as i,V as a,Y as o,a as s,et as c,o as l,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{An as f,In as p,Lt as m,Sn as h,ht as g,kn as _,ot as v,rr as y,sr as b,un as x}from"./player-overlays-Cs6l33cj.js";import{$t as S,Fi as ee,Yr as C}from"./client-Ct1F5MoE.js";import{h as w,s as T}from"./video-Byw3ItoR.js";import{t as E}from"./log-in-53JDrQ-P.js";import{t as D}from"./monitor-smartphone-Cqk6Z8Hg.js";import{t as te}from"./recycle-DpB4QxbX.js";import{Ai as O,Ca as k,Cn as ne,Er as A,Ka as j,Ot as M,Qr as re,Ta as ie,Vl as ae,_r as N,ba as P,ei as F,fr as I,ga as L,ha as oe,hr as se,ht as ce,kr as le,kt as R,mr as z,pr as ue,pt as de,si as B,sr as fe,ut as V,vr as H,wa as U,xa as W,ya as pe}from"./src-DFzrn-CX.js";import{t as G}from"./i18n-DJ4egBMY.js";import{t as K}from"./useTranslation-BJr-n0es.js";import{P as q,S as me,g as J,hr as he,i as ge,pr as _e}from"./index-hKEeWkm1.js";import{t as ve}from"./AdminSectionedPage-DYCbg6TR.js";import{t as ye}from"./BrokerForm-C0PFW-8b.js";import{t as be}from"./NodeAddonsSettingsPanel-DOuw1uWS.js";import{n as xe,r as Y,t as Se}from"./IntegrationHub-Crv-Ut8D.js";c();var X=`kind`,Z=`name`,Ce=`restore`,we=`restoreId`;function Te(e){return{sections:[{id:`broker-identity`,title:G.t(`helpers.brokerIdentitySchema.title`),columns:1,fields:[{type:`select`,key:X,label:G.t(`helpers.brokerIdentitySchema.kind`),options:e.map(e=>({value:e.key,label:e.label})),disabled:e.length<=1},{type:`text`,key:Z,label:G.t(`helpers.brokerIdentitySchema.name`),placeholder:G.t(`helpers.brokerIdentitySchema.namePlaceholder`),required:!0},{type:`boolean`,key:Ce,label:G.t(`helpers.brokerIdentitySchema.restore`),description:G.t(`helpers.brokerIdentitySchema.restoreHint`)},{type:`text`,key:we,label:G.t(`helpers.brokerIdentitySchema.originalId`),placeholder:`ha_004`,required:!0,showWhen:{field:Ce,equals:!0}}]}]}}function Ee(e){let t=t=>{let n=e[t];return typeof n==`string`?n.trim():``},n=t(X);if(n===``)return{ok:!1,problem:`Pick a kind.`};let r=t(Z);if(r===``)return{ok:!1,problem:`Enter a name before saving.`};if(e.restore!==!0)return{ok:!0,identity:{kindKey:n,name:r,restoreId:null}};let i=t(we);return i===``?{ok:!1,problem:`Enter the original id, or turn restore off to create a new broker.`}:{ok:!0,identity:{kindKey:n,name:r,restoreId:i}}}var De={"home-assistant":`Home Assistant`,mqtt:`MQTT`};function Oe(e){return De[e]??e}function ke(e){return Array.isArray(e)?e.filter(e=>typeof e==`object`&&!!e&&typeof e.addonId==`string`&&Array.isArray(e.kinds)):[]}var Ae={connected:`success`,connecting:`warning`,disconnected:`default`,"auth-failed":`danger`,unreachable:`danger`,error:`danger`};function je({status:e}){return i(B,{variant:Ae[e],className:`text-[10px]`,children:e})}function Me(e){return Array.isArray(e)?e.filter(e=>typeof e==`object`&&!!e&&typeof e.id==`string`):[]}function Ne({title:t,subtitle:n,onClose:r,children:a}){return i(I,{open:!0,onOpenChange:e=>!e&&r(),children:e(z,{width:`md`,placement:`sheet-on-mobile`,scroll:`body`,children:[e(N,{children:[i(H,{children:t}),n&&i(se,{children:n})]}),i(ue,{className:`space-y-3 pr-1`,children:a})]})})}function Pe({kinds:t,onClose:r,onDone:a}){let{t:s}=K(),c=l(),u=n(()=>Te(t.map(e=>({key:Q(e),label:e.label}))),[t]),[d,f]=o(()=>({[X]:Q(t[0]),[Z]:``,[Ce]:!1,[we]:``})),[p,m]=o(null),h=t.find(e=>Q(e)===d.kind)??t[0],g=h?.kind??``,_=h?.addonId,v=h?.interactiveConnectPath,y=oe({onSuccess:e=>{c.invalidateQueries({queryKey:[[`broker`,`list`]]});let t=typeof e==`object`&&e&&typeof e.id==`string`?e.id:null;t!==null&&v!==void 0&&v.length>0&&J(v,t,()=>{c.invalidateQueries({queryKey:[[`broker`,`list`]]})}),a()}}),b=e=>{let t=Ee(d);if(!t.ok){m(t.problem);return}m(null);let{name:n,restoreId:r}=t.identity;y.mutate({kind:g,name:n,settings:e,...r===null?{}:{id:r},..._===void 0?{}:{addonId:_}})};return e(Ne,{title:s(`brokers.brokerManager.addBroker`,`Add broker`),subtitle:s(`brokers.brokerManager.registerAMessageBrokerFor`,`Register a message broker for exporters and automations.`),onClose:y.isPending?()=>{}:r,children:[i(q,{schema:u,values:d,onChange:f}),p!==null&&i(A,{message:p}),y.isError&&i(A,{message:y.error instanceof Error?y.error.message:String(y.error)}),g&&i(ye,{kind:g,..._===void 0?{}:{addonId:_},onSubmit:b,onCancel:r,submitLabel:y.isPending?s(`brokers.brokerManager.adding`,`Adding…`):s(`brokers.brokerManager.addBroker`,`Add broker`),disabled:y.isPending},Q(h))]})}function Q(e){return e===void 0?``:`${e.addonId??``}::${e.kind}`}function Fe({broker:t,onClose:r,onDone:a}){let{t:o}=K(),s=l(),c=L({id:t.id,addonId:t.addonId}),u=U({onSuccess:()=>{s.invalidateQueries({queryKey:[[`broker`,`list`]]}),s.invalidateQueries({queryKey:[[`broker`,`getSettings`],{input:{id:t.id,addonId:t.addonId}}]}),a()}}),d=n(()=>{let e=c.data;return e&&typeof e==`object`?{...e}:{}},[c.data]);return i(Ne,{title:o(`brokers.brokerManager.edit`,`Edit {{name}}`,{name:t.name}),subtitle:`${Oe(t.kind)} · ${t.id}`,onClose:u.isPending?()=>{}:r,children:c.isLoading?e(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[i(b,{className:`h-3.5 w-3.5 animate-spin`}),` `,o(`brokers.brokerManager.loadingSettings`)]}):c.isError?e(`div`,{className:`space-y-3`,children:[i(A,{message:o(`brokers.brokerManager.loadSettingsFailed`,{message:c.error instanceof Error?c.error.message:o(`common.unknownError`)})}),i(`div`,{className:`flex justify-end`,children:i(F,{variant:`outline`,size:`sm`,onClick:r,children:o(`common.close`,`Close`)})})]}):e(`div`,{className:`space-y-3`,children:[u.isError&&i(A,{message:u.error instanceof Error?u.error.message:String(u.error)}),i(ye,{kind:t.kind,addonId:t.addonId,brokerId:t.id,initialValues:d,onSubmit:e=>{u.mutate({id:t.id,settings:e,addonId:t.addonId})},onCancel:r,submitLabel:u.isPending?o(`brokers.brokerManager.saving`,`Saving…`):o(`common.save`,`Save`),disabled:u.isPending})]})})}function Ie({broker:t,interactiveConnectPath:n,interactiveDisconnectPath:r,onEdit:a}){let{t:s}=K(),c=l(),u=re(),[d,f]=o(null),h=ie({onSuccess:e=>f(e.ok?{ok:!0}:{ok:!1,error:e.error}),onError:e=>f({ok:!1,error:e instanceof Error?e.message:String(e)})}),_=k({onSuccess:()=>{c.invalidateQueries({queryKey:[[`broker`,`list`]]})}}),v=async()=>{await u({title:s(`brokers.brokerManager.deleteBroker`,`Delete broker`),message:s(`brokers.brokerManager.deleteBrokerIntegrationsThatDepend`,`Delete broker "{{name}}"? Integrations that depend on it will stop working.`,{name:t.name}),confirmLabel:s(`common.delete`,`Delete`),variant:`danger`})&&_.mutate({id:t.id,addonId:t.addonId})},y=n!==void 0&&n.length>0&&t.status!==`connected`,x=r!==void 0&&r.length>0&&t.status===`connected`;return e(`tr`,{className:`border-b border-border last:border-0`,children:[i(`td`,{className:`px-3 py-2 text-xs text-foreground font-medium`,children:t.name}),i(`td`,{className:`px-3 py-2 text-xs text-foreground-subtle`,children:Oe(t.kind)}),e(`td`,{className:`px-3 py-2`,children:[i(je,{status:t.status}),d&&i(`span`,{className:`ml-2 text-[10px] ${d.ok?`text-success`:`text-danger`}`,children:d.ok?`OK`:d.error??s(`common.failedWord`)})]}),i(`td`,{className:`px-3 py-2`,children:e(`div`,{className:`flex items-center justify-end gap-1.5`,children:[y&&e(F,{variant:`primary`,size:`sm`,onClick:()=>{J(n,t.id,()=>{c.invalidateQueries({queryKey:[[`broker`,`list`]]})})},title:s(`brokers.brokerManager.signInOpensAPopup`,`Sign in — opens a popup that closes when done`),children:[i(E,{className:`h-3 w-3`}),` `,s(`brokers.brokerManager.signIn`)]}),x&&e(F,{variant:`outline`,size:`sm`,onClick:()=>{J(r,t.id,()=>{c.invalidateQueries({queryKey:[[`broker`,`list`]]})})},title:s(`brokers.brokerManager.signOutClearsTheLinked`,`Sign out — clears the linked Google account on this broker`),children:[i(T,{className:`h-3 w-3`}),` `,s(`brokers.brokerManager.signOut`)]}),e(F,{variant:`outline`,size:`sm`,onClick:()=>h.mutate({id:t.id,addonId:t.addonId}),disabled:h.isPending,title:s(`brokers.brokerManager.testConnection`,`Test connection`),children:[h.isPending?i(b,{className:`h-3 w-3 animate-spin`}):i(g,{className:`h-3 w-3`}),s(`brokers.brokerManager.test`,`Test`)]}),e(F,{variant:`outline`,size:`sm`,onClick:()=>a(t),title:s(`common.edit`,`Edit`),children:[i(p,{className:`h-3 w-3`}),` `,s(`common.edit`)]}),e(F,{variant:`outline`,size:`sm`,className:`border-danger/40 text-danger hover:bg-danger/10`,onClick:()=>{v()},disabled:_.isPending,title:s(`common.delete`,`Delete`),children:[_.isPending?i(b,{className:`h-3 w-3 animate-spin`}):i(m,{className:`h-3 w-3`}),s(`common.delete`,`Delete`)]})]})})]})}function Le({addonId:t}={}){let{t:r}=K(),a=P({}),s=W(),c=n(()=>Me(a.data).filter(e=>t===void 0||e.addonId===t),[a.data,t]),[l,u]=o(!1),[d,p]=o(null),m=n(()=>{let e=new Map;for(let n of ke(s.data))if(!(t!==void 0&&n.addonId!==t))for(let t of n.kinds){let r=typeof t.interactiveConnectPath==`string`&&t.interactiveConnectPath.length>0?t.interactiveConnectPath:void 0,i=typeof t.interactiveDisconnectPath==`string`&&t.interactiveDisconnectPath.length>0?t.interactiveDisconnectPath:void 0;e.set(`${n.addonId}::${t.kind}`,{addonId:n.addonId,kind:t.kind,label:t.label,...r===void 0?{}:{interactiveConnectPath:r},...i===void 0?{}:{interactiveDisconnectPath:i}})}for(let t of c)[...e.values()].some(e=>e.kind===t.kind)||e.set(`::${t.kind}`,{kind:t.kind,label:Oe(t.kind)});return[...e.values()]},[c,s.data,t]),h=n(()=>{let e=new Map;for(let t of m)e.has(t.kind)||e.set(t.kind,{...t.interactiveConnectPath===void 0?{}:{connect:t.interactiveConnectPath},...t.interactiveDisconnectPath===void 0?{}:{disconnect:t.interactiveDisconnectPath}});return e},[m]);return e(`div`,{className:`space-y-3`,children:[i(`div`,{className:`flex items-center justify-end`,children:e(F,{variant:`primary`,size:`sm`,onClick:()=>u(!0),disabled:m.length===0,title:m.length===0?r(`brokers.brokerManager.noBrokerProvidersAvailable`,`No broker providers available`):void 0,children:[i(f,{className:`h-3.5 w-3.5`}),` `,r(`brokers.brokerManager.addBroker`)]})}),i(`div`,{className:`rounded-lg border border-border bg-surface overflow-x-auto`,children:e(`table`,{className:`w-full min-w-[36rem] border-collapse`,children:[i(`thead`,{children:e(`tr`,{className:`border-b border-border bg-background/50`,children:[i(`th`,{className:`px-3 py-2 text-left text-[10px] font-semibold uppercase tracking-wider text-foreground-subtle`,children:r(`brokers.brokerManager.name`,`Name`)}),i(`th`,{className:`px-3 py-2 text-left text-[10px] font-semibold uppercase tracking-wider text-foreground-subtle`,children:r(`brokers.brokerManager.kind`,`Kind`)}),i(`th`,{className:`px-3 py-2 text-left text-[10px] font-semibold uppercase tracking-wider text-foreground-subtle`,children:r(`brokers.brokerManager.status`,`Status`)}),i(`th`,{className:`px-3 py-2 text-right text-[10px] font-semibold uppercase tracking-wider text-foreground-subtle`,children:r(`brokers.brokerManager.actions`,`Actions`)})]})}),e(`tbody`,{children:[a.isLoading&&i(`tr`,{children:e(`td`,{colSpan:4,className:`px-3 py-6 text-center text-xs text-foreground-subtle`,children:[i(b,{className:`inline h-4 w-4 animate-spin`}),` `,r(`brokers.brokerManager.loadingBrokers`)]})}),a.isError&&i(`tr`,{children:e(`td`,{colSpan:4,className:`px-3 py-4 text-center text-xs text-danger`,children:[r(`brokers.brokerManager.failedToLoadBrokers`,`Failed to load brokers:`),` `,a.error instanceof Error?a.error.message:r(`brokers.brokerManager.unknownError`,`Unknown error`)]})}),!a.isLoading&&!a.isError&&c.length===0&&i(`tr`,{children:i(`td`,{colSpan:4,className:`px-3 py-6 text-center text-xs text-foreground-subtle`,children:r(`brokers.brokerManager.noBrokersRegisteredYetAdd`,`No brokers registered yet. Add one to publish device events for downstream automations.`)})}),c.map(e=>{let t=h.get(e.kind);return i(Ie,{broker:e,...t?.connect===void 0?{}:{interactiveConnectPath:t.connect},...t?.disconnect===void 0?{}:{interactiveDisconnectPath:t.disconnect},onEdit:p},e.id)})]})]})}),l&&i(Pe,{kinds:m,onClose:()=>u(!1),onDone:()=>u(!1)}),d&&i(Fe,{broker:d,onClose:()=>p(null),onDone:()=>p(null)})]})}c();function Re({addonId:e,fallback:t}){let{t:n}=K(),r=ae({});if(r.isPending)return i(`div`,{className:`flex justify-center py-8`,children:i(b,{className:`size-6 animate-spin text-muted-foreground`})});if(r.isError)return i(A,{message:n(`brokers.brokerRecordEntriesPanel.loadKindsFailed`,`Could not load entry kinds`)});let a=r.data.kinds.find(t=>t.owner===e&&t.kind===`brokers`);return a===void 0?t:i(ze,{addonId:e,kind:a})}function ze({addonId:t,kind:r}){let{t:a}=K(),o=l(),s=P({}),c=W(),u=n(()=>{let e=new Map;for(let n of Me(s.data))n.addonId===t&&e.set(n.id,n);return e},[s.data,t]),f=n(()=>{let e=new Map;for(let t of ke(c.data))for(let n of t.kinds){let r=n.interactiveConnectPath,i=n.interactiveDisconnectPath;e.set(`${t.addonId}::${n.kind}`,{...typeof r==`string`&&r.length>0?{connect:r}:{},...typeof i==`string`&&i.length>0?{disconnect:i}:{}})}return e},[c.data]),p=()=>{o.invalidateQueries({queryKey:[[`broker`]]}),o.invalidateQueries({queryKey:[[`recordEntries`]]})};return i(V,{kind:r,extraColumns:n(()=>[{key:`status`,header:a(`brokers.brokerManager.status`,`Status`),nowrap:!0,width:`w-px`,render:e=>{let t=u.get(e.id);return t===void 0?null:i(je,{status:t.status})}}],[u,a]),rowActions:t=>{let n=u.get(t.id);if(n===void 0)return null;let r=f.get(`${n.addonId}::${n.kind}`);if(r===void 0)return null;let o=n.status===`connected`;return e(d,{children:[r.connect!==void 0&&!o&&e(F,{variant:`primary`,size:`sm`,"aria-label":a(`brokers.brokerManager.signIn`),onClick:()=>J(r.connect??``,n.id,p),title:a(`brokers.brokerManager.signInOpensAPopup`,`Sign in — opens a popup that closes when done`),children:[i(E,{className:`h-3 w-3`}),i(`span`,{className:`hidden sm:inline`,children:a(`brokers.brokerManager.signIn`)})]}),r.disconnect!==void 0&&o&&e(F,{variant:`outline`,size:`sm`,"aria-label":a(`brokers.brokerManager.signOut`),onClick:()=>J(r.disconnect??``,n.id,p),title:a(`brokers.brokerManager.signOutClearsTheLinked`,`Sign out — clears the linked Google account on this broker`),children:[i(T,{className:`h-3 w-3`}),i(`span`,{className:`hidden sm:inline`,children:a(`brokers.brokerManager.signOut`)})]})]})},showUpdated:!1,minWidthPx:340})}function Be(e){if(typeof e==`string`)return e;if(typeof e==`object`&&e){let t=e.name;if(typeof t==`string`)return t}return null}function Ve(e){let t=e,n=t?.manifest;if(n?.id===void 0)return null;let r=(n.capabilities??[]).map(Be).filter(e=>e!==null);return{addonId:n.id,displayName:n.packageDisplayName??n.name??n.id,capNames:r,processState:t?.process?.state??null}}function He(e,t){return Object.entries(e).filter(([,e])=>e===t).map(([e])=>e)}function Ue(e,t){return t.find(t=>e.capNames.includes(t))??null}function We(e){switch(e){case`running`:return{state:`ok`,label:G.t(`helpers.connectivityModel.running`)};case`crashed`:case`failed`:return{state:`error`,label:e};case`stopped`:case`disabled`:return{state:`off`,label:G.t(`helpers.connectivityModel.stopped`)};default:return{state:`unknown`,label:e??G.t(`common.unknownWord`)}}}c();var Ge=[`wasteCollections`,`listSources`],Ke=[`wasteCollections`,`listCountries`];function qe(e){return e instanceof Error?e.message:String(e)}function Je(e){return typeof e!=`object`||!e?!1:Array.isArray(Reflect.get(e,`sections`))}function Ye(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(typeof n!=`object`||!n)continue;let e=Reflect.get(n,`id`),r=Reflect.get(n,`label`),i=Reflect.get(n,`module`);if(typeof e!=`string`||typeof r!=`string`||typeof i!=`string`)continue;let a=Reflect.get(n,`enabled`),o=Reflect.get(n,`formValues`),s=Reflect.get(n,`serviceId`),c=Reflect.get(n,`countryId`);t.push({id:e,label:r,module:i,enabled:typeof a==`boolean`?a:!0,formValues:typeof o==`object`&&o&&!Array.isArray(o)?o:void 0,serviceId:typeof s==`string`?s:void 0,countryId:typeof c==`string`?c:void 0})}return t}function Xe(e){return Array.isArray(e)?e.flatMap(e=>{if(typeof e!=`object`||!e)return[];let t=Reflect.get(e,`id`),n=Reflect.get(e,`label`);return typeof t!=`string`||typeof n!=`string`?[]:[{id:t,label:n}]}):[]}function Ze(e){return Array.isArray(e)?e.flatMap(e=>{if(typeof e!=`object`||!e)return[];let t=Reflect.get(e,`id`),n=Reflect.get(e,`label`),r=Reflect.get(e,`module`);if(typeof t!=`string`||typeof n!=`string`||typeof r!=`string`)return[];let i=Reflect.get(e,`title`);return[{id:t,label:n,title:typeof i==`string`&&i.length>0?i:n,module:r}]}):[]}function Qe(e,t,n){return{sections:[{id:`picker`,title:G.t(`system.wasteSettingsSources.countryService`,`Country & service`),columns:2,fields:[{type:`select`,key:`countryId`,label:G.t(`system.wasteSettingsSources.country`,`Country`),options:[{value:``,label:G.t(`system.wasteSettingsSources.selectCountry`,`Select country…`)},...e.map(e=>({value:e.id,label:e.label}))]},{type:`select`,key:`serviceId`,label:G.t(`system.wasteSettingsSources.service`,`Service`),options:[{value:``,label:n===``?G.t(`system.wasteSettingsSources.pickACountryFirst`,`Pick a country first`):G.t(`system.wasteSettingsSources.selectService`,`Select service…`)},...t.map(e=>({value:e.id,label:e.label}))]}]}]}}function $e({addonId:c,capName:p}){let{t:h}=K(),g=v(),_=l(),y=re(),b=de({editKey:`wasteEdit`,newKey:`wasteNew`}),[x,S]=o(!1),[ee,C]=o(null),[w,T]=o({countryId:``,serviceId:``}),[E,D]=o({label:h(`system.wasteSettingsSources.newSource`,`New source`),enabled:!0}),O=t(null),k=typeof w.countryId==`string`?w.countryId:``,A=typeof w.serviceId==`string`?w.serviceId:``,j=r((e,t)=>g.trpcClient.addons.custom.mutate({addonId:c,action:e,input:t}),[c,g]),M=s({queryKey:[...Ge,c],queryFn:async()=>Ye(await j(`listSources`,{}))}),ie=s({queryKey:[...Ke,c],queryFn:async()=>Xe(await j(`listCountries`,{}))}),ae=s({queryKey:[`wasteCollections`,`listServices`,c,k],enabled:k!==``,queryFn:async()=>Ze(await j(`listServices`,{countryId:k}))}),N=s({queryKey:[`wasteCollections`,`serviceFormSchema`,c,A],enabled:A!==``,queryFn:async()=>j(`serviceFormSchema`,{serviceId:A})}),P=M.data??[],I=ie.data??[],L=ae.data??[],oe=Je(N.data)?N.data:void 0,se=n(()=>Qe(I,k===``?[]:L,k),[I,L,k]),R=b.state,z=R.mode===`edit`?P.find(e=>e.id===R.id)??null:null;a(()=>{if(b.state.mode===`edit`&&z!==null){let e=`edit:${z.id}`;if(O.current===e)return;O.current=e,C(null),T({countryId:z.countryId??``,serviceId:z.serviceId??``}),D(z.formValues===void 0?{label:z.label,enabled:z.enabled}:{...z.formValues});return}if(b.state.mode===`new`){if(O.current===`new`)return;O.current=`new`,C(null),T({countryId:``,serviceId:``}),D({label:h(`system.wasteSettingsSources.newSource`,`New source`),enabled:!0})}},[z,b.state]),a(()=>{if(b.state.mode!==`new`||A===``)return;let e=L.find(e=>e.id===A);e&&D(t=>{let n=t.label;return typeof n==`string`&&n!==``&&n!==`New source`?t:{...t,label:e.title}})},[b.state.mode,A,L]);let ue=r(e=>{T(t=>{let n=typeof e.countryId==`string`?e.countryId:``;return n===(typeof t.countryId==`string`?t.countryId:``)?e:{countryId:n,serviceId:``}})},[]),V=r(async()=>{await _.invalidateQueries({queryKey:Ge})},[_]),H=u({mutationFn:async e=>j(`deleteSource`,{id:e}),onSuccess:async()=>V()}),U=r(async e=>{await y({title:h(`system.wasteSettingsSources.deleteWasteSource`,`Delete waste source?`),message:h(`system.wasteSettingsSources.removeItsCalendarUnderSystem`,`Remove “{{label}}” ({{id}}). Its calendar under System → Calendars is dropped.`,{label:e.label,id:e.id}),confirmLabel:h(`common.delete`,`Delete`),cancelLabel:h(`common.cancel`,`Cancel`),variant:`danger`})&&(await H.mutateAsync(e.id),b.state.mode===`edit`&&b.state.id===e.id&&(b.close(),O.current=null))},[y,H,b,h]),W=r(async()=>{let e=E.label,t=typeof e==`string`&&e.trim()!==``?e.trim():``;if(t===``){C(`Label is required.`);return}if(A===``){C(`Pick a country and a service.`);return}let n=b.state.mode===`new`,r=z?.id;if(!n&&(r===void 0||r===``)){C(`That source is no longer available.`);return}let i=E.enabled,a={...E};delete a.label,delete a.enabled,S(!0),C(null);try{n?await j(`createSource`,{label:t,serviceId:A,args:a,enabled:typeof i==`boolean`?i:!0}):r!==void 0&&await j(`updateSource`,{id:r,label:t,serviceId:A,args:a,enabled:typeof i==`boolean`?i:!0}),await V(),b.close(),O.current=null}catch(e){C(qe(e))}finally{S(!1)}},[j,z,b,E,V,A]),pe=n(()=>[{key:`label`,header:h(`system.wasteSettingsSources.label`,`Label`),sortValue:e=>e.label,render:e=>i(`span`,{className:`text-sm text-foreground`,children:e.label})},{key:`module`,header:h(`system.wasteSettingsSources.module`,`Module`),sortValue:e=>e.module,render:e=>i(`span`,{className:`font-mono text-xs text-foreground-muted`,children:e.module})},{key:`enabled`,header:h(`system.wasteSettingsSources.enabled`,`Enabled`),sortValue:e=>+!!e.enabled,render:e=>i(B,{variant:e.enabled?`success`:`default`,children:e.enabled?h(`system.wasteSettingsSources.on`,`On`):h(`system.wasteSettingsSources.off`,`Off`)})},{key:`actions`,header:``,notSortableReason:`actions`,render:e=>i(F,{type:`button`,size:`sm`,variant:`ghost`,"aria-label":h(`system.wasteSettingsSources.delete`,`Delete {{label}}`,{label:e.label}),"data-testid":`waste-source-delete-${e.id}`,onClick:t=>{t.stopPropagation(),U(e)},children:i(m,{className:`h-3.5 w-3.5 text-danger`})})}],[U,h]),G=b.state.mode===`new`,q=G||z!==null,me=`${A}:${G?`new`:z?.id??`closed`}`;return e(`div`,{className:`flex min-h-0 flex-col gap-4`,"data-testid":`waste-settings-sources`,children:[e(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[i(`p`,{className:`text-sm text-foreground-muted`,children:h(`system.wasteSettingsSources.pickACountryAndA`,`Pick a country and a service — configuration fields come from that HACS source.`)}),e(F,{type:`button`,size:`sm`,"data-testid":`waste-sources-add`,onClick:()=>b.openNew(),children:[i(f,{className:`h-3.5 w-3.5`}),h(`system.wasteSettingsSources.addSource`,`Add source`)]})]}),M.isError?i(`p`,{className:`text-sm text-danger`,children:h(`system.wasteSettingsSources.couldNotLoadSources`,`Could not load sources.`)}):null,M.isPending?i(le,{className:`h-32 w-full`}):i(ne,{columns:pe,rows:P,rowKey:e=>e.id,pageSize:25,emptyMessage:h(`system.wasteSettingsSources.noWasteSourcesYetAdd`,`No waste sources yet. Add one to register a municipal service.`),onRowClick:e=>b.openEdit(e.id),defaultSort:{columnKey:`label`,dir:`asc`}}),i(ce,{open:q,onClose:()=>{b.close(),C(null),O.current=null},title:G?h(`system.wasteSettingsSources.addWasteSource`,`Add waste source`):h(`system.wasteSettingsSources.edit`,`Edit {{value1}}`,{value1:z?.label??`source`}),icon:te,width:`xl`,testId:`waste-source-editor`,error:ee,footer:i(F,{type:`button`,size:`sm`,disabled:x||A===``,onClick:()=>void W(),children:x?h(`system.wasteSettingsSources.saving`,`Saving…`):h(`common.save`,`Save`)}),children:q?e(d,{children:[i(`div`,{"data-testid":`waste-country-service`,children:i(fe,{schema:se,values:w,onChange:ue},`picker:${k}:${L.length}`)}),A!==``&&oe!==void 0?i(fe,{schema:oe,values:E,onChange:D,bare:!0},me):A!==``&&N.isPending?i(`p`,{className:`text-sm text-foreground-muted`,children:h(`system.wasteSettingsSources.loadingFields`,`Loading fields…`)}):i(`p`,{className:`text-sm text-foreground-muted`,children:h(`system.wasteSettingsSources.chooseACountryAndService`,`Choose a country and service to see the required fields.`)})]}):null}),i(be,{nodeId:`hub`,addonIds:[c],level:`global`,capability:p,hideSectionChrome:!0})]})}c();var $=1e4,et={"device-export":`exporters`,exporters:`exporters`,email:`email`,broker:`brokers`,brokers:`brokers`,"message-brokers":`brokers`,calendar:`calendars`,calendars:`calendars`,"calendar-source":`calendars`},tt=[{sectionId:`exporters`,kind:`device-export`,labelKey:`system.connectivity.exporters`,icon:x,installLabelKey:`system.connectivity.exportersInstall`,emptyTitleKey:`system.connectivity.exportersEmptyTitle`,emptyDescriptionKey:`system.connectivity.exportersEmptyDescription`},{sectionId:`email`,kind:`email`,labelKey:`system.connectivity.email`,icon:y,installLabelKey:`system.connectivity.emailInstall`,emptyTitleKey:`system.connectivity.emailEmptyTitle`,emptyDescriptionKey:`system.connectivity.emailEmptyDescription`},{sectionId:`brokers`,kind:`broker`,labelKey:`system.connectivity.brokers`,icon:h,installLabelKey:`system.connectivity.brokersInstall`,emptyTitleKey:`system.connectivity.brokersEmptyTitle`,emptyDescriptionKey:`system.connectivity.brokersEmptyDescription`},{sectionId:`calendars`,kind:`calendar`,labelKey:`system.connectivity.calendars`,icon:w,installLabelKey:`system.connectivity.calendarsInstall`,emptyTitleKey:`system.connectivity.calendarsEmptyTitle`,emptyDescriptionKey:`system.connectivity.calendarsEmptyDescription`}];function nt(t,n,r,a){let o=He(S,t.kind),s=n.flatMap(n=>{let a=Ue(n,o);if(a===null)return[];let s=We(n.processState);return[{id:n.addonId,name:n.displayName,fallbackIcon:t.icon,state:s.state,stateLabel:s.label,render:()=>i(xe,{addonId:n.addonId,displayName:n.displayName,capName:a,isActive:n.processState===`running`,badges:e(d,{children:[i(ot,{processState:n.processState}),i(st,{kind:t.kind,addonId:n.addonId})]}),lead:t.kind===`device-export`?i(R,{addonId:n.addonId}):void 0,panels:at(t.kind,n.addonId,e=>r(`/devices/${e}`)),settingsContent:n.addonId===`waste-collections`?i($e,{addonId:n.addonId,capName:a}):void 0})}]});return{id:t.sectionId,label:a(t.labelKey),entries:s,install:{capability:o[0]??t.kind,label:a(t.installLabelKey)}}}function rt({descriptor:e,rows:t,isLoading:r}){let{t:a}=K(),o=_e(),s=n(()=>nt(e,t,o,a),[e,t,o,a]);return i(Se,{embedded:!0,icon:e.icon,title:a(e.labelKey),subtitle:null,groups:[s],isLoading:r,emptyTitle:a(e.emptyTitleKey),emptyDescription:a(e.emptyDescriptionKey)})}function it(){let{t:e}=K(),t=O(void 0,{refetchInterval:$}),[r,o]=he(),s=me(`/system/integrations`,{t:e,isAdmin:!0})??{icon:_,title:e(`admin.system.integrations.connectivity`,`Connectivity`)};a(()=>{let e=r.get(`tab`);if(e===null)return;let t=et[e];t===void 0||t===e||o(e=>{let n=new URLSearchParams(e);return n.set(`tab`,t),n},{replace:!0})},[r,o]);let c=n(()=>(t.data??[]).map(Ve).filter(e=>e!==null),[t.data]),l=n(()=>tt.map(n=>({id:n.sectionId,label:e(n.labelKey),ownedParams:ge,content:i(rt,{descriptor:n,rows:c,isLoading:t.isLoading})})),[t.isLoading,c,e]);return i(ve,{icon:s.icon,title:s.title,subtitle:e(`admin.system.integrations.externalSystemsThisHubTalks`,`External systems this hub talks to — exporters, email, brokers and calendar sources.`),defaultSection:`exporters`,sectionsLabel:`Connectivity sections`,sections:l})}function at(e,t,n){return e===`device-export`?[{id:`devices`,title:G.t(`admin.system.integrations.devices`,`Devices`),icon:D,placement:`end`,content:i(M,{addonId:t,onOpenDevice:n,showSetup:!1})}]:e===`broker`?[{id:`connections`,title:G.t(`admin.system.integrations.connections`,`Connections`),icon:h,content:i(Re,{addonId:t,fallback:i(Le,{addonId:t})})}]:[]}function ot({processState:e}){let{state:t,label:n}=We(e);return i(B,{variant:t===`ok`?`success`:t===`error`?`danger`:`default`,className:`${Y} capitalize`,children:n})}function st({kind:e,addonId:t}){return e===`broker`?i(ct,{addonId:t}):e===`device-export`?i(lt,{addonId:t}):null}function ct({addonId:e}){let{t}=K(),{data:n}=pe({addonId:e},{refetchInterval:$,retry:!1}),r=ee.safeParse(n);if(!r.success)return null;let{brokerCount:a,connectedCount:o}=r.data;return i(B,{variant:`info`,className:Y,children:o>0?t(`system.connectivity.connectionsConnected`,{count:a,connected:o}):t(`system.connectivity.connections`,{count:a})})}function lt({addonId:e}){let{t}=K(),{data:n}=j({addonId:e},{refetchInterval:$,retry:!1}),r=C.safeParse(n);if(!r.success)return null;let{linkState:a,exposedDeviceCount:o}=r.data;return i(B,{variant:a===`linked`?`success`:a===`error`?`danger`:`default`,className:Y,children:t(`admin.system.integrations.exposed`,`{{linkState}} · {{exposedDeviceCount}} exposed`,{linkState:a,exposedDeviceCount:o})})}export{it as IntegrationsPage};
@@ -0,0 +1 @@
1
+ import{C as e,J as t,K as n,R as r,S as i,V as a,Y as o,et as s,o as c,x as l}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{An as u,Ci as d,Oi as f,Si as p,bi as m,dn as h,dt as g,kn as _,ot as v,pn as y,pr as ee,sr as b,wn as x,xn as te}from"./player-overlays-Cs6l33cj.js";import{t as ne}from"./table-2-lftK0wHb.js";import{$a as re,At as S,Er as C,F as ie,Nt as w,So as ae,_d as T,_i as oe,at as E,bs as D,do as se,ei as O,hs as k,jt as A,ld as ce,r as j,ud as le,vs as M}from"./src-DFzrn-CX.js";import{t as N}from"./i18n-DJ4egBMY.js";import{t as P}from"./useTranslation-BJr-n0es.js";import{fr as ue,hr as F,pr as de,sr as I}from"./index-hKEeWkm1.js";import{t as L}from"./AdminPage-QmLz5qjj.js";import"./useEventInvalidation-P-UzQOB7.js";import{t as R}from"./device-integration-icon-DukkUZAm.js";import{i as fe,n as pe,r as z,t as me}from"./ScanNetworkModal-qjbQd1Q4.js";s();function he({rows:t,isExpanded:r,onToggleExpand:a,onOpen:s,renderExpanded:c,searchPlaceholder:l,emptyLabel:u}){let[d,f]=o(``),p=n(()=>{let e=d.trim().toLowerCase();return e.length===0?t:t.filter(t=>`${t.name} ${t.addonId}`.toLowerCase().includes(e))},[d,t]);return e(`div`,{className:`space-y-3`,children:[e(`div`,{className:`relative`,children:[i(y,{className:`pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-foreground-subtle`,"aria-hidden":!0}),i(ce,{type:`search`,value:d,onChange:e=>f(e.target.value),placeholder:l,"aria-label":l,className:`pl-8`})]}),p.length===0?i(`p`,{className:`py-8 text-center text-xs text-foreground-subtle`,children:u}):i(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-2 sm:gap-3 lg:grid-cols-3`,children:p.map(e=>i(ge,{integration:e,expanded:r(e),onToggleExpand:a,onOpen:s,renderExpanded:c},e.id))})]})}function ge({integration:t,expanded:n,onToggleExpand:r,onOpen:a,renderExpanded:o}){return e(`article`,{"data-testid":`integration-card-${t.id}`,className:T(`flex min-w-0 flex-col gap-2 overflow-x-clip rounded-lg border border-border bg-surface p-3`,n&&`sm:col-span-2 lg:col-span-3`),children:[i(_e,{integration:t,expanded:n,onToggleExpand:r,onOpen:a}),n?i(`div`,{className:`min-w-0`,children:o(t)}):null]})}function _e({integration:t,expanded:n,onToggleExpand:r,onOpen:a}){let{t:o}=P(),s=n?o(`integrations.integrationColumns.collapse`,`Collapse`):o(`integrations.integrationColumns.expand`,`Expand`);return e(`div`,{className:`relative flex min-w-0 items-stretch gap-3`,children:[i(O,{type:`button`,variant:`ghost`,"aria-label":o(`integrations.openNamed`,{name:t.name,defaultValue:`Open {{name}}`}),onClick:()=>a(t),className:`absolute inset-0 z-0 h-auto w-auto rounded-lg p-0 focus-visible:ring-2 focus-visible:ring-primary`}),i(B,{integration:t}),e(`div`,{className:`pointer-events-none relative z-10 flex min-w-0 flex-1 flex-col items-start gap-1.5`,children:[i(E,{status:t.status,className:`shrink-0`}),i(`p`,{className:`text-[11px] text-foreground-muted`,children:o(`integrations.integrationColumns.deviceCount`,{count:t.deviceCount})}),i(`div`,{className:`pointer-events-auto mt-auto self-end`,children:i(le,{type:`button`,variant:`ghost`,size:`sm`,icon:n?p:m,"aria-label":s,"aria-expanded":n,onClick:e=>H(e,t.addonId,r)})})]})]})}function B({integration:t}){return e(`div`,{className:`pointer-events-none relative z-10 flex w-28 shrink-0 flex-col items-center gap-1 lg:w-24`,children:[i(I,{type:t.addonId,size:`xl`}),i(`p`,{className:`w-full text-center text-xs font-semibold text-foreground`,children:t.name}),i(V,{addonId:t.addonId})]})}function V({addonId:t}){return i(`p`,{className:`w-full text-center text-[10px] leading-tight text-foreground-subtle`,children:t.split(`-`).map((t,n)=>e(`span`,{children:[n>0?e(l,{children:[`-`,i(`wbr`,{})]}):null,t]},`${t}-${String(n)}`))})}function H(e,t,n){e.stopPropagation(),n(t)}s();var U=`camstack.admin.integrations.view`;function W(e){return e===`table`||e===`grid`}function G(){try{return typeof window>`u`?null:window.localStorage}catch{return null}}function K(e=G()){if(e===null)return`table`;try{let t=e.getItem(U);return W(t)?t:`table`}catch{return`table`}}function q(e,t=G()){if(t!==null)try{t.setItem(U,e)}catch{}}function ve(){let[e,t]=o(()=>K());return[e,r(e=>{t(e),q(e)},[])]}s();function J(e=!0){a(()=>{if(!e)return;let t=document.body.style.overflow;return document.body.style.overflow=`hidden`,()=>{document.body.style.overflow=t}},[e])}s();function ye(e,t){let[n,r]=o(!1);return a(()=>{if(!e){r(!1);return}r(!1);let n=setTimeout(()=>r(!0),t);return()=>clearTimeout(n)},[e,t]),n}s();function be({providerId:t,onImport:n,onSkip:r}){let{t:s}=P(),[c,l]=o(new Set),u=se(),p=u.data,m=u.isPending||!u.data&&!u.isError;a(()=>{t&&(u.isPending||u.data||u.mutate({addonId:t}))},[t,u]);function h(e){l(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}if(m)return e(`div`,{className:`flex flex-col items-center py-12`,children:[i(`div`,{className:`h-6 w-6 animate-spin rounded-full border-2 border-primary border-t-transparent`}),i(`p`,{className:`mt-3 text-xs text-foreground-subtle`,children:s(`integrations.searchingDevices`)})]});let g=p??[];return e(`div`,{className:`space-y-4`,children:[i(`p`,{className:`text-xs text-foreground-subtle`,children:g.length>0?s(`integrations.foundDevices`,{count:g.length}):s(`integrations.noDevicesFound`)}),g.length>0&&i(`div`,{className:`space-y-1.5 max-h-64 overflow-y-auto`,children:g.map(t=>{let n=t.stableId,r=t.suggestedName??n,a=c.has(n),o=t.alreadyOnboarded===!0;return e(`button`,{onClick:()=>{o||h(n)},disabled:o,title:o?s(`integrations.alreadyAddedHint`,{defaultValue:`Already added as "{{name}}" — re-adding would overwrite its settings.`,name:t.onboardedName??r}):void 0,className:`flex w-full items-center gap-3 rounded-lg border p-3 text-left transition-colors ${o?`border-border bg-surface opacity-60 cursor-not-allowed`:a?`border-primary/40 bg-primary/5`:`border-border bg-surface hover:border-foreground-subtle/30`}`,children:[i(`div`,{className:`flex h-5 w-5 items-center justify-center rounded border flex-shrink-0 ${a&&!o?`border-primary bg-primary`:`border-border`}`,children:a&&!o&&i(d,{className:`h-3 w-3 text-primary-foreground`})}),i(f,{className:`h-3.5 w-3.5 text-foreground-subtle flex-shrink-0`}),i(`span`,{className:`text-xs font-medium text-foreground truncate`,children:r}),o&&i(`span`,{className:`ml-auto flex-shrink-0 rounded bg-surface-muted px-1.5 py-0.5 text-[10px] font-medium text-foreground-subtle`,children:s(`integrations.alreadyAdded`,{defaultValue:`Already added`})})]},n)})}),e(`div`,{className:`flex items-center justify-between pt-2`,children:[i(`button`,{onClick:r,className:`rounded-lg border border-border px-3 py-1.5 text-xs text-foreground-subtle hover:text-foreground transition-colors`,children:s(`integrations.skip`)}),g.length>0&&e(`button`,{onClick:()=>n(Array.from(c)),disabled:c.size===0,className:`rounded-lg bg-primary px-4 py-1.5 text-xs font-medium text-primary-foreground shadow-sm disabled:opacity-50`,children:[s(`integrations.importSelected`),` (`,c.size,`)`]})]})]})}var Y=`(hover: none) and (pointer: coarse)`;function X(){if(typeof window>`u`||typeof window.matchMedia!=`function`)return!0;try{return!window.matchMedia(Y).matches}catch{return!0}}s();function Z({onSelect:r,onClose:s,pendingAddonId:c=null}){let{t:l}=P(),u=de(),[d,f]=o(``),p=t(null),{data:m,isLoading:g}=M();a(()=>{g||!X()||p.current?.focus()},[g]);let _=n(()=>{let e=m??[],t=d.trim().toLowerCase();return t.length===0?e:e.filter(e=>`${e.name} ${e.description??``} ${e.addonId}`.toLowerCase().includes(t))},[m,d]);if(g)return i(`div`,{className:`grid grid-cols-2 gap-2 p-2`,children:[1,2,3,4].map(e=>i(`div`,{className:`h-24 rounded-lg bg-surface animate-pulse`},e))});let v=c!==null;return e(`div`,{className:`space-y-3`,"data-testid":`provider-picker`,children:[e(`div`,{className:`relative`,children:[i(y,{className:`pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-foreground-subtle`,"aria-hidden":!0}),i(ce,{ref:p,type:`search`,value:d,onChange:e=>f(e.target.value),placeholder:l(`integrations.searchProviders`,`Search integrations…`),className:`pl-8`,"data-testid":`provider-picker-search`,"aria-label":l(`integrations.searchProviders`,`Search integrations…`)})]}),i(`div`,{className:`grid grid-cols-2 gap-2`,children:_.map(t=>{let n=t.instanceMode===`unique`&&t.existingInstances.length>0,a=c===t.addonId,o=v;return e(`button`,{type:`button`,disabled:o,"data-testid":`provider-pick-${t.addonId}`,onClick:()=>{if(!o)if(n){let e=t.existingInstances[0].id;s(),u(`/integrations/${e}`)}else r(t.addonId,t.instanceMode,t.discoveryMode,t.name,t.kind,t.brokerKind,t.mode,t.canTest)},className:`flex flex-col items-center gap-1.5 rounded-lg border border-border bg-surface px-3 py-3 text-center text-xs hover:border-primary/50 hover:bg-surface-hover transition-colors disabled:opacity-60 disabled:cursor-not-allowed disabled:hover:border-border`,children:[t.iconUrl?i(`div`,{className:`flex h-9 w-9 items-center justify-center rounded-lg flex-shrink-0`,style:{backgroundColor:`${t.color}15`},children:i(`img`,{src:t.iconUrl,alt:``,className:`h-5 w-5`})}):i(`div`,{className:`flex h-9 w-9 items-center justify-center rounded-lg flex-shrink-0`,style:{backgroundColor:`${t.color}15`},children:i(`span`,{className:`text-sm`,style:{color:t.color},children:`◉`})}),i(`p`,{className:`w-full truncate text-xs font-semibold text-foreground`,children:t.name}),t.description?i(`p`,{className:`w-full line-clamp-2 text-[10px] text-foreground-subtle`,children:t.description}):null,a?i(b,{className:`h-4 w-4 animate-spin text-primary`}):n?e(`span`,{className:`flex items-center gap-1 text-[10px] font-medium text-foreground-subtle`,children:[i(h,{className:`h-3 w-3`}),l(`integrations.manage`)]}):null]},t.addonId)})}),_.length===0&&i(`div`,{className:`py-8 text-center text-xs text-foreground-subtle`,children:(m??[]).length===0?l(`integrations.noProviders`):l(`integrations.noProvidersMatch`,`No integrations match your search.`)})]})}s();function xe(e){let t=e=>{if(e.type===`separator`||e.type===`info`||e.type===`button`)return e;if(e.type===`group`)return{...e,fields:e.fields.map(e=>t(e))};let{value:n,...r}=e;return r};return{...e.tabs?{tabs:e.tabs}:{},sections:e.sections.map(e=>({...e,fields:e.fields.map(t)}))}}var Se=2e4;function Ce({open:t,onClose:r,seed:s=null}){let{t:u}=P(),d=de(),f=c(),[p,m]=o(`picker`),[h,_]=o(null),[v,y]=o(null),[ee,x]=o(`manual`),[te,ne]=o(null),[S,C]=o(``),[ie,w]=o(null),[ae,T]=o(null),[E,D]=o(!1),[O,A]=o({}),[ce,j]=o(``),le=s?.config.host,N=s===null?``:`${s.addonId}\0${s.name}\0${typeof le==`string`?le:``}`;t&&s!==null&&ce!==N&&(j(N),_(s.addonId),C(s.name),A({...s.config}),m(`config`));let ue=M(void 0,{enabled:t&&s!==null}),{data:F}=oe({addonId:h??``,nodeId:`hub`},{enabled:h!=null}),I=n(()=>F?xe(F):null,[F]),L=k({onSuccess:()=>f.invalidateQueries({queryKey:[[`integrations`]]})}),R=se(),pe=R.data;a(()=>{if(!t||s===null)return;let e=ue.data?.find(e=>e.addonId===s.addonId);e&&(D(e.canTest),x(e.discoveryMode))},[t,s,ue.data]),a(()=>{p!==`discovery`||!v||!h||R.isPending||R.data||R.mutate({addonId:h})},[p,v,h,R]);let me=re({onSuccess:()=>f.invalidateQueries({queryKey:[[`deviceManager`]]})});function he(e,t,n,r,i,a,o,s){if(!L.isPending){if(_(e),D(s),x(n),C(r),T(null),o===`broker`){if(!a){T(`Addon '${e}' declares mode 'broker' but no brokerKind in its manifest`);return}ne(a),m(`broker`);return}if(o===`account`){m(`config`);return}ge(e,r)}}async function ge(e,t){try{let n=await L.mutateAsync({addonId:e,name:t,settings:{}});r(),U(),d(`/integrations/${n.id}?add=1`)}catch{}}async function _e(e){if(h)try{let t=await L.mutateAsync({addonId:h,name:e.name,settings:e.config,secretKeys:[...e.secretKeys]});y(t.id),w(t.id),ee===`auto`||ee===`both`?m(`discovery`):H(t.id,{openAdd:!0})}catch{}}async function B(e){if(h)try{let t=await L.mutateAsync({addonId:h,name:S,settings:{brokerId:e}});w(t.id),y(t.id),H(t.id)}catch{}}async function V(e){if(h){for(let t of e){let e=pe?.find(e=>e.stableId===t);e&&await me.mutateAsync({addonId:h,candidate:e,...ie===null?{}:{integrationId:ie}})}H()}}function H(e,t){let n=e??v??h;r(),U(),n&&d(t?.openAdd===!0?`/integrations/${n}?add=1`:`/integrations/${n}`)}function U(){m(`picker`),_(null),y(null),x(`manual`),ne(null),C(``),w(null),T(null),D(!1),A({}),j(``)}function W(){r(),U()}J(t);let G=L.isPending,K=ye(G,Se);if(!t)return null;let q={picker:u(`integrations.newIntegration`),config:u(`integrations.configureIntegration`),discovery:u(`integrations.importDevices`),broker:u(`integrations.connectBroker`,{defaultValue:`Connect a broker`})},ve=G?h:null,Y=L.error,X=G&&!K;return e(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center`,children:[i(`div`,{className:`absolute inset-0 bg-black/60`,onClick:X?void 0:W}),e(`div`,{className:`relative z-10 w-full max-w-lg max-h-[calc(85dvh-2*max(env(safe-area-inset-top),env(safe-area-inset-bottom)))] rounded-xl border border-border bg-background shadow-2xl flex flex-col overflow-hidden`,children:[e(`div`,{className:`flex items-center justify-between border-b border-border px-5 py-4 flex-shrink-0`,children:[i(`h2`,{className:`text-sm font-semibold text-foreground`,children:q[p]}),i(`button`,{onClick:W,disabled:X,className:`rounded-md p-1 text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-40 disabled:cursor-not-allowed`,children:i(g,{className:`h-4 w-4`})})]}),e(`div`,{className:`px-5 py-4 flex-1 overflow-y-auto overscroll-contain`,children:[Y&&!G&&i(`div`,{className:`mb-3 rounded-lg border border-destructive/40 bg-destructive/10 px-3 py-2 text-xs text-destructive`,children:Y instanceof Error?Y.message:String(Y)}),p===`picker`&&e(l,{children:[ae&&i(`div`,{className:`mb-3 rounded-lg border border-destructive/40 bg-destructive/10 px-3 py-2 text-xs text-destructive`,children:ae}),i(Z,{onSelect:he,onClose:W,pendingAddonId:ve})]}),p===`config`&&h&&i(z,{addonId:h,configSchema:I??null,canTest:E,initialName:typeof O.host==`string`?S:void 0,initialConfig:{...O},onSave:_e,onBack:()=>{A({}),m(`picker`)}},N.length>0?N:h),p===`broker`&&te&&i(fe,{kind:te,onResolved:e=>{B(e)},onBack:()=>m(`picker`)}),p===`discovery`&&v&&i(be,{providerId:v,onImport:V,onSkip:H})]}),G&&e(`div`,{className:`absolute inset-0 z-20 flex flex-col items-center justify-center gap-2 rounded-xl bg-background/85 backdrop-blur-sm px-6 text-center`,children:[i(b,{className:`h-6 w-6 animate-spin text-primary`}),i(`p`,{className:`text-xs font-medium text-foreground`,children:u(`integrations.creating`,{defaultValue:`Creating integration…`})}),!K&&i(`p`,{className:`text-[10px] text-foreground-subtle`,children:u(`integrations.creatingHint`,{defaultValue:`Waiting for the addon to restart and register`})}),K&&e(l,{children:[i(`p`,{className:`text-[10px] text-foreground-subtle max-w-xs`,children:u(`integrations.creatingOverdue`,{defaultValue:`This is taking longer than expected. The integration may already have been created — close this dialog and refresh to check.`})}),i(`button`,{onClick:W,className:`mt-1 rounded-md border border-border bg-surface px-3 py-1.5 text-[11px] font-medium text-foreground hover:bg-surface-hover transition-colors`,children:u(`integrations.closeAndRefresh`,{defaultValue:`Close`})})]})]})]})]})}function we({integration:t,expanded:n,onToggleExpand:r}){let{t:a}=P();return e(`div`,{className:`flex items-center gap-2.5`,children:[i(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),r(t.addonId)},"aria-label":n?a(`integrations.integrationColumns.collapse`,`Collapse`):a(`integrations.integrationColumns.expand`,`Expand`),"aria-expanded":n,className:`flex h-5 w-5 flex-shrink-0 items-center justify-center rounded text-foreground-subtle transition-colors hover:bg-surface-hover hover:text-foreground`,children:i(n?p:m,{className:`h-3.5 w-3.5`})}),i(I,{type:t.addonId,size:`sm`}),e(`div`,{className:`flex min-w-0 flex-col`,children:[i(`span`,{className:`truncate text-xs font-semibold text-foreground`,children:t.name}),i(`span`,{className:`truncate text-[10px] text-foreground-subtle`,children:t.addonId})]})]})}function Te(e){let{isExpanded:t,onToggleExpand:n}=e;return[{key:`name`,header:N.t(`integrations.integrationColumns.integration`,`Integration`),headerClassName:`w-[55%]`,cell:e=>i(we,{integration:e,expanded:t(e),onToggleExpand:n})},{key:`devices`,header:N.t(`integrations.integrationColumns.devices`,`Devices`),headerClassName:`w-[15%]`,cellClassName:`text-[11px] text-foreground-subtle`,cell:e=>N.t(`integrations.integrationColumns.deviceCount`,{count:e.deviceCount})},{key:`status`,header:N.t(`integrations.integrationColumns.status`,`Status`),headerClassName:`w-[15%]`,cell:e=>i(E,{status:e.status})}]}s();function Ee(e){if(!e.enabled)return`disabled`;switch(e.processState){case`running`:return`running`;default:return`stopped`}}var De=`expand`;function Oe(){let{t}=P(),s=de(),c=ue(),d=v(),[f]=F(),[p,m]=ve(),[h,g]=o(!1),[y,b]=o(null),re=r(()=>{b(null),g(!0)},[]),oe=r(()=>{g(!1),b(null)},[]),E=r(e=>{O(!1),b(e),g(!0)},[]),[se,O]=o(!1);a(()=>{let e=pe(c.state);e!==null&&(b(e),g(!0),s(`/integrations`,{replace:!0,state:null}))},[c.state,s]);let k=f.get(`setup`);a(()=>{k===null||k.length===0||(b({addonId:k,name:k,config:{}}),g(!0))},[k]);let ce=r(()=>O(!0),[]),le=r(()=>O(!1),[]);j([`integrations`],[`integration.enabled`,`integration.disabled`,`integration.deleted`,`provider.started`,`provider.stopped`,`addon.installed`,`addon.uninstalled`,`addon.started`,`addon.stopped`,`addon.updated`]),j([`deviceManager`],[`device.registered`,`device.unregistered`,`device.online`,`device.offline`,`device.disabled`,`device.enabled`]);let{data:M,isLoading:N,isError:I,refetch:fe}=D(void 0),{data:z,isLoading:ge,isError:_e,refetch:B}=ae({projection:`slim`}),V=n(()=>z??[],[z]),H=n(()=>M??[],[M]),U=n(()=>{let e=new Map;for(let t of V)e.set(t.id,{id:t.id,name:t.name??t.stableId??`#${String(t.id)}`});return e},[V]),W=n(()=>A(M),[M]),G=n(()=>{let e=new Map;for(let t of w(V)){let n=W(t);if(n.kind!==`resolved`)continue;let r=n.integration.id;e.set(r,(e.get(r)??0)+1)}return e},[V,W]),K=n(()=>H.map(e=>({id:e.id,addonId:e.addonId,name:e.name,enabled:e.enabled,status:Ee(e),deviceCount:G.get(e.id)??0})),[H,G]),q=f.get(De),J=r(e=>{let t=new URLSearchParams(window.location.search);t.get(De)===e?t.delete(De):t.set(De,e);let n=t.toString(),r=`${window.location.pathname}${n?`?${n}`:``}${window.location.hash}`;window.history.replaceState(window.history.state,``,r),window.dispatchEvent(new PopStateEvent(`popstate`))},[]),ye=r(e=>s(`/integrations/${e.id}`),[s]),be=r(e=>U.get(e)??null,[U]),Y=r(e=>s(`/devices/${String(e)}`),[s]),X=r(e=>i(S,{context:`integration-detail`,devices:V,trpc:d.trpcClient,integrationOf:W,forceIntegrationId:e.id,urlScope:`nested`,lsKey:`integrations:nested:${e.addonId}`,resolveIntegrationIcon:R,resolveParent:be,onNavigate:Y}),[V,d.trpcClient,W,be,Y]),Z=r(e=>q===e.addonId,[q]),xe=n(()=>Te({isExpanded:Z,onToggleExpand:J}),[Z,J]),Se=r(e=>`${e.name} ${e.addonId}`,[]),we=r(e=>e.addonId,[]),Oe=r(()=>{fe(),B()},[fe,B]),Q=I===!0||_e===!0,$=!Q&&(N||ge||M===void 0||z===void 0),ke=H.length>0,Ae=[{id:`table`,label:t(`integrations.viewTable`,`Table`),icon:ne},{id:`grid`,label:t(`integrations.viewGrid`,`Grid`),icon:ee}];return e(L,{icon:_,title:t(`nav.integrations`,`Integrations`),actions:e(l,{children:[i(ie,{ariaLabel:t(`integrations.viewLabel`,`Layout`),value:p,onChange:m,options:Ae,testId:`integrations-view`}),i(`button`,{onClick:Oe,disabled:$,className:`flex items-center gap-1 rounded-lg border border-border bg-surface px-2.5 py-1.5 text-xs font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50`,title:t(`common.refresh`,`Refresh`),children:i(te,{className:T(`h-3.5 w-3.5`,$&&`animate-spin`)})}),e(`button`,{onClick:ce,className:`flex items-center gap-1.5 rounded-lg border border-border bg-surface px-2.5 py-1.5 text-xs font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,title:t(`integrations.scanTheLocalNetworkFor`,`Scan the local network for devices`),children:[i(x,{className:`h-3.5 w-3.5`}),t(`integrations.scanNetwork`,`Scan network`)]}),e(`button`,{onClick:re,className:`flex items-center gap-1.5 rounded-lg bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground shadow-sm`,children:[i(u,{className:`h-3.5 w-3.5`}),t(`integrations.newIntegration`,`New Integration`)]})]}),children:[Q&&i(C,{message:t(`integrations.loadFailed`,`Integrations could not be loaded.`),onRetry:Oe}),$&&i(`div`,{className:`space-y-2`,"data-testid":`integrations-pending`,children:[1,2,3].map(e=>i(`div`,{className:`h-12 rounded-lg border border-border bg-surface animate-pulse`},e))}),!Q&&!$&&!ke&&e(`div`,{className:`flex flex-col items-center py-20 text-foreground-subtle`,children:[i(`p`,{className:`text-sm`,children:t(`integrations.noIntegrationsConfigured`,`No integrations configured.`)}),i(`p`,{className:`text-xs mt-1`,children:t(`integrations.clickNewIntegrationToConnect`,`Click "New Integration" to connect cameras and devices.`)})]}),!Q&&!$&&ke&&p===`table`&&i(S,{mode:`generic`,items:K,getKey:we,getSearchText:Se,columns:xe,onRowClick:ye,isExpanded:Z,renderExpanded:X,searchPlaceholder:t(`integrations.search`,{defaultValue:`Search integrations…`}),emptyLabel:t(`integrations.empty`,{defaultValue:`No integrations found.`})}),!Q&&!$&&ke&&p===`grid`&&i(he,{rows:K,isExpanded:Z,onToggleExpand:J,onOpen:ye,renderExpanded:X,searchPlaceholder:t(`integrations.search`,{defaultValue:`Search integrations…`}),emptyLabel:t(`integrations.empty`,{defaultValue:`No integrations found.`})}),i(Ce,{open:h,onClose:oe,seed:y}),i(me,{open:se,onClose:le,onSetupIntegration:E})]})}export{Oe as IntegrationsPage};