@camstack/addon-admin-ui 1.2.642 → 1.2.644
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.
- package/CHANGELOG.md +20 -1
- package/dist/assets/Addons-ShOLWXd0.js +5 -0
- package/dist/assets/{AdminPage-BZvFoK-C.js → AdminPage-DBIlGQcg.js} +1 -1
- package/dist/assets/{AdminSectionedPage-BNsx61E4.js → AdminSectionedPage-BZZVpePX.js} +1 -1
- package/dist/assets/AiProfiles-0WnsACbl.js +3 -0
- package/dist/assets/{BootstrapSettingsForm-CkiwOoo0.js → BootstrapSettingsForm-B4JdtXuz.js} +1 -1
- package/dist/assets/Build-9NCzkPDG.js +39 -0
- package/dist/assets/{Calendars-DtHYKG5I.js → Calendars-C7qfbr7A.js} +1 -1
- package/dist/assets/{CameraGrids-Cx67r4Df.js → CameraGrids-mWpZKvQ5.js} +1 -1
- package/dist/assets/{Cluster-BlmFWuTu.js → Cluster-DZcoj2rP.js} +1 -1
- package/dist/assets/CompositionBlockEditor-C76eQ7Js.js +2 -0
- package/dist/assets/{CompositionEditorPage-DgQY61Sl.js → CompositionEditorPage-D2-woXyS.js} +1 -1
- package/dist/assets/Data-DKNCfvhH.js +2 -0
- package/dist/assets/DeviceDetail-DHep5JCp.js +2 -0
- package/dist/assets/{Devices-BrW5bSBu.js → Devices-CWvTKpnT.js} +1 -1
- package/dist/assets/EmbedDevicePage-CvbzEbvN.js +1 -0
- package/dist/assets/{EmbedPlayerPage-Dw6ZuDJq.js → EmbedPlayerPage-MuC48n-_.js} +1 -1
- package/dist/assets/{History-Bso_JvSZ.js → History-EJImyfJF.js} +1 -1
- package/dist/assets/Identity-Bp-Zr3O5.js +1 -0
- package/dist/assets/InstancesTable-CvfpkEKd.js +1 -0
- package/dist/assets/{IntegrationDetail-BzGmbnVv.js → IntegrationDetail-D8rUMymg.js} +1 -1
- package/dist/assets/{IntegrationWizard-ClEvGA8I.js → IntegrationWizard-CUcCjYQD.js} +1 -1
- package/dist/assets/{Integrations-j4mEGq7T.js → Integrations-2NtF5fL7.js} +2 -2
- package/dist/assets/Integrations-DsjUFK8h.js +1 -0
- package/dist/assets/Library-Dxr2Pajp.js +1 -0
- package/dist/assets/Locations-rnb6AjY3.js +3 -0
- package/dist/assets/{Logs-C7-7A0fI.js → Logs-CoJh-c0a.js} +1 -1
- package/dist/assets/{MaskShapeCanvas-dpTYLn-I.js → MaskShapeCanvas-j1uA0PkL.js} +1 -1
- package/dist/assets/{MotionZonesSettings-BeZ8c48s.js → MotionZonesSettings-0iA5mYRg.js} +1 -1
- package/dist/assets/{MyAccess-Bo1ZsFv7.js → MyAccess-DHgBU4Se.js} +1 -1
- package/dist/assets/Network-DzqpooQx.js +1 -0
- package/dist/assets/{NodeAddonsSettingsPanel-BWTKJlYh.js → NodeAddonsSettingsPanel-CieUBerm.js} +1 -1
- package/dist/assets/Notifications-DIrApxQt.js +1 -0
- package/dist/assets/Pipeline-CXIrhlea.js +1 -0
- package/dist/assets/{PrivacyMaskSettings-ufaM81lx.js → PrivacyMaskSettings-BLOdiPL9.js} +1 -1
- package/dist/assets/{Recordings-ChIuKrFQ.js → Recordings-D_GHaGDS.js} +1 -1
- package/dist/assets/{RemoteGrid-mhCQPrw4.js → RemoteGrid-DdvsdB_y.js} +1 -1
- package/dist/assets/{ScanSubnetEditor-ByUeuUPH.js → ScanSubnetEditor-BCfqLZIA.js} +1 -1
- package/dist/assets/{SceneMonitorEditor-_WrCw9Qm.js → SceneMonitorEditor-Cy11U5pJ.js} +1 -1
- package/dist/assets/{SessionsList-IXq42auR.js → SessionsList-CFVXs0eU.js} +2 -2
- package/dist/assets/{Showroom-JdOKuaQ4.js → Showroom-CDNZCmQ9.js} +1 -1
- package/dist/assets/{StorageLocationsTable-CM-mBdqU.js → StorageLocationsTable-C2jWCBaP.js} +1 -1
- package/dist/assets/{System-BHtMqcXN.js → System-CKbbRmxa.js} +1 -1
- package/dist/assets/{Templates-BH4pm3Du.js → Templates-BQW0A24V.js} +1 -1
- package/dist/assets/{Terminal-C_8sHhI0.js → Terminal-CflJDBLw.js} +3 -3
- package/dist/assets/{TrainingProviders-Czk4fPXW.js → TrainingProviders--io-U4Mx.js} +1 -1
- package/dist/assets/{Viewer-g8Ina8Au.js → Viewer-z_gjByXA.js} +1 -1
- package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-DP55Xu7L.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-CMJDSqwo.js} +1 -1
- package/dist/assets/{action-draft-B8uc37EO.js → action-draft-Dg61GkLS.js} +1 -1
- package/dist/assets/{ai-page.helpers-wT_pU6RH.js → ai-page.helpers-QIeUykiQ.js} +1 -1
- package/dist/assets/{assignment-candidates-CcPnvJbz.js → assignment-candidates-CwKJ2Z54.js} +1 -1
- package/dist/assets/{authed-media-C3W-vMO8.js → authed-media-BkzUgfxS.js} +1 -1
- package/dist/assets/{board-model-CTJyPV2E.js → board-model-K39WWIgs.js} +1 -1
- package/dist/assets/client-B60QT14E.js +951 -0
- package/dist/assets/create-composition-B7qf5-qP.js +2 -0
- package/dist/assets/{device-detail-DJnsgqNb.js → device-detail-CJ8-lleI.js} +1 -1
- package/dist/assets/{device-integration-icon-C_Binc-A.js → device-integration-icon-TWc3Gi9v.js} +1 -1
- package/dist/assets/device-picker-model-CsHVNi49.js +1 -0
- package/dist/assets/{dist-DZjvZVe0.js → dist-B8qwp9-f.js} +1 -1
- package/dist/assets/dist-DXms20e9.js +951 -0
- package/dist/assets/{format-Bg7MmBWg.js → format-hVW7RBVv.js} +1 -1
- package/dist/assets/{hostInit-CgEEuJPE.js → hostInit-CWx4j9gp.js} +1 -1
- package/dist/assets/{i18n-DkvVOm9n.js → i18n-CvWKDmFM.js} +1 -1
- package/dist/assets/icons-Di72eW9A.js +1 -0
- package/dist/assets/index-CxPpnulu.js +4 -0
- package/dist/assets/{linked-devices-model-BClISpye.js → linked-devices-model-h00bTRRT.js} +1 -1
- package/dist/assets/{mf-entry-bootstrap-0-5b022514.js → mf-entry-bootstrap-0-58e92d28.js} +2 -2
- package/dist/assets/mount-CsHVNi49.js +1 -0
- package/dist/assets/{notification-rule-status-BzjC2WhB.js → notification-rule-status-B-P-wl_0.js} +1 -1
- package/dist/assets/{player-overlays-BHFWIcWp.js → player-overlays-D-63t-DL.js} +1 -1
- package/dist/assets/remoteEntry-Bz4Zdkwj.js +1 -0
- package/dist/assets/src-g2TJby3U.js +230 -0
- package/dist/assets/{step-inspector-model-C-JrVwID.js → step-inspector-model-De5uJK-p.js} +1 -1
- package/dist/assets/{use-scenes-feed-Cr8kNEzV.js → use-scenes-feed-CpY0pBjC.js} +1 -1
- package/dist/assets/{use-stationary-objects-Befc4ui9.js → use-stationary-objects-BACQuMo9.js} +1 -1
- package/dist/assets/{useAdminDeviceRemoval-zLWwXi-O.js → useAdminDeviceRemoval-8_UQkuQg.js} +1 -1
- package/dist/assets/useEventInvalidation-CsHVNi49.js +1 -0
- package/dist/assets/{useNodeUrlSelection-C3gvoDWa.js → useNodeUrlSelection-gHQAfZml.js} +1 -1
- package/dist/assets/{useTemplateSave-B5WJqsrS.js → useTemplateSave-DxkUWI5Q.js} +1 -1
- package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-CqjtgsPE.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-hv9stH43.js} +2 -2
- package/dist/index.html +7 -7
- package/dist/server/addon.js +113 -4
- package/package.json +2 -2
- package/dist/assets/Addons-CWndl9XT.js +0 -5
- package/dist/assets/AiProfiles-CfmaO1o5.js +0 -3
- package/dist/assets/Build-DcfjQ5XX.js +0 -39
- package/dist/assets/CompositionBlockEditor-kfpX5tHd.js +0 -2
- package/dist/assets/Data-Dz-A8tUL.js +0 -2
- package/dist/assets/DeviceDetail-qgkGjG5-.js +0 -2
- package/dist/assets/EmbedDevicePage-BeF3FBg6.js +0 -1
- package/dist/assets/Identity-BGsRk3P5.js +0 -1
- package/dist/assets/InstancesTable-CebcSa4W.js +0 -1
- package/dist/assets/Integrations-CPsDqMeh.js +0 -1
- package/dist/assets/Library-DIEraCix.js +0 -1
- package/dist/assets/Locations-B3Hqll41.js +0 -3
- package/dist/assets/Network-BwvJ0Qbh.js +0 -1
- package/dist/assets/Notifications-Drs7V7HZ.js +0 -1
- package/dist/assets/Pipeline-C8Anqyk1.js +0 -1
- package/dist/assets/client-BsGn43se.js +0 -921
- package/dist/assets/create-composition-zb2jPO3-.js +0 -2
- package/dist/assets/device-picker-model-ChgpoWnb.js +0 -1
- package/dist/assets/dist-Zu7rz3zb.js +0 -921
- package/dist/assets/icons-pVM3dlwn.js +0 -1
- package/dist/assets/index-qwEfJCr_.js +0 -4
- package/dist/assets/mount-ChgpoWnb.js +0 -1
- package/dist/assets/remoteEntry-x4q7yukG.js +0 -1
- package/dist/assets/src-5RckhTPX.js +0 -230
- package/dist/assets/useEventInvalidation-ChgpoWnb.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{C as e,J as t,K as n,R as r,S as i,V as a,Y as o,et as s,o as c,x as l}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{Ca as u,Er as d,Gn as f,Hn as p,Kt as m,Ri as h,V as g,Wi as _,jn as v,kn as y,si as b,zi as x}from"./player-overlays-BHFWIcWp.js";import{$s as S}from"./client-BsGn43se.js";import{Br as C,Co as w,Fo as T,Gr as E,Gs as D,Hr as ee,Io as O,Js as te,Kr as ne,Lo as re,Pi as k,Po as ie,Vr as ae,Xs as A,af as j,ec as oe,is as se,na as M,qo as ce,qs as le,ua as N}from"./src-5RckhTPX.js";import{t as P}from"./useTranslation-BJr-n0es.js";import{J as ue,W as F,Xr as de,dt as I,lt as L,ut as fe,y as pe}from"./index-qwEfJCr_.js";import{a as me,n as he,o as R,r as ge,s as _e,t as ve}from"./ScanSubnetEditor-ByUeuUPH.js";import{t as ye}from"./framework-packages-B0ugw-Ay.js";s();function be(e){return e.integrationSection===void 0?ye(e.packageName)?`system`:`providers`:e.integrationSection}function z(e){let t=new Set;for(let n of e??[])be(n.manifest)===`system`&&t.add(n.manifest.id);return t}function B(e,t){return{providers:e.filter(e=>!t.has(e.addonId)),system:e.filter(e=>t.has(e.addonId))}}function V(e,t){return[...e].sort((e,n)=>e.name.localeCompare(n.name,t,{sensitivity:`base`}))}function H({kind:t,children:n}){let{t:r}=P(),a=`integrations-section-${t}`;return e(`section`,{"aria-labelledby":a,"data-testid":a,className:`min-w-0 space-y-2`,children:[i(`h2`,{id:a,className:g,children:t===`providers`?r(`integrations.sections.providers`,`Providers`):r(`integrations.sections.system`,`System`)}),n]})}function U({children:e}){return i(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-2 sm:gap-3 lg:grid-cols-3`,children:e})}function W({addonId:t,name:n,openLabel:r,onOpen:a,body:o,footer:s,disabled:c=!1,testId:l,buttonTestId:u}){return e(`article`,{"data-testid":l,className:`relative flex min-w-0 items-stretch gap-3 overflow-x-clip rounded-lg border border-border bg-surface p-3`,children:[i(k,{type:`button`,variant:`ghost`,"aria-label":r,disabled:c,"data-testid":u,onClick:a,className:`absolute inset-0 z-0 h-auto w-auto rounded-lg p-0 focus-visible:ring-2 focus-visible:ring-primary`}),i(`div`,{className:`pointer-events-none relative z-10 flex w-20 shrink-0 items-center justify-center`,children:i(F,{type:t,size:`xl`})}),e(`div`,{className:`pointer-events-none relative z-10 grid min-w-0 flex-1 grid-rows-[1fr_auto_1fr] gap-1`,children:[i(`p`,{className:`min-w-0 self-start truncate text-sm font-semibold text-foreground`,children:n}),o,i(`div`,{className:`self-end justify-self-start`,children:s})]})]})}function xe(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 Se(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 Ce({kind:t,onResolved:n,onBack:r}){let{t:a}=P(),[s,c]=o(null);return e(`div`,{className:`space-y-4`,children:[e(k,{variant:`ghost`,size:`sm`,onClick:r,children:[i(h,{className:`h-3.5 w-3.5`}),` `,a(`common.back`)]}),i(ue,{kind:t,value:s,onChange:c}),i(`div`,{className:`flex justify-end pt-1`,children:i(k,{variant:`primary`,size:`sm`,disabled:s===null,onClick:()=>s!==null&&n(s),children:a(`integrations.brokerStep.useThisBroker`,`Use this broker`)})})]})}s();function we({providerId:t,onImport:n,onSkip:r}){let{t:s}=P(),[c,l]=o(new Set),u=T(),d=u.data,f=u.isPending||!u.data&&!u.isError;a(()=>{t&&(u.isPending||u.data||u.mutate({addonId:t}))},[t,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 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 m=d??[];return e(`div`,{className:`space-y-4`,children:[i(`p`,{className:`text-xs text-foreground-subtle`,children:m.length>0?s(`integrations.foundDevices`,{count:m.length}):s(`integrations.noDevicesFound`)}),m.length>0&&i(`div`,{className:`space-y-1.5 max-h-64 overflow-y-auto`,children:m.map(t=>{let n=t.stableId,r=t.suggestedName??n,a=c.has(n),o=t.alreadyOnboarded===!0;return e(k,{variant:`unstyled`,onClick:()=>{o||p(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(x,{className:`h-3 w-3 text-primary-foreground`})}),i(_,{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(k,{variant:`unstyled`,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`)}),m.length>0&&e(k,{variant:`unstyled`,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,`)`]})]})]})}s();function Te({addonId:t,configSchema:n,canTest:r=!0,instanceKind:a,initialName:s,initialConfig:c,submitLabel:l,hideName:u=!1,saving:d=!1,onScan:p,onSave:m,onBack:h}){let{t:g}=P(),[_,v]=o(s??``),[y,b]=o(c??{}),[x,C]=o(null),w=A({onSuccess:e=>C(fe(e)),onError:e=>C({status:`inconclusive`,error:String(e)})}),T=M(),E=!r||x?.status===`validated`,D=!u&&_.trim().length===0,ee=!D&&E;return e(`div`,{className:`space-y-4`,children:[!u&&e(`div`,{children:[i(`label`,{htmlFor:`integration-name`,className:`block text-[11px] font-medium text-foreground mb-1`,children:g(`integrations.integrationName`)}),i(j,{id:`integration-name`,type:`text`,value:_,onChange:e=>v(e.target.value),placeholder:g(`integrations.integrationNamePlaceholder`),"aria-invalid":D,"aria-describedby":D?`integration-name-error`:void 0,className:`w-full rounded-lg border bg-surface px-3 py-2 text-xs text-foreground placeholder:text-foreground-subtle focus:outline-none ${D?`border-danger focus:border-danger`:`border-border focus:border-primary/50`}`}),D&&i(`p`,{id:`integration-name-error`,"data-testid":`integration-name-error`,className:`mt-1 text-xs text-danger`,children:g(`integrations.nameRequired`,`Name is required`)})]}),n&&i(I,{schema:n,values:y,onChange:e=>{b(e),C(null)},onAction:async(e,i,o)=>{let s=await T.mutateAsync({addonId:t,action:e,input:o??{}});if(r&&typeof s==`object`&&s){let e=s;if(!(typeof e.token==`string`||typeof e.sslCertificate==`string`||typeof e.host==`string`))return s;let r={...y};for(let[t,n]of Object.entries(e))typeof n==`string`&&t!==`summary`&&(r[t]=n);let i=S(n,r);b(i),C(null),w.mutate({addonId:t,id:null,values:i,...a===void 0?{}:{kind:a}})}return s}}),x&&i(L,{verdict:x}),e(`div`,{className:`flex items-center justify-between pt-2`,children:[i(k,{variant:`unstyled`,onClick:h,className:`rounded-lg border border-border px-3 py-1.5 text-xs text-foreground-subtle hover:text-foreground transition-colors`,children:g(`integrations.back`)}),e(`div`,{className:`flex items-center gap-2`,children:[p&&e(k,{variant:`outline`,size:`sm`,onClick:p,"data-testid":`integration-scan`,children:[i(f,{className:`h-3.5 w-3.5`}),g(`integrations.scanFromForm`,`Scan the network`)]}),i(k,{variant:`unstyled`,onClick:()=>w.mutate({addonId:t,id:null,values:S(n,y),...a===void 0?{}:{kind:a}}),disabled:w.isPending||!r,title:r?void 0:g(`integrations.connectionUntestable`,{defaultValue:`This integration cannot be tested before it is created.`}),className:`rounded-lg border border-border px-3 py-1.5 text-xs text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50 disabled:cursor-not-allowed`,children:w.isPending?g(`integrations.testing`):g(`integrations.testConnection`)}),e(`div`,{className:`flex flex-col items-end gap-1`,children:[D&&i(`p`,{"data-testid":`integration-name-submit-error`,className:`text-xs text-danger`,children:g(`integrations.nameRequiredSubmit`,`Enter a name before continuing.`)}),i(k,{variant:`unstyled`,onClick:()=>{D||m({name:_,config:S(n,y)})},disabled:!ee||d,className:`rounded-lg bg-primary px-4 py-1.5 text-xs font-medium text-primary-foreground shadow-sm disabled:opacity-50`,children:d?g(`integrations.saving`,{defaultValue:`Saving…`}):l??g(`integrations.forward`)})]})]})]})]})}var Ee=`(hover: none) and (pointer: coarse)`;function G(){if(typeof window>`u`||typeof window.matchMedia!=`function`)return!0;try{return!window.matchMedia(Ee).matches}catch{return!0}}s();function De(e,t){return`${e.name} ${e.description} ${e.addonId}`.toLowerCase().includes(t)}function Oe({onSelect:r,onClose:s,pendingAddonId:c=null,source:l}){let{t:u,i18n:f}=P(),p=de(),[m,h]=o(``),g=t(null),_=oe(void 0,{enabled:l===void 0}),b=l===void 0?_.data:void 0,x=l===void 0&&_.isLoading;a(()=>{x||!G()||g.current?.focus()},[x]);let{data:S}=N(void 0),C=c!==null,w=n(()=>l===void 0?(b??[]).map(t=>{let n=t.instanceMode===`unique`&&t.existingInstances.length>0;return{addonId:t.addonId,name:t.name,description:t.description??``,open:()=>{let e=t.existingInstances[0];n&&e!==void 0?(s(),p(pe(t.addonId,e.id))):r(t.addonId,t.instanceMode,t.discoveryMode,t.name,t.kind,t.brokerKind,t.mode,t.canTest)},footer:n?e(`span`,{className:`flex items-center gap-1 text-xs font-medium text-foreground-subtle`,children:[i(y,{className:`h-3 w-3`}),u(`integrations.manage`)]}):null}}):l.providers.map(e=>({...e,open:()=>l.onPick(e.addonId),footer:null})),[l,b,s,r,p,u]),T=n(()=>{let e=m.trim().toLowerCase();return e.length===0?w:w.filter(t=>De(t,e))},[w,m]),E=n(()=>{let e=B(T,z(S));return{providers:V(e.providers,f.language),system:V(e.system,f.language)}},[T,S,f.language]);if(x)return i(`div`,{className:`grid grid-cols-1 gap-2 p-2 sm:grid-cols-2 lg:grid-cols-3`,children:[1,2,3,4].map(e=>i(`div`,{className:`h-24 rounded-lg bg-surface animate-pulse`},e))});let D=e=>i(U,{children:e.map(e=>i(W,{testId:`provider-card-${e.addonId}`,buttonTestId:`provider-pick-${e.addonId}`,addonId:e.addonId,name:e.name,openLabel:e.name,disabled:C,onOpen:e.open,body:e.description.length>0?i(`p`,{className:`line-clamp-2 text-xs text-foreground-muted`,children:e.description}):i(`span`,{}),footer:c===e.addonId?i(d,{className:`h-4 w-4 animate-spin text-primary`}):e.footer},e.addonId))});return e(`div`,{className:`space-y-3`,"data-testid":`provider-picker`,children:[e(`div`,{className:`relative`,children:[i(v,{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(j,{ref:g,type:`search`,value:m,onChange:e=>h(e.target.value),placeholder:u(`integrations.searchProviders`,`Search integrations…`),className:`pl-8`,"data-testid":`provider-picker-search`,"aria-label":u(`integrations.searchProviders`,`Search integrations…`)})]}),E.providers.length>0&&i(H,{kind:`providers`,children:D(E.providers)}),E.system.length>0&&i(H,{kind:`system`,children:D(E.system)}),T.length===0&&i(`div`,{className:`py-8 text-center text-xs text-foreground-subtle`,children:w.length===0?u(`integrations.noProviders`):u(`integrations.noProvidersMatch`,`No integrations match your search.`)})]})}s();function ke({open:t,onClose:a,scope:s,onSetupIntegration:c,pickMode:l=`adopt`}){let{t:u}=P(),d=w(),[p,m]=o(new Set),[h,g]=o(new Set),[_,v]=o(new Set),{data:y}=ce({projection:`slim`}),b=n(()=>new Set((y??[]).map(e=>e.stableId)),[y]),x=r(async(e,t)=>{g(e=>new Set(e).add(t.stableId));try{await d.mutateAsync({addonId:e,candidate:t}),m(e=>new Set(e).add(t.stableId)),v(e=>{let n=new Set(e);return n.delete(t.stableId),n})}catch{}finally{g(e=>{let n=new Set(e);return n.delete(t.stableId),n})}},[d]),S=r(async(e,t)=>{let n=l===`fill`?me(e,t):he(e,t);if(n!==null){c?.(n),a();return}await x(e,t)},[x,a,c,l]),T=r(e=>{v(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),D=r(()=>{m(new Set),v(new Set)},[]),O=n(()=>({existingStableIds:b,adopted:p,adopting:h,selection:{selected:_,toggle:T},pick:S,adoptOne:x,fill:l===`fill`}),[b,p,h,_,T,S,l]),te=s?u(`integrations.scanNetworkModal.titleScoped`,`Scan network — {{label}}`,{label:s.label}):u(`integrations.scanNetworkModal.title`,`Scan network for devices`);return i(C,{open:t,onOpenChange:e=>!e&&a(),children:e(ee,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,children:[i(E,{children:i(ne,{children:e(`span`,{className:`flex items-center gap-2`,children:[i(f,{className:`h-4 w-4 text-primary`}),te]})})}),e(ae,{className:`space-y-4`,children:[i(ve,{}),s?i(Pe,{scope:s,row:O,onReset:D}):i(Ne,{row:O,onReset:D})]})]})})}function K(e,t){return!t&&e.selectable!==!1&&!ge(e)}function q({addonId:t,nodes:n,row:r,depth:a}){return i(`div`,{className:a===0?`space-y-1.5`:`ml-4 space-y-1.5 border-l border-border pl-3`,"data-testid":a===0?void 0:`scan-children`,children:n.map(n=>e(`div`,{className:`space-y-1.5`,children:[i(Ae,{addonId:t,candidate:n.candidate,row:r}),n.children.length>0&&i(q,{addonId:t,nodes:n.children,row:r,depth:a+1})]},n.candidate.stableId))})}function Ae({addonId:t,candidate:n,row:r}){let{t:a}=P(),o=n.prefilledConfig.host,s=typeof o==`string`?o:null,c=r.existingStableIds.has(n.stableId)||n.alreadyOnboarded===!0||n.onboardedDeviceId!==void 0,l=r.adopted.has(n.stableId)||c,f=r.adopting.has(n.stableId),p=r.fill||ge(n),m=!l&&(p||n.selectable!==!1),h=m&&K(n,r.fill);return e(`div`,{className:`flex items-center gap-3 rounded-lg border border-border bg-surface px-3 py-2`,"data-testid":`scan-row-${n.stableId}`,children:[h&&i(u,{checked:r.selection.selected.has(n.stableId),onChange:()=>r.selection.toggle(n.stableId),disabled:f,"aria-label":a(`integrations.scanNetworkModal.select`,`Select {{name}}`,{name:n.suggestedName})}),e(`div`,{className:`min-w-0 flex-1`,children:[i(`p`,{className:`truncate text-xs font-medium text-foreground`,children:n.suggestedName}),s&&i(`p`,{className:`truncate font-mono text-[10px] text-foreground-subtle`,children:s}),c&&n.onboardedName!==void 0&&i(`p`,{className:`truncate text-[10px] text-foreground-subtle`,children:n.onboardedName})]}),l?e(`span`,{className:`flex items-center gap-1 text-[11px] text-foreground-subtle`,children:[i(x,{className:`h-3.5 w-3.5`}),` `,c?a(`integrations.scanNetworkModal.alreadyAdded`,`Already added`):a(`integrations.scanNetworkModal.added`,`Added`)]}):m?e(k,{size:`sm`,variant:p?`outline`:`primary`,onClick:()=>void r.pick(t,n),disabled:f,children:[f?i(d,{className:`h-3.5 w-3.5 animate-spin`}):p?null:i(b,{className:`h-3.5 w-3.5`}),p?r.fill?a(`integrations.scanNetworkModal.use`,`Use`):a(`integrations.scanNetworkModal.setUp`,`Set up`):a(`common.add`,`Add`)]}):null]})}function je({addonId:t,label:r,candidates:a,row:o}){let s=n(()=>R(a),[a]);return e(`section`,{className:`space-y-2`,"data-testid":`scan-group-${t}`,children:[e(`h3`,{className:`flex items-center gap-2`,children:[i(F,{type:t,size:`sm`}),i(`span`,{className:g,children:r}),e(`span`,{className:`text-[10px] text-foreground-subtle`,children:[`(`,a.length,`)`]})]}),i(q,{addonId:t,nodes:s,row:o,depth:0})]})}function Me(e,t){return e.flatMap(e=>_e(R(e.candidates)).filter(e=>K(e,t)).map(t=>({addonId:e.addonId,candidate:t})))}function Ne({row:t,onReset:o}){let{t:s}=P(),c=ie(),l=r(()=>{o(),c.mutate({})},[c,o]);a(()=>{!c.isPending&&!c.data&&l()},[]);let u=n(()=>(c.data?.groups??[]).filter(e=>e.candidates.length>0),[c.data]),d=n(()=>u.reduce((e,t)=>e+t.candidates.length,0),[u]),f=n(()=>Me(u,t.fill),[u,t.fill]);return e(`div`,{className:`space-y-4`,children:[e(`div`,{className:`flex items-center justify-between gap-2`,children:[i(`p`,{className:`text-xs text-foreground-subtle`,children:!c.isPending&&u.length>0?s(`integrations.scanNetworkModal.found`,{count:d}):null}),e(`div`,{className:`flex items-center gap-2`,children:[i(Fe,{entries:f,row:t}),e(k,{variant:`outline`,size:`sm`,onClick:l,disabled:c.isPending,children:[i(p,{className:`h-3.5 w-3.5 ${c.isPending?`animate-spin`:``}`}),s(`integrations.scanNetworkModal.reScan`,`Re-scan`)]})]})]}),c.isPending&&i(Y,{label:s(`integrations.scanNetworkModal.scanningTheLocalNetwork`,`Scanning the local network…`)}),!c.isPending&&c.isError&&i(X,{}),!c.isPending&&c.data&&u.length===0&&i(J,{}),!c.isPending&&u.map(e=>i(je,{addonId:e.addonId,label:e.label,candidates:e.candidates,row:t},e.addonId))]})}function Pe({scope:t,row:a,onReset:s}){let{t:c}=P(),l=se({addonId:t.addonId}).data??null,[u,p]=o({}),m=O(),h=r(()=>{s(),m.mutate({addonId:t.addonId,params:u})},[m,t.addonId,u,s]),g=n(()=>m.data?.candidates??[],[m.data]),_=n(()=>Me([{addonId:t.addonId,candidates:g}],a.fill),[t.addonId,g,a.fill]);return e(`div`,{className:`space-y-4`,children:[l&&i(I,{schema:l,values:u,onChange:p}),e(k,{onClick:h,disabled:m.isPending,children:[m.isPending?i(d,{className:`h-3.5 w-3.5 animate-spin`}):i(f,{className:`h-3.5 w-3.5`}),m.isPending?c(`integrations.scanNetworkModal.scanning`,`Scanning…`):c(`integrations.scanNetworkModal.scan`,`Scan`)]}),i(Fe,{entries:_,row:a}),m.isError&&i(X,{}),!m.isPending&&m.data&&g.length===0&&i(J,{}),!m.isPending&&g.length>0&&e(`div`,{className:`space-y-2`,children:[i(`p`,{className:`text-xs text-foreground-subtle`,children:c(`integrations.scanNetworkModal.foundShort`,{count:g.length})}),i(je,{addonId:t.addonId,label:t.label,candidates:g,row:a})]})]})}function Fe({entries:t,row:n}){let{t:r}=P(),a=t.filter(e=>n.selection.selected.has(e.candidate.stableId));if(a.length===0)return null;let o=async()=>{for(let e of a)await n.adoptOne(e.addonId,e.candidate)};return e(k,{size:`sm`,onClick:()=>void o(),"data-testid":`scan-add-selected`,children:[i(b,{className:`h-3.5 w-3.5`}),r(`integrations.scanNetworkModal.addSelected`,`Add selected ({{count}})`,{count:a.length})]})}function J(){let{t:e}=P();return i(`p`,{className:`py-6 text-center text-xs text-foreground-subtle`,children:e(`integrations.scanNetworkModal.noDevicesRespondedToThe`,`No devices responded to the scan.`)})}function Y({label:t}){return e(`div`,{className:`flex flex-col items-center py-12`,children:[i(d,{className:`h-6 w-6 animate-spin text-primary`}),i(`p`,{className:`mt-3 text-xs text-foreground-subtle`,children:t})]})}function X(){let{t}=P();return e(`div`,{className:`flex items-start gap-3 rounded-lg border border-danger/40 bg-danger/10 px-4 py-3`,children:[i(m,{className:`mt-0.5 h-4 w-4 shrink-0 text-danger`}),i(`p`,{className:`text-xs text-danger`,children:t(`integrations.scanNetworkModal.theScanFailedTryAgain`,`The scan failed. Try again.`)})]})}s();function Ie(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 Le=2e4;function Z({open:t,onClose:r,seed:s=null,pickFrom:u}){let{t:f}=P(),p=de(),m=c(),[h,g]=o(`picker`),[_,v]=o(null),[y,b]=o(null),[x,S]=o(`manual`),[O,ie]=o(null),[A,j]=o(``),[se,M]=o(null),[ce,N]=o(null),[ue,F]=o(!1),[I,L]=o({}),[fe,me]=o(``),[he,R]=o(!1),[ge,_e]=o(0),[ve,ye]=o(``),be=re({},{enabled:t&&h===`config`}),z=(le({addonId:_??``},{enabled:t&&h===`config`&&_!==null}).data?.kinds??[]).filter(e=>e.canTest!==!1),B=z.length===1?z[0]?.id:void 0,V=_!==null&&(be.data?.providers??[]).some(e=>e.addonId===_),H=s?.config.host,U=s===null?``:`${s.addonId}\0${s.name}\0${typeof H==`string`?H:``}`;t&&s!==null&&fe!==U&&(me(U),v(s.addonId),j(s.name),L({...s.config}),g(`config`));let W=oe(void 0,{enabled:t&&s!==null}),Ee=W.data?.find(e=>e.addonId===_)?.mode??`account`,{data:G}=te({addonId:_??``,id:null,mode:Ee,...s?.originStableId===void 0?{}:{candidateStableId:s.originStableId}},{enabled:_!=null}),De=n(()=>G?Ie(G):null,[G]),K=D({onSuccess:()=>{m.invalidateQueries({queryKey:[[`integrations`]]}),m.invalidateQueries({queryKey:[[`integrationInstances`]]})}}),q=T(),Ae=q.data;a(()=>{if(!t||s===null)return;let e=W.data?.find(e=>e.addonId===s.addonId);e&&(F(e.canTest),S(e.discoveryMode))},[t,s,W.data]),a(()=>{h!==`discovery`||!y||!_||q.isPending||q.data||q.mutate({addonId:_})},[h,y,_,q]);let je=w({onSuccess:()=>m.invalidateQueries({queryKey:[[`deviceManager`]]})});function Me(e,t,n,r,i,a,o,s){if(!K.isPending){if(v(e),F(s),S(n),j(r),N(null),K.reset(),o===`broker`){if(!a){N(`Addon '${e}' declares mode 'broker' but no brokerKind in its manifest`);return}ie(a),g(`broker`);return}if(o===`account`){g(`config`);return}Ne(e,r)}}async function Ne(e,t){try{let n=await K.mutateAsync({addonId:e,name:t,values:{}});r(),X(),p(`${pe(e,n.id)}&add=1`)}catch{}}async function Pe(e){if(_)try{let t=await K.mutateAsync({addonId:_,name:e.name,values:e.config,...B===void 0?{}:{kind:B},...s!==null&&s.addonId===_&&s.originStableId!==void 0?{originStableId:s.originStableId}:{}});b(t.id),M(t.id),x===`auto`||x===`both`?g(`discovery`):Y(t.id,{openAdd:!0})}catch{}}async function Fe(e){if(_)try{let t=await K.mutateAsync({addonId:_,name:A,values:{brokerId:e}});M(t.id),b(t.id),Y(t.id)}catch{}}async function J(e){if(_){for(let t of e){let e=Ae?.find(e=>e.stableId===t);e&&await je.mutateAsync({addonId:_,candidate:e,...se===null?{}:{integrationId:se}})}Y()}}function Y(e,t){let n=e??y??_;if(r(),X(),n&&_){let e=pe(_,n);p(t?.openAdd===!0?`${e}&add=1`:e)}}function X(){g(`picker`),v(null),b(null),S(`manual`),ie(null),j(``),M(null),N(null),K.reset(),F(!1),L({}),me(``)}function Z(){r(),X()}xe(t);let Q=K.isPending,Re=Se(Q,Le);if(!t)return null;let ze={picker:u?.title??f(`integrations.newIntegration`),config:f(`integrations.configureIntegration`),discovery:f(`integrations.importDevices`),broker:f(`integrations.connectBroker`,{defaultValue:`Connect a broker`})},Be=Q?_:null,$=K.error,Ve=Q&&!Re;return e(l,{children:[i(C,{open:!0,onOpenChange:e=>{!e&&!Ve&&Z()},children:e(ee,{width:h===`picker`?`xl`:`lg`,scroll:`body`,onCancel:e=>{Ve&&e.preventDefault()},children:[i(E,{children:i(ne,{children:ze[h]})}),e(ae,{children:[$&&!Q&&i(`div`,{className:`mb-3 rounded-lg border border-danger/40 bg-danger/10 px-3 py-2 text-xs text-danger`,children:$ instanceof Error?$.message:String($)}),h===`picker`&&e(l,{children:[ce&&i(`div`,{className:`mb-3 rounded-lg border border-danger/40 bg-danger/10 px-3 py-2 text-xs text-danger`,children:ce}),i(Oe,{onSelect:Me,onClose:Z,pendingAddonId:Be,...u===void 0?{}:{source:u}})]}),h===`config`&&_&&i(Te,{addonId:_,configSchema:De??null,canTest:ue,...B===void 0?{}:{instanceKind:B},initialName:A.length>0&&Object.keys(I).length>0?A:void 0,initialConfig:{...I},onScan:V?()=>{ye(A.length>0?A:_),R(!0)}:void 0,onSave:Pe,onBack:()=>{L({}),g(`picker`)}},`${U.length>0?U:_}:${ge}`),h===`broker`&&O&&i(Ce,{kind:O,onResolved:e=>{Fe(e)},onBack:()=>g(`picker`)}),h===`discovery`&&y&&i(we,{providerId:y,onImport:J,onSkip:Y})]}),Q&&e(`div`,{className:`absolute inset-0 z-20 flex flex-col items-center justify-center gap-2 rounded-lg bg-background/85 backdrop-blur-sm px-6 text-center`,children:[i(d,{className:`h-6 w-6 animate-spin text-primary`}),i(`p`,{className:`text-xs font-medium text-foreground`,children:f(`integrations.creating`,{defaultValue:`Creating integration…`})}),!Re&&i(`p`,{className:`text-[10px] text-foreground-subtle`,children:f(`integrations.creatingHint`,{defaultValue:`Waiting for the addon to restart and register`})}),Re&&e(l,{children:[i(`p`,{className:`text-[10px] text-foreground-subtle max-w-xs`,children:f(`integrations.creatingOverdue`,{defaultValue:`This is taking longer than expected. The integration may already have been created — close this dialog and refresh to check.`})}),i(k,{variant:`unstyled`,onClick:Z,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:f(`integrations.closeAndRefresh`,{defaultValue:`Close`})})]})]})]})}),he&&_!==null&&i(ke,{open:he,scope:{addonId:_,label:ve},pickMode:`fill`,onClose:()=>R(!1),onSetupIntegration:e=>{j(e.name),L({...e.config}),_e(e=>e+1)}})]})}export{H as a,z as c,U as i,ke as n,V as o,W as r,B as s,Z as t};
|
|
1
|
+
import{C as e,J as t,K as n,R as r,S as i,V as a,Y as o,et as s,o as c,x as l}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{An as u,Bi as d,Dr as f,Gi as p,Kn as m,Kt as h,Mn as g,Un as _,V as v,ci as y,wa as b,zi as x}from"./player-overlays-D-63t-DL.js";import{tc as S}from"./client-B60QT14E.js";import{Br as C,Co as w,Fo as T,Gr as E,Gs as D,Hr as ee,Io as O,Js as te,Kr as ne,Lo as re,Pi as k,Po as ie,Vr as ae,Xs as A,af as j,ec as oe,is as se,na as M,qo as ce,qs as le,ua as N}from"./src-g2TJby3U.js";import{t as P}from"./useTranslation-BJr-n0es.js";import{J as ue,W as F,Xr as de,dt as I,lt as L,ut as fe,y as pe}from"./index-CxPpnulu.js";import{a as me,n as he,o as R,r as ge,s as _e,t as ve}from"./ScanSubnetEditor-BCfqLZIA.js";import{t as ye}from"./framework-packages-B0ugw-Ay.js";s();function be(e){return e.integrationSection===void 0?ye(e.packageName)?`system`:`providers`:e.integrationSection}function z(e){let t=new Set;for(let n of e??[])be(n.manifest)===`system`&&t.add(n.manifest.id);return t}function B(e,t){return{providers:e.filter(e=>!t.has(e.addonId)),system:e.filter(e=>t.has(e.addonId))}}function V(e,t){return[...e].sort((e,n)=>e.name.localeCompare(n.name,t,{sensitivity:`base`}))}function H({kind:t,children:n}){let{t:r}=P(),a=`integrations-section-${t}`;return e(`section`,{"aria-labelledby":a,"data-testid":a,className:`min-w-0 space-y-2`,children:[i(`h2`,{id:a,className:v,children:t===`providers`?r(`integrations.sections.providers`,`Providers`):r(`integrations.sections.system`,`System`)}),n]})}function U({children:e}){return i(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-2 sm:gap-3 lg:grid-cols-3`,children:e})}function W({addonId:t,name:n,openLabel:r,onOpen:a,body:o,footer:s,disabled:c=!1,testId:l,buttonTestId:u}){return e(`article`,{"data-testid":l,className:`relative flex min-w-0 items-stretch gap-3 overflow-x-clip rounded-lg border border-border bg-surface p-3`,children:[i(k,{type:`button`,variant:`ghost`,"aria-label":r,disabled:c,"data-testid":u,onClick:a,className:`absolute inset-0 z-0 h-auto w-auto rounded-lg p-0 focus-visible:ring-2 focus-visible:ring-primary`}),i(`div`,{className:`pointer-events-none relative z-10 flex w-20 shrink-0 items-center justify-center`,children:i(F,{type:t,size:`xl`})}),e(`div`,{className:`pointer-events-none relative z-10 grid min-w-0 flex-1 grid-rows-[1fr_auto_1fr] gap-1`,children:[i(`p`,{className:`min-w-0 self-start truncate text-sm font-semibold text-foreground`,children:n}),o,i(`div`,{className:`self-end justify-self-start`,children:s})]})]})}function xe(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 Se(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 Ce({kind:t,onResolved:n,onBack:r}){let{t:a}=P(),[s,c]=o(null);return e(`div`,{className:`space-y-4`,children:[e(k,{variant:`ghost`,size:`sm`,onClick:r,children:[i(x,{className:`h-3.5 w-3.5`}),` `,a(`common.back`)]}),i(ue,{kind:t,value:s,onChange:c}),i(`div`,{className:`flex justify-end pt-1`,children:i(k,{variant:`primary`,size:`sm`,disabled:s===null,onClick:()=>s!==null&&n(s),children:a(`integrations.brokerStep.useThisBroker`,`Use this broker`)})})]})}s();function we({providerId:t,onImport:n,onSkip:r}){let{t:s}=P(),[c,l]=o(new Set),u=T(),f=u.data,m=u.isPending||!u.data&&!u.isError;a(()=>{t&&(u.isPending||u.data||u.mutate({addonId:t}))},[t,u]);function h(e){l(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}if(m)return e(`div`,{className:`flex flex-col items-center py-12`,children:[i(`div`,{className:`h-6 w-6 animate-spin rounded-full border-2 border-primary border-t-transparent`}),i(`p`,{className:`mt-3 text-xs text-foreground-subtle`,children:s(`integrations.searchingDevices`)})]});let g=f??[];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(k,{variant:`unstyled`,onClick:()=>{o||h(n)},disabled:o,title:o?s(`integrations.alreadyAddedHint`,{defaultValue:`Already added as "{{name}}" — re-adding would overwrite its settings.`,name:t.onboardedName??r}):void 0,className:`flex w-full items-center gap-3 rounded-lg border p-3 text-left transition-colors ${o?`border-border bg-surface opacity-60 cursor-not-allowed`:a?`border-primary/40 bg-primary/5`:`border-border bg-surface hover:border-foreground-subtle/30`}`,children:[i(`div`,{className:`flex h-5 w-5 items-center justify-center rounded border flex-shrink-0 ${a&&!o?`border-primary bg-primary`:`border-border`}`,children:a&&!o&&i(d,{className:`h-3 w-3 text-primary-foreground`})}),i(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(k,{variant:`unstyled`,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(k,{variant:`unstyled`,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,`)`]})]})]})}s();function Te({addonId:t,configSchema:n,canTest:r=!0,instanceKind:a,initialName:s,initialConfig:c,submitLabel:l,hideName:u=!1,saving:d=!1,onScan:f,onSave:p,onBack:h}){let{t:g}=P(),[_,v]=o(s??``),[y,b]=o(c??{}),[x,C]=o(null),w=A({onSuccess:e=>C(fe(e)),onError:e=>C({status:`inconclusive`,error:String(e)})}),T=M(),E=!r||x?.status===`validated`,D=!u&&_.trim().length===0,ee=!D&&E;return e(`div`,{className:`space-y-4`,children:[!u&&e(`div`,{children:[i(`label`,{htmlFor:`integration-name`,className:`block text-[11px] font-medium text-foreground mb-1`,children:g(`integrations.integrationName`)}),i(j,{id:`integration-name`,type:`text`,value:_,onChange:e=>v(e.target.value),placeholder:g(`integrations.integrationNamePlaceholder`),"aria-invalid":D,"aria-describedby":D?`integration-name-error`:void 0,className:`w-full rounded-lg border bg-surface px-3 py-2 text-xs text-foreground placeholder:text-foreground-subtle focus:outline-none ${D?`border-danger focus:border-danger`:`border-border focus:border-primary/50`}`}),D&&i(`p`,{id:`integration-name-error`,"data-testid":`integration-name-error`,className:`mt-1 text-xs text-danger`,children:g(`integrations.nameRequired`,`Name is required`)})]}),n&&i(I,{schema:n,values:y,onChange:e=>{b(e),C(null)},onAction:async(e,i,o)=>{let s=await T.mutateAsync({addonId:t,action:e,input:o??{}});if(r&&typeof s==`object`&&s){let e=s;if(!(typeof e.token==`string`||typeof e.sslCertificate==`string`||typeof e.host==`string`))return s;let r={...y};for(let[t,n]of Object.entries(e))typeof n==`string`&&t!==`summary`&&(r[t]=n);let i=S(n,r);b(i),C(null),w.mutate({addonId:t,id:null,values:i,...a===void 0?{}:{kind:a}})}return s}}),x&&i(L,{verdict:x}),e(`div`,{className:`flex items-center justify-between pt-2`,children:[i(k,{variant:`unstyled`,onClick:h,className:`rounded-lg border border-border px-3 py-1.5 text-xs text-foreground-subtle hover:text-foreground transition-colors`,children:g(`integrations.back`)}),e(`div`,{className:`flex items-center gap-2`,children:[f&&e(k,{variant:`outline`,size:`sm`,onClick:f,"data-testid":`integration-scan`,children:[i(m,{className:`h-3.5 w-3.5`}),g(`integrations.scanFromForm`,`Scan the network`)]}),i(k,{variant:`unstyled`,onClick:()=>w.mutate({addonId:t,id:null,values:S(n,y),...a===void 0?{}:{kind:a}}),disabled:w.isPending||!r,title:r?void 0:g(`integrations.connectionUntestable`,{defaultValue:`This integration cannot be tested before it is created.`}),className:`rounded-lg border border-border px-3 py-1.5 text-xs text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50 disabled:cursor-not-allowed`,children:w.isPending?g(`integrations.testing`):g(`integrations.testConnection`)}),e(`div`,{className:`flex flex-col items-end gap-1`,children:[D&&i(`p`,{"data-testid":`integration-name-submit-error`,className:`text-xs text-danger`,children:g(`integrations.nameRequiredSubmit`,`Enter a name before continuing.`)}),i(k,{variant:`unstyled`,onClick:()=>{D||p({name:_,config:S(n,y)})},disabled:!ee||d,className:`rounded-lg bg-primary px-4 py-1.5 text-xs font-medium text-primary-foreground shadow-sm disabled:opacity-50`,children:d?g(`integrations.saving`,{defaultValue:`Saving…`}):l??g(`integrations.forward`)})]})]})]})]})}var Ee=`(hover: none) and (pointer: coarse)`;function G(){if(typeof window>`u`||typeof window.matchMedia!=`function`)return!0;try{return!window.matchMedia(Ee).matches}catch{return!0}}s();function De(e,t){return`${e.name} ${e.description} ${e.addonId}`.toLowerCase().includes(t)}function Oe({onSelect:r,onClose:s,pendingAddonId:c=null,source:l}){let{t:d,i18n:p}=P(),m=de(),[h,_]=o(``),v=t(null),y=oe(void 0,{enabled:l===void 0}),b=l===void 0?y.data:void 0,x=l===void 0&&y.isLoading;a(()=>{x||!G()||v.current?.focus()},[x]);let{data:S}=N(void 0),C=c!==null,w=n(()=>l===void 0?(b??[]).map(t=>{let n=t.instanceMode===`unique`&&t.existingInstances.length>0;return{addonId:t.addonId,name:t.name,description:t.description??``,open:()=>{let e=t.existingInstances[0];n&&e!==void 0?(s(),m(pe(t.addonId,e.id))):r(t.addonId,t.instanceMode,t.discoveryMode,t.name,t.kind,t.brokerKind,t.mode,t.canTest)},footer:n?e(`span`,{className:`flex items-center gap-1 text-xs font-medium text-foreground-subtle`,children:[i(u,{className:`h-3 w-3`}),d(`integrations.manage`)]}):null}}):l.providers.map(e=>({...e,open:()=>l.onPick(e.addonId),footer:null})),[l,b,s,r,m,d]),T=n(()=>{let e=h.trim().toLowerCase();return e.length===0?w:w.filter(t=>De(t,e))},[w,h]),E=n(()=>{let e=B(T,z(S));return{providers:V(e.providers,p.language),system:V(e.system,p.language)}},[T,S,p.language]);if(x)return i(`div`,{className:`grid grid-cols-1 gap-2 p-2 sm:grid-cols-2 lg:grid-cols-3`,children:[1,2,3,4].map(e=>i(`div`,{className:`h-24 rounded-lg bg-surface animate-pulse`},e))});let D=e=>i(U,{children:e.map(e=>i(W,{testId:`provider-card-${e.addonId}`,buttonTestId:`provider-pick-${e.addonId}`,addonId:e.addonId,name:e.name,openLabel:e.name,disabled:C,onOpen:e.open,body:e.description.length>0?i(`p`,{className:`line-clamp-2 text-xs text-foreground-muted`,children:e.description}):i(`span`,{}),footer:c===e.addonId?i(f,{className:`h-4 w-4 animate-spin text-primary`}):e.footer},e.addonId))});return e(`div`,{className:`space-y-3`,"data-testid":`provider-picker`,children:[e(`div`,{className:`relative`,children:[i(g,{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(j,{ref:v,type:`search`,value:h,onChange:e=>_(e.target.value),placeholder:d(`integrations.searchProviders`,`Search integrations…`),className:`pl-8`,"data-testid":`provider-picker-search`,"aria-label":d(`integrations.searchProviders`,`Search integrations…`)})]}),E.providers.length>0&&i(H,{kind:`providers`,children:D(E.providers)}),E.system.length>0&&i(H,{kind:`system`,children:D(E.system)}),T.length===0&&i(`div`,{className:`py-8 text-center text-xs text-foreground-subtle`,children:w.length===0?d(`integrations.noProviders`):d(`integrations.noProvidersMatch`,`No integrations match your search.`)})]})}s();function ke({open:t,onClose:a,scope:s,onSetupIntegration:c,pickMode:l=`adopt`}){let{t:u}=P(),d=w(),[f,p]=o(new Set),[h,g]=o(new Set),[_,v]=o(new Set),{data:y}=ce({projection:`slim`}),b=n(()=>new Set((y??[]).map(e=>e.stableId)),[y]),x=r(async(e,t)=>{g(e=>new Set(e).add(t.stableId));try{await d.mutateAsync({addonId:e,candidate:t}),p(e=>new Set(e).add(t.stableId)),v(e=>{let n=new Set(e);return n.delete(t.stableId),n})}catch{}finally{g(e=>{let n=new Set(e);return n.delete(t.stableId),n})}},[d]),S=r(async(e,t)=>{let n=l===`fill`?me(e,t):he(e,t);if(n!==null){c?.(n),a();return}await x(e,t)},[x,a,c,l]),T=r(e=>{v(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),D=r(()=>{p(new Set),v(new Set)},[]),O=n(()=>({existingStableIds:b,adopted:f,adopting:h,selection:{selected:_,toggle:T},pick:S,adoptOne:x,fill:l===`fill`}),[b,f,h,_,T,S,l]),te=s?u(`integrations.scanNetworkModal.titleScoped`,`Scan network — {{label}}`,{label:s.label}):u(`integrations.scanNetworkModal.title`,`Scan network for devices`);return i(C,{open:t,onOpenChange:e=>!e&&a(),children:e(ee,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,children:[i(E,{children:i(ne,{children:e(`span`,{className:`flex items-center gap-2`,children:[i(m,{className:`h-4 w-4 text-primary`}),te]})})}),e(ae,{className:`space-y-4`,children:[i(ve,{}),s?i(Pe,{scope:s,row:O,onReset:D}):i(Ne,{row:O,onReset:D})]})]})})}function K(e,t){return!t&&e.selectable!==!1&&!ge(e)}function q({addonId:t,nodes:n,row:r,depth:a}){return i(`div`,{className:a===0?`space-y-1.5`:`ml-4 space-y-1.5 border-l border-border pl-3`,"data-testid":a===0?void 0:`scan-children`,children:n.map(n=>e(`div`,{className:`space-y-1.5`,children:[i(Ae,{addonId:t,candidate:n.candidate,row:r}),n.children.length>0&&i(q,{addonId:t,nodes:n.children,row:r,depth:a+1})]},n.candidate.stableId))})}function Ae({addonId:t,candidate:n,row:r}){let{t:a}=P(),o=n.prefilledConfig.host,s=typeof o==`string`?o:null,c=r.existingStableIds.has(n.stableId)||n.alreadyOnboarded===!0||n.onboardedDeviceId!==void 0,l=r.adopted.has(n.stableId)||c,u=r.adopting.has(n.stableId),p=r.fill||ge(n),m=!l&&(p||n.selectable!==!1),h=m&&K(n,r.fill);return e(`div`,{className:`flex items-center gap-3 rounded-lg border border-border bg-surface px-3 py-2`,"data-testid":`scan-row-${n.stableId}`,children:[h&&i(b,{checked:r.selection.selected.has(n.stableId),onChange:()=>r.selection.toggle(n.stableId),disabled:u,"aria-label":a(`integrations.scanNetworkModal.select`,`Select {{name}}`,{name:n.suggestedName})}),e(`div`,{className:`min-w-0 flex-1`,children:[i(`p`,{className:`truncate text-xs font-medium text-foreground`,children:n.suggestedName}),s&&i(`p`,{className:`truncate font-mono text-[10px] text-foreground-subtle`,children:s}),c&&n.onboardedName!==void 0&&i(`p`,{className:`truncate text-[10px] text-foreground-subtle`,children:n.onboardedName})]}),l?e(`span`,{className:`flex items-center gap-1 text-[11px] text-foreground-subtle`,children:[i(d,{className:`h-3.5 w-3.5`}),` `,c?a(`integrations.scanNetworkModal.alreadyAdded`,`Already added`):a(`integrations.scanNetworkModal.added`,`Added`)]}):m?e(k,{size:`sm`,variant:p?`outline`:`primary`,onClick:()=>void r.pick(t,n),disabled:u,children:[u?i(f,{className:`h-3.5 w-3.5 animate-spin`}):p?null:i(y,{className:`h-3.5 w-3.5`}),p?r.fill?a(`integrations.scanNetworkModal.use`,`Use`):a(`integrations.scanNetworkModal.setUp`,`Set up`):a(`common.add`,`Add`)]}):null]})}function je({addonId:t,label:r,candidates:a,row:o}){let s=n(()=>R(a),[a]);return e(`section`,{className:`space-y-2`,"data-testid":`scan-group-${t}`,children:[e(`h3`,{className:`flex items-center gap-2`,children:[i(F,{type:t,size:`sm`}),i(`span`,{className:v,children:r}),e(`span`,{className:`text-[10px] text-foreground-subtle`,children:[`(`,a.length,`)`]})]}),i(q,{addonId:t,nodes:s,row:o,depth:0})]})}function Me(e,t){return e.flatMap(e=>_e(R(e.candidates)).filter(e=>K(e,t)).map(t=>({addonId:e.addonId,candidate:t})))}function Ne({row:t,onReset:o}){let{t:s}=P(),c=ie(),l=r(()=>{o(),c.mutate({})},[c,o]);a(()=>{!c.isPending&&!c.data&&l()},[]);let u=n(()=>(c.data?.groups??[]).filter(e=>e.candidates.length>0),[c.data]),d=n(()=>u.reduce((e,t)=>e+t.candidates.length,0),[u]),f=n(()=>Me(u,t.fill),[u,t.fill]);return e(`div`,{className:`space-y-4`,children:[e(`div`,{className:`flex items-center justify-between gap-2`,children:[i(`p`,{className:`text-xs text-foreground-subtle`,children:!c.isPending&&u.length>0?s(`integrations.scanNetworkModal.found`,{count:d}):null}),e(`div`,{className:`flex items-center gap-2`,children:[i(Fe,{entries:f,row:t}),e(k,{variant:`outline`,size:`sm`,onClick:l,disabled:c.isPending,children:[i(_,{className:`h-3.5 w-3.5 ${c.isPending?`animate-spin`:``}`}),s(`integrations.scanNetworkModal.reScan`,`Re-scan`)]})]})]}),c.isPending&&i(Y,{label:s(`integrations.scanNetworkModal.scanningTheLocalNetwork`,`Scanning the local network…`)}),!c.isPending&&c.isError&&i(X,{}),!c.isPending&&c.data&&u.length===0&&i(J,{}),!c.isPending&&u.map(e=>i(je,{addonId:e.addonId,label:e.label,candidates:e.candidates,row:t},e.addonId))]})}function Pe({scope:t,row:a,onReset:s}){let{t:c}=P(),l=se({addonId:t.addonId}).data??null,[u,d]=o({}),p=O(),h=r(()=>{s(),p.mutate({addonId:t.addonId,params:u})},[p,t.addonId,u,s]),g=n(()=>p.data?.candidates??[],[p.data]),_=n(()=>Me([{addonId:t.addonId,candidates:g}],a.fill),[t.addonId,g,a.fill]);return e(`div`,{className:`space-y-4`,children:[l&&i(I,{schema:l,values:u,onChange:d}),e(k,{onClick:h,disabled:p.isPending,children:[p.isPending?i(f,{className:`h-3.5 w-3.5 animate-spin`}):i(m,{className:`h-3.5 w-3.5`}),p.isPending?c(`integrations.scanNetworkModal.scanning`,`Scanning…`):c(`integrations.scanNetworkModal.scan`,`Scan`)]}),i(Fe,{entries:_,row:a}),p.isError&&i(X,{}),!p.isPending&&p.data&&g.length===0&&i(J,{}),!p.isPending&&g.length>0&&e(`div`,{className:`space-y-2`,children:[i(`p`,{className:`text-xs text-foreground-subtle`,children:c(`integrations.scanNetworkModal.foundShort`,{count:g.length})}),i(je,{addonId:t.addonId,label:t.label,candidates:g,row:a})]})]})}function Fe({entries:t,row:n}){let{t:r}=P(),a=t.filter(e=>n.selection.selected.has(e.candidate.stableId));if(a.length===0)return null;let o=async()=>{for(let e of a)await n.adoptOne(e.addonId,e.candidate)};return e(k,{size:`sm`,onClick:()=>void o(),"data-testid":`scan-add-selected`,children:[i(y,{className:`h-3.5 w-3.5`}),r(`integrations.scanNetworkModal.addSelected`,`Add selected ({{count}})`,{count:a.length})]})}function J(){let{t:e}=P();return i(`p`,{className:`py-6 text-center text-xs text-foreground-subtle`,children:e(`integrations.scanNetworkModal.noDevicesRespondedToThe`,`No devices responded to the scan.`)})}function Y({label:t}){return e(`div`,{className:`flex flex-col items-center py-12`,children:[i(f,{className:`h-6 w-6 animate-spin text-primary`}),i(`p`,{className:`mt-3 text-xs text-foreground-subtle`,children:t})]})}function X(){let{t}=P();return e(`div`,{className:`flex items-start gap-3 rounded-lg border border-danger/40 bg-danger/10 px-4 py-3`,children:[i(h,{className:`mt-0.5 h-4 w-4 shrink-0 text-danger`}),i(`p`,{className:`text-xs text-danger`,children:t(`integrations.scanNetworkModal.theScanFailedTryAgain`,`The scan failed. Try again.`)})]})}s();function Ie(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 Le=2e4;function Z({open:t,onClose:r,seed:s=null,pickFrom:u}){let{t:d}=P(),p=de(),m=c(),[h,g]=o(`picker`),[_,v]=o(null),[y,b]=o(null),[x,S]=o(`manual`),[O,ie]=o(null),[A,j]=o(``),[se,M]=o(null),[ce,N]=o(null),[ue,F]=o(!1),[I,L]=o({}),[fe,me]=o(``),[he,R]=o(!1),[ge,_e]=o(0),[ve,ye]=o(``),be=re({},{enabled:t&&h===`config`}),z=(le({addonId:_??``},{enabled:t&&h===`config`&&_!==null}).data?.kinds??[]).filter(e=>e.canTest!==!1),B=z.length===1?z[0]?.id:void 0,V=_!==null&&(be.data?.providers??[]).some(e=>e.addonId===_),H=s?.config.host,U=s===null?``:`${s.addonId}\0${s.name}\0${typeof H==`string`?H:``}`;t&&s!==null&&fe!==U&&(me(U),v(s.addonId),j(s.name),L({...s.config}),g(`config`));let W=oe(void 0,{enabled:t&&s!==null}),Ee=W.data?.find(e=>e.addonId===_)?.mode??`account`,{data:G}=te({addonId:_??``,id:null,mode:Ee,...s?.originStableId===void 0?{}:{candidateStableId:s.originStableId}},{enabled:_!=null}),De=n(()=>G?Ie(G):null,[G]),K=D({onSuccess:()=>{m.invalidateQueries({queryKey:[[`integrations`]]}),m.invalidateQueries({queryKey:[[`integrationInstances`]]})}}),q=T(),Ae=q.data;a(()=>{if(!t||s===null)return;let e=W.data?.find(e=>e.addonId===s.addonId);e&&(F(e.canTest),S(e.discoveryMode))},[t,s,W.data]),a(()=>{h!==`discovery`||!y||!_||q.isPending||q.data||q.mutate({addonId:_})},[h,y,_,q]);let je=w({onSuccess:()=>m.invalidateQueries({queryKey:[[`deviceManager`]]})});function Me(e,t,n,r,i,a,o,s){if(!K.isPending){if(v(e),F(s),S(n),j(r),N(null),K.reset(),o===`broker`){if(!a){N(`Addon '${e}' declares mode 'broker' but no brokerKind in its manifest`);return}ie(a),g(`broker`);return}if(o===`account`){g(`config`);return}Ne(e,r)}}async function Ne(e,t){try{let n=await K.mutateAsync({addonId:e,name:t,values:{}});r(),X(),p(`${pe(e,n.id)}&add=1`)}catch{}}async function Pe(e){if(_)try{let t=await K.mutateAsync({addonId:_,name:e.name,values:e.config,...B===void 0?{}:{kind:B},...s!==null&&s.addonId===_&&s.originStableId!==void 0?{originStableId:s.originStableId}:{}});b(t.id),M(t.id),x===`auto`||x===`both`?g(`discovery`):Y(t.id,{openAdd:!0})}catch{}}async function Fe(e){if(_)try{let t=await K.mutateAsync({addonId:_,name:A,values:{brokerId:e}});M(t.id),b(t.id),Y(t.id)}catch{}}async function J(e){if(_){for(let t of e){let e=Ae?.find(e=>e.stableId===t);e&&await je.mutateAsync({addonId:_,candidate:e,...se===null?{}:{integrationId:se}})}Y()}}function Y(e,t){let n=e??y??_;if(r(),X(),n&&_){let e=pe(_,n);p(t?.openAdd===!0?`${e}&add=1`:e)}}function X(){g(`picker`),v(null),b(null),S(`manual`),ie(null),j(``),M(null),N(null),K.reset(),F(!1),L({}),me(``)}function Z(){r(),X()}xe(t);let Q=K.isPending,Re=Se(Q,Le);if(!t)return null;let ze={picker:u?.title??d(`integrations.newIntegration`),config:d(`integrations.configureIntegration`),discovery:d(`integrations.importDevices`),broker:d(`integrations.connectBroker`,{defaultValue:`Connect a broker`})},Be=Q?_:null,$=K.error,Ve=Q&&!Re;return e(l,{children:[i(C,{open:!0,onOpenChange:e=>{!e&&!Ve&&Z()},children:e(ee,{width:h===`picker`?`xl`:`lg`,scroll:`body`,onCancel:e=>{Ve&&e.preventDefault()},children:[i(E,{children:i(ne,{children:ze[h]})}),e(ae,{children:[$&&!Q&&i(`div`,{className:`mb-3 rounded-lg border border-danger/40 bg-danger/10 px-3 py-2 text-xs text-danger`,children:$ instanceof Error?$.message:String($)}),h===`picker`&&e(l,{children:[ce&&i(`div`,{className:`mb-3 rounded-lg border border-danger/40 bg-danger/10 px-3 py-2 text-xs text-danger`,children:ce}),i(Oe,{onSelect:Me,onClose:Z,pendingAddonId:Be,...u===void 0?{}:{source:u}})]}),h===`config`&&_&&i(Te,{addonId:_,configSchema:De??null,canTest:ue,...B===void 0?{}:{instanceKind:B},initialName:A.length>0&&Object.keys(I).length>0?A:void 0,initialConfig:{...I},onScan:V?()=>{ye(A.length>0?A:_),R(!0)}:void 0,onSave:Pe,onBack:()=>{L({}),g(`picker`)}},`${U.length>0?U:_}:${ge}`),h===`broker`&&O&&i(Ce,{kind:O,onResolved:e=>{Fe(e)},onBack:()=>g(`picker`)}),h===`discovery`&&y&&i(we,{providerId:y,onImport:J,onSkip:Y})]}),Q&&e(`div`,{className:`absolute inset-0 z-20 flex flex-col items-center justify-center gap-2 rounded-lg bg-background/85 backdrop-blur-sm px-6 text-center`,children:[i(f,{className:`h-6 w-6 animate-spin text-primary`}),i(`p`,{className:`text-xs font-medium text-foreground`,children:d(`integrations.creating`,{defaultValue:`Creating integration…`})}),!Re&&i(`p`,{className:`text-[10px] text-foreground-subtle`,children:d(`integrations.creatingHint`,{defaultValue:`Waiting for the addon to restart and register`})}),Re&&e(l,{children:[i(`p`,{className:`text-[10px] text-foreground-subtle max-w-xs`,children:d(`integrations.creatingOverdue`,{defaultValue:`This is taking longer than expected. The integration may already have been created — close this dialog and refresh to check.`})}),i(k,{variant:`unstyled`,onClick:Z,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:d(`integrations.closeAndRefresh`,{defaultValue:`Close`})})]})]})]})}),he&&_!==null&&i(ke,{open:he,scope:{addonId:_,label:ve},pickMode:`fill`,onClose:()=>R(!1),onSetupIntegration:e=>{j(e.name),L({...e.config}),_e(e=>e+1)}})]})}export{H as a,z as c,U as i,ke as n,V as o,W as r,B as s,Z as t};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{C as e,K as t,S as n,V as r,Y as i,et as a,o,x as s}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{
|
|
2
|
-
`),variant:o.length===0?`default`:`danger`})},onError:async e=>{await r({title:t(`wasteFetchNow.allNotFetched`,`The calendars could not be fetched`),message:e.message,variant:`danger`})}});return e(w,{size:`sm`,variant:`secondary`,disabled:a.isPending,onClick:()=>a.mutate({addonId:H,action:`fetchNow`,input:{}}),children:[n(
|
|
1
|
+
import{C as e,K as t,S as n,V as r,Y as i,et as a,o,x as s}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{Cr as c,Wn as l,Zn as u,ci as d,kn as f,ot as p}from"./player-overlays-D-63t-DL.js";import{Vi as m}from"./client-B60QT14E.js";import{D as h,N as g,O as _,v}from"./__vite-browser-external-BCAtXlNQ.js";import{y}from"./video-BV-3O_ZC.js";import{Br as b,Gr as x,Hr as S,Kr as C,Pi as w,Vr as T,go as E,gt as D,ht as O,mt as k,na as A,of as j}from"./src-g2TJby3U.js";import{t as M}from"./useTranslation-BJr-n0es.js";import{Qr as N,X as P,x as F}from"./index-CxPpnulu.js";import{t as I}from"./AdminSectionedPage-BZZVpePX.js";import{t as L}from"./InstancesTable-CvfpkEKd.js";a();var R=1e4;function z({row:t}){let{t:r}=M(),[a,o]=i(!1),c=t.kind===`instance`?t.id:void 0,{data:l}=E({addonId:t.addonId,...c===void 0?{}:{instanceId:c}},{refetchInterval:R,retry:!1}),u=m.safeParse(l);if(!u.success||t.kind===`instance`&&!t.enabled)return null;let d=u.data.exposedDeviceCount;return e(s,{children:[n(w,{variant:`ghost`,size:`sm`,type:`button`,onClick:()=>o(!0),children:r(`system.connectivity.devicesExported`,`{{count}} devices exported`,{count:d})}),a&&n(b,{open:!0,onOpenChange:o,children:e(S,{width:`full`,scroll:`body`,children:[n(x,{children:n(C,{children:r(`system.connectivity.devicesDialogTitle`,`Devices of {{name}}`,{name:t.name})})}),n(T,{children:c===void 0?n(O,{addonId:t.addonId,showSetup:!1}):n(k,{addonId:t.addonId,instance:{instanceId:c,name:t.name,enabled:!0},showSetup:!1})})]})})]})}function B(e){return{key:`devices`,header:e(`system.connectivity.devicesColumn`,`Devices`),notSortableReason:e(`system.connectivity.devicesNotSortable`,`A button that opens the list is not a value to order by.`),render:e=>n(z,{row:e})}}function V({addonId:e,instanceId:t}){return n(D,{addonId:e,instanceId:t})}var H=`waste-collections`,U=_({refreshed:v(_({sourceId:g(),entryCount:h().int(),error:g().optional()}))});function W({row:e}){let{t}=M(),r=p(),i=o(),a=A({onSuccess:async n=>{let a=U.safeParse(n),o=a.success?a.data.refreshed[0]:void 0;if(i.invalidateQueries({queryKey:[P]}),o===void 0){await r({title:t(`wasteFetchNow.nothingFetched`,`Nothing to fetch`),message:t(`wasteFetchNow.sourceIsOff`,`{{name}} is switched off, so it was not fetched.`,{name:e.name})});return}await r({title:o.error===void 0?t(`wasteFetchNow.fetched`,`{{name}} fetched`,{name:e.name}):t(`wasteFetchNow.failed`,`{{name}} could not be fetched`,{name:e.name}),message:o.error??t(`wasteFetchNow.collections`,`{{count}} collections read.`,{count:o.entryCount}),variant:o.error===void 0?`default`:`danger`})},onError:async n=>{await r({title:t(`wasteFetchNow.failed`,`{{name}} could not be fetched`,{name:e.name}),message:n.message,variant:`danger`})}});return n(j,{icon:d,variant:`ghost`,size:`sm`,"aria-label":t(`wasteFetchNow.label`,`Fetch {{name}} now`,{name:e.name}),disabled:a.isPending,onClick:()=>a.mutate({addonId:H,action:`fetchNow`,input:{sourceId:e.id}})})}function G(e){return e.addonId===H?n(W,{row:e}):null}function K(){let{t}=M(),r=p(),i=o(),a=A({onSuccess:async e=>{let n=U.safeParse(e);i.invalidateQueries({queryKey:[P]});let a=n.success?n.data.refreshed:[],o=a.filter(e=>e.error!==void 0);await r({title:o.length===0?t(`wasteFetchNow.allFetched`,`Calendars fetched`):t(`wasteFetchNow.allFailed`,`{{count}} calendars could not be fetched`,{count:o.length}),message:o.length===0?t(`wasteFetchNow.allCollections`,`{{count}} sources refreshed.`,{count:a.length}):o.map(e=>`${e.sourceId}: ${e.error}`).join(`
|
|
2
|
+
`),variant:o.length===0?`default`:`danger`})},onError:async e=>{await r({title:t(`wasteFetchNow.allNotFetched`,`The calendars could not be fetched`),message:e.message,variant:`danger`})}});return e(w,{size:`sm`,variant:`secondary`,disabled:a.isPending,onClick:()=>a.mutate({addonId:H,action:`fetchNow`,input:{}}),children:[n(d,{className:`h-3.5 w-3.5`}),t(`wasteFetchNow.all`,`Fetch all now`)]})}function q(e){return e.some(e=>e.addonId===H)?n(K,{}):null}a();var J={"device-export":`exporters`,exporters:`exporters`,email:`email`,broker:`brokers`,brokers:`brokers`,"message-brokers":`brokers`,calendar:`calendars`,calendars:`calendars`,"calendar-source":`calendars`},Y=[{sectionId:`exporters`,labelKey:`system.connectivity.exporters`,icon:f,installLabelKey:`system.connectivity.exportersInstall`,emptyTitleKey:`system.connectivity.exportersEmptyTitle`,emptyDescriptionKey:`system.connectivity.exportersEmptyDescription`,instances:{functionCap:`device-export`,subtitleKey:`system.connectivity.exportersSubtitle`,subtitleDefault:`The ecosystems and hubs this hub publishes its devices to.`,addLabelKey:`system.connectivity.exportersAdd`,addLabelDefault:`Add export`,extraColumns:e=>[B(e)],lead:e=>n(V,{addonId:e.addonId,instanceId:e.id})}},{sectionId:`email`,labelKey:`system.connectivity.email`,icon:c,installLabelKey:`system.connectivity.emailInstall`,emptyTitleKey:`system.connectivity.emailEmptyTitle`,emptyDescriptionKey:`system.connectivity.emailEmptyDescription`,instances:{functionCap:`smtp-provider`,subtitleKey:`system.connectivity.emailSubtitle`,subtitleDefault:`The SMTP relays that notification targets send mail through.`,addLabelKey:`system.connectivity.emailAdd`,addLabelDefault:`Add relay`}},{sectionId:`brokers`,labelKey:`system.connectivity.brokers`,icon:l,installLabelKey:`system.connectivity.brokersInstall`,emptyTitleKey:`system.connectivity.brokersEmptyTitle`,emptyDescriptionKey:`system.connectivity.brokersEmptyDescription`,instances:{functionCap:`broker`,subtitleKey:`system.connectivity.brokersSubtitle`,subtitleDefault:`The accounts and connections this hub reaches its devices through.`,addLabelKey:`system.connectivity.brokersAdd`,addLabelDefault:`Add connection`}},{sectionId:`calendars`,labelKey:`system.connectivity.calendars`,icon:y,installLabelKey:`system.connectivity.calendarsInstall`,emptyTitleKey:`system.connectivity.calendarsEmptyTitle`,emptyDescriptionKey:`system.connectivity.calendarsEmptyDescription`,instances:{functionCap:`calendar-source`,subtitleKey:`system.connectivity.calendarsSubtitle`,subtitleDefault:`The calendars this hub reads events from.`,addLabelKey:`system.connectivity.calendarsAdd`,addLabelDefault:`Add calendar`,rowActions:G,pageActions:q}}];function X(){let{t:e}=M(),[i,a]=N(),o=F(`/system/integrations`,{t:e,isAdmin:!0})??{icon:u,title:e(`admin.system.integrations.connectivity`,`Connectivity`)};r(()=>{let e=i.get(`tab`);if(e===null)return;let t=J[e];t===void 0||t===e||a(e=>{let n=new URLSearchParams(e);return n.set(`tab`,t),n},{replace:!0})},[i,a]);let s=t(()=>Y.map(t=>{let r=t.instances;return{id:t.sectionId,label:e(t.labelKey),content:n(L,{functionCap:r.functionCap,icon:t.icon,title:e(t.labelKey),subtitle:e(r.subtitleKey,r.subtitleDefault),emptyTitle:e(t.emptyTitleKey),emptyDescription:e(t.emptyDescriptionKey),addLabel:e(r.addLabelKey,r.addLabelDefault),install:{capability:r.functionCap,label:e(t.installLabelKey)},...r.extraColumns===void 0?{}:{extraColumns:r.extraColumns(e)},...r.lead===void 0?{}:{lead:r.lead},...r.rowActions===void 0?{}:{rowActions:r.rowActions},...r.pageActions===void 0?{}:{pageActions:r.pageActions}})}}),[e]);return n(I,{icon:o.icon,title:o.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:s})}export{X as IntegrationsPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{C as e,K as t,R as n,S as r,V as i,Y as a,et as o,x as s}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{Bi as c,Dr as l,Ea as u,Kn as d,Mn as f,Mr as p,Qn as m,Ri as h,Un as g,Zn as _,gt as v}from"./player-overlays-D-63t-DL.js";import{t as y}from"./chevron-down-CBb-F8DT.js";import{t as ee}from"./table-2-DMxm3oyu.js";import{Br as b,Co as te,Ei as ne,Gr as x,Hr as re,J as S,Kr as ie,Pi as C,Ro as ae,Vr as w,Xo as oe,_t as se,a as ce,af as T,bt as le,ec as ue,qo as de,tc as fe,ua as pe,vt as me,x as he}from"./src-g2TJby3U.js";import{t as E}from"./i18n-CvWKDmFM.js";import{t as D}from"./useTranslation-BJr-n0es.js";import{Qr as ge,W as _e,Xr as ve,Yr as ye,y as be}from"./index-CxPpnulu.js";import{t as xe}from"./AdminPage-DBIlGQcg.js";import"./useEventInvalidation-CsHVNi49.js";import{t as Se}from"./device-integration-icon-TWc3Gi9v.js";import{i as Ce,n as O}from"./ScanSubnetEditor-BCfqLZIA.js";import{a as k,c as we,i as A,n as Te,o as j,r as M,s as N,t as Ee}from"./IntegrationWizard-CUcCjYQD.js";o();function De(e){return e.some(e=>e.status===`running`)?`running`:e.some(e=>e.status===`stopped`)?`stopped`:`disabled`}function Oe(e,t){let n=new Map;for(let t of e){let e=n.get(t.addonId);e===void 0?n.set(t.addonId,[t]):e.push(t)}return[...n.entries()].map(([e,n])=>{let r=t.get(e)?.trim()??``;return{addonId:e,name:r.length>0?r:n[0]?.name??e,instances:n,instanceCount:n.length,deviceCount:n.reduce((e,t)=>e+t.deviceCount,0),status:De(n)}})}var ke=3e3,P=new Set([`no-provider`,`node-offline`,`transport-failed`]),F=[`provider not available`,`failed to fetch`,`networkerror`,`load failed`];function Ae(e){if(typeof e!=`object`||!e)return null;let t=Reflect.get(e,`data`);if(typeof t!=`object`||!t)return null;let n=Reflect.get(t,`capRouteReason`);return typeof n==`string`?n:null}function I(e,t){if(e==null||t>10)return!1;let n=Ae(e);if(n!==null)return P.has(n);let r=(e instanceof Error?e.message:String(e)).toLowerCase();return F.some(e=>r.includes(e))}function je(e){return I(e.state.error,e.state.errorUpdateCount)?ke:!1}function Me({providers:n,system:i,onOpen:o,searchPlaceholder:s,emptyLabel:c}){let[l,u]=a(``),d=t(()=>{let e=l.trim().toLowerCase(),t=t=>e.length===0||`${t.name} ${t.addonId} ${t.instances.map(e=>e.name).join(` `)}`.toLowerCase().includes(e);return{providers:n.filter(t),system:i.filter(t)}},[l,n,i]),p=d.providers.length===0&&d.system.length===0;return e(`div`,{className:`space-y-3`,children:[e(`div`,{className:`relative`,children:[r(f,{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}),r(T,{type:`search`,value:l,onChange:e=>u(e.target.value),placeholder:s,"aria-label":s,className:`pl-8`})]}),p?r(`p`,{className:`py-8 text-center text-xs text-foreground-subtle`,children:c}):e(`div`,{className:`space-y-4`,children:[d.providers.length>0&&r(k,{kind:`providers`,children:r(L,{groups:d.providers,onOpen:o})}),d.system.length>0&&r(k,{kind:`system`,children:r(L,{groups:d.system,onOpen:o})})]})]})}function L({groups:e,onOpen:n}){let{t:i,i18n:a}=D();return r(A,{children:t(()=>j(e,a.language),[e,a.language]).map(e=>r(M,{testId:`integration-card-${e.addonId}`,addonId:e.addonId,name:e.name,openLabel:i(`integrations.openNamed`,{name:e.name,defaultValue:`Open {{name}}`}),onOpen:()=>n(e),body:r(`p`,{className:`text-xs text-foreground-muted`,children:i(`integrations.addonCard.summary`,{integrations:i(`integrations.addonCard.integrationCount`,{count:e.instanceCount}),devices:i(`integrations.integrationColumns.deviceCount`,{count:e.deviceCount}),defaultValue:`{{integrations}} · {{devices}}`})}),footer:r(S,{status:e.status,className:`shrink-0`})},e.addonId))})}o();var R=`camstack.admin.integrations.view`;function Ne(e){return e===`table`||e===`grid`}function z(){try{return typeof window>`u`?null:window.localStorage}catch{return null}}function B(e=z()){if(e===null)return`table`;try{let t=e.getItem(R);return Ne(t)?t:`table`}catch{return`table`}}function V(e,t=z()){if(t!==null)try{t.setItem(R,e)}catch{}}function Pe(){let[e,t]=a(()=>B());return[e,n(e=>{t(e),V(e)},[])]}function H({integration:t,expanded:n,onToggleExpand:i}){let{t:a}=D();return e(`div`,{className:`flex items-center gap-2.5`,children:[r(C,{variant:`unstyled`,type:`button`,onClick:e=>{e.stopPropagation(),i(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:r(n?y:h,{className:`h-3.5 w-3.5`})}),r(_e,{type:t.addonId,size:`sm`}),e(`div`,{className:`flex min-w-0 flex-col`,children:[r(`span`,{className:`truncate text-xs font-semibold text-foreground`,children:t.name}),r(`span`,{className:`truncate text-[10px] text-foreground-subtle`,children:t.addonId})]})]})}function Fe(e){let{isExpanded:t,onToggleExpand:n}=e;return[{key:`name`,header:E.t(`integrations.integrationColumns.integration`,`Integration`),headerClassName:`w-[55%]`,cell:e=>r(H,{integration:e,expanded:t(e),onToggleExpand:n})},{key:`devices`,header:E.t(`integrations.integrationColumns.devices`,`Devices`),headerClassName:`w-[15%]`,cellClassName:`text-[11px] text-foreground-subtle`,cell:e=>E.t(`integrations.integrationColumns.deviceCount`,{count:e.deviceCount})},{key:`status`,header:E.t(`integrations.integrationColumns.status`,`Status`),headerClassName:`w-[15%]`,cell:e=>r(S,{status:e.status})}]}o();var U=6e4;function Ie({onSetupIntegration:t}){let{t:n}=D(),[i,o]=a(!1),c=oe({},{refetchInterval:U}),l=c.data?.proposals??[];return l.length===0?null:e(s,{children:[e(`div`,{role:`status`,"data-testid":`discovery-banner`,className:`flex flex-wrap items-center gap-2 rounded-lg border border-info/30 bg-info/10 px-3 py-2 text-xs text-foreground`,children:[r(d,{className:`h-3.5 w-3.5 text-info`,"aria-hidden":!0}),r(`span`,{className:`flex-1`,children:n(`integrations.discoveryBanner.count`,{defaultValue_one:`{{count}} new device found`,defaultValue_other:`{{count}} new devices found`,count:l.length})}),r(C,{variant:`secondary`,size:`sm`,onClick:()=>o(!0),children:n(`integrations.discoveryBanner.review`,`Review`)})]}),r(W,{open:i,onClose:()=>o(!1),proposals:l,onChanged:()=>void c.refetch(),onSetupIntegration:e=>{o(!1),t(e)}})]})}function W({open:t,onClose:i,proposals:o,onChanged:u,onSetupIntegration:f}){let{t:p}=D(),m=te(),h=ae(),[g,_]=a(new Set),v=n(async(e,t)=>{_(t=>new Set(t).add(e));try{await t(),u()}catch{}finally{_(t=>{let n=new Set(t);return n.delete(e),n})}},[u]),y=n(async e=>{let t=O(e.addonId,e.candidate);if(t!==null){f(t);return}await v(e.id,()=>m.mutateAsync({addonId:e.addonId,candidate:e.candidate}))},[m,f,v]),ee=n(e=>v(e.id,()=>h.mutateAsync({id:e.id})),[h,v]);return r(b,{open:t,onOpenChange:e=>!e&&i(),children:e(re,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,children:[r(x,{children:r(ie,{children:e(`span`,{className:`flex items-center gap-2`,children:[r(d,{className:`h-4 w-4 text-primary`}),p(`integrations.discoveryBanner.title`,`New devices found`)]})})}),r(w,{className:`space-y-1.5`,children:o.map(t=>e(`div`,{"data-testid":`discovery-proposal`,className:`flex items-center gap-2 rounded-lg border border-border bg-surface px-3 py-2`,children:[e(`div`,{className:`min-w-0 flex-1`,children:[r(`p`,{className:`truncate text-sm font-medium text-foreground`,children:t.candidate.suggestedName}),r(`p`,{className:`truncate text-xs text-foreground-muted`,children:t.addonId})]}),g.has(t.id)?r(l,{className:`h-4 w-4 animate-spin text-foreground-muted`,"aria-hidden":!0}):e(s,{children:[r(C,{variant:`secondary`,size:`sm`,onClick:()=>void ee(t),children:p(`integrations.discoveryBanner.dismiss`,`Dismiss`)}),e(C,{size:`sm`,onClick:()=>void y(t),children:[r(c,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),p(`integrations.discoveryBanner.adopt`,`Adopt`)]})]})]},t.id))})]})})}o();function Le(e){if(!e.enabled&&e.switchUnknown!==!0)return`disabled`;switch(e.processState){case`running`:return`running`;default:return`stopped`}}var G=`expand`;function K(){let{t:o}=D(),c=ve(),l=ye(),f=v(),[h]=ge(),[y,b]=Pe(),[te,x]=a(!1),[re,S]=a(null),ie=n(()=>{S(null),x(!0)},[]),ae=n(()=>{x(!1),S(null)},[]),w=n(e=>{T(!1),S(e),x(!0)},[]),[oe,T]=a(!1);i(()=>{let e=Ce(l.state);e!==null&&(S(e),x(!0),c(`/integrations`,{replace:!0,state:null}))},[l.state,c]);let E=h.get(`setup`);i(()=>{E===null||E.length===0||(S({addonId:E,name:E,config:{}}),x(!0))},[E]);let _e=n(()=>T(!0),[]),O=n(()=>T(!1),[]);ce([`integrations`],[`integration.enabled`,`integration.disabled`,`integration.deleted`,`provider.started`,`provider.stopped`,`addon.installed`,`addon.uninstalled`,`addon.started`,`addon.stopped`,`addon.updated`]),ce([`deviceManager`],[`device.registered`,`device.unregistered`,`device.online`,`device.offline`,`device.disabled`,`device.enabled`]);let{data:A,isLoading:j,isError:M,error:De,errorUpdateCount:ke,refetch:P}=fe(void 0,{refetchInterval:je}),{data:F,isLoading:Ae,isError:L,error:R,errorUpdateCount:Ne,refetch:z}=de({projection:`slim`},{refetchInterval:je}),B=t(()=>F??[],[F]),V=t(()=>A??[],[A]),H=t(()=>{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=t(()=>me(A),[A]),W=t(()=>{let e=new Map;for(let t of le(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]),K=t(()=>V.map(e=>({id:e.id,addonId:e.addonId,name:e.name,enabled:e.enabled,status:Le(e),deviceCount:W.get(e.id)??0})),[V,W]),{data:Re}=ue(),ze=t(()=>new Map((Re??[]).map(e=>[e.addonId,e.name])),[Re]),Be=h.get(G),Ve=n(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`))},[]),{data:He}=pe(void 0),q=t(()=>we(He),[He]),J=t(()=>N(K,q),[K,q]),Ue=t(()=>N(Oe(K,ze),q),[K,ze,q]),We=n(e=>c(be(e.addonId)),[c]),Ge=n(e=>c(be(e.addonId,e.id)),[c]),Ke=n(e=>H.get(e)??null,[H]),qe=n(e=>c(`/devices/${String(e)}`),[c]),Je=n(e=>r(se,{context:`integration-detail`,devices:B,trpc:f.trpcClient,integrationOf:U,forceIntegrationId:e.id,urlScope:`nested`,lsKey:`integrations:nested:${e.addonId}`,resolveIntegrationIcon:Se,resolveParent:Ke,onNavigate:qe}),[B,f.trpcClient,U,Ke,qe]),Y=n(e=>Be===e.addonId,[Be]),Ye=t(()=>Fe({isExpanded:Y,onToggleExpand:Ve}),[Y,Ve]),Xe=n(e=>`${e.name} ${e.addonId}`,[]),Ze=n(e=>e.id,[]),Qe=e=>r(se,{mode:`generic`,items:e,getKey:Ze,getSearchText:Xe,columns:Ye,onRowClick:Ge,isExpanded:Y,renderExpanded:Je,searchPlaceholder:o(`integrations.search`,{defaultValue:`Search integrations…`}),emptyLabel:o(`integrations.empty`,{defaultValue:`No integrations found.`})}),$e=n(()=>{P(),z()},[P,z]),et=M===!0&&I(De,ke),tt=L===!0&&I(R,Ne),X=et||tt,Z=M===!0&&!et||L===!0&&!tt,Q=!Z&&!X&&(j||Ae||A===void 0||F===void 0),$=V.length>0,nt=[{id:`table`,label:o(`integrations.viewTable`,`Table`),icon:ee},{id:`grid`,label:o(`integrations.viewGrid`,`Grid`),icon:p}];return e(xe,{icon:_,title:o(`nav.integrations`,`Integrations`),actions:e(s,{children:[r(he,{ariaLabel:o(`integrations.viewLabel`,`Layout`),value:y,onChange:b,options:nt,testId:`integrations-view`}),r(C,{variant:`unstyled`,onClick:$e,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:o(`common.refresh`,`Refresh`),children:r(g,{className:u(`h-3.5 w-3.5`,Q&&`animate-spin`)})}),e(C,{variant:`unstyled`,onClick:_e,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:o(`integrations.scanTheLocalNetworkFor`,`Scan the local network for devices`),children:[r(d,{className:`h-3.5 w-3.5`}),o(`integrations.scanNetwork`,`Scan network`)]}),e(C,{variant:`unstyled`,onClick:ie,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:[r(m,{className:`h-3.5 w-3.5`}),o(`integrations.newIntegration`,`New Integration`)]})]}),children:[r(Ie,{onSetupIntegration:w}),Z&&r(ne,{message:o(`integrations.loadFailed`,`Integrations could not be loaded.`),onRetry:$e}),X&&!Z&&e(`div`,{role:`status`,"data-testid":`integrations-reconnecting`,className:`flex items-center gap-2 rounded-lg border border-border bg-surface px-3 py-2 text-xs text-foreground-subtle`,children:[r(g,{className:`h-3.5 w-3.5 animate-spin`,"aria-hidden":!0}),o(`integrations.reconnecting`,`An integration is restarting. The list will refresh on its own.`)]}),Q&&r(`div`,{className:`space-y-2`,"data-testid":`integrations-pending`,children:[1,2,3].map(e=>r(`div`,{className:`h-12 rounded-lg border border-border bg-surface animate-pulse`},e))}),!Z&&!Q&&!X&&!$&&e(`div`,{className:`flex flex-col items-center py-20 text-foreground-subtle`,children:[r(`p`,{className:`text-sm`,children:o(`integrations.noIntegrationsConfigured`,`No integrations configured.`)}),r(`p`,{className:`text-xs mt-1`,children:o(`integrations.clickNewIntegrationToConnect`,`Click "New Integration" to connect cameras and devices.`)})]}),!Z&&!Q&&$&&y===`table`&&e(`div`,{className:`space-y-4`,children:[J.providers.length>0&&r(k,{kind:`providers`,children:Qe(J.providers)}),J.system.length>0&&r(k,{kind:`system`,children:Qe(J.system)})]}),!Z&&!Q&&$&&y===`grid`&&r(Me,{providers:Ue.providers,system:Ue.system,onOpen:We,searchPlaceholder:o(`integrations.search`,{defaultValue:`Search integrations…`}),emptyLabel:o(`integrations.empty`,{defaultValue:`No integrations found.`})}),r(Ee,{open:te,onClose:ae,seed:re}),r(Te,{open:oe,onClose:O,onSetupIntegration:w})]})}export{K as IntegrationsPage};
|