@camstack/addon-admin-ui 1.2.422 → 1.2.423

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 (41) hide show
  1. package/dist/assets/{Addons-D6p7m_1Q.js → Addons-BktOW4F8.js} +1 -1
  2. package/dist/assets/{AdminSectionedPage-Dn3pfXpN.js → AdminSectionedPage-Bxl6ynK9.js} +1 -1
  3. package/dist/assets/{AiProfiles-A_EtYWgt.js → AiProfiles-C1gPj2bX.js} +1 -1
  4. package/dist/assets/{BrokerForm-B50lYczl.js → BrokerForm-IsugOBK4.js} +1 -1
  5. package/dist/assets/{Build-CYzfQeUi.js → Build-B_z36azr.js} +1 -1
  6. package/dist/assets/{Calendars-DxzSNlaT.js → Calendars-Cf3-_VqS.js} +1 -1
  7. package/dist/assets/{Cluster-CdpU74GH.js → Cluster-Toaq2cXH.js} +1 -1
  8. package/dist/assets/{ClusterStepModel-CL6OTKoe.js → ClusterStepModel-HGdVtQDz.js} +1 -1
  9. package/dist/assets/{CompositionEditorPage-BtUyHyvc.js → CompositionEditorPage-uV-Cm8er.js} +1 -1
  10. package/dist/assets/{Data-DjwFU5Th.js → Data-bKesoA54.js} +1 -1
  11. package/dist/assets/{DeviceDetail-_84gb-7d.js → DeviceDetail-BjXcgEMv.js} +1 -1
  12. package/dist/assets/{Devices-Bn806mzY.js → Devices-fjoSRvSX.js} +1 -1
  13. package/dist/assets/Identity-DQ0v3wpf.js +1 -0
  14. package/dist/assets/{IntegrationDetail-NFPFWNqY.js → IntegrationDetail-DVT833aa.js} +1 -1
  15. package/dist/assets/{IntegrationHub-nkG_70wF.js → IntegrationHub-Diwlzwdk.js} +1 -1
  16. package/dist/assets/{Integrations-BnJ0plVy.js → Integrations-Bv9yI-aK.js} +1 -1
  17. package/dist/assets/{Integrations-DwbH7OPk.js → Integrations-D2m9GJEd.js} +1 -1
  18. package/dist/assets/{Library-BeKXIn8H.js → Library-CpjvRB_8.js} +1 -1
  19. package/dist/assets/{Locations-LFHKGJj6.js → Locations-BOqmVhMT.js} +1 -1
  20. package/dist/assets/{Logs-Bv7UFKGr.js → Logs-ANsOyCMt.js} +1 -1
  21. package/dist/assets/MyAccess-CYYdpIJp.js +2 -0
  22. package/dist/assets/{Network-Dm89K78z.js → Network-BgzNU0Jj.js} +1 -1
  23. package/dist/assets/{NodeAddonsSettingsPanel-DW1CFRqr.js → NodeAddonsSettingsPanel-Bhu-tW8k.js} +1 -1
  24. package/dist/assets/{Notifications--YlWuq7D.js → Notifications-BoUEVbJ-.js} +1 -1
  25. package/dist/assets/{Recordings-B3tdsucL.js → Recordings-CciKKl6g.js} +1 -1
  26. package/dist/assets/{ScanNetworkModal-DVDP8rFS.js → ScanNetworkModal-DstPO1i_.js} +1 -1
  27. package/dist/assets/SessionsList-BGuCGBZB.js +2 -0
  28. package/dist/assets/{Showroom-DBz_kmHd.js → Showroom-C8zKWI0u.js} +1 -1
  29. package/dist/assets/{System-CbZHPKfq.js → System-8fNvqrsY.js} +1 -1
  30. package/dist/assets/{Terminal-CECng0sk.js → Terminal-CI2Bx9Jq.js} +1 -1
  31. package/dist/assets/{device-integration-icon-DC6GK3pO.js → device-integration-icon-DNAzKen7.js} +1 -1
  32. package/dist/assets/{index-Dbcd0nug.js → index-BuW8Mb0x.js} +2 -2
  33. package/dist/assets/{location-owned-usage-D9_fG4z9.js → location-owned-usage-CueI-yQx.js} +1 -1
  34. package/dist/assets/{mf-entry-bootstrap-0-dcb80f94.js → mf-entry-bootstrap-0-8e819fac.js} +1 -1
  35. package/dist/assets/{useNodeUrlSelection-DD1VIgYL.js → useNodeUrlSelection-6F8U-uWa.js} +1 -1
  36. package/dist/index.html +2 -2
  37. package/dist/server/addon.js +1 -1
  38. package/package.json +1 -1
  39. package/dist/assets/Identity-aeXxefik.js +0 -1
  40. package/dist/assets/MyAccess-BrfWHy-Y.js +0 -2
  41. package/dist/assets/SessionsList-BFeOCT72.js +0 -2
@@ -1 +1 @@
1
- import{I as e,Q as t,S as n,W as r,b as i,o as a,q as o,x as s,z as c}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{Dn as l,On as u,Sn as d,_i as f,ar as p,bi as m,dn as h,dt as g,ln as _,ot as v,wi as y,yi as b,yn as x}from"./player-overlays-BOsDheHc.js";import{Ki as ee,M as S,Xl as C,co as te,et as w,iu as T,ma as E,mr as D,oo as O,r as k,ra as A,ro as j,rt as ne,tt as M}from"./src-CCd-7AXY.js";import{t as N}from"./useTranslation-Bc5yH9V9.js";import{K as P,Q as re,X as F}from"./index-Dbcd0nug.js";import{t as I}from"./AdminPage-BXCcRjRj.js";import"./useEventInvalidation-BmKHpH-F.js";import{t as L}from"./device-integration-icon-DC6GK3pO.js";import{n as R,r as z,t as ie}from"./ScanNetworkModal-DVDP8rFS.js";t();function B(e=!0){c(()=>{if(!e)return;let t=document.body.style.overflow;return document.body.style.overflow=`hidden`,()=>{document.body.style.overflow=t}},[e])}t();function V(e,t){let[n,r]=o(!1);return c(()=>{if(!e){r(!1);return}r(!1);let n=setTimeout(()=>r(!0),t);return()=>clearTimeout(n)},[e,t]),n}t();function ae({providerId:e,onImport:t,onSkip:r}){let{t:i}=N(),[a,l]=o(new Set),u=A(),d=u.data,f=u.isPending||!u.data&&!u.isError;c(()=>{e&&(u.isPending||u.data||u.mutate({addonId:e}))},[e,u]);function p(e){l(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}if(f)return n(`div`,{className:`flex flex-col items-center py-12`,children:[s(`div`,{className:`h-6 w-6 animate-spin rounded-full border-2 border-primary border-t-transparent`}),s(`p`,{className:`mt-3 text-xs text-foreground-subtle`,children:i(`integrations.searchingDevices`)})]});let h=d??[];return n(`div`,{className:`space-y-4`,children:[s(`p`,{className:`text-xs text-foreground-subtle`,children:h.length>0?i(`integrations.foundDevices`,{count:h.length}):i(`integrations.noDevicesFound`)}),h.length>0&&s(`div`,{className:`space-y-1.5 max-h-64 overflow-y-auto`,children:h.map(e=>{let t=e.stableId,r=e.suggestedName??t,o=a.has(t),c=e.alreadyOnboarded===!0;return n(`button`,{onClick:()=>{c||p(t)},disabled:c,title:c?i(`integrations.alreadyAddedHint`,{defaultValue:`Already added as "{{name}}" — re-adding would overwrite its settings.`,name:e.onboardedName??r}):void 0,className:`flex w-full items-center gap-3 rounded-lg border p-3 text-left transition-colors ${c?`border-border bg-surface opacity-60 cursor-not-allowed`:o?`border-primary/40 bg-primary/5`:`border-border bg-surface hover:border-foreground-subtle/30`}`,children:[s(`div`,{className:`flex h-5 w-5 items-center justify-center rounded border flex-shrink-0 ${o&&!c?`border-primary bg-primary`:`border-border`}`,children:o&&!c&&s(m,{className:`h-3 w-3 text-primary-foreground`})}),s(y,{className:`h-3.5 w-3.5 text-foreground-subtle flex-shrink-0`}),s(`span`,{className:`text-xs font-medium text-foreground truncate`,children:r}),c&&s(`span`,{className:`ml-auto flex-shrink-0 rounded bg-surface-muted px-1.5 py-0.5 text-[10px] font-medium text-foreground-subtle`,children:i(`integrations.alreadyAdded`,{defaultValue:`Already added`})})]},t)})}),n(`div`,{className:`flex items-center justify-between pt-2`,children:[s(`button`,{onClick:r,className:`rounded-lg border border-border px-3 py-1.5 text-xs text-foreground-subtle hover:text-foreground transition-colors`,children:i(`integrations.skip`)}),h.length>0&&n(`button`,{onClick:()=>t(Array.from(a)),disabled:a.size===0,className:`rounded-lg bg-primary px-4 py-1.5 text-xs font-medium text-primary-foreground shadow-sm disabled:opacity-50`,children:[i(`integrations.importSelected`),` (`,a.size,`)`]})]})]})}t();function H({onSelect:e,onClose:t,pendingAddonId:i=null}){let{t:a}=N(),c=F(),[l,u]=o(``),{data:d,isLoading:m}=O(),g=r(()=>{let e=d??[],t=l.trim().toLowerCase();return t.length===0?e:e.filter(e=>`${e.name} ${e.description??``} ${e.addonId}`.toLowerCase().includes(t))},[d,l]);if(m)return s(`div`,{className:`grid grid-cols-2 gap-2 p-2`,children:[1,2,3,4].map(e=>s(`div`,{className:`h-24 rounded-lg bg-surface animate-pulse`},e))});let v=i!==null;return n(`div`,{className:`space-y-3`,"data-testid":`provider-picker`,children:[n(`div`,{className:`relative`,children:[s(h,{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}),s(C,{type:`search`,value:l,onChange:e=>u(e.target.value),placeholder:a(`integrations.searchProviders`,`Search integrations…`),className:`pl-8`,"data-testid":`provider-picker-search`,"aria-label":a(`integrations.searchProviders`,`Search integrations…`)})]}),s(`div`,{className:`grid grid-cols-2 gap-2`,children:g.map(r=>{let o=r.instanceMode===`unique`&&r.existingInstances.length>0,l=i===r.addonId,u=v;return n(`button`,{type:`button`,disabled:u,"data-testid":`provider-pick-${r.addonId}`,onClick:()=>{if(!u)if(o){let e=r.existingInstances[0].id;t(),c(`/integrations/${e}`)}else e(r.addonId,r.instanceMode,r.discoveryMode,r.name,r.kind,r.brokerKind,r.mode,r.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:[r.iconUrl?s(`div`,{className:`flex h-9 w-9 items-center justify-center rounded-lg flex-shrink-0`,style:{backgroundColor:`${r.color}15`},children:s(`img`,{src:r.iconUrl,alt:``,className:`h-5 w-5`})}):s(`div`,{className:`flex h-9 w-9 items-center justify-center rounded-lg flex-shrink-0`,style:{backgroundColor:`${r.color}15`},children:s(`span`,{className:`text-sm`,style:{color:r.color},children:`◉`})}),s(`p`,{className:`w-full truncate text-xs font-semibold text-foreground`,children:r.name}),r.description?s(`p`,{className:`w-full line-clamp-2 text-[10px] text-foreground-subtle`,children:r.description}):null,l?s(p,{className:`h-4 w-4 animate-spin text-primary`}):o?n(`span`,{className:`flex items-center gap-1 text-[10px] font-medium text-foreground-subtle`,children:[s(_,{className:`h-3 w-3`}),a(`integrations.manage`)]}):s(f,{className:`h-3.5 w-3.5 text-foreground-subtle`,"aria-hidden":!0})]},r.addonId)})}),g.length===0&&s(`div`,{className:`py-8 text-center text-xs text-foreground-subtle`,children:(d??[]).length===0?a(`integrations.noProviders`):a(`integrations.noProvidersMatch`,`No integrations match your search.`)})]})}t();function U(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 oe=2e4;function se({open:e,onClose:t}){let{t:l}=N(),u=F(),d=a(),[f,m]=o(`picker`),[h,_]=o(null),[v,y]=o(null),[b,x]=o(`manual`),[S,C]=o(null),[te,w]=o(``),[T,E]=o(null),[O,k]=o(null),[ne,M]=o(!1),{data:P}=D({addonId:h??``,nodeId:`hub`},{enabled:h!=null}),re=r(()=>P?U(P):null,[P]),I=j({onSuccess:()=>d.invalidateQueries({queryKey:[[`integrations`]]})}),L=A(),ie=L.data;c(()=>{f!==`discovery`||!v||!h||L.isPending||L.data||L.mutate({addonId:h})},[f,v,h,L]);let se=ee({onSuccess:()=>d.invalidateQueries({queryKey:[[`deviceManager`]]})});function W(e,t,n,r,i,a,o,s){if(!I.isPending){if(_(e),M(s),x(n),w(r),k(null),o===`broker`){if(!a){k(`Addon '${e}' declares mode 'broker' but no brokerKind in its manifest`);return}C(a),m(`broker`);return}if(o===`account`){m(`config`);return}ce(e,r)}}async function ce(e,n){try{let r=await I.mutateAsync({addonId:e,name:n,settings:{}});t(),J(),u(`/integrations/${r.id}?add=1`)}catch{}}async function le(e){if(h)try{let t=await I.mutateAsync({addonId:h,name:e.name,settings:e.config,secretKeys:[...e.secretKeys]});y(t.id),b===`auto`||b===`both`?m(`discovery`):q(t.id)}catch{}}async function G(e){if(h)try{let t=await I.mutateAsync({addonId:h,name:te,settings:{brokerId:e}});E(t.id),y(t.id),q(t.id)}catch{}}async function K(e){if(h){for(let t of e){let e=ie?.find(e=>e.stableId===t);e&&await se.mutateAsync({addonId:h,candidate:e,...T===null?{}:{integrationId:T}})}q()}}function q(e){let n=e??v??h;t(),J(),n&&u(`/integrations/${n}`)}function J(){m(`picker`),_(null),y(null),x(`manual`),C(null),w(``),E(null),k(null),M(!1)}function Y(){t(),J()}B(e);let X=I.isPending,Z=V(X,oe);if(!e)return null;let ue={picker:l(`integrations.newIntegration`),config:l(`integrations.configureIntegration`),discovery:l(`integrations.importDevices`),broker:l(`integrations.connectBroker`,{defaultValue:`Connect a broker`})},Q=X?h:null,$=I.error,de=X&&!Z;return n(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center`,children:[s(`div`,{className:`absolute inset-0 bg-black/60`,onClick:de?void 0:Y}),n(`div`,{className:`relative z-10 w-full max-w-lg max-h-[calc(85dvh-2*max(env(safe-area-inset-top),env(safe-area-inset-bottom)))] rounded-xl border border-border bg-background shadow-2xl flex flex-col overflow-hidden`,children:[n(`div`,{className:`flex items-center justify-between border-b border-border px-5 py-4 flex-shrink-0`,children:[s(`h2`,{className:`text-sm font-semibold text-foreground`,children:ue[f]}),s(`button`,{onClick:Y,disabled:de,className:`rounded-md p-1 text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-40 disabled:cursor-not-allowed`,children:s(g,{className:`h-4 w-4`})})]}),n(`div`,{className:`px-5 py-4 flex-1 overflow-y-auto overscroll-contain`,children:[$&&!X&&s(`div`,{className:`mb-3 rounded-lg border border-destructive/40 bg-destructive/10 px-3 py-2 text-xs text-destructive`,children:$ instanceof Error?$.message:String($)}),f===`picker`&&n(i,{children:[O&&s(`div`,{className:`mb-3 rounded-lg border border-destructive/40 bg-destructive/10 px-3 py-2 text-xs text-destructive`,children:O}),s(H,{onSelect:W,onClose:Y,pendingAddonId:Q})]}),f===`config`&&h&&s(R,{addonId:h,configSchema:re??null,canTest:ne,onSave:le,onBack:()=>m(`picker`)}),f===`broker`&&S&&s(z,{kind:S,onResolved:e=>{G(e)},onBack:()=>m(`picker`)}),f===`discovery`&&v&&s(ae,{providerId:v,onImport:K,onSkip:q})]}),X&&n(`div`,{className:`absolute inset-0 z-20 flex flex-col items-center justify-center gap-2 rounded-xl bg-background/85 backdrop-blur-sm px-6 text-center`,children:[s(p,{className:`h-6 w-6 animate-spin text-primary`}),s(`p`,{className:`text-xs font-medium text-foreground`,children:l(`integrations.creating`,{defaultValue:`Creating integration…`})}),!Z&&s(`p`,{className:`text-[10px] text-foreground-subtle`,children:l(`integrations.creatingHint`,{defaultValue:`Waiting for the addon to restart and register`})}),Z&&n(i,{children:[s(`p`,{className:`text-[10px] text-foreground-subtle max-w-xs`,children:l(`integrations.creatingOverdue`,{defaultValue:`This is taking longer than expected. The integration may already have been created — close this dialog and refresh to check.`})}),s(`button`,{onClick:Y,className:`mt-1 rounded-md border border-border bg-surface px-3 py-1.5 text-[11px] font-medium text-foreground hover:bg-surface-hover transition-colors`,children:l(`integrations.closeAndRefresh`,{defaultValue:`Close`})})]})]})]})]})}function W({integration:e,expanded:t,onToggleExpand:r}){return n(`div`,{className:`flex items-center gap-2.5`,children:[s(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),r(e.addonId)},"aria-label":t?`Collapse`:`Expand`,"aria-expanded":t,className:`flex h-5 w-5 flex-shrink-0 items-center justify-center rounded text-foreground-subtle transition-colors hover:bg-surface-hover hover:text-foreground`,children:s(t?b:f,{className:`h-3.5 w-3.5`})}),s(P,{type:e.addonId,size:`sm`}),n(`div`,{className:`flex min-w-0 flex-col`,children:[s(`span`,{className:`truncate text-xs font-semibold text-foreground`,children:e.name}),s(`span`,{className:`truncate text-[10px] text-foreground-subtle`,children:e.addonId})]})]})}function ce(e){let{isExpanded:t,onToggleExpand:n}=e;return[{key:`name`,header:`Integration`,headerClassName:`w-[55%]`,cell:e=>s(W,{integration:e,expanded:t(e),onToggleExpand:n})},{key:`devices`,header:`Devices`,headerClassName:`w-[15%]`,cellClassName:`text-[11px] text-foreground-subtle`,cell:e=>`${e.deviceCount} device${e.deviceCount===1?``:`s`}`},{key:`status`,header:`Status`,headerClassName:`w-[15%]`,cell:e=>s(S,{status:e.status})}]}t();function le(e){if(!e.enabled)return`disabled`;switch(e.processState){case`running`:return`running`;default:return`stopped`}}var G=`expand`;function K(){let{t}=N(),a=F(),c=v(),[f]=re(),[p,m]=o(!1),h=e(()=>m(!0),[]),g=e(()=>m(!1),[]),[_,y]=o(!1),b=e(()=>y(!0),[]),ee=e(()=>y(!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:S,isLoading:C,refetch:D}=te(void 0),{data:O,isLoading:A,refetch:j}=E({projection:`slim`}),P=r(()=>O??[],[O]),R=r(()=>S??[],[S]),z=r(()=>{let e=new Map;for(let t of P)e.set(t.id,{id:t.id,name:t.name??t.stableId??`#${String(t.id)}`});return e},[P]),B=r(()=>M(S),[S]),V=r(()=>{let e=new Map;for(let t of ne(P)){let n=B(t);if(n.kind!==`resolved`)continue;let r=n.integration.id;e.set(r,(e.get(r)??0)+1)}return e},[P,B]),ae=r(()=>R.map(e=>({id:e.id,addonId:e.addonId,name:e.name,enabled:e.enabled,status:le(e),deviceCount:V.get(e.id)??0})),[R,V]),H=f.get(G),U=e(e=>{let t=new URLSearchParams(window.location.search);t.get(G)===e?t.delete(G):t.set(G,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`))},[]),oe=e(e=>a(`/integrations/${e.id}`),[a]),W=e(e=>z.get(e)??null,[z]),K=e(e=>a(`/devices/${String(e)}`),[a]),q=e(e=>s(w,{context:`integration-detail`,devices:P,trpc:c.trpcClient,integrationOf:B,forceIntegrationId:e.id,urlScope:`nested`,lsKey:`integrations:nested:${e.addonId}`,resolveIntegrationIcon:L,resolveParent:W,onNavigate:K}),[P,c.trpcClient,B,W,K]),J=e(e=>H===e.addonId,[H]),Y=r(()=>ce({isExpanded:J,onToggleExpand:U}),[J,U]),X=e(e=>`${e.name} ${e.addonId}`,[]),Z=e(e=>e.addonId,[]),ue=e(()=>{D(),j()},[D,j]),Q=C||A,$=R.length>0;return n(I,{icon:l,title:t(`nav.integrations`,`Integrations`),actions:n(i,{children:[s(`button`,{onClick:ue,disabled:Q,className:`flex items-center gap-1 rounded-lg border border-border bg-surface px-2.5 py-1.5 text-xs font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50`,title:`Refresh`,children:s(x,{className:T(`h-3.5 w-3.5`,Q&&`animate-spin`)})}),n(`button`,{onClick:b,className:`flex items-center gap-1.5 rounded-lg border border-border bg-surface px-2.5 py-1.5 text-xs font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,title:`Scan the local network for devices`,children:[s(d,{className:`h-3.5 w-3.5`}),`Scan network`]}),n(`button`,{onClick:h,className:`flex items-center gap-1.5 rounded-lg bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground shadow-sm`,children:[s(u,{className:`h-3.5 w-3.5`}),`New Integration`]})]}),children:[Q&&s(`div`,{className:`space-y-2`,children:[1,2,3].map(e=>s(`div`,{className:`h-12 rounded-lg border border-border bg-surface animate-pulse`},e))}),!Q&&!$&&n(`div`,{className:`flex flex-col items-center py-20 text-foreground-subtle`,children:[s(`p`,{className:`text-sm`,children:`No integrations configured.`}),s(`p`,{className:`text-xs mt-1`,children:`Click "New Integration" to connect cameras and devices.`})]}),!Q&&$&&s(w,{mode:`generic`,items:ae,getKey:Z,getSearchText:X,columns:Y,onRowClick:oe,isExpanded:J,renderExpanded:q,searchPlaceholder:t(`integrations.search`,{defaultValue:`Search integrations…`}),emptyLabel:t(`integrations.empty`,{defaultValue:`No integrations found.`})}),s(se,{open:p,onClose:g}),s(ie,{open:_,onClose:ee})]})}export{K as IntegrationsPage};
1
+ import{I as e,Q as t,S as n,W as r,b as i,o as a,q as o,x as s,z as c}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{Dn as l,On as u,Sn as d,_i as f,ar as p,bi as m,dn as h,dt as g,ln as _,ot as v,wi as y,yi as b,yn as x}from"./player-overlays-BOsDheHc.js";import{Ki as ee,M as S,Xl as C,co as te,et as w,iu as T,ma as E,mr as D,oo as O,r as k,ra as A,ro as j,rt as ne,tt as M}from"./src-CCd-7AXY.js";import{t as N}from"./useTranslation-Bc5yH9V9.js";import{K as P,Q as re,X as F}from"./index-BuW8Mb0x.js";import{t as I}from"./AdminPage-BXCcRjRj.js";import"./useEventInvalidation-BmKHpH-F.js";import{t as L}from"./device-integration-icon-DNAzKen7.js";import{n as R,r as z,t as ie}from"./ScanNetworkModal-DstPO1i_.js";t();function B(e=!0){c(()=>{if(!e)return;let t=document.body.style.overflow;return document.body.style.overflow=`hidden`,()=>{document.body.style.overflow=t}},[e])}t();function V(e,t){let[n,r]=o(!1);return c(()=>{if(!e){r(!1);return}r(!1);let n=setTimeout(()=>r(!0),t);return()=>clearTimeout(n)},[e,t]),n}t();function ae({providerId:e,onImport:t,onSkip:r}){let{t:i}=N(),[a,l]=o(new Set),u=A(),d=u.data,f=u.isPending||!u.data&&!u.isError;c(()=>{e&&(u.isPending||u.data||u.mutate({addonId:e}))},[e,u]);function p(e){l(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}if(f)return n(`div`,{className:`flex flex-col items-center py-12`,children:[s(`div`,{className:`h-6 w-6 animate-spin rounded-full border-2 border-primary border-t-transparent`}),s(`p`,{className:`mt-3 text-xs text-foreground-subtle`,children:i(`integrations.searchingDevices`)})]});let h=d??[];return n(`div`,{className:`space-y-4`,children:[s(`p`,{className:`text-xs text-foreground-subtle`,children:h.length>0?i(`integrations.foundDevices`,{count:h.length}):i(`integrations.noDevicesFound`)}),h.length>0&&s(`div`,{className:`space-y-1.5 max-h-64 overflow-y-auto`,children:h.map(e=>{let t=e.stableId,r=e.suggestedName??t,o=a.has(t),c=e.alreadyOnboarded===!0;return n(`button`,{onClick:()=>{c||p(t)},disabled:c,title:c?i(`integrations.alreadyAddedHint`,{defaultValue:`Already added as "{{name}}" — re-adding would overwrite its settings.`,name:e.onboardedName??r}):void 0,className:`flex w-full items-center gap-3 rounded-lg border p-3 text-left transition-colors ${c?`border-border bg-surface opacity-60 cursor-not-allowed`:o?`border-primary/40 bg-primary/5`:`border-border bg-surface hover:border-foreground-subtle/30`}`,children:[s(`div`,{className:`flex h-5 w-5 items-center justify-center rounded border flex-shrink-0 ${o&&!c?`border-primary bg-primary`:`border-border`}`,children:o&&!c&&s(m,{className:`h-3 w-3 text-primary-foreground`})}),s(y,{className:`h-3.5 w-3.5 text-foreground-subtle flex-shrink-0`}),s(`span`,{className:`text-xs font-medium text-foreground truncate`,children:r}),c&&s(`span`,{className:`ml-auto flex-shrink-0 rounded bg-surface-muted px-1.5 py-0.5 text-[10px] font-medium text-foreground-subtle`,children:i(`integrations.alreadyAdded`,{defaultValue:`Already added`})})]},t)})}),n(`div`,{className:`flex items-center justify-between pt-2`,children:[s(`button`,{onClick:r,className:`rounded-lg border border-border px-3 py-1.5 text-xs text-foreground-subtle hover:text-foreground transition-colors`,children:i(`integrations.skip`)}),h.length>0&&n(`button`,{onClick:()=>t(Array.from(a)),disabled:a.size===0,className:`rounded-lg bg-primary px-4 py-1.5 text-xs font-medium text-primary-foreground shadow-sm disabled:opacity-50`,children:[i(`integrations.importSelected`),` (`,a.size,`)`]})]})]})}t();function H({onSelect:e,onClose:t,pendingAddonId:i=null}){let{t:a}=N(),c=F(),[l,u]=o(``),{data:d,isLoading:m}=O(),g=r(()=>{let e=d??[],t=l.trim().toLowerCase();return t.length===0?e:e.filter(e=>`${e.name} ${e.description??``} ${e.addonId}`.toLowerCase().includes(t))},[d,l]);if(m)return s(`div`,{className:`grid grid-cols-2 gap-2 p-2`,children:[1,2,3,4].map(e=>s(`div`,{className:`h-24 rounded-lg bg-surface animate-pulse`},e))});let v=i!==null;return n(`div`,{className:`space-y-3`,"data-testid":`provider-picker`,children:[n(`div`,{className:`relative`,children:[s(h,{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}),s(C,{type:`search`,value:l,onChange:e=>u(e.target.value),placeholder:a(`integrations.searchProviders`,`Search integrations…`),className:`pl-8`,"data-testid":`provider-picker-search`,"aria-label":a(`integrations.searchProviders`,`Search integrations…`)})]}),s(`div`,{className:`grid grid-cols-2 gap-2`,children:g.map(r=>{let o=r.instanceMode===`unique`&&r.existingInstances.length>0,l=i===r.addonId,u=v;return n(`button`,{type:`button`,disabled:u,"data-testid":`provider-pick-${r.addonId}`,onClick:()=>{if(!u)if(o){let e=r.existingInstances[0].id;t(),c(`/integrations/${e}`)}else e(r.addonId,r.instanceMode,r.discoveryMode,r.name,r.kind,r.brokerKind,r.mode,r.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:[r.iconUrl?s(`div`,{className:`flex h-9 w-9 items-center justify-center rounded-lg flex-shrink-0`,style:{backgroundColor:`${r.color}15`},children:s(`img`,{src:r.iconUrl,alt:``,className:`h-5 w-5`})}):s(`div`,{className:`flex h-9 w-9 items-center justify-center rounded-lg flex-shrink-0`,style:{backgroundColor:`${r.color}15`},children:s(`span`,{className:`text-sm`,style:{color:r.color},children:`◉`})}),s(`p`,{className:`w-full truncate text-xs font-semibold text-foreground`,children:r.name}),r.description?s(`p`,{className:`w-full line-clamp-2 text-[10px] text-foreground-subtle`,children:r.description}):null,l?s(p,{className:`h-4 w-4 animate-spin text-primary`}):o?n(`span`,{className:`flex items-center gap-1 text-[10px] font-medium text-foreground-subtle`,children:[s(_,{className:`h-3 w-3`}),a(`integrations.manage`)]}):s(f,{className:`h-3.5 w-3.5 text-foreground-subtle`,"aria-hidden":!0})]},r.addonId)})}),g.length===0&&s(`div`,{className:`py-8 text-center text-xs text-foreground-subtle`,children:(d??[]).length===0?a(`integrations.noProviders`):a(`integrations.noProvidersMatch`,`No integrations match your search.`)})]})}t();function U(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 oe=2e4;function se({open:e,onClose:t}){let{t:l}=N(),u=F(),d=a(),[f,m]=o(`picker`),[h,_]=o(null),[v,y]=o(null),[b,x]=o(`manual`),[S,C]=o(null),[te,w]=o(``),[T,E]=o(null),[O,k]=o(null),[ne,M]=o(!1),{data:P}=D({addonId:h??``,nodeId:`hub`},{enabled:h!=null}),re=r(()=>P?U(P):null,[P]),I=j({onSuccess:()=>d.invalidateQueries({queryKey:[[`integrations`]]})}),L=A(),ie=L.data;c(()=>{f!==`discovery`||!v||!h||L.isPending||L.data||L.mutate({addonId:h})},[f,v,h,L]);let se=ee({onSuccess:()=>d.invalidateQueries({queryKey:[[`deviceManager`]]})});function W(e,t,n,r,i,a,o,s){if(!I.isPending){if(_(e),M(s),x(n),w(r),k(null),o===`broker`){if(!a){k(`Addon '${e}' declares mode 'broker' but no brokerKind in its manifest`);return}C(a),m(`broker`);return}if(o===`account`){m(`config`);return}ce(e,r)}}async function ce(e,n){try{let r=await I.mutateAsync({addonId:e,name:n,settings:{}});t(),J(),u(`/integrations/${r.id}?add=1`)}catch{}}async function le(e){if(h)try{let t=await I.mutateAsync({addonId:h,name:e.name,settings:e.config,secretKeys:[...e.secretKeys]});y(t.id),b===`auto`||b===`both`?m(`discovery`):q(t.id)}catch{}}async function G(e){if(h)try{let t=await I.mutateAsync({addonId:h,name:te,settings:{brokerId:e}});E(t.id),y(t.id),q(t.id)}catch{}}async function K(e){if(h){for(let t of e){let e=ie?.find(e=>e.stableId===t);e&&await se.mutateAsync({addonId:h,candidate:e,...T===null?{}:{integrationId:T}})}q()}}function q(e){let n=e??v??h;t(),J(),n&&u(`/integrations/${n}`)}function J(){m(`picker`),_(null),y(null),x(`manual`),C(null),w(``),E(null),k(null),M(!1)}function Y(){t(),J()}B(e);let X=I.isPending,Z=V(X,oe);if(!e)return null;let ue={picker:l(`integrations.newIntegration`),config:l(`integrations.configureIntegration`),discovery:l(`integrations.importDevices`),broker:l(`integrations.connectBroker`,{defaultValue:`Connect a broker`})},Q=X?h:null,$=I.error,de=X&&!Z;return n(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center`,children:[s(`div`,{className:`absolute inset-0 bg-black/60`,onClick:de?void 0:Y}),n(`div`,{className:`relative z-10 w-full max-w-lg max-h-[calc(85dvh-2*max(env(safe-area-inset-top),env(safe-area-inset-bottom)))] rounded-xl border border-border bg-background shadow-2xl flex flex-col overflow-hidden`,children:[n(`div`,{className:`flex items-center justify-between border-b border-border px-5 py-4 flex-shrink-0`,children:[s(`h2`,{className:`text-sm font-semibold text-foreground`,children:ue[f]}),s(`button`,{onClick:Y,disabled:de,className:`rounded-md p-1 text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-40 disabled:cursor-not-allowed`,children:s(g,{className:`h-4 w-4`})})]}),n(`div`,{className:`px-5 py-4 flex-1 overflow-y-auto overscroll-contain`,children:[$&&!X&&s(`div`,{className:`mb-3 rounded-lg border border-destructive/40 bg-destructive/10 px-3 py-2 text-xs text-destructive`,children:$ instanceof Error?$.message:String($)}),f===`picker`&&n(i,{children:[O&&s(`div`,{className:`mb-3 rounded-lg border border-destructive/40 bg-destructive/10 px-3 py-2 text-xs text-destructive`,children:O}),s(H,{onSelect:W,onClose:Y,pendingAddonId:Q})]}),f===`config`&&h&&s(R,{addonId:h,configSchema:re??null,canTest:ne,onSave:le,onBack:()=>m(`picker`)}),f===`broker`&&S&&s(z,{kind:S,onResolved:e=>{G(e)},onBack:()=>m(`picker`)}),f===`discovery`&&v&&s(ae,{providerId:v,onImport:K,onSkip:q})]}),X&&n(`div`,{className:`absolute inset-0 z-20 flex flex-col items-center justify-center gap-2 rounded-xl bg-background/85 backdrop-blur-sm px-6 text-center`,children:[s(p,{className:`h-6 w-6 animate-spin text-primary`}),s(`p`,{className:`text-xs font-medium text-foreground`,children:l(`integrations.creating`,{defaultValue:`Creating integration…`})}),!Z&&s(`p`,{className:`text-[10px] text-foreground-subtle`,children:l(`integrations.creatingHint`,{defaultValue:`Waiting for the addon to restart and register`})}),Z&&n(i,{children:[s(`p`,{className:`text-[10px] text-foreground-subtle max-w-xs`,children:l(`integrations.creatingOverdue`,{defaultValue:`This is taking longer than expected. The integration may already have been created — close this dialog and refresh to check.`})}),s(`button`,{onClick:Y,className:`mt-1 rounded-md border border-border bg-surface px-3 py-1.5 text-[11px] font-medium text-foreground hover:bg-surface-hover transition-colors`,children:l(`integrations.closeAndRefresh`,{defaultValue:`Close`})})]})]})]})]})}function W({integration:e,expanded:t,onToggleExpand:r}){return n(`div`,{className:`flex items-center gap-2.5`,children:[s(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),r(e.addonId)},"aria-label":t?`Collapse`:`Expand`,"aria-expanded":t,className:`flex h-5 w-5 flex-shrink-0 items-center justify-center rounded text-foreground-subtle transition-colors hover:bg-surface-hover hover:text-foreground`,children:s(t?b:f,{className:`h-3.5 w-3.5`})}),s(P,{type:e.addonId,size:`sm`}),n(`div`,{className:`flex min-w-0 flex-col`,children:[s(`span`,{className:`truncate text-xs font-semibold text-foreground`,children:e.name}),s(`span`,{className:`truncate text-[10px] text-foreground-subtle`,children:e.addonId})]})]})}function ce(e){let{isExpanded:t,onToggleExpand:n}=e;return[{key:`name`,header:`Integration`,headerClassName:`w-[55%]`,cell:e=>s(W,{integration:e,expanded:t(e),onToggleExpand:n})},{key:`devices`,header:`Devices`,headerClassName:`w-[15%]`,cellClassName:`text-[11px] text-foreground-subtle`,cell:e=>`${e.deviceCount} device${e.deviceCount===1?``:`s`}`},{key:`status`,header:`Status`,headerClassName:`w-[15%]`,cell:e=>s(S,{status:e.status})}]}t();function le(e){if(!e.enabled)return`disabled`;switch(e.processState){case`running`:return`running`;default:return`stopped`}}var G=`expand`;function K(){let{t}=N(),a=F(),c=v(),[f]=re(),[p,m]=o(!1),h=e(()=>m(!0),[]),g=e(()=>m(!1),[]),[_,y]=o(!1),b=e(()=>y(!0),[]),ee=e(()=>y(!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:S,isLoading:C,refetch:D}=te(void 0),{data:O,isLoading:A,refetch:j}=E({projection:`slim`}),P=r(()=>O??[],[O]),R=r(()=>S??[],[S]),z=r(()=>{let e=new Map;for(let t of P)e.set(t.id,{id:t.id,name:t.name??t.stableId??`#${String(t.id)}`});return e},[P]),B=r(()=>M(S),[S]),V=r(()=>{let e=new Map;for(let t of ne(P)){let n=B(t);if(n.kind!==`resolved`)continue;let r=n.integration.id;e.set(r,(e.get(r)??0)+1)}return e},[P,B]),ae=r(()=>R.map(e=>({id:e.id,addonId:e.addonId,name:e.name,enabled:e.enabled,status:le(e),deviceCount:V.get(e.id)??0})),[R,V]),H=f.get(G),U=e(e=>{let t=new URLSearchParams(window.location.search);t.get(G)===e?t.delete(G):t.set(G,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`))},[]),oe=e(e=>a(`/integrations/${e.id}`),[a]),W=e(e=>z.get(e)??null,[z]),K=e(e=>a(`/devices/${String(e)}`),[a]),q=e(e=>s(w,{context:`integration-detail`,devices:P,trpc:c.trpcClient,integrationOf:B,forceIntegrationId:e.id,urlScope:`nested`,lsKey:`integrations:nested:${e.addonId}`,resolveIntegrationIcon:L,resolveParent:W,onNavigate:K}),[P,c.trpcClient,B,W,K]),J=e(e=>H===e.addonId,[H]),Y=r(()=>ce({isExpanded:J,onToggleExpand:U}),[J,U]),X=e(e=>`${e.name} ${e.addonId}`,[]),Z=e(e=>e.addonId,[]),ue=e(()=>{D(),j()},[D,j]),Q=C||A,$=R.length>0;return n(I,{icon:l,title:t(`nav.integrations`,`Integrations`),actions:n(i,{children:[s(`button`,{onClick:ue,disabled:Q,className:`flex items-center gap-1 rounded-lg border border-border bg-surface px-2.5 py-1.5 text-xs font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50`,title:`Refresh`,children:s(x,{className:T(`h-3.5 w-3.5`,Q&&`animate-spin`)})}),n(`button`,{onClick:b,className:`flex items-center gap-1.5 rounded-lg border border-border bg-surface px-2.5 py-1.5 text-xs font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,title:`Scan the local network for devices`,children:[s(d,{className:`h-3.5 w-3.5`}),`Scan network`]}),n(`button`,{onClick:h,className:`flex items-center gap-1.5 rounded-lg bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground shadow-sm`,children:[s(u,{className:`h-3.5 w-3.5`}),`New Integration`]})]}),children:[Q&&s(`div`,{className:`space-y-2`,children:[1,2,3].map(e=>s(`div`,{className:`h-12 rounded-lg border border-border bg-surface animate-pulse`},e))}),!Q&&!$&&n(`div`,{className:`flex flex-col items-center py-20 text-foreground-subtle`,children:[s(`p`,{className:`text-sm`,children:`No integrations configured.`}),s(`p`,{className:`text-xs mt-1`,children:`Click "New Integration" to connect cameras and devices.`})]}),!Q&&$&&s(w,{mode:`generic`,items:ae,getKey:Z,getSearchText:X,columns:Y,onRowClick:oe,isExpanded:J,renderExpanded:q,searchPlaceholder:t(`integrations.search`,{defaultValue:`Search integrations…`}),emptyLabel:t(`integrations.empty`,{defaultValue:`No integrations found.`})}),s(se,{open:p,onClose:g}),s(ie,{open:_,onClose:ee})]})}export{K as IntegrationsPage};