@camstack/addon-admin-ui 1.2.487 → 1.2.489
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/dist/assets/{AddonAssetIcon-C_RF_2Yp.js → AddonAssetIcon-C0cWByHj.js} +1 -1
- package/dist/assets/Addons-DtmmHLxt.js +5 -0
- package/dist/assets/{AdminPage-Qn0NDZXK.js → AdminPage-D6Yva5zf.js} +1 -1
- package/dist/assets/{AdminSectionedPage-xGVLV1j3.js → AdminSectionedPage-ytDsnoAA.js} +1 -1
- package/dist/assets/AiProfiles-Dr62eghf.js +3 -0
- package/dist/assets/BrokerEditorDialog-CTEagRft.js +1 -0
- package/dist/assets/{Build-BhxXDEVz.js → Build-B8CmNZth.js} +4 -4
- package/dist/assets/{Calendars-v8J_zj4w.js → Calendars-BzsJnrEA.js} +1 -1
- package/dist/assets/Cluster-C2D1ovUW.js +1 -0
- package/dist/assets/{CompositionBlockEditor-BK2Or4Pz.js → CompositionBlockEditor-CYmfatQE.js} +1 -1
- package/dist/assets/{CompositionEditorPage-CTPdWS1m.js → CompositionEditorPage-B5Cgu9cj.js} +1 -1
- package/dist/assets/Data-ChStbBhF.js +2 -0
- package/dist/assets/{DeviceDetail-DGJeLN9c.js → DeviceDetail-B4rdvagQ.js} +2 -2
- package/dist/assets/{DeviceDoActionFields-OU-F7_Md.js → DeviceDoActionFields-GHZBRE4Q.js} +1 -1
- package/dist/assets/{Devices-C9LPgFce.js → Devices-Bzyikktm.js} +1 -1
- package/dist/assets/{EmbedPlayerPage-8ilkZLox.js → EmbedPlayerPage-ClpQaFoO.js} +1 -1
- package/dist/assets/{HelperWizard-Dq94Geed.js → HelperWizard-C9VjtAAi.js} +2 -2
- package/dist/assets/History-C6N6VRgs.js +1 -0
- package/dist/assets/{Identity-DOSuuL8C.js → Identity-CvFSqL46.js} +1 -1
- package/dist/assets/IntegrationDetail-AVnEA7GO.js +1 -0
- package/dist/assets/IntegrationHub-BqWPAkYu.js +1 -0
- package/dist/assets/Integrations-BYiw8_da.js +1 -0
- package/dist/assets/Integrations-CBEyPYvE.js +1 -0
- package/dist/assets/{Library-DzwP0Wnj.js → Library-BcuUHsq3.js} +1 -1
- package/dist/assets/Locations-BrPK_nfE.js +3 -0
- package/dist/assets/{Logs-BlImwaLa.js → Logs-D_Jnlf_J.js} +1 -1
- package/dist/assets/{MaskShapeCanvas-Cs9lGzkk.js → MaskShapeCanvas-C1WSjh5s.js} +1 -1
- package/dist/assets/{MotionZonesSettings-5ocz0RHa.js → MotionZonesSettings-BB6LidaW.js} +1 -1
- package/dist/assets/MyAccess-DjL1Z681.js +2 -0
- package/dist/assets/Network-DjKf4STc.js +1 -0
- package/dist/assets/{NodeAddonsSettingsPanel-AvBI4Evv.js → NodeAddonsSettingsPanel-ivvFi7qU.js} +1 -1
- package/dist/assets/{Notifications-H77YTWdJ.js → Notifications-Ck0_YzEY.js} +1 -1
- package/dist/assets/{Pipeline-pHUqWRzY.js → Pipeline-4J5lhNWd.js} +1 -1
- package/dist/assets/{PrivacyMaskSettings-UQH7zTTO.js → PrivacyMaskSettings-CSdKuS75.js} +1 -1
- package/dist/assets/Recordings-Ce8DTG1O.js +1 -0
- package/dist/assets/ScanNetworkModal-81xkyJSk.js +1 -0
- package/dist/assets/{SceneMonitorEditor-PrBW7EMG.js → SceneMonitorEditor-ucsduhsM.js} +1 -1
- package/dist/assets/SessionsList-Dgrg9zT1.js +2 -0
- package/dist/assets/{Showroom-mL9KRe6u.js → Showroom-CkHdCDH1.js} +1 -1
- package/dist/assets/{System-CW6fpBto.js → System-HvIXTTB1.js} +1 -1
- package/dist/assets/{Terminal-CLB_5tnQ.js → Terminal-CwE2WbSi.js} +5 -5
- package/dist/assets/{Viewer-CVsr_E-j.js → Viewer-B6suHwLq.js} +1 -1
- package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-CK4gM4oq.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-BkS64PhS.js} +1 -1
- package/dist/assets/{addon-icons-context-BKk0-b-B.js → addon-icons-context-BY_MClqz.js} +1 -1
- package/dist/assets/{archive-BR503Bgl.js → archive-DSecC29S.js} +1 -1
- package/dist/assets/{assignment-candidates-Bt36QoWU.js → assignment-candidates-CCD35Rpj.js} +1 -1
- package/dist/assets/{authed-media-B5-BZoAQ.js → authed-media-Dow1_6zk.js} +1 -1
- package/dist/assets/{bell-off-3JXpdmf4.js → bell-off-kKEnaAlY.js} +1 -1
- package/dist/assets/{board-model-B0Q2QBXn.js → board-model-CGmvb_0S.js} +1 -1
- package/dist/assets/{boxes-0Xg4N6GT.js → boxes-D29FuJd_.js} +1 -1
- package/dist/assets/circle-slash-BEdaE_jf.js +1 -0
- package/dist/assets/client-CdHPjeIs.js +358 -0
- package/dist/assets/{cloud-upload-BgVc9mNQ.js → cloud-upload-CNHrN4UO.js} +1 -1
- package/dist/assets/crop-E8rhIxyE.js +1 -0
- package/dist/assets/{device-integration-icon-CxktyXD5.js → device-integration-icon-Dg_7SOuH.js} +1 -1
- package/dist/assets/device-picker-model-CdWcoivb.js +1 -0
- package/dist/assets/dist-CMh2DitE.js +358 -0
- package/dist/assets/{dist-BCJVDfA5.js → dist-pyNtUJBC.js} +1 -1
- package/dist/assets/{eraser-xkgMNpsn.js → eraser-DQdA4r-4.js} +1 -1
- package/dist/assets/{format-6k9X14Bz.js → format-CvRuKl82.js} +1 -1
- package/dist/assets/{hard-drive-download-CUmPIudl.js → hard-drive-download-BWtxkXEP.js} +1 -1
- package/dist/assets/{hostInit-DcyTvfcE.js → hostInit-C4zImIaq.js} +1 -1
- package/dist/assets/i18n-Dgilx0WT.js +1 -0
- package/dist/assets/{icons-D7uD703E.js → icons-CeHJ12H1.js} +1 -1
- package/dist/assets/{index-Cgn0pmzp.js → index-4kmzPYxW.js} +3 -3
- package/dist/assets/index-DTd1apaT.css +2 -0
- package/dist/assets/{key-VxuVSDcq.js → key-ibd36DX6.js} +1 -1
- package/dist/assets/{key-round-DOAkaBGK.js → key-round-Cx5S95mB.js} +1 -1
- package/dist/assets/{layers-hN2OAslg.js → layers-f2rCYTNI.js} +1 -1
- package/dist/assets/{linked-devices-model-m3azqStw.js → linked-devices-model-DBaDc0Fe.js} +1 -1
- package/dist/assets/{list-ordered-B7_m7mQG.js → list-ordered-DVEuSX72.js} +1 -1
- package/dist/assets/{location-owned-usage-D-K-peZa.js → location-owned-usage-D20qY7jM.js} +1 -1
- package/dist/assets/{log-in-CyzfmKrH.js → log-in-YSzSSnpb.js} +1 -1
- package/dist/assets/{memory-stick-Bh-D1JrM.js → memory-stick-BxkFX9Lp.js} +1 -1
- package/dist/assets/{message-square-plus-Jq5Qx-ZG.js → message-square-plus-CReLm1AI.js} +1 -1
- package/dist/assets/{mf-entry-bootstrap-0-01ed437f.js → mf-entry-bootstrap-0-3901d897.js} +2 -2
- package/dist/assets/{mic-off-HMWnEzre.js → mic-off-CzIbHCeE.js} +1 -1
- package/dist/assets/{monitor-off-jWwMgNhA.js → monitor-off-D6AnJas6.js} +1 -1
- package/dist/assets/{monitor-smartphone-CR32s5N4.js → monitor-smartphone-BYEnK_6t.js} +1 -1
- package/dist/assets/mount-CdWcoivb.js +1 -0
- package/dist/assets/{player-overlays-BT3xIHAn.js → player-overlays-nQJCQERn.js} +1 -1
- package/dist/assets/{recycle-DZmrkdVl.js → recycle-CWMxz1Q3.js} +1 -1
- package/dist/assets/remoteEntry-BNS8ga8f.js +1 -0
- package/dist/assets/{scan-eye-B5rZ7zGT.js → scan-eye-t_4fVxI4.js} +1 -1
- package/dist/assets/{scissors-DwAZ3q7Q.js → scissors-DL5nVl1a.js} +1 -1
- package/dist/assets/{search-x-B-oRfcQP.js → search-x-CbPl9Xi3.js} +1 -1
- package/dist/assets/{send-ZjS8CwTz.js → send-BQl_zLK4.js} +1 -1
- package/dist/assets/{settings-2-5VaXifkQ.js → settings-2-7F6aVC_u.js} +1 -1
- package/dist/assets/{sigma-Do3DgNJ1.js → sigma-kEBBYTCa.js} +1 -1
- package/dist/assets/{speaker-TZvdN1cH.js → speaker-CkI0pe60.js} +1 -1
- package/dist/assets/{src-DX_JbsFG.js → src-DzfpPZrG.js} +10 -10
- package/dist/assets/step-inspector-model-HSCaPOVt.js +1 -0
- package/dist/assets/{table-2-Dqcebk-T.js → table-2-Cukv2oib.js} +1 -1
- package/dist/assets/{timer-reset-y8kv-UE8.js → timer-reset-hysIbh2s.js} +1 -1
- package/dist/assets/{ungroup-Cy8_Al2f.js → ungroup-D4Nql8ck.js} +1 -1
- package/dist/assets/{unlink-Db_gKOzw.js → unlink-DNVVxO6S.js} +1 -1
- package/dist/assets/{usb-B0VgCbP1.js → usb-DNmhv4AW.js} +1 -1
- package/dist/assets/{use-scenes-feed-BX2r5CSu.js → use-scenes-feed-BUQTm5ig.js} +1 -1
- package/dist/assets/{use-stationary-objects-B6gvXwen.js → use-stationary-objects-B4f1cFoy.js} +1 -1
- package/dist/assets/useEventInvalidation-CdWcoivb.js +1 -0
- package/dist/assets/{useNodeUrlSelection-cuUDxmhY.js → useNodeUrlSelection-BKSL_pMO.js} +1 -1
- package/dist/assets/user-round-I0Uty2ao.js +1 -0
- package/dist/assets/{user-x-CgHtIGhf.js → user-x-DGZKKLZG.js} +1 -1
- package/dist/assets/{video-DYC_GW17.js → video-DEeXGFHo.js} +1 -1
- package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-HxO7Tlud.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-CF1E4s_B.js} +2 -2
- package/dist/index.html +10 -10
- package/dist/server/addon.js +17 -2
- package/package.json +1 -1
- package/dist/assets/Addons-kSjXhQba.js +0 -5
- package/dist/assets/AiProfiles-C7RRiZ-Y.js +0 -3
- package/dist/assets/BrokerForm-pprTt8-v.js +0 -1
- package/dist/assets/Cluster-dhAPfJv6.js +0 -1
- package/dist/assets/Data-CPdzZaQ6.js +0 -2
- package/dist/assets/History-CTyWzxbJ.js +0 -1
- package/dist/assets/IntegrationDetail-Bj2o8Gyl.js +0 -1
- package/dist/assets/IntegrationHub-D-BT1i-q.js +0 -1
- package/dist/assets/Integrations-CKR4hJyA.js +0 -1
- package/dist/assets/Integrations-Dn8CFiTq.js +0 -1
- package/dist/assets/Locations-BYPw-b2Z.js +0 -3
- package/dist/assets/MyAccess-VP7h9O7-.js +0 -2
- package/dist/assets/Network-Bla9sJtL.js +0 -1
- package/dist/assets/Recordings-BDCMjtre.js +0 -1
- package/dist/assets/ScanNetworkModal-B59m4nHs.js +0 -1
- package/dist/assets/SessionsList-CSJK-M1F.js +0 -2
- package/dist/assets/circle-slash-bfqjP0sy.js +0 -1
- package/dist/assets/client-CgAb3Nw-.js +0 -358
- package/dist/assets/crop-DYBE_kWG.js +0 -1
- package/dist/assets/device-picker-model-DF4u2b9z.js +0 -1
- package/dist/assets/dist-BJ8kdWPh.js +0 -358
- package/dist/assets/i18n-Zscg3Dkf.js +0 -1
- package/dist/assets/index-D4id__eL.css +0 -2
- package/dist/assets/mount-DF4u2b9z.js +0 -1
- package/dist/assets/remoteEntry-HwnLQWmW.js +0 -1
- package/dist/assets/step-inspector-model-Cge4IaLZ.js +0 -1
- package/dist/assets/useEventInvalidation-DF4u2b9z.js +0 -1
- package/dist/assets/user-round-84cYKzbg.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{C as e,J as t,K as n,R as r,S as i,V as a,Y as o,a as s,et as c,o as l,t as u,x as d}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{An as f,In as p,Lt as m,Sn as h,ht as g,kn as _,ot as v,rr as y,sr as b,un as x}from"./player-overlays-nQJCQERn.js";import{$r as S,$t as ee,Hi as C}from"./client-CdHPjeIs.js";import{h as w,s as T}from"./video-DEeXGFHo.js";import{t as E}from"./log-in-YSzSSnpb.js";import{t as D}from"./monitor-smartphone-BYEnK_6t.js";import{t as te}from"./recycle-CWMxz1Q3.js";import{$r as O,Dt as k,Ga as A,Or as ne,Ot as j,Sa as M,Sn as re,Zr as ie,ft as ae,ki as N,mt as oe,oi as P,or as F,va as I,wa as se,ya as L}from"./src-DzfpPZrG.js";import{t as R}from"./i18n-Dgilx0WT.js";import{t as z}from"./useTranslation-BJr-n0es.js";import{S as B,g as V,gr as H,i as U,mr as W}from"./index-4kmzPYxW.js";import{t as G}from"./AdminSectionedPage-ytDsnoAA.js";import{n as K,r as q,t as J}from"./BrokerEditorDialog-CTEagRft.js";import{t as ce}from"./NodeAddonsSettingsPanel-ivvFi7qU.js";import{n as Y,r as X,t as le}from"./IntegrationHub-BqWPAkYu.js";c();var Z={connected:`success`,connecting:`warning`,disconnected:`default`,"auth-failed":`danger`,unreachable:`danger`,error:`danger`};function Q({status:e}){return i(P,{variant:Z[e],className:`text-[10px]`,children:e})}function ue({broker:t,interactiveConnectPath:n,interactiveDisconnectPath:r,kindLabel:a,onEdit:s}){let{t:c}=z(),u=l(),d=ie(),[f,h]=o(null),_=se({onSuccess:e=>h(e.ok?{ok:!0}:{ok:!1,error:e.error}),onError:e=>h({ok:!1,error:e instanceof Error?e.message:String(e)})}),v=M({onSuccess:()=>{u.invalidateQueries({queryKey:[[`broker`,`list`]]})}}),y=async()=>{await d({title:c(`brokers.brokerManager.deleteBroker`,`Delete broker`),message:c(`brokers.brokerManager.deleteBrokerIntegrationsThatDepend`,`Delete broker "{{name}}"? Integrations that depend on it will stop working.`,{name:t.name}),confirmLabel:c(`common.delete`,`Delete`),variant:`danger`})&&v.mutate({id:t.id,addonId:t.addonId})},x=n!==void 0&&n.length>0&&t.status!==`connected`,S=r!==void 0&&r.length>0&&t.status===`connected`;return e(`tr`,{className:`border-b border-border last:border-0`,children:[i(`td`,{className:`px-3 py-2 text-xs text-foreground font-medium`,children:t.name}),i(`td`,{className:`px-3 py-2 text-xs text-foreground-subtle`,children:a}),e(`td`,{className:`px-3 py-2`,children:[i(Q,{status:t.status}),f&&i(`span`,{className:`ml-2 text-[10px] ${f.ok?`text-success`:`text-danger`}`,children:f.ok?`OK`:f.error??c(`common.failedWord`)})]}),i(`td`,{className:`px-3 py-2`,children:e(`div`,{className:`flex items-center justify-end gap-1.5`,children:[x&&e(O,{variant:`primary`,size:`sm`,onClick:()=>{V(n,t.id,()=>{u.invalidateQueries({queryKey:[[`broker`,`list`]]})})},title:c(`brokers.brokerManager.signInOpensAPopup`,`Sign in — opens a popup that closes when done`),children:[i(E,{className:`h-3 w-3`}),` `,c(`brokers.brokerManager.signIn`)]}),S&&e(O,{variant:`outline`,size:`sm`,onClick:()=>{V(r,t.id,()=>{u.invalidateQueries({queryKey:[[`broker`,`list`]]})})},title:c(`brokers.brokerManager.signOutClearsTheLinked`,`Sign out — clears the linked Google account on this broker`),children:[i(T,{className:`h-3 w-3`}),` `,c(`brokers.brokerManager.signOut`)]}),e(O,{variant:`outline`,size:`sm`,onClick:()=>_.mutate({id:t.id,addonId:t.addonId}),disabled:_.isPending,title:c(`brokers.brokerManager.testConnection`,`Test connection`),children:[_.isPending?i(b,{className:`h-3 w-3 animate-spin`}):i(g,{className:`h-3 w-3`}),c(`brokers.brokerManager.test`,`Test`)]}),e(O,{variant:`outline`,size:`sm`,onClick:()=>s(t),title:c(`common.edit`,`Edit`),children:[i(p,{className:`h-3 w-3`}),` `,c(`common.edit`)]}),e(O,{variant:`outline`,size:`sm`,className:`border-danger/40 text-danger hover:bg-danger/10`,onClick:()=>{y()},disabled:v.isPending,title:c(`common.delete`,`Delete`),children:[v.isPending?i(b,{className:`h-3 w-3 animate-spin`}):i(m,{className:`h-3 w-3`}),c(`common.delete`,`Delete`)]})]})})]})}function de({addonId:t}={}){let{t:r}=z(),a=L({}),s=n(()=>K(a.data).filter(e=>t===void 0||e.addonId===t),[a.data,t]),[c,l]=o(!1),[u,d]=o(null),{options:p}=q(t===void 0?{}:{addonId:t}),m=n(()=>new Map(p.map(e=>[e.kind,e.label])),[p]),h=n(()=>{let e=new Map;for(let t of p)e.has(t.kind)||e.set(t.kind,{...t.interactiveConnectPath===void 0?{}:{connect:t.interactiveConnectPath},...t.interactiveDisconnectPath===void 0?{}:{disconnect:t.interactiveDisconnectPath}});return e},[p]);return e(`div`,{className:`space-y-3`,children:[i(`div`,{className:`flex items-center justify-end`,children:e(O,{variant:`primary`,size:`sm`,onClick:()=>l(!0),disabled:p.length===0,title:p.length===0?r(`brokers.brokerManager.noBrokerProvidersAvailable`,`No broker providers available`):void 0,children:[i(f,{className:`h-3.5 w-3.5`}),` `,r(`brokers.brokerManager.addBroker`)]})}),i(`div`,{className:`rounded-lg border border-border bg-surface overflow-x-auto`,children:e(`table`,{className:`w-full min-w-[36rem] border-collapse`,children:[i(`thead`,{children:e(`tr`,{className:`border-b border-border bg-background/50`,children:[i(`th`,{className:`px-3 py-2 text-left text-[10px] font-semibold uppercase tracking-wider text-foreground-subtle`,children:r(`brokers.brokerManager.name`,`Name`)}),i(`th`,{className:`px-3 py-2 text-left text-[10px] font-semibold uppercase tracking-wider text-foreground-subtle`,children:r(`brokers.brokerManager.kind`,`Kind`)}),i(`th`,{className:`px-3 py-2 text-left text-[10px] font-semibold uppercase tracking-wider text-foreground-subtle`,children:r(`brokers.brokerManager.status`,`Status`)}),i(`th`,{className:`px-3 py-2 text-right text-[10px] font-semibold uppercase tracking-wider text-foreground-subtle`,children:r(`brokers.brokerManager.actions`,`Actions`)})]})}),e(`tbody`,{children:[a.isLoading&&i(`tr`,{children:e(`td`,{colSpan:4,className:`px-3 py-6 text-center text-xs text-foreground-subtle`,children:[i(b,{className:`inline h-4 w-4 animate-spin`}),` `,r(`brokers.brokerManager.loadingBrokers`)]})}),a.isError&&i(`tr`,{children:e(`td`,{colSpan:4,className:`px-3 py-4 text-center text-xs text-danger`,children:[r(`brokers.brokerManager.failedToLoadBrokers`,`Failed to load brokers:`),` `,a.error instanceof Error?a.error.message:r(`brokers.brokerManager.unknownError`,`Unknown error`)]})}),!a.isLoading&&!a.isError&&s.length===0&&i(`tr`,{children:i(`td`,{colSpan:4,className:`px-3 py-6 text-center text-xs text-foreground-subtle`,children:r(`brokers.brokerManager.noBrokersRegisteredYetAdd`,`No brokers registered yet. Add one to publish device events for downstream automations.`)})}),s.map(e=>{let t=h.get(e.kind);return i(ue,{broker:e,...t?.connect===void 0?{}:{interactiveConnectPath:t.connect},...t?.disconnect===void 0?{}:{interactiveDisconnectPath:t.disconnect},kindLabel:m.get(e.kind)??e.kind,onEdit:d},e.id)})]})]})}),c&&i(J,{...t===void 0?{}:{addonId:t},onClose:()=>l(!1),onSaved:()=>l(!1)}),u&&i(J,{broker:u,onClose:()=>d(null),onSaved:()=>d(null)})]})}function fe(e){if(typeof e==`string`)return e;if(typeof e==`object`&&e){let t=e.name;if(typeof t==`string`)return t}return null}function pe(e){let t=e,n=t?.manifest;if(n?.id===void 0)return null;let r=(n.capabilities??[]).map(fe).filter(e=>e!==null);return{addonId:n.id,displayName:n.packageDisplayName??n.name??n.id,capNames:r,processState:t?.process?.state??null}}function me(e,t){return Object.entries(e).filter(([,e])=>e===t).map(([e])=>e)}function he(e,t){return t.find(t=>e.capNames.includes(t))??null}function ge(e){switch(e){case`running`:return{state:`ok`,label:R.t(`helpers.connectivityModel.running`)};case`crashed`:case`failed`:return{state:`error`,label:e};case`stopped`:case`disabled`:return{state:`off`,label:R.t(`helpers.connectivityModel.stopped`)};default:return{state:`unknown`,label:e??R.t(`common.unknownWord`)}}}c();var _e=[`wasteCollections`,`listSources`],ve=[`wasteCollections`,`listCountries`];function ye(e){return e instanceof Error?e.message:String(e)}function be(e){return typeof e!=`object`||!e?!1:Array.isArray(Reflect.get(e,`sections`))}function xe(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(typeof n!=`object`||!n)continue;let e=Reflect.get(n,`id`),r=Reflect.get(n,`label`),i=Reflect.get(n,`module`);if(typeof e!=`string`||typeof r!=`string`||typeof i!=`string`)continue;let a=Reflect.get(n,`enabled`),o=Reflect.get(n,`formValues`),s=Reflect.get(n,`serviceId`),c=Reflect.get(n,`countryId`);t.push({id:e,label:r,module:i,enabled:typeof a==`boolean`?a:!0,formValues:typeof o==`object`&&o&&!Array.isArray(o)?o:void 0,serviceId:typeof s==`string`?s:void 0,countryId:typeof c==`string`?c:void 0})}return t}function Se(e){return Array.isArray(e)?e.flatMap(e=>{if(typeof e!=`object`||!e)return[];let t=Reflect.get(e,`id`),n=Reflect.get(e,`label`);return typeof t!=`string`||typeof n!=`string`?[]:[{id:t,label:n}]}):[]}function Ce(e){return Array.isArray(e)?e.flatMap(e=>{if(typeof e!=`object`||!e)return[];let t=Reflect.get(e,`id`),n=Reflect.get(e,`label`),r=Reflect.get(e,`module`);if(typeof t!=`string`||typeof n!=`string`||typeof r!=`string`)return[];let i=Reflect.get(e,`title`);return[{id:t,label:n,title:typeof i==`string`&&i.length>0?i:n,module:r}]}):[]}function we(e,t,n){return{sections:[{id:`picker`,title:R.t(`system.wasteSettingsSources.countryService`,`Country & service`),columns:2,fields:[{type:`select`,key:`countryId`,label:R.t(`system.wasteSettingsSources.country`,`Country`),options:[{value:``,label:R.t(`system.wasteSettingsSources.selectCountry`,`Select country…`)},...e.map(e=>({value:e.id,label:e.label}))]},{type:`select`,key:`serviceId`,label:R.t(`system.wasteSettingsSources.service`,`Service`),options:[{value:``,label:n===``?R.t(`system.wasteSettingsSources.pickACountryFirst`,`Pick a country first`):R.t(`system.wasteSettingsSources.selectService`,`Select service…`)},...t.map(e=>({value:e.id,label:e.label}))]}]}]}}function Te({addonId:c,capName:p}){let{t:h}=z(),g=v(),_=l(),y=ie(),b=ae({editKey:`wasteEdit`,newKey:`wasteNew`}),[x,S]=o(!1),[ee,C]=o(null),[w,T]=o({countryId:``,serviceId:``}),[E,D]=o({label:h(`system.wasteSettingsSources.newSource`,`New source`),enabled:!0}),k=t(null),A=typeof w.countryId==`string`?w.countryId:``,j=typeof w.serviceId==`string`?w.serviceId:``,M=r((e,t)=>g.trpcClient.addons.custom.mutate({addonId:c,action:e,input:t}),[c,g]),N=s({queryKey:[..._e,c],queryFn:async()=>xe(await M(`listSources`,{}))}),I=s({queryKey:[...ve,c],queryFn:async()=>Se(await M(`listCountries`,{}))}),se=s({queryKey:[`wasteCollections`,`listServices`,c,A],enabled:A!==``,queryFn:async()=>Ce(await M(`listServices`,{countryId:A}))}),L=s({queryKey:[`wasteCollections`,`serviceFormSchema`,c,j],enabled:j!==``,queryFn:async()=>M(`serviceFormSchema`,{serviceId:j})}),R=N.data??[],B=I.data??[],V=se.data??[],H=be(L.data)?L.data:void 0,U=n(()=>we(B,A===``?[]:V,A),[B,V,A]),W=b.state,G=W.mode===`edit`?R.find(e=>e.id===W.id)??null:null;a(()=>{if(b.state.mode===`edit`&&G!==null){let e=`edit:${G.id}`;if(k.current===e)return;k.current=e,C(null),T({countryId:G.countryId??``,serviceId:G.serviceId??``}),D(G.formValues===void 0?{label:G.label,enabled:G.enabled}:{...G.formValues});return}if(b.state.mode===`new`){if(k.current===`new`)return;k.current=`new`,C(null),T({countryId:``,serviceId:``}),D({label:h(`system.wasteSettingsSources.newSource`,`New source`),enabled:!0})}},[G,b.state]),a(()=>{if(b.state.mode!==`new`||j===``)return;let e=V.find(e=>e.id===j);e&&D(t=>{let n=t.label;return typeof n==`string`&&n!==``&&n!==`New source`?t:{...t,label:e.title}})},[b.state.mode,j,V]);let K=r(e=>{T(t=>{let n=typeof e.countryId==`string`?e.countryId:``;return n===(typeof t.countryId==`string`?t.countryId:``)?e:{countryId:n,serviceId:``}})},[]),q=r(async()=>{await _.invalidateQueries({queryKey:_e})},[_]),J=u({mutationFn:async e=>M(`deleteSource`,{id:e}),onSuccess:async()=>q()}),Y=r(async e=>{await y({title:h(`system.wasteSettingsSources.deleteWasteSource`,`Delete waste source?`),message:h(`system.wasteSettingsSources.removeItsCalendarUnderSystem`,`Remove “{{label}}” ({{id}}). Its calendar under System → Calendars is dropped.`,{label:e.label,id:e.id}),confirmLabel:h(`common.delete`,`Delete`),cancelLabel:h(`common.cancel`,`Cancel`),variant:`danger`})&&(await J.mutateAsync(e.id),b.state.mode===`edit`&&b.state.id===e.id&&(b.close(),k.current=null))},[y,J,b,h]),X=r(async()=>{let e=E.label,t=typeof e==`string`&&e.trim()!==``?e.trim():``;if(t===``){C(`Label is required.`);return}if(j===``){C(`Pick a country and a service.`);return}let n=b.state.mode===`new`,r=G?.id;if(!n&&(r===void 0||r===``)){C(`That source is no longer available.`);return}let i=E.enabled,a={...E};delete a.label,delete a.enabled,S(!0),C(null);try{n?await M(`createSource`,{label:t,serviceId:j,args:a,enabled:typeof i==`boolean`?i:!0}):r!==void 0&&await M(`updateSource`,{id:r,label:t,serviceId:j,args:a,enabled:typeof i==`boolean`?i:!0}),await q(),b.close(),k.current=null}catch(e){C(ye(e))}finally{S(!1)}},[M,G,b,E,q,j]),le=n(()=>[{key:`label`,header:h(`system.wasteSettingsSources.label`,`Label`),sortValue:e=>e.label,render:e=>i(`span`,{className:`text-sm text-foreground`,children:e.label})},{key:`module`,header:h(`system.wasteSettingsSources.module`,`Module`),sortValue:e=>e.module,render:e=>i(`span`,{className:`font-mono text-xs text-foreground-muted`,children:e.module})},{key:`enabled`,header:h(`system.wasteSettingsSources.enabled`,`Enabled`),sortValue:e=>+!!e.enabled,render:e=>i(P,{variant:e.enabled?`success`:`default`,children:e.enabled?h(`system.wasteSettingsSources.on`,`On`):h(`system.wasteSettingsSources.off`,`Off`)})},{key:`actions`,header:``,notSortableReason:`actions`,render:e=>i(O,{type:`button`,size:`sm`,variant:`ghost`,"aria-label":h(`system.wasteSettingsSources.delete`,`Delete {{label}}`,{label:e.label}),"data-testid":`waste-source-delete-${e.id}`,onClick:t=>{t.stopPropagation(),Y(e)},children:i(m,{className:`h-3.5 w-3.5 text-danger`})})}],[Y,h]),Z=b.state.mode===`new`,Q=Z||G!==null,ue=`${j}:${Z?`new`:G?.id??`closed`}`;return e(`div`,{className:`flex min-h-0 flex-col gap-4`,"data-testid":`waste-settings-sources`,children:[e(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[i(`p`,{className:`text-sm text-foreground-muted`,children:h(`system.wasteSettingsSources.pickACountryAndA`,`Pick a country and a service — configuration fields come from that HACS source.`)}),e(O,{type:`button`,size:`sm`,"data-testid":`waste-sources-add`,onClick:()=>b.openNew(),children:[i(f,{className:`h-3.5 w-3.5`}),h(`system.wasteSettingsSources.addSource`,`Add source`)]})]}),N.isError?i(`p`,{className:`text-sm text-danger`,children:h(`system.wasteSettingsSources.couldNotLoadSources`,`Could not load sources.`)}):null,N.isPending?i(ne,{className:`h-32 w-full`}):i(re,{columns:le,rows:R,rowKey:e=>e.id,pageSize:25,emptyMessage:h(`system.wasteSettingsSources.noWasteSourcesYetAdd`,`No waste sources yet. Add one to register a municipal service.`),onRowClick:e=>b.openEdit(e.id),defaultSort:{columnKey:`label`,dir:`asc`}}),i(oe,{open:Q,onClose:()=>{b.close(),C(null),k.current=null},title:Z?h(`system.wasteSettingsSources.addWasteSource`,`Add waste source`):h(`system.wasteSettingsSources.edit`,`Edit {{value1}}`,{value1:G?.label??`source`}),icon:te,width:`xl`,testId:`waste-source-editor`,error:ee,footer:i(O,{type:`button`,size:`sm`,disabled:x||j===``,onClick:()=>void X(),children:x?h(`system.wasteSettingsSources.saving`,`Saving…`):h(`common.save`,`Save`)}),children:Q?e(d,{children:[i(`div`,{"data-testid":`waste-country-service`,children:i(F,{schema:U,values:w,onChange:K},`picker:${A}:${V.length}`)}),j!==``&&H!==void 0?i(F,{schema:H,values:E,onChange:D,bare:!0},ue):j!==``&&L.isPending?i(`p`,{className:`text-sm text-foreground-muted`,children:h(`system.wasteSettingsSources.loadingFields`,`Loading fields…`)}):i(`p`,{className:`text-sm text-foreground-muted`,children:h(`system.wasteSettingsSources.chooseACountryAndService`,`Choose a country and service to see the required fields.`)})]}):null}),i(ce,{nodeId:`hub`,addonIds:[c],level:`global`,capability:p,hideSectionChrome:!0})]})}c();var $=1e4,Ee={"device-export":`exporters`,exporters:`exporters`,email:`email`,broker:`brokers`,brokers:`brokers`,"message-brokers":`brokers`,calendar:`calendars`,calendars:`calendars`,"calendar-source":`calendars`},De=[{sectionId:`exporters`,kind:`device-export`,labelKey:`system.connectivity.exporters`,icon:x,installLabelKey:`system.connectivity.exportersInstall`,emptyTitleKey:`system.connectivity.exportersEmptyTitle`,emptyDescriptionKey:`system.connectivity.exportersEmptyDescription`},{sectionId:`email`,kind:`email`,labelKey:`system.connectivity.email`,icon:y,installLabelKey:`system.connectivity.emailInstall`,emptyTitleKey:`system.connectivity.emailEmptyTitle`,emptyDescriptionKey:`system.connectivity.emailEmptyDescription`},{sectionId:`brokers`,kind:`broker`,labelKey:`system.connectivity.brokers`,icon:h,installLabelKey:`system.connectivity.brokersInstall`,emptyTitleKey:`system.connectivity.brokersEmptyTitle`,emptyDescriptionKey:`system.connectivity.brokersEmptyDescription`},{sectionId:`calendars`,kind:`calendar`,labelKey:`system.connectivity.calendars`,icon:w,installLabelKey:`system.connectivity.calendarsInstall`,emptyTitleKey:`system.connectivity.calendarsEmptyTitle`,emptyDescriptionKey:`system.connectivity.calendarsEmptyDescription`}];function Oe(t,n,r,a){let o=me(ee,t.kind),s=n.flatMap(n=>{let a=he(n,o);if(a===null)return[];let s=ge(n.processState);return[{id:n.addonId,name:n.displayName,fallbackIcon:t.icon,state:s.state,stateLabel:s.label,render:()=>i(Y,{addonId:n.addonId,displayName:n.displayName,capName:a,isActive:n.processState===`running`,badges:e(d,{children:[i(Me,{processState:n.processState}),i(Ne,{kind:t.kind,addonId:n.addonId})]}),lead:t.kind===`device-export`?i(j,{addonId:n.addonId}):void 0,panels:je(t.kind,n.addonId,e=>r(`/devices/${e}`)),settingsContent:n.addonId===`waste-collections`?i(Te,{addonId:n.addonId,capName:a}):void 0})}]});return{id:t.sectionId,label:a(t.labelKey),entries:s,install:{capability:o[0]??t.kind,label:a(t.installLabelKey)}}}function ke({descriptor:e,rows:t,isLoading:r}){let{t:a}=z(),o=W(),s=n(()=>Oe(e,t,o,a),[e,t,o,a]);return i(le,{embedded:!0,icon:e.icon,title:a(e.labelKey),subtitle:null,groups:[s],isLoading:r,emptyTitle:a(e.emptyTitleKey),emptyDescription:a(e.emptyDescriptionKey)})}function Ae(){let{t:e}=z(),t=N(void 0,{refetchInterval:$}),[r,o]=H(),s=B(`/system/integrations`,{t:e,isAdmin:!0})??{icon:_,title:e(`admin.system.integrations.connectivity`,`Connectivity`)};a(()=>{let e=r.get(`tab`);if(e===null)return;let t=Ee[e];t===void 0||t===e||o(e=>{let n=new URLSearchParams(e);return n.set(`tab`,t),n},{replace:!0})},[r,o]);let c=n(()=>(t.data??[]).map(pe).filter(e=>e!==null),[t.data]),l=n(()=>De.map(n=>({id:n.sectionId,label:e(n.labelKey),ownedParams:U,content:i(ke,{descriptor:n,rows:c,isLoading:t.isLoading})})),[t.isLoading,c,e]);return i(G,{icon:s.icon,title:s.title,subtitle:e(`admin.system.integrations.externalSystemsThisHubTalks`,`External systems this hub talks to — exporters, email, brokers and calendar sources.`),defaultSection:`exporters`,sectionsLabel:`Connectivity sections`,sections:l})}function je(e,t,n){return e===`device-export`?[{id:`devices`,title:R.t(`admin.system.integrations.devices`,`Devices`),icon:D,placement:`end`,content:i(k,{addonId:t,onOpenDevice:n,showSetup:!1})}]:e===`broker`?[{id:`connections`,title:R.t(`admin.system.integrations.connections`,`Connections`),icon:h,content:i(de,{addonId:t})}]:[]}function Me({processState:e}){let{state:t,label:n}=ge(e);return i(P,{variant:t===`ok`?`success`:t===`error`?`danger`:`default`,className:`${X} capitalize`,children:n})}function Ne({kind:e,addonId:t}){return e===`broker`?i(Pe,{addonId:t}):e===`device-export`?i(Fe,{addonId:t}):null}function Pe({addonId:e}){let{t}=z(),{data:n}=I({addonId:e},{refetchInterval:$,retry:!1}),r=C.safeParse(n);if(!r.success)return null;let{brokerCount:a,connectedCount:o}=r.data;return i(P,{variant:`info`,className:X,children:o>0?t(`system.connectivity.connectionsConnected`,{count:a,connected:o}):t(`system.connectivity.connections`,{count:a})})}function Fe({addonId:e}){let{t}=z(),{data:n}=A({addonId:e},{refetchInterval:$,retry:!1}),r=S.safeParse(n);if(!r.success)return null;let{linkState:a,exposedDeviceCount:o}=r.data;return i(P,{variant:a===`linked`?`success`:a===`error`?`danger`:`default`,className:X,children:t(`admin.system.integrations.exposed`,`{{linkState}} · {{exposedDeviceCount}} exposed`,{linkState:a,exposedDeviceCount:o})})}export{Ae as IntegrationsPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{C as e,J as t,K as n,R as r,S as i,V as a,Y as o,et as s,o as c,x as l}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{An as u,Ci as d,Oi as f,Si as p,bi as m,dn as h,dt as g,kn as _,ot as v,pn as y,pr as ee,sr as b,wn as x,xn as te}from"./player-overlays-nQJCQERn.js";import{t as ne}from"./table-2-Cukv2oib.js";import{$r as S,At as C,F as re,Mt as w,Qa as ie,Tr as ae,_d as T,_s as oe,at as E,gi as D,kt as O,ld as k,ms as se,r as A,ud as ce,uo as j,xo as le,ys as ue}from"./src-DzfpPZrG.js";import{t as M}from"./i18n-Dgilx0WT.js";import{t as N}from"./useTranslation-BJr-n0es.js";import{cr as P,gr as F,mr as de,pr as fe}from"./index-4kmzPYxW.js";import{t as I}from"./AdminPage-D6Yva5zf.js";import"./useEventInvalidation-CdWcoivb.js";import{t as L}from"./device-integration-icon-Dg_7SOuH.js";import{i as pe,n as me,r as R,t as he}from"./ScanNetworkModal-81xkyJSk.js";s();function ge({rows:t,isExpanded:r,onToggleExpand:a,onOpen:s,renderExpanded:c,searchPlaceholder:l,emptyLabel:u}){let[d,f]=o(``),p=n(()=>{let e=d.trim().toLowerCase();return e.length===0?t:t.filter(t=>`${t.name} ${t.addonId}`.toLowerCase().includes(e))},[d,t]);return e(`div`,{className:`space-y-3`,children:[e(`div`,{className:`relative`,children:[i(y,{className:`pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-foreground-subtle`,"aria-hidden":!0}),i(k,{type:`search`,value:d,onChange:e=>f(e.target.value),placeholder:l,"aria-label":l,className:`pl-8`})]}),p.length===0?i(`p`,{className:`py-8 text-center text-xs text-foreground-subtle`,children:u}):i(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-2 sm:gap-3 lg:grid-cols-3`,children:p.map(e=>i(_e,{integration:e,expanded:r(e),onToggleExpand:a,onOpen:s,renderExpanded:c},e.id))})]})}function _e({integration:t,expanded:n,onToggleExpand:r,onOpen:a,renderExpanded:o}){return e(`article`,{"data-testid":`integration-card-${t.id}`,className:T(`flex min-w-0 flex-col gap-2 overflow-x-clip rounded-lg border border-border bg-surface p-3`,n&&`sm:col-span-2 lg:col-span-3`),children:[i(ve,{integration:t,expanded:n,onToggleExpand:r,onOpen:a}),n?i(`div`,{className:`min-w-0`,children:o(t)}):null]})}function ve({integration:t,expanded:n,onToggleExpand:r,onOpen:a}){let{t:o}=N(),s=n?o(`integrations.integrationColumns.collapse`,`Collapse`):o(`integrations.integrationColumns.expand`,`Expand`);return e(`div`,{className:`relative flex min-w-0 items-stretch gap-3`,children:[i(S,{type:`button`,variant:`ghost`,"aria-label":o(`integrations.openNamed`,{name:t.name,defaultValue:`Open {{name}}`}),onClick:()=>a(t),className:`absolute inset-0 z-0 h-auto w-auto rounded-lg p-0 focus-visible:ring-2 focus-visible:ring-primary`}),i(z,{integration:t}),e(`div`,{className:`pointer-events-none relative z-10 flex min-w-0 flex-1 flex-col items-start gap-1.5`,children:[i(E,{status:t.status,className:`shrink-0`}),i(`p`,{className:`text-[11px] text-foreground-muted`,children:o(`integrations.integrationColumns.deviceCount`,{count:t.deviceCount})}),i(`div`,{className:`pointer-events-auto mt-auto self-end`,children:i(ce,{type:`button`,variant:`ghost`,size:`sm`,icon:n?p:m,"aria-label":s,"aria-expanded":n,onClick:e=>V(e,t.addonId,r)})})]})]})}function z({integration:t}){return e(`div`,{className:`pointer-events-none relative z-10 flex w-28 shrink-0 flex-col items-center gap-1 lg:w-24`,children:[i(P,{type:t.addonId,size:`xl`}),i(`p`,{className:`w-full text-center text-xs font-semibold text-foreground`,children:t.name}),i(B,{addonId:t.addonId})]})}function B({addonId:t}){return i(`p`,{className:`w-full text-center text-[10px] leading-tight text-foreground-subtle`,children:t.split(`-`).map((t,n)=>e(`span`,{children:[n>0?e(l,{children:[`-`,i(`wbr`,{})]}):null,t]},`${t}-${String(n)}`))})}function V(e,t,n){e.stopPropagation(),n(t)}s();var H=`camstack.admin.integrations.view`;function U(e){return e===`table`||e===`grid`}function W(){try{return typeof window>`u`?null:window.localStorage}catch{return null}}function G(e=W()){if(e===null)return`table`;try{let t=e.getItem(H);return U(t)?t:`table`}catch{return`table`}}function K(e,t=W()){if(t!==null)try{t.setItem(H,e)}catch{}}function ye(){let[e,t]=o(()=>G());return[e,r(e=>{t(e),K(e)},[])]}s();function q(e=!0){a(()=>{if(!e)return;let t=document.body.style.overflow;return document.body.style.overflow=`hidden`,()=>{document.body.style.overflow=t}},[e])}s();function be(e,t){let[n,r]=o(!1);return a(()=>{if(!e){r(!1);return}r(!1);let n=setTimeout(()=>r(!0),t);return()=>clearTimeout(n)},[e,t]),n}s();function xe({providerId:t,onImport:n,onSkip:r}){let{t:s}=N(),[c,l]=o(new Set),u=j(),p=u.data,m=u.isPending||!u.data&&!u.isError;a(()=>{t&&(u.isPending||u.data||u.mutate({addonId:t}))},[t,u]);function h(e){l(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}if(m)return e(`div`,{className:`flex flex-col items-center py-12`,children:[i(`div`,{className:`h-6 w-6 animate-spin rounded-full border-2 border-primary border-t-transparent`}),i(`p`,{className:`mt-3 text-xs text-foreground-subtle`,children:s(`integrations.searchingDevices`)})]});let g=p??[];return e(`div`,{className:`space-y-4`,children:[i(`p`,{className:`text-xs text-foreground-subtle`,children:g.length>0?s(`integrations.foundDevices`,{count:g.length}):s(`integrations.noDevicesFound`)}),g.length>0&&i(`div`,{className:`space-y-1.5 max-h-64 overflow-y-auto`,children:g.map(t=>{let n=t.stableId,r=t.suggestedName??n,a=c.has(n),o=t.alreadyOnboarded===!0;return e(`button`,{onClick:()=>{o||h(n)},disabled:o,title:o?s(`integrations.alreadyAddedHint`,{defaultValue:`Already added as "{{name}}" — re-adding would overwrite its settings.`,name:t.onboardedName??r}):void 0,className:`flex w-full items-center gap-3 rounded-lg border p-3 text-left transition-colors ${o?`border-border bg-surface opacity-60 cursor-not-allowed`:a?`border-primary/40 bg-primary/5`:`border-border bg-surface hover:border-foreground-subtle/30`}`,children:[i(`div`,{className:`flex h-5 w-5 items-center justify-center rounded border flex-shrink-0 ${a&&!o?`border-primary bg-primary`:`border-border`}`,children:a&&!o&&i(d,{className:`h-3 w-3 text-primary-foreground`})}),i(f,{className:`h-3.5 w-3.5 text-foreground-subtle flex-shrink-0`}),i(`span`,{className:`text-xs font-medium text-foreground truncate`,children:r}),o&&i(`span`,{className:`ml-auto flex-shrink-0 rounded bg-surface-muted px-1.5 py-0.5 text-[10px] font-medium text-foreground-subtle`,children:s(`integrations.alreadyAdded`,{defaultValue:`Already added`})})]},n)})}),e(`div`,{className:`flex items-center justify-between pt-2`,children:[i(`button`,{onClick:r,className:`rounded-lg border border-border px-3 py-1.5 text-xs text-foreground-subtle hover:text-foreground transition-colors`,children:s(`integrations.skip`)}),g.length>0&&e(`button`,{onClick:()=>n(Array.from(c)),disabled:c.size===0,className:`rounded-lg bg-primary px-4 py-1.5 text-xs font-medium text-primary-foreground shadow-sm disabled:opacity-50`,children:[s(`integrations.importSelected`),` (`,c.size,`)`]})]})]})}var J=`(hover: none) and (pointer: coarse)`;function Y(){if(typeof window>`u`||typeof window.matchMedia!=`function`)return!0;try{return!window.matchMedia(J).matches}catch{return!0}}s();function X({onSelect:r,onClose:s,pendingAddonId:c=null}){let{t:l}=N(),u=de(),[d,f]=o(``),p=t(null),{data:m,isLoading:g}=oe();a(()=>{g||!Y()||p.current?.focus()},[g]);let _=n(()=>{let e=m??[],t=d.trim().toLowerCase();return t.length===0?e:e.filter(e=>`${e.name} ${e.description??``} ${e.addonId}`.toLowerCase().includes(t))},[m,d]);if(g)return i(`div`,{className:`grid grid-cols-2 gap-2 p-2`,children:[1,2,3,4].map(e=>i(`div`,{className:`h-24 rounded-lg bg-surface animate-pulse`},e))});let v=c!==null;return e(`div`,{className:`space-y-3`,"data-testid":`provider-picker`,children:[e(`div`,{className:`relative`,children:[i(y,{className:`pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-foreground-subtle`,"aria-hidden":!0}),i(k,{ref:p,type:`search`,value:d,onChange:e=>f(e.target.value),placeholder:l(`integrations.searchProviders`,`Search integrations…`),className:`pl-8`,"data-testid":`provider-picker-search`,"aria-label":l(`integrations.searchProviders`,`Search integrations…`)})]}),i(`div`,{className:`grid grid-cols-2 gap-2`,children:_.map(t=>{let n=t.instanceMode===`unique`&&t.existingInstances.length>0,a=c===t.addonId,o=v;return e(`button`,{type:`button`,disabled:o,"data-testid":`provider-pick-${t.addonId}`,onClick:()=>{if(!o)if(n){let e=t.existingInstances[0].id;s(),u(`/integrations/${e}`)}else r(t.addonId,t.instanceMode,t.discoveryMode,t.name,t.kind,t.brokerKind,t.mode,t.canTest)},className:`flex flex-col items-center gap-1.5 rounded-lg border border-border bg-surface px-3 py-3 text-center text-xs hover:border-primary/50 hover:bg-surface-hover transition-colors disabled:opacity-60 disabled:cursor-not-allowed disabled:hover:border-border`,children:[t.iconUrl?i(`div`,{className:`flex h-9 w-9 items-center justify-center rounded-lg flex-shrink-0`,style:{backgroundColor:`${t.color}15`},children:i(`img`,{src:t.iconUrl,alt:``,className:`h-5 w-5`})}):i(`div`,{className:`flex h-9 w-9 items-center justify-center rounded-lg flex-shrink-0`,style:{backgroundColor:`${t.color}15`},children:i(`span`,{className:`text-sm`,style:{color:t.color},children:`◉`})}),i(`p`,{className:`w-full truncate text-xs font-semibold text-foreground`,children:t.name}),t.description?i(`p`,{className:`w-full line-clamp-2 text-[10px] text-foreground-subtle`,children:t.description}):null,a?i(b,{className:`h-4 w-4 animate-spin text-primary`}):n?e(`span`,{className:`flex items-center gap-1 text-[10px] font-medium text-foreground-subtle`,children:[i(h,{className:`h-3 w-3`}),l(`integrations.manage`)]}):null]},t.addonId)})}),_.length===0&&i(`div`,{className:`py-8 text-center text-xs text-foreground-subtle`,children:(m??[]).length===0?l(`integrations.noProviders`):l(`integrations.noProvidersMatch`,`No integrations match your search.`)})]})}s();function Se(e){let t=e=>{if(e.type===`separator`||e.type===`info`||e.type===`button`)return e;if(e.type===`group`)return{...e,fields:e.fields.map(e=>t(e))};let{value:n,...r}=e;return r};return{...e.tabs?{tabs:e.tabs}:{},sections:e.sections.map(e=>({...e,fields:e.fields.map(t)}))}}var Ce=2e4;function we({open:t,onClose:r,seed:s=null}){let{t:u}=N(),d=de(),f=c(),[p,m]=o(`picker`),[h,_]=o(null),[v,y]=o(null),[ee,x]=o(`manual`),[te,ne]=o(null),[S,C]=o(``),[re,w]=o(null),[ae,T]=o(null),[E,O]=o(!1),[k,A]=o({}),[ce,le]=o(``),ue=s?.config.host,M=s===null?``:`${s.addonId}\0${s.name}\0${typeof ue==`string`?ue:``}`;t&&s!==null&&ce!==M&&(le(M),_(s.addonId),C(s.name),A({...s.config}),m(`config`));let P=oe(void 0,{enabled:t&&s!==null}),{data:F}=D({addonId:h??``,nodeId:`hub`},{enabled:h!=null}),fe=n(()=>F?Se(F):null,[F]),I=se({onSuccess:()=>f.invalidateQueries({queryKey:[[`integrations`]]})}),L=j(),me=L.data;a(()=>{if(!t||s===null)return;let e=P.data?.find(e=>e.addonId===s.addonId);e&&(O(e.canTest),x(e.discoveryMode))},[t,s,P.data]),a(()=>{p!==`discovery`||!v||!h||L.isPending||L.data||L.mutate({addonId:h})},[p,v,h,L]);let he=ie({onSuccess:()=>f.invalidateQueries({queryKey:[[`deviceManager`]]})});function ge(e,t,n,r,i,a,o,s){if(!I.isPending){if(_(e),O(s),x(n),C(r),T(null),o===`broker`){if(!a){T(`Addon '${e}' declares mode 'broker' but no brokerKind in its manifest`);return}ne(a),m(`broker`);return}if(o===`account`){m(`config`);return}_e(e,r)}}async function _e(e,t){try{let n=await I.mutateAsync({addonId:e,name:t,settings:{}});r(),H(),d(`/integrations/${n.id}?add=1`)}catch{}}async function ve(e){if(h)try{let t=await I.mutateAsync({addonId:h,name:e.name,settings:e.config,secretKeys:[...e.secretKeys]});y(t.id),w(t.id),ee===`auto`||ee===`both`?m(`discovery`):V(t.id,{openAdd:!0})}catch{}}async function z(e){if(h)try{let t=await I.mutateAsync({addonId:h,name:S,settings:{brokerId:e}});w(t.id),y(t.id),V(t.id)}catch{}}async function B(e){if(h){for(let t of e){let e=me?.find(e=>e.stableId===t);e&&await he.mutateAsync({addonId:h,candidate:e,...re===null?{}:{integrationId:re}})}V()}}function V(e,t){let n=e??v??h;r(),H(),n&&d(t?.openAdd===!0?`/integrations/${n}?add=1`:`/integrations/${n}`)}function H(){m(`picker`),_(null),y(null),x(`manual`),ne(null),C(``),w(null),T(null),O(!1),A({}),le(``)}function U(){r(),H()}q(t);let W=I.isPending,G=be(W,Ce);if(!t)return null;let K={picker:u(`integrations.newIntegration`),config:u(`integrations.configureIntegration`),discovery:u(`integrations.importDevices`),broker:u(`integrations.connectBroker`,{defaultValue:`Connect a broker`})},ye=W?h:null,J=I.error,Y=W&&!G;return e(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center`,children:[i(`div`,{className:`absolute inset-0 bg-black/60`,onClick:Y?void 0:U}),e(`div`,{className:`relative z-10 w-full max-w-lg max-h-[calc(85dvh-2*max(env(safe-area-inset-top),env(safe-area-inset-bottom)))] rounded-xl border border-border bg-background shadow-2xl flex flex-col overflow-hidden`,children:[e(`div`,{className:`flex items-center justify-between border-b border-border px-5 py-4 flex-shrink-0`,children:[i(`h2`,{className:`text-sm font-semibold text-foreground`,children:K[p]}),i(`button`,{onClick:U,disabled:Y,className:`rounded-md p-1 text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-40 disabled:cursor-not-allowed`,children:i(g,{className:`h-4 w-4`})})]}),e(`div`,{className:`px-5 py-4 flex-1 overflow-y-auto overscroll-contain`,children:[J&&!W&&i(`div`,{className:`mb-3 rounded-lg border border-destructive/40 bg-destructive/10 px-3 py-2 text-xs text-destructive`,children:J instanceof Error?J.message:String(J)}),p===`picker`&&e(l,{children:[ae&&i(`div`,{className:`mb-3 rounded-lg border border-destructive/40 bg-destructive/10 px-3 py-2 text-xs text-destructive`,children:ae}),i(X,{onSelect:ge,onClose:U,pendingAddonId:ye})]}),p===`config`&&h&&i(R,{addonId:h,configSchema:fe??null,canTest:E,initialName:typeof k.host==`string`?S:void 0,initialConfig:{...k},onSave:ve,onBack:()=>{A({}),m(`picker`)}},M.length>0?M:h),p===`broker`&&te&&i(pe,{kind:te,onResolved:e=>{z(e)},onBack:()=>m(`picker`)}),p===`discovery`&&v&&i(xe,{providerId:v,onImport:B,onSkip:V})]}),W&&e(`div`,{className:`absolute inset-0 z-20 flex flex-col items-center justify-center gap-2 rounded-xl bg-background/85 backdrop-blur-sm px-6 text-center`,children:[i(b,{className:`h-6 w-6 animate-spin text-primary`}),i(`p`,{className:`text-xs font-medium text-foreground`,children:u(`integrations.creating`,{defaultValue:`Creating integration…`})}),!G&&i(`p`,{className:`text-[10px] text-foreground-subtle`,children:u(`integrations.creatingHint`,{defaultValue:`Waiting for the addon to restart and register`})}),G&&e(l,{children:[i(`p`,{className:`text-[10px] text-foreground-subtle max-w-xs`,children:u(`integrations.creatingOverdue`,{defaultValue:`This is taking longer than expected. The integration may already have been created — close this dialog and refresh to check.`})}),i(`button`,{onClick:U,className:`mt-1 rounded-md border border-border bg-surface px-3 py-1.5 text-[11px] font-medium text-foreground hover:bg-surface-hover transition-colors`,children:u(`integrations.closeAndRefresh`,{defaultValue:`Close`})})]})]})]})]})}function Te({integration:t,expanded:n,onToggleExpand:r}){let{t:a}=N();return e(`div`,{className:`flex items-center gap-2.5`,children:[i(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),r(t.addonId)},"aria-label":n?a(`integrations.integrationColumns.collapse`,`Collapse`):a(`integrations.integrationColumns.expand`,`Expand`),"aria-expanded":n,className:`flex h-5 w-5 flex-shrink-0 items-center justify-center rounded text-foreground-subtle transition-colors hover:bg-surface-hover hover:text-foreground`,children:i(n?p:m,{className:`h-3.5 w-3.5`})}),i(P,{type:t.addonId,size:`sm`}),e(`div`,{className:`flex min-w-0 flex-col`,children:[i(`span`,{className:`truncate text-xs font-semibold text-foreground`,children:t.name}),i(`span`,{className:`truncate text-[10px] text-foreground-subtle`,children:t.addonId})]})]})}function Ee(e){let{isExpanded:t,onToggleExpand:n}=e;return[{key:`name`,header:M.t(`integrations.integrationColumns.integration`,`Integration`),headerClassName:`w-[55%]`,cell:e=>i(Te,{integration:e,expanded:t(e),onToggleExpand:n})},{key:`devices`,header:M.t(`integrations.integrationColumns.devices`,`Devices`),headerClassName:`w-[15%]`,cellClassName:`text-[11px] text-foreground-subtle`,cell:e=>M.t(`integrations.integrationColumns.deviceCount`,{count:e.deviceCount})},{key:`status`,header:M.t(`integrations.integrationColumns.status`,`Status`),headerClassName:`w-[15%]`,cell:e=>i(E,{status:e.status})}]}s();function De(e){if(!e.enabled)return`disabled`;switch(e.processState){case`running`:return`running`;default:return`stopped`}}var Z=`expand`;function Oe(){let{t}=N(),s=de(),c=fe(),d=v(),[f]=F(),[p,m]=ye(),[h,g]=o(!1),[y,b]=o(null),S=r(()=>{b(null),g(!0)},[]),ie=r(()=>{g(!1),b(null)},[]),oe=r(e=>{D(!1),b(e),g(!0)},[]),[E,D]=o(!1);a(()=>{let e=me(c.state);e!==null&&(b(e),g(!0),s(`/integrations`,{replace:!0,state:null}))},[c.state,s]);let k=f.get(`setup`);a(()=>{k===null||k.length===0||(b({addonId:k,name:k,config:{}}),g(!0))},[k]);let se=r(()=>D(!0),[]),ce=r(()=>D(!1),[]);A([`integrations`],[`integration.enabled`,`integration.disabled`,`integration.deleted`,`provider.started`,`provider.stopped`,`addon.installed`,`addon.uninstalled`,`addon.started`,`addon.stopped`,`addon.updated`]),A([`deviceManager`],[`device.registered`,`device.unregistered`,`device.online`,`device.offline`,`device.disabled`,`device.enabled`]);let{data:j,isLoading:M,isError:P,refetch:pe}=ue(void 0),{data:R,isLoading:_e,isError:ve,refetch:z}=le({projection:`slim`}),B=n(()=>R??[],[R]),V=n(()=>j??[],[j]),H=n(()=>{let e=new Map;for(let t of B)e.set(t.id,{id:t.id,name:t.name??t.stableId??`#${String(t.id)}`});return e},[B]),U=n(()=>C(j),[j]),W=n(()=>{let e=new Map;for(let t of w(B)){let n=U(t);if(n.kind!==`resolved`)continue;let r=n.integration.id;e.set(r,(e.get(r)??0)+1)}return e},[B,U]),G=n(()=>V.map(e=>({id:e.id,addonId:e.addonId,name:e.name,enabled:e.enabled,status:De(e),deviceCount:W.get(e.id)??0})),[V,W]),K=f.get(Z),q=r(e=>{let t=new URLSearchParams(window.location.search);t.get(Z)===e?t.delete(Z):t.set(Z,e);let n=t.toString(),r=`${window.location.pathname}${n?`?${n}`:``}${window.location.hash}`;window.history.replaceState(window.history.state,``,r),window.dispatchEvent(new PopStateEvent(`popstate`))},[]),be=r(e=>s(`/integrations/${e.id}`),[s]),xe=r(e=>H.get(e)??null,[H]),J=r(e=>s(`/devices/${String(e)}`),[s]),Y=r(e=>i(O,{context:`integration-detail`,devices:B,trpc:d.trpcClient,integrationOf:U,forceIntegrationId:e.id,urlScope:`nested`,lsKey:`integrations:nested:${e.addonId}`,resolveIntegrationIcon:L,resolveParent:xe,onNavigate:J}),[B,d.trpcClient,U,xe,J]),X=r(e=>K===e.addonId,[K]),Se=n(()=>Ee({isExpanded:X,onToggleExpand:q}),[X,q]),Ce=r(e=>`${e.name} ${e.addonId}`,[]),Te=r(e=>e.addonId,[]),Oe=r(()=>{pe(),z()},[pe,z]),Q=P===!0||ve===!0,$=!Q&&(M||_e||j===void 0||R===void 0),ke=V.length>0,Ae=[{id:`table`,label:t(`integrations.viewTable`,`Table`),icon:ne},{id:`grid`,label:t(`integrations.viewGrid`,`Grid`),icon:ee}];return e(I,{icon:_,title:t(`nav.integrations`,`Integrations`),actions:e(l,{children:[i(re,{ariaLabel:t(`integrations.viewLabel`,`Layout`),value:p,onChange:m,options:Ae,testId:`integrations-view`}),i(`button`,{onClick:Oe,disabled:$,className:`flex items-center gap-1 rounded-lg border border-border bg-surface px-2.5 py-1.5 text-xs font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50`,title:t(`common.refresh`,`Refresh`),children:i(te,{className:T(`h-3.5 w-3.5`,$&&`animate-spin`)})}),e(`button`,{onClick:se,className:`flex items-center gap-1.5 rounded-lg border border-border bg-surface px-2.5 py-1.5 text-xs font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,title:t(`integrations.scanTheLocalNetworkFor`,`Scan the local network for devices`),children:[i(x,{className:`h-3.5 w-3.5`}),t(`integrations.scanNetwork`,`Scan network`)]}),e(`button`,{onClick:S,className:`flex items-center gap-1.5 rounded-lg bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground shadow-sm`,children:[i(u,{className:`h-3.5 w-3.5`}),t(`integrations.newIntegration`,`New Integration`)]})]}),children:[Q&&i(ae,{message:t(`integrations.loadFailed`,`Integrations could not be loaded.`),onRetry:Oe}),$&&i(`div`,{className:`space-y-2`,"data-testid":`integrations-pending`,children:[1,2,3].map(e=>i(`div`,{className:`h-12 rounded-lg border border-border bg-surface animate-pulse`},e))}),!Q&&!$&&!ke&&e(`div`,{className:`flex flex-col items-center py-20 text-foreground-subtle`,children:[i(`p`,{className:`text-sm`,children:t(`integrations.noIntegrationsConfigured`,`No integrations configured.`)}),i(`p`,{className:`text-xs mt-1`,children:t(`integrations.clickNewIntegrationToConnect`,`Click "New Integration" to connect cameras and devices.`)})]}),!Q&&!$&&ke&&p===`table`&&i(O,{mode:`generic`,items:G,getKey:Te,getSearchText:Ce,columns:Se,onRowClick:be,isExpanded:X,renderExpanded:Y,searchPlaceholder:t(`integrations.search`,{defaultValue:`Search integrations…`}),emptyLabel:t(`integrations.empty`,{defaultValue:`No integrations found.`})}),!Q&&!$&&ke&&p===`grid`&&i(ge,{rows:G,isExpanded:X,onToggleExpand:q,onOpen:be,renderExpanded:Y,searchPlaceholder:t(`integrations.search`,{defaultValue:`Search integrations…`}),emptyLabel:t(`integrations.empty`,{defaultValue:`No integrations found.`})}),i(we,{open:h,onClose:ie,seed:y}),i(he,{open:E,onClose:ce,onSetupIntegration:oe})]})}export{Oe as IntegrationsPage};
|