@camstack/addon-admin-ui 1.2.487 → 1.2.488
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-D0sLOBuE.js} +1 -1
- package/dist/assets/{Addons-kSjXhQba.js → Addons-CZCQrk7s.js} +1 -1
- package/dist/assets/{AdminPage-Qn0NDZXK.js → AdminPage-Bm98o4hS.js} +1 -1
- package/dist/assets/{AdminSectionedPage-xGVLV1j3.js → AdminSectionedPage-DJf3yj1e.js} +1 -1
- package/dist/assets/{AiProfiles-C7RRiZ-Y.js → AiProfiles-evs8uf02.js} +1 -1
- package/dist/assets/BrokerEditorDialog-B4IYR2V5.js +1 -0
- package/dist/assets/{Build-BhxXDEVz.js → Build-eOPgiJkS.js} +1 -1
- package/dist/assets/{Calendars-v8J_zj4w.js → Calendars-B6wuMidY.js} +1 -1
- package/dist/assets/{Cluster-dhAPfJv6.js → Cluster-BInnf_-U.js} +1 -1
- package/dist/assets/{CompositionBlockEditor-BK2Or4Pz.js → CompositionBlockEditor-DJDcpaAM.js} +1 -1
- package/dist/assets/{CompositionEditorPage-CTPdWS1m.js → CompositionEditorPage-2D6sSx-T.js} +1 -1
- package/dist/assets/{Data-CPdzZaQ6.js → Data-DqaIHJmW.js} +1 -1
- package/dist/assets/{DeviceDetail-DGJeLN9c.js → DeviceDetail-CjwCeby2.js} +1 -1
- package/dist/assets/{DeviceDoActionFields-OU-F7_Md.js → DeviceDoActionFields-BIglpx6B.js} +1 -1
- package/dist/assets/{Devices-C9LPgFce.js → Devices-B_qA6OPU.js} +1 -1
- package/dist/assets/{EmbedPlayerPage-8ilkZLox.js → EmbedPlayerPage-D4WZcOrL.js} +1 -1
- package/dist/assets/{HelperWizard-Dq94Geed.js → HelperWizard-DpSct7dY.js} +1 -1
- package/dist/assets/{History-CTyWzxbJ.js → History-Ce6Ogsq9.js} +1 -1
- package/dist/assets/{Identity-DOSuuL8C.js → Identity-CpsGUQUL.js} +1 -1
- package/dist/assets/IntegrationDetail-CBkpemj6.js +1 -0
- package/dist/assets/{IntegrationHub-D-BT1i-q.js → IntegrationHub-HoJLco7C.js} +1 -1
- package/dist/assets/Integrations-DCVw5Nwp.js +1 -0
- package/dist/assets/{Integrations-CKR4hJyA.js → Integrations-Q-XZjb4J.js} +1 -1
- package/dist/assets/{Library-DzwP0Wnj.js → Library-B5hJS9Eu.js} +1 -1
- package/dist/assets/{Locations-BYPw-b2Z.js → Locations-C4_IvvDp.js} +1 -1
- package/dist/assets/{Logs-BlImwaLa.js → Logs-BMGBLu9D.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-VP7h9O7-.js → MyAccess-Cj2tBcDx.js} +1 -1
- package/dist/assets/{Network-Bla9sJtL.js → Network-C2KtyX-M.js} +1 -1
- package/dist/assets/{NodeAddonsSettingsPanel-AvBI4Evv.js → NodeAddonsSettingsPanel-SKEgEbfP.js} +1 -1
- package/dist/assets/{Notifications-H77YTWdJ.js → Notifications-DLBWNg7M.js} +1 -1
- package/dist/assets/{Pipeline-pHUqWRzY.js → Pipeline-ByR1YehD.js} +1 -1
- package/dist/assets/{PrivacyMaskSettings-UQH7zTTO.js → PrivacyMaskSettings-CSdKuS75.js} +1 -1
- package/dist/assets/{Recordings-BDCMjtre.js → Recordings-DGVoXt04.js} +1 -1
- package/dist/assets/ScanNetworkModal-DzV87kuW.js +1 -0
- package/dist/assets/{SceneMonitorEditor-PrBW7EMG.js → SceneMonitorEditor-ucsduhsM.js} +1 -1
- package/dist/assets/{SessionsList-CSJK-M1F.js → SessionsList-Cq-5x1H5.js} +1 -1
- package/dist/assets/{Showroom-mL9KRe6u.js → Showroom-Bl7Xw5HQ.js} +1 -1
- package/dist/assets/{System-CW6fpBto.js → System-BwIT8r3c.js} +1 -1
- package/dist/assets/{Terminal-CLB_5tnQ.js → Terminal-DHnbg7SD.js} +1 -1
- package/dist/assets/{Viewer-CVsr_E-j.js → Viewer-ClMEneNi.js} +1 -1
- package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-CK4gM4oq.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-CcFWmBqL.js} +1 -1
- package/dist/assets/{addon-icons-context-BKk0-b-B.js → addon-icons-context-CrIg7jRp.js} +1 -1
- package/dist/assets/{archive-BR503Bgl.js → archive-DSecC29S.js} +1 -1
- package/dist/assets/{assignment-candidates-Bt36QoWU.js → assignment-candidates-C23w5MN2.js} +1 -1
- package/dist/assets/{authed-media-B5-BZoAQ.js → authed-media-DaZ7aBed.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-GgYmAssp.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-CL_G93QX.js} +1 -1
- package/dist/assets/device-picker-model-Di8k2vXt.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-B7ptHU_u.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-r7ojSb2_.js} +1 -1
- package/dist/assets/i18n-CbVhWDGQ.js +1 -0
- package/dist/assets/{icons-D7uD703E.js → icons-CeHJ12H1.js} +1 -1
- package/dist/assets/{index-Cgn0pmzp.js → index-CizVDZHi.js} +3 -3
- 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-B5DZflLR.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-DRF9VnKV.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-96140f20.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-Di8k2vXt.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-CIvYUfKV.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-DVuhwnP3.js} +3 -3
- package/dist/assets/{step-inspector-model-Cge4IaLZ.js → step-inspector-model-CtgWliQT.js} +1 -1
- 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-QajBxHOY.js} +1 -1
- package/dist/assets/{use-stationary-objects-B6gvXwen.js → use-stationary-objects-AMw862tO.js} +1 -1
- package/dist/assets/useEventInvalidation-Di8k2vXt.js +1 -0
- package/dist/assets/{useNodeUrlSelection-cuUDxmhY.js → useNodeUrlSelection-B-2x_sVg.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_-Dpshj8Bv.js} +2 -2
- package/dist/index.html +9 -9
- package/dist/server/addon.js +17 -2
- package/package.json +1 -1
- package/dist/assets/BrokerForm-pprTt8-v.js +0 -1
- package/dist/assets/IntegrationDetail-Bj2o8Gyl.js +0 -1
- package/dist/assets/Integrations-Dn8CFiTq.js +0 -1
- package/dist/assets/ScanNetworkModal-B59m4nHs.js +0 -1
- 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/mount-DF4u2b9z.js +0 -1
- package/dist/assets/remoteEntry-HwnLQWmW.js +0 -1
- package/dist/assets/useEventInvalidation-DF4u2b9z.js +0 -1
- package/dist/assets/user-round-84cYKzbg.js +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{C as e,J as t,K as n,R as r,S as i,V as a,Y as o,et as s,o as c}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{An as l,Br as u,Ci as d,Lt as f,Pt as p,Si as m,Zi as h,bi as g,ca as _,ci as v,dn as y,dt as b,ht as x,mi as S,mn as C,ot as w,sr as T,wn as ee,xn as E,yn as D,zr as O}from"./player-overlays-BT3xIHAn.js";import{na as te}from"./client-CgAb3Nw-.js";import{t as k}from"./search-x-B-oRfcQP.js";import{Ao as A,At as ne,Cs as j,Ed as re,En as ie,Er as M,Gn as N,Ii as P,Mo as F,Nt as ae,Sa as I,Sd as L,So as R,Un as z,Yo as B,_i as V,_o as H,_r as U,_s as W,ba as G,bs as oe,co as se,dd as ce,ei as K,eo as q,fr as le,gn as ue,gr as de,gs as fe,io as pe,jt as J,lo as Y,mo as me,mr as he,no as ge,oo as _e,or as X,po as ve,pr as ye,ro as be,tn as xe,to as Se,va as Ce,vi as we,vr as Te,vs as Ee,xs as De,ys as Oe}from"./src-DX_JbsFG.js";import{t as Z}from"./useTranslation-BJr-n0es.js";import{n as ke}from"./addon-icons-context-BKk0-b-B.js";import{P as Ae,gr as je,hr as Me,mr as Ne,ur as Pe}from"./index-Cgn0pmzp.js";import{t as Fe}from"./device-integration-icon-CxktyXD5.js";import{i as Ie,r as Le,t as Re}from"./ScanNetworkModal-B59m4nHs.js";import{t as ze}from"./NodeAddonsSettingsPanel-AvBI4Evv.js";s();function Be(e){let t=[];for(let n of e)n.type===`probe`&&t.push(n.key),n.type===`group`&&`fields`in n&&t.push(...Be(n.fields));return t}function Ve(e,t,i){let[a,s]=o(`idle`),[c,l]=o({}),u=n(()=>{let t=[];for(let n of e.sections)t.push(...Be(n.fields));return t},[e]),d=u.length>0&&i!==void 0,f=r(e=>{l(t=>{if(!t[e])return t;let n={...t};return delete n[e],n})},[]);return{testAllStatus:a,hasProbeFields:d,probeResults:c,handleTestAll:r(async()=>{if(!i)return;let e=u.filter(e=>{let n=t[e];return n!=null&&String(n).trim()!==``});if(e.length===0)return;s(`testing`);let n={};for(let t of e)n[t]={status:`probing`};l(n);let r=await Promise.allSettled(e.map(async e=>{try{return{key:e,result:await i(e,t[e])}}catch(t){return{key:e,result:{status:`error`,error:t instanceof Error?t.message:String(t)}}}})),a={};for(let e of r)if(e.status===`fulfilled`){let{key:t,result:n}=e.value;a[t]={status:n.status===`ok`?`ok`:`error`,result:n}}l(a),s(`idle`)},[i,u,t]),clearProbeResult:f}}s();function Q(e){let t=[];for(let n of e)`required`in n&&n.required===!0&&`key`in n&&n.key&&t.push(n.key),n.type===`group`&&`fields`in n&&t.push(...Q(n.fields));return t}function He(e){return e==null?!0:typeof e==`string`?e.trim()===``:!1}function Ue(e,t={}){for(let n of e){if(n.type===`group`&&`fields`in n){Ue(n.fields,t);continue}`key`in n&&n.key&&`default`in n&&n.default!==void 0&&(t[n.key]=n.default)}return t}function $(){return typeof crypto<`u`&&typeof crypto.randomUUID==`function`?`probe-${crypto.randomUUID()}`:`probe-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function We({open:t,integrationId:s,addonId:l,onClose:u}){let{t:d}=Z(),f=c(),[h,g]=o({}),[_,v]=o(!1),[y,S]=o(null),[w,ee]=o($),E=A({addonId:l},{enabled:t}),D=E.data?.deviceType??null,O=H({addonId:l,type:D??te.Camera},{enabled:t&&E.isSuccess&&D!==null}),k=O.data??null;a(()=>{t&&(g(k?Ue(k.sections.flatMap(e=>e.fields)):{}),ee($()),v(!1),S(null))},[t,s,k]);let ne=n(()=>({...h,_probeRequestId:w}),[h,w]),j=se({onSuccess:()=>{f.invalidateQueries({queryKey:[[`deviceManager`]]})}}),re=B(),ie=r(async(e,t)=>{v(!0);let n=await re.mutateAsync({addonId:l,type:D??te.Camera,key:e,value:t,formValues:ne});return n.status===`ok`&&n.suggestedValues&&g(e=>{let t=!1,r={...e};for(let[i,a]of Object.entries(n.suggestedValues??{}))He(e[i])&&!He(a)&&(r[i]=a,t=!0);return t?r:e}),n},[re,l,ne,D]),{testAllStatus:M,hasProbeFields:N,probeResults:P,handleTestAll:F,clearProbeResult:ae}=Ve(k??{sections:[]},h,ie);async function I(e){S(null);try{await j.mutateAsync({addonId:l,type:D??te.Camera,config:h,integrationId:s}),e?g(k?Ue(k.sections.flatMap(e=>e.fields)):{}):u()}catch(e){S(e instanceof Error?e.message:String(e))}}if(!t)return null;let L=Q((k?.sections??[]).flatMap(e=>e.fields)).filter(e=>He(h[e])),R=L.length===0,z=E.isLoading||D!==null&&O.isLoading,V=E.isError||E.isSuccess&&D===null||O.isError||O.isSuccess&&k===null;return e(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center`,children:[i(`div`,{className:`absolute inset-0 bg-black/60`,onClick:u}),e(`div`,{className:`relative z-10 flex w-full max-w-2xl flex-col max-h-[calc(90dvh-2*max(env(safe-area-inset-top),env(safe-area-inset-bottom)))] rounded-xl border border-border bg-background shadow-2xl`,children:[e(`div`,{className:`flex items-center justify-between border-b border-border px-5 py-4 shrink-0`,children:[i(`h2`,{className:`text-sm font-semibold text-foreground`,children:d(`integrations.addDevice`)}),i(`button`,{onClick:u,className:`rounded-md p-1 text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,children:i(b,{className:`h-4 w-4`})})]}),i(`div`,{className:`flex-1 min-h-0 overflow-y-auto px-5 py-4 space-y-3`,children:z?i(`div`,{className:`flex items-center justify-center py-8`,children:i(T,{className:`h-5 w-5 animate-spin text-primary`})}):V?e(`div`,{className:`flex items-start gap-3 rounded-lg border border-destructive/40 bg-destructive/10 px-4 py-3`,children:[i(p,{className:`h-4 w-4 text-destructive mt-0.5 shrink-0`}),e(`div`,{className:`space-y-1`,children:[i(`p`,{className:`text-xs font-medium text-destructive`,children:d(`integrations.addDeviceDialog.providerUnavailable`,`Provider unavailable`)}),i(`p`,{className:`text-xs text-foreground-subtle`,children:i(Pe,{i18nKey:`integrations.addDeviceDialog.notReady`,values:{addonId:l},components:{mono:i(`span`,{className:`font-mono`})}})})]})]}):i(Ae,{schema:k,values:h,onChange:g,onTestField:ie,probeResults:P,onClearProbe:ae})}),!V&&!z&&e(`div`,{className:`border-t border-border bg-surface/50 shrink-0`,children:[e(`button`,{type:`button`,onClick:()=>v(e=>!e),className:`flex w-full items-center justify-between px-5 py-2 text-[11px] text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,children:[e(`span`,{className:`flex items-center gap-2`,children:[i(C,{className:`h-3.5 w-3.5`}),d(`integrations.addDeviceDialog.testLogs`,`Test logs`),i(`span`,{className:`font-mono text-[9px] opacity-60`,children:w.slice(0,14)})]}),i(m,{className:`h-3.5 w-3.5 transition-transform ${_?`rotate-180`:``}`})]}),_&&i(`div`,{className:`border-t border-border max-h-64 overflow-hidden`,children:i(xe,{addonId:l,requestId:w,limit:50,maxHeight:`max-h-64`,showFilters:!1,showScope:!1,className:`border-0 rounded-none`})})]}),!V&&!z&&(y||L.length>0)&&i(`div`,{className:`border-t border-destructive/30 bg-destructive/5 px-5 py-2 shrink-0`,children:e(`div`,{className:`flex items-start gap-2`,children:[i(p,{className:`h-3.5 w-3.5 text-destructive mt-0.5 shrink-0`}),i(`p`,{className:`text-[11px] text-destructive`,children:y||d(`integrations.addDeviceDialog.required`,`Required: {{value1}}`,{value1:L.join(`, `)})})]})}),e(`div`,{className:`flex items-center justify-between border-t border-border px-5 py-3 shrink-0`,children:[e(`div`,{className:`flex items-center gap-2`,children:[i(`button`,{onClick:u,className:`rounded-lg border border-border px-3 py-1.5 text-xs text-foreground-subtle hover:text-foreground transition-colors`,children:d(`integrations.cancel`)}),!V&&N&&e(`button`,{type:`button`,onClick:F,disabled:M===`testing`,className:`inline-flex items-center gap-1.5 rounded-lg border border-border px-3 py-1.5 text-xs font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50`,children:[M===`testing`?i(T,{className:`h-3.5 w-3.5 animate-spin`}):i(x,{className:`h-3.5 w-3.5`}),d(`integrations.addDeviceDialog.testAll`,`Test All`)]})]}),e(`div`,{className:`flex items-center gap-2`,children:[i(`button`,{onClick:()=>I(!0),disabled:V||!R||j.isPending,className:`rounded-lg border border-border px-3 py-1.5 text-xs text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50`,children:d(`integrations.saveAndNew`)}),i(`button`,{onClick:()=>I(!1),disabled:V||!R||j.isPending,className:`rounded-lg bg-primary px-4 py-1.5 text-xs font-medium text-primary-foreground shadow-sm disabled:opacity-50`,children:j.isPending?d(`integrations.saving`):d(`integrations.save`)})]})]})]})]})}s();var Ge=[`discovering`,`pase`,`commissioning`,`done`];function Ke(e){return!(typeof e!=`object`||!e||!(`phase`in e)||typeof e.phase!=`string`)}function qe(e,t){return e===`code-expired`||t?.includes(`matter-commission:code-expired`)?{key:`integrations.addMatter.failure.expired`,defaultValue:`The pairing code expired. Share the device again and paste the new code.`}:e===`device-not-found`||t?.includes(`matter-commission:device-not-found`)?{key:`integrations.addMatter.failure.notFound`,defaultValue:`No Matter device with that code was found on the network.`}:e===`wrong-code`||t?.includes(`matter-commission:wrong-code`)?{key:`integrations.addMatter.failure.wrongCode`,defaultValue:`The pairing code was rejected.`}:e===`invalid-code`||t?.includes(`invalid pairing code`)?{key:`integrations.addMatter.failure.invalid`,defaultValue:`Enter an 11-digit or 21-digit manual code, or a code that starts with MT:.`}:{key:`integrations.addMatter.failure.unknown`,defaultValue:t??`Commissioning failed.`}}function Je({onClose:t,onCommissioned:n}){let{t:r}=Z(),s=G({kind:`matter`}),c=s.data?.[0]?.id??null,l=I(),[u,d]=o(``),[f,p]=o({phase:`idle`,failure:null,message:null}),m=f.phase===`discovering`||f.phase===`pase`||f.phase===`commissioning`,h=Ce({brokerId:c??``,key:`commission`},{enabled:c!==null&&m,refetchInterval:m?400:!1});a(()=>{m&&Ke(h.data)&&h.data.phase!==`idle`&&p({phase:h.data.phase,failure:typeof h.data.failure==`string`?h.data.failure:null,message:typeof h.data.message==`string`?h.data.message:null})},[m,h.data]);let g=()=>{c!==null&&(p({phase:`discovering`,failure:null,message:null}),l.mutate({brokerId:c,target:{action:`commissionNode`},payload:{pairingCode:u.trim()}},{onSuccess:()=>p({phase:`done`,failure:null,message:null}),onError:e=>{let t=e instanceof Error?e.message:`Commissioning failed.`;p({phase:`failed`,failure:t.includes(`matter-commission:`)?t.split(`matter-commission:`)[1]?.split(`:`)[0]??`unknown`:t.includes(`invalid pairing code`)?`invalid-code`:`unknown`,message:t})}}))},_=f.phase===`failed`?qe(f.failure,f.message):null,v=_===null?null:r(_.key,{defaultValue:_.defaultValue}),y=(s.isSuccess===!0||s.data!==void 0)&&c===null;return i(le,{open:!0,onOpenChange:e=>!e&&t(),children:e(he,{width:`md`,placement:`sheet-on-mobile`,scroll:`body`,children:[i(U,{children:i(Te,{children:r(`integrations.addMatter.title`,{defaultValue:`Add Matter device`})})}),e(ye,{className:`space-y-4`,children:[i(`p`,{className:`text-xs text-foreground-subtle`,children:r(`integrations.addMatter.help`,{defaultValue:`In Home Assistant, open the device and choose Share device. Paste the numeric code or the MT: code here. The device stays in Home Assistant.`})}),y?i(M,{message:r(`integrations.addMatter.noBroker`,{defaultValue:`Create the Matter fabric from this integration’s settings first.`})}):e(`div`,{className:`space-y-1.5`,children:[i(N,{htmlFor:`matter-pairing-code`,children:r(`integrations.addMatter.code`,{defaultValue:`Pairing code`})}),i(ce,{id:`matter-pairing-code`,value:u,autoComplete:`off`,spellCheck:!1,placeholder:`34970112332`,disabled:m||f.phase===`done`,onChange:e=>d(e.target.value)})]}),f.phase!==`idle`&&i(`ol`,{className:`space-y-1`,"aria-label":r(`integrations.addMatter.progress`,{defaultValue:`Commissioning progress`}),children:Ge.map(t=>{let n=f.phase===t;return e(`li`,{className:`text-xs ${n?`text-foreground font-medium`:`text-foreground-subtle`}`,children:[n&&m?i(T,{className:`mr-1 inline h-3 w-3 animate-spin`}):null,r(`integrations.addMatter.phase.${t}`,{defaultValue:t===`discovering`?`Discovering`:t===`pase`?`PASE`:t===`commissioning`?`Commissioning`:`Done`})]},t)})}),v!==null&&i(M,{message:v})]}),e(de,{children:[i(K,{variant:`ghost`,size:`sm`,onClick:t,children:r(`common.close`,{defaultValue:`Close`})}),f.phase===`done`?i(K,{size:`sm`,onClick:n,children:r(`integrations.adoptDevices`,{defaultValue:`Adopt devices`})}):i(K,{size:`sm`,disabled:m||y||u.trim().length===0,onClick:g,children:m?r(`integrations.addMatter.working`,{defaultValue:`Adding…`}):r(`integrations.addMatter.submit`,{defaultValue:`Add device`})})]})]})})}var Ye=1500;function Xe({addonId:t,integrationId:n,jobId:r,onFinished:a}){let{t:o}=Z(),s=q(),c=(be({addonId:t,integrationId:n},{refetchInterval:e=>(e.state.data??[]).some(e=>e.state===`running`)?Ye:!1}).data??[]).find(e=>e.jobId===r);if(!c)return null;let l=c.state===`running`,u=c.processed,d=c.total>0?Math.round(u/c.total*100):0;!l&&c.finishedAt!==null&&a();let f=[`${u}/${c.total} ${o(`integrations.adoptJobProcessed`,{defaultValue:`processed`})}`];c.adopted>0&&f.push(`${c.adopted} ${o(`integrations.adoptJobAdded`,{defaultValue:`added`})}`),c.alreadyAdopted>0&&f.push(`${c.alreadyAdopted} ${o(`integrations.adoptJobSkipped`,{defaultValue:`already there`})}`),c.failed>0&&f.push(`${c.failed} ${o(`integrations.adoptJobFailed`,{defaultValue:`failed`})}`);let m=f.join(` · `);return e(`div`,{className:`border-t border-border px-5 py-3 shrink-0 space-y-2`,children:[e(`div`,{className:`flex items-center gap-2`,children:[l?i(T,{className:`h-3.5 w-3.5 animate-spin text-primary shrink-0`}):c.failed>0?i(p,{className:`h-3.5 w-3.5 text-destructive shrink-0`}):c.state===`cancelled`?i(v,{className:`h-3.5 w-3.5 text-foreground-subtle shrink-0`}):i(S,{className:`h-3.5 w-3.5 text-primary shrink-0`}),i(`p`,{className:`text-[11px] text-foreground`,children:m}),l&&i(`button`,{onClick:()=>s.mutate({jobId:r}),className:`ml-auto rounded-lg border border-border px-2 py-1 text-[11px] text-foreground-subtle hover:text-foreground transition-colors`,children:o(`integrations.adoptJobCancel`,{defaultValue:`Stop`})})]}),i(`div`,{className:`h-1 w-full rounded-full bg-border overflow-hidden`,children:i(`div`,{className:`h-full bg-primary transition-all`,style:{width:`${d}%`},role:`progressbar`,"aria-valuenow":d,"aria-valuemin":0,"aria-valuemax":100})}),c.results.filter(e=>e.outcome===`failed`).slice(0,5).map(t=>e(`p`,{className:`text-[11px] text-destructive`,children:[t.childNativeId,`: `,t.error]},t.childNativeId))]})}function Ze(e){let t=e.metadata;return[e.name,e.childNativeId,t.model,t.manufacturer,t.integration,t.externalLocation].filter(e=>typeof e==`string`&&e.length>0).join(` `)}s();var Qe=`devices`;function $e(e){return{id:Qe,label:e(`integrations.adoptDevicesModal.defaultFilter`),isDefault:!0}}var et=2e4,tt=100;function nt({addonId:n,integrationId:s,onClose:l}){let u=_(),{t:f}=Z(),m=c(),[h,g]=o(new Set),[v,y]=o(new Set),[x,S]=o(new Map),[C,w]=o(null),{data:ee}=Ee(),E=(ee??[]).find(e=>e.addonId===n)?.supportsLocationImport??!1,[O,te]=o(!0),k=Se({addonId:n,integrationId:s}).data?.filters,A=k&&k.length>0?k:[$e(f)],[j,ie]=o(A.find(e=>e.isDefault)?.id??(A.some(e=>e.id===Qe)?Qe:A[0].id)),M=j!==Qe,N=pe(),P=ge({addonId:n,integrationId:s,page:1,pageSize:et,filter:j}),F=P.refetch,ae=N.mutate,I=r(()=>{ae({addonId:n,integrationId:s},{onSettled:()=>{F()}})},[ae,n,s,F]),R=t(null);a(()=>{let e=`${n}::${s}`;R.current===e||P.isLoading||(R.current=e,(P.data?.candidates.length??0)===0&&I())},[n,s,P.isLoading,P.data,I]);let z=N.isPending,B=N.isError?N.error instanceof Error?N.error.message:String(N.error):null,V=typeof N.data?.lastError==`string`&&N.data.lastError.length>0?N.data.lastError:null,H=P.data?.candidates??[],U=P.isError?P.error instanceof Error?P.error.message:String(P.error):null,W=_e(),[G,oe]=o(null),se=r(e=>{e.alreadyAdopted||g(t=>{let n=new Set(t);return n.has(e.childNativeId)?n.delete(e.childNativeId):n.add(e.childNativeId),n})},[]),ce=r(e=>{y(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),K=r((e,t)=>{S(n=>{let r=new Map(n),i=r.get(e)?.hiddenChildIds??new Set,a=new Set(i);return a.has(t)?a.delete(t):a.add(t),a.size===0?r.delete(e):r.set(e,{hiddenChildIds:a}),r})},[]),q=r(e=>{let t={};for(let n of e){let e=x.get(n);e&&e.hiddenChildIds.size>0&&(t[n]={hiddenChildIds:[...e.hiddenChildIds]})}return Object.keys(t).length>0?t:void 0},[x]),le=r(async()=>{w(null);let e=[...h];if(e.length!==0)try{let t=q(e),{jobId:r}=await W.mutateAsync({addonId:n,integrationId:s,filter:j,childNativeIds:e,...t?{perCandidate:t}:{},...E?{importLocations:O}:{}});oe(r),g(new Set),S(new Map)}catch(e){w(e instanceof Error?e.message:String(e))}},[h,q,W,n,s,j,E,O]),ue=t(null),de=r(()=>{G===null||ue.current===G||(ue.current=G,F(),m.invalidateQueries({queryKey:[[`integrations`]]}),m.invalidateQueries({queryKey:[[`deviceManager`]]}))},[G,F,m]),fe=r(e=>{ie(e),g(new Set),y(new Set),S(new Map),w(null)},[]),J=h.size,Y=G!==null&&J===0&&!W.isPending;return e(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center`,children:[i(`div`,{className:`absolute inset-0 bg-black/60`,onClick:l}),e(`div`,{className:`relative z-10 flex w-full max-w-3xl flex-col h-[85vh] rounded-xl border border-border bg-background shadow-2xl`,children:[e(`div`,{className:`flex items-center justify-between border-b border-border px-5 py-4 shrink-0`,children:[e(`div`,{className:`min-w-0`,children:[i(`h2`,{className:`text-sm font-semibold text-foreground`,children:f(`integrations.adoptDevices`,{defaultValue:`Adopt devices`})}),i(`p`,{className:`text-[11px] text-foreground-subtle mt-0.5`,children:f(`integrations.adoptDevicesHint`,{defaultValue:`Preview the candidate devices and add the ones you want.`})})]}),e(`div`,{className:`flex items-center gap-3 shrink-0`,children:[E&&e(`label`,{className:`flex items-center gap-1.5 cursor-pointer text-[11px] text-foreground-subtle hover:text-foreground transition-colors`,children:[i(`input`,{type:`checkbox`,checked:O,onChange:e=>te(e.target.checked),className:`accent-primary`}),f(`integrations.importLocations`,{defaultValue:`Import locations from the integration`})]}),i(`button`,{onClick:l,className:`rounded-md p-1 text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,"aria-label":f(`common.close`,`Close`),children:i(b,{className:`h-4 w-4`})})]})]}),e(`div`,{className:`flex-1 min-h-0 px-5 py-3 flex flex-col gap-2 overflow-hidden`,children:[(B??U??V)&&H.length===0&&i(`div`,{className:`rounded-lg border border-destructive/30 bg-destructive/5 px-4 py-3 shrink-0`,children:e(`div`,{className:`flex items-start gap-2`,children:[i(p,{className:`h-3.5 w-3.5 text-destructive mt-0.5 shrink-0`}),e(`div`,{className:`min-w-0`,children:[i(`p`,{className:`text-xs font-medium text-destructive`,children:f(`integrations.adoptRefreshFailed`,{defaultValue:`Could not discover devices.`})}),i(`p`,{className:`text-[11px] text-destructive/90 mt-0.5`,children:B??U??V})]})]})}),A.length>1&&i(rt,{filters:A,activeFilter:j,onSelect:fe}),i(`div`,{className:`flex-1 min-h-0`,children:i(ne,{mode:`generic`,items:H,pageSize:tt,getKey:e=>e.childNativeId,getSearchText:Ze,getFilterType:e=>e.type,filterOptions:L(u),filterLabel:f(`integrations.adoptColType`,{defaultValue:`Type`}),isLoading:P.isLoading||z&&H.length===0,searchPlaceholder:f(`integrations.adoptSearch`,{defaultValue:`Search candidates…`}),emptyLabel:(B??U??V)&&H.length===0?``:f(`integrations.adoptNoCandidates`,{defaultValue:`No candidate devices found.`}),toolbar:e(`button`,{type:`button`,onClick:I,disabled:z,title:f(`integrations.adoptRefreshTitle`,{defaultValue:`Re-scan Home Assistant for devices`}),className:`inline-flex items-center gap-1.5 rounded-lg border border-border bg-surface px-2.5 py-1.5 text-xs text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-60 shrink-0`,children:[i(D,{className:`h-3.5 w-3.5 ${z?`animate-spin`:``}`}),f(`integrations.adoptRefresh`,{defaultValue:`Refresh`})]}),columns:[{key:`name`,header:f(`integrations.adoptColName`,{defaultValue:`Name`}),headerClassName:`w-[55%]`,cell:e=>i(it,{candidate:e,expandable:!M,expanded:v.has(e.childNativeId),onToggleExpand:()=>ce(e.childNativeId),adoptedLabel:f(`integrations.adoptAlready`,{defaultValue:`Adopted`})})},{key:`type`,header:f(`integrations.adoptColType`,{defaultValue:`Type`}),headerClassName:`w-[30%] hidden sm:table-cell`,cellClassName:`hidden sm:table-cell`,cell:t=>{let n=re(t.type,u),r=n.icon;return e(`span`,{className:`inline-flex items-center gap-1.5 text-[10px] text-foreground-subtle`,children:[i(r,{className:`h-3.5 w-3.5 shrink-0`}),n.label]})}},{key:`select`,header:``,headerClassName:`w-[15%] text-right`,cellClassName:`text-right`,cell:e=>i(`div`,{className:`flex items-center justify-end`,children:i(`button`,{onClick:()=>se(e),disabled:e.alreadyAdopted,"aria-label":h.has(e.childNativeId)?f(`integrations.adoptDevicesModal.deselect`,`Deselect`):f(`integrations.adoptDevicesModal.select`,`Select`),className:`inline-flex h-5 w-5 items-center justify-center rounded border ${h.has(e.childNativeId)?`border-primary bg-primary`:`border-border`} ${e.alreadyAdopted?`cursor-not-allowed opacity-50`:``}`,children:h.has(e.childNativeId)&&i(d,{className:`h-3 w-3 text-primary-foreground`})})})}],isExpanded:e=>!M&&v.has(e.childNativeId),renderExpanded:M?void 0:e=>i(at,{candidate:e,hiddenChildIds:x.get(e.childNativeId)?.hiddenChildIds??new Set,onToggleChildHidden:t=>K(e.childNativeId,t)}),rowClassName:e=>e.alreadyAdopted?`opacity-60`:h.has(e.childNativeId)?`bg-primary/5`:``})})]}),C&&i(`div`,{className:`border-t border-destructive/30 bg-destructive/5 px-5 py-2 shrink-0`,children:e(`div`,{className:`flex items-start gap-2`,children:[i(p,{className:`h-3.5 w-3.5 text-destructive mt-0.5 shrink-0`}),i(`p`,{className:`text-[11px] text-destructive`,children:C})]})}),G!==null&&i(Xe,{addonId:n,integrationId:s,jobId:G,onFinished:de}),e(`div`,{className:`flex items-center justify-between border-t border-border px-5 py-3 shrink-0`,children:[i(`div`,{}),e(`div`,{className:`flex items-center gap-2`,children:[i(`button`,{onClick:l,className:`rounded-lg border border-border px-3 py-1.5 text-xs text-foreground-subtle hover:text-foreground transition-colors`,children:f(`integrations.cancel`,{defaultValue:`Cancel`})}),e(`button`,{onClick:Y?l:le,disabled:!Y&&(J===0||W.isPending),className:`inline-flex items-center gap-1.5 rounded-lg bg-primary px-4 py-1.5 text-xs font-medium text-primary-foreground shadow-sm disabled:opacity-50 disabled:cursor-not-allowed`,children:[W.isPending&&i(T,{className:`h-3.5 w-3.5 animate-spin`}),Y?f(`integrations.close`,{defaultValue:`Close`}):f(`integrations.addSelected`,{defaultValue:`Add selected`}),!Y&&J>0?` (${J})`:``]})]})]})]})]})}function rt({filters:e,activeFilter:t,onSelect:n}){let{t:r}=Z();return i(`div`,{role:`tablist`,"aria-label":r(`integrations.adoptDevicesModal.discoveryGranularity`,`Discovery granularity`),className:`inline-flex shrink-0 self-start rounded-lg border border-border bg-surface p-0.5`,children:e.map(e=>{let r=e.id===t;return i(`button`,{type:`button`,role:`tab`,"aria-selected":r,onClick:()=>n(e.id),className:`rounded-md px-3 py-1 text-xs font-medium transition-colors ${r?`bg-primary text-primary-foreground shadow-sm`:`text-foreground-subtle hover:text-foreground hover:bg-surface-hover`}`,children:e.label},e.id)})})}function it({candidate:t,expandable:n,expanded:r,onToggleExpand:a,adoptedLabel:o}){let{t:s}=Z(),c=(t.children??[]).length;return e(`div`,{className:`flex items-center gap-2.5 min-w-0`,children:[n&&c>0?e(`button`,{type:`button`,onClick:a,"aria-label":r?s(`integrations.adoptDevicesModal.collapse`,`Collapse`):s(`integrations.adoptDevicesModal.expand`,`Expand`),"aria-expanded":r,className:`flex h-5 flex-shrink-0 items-center justify-center gap-0.5 rounded px-0.5 text-[10px] text-foreground-subtle transition-colors hover:bg-surface-hover hover:text-foreground`,children:[i(r?m:g,{className:`h-3.5 w-3.5`}),c]}):i(`span`,{className:`flex h-5 w-5 flex-shrink-0 items-center justify-center text-foreground-subtle/40`,children:`—`}),i(`span`,{className:`truncate text-xs font-medium text-foreground`,children:t.name}),t.alreadyAdopted&&i(`span`,{className:`rounded-full bg-success/10 px-2 py-0.5 text-[9px] font-medium text-success shrink-0`,children:o})]})}function at({candidate:t,hiddenChildIds:n,onToggleChildHidden:r}){let{t:a}=Z(),o=t.children??[];return o.length===0?null:i(`div`,{className:`space-y-1 py-1`,children:o.map(t=>{let o=n.has(t.childNativeId),s=t.capabilities??[];return e(`div`,{className:`flex items-center gap-2 rounded px-2 py-1 ${o?`opacity-50`:``}`,children:[i(`span`,{className:`text-[11px] text-foreground truncate flex-1 min-w-0`,children:t.name}),s.length>0&&i(`span`,{className:`text-[9px] text-foreground-subtle truncate`,children:s.join(`, `)}),i(`button`,{onClick:()=>r(t.childNativeId),"aria-label":o?a(`integrations.adoptDevicesModal.showChild`,`Show child`):a(`integrations.adoptDevicesModal.hideChild`,`Hide child`),title:o?a(`integrations.adoptDevicesModal.showAfterAdopt`,`Show after adopt`):a(`integrations.adoptDevicesModal.hideAfterAdopt`,`Hide after adopt`),className:`flex h-5 w-5 items-center justify-center rounded text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors flex-shrink-0`,children:i(o?u:O,{className:`h-3 w-3`})})]},t.childNativeId)})})}s();function ot(e){let t=[];for(let n of e){if(n.type===`group`){t.push(...ot(n.fields));continue}`key`in n&&typeof n.key==`string`&&t.push(n.key)}return t}function st(e,t){if(!e)return{};let n=new Set(e.sections.flatMap(e=>ot(e.fields))),r={};for(let e of n)Object.prototype.hasOwnProperty.call(t,e)&&(r[e]=t[e]);return r}function ct(e){return{...e.tabs?{tabs:e.tabs}:{},sections:e.sections.map(e=>({...e,fields:e.fields.map(e=>{if(`value`in e){let{value:t,...n}=e;return n}return e})}))}}function lt({integrationId:t,addonId:r,name:a,kind:o,mode:s,brokerKind:l,canTest:u=!1,trpc:d,onClose:f}){let{t:p}=Z(),m=c(),{data:h,isLoading:g}=Oe({id:t},{enabled:s===`account`||s===`broker`}),_=n(()=>{let e=h?.brokerId;return typeof e==`string`?e:null},[h]),{data:v,isLoading:y}=V({addonId:r,nodeId:`hub`},{enabled:s===`account`}),b=n(()=>v?ct(v):null,[v]),x=De(),S=(e,n)=>{x.mutate({id:t,settings:e,...n?{secretKeys:[...n]}:{}},{onSuccess:()=>{m.invalidateQueries(),f()}})};return i(le,{open:!0,onOpenChange:e=>!e&&f(),children:e(he,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,children:[i(U,{children:e(Te,{children:[p(`integrations.editConfig`,{defaultValue:`Edit configuration`}),` — `,a]})}),i(ye,{children:s===`broker`?l?e(`div`,{className:`space-y-3`,children:[i(`p`,{className:`text-[11px] text-foreground-subtle`,children:p(`integrations.relinkBrokerHelp`,{defaultValue:`Choose the broker this integration connects through. Picking a different broker re-points it and restarts the addon.`})}),_&&e(`p`,{className:`text-[11px] text-foreground`,children:[p(`integrations.currentBroker`,{defaultValue:`Current broker`}),`:`,` `,i(`span`,{className:`font-mono text-foreground-subtle`,children:_})]}),x.isPending?e(`div`,{className:`flex items-center gap-2 text-[11px] text-foreground-subtle`,children:[i(T,{className:`h-3 w-3 animate-spin`}),p(`integrations.saving`,{defaultValue:`Saving…`})]}):i(Ie,{kind:l,onResolved:e=>{S({brokerId:e})},onBack:f}),x.isError&&i(`p`,{className:`text-[11px] text-danger`,children:p(`integrations.relinkFailed`,{defaultValue:`Failed to update broker link.`})})]}):i(`p`,{className:`text-[11px] text-danger`,children:p(`integrations.noBrokerKind`,{defaultValue:`This integration declares device-adoption but its addon manifest has no brokerKind.`})}):s===`account`?g||y?e(`div`,{className:`flex items-center gap-2 text-[11px] text-foreground-subtle`,children:[i(T,{className:`h-3 w-3 animate-spin`}),p(`integrations.loading`,{defaultValue:`Loading…`})]}):i(Le,{addonId:r,configSchema:b,canTest:u,initialName:a,initialConfig:st(b,h??{}),submitLabel:p(`integrations.save`,{defaultValue:`Save`}),hideName:!0,onSave:({config:e,secretKeys:t})=>S(e,t),onBack:f}):i(X,{trpc:d,addonId:r,nodeId:`hub`,title:a})})]})})}function ut(e){return e==null?!1:e.sections.some(e=>e.fields.length>0)}s();function dt(){let{t}=Z(),{integrationId:s}=Me(),u=c(),d=Ne(),[p,m]=je(),g=w(),[_,v]=o(!1),[b,x]=o(!1),[S,D]=o(!1),O=r(e=>{D(!1),d(`/integrations`,{state:{integrationSeed:e}})},[d]),[te,A]=o(!1),[re,M]=o(!1),{data:N,isLoading:I}=W({id:s??``},{enabled:!!s}),{data:L}=V({addonId:N?.addonId??``,nodeId:`hub`},{enabled:!!N?.addonId}),{data:B,isSuccess:H}=Ee(),G=n(()=>{let e=N?.addonId;return!e||!H?null:(B??[]).find(t=>t.addonId===e)?.kind===`device-adoption`?`device-adoption`:`device-provider`},[B,N?.addonId,H]),{data:se}=ve({}),ce=n(()=>(se?.providers??[]).some(e=>e.addonId===N?.addonId),[se,N?.addonId]),K=G!==null,q=N?.info?.fixed===!0,de=n(()=>{let e=N?.addonId;return!e||!H?null:(B??[]).find(t=>t.addonId===e)?.brokerKind??null},[B,N?.addonId,H]),pe=de===`matter`,ge=K?pe?t(`integrations.addMatter.title`,{defaultValue:`Add Matter device`}):G===`device-adoption`?t(`integrations.adoptDevices`,{defaultValue:`Adopt devices`}):t(`integrations.addDevice`):t(`integrations.addDeviceLoading`,{defaultValue:`Loading…`}),_e=n(()=>{let e=N?.addonId;return!e||!H?!1:(B??[]).find(t=>t.addonId===e)?.canTest===!0},[B,N?.addonId,H]),X=n(()=>{let e=N?.addonId;return!e||!H?null:(B??[]).find(t=>t.addonId===e)?.mode??null},[B,N?.addonId,H]);a(()=>{p.get(`add`)===`1`&&K&&(x(!1),v(!0),m(e=>{let t=new URLSearchParams(e);return t.delete(`add`),t},{replace:!0}))},[p,K,m]);let be=L!=null&&Array.isArray(L.sections)&&L.sections.some(e=>e.fields.length>0),{data:Se}=we({addonId:N?.addonId??``,nodeId:`hub`},{enabled:!!N?.addonId&&X!==`account`}),Ce=X!==null&&X!==`account`&&ut(Se),De=n(()=>N?.addonId?[N.addonId]:[],[N?.addonId]),{data:Oe}=R({projection:`slim`},{refetchInterval:3e4}),ke=[[`integrations`,`get`],{input:{id:s??``},type:`query`}],Ae=j({onMutate:async e=>{await u.cancelQueries({queryKey:ke});let t=u.getQueryData(ke);return t!=null&&u.setQueryData(ke,{...t,enabled:e.enabled}),{previous:t}},onError:(e,t,n)=>{let r=n;r?.previous!=null&&u.setQueryData(ke,r.previous)},onSettled:()=>{u.invalidateQueries({queryKey:[[`integrations`]]}),u.invalidateQueries({queryKey:[[`deviceManager`]]})}}),Pe=fe({onSuccess:()=>{u.invalidateQueries({queryKey:[[`integrations`]]}),u.invalidateQueries({queryKey:[[`deviceManager`]]}),d(`/integrations`)}}),Ie=P({onSuccess:()=>{u.invalidateQueries({queryKey:[[`integrations`]]}),u.invalidateQueries({queryKey:[[`deviceManager`]]})}}),Le=F({onSuccess:()=>{u.invalidateQueries({queryKey:[[`deviceManager`]]})}}),Be=Y({onSuccess:()=>{u.invalidateQueries({queryKey:[[`deviceManager`]]})}}),Ve=me({onSuccess:()=>{u.invalidateQueries({queryKey:[[`deviceManager`]]})}}),Q=n(()=>Oe??[],[Oe]),He=n(()=>{let e=new Map;for(let t of Q)e.set(t.id,{id:t.id,name:t.name??t.stableId??`#${String(t.id)}`});return e},[Q]),Ue=r(e=>He.get(e)??null,[He]),{data:$}=oe(void 0),Ge=n(()=>J($),[$]),Ke=r(e=>d(`/devices/${String(e)}`),[d]),qe=n(()=>{let e=N?.id;return e?Q.filter(t=>{let n=Ge(t);return n.kind===`resolved`&&n.integration.id===e}):[]},[Q,N?.id,Ge]),Ye=n(()=>$===void 0?null:ae(qe).length,[$,qe])??`…`;return I?e(`div`,{className:`p-4`,children:[i(`div`,{className:`h-16 rounded-lg bg-surface animate-pulse mb-4`}),i(`div`,{className:`h-40 rounded-lg bg-surface animate-pulse`})]}):N?e(`div`,{className:`p-4 space-y-4 overflow-x-hidden`,children:[i(ie,{items:[{label:t(`integrationDetail.integrations`,`Integrations`),onClick:()=>d(`/integrations`)},{label:N.name}]}),e(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[e(`div`,{className:`flex items-center gap-3 min-w-0`,children:[i(ft,{addonId:N.addonId}),e(`div`,{className:`min-w-0`,children:[i(`h1`,{className:`text-lg font-semibold text-foreground truncate`,children:N.name}),e(`p`,{className:`text-[11px] text-foreground-subtle mt-0.5 truncate`,children:[N.addonId,` · `,Ye,` `,t(`integrations.devices`)]})]})]}),e(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[ce&&e(`button`,{onClick:()=>D(!0),className:`flex items-center gap-1.5 rounded-lg border border-border bg-surface px-2.5 py-1.5 text-xs font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,title:t(`integrationDetail.scanTheNetworkForDevices`,`Scan the network for devices (incl. a different subnet)`),children:[i(ee,{className:`h-3.5 w-3.5`}),t(`integrationDetail.scanNetwork`,`Scan network`)]}),!q&&e(`button`,{onClick:()=>{x(!1),v(!0)},disabled:!K,className:`flex items-center gap-1.5 rounded-lg bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground shadow-sm disabled:opacity-50 disabled:cursor-not-allowed`,title:ge,children:[i(l,{className:`h-3.5 w-3.5`}),ge]}),e(`div`,{className:`inline-flex items-center gap-2 rounded-lg border px-3 py-1.5 transition-colors ${Ae.isPending?`opacity-60`:``} ${N.enabled?`border-success/30 bg-success/5`:`border-border bg-surface`}`,title:t(`integrations.toggleHint`,{defaultValue:`Click to toggle`}),children:[i(z,{checked:N.enabled,onCheckedChange:e=>Ae.mutate({id:s,enabled:e}),disabled:Ae.isPending,"aria-label":N.enabled?t(`integrationDetail.disableIntegration`,`Disable integration`):t(`integrationDetail.enableIntegration`,`Enable integration`)}),i(`span`,{className:`text-[11px] font-medium ${N.enabled?`text-success`:`text-foreground-subtle`}`,children:N.enabled?t(`integrationDetail.enabled`,`Enabled`):t(`integrationDetail.disabled`,`Disabled`)}),Ae.isPending&&i(T,{className:`h-3 w-3 animate-spin text-foreground-subtle`})]}),X!==`standalone`&&(be||G===`device-adoption`)&&e(`button`,{onClick:()=>A(!0),className:`flex items-center gap-1.5 rounded-lg border border-border bg-surface px-3 py-1.5 text-[11px] text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,children:[i(y,{className:`h-3 w-3`}),t(`integrations.config`)]}),e(`button`,{onClick:()=>M(!0),className:`flex items-center gap-1.5 rounded-lg border border-border bg-surface px-3 py-1.5 text-[11px] text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,title:t(`integrations.logs`,{defaultValue:`View logs`}),children:[i(C,{className:`h-3 w-3`}),t(`integrations.logs`,{defaultValue:`Logs`})]}),i(ue,{label:t(`integrationDetail.restart`,`Restart`),icon:E,title:t(`integrationDetail.restart2`,`Restart "{{name}}"?`,{name:N.name}),description:t(`integrationDetail.restartingTheAddonWillBriefly`,`Restarting the addon will briefly disconnect every device backed by it ({{topLevelCountLabel}} active). Streams will reconnect automatically.`,{topLevelCountLabel:Ye}),confirmLabel:t(`integrationDetail.restart`,`Restart`),triggerVariant:`outline`,confirmVariant:`danger`,disabled:Ie.isPending,action:()=>Ie.mutateAsync({addonId:N.addonId})}),!q&&s&&i(ue,{label:t(`integrations.delete`,{defaultValue:`Delete`}),icon:f,title:t(`integrations.deleteTitle`,{defaultValue:`Delete integration?`}),description:t(`integrations.deleteWarning`,{defaultValue:`This removes the integration "{{name}}" and its {{count}} device(s). The addon will restart. This cannot be undone.`,name:N.name,count:Ye}),confirmLabel:t(`integrations.confirmDelete`,{defaultValue:`Delete integration`}),triggerVariant:`outline`,confirmVariant:`danger`,className:`border-danger bg-danger/10 text-danger hover:bg-danger hover:text-background`,disabled:Pe.isPending,action:()=>Pe.mutateAsync({id:s})})]})]}),Ce&&i(ze,{nodeId:null,addonIds:De,level:`global`,surface:`integration`,title:t(`integrations.settings`,{defaultValue:`Settings`})}),i(ne,{context:`integration-detail`,devices:Q,trpc:g.trpcClient,integrationOf:Ge,forceIntegrationId:N.id,urlScope:`root`,lsKey:`integration-detail:${N.addonId}`,resolveIntegrationIcon:Fe,resolveParent:Ue,onNavigate:Ke,batchActions:{remove:Le.mutate,disable:Be.mutate,enable:Ve.mutate},...q?{}:{onDeleteDevice:e=>Le.mutate({deviceId:e.id})}}),_&&s&&pe&&!b&&i(Je,{onClose:()=>v(!1),onCommissioned:()=>x(!0)}),_&&s&&G===`device-adoption`&&(!pe||b)&&i(nt,{addonId:N.addonId,integrationId:s,onClose:()=>{v(!1),x(!1)}}),_&&s&&G===`device-provider`&&i(We,{open:_,integrationId:s,addonId:N.addonId,onClose:()=>v(!1)}),S&&N&&i(Re,{open:S,scope:{addonId:N.addonId,label:N.name},onClose:()=>D(!1),onSetupIntegration:O}),te&&s&&G!==null&&X!==null&&i(lt,{integrationId:s,addonId:N.addonId,name:N.name,kind:G,mode:X,brokerKind:de,canTest:_e,trpc:g.trpcClient,onClose:()=>A(!1)}),re&&i(le,{open:!0,onOpenChange:e=>!e&&M(!1),children:e(he,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,className:`md:max-w-5xl md:h-[80vh]`,children:[i(U,{className:`mb-0`,children:e(Te,{className:`flex items-center gap-2 min-w-0`,children:[i(C,{className:`h-4 w-4 text-primary shrink-0`}),i(`span`,{className:`truncate`,children:N.name}),e(`span`,{className:`text-[10px] text-foreground-subtle font-mono truncate font-normal`,children:[N.addonId,s?` · ${s}`:``]})]})}),i(ye,{className:`min-h-0 overflow-hidden p-0`,children:i(xe,{addonId:N.addonId,limit:200,maxHeight:`max-h-full`,showScope:!1,className:`h-full border-0 rounded-none`})})]})})]}):e(`div`,{className:`flex flex-col items-center justify-center py-20 px-6 text-center gap-4`,children:[i(`div`,{className:`flex h-12 w-12 items-center justify-center rounded-full bg-foreground-subtle/10`,children:i(k,{className:`h-6 w-6 text-foreground-subtle`})}),e(`div`,{className:`space-y-1 max-w-sm`,children:[i(`h2`,{className:`text-sm font-semibold text-foreground`,children:t(`integrations.integrationNotFound`,{defaultValue:`Integration not found`})}),i(`p`,{className:`text-[11px] text-foreground-subtle`,children:t(`integrations.integrationNotFoundHint`,{defaultValue:`The integration "{{id}}" does not exist. It may have been deleted, or the URL may be wrong.`,id:s??``})})]}),e(`button`,{onClick:()=>d(`/integrations`),className:`inline-flex items-center gap-1.5 rounded-lg border border-border bg-surface px-3 py-1.5 text-[11px] font-medium text-foreground hover:bg-surface-hover transition-colors`,children:[i(h,{className:`h-3 w-3`}),t(`integrations.backToList`,{defaultValue:`Back to integrations`})]})]})}function ft({addonId:e}){let t=ke(e),[n,r]=o(!1);return!t||n?null:i(`img`,{src:t,alt:``,className:`h-8 w-8 rounded-lg shrink-0`,onError:()=>r(!0)})}export{dt as IntegrationDetailPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{C as e,J as t,K as n,R as r,S as i,V as a,Y as o,a as s,et as c,o as l,t as u,x as d}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{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-BT3xIHAn.js";import{$r as S,$t as ee,Hi as C}from"./client-CgAb3Nw-.js";import{h as w,s as T}from"./video-DYC_GW17.js";import{t as E}from"./log-in-CyzfmKrH.js";import{t as D}from"./monitor-smartphone-CR32s5N4.js";import{t as te}from"./recycle-DZmrkdVl.js";import{Ai as O,Ca as k,Cn as ne,Er as A,Ka as j,Ot as M,Qr as re,Ta as ie,Ul as ae,_r as N,ba as P,ei as F,fr as I,ga as L,ha as oe,hr as se,ht as ce,kr as le,kt as R,mr as z,pr as ue,pt as de,si as B,sr as fe,ut as V,vr as H,wa as U,xa as W,ya as pe}from"./src-DX_JbsFG.js";import{t as G}from"./i18n-Zscg3Dkf.js";import{t as K}from"./useTranslation-BJr-n0es.js";import{P as q,S as me,g as J,gr as he,i as ge,mr as _e}from"./index-Cgn0pmzp.js";import{t as ve}from"./AdminSectionedPage-xGVLV1j3.js";import{t as ye}from"./BrokerForm-pprTt8-v.js";import{t as be}from"./NodeAddonsSettingsPanel-AvBI4Evv.js";import{n as xe,r as Y,t as Se}from"./IntegrationHub-D-BT1i-q.js";c();var X=`kind`,Z=`name`,Ce=`restore`,we=`restoreId`;function Te(e){return{sections:[{id:`broker-identity`,title:G.t(`helpers.brokerIdentitySchema.title`),columns:1,fields:[{type:`select`,key:X,label:G.t(`helpers.brokerIdentitySchema.kind`),options:e.map(e=>({value:e.key,label:e.label})),disabled:e.length<=1},{type:`text`,key:Z,label:G.t(`helpers.brokerIdentitySchema.name`),placeholder:G.t(`helpers.brokerIdentitySchema.namePlaceholder`),required:!0},{type:`boolean`,key:Ce,label:G.t(`helpers.brokerIdentitySchema.restore`),description:G.t(`helpers.brokerIdentitySchema.restoreHint`)},{type:`text`,key:we,label:G.t(`helpers.brokerIdentitySchema.originalId`),placeholder:`ha_004`,required:!0,showWhen:{field:Ce,equals:!0}}]}]}}function Ee(e){let t=t=>{let n=e[t];return typeof n==`string`?n.trim():``},n=t(X);if(n===``)return{ok:!1,problem:`Pick a kind.`};let r=t(Z);if(r===``)return{ok:!1,problem:`Enter a name before saving.`};if(e.restore!==!0)return{ok:!0,identity:{kindKey:n,name:r,restoreId:null}};let i=t(we);return i===``?{ok:!1,problem:`Enter the original id, or turn restore off to create a new broker.`}:{ok:!0,identity:{kindKey:n,name:r,restoreId:i}}}var De={"home-assistant":`Home Assistant`,mqtt:`MQTT`};function Oe(e){return De[e]??e}function ke(e){return Array.isArray(e)?e.filter(e=>typeof e==`object`&&!!e&&typeof e.addonId==`string`&&Array.isArray(e.kinds)):[]}var Ae={connected:`success`,connecting:`warning`,disconnected:`default`,"auth-failed":`danger`,unreachable:`danger`,error:`danger`};function je({status:e}){return i(B,{variant:Ae[e],className:`text-[10px]`,children:e})}function Me(e){return Array.isArray(e)?e.filter(e=>typeof e==`object`&&!!e&&typeof e.id==`string`):[]}function Ne({title:t,subtitle:n,onClose:r,children:a}){return i(I,{open:!0,onOpenChange:e=>!e&&r(),children:e(z,{width:`md`,placement:`sheet-on-mobile`,scroll:`body`,children:[e(N,{children:[i(H,{children:t}),n&&i(se,{children:n})]}),i(ue,{className:`space-y-3 pr-1`,children:a})]})})}function Pe({kinds:t,onClose:r,onDone:a}){let{t:s}=K(),c=l(),u=n(()=>Te(t.map(e=>({key:Q(e),label:e.label}))),[t]),[d,f]=o(()=>({[X]:Q(t[0]),[Z]:``,[Ce]:!1,[we]:``})),[p,m]=o(null),h=t.find(e=>Q(e)===d.kind)??t[0],g=h?.kind??``,_=h?.addonId,v=h?.interactiveConnectPath,y=oe({onSuccess:e=>{c.invalidateQueries({queryKey:[[`broker`,`list`]]});let t=typeof e==`object`&&e&&typeof e.id==`string`?e.id:null;t!==null&&v!==void 0&&v.length>0&&J(v,t,()=>{c.invalidateQueries({queryKey:[[`broker`,`list`]]})}),a()}}),b=e=>{let t=Ee(d);if(!t.ok){m(t.problem);return}m(null);let{name:n,restoreId:r}=t.identity;y.mutate({kind:g,name:n,settings:e,...r===null?{}:{id:r},..._===void 0?{}:{addonId:_}})};return e(Ne,{title:s(`brokers.brokerManager.addBroker`,`Add broker`),subtitle:s(`brokers.brokerManager.registerAMessageBrokerFor`,`Register a message broker for exporters and automations.`),onClose:y.isPending?()=>{}:r,children:[i(q,{schema:u,values:d,onChange:f}),p!==null&&i(A,{message:p}),y.isError&&i(A,{message:y.error instanceof Error?y.error.message:String(y.error)}),g&&i(ye,{kind:g,..._===void 0?{}:{addonId:_},onSubmit:b,onCancel:r,submitLabel:y.isPending?s(`brokers.brokerManager.adding`,`Adding…`):s(`brokers.brokerManager.addBroker`,`Add broker`),disabled:y.isPending},Q(h))]})}function Q(e){return e===void 0?``:`${e.addonId??``}::${e.kind}`}function Fe({broker:t,onClose:r,onDone:a}){let{t:o}=K(),s=l(),c=L({id:t.id,addonId:t.addonId}),u=U({onSuccess:()=>{s.invalidateQueries({queryKey:[[`broker`,`list`]]}),s.invalidateQueries({queryKey:[[`broker`,`getSettings`],{input:{id:t.id,addonId:t.addonId}}]}),a()}}),d=n(()=>{let e=c.data;return e&&typeof e==`object`?{...e}:{}},[c.data]);return i(Ne,{title:o(`brokers.brokerManager.edit`,`Edit {{name}}`,{name:t.name}),subtitle:`${Oe(t.kind)} · ${t.id}`,onClose:u.isPending?()=>{}:r,children:c.isLoading?e(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[i(b,{className:`h-3.5 w-3.5 animate-spin`}),` `,o(`brokers.brokerManager.loadingSettings`)]}):c.isError?e(`div`,{className:`space-y-3`,children:[i(A,{message:o(`brokers.brokerManager.loadSettingsFailed`,{message:c.error instanceof Error?c.error.message:o(`common.unknownError`)})}),i(`div`,{className:`flex justify-end`,children:i(F,{variant:`outline`,size:`sm`,onClick:r,children:o(`common.close`,`Close`)})})]}):e(`div`,{className:`space-y-3`,children:[u.isError&&i(A,{message:u.error instanceof Error?u.error.message:String(u.error)}),i(ye,{kind:t.kind,addonId:t.addonId,brokerId:t.id,initialValues:d,onSubmit:e=>{u.mutate({id:t.id,settings:e,addonId:t.addonId})},onCancel:r,submitLabel:u.isPending?o(`brokers.brokerManager.saving`,`Saving…`):o(`common.save`,`Save`),disabled:u.isPending})]})})}function Ie({broker:t,interactiveConnectPath:n,interactiveDisconnectPath:r,onEdit:a}){let{t:s}=K(),c=l(),u=re(),[d,f]=o(null),h=ie({onSuccess:e=>f(e.ok?{ok:!0}:{ok:!1,error:e.error}),onError:e=>f({ok:!1,error:e instanceof Error?e.message:String(e)})}),_=k({onSuccess:()=>{c.invalidateQueries({queryKey:[[`broker`,`list`]]})}}),v=async()=>{await u({title:s(`brokers.brokerManager.deleteBroker`,`Delete broker`),message:s(`brokers.brokerManager.deleteBrokerIntegrationsThatDepend`,`Delete broker "{{name}}"? Integrations that depend on it will stop working.`,{name:t.name}),confirmLabel:s(`common.delete`,`Delete`),variant:`danger`})&&_.mutate({id:t.id,addonId:t.addonId})},y=n!==void 0&&n.length>0&&t.status!==`connected`,x=r!==void 0&&r.length>0&&t.status===`connected`;return e(`tr`,{className:`border-b border-border last:border-0`,children:[i(`td`,{className:`px-3 py-2 text-xs text-foreground font-medium`,children:t.name}),i(`td`,{className:`px-3 py-2 text-xs text-foreground-subtle`,children:Oe(t.kind)}),e(`td`,{className:`px-3 py-2`,children:[i(je,{status:t.status}),d&&i(`span`,{className:`ml-2 text-[10px] ${d.ok?`text-success`:`text-danger`}`,children:d.ok?`OK`:d.error??s(`common.failedWord`)})]}),i(`td`,{className:`px-3 py-2`,children:e(`div`,{className:`flex items-center justify-end gap-1.5`,children:[y&&e(F,{variant:`primary`,size:`sm`,onClick:()=>{J(n,t.id,()=>{c.invalidateQueries({queryKey:[[`broker`,`list`]]})})},title:s(`brokers.brokerManager.signInOpensAPopup`,`Sign in — opens a popup that closes when done`),children:[i(E,{className:`h-3 w-3`}),` `,s(`brokers.brokerManager.signIn`)]}),x&&e(F,{variant:`outline`,size:`sm`,onClick:()=>{J(r,t.id,()=>{c.invalidateQueries({queryKey:[[`broker`,`list`]]})})},title:s(`brokers.brokerManager.signOutClearsTheLinked`,`Sign out — clears the linked Google account on this broker`),children:[i(T,{className:`h-3 w-3`}),` `,s(`brokers.brokerManager.signOut`)]}),e(F,{variant:`outline`,size:`sm`,onClick:()=>h.mutate({id:t.id,addonId:t.addonId}),disabled:h.isPending,title:s(`brokers.brokerManager.testConnection`,`Test connection`),children:[h.isPending?i(b,{className:`h-3 w-3 animate-spin`}):i(g,{className:`h-3 w-3`}),s(`brokers.brokerManager.test`,`Test`)]}),e(F,{variant:`outline`,size:`sm`,onClick:()=>a(t),title:s(`common.edit`,`Edit`),children:[i(p,{className:`h-3 w-3`}),` `,s(`common.edit`)]}),e(F,{variant:`outline`,size:`sm`,className:`border-danger/40 text-danger hover:bg-danger/10`,onClick:()=>{v()},disabled:_.isPending,title:s(`common.delete`,`Delete`),children:[_.isPending?i(b,{className:`h-3 w-3 animate-spin`}):i(m,{className:`h-3 w-3`}),s(`common.delete`,`Delete`)]})]})})]})}function Le({addonId:t}={}){let{t:r}=K(),a=P({}),s=W(),c=n(()=>Me(a.data).filter(e=>t===void 0||e.addonId===t),[a.data,t]),[l,u]=o(!1),[d,p]=o(null),m=n(()=>{let e=new Map;for(let n of ke(s.data))if(!(t!==void 0&&n.addonId!==t))for(let t of n.kinds){let r=typeof t.interactiveConnectPath==`string`&&t.interactiveConnectPath.length>0?t.interactiveConnectPath:void 0,i=typeof t.interactiveDisconnectPath==`string`&&t.interactiveDisconnectPath.length>0?t.interactiveDisconnectPath:void 0;e.set(`${n.addonId}::${t.kind}`,{addonId:n.addonId,kind:t.kind,label:t.label,...r===void 0?{}:{interactiveConnectPath:r},...i===void 0?{}:{interactiveDisconnectPath:i}})}for(let t of c)[...e.values()].some(e=>e.kind===t.kind)||e.set(`::${t.kind}`,{kind:t.kind,label:Oe(t.kind)});return[...e.values()]},[c,s.data,t]),h=n(()=>{let e=new Map;for(let t of m)e.has(t.kind)||e.set(t.kind,{...t.interactiveConnectPath===void 0?{}:{connect:t.interactiveConnectPath},...t.interactiveDisconnectPath===void 0?{}:{disconnect:t.interactiveDisconnectPath}});return e},[m]);return e(`div`,{className:`space-y-3`,children:[i(`div`,{className:`flex items-center justify-end`,children:e(F,{variant:`primary`,size:`sm`,onClick:()=>u(!0),disabled:m.length===0,title:m.length===0?r(`brokers.brokerManager.noBrokerProvidersAvailable`,`No broker providers available`):void 0,children:[i(f,{className:`h-3.5 w-3.5`}),` `,r(`brokers.brokerManager.addBroker`)]})}),i(`div`,{className:`rounded-lg border border-border bg-surface overflow-x-auto`,children:e(`table`,{className:`w-full min-w-[36rem] border-collapse`,children:[i(`thead`,{children:e(`tr`,{className:`border-b border-border bg-background/50`,children:[i(`th`,{className:`px-3 py-2 text-left text-[10px] font-semibold uppercase tracking-wider text-foreground-subtle`,children:r(`brokers.brokerManager.name`,`Name`)}),i(`th`,{className:`px-3 py-2 text-left text-[10px] font-semibold uppercase tracking-wider text-foreground-subtle`,children:r(`brokers.brokerManager.kind`,`Kind`)}),i(`th`,{className:`px-3 py-2 text-left text-[10px] font-semibold uppercase tracking-wider text-foreground-subtle`,children:r(`brokers.brokerManager.status`,`Status`)}),i(`th`,{className:`px-3 py-2 text-right text-[10px] font-semibold uppercase tracking-wider text-foreground-subtle`,children:r(`brokers.brokerManager.actions`,`Actions`)})]})}),e(`tbody`,{children:[a.isLoading&&i(`tr`,{children:e(`td`,{colSpan:4,className:`px-3 py-6 text-center text-xs text-foreground-subtle`,children:[i(b,{className:`inline h-4 w-4 animate-spin`}),` `,r(`brokers.brokerManager.loadingBrokers`)]})}),a.isError&&i(`tr`,{children:e(`td`,{colSpan:4,className:`px-3 py-4 text-center text-xs text-danger`,children:[r(`brokers.brokerManager.failedToLoadBrokers`,`Failed to load brokers:`),` `,a.error instanceof Error?a.error.message:r(`brokers.brokerManager.unknownError`,`Unknown error`)]})}),!a.isLoading&&!a.isError&&c.length===0&&i(`tr`,{children:i(`td`,{colSpan:4,className:`px-3 py-6 text-center text-xs text-foreground-subtle`,children:r(`brokers.brokerManager.noBrokersRegisteredYetAdd`,`No brokers registered yet. Add one to publish device events for downstream automations.`)})}),c.map(e=>{let t=h.get(e.kind);return i(Ie,{broker:e,...t?.connect===void 0?{}:{interactiveConnectPath:t.connect},...t?.disconnect===void 0?{}:{interactiveDisconnectPath:t.disconnect},onEdit:p},e.id)})]})]})}),l&&i(Pe,{kinds:m,onClose:()=>u(!1),onDone:()=>u(!1)}),d&&i(Fe,{broker:d,onClose:()=>p(null),onDone:()=>p(null)})]})}c();function Re({addonId:e,fallback:t}){let{t:n}=K(),r=ae({});if(r.isPending)return i(`div`,{className:`flex justify-center py-8`,children:i(b,{className:`size-6 animate-spin text-muted-foreground`})});if(r.isError)return i(A,{message:n(`brokers.brokerRecordEntriesPanel.loadKindsFailed`,`Could not load entry kinds`)});let a=r.data.kinds.find(t=>t.owner===e&&t.kind===`brokers`);return a===void 0?t:i(ze,{addonId:e,kind:a})}function ze({addonId:t,kind:r}){let{t:a}=K(),o=l(),s=P({}),c=W(),u=n(()=>{let e=new Map;for(let n of Me(s.data))n.addonId===t&&e.set(n.id,n);return e},[s.data,t]),f=n(()=>{let e=new Map;for(let t of ke(c.data))for(let n of t.kinds){let r=n.interactiveConnectPath,i=n.interactiveDisconnectPath;e.set(`${t.addonId}::${n.kind}`,{...typeof r==`string`&&r.length>0?{connect:r}:{},...typeof i==`string`&&i.length>0?{disconnect:i}:{}})}return e},[c.data]),p=()=>{o.invalidateQueries({queryKey:[[`broker`]]}),o.invalidateQueries({queryKey:[[`recordEntries`]]})};return i(V,{kind:r,extraColumns:n(()=>[{key:`status`,header:a(`brokers.brokerManager.status`,`Status`),nowrap:!0,width:`w-px`,render:e=>{let t=u.get(e.id);return t===void 0?null:i(je,{status:t.status})}}],[u,a]),rowActions:t=>{let n=u.get(t.id);if(n===void 0)return null;let r=f.get(`${n.addonId}::${n.kind}`);if(r===void 0)return null;let o=n.status===`connected`;return e(d,{children:[r.connect!==void 0&&!o&&e(F,{variant:`primary`,size:`sm`,"aria-label":a(`brokers.brokerManager.signIn`),onClick:()=>J(r.connect??``,n.id,p),title:a(`brokers.brokerManager.signInOpensAPopup`,`Sign in — opens a popup that closes when done`),children:[i(E,{className:`h-3 w-3`}),i(`span`,{className:`hidden sm:inline`,children:a(`brokers.brokerManager.signIn`)})]}),r.disconnect!==void 0&&o&&e(F,{variant:`outline`,size:`sm`,"aria-label":a(`brokers.brokerManager.signOut`),onClick:()=>J(r.disconnect??``,n.id,p),title:a(`brokers.brokerManager.signOutClearsTheLinked`,`Sign out — clears the linked Google account on this broker`),children:[i(T,{className:`h-3 w-3`}),i(`span`,{className:`hidden sm:inline`,children:a(`brokers.brokerManager.signOut`)})]})]})},showUpdated:!1,minWidthPx:340})}function Be(e){if(typeof e==`string`)return e;if(typeof e==`object`&&e){let t=e.name;if(typeof t==`string`)return t}return null}function Ve(e){let t=e,n=t?.manifest;if(n?.id===void 0)return null;let r=(n.capabilities??[]).map(Be).filter(e=>e!==null);return{addonId:n.id,displayName:n.packageDisplayName??n.name??n.id,capNames:r,processState:t?.process?.state??null}}function He(e,t){return Object.entries(e).filter(([,e])=>e===t).map(([e])=>e)}function Ue(e,t){return t.find(t=>e.capNames.includes(t))??null}function We(e){switch(e){case`running`:return{state:`ok`,label:G.t(`helpers.connectivityModel.running`)};case`crashed`:case`failed`:return{state:`error`,label:e};case`stopped`:case`disabled`:return{state:`off`,label:G.t(`helpers.connectivityModel.stopped`)};default:return{state:`unknown`,label:e??G.t(`common.unknownWord`)}}}c();var Ge=[`wasteCollections`,`listSources`],Ke=[`wasteCollections`,`listCountries`];function qe(e){return e instanceof Error?e.message:String(e)}function Je(e){return typeof e!=`object`||!e?!1:Array.isArray(Reflect.get(e,`sections`))}function Ye(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(typeof n!=`object`||!n)continue;let e=Reflect.get(n,`id`),r=Reflect.get(n,`label`),i=Reflect.get(n,`module`);if(typeof e!=`string`||typeof r!=`string`||typeof i!=`string`)continue;let a=Reflect.get(n,`enabled`),o=Reflect.get(n,`formValues`),s=Reflect.get(n,`serviceId`),c=Reflect.get(n,`countryId`);t.push({id:e,label:r,module:i,enabled:typeof a==`boolean`?a:!0,formValues:typeof o==`object`&&o&&!Array.isArray(o)?o:void 0,serviceId:typeof s==`string`?s:void 0,countryId:typeof c==`string`?c:void 0})}return t}function Xe(e){return Array.isArray(e)?e.flatMap(e=>{if(typeof e!=`object`||!e)return[];let t=Reflect.get(e,`id`),n=Reflect.get(e,`label`);return typeof t!=`string`||typeof n!=`string`?[]:[{id:t,label:n}]}):[]}function Ze(e){return Array.isArray(e)?e.flatMap(e=>{if(typeof e!=`object`||!e)return[];let t=Reflect.get(e,`id`),n=Reflect.get(e,`label`),r=Reflect.get(e,`module`);if(typeof t!=`string`||typeof n!=`string`||typeof r!=`string`)return[];let i=Reflect.get(e,`title`);return[{id:t,label:n,title:typeof i==`string`&&i.length>0?i:n,module:r}]}):[]}function Qe(e,t,n){return{sections:[{id:`picker`,title:G.t(`system.wasteSettingsSources.countryService`,`Country & service`),columns:2,fields:[{type:`select`,key:`countryId`,label:G.t(`system.wasteSettingsSources.country`,`Country`),options:[{value:``,label:G.t(`system.wasteSettingsSources.selectCountry`,`Select country…`)},...e.map(e=>({value:e.id,label:e.label}))]},{type:`select`,key:`serviceId`,label:G.t(`system.wasteSettingsSources.service`,`Service`),options:[{value:``,label:n===``?G.t(`system.wasteSettingsSources.pickACountryFirst`,`Pick a country first`):G.t(`system.wasteSettingsSources.selectService`,`Select service…`)},...t.map(e=>({value:e.id,label:e.label}))]}]}]}}function $e({addonId:c,capName:p}){let{t:h}=K(),g=v(),_=l(),y=re(),b=de({editKey:`wasteEdit`,newKey:`wasteNew`}),[x,S]=o(!1),[ee,C]=o(null),[w,T]=o({countryId:``,serviceId:``}),[E,D]=o({label:h(`system.wasteSettingsSources.newSource`,`New source`),enabled:!0}),O=t(null),k=typeof w.countryId==`string`?w.countryId:``,A=typeof w.serviceId==`string`?w.serviceId:``,j=r((e,t)=>g.trpcClient.addons.custom.mutate({addonId:c,action:e,input:t}),[c,g]),M=s({queryKey:[...Ge,c],queryFn:async()=>Ye(await j(`listSources`,{}))}),ie=s({queryKey:[...Ke,c],queryFn:async()=>Xe(await j(`listCountries`,{}))}),ae=s({queryKey:[`wasteCollections`,`listServices`,c,k],enabled:k!==``,queryFn:async()=>Ze(await j(`listServices`,{countryId:k}))}),N=s({queryKey:[`wasteCollections`,`serviceFormSchema`,c,A],enabled:A!==``,queryFn:async()=>j(`serviceFormSchema`,{serviceId:A})}),P=M.data??[],I=ie.data??[],L=ae.data??[],oe=Je(N.data)?N.data:void 0,se=n(()=>Qe(I,k===``?[]:L,k),[I,L,k]),R=b.state,z=R.mode===`edit`?P.find(e=>e.id===R.id)??null:null;a(()=>{if(b.state.mode===`edit`&&z!==null){let e=`edit:${z.id}`;if(O.current===e)return;O.current=e,C(null),T({countryId:z.countryId??``,serviceId:z.serviceId??``}),D(z.formValues===void 0?{label:z.label,enabled:z.enabled}:{...z.formValues});return}if(b.state.mode===`new`){if(O.current===`new`)return;O.current=`new`,C(null),T({countryId:``,serviceId:``}),D({label:h(`system.wasteSettingsSources.newSource`,`New source`),enabled:!0})}},[z,b.state]),a(()=>{if(b.state.mode!==`new`||A===``)return;let e=L.find(e=>e.id===A);e&&D(t=>{let n=t.label;return typeof n==`string`&&n!==``&&n!==`New source`?t:{...t,label:e.title}})},[b.state.mode,A,L]);let ue=r(e=>{T(t=>{let n=typeof e.countryId==`string`?e.countryId:``;return n===(typeof t.countryId==`string`?t.countryId:``)?e:{countryId:n,serviceId:``}})},[]),V=r(async()=>{await _.invalidateQueries({queryKey:Ge})},[_]),H=u({mutationFn:async e=>j(`deleteSource`,{id:e}),onSuccess:async()=>V()}),U=r(async e=>{await y({title:h(`system.wasteSettingsSources.deleteWasteSource`,`Delete waste source?`),message:h(`system.wasteSettingsSources.removeItsCalendarUnderSystem`,`Remove “{{label}}” ({{id}}). Its calendar under System → Calendars is dropped.`,{label:e.label,id:e.id}),confirmLabel:h(`common.delete`,`Delete`),cancelLabel:h(`common.cancel`,`Cancel`),variant:`danger`})&&(await H.mutateAsync(e.id),b.state.mode===`edit`&&b.state.id===e.id&&(b.close(),O.current=null))},[y,H,b,h]),W=r(async()=>{let e=E.label,t=typeof e==`string`&&e.trim()!==``?e.trim():``;if(t===``){C(`Label is required.`);return}if(A===``){C(`Pick a country and a service.`);return}let n=b.state.mode===`new`,r=z?.id;if(!n&&(r===void 0||r===``)){C(`That source is no longer available.`);return}let i=E.enabled,a={...E};delete a.label,delete a.enabled,S(!0),C(null);try{n?await j(`createSource`,{label:t,serviceId:A,args:a,enabled:typeof i==`boolean`?i:!0}):r!==void 0&&await j(`updateSource`,{id:r,label:t,serviceId:A,args:a,enabled:typeof i==`boolean`?i:!0}),await V(),b.close(),O.current=null}catch(e){C(qe(e))}finally{S(!1)}},[j,z,b,E,V,A]),pe=n(()=>[{key:`label`,header:h(`system.wasteSettingsSources.label`,`Label`),sortValue:e=>e.label,render:e=>i(`span`,{className:`text-sm text-foreground`,children:e.label})},{key:`module`,header:h(`system.wasteSettingsSources.module`,`Module`),sortValue:e=>e.module,render:e=>i(`span`,{className:`font-mono text-xs text-foreground-muted`,children:e.module})},{key:`enabled`,header:h(`system.wasteSettingsSources.enabled`,`Enabled`),sortValue:e=>+!!e.enabled,render:e=>i(B,{variant:e.enabled?`success`:`default`,children:e.enabled?h(`system.wasteSettingsSources.on`,`On`):h(`system.wasteSettingsSources.off`,`Off`)})},{key:`actions`,header:``,notSortableReason:`actions`,render:e=>i(F,{type:`button`,size:`sm`,variant:`ghost`,"aria-label":h(`system.wasteSettingsSources.delete`,`Delete {{label}}`,{label:e.label}),"data-testid":`waste-source-delete-${e.id}`,onClick:t=>{t.stopPropagation(),U(e)},children:i(m,{className:`h-3.5 w-3.5 text-danger`})})}],[U,h]),G=b.state.mode===`new`,q=G||z!==null,me=`${A}:${G?`new`:z?.id??`closed`}`;return e(`div`,{className:`flex min-h-0 flex-col gap-4`,"data-testid":`waste-settings-sources`,children:[e(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[i(`p`,{className:`text-sm text-foreground-muted`,children:h(`system.wasteSettingsSources.pickACountryAndA`,`Pick a country and a service — configuration fields come from that HACS source.`)}),e(F,{type:`button`,size:`sm`,"data-testid":`waste-sources-add`,onClick:()=>b.openNew(),children:[i(f,{className:`h-3.5 w-3.5`}),h(`system.wasteSettingsSources.addSource`,`Add source`)]})]}),M.isError?i(`p`,{className:`text-sm text-danger`,children:h(`system.wasteSettingsSources.couldNotLoadSources`,`Could not load sources.`)}):null,M.isPending?i(le,{className:`h-32 w-full`}):i(ne,{columns:pe,rows:P,rowKey:e=>e.id,pageSize:25,emptyMessage:h(`system.wasteSettingsSources.noWasteSourcesYetAdd`,`No waste sources yet. Add one to register a municipal service.`),onRowClick:e=>b.openEdit(e.id),defaultSort:{columnKey:`label`,dir:`asc`}}),i(ce,{open:q,onClose:()=>{b.close(),C(null),O.current=null},title:G?h(`system.wasteSettingsSources.addWasteSource`,`Add waste source`):h(`system.wasteSettingsSources.edit`,`Edit {{value1}}`,{value1:z?.label??`source`}),icon:te,width:`xl`,testId:`waste-source-editor`,error:ee,footer:i(F,{type:`button`,size:`sm`,disabled:x||A===``,onClick:()=>void W(),children:x?h(`system.wasteSettingsSources.saving`,`Saving…`):h(`common.save`,`Save`)}),children:q?e(d,{children:[i(`div`,{"data-testid":`waste-country-service`,children:i(fe,{schema:se,values:w,onChange:ue},`picker:${k}:${L.length}`)}),A!==``&&oe!==void 0?i(fe,{schema:oe,values:E,onChange:D,bare:!0},me):A!==``&&N.isPending?i(`p`,{className:`text-sm text-foreground-muted`,children:h(`system.wasteSettingsSources.loadingFields`,`Loading fields…`)}):i(`p`,{className:`text-sm text-foreground-muted`,children:h(`system.wasteSettingsSources.chooseACountryAndService`,`Choose a country and service to see the required fields.`)})]}):null}),i(be,{nodeId:`hub`,addonIds:[c],level:`global`,capability:p,hideSectionChrome:!0})]})}c();var $=1e4,et={"device-export":`exporters`,exporters:`exporters`,email:`email`,broker:`brokers`,brokers:`brokers`,"message-brokers":`brokers`,calendar:`calendars`,calendars:`calendars`,"calendar-source":`calendars`},tt=[{sectionId:`exporters`,kind:`device-export`,labelKey:`system.connectivity.exporters`,icon:x,installLabelKey:`system.connectivity.exportersInstall`,emptyTitleKey:`system.connectivity.exportersEmptyTitle`,emptyDescriptionKey:`system.connectivity.exportersEmptyDescription`},{sectionId:`email`,kind:`email`,labelKey:`system.connectivity.email`,icon:y,installLabelKey:`system.connectivity.emailInstall`,emptyTitleKey:`system.connectivity.emailEmptyTitle`,emptyDescriptionKey:`system.connectivity.emailEmptyDescription`},{sectionId:`brokers`,kind:`broker`,labelKey:`system.connectivity.brokers`,icon:h,installLabelKey:`system.connectivity.brokersInstall`,emptyTitleKey:`system.connectivity.brokersEmptyTitle`,emptyDescriptionKey:`system.connectivity.brokersEmptyDescription`},{sectionId:`calendars`,kind:`calendar`,labelKey:`system.connectivity.calendars`,icon:w,installLabelKey:`system.connectivity.calendarsInstall`,emptyTitleKey:`system.connectivity.calendarsEmptyTitle`,emptyDescriptionKey:`system.connectivity.calendarsEmptyDescription`}];function nt(t,n,r,a){let o=He(ee,t.kind),s=n.flatMap(n=>{let a=Ue(n,o);if(a===null)return[];let s=We(n.processState);return[{id:n.addonId,name:n.displayName,fallbackIcon:t.icon,state:s.state,stateLabel:s.label,render:()=>i(xe,{addonId:n.addonId,displayName:n.displayName,capName:a,isActive:n.processState===`running`,badges:e(d,{children:[i(ot,{processState:n.processState}),i(st,{kind:t.kind,addonId:n.addonId})]}),lead:t.kind===`device-export`?i(R,{addonId:n.addonId}):void 0,panels:at(t.kind,n.addonId,e=>r(`/devices/${e}`)),settingsContent:n.addonId===`waste-collections`?i($e,{addonId:n.addonId,capName:a}):void 0})}]});return{id:t.sectionId,label:a(t.labelKey),entries:s,install:{capability:o[0]??t.kind,label:a(t.installLabelKey)}}}function rt({descriptor:e,rows:t,isLoading:r}){let{t:a}=K(),o=_e(),s=n(()=>nt(e,t,o,a),[e,t,o,a]);return i(Se,{embedded:!0,icon:e.icon,title:a(e.labelKey),subtitle:null,groups:[s],isLoading:r,emptyTitle:a(e.emptyTitleKey),emptyDescription:a(e.emptyDescriptionKey)})}function it(){let{t:e}=K(),t=O(void 0,{refetchInterval:$}),[r,o]=he(),s=me(`/system/integrations`,{t:e,isAdmin:!0})??{icon:_,title:e(`admin.system.integrations.connectivity`,`Connectivity`)};a(()=>{let e=r.get(`tab`);if(e===null)return;let t=et[e];t===void 0||t===e||o(e=>{let n=new URLSearchParams(e);return n.set(`tab`,t),n},{replace:!0})},[r,o]);let c=n(()=>(t.data??[]).map(Ve).filter(e=>e!==null),[t.data]),l=n(()=>tt.map(n=>({id:n.sectionId,label:e(n.labelKey),ownedParams:ge,content:i(rt,{descriptor:n,rows:c,isLoading:t.isLoading})})),[t.isLoading,c,e]);return i(ve,{icon:s.icon,title:s.title,subtitle:e(`admin.system.integrations.externalSystemsThisHubTalks`,`External systems this hub talks to — exporters, email, brokers and calendar sources.`),defaultSection:`exporters`,sectionsLabel:`Connectivity sections`,sections:l})}function at(e,t,n){return e===`device-export`?[{id:`devices`,title:G.t(`admin.system.integrations.devices`,`Devices`),icon:D,placement:`end`,content:i(M,{addonId:t,onOpenDevice:n,showSetup:!1})}]:e===`broker`?[{id:`connections`,title:G.t(`admin.system.integrations.connections`,`Connections`),icon:h,content:i(Re,{addonId:t,fallback:i(Le,{addonId:t})})}]:[]}function ot({processState:e}){let{state:t,label:n}=We(e);return i(B,{variant:t===`ok`?`success`:t===`error`?`danger`:`default`,className:`${Y} capitalize`,children:n})}function st({kind:e,addonId:t}){return e===`broker`?i(ct,{addonId:t}):e===`device-export`?i(lt,{addonId:t}):null}function ct({addonId:e}){let{t}=K(),{data:n}=pe({addonId:e},{refetchInterval:$,retry:!1}),r=C.safeParse(n);if(!r.success)return null;let{brokerCount:a,connectedCount:o}=r.data;return i(B,{variant:`info`,className:Y,children:o>0?t(`system.connectivity.connectionsConnected`,{count:a,connected:o}):t(`system.connectivity.connections`,{count:a})})}function lt({addonId:e}){let{t}=K(),{data:n}=j({addonId:e},{refetchInterval:$,retry:!1}),r=S.safeParse(n);if(!r.success)return null;let{linkState:a,exposedDeviceCount:o}=r.data;return i(B,{variant:a===`linked`?`success`:a===`error`?`danger`:`default`,className:Y,children:t(`admin.system.integrations.exposed`,`{{linkState}} · {{exposedDeviceCount}} exposed`,{linkState:a,exposedDeviceCount:o})})}export{it as IntegrationsPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{C as e,J as t,K as n,R as r,S as i,V as a,Y as o,et as s,x as c}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{Ci as l,Gr as u,Pt as d,Q as f,Vr as p,dt as m,sr as h,wn as g,xi as _,xn as v}from"./player-overlays-BT3xIHAn.js";import{Ja as y,Za as b}from"./client-CgAb3Nw-.js";import{$a as x,Si as S,So as C,Ss as w,ba as T,fo as E,ha as D,jo as O,uo as k,xa as A}from"./src-DX_JbsFG.js";import{t as j}from"./useTranslation-BJr-n0es.js";import"./mount-DF4u2b9z.js";import{P as M,ur as N}from"./index-Cgn0pmzp.js";import{t as P}from"./BrokerForm-pprTt8-v.js";s();var F=[`amazon.com`,`amazon.it`,`amazon.de`,`amazon.co.uk`,`amazon.fr`,`amazon.es`,`amazon.ca`,`amazon.com.au`,`amazon.co.jp`,`amazon.in`,`amazon.com.br`,`amazon.com.mx`],I=f(`/addon/import-alexa`),L=2e3;function R(e){return typeof e==`object`&&!!e&&typeof e.sessionId==`string`&&typeof e.loginUrl==`string`}function z(e){return typeof e==`object`&&!!e&&typeof e.phase==`string`&&typeof e.sessionId==`string`}function ee(e){return typeof e==`object`&&!!e&&typeof e.brokerId==`string`}function B(e){return{"Content-Type":`application/json`,Authorization:`Bearer ${localStorage.getItem(`camstack_admin_token`)??``}`,...e}}async function V(e,t,n){let r=await fetch(`${I}${e}`,{method:`POST`,headers:B(),body:JSON.stringify(t)}),i=await r.json();if(!r.ok){let e=typeof i==`object`&&i?i.error??`Unknown error`:`Unknown error`;throw Error(String(e))}if(!n(i))throw Error(`Unexpected response from server`);return i}async function H(e){let t=new URLSearchParams({sessionId:e}),n=localStorage.getItem(`camstack_admin_token`)??``,r=await fetch(`${I}/login/status?${t.toString()}`,{headers:{Authorization:`Bearer ${n}`}}),i=await r.json();if(!r.ok){let e=typeof i==`object`&&i?i.error??`Unknown error`:`Unknown error`;throw Error(String(e))}if(!z(i))throw Error(`Unexpected status response from server`);return i}async function U(e){try{await fetch(`${I}/login/cancel`,{method:`POST`,headers:B(),body:JSON.stringify({sessionId:e})})}catch{}}function W({brokerId:n,onResolved:s,onCancel:c}){let{t:l}=j(),[u,f]=o(`amazon.it`),[m,g]=o(`Alexa account`),[_,y]=o({kind:`idle`}),b=t(!0);a(()=>(b.current=!0,()=>{b.current=!1}),[]);let x=t(null),S=t(null),C=r(()=>{S.current!==null&&(clearInterval(S.current),S.current=null)},[]),w=r(async e=>{C(),b.current&&y({kind:`committing`,sessionId:e});try{let t=await V(`/login/commit`,{sessionId:e,name:m.trim().length>0?m.trim():`Alexa account`,...n===void 0?{}:{brokerId:n}},ee);x.current=null,s(t.brokerId)}catch(t){let n=t instanceof Error?t.message:String(t);b.current&&y({kind:`error`,message:n,sessionId:e})}},[n,m,s,C]),T=r((e,t)=>{C();let n=async()=>{try{let n=await H(e);if(n.phase===`captured`){C(),w(e);return}if(n.phase===`error`){C(),b.current&&y({kind:`error`,message:n.error??l(`integrations.alexaLoginStep.loginProxyReturnedAnError`,`Login proxy returned an error`),sessionId:e});return}if(n.phase===`cancelled`){C(),b.current&&y({kind:`idle`});return}b.current&&y({kind:`polling`,sessionId:e,loginUrl:n.loginUrl||t,phase:n.phase})}catch(e){let t=e instanceof Error?e.message:String(e);b.current&&y(e=>e.kind===`polling`?{...e}:{kind:`error`,message:t,sessionId:null})}};S.current=setInterval(()=>{n()},L)},[C,w,l]);a(()=>()=>{C(),x.current!==null&&U(x.current)},[C]);let E=async()=>{C(),x.current!==null&&(U(x.current),x.current=null),y({kind:`starting`});try{let e=await V(`/login/start`,{amazonDomain:u},R);x.current=e.sessionId,y({kind:`polling`,sessionId:e.sessionId,loginUrl:e.loginUrl,phase:`starting`}),T(e.sessionId,e.loginUrl)}catch(e){y({kind:`error`,message:e instanceof Error?e.message:String(e),sessionId:null})}},D=()=>{C(),x.current!==null&&(U(x.current),x.current=null),y({kind:`idle`})},O=()=>{D()},k=_.kind===`idle`,A=_.kind===`starting`,M=_.kind===`polling`,P=_.kind===`committing`,I=_.kind===`error`,z=A||M||P,B=_.kind===`polling`?_.phase:null,W=_.kind===`polling`?_.loginUrl:null,G=M&&B===`awaiting-login`,K=M&&(B===`starting`||B===null);return e(`div`,{className:`space-y-4`,children:[(k||I)&&e(`div`,{className:`space-y-3`,children:[n===void 0&&e(`div`,{className:`space-y-1`,children:[i(`label`,{htmlFor:`alexa-account-name`,className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:l(`integrations.alexaLoginStep.accountName`,`Account name`)}),i(`input`,{id:`alexa-account-name`,type:`text`,value:m,onChange:e=>g(e.target.value),placeholder:l(`integrations.alexaLoginStep.alexaAccount`,`Alexa account`),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`})]}),e(`div`,{className:`space-y-1`,children:[i(`label`,{htmlFor:`alexa-amazon-region`,className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:l(`integrations.alexaLoginStep.amazonRegion`,`Amazon region`)}),i(`select`,{id:`alexa-amazon-region`,value:u,onChange:e=>f(e.target.value),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`,children:F.map(e=>i(`option`,{value:e,children:e},e))})]})]}),I&&e(`div`,{className:`rounded border border-danger/30 bg-danger/5 text-danger px-3 py-2 text-[11px] flex items-start gap-2`,children:[i(d,{className:`h-3.5 w-3.5 mt-0.5 flex-shrink-0`}),i(`span`,{children:_.message})]}),A&&e(`div`,{className:`flex items-center gap-2 rounded-lg border border-border bg-surface px-3 py-3 text-xs text-foreground-subtle`,children:[i(h,{className:`h-4 w-4 animate-spin flex-shrink-0`}),l(`integrations.alexaLoginStep.startingLoginProxy`,`Starting login proxy…`)]}),K&&e(`div`,{className:`flex items-center gap-2 rounded-lg border border-border bg-surface px-3 py-3 text-xs text-foreground-subtle`,children:[i(h,{className:`h-4 w-4 animate-spin flex-shrink-0`}),l(`integrations.alexaLoginStep.waitingForProxyToBe`,`Waiting for proxy to be ready…`)]}),P&&e(`div`,{className:`flex items-center gap-2 rounded-lg border border-border bg-surface px-3 py-3 text-xs text-foreground-subtle`,children:[i(h,{className:`h-4 w-4 animate-spin flex-shrink-0`}),l(`integrations.alexaLoginStep.savingCredentials`,`Saving credentials…`)]}),G&&W!==null&&e(`div`,{className:`space-y-3`,children:[e(`div`,{className:`rounded-lg border border-border bg-surface p-3 space-y-2`,children:[i(`p`,{className:`text-xs font-semibold text-foreground`,children:l(`integrations.alexaLoginStep.openTheLinkBelowTo`,`Open the link below to log in to your Amazon account`)}),i(`p`,{className:`text-[10px] text-foreground-subtle`,children:l(`integrations.alexaLoginStep.afterCompletingTheLoginAnd`,`After completing the login and any 2FA steps, this wizard will continue automatically.`)}),e(`a`,{href:W,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1.5 rounded bg-primary px-4 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90`,children:[i(p,{className:`h-3.5 w-3.5`}),l(`integrations.alexaLoginStep.loginToAmazon`,`Login to Amazon`)]})]}),i(`div`,{className:`rounded border border-warning/30 bg-warning/10 px-3 py-2 text-[10px] text-warning`,children:i(N,{i18nKey:`integrations.alexaLoginStep.proxyNote`,components:{b:i(`strong`,{}),code:i(`code`,{className:`font-mono`})}})}),e(`div`,{className:`flex items-center gap-2 text-[10px] text-foreground-subtle`,children:[i(h,{className:`h-3 w-3 animate-spin`}),l(`integrations.alexaLoginStep.waitingForAmazonLoginTo`,`Waiting for Amazon login to complete…`)]})]}),e(`div`,{className:`flex items-center justify-between gap-2 pt-1`,children:[i(`button`,{type:`button`,onClick:z?D:c,className:`rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground`,children:z?l(`integrations.alexaLoginStep.cancelLogin`,`Cancel login`):l(`common.back`,`Back`)}),e(`div`,{className:`flex items-center gap-2`,children:[I&&e(`button`,{type:`button`,onClick:O,className:`inline-flex items-center gap-1.5 rounded border border-border px-3 py-1.5 text-xs text-foreground hover:bg-primary/10`,children:[i(v,{className:`h-3.5 w-3.5`}),l(`common.retry`,`Retry`)]}),k&&i(`button`,{type:`button`,onClick:()=>{E()},disabled:n===void 0&&m.trim().length===0,className:`inline-flex items-center gap-1.5 rounded bg-primary px-4 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50`,children:l(`integrations.alexaLoginStep.startLogin`,`Start login`)})]})]})]})}s();var G=`alexa`;function K(e){return Array.isArray(e)?e.filter(e=>typeof e==`object`&&!!e&&typeof e.id==`string`):[]}function q(e){return Array.isArray(e)?e.filter(e=>typeof e==`object`&&!!e&&typeof e.addonId==`string`&&Array.isArray(e.kinds)):[]}var J={connected:`bg-success/15 text-success`,connecting:`bg-warning/15 text-warning`,disconnected:`bg-foreground-subtle/15 text-foreground-subtle`,"auth-failed":`bg-danger/15 text-danger`,unreachable:`bg-danger/15 text-danger`,error:`bg-danger/15 text-danger`};function Y({kind:t,onResolved:r,onBack:a}){let{t:s}=j(),[c,l]=o(t===G?`alexa-login`:`existing`),u=T({kind:t}),d=n(()=>K(u.data).filter(e=>e.kind===t),[u.data,t]),f=A(),p=n(()=>{for(let e of q(f.data))if(e.kinds.some(e=>e.kind===t))return e.addonId},[f.data,t]),[m,g]=o(null),[v,y]=o(``),b=D({}),x=()=>{m&&r(m)},S=async e=>{v.trim().length!==0&&r((await b.mutateAsync({kind:t,name:v.trim(),settings:e,...p===void 0?{}:{addonId:p}})).id)},C=e=>{e===`new`?g(null):b.reset(),l(e)};return e(`div`,{className:`space-y-4`,children:[e(`button`,{type:`button`,onClick:a,className:`inline-flex items-center gap-1 text-[11px] text-foreground-subtle hover:text-foreground`,children:[i(_,{className:`h-3.5 w-3.5`}),` `,s(`common.back`)]}),e(`div`,{className:`inline-flex rounded-lg border border-border p-0.5 flex-wrap gap-0.5`,children:[t===G&&i(`button`,{type:`button`,onClick:()=>C(`alexa-login`),className:`rounded-md px-3 py-1 text-xs font-medium transition-colors ${c===`alexa-login`?`bg-primary text-primary-foreground`:`text-foreground-subtle hover:text-foreground`}`,children:s(`integrations.brokerStep.loginInteractively`,`Login interactively`)}),i(`button`,{type:`button`,onClick:()=>C(`existing`),className:`rounded-md px-3 py-1 text-xs font-medium transition-colors ${c===`existing`?`bg-primary text-primary-foreground`:`text-foreground-subtle hover:text-foreground`}`,children:s(`integrations.brokerStep.useExisting`,`Use existing`)}),i(`button`,{type:`button`,onClick:()=>C(`new`),className:`rounded-md px-3 py-1 text-xs font-medium transition-colors ${c===`new`?`bg-primary text-primary-foreground`:`text-foreground-subtle hover:text-foreground`}`,children:t===G?s(`integrations.brokerStep.pasteCookie`,`Paste cookie`):s(`integrations.brokerStep.createNew`,`Create new`)})]}),c===`alexa-login`&&i(W,{onResolved:r,onCancel:a}),c===`existing`&&e(`div`,{className:`space-y-3`,children:[u.isLoading&&e(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[i(h,{className:`h-3.5 w-3.5 animate-spin`}),` `,s(`integrations.brokerStep.loadingBrokers`)]}),u.isError&&e(`div`,{className:`rounded border border-danger/30 bg-danger/5 text-danger px-3 py-2 text-[11px]`,children:[s(`integrations.brokerStep.failedToLoadBrokers`,`Failed to load brokers:`),` `,u.error instanceof Error?u.error.message:s(`integrations.brokerStep.unknownError`,`Unknown error`)]}),!u.isLoading&&!u.isError&&d.length===0&&i(`div`,{className:`rounded-lg border border-border bg-surface px-3 py-6 text-center text-xs text-foreground-subtle`,children:i(N,{i18nKey:`integrations.brokerStep.noBrokers`,values:{mode:t===G?s(`integrations.brokerStep.loginInteractively`,`Login interactively`):s(`integrations.brokerStep.createNew`,`Create new`)},components:{b:i(`span`,{className:`font-medium text-foreground`})}})}),i(`div`,{className:`space-y-2`,children:d.map(t=>e(`button`,{type:`button`,onClick:()=>g(t.id),className:`flex w-full items-center justify-between gap-3 rounded-lg border bg-surface p-3 text-left transition-colors ${m===t.id?`border-primary ring-1 ring-primary`:`border-border hover:border-foreground-subtle/30`}`,children:[i(`span`,{className:`text-xs font-semibold text-foreground`,children:t.name}),i(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium ${J[t.status]}`,children:t.status})]},t.id))}),d.length>0&&i(`div`,{className:`flex justify-end pt-1`,children:i(`button`,{type:`button`,onClick:x,disabled:!m,className:`inline-flex items-center gap-1.5 rounded bg-primary px-4 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50`,children:s(`integrations.brokerStep.useThisBroker`,`Use this broker`)})})]}),c===`new`&&e(`div`,{className:`space-y-3`,children:[e(`div`,{className:`space-y-1`,children:[i(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:s(`integrations.brokerStep.name`,`Name`)}),i(`input`,{type:`text`,value:v,onChange:e=>y(e.target.value),placeholder:s(`integrations.brokerStep.myHomeAssistant`,`My Home Assistant`),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`})]}),b.isError&&i(`div`,{className:`rounded border border-danger/30 bg-danger/5 text-danger px-3 py-2 text-[11px]`,children:b.error instanceof Error?b.error.message:String(b.error)}),i(P,{kind:t,...p===void 0?{}:{addonId:p},onSubmit:e=>{S(e).catch(()=>{})},onCancel:a,submitLabel:b.isPending?s(`integrations.brokerStep.creating`,`Creating…`):s(`integrations.brokerStep.createBroker`,`Create broker`),disabled:b.isPending||v.trim().length===0}),v.trim().length===0&&i(`p`,{className:`text-[10px] text-foreground-subtle`,children:s(`integrations.brokerStep.enterANameBeforeCreating`,`Enter a name before creating.`)})]})]})}s();function X(e){return{status:e.status===`validated`||e.status===`rejected`||e.status===`inconclusive`||e.status===`unsupported`?e.status:e.success?`validated`:`rejected`,...e.error===void 0?{}:{error:e.error},...e.detail===void 0?{}:{detail:e.detail}}}var Z={validated:`border-success/30 bg-success/5 text-success`,rejected:`border-danger/30 bg-danger/5 text-danger`,inconclusive:`border-warning/30 bg-warning/5 text-warning`,unsupported:`border-border bg-surface text-foreground-subtle`};function te({addonId:t,configSchema:n,canTest:r=!0,initialName:a,initialConfig:s,submitLabel:c,hideName:l=!1,onSave:u,onBack:d}){let{t:f}=j(),[p,m]=o(a??``),[h,g]=o(s??{}),[_,v]=o(null),x=w({onSuccess:e=>v(X(e)),onError:e=>v({status:`inconclusive`,error:String(e)})}),C=S(),T=!r||_?.status===`validated`,E=!l&&p.trim().length===0,D=!E&&T;return e(`div`,{className:`space-y-4`,children:[!l&&e(`div`,{children:[i(`label`,{htmlFor:`integration-name`,className:`block text-[11px] font-medium text-foreground mb-1`,children:f(`integrations.integrationName`)}),i(`input`,{id:`integration-name`,type:`text`,value:p,onChange:e=>m(e.target.value),placeholder:f(`integrations.integrationNamePlaceholder`),"aria-invalid":E,"aria-describedby":E?`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 ${E?`border-danger focus:border-danger`:`border-border focus:border-primary/50`}`}),E&&i(`p`,{id:`integration-name-error`,"data-testid":`integration-name-error`,className:`mt-1 text-xs text-danger`,children:f(`integrations.nameRequired`,`Name is required`)})]}),n&&i(M,{schema:n,values:h,onChange:e=>{g(e),v(null)},onAction:async(e,i,a)=>{let o=await C.mutateAsync({addonId:t,action:e,input:a??{}});if(r&&typeof o==`object`&&o){let e=o;if(!(typeof e.token==`string`||typeof e.sslCertificate==`string`||typeof e.host==`string`))return o;let r={...h};for(let[t,n]of Object.entries(e))typeof n==`string`&&t!==`summary`&&(r[t]=n);let i=b(n,r);g(i),v(null),x.mutate({addonId:t,settings:i})}return o}}),_&&i(`div`,{className:`rounded-lg border px-3 py-2 text-xs ${Z[_.status]}`,children:(e=>{switch(e.status){case`validated`:return e.detail?`${f(`integrations.connectionSuccess`)} — ${e.detail}`:f(`integrations.connectionSuccess`);case`rejected`:return`${f(`integrations.errorPrefix`)} ${e.error??``}`;case`inconclusive`:return`${f(`integrations.connectionInconclusive`,{defaultValue:`Could not be checked:`})} ${e.error??``}`;case`unsupported`:return e.error??f(`integrations.connectionUntestable`,{defaultValue:`This integration cannot be tested before it is created.`})}})(_)}),e(`div`,{className:`flex items-center justify-between pt-2`,children:[i(`button`,{onClick:d,className:`rounded-lg border border-border px-3 py-1.5 text-xs text-foreground-subtle hover:text-foreground transition-colors`,children:f(`integrations.back`)}),e(`div`,{className:`flex items-center gap-2`,children:[i(`button`,{onClick:()=>x.mutate({addonId:t,settings:b(n,h)}),disabled:x.isPending||!r,title:r?void 0:f(`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:x.isPending?f(`integrations.testing`):f(`integrations.testConnection`)}),e(`div`,{className:`flex flex-col items-end gap-1`,children:[E&&i(`p`,{"data-testid":`integration-name-submit-error`,className:`text-xs text-danger`,children:f(`integrations.nameRequiredSubmit`,`Enter a name before continuing.`)}),i(`button`,{onClick:()=>{E||u({name:p,config:b(n,h),secretKeys:[...y(n)]})},disabled:!D,className:`rounded-lg bg-primary px-4 py-1.5 text-xs font-medium text-primary-foreground shadow-sm disabled:opacity-50`,children:c??f(`integrations.forward`)})]})]})]})]})}function ne(e,t){if(t.prefilledConfig.setupIntegration!==!0)return null;let n=t.prefilledConfig.host;return typeof n!=`string`||n.trim().length===0?null:{addonId:e,name:t.suggestedName,config:{host:n.trim()}}}function Q(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function re(e){if(!Q(e)||!Q(e.integrationSeed))return null;let t=e.integrationSeed,n=t.addonId,r=t.name,i=t.config;if(typeof n!=`string`||n.length===0||typeof r!=`string`||!Q(i))return null;let a={};for(let[e,t]of Object.entries(i))a[e]=t;return{addonId:n,name:r,config:a}}s();function ie({open:t,onClose:a,scope:s,onSetupIntegration:c}){let{t:d}=j(),f=x(),[p,_]=o(new Set),[v,y]=o(new Set),{data:b}=C({projection:`slim`}),S=n(()=>new Set((b??[]).map(e=>e.stableId)),[b]),w=r(async(e,t)=>{let n=ne(e,t);if(n!==null){c?.(n),a();return}y(e=>new Set(e).add(t.stableId));try{await f.mutateAsync({addonId:e,candidate:t}),_(e=>new Set(e).add(t.stableId))}catch{}finally{y(e=>{let n=new Set(e);return n.delete(t.stableId),n})}},[f,a,c]),T=r((t,n)=>{let r=typeof n.prefilledConfig.host==`string`?n.prefilledConfig.host:null,a=S.has(n.stableId),o=p.has(n.stableId)||a,s=v.has(n.stableId);return e(`div`,{className:`flex items-center justify-between rounded-lg border border-border bg-surface px-3 py-2`,children:[e(`div`,{className:`min-w-0`,children:[i(`p`,{className:`truncate text-xs font-medium text-foreground`,children:n.suggestedName}),r&&i(`p`,{className:`truncate text-[10px] font-mono text-foreground-subtle`,children:r})]}),o?e(`span`,{className:`flex items-center gap-1 text-[11px] text-foreground-subtle`,children:[i(l,{className:`h-3.5 w-3.5`}),` `,a?d(`integrations.scanNetworkModal.alreadyAdded`,`Already added`):d(`integrations.scanNetworkModal.added`,`Added`)]}):e(`button`,{type:`button`,onClick:()=>void w(t,n),disabled:s,className:`flex items-center gap-1 rounded-md bg-primary px-2.5 py-1 text-[11px] font-medium text-primary-foreground disabled:opacity-50`,children:[s?i(h,{className:`h-3.5 w-3.5 animate-spin`}):i(u,{className:`h-3.5 w-3.5`}),d(`common.add`,`Add`)]})]},n.stableId)},[p,v,S,w,d]);if(!t)return null;let E=s?`Scan network — ${s.label}`:`Scan network for devices`;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:a}),e(`div`,{className:`relative z-10 flex w-full max-w-2xl flex-col max-h-[calc(90dvh-2*max(env(safe-area-inset-top),env(safe-area-inset-bottom)))] rounded-xl border border-border bg-background shadow-2xl`,children:[e(`div`,{className:`flex items-center justify-between border-b border-border px-5 py-4 shrink-0`,children:[e(`div`,{className:`flex items-center gap-2`,children:[i(g,{className:`h-4 w-4 text-primary`}),i(`h2`,{className:`text-sm font-semibold text-foreground`,children:E})]}),i(`button`,{onClick:a,className:`rounded-md p-1 text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,children:i(m,{className:`h-4 w-4`})})]}),s?i(oe,{scope:s,onAdopt:T,onReset:()=>_(new Set)}):i(ae,{onAdopt:T,onReset:()=>_(new Set)})]})]})}function ae({onAdopt:t,onReset:o}){let{t:s}=j(),l=k(),u=r(()=>{o(),l.mutate({})},[l,o]);a(()=>{!l.isPending&&!l.data&&u()},[]);let d=n(()=>(l.data?.groups??[]).filter(e=>e.candidates.length>0),[l.data]),f=n(()=>d.reduce((e,t)=>e+t.candidates.length,0),[d]);return e(c,{children:[i(`div`,{className:`flex items-center justify-end gap-2 border-b border-border px-5 py-2 shrink-0`,children:e(`button`,{onClick:u,disabled:l.isPending,className:`flex items-center gap-1 rounded-md border border-border px-2 py-1 text-xs text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50`,children:[i(v,{className:`h-3.5 w-3.5 ${l.isPending?`animate-spin`:``}`}),s(`integrations.scanNetworkModal.reScan`,`Re-scan`)]})}),e(`div`,{className:`flex-1 min-h-0 overflow-y-auto px-5 py-4 space-y-4`,children:[l.isPending&&i(se,{label:s(`integrations.scanNetworkModal.scanningTheLocalNetwork`,`Scanning the local network…`)}),!l.isPending&&l.isError&&i($,{}),!l.isPending&&l.data&&d.length===0&&i(`p`,{className:`py-8 text-center text-xs text-foreground-subtle`,children:s(`integrations.scanNetworkModal.noDevicesRespondedToThe`,`No devices responded to the scan.`)}),!l.isPending&&d.length>0&&i(`p`,{className:`text-xs text-foreground-subtle`,children:s(`integrations.scanNetworkModal.found`,{count:f})}),!l.isPending&&d.map(n=>e(`div`,{className:`space-y-1.5`,children:[e(`div`,{className:`flex items-center gap-2`,children:[i(`span`,{className:`text-[11px] font-semibold text-foreground`,children:n.label}),e(`span`,{className:`text-[10px] text-foreground-subtle`,children:[`(`,n.candidates.length,`)`]})]}),n.candidates.map(e=>t(n.addonId,e))]},n.addonId))]})]})}function oe({scope:t,onAdopt:n,onReset:a}){let{t:s}=j(),l=O({addonId:t.addonId}).data??null,[u,d]=o({}),f=E(),p=r(()=>{a(),f.mutate({addonId:t.addonId,params:u})},[f,t.addonId,u,a]),m=f.data?.candidates??[];return i(c,{children:e(`div`,{className:`flex-1 min-h-0 overflow-y-auto px-5 py-4 space-y-4`,children:[l&&i(M,{schema:l,values:u,onChange:d}),e(`button`,{onClick:p,disabled:f.isPending,className:`flex items-center gap-1.5 rounded-lg bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground disabled:opacity-50`,children:[f.isPending?i(h,{className:`h-3.5 w-3.5 animate-spin`}):i(g,{className:`h-3.5 w-3.5`}),f.isPending?s(`integrations.scanNetworkModal.scanning`,`Scanning…`):s(`integrations.scanNetworkModal.scan`,`Scan`)]}),f.isError&&i($,{}),!f.isPending&&f.data&&m.length===0&&i(`p`,{className:`py-6 text-center text-xs text-foreground-subtle`,children:s(`integrations.scanNetworkModal.noDevicesRespondedToThe`,`No devices responded to the scan.`)}),!f.isPending&&m.length>0&&e(`div`,{className:`space-y-1.5`,children:[i(`p`,{className:`text-xs text-foreground-subtle`,children:s(`integrations.scanNetworkModal.foundShort`,{count:m.length})}),m.map(e=>n(t.addonId,e))]})]})})}function se({label:t}){return e(`div`,{className:`flex flex-col items-center py-12`,children:[i(h,{className:`h-6 w-6 animate-spin text-primary`}),i(`p`,{className:`mt-3 text-xs text-foreground-subtle`,children:t})]})}function $(){let{t}=j();return e(`div`,{className:`flex items-start gap-3 rounded-lg border border-destructive/40 bg-destructive/10 px-4 py-3`,children:[i(d,{className:`h-4 w-4 text-destructive mt-0.5 shrink-0`}),i(`p`,{className:`text-xs text-destructive`,children:t(`integrations.scanNetworkModal.theScanFailedTryAgain`,`The scan failed. Try again.`)})]})}export{Y as i,re as n,te as r,ie as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{ra as e}from"./player-overlays-BT3xIHAn.js";var t=e(`circle-slash`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`9`,x2:`15`,y1:`15`,y2:`9`,key:`1dfufj`}]]);export{t};
|