@camstack/addon-admin-ui 1.2.503 → 1.2.504

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 (81) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/assets/{AddonAssetIcon-DRZmNGlG.js → AddonAssetIcon-NEsi-wOP.js} +1 -1
  3. package/dist/assets/Addons-BBTz7bMK.js +5 -0
  4. package/dist/assets/{AdminPage-Bn1s1Zyw.js → AdminPage-aCyydhgN.js} +1 -1
  5. package/dist/assets/{AdminSectionedPage-OHmEcMxM.js → AdminSectionedPage-DQApNUvC.js} +1 -1
  6. package/dist/assets/{AiProfiles-CrsCHAWJ.js → AiProfiles-BE-rCiys.js} +1 -1
  7. package/dist/assets/{BrokerEditorDialog-0I2FqCxl.js → BrokerEditorDialog-DaJ4BMP-.js} +1 -1
  8. package/dist/assets/{Build-vzgL6An-.js → Build-BEJ9LiOb.js} +3 -3
  9. package/dist/assets/{Calendars-CdAizSco.js → Calendars-DwmEazlr.js} +1 -1
  10. package/dist/assets/{Cluster-Bg0lO7ax.js → Cluster-DXvpkuQ_.js} +1 -1
  11. package/dist/assets/{CompositionBlockEditor-CP3_SX84.js → CompositionBlockEditor-Dn1dNrUj.js} +1 -1
  12. package/dist/assets/{CompositionEditorPage-DfjSU7uD.js → CompositionEditorPage-BAtIrfop.js} +1 -1
  13. package/dist/assets/{Data-D2dSu7s6.js → Data-CxbvhxJ0.js} +2 -2
  14. package/dist/assets/DeviceDetail-1SsTjU6R.js +2 -0
  15. package/dist/assets/{DeviceDoActionFields-CHeeEoE0.js → DeviceDoActionFields-CbeCW7Ej.js} +1 -1
  16. package/dist/assets/{Devices-gen3hRHJ.js → Devices-P2Awkb88.js} +1 -1
  17. package/dist/assets/{EmbedPlayerPage-rhZJ1QKl.js → EmbedPlayerPage-DHx71JZg.js} +1 -1
  18. package/dist/assets/{HelperWizard-QNL7ojgt.js → HelperWizard-dV1HzKlU.js} +2 -2
  19. package/dist/assets/{History-D84HQRm3.js → History-COrccgVX.js} +1 -1
  20. package/dist/assets/{Identity-CxluBwKM.js → Identity-DwNJielZ.js} +1 -1
  21. package/dist/assets/IntegrationDetail-B62OySBK.js +1 -0
  22. package/dist/assets/{IntegrationHub-DXhDIgkG.js → IntegrationHub-DkSP6wag.js} +1 -1
  23. package/dist/assets/Integrations-BOcxxDmP.js +1 -0
  24. package/dist/assets/Integrations-qJr63PpD.js +1 -0
  25. package/dist/assets/{Library-BYQs9rzN.js → Library-BV1qzsuk.js} +1 -1
  26. package/dist/assets/{Locations-LcX-LYMF.js → Locations-CZB5AlmP.js} +1 -1
  27. package/dist/assets/{Logs-BEZRwDcR.js → Logs-GyrX39DG.js} +1 -1
  28. package/dist/assets/MyAccess-CX7W9s59.js +2 -0
  29. package/dist/assets/Network-hBrZTqKM.js +1 -0
  30. package/dist/assets/{NodeAddonsSettingsPanel-DEdzDp8P.js → NodeAddonsSettingsPanel-DcAc9h3n.js} +1 -1
  31. package/dist/assets/Notifications-CVo2lV8_.js +1 -0
  32. package/dist/assets/{Pipeline-DanfCspn.js → Pipeline-ULrA6vbR.js} +1 -1
  33. package/dist/assets/{Recordings-DPC7wBK7.js → Recordings-O3tK-kRN.js} +1 -1
  34. package/dist/assets/{ScanNetworkModal-DYNrpcKO.js → ScanNetworkModal-DRTFnUxd.js} +1 -1
  35. package/dist/assets/{SessionsList-_-3LQsWm.js → SessionsList-CmkI6hmY.js} +2 -2
  36. package/dist/assets/{Showroom-Cb8HIezy.js → Showroom-PcX3gurw.js} +1 -1
  37. package/dist/assets/{System-CmmWc699.js → System-74cpSs_X.js} +1 -1
  38. package/dist/assets/{Terminal-B-DbiagD.js → Terminal-BzqwEea0.js} +1 -1
  39. package/dist/assets/{Viewer-h_DWBxgH.js → Viewer-DhjS-14b.js} +1 -1
  40. package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-ChYA9pOs.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-Bj_EUdNV.js} +1 -1
  41. package/dist/assets/{addon-icons-context-aYGMdVc6.js → addon-icons-context-BfGPQ4xZ.js} +1 -1
  42. package/dist/assets/{assignment-candidates-C73e9ykO.js → assignment-candidates-BWSRqjeY.js} +1 -1
  43. package/dist/assets/{authed-media-OiQVKexs.js → authed-media-CCu_0Mkk.js} +1 -1
  44. package/dist/assets/{board-model-CCAK2YmC.js → board-model-D0x2o-FF.js} +1 -1
  45. package/dist/assets/{device-integration-icon-BStZ5ytk.js → device-integration-icon-RKJ1i9-y.js} +1 -1
  46. package/dist/assets/device-picker-model-CCtDoCaE.js +1 -0
  47. package/dist/assets/{format-XZs_xh1r.js → format-BrcsXZgx.js} +1 -1
  48. package/dist/assets/framework-packages-B7oma9J4.js +1 -0
  49. package/dist/assets/{hostInit-Dugn9T0N.js → hostInit-C9UJbeBX.js} +1 -1
  50. package/dist/assets/i18n-DNh4GW93.js +1 -0
  51. package/dist/assets/index-DOFPItyi.css +2 -0
  52. package/dist/assets/{index-pzq9LOji.js → index-Dm-ruGxs.js} +3 -3
  53. package/dist/assets/{linked-devices-model-CNnR_mjb.js → linked-devices-model-Bd2asZR8.js} +1 -1
  54. package/dist/assets/{location-owned-usage-Cwiz3bVN.js → location-owned-usage-AoW2HSuk.js} +1 -1
  55. package/dist/assets/{mf-entry-bootstrap-0-e18bf152.js → mf-entry-bootstrap-0-44b53b1c.js} +2 -2
  56. package/dist/assets/mount-CCtDoCaE.js +1 -0
  57. package/dist/assets/remoteEntry-CFFHRTAl.js +1 -0
  58. package/dist/assets/{src-DlnTixq9.js → src-DY9QaWNW.js} +1 -1
  59. package/dist/assets/{step-inspector-model-DP-n2a-m.js → step-inspector-model-_xqNTlQX.js} +1 -1
  60. package/dist/assets/{use-scenes-feed-Px1hbQDA.js → use-scenes-feed-Co3WLAh1.js} +1 -1
  61. package/dist/assets/{use-stationary-objects-WqiRmYIc.js → use-stationary-objects-o-ZgylqM.js} +1 -1
  62. package/dist/assets/useEventInvalidation-CCtDoCaE.js +1 -0
  63. package/dist/assets/{useNodeUrlSelection-DW98VTZs.js → useNodeUrlSelection--XA1ndxK.js} +1 -1
  64. package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-CoUIkQxD.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-CX8JLNds.js} +2 -2
  65. package/dist/index.html +7 -7
  66. package/dist/server/addon.js +1 -1
  67. package/package.json +1 -1
  68. package/dist/assets/Addons-RW0QdiVT.js +0 -5
  69. package/dist/assets/DeviceDetail-Dd1ulCyf.js +0 -2
  70. package/dist/assets/IntegrationDetail-2QlbVLE7.js +0 -1
  71. package/dist/assets/Integrations-Cs-b-69p.js +0 -1
  72. package/dist/assets/Integrations-DT3z5Q5Q.js +0 -1
  73. package/dist/assets/MyAccess-ChxQGXAk.js +0 -2
  74. package/dist/assets/Network-C7jEJlX5.js +0 -1
  75. package/dist/assets/Notifications-Dk-cpsUG.js +0 -1
  76. package/dist/assets/device-picker-model-DuRGlFHX.js +0 -1
  77. package/dist/assets/i18n-uD14huY2.js +0 -1
  78. package/dist/assets/index-WAVCQxxk.css +0 -2
  79. package/dist/assets/mount-DuRGlFHX.js +0 -1
  80. package/dist/assets/remoteEntry-C4v7BKsX.js +0 -1
  81. package/dist/assets/useEventInvalidation-DuRGlFHX.js +0 -1
@@ -1 +0,0 @@
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{Dn as f,Fn as p,Ht as m,Pn as h,Vn as g,bt as _,cr as v,dt as y,fr as b,hn as x,st as ee}from"./player-overlays-B4lehTI4.js";import{$t as S,ii as C,qi as w}from"./client-C6c46gRD.js";import{h as T,s as E}from"./video-B-2RwuDj.js";import{t as D}from"./log-in-DtNu6ihw.js";import{t as O}from"./monitor-smartphone-DJqsZ1_F.js";import{t as te}from"./recycle-Clfv9-vM.js";import{Ca as k,Da as A,Dt as j,Or as ne,Ot as M,Pi as N,Sn as re,Yr as P,Za as ie,ft as ae,ka as F,mt as oe,or as I,ri as L,wa as R}from"./src-DlnTixq9.js";import{t as z}from"./i18n-uD14huY2.js";import{t as B}from"./useTranslation-BJr-n0es.js";import{S as V,g as H,gr as U,i as W,mr as G}from"./index-pzq9LOji.js";import{t as K}from"./AdminSectionedPage-OHmEcMxM.js";import{n as se,r as q,t as J}from"./BrokerEditorDialog-0I2FqCxl.js";import{t as ce}from"./NodeAddonsSettingsPanel-DEdzDp8P.js";import{n as Y,r as X,t as le}from"./IntegrationHub-DXhDIgkG.js";c();var Z={connected:`success`,connecting:`warning`,disconnected:`default`,"auth-failed":`danger`,unreachable:`danger`,error:`danger`};function Q({status:e}){return i(L,{variant:Z[e],className:`text-[10px]`,children:e})}function ue({broker:t,interactiveConnectPath:n,interactiveDisconnectPath:r,kindLabel:a,onEdit:s}){let{t:c}=B(),u=l(),d=ee(),[f,p]=o(null),h=F({onSuccess:e=>p(e.ok?{ok:!0}:{ok:!1,error:e.error}),onError:e=>p({ok:!1,error:e instanceof Error?e.message:String(e)})}),v=A({onSuccess:()=>{u.invalidateQueries({queryKey:[[`broker`,`list`]]})}}),y=async()=>{await d({title:c(`brokers.brokerManager.deleteBroker`,`Delete broker`),message:c(`brokers.brokerManager.deleteBrokerIntegrationsThatDepend`,`Delete broker "{{name}}"? Integrations that depend on it will stop working.`,{name:t.name}),confirmLabel:c(`common.delete`,`Delete`),variant:`danger`})&&v.mutate({id:t.id,addonId:t.addonId})},x=n!==void 0&&n.length>0&&t.status!==`connected`,S=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:a}),e(`td`,{className:`px-3 py-2`,children:[i(Q,{status:t.status}),f&&i(`span`,{className:`ml-2 text-[10px] ${f.ok?`text-success`:`text-danger`}`,children:f.ok?`OK`:f.error??c(`common.failedWord`)})]}),i(`td`,{className:`px-3 py-2`,children:e(`div`,{className:`flex items-center justify-end gap-1.5`,children:[x&&e(P,{variant:`primary`,size:`sm`,onClick:()=>{H(n,t.id,()=>{u.invalidateQueries({queryKey:[[`broker`,`list`]]})})},title:c(`brokers.brokerManager.signInOpensAPopup`,`Sign in — opens a popup that closes when done`),children:[i(D,{className:`h-3 w-3`}),` `,c(`brokers.brokerManager.signIn`)]}),S&&e(P,{variant:`outline`,size:`sm`,onClick:()=>{H(r,t.id,()=>{u.invalidateQueries({queryKey:[[`broker`,`list`]]})})},title:c(`brokers.brokerManager.signOutClearsTheLinked`,`Sign out — clears the linked Google account on this broker`),children:[i(E,{className:`h-3 w-3`}),` `,c(`brokers.brokerManager.signOut`)]}),e(P,{variant:`outline`,size:`sm`,onClick:()=>h.mutate({id:t.id,addonId:t.addonId}),disabled:h.isPending,title:c(`brokers.brokerManager.testConnection`,`Test connection`),children:[h.isPending?i(b,{className:`h-3 w-3 animate-spin`}):i(_,{className:`h-3 w-3`}),c(`brokers.brokerManager.test`,`Test`)]}),e(P,{variant:`outline`,size:`sm`,onClick:()=>s(t),title:c(`common.edit`,`Edit`),children:[i(g,{className:`h-3 w-3`}),` `,c(`common.edit`)]}),e(P,{variant:`outline`,size:`sm`,className:`border-danger/40 text-danger hover:bg-danger/10`,onClick:()=>{y()},disabled:v.isPending,title:c(`common.delete`,`Delete`),children:[v.isPending?i(b,{className:`h-3 w-3 animate-spin`}):i(m,{className:`h-3 w-3`}),c(`common.delete`,`Delete`)]})]})})]})}function de({addonId:t}={}){let{t:r}=B(),a=R({}),s=n(()=>se(a.data).filter(e=>t===void 0||e.addonId===t),[a.data,t]),[c,l]=o(!1),[u,d]=o(null),{options:f}=q(t===void 0?{}:{addonId:t}),m=n(()=>new Map(f.map(e=>[e.kind,e.label])),[f]),h=n(()=>{let e=new Map;for(let t of f)e.has(t.kind)||e.set(t.kind,{...t.interactiveConnectPath===void 0?{}:{connect:t.interactiveConnectPath},...t.interactiveDisconnectPath===void 0?{}:{disconnect:t.interactiveDisconnectPath}});return e},[f]);return e(`div`,{className:`space-y-3`,children:[i(`div`,{className:`flex items-center justify-end`,children:e(P,{variant:`primary`,size:`sm`,onClick:()=>l(!0),disabled:f.length===0,title:f.length===0?r(`brokers.brokerManager.noBrokerProvidersAvailable`,`No broker providers available`):void 0,children:[i(p,{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&&s.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.`)})}),s.map(e=>{let t=h.get(e.kind);return i(ue,{broker:e,...t?.connect===void 0?{}:{interactiveConnectPath:t.connect},...t?.disconnect===void 0?{}:{interactiveDisconnectPath:t.disconnect},kindLabel:m.get(e.kind)??e.kind,onEdit:d},e.id)})]})]})}),c&&i(J,{...t===void 0?{}:{addonId:t},onClose:()=>l(!1),onSaved:()=>l(!1)}),u&&i(J,{broker:u,onClose:()=>d(null),onSaved:()=>d(null)})]})}function fe(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 pe(e){let t=e,n=t?.manifest;if(n?.id===void 0)return null;let r=(n.capabilities??[]).map(fe).filter(e=>e!==null);return{addonId:n.id,displayName:n.packageDisplayName??n.name??n.id,capNames:r,processState:t?.process?.state??null}}function me(e,t){return Object.entries(e).filter(([,e])=>e===t).map(([e])=>e)}function he(e,t){return t.find(t=>e.capNames.includes(t))??null}function ge(e){switch(e){case`running`:return{state:`ok`,label:z.t(`helpers.connectivityModel.running`)};case`crashed`:case`failed`:return{state:`error`,label:e};case`stopped`:case`disabled`:return{state:`off`,label:z.t(`helpers.connectivityModel.stopped`)};default:return{state:`unknown`,label:e??z.t(`common.unknownWord`)}}}c();var _e=[`wasteCollections`,`listSources`],ve=[`wasteCollections`,`listCountries`];function ye(e){return e instanceof Error?e.message:String(e)}function be(e){return typeof e!=`object`||!e?!1:Array.isArray(Reflect.get(e,`sections`))}function xe(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 Se(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 Ce(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 we(e,t,n){return{sections:[{id:`picker`,title:z.t(`system.wasteSettingsSources.countryService`,`Country & service`),columns:2,fields:[{type:`select`,key:`countryId`,label:z.t(`system.wasteSettingsSources.country`,`Country`),options:[{value:``,label:z.t(`system.wasteSettingsSources.selectCountry`,`Select country…`)},...e.map(e=>({value:e.id,label:e.label}))]},{type:`select`,key:`serviceId`,label:z.t(`system.wasteSettingsSources.service`,`Service`),options:[{value:``,label:n===``?z.t(`system.wasteSettingsSources.pickACountryFirst`,`Pick a country first`):z.t(`system.wasteSettingsSources.selectService`,`Select service…`)},...t.map(e=>({value:e.id,label:e.label}))]}]}]}}function Te({addonId:c,capName:f}){let{t:h}=B(),g=y(),_=l(),v=ee(),b=ae({editKey:`wasteEdit`,newKey:`wasteNew`}),[x,S]=o(!1),[C,w]=o(null),[T,E]=o({countryId:``,serviceId:``}),[D,O]=o({label:h(`system.wasteSettingsSources.newSource`,`New source`),enabled:!0}),k=t(null),A=typeof T.countryId==`string`?T.countryId:``,j=typeof T.serviceId==`string`?T.serviceId:``,M=r((e,t)=>g.trpcClient.addons.custom.mutate({addonId:c,action:e,input:t}),[c,g]),N=s({queryKey:[..._e,c],queryFn:async()=>xe(await M(`listSources`,{}))}),ie=s({queryKey:[...ve,c],queryFn:async()=>Se(await M(`listCountries`,{}))}),F=s({queryKey:[`wasteCollections`,`listServices`,c,A],enabled:A!==``,queryFn:async()=>Ce(await M(`listServices`,{countryId:A}))}),R=s({queryKey:[`wasteCollections`,`serviceFormSchema`,c,j],enabled:j!==``,queryFn:async()=>M(`serviceFormSchema`,{serviceId:j})}),z=N.data??[],V=ie.data??[],H=F.data??[],U=be(R.data)?R.data:void 0,W=n(()=>we(V,A===``?[]:H,A),[V,H,A]),G=b.state,K=G.mode===`edit`?z.find(e=>e.id===G.id)??null:null;a(()=>{if(b.state.mode===`edit`&&K!==null){let e=`edit:${K.id}`;if(k.current===e)return;k.current=e,w(null),E({countryId:K.countryId??``,serviceId:K.serviceId??``}),O(K.formValues===void 0?{label:K.label,enabled:K.enabled}:{...K.formValues});return}if(b.state.mode===`new`){if(k.current===`new`)return;k.current=`new`,w(null),E({countryId:``,serviceId:``}),O({label:h(`system.wasteSettingsSources.newSource`,`New source`),enabled:!0})}},[K,b.state]),a(()=>{if(b.state.mode!==`new`||j===``)return;let e=H.find(e=>e.id===j);e&&O(t=>{let n=t.label;return typeof n==`string`&&n!==``&&n!==`New source`?t:{...t,label:e.title}})},[b.state.mode,j,H]);let se=r(e=>{E(t=>{let n=typeof e.countryId==`string`?e.countryId:``;return n===(typeof t.countryId==`string`?t.countryId:``)?e:{countryId:n,serviceId:``}})},[]),q=r(async()=>{await _.invalidateQueries({queryKey:_e})},[_]),J=u({mutationFn:async e=>M(`deleteSource`,{id:e}),onSuccess:async()=>q()}),Y=r(async e=>{await v({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 J.mutateAsync(e.id),b.state.mode===`edit`&&b.state.id===e.id&&(b.close(),k.current=null))},[v,J,b,h]),X=r(async()=>{let e=D.label,t=typeof e==`string`&&e.trim()!==``?e.trim():``;if(t===``){w(`Label is required.`);return}if(j===``){w(`Pick a country and a service.`);return}let n=b.state.mode===`new`,r=K?.id;if(!n&&(r===void 0||r===``)){w(`That source is no longer available.`);return}let i=D.enabled,a={...D};delete a.label,delete a.enabled,S(!0),w(null);try{n?await M(`createSource`,{label:t,serviceId:j,args:a,enabled:typeof i==`boolean`?i:!0}):r!==void 0&&await M(`updateSource`,{id:r,label:t,serviceId:j,args:a,enabled:typeof i==`boolean`?i:!0}),await q(),b.close(),k.current=null}catch(e){w(ye(e))}finally{S(!1)}},[M,K,b,D,q,j]),le=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(L,{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(P,{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(),Y(e)},children:i(m,{className:`h-3.5 w-3.5 text-danger`})})}],[Y,h]),Z=b.state.mode===`new`,Q=Z||K!==null,ue=`${j}:${Z?`new`:K?.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(P,{type:`button`,size:`sm`,"data-testid":`waste-sources-add`,onClick:()=>b.openNew(),children:[i(p,{className:`h-3.5 w-3.5`}),h(`system.wasteSettingsSources.addSource`,`Add source`)]})]}),N.isError?i(`p`,{className:`text-sm text-danger`,children:h(`system.wasteSettingsSources.couldNotLoadSources`,`Could not load sources.`)}):null,N.isPending?i(ne,{className:`h-32 w-full`}):i(re,{columns:le,rows:z,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(oe,{open:Q,onClose:()=>{b.close(),w(null),k.current=null},title:Z?h(`system.wasteSettingsSources.addWasteSource`,`Add waste source`):h(`system.wasteSettingsSources.edit`,`Edit {{value1}}`,{value1:K?.label??`source`}),icon:te,width:`xl`,testId:`waste-source-editor`,error:C,footer:i(P,{type:`button`,size:`sm`,disabled:x||j===``,onClick:()=>void X(),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(I,{schema:W,values:T,onChange:se},`picker:${A}:${H.length}`)}),j!==``&&U!==void 0?i(I,{schema:U,values:D,onChange:O,bare:!0},ue):j!==``&&R.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(ce,{nodeId:`hub`,addonIds:[c],level:`global`,capability:f,hideSectionChrome:!0})]})}c();var $=1e4,Ee={"device-export":`exporters`,exporters:`exporters`,email:`email`,broker:`brokers`,brokers:`brokers`,"message-brokers":`brokers`,calendar:`calendars`,calendars:`calendars`,"calendar-source":`calendars`},De=[{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:v,installLabelKey:`system.connectivity.emailInstall`,emptyTitleKey:`system.connectivity.emailEmptyTitle`,emptyDescriptionKey:`system.connectivity.emailEmptyDescription`},{sectionId:`brokers`,kind:`broker`,labelKey:`system.connectivity.brokers`,icon:f,installLabelKey:`system.connectivity.brokersInstall`,emptyTitleKey:`system.connectivity.brokersEmptyTitle`,emptyDescriptionKey:`system.connectivity.brokersEmptyDescription`},{sectionId:`calendars`,kind:`calendar`,labelKey:`system.connectivity.calendars`,icon:T,installLabelKey:`system.connectivity.calendarsInstall`,emptyTitleKey:`system.connectivity.calendarsEmptyTitle`,emptyDescriptionKey:`system.connectivity.calendarsEmptyDescription`}];function Oe(t,n,r,a){let o=me(S,t.kind),s=n.flatMap(n=>{let a=he(n,o);if(a===null)return[];let s=ge(n.processState);return[{id:n.addonId,name:n.displayName,fallbackIcon:t.icon,state:s.state,stateLabel:s.label,render:()=>i(Y,{addonId:n.addonId,displayName:n.displayName,capName:a,isActive:n.processState===`running`,badges:e(d,{children:[i(Me,{processState:n.processState}),i(Ne,{kind:t.kind,addonId:n.addonId})]}),lead:t.kind===`device-export`?i(M,{addonId:n.addonId}):void 0,panels:je(t.kind,n.addonId,e=>r(`/devices/${e}`)),settingsContent:n.addonId===`waste-collections`?i(Te,{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 ke({descriptor:e,rows:t,isLoading:r}){let{t:a}=B(),o=G(),s=n(()=>Oe(e,t,o,a),[e,t,o,a]);return i(le,{embedded:!0,icon:e.icon,title:a(e.labelKey),subtitle:null,groups:[s],isLoading:r,emptyTitle:a(e.emptyTitleKey),emptyDescription:a(e.emptyDescriptionKey)})}function Ae(){let{t:e}=B(),t=N(void 0,{refetchInterval:$}),[r,o]=U(),s=V(`/system/integrations`,{t:e,isAdmin:!0})??{icon:h,title:e(`admin.system.integrations.connectivity`,`Connectivity`)};a(()=>{let e=r.get(`tab`);if(e===null)return;let t=Ee[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(pe).filter(e=>e!==null),[t.data]),l=n(()=>De.map(n=>({id:n.sectionId,label:e(n.labelKey),ownedParams:W,content:i(ke,{descriptor:n,rows:c,isLoading:t.isLoading})})),[t.isLoading,c,e]);return i(K,{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 je(e,t,n){return e===`device-export`?[{id:`devices`,title:z.t(`admin.system.integrations.devices`,`Devices`),icon:O,placement:`end`,content:i(j,{addonId:t,onOpenDevice:n,showSetup:!1})}]:e===`broker`?[{id:`connections`,title:z.t(`admin.system.integrations.connections`,`Connections`),icon:f,content:i(de,{addonId:t})}]:[]}function Me({processState:e}){let{state:t,label:n}=ge(e);return i(L,{variant:t===`ok`?`success`:t===`error`?`danger`:`default`,className:`${X} capitalize`,children:n})}function Ne({kind:e,addonId:t}){return e===`broker`?i(Pe,{addonId:t}):e===`device-export`?i(Fe,{addonId:t}):null}function Pe({addonId:e}){let{t}=B(),{data:n}=k({addonId:e},{refetchInterval:$,retry:!1}),r=w.safeParse(n);if(!r.success)return null;let{brokerCount:a,connectedCount:o}=r.data;return i(L,{variant:`info`,className:X,children:o>0?t(`system.connectivity.connectionsConnected`,{count:a,connected:o}):t(`system.connectivity.connections`,{count:a})})}function Fe({addonId:e}){let{t}=B(),{data:n}=ie({addonId:e},{refetchInterval:$,retry:!1}),r=C.safeParse(n);if(!r.success)return null;let{linkState:a,exposedDeviceCount:o}=r.data;return i(L,{variant:a===`linked`?`success`:a===`error`?`danger`:`default`,className:X,children:t(`admin.system.integrations.exposed`,`{{linkState}} · {{exposedDeviceCount}} exposed`,{linkState:a,exposedDeviceCount:o})})}export{Ae as IntegrationsPage};
@@ -1 +0,0 @@
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{Di as u,En as d,Fn as f,Ni as p,Oi as m,Pn as h,Ti as g,dt as _,fr as ee,gn as v,gt as te,kn as ne,vn as y,vr as re}from"./player-overlays-B4lehTI4.js";import{t as b}from"./table-2-DecfWh5K.js";import{At as ie,Cs as ae,Do as x,F as oe,Mt as S,Tr as se,Ts as C,Yr as w,_d as T,at as E,bs as D,gd as O,go as ce,io as le,kt as ue,r as k,wd as A,xi as j}from"./src-DlnTixq9.js";import{t as M}from"./i18n-uD14huY2.js";import{t as N}from"./useTranslation-BJr-n0es.js";import{cr as P,gr as F,mr as de,pr as fe}from"./index-pzq9LOji.js";import{t as I}from"./AdminPage-Bn1s1Zyw.js";import"./useEventInvalidation-DuRGlFHX.js";import{t as L}from"./device-integration-icon-BStZ5ytk.js";import{i as pe,n as me,r as R,t as he}from"./ScanNetworkModal-DYNrpcKO.js";s();function ge({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(O,{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(_e,{integration:e,expanded:r(e),onToggleExpand:a,onOpen:s,renderExpanded:c},e.id))})]})}function _e({integration:t,expanded:n,onToggleExpand:r,onOpen:a,renderExpanded:o}){return e(`article`,{"data-testid":`integration-card-${t.id}`,className:A(`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(ve,{integration:t,expanded:n,onToggleExpand:r,onOpen:a}),n?i(`div`,{className:`min-w-0`,children:o(t)}):null]})}function ve({integration:t,expanded:n,onToggleExpand:r,onOpen:a}){let{t:o}=N(),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(w,{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(z,{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(T,{type:`button`,variant:`ghost`,size:`sm`,icon:n?u:g,"aria-label":s,"aria-expanded":n,onClick:e=>V(e,t.addonId,r)})})]})]})}function z({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(P,{type:t.addonId,size:`xl`}),i(`p`,{className:`w-full text-center text-xs font-semibold text-foreground`,children:t.name}),i(B,{addonId:t.addonId})]})}function B({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 V(e,t,n){e.stopPropagation(),n(t)}s();var H=`camstack.admin.integrations.view`;function U(e){return e===`table`||e===`grid`}function W(){try{return typeof window>`u`?null:window.localStorage}catch{return null}}function G(e=W()){if(e===null)return`table`;try{let t=e.getItem(H);return U(t)?t:`table`}catch{return`table`}}function K(e,t=W()){if(t!==null)try{t.setItem(H,e)}catch{}}function ye(){let[e,t]=o(()=>G());return[e,r(e=>{t(e),K(e)},[])]}s();function q(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 be(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 xe({providerId:t,onImport:n,onSkip:r}){let{t:s}=N(),[c,l]=o(new Set),u=ce(),d=u.data,f=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(f)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=d??[];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(m,{className:`h-3 w-3 text-primary-foreground`})}),i(p,{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 J=`(hover: none) and (pointer: coarse)`;function Y(){if(typeof window>`u`||typeof window.matchMedia!=`function`)return!0;try{return!window.matchMedia(J).matches}catch{return!0}}s();function X({onSelect:r,onClose:s,pendingAddonId:c=null}){let{t:l}=N(),u=de(),[d,f]=o(``),p=t(null),{data:m,isLoading:h}=ae();a(()=>{h||!Y()||p.current?.focus()},[h]);let g=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(h)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 _=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(O,{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:g.map(t=>{let n=t.instanceMode===`unique`&&t.existingInstances.length>0,a=c===t.addonId,o=_;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(ee,{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(v,{className:`h-3 w-3`}),l(`integrations.manage`)]}):null]},t.addonId)})}),g.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 Se(e){let t=e=>{if(e.type===`separator`||e.type===`info`||e.type===`button`)return e;if(e.type===`group`)return{...e,fields:e.fields.map(e=>t(e))};let{value:n,...r}=e;return r};return{...e.tabs?{tabs:e.tabs}:{},sections:e.sections.map(e=>({...e,fields:e.fields.map(t)}))}}var Ce=2e4;function we({open:t,onClose:r,seed:s=null}){let{t:u}=N(),d=de(),f=c(),[p,m]=o(`picker`),[h,g]=o(null),[_,v]=o(null),[ne,y]=o(`manual`),[re,b]=o(null),[ie,x]=o(``),[oe,S]=o(null),[se,C]=o(null),[w,T]=o(!1),[E,O]=o({}),[ue,k]=o(``),A=s?.config.host,M=s===null?``:`${s.addonId}\0${s.name}\0${typeof A==`string`?A:``}`;t&&s!==null&&ue!==M&&(k(M),g(s.addonId),x(s.name),O({...s.config}),m(`config`));let P=ae(void 0,{enabled:t&&s!==null}),{data:F}=j({addonId:h??``,nodeId:`hub`},{enabled:h!=null}),fe=n(()=>F?Se(F):null,[F]),I=D({onSuccess:()=>f.invalidateQueries({queryKey:[[`integrations`]]})}),L=ce(),me=L.data;a(()=>{if(!t||s===null)return;let e=P.data?.find(e=>e.addonId===s.addonId);e&&(T(e.canTest),y(e.discoveryMode))},[t,s,P.data]),a(()=>{p!==`discovery`||!_||!h||L.isPending||L.data||L.mutate({addonId:h})},[p,_,h,L]);let he=le({onSuccess:()=>f.invalidateQueries({queryKey:[[`deviceManager`]]})});function ge(e,t,n,r,i,a,o,s){if(!I.isPending){if(g(e),T(s),y(n),x(r),C(null),o===`broker`){if(!a){C(`Addon '${e}' declares mode 'broker' but no brokerKind in its manifest`);return}b(a),m(`broker`);return}if(o===`account`){m(`config`);return}_e(e,r)}}async function _e(e,t){try{let n=await I.mutateAsync({addonId:e,name:t,settings:{}});r(),H(),d(`/integrations/${n.id}?add=1`)}catch{}}async function ve(e){if(h)try{let t=await I.mutateAsync({addonId:h,name:e.name,settings:e.config,secretKeys:[...e.secretKeys]});v(t.id),S(t.id),ne===`auto`||ne===`both`?m(`discovery`):V(t.id,{openAdd:!0})}catch{}}async function z(e){if(h)try{let t=await I.mutateAsync({addonId:h,name:ie,settings:{brokerId:e}});S(t.id),v(t.id),V(t.id)}catch{}}async function B(e){if(h){for(let t of e){let e=me?.find(e=>e.stableId===t);e&&await he.mutateAsync({addonId:h,candidate:e,...oe===null?{}:{integrationId:oe}})}V()}}function V(e,t){let n=e??_??h;r(),H(),n&&d(t?.openAdd===!0?`/integrations/${n}?add=1`:`/integrations/${n}`)}function H(){m(`picker`),g(null),v(null),y(`manual`),b(null),x(``),S(null),C(null),T(!1),O({}),k(``)}function U(){r(),H()}q(t);let W=I.isPending,G=be(W,Ce);if(!t)return null;let K={picker:u(`integrations.newIntegration`),config:u(`integrations.configureIntegration`),discovery:u(`integrations.importDevices`),broker:u(`integrations.connectBroker`,{defaultValue:`Connect a broker`})},ye=W?h:null,J=I.error,Y=W&&!G;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:Y?void 0:U}),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:K[p]}),i(`button`,{onClick:U,disabled:Y,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(te,{className:`h-4 w-4`})})]}),e(`div`,{className:`px-5 py-4 flex-1 overflow-y-auto overscroll-contain`,children:[J&&!W&&i(`div`,{className:`mb-3 rounded-lg border border-destructive/40 bg-destructive/10 px-3 py-2 text-xs text-destructive`,children:J instanceof Error?J.message:String(J)}),p===`picker`&&e(l,{children:[se&&i(`div`,{className:`mb-3 rounded-lg border border-destructive/40 bg-destructive/10 px-3 py-2 text-xs text-destructive`,children:se}),i(X,{onSelect:ge,onClose:U,pendingAddonId:ye})]}),p===`config`&&h&&i(R,{addonId:h,configSchema:fe??null,canTest:w,initialName:typeof E.host==`string`?ie:void 0,initialConfig:{...E},onSave:ve,onBack:()=>{O({}),m(`picker`)}},M.length>0?M:h),p===`broker`&&re&&i(pe,{kind:re,onResolved:e=>{z(e)},onBack:()=>m(`picker`)}),p===`discovery`&&_&&i(xe,{providerId:_,onImport:B,onSkip:V})]}),W&&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(ee,{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…`})}),!G&&i(`p`,{className:`text-[10px] text-foreground-subtle`,children:u(`integrations.creatingHint`,{defaultValue:`Waiting for the addon to restart and register`})}),G&&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:U,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 Te({integration:t,expanded:n,onToggleExpand:r}){let{t:a}=N();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?u:g,{className:`h-3.5 w-3.5`})}),i(P,{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 Ee(e){let{isExpanded:t,onToggleExpand:n}=e;return[{key:`name`,header:M.t(`integrations.integrationColumns.integration`,`Integration`),headerClassName:`w-[55%]`,cell:e=>i(Te,{integration:e,expanded:t(e),onToggleExpand:n})},{key:`devices`,header:M.t(`integrations.integrationColumns.devices`,`Devices`),headerClassName:`w-[15%]`,cellClassName:`text-[11px] text-foreground-subtle`,cell:e=>M.t(`integrations.integrationColumns.deviceCount`,{count:e.deviceCount})},{key:`status`,header:M.t(`integrations.integrationColumns.status`,`Status`),headerClassName:`w-[15%]`,cell:e=>i(E,{status:e.status})}]}s();function De(e){if(!e.enabled)return`disabled`;switch(e.processState){case`running`:return`running`;default:return`stopped`}}var Z=`expand`;function Oe(){let{t}=N(),s=de(),c=fe(),u=_(),[p]=F(),[m,g]=ye(),[ee,v]=o(!1),[te,y]=o(null),ae=r(()=>{y(null),v(!0)},[]),w=r(()=>{v(!1),y(null)},[]),T=r(e=>{D(!1),y(e),v(!0)},[]),[E,D]=o(!1);a(()=>{let e=me(c.state);e!==null&&(y(e),v(!0),s(`/integrations`,{replace:!0,state:null}))},[c.state,s]);let O=p.get(`setup`);a(()=>{O===null||O.length===0||(y({addonId:O,name:O,config:{}}),v(!0))},[O]);let ce=r(()=>D(!0),[]),le=r(()=>D(!1),[]);k([`integrations`],[`integration.enabled`,`integration.disabled`,`integration.deleted`,`provider.started`,`provider.stopped`,`addon.installed`,`addon.uninstalled`,`addon.started`,`addon.stopped`,`addon.updated`]),k([`deviceManager`],[`device.registered`,`device.unregistered`,`device.online`,`device.offline`,`device.disabled`,`device.enabled`]);let{data:j,isLoading:M,isError:P,refetch:pe}=C(void 0),{data:R,isLoading:_e,isError:ve,refetch:z}=x({projection:`slim`}),B=n(()=>R??[],[R]),V=n(()=>j??[],[j]),H=n(()=>{let e=new Map;for(let t of B)e.set(t.id,{id:t.id,name:t.name??t.stableId??`#${String(t.id)}`});return e},[B]),U=n(()=>ie(j),[j]),W=n(()=>{let e=new Map;for(let t of S(B)){let n=U(t);if(n.kind!==`resolved`)continue;let r=n.integration.id;e.set(r,(e.get(r)??0)+1)}return e},[B,U]),G=n(()=>V.map(e=>({id:e.id,addonId:e.addonId,name:e.name,enabled:e.enabled,status:De(e),deviceCount:W.get(e.id)??0})),[V,W]),K=p.get(Z),q=r(e=>{let t=new URLSearchParams(window.location.search);t.get(Z)===e?t.delete(Z):t.set(Z,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`))},[]),be=r(e=>s(`/integrations/${e.id}`),[s]),xe=r(e=>H.get(e)??null,[H]),J=r(e=>s(`/devices/${String(e)}`),[s]),Y=r(e=>i(ue,{context:`integration-detail`,devices:B,trpc:u.trpcClient,integrationOf:U,forceIntegrationId:e.id,urlScope:`nested`,lsKey:`integrations:nested:${e.addonId}`,resolveIntegrationIcon:L,resolveParent:xe,onNavigate:J}),[B,u.trpcClient,U,xe,J]),X=r(e=>K===e.addonId,[K]),Se=n(()=>Ee({isExpanded:X,onToggleExpand:q}),[X,q]),Ce=r(e=>`${e.name} ${e.addonId}`,[]),Te=r(e=>e.addonId,[]),Oe=r(()=>{pe(),z()},[pe,z]),Q=P===!0||ve===!0,$=!Q&&(M||_e||j===void 0||R===void 0),ke=V.length>0,Ae=[{id:`table`,label:t(`integrations.viewTable`,`Table`),icon:b},{id:`grid`,label:t(`integrations.viewGrid`,`Grid`),icon:re}];return e(I,{icon:h,title:t(`nav.integrations`,`Integrations`),actions:e(l,{children:[i(oe,{ariaLabel:t(`integrations.viewLabel`,`Layout`),value:m,onChange:g,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(d,{className:A(`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(ne,{className:`h-3.5 w-3.5`}),t(`integrations.scanNetwork`,`Scan network`)]}),e(`button`,{onClick:ae,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(f,{className:`h-3.5 w-3.5`}),t(`integrations.newIntegration`,`New Integration`)]})]}),children:[Q&&i(se,{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&&m===`table`&&i(ue,{mode:`generic`,items:G,getKey:Te,getSearchText:Ce,columns:Se,onRowClick:be,isExpanded:X,renderExpanded:Y,searchPlaceholder:t(`integrations.search`,{defaultValue:`Search integrations…`}),emptyLabel:t(`integrations.empty`,{defaultValue:`No integrations found.`})}),!Q&&!$&&ke&&m===`grid`&&i(ge,{rows:G,isExpanded:X,onToggleExpand:q,onOpen:be,renderExpanded:Y,searchPlaceholder:t(`integrations.search`,{defaultValue:`Search integrations…`}),emptyLabel:t(`integrations.empty`,{defaultValue:`No integrations found.`})}),i(we,{open:ee,onClose:w,seed:te}),i(he,{open:E,onClose:le,onSetupIntegration:T})]})}export{Oe as IntegrationsPage};
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./browser-BHo8W_uH.js","./rolldown-runtime-Cyuzqnbw.js"])))=>i.map(i=>d[i]);
2
- import{a as e}from"./rolldown-runtime-Cyuzqnbw.js";import{t}from"./vite-preload-helper-kNaey6uv.js";import{C as n,J as r,K as i,S as a,V as o,Y as s,a as c,et as l,t as u,x as d}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{Ht as f,Q as p,Vn as m,Wr as h,Zi as g,an as _,bi as v,br as y,dt as b,fr as x,hr as S,lr as C,pa as w,pn as T,ri as E,st as D,xi as O,zt as k}from"./player-overlays-B4lehTI4.js";import{Gr as A,Kr as j}from"./client-C6c46gRD.js";import{s as M}from"./video-B-2RwuDj.js";import{t as N}from"./key-round-DmUg5DWL.js";import{t as ee}from"./monitor-smartphone-DJqsZ1_F.js";import{t as te}from"./unlink-Chgtl9c5.js";import{Et as ne,Ks as re,Ld as P,Wr as F,Ws as I,Yr as L,dd as ie,lr as ae,mn as oe,ur as se}from"./src-DlnTixq9.js";import{t as ce}from"./i18n-uD14huY2.js";import{t as R}from"./useTranslation-BJr-n0es.js";import"./mount-DuRGlFHX.js";import{_ as le,b as z,er as B,fr as V,gr as H,ur as U,v as W,y as ue}from"./index-pzq9LOji.js";import{t as de}from"./AdminSectionedPage-OHmEcMxM.js";import{t as fe}from"./AdminPage-Bn1s1Zyw.js";import{O as pe,T as me,_ as G,a as he,h as ge,k as _e,r as ve,t as K,v as ye}from"./SessionsList-_-3LQsWm.js";l();var be=`${A}/connect`,q={public:0,mesh:1,lan:2,"lan-ipv6":3};function xe(e){switch(e.kind){case`public`:return e.interfaceKind===`vpn`?`mesh`:`public`;case`lan-ipv4`:return`lan`;case`lan-ipv6`:return`lan-ipv6`;case`custom`:return`public`;case`loopback`:case`app-link`:return null}}function J(e){return j(e)}function Se(e){return e.startsWith(`https://`)}function Ce(e){let t=e.flatMap(e=>{let t=xe(e),n=J(e.baseUrl);return t===null||n===null?[]:[{endpoint:e,tier:t,origin:n}]}).toSorted((e,t)=>q[e.tier]-q[t.tier]||Number(t.endpoint.plausible)-Number(e.endpoint.plausible)||e.endpoint.priority-t.endpoint.priority),n=new Set;return t.flatMap(({endpoint:e,tier:t,origin:r})=>n.has(r)?[]:(n.add(r),[{origin:r,label:e.label,tier:t,secure:Se(r),plausible:e.plausible}]))}function we(e,t,n=null){for(let r of[t,n]){if(r===null)continue;let t=J(r),n=e.find(e=>e.origin===t);if(n!==void 0)return n}return e[0]??null}function Te(e){let t=new URL(be);return t.searchParams.set(`hub`,e),t.toString()}var Ee=176,Y={scheme:`https`};function De(){let{t:e}=R(),t=re(Y),r=I(Y).data?.roles.publicEndpoint.resolved??null;return n(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[n(`div`,{className:`px-4 py-2.5 border-b border-border flex items-center gap-2`,children:[a(_,{className:`h-3.5 w-3.5 text-foreground-subtle`}),a(`div`,{className:`text-xs font-semibold text-foreground`,children:e(`connectPhone.title`)})]}),n(`div`,{className:`p-4 space-y-3`,children:[a(`p`,{className:`text-[11px] text-foreground-subtle`,children:e(`connectPhone.description`)}),t.isPending?n(`div`,{className:`flex items-center gap-2 text-[11px] text-foreground-subtle`,children:[a(x,{className:`h-3.5 w-3.5 animate-spin`}),e(`connectPhone.loading`)]}):t.isError?n(`div`,{className:`flex items-start gap-2 text-[11px] text-danger`,children:[a(k,{className:`h-3.5 w-3.5 mt-0.5 shrink-0`}),n(`div`,{className:`flex-1 min-w-0 space-y-1.5`,children:[a(`div`,{className:`break-words`,children:e(`connectPhone.error`,{message:t.error.message})}),a(L,{size:`sm`,variant:`ghost`,onClick:()=>void t.refetch(),children:e(`connectPhone.retry`)})]})]}):a(Oe,{candidates:Ce(t.data.endpoints),preferredOrigin:r})]})]})}function Oe({candidates:e,preferredOrigin:t}){let{t:r}=R(),[o,c]=s(null),l=we(e,o,t),u=i(()=>l?Te(l.origin):null,[l]);if(l===null||u===null)return a(`p`,{className:`text-[11px] text-foreground-subtle`,children:r(`connectPhone.empty`)});let d=e=>r(`connectPhone.tier.${e}`),f=e.map(e=>({value:e.origin,label:`${d(e.tier)} — ${e.origin}`}));return n(`div`,{className:`flex flex-col sm:flex-row gap-4`,children:[a(ae,{value:u,size:Ee,alt:r(`connectPhone.qrAlt`),className:`self-start`}),n(`div`,{className:`flex-1 min-w-0 space-y-3`,children:[n(`label`,{className:`block space-y-1`,children:[a(`span`,{className:`text-[11px] font-medium text-foreground`,children:r(`connectPhone.addressLabel`)}),a(ie,{value:l.origin,options:f,onChange:e=>c(e.target.value)}),n(`span`,{className:`block text-[10px] text-foreground-subtle`,children:[d(l.tier),` · `,l.label]})]}),!l.secure&&a(X,{text:r(`connectPhone.insecure`)}),!l.plausible&&a(X,{text:r(`connectPhone.implausible`)}),n(`div`,{className:`space-y-1`,children:[a(`span`,{className:`text-[11px] font-medium text-foreground`,children:r(`connectPhone.linkLabel`)}),n(`div`,{className:`flex items-center gap-1 rounded-md border border-border bg-background px-2 py-1`,children:[a(`code`,{className:`flex-1 min-w-0 font-mono text-[11px] text-foreground break-all select-all`,children:u}),a(oe,{value:u,srLabel:r(`connectPhone.linkLabel`)})]})]}),a(`p`,{className:`text-[11px] text-foreground-subtle`,children:r(`connectPhone.signInHint`)})]})]})}function X({text:e}){return n(`div`,{className:`flex items-start gap-2 rounded-md border border-warning/30 bg-warning/5 px-2.5 py-1.5 text-[11px] text-foreground`,children:[a(k,{className:`h-3.5 w-3.5 text-warning mt-0.5 shrink-0`}),a(`span`,{children:e})]})}l();function ke(e){return new Date(e).toLocaleDateString()}function Ae(){let{t:e}=R(),t=D(),i=P.useUtils(),c=P.auth.listLinkableProviders.useQuery(),l=P.auth.listOwnExternalIdentities.useQuery(),[u,d]=s(null),[f,m]=s(()=>z(window.location.search)),h=r(null),g=G(`Linking a sign-in account`),_=r(null);o(()=>()=>_.current?.(),[]);let[y,b]=s(null);o(()=>{if(f===null)return;let e=new URL(window.location.href);e.searchParams.delete(`linked`),e.searchParams.delete(`linkError`),window.history.replaceState({},``,e.pathname+e.search+e.hash)},[f]);let C=P.auth.beginExternalLink.useMutation({onSuccess:({url:e})=>{let t=h.current;if(h.current=null,t===null||t.closed){window.location.assign(e);return}let n=e=>{b(null),m(z(`?${e}`)),i.auth.listOwnExternalIdentities.invalidate()};_.current?.(),_.current=W(t,{onReturn:e=>{e.target===`profile`&&n(e.query)},onDone:e=>{e.target===`profile`&&n(e.query)},onClosed:()=>{_.current?.(),_.current=null,i.auth.listOwnExternalIdentities.invalidate()}}),t.location.href=p(ue(e))},onError:e=>{h.current?.close(),h.current=null,b(null),d(e.message)}}),w=P.auth.unlinkOwnExternalIdentity.useMutation({onSuccess:()=>void i.auth.listOwnExternalIdentities.invalidate(),onError:e=>d(e.message)}),T=c.data??[],E=l.data??[],k=y!==null&&E.some(e=>e.provider===y);if(o(()=>{!k||y===null||(b(null),m({kind:`linked`,provider:y}))},[k,y]),T.length===0&&E.length===0)return null;let A=new Set(E.map(e=>e.provider)),j=e=>T.find(t=>t.provider===e)?.label??e,M=async(n,r)=>{await t({title:e(`users.linkedSignInsSection.unlinkSignInAccount`,`Unlink sign-in account`),message:e(`users.linkedSignInsSection.stopSigningInWithThis`,`Stop signing in with this {{label}} account?`,{label:r}),confirmLabel:e(`users.linkedSignInsSection.unlink`,`Unlink`),variant:`danger`})&&(d(null),w.mutate({provider:n.provider,subject:n.subject}))};return n(`div`,{"data-testid":`linked-sign-ins`,className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[g.dialog,n(`div`,{className:`px-4 py-2.5 border-b border-border flex items-center gap-2`,children:[a(S,{className:`h-3.5 w-3.5 text-foreground-subtle`}),a(`div`,{className:`text-xs font-semibold text-foreground`,children:e(`users.linkedSignInsSection.linkedSignInAccounts`,`Linked sign-in accounts`)})]}),n(`div`,{className:`p-4 space-y-3`,children:[a(`p`,{className:`text-[11px] text-foreground-subtle`,children:e(`users.linkedSignInsSection.signInWithAnExternal`,`Sign in with an external account instead of your password. Only accounts you link here can sign you in; your two-factor authentication still applies.`)}),f?.kind===`linked`&&n(`div`,{className:`flex items-center gap-2 rounded-md border border-emerald-500/30 bg-emerald-500/5 px-3 py-2 text-xs text-foreground`,children:[a(v,{className:`h-3.5 w-3.5 text-emerald-500 shrink-0`}),e(`users.linkedSignIns.linkedNotice`,{provider:j(f.provider)})]}),(f?.kind===`error`||u)&&n(`div`,{className:`flex items-center gap-2 rounded-md border border-danger/20 bg-danger/10 px-3 py-2 text-xs text-danger`,children:[a(O,{className:`h-3.5 w-3.5 shrink-0`}),u??(f?.kind===`error`?f.message:``)]}),E.length>0&&a(`ul`,{className:`divide-y divide-border rounded-md border border-border`,children:E.map(t=>{let r=t.providerLabel??t.provider;return n(`li`,{className:`flex items-center gap-3 px-3 py-2 text-xs`,children:[n(`div`,{className:`flex-1 min-w-0`,children:[n(`div`,{className:`font-medium text-foreground truncate`,children:[r,!t.available&&a(`span`,{className:`ml-2 rounded bg-foreground-subtle/15 px-1.5 py-0.5 text-[10px] font-normal text-foreground-subtle`,children:e(`users.linkedSignInsSection.providerUnavailable`,`provider unavailable`)})]}),a(`div`,{className:`text-[11px] text-foreground-subtle truncate`,children:e(`users.linkedSignIns.linkedOn`,{label:t.label??t.subject,date:ke(t.linkedAt)})})]}),n(`button`,{onClick:()=>void M(t,r),disabled:w.isPending,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] text-danger hover:bg-danger/10 disabled:opacity-50`,children:[a(te,{className:`h-3 w-3`}),e(`users.linkedSignInsSection.unlink`,`Unlink`)]})]},`${t.provider}|${t.subject}`)})}),a(`div`,{className:`flex flex-wrap gap-2`,children:T.filter(e=>!A.has(e.provider)).map(t=>n(`button`,{onClick:()=>{d(null),m(null),g.requestProof().then(e=>{e!==null&&(h.current=le(null),b(h.current===null?null:t.provider),C.mutate({provider:t.provider,reauthToken:e}))})},disabled:C.isPending,className:`inline-flex items-center gap-1.5 rounded border border-border px-2.5 py-1 text-[11px] font-medium text-foreground hover:bg-surface-hover disabled:opacity-50`,children:[C.isPending&&C.variables?.provider===t.provider?a(x,{className:`h-3 w-3 animate-spin`}):a(S,{className:`h-3 w-3`}),e(`users.linkedSignIns.link`,{provider:t.label})]},t.provider))})]})]})}l();function je({value:r,size:i=192}){let{t:c}=R(),[l,u]=s(null),[d,f]=s(null);if(o(()=>{let n=!1;return t(()=>import(`./browser-BHo8W_uH.js`).then(t=>e(t.default,1)).then(async e=>{if(n)return;let t=e.create;if(typeof t!=`function`){f(`qrcode.create() unavailable in installed version`);return}try{let e=t(r,{errorCorrectionLevel:`M`});n||u(e)}catch(e){n||f(e instanceof Error?e.message:`QR generation failed`)}}),__vite__mapDeps([0,1]),import.meta.url).catch(()=>{n||f(`qrcode library not installed`)}),()=>{n=!0}},[r]),d)return a(`div`,{className:`flex items-center justify-center text-[10px] text-foreground-subtle text-center p-4`,style:{width:i,height:i},children:c(`users.totpQrCode.qrRenderingUnavailableUseThe`,`QR rendering unavailable — use the secret below.`)});if(!l)return a(`div`,{className:`flex items-center justify-center text-[10px] text-foreground-subtle animate-pulse`,style:{width:i,height:i},children:c(`users.totpQrCode.generating`,`Generating…`)});let p=l.modules.size,m=i/p,h=[];for(let e=0;e<p;e++)for(let t=0;t<p;t++)l.modules.data[e*p+t]&&h.push(a(`rect`,{x:t*m,y:e*m,width:m,height:m,fill:`currentColor`},`${t}-${e}`));return n(`svg`,{width:i,height:i,viewBox:`0 0 ${i} ${i}`,className:`text-black`,children:[a(`rect`,{x:0,y:0,width:i,height:i,fill:`white`}),h]})}l();function Me(){let{t:e}=R(),t=b(),[r,i]=s(``),[o,c]=s(``),[l,d]=s(``),[f,p]=s(null),m=u({mutationFn:e=>t.changeOwnPassword(e),onSuccess:()=>{p({kind:`success`,msg:`Password updated.`}),i(``),c(``),d(``)},onError:e=>{p({kind:`error`,msg:e instanceof Error?e.message:`Update failed`})}}),h=o.length>0&&l.length>0&&o!==l,g=o.length>0&&o.length<8,_=r.length>=1&&o.length>=8&&o===l;return n(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[n(`div`,{className:`px-4 py-2.5 border-b border-border flex items-center gap-2`,children:[a(N,{className:`h-3.5 w-3.5 text-foreground-subtle`}),a(`div`,{className:`text-xs font-semibold text-foreground`,children:e(`systemPage.myAccess.changePassword`,`Change password`)})]}),n(`div`,{className:`p-4 space-y-3`,children:[a(Z,{label:e(`systemPage.myAccess.currentPassword`,`Current password`),value:r,onChange:i,autoComplete:`current-password`}),a(Z,{label:e(`systemPage.myAccess.newPassword`,`New password`),value:o,onChange:c,autoComplete:`new-password`,hint:e(`systemPage.myAccess.atLeast8Characters`,`At least 8 characters.`)}),a(Z,{label:e(`systemPage.myAccess.confirmNewPassword`,`Confirm new password`),value:l,onChange:d,autoComplete:`new-password`}),(h||g)&&a(`div`,{className:`text-[11px] text-danger`,children:h?e(`systemPage.myAccess.passwordsDoNotMatch`,`Passwords do not match.`):e(`systemPage.myAccess.newPasswordMustBeAt`,`New password must be at least 8 characters.`)}),f&&n(`div`,{className:`text-[11px] flex items-center gap-1 ${f.kind===`success`?`text-success`:`text-danger`}`,children:[f.kind===`success`?a(v,{className:`h-3 w-3`}):a(O,{className:`h-3 w-3`}),f.msg]}),a(`div`,{className:`flex justify-end`,children:n(L,{onClick:()=>{p(null),m.mutate({currentPassword:r,newPassword:o})},disabled:!_||m.isPending,children:[m.isPending?a(x,{className:`h-3 w-3 animate-spin`}):a(C,{className:`h-3 w-3`}),e(`systemPage.myAccess.updatePassword`,`Update password`)]})})]})]})}function Z({label:e,value:t,onChange:r,autoComplete:i,hint:o}){return n(`div`,{className:`space-y-1`,children:[a(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:e}),a(`input`,{type:`password`,value:t,onChange:e=>r(e.target.value),autoComplete:i,className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`}),o&&a(`div`,{className:`text-[10px] text-foreground-subtle`,children:o})]})}function Ne({username:e}){let{t}=R(),r=b(),l=c({queryKey:[`auth`,`getOwnTotpStatus`],queryFn:()=>r.getOwnTotpStatus()}),f=l.data,[p,m]=s(null),[h,g]=s(``),[y,S]=s(null),[C,w]=s(!1),T=u({mutationFn:()=>r.setupOwnTotp(),onSuccess:e=>{m({secret:e.secret,otpauthUrl:e.otpauthUrl}),g(``),S(null)},onError:e=>S(e instanceof Error?e.message:`Setup failed`)}),D=u({mutationFn:e=>r.confirmOwnTotp(e),onSuccess:()=>{m(null),g(``),S(null),l.refetch()},onError:e=>S(e instanceof Error?e.message:`Confirmation failed — code did not match`)}),k=G(`Turning off two-factor authentication`),A=u({mutationFn:async()=>{let e=await k.requestProof();return e===null?null:r.disableOwnTotp({reauthToken:e})},onSuccess:()=>{S(null),l.refetch()},onError:e=>S(e instanceof Error?e.message:`Disable failed`)});o(()=>{if(!C)return;let e=setTimeout(()=>w(!1),1500);return()=>clearTimeout(e)},[C]);let j=i(()=>l.isLoading?`loading`:p?`setup_in_progress`:f?.enabled?`enrolled`:`not_enrolled`,[l.isLoading,f?.enabled,p]);return n(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[k.dialog,n(`div`,{className:`px-4 py-2.5 border-b border-border flex items-center gap-2`,children:[a(_,{className:`h-3.5 w-3.5 text-foreground-subtle`}),a(`div`,{className:`text-xs font-semibold text-foreground`,children:t(`systemPage.myAccess.twoFactorAuthentication`,`Two-factor authentication`)})]}),n(`div`,{className:`p-4 space-y-3`,children:[j===`loading`&&n(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[a(x,{className:`h-3.5 w-3.5 animate-spin`}),t(`systemPage.myAccess.checkingStatus`,`Checking status…`)]}),j===`not_enrolled`&&n(d,{children:[a(`div`,{className:`text-xs text-foreground-subtle`,children:t(`systemPage.myAccess.2faIsnTActiveOn`,`2FA isn't active on your account. Enable it to require a 6-digit code from your authenticator app at every login.`)}),a(`div`,{className:`flex justify-end`,children:n(L,{onClick:()=>{S(null),T.mutate()},disabled:T.isPending,children:[T.isPending?a(x,{className:`h-3 w-3 animate-spin`}):a(_,{className:`h-3 w-3`}),t(`systemPage.myAccess.enable2fa`,`Enable 2FA`)]})})]}),j===`setup_in_progress`&&p&&n(d,{children:[a(`div`,{className:`text-[11px] text-foreground-subtle`,children:a(U,{i18nKey:`systemPage.myAccess.scanQr`,values:{username:e},components:{mono:a(`span`,{className:`font-mono`})}})}),n(`div`,{className:`flex flex-col items-center gap-3`,children:[a(`div`,{className:`rounded-lg border border-border bg-white p-3`,children:a(je,{value:p.otpauthUrl,size:180})}),n(`div`,{className:`w-full`,children:[a(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle mb-1`,children:t(`systemPage.myAccess.secretManualEntry`,`Secret (manual entry)`)}),n(`div`,{className:`flex items-center gap-2 rounded border border-border bg-surface-hover/30 px-2 py-1.5`,children:[a(`code`,{className:`text-[11px] font-mono text-foreground break-all flex-1`,children:p.secret}),n(L,{variant:`ghost`,onClick:()=>{p&&navigator.clipboard.writeText(p.secret).then(()=>w(!0))},children:[C?a(v,{className:`h-3 w-3 text-success`}):a(E,{className:`h-3 w-3`}),C?t(`systemPage.myAccess.copied`,`Copied`):t(`common.copy`,`Copy`)]})]})]})]}),n(`div`,{className:`space-y-1`,children:[a(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`6-digit code`}),a(`input`,{type:`text`,inputMode:`numeric`,autoComplete:`one-time-code`,placeholder:`123456`,value:h,onChange:e=>g(e.target.value.replace(/\D/g,``).slice(0,6)),className:`w-full rounded-md border border-border bg-surface px-3 py-2 text-center text-lg font-mono tracking-widest text-foreground focus:outline-none focus:ring-2 focus:ring-primary`})]}),y&&n(`div`,{className:`text-[11px] text-danger flex items-center gap-1`,children:[a(O,{className:`h-3 w-3`}),y]}),n(`div`,{className:`flex justify-end gap-2`,children:[a(L,{variant:`outline`,onClick:()=>{m(null),S(null),g(``)},children:t(`common.cancel`,`Cancel`)}),n(L,{onClick:()=>{S(null),D.mutate({code:h})},disabled:D.isPending||h.length!==6,children:[D.isPending?a(x,{className:`h-3 w-3 animate-spin`}):a(v,{className:`h-3 w-3`}),t(`common.confirm`,`Confirm`)]})]})]}),j===`enrolled`&&f&&n(d,{children:[n(`div`,{className:`rounded-md border border-success/30 bg-success/5 px-3 py-2.5 flex items-start gap-2.5`,children:[a(v,{className:`h-4 w-4 mt-0.5 text-success shrink-0`}),n(`div`,{className:`text-xs text-foreground space-y-0.5`,children:[a(`div`,{className:`font-medium`,children:t(`systemPage.myAccess.2faIsActive`,`2FA is active`)}),a(`div`,{className:`text-foreground-subtle`,children:t(`common.enrolledOn`,{when:f.confirmedAt?new Date(f.confirmedAt).toLocaleString():`—`})})]})]}),y&&n(`div`,{className:`text-[11px] text-danger flex items-center gap-1`,children:[a(O,{className:`h-3 w-3`}),y]}),a(`div`,{className:`flex justify-end`,children:n(L,{variant:`danger`,onClick:()=>{S(null),A.mutate()},disabled:A.isPending,children:[A.isPending?a(x,{className:`h-3 w-3 animate-spin`}):a(_,{className:`h-3 w-3`}),t(`systemPage.myAccess.disable2fa`,`Disable 2FA`)]})})]})]})]})}function Pe(){return F(`auth-webauthn/passkey-enrollment`)?a(se,{widgetId:`auth-webauthn/passkey-enrollment`,host:`dashboard`}):null}l();function Q(e){return e.message.length>0?e.message:ce.t(`auth.authAuditSection.requestFailed`)}function Fe(){let{t:e}=R(),{logout:t}=B(),r=D(),i=P.useUtils(),o=P.auth.listOwnSessions.useQuery(),[c,l]=s(null),u=P.auth.revokeOwnSession.useMutation({onSuccess:()=>void i.auth.listOwnSessions.invalidate(),onError:e=>l(`Sign out failed: ${Q(e)}`)}),d=P.auth.logout.useMutation({onSuccess:()=>t(),onError:e=>l(`Sign out failed: ${Q(e)}`)}),f=async t=>{await r({title:e(`auth.mySessionsSection.signOutThisSession`,`Sign out this session`),message:e(`auth.mySessionsSection.willHaveToSignIn`,`{{label}} will have to sign in again.`,{label:ye(t.client).label}),confirmLabel:e(`auth.mySessionsSection.signOut`,`Sign out`),variant:`danger`})&&(l(null),u.mutate({id:t.id}))},p=async()=>{await r({title:e(`auth.mySessionsSection.signOutEverywhere`,`Sign out everywhere`),message:e(`auth.mySessionsSection.everySessionOfYourAccount`,`Every session of your account ends, this browser included: you will be signed out here too and every device has to sign in again.`),confirmLabel:e(`auth.mySessionsSection.signOutEverywhere`,`Sign out everywhere`),variant:`danger`})&&(l(null),d.mutate({everywhere:!0}))};return n(`div`,{"data-testid":`my-sessions`,className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[n(`div`,{className:`px-4 py-2.5 border-b border-border flex items-center gap-2`,children:[a(ee,{className:`h-3.5 w-3.5 text-foreground-subtle`}),a(`div`,{className:`text-xs font-semibold text-foreground`,children:e(`auth.mySessionsSection.activeSessions`,`Active sessions`)})]}),n(`div`,{className:`p-4 space-y-3`,children:[a(`p`,{className:`text-[11px] text-foreground-subtle`,children:e(`auth.mySessionsSection.theBrowsersAndAppsSigned`,`The browsers and apps signed in to your account. Signing one out ends it at once.`)}),c!==null&&a(`div`,{className:`text-[11px] text-danger`,children:c}),a(K,{sessions:o.data??[],isLoading:o.isLoading,loadError:o.isError?o.error?.message??e(`auth.authAuditSection.requestFailed`):null,emptyText:`No active sessions.`,onRevoke:e=>void f(e),revokingId:u.isPending?u.variables?.id??null:null}),a(`div`,{className:`flex justify-end`,children:n(`button`,{onClick:()=>void p(),disabled:d.isPending,className:`inline-flex items-center gap-1.5 rounded border border-danger/40 px-2.5 py-1 text-[11px] font-medium text-danger hover:bg-danger/10 disabled:opacity-50`,children:[d.isPending?a(x,{className:`h-3 w-3 animate-spin`}):a(M,{className:`h-3 w-3`}),e(`auth.mySessionsSection.signOutEverywhere`,`Sign out everywhere`)]})})]})]})}l();var Ie=`You`;function Le(){let{t:e}=R(),t=D(),n=P.useUtils(),r=P.auth.listOwnDeviceCredentials.useQuery(),[o,c]=s(null),l=P.auth.revokeOwnDeviceCredential.useMutation({onSuccess:e=>{e.revoked||c(`That device could not be revoked - it may already be gone.`),n.auth.listOwnDeviceCredentials.invalidate()},onError:e=>c(`Revoke failed: ${e.message}`)}),u=i(()=>(r.data??[]).map(e=>ve(e,Ie)),[r.data]),d=async n=>{await t({title:e(`certificates.myDevicesSection.revoke`,`Revoke "{{name}}"?`,{name:n.name}),message:e(`certificates.myDevicesSection.theDeviceStopsSigningIn`,`The device stops signing in at once and its open sessions end. To use it again you have to pair it anew. This cannot be undone.`),confirmLabel:e(`certificates.myDevicesSection.revoke2`,`Revoke`),variant:`danger`})&&(c(null),l.mutate({id:n.id}))},f={label:e(`certificates.myDevicesSection.revoke2`,`Revoke`),icon:g,isAvailable:he,onRun:e=>void d(e),busyId:l.isPending?l.variables?.id??null:null,disabled:l.isPending};return a(pe,{id:`my-devices`,title:e(`certificates.myDevicesSection.myDevices`,`My devices`),icon:_,description:e(`certificates.myDevicesSection.phonesThatStaySignedIn`,`Phones that stay signed in to your account with a certificate. If one is lost, revoke it here and it is signed out at once.`),notice:_e(o),onDismissNotice:()=>c(null),children:a(me,{rows:u,label:e(`certificates.devicesCard.label`),isLoading:r.isPending,loadError:r.error===null?null:r.error.message||`Request failed`,emptyText:`No devices are signed in with a certificate.`,hideOwner:!0,expiresNone:`—`,action:f})})}var $={profile:`profile`,signIn:`sign-in`,sessions:`sessions`,tokens:`tokens`},Re=[`linked`,`linkError`],ze={view:{icon:h,cls:`bg-foreground-subtle/15 text-foreground-subtle`},create:{icon:m,cls:`bg-primary/15 text-primary`},delete:{icon:f,cls:`bg-danger/15 text-danger`}};function Be(){let{t:e}=R(),{user:t,logout:r}=B(),[i]=H(),o=e(`system.myAccess`,`My access`);if(!t)return a(fe,{icon:T,title:o,children:a(`div`,{className:`text-xs text-foreground-subtle`,children:e(`systemPage.myAccess.notSignedIn`,`Not signed in.`)})});if(Re.some(e=>i.has(e))&&!i.has(`tab`)){let e=new URLSearchParams(i);return e.set(`tab`,$.signIn),a(V,{to:`?${e.toString()}`,replace:!0})}return a(de,{icon:T,title:o,subtitle:e(`systemPage.myAccess.subtitle`,`Your account, how you sign in, where you are signed in, and your tokens.`),sectionsLabel:e(`systemPage.myAccess.sectionsLabel`,`My access sections`),defaultSection:$.profile,actions:n(L,{variant:`outline`,onClick:r,children:[a(M,{className:`h-3 w-3`}),e(`systemPage.myAccess.signOut`,`Sign out`)]}),sections:[{id:$.profile,label:e(`systemPage.myAccess.sections.profile`,`Profile`),content:a(Ve,{user:t})},{id:$.signIn,label:e(`systemPage.myAccess.sections.signIn`,`Sign-in & security`),content:n(`div`,{className:`space-y-4`,children:[a(Me,{}),a(Ne,{username:t.username}),a(Pe,{}),a(Ae,{})]})},{id:$.sessions,label:e(`systemPage.myAccess.sections.sessions`,`Sessions & devices`),content:n(`div`,{className:`space-y-4`,children:[a(Fe,{}),a(Le,{}),a(De,{})]})},{id:$.tokens,label:e(`systemPage.myAccess.sections.tokens`,`Tokens`),content:a(ge,{ownOnly:!0})}]})}function Ve({user:e}){let{t}=R(),r=e.isAdmin,i=e.scopes??[];return n(`div`,{className:`space-y-4`,children:[n(`div`,{className:`rounded-lg border border-border bg-surface px-4 py-3 flex items-center gap-3`,children:[a(`div`,{className:`flex h-10 w-10 items-center justify-center rounded-full bg-primary/10 text-primary font-semibold text-base`,children:e.username.slice(0,1).toUpperCase()}),n(`div`,{className:`flex-1 min-w-0`,children:[a(`div`,{className:`text-sm font-semibold text-foreground truncate`,children:e.username}),n(`div`,{className:`text-[11px] text-foreground-subtle`,children:[r?t(`systemPage.myAccess.administrator`,`Administrator`):t(`systemPage.myAccess.user`,`User`),` `,a(U,{i18nKey:`systemPage.myAccess.sessionId`,values:{id:e.id.slice(0,8)},components:{mono:a(`span`,{className:`font-mono`})}})]})]})]}),r&&n(`div`,{className:`rounded-lg border border-primary/30 bg-primary/5 px-4 py-3 text-xs text-foreground flex items-start gap-2.5`,children:[a(y,{className:`h-4 w-4 text-primary mt-0.5 shrink-0`}),n(`div`,{children:[a(`div`,{className:`font-semibold text-foreground`,children:t(`systemPage.myAccess.unrestrictedAccess`,`Unrestricted access`)}),a(`p`,{className:`text-foreground-subtle mt-0.5`,children:t(`systemPage.myAccess.adminSessionsBypassThePer`,`Admin sessions bypass the per-call scope check. Every protected endpoint is reachable regardless of the list below.`)})]})]}),i.length>0&&a(He,{scopes:i})]})}function He({scopes:e}){let{t}=R(),r=w();return n(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[n(`div`,{className:`px-4 py-2 border-b border-border`,children:[a(`div`,{className:`text-xs font-semibold text-foreground`,children:t(`systemPage.myAccess.grantedScopes`,`Granted scopes`)}),a(`div`,{className:`text-[10px] text-foreground-subtle`,children:t(`systemPage.myAccess.bakedIntoYourSessionToken`,`Baked into your session token at login; sign out + back in to refresh after changes.`)})]}),n(`div`,{className:`grid grid-cols-[100px_1fr_240px] gap-3 px-4 py-2 text-[10px] uppercase tracking-wide text-foreground-subtle border-b border-border`,children:[a(`div`,{children:t(`systemPage.myAccess.type`,`Type`)}),a(`div`,{children:t(`systemPage.myAccess.target`,`Target`)}),a(`div`,{children:t(`systemPage.myAccess.access`,`Access`)})]}),a(`ul`,{className:`divide-y divide-border`,children:e.map((e,i)=>n(`li`,{className:`grid grid-cols-[100px_1fr_240px] gap-3 px-4 py-2.5 items-center text-xs`,children:[a(`span`,{className:`font-mono text-foreground-subtle`,children:e.type}),a(`span`,{className:`font-mono text-foreground`,children:e.type===`device`?ne(e.selector,r):e.target}),a(`div`,{className:`flex items-center gap-1`,children:[`view`,`create`,`delete`].map(r=>{let i=e.access.includes(r),{icon:o,cls:s}=ze[r];return n(`span`,{className:`inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] font-medium ${i?s:`bg-transparent text-foreground-subtle/40 line-through`}`,title:i?t(`systemPage.myAccess.can`,`Can {{a}}`,{a:r}):t(`systemPage.myAccess.cannot`,`Cannot {{a}}`,{a:r}),children:[a(o,{className:`h-3 w-3`}),r]},r)})})]},i))})]})}export{Be as MyAccessPage};
@@ -1 +0,0 @@
1
- import{C as e,K as t,R as n,S as r,V as i,Y as a,et as o,o as s,x 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{D as l,En as u,Fn as d,Gn as f,Ht as p,In as m,Kr as h,L as g,Oi as _,Tn as v,Z as y,_n as b,bt as x,dt as S,fn as C,fr as w,gt as T,lr as ee,ri as E,rn as te,tn as D,xn as ne,zt as O}from"./player-overlays-B4lehTI4.js";import{Ur as re,Wr as ie,ar as k,zr as ae}from"./client-C6c46gRD.js";import{t as A}from"./boxes-DTEgIla8.js";import{l as j,s as oe}from"./video-B-2RwuDj.js";import{t as se}from"./log-in-DtNu6ihw.js";import{$s as ce,Do as le,Fi as M,Gs as ue,Js as de,Pi as N,Sn as fe,Tr as pe,Un as me,Us as he,Ws as ge,Xs as _e,Yr as P,Zs as ve,_n as ye,ac as be,bn as xe,br as Se,cc as Ce,dd as we,ec as Te,fc as Ee,gd as De,lc as Oe,mc as ke,oc as Ae,pc as je,qu as Me,ri as F,sc as Ne,yn as Pe}from"./src-DlnTixq9.js";import{t as I}from"./i18n-uD14huY2.js";import{t as L}from"./useTranslation-BJr-n0es.js";import"./mount-DuRGlFHX.js";import{S as Fe,a as R,dr as Ie,fr as Le,gr as Re,i as z}from"./index-pzq9LOji.js";import{t as ze}from"./AdminSectionedPage-OHmEcMxM.js";import{t as B}from"./AdminPage-Bn1s1Zyw.js";import{t as Be}from"./NodeAddonsSettingsPanel-DEdzDp8P.js";import{n as V,r as H,t as U}from"./IntegrationHub-DXhDIgkG.js";import{n as W,t as G}from"./addon-display-names-BkwMrExv.js";o();var K=5e3,q=`network-access`,Ve={connected:!1,endpoint:null};function He(){let{t:e}=L(),n=s(),i=M({capName:`network-access`},{refetchInterval:K}),o=N(void 0,{refetchInterval:K}),c=t(()=>G(o.data??[]),[o.data]),l=t(()=>(i.data??[]).map(e=>({addonId:e.addonId,displayName:c.get(e.addonId)??e.addonId,isActive:e.isActive})),[i.data,c]),[u,d]=a(null),[f,p]=a({}),m=(e,t)=>{let r=t?.addonId;n.invalidateQueries({queryKey:[[`networkAccess`,`getStatus`],{input:{addonId:r},type:`query`}]}),d(null),p(e=>{if(r===void 0||!(r in e))return e;let t={...e};return delete t[r],t})},h=(e,t)=>{d(null);let n=t?.addonId;if(n===void 0)return;let r=e instanceof Error?e.message:String(e);p(e=>({...e,[n]:r}))},g=je({onSuccess:m,onError:h}),_=ke({onSuccess:m,onError:h}),v=[{id:q,label:e(`system.remoteAccess.remoteAccess`,`Remote access`),install:{capability:q,label:e(`system.remoteAccess.addTunnel`,`Add tunnel`)},entries:l.map(e=>({id:e.addonId,name:e.displayName,fallbackIcon:j,...W(e.isActive),render:()=>r(V,{addonId:e.addonId,displayName:e.displayName,capName:q,isActive:e.isActive,badges:r(We,{addonId:e.addonId}),error:f[e.addonId]??null,primaryAction:r(Ge,{addonId:e.addonId,busyId:u,onStart:e=>{d(e),g.mutate({addonId:e})},onStop:e=>{d(e),_.mutate({addonId:e})}})})}))}];return r(U,{embedded:!0,icon:j,title:e(`system.remoteAccess.remoteAccess2`,`Remote Access`),subtitle:e(`system.remoteAccess.publicFacingTunnelsThatExpose`,`Public-facing tunnels that expose this hub to the internet (Cloudflare Tunnel, ngrok, …).`),groups:v,isLoading:i.isLoading,emptyTitle:e(`system.remoteAccess.noRemoteAccessProvidersInstalled`,`No remote-access providers installed`),emptyDescription:e(`system.remoteAccess.installATunnelAddonE`,`Install a tunnel addon (e.g. @camstack/addon-cloudflare) to expose this hub publicly.`)})}function Ue(e){let{data:t}=Ee({addonId:e},{refetchInterval:K,retry:!1}),n=t?ae.safeParse(t):null;return n?.success?n.data:Ve}function We({addonId:t}){let{t:n}=L(),i=Ue(t);return e(c,{children:[r(F,{variant:i.connected?`success`:`default`,className:H,children:i.connected?n(`system.remoteAccess.connected`,`Connected`):n(`system.remoteAccess.disconnected`,`Disconnected`)}),i.endpoint&&e(`a`,{href:i.endpoint.url,target:`_blank`,rel:`noopener noreferrer`,className:`flex min-w-0 items-center gap-1 break-all text-[11px] text-success hover:underline`,children:[r(h,{className:`h-3 w-3`}),i.endpoint.url]})]})}function Ge({addonId:t,busyId:n,onStart:i,onStop:a}){let{t:o}=L(),s=Ue(t),c=n===t;return s.connected?e(P,{size:`sm`,variant:`secondary`,disabled:c,onClick:()=>a(t),children:[c?r(w,{className:`h-3 w-3 animate-spin`}):r(D,{className:`h-3 w-3`}),o(`system.remoteAccess.stop`,`Stop`)]}):e(P,{size:`sm`,variant:`primary`,disabled:c,onClick:()=>i(t),children:[c?r(w,{className:`h-3 w-3 animate-spin`}):r(m,{className:`h-3 w-3`}),o(`system.remoteAccess.start`,`Start`)]})}o();var Ke=3e4,J=`turn-provider`;function qe(e){let t=[];for(let n of e)typeof n.urls==`string`?t.push(n.urls):t.push(...n.urls);return t}function Je(){let{t:n}=L(),i=M({capName:`turn-provider`},{refetchInterval:Ke}),a=N(void 0,{refetchInterval:Ke}),o=Me(),s=o.data??[],c=t(()=>G(a.data??[]),[a.data]),u=t(()=>(i.data??[]).map(e=>({addonId:e.addonId,displayName:c.get(e.addonId)??e.addonId,isActive:e.isActive})),[i.data,c]),d=[{id:J,label:n(`system.turnServers.turnProviders`,`TURN providers`),install:{capability:J,label:n(`system.turnServers.addProvider`,`Add provider`)},entries:u.map(e=>({id:e.addonId,name:e.displayName,fallbackIcon:f,...W(e.isActive),render:()=>r(V,{addonId:e.addonId,displayName:e.displayName,capName:J,isActive:e.isActive,panels:[{id:`ice-servers`,title:n(`system.turnServers.discoveredIceServers`,`Discovered ICE servers`),icon:f,content:r(Ye,{addonId:e.addonId,enabled:e.isActive})}]})}))}];return r(U,{embedded:!0,icon:f,title:n(`system.turnServers.turnServers`,`TURN Servers`),subtitle:n(`system.turnServers.iceServersUsedForWebrtc`,`ICE servers used for WebRTC NAT traversal. Multiple providers can coexist — the WebRTC layer concatenates servers from all enabled providers per session.`),groups:d,isLoading:i.isLoading,emptyTitle:n(`system.turnServers.noTurnProvidersInstalled`,`No TURN providers installed`),emptyDescription:n(`system.turnServers.installATurnAddonE`,`Install a TURN addon (e.g. @camstack/addon-cloudflare) to enable WebRTC behind restrictive NATs.`),trailing:r(xe,{headingId:`turn-combined-ice`,title:n(`system.turnServers.combinedIceServerListAll`,`Combined ICE server list — all enabled providers`),icon:f,actions:r(P,{size:`sm`,variant:`secondary`,onClick:()=>o.refetch(),disabled:o.isFetching,children:n(`common.refresh`,`Refresh`)}),children:r(`div`,{className:l,children:s.length===0?r(`div`,{className:`text-xs text-foreground-subtle`,children:n(`system.turnServers.noServersFromEnabledProviders`,`No servers from enabled providers.`)}):r(`div`,{className:`flex flex-col gap-3`,children:s.map((t,n)=>{let i=Array.isArray(t.urls)?t.urls:[t.urls];return e(`div`,{className:`rounded border border-border bg-surface`,children:[(t.username||t.credential)&&e(`div`,{className:`px-3 py-1.5 border-b border-border text-[10px] font-mono text-foreground-subtle flex items-center gap-3`,children:[t.username&&e(`span`,{children:[r(`span`,{className:`text-foreground-subtle`,children:`user:`}),` `,r(`span`,{className:`text-foreground`,children:t.username})]}),t.credential&&e(`span`,{children:[r(`span`,{className:`text-foreground-subtle`,children:`credential:`}),` `,r(`span`,{className:`text-foreground`,children:`••••••••`})]})]}),r(`ul`,{className:`divide-y divide-border`,children:i.map(e=>r(`li`,{className:`px-3 py-1.5 font-mono text-xs text-foreground break-all`,children:e},e))})]},n)})})})})})}function Ye({addonId:e,enabled:n}){let i=Me({addonId:e},{enabled:n,retry:!1}),a=t(()=>qe(i.data??[]),[i.data]),o=n?i.isLoading?`Loading…`:a.length===0?`This provider returned no servers.`:null:`Disabled — enable the provider to fetch its servers.`;return r(`div`,{className:`rounded-lg border border-border bg-surface p-2 sm:p-3`,children:o===null?r(`div`,{className:`flex flex-wrap gap-1`,children:a.map(e=>r(`span`,{className:`inline-block break-all rounded bg-foreground-subtle/10 px-1.5 py-0.5 font-mono text-[10px] text-foreground`,children:e},e))}):r(`div`,{className:`text-xs text-foreground-subtle`,children:o})})}o();var Xe={lan:f,wifi:x,docker:A,vpn:ee,loopback:b,other:b},Ze={lan:`LAN`,wifi:`Wi-Fi`,docker:`Docker`,vpn:`VPN`,loopback:`Loopback`,other:`Other`},Qe=[`lan`,`wifi`,`vpn`,`docker`,`other`,`loopback`];function $e(n){let{t:i}=L(),{interfaces:a,disabled:o,hideLoopback:s,ipv4Only:c,emptyMessage:l}=n,u=t(()=>a.filter(e=>!(s&&e.kind===`loopback`||c&&e.family!==`IPv4`)),[a,s,c]),d=t(()=>{let e=new Map;for(let t of u){let n=e.get(t.kind)??[];n.push(t),e.set(t.kind,n)}return Qe.filter(t=>e.has(t)).map(t=>({kind:t,items:e.get(t)}))},[u]),f=e=>n.mode===`single`?n.value===e:n.value.includes(e),p=e=>{if(o||e.kind===`loopback`)return;if(n.mode===`single`){n.onChange(n.value===e.address?null:e.address);return}let t=new Set(n.value);t.has(e.address)?t.delete(e.address):t.add(e.address),n.onChange([...t])};return u.length===0?r(`div`,{className:`text-xs text-foreground-subtle italic`,children:l??i(`shared.addressSelector.noAddressesAvailable`,`No addresses available.`)}):r(`div`,{className:`flex flex-col gap-3`,children:d.map(({kind:t,items:a})=>e(`div`,{className:`rounded-md border border-border overflow-hidden`,children:[e(`div`,{className:`flex items-center gap-2 px-3 py-1.5 bg-surface-hover/30 border-b border-border`,children:[r(Xe[t]??b,{className:`h-3.5 w-3.5 text-foreground-subtle`}),r(`span`,{className:`text-[11px] font-semibold uppercase tracking-wide text-foreground-subtle`,children:Ze[t]??t}),e(`span`,{className:`text-[10px] text-foreground-subtle`,children:[`· `,a.length]})]}),r(`ul`,{className:`divide-y divide-border`,children:a.map(t=>{let a=f(t.address),s=t.kind===`loopback`,c=!t.plausible&&!s;return e(`li`,{className:`flex items-center gap-3 px-3 py-2 ${s?`opacity-60 cursor-not-allowed`:o?`opacity-60`:c?`cursor-pointer hover:bg-surface-hover/30 bg-amber-500/[0.04]`:`cursor-pointer hover:bg-surface-hover/30`}`,onClick:()=>p(t),children:[r(`span`,{className:`flex items-center justify-center h-4 w-4 rounded ${n.mode===`single`?`rounded-full`:`rounded`} border ${a?`border-primary bg-primary text-primary-foreground`:`border-border bg-surface`}`,children:a&&r(_,{className:`h-3 w-3`})}),e(`div`,{className:`flex-1 min-w-0 ${c?`text-foreground-subtle`:``}`,children:[e(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[r(`span`,{className:`font-mono text-xs font-semibold ${c?`text-foreground-subtle`:`text-foreground`}`,children:t.name}),r(`span`,{className:`text-[10px] rounded px-1.5 py-0.5 bg-foreground-subtle/10 text-foreground-subtle font-mono`,children:t.family}),t.preferred&&r(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium bg-primary/15 text-primary`,children:i(`shared.addressSelector.autoPreferred`,`Auto-preferred`)}),s&&r(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium bg-foreground-subtle/15 text-foreground-subtle`,children:i(`shared.addressSelector.alwaysIncluded`,`Always included`)}),c&&e(`span`,{className:`inline-flex items-center gap-1 text-[10px] rounded-full px-2 py-0.5 font-medium bg-amber-500/15 text-amber-700 dark:text-amber-300`,title:t.plausibleReason||void 0,children:[r(O,{className:`h-2.5 w-2.5`}),i(`shared.addressSelector.unlikelyUsable`,`Unlikely usable`)]})]}),e(`div`,{className:`text-xs text-foreground-subtle mt-0.5 font-mono break-all`,children:[t.address,t.cidr&&t.cidr!==t.address?` (${t.cidr})`:``]})]})]},`${t.name}-${t.family}-${t.address}`)})})]},t))})}var Y=[{role:`appConnections`,get title(){return I.t(`helpers.addressTableModel.appConnectionsTitle`)},single:!1,get help(){return I.t(`helpers.addressTableModel.appConnectionsHelp`)}},{role:`notificationTaps`,get title(){return I.t(`helpers.addressTableModel.notificationTapsTitle`)},single:!0,get help(){return I.t(`helpers.addressTableModel.notificationTapsHelp`)}},{role:`publicEndpoint`,get title(){return I.t(`helpers.addressTableModel.publicEndpointTitle`)},single:!0,get help(){return I.t(`helpers.addressTableModel.publicEndpointHelp`)}},{role:`internal`,get title(){return I.t(`helpers.addressTableModel.internalTitle`)},single:!0,get help(){return I.t(`helpers.addressTableModel.internalHelp`)}}],et=`A role with nothing ticked is automatic. Add a custom address when the hub is reached at an address it cannot see itself (NAT, reverse proxy, VPN, Docker bridge).`;function X(e,t){return e.inUse.includes(t)}function tt(e,t){if(!e.eligible.includes(t))return{kind:`none`};if(e.kind===`app-link`)return X(e,t)?{kind:`none`}:{kind:`set`,input:{role:t,baseUrl:null,enabled:!0}};if(e.flags.includes(t)||t===`appConnections`&&X(e,t))return{kind:`set`,input:{role:t,baseUrl:e.baseUrl,enabled:!1}};let n={role:t,baseUrl:e.baseUrl,enabled:!0};return t===`publicEndpoint`&&e.baseUrl.startsWith(`http:`)?{kind:`confirm-http`,input:n,reason:re}:{kind:`set`,input:n}}function nt(e){return Y.map(({role:t,title:n})=>{if(t===`appConnections`){let r=e.roles.appConnections;return{role:t,title:n,inUse:r.resolved.length===0?`nothing reachable`:r.resolved.join(`, `),automatic:r.source!==`flagged`}}let r=e.roles[t];return{role:t,title:n,inUse:r.resolved===null?`nothing reachable`:t===`notificationTaps`&&r.source===`auto`?`CamStack app link`:r.resolved,automatic:r.source!==`flagged`}})}o();var rt={"lan-ipv4":{labelKey:`system.addressesCard.kindIpv4`,className:`bg-emerald-500/15 text-emerald-700 dark:text-emerald-300`},"lan-ipv6":{labelKey:`system.addressesCard.kindIpv6`,className:`bg-violet-500/15 text-violet-700 dark:text-violet-300`},public:{labelKey:`system.addressesCard.kindPublic`,className:`bg-blue-500/15 text-blue-700 dark:text-blue-300`},"app-link":{labelKey:`system.addressesCard.kindAppLink`,className:`bg-amber-500/15 text-amber-700 dark:text-amber-300`},custom:{labelKey:`system.addressesCard.kindCustom`,className:`bg-sky-500/15 text-sky-700 dark:text-sky-300`},loopback:{labelKey:`system.addressesCard.kindLoopback`,className:`bg-foreground-subtle/15 text-foreground-subtle`}};function it({book:t,loading:n,saving:i,error:o,onSetRole:s,onAdd:c,onRemove:l}){let{t:u}=L(),[f,m]=a(``),[h,g]=a(``),[_,v]=a(null),[y,b]=a(null),x=()=>{let e=ie(f);if(!e.ok){v(e.reason);return}v(null),m(``),g(``),c(e.baseUrl,h.trim())},S=(e,t)=>{let n=tt(e,t.role);if(n.kind!==`none`){if(n.kind===`confirm-http`){b({input:n.input,reason:n.reason});return}b(null),s(n.input)}},C=[{key:`url`,header:u(`system.addressesCard.address`,`Address`),render:n=>e(`div`,{className:`min-w-0 py-0.5`,children:[r(`div`,{className:`font-mono text-[12px] break-all ${n.plausible?`text-foreground`:`text-foreground-subtle`}`,children:n.baseUrl}),e(`div`,{className:`mt-0.5 flex flex-wrap items-center gap-1.5 text-[11px] text-foreground-subtle`,children:[r(`span`,{children:n.label}),n.kind===`app-link`&&e(`span`,{className:`font-mono`,children:[`hub=`,` `,t?.appLinkHub??u(`system.addressesCard.noneNoTunnelOrTailscale`,`none (no tunnel or Tailscale)`)]}),n.custom&&n.detected&&r(`span`,{children:u(`system.addressesCard.alsoAddedAsACustom`,`also added as a custom address`)}),n.kind!==`custom`&&n.interfaceKind!==`lan`&&n.interfaceKind!==`public`&&n.interfaceKind!==`other`&&r(`span`,{className:`uppercase tracking-wide`,children:n.interfaceKind}),!n.plausible&&n.interfaceKind!==`loopback`&&e(`span`,{className:`inline-flex items-center gap-1 text-amber-700 dark:text-amber-300`,title:n.plausibleReason||void 0,children:[r(O,{className:`h-2.5 w-2.5`}),u(`system.addressesCard.unlikelyUsable`,`Unlikely usable`)]})]})]})},{key:`kind`,header:u(`system.addressesCard.kind`,`Kind`),nowrap:!0,render:e=>{let t=rt[e.kind]??rt.loopback;return r(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium ${t.className}`,children:u(t.labelKey)})}},...Y.map(t=>({key:t.role,headerRender:()=>r(`span`,{title:t.help,children:t.title}),align:`center`,nowrap:!0,width:`w-24`,render:n=>{let a=n.eligible.includes(t.role),o=n.flags.includes(t.role),s=X(n,t.role);return e(`label`,{className:`inline-flex items-center justify-center gap-1 ${a?`cursor-pointer`:`cursor-not-allowed opacity-40`}`,title:a?s&&!o?u(`system.addressesCard.inUseAutomatically`,`{{title}}: in use automatically. {{help}}`,{title:t.title,help:t.help}):t.help:u(`system.addressesCard.thisAddressCannotBeUsed`,`This address cannot be used for this.`),children:[r(me,{checked:a&&s,disabled:!a||i,onChange:()=>S(n,t),"aria-label":`${t.title}: ${n.baseUrl}`}),s&&!o&&a&&r(`span`,{className:`text-[9px] text-foreground-subtle`,children:u(`common.auto`)})]})}})),{key:`actions`,header:``,align:`right`,nowrap:!0,render:e=>e.custom?r(P,{size:`sm`,variant:`ghost`,disabled:i,onClick:()=>l(e.baseUrl),"aria-label":u(`system.addressesCard.remove`,`Remove {{baseUrl}}`,{baseUrl:e.baseUrl}),title:u(`system.addressesCard.removeThisCustomAddressIts`,`Remove this custom address (its roles turn automatic)`),children:r(p,{className:`h-3 w-3`})}):null}],w=t===void 0?[]:nt(t);return e(Se,{children:[e(`div`,{className:`px-4 py-3 border-b border-border flex flex-col gap-2`,children:[e(`div`,{children:[r(`div`,{className:`text-sm font-semibold`,children:u(`system.addressesCard.addresses`,`Addresses`)}),r(`div`,{className:`text-xs text-foreground-subtle max-w-3xl`,children:u(`system.addressesCard.everyAddressThisHubIs`,`Every address this hub is reached at, detected or added by you. Tick what each one is used for.`)}),e(`details`,{className:`mt-1.5 text-xs max-w-3xl`,"data-testid":`address-roles-help`,children:[r(`summary`,{className:`cursor-pointer select-none text-foreground-subtle hover:text-foreground`,children:u(`system.addressesCard.whatAreRoles`,`What are roles?`)}),r(`dl`,{className:`mt-1.5 grid grid-cols-[auto_1fr] gap-x-3 gap-y-1`,children:Y.map(t=>e(`div`,{className:`contents`,children:[r(`dt`,{className:`font-medium`,children:t.title}),r(`dd`,{className:`text-foreground-subtle`,children:t.help})]},t.role))}),r(`p`,{className:`mt-1.5 text-foreground-subtle`,children:et})]})]}),w.length>0&&r(`div`,{className:`grid grid-cols-[auto_1fr_auto] gap-x-3 gap-y-1 items-baseline text-xs`,"data-testid":`address-roles-summary`,children:w.map(t=>e(`div`,{className:`contents`,children:[r(`span`,{className:`text-foreground-subtle`,children:t.title}),e(`span`,{className:`font-mono break-all`,"data-testid":`address-role-${t.role}`,children:[t.inUse,r(`span`,{className:`ml-1.5 font-sans text-foreground-subtle`,children:t.automatic?u(`system.addressesCard.automatic`,`(automatic)`):u(`system.addressesCard.setByYou`,`(set by you)`)})]}),t.automatic?r(`span`,{}):r(P,{size:`sm`,variant:`secondary`,disabled:i,onClick:()=>s({role:t.role,baseUrl:null,enabled:!1}),children:u(`system.addressesCard.useAutomatic`,`Use automatic`)})]},t.role))}),y!==null&&e(`div`,{className:`rounded-md border border-amber-500/40 bg-amber-500/10 px-3 py-2 text-xs flex flex-wrap items-center gap-2`,children:[r(O,{className:`h-3.5 w-3.5 text-amber-600`}),r(`span`,{className:`flex-1 min-w-[220px]`,children:y.reason}),r(P,{size:`sm`,variant:`secondary`,onClick:()=>{s({...y.input,acceptInsecureHttp:!0}),b(null)},children:u(`system.addressesCard.useHttpAnyway`,`Use http anyway`)}),r(P,{size:`sm`,variant:`ghost`,onClick:()=>b(null),children:u(`common.cancel`,`Cancel`)})]}),o!==null&&r(`div`,{className:`text-[11px] text-red-600 dark:text-red-400`,role:`alert`,children:o})]}),r(fe,{columns:C,rows:t?.rows??[],rowKey:e=>`${e.kind}-${e.baseUrl}`,minWidthPx:760,bordered:!1,emptyMessage:n?u(`common.loading`,`Loading…`):u(`system.addressesCard.noAddressesAvailable`,`No addresses available.`),rowClassName:e=>e.plausible?void 0:`opacity-80`}),e(`div`,{className:`px-4 py-3 border-t border-border flex flex-wrap items-start gap-2`,children:[e(`div`,{className:`flex-1 min-w-[220px]`,children:[r(De,{value:f,onChange:e=>{m(e.target.value),v(null)},placeholder:`https://cams.example.com or https://192.0.2.20:4443`,"aria-label":u(`system.addressesCard.customAddress`,`Custom address`),disabled:i}),_!==null&&r(`div`,{className:`mt-1 text-[11px] text-red-600 dark:text-red-400`,children:_})]}),r(`div`,{className:`w-48`,children:r(De,{value:h,onChange:e=>g(e.target.value),placeholder:u(`system.addressesCard.labelOptional`,`Label (optional)`),"aria-label":u(`system.addressesCard.customAddressLabel`,`Custom address label`),maxLength:80,disabled:i})}),e(P,{size:`sm`,variant:`secondary`,disabled:i||f.trim()===``,onClick:x,children:[r(d,{className:`h-3 w-3`}),u(`system.addressesCard.addCustomAddress`,`Add custom address`)]})]})]})}o();function at(){let{t:n}=L(),o=s(),c=()=>{o.invalidateQueries({queryKey:[[`localNetwork`]]})},d=de(void 0,{refetchInterval:3e4}),f=ue(void 0),p=Te({onSuccess:c}),m=ve({onSuccess:e=>{w(e.addresses),c()}}),h=t(()=>d.data?.interfaces??[],[d.data]),g=ge({scheme:typeof window<`u`&&window.location.protocol===`https:`?`https`:`http`},{refetchInterval:3e4}),_=ce({onSuccess:c}),y=he({onSuccess:c}),b=_e({onSuccess:c}),x=_.error?.message??y.error?.message??b.error?.message??null,S=_.isPending||y.isPending||b.isPending,[C,w]=a([]),[T,ee]=a(!1);i(()=>{!T&&f.data&&(w(f.data.addresses),ee(!0))},[f.data,T]);let E=f.data?.addresses??[],D=t(()=>{if(C.length!==E.length)return!0;let e=[...C].toSorted(),t=[...E].toSorted();return e.some((e,n)=>e!==t[n])},[C,E]);return e(B,{embedded:!0,children:[e(`div`,{className:`flex items-center justify-between gap-3 flex-wrap`,children:[r(`p`,{className:`text-xs text-foreground-subtle max-w-2xl`,children:n(`system.networkAddresses.pinWhichHostInterfacesExist`,`Pin which host interfaces exist, then tick what each address is used for. Add a custom address when this hub is reached at one it cannot detect.`)}),r(`div`,{className:`flex items-center gap-2 shrink-0`,children:e(P,{size:`sm`,variant:`secondary`,onClick:()=>{d.refetch(),f.refetch(),g.refetch()},disabled:d.isLoading,children:[r(u,{className:`h-3 w-3 ${d.isLoading?`animate-spin`:``}`}),n(`common.refresh`,`Refresh`)]})})]}),r(xe,{headingId:`network-allowed-addresses`,title:n(`system.networkAddresses.allowedAddresses`,`Allowed addresses`),actions:e(`div`,{className:`flex flex-wrap items-center gap-1`,children:[e(P,{size:`sm`,variant:`secondary`,onClick:()=>m.mutate(void 0),disabled:m.isPending||p.isPending,title:n(`system.networkAddresses.reRunTheAutoDetection`,`Re-run the auto-detection heuristic + overwrite the current allowlist with the best matches.`),children:[r(te,{className:`h-3 w-3`}),m.isPending?n(`system.networkAddresses.detecting`,`Detecting…`):n(`system.networkAddresses.bestMatch`,`Best match`)]}),e(P,{size:`sm`,variant:`secondary`,onClick:()=>{w([])},disabled:C.length===0||p.isPending,children:[r(v,{className:`h-3 w-3`}),n(`system.networkAddresses.clear`,`Clear`)]}),D&&r(P,{size:`sm`,variant:`secondary`,onClick:()=>{w(E)},disabled:p.isPending,children:n(`system.networkAddresses.discard`,`Discard`)}),e(P,{size:`sm`,variant:`primary`,onClick:()=>{p.mutate({addresses:[...C]})},disabled:!D||p.isPending,children:[r(ne,{className:`h-3 w-3`}),p.isPending?n(`system.networkAddresses.saving`,`Saving…`):n(`common.save`,`Save`)]})]}),children:e(`div`,{className:l,children:[r(`p`,{className:`mb-3 text-xs text-foreground-subtle`,children:C.length===0?n(`system.networkAddresses.autoEveryNonLoopbackNon`,`Auto — every non-loopback / non-link-local interface participates.`):n(`system.networkAddresses.pinned`,`{{value1}} pinned`,{value1:String(C.length)})}),r($e,{mode:`multiple`,interfaces:h,value:C,onChange:w,disabled:p.isPending,emptyMessage:d.isLoading?n(`system.networkAddresses.loadingInterfaces`,`Loading interfaces…`):n(`system.networkAddresses.noInterfacesDetected`,`No interfaces detected.`)})]})}),r(it,{book:g.data,loading:g.isLoading,saving:S,error:x,onSetRole:e=>_.mutate({...e}),onAdd:(e,t)=>y.mutate({baseUrl:e,label:t}),onRemove:e=>b.mutate({baseUrl:e})})]})}o();var ot={mesh:`bg-violet-500/15 text-violet-700 dark:text-violet-300`,public:`bg-blue-500/15 text-blue-700 dark:text-blue-300`},Z=5e3,Q=`mesh-network`,st=3e4,ct={joined:!1,meshIp:``,magicDnsHostname:``,peerCount:0,endpoints:[],tenantName:``,magicDnsSuffix:``,userLogin:null,controlPlaneUrl:``,keyExpiry:null};function lt(){let{t:e}=L(),n=M({capName:`mesh-network`},{refetchInterval:Z}),i=N(void 0,{refetchInterval:Z}),a=t(()=>G(i.data??[]),[i.data]),o=t(()=>(n.data??[]).map(e=>({addonId:e.addonId,displayName:a.get(e.addonId)??e.addonId,isActive:e.isActive})),[n.data,a]),s=[{id:Q,label:e(`system.meshNetworks.meshNetworks`,`Mesh networks`),install:{capability:Q,label:e(`system.meshNetworks.addMesh`,`Add mesh`)},entries:o.map(t=>({id:t.addonId,name:t.displayName,fallbackIcon:f,...W(t.isActive),render:()=>r(V,{addonId:t.addonId,displayName:t.displayName,capName:Q,isActive:t.isActive,badges:r(ut,{addonId:t.addonId}),primaryAction:r(dt,{addonId:t.addonId}),panels:[{id:`status`,title:e(`system.meshNetworks.status`,`Status`),icon:A,content:r(ft,{addonId:t.addonId})}]})}))}];return r(U,{embedded:!0,icon:A,title:e(`system.meshNetworks.meshNetworks2`,`Mesh Networks`),subtitle:e(`system.meshNetworks.privateVpnMeshesThatConnect`,`Private VPN meshes that connect CamStack to your other devices (Tailscale, Headscale, …). Each provider can also expose this hub publicly via its ingress (Tailscale Funnel).`),groups:s,isLoading:n.isLoading,emptyTitle:e(`system.meshNetworks.noMeshNetworkProvidersInstalled`,`No mesh-network providers installed`),emptyDescription:e(`system.meshNetworks.installAMeshAddonE`,`Install a mesh addon (e.g. @camstack/addon-tailscale) to join this hub into a private VPN mesh.`)})}function $(e){let{data:t,isLoading:n}=be({addonId:e},{refetchInterval:Z,retry:!1}),r=t?k.safeParse(t):null;return{status:r?.success?r.data:ct,isLoading:n}}function ut({addonId:t}){let{t:n}=L(),{status:i}=$(t);return e(c,{children:[r(F,{variant:i.joined?`success`:`default`,className:H,children:i.joined?n(`system.meshNetworks.joined`,`Joined`):n(`system.meshNetworks.notJoined`,`Not joined`)}),i.joined&&r(F,{className:`text-[10px]`,children:n(`common.peers`,{count:i.peerCount})})]})}function dt({addonId:t}){let{t:i}=L(),o=s(),[l,u]=a(!1),[d,f]=a(null),p=S(),{status:m}=$(t),h=n(()=>{o.invalidateQueries({queryKey:[[`meshNetwork`]]})},[o]),g=Oe(),_=Ae({onSuccess:h}),v=Ce({onSuccess:h}),y=n(async()=>{u(!0);let e={cancelled:!1};f(e);try{let n=await g.mutateAsync({addonId:t});if(e.cancelled)return;n.loginUrl&&window.open(n.loginUrl,`_blank`,`noopener,noreferrer`);let r=Date.now();for(;!e.cancelled&&(await yt(2e3),!e.cancelled);){let e=await p.trpcClient.meshNetwork.getStatus.query({addonId:t}).catch(()=>null),n=e?k.safeParse(e):null;if(n?.success&&n.data.joined){h();break}if(Date.now()-r>6e5)break}}finally{u(!1),f(null)}},[t,h,g,p]),b=n(()=>{d&&(d.cancelled=!0),u(!1),f(null)},[d]);return r(c,{children:m.joined?e(c,{children:[e(P,{size:`sm`,variant:`secondary`,disabled:_.isPending,onClick:()=>_.mutate({addonId:t}),children:[_.isPending?r(w,{className:`h-3 w-3 animate-spin`}):r(oe,{className:`h-3 w-3`}),i(`system.meshNetworks.disconnect`,`Disconnect`)]}),e(P,{size:`sm`,variant:`ghost`,disabled:v.isPending,onClick:()=>v.mutate({addonId:t}),children:[v.isPending?r(w,{className:`h-3 w-3 animate-spin`}):r(C,{className:`h-3 w-3`}),i(`system.meshNetworks.logOut`,`Log out`)]})]}):l?e(P,{size:`sm`,variant:`ghost`,onClick:b,children:[r(T,{className:`h-3 w-3 mr-1`}),` `,i(`common.cancel`)]}):e(c,{children:[e(P,{size:`sm`,variant:`primary`,onClick:()=>void y(),children:[r(se,{className:`h-3 w-3`}),i(`system.meshNetworks.connect`,`Connect`)]}),e(P,{size:`sm`,variant:`ghost`,disabled:v.isPending,onClick:()=>v.mutate({addonId:t}),children:[v.isPending?r(w,{className:`h-3 w-3 animate-spin`}):r(C,{className:`h-3 w-3`}),i(`system.meshNetworks.logOut`,`Log out`)]})]})})}function ft({addonId:t}){let{t:n}=L(),{status:i}=$(t),a=Ne({addonId:t},{refetchInterval:st,retry:!1});return e(`div`,{className:`rounded-lg border border-border bg-surface`,children:[e(`div`,{className:`space-y-4 p-2 sm:p-4`,children:[i.error&&r(pe,{message:i.error}),r(pt,{status:i}),i.endpoints.length>0&&e(`div`,{className:`space-y-1.5`,children:[r(`div`,{className:`text-[11px] font-semibold text-foreground-subtle uppercase tracking-wide`,children:n(`system.meshNetworks.endpoints`,`Endpoints`)}),i.endpoints.map(t=>e(`div`,{className:`flex items-center gap-2 text-xs flex-wrap`,children:[e(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium ${ot[t.scope]??`bg-foreground-subtle/15 text-foreground-subtle`}`,children:[t.scope===`public`?r(j,{className:`inline h-2.5 w-2.5 mr-0.5`}):null,t.label]}),e(`a`,{href:t.url,target:`_blank`,rel:`noopener noreferrer`,className:`text-emerald-700 dark:text-emerald-300 hover:underline break-all flex items-center gap-1`,children:[r(h,{className:`h-3 w-3 shrink-0`}),t.url]})]},t.id))]})]}),r(`div`,{className:`border-t border-border`,children:r(ht,{peers:a.data?.peers??[],loading:a.isLoading})})]})}function pt({status:t}){let{t:n}=L();return r(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-x-6 gap-y-1.5`,children:[{label:n(`system.meshNetworks.tenant`,`Tenant`),value:t.tenantName||`—`},{label:n(`system.meshNetworks.user`,`User`),value:t.userLogin??`—`},{label:n(`system.meshNetworks.controlPlane`,`Control plane`),value:t.controlPlaneUrl||`—`},{label:n(`system.meshNetworks.meshIp`,`Mesh IP`),value:t.meshIp||`—`,mono:!0},{label:n(`system.meshNetworks.magicdns`,`MagicDNS`),value:t.magicDnsHostname||`—`,mono:!0},{label:n(`system.meshNetworks.dnsSuffix`,`DNS suffix`),value:t.magicDnsSuffix||`—`,mono:!0},{label:n(`system.meshNetworks.peers`,`Peers`),value:String(t.peerCount)},{label:n(`system.meshNetworks.keyExpiry`,`Key expiry`),value:t.keyExpiry?mt(t.keyExpiry):`—`}].map(t=>e(`div`,{className:`flex items-baseline justify-between gap-3 text-xs`,children:[r(`span`,{className:`text-foreground-subtle shrink-0`,children:t.label}),r(`span`,{className:`text-foreground truncate ${t.mono?`font-mono`:``}`,children:t.value})]},t.label))})}function mt(e){let t=e-Date.now();if(t<0)return I.t(`system.meshNetworks.expiredAgo`,{when:vt(e)});let n=Math.floor(t/864e5);if(n>60)return new Date(e).toLocaleDateString();if(n>1)return I.t(`system.meshNetworks.expiryDays`,{count:n});let r=Math.floor(t/36e5);return r>1?I.t(`system.meshNetworks.expiryHours`,{count:r}):I.t(`system.meshNetworks.expiryMin`,{count:Math.max(1,Math.floor(t/6e4))})}function ht({peers:i,loading:a}){let{t:o}=L(),s=t(()=>i.map(e=>({...e,_id:e.id})),[i]),c=n(e=>{e&&navigator.clipboard?.writeText(e)},[]),l=t(()=>[{key:`hostname`,header:o(`system.meshNetworks.hostname`,`Hostname`),render:t=>e(`div`,{className:`flex flex-col`,children:[e(`div`,{className:`flex items-center gap-1.5`,children:[r(`span`,{className:`font-medium text-foreground`,children:t.hostname||o(`system.meshNetworks.unknown`,`(unknown)`)}),t.isSelf&&r(F,{variant:`info`,children:o(`common.self`)}),t.exitNodeOption&&r(F,{variant:`warning`,children:`exit-node`})]}),t.userLogin&&r(`div`,{className:`text-[10px] text-foreground-subtle truncate`,children:t.userLogin})]})},{key:`magicDns`,header:o(`system.meshNetworks.magicdns`,`MagicDNS`),render:t=>t.magicDns?e(`div`,{className:`flex items-center gap-1`,children:[r(`span`,{className:`font-mono text-xs truncate`,children:t.magicDns}),r(`button`,{onClick:()=>c(t.magicDns),className:`p-0.5 hover:bg-foreground-subtle/10 rounded`,"aria-label":o(`system.meshNetworks.copyMagicdns`,`Copy MagicDNS`),children:r(E,{className:`h-3 w-3 text-foreground-subtle`})})]}):r(`span`,{className:`text-foreground-subtle`,children:`—`})},{key:`addresses`,header:`IP`,render:t=>{let n=t.addresses[0]??``;return n?e(`div`,{className:`flex items-center gap-1`,children:[r(`span`,{className:`font-mono text-xs`,children:n}),r(`button`,{onClick:()=>c(n),className:`p-0.5 hover:bg-foreground-subtle/10 rounded`,"aria-label":o(`system.meshNetworks.copyIp`,`Copy IP`),children:r(E,{className:`h-3 w-3 text-foreground-subtle`})})]}):r(`span`,{className:`text-foreground-subtle`,children:`—`})}},{key:`connection`,header:o(`system.meshNetworks.connection`,`Connection`),render:t=>e(`div`,{className:`flex items-center gap-1.5`,children:[r(F,{variant:gt(t.connection),children:t.connection}),t.relay&&r(`span`,{className:`text-[10px] text-foreground-subtle font-mono`,children:t.relay})]})},{key:`routes`,header:o(`system.meshNetworks.routes`,`Routes`),render:e=>e.advertisedRoutes.length>0?r(`span`,{className:`text-[10px] font-mono text-foreground-subtle truncate`,children:e.advertisedRoutes.join(`, `)}):r(`span`,{className:`text-foreground-subtle`,children:`—`})},{key:`tx`,header:o(`system.meshNetworks.txRx`,`TX / RX`),render:t=>e(`span`,{className:`text-[10px] text-foreground-subtle font-mono`,children:[`↑ `,_t(t.txBytes),` · ↓ `,_t(t.rxBytes)]})},{key:`lastSeen`,header:o(`system.meshNetworks.lastSeen`,`Last seen`),render:e=>r(`span`,{className:`text-[10px] text-foreground-subtle`,children:e.lastSeenMs>0?vt(e.lastSeenMs):`—`})}],[c,o]);return a&&i.length===0?e(`div`,{className:`p-4 text-xs text-foreground-subtle`,children:[r(w,{className:`h-3 w-3 animate-spin inline mr-1`}),` `,o(`systemPage.meshNetworks.loadingPeers`)]}):i.length===0?r(`div`,{className:`p-4 text-xs text-foreground-subtle`,children:o(`system.meshNetworks.noPeersVisibleYourTailnet`,`No peers visible — your tailnet may be empty or the host is not joined.`)}):r(`div`,{className:`p-4`,children:r(fe,{columns:l,rows:s,rowKey:e=>e._id,minWidthPx:820})})}function gt(e){return e===`direct`?`success`:e===`relay`?`warning`:`info`}function _t(e){return e<1024?`${e}B`:e<1024*1024?`${(e/1024).toFixed(1)}KB`:e<1024*1024*1024?`${(e/1024/1024).toFixed(1)}MB`:`${(e/1024/1024/1024).toFixed(2)}GB`}function vt(e){let t=Date.now()-e;return t<6e4?I.t(`system.meshNetworks.justNow`):t<36e5?I.t(`system.meshNetworks.agoMin`,{count:Math.round(t/6e4)}):t<864e5?I.t(`system.meshNetworks.agoHour`,{count:Math.round(t/36e5)}):I.t(`system.meshNetworks.agoDay`,{count:Math.round(t/864e5)})}function yt(e){return new Promise(t=>setTimeout(t,e))}var bt=`/system/identity?tab=certificates`;function xt(){let{t}=L();return r(B,{embedded:!0,children:e(`div`,{className:g,children:[r(Be,{nodeId:`hub`,addonIds:[`local-network`],level:`global`,title:t(`system.localAccess.lanHttp`,`LAN HTTP`),description:t(`system.localAccess.nativeAppsOnThisWi`,`Native apps on this Wi-Fi use http:// and skip the private certificate. The tunnel and this admin UI stay on HTTPS.`)}),e(`p`,{className:`text-xs text-foreground-subtle`,"data-testid":`https-certificate-hint`,children:[t(`system.localAccess.certificateMoved`,`The HTTPS certificate and the local CA are managed under`),` `,r(Ie,{className:`underline`,to:bt,children:t(`system.localAccess.certificateMovedLink`,`Identity → Certificates`)}),`.`]})]})})}o();function St({value:n,onChange:i}){let{t:a}=L(),{data:o}=le({isCamera:!0,projection:`slim`}),s=t(()=>o===void 0?[{value:``,label:a(`system.networkDiagnostics.loadingCameras`,`Loading cameras…`)}]:o.length===0?[{value:``,label:a(`system.networkDiagnostics.noCameras`,`No cameras`)}]:[{value:``,label:a(`system.networkDiagnostics.pickACamera`,`Pick a camera`)},...o.toSorted((e,t)=>e.name.localeCompare(t.name)).map(e=>({value:String(e.id),label:`${e.name} (#${String(e.id)})`}))],[o,a]);return e(`label`,{className:`flex min-w-0 flex-col gap-1`,children:[r(`span`,{className:`text-[11px] text-foreground-subtle`,children:a(`system.networkDiagnostics.camera`,`Camera`)}),r(we,{value:n===null?``:String(n),disabled:o===void 0||o.length===0,onChange:e=>i(e.target.value===``?null:Number(e.target.value)),options:s})]})}function Ct(){let t=S(),[i,o]=a(null);return r(B,{embedded:!0,children:e(`div`,{className:g,"data-testid":`network-diagnostics`,children:[r(Pe,{loadServers:n(async()=>t.trpcClient.turnProvider.getTurnServers.query(),[t])}),r(ye,{trpc:t.trpcClient,serverUrl:y(),deviceId:i,cameraField:r(St,{value:i,onChange:o})})]})})}var wt=[`certificate`,`certificates`,`https`];function Tt(){let{t:e}=L(),[t]=Re();if(wt.includes(t.get(`tab`)??``))return r(Le,{to:bt,replace:!0});let n=Fe(`/system/network`,{t:e,isAdmin:!0})??{icon:j,title:e(`system.network`,`Network`)};return r(ze,{icon:n.icon,title:n.title,defaultSection:`addresses`,sectionsLabel:`${n.title} sections`,sections:[{id:`local-access`,label:e(`systemPage.network.localAccess`,`Local access`),content:r(xt,{})},{id:`addresses`,label:e(`systemPage.network.networkAddresses`,`Network Addresses`),content:r(at,{})},{id:R.remoteAccess.tab,label:e(`systemPage.network.remoteAccess`,`Remote Access`),content:r(He,{}),ownedParams:z},{id:R.mesh.tab,label:e(`systemPage.network.meshNetworks`,`Mesh Networks`),content:r(lt,{}),ownedParams:z},{id:R.turn.tab,label:e(`systemPage.network.turnServers`,`TURN Servers`),content:r(Je,{}),ownedParams:z},{id:`diagnostics`,label:e(`systemPage.network.diagnostics`,`Diagnostics`),content:r(Ct,{})}]})}export{Tt as NetworkPage};