@camstack/addon-admin-ui 1.2.512 → 1.2.514
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/dist/assets/{AddonAssetIcon-DCKCRhEh.js → AddonAssetIcon-CBiyVWSK.js} +1 -1
- package/dist/assets/Addons-DsbbYUDT.js +5 -0
- package/dist/assets/{AdminPage-CVSTxsAk.js → AdminPage-B_wUVHLs.js} +1 -1
- package/dist/assets/{AdminSectionedPage-BG6w5-w1.js → AdminSectionedPage-B2kIEVFJ.js} +1 -1
- package/dist/assets/AiProfiles-sNt-u_by.js +3 -0
- package/dist/assets/{BrokerEditorDialog-Dd6KEwRN.js → BrokerEditorDialog-DyIsWyfA.js} +1 -1
- package/dist/assets/Build-CsuCOGY2.js +40 -0
- package/dist/assets/{Calendars-BHqwUpG9.js → Calendars-6W4Ardeb.js} +1 -1
- package/dist/assets/{Cluster-DDjN53AW.js → Cluster-CWoYZoPu.js} +1 -1
- package/dist/assets/{CompositionBlockEditor-B81aTqq3.js → CompositionBlockEditor-qEFV1AKI.js} +1 -1
- package/dist/assets/{CompositionEditorPage-CbLv15x4.js → CompositionEditorPage-CKCgT4Sc.js} +1 -1
- package/dist/assets/Data-CKbI6H28.js +2 -0
- package/dist/assets/DeviceDetail-CWaYy5st.js +2 -0
- package/dist/assets/DeviceDoActionFields-Bfl8v0Ww.js +1 -0
- package/dist/assets/{Devices-B9SE3Rwm.js → Devices-BXmHX1Iz.js} +1 -1
- package/dist/assets/{EmbedPlayerPage-D63WF3oV.js → EmbedPlayerPage-C0JL6O13.js} +1 -1
- package/dist/assets/HelperWizard-Bu6DbISr.js +2 -0
- package/dist/assets/History-B2COiYTg.js +1 -0
- package/dist/assets/Identity-Cp5m445y.js +1 -0
- package/dist/assets/IntegrationDetail-CsQJqy0O.js +1 -0
- package/dist/assets/IntegrationHub-Cxb40a46.js +1 -0
- package/dist/assets/Integrations-CKTnFV7-.js +1 -0
- package/dist/assets/Integrations-Wb3Nvqvk.js +1 -0
- package/dist/assets/{Library-C2NTg1uA.js → Library-Cnom4jTv.js} +1 -1
- package/dist/assets/Locations-RMAhldT5.js +3 -0
- package/dist/assets/{Logs-kEWkWloD.js → Logs-YZGGdk7a.js} +1 -1
- package/dist/assets/{MaskShapeCanvas-D6XVNdwA.js → MaskShapeCanvas-CCcjwlTm.js} +1 -1
- package/dist/assets/{MotionZonesSettings-BXHdXw3X.js → MotionZonesSettings-15VWTACI.js} +1 -1
- package/dist/assets/MyAccess-ChjuVjHq.js +2 -0
- package/dist/assets/{Network-DtfAuiol.js → Network-ByvZRKWM.js} +1 -1
- package/dist/assets/NodeAddonsSettingsPanel-tEpUh0Q6.js +1 -0
- package/dist/assets/Notifications-WK1xVjAV.js +1 -0
- package/dist/assets/Pipeline-C3zZKn-f.js +1 -0
- package/dist/assets/{PrivacyMaskSettings-BXiuTmLQ.js → PrivacyMaskSettings-boU8xnXR.js} +1 -1
- package/dist/assets/Recordings-DT5kHAwS.js +1 -0
- package/dist/assets/RemoteGrid-HppYsb5t.js +1 -0
- package/dist/assets/{ScanNetworkModal-Bg22q8vm.js → ScanNetworkModal-Dk1v70-s.js} +1 -1
- package/dist/assets/{SceneMonitorEditor-ChgZnP_I.js → SceneMonitorEditor-DbEDdw8n.js} +1 -1
- package/dist/assets/SessionsList-4nVxGpqc.js +2 -0
- package/dist/assets/{Showroom-R3reqgpn.js → Showroom-Cyf_5WTf.js} +1 -1
- package/dist/assets/System-B47qVCVK.js +1 -0
- package/dist/assets/Templates-lCo5yN4g.js +1 -0
- package/dist/assets/{Terminal-B5qyGLn1.js → Terminal-RLflxok5.js} +3 -3
- package/dist/assets/{Viewer-CLvHpMj8.js → Viewer-BFtLOgb5.js} +1 -1
- package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-GbWwXkZ2.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-Dd1lnVnV.js} +1 -1
- package/dist/assets/{addon-icons-context-ClSTx0Nd.js → addon-icons-context-BqCF3aDM.js} +1 -1
- package/dist/assets/{archive-P7vGIXBL.js → archive-COJvuz8j.js} +1 -1
- package/dist/assets/{assignment-candidates-B0B3pJGN.js → assignment-candidates-GFFTkY5s.js} +1 -1
- package/dist/assets/{authed-media-Ba0gOxiM.js → authed-media-CPH4gDSb.js} +1 -1
- package/dist/assets/automation-data-D3oEGSM3.js +1 -0
- package/dist/assets/{bell-off-B4S4Brhx.js → bell-off-CEHvcpV8.js} +1 -1
- package/dist/assets/{board-model-DcpPhztF.js → board-model-uN4dojCw.js} +1 -1
- package/dist/assets/{boxes-Cc83jXU7.js → boxes-C0Z7cB0S.js} +1 -1
- package/dist/assets/circle-slash-BY9zkWdJ.js +1 -0
- package/dist/assets/client-BjsFVjEa.js +674 -0
- package/dist/assets/{cloud-upload-BNAApVPM.js → cloud-upload-yzPIJtWW.js} +1 -1
- package/dist/assets/crop-DpfML6TR.js +1 -0
- package/dist/assets/{device-integration-icon-Nwyo5V5H.js → device-integration-icon-DC0L96qt.js} +1 -1
- package/dist/assets/device-picker-model-C9XdDI0R.js +1 -0
- package/dist/assets/{dist-97mm2unN.js → dist-D7eSjbBx.js} +1 -1
- package/dist/assets/dist-DuYXDhcZ.js +674 -0
- package/dist/assets/{eraser-CfQsg9Ve.js → eraser-CcAxRsoL.js} +1 -1
- package/dist/assets/file-up-gEH5fPam.js +1 -0
- package/dist/assets/{hard-drive-download-PwUdP9sZ.js → hard-drive-download-CwO_DU-K.js} +1 -1
- package/dist/assets/{hostInit-VFHoBRCk.js → hostInit-BonUhoQT.js} +1 -1
- package/dist/assets/i18n-CtSKEBgX.js +1 -0
- package/dist/assets/icons-l5aYjks5.js +1 -0
- package/dist/assets/index-C1TP1bDM.js +4 -0
- package/dist/assets/index-i7JLUpAu.css +2 -0
- package/dist/assets/key-03tb4am1.js +1 -0
- package/dist/assets/{key-round-CBhTR29b.js → key-round-CxRbUD09.js} +1 -1
- package/dist/assets/{layers-C5Yl1IY5.js → layers-B_aq5GyC.js} +1 -1
- package/dist/assets/{linked-devices-model-COUfIEod.js → linked-devices-model-BDwJCC37.js} +1 -1
- package/dist/assets/{list-ordered-A3gv0vJA.js → list-ordered-BIOnBH5V.js} +1 -1
- package/dist/assets/location-owned-usage-C8KAIY_m.js +1 -0
- package/dist/assets/{log-in-ChqbFBLh.js → log-in-DYRRiyUu.js} +1 -1
- package/dist/assets/{memory-stick-B__TSEyk.js → memory-stick-BTjX5XXU.js} +1 -1
- package/dist/assets/{message-square-plus-BERx-QaF.js → message-square-plus-CYHn2tx1.js} +1 -1
- package/dist/assets/{mf-entry-bootstrap-0-556ccfd0.js → mf-entry-bootstrap-0-55c9b237.js} +2 -2
- package/dist/assets/{mic-off-Dyo6dwK_.js → mic-off-BfWqJn2R.js} +1 -1
- package/dist/assets/{monitor-off-Czfm61g6.js → monitor-off-Dy7WsqTN.js} +1 -1
- package/dist/assets/{monitor-smartphone-tJnvQ6Wt.js → monitor-smartphone-Cl-w7Gs0.js} +1 -1
- package/dist/assets/mount-C9XdDI0R.js +1 -0
- package/dist/assets/{player-overlays-B5FSaids.js → player-overlays-DaSesfVn.js} +1 -1
- package/dist/assets/{recycle-droAKct3.js → recycle-CC6kU24N.js} +1 -1
- package/dist/assets/remoteEntry-C7WJfwvN.js +1 -0
- package/dist/assets/ruler-C6bIqLbX.js +1 -0
- package/dist/assets/{scan-eye-gmpggdW4.js → scan-eye-BbYgoJiK.js} +1 -1
- package/dist/assets/{scissors-CCgXntCX.js → scissors-oYo-ZhBm.js} +1 -1
- package/dist/assets/{search-x-D1xSmXhu.js → search-x-CySi2ygd.js} +1 -1
- package/dist/assets/{send-B8FKrOyC.js → send-FMXSDirA.js} +1 -1
- package/dist/assets/{settings-2-BdhYf7UQ.js → settings-2-WfXnibr2.js} +1 -1
- package/dist/assets/shapes-JaoPTvAm.js +1 -0
- package/dist/assets/{sigma-Bzh2qqL3.js → sigma-C2um2nX9.js} +1 -1
- package/dist/assets/{speaker-CmGzkRdE.js → speaker-DVh7yO4_.js} +1 -1
- package/dist/assets/src-DxOL9qHw.js +67 -0
- package/dist/assets/step-inspector-model-D4wNZnAf.js +1 -0
- package/dist/assets/{table-2-DaQYtXJ7.js → table-2-BzvZ1C8Y.js} +1 -1
- package/dist/assets/{timer-reset-ceaN5uh6.js → timer-reset-BFyZoIS7.js} +1 -1
- package/dist/assets/{unlink-CZPQIK73.js → unlink-Bf6pcFmm.js} +1 -1
- package/dist/assets/{usb-CdZusF7Y.js → usb-oSHxCOV9.js} +1 -1
- package/dist/assets/{use-scenes-feed-CQOhXjvP.js → use-scenes-feed-DrR6sBRO.js} +1 -1
- package/dist/assets/{use-stationary-objects-D9KV1ze2.js → use-stationary-objects-DVmg7h4R.js} +1 -1
- package/dist/assets/useEventInvalidation-C9XdDI0R.js +1 -0
- package/dist/assets/{useNodeUrlSelection-CAyN93HW.js → useNodeUrlSelection-CJVhV7Gy.js} +1 -1
- package/dist/assets/user-round-BZHQXbgV.js +1 -0
- package/dist/assets/{user-x-DKorc3CR.js → user-x-aU8InWh0.js} +1 -1
- package/dist/assets/{variable-BXBhuk59.js → variable-DwONvC9h.js} +1 -1
- package/dist/assets/video-DOy8UceJ.js +1 -0
- package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-Dyo8T61H.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-DXQ8OkGD.js} +2 -2
- package/dist/index.html +10 -10
- package/dist/server/addon.js +474 -12
- package/package.json +1 -1
- package/dist/assets/Addons-DPAqJ5aW.js +0 -5
- package/dist/assets/AiProfiles-DR_I4RIr.js +0 -3
- package/dist/assets/Build-C8Iyyb5o.js +0 -40
- package/dist/assets/Data-CJqiuGjd.js +0 -2
- package/dist/assets/DeviceDetail-DvtPS7Er.js +0 -2
- package/dist/assets/DeviceDoActionFields-DnA_DSYw.js +0 -1
- package/dist/assets/HelperWizard-BigkVmsB.js +0 -2
- package/dist/assets/History-D0syoHcx.js +0 -1
- package/dist/assets/Identity-CElkwZnz.js +0 -1
- package/dist/assets/IntegrationDetail-DZ8ztuOE.js +0 -1
- package/dist/assets/IntegrationHub-DiscqOsj.js +0 -1
- package/dist/assets/Integrations-BfCE8MnT.js +0 -1
- package/dist/assets/Integrations-CHguUclI.js +0 -1
- package/dist/assets/Locations-DWad73x-.js +0 -3
- package/dist/assets/MyAccess-CS5GrN5k.js +0 -2
- package/dist/assets/NodeAddonsSettingsPanel-lczGJdHs.js +0 -1
- package/dist/assets/Notifications-DchKpNOg.js +0 -1
- package/dist/assets/Pipeline-vgUZsFFP.js +0 -1
- package/dist/assets/Recordings-CyPYQ20P.js +0 -1
- package/dist/assets/SessionsList-CfuTFr66.js +0 -2
- package/dist/assets/System-r9rg9iWn.js +0 -1
- package/dist/assets/circle-slash-fwUwJ3r8.js +0 -1
- package/dist/assets/client-JLEP7nv7.js +0 -674
- package/dist/assets/crop-j4n-xPUF.js +0 -1
- package/dist/assets/device-picker-model-C44QyL85.js +0 -1
- package/dist/assets/dist-BW5MRjy3.js +0 -674
- package/dist/assets/format-u0sqgb1J.js +0 -1
- package/dist/assets/i18n-CXGP1uaw.js +0 -1
- package/dist/assets/icons-BJz9Yj7E.js +0 -1
- package/dist/assets/index-Dep3DVAz.css +0 -2
- package/dist/assets/index-lH9UKmhf.js +0 -4
- package/dist/assets/key-drN5OJov.js +0 -1
- package/dist/assets/location-owned-usage-BmtVONF0.js +0 -1
- package/dist/assets/mount-C44QyL85.js +0 -1
- package/dist/assets/remoteEntry-De9zVsA0.js +0 -1
- package/dist/assets/src-IQsaq5W-.js +0 -67
- package/dist/assets/step-inspector-model-CW9NPxgI.js +0 -1
- package/dist/assets/useEventInvalidation-C44QyL85.js +0 -1
- package/dist/assets/user-round-yFN2hAUV.js +0 -1
- package/dist/assets/video-2nOnVl_R.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{Di as l,En as u,Fn as d,Gr as f,Ht as p,Oi as m,Ti as h,Wr as g,bt as _,dt as v,fr as y,gn as b,gt as x,kn as S,na as C,pa as ee,pi as w,wn as T,yi as E,yn as D,zt as O}from"./player-overlays-B5FSaids.js";import{da as te}from"./client-JLEP7nv7.js";import{t as k}from"./search-x-D1xSmXhu.js";import{Ad as ne,At as A,Bi as j,Cs as re,Do as ie,Ea as M,Es as N,Fo as P,Hn as F,Lo as ae,Mt as I,Os as L,Pd as R,Qr as z,Sa as B,Si as oe,So as V,Ss as se,Tn as H,Tr as U,Ts as ce,Wn as W,Yr as le,_r as ue,ao as G,ar as K,co as q,do as J,dr as de,en as fe,es as Y,fr as X,gd as pe,gr as me,hn as he,hr as ge,kt as _e,lo as ve,mo as ye,oo as be,po as xe,pr as Se,so as Ce,vo as we,wa as Te,ws as Z,xi as Ee,xs as De,yo as Oe}from"./src-IQsaq5W-.js";import{t as Q}from"./useTranslation-BJr-n0es.js";import{n as ke}from"./addon-icons-context-ClSTx0Nd.js";import{C as Ae,L as je,S as Me,_r as Ne,pr as Pe,vr as Fe,w as Ie,yr as Le}from"./index-lH9UKmhf.js";import{t as Re}from"./device-integration-icon-Nwyo5V5H.js";import{a as ze,i as Be,r as Ve,t as He}from"./ScanNetworkModal-Bg22q8vm.js";import{t as Ue}from"./NodeAddonsSettingsPanel-lczGJdHs.js";s();function We(e){let t=[];for(let n of e)n.type===`probe`&&t.push(n.key),n.type===`group`&&`fields`in n&&t.push(...We(n.fields));return t}function Ge(e,t,i){let[a,s]=o(`idle`),[c,l]=o({}),u=n(()=>{let t=[];for(let n of e.sections)t.push(...We(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 Ke(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(...Ke(n.fields));return t}function qe(e){return e==null?!0:typeof e==`string`?e.trim()===``:!1}function Je(e,t={}){for(let n of e){if(n.type===`group`&&`fields`in n){Je(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 Ye({open:t,integrationId:s,addonId:u,onClose:d}){let{t:f}=Q(),p=c(),[m,h]=o({}),[g,v]=o(!1),[b,S]=o(null),[C,ee]=o($),w=P({addonId:u},{enabled:t}),T=w.data?.deviceType??null,E=V({addonId:u,type:T??te.Camera},{enabled:t&&w.isSuccess&&T!==null}),k=E.data??null;a(()=>{t&&(h(k?Je(k.sections.flatMap(e=>e.fields)):{}),ee($()),v(!1),S(null))},[t,s,k]);let ne=n(()=>({...m,_probeRequestId:C}),[m,C]),A=xe({onSuccess:()=>{p.invalidateQueries({queryKey:[[`deviceManager`]]})}}),j=Y(),re=r(async(e,t)=>{v(!0);let n=await j.mutateAsync({addonId:u,type:T??te.Camera,key:e,value:t,formValues:ne});return n.status===`ok`&&n.suggestedValues&&h(e=>{let t=!1,r={...e};for(let[i,a]of Object.entries(n.suggestedValues??{}))qe(e[i])&&!qe(a)&&(r[i]=a,t=!0);return t?r:e}),n},[j,u,ne,T]),{testAllStatus:ie,hasProbeFields:M,probeResults:N,handleTestAll:F,clearProbeResult:ae}=Ge(k??{sections:[]},m,re);async function I(e){S(null);try{await A.mutateAsync({addonId:u,type:T??te.Camera,config:m,integrationId:s}),e?h(k?Je(k.sections.flatMap(e=>e.fields)):{}):d()}catch(e){S(e instanceof Error?e.message:String(e))}}if(!t)return null;let L=Ke((k?.sections??[]).flatMap(e=>e.fields)).filter(e=>qe(m[e])),R=L.length===0,z=w.isLoading||T!==null&&E.isLoading,B=w.isError||w.isSuccess&&T===null||E.isError||E.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:d}),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:f(`integrations.addDevice`)}),i(`button`,{onClick:d,className:`rounded-md p-1 text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,children:i(x,{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(y,{className:`h-5 w-5 animate-spin text-primary`})}):B?e(`div`,{className:`flex items-start gap-3 rounded-lg border border-destructive/40 bg-destructive/10 px-4 py-3`,children:[i(O,{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:f(`integrations.addDeviceDialog.providerUnavailable`,`Provider unavailable`)}),i(`p`,{className:`text-xs text-foreground-subtle`,children:i(Pe,{i18nKey:`integrations.addDeviceDialog.notReady`,values:{addonId:u},components:{mono:i(`span`,{className:`font-mono`})}})})]})]}):i(je,{schema:k,values:m,onChange:h,onTestField:re,probeResults:N,onClearProbe:ae})}),!B&&!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(D,{className:`h-3.5 w-3.5`}),f(`integrations.addDeviceDialog.testLogs`,`Test logs`),i(`span`,{className:`font-mono text-[9px] opacity-60`,children:C.slice(0,14)})]}),i(l,{className:`h-3.5 w-3.5 transition-transform ${g?`rotate-180`:``}`})]}),g&&i(`div`,{className:`border-t border-border max-h-64 overflow-hidden`,children:i(fe,{addonId:u,requestId:C,limit:50,maxHeight:`max-h-64`,showFilters:!1,showScope:!1,className:`border-0 rounded-none`})})]}),!B&&!z&&(b||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(O,{className:`h-3.5 w-3.5 text-destructive mt-0.5 shrink-0`}),i(`p`,{className:`text-[11px] text-destructive`,children:b||f(`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: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.cancel`)}),!B&&M&&e(`button`,{type:`button`,onClick:F,disabled:ie===`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:[ie===`testing`?i(y,{className:`h-3.5 w-3.5 animate-spin`}):i(_,{className:`h-3.5 w-3.5`}),f(`integrations.addDeviceDialog.testAll`,`Test All`)]})]}),e(`div`,{className:`flex items-center gap-2`,children:[i(`button`,{onClick:()=>I(!0),disabled:B||!R||A.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:f(`integrations.saveAndNew`)}),i(`button`,{onClick:()=>I(!1),disabled:B||!R||A.isPending,className:`rounded-lg bg-primary px-4 py-1.5 text-xs font-medium text-primary-foreground shadow-sm disabled:opacity-50`,children:A.isPending?f(`integrations.saving`):f(`integrations.save`)})]})]})]})]})}s();var Xe=`matter`,Ze=[`discovering`,`pase`,`commissioning`,`done`];function Qe(e){return!(typeof e!=`object`||!e||!(`phase`in e)||typeof e.phase!=`string`)}function $e(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 et({onClose:t,onCommissioned:n}){let{t:r}=Q(),s=Te({kind:Xe}),[c,l]=o(null),u=s.data?.length??0,d=c??s.data?.[0]?.id??null,f=M(),[p,m]=o(``),[h,g]=o({phase:`idle`,failure:null,message:null}),_=h.phase===`discovering`||h.phase===`pase`||h.phase===`commissioning`,v=B({brokerId:d??``,key:`commission`},{enabled:d!==null&&_,refetchInterval:_?400:!1});a(()=>{_&&Qe(v.data)&&v.data.phase!==`idle`&&g({phase:v.data.phase,failure:typeof v.data.failure==`string`?v.data.failure:null,message:typeof v.data.message==`string`?v.data.message:null})},[_,v.data]);let b=()=>{d!==null&&(g({phase:`discovering`,failure:null,message:null}),f.mutate({brokerId:d,target:{action:`commissionNode`},payload:{pairingCode:p.trim()}},{onSuccess:()=>g({phase:`done`,failure:null,message:null}),onError:e=>{let t=e instanceof Error?e.message:`Commissioning failed.`;g({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})}}))},x=h.phase===`failed`?$e(h.failure,h.message):null,S=x===null?null:r(x.key,{defaultValue:x.defaultValue}),C=(s.isSuccess===!0||s.data!==void 0)&&d===null;return i(de,{open:!0,onOpenChange:e=>!e&&t(),children:e(Se,{width:`md`,placement:`sheet-on-mobile`,scroll:`body`,children:[i(me,{children:i(ue,{children:r(`integrations.addMatter.title`,{defaultValue:`Add Matter device`})})}),e(X,{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.`})}),(C||u>1)&&!_&&h.phase!==`done`&&e(`div`,{className:`space-y-1.5`,children:[i(W,{children:r(`integrations.addMatter.broker`,{defaultValue:`Matter fabric`})}),i(ze,{kind:Xe,value:d,onChange:l})]}),!C&&e(`div`,{className:`space-y-1.5`,children:[i(W,{htmlFor:`matter-pairing-code`,children:r(`integrations.addMatter.code`,{defaultValue:`Pairing code`})}),i(pe,{id:`matter-pairing-code`,value:p,autoComplete:`off`,spellCheck:!1,placeholder:`34970112332`,disabled:_||h.phase===`done`,onChange:e=>m(e.target.value)})]}),h.phase!==`idle`&&i(`ol`,{className:`space-y-1`,"aria-label":r(`integrations.addMatter.progress`,{defaultValue:`Commissioning progress`}),children:Ze.map(t=>{let n=h.phase===t;return e(`li`,{className:`text-xs ${n?`text-foreground font-medium`:`text-foreground-subtle`}`,children:[n&&_?i(y,{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)})}),S!==null&&i(U,{message:S})]}),e(ge,{children:[i(le,{variant:`ghost`,size:`sm`,onClick:t,children:r(`common.close`,{defaultValue:`Close`})}),h.phase===`done`?i(le,{size:`sm`,onClick:n,children:r(`integrations.adoptDevices`,{defaultValue:`Adopt devices`})}):i(le,{size:`sm`,disabled:_||C||p.trim().length===0,onClick:b,children:_?r(`integrations.addMatter.working`,{defaultValue:`Adding…`}):r(`integrations.addMatter.submit`,{defaultValue:`Add device`})})]})]})})}var tt=1500;function nt({addonId:t,integrationId:n,jobId:r,onFinished:a}){let{t:o}=Q(),s=G(),c=(q({addonId:t,integrationId:n},{refetchInterval:e=>(e.state.data??[]).some(e=>e.state===`running`)?tt:!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 p=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(y,{className:`h-3.5 w-3.5 animate-spin text-primary shrink-0`}):c.failed>0?i(O,{className:`h-3.5 w-3.5 text-destructive shrink-0`}):c.state===`cancelled`?i(w,{className:`h-3.5 w-3.5 text-foreground-subtle shrink-0`}):i(E,{className:`h-3.5 w-3.5 text-primary shrink-0`}),i(`p`,{className:`text-[11px] text-foreground`,children:p}),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 rt(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 it=`devices`;function at(e){return{id:it,label:e(`integrations.adoptDevicesModal.defaultFilter`),isDefault:!0}}var ot=2e4,st=100;function ct({addonId:n,integrationId:s,onClose:l}){let u=ee(),{t:d}=Q(),f=c(),[p,h]=o(new Set),[g,_]=o(new Set),[v,b]=o(new Map),[S,C]=o(null),{data:w}=re(),E=(w??[]).find(e=>e.addonId===n)?.supportsLocationImport??!1,[D,te]=o(!0),k=be({addonId:n,integrationId:s}).data?.filters,A=k&&k.length>0?k:[at(d)],[j,ie]=o(A.find(e=>e.isDefault)?.id??(A.some(e=>e.id===it)?it:A[0].id)),M=j!==it,N=ve(),P=Ce({addonId:n,integrationId:s,page:1,pageSize:ot,filter:j}),F=P.refetch,ae=N.mutate,I=r(()=>{ae({addonId:n,integrationId:s},{onSettled:()=>{F()}})},[ae,n,s,F]),L=t(null);a(()=>{let e=`${n}::${s}`;L.current===e||P.isLoading||(L.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,oe=typeof N.data?.lastError==`string`&&N.data.lastError.length>0?N.data.lastError:null,V=P.data?.candidates??[],se=P.isError?P.error instanceof Error?P.error.message:String(P.error):null,H=J(),[U,ce]=o(null),W=r(e=>{e.alreadyAdopted||h(t=>{let n=new Set(t);return n.has(e.childNativeId)?n.delete(e.childNativeId):n.add(e.childNativeId),n})},[]),le=r(e=>{_(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),ue=r((e,t)=>{b(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})},[]),G=r(e=>{let t={};for(let n of e){let e=v.get(n);e&&e.hiddenChildIds.size>0&&(t[n]={hiddenChildIds:[...e.hiddenChildIds]})}return Object.keys(t).length>0?t:void 0},[v]),K=r(async()=>{C(null);let e=[...p];if(e.length!==0)try{let t=G(e),{jobId:r}=await H.mutateAsync({addonId:n,integrationId:s,filter:j,childNativeIds:e,...t?{perCandidate:t}:{},...E?{importLocations:D}:{}});ce(r),h(new Set),b(new Map)}catch(e){C(e instanceof Error?e.message:String(e))}},[p,G,H,n,s,j,E,D]),q=t(null),de=r(()=>{U===null||q.current===U||(q.current=U,F(),f.invalidateQueries({queryKey:[[`integrations`]]}),f.invalidateQueries({queryKey:[[`deviceManager`]]}))},[U,F,f]),fe=r(e=>{ie(e),h(new Set),_(new Set),b(new Map),C(null)},[]),Y=p.size,X=U!==null&&Y===0&&!H.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:d(`integrations.adoptDevices`,{defaultValue:`Adopt devices`})}),i(`p`,{className:`text-[11px] text-foreground-subtle mt-0.5`,children:d(`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:D,onChange:e=>te(e.target.checked),className:`accent-primary`}),d(`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":d(`common.close`,`Close`),children:i(x,{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??se??oe)&&V.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(O,{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:d(`integrations.adoptRefreshFailed`,{defaultValue:`Could not discover devices.`})}),i(`p`,{className:`text-[11px] text-destructive/90 mt-0.5`,children:B??se??oe})]})]})}),A.length>1&&i(lt,{filters:A,activeFilter:j,onSelect:fe}),i(`div`,{className:`flex-1 min-h-0`,children:i(_e,{mode:`generic`,items:V,pageSize:st,getKey:e=>e.childNativeId,getSearchText:rt,getFilterType:e=>e.type,filterOptions:ne(u),filterLabel:d(`integrations.adoptColType`,{defaultValue:`Type`}),isLoading:P.isLoading||z&&V.length===0,searchPlaceholder:d(`integrations.adoptSearch`,{defaultValue:`Search candidates…`}),emptyLabel:(B??se??oe)&&V.length===0?``:d(`integrations.adoptNoCandidates`,{defaultValue:`No candidate devices found.`}),toolbar:e(`button`,{type:`button`,onClick:I,disabled:z,title:d(`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(T,{className:`h-3.5 w-3.5 ${z?`animate-spin`:``}`}),d(`integrations.adoptRefresh`,{defaultValue:`Refresh`})]}),columns:[{key:`name`,header:d(`integrations.adoptColName`,{defaultValue:`Name`}),headerClassName:`w-[55%]`,cell:e=>i(ut,{candidate:e,expandable:!M,expanded:g.has(e.childNativeId),onToggleExpand:()=>le(e.childNativeId),adoptedLabel:d(`integrations.adoptAlready`,{defaultValue:`Adopted`})})},{key:`type`,header:d(`integrations.adoptColType`,{defaultValue:`Type`}),headerClassName:`w-[30%] hidden sm:table-cell`,cellClassName:`hidden sm:table-cell`,cell:t=>{let n=R(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:()=>W(e),disabled:e.alreadyAdopted,"aria-label":p.has(e.childNativeId)?d(`integrations.adoptDevicesModal.deselect`,`Deselect`):d(`integrations.adoptDevicesModal.select`,`Select`),className:`inline-flex h-5 w-5 items-center justify-center rounded border ${p.has(e.childNativeId)?`border-primary bg-primary`:`border-border`} ${e.alreadyAdopted?`cursor-not-allowed opacity-50`:``}`,children:p.has(e.childNativeId)&&i(m,{className:`h-3 w-3 text-primary-foreground`})})})}],isExpanded:e=>!M&&g.has(e.childNativeId),renderExpanded:M?void 0:e=>i(dt,{candidate:e,hiddenChildIds:v.get(e.childNativeId)?.hiddenChildIds??new Set,onToggleChildHidden:t=>ue(e.childNativeId,t)}),rowClassName:e=>e.alreadyAdopted?`opacity-60`:p.has(e.childNativeId)?`bg-primary/5`:``})})]}),S&&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(O,{className:`h-3.5 w-3.5 text-destructive mt-0.5 shrink-0`}),i(`p`,{className:`text-[11px] text-destructive`,children:S})]})}),U!==null&&i(nt,{addonId:n,integrationId:s,jobId:U,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:d(`integrations.cancel`,{defaultValue:`Cancel`})}),e(`button`,{onClick:X?l:K,disabled:!X&&(Y===0||H.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:[H.isPending&&i(y,{className:`h-3.5 w-3.5 animate-spin`}),X?d(`integrations.close`,{defaultValue:`Close`}):d(`integrations.addSelected`,{defaultValue:`Add selected`}),!X&&Y>0?` (${Y})`:``]})]})]})]})]})}function lt({filters:e,activeFilter:t,onSelect:n}){let{t:r}=Q();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 ut({candidate:t,expandable:n,expanded:r,onToggleExpand:a,adoptedLabel:o}){let{t:s}=Q(),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?l:h,{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 dt({candidate:t,hiddenChildIds:n,onToggleChildHidden:r}){let{t:a}=Q(),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?f:g,{className:`h-3 w-3`})})]},t.childNativeId)})})}s();function ft(e){let t=[];for(let n of e){if(n.type===`group`){t.push(...ft(n.fields));continue}`key`in n&&typeof n.key==`string`&&t.push(n.key)}return t}function pt(e,t){if(!e)return{};let n=new Set(e.sections.flatMap(e=>ft(e.fields))),r={};for(let e of n)Object.prototype.hasOwnProperty.call(t,e)&&(r[e]=t[e]);return r}function mt(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 ht({integrationId:t,addonId:r,name:a,kind:o,mode:s,brokerKind:l,canTest:u=!1,trpc:d,onClose:f}){let{t:p}=Q(),m=c(),{data:h,isLoading:g}=Z({id:t},{enabled:s===`account`||s===`broker`}),_=n(()=>{let e=h?.brokerId;return typeof e==`string`?e:null},[h]),{data:v,isLoading:b}=Ee({addonId:r,nodeId:`hub`},{enabled:s===`account`}),x=n(()=>v?mt(v):null,[v]),S=N(),C=(e,n)=>{S.mutate({id:t,settings:e,...n?{secretKeys:[...n]}:{}},{onSuccess:()=>{m.invalidateQueries(),f()}})};return i(de,{open:!0,onOpenChange:e=>!e&&f(),children:e(Se,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,children:[i(me,{children:e(ue,{children:[p(`integrations.editConfig`,{defaultValue:`Edit configuration`}),` — `,a]})}),i(X,{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:_})]}),S.isPending?e(`div`,{className:`flex items-center gap-2 text-[11px] text-foreground-subtle`,children:[i(y,{className:`h-3 w-3 animate-spin`}),p(`integrations.saving`,{defaultValue:`Saving…`})]}):i(Be,{kind:l,onResolved:e=>{C({brokerId:e})},onBack:f}),S.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||b?e(`div`,{className:`flex items-center gap-2 text-[11px] text-foreground-subtle`,children:[i(y,{className:`h-3 w-3 animate-spin`}),p(`integrations.loading`,{defaultValue:`Loading…`})]}):i(Ve,{addonId:r,configSchema:x,canTest:u,initialName:a,initialConfig:pt(x,h??{}),submitLabel:p(`integrations.save`,{defaultValue:`Save`}),hideName:!0,onSave:({config:e,secretKeys:t})=>C(e,t),onBack:f}):i(K,{trpc:d,addonId:r,nodeId:`hub`,title:a})})]})})}function gt(e){return e==null?!1:e.sections.some(e=>e.fields.length>0)}s();function _t(){let{addonId:e=``}=Fe();return i(yt,{addonId:e})}function vt(){return 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`})]})}function yt({addonId:t}){let{t:s}=Q(),l=c(),f=Ne(),[m,h]=Le(),g=v(),[_,x]=o(!1),[ee,w]=o(!1),[T,E]=o(!1),O=r(e=>{E(!1),f(`/integrations`,{state:{integrationSeed:e}})},[f]),[te,ne]=o(!1),[M,N]=o(!1),{data:P}=ce(void 0),R=n(()=>(P??[]).filter(e=>e.addonId===t),[P,t]),B=Ie(m.get(`instance`),R)??``,V=r(e=>{h(t=>{let n=new URLSearchParams(t);return n.set(Me,e),n},{replace:!0})},[h]),U=n(()=>R.map(e=>({value:e.id,label:e.name})),[R]),{data:W,isLoading:le}=se({id:B},{enabled:!!B}),{data:G}=Ee({addonId:W?.addonId??``,nodeId:`hub`},{enabled:!!W?.addonId}),{data:K,isSuccess:q}=re(),J=n(()=>{let e=W?.addonId;return!e||!q?null:(K??[]).find(t=>t.addonId===e)?.kind===`device-adoption`?`device-adoption`:`device-provider`},[K,W?.addonId,q]),{data:Y}=we({}),pe=n(()=>(Y?.providers??[]).some(e=>e.addonId===W?.addonId),[Y,W?.addonId]),ge=J!==null,ve=W?.info?.fixed===!0,be=n(()=>{let e=W?.addonId;return!e||!q?null:(K??[]).find(t=>t.addonId===e)?.brokerKind??null},[K,W?.addonId,q]),xe=be===`matter`,Ce=ge?xe?s(`integrations.addMatter.title`,{defaultValue:`Add Matter device`}):J===`device-adoption`?s(`integrations.adoptDevices`,{defaultValue:`Adopt devices`}):s(`integrations.addDevice`):s(`integrations.addDeviceLoading`,{defaultValue:`Loading…`}),Te=n(()=>{let e=W?.addonId;return!e||!q?!1:(K??[]).find(t=>t.addonId===e)?.canTest===!0},[K,W?.addonId,q]),Z=n(()=>{let e=W?.addonId;return!e||!q?null:(K??[]).find(t=>t.addonId===e)?.mode??null},[K,W?.addonId,q]);a(()=>{m.get(`add`)===`1`&&ge&&(w(!1),x(!0),h(e=>{let t=new URLSearchParams(e);return t.delete(`add`),t},{replace:!0}))},[m,ge,h]);let ke=G!=null&&Array.isArray(G.sections)&&G.sections.some(e=>e.fields.length>0),{data:je}=oe({addonId:W?.addonId??``,nodeId:`hub`},{enabled:!!W?.addonId&&Z!==`account`}),Pe=Z!==null&&Z!==`account`&>(je),Fe=n(()=>W?.addonId?[W.addonId]:[],[W?.addonId]),{data:ze}=ie({projection:`slim`},{refetchInterval:3e4}),Be=[[`integrations`,`get`],{input:{id:B},type:`query`}],Ve=L({onMutate:async e=>{await l.cancelQueries({queryKey:Be});let t=l.getQueryData(Be);return t!=null&&l.setQueryData(Be,{...t,enabled:e.enabled}),{previous:t}},onError:(e,t,n)=>{let r=n;r?.previous!=null&&l.setQueryData(Be,r.previous)},onSettled:()=>{l.invalidateQueries({queryKey:[[`integrations`]]}),l.invalidateQueries({queryKey:[[`deviceManager`]]})}}),We=De({onSuccess:()=>{l.invalidateQueries({queryKey:[[`integrations`]]}),l.invalidateQueries({queryKey:[[`deviceManager`]]}),f(R.length>1?Ae(t):`/integrations`)}}),Ge=j({onSuccess:()=>{l.invalidateQueries({queryKey:[[`integrations`]]}),l.invalidateQueries({queryKey:[[`deviceManager`]]})}}),Ke=ae({onSuccess:()=>{l.invalidateQueries({queryKey:[[`deviceManager`]]})}}),qe=ye({onSuccess:()=>{l.invalidateQueries({queryKey:[[`deviceManager`]]})}}),Je=Oe({onSuccess:()=>{l.invalidateQueries({queryKey:[[`deviceManager`]]})}}),$=n(()=>ze??[],[ze]),Xe=n(()=>{let e=new Map;for(let t of $)e.set(t.id,{id:t.id,name:t.name??t.stableId??`#${String(t.id)}`});return e},[$]),Ze=r(e=>Xe.get(e)??null,[Xe]),Qe=n(()=>A(P),[P]),$e=r(e=>f(`/devices/${String(e)}`),[f]),tt=n(()=>$.filter(e=>{let t=Qe(e);return t.kind===`resolved`&&t.integration.id===B}),[$,B,Qe]),nt=n(()=>P===void 0?null:I(tt).length,[P,tt])??`…`;if(le||P===void 0)return i(vt,{});let rt=(K??[]).find(e=>e.addonId===t)?.name??W?.name??t;return W?e(`div`,{className:`p-4 space-y-4 overflow-x-hidden`,children:[i(H,{items:[{label:s(`integrationDetail.integrations`,`Integrations`),onClick:()=>f(`/integrations`)},{label:rt}]}),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(bt,{addonId:W.addonId}),e(`div`,{className:`min-w-0`,children:[i(`h1`,{className:`text-lg font-semibold text-foreground truncate`,children:rt}),e(`p`,{className:`text-[11px] text-foreground-subtle mt-0.5 truncate`,children:[nt,` `,s(`integrations.devices`)]})]})]}),e(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[pe&&e(`button`,{onClick:()=>E(!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:s(`integrationDetail.scanTheNetworkForDevices`,`Scan the network for devices (incl. a different subnet)`),children:[i(S,{className:`h-3.5 w-3.5`}),s(`integrationDetail.scanNetwork`,`Scan network`)]}),!ve&&e(`button`,{onClick:()=>{w(!1),x(!0)},disabled:!ge,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:Ce,children:[i(d,{className:`h-3.5 w-3.5`}),Ce]}),e(`div`,{className:`inline-flex items-center gap-2 rounded-lg border px-3 py-1.5 transition-colors ${Ve.isPending?`opacity-60`:``} ${W.enabled?`border-success/30 bg-success/5`:`border-border bg-surface`}`,title:s(`integrations.toggleHint`,{defaultValue:`Click to toggle`}),children:[i(F,{checked:W.enabled,onCheckedChange:e=>Ve.mutate({id:B,enabled:e}),disabled:Ve.isPending,"aria-label":W.enabled?s(`integrationDetail.disableIntegration`,`Disable integration`):s(`integrationDetail.enableIntegration`,`Enable integration`)}),i(`span`,{className:`text-[11px] font-medium ${W.enabled?`text-success`:`text-foreground-subtle`}`,children:W.enabled?s(`integrationDetail.enabled`,`Enabled`):s(`integrationDetail.disabled`,`Disabled`)}),Ve.isPending&&i(y,{className:`h-3 w-3 animate-spin text-foreground-subtle`})]}),Z!==`standalone`&&(ke||J===`device-adoption`)&&e(`button`,{onClick:()=>ne(!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(b,{className:`h-3 w-3`}),s(`integrations.config`)]}),e(`button`,{onClick:()=>N(!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:s(`integrations.logs`,{defaultValue:`View logs`}),children:[i(D,{className:`h-3 w-3`}),s(`integrations.logs`,{defaultValue:`Logs`})]}),i(he,{label:s(`integrationDetail.restart`,`Restart`),icon:u,title:s(`integrationDetail.restart2`,`Restart "{{name}}"?`,{name:W.name}),description:s(`integrationDetail.restartingTheAddonWillBriefly`,`Restarting the addon will briefly disconnect every device backed by it ({{topLevelCountLabel}} active). Streams will reconnect automatically.`,{topLevelCountLabel:nt}),confirmLabel:s(`integrationDetail.restart`,`Restart`),triggerVariant:`outline`,confirmVariant:`danger`,disabled:Ge.isPending,action:()=>Ge.mutateAsync({addonId:W.addonId})}),!ve&&B&&i(he,{label:s(`integrations.delete`,{defaultValue:`Delete`}),icon:p,title:s(`integrations.deleteTitle`,{defaultValue:`Delete integration?`}),description:s(`integrations.deleteWarning`,{defaultValue:`This removes the integration "{{name}}" and its {{count}} device(s). The addon will restart. This cannot be undone.`,name:W.name,count:nt}),confirmLabel:s(`integrations.confirmDelete`,{defaultValue:`Delete integration`}),triggerVariant:`outline`,confirmVariant:`danger`,className:`border-danger bg-danger/10 text-danger hover:bg-danger hover:text-background`,disabled:We.isPending,action:()=>We.mutateAsync({id:B})})]})]}),R.length>1&&i(`div`,{className:`max-w-sm`,children:i(z,{mode:`single`,singleDisplay:`field`,label:s(`integrationDetail.instances`,`Integration`),options:U,value:B,onChange:V,testId:`integration-instance-picker`,optionTestIdPrefix:`integration-instance`})}),Pe&&i(Ue,{nodeId:null,addonIds:Fe,level:`global`,surface:`integration`,title:s(`integrations.settings`,{defaultValue:`Settings`})}),i(_e,{context:`integration-detail`,devices:$,trpc:g.trpcClient,integrationOf:Qe,forceIntegrationId:B,urlScope:`root`,lsKey:`integration-detail:${W.addonId}`,resolveIntegrationIcon:Re,resolveParent:Ze,onNavigate:$e,batchActions:{remove:Ke.mutate,disable:qe.mutate,enable:Je.mutate},...ve?{}:{onDeleteDevice:e=>Ke.mutate({deviceId:e.id})}}),_&&B&&xe&&!ee&&i(et,{onClose:()=>x(!1),onCommissioned:()=>w(!0)}),_&&B&&J===`device-adoption`&&(!xe||ee)&&i(ct,{addonId:W.addonId,integrationId:B,onClose:()=>{x(!1),w(!1)}}),_&&B&&J===`device-provider`&&i(Ye,{open:_,integrationId:B,addonId:W.addonId,onClose:()=>x(!1)}),T&&W&&i(He,{open:T,scope:{addonId:W.addonId,label:W.name},onClose:()=>E(!1),onSetupIntegration:O}),te&&B&&J!==null&&Z!==null&&i(ht,{integrationId:B,addonId:W.addonId,name:W.name,kind:J,mode:Z,brokerKind:be,canTest:Te,trpc:g.trpcClient,onClose:()=>ne(!1)}),M&&i(de,{open:!0,onOpenChange:e=>!e&&N(!1),children:e(Se,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,className:`md:max-w-5xl md:h-[80vh]`,children:[i(me,{className:`mb-0`,children:e(ue,{className:`flex items-center gap-2 min-w-0`,children:[i(D,{className:`h-4 w-4 text-primary shrink-0`}),i(`span`,{className:`truncate`,children:W.name}),e(`span`,{className:`text-[10px] text-foreground-subtle font-mono truncate font-normal`,children:[W.addonId,B?` · ${B}`:``]})]})}),i(X,{className:`min-h-0 overflow-hidden p-0`,children:i(fe,{addonId:W.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:s(`integrations.integrationNotFound`,{defaultValue:`Integration not found`})}),i(`p`,{className:`text-[11px] text-foreground-subtle`,children:s(`integrations.integrationNotFoundHint`,{defaultValue:`The integration "{{id}}" does not exist. It may have been deleted, or the URL may be wrong.`,id:t})})]}),e(`button`,{onClick:()=>f(`/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(C,{className:`h-3 w-3`}),s(`integrations.backToList`,{defaultValue:`Back to integrations`})]})]})}function bt({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{_t as IntegrationDetailPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{C as e,J as t,K as n,S as r,V as i,Y as a,et as o,k as s,o as c,x as l,z as u}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{En as d,Fn as f,In as p,Ui as m,V as h,fr as g,hr as _,tn as v,yn as y,zt as b}from"./player-overlays-B5FSaids.js";import{Wr as x}from"./client-JLEP7nv7.js";import{t as S}from"./settings-2-BdhYf7UQ.js";import{$t as C,Bi as w,Er as ee,Ki as T,Tr as E,Yr as D,bn as O,br as k,en as A,hn as te,ri as ne}from"./src-IQsaq5W-.js";import{t as j}from"./useTranslation-BJr-n0es.js";import{c as re,d as M,mr as N,o as P,pr as F,r as I,s as L,u as R,yr as z}from"./index-lH9UKmhf.js";import{t as B}from"./AdminPage-CVSTxsAk.js";import{t as V}from"./NodeAddonsSettingsPanel-lczGJdHs.js";import{t as H}from"./AddonAssetIcon-DCKCRhEh.js";o();function U(e){let{ids:t,answered:r,legacyGroupParam:i=null,groupFirst:a}=e,[o]=z(),s=o.get(P),c=i===null?null:o.get(i),l=o.get(L),u=n(()=>R({ids:t,requested:s,answered:r,legacyGroup:c,...a===void 0?{}:{groupFirst:a}}),[t,s,r,c,a]),d=n(()=>(e,t)=>`?${M(o,e,i,t??null).toString()}`,[o,i]);return{...u,requestedSection:l,hrefFor:d}}var W=[[[`addons`,`listCapabilityProviders`]],[[`addons`,`list`]]],G=`text-[10px]`;function K({isActive:e}){let{t}=j();return r(ne,{variant:e?`success`:`default`,className:G,children:e?t(`integrationHub.addonControls.enabled`,`Enabled`):t(`integrationHub.addonControls.disabled`,`Disabled`)})}function q({capName:t,addonId:n,isActive:i}){let{t:a}=j(),o=c(),s=T({onSuccess:()=>{for(let e of W)o.invalidateQueries({queryKey:e})}}),l=s.isPending;return e(D,{size:`sm`,variant:i?`secondary`:`primary`,disabled:l,onClick:()=>s.mutate({capName:t,addonId:n,enabled:!i}),children:[l?r(g,{className:`h-3 w-3 animate-spin`}):r(i?v:p,{className:`h-3 w-3`}),i?a(`common.disable`,`Disable`):a(`common.enable`,`Enable`)]})}function ie({addonId:e,displayName:t}){let{t:n}=j(),i=c(),a=w({onSuccess:()=>{for(let e of W)i.invalidateQueries({queryKey:e})}});return r(te,{label:n(`integrationHub.addonControls.restart`,`Restart`),icon:d,size:`sm`,title:n(`integrationHub.addonControls.restart2`,`Restart "{{displayName}}"?`,{displayName:t}),description:n(`integrationHub.addonControls.restartingTheAddonBouncesIts`,`Restarting the addon bounces its subprocess — the provider will briefly drop and reconnect automatically.`),confirmLabel:n(`integrationHub.addonControls.restart`,`Restart`),triggerVariant:`ghost`,confirmVariant:`danger`,disabled:a.isPending,action:()=>a.mutateAsync({addonId:e})})}o();var J=600,Y=s(null);function X({id:n,title:i,icon:a,actions:o,framed:s=!1,children:c}){let{t:d}=j(),f=u(Y),p=t(null),m=`integration-section-${n}`;ae(p,f,n);let g=e(l,{children:[f===null?null:r(N,{to:f.sectionHref(n),"aria-label":d(`integrationHub.integrationSection.linkTo`,`Link to {{title}}`,{title:i}),title:d(`integrationHub.integrationSection.linkTo`,`Link to {{title}}`,{title:i}),className:`rounded p-0.5 text-foreground-subtle/60 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40`,children:r(_,{className:`h-3 w-3`,"aria-hidden":!0})}),o]});return s?r(`div`,{ref:p,className:`scroll-mt-4`,children:r(O,{headingId:m,title:i,icon:a,actions:g,children:c})}):e(`section`,{ref:p,"aria-labelledby":m,className:`scroll-mt-4 space-y-2`,children:[e(`header`,{className:`flex min-h-7 flex-wrap items-center gap-2 px-0.5`,children:[a!==void 0&&r(a,{className:`h-3.5 w-3.5 shrink-0 text-foreground-subtle`,"aria-hidden":!0}),r(`h2`,{id:m,className:`${h} min-w-0 flex-1`,children:i}),g]}),c]})}function ae(e,t,n){let r=t?.requestedSection===n,a=t?.integrationId;i(()=>{if(!r)return;let t=()=>e.current?.scrollIntoView?.({block:`start`});t();let n=!1,i=()=>{n=!0},a=[`wheel`,`touchmove`,`keydown`];for(let e of a)window.addEventListener(e,i,{once:!0,passive:!0});let o=window.setTimeout(()=>{n||t()},J);return()=>{window.clearTimeout(o);for(let e of a)window.removeEventListener(e,i)}},[r,a,e])}o();var Z=`max-h-72`;function oe({addonId:t,displayName:n,capName:i,isActive:a,badges:o,primaryAction:s,error:c=null,lead:l,panels:u=[],settingsContent:d}){let{t:f}=j(),p=u.filter(e=>e.placement!==`end`),m=u.filter(e=>e.placement===`end`);return e(`div`,{className:`flex flex-col gap-4`,children:[r(se,{addonId:t,displayName:n,capName:i,isActive:a,badges:o,primaryAction:s}),c!==null&&r(E,{message:c}),l,r(Q,{panels:p}),r(X,{id:re,title:f(`integrationHub.addonIntegrationBody.settings`,`Settings`),icon:S,children:d===void 0?r(V,{nodeId:`hub`,addonIds:[t],level:`global`,capability:i}):d}),r(le,{addonId:t}),r(Q,{panels:m})]})}function Q({panels:e}){return r(l,{children:e.map(e=>r(X,{id:e.id,title:e.title,icon:e.icon,children:e.content},e.id))})}function se({addonId:t,displayName:n,capName:i,isActive:a,badges:o,primaryAction:s}){return e(`div`,{className:`flex flex-wrap items-center justify-between gap-2 rounded-lg border border-border bg-surface px-2 py-1.5 sm:px-3`,"data-testid":`integration-status-strip`,children:[e(`div`,{className:`flex min-w-0 flex-wrap items-center gap-1.5`,children:[r(K,{isActive:a}),o,r(`span`,{className:`break-all font-mono text-[11px] text-foreground-subtle`,children:t})]}),e(`div`,{className:`flex flex-wrap items-center justify-end gap-1`,children:[s,r(q,{capName:i,addonId:t,isActive:a}),r(ie,{addonId:t,displayName:n})]})]})}var ce=[{kind:`logs`,labelKey:`common.logs`,icon:y},{kind:`events`,labelKey:`common.events`,icon:m}];function le({addonId:t}){let{t:n}=j(),[i,o]=a(`logs`);return r(X,{id:I,title:n(`integrationHub.addonIntegrationBody.activity`,`Activity`),framed:!0,actions:r(`div`,{role:`group`,"aria-label":n(`integrationHub.addonIntegrationBody.activityStream`,`Activity stream`),className:`flex items-center gap-1`,children:ce.map(({kind:t,labelKey:a,icon:s})=>e(`button`,{type:`button`,"aria-pressed":i===t,onClick:()=>o(t),className:`inline-flex items-center gap-1 rounded px-2 py-0.5 text-[11px] font-medium transition-colors ${i===t?`bg-primary/10 text-primary`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,children:[r(s,{className:`h-3 w-3`,"aria-hidden":!0}),n(a)]},t))}),children:i===`logs`?r(A,{addonId:t,maxHeight:Z,showFilters:!1}):r(C,{addonId:t,category:`addon.*`,maxHeight:Z})})}var ue=`inline-flex min-w-0 max-w-full items-center gap-1.5 rounded-full border py-1 pl-1 pr-2.5 text-xs transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40`,de=`border-primary bg-primary/10 text-primary font-medium`,fe=`border-border bg-surface text-foreground-subtle hover:bg-surface-hover hover:text-foreground`,pe={ok:`bg-success`,off:`bg-foreground-subtle/60`,error:`bg-danger`,unknown:`border border-foreground-subtle bg-transparent`};function $({label:t,groups:n,selectedId:i,hrefFor:a}){let o=n.length>1;return r(`nav`,{"aria-label":t,className:o?`flex flex-col gap-2 sm:grid sm:grid-cols-[max-content_minmax(0,1fr)] sm:items-start sm:gap-x-3`:`flex flex-col`,children:n.map(t=>e(`div`,{role:`group`,"aria-label":t.label,className:o?`flex min-w-0 flex-col gap-1 sm:col-span-2 sm:grid sm:grid-cols-subgrid sm:items-start`:`min-w-0`,children:[o&&r(`span`,{className:`text-[10px] font-semibold uppercase tracking-wider text-foreground-subtle sm:pt-2`,children:t.label}),e(`div`,{className:`flex min-w-0 flex-wrap items-center gap-1.5`,children:[t.entries.map(e=>r(me,{entry:e,current:e.id===i,href:a(e.id)},e.id)),t.install&&e(N,{to:x(t.install.capability),className:`inline-flex min-w-0 max-w-full items-center gap-1.5 rounded-full border py-1 pl-1 pr-2.5 text-xs transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40 border-dashed border-border pl-2 text-foreground-subtle hover:border-primary/50 hover:text-foreground`,children:[r(f,{className:`h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),r(`span`,{className:`truncate`,children:t.install.label})]})]})]},t.id))})}function me({entry:t,current:n,href:i}){let a=t.state===`ok`;return e(N,{to:i,"aria-current":n?`true`:void 0,className:`${ue} ${n?de:fe}`,"data-testid":`integration-pill-${t.id}`,children:[r(H,{addonId:t.id,fallback:t.fallbackIcon,tileClassName:``,size:`sm`}),r(`span`,{className:`truncate`,children:t.name}),t.showState!==!1&&r(he,{entry:t,quiet:a})]})}function he({entry:t,quiet:n}){return e(l,{children:[r(`span`,{className:`h-1.5 w-1.5 shrink-0 rounded-full ${pe[t.state]}`,"aria-hidden":!0}),r(`span`,{className:n?`sr-only`:`shrink-0 text-[10px] font-normal text-foreground-subtle`,children:t.stateLabel})]})}o();function ge({icon:t,title:i,subtitle:a,groups:o,isLoading:s,emptyTitle:c,emptyDescription:u,legacyGroupParam:d,trailing:f,embedded:p=!1}){let{t:m}=j(),h=n(()=>o.flatMap(e=>e.entries),[o]),g=n(()=>h.map(e=>e.id),[h]),_=n(()=>{let e={};for(let t of o){let n=t.entries[0];n!==void 0&&(e[t.id]=n.id)}return e},[o]),v=U({ids:g,answered:!s,legacyGroupParam:d??null,groupFirst:_}),y=h.find(e=>e.id===v.selectedId)??null,b=n(()=>y===null?null:{integrationId:y.id,requestedSection:v.requestedSection,sectionHref:e=>v.hrefFor(y.id,e)},[y,v]),x=s?null:r($,{label:m(`integrationHub.integrationHub.integrations`,`{{title}} integrations`,{title:i}),groups:o,selectedId:v.selectedId,hrefFor:e=>v.hrefFor(e)}),S=s?r(k,{children:r(`div`,{className:`p-6 text-sm text-foreground-subtle`,children:m(`common.loading`,`Loading…`)})}):e(l,{children:[v.staleId!==null&&r(ve,{staleId:v.staleId,shownName:y?.name??null}),y!==null&&b!==null?r(Y.Provider,{value:b,children:r(`div`,{role:`region`,"aria-label":y.name,"data-testid":`integration-body`,children:y.render()},y.id)}):r(_e,{groups:o,title:c,description:u}),f]});return p?e(`div`,{className:`space-y-3`,"data-testid":`integration-hub-embedded`,children:[x,S]}):r(B,{icon:t,title:i,subtitle:a,nav:x,children:S})}function _e({groups:t,title:n,description:i}){let a=t.find(e=>e.install!==void 0)?.install;return r(k,{children:r(ee,{title:n,description:i,action:a?r(N,{to:x(a.capability),children:e(D,{variant:`primary`,size:`sm`,children:[r(f,{className:`mr-1 h-3.5 w-3.5`}),a.label]})}):void 0})})}function ve({staleId:t,shownName:n}){let{t:i}=j();return e(`div`,{role:`status`,className:`flex items-start gap-2 rounded-md border border-warning/30 bg-warning/5 px-3 py-2 text-[11px] text-foreground-subtle`,children:[r(b,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-warning`,"aria-hidden":!0}),e(`span`,{children:[r(F,{i18nKey:`integrationHub.staleIntegration.notice`,values:{id:t},components:{mono:r(`span`,{className:`font-mono text-foreground`})}}),n!==null&&e(l,{children:[` `,r(F,{i18nKey:`integrationHub.staleIntegration.showing`,values:{name:n},components:{b:r(`span`,{className:`font-medium text-foreground`})}})]})]})]})}export{U as i,oe as n,G as r,ge as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{C as e,J as t,K as n,R as r,S as i,V as a,Y as o,et as s,o as c,x as l}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{Di as u,En as d,Fn as f,Ni as p,Oi as m,Pn as h,Ti as g,V as _,dt as v,fr as y,gn as b,gt as x,kn as S,vn as C,vr as w}from"./player-overlays-B5FSaids.js";import{t as ee}from"./table-2-DaQYtXJ7.js";import{At as T,Cs as te,Do as ne,F as E,Mt as re,Pi as D,Tr as ie,Ts as ae,Yr as O,at as k,bs as oe,gd as A,go as j,io as se,kt as ce,r as M,wd as N,xi as le}from"./src-IQsaq5W-.js";import{t as P}from"./i18n-CXGP1uaw.js";import{t as F}from"./useTranslation-BJr-n0es.js";import{C as I,_r as ue,dr as L,gr as de,yr as R}from"./index-lH9UKmhf.js";import{t as z}from"./AdminPage-CVSTxsAk.js";import"./useEventInvalidation-C44QyL85.js";import{t as fe}from"./device-integration-icon-Nwyo5V5H.js";import{i as pe,n as me,r as he,t as ge}from"./ScanNetworkModal-Bg22q8vm.js";import{t as B}from"./framework-packages-B7oma9J4.js";s();function _e(e){return e.some(e=>e.status===`running`)?`running`:e.some(e=>e.status===`stopped`)?`stopped`:`disabled`}function ve(e,t){let n=new Map;for(let t of e){let e=n.get(t.addonId);e===void 0?n.set(t.addonId,[t]):e.push(t)}return[...n.entries()].map(([e,n])=>{let r=t.get(e)?.trim()??``;return{addonId:e,name:r.length>0?r:n[0]?.name??e,instances:n,instanceCount:n.length,deviceCount:n.reduce((e,t)=>e+t.deviceCount,0),status:_e(n)}})}function ye(e){return e.integrationSection===void 0?B(e.packageName)?`system`:`providers`:e.integrationSection}function V(e){let t=new Set;for(let n of e??[])ye(n.manifest)===`system`&&t.add(n.manifest.id);return t}function H(e,t){return{providers:e.filter(e=>!t.has(e.addonId)),system:e.filter(e=>t.has(e.addonId))}}function U(e,t){return[...e].sort((e,n)=>e.name.localeCompare(n.name,t,{sensitivity:`base`}))}function W({kind:t,children:n}){let{t:r}=F(),a=`integrations-section-${t}`;return e(`section`,{"aria-labelledby":a,"data-testid":a,className:`min-w-0 space-y-2`,children:[i(`h2`,{id:a,className:_,children:t===`providers`?r(`integrations.sections.providers`,`Providers`):r(`integrations.sections.system`,`System`)}),n]})}function G({children:e}){return i(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-2 sm:gap-3 lg:grid-cols-3`,children:e})}function K({addonId:t,name:n,openLabel:r,onOpen:a,body:o,footer:s,disabled:c=!1,testId:l,buttonTestId:u}){return e(`article`,{"data-testid":l,className:`relative flex min-w-0 items-stretch gap-3 overflow-x-clip rounded-lg border border-border bg-surface p-3`,children:[i(O,{type:`button`,variant:`ghost`,"aria-label":r,disabled:c,"data-testid":u,onClick:a,className:`absolute inset-0 z-0 h-auto w-auto rounded-lg p-0 focus-visible:ring-2 focus-visible:ring-primary`}),i(`div`,{className:`pointer-events-none relative z-10 flex w-20 shrink-0 items-center justify-center`,children:i(L,{type:t,size:`xl`})}),e(`div`,{className:`pointer-events-none relative z-10 grid min-w-0 flex-1 grid-rows-[1fr_auto_1fr] gap-1`,children:[i(`p`,{className:`min-w-0 self-start truncate text-sm font-semibold text-foreground`,children:n}),o,i(`div`,{className:`self-end justify-self-start`,children:s})]})]})}function be({providers:t,system:r,onOpen:a,searchPlaceholder:s,emptyLabel:c}){let[l,u]=o(``),d=n(()=>{let e=l.trim().toLowerCase(),n=t=>e.length===0||`${t.name} ${t.addonId} ${t.instances.map(e=>e.name).join(` `)}`.toLowerCase().includes(e);return{providers:t.filter(n),system:r.filter(n)}},[l,t,r]),f=d.providers.length===0&&d.system.length===0;return e(`div`,{className:`space-y-3`,children:[e(`div`,{className:`relative`,children:[i(C,{className:`pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-foreground-subtle`,"aria-hidden":!0}),i(A,{type:`search`,value:l,onChange:e=>u(e.target.value),placeholder:s,"aria-label":s,className:`pl-8`})]}),f?i(`p`,{className:`py-8 text-center text-xs text-foreground-subtle`,children:c}):e(`div`,{className:`space-y-4`,children:[d.providers.length>0&&i(W,{kind:`providers`,children:i(q,{groups:d.providers,onOpen:a})}),d.system.length>0&&i(W,{kind:`system`,children:i(q,{groups:d.system,onOpen:a})})]})]})}function q({groups:e,onOpen:t}){let{t:r,i18n:a}=F();return i(G,{children:n(()=>U(e,a.language),[e,a.language]).map(e=>i(K,{testId:`integration-card-${e.addonId}`,addonId:e.addonId,name:e.name,openLabel:r(`integrations.openNamed`,{name:e.name,defaultValue:`Open {{name}}`}),onOpen:()=>t(e),body:i(`p`,{className:`text-xs text-foreground-muted`,children:r(`integrations.addonCard.summary`,{integrations:r(`integrations.addonCard.integrationCount`,{count:e.instanceCount}),devices:r(`integrations.integrationColumns.deviceCount`,{count:e.deviceCount}),defaultValue:`{{integrations}} · {{devices}}`})}),footer:i(k,{status:e.status,className:`shrink-0`})},e.addonId))})}s();var J=`camstack.admin.integrations.view`;function xe(e){return e===`table`||e===`grid`}function Y(){try{return typeof window>`u`?null:window.localStorage}catch{return null}}function Se(e=Y()){if(e===null)return`table`;try{let t=e.getItem(J);return xe(t)?t:`table`}catch{return`table`}}function Ce(e,t=Y()){if(t!==null)try{t.setItem(J,e)}catch{}}function we(){let[e,t]=o(()=>Se());return[e,r(e=>{t(e),Ce(e)},[])]}s();function Te(e=!0){a(()=>{if(!e)return;let t=document.body.style.overflow;return document.body.style.overflow=`hidden`,()=>{document.body.style.overflow=t}},[e])}s();function Ee(e,t){let[n,r]=o(!1);return a(()=>{if(!e){r(!1);return}r(!1);let n=setTimeout(()=>r(!0),t);return()=>clearTimeout(n)},[e,t]),n}s();function De({providerId:t,onImport:n,onSkip:r}){let{t:s}=F(),[c,l]=o(new Set),u=j(),d=u.data,f=u.isPending||!u.data&&!u.isError;a(()=>{t&&(u.isPending||u.data||u.mutate({addonId:t}))},[t,u]);function h(e){l(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}if(f)return e(`div`,{className:`flex flex-col items-center py-12`,children:[i(`div`,{className:`h-6 w-6 animate-spin rounded-full border-2 border-primary border-t-transparent`}),i(`p`,{className:`mt-3 text-xs text-foreground-subtle`,children:s(`integrations.searchingDevices`)})]});let g=d??[];return e(`div`,{className:`space-y-4`,children:[i(`p`,{className:`text-xs text-foreground-subtle`,children:g.length>0?s(`integrations.foundDevices`,{count:g.length}):s(`integrations.noDevicesFound`)}),g.length>0&&i(`div`,{className:`space-y-1.5 max-h-64 overflow-y-auto`,children:g.map(t=>{let n=t.stableId,r=t.suggestedName??n,a=c.has(n),o=t.alreadyOnboarded===!0;return e(`button`,{onClick:()=>{o||h(n)},disabled:o,title:o?s(`integrations.alreadyAddedHint`,{defaultValue:`Already added as "{{name}}" — re-adding would overwrite its settings.`,name:t.onboardedName??r}):void 0,className:`flex w-full items-center gap-3 rounded-lg border p-3 text-left transition-colors ${o?`border-border bg-surface opacity-60 cursor-not-allowed`:a?`border-primary/40 bg-primary/5`:`border-border bg-surface hover:border-foreground-subtle/30`}`,children:[i(`div`,{className:`flex h-5 w-5 items-center justify-center rounded border flex-shrink-0 ${a&&!o?`border-primary bg-primary`:`border-border`}`,children:a&&!o&&i(m,{className:`h-3 w-3 text-primary-foreground`})}),i(p,{className:`h-3.5 w-3.5 text-foreground-subtle flex-shrink-0`}),i(`span`,{className:`text-xs font-medium text-foreground truncate`,children:r}),o&&i(`span`,{className:`ml-auto flex-shrink-0 rounded bg-surface-muted px-1.5 py-0.5 text-[10px] font-medium text-foreground-subtle`,children:s(`integrations.alreadyAdded`,{defaultValue:`Already added`})})]},n)})}),e(`div`,{className:`flex items-center justify-between pt-2`,children:[i(`button`,{onClick:r,className:`rounded-lg border border-border px-3 py-1.5 text-xs text-foreground-subtle hover:text-foreground transition-colors`,children:s(`integrations.skip`)}),g.length>0&&e(`button`,{onClick:()=>n(Array.from(c)),disabled:c.size===0,className:`rounded-lg bg-primary px-4 py-1.5 text-xs font-medium text-primary-foreground shadow-sm disabled:opacity-50`,children:[s(`integrations.importSelected`),` (`,c.size,`)`]})]})]})}var X=`(hover: none) and (pointer: coarse)`;function Z(){if(typeof window>`u`||typeof window.matchMedia!=`function`)return!0;try{return!window.matchMedia(X).matches}catch{return!0}}s();function Oe({onSelect:r,onClose:s,pendingAddonId:c=null}){let{t:l,i18n:u}=F(),d=ue(),[f,p]=o(``),m=t(null),{data:h,isLoading:g}=te();a(()=>{g||!Z()||m.current?.focus()},[g]);let _=n(()=>{let e=h??[],t=f.trim().toLowerCase();return t.length===0?e:e.filter(e=>`${e.name} ${e.description??``} ${e.addonId}`.toLowerCase().includes(t))},[h,f]),{data:v}=D(void 0),x=n(()=>{let e=H(_,V(v));return{providers:U(e.providers,u.language),system:U(e.system,u.language)}},[_,v,u.language]);if(g)return i(`div`,{className:`grid grid-cols-1 gap-2 p-2 sm:grid-cols-2 lg:grid-cols-3`,children:[1,2,3,4].map(e=>i(`div`,{className:`h-24 rounded-lg bg-surface animate-pulse`},e))});let S=c!==null,w=t=>i(G,{children:t.map(t=>{let n=t.instanceMode===`unique`&&t.existingInstances.length>0,a=c===t.addonId;return i(K,{testId:`provider-card-${t.addonId}`,buttonTestId:`provider-pick-${t.addonId}`,addonId:t.addonId,name:t.name,openLabel:t.name,disabled:S,onOpen:()=>{if(n){let e=t.existingInstances[0].id;s(),d(I(t.addonId,e))}else r(t.addonId,t.instanceMode,t.discoveryMode,t.name,t.kind,t.brokerKind,t.mode,t.canTest)},body:t.description?i(`p`,{className:`line-clamp-2 text-xs text-foreground-muted`,children:t.description}):i(`span`,{}),footer:a?i(y,{className:`h-4 w-4 animate-spin text-primary`}):n?e(`span`,{className:`flex items-center gap-1 text-xs font-medium text-foreground-subtle`,children:[i(b,{className:`h-3 w-3`}),l(`integrations.manage`)]}):null},t.addonId)})});return e(`div`,{className:`space-y-3`,"data-testid":`provider-picker`,children:[e(`div`,{className:`relative`,children:[i(C,{className:`pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-foreground-subtle`,"aria-hidden":!0}),i(A,{ref:m,type:`search`,value:f,onChange:e=>p(e.target.value),placeholder:l(`integrations.searchProviders`,`Search integrations…`),className:`pl-8`,"data-testid":`provider-picker-search`,"aria-label":l(`integrations.searchProviders`,`Search integrations…`)})]}),x.providers.length>0&&i(W,{kind:`providers`,children:w(x.providers)}),x.system.length>0&&i(W,{kind:`system`,children:w(x.system)}),_.length===0&&i(`div`,{className:`py-8 text-center text-xs text-foreground-subtle`,children:(h??[]).length===0?l(`integrations.noProviders`):l(`integrations.noProvidersMatch`,`No integrations match your search.`)})]})}s();function ke(e){let t=e=>{if(e.type===`separator`||e.type===`info`||e.type===`button`)return e;if(e.type===`group`)return{...e,fields:e.fields.map(e=>t(e))};let{value:n,...r}=e;return r};return{...e.tabs?{tabs:e.tabs}:{},sections:e.sections.map(e=>({...e,fields:e.fields.map(t)}))}}var Ae=2e4;function je({open:t,onClose:r,seed:s=null}){let{t:u}=F(),d=ue(),f=c(),[p,m]=o(`picker`),[h,g]=o(null),[_,v]=o(null),[b,S]=o(`manual`),[C,w]=o(null),[ee,T]=o(``),[ne,E]=o(null),[re,D]=o(null),[ie,ae]=o(!1),[O,k]=o({}),[A,ce]=o(``),M=s?.config.host,N=s===null?``:`${s.addonId}\0${s.name}\0${typeof M==`string`?M:``}`;t&&s!==null&&A!==N&&(ce(N),g(s.addonId),T(s.name),k({...s.config}),m(`config`));let P=te(void 0,{enabled:t&&s!==null}),{data:L}=le({addonId:h??``,nodeId:`hub`},{enabled:h!=null}),de=n(()=>L?ke(L):null,[L]),R=oe({onSuccess:()=>f.invalidateQueries({queryKey:[[`integrations`]]})}),z=j(),fe=z.data;a(()=>{if(!t||s===null)return;let e=P.data?.find(e=>e.addonId===s.addonId);e&&(ae(e.canTest),S(e.discoveryMode))},[t,s,P.data]),a(()=>{p!==`discovery`||!_||!h||z.isPending||z.data||z.mutate({addonId:h})},[p,_,h,z]);let me=se({onSuccess:()=>f.invalidateQueries({queryKey:[[`deviceManager`]]})});function ge(e,t,n,r,i,a,o,s){if(!R.isPending){if(g(e),ae(s),S(n),T(r),D(null),o===`broker`){if(!a){D(`Addon '${e}' declares mode 'broker' but no brokerKind in its manifest`);return}w(a),m(`broker`);return}if(o===`account`){m(`config`);return}B(e,r)}}async function B(e,t){try{let n=await R.mutateAsync({addonId:e,name:t,settings:{}});r(),H(),d(`${I(e,n.id)}&add=1`)}catch{}}async function _e(e){if(h)try{let t=await R.mutateAsync({addonId:h,name:e.name,settings:e.config,secretKeys:[...e.secretKeys]});v(t.id),E(t.id),b===`auto`||b===`both`?m(`discovery`):V(t.id,{openAdd:!0})}catch{}}async function ve(e){if(h)try{let t=await R.mutateAsync({addonId:h,name:ee,settings:{brokerId:e}});E(t.id),v(t.id),V(t.id)}catch{}}async function ye(e){if(h){for(let t of e){let e=fe?.find(e=>e.stableId===t);e&&await me.mutateAsync({addonId:h,candidate:e,...ne===null?{}:{integrationId:ne}})}V()}}function V(e,t){let n=e??_??h;if(r(),H(),n&&h){let e=I(h,n);d(t?.openAdd===!0?`${e}&add=1`:e)}}function H(){m(`picker`),g(null),v(null),S(`manual`),w(null),T(``),E(null),D(null),ae(!1),k({}),ce(``)}function U(){r(),H()}Te(t);let W=R.isPending,G=Ee(W,Ae);if(!t)return null;let K={picker:u(`integrations.newIntegration`),config:u(`integrations.configureIntegration`),discovery:u(`integrations.importDevices`),broker:u(`integrations.connectBroker`,{defaultValue:`Connect a broker`})},be=W?h:null,q=R.error,J=W&&!G;return e(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center`,children:[i(`div`,{className:`absolute inset-0 bg-black/60`,onClick:J?void 0:U}),e(`div`,{className:`relative z-10 w-full ${p===`picker`?`max-w-5xl`:`max-w-lg`} max-h-[calc(85dvh-2*max(env(safe-area-inset-top),env(safe-area-inset-bottom)))] rounded-xl border border-border bg-background shadow-2xl flex flex-col overflow-hidden`,children:[e(`div`,{className:`flex items-center justify-between border-b border-border px-5 py-4 flex-shrink-0`,children:[i(`h2`,{className:`text-sm font-semibold text-foreground`,children:K[p]}),i(`button`,{onClick:U,disabled:J,className:`rounded-md p-1 text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-40 disabled:cursor-not-allowed`,children:i(x,{className:`h-4 w-4`})})]}),e(`div`,{className:`px-5 py-4 flex-1 overflow-y-auto overscroll-contain`,children:[q&&!W&&i(`div`,{className:`mb-3 rounded-lg border border-destructive/40 bg-destructive/10 px-3 py-2 text-xs text-destructive`,children:q instanceof Error?q.message:String(q)}),p===`picker`&&e(l,{children:[re&&i(`div`,{className:`mb-3 rounded-lg border border-destructive/40 bg-destructive/10 px-3 py-2 text-xs text-destructive`,children:re}),i(Oe,{onSelect:ge,onClose:U,pendingAddonId:be})]}),p===`config`&&h&&i(he,{addonId:h,configSchema:de??null,canTest:ie,initialName:typeof O.host==`string`?ee:void 0,initialConfig:{...O},onSave:_e,onBack:()=>{k({}),m(`picker`)}},N.length>0?N:h),p===`broker`&&C&&i(pe,{kind:C,onResolved:e=>{ve(e)},onBack:()=>m(`picker`)}),p===`discovery`&&_&&i(De,{providerId:_,onImport:ye,onSkip:V})]}),W&&e(`div`,{className:`absolute inset-0 z-20 flex flex-col items-center justify-center gap-2 rounded-xl bg-background/85 backdrop-blur-sm px-6 text-center`,children:[i(y,{className:`h-6 w-6 animate-spin text-primary`}),i(`p`,{className:`text-xs font-medium text-foreground`,children:u(`integrations.creating`,{defaultValue:`Creating integration…`})}),!G&&i(`p`,{className:`text-[10px] text-foreground-subtle`,children:u(`integrations.creatingHint`,{defaultValue:`Waiting for the addon to restart and register`})}),G&&e(l,{children:[i(`p`,{className:`text-[10px] text-foreground-subtle max-w-xs`,children:u(`integrations.creatingOverdue`,{defaultValue:`This is taking longer than expected. The integration may already have been created — close this dialog and refresh to check.`})}),i(`button`,{onClick:U,className:`mt-1 rounded-md border border-border bg-surface px-3 py-1.5 text-[11px] font-medium text-foreground hover:bg-surface-hover transition-colors`,children:u(`integrations.closeAndRefresh`,{defaultValue:`Close`})})]})]})]})]})}function Me({integration:t,expanded:n,onToggleExpand:r}){let{t:a}=F();return e(`div`,{className:`flex items-center gap-2.5`,children:[i(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),r(t.addonId)},"aria-label":n?a(`integrations.integrationColumns.collapse`,`Collapse`):a(`integrations.integrationColumns.expand`,`Expand`),"aria-expanded":n,className:`flex h-5 w-5 flex-shrink-0 items-center justify-center rounded text-foreground-subtle transition-colors hover:bg-surface-hover hover:text-foreground`,children:i(n?u:g,{className:`h-3.5 w-3.5`})}),i(L,{type:t.addonId,size:`sm`}),e(`div`,{className:`flex min-w-0 flex-col`,children:[i(`span`,{className:`truncate text-xs font-semibold text-foreground`,children:t.name}),i(`span`,{className:`truncate text-[10px] text-foreground-subtle`,children:t.addonId})]})]})}function Ne(e){let{isExpanded:t,onToggleExpand:n}=e;return[{key:`name`,header:P.t(`integrations.integrationColumns.integration`,`Integration`),headerClassName:`w-[55%]`,cell:e=>i(Me,{integration:e,expanded:t(e),onToggleExpand:n})},{key:`devices`,header:P.t(`integrations.integrationColumns.devices`,`Devices`),headerClassName:`w-[15%]`,cellClassName:`text-[11px] text-foreground-subtle`,cell:e=>P.t(`integrations.integrationColumns.deviceCount`,{count:e.deviceCount})},{key:`status`,header:P.t(`integrations.integrationColumns.status`,`Status`),headerClassName:`w-[15%]`,cell:e=>i(k,{status:e.status})}]}s();function Pe(e){if(!e.enabled)return`disabled`;switch(e.processState){case`running`:return`running`;default:return`stopped`}}var Fe=`expand`;function Ie(){let{t}=F(),s=ue(),c=de(),u=v(),[p]=R(),[m,g]=we(),[_,y]=o(!1),[b,x]=o(null),C=r(()=>{x(null),y(!0)},[]),O=r(()=>{y(!1),x(null)},[]),k=r(e=>{A(!1),x(e),y(!0)},[]),[oe,A]=o(!1);a(()=>{let e=me(c.state);e!==null&&(x(e),y(!0),s(`/integrations`,{replace:!0,state:null}))},[c.state,s]);let j=p.get(`setup`);a(()=>{j===null||j.length===0||(x({addonId:j,name:j,config:{}}),y(!0))},[j]);let se=r(()=>A(!0),[]),le=r(()=>A(!1),[]);M([`integrations`],[`integration.enabled`,`integration.disabled`,`integration.deleted`,`provider.started`,`provider.stopped`,`addon.installed`,`addon.uninstalled`,`addon.started`,`addon.stopped`,`addon.updated`]),M([`deviceManager`],[`device.registered`,`device.unregistered`,`device.online`,`device.offline`,`device.disabled`,`device.enabled`]);let{data:P,isLoading:L,isError:pe,refetch:he}=ae(void 0),{data:B,isLoading:_e,isError:ye,refetch:U}=ne({projection:`slim`}),G=n(()=>B??[],[B]),K=n(()=>P??[],[P]),q=n(()=>{let e=new Map;for(let t of G)e.set(t.id,{id:t.id,name:t.name??t.stableId??`#${String(t.id)}`});return e},[G]),J=n(()=>T(P),[P]),xe=n(()=>{let e=new Map;for(let t of re(G)){let n=J(t);if(n.kind!==`resolved`)continue;let r=n.integration.id;e.set(r,(e.get(r)??0)+1)}return e},[G,J]),Y=n(()=>K.map(e=>({id:e.id,addonId:e.addonId,name:e.name,enabled:e.enabled,status:Pe(e),deviceCount:xe.get(e.id)??0})),[K,xe]),{data:Se}=te(),Ce=n(()=>new Map((Se??[]).map(e=>[e.addonId,e.name])),[Se]),Te=p.get(Fe),Ee=r(e=>{let t=new URLSearchParams(window.location.search);t.get(Fe)===e?t.delete(Fe):t.set(Fe,e);let n=t.toString(),r=`${window.location.pathname}${n?`?${n}`:``}${window.location.hash}`;window.history.replaceState(window.history.state,``,r),window.dispatchEvent(new PopStateEvent(`popstate`))},[]),{data:De}=D(void 0),X=n(()=>V(De),[De]),Z=n(()=>H(Y,X),[Y,X]),Oe=n(()=>H(ve(Y,Ce),X),[Y,Ce,X]),ke=r(e=>s(I(e.addonId)),[s]),Ae=r(e=>s(I(e.addonId,e.id)),[s]),Me=r(e=>q.get(e)??null,[q]),Ie=r(e=>s(`/devices/${String(e)}`),[s]),Le=r(e=>i(ce,{context:`integration-detail`,devices:G,trpc:u.trpcClient,integrationOf:J,forceIntegrationId:e.id,urlScope:`nested`,lsKey:`integrations:nested:${e.addonId}`,resolveIntegrationIcon:fe,resolveParent:Me,onNavigate:Ie}),[G,u.trpcClient,J,Me,Ie]),Re=r(e=>Te===e.addonId,[Te]),ze=n(()=>Ne({isExpanded:Re,onToggleExpand:Ee}),[Re,Ee]),Be=r(e=>`${e.name} ${e.addonId}`,[]),Ve=r(e=>e.id,[]),He=e=>i(ce,{mode:`generic`,items:e,getKey:Ve,getSearchText:Be,columns:ze,onRowClick:Ae,isExpanded:Re,renderExpanded:Le,searchPlaceholder:t(`integrations.search`,{defaultValue:`Search integrations…`}),emptyLabel:t(`integrations.empty`,{defaultValue:`No integrations found.`})}),Ue=r(()=>{he(),U()},[he,U]),Q=pe===!0||ye===!0,$=!Q&&(L||_e||P===void 0||B===void 0),We=K.length>0,Ge=[{id:`table`,label:t(`integrations.viewTable`,`Table`),icon:ee},{id:`grid`,label:t(`integrations.viewGrid`,`Grid`),icon:w}];return e(z,{icon:h,title:t(`nav.integrations`,`Integrations`),actions:e(l,{children:[i(E,{ariaLabel:t(`integrations.viewLabel`,`Layout`),value:m,onChange:g,options:Ge,testId:`integrations-view`}),i(`button`,{onClick:Ue,disabled:$,className:`flex items-center gap-1 rounded-lg border border-border bg-surface px-2.5 py-1.5 text-xs font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50`,title:t(`common.refresh`,`Refresh`),children:i(d,{className:N(`h-3.5 w-3.5`,$&&`animate-spin`)})}),e(`button`,{onClick:se,className:`flex items-center gap-1.5 rounded-lg border border-border bg-surface px-2.5 py-1.5 text-xs font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,title:t(`integrations.scanTheLocalNetworkFor`,`Scan the local network for devices`),children:[i(S,{className:`h-3.5 w-3.5`}),t(`integrations.scanNetwork`,`Scan network`)]}),e(`button`,{onClick:C,className:`flex items-center gap-1.5 rounded-lg bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground shadow-sm`,children:[i(f,{className:`h-3.5 w-3.5`}),t(`integrations.newIntegration`,`New Integration`)]})]}),children:[Q&&i(ie,{message:t(`integrations.loadFailed`,`Integrations could not be loaded.`),onRetry:Ue}),$&&i(`div`,{className:`space-y-2`,"data-testid":`integrations-pending`,children:[1,2,3].map(e=>i(`div`,{className:`h-12 rounded-lg border border-border bg-surface animate-pulse`},e))}),!Q&&!$&&!We&&e(`div`,{className:`flex flex-col items-center py-20 text-foreground-subtle`,children:[i(`p`,{className:`text-sm`,children:t(`integrations.noIntegrationsConfigured`,`No integrations configured.`)}),i(`p`,{className:`text-xs mt-1`,children:t(`integrations.clickNewIntegrationToConnect`,`Click "New Integration" to connect cameras and devices.`)})]}),!Q&&!$&&We&&m===`table`&&e(`div`,{className:`space-y-4`,children:[Z.providers.length>0&&i(W,{kind:`providers`,children:He(Z.providers)}),Z.system.length>0&&i(W,{kind:`system`,children:He(Z.system)})]}),!Q&&!$&&We&&m===`grid`&&i(be,{providers:Oe.providers,system:Oe.system,onOpen:ke,searchPlaceholder:t(`integrations.search`,{defaultValue:`Search integrations…`}),emptyLabel:t(`integrations.empty`,{defaultValue:`No integrations found.`})}),i(je,{open:_,onClose:O,seed:b}),i(ge,{open:oe,onClose:le,onSetupIntegration:k})]})}export{Ie 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,a as s,et as c,o as l,t as u,x as d}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{Dn as f,Fn as p,Ht as m,Pn as h,Vn as g,bt as _,cr as v,dt as y,fr as b,hn as x,st as S}from"./player-overlays-B5FSaids.js";import{Yi as C,en as w,oi as T}from"./client-JLEP7nv7.js";import{h as E,s as D}from"./video-2nOnVl_R.js";import{t as O}from"./log-in-ChqbFBLh.js";import{t as k}from"./monitor-smartphone-tJnvQ6Wt.js";import{t as ee}from"./recycle-droAKct3.js";import{Ca as A,Da as j,Dt as M,Or as te,Ot as N,Pi as P,Sn as ne,Yr as F,Za as re,ft as ie,ka as ae,mt as oe,or as I,ri as L,wa as R}from"./src-IQsaq5W-.js";import{t as z}from"./i18n-CXGP1uaw.js";import{t as B}from"./useTranslation-BJr-n0es.js";import{T as V,_r as H,g as U,i as W,yr as G}from"./index-lH9UKmhf.js";import{t as K}from"./AdminSectionedPage-BG6w5-w1.js";import{n as se,r as q,t as J}from"./BrokerEditorDialog-Dd6KEwRN.js";import{t as ce}from"./NodeAddonsSettingsPanel-lczGJdHs.js";import{n as Y,r as X,t as le}from"./IntegrationHub-DiscqOsj.js";c();var Z={connected:`success`,connecting:`warning`,disconnected:`default`,"auth-failed":`danger`,unreachable:`danger`,error:`danger`};function Q({status:e}){return i(L,{variant:Z[e],className:`text-[10px]`,children:e})}function ue({broker:t,interactiveConnectPath:n,interactiveDisconnectPath:r,kindLabel:a,onEdit:s}){let{t:c}=B(),u=l(),d=S(),[f,p]=o(null),h=ae({onSuccess:e=>p(e.ok?{ok:!0}:{ok:!1,error:e.error}),onError:e=>p({ok:!1,error:e instanceof Error?e.message:String(e)})}),v=j({onSuccess:()=>{u.invalidateQueries({queryKey:[[`broker`,`list`]]})}}),y=async()=>{await d({title:c(`brokers.brokerManager.deleteBroker`,`Delete broker`),message:c(`brokers.brokerManager.deleteBrokerIntegrationsThatDepend`,`Delete broker "{{name}}"? Integrations that depend on it will stop working.`,{name:t.name}),confirmLabel:c(`common.delete`,`Delete`),variant:`danger`})&&v.mutate({id:t.id,addonId:t.addonId})},x=n!==void 0&&n.length>0&&t.status!==`connected`,C=r!==void 0&&r.length>0&&t.status===`connected`;return e(`tr`,{className:`border-b border-border last:border-0`,children:[i(`td`,{className:`px-3 py-2 text-xs text-foreground font-medium`,children:t.name}),i(`td`,{className:`px-3 py-2 text-xs text-foreground-subtle`,children:a}),e(`td`,{className:`px-3 py-2`,children:[i(Q,{status:t.status}),f&&i(`span`,{className:`ml-2 text-[10px] ${f.ok?`text-success`:`text-danger`}`,children:f.ok?`OK`:f.error??c(`common.failedWord`)})]}),i(`td`,{className:`px-3 py-2`,children:e(`div`,{className:`flex items-center justify-end gap-1.5`,children:[x&&e(F,{variant:`primary`,size:`sm`,onClick:()=>{U(n,t.id,()=>{u.invalidateQueries({queryKey:[[`broker`,`list`]]})})},title:c(`brokers.brokerManager.signInOpensAPopup`,`Sign in — opens a popup that closes when done`),children:[i(O,{className:`h-3 w-3`}),` `,c(`brokers.brokerManager.signIn`)]}),C&&e(F,{variant:`outline`,size:`sm`,onClick:()=>{U(r,t.id,()=>{u.invalidateQueries({queryKey:[[`broker`,`list`]]})})},title:c(`brokers.brokerManager.signOutClearsTheLinked`,`Sign out — clears the linked Google account on this broker`),children:[i(D,{className:`h-3 w-3`}),` `,c(`brokers.brokerManager.signOut`)]}),e(F,{variant:`outline`,size:`sm`,onClick:()=>h.mutate({id:t.id,addonId:t.addonId}),disabled:h.isPending,title:c(`brokers.brokerManager.testConnection`,`Test connection`),children:[h.isPending?i(b,{className:`h-3 w-3 animate-spin`}):i(_,{className:`h-3 w-3`}),c(`brokers.brokerManager.test`,`Test`)]}),e(F,{variant:`outline`,size:`sm`,onClick:()=>s(t),title:c(`common.edit`,`Edit`),children:[i(g,{className:`h-3 w-3`}),` `,c(`common.edit`)]}),e(F,{variant:`outline`,size:`sm`,className:`border-danger/40 text-danger hover:bg-danger/10`,onClick:()=>{y()},disabled:v.isPending,title:c(`common.delete`,`Delete`),children:[v.isPending?i(b,{className:`h-3 w-3 animate-spin`}):i(m,{className:`h-3 w-3`}),c(`common.delete`,`Delete`)]})]})})]})}function de({addonId:t}={}){let{t:r}=B(),a=R({}),s=n(()=>se(a.data).filter(e=>t===void 0||e.addonId===t),[a.data,t]),[c,l]=o(!1),[u,d]=o(null),{options:f}=q(t===void 0?{}:{addonId:t}),m=n(()=>new Map(f.map(e=>[e.kind,e.label])),[f]),h=n(()=>{let e=new Map;for(let t of f)e.has(t.kind)||e.set(t.kind,{...t.interactiveConnectPath===void 0?{}:{connect:t.interactiveConnectPath},...t.interactiveDisconnectPath===void 0?{}:{disconnect:t.interactiveDisconnectPath}});return e},[f]);return e(`div`,{className:`space-y-3`,children:[i(`div`,{className:`flex items-center justify-end`,children:e(F,{variant:`primary`,size:`sm`,onClick:()=>l(!0),disabled:f.length===0,title:f.length===0?r(`brokers.brokerManager.noBrokerProvidersAvailable`,`No broker providers available`):void 0,children:[i(p,{className:`h-3.5 w-3.5`}),` `,r(`brokers.brokerManager.addBroker`)]})}),i(`div`,{className:`rounded-lg border border-border bg-surface overflow-x-auto`,children:e(`table`,{className:`w-full min-w-[36rem] border-collapse`,children:[i(`thead`,{children:e(`tr`,{className:`border-b border-border bg-background/50`,children:[i(`th`,{className:`px-3 py-2 text-left text-[10px] font-semibold uppercase tracking-wider text-foreground-subtle`,children:r(`brokers.brokerManager.name`,`Name`)}),i(`th`,{className:`px-3 py-2 text-left text-[10px] font-semibold uppercase tracking-wider text-foreground-subtle`,children:r(`brokers.brokerManager.kind`,`Kind`)}),i(`th`,{className:`px-3 py-2 text-left text-[10px] font-semibold uppercase tracking-wider text-foreground-subtle`,children:r(`brokers.brokerManager.status`,`Status`)}),i(`th`,{className:`px-3 py-2 text-right text-[10px] font-semibold uppercase tracking-wider text-foreground-subtle`,children:r(`brokers.brokerManager.actions`,`Actions`)})]})}),e(`tbody`,{children:[a.isLoading&&i(`tr`,{children:e(`td`,{colSpan:4,className:`px-3 py-6 text-center text-xs text-foreground-subtle`,children:[i(b,{className:`inline h-4 w-4 animate-spin`}),` `,r(`brokers.brokerManager.loadingBrokers`)]})}),a.isError&&i(`tr`,{children:e(`td`,{colSpan:4,className:`px-3 py-4 text-center text-xs text-danger`,children:[r(`brokers.brokerManager.failedToLoadBrokers`,`Failed to load brokers:`),` `,a.error instanceof Error?a.error.message:r(`brokers.brokerManager.unknownError`,`Unknown error`)]})}),!a.isLoading&&!a.isError&&s.length===0&&i(`tr`,{children:i(`td`,{colSpan:4,className:`px-3 py-6 text-center text-xs text-foreground-subtle`,children:r(`brokers.brokerManager.noBrokersRegisteredYetAdd`,`No brokers registered yet. Add one to publish device events for downstream automations.`)})}),s.map(e=>{let t=h.get(e.kind);return i(ue,{broker:e,...t?.connect===void 0?{}:{interactiveConnectPath:t.connect},...t?.disconnect===void 0?{}:{interactiveDisconnectPath:t.disconnect},kindLabel:m.get(e.kind)??e.kind,onEdit:d},e.id)})]})]})}),c&&i(J,{...t===void 0?{}:{addonId:t},onClose:()=>l(!1),onSaved:()=>l(!1)}),u&&i(J,{broker:u,onClose:()=>d(null),onSaved:()=>d(null)})]})}function fe(e){if(typeof e==`string`)return e;if(typeof e==`object`&&e){let t=e.name;if(typeof t==`string`)return t}return null}function pe(e){let t=e,n=t?.manifest;if(n?.id===void 0)return null;let r=(n.capabilities??[]).map(fe).filter(e=>e!==null);return{addonId:n.id,displayName:n.packageDisplayName??n.name??n.id,capNames:r,processState:t?.process?.state??null}}function me(e,t){return Object.entries(e).filter(([,e])=>e===t).map(([e])=>e)}function he(e,t){return t.find(t=>e.capNames.includes(t))??null}function ge(e){switch(e){case`running`:return{state:`ok`,label:z.t(`helpers.connectivityModel.running`)};case`crashed`:case`failed`:return{state:`error`,label:e};case`stopped`:case`disabled`:return{state:`off`,label:z.t(`helpers.connectivityModel.stopped`)};default:return{state:`unknown`,label:e??z.t(`common.unknownWord`)}}}c();var _e=[`wasteCollections`,`listSources`],ve=[`wasteCollections`,`listCountries`];function ye(e){return e instanceof Error?e.message:String(e)}function be(e){return typeof e!=`object`||!e?!1:Array.isArray(Reflect.get(e,`sections`))}function xe(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(typeof n!=`object`||!n)continue;let e=Reflect.get(n,`id`),r=Reflect.get(n,`label`),i=Reflect.get(n,`module`);if(typeof e!=`string`||typeof r!=`string`||typeof i!=`string`)continue;let a=Reflect.get(n,`enabled`),o=Reflect.get(n,`formValues`),s=Reflect.get(n,`serviceId`),c=Reflect.get(n,`countryId`);t.push({id:e,label:r,module:i,enabled:typeof a==`boolean`?a:!0,formValues:typeof o==`object`&&o&&!Array.isArray(o)?o:void 0,serviceId:typeof s==`string`?s:void 0,countryId:typeof c==`string`?c:void 0})}return t}function Se(e){return Array.isArray(e)?e.flatMap(e=>{if(typeof e!=`object`||!e)return[];let t=Reflect.get(e,`id`),n=Reflect.get(e,`label`);return typeof t!=`string`||typeof n!=`string`?[]:[{id:t,label:n}]}):[]}function Ce(e){return Array.isArray(e)?e.flatMap(e=>{if(typeof e!=`object`||!e)return[];let t=Reflect.get(e,`id`),n=Reflect.get(e,`label`),r=Reflect.get(e,`module`);if(typeof t!=`string`||typeof n!=`string`||typeof r!=`string`)return[];let i=Reflect.get(e,`title`);return[{id:t,label:n,title:typeof i==`string`&&i.length>0?i:n,module:r}]}):[]}function we(e,t,n){return{sections:[{id:`picker`,title:z.t(`system.wasteSettingsSources.countryService`,`Country & service`),columns:2,fields:[{type:`select`,key:`countryId`,label:z.t(`system.wasteSettingsSources.country`,`Country`),options:[{value:``,label:z.t(`system.wasteSettingsSources.selectCountry`,`Select country…`)},...e.map(e=>({value:e.id,label:e.label}))]},{type:`select`,key:`serviceId`,label:z.t(`system.wasteSettingsSources.service`,`Service`),options:[{value:``,label:n===``?z.t(`system.wasteSettingsSources.pickACountryFirst`,`Pick a country first`):z.t(`system.wasteSettingsSources.selectService`,`Select service…`)},...t.map(e=>({value:e.id,label:e.label}))]}]}]}}function Te({addonId:c,capName:f}){let{t:h}=B(),g=y(),_=l(),v=S(),b=ie({editKey:`wasteEdit`,newKey:`wasteNew`}),[x,C]=o(!1),[w,T]=o(null),[E,D]=o({countryId:``,serviceId:``}),[O,k]=o({label:h(`system.wasteSettingsSources.newSource`,`New source`),enabled:!0}),A=t(null),j=typeof E.countryId==`string`?E.countryId:``,M=typeof E.serviceId==`string`?E.serviceId:``,N=r((e,t)=>g.trpcClient.addons.custom.mutate({addonId:c,action:e,input:t}),[c,g]),P=s({queryKey:[..._e,c],queryFn:async()=>xe(await N(`listSources`,{}))}),re=s({queryKey:[...ve,c],queryFn:async()=>Se(await N(`listCountries`,{}))}),ae=s({queryKey:[`wasteCollections`,`listServices`,c,j],enabled:j!==``,queryFn:async()=>Ce(await N(`listServices`,{countryId:j}))}),R=s({queryKey:[`wasteCollections`,`serviceFormSchema`,c,M],enabled:M!==``,queryFn:async()=>N(`serviceFormSchema`,{serviceId:M})}),z=P.data??[],V=re.data??[],H=ae.data??[],U=be(R.data)?R.data:void 0,W=n(()=>we(V,j===``?[]:H,j),[V,H,j]),G=b.state,K=G.mode===`edit`?z.find(e=>e.id===G.id)??null:null;a(()=>{if(b.state.mode===`edit`&&K!==null){let e=`edit:${K.id}`;if(A.current===e)return;A.current=e,T(null),D({countryId:K.countryId??``,serviceId:K.serviceId??``}),k(K.formValues===void 0?{label:K.label,enabled:K.enabled}:{...K.formValues});return}if(b.state.mode===`new`){if(A.current===`new`)return;A.current=`new`,T(null),D({countryId:``,serviceId:``}),k({label:h(`system.wasteSettingsSources.newSource`,`New source`),enabled:!0})}},[K,b.state]),a(()=>{if(b.state.mode!==`new`||M===``)return;let e=H.find(e=>e.id===M);e&&k(t=>{let n=t.label;return typeof n==`string`&&n!==``&&n!==`New source`?t:{...t,label:e.title}})},[b.state.mode,M,H]);let se=r(e=>{D(t=>{let n=typeof e.countryId==`string`?e.countryId:``;return n===(typeof t.countryId==`string`?t.countryId:``)?e:{countryId:n,serviceId:``}})},[]),q=r(async()=>{await _.invalidateQueries({queryKey:_e})},[_]),J=u({mutationFn:async e=>N(`deleteSource`,{id:e}),onSuccess:async()=>q()}),Y=r(async e=>{await v({title:h(`system.wasteSettingsSources.deleteWasteSource`,`Delete waste source?`),message:h(`system.wasteSettingsSources.removeItsCalendarUnderSystem`,`Remove “{{label}}” ({{id}}). Its calendar under System → Calendars is dropped.`,{label:e.label,id:e.id}),confirmLabel:h(`common.delete`,`Delete`),cancelLabel:h(`common.cancel`,`Cancel`),variant:`danger`})&&(await J.mutateAsync(e.id),b.state.mode===`edit`&&b.state.id===e.id&&(b.close(),A.current=null))},[v,J,b,h]),X=r(async()=>{let e=O.label,t=typeof e==`string`&&e.trim()!==``?e.trim():``;if(t===``){T(`Label is required.`);return}if(M===``){T(`Pick a country and a service.`);return}let n=b.state.mode===`new`,r=K?.id;if(!n&&(r===void 0||r===``)){T(`That source is no longer available.`);return}let i=O.enabled,a={...O};delete a.label,delete a.enabled,C(!0),T(null);try{n?await N(`createSource`,{label:t,serviceId:M,args:a,enabled:typeof i==`boolean`?i:!0}):r!==void 0&&await N(`updateSource`,{id:r,label:t,serviceId:M,args:a,enabled:typeof i==`boolean`?i:!0}),await q(),b.close(),A.current=null}catch(e){T(ye(e))}finally{C(!1)}},[N,K,b,O,q,M]),le=n(()=>[{key:`label`,header:h(`system.wasteSettingsSources.label`,`Label`),sortValue:e=>e.label,render:e=>i(`span`,{className:`text-sm text-foreground`,children:e.label})},{key:`module`,header:h(`system.wasteSettingsSources.module`,`Module`),sortValue:e=>e.module,render:e=>i(`span`,{className:`font-mono text-xs text-foreground-muted`,children:e.module})},{key:`enabled`,header:h(`system.wasteSettingsSources.enabled`,`Enabled`),sortValue:e=>+!!e.enabled,render:e=>i(L,{variant:e.enabled?`success`:`default`,children:e.enabled?h(`system.wasteSettingsSources.on`,`On`):h(`system.wasteSettingsSources.off`,`Off`)})},{key:`actions`,header:``,notSortableReason:`actions`,render:e=>i(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(),Y(e)},children:i(m,{className:`h-3.5 w-3.5 text-danger`})})}],[Y,h]),Z=b.state.mode===`new`,Q=Z||K!==null,ue=`${M}:${Z?`new`:K?.id??`closed`}`;return e(`div`,{className:`flex min-h-0 flex-col gap-4`,"data-testid":`waste-settings-sources`,children:[e(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[i(`p`,{className:`text-sm text-foreground-muted`,children:h(`system.wasteSettingsSources.pickACountryAndA`,`Pick a country and a service — configuration fields come from that HACS source.`)}),e(F,{type:`button`,size:`sm`,"data-testid":`waste-sources-add`,onClick:()=>b.openNew(),children:[i(p,{className:`h-3.5 w-3.5`}),h(`system.wasteSettingsSources.addSource`,`Add source`)]})]}),P.isError?i(`p`,{className:`text-sm text-danger`,children:h(`system.wasteSettingsSources.couldNotLoadSources`,`Could not load sources.`)}):null,P.isPending?i(te,{className:`h-32 w-full`}):i(ne,{columns:le,rows:z,rowKey:e=>e.id,pageSize:25,emptyMessage:h(`system.wasteSettingsSources.noWasteSourcesYetAdd`,`No waste sources yet. Add one to register a municipal service.`),onRowClick:e=>b.openEdit(e.id),defaultSort:{columnKey:`label`,dir:`asc`}}),i(oe,{open:Q,onClose:()=>{b.close(),T(null),A.current=null},title:Z?h(`system.wasteSettingsSources.addWasteSource`,`Add waste source`):h(`system.wasteSettingsSources.edit`,`Edit {{value1}}`,{value1:K?.label??`source`}),icon:ee,width:`xl`,testId:`waste-source-editor`,error:w,footer:i(F,{type:`button`,size:`sm`,disabled:x||M===``,onClick:()=>void X(),children:x?h(`system.wasteSettingsSources.saving`,`Saving…`):h(`common.save`,`Save`)}),children:Q?e(d,{children:[i(`div`,{"data-testid":`waste-country-service`,children:i(I,{schema:W,values:E,onChange:se},`picker:${j}:${H.length}`)}),M!==``&&U!==void 0?i(I,{schema:U,values:O,onChange:k,bare:!0},ue):M!==``&&R.isPending?i(`p`,{className:`text-sm text-foreground-muted`,children:h(`system.wasteSettingsSources.loadingFields`,`Loading fields…`)}):i(`p`,{className:`text-sm text-foreground-muted`,children:h(`system.wasteSettingsSources.chooseACountryAndService`,`Choose a country and service to see the required fields.`)})]}):null}),i(ce,{nodeId:`hub`,addonIds:[c],level:`global`,capability:f,hideSectionChrome:!0})]})}c();var $=1e4,Ee={"device-export":`exporters`,exporters:`exporters`,email:`email`,broker:`brokers`,brokers:`brokers`,"message-brokers":`brokers`,calendar:`calendars`,calendars:`calendars`,"calendar-source":`calendars`},De=[{sectionId:`exporters`,kind:`device-export`,labelKey:`system.connectivity.exporters`,icon:x,installLabelKey:`system.connectivity.exportersInstall`,emptyTitleKey:`system.connectivity.exportersEmptyTitle`,emptyDescriptionKey:`system.connectivity.exportersEmptyDescription`},{sectionId:`email`,kind:`email`,labelKey:`system.connectivity.email`,icon:v,installLabelKey:`system.connectivity.emailInstall`,emptyTitleKey:`system.connectivity.emailEmptyTitle`,emptyDescriptionKey:`system.connectivity.emailEmptyDescription`},{sectionId:`brokers`,kind:`broker`,labelKey:`system.connectivity.brokers`,icon:f,installLabelKey:`system.connectivity.brokersInstall`,emptyTitleKey:`system.connectivity.brokersEmptyTitle`,emptyDescriptionKey:`system.connectivity.brokersEmptyDescription`},{sectionId:`calendars`,kind:`calendar`,labelKey:`system.connectivity.calendars`,icon:E,installLabelKey:`system.connectivity.calendarsInstall`,emptyTitleKey:`system.connectivity.calendarsEmptyTitle`,emptyDescriptionKey:`system.connectivity.calendarsEmptyDescription`}];function Oe(t,n,r,a){let o=me(w,t.kind),s=n.flatMap(n=>{let a=he(n,o);if(a===null)return[];let s=ge(n.processState);return[{id:n.addonId,name:n.displayName,fallbackIcon:t.icon,state:s.state,stateLabel:s.label,render:()=>i(Y,{addonId:n.addonId,displayName:n.displayName,capName:a,isActive:n.processState===`running`,badges:e(d,{children:[i(Me,{processState:n.processState}),i(Ne,{kind:t.kind,addonId:n.addonId})]}),lead:t.kind===`device-export`?i(N,{addonId:n.addonId}):void 0,panels:je(t.kind,n.addonId,e=>r(`/devices/${e}`)),settingsContent:n.addonId===`waste-collections`?i(Te,{addonId:n.addonId,capName:a}):void 0})}]});return{id:t.sectionId,label:a(t.labelKey),entries:s,install:{capability:o[0]??t.kind,label:a(t.installLabelKey)}}}function ke({descriptor:e,rows:t,isLoading:r}){let{t:a}=B(),o=H(),s=n(()=>Oe(e,t,o,a),[e,t,o,a]);return i(le,{embedded:!0,icon:e.icon,title:a(e.labelKey),subtitle:null,groups:[s],isLoading:r,emptyTitle:a(e.emptyTitleKey),emptyDescription:a(e.emptyDescriptionKey)})}function Ae(){let{t:e}=B(),t=P(void 0,{refetchInterval:$}),[r,o]=G(),s=V(`/system/integrations`,{t:e,isAdmin:!0})??{icon:h,title:e(`admin.system.integrations.connectivity`,`Connectivity`)};a(()=>{let e=r.get(`tab`);if(e===null)return;let t=Ee[e];t===void 0||t===e||o(e=>{let n=new URLSearchParams(e);return n.set(`tab`,t),n},{replace:!0})},[r,o]);let c=n(()=>(t.data??[]).map(pe).filter(e=>e!==null),[t.data]),l=n(()=>De.map(n=>({id:n.sectionId,label:e(n.labelKey),ownedParams:W,content:i(ke,{descriptor:n,rows:c,isLoading:t.isLoading})})),[t.isLoading,c,e]);return i(K,{icon:s.icon,title:s.title,subtitle:e(`admin.system.integrations.externalSystemsThisHubTalks`,`External systems this hub talks to — exporters, email, brokers and calendar sources.`),defaultSection:`exporters`,sectionsLabel:`Connectivity sections`,sections:l})}function je(e,t,n){return e===`device-export`?[{id:`devices`,title:z.t(`admin.system.integrations.devices`,`Devices`),icon:k,placement:`end`,content:i(M,{addonId:t,onOpenDevice:n,showSetup:!1})}]:e===`broker`?[{id:`connections`,title:z.t(`admin.system.integrations.connections`,`Connections`),icon:f,content:i(de,{addonId:t})}]:[]}function Me({processState:e}){let{state:t,label:n}=ge(e);return i(L,{variant:t===`ok`?`success`:t===`error`?`danger`:`default`,className:`${X} capitalize`,children:n})}function Ne({kind:e,addonId:t}){return e===`broker`?i(Pe,{addonId:t}):e===`device-export`?i(Fe,{addonId:t}):null}function Pe({addonId:e}){let{t}=B(),{data:n}=A({addonId:e},{refetchInterval:$,retry:!1}),r=C.safeParse(n);if(!r.success)return null;let{brokerCount:a,connectedCount:o}=r.data;return i(L,{variant:`info`,className:X,children:o>0?t(`system.connectivity.connectionsConnected`,{count:a,connected:o}):t(`system.connectivity.connections`,{count:a})})}function Fe({addonId:e}){let{t}=B(),{data:n}=re({addonId:e},{refetchInterval:$,retry:!1}),r=T.safeParse(n);if(!r.success)return null;let{linkState:a,exposedDeviceCount:o}=r.data;return i(L,{variant:a===`linked`?`success`:a===`error`?`danger`:`default`,className:X,children:t(`admin.system.integrations.exposed`,`{{linkState}} · {{exposedDeviceCount}} exposed`,{linkState:a,exposedDeviceCount:o})})}export{Ae as IntegrationsPage};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{C as e,K as t,S as n,V as r,Y as i,et as a,o,x as s}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{Bi as c,Br as l,Di as u,En as d,Fn as f,Gt as p,Ht as m,Jr as h,Jt as g,Ni as _,O as v,Ri as y,Sr as b,Ti as x,Ur as S,V as C,Vn as w,Wi as T,Wt as E,Yr as D,Zi as O,aa as k,gr as A,gt as ee,hr as j,ht as M,k as N,ln as P,lr as F,mn as I,oa as L,oi as te,on as R,sa as ne,sr as re,st as ie,vi as ae,vt as z,yn as B,z as oe}from"./player-overlays-B5FSaids.js";import{$r as se,ti as ce,yn as le}from"./client-JLEP7nv7.js";import{t as ue}from"./boxes-Cc83jXU7.js";import{n as de,r as fe,t as pe}from"./speaker-CmGzkRdE.js";import{t as V}from"./user-round-yFN2hAUV.js";import{$a as me,Ao as he,Bo as ge,Do as _e,Fr as H,Go as ve,Ko as ye,Lr as U,No as be,Nr as W,Pr as xe,Qa as Se,Qo as Ce,Qr as we,R as Te,Ro as Ee,Sn as G,Un as De,Vo as Oe,Vr as ke,Wn as Ae,Wo as je,Yr as K,_d as Me,_r as Ne,dd as Pe,dr as Fe,eo as Ie,fn as Le,fr as Re,gd as q,gr as ze,hr as Be,jo as Ve,ko as He,pn as Ue,pr as We,qo as Ge,ri as Ke,ro as qe,vd as Je,yt as Ye,zo as Xe}from"./src-IQsaq5W-.js";import{t as J}from"./i18n-CXGP1uaw.js";import{t as Y}from"./useTranslation-BJr-n0es.js";import{_r as Ze,m as Qe,mr as X,yr as $e}from"./index-lH9UKmhf.js";import{t as et}from"./AdminSectionedPage-BG6w5-w1.js";import{a as tt,n as nt,r as rt}from"./linked-devices-model-COUfIEod.js";a();function Z(e){return{id:e.id,name:e.name,type:e.type,stableId:e.stableId??``,parentDeviceId:e.parentDeviceId,location:e.location,...e.role!==void 0&&e.role!==null?{role:e.role}:{},...e.primaryChildEntityId!==void 0&&e.primaryChildEntityId!==null?{primaryChildEntityId:e.primaryChildEntityId}:{}}}function Q(e){if(e==null)return null;let t=e.trim();return t.length===0?null:t.toLowerCase()}function it(e,t){let n=Q(t);return n===null?[]:e.filter(e=>Q(e.location)===n)}function at(e,t){let n=it(e,t),r=new Set(n.map(e=>e.id));return n.filter(e=>e.parentDeviceId===null||!r.has(e.parentDeviceId))}function ot(e,t){let n=Q(e.location);return n===null||new Set(t.map(e=>Q(e))).has(n)?null:e.location?.trim()??null}function st(e,t){let n=Q(e.location);return n!==null&&t.has(n)}function ct(e,t){let n=new Set(t.map(e=>Q(e))),r=new Set(e.filter(e=>st(e,n)).map(e=>e.id));return e.filter(e=>!(st(e,n)||e.parentDeviceId!==null&&r.has(e.parentDeviceId)))}function lt(e,t){return ct(e,t).filter(e=>e.parentDeviceId===null)}function ut(e,t){let n=new Map;for(let t of e){if(t.parentDeviceId===null)continue;let e=n.get(t.parentDeviceId);e?e.push(t):n.set(t.parentDeviceId,[t])}let r=[],i=new Set([t]),a=[t];for(;a.length>0;){let e=[];for(let t of a)for(let a of n.get(t)??[])i.has(a.id)||(i.add(a.id),r.push(a),e.push(a.id));a=e}return r}function dt(e,t){return ut(e,t).length}function ft(e,t){return e.filter(e=>!e.isCamera&&e.parentDeviceId===t)}function pt(e,t){return t.map(t=>({name:t,members:at(e,t)}))}var mt={camera:_,hub:de,container:ue,light:A,siren:P,switch:p,sensor:ne,thermostat:g,climate:L,button:ae,"event-emitter":M,update:fe,notifier:T,script:B,automation:z,lock:F,cover:c,valve:D,humidifier:h,"water-heater":l,fan:S,"media-player":pe,"alarm-panel":I,control:R,presence:V,weather:te,vacuum:y,"lawn-mower":E,image:b,smoke:k};function $({type:e,className:t}){return n(mt[e]??ae,{"aria-hidden":`true`,className:t??`h-3.5 w-3.5 shrink-0 text-foreground-subtle`})}function ht({device:e}){let t=H(Z(e),`compact`);return n(gt,{online:e.online,deviceName:t})}function gt({online:e,deviceName:t}){return n(`span`,{className:e?`inline-block h-1.5 w-1.5 shrink-0 rounded-full bg-success`:`inline-block h-1.5 w-1.5 shrink-0 rounded-full border border-foreground-subtle`,role:`img`,"aria-label":J.t(`locations.deviceGlyphs.aria`,{name:t,state:e?J.t(`common.online`):J.t(`common.offline`)}),title:e?J.t(`common.online`):J.t(`common.offline`)})}function _t({open:t,title:a,items:o,listState:s,lockedIds:c,lockedNote:l,suggestions:u=null,busy:d=!1,onConfirm:f,onClose:p}){let{t:m}=Y(),[h,g]=i([]);r(()=>{t||g([])},[t]);let _=new Map(o.map(e=>[e.id,e.name])),v=(u?.ids??[]).filter(e=>_.has(e)&&!c.includes(e)),y=e=>g(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]);return n(Fe,{open:t,onOpenChange:e=>e?void 0:p(),children:e(We,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,"aria-label":a,children:[n(ze,{children:n(Ne,{children:a})}),e(Re,{className:`flex flex-col gap-3 p-2 sm:p-4`,children:[t&&u!==null&&v.length>0&&e(`section`,{"aria-label":u.heading,className:`flex flex-col gap-1`,children:[n(`h3`,{className:`text-[10px] sm:text-[11px] font-semibold text-foreground uppercase tracking-wider`,children:u.heading}),n(`div`,{className:`flex flex-wrap gap-1`,children:v.map(e=>n(`button`,{type:`button`,"aria-pressed":h.includes(e),className:`inline-flex items-center gap-1 rounded-full border px-1.5 py-0.5 text-[10px] font-medium transition-colors ${h.includes(e)?`border-primary/50 bg-primary/15 text-primary`:`border-border bg-surface text-foreground-subtle hover:bg-surface-hover`}`,onClick:()=>y(e),children:_.get(e)},e))})]}),t&&n(Te,{devices:o,listState:s,value:h,onChange:e=>g(e),noun:`device`,emptyLabel:m(`locations.addDialog.nonePicked`),showAll:!0,lockedIds:c,lockedNote:l,testId:`quick-add-picker`})]}),e(Be,{children:[n(K,{variant:`ghost`,onClick:p,children:m(`locations.addDialog.cancel`)}),n(K,{disabled:h.length===0||d,onClick:()=>f(h),children:m(`locations.addDialog.confirm`,{count:h.length})})]})]})})}a();function vt({room:e,cameras:r,fleet:i}){let{t:a}=Y(),o=t(()=>new Map(i.map(e=>[e.id,e])),[i]);return e===null?n(`p`,{className:`text-xs text-foreground-subtle`,children:a(`locations.links.noRoom`)}):n(`div`,{className:`flex flex-col gap-3`,"data-testid":`camera-links-section`,children:r.length===0?n(`p`,{className:`text-xs text-foreground-subtle`,"data-testid":`camera-links-empty`,children:a(`locations.links.noCameras`,{room:e})}):r.map(e=>n(bt,{camera:e,byId:o},e.id))})}function yt(e){return{id:e.deviceId,name:e.name,type:e.type,location:e.location}}function bt({camera:t,byId:r}){let{t:a}=Y(),s=H(Z(t),`full`),c=o(),l=Ze(),[u,d]=i(!1),[f,p]=i(null),m=me({deviceId:t.id}),h=rt({status:m.status,data:m.data,error:m.error===null||m.error===void 0?null:m.error}),g=Ie(),_=h.kind===`present`?h:null,y=Se({deviceId:t.id,slotRef:_?.slot.slotRef??``},{enabled:u&&_!==null}),b=_===null?[]:nt(_.slot,_.value),x=b.map(e=>e.deviceId),S=(y.data?.candidates??[]).map(yt),C=new Set(S.map(e=>e.id)),w=x.filter(e=>!C.has(e)).map(e=>{let t=r.get(e);return{id:e,name:t?.name??`#${String(e)}`,...t===void 0?{}:{type:t.type,location:t.location}}}),T=[...S,...w],E=(y.data?.candidates??[]).filter(e=>e.suggested).map(e=>e.deviceId),D=async e=>{if(_!==null){p(null);try{await g.mutateAsync({deviceId:t.id,slotRef:_.slot.slotRef,value:tt(_.value,e)}),await m.refetch(),await c.invalidateQueries({queryKey:[[`deviceManager`]]}),d(!1)}catch(e){p(e instanceof Error?e.message:String(e))}}},O=[{key:`device`,header:a(`locations.columns.device`),notSortableReason:a(`locations.columns.noSort`),render:t=>{let i=r.get(t.deviceId),o=t.name??i?.name??`#${String(t.deviceId)}`;return e(`span`,{className:`flex items-center gap-1.5`,children:[i!==void 0&&n($,{type:i.type}),n(X,{to:`/devices/${String(t.deviceId)}`,className:`min-w-0 truncate text-xs text-foreground hover:underline`,children:i===void 0?o:n(W,{device:Z(i),form:`compact`})}),t.implied&&n(`span`,{className:`text-[10px] text-foreground-subtle`,children:a(`locations.links.implied`)})]})}},{key:`type`,header:a(`locations.columns.type`),notSortableReason:a(`locations.columns.noSort`),render:e=>n(`span`,{className:`text-xs text-foreground-muted`,children:r.get(e.deviceId)?.type??`—`})},{key:`status`,header:a(`locations.columns.status`),notSortableReason:a(`locations.columns.noSort`),render:t=>{let i=r.get(t.deviceId);return i===void 0?n(`span`,{className:`text-xs text-foreground-subtle`,children:`—`}):e(`span`,{className:`flex items-center gap-1.5`,children:[n(ht,{device:i}),n(`span`,{className:`text-xs text-foreground-muted`,children:i.online?a(`common.online`):a(`common.offline`)})]})}}];return e(`section`,{className:`min-w-0 ${v}`,"data-testid":`camera-links-${String(t.id)}`,children:[e(`header`,{className:`${N} flex min-h-9 items-center gap-1.5`,children:[n($,{type:t.type}),n(`h2`,{className:`min-w-0 flex-1 truncate text-sm font-semibold text-foreground`,children:n(W,{device:Z(t),form:`full`})}),e(K,{variant:`ghost`,size:`sm`,onClick:()=>l(Qe(t.id)),children:[n(j,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),a(`locations.links.edit`)]}),n(K,{variant:`outline`,size:`sm`,disabled:_===null,onClick:()=>d(!0),"aria-label":a(`locations.links.addNamed`,{camera:s}),children:a(`locations.room.add`)})]}),h.kind===`pending`&&n(`p`,{role:`status`,className:`px-3 py-3 text-xs text-foreground-subtle sm:px-4`,children:a(`locations.links.loading`)}),h.kind===`unknown`&&n(`p`,{role:`alert`,className:`px-3 py-3 text-xs text-warning sm:px-4`,children:a(`locations.links.unreadable`,{reason:h.reason})}),h.kind===`absent`&&n(`p`,{className:`px-3 py-3 text-xs text-foreground-subtle sm:px-4`,children:a(`locations.links.unsupported`)}),f!==null&&n(`p`,{role:`alert`,className:`px-3 pt-2 text-xs text-danger break-words sm:px-4`,children:f}),_!==null&&(b.length===0?n(`p`,{className:`px-3 py-3 text-xs text-foreground-subtle sm:px-4`,children:a(`locations.links.none`)}):n(G,{columns:O,rows:b,rowKey:e=>String(e.deviceId),bordered:!1,minWidthPx:360})),n(_t,{open:u,title:a(`locations.links.pickTitle`,{camera:s}),items:T,listState:y.status===`error`?`failed`:y.data===void 0?`pending`:`answered`,lockedIds:x,lockedNote:a(`locations.links.alreadyLinked`),suggestions:t.location===null?null:{heading:a(`locations.links.suggested`,{room:t.location}),ids:E},busy:g.isPending,onConfirm:e=>void D(e),onClose:()=>d(!1)})]})}a();function xt({name:t,description:a,busy:o,onSave:s}){let{t:c}=Y(),[l,u]=i(a??``);return r(()=>{u(a??``)},[a]),e(`div`,{className:`border-t border-border px-3 py-2 sm:px-4`,children:[n(Ae,{htmlFor:`location-description-${t}`,className:`block`,children:c(`locations.locationDescriptionField.whatIsThere`,`What is there`)}),n(`textarea`,{id:`location-description-${t}`,value:l,onChange:e=>u(e.target.value),onBlur:()=>{let e=l.trim();e!==(a??``)&&s(e.length===0?null:e)},disabled:o,rows:2,maxLength:400,placeholder:c(`locations.locationDescriptionField.surfacesBoundariesWhatIsNormally`,`Surfaces, boundaries, what is normally parked or stored here.`),className:`mt-1 w-full resize-y rounded-md border border-border bg-surface px-2.5 py-1.5 text-xs text-foreground placeholder:text-foreground-subtle focus:outline-none focus:ring-1 focus:ring-inset focus:ring-primary disabled:cursor-not-allowed disabled:opacity-50`}),n(`p`,{className:`mt-1 ${oe}`,children:c(`locations.locationDescriptionField.givenToTheAiWith`,`Given to the AI with the pictures, so it knows what it is looking at. Describe the PLACE, not what happens in it — events change, the ground does not.`)})]})}function St(e,t){let n=e?.find(e=>e.locationKey===t);return n===void 0||n.description.length===0?null:n.description}var Ct=` none`;function wt({name:t,zones:r,zoneKey:i,busy:a,onChange:o}){let{t:s}=Y();if(r.length===0)return null;let c=[{value:Ct,label:s(`locations.locationZoneField.none`,`— none —`)},...r.map(e=>({value:e.zoneKey,label:e.label}))];return e(`div`,{className:`flex items-center gap-2 border-t border-border px-3 py-1.5 sm:px-4 sm:py-2`,children:[n(Ae,{htmlFor:`location-zone-${t}`,children:s(`locations.locationZoneField.zone`,`Zone`)}),n(Pe,{id:`location-zone-${t}`,value:i??Ct,disabled:a,onChange:e=>{let t=e.target.value;if(t===Ct){o(null);return}let n=r.find(e=>e.zoneKey===t);n!==void 0&&o(n.label)},options:c})]})}function Tt(e,t){return e.find(e=>e.locationKeys.includes(t))?.zoneKey??null}function Et({name:e,icon:t,busy:r,onPick:i}){return n(Je,{value:t,onPick:i,fallbackGlyph:re,clearGlyph:O,labels:{trigger:`Change the icon of ${e}`,panel:`Icon for ${e}`,searchPlaceholder:`Search icons`,clear:`No icon`,noMatches:`No icon matches that`},disabled:r})}function Dt(e,t){let n=e?.find(e=>e.locationKey===t);return n===void 0?null:ce(n.icon)??`map-pin`}function Ot(e){return`${e.kind}:${String(e.device.id)}`}function kt(e,t,n){return e.flatMap(e=>{let r=ft(t,e.id),i=n.has(e.id),a={kind:`member`,device:e,accessories:r,open:i};return!i||r.length===0?[a]:[a,...r.map(t=>({kind:`accessory`,device:t,parent:e}))]})}a();function At({name:r,members:a,devices:o,busy:c,icon:l,description:u,onRename:f,onDelete:p,onRebuildLinks:h,onAddDevices:g,onPickIcon:_,onSaveDescription:y,zones:b,zoneKey:x,onChangeZone:S}){let{t:C}=Y(),[T,E]=i(!1),[D,O]=i(r),k=Le(a,t(()=>({searchText:e=>[e.name,...ft(o,e.id).map(e=>e.name)],facetValue:e=>e.type}),[o])),[A,j]=i(()=>new Set),M=e=>j(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),P=t(()=>kt(k.rows,o,A),[k.rows,o,A]),F=[{key:`name`,header:C(`locations.columns.device`),notSortableReason:C(`locations.columns.noSort`),render:e=>e.kind===`member`?n(jt,{row:e,onToggle:()=>M(e.device.id)}):n(Mt,{row:e})},{key:`type`,header:C(`locations.columns.type`),notSortableReason:C(`locations.columns.noSort`),render:e=>n(`span`,{className:`text-xs text-foreground-muted`,children:e.device.type})},{key:`status`,header:C(`locations.columns.status`),notSortableReason:C(`locations.columns.noSort`),render:t=>e(`span`,{className:`flex items-center gap-1.5`,children:[n(ht,{device:t.device}),n(`span`,{className:`text-xs text-foreground-muted`,children:t.device.online?C(`common.online`):C(`common.offline`)})]})}],I=()=>{O(r),E(!1)},L=async()=>{let e=D.trim();if(e.length===0||e===r){I();return}await f(e),E(!1)},te=[{id:`rename`,label:C(`locations.locationCard.rename`,`Rename`),icon:w,disabled:c,onClick:()=>{O(r),E(!0)}},{id:`rebuild-links`,label:C(`locations.locationCard.rebuildLinkedDevices`,`Rebuild linked devices`),icon:d,separatorBefore:!0,disabled:c,onClick:()=>void h()},{id:`delete`,label:C(`common.delete`,`Delete`),icon:m,danger:!0,separatorBefore:!0,disabled:c,onClick:()=>void p()}];return e(`section`,{className:`min-w-0 ${v}`,children:[e(`header`,{className:`${N} flex min-h-9 items-center gap-1.5`,children:[n(Et,{name:r,icon:l,busy:c,onPick:_}),T?e(s,{children:[n(q,{value:D,onChange:e=>O(e.target.value),onKeyDown:e=>{e.key===`Enter`&&L(),e.key===`Escape`&&I()},"aria-label":C(`locations.locationCard.rename2`,`Rename {{name}}`,{name:r}),className:`min-w-0 flex-1`,autoFocus:!0}),n(K,{type:`button`,size:`sm`,onClick:()=>void L(),children:C(`common.save`,`Save`)}),n(Me,{type:`button`,variant:`ghost`,icon:ee,onClick:I,"aria-label":C(`locations.locationCard.cancelRename`,`Cancel rename`)})]}):e(s,{children:[n(`h2`,{className:`min-w-0 flex-1 truncate text-sm font-semibold text-foreground`,children:r}),n(K,{type:`button`,variant:`outline`,size:`sm`,disabled:c,onClick:g,"aria-label":C(`locations.room.addTo`,{room:r}),children:C(`locations.room.add`)}),n(Ye,{items:te,title:C(`locations.locationCard.actionsFor`,`Actions for {{name}}`,{name:r}),triggerClassName:`p-1`})]})]}),n(wt,{name:r,zones:b,zoneKey:x,busy:c,onChange:S}),n(xt,{name:r,description:u,busy:c,onSave:y}),a.length>0&&n(`div`,{className:`border-b border-border px-3 py-1.5 sm:px-4 sm:py-2`,children:n(Ue,{state:k.state,facets:k.facets,labels:{searchPlaceholder:C(`locations.filter.searchPlaceholder`),searchLabel:C(`locations.room.searchLabel`,{room:r}),facetsLabel:C(`locations.filter.typesLabel`),clearLabel:C(`locations.filter.clear`)},onSearch:k.setSearch,onToggleFacet:k.toggleFacet,onClear:k.clear})}),a.length===0?n(`p`,{className:`px-3 py-3 text-xs text-foreground-subtle sm:px-4`,children:C(`locations.locationCard.nothingHereYetAssignA`,`Nothing here yet — assign a device from the table below.`)}):n(G,{columns:F,rows:P,rowKey:Ot,bordered:!1,minWidthPx:360,emptyMessage:C(`locations.filter.noMatch`)})]})}function jt({row:t,onToggle:r}){let{t:i}=Y(),{device:a,accessories:o,open:s}=t,c=H(Z(a),`compact`),l=s?u:x;return e(`span`,{className:`flex items-center gap-1.5`,children:[o.length>0?e(K,{type:`button`,variant:`ghost`,onClick:r,"aria-expanded":s,"aria-label":i(s?`locations.locationCard.collapseAccessories`:`locations.locationCard.expandAccessories`,{count:o.length,name:c}),className:`h-auto shrink-0 gap-0.5 p-0.5 text-foreground-subtle hover:text-foreground`,children:[n(l,{className:`h-3 w-3`}),n(`span`,{className:`text-[10px] tabular-nums`,children:o.length})]}):n(`span`,{"aria-hidden":`true`,className:`w-[1.35rem] shrink-0`}),n($,{type:a.type}),n(X,{to:`/devices/${String(a.id)}`,className:`min-w-0 truncate text-xs text-foreground hover:underline`,children:n(W,{device:Z(a),form:`compact`})})]})}function Mt({row:t}){let{device:r,parent:i}=t;return e(`span`,{className:`flex items-center gap-1.5 pl-6`,children:[n(`span`,{"aria-hidden":`true`,className:`text-[10px] text-foreground-subtle`,children:`└`}),n($,{type:r.type,className:`h-3 w-3 shrink-0 text-foreground-subtle`}),n(X,{to:`/devices/${String(r.id)}`,className:`min-w-0 truncate text-xs text-foreground-muted hover:underline`,children:n(W,{device:Z(r),form:`nested`,parent:Z(i)})})]})}a();function Nt({zones:e,busy:t,onRename:r,onDelete:a,onPickIcon:o}){let{t:s}=Y(),[c,l]=i(null),[u,d]=i(``),f=async e=>{let t=u.trim();l(null),!(t.length===0||t===e)&&await r(e,t)};return n(G,{columns:[{key:`icon`,header:s(`locations.siteZonesPanel.icon`,`Icon`),width:`w-12`,notSortableReason:`An icon has no order`,render:e=>n(Et,{name:e.label,icon:e.icon,busy:t,onPick:t=>o(e.label,t)})},{key:`name`,header:s(`locations.siteZonesPanel.zone`,`Zone`),sortValue:e=>e.label.toLowerCase(),render:e=>c===e.label?n(q,{value:u,onChange:e=>d(e.target.value),onKeyDown:t=>{t.key===`Enter`&&f(e.label),t.key===`Escape`&&l(null)},onBlur:()=>void f(e.label),"aria-label":s(`locations.siteZonesPanel.rename`,`Rename {{label}}`,{label:e.label}),autoFocus:!0}):n(K,{type:`button`,variant:`ghost`,size:`sm`,className:`px-0`,onClick:()=>{d(e.label),l(e.label)},disabled:t,title:s(`locations.siteZonesPanel.renameTheZone`,`Rename the zone`),children:e.label})},{key:`rooms`,header:s(`locations.siteZonesPanel.rooms`,`Rooms`),align:`right`,sortValue:e=>e.locationKeys.length,render:e=>n(`span`,{className:`tabular-nums text-foreground-subtle`,children:e.locationKeys.length===0?s(`common.empty`):s(`common.rooms`,{count:e.locationKeys.length})})},{key:`actions`,header:s(`locations.siteZonesPanel.actions`,`Actions`),align:`right`,notSortableReason:`Actions have no order`,render:e=>n(K,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>void a(e.label),disabled:t,"aria-label":s(`locations.siteZonesPanel.delete`,`Delete {{label}}`,{label:e.label}),title:s(`locations.siteZonesPanel.deleteTheZoneTheRooms`,`Delete the zone — the rooms in it are kept`),children:n(m,{className:`h-3.5 w-3.5`})})}],rows:e,rowKey:e=>e.zoneKey,emptyMessage:s(`locations.siteZonesPanel.noZonesYetAZone`,`No zones yet. A zone groups rooms — “Night zone” for the bedrooms — and shows up before them in the app’s camera filter.`)})}a();function Pt({busy:t,onCreate:r}){let{t:a}=Y(),[o,s]=i(!1),[c,l]=i(``),u=()=>{l(``),s(!1)},d=async()=>{let e=c.trim();e.length!==0&&(await r(e),u())};return o?e(`form`,{className:`flex flex-wrap items-center gap-2`,onSubmit:e=>{e.preventDefault(),d()},children:[n(q,{value:c,onChange:e=>l(e.target.value),onKeyDown:e=>{e.key===`Escape`&&u()},placeholder:a(`locations.newLocationButton.frontDoorHallKitchen`,`Front door, Hall, Kitchen…`),"aria-label":a(`locations.newLocationButton.newLocationName`,`New location name`),className:`min-w-[12rem] flex-1`,autoFocus:!0}),e(K,{size:`sm`,type:`submit`,disabled:c.trim().length===0||t,children:[n(f,{className:`h-3.5 w-3.5`}),a(`common.add`,`Add`)]}),n(K,{size:`sm`,variant:`ghost`,type:`button`,onClick:u,"aria-label":a(`locations.newLocationButton.cancelNewLocation`,`Cancel new location`),children:n(ee,{className:`h-3.5 w-3.5`})})]}):e(K,{size:`sm`,type:`button`,onClick:()=>s(!0),"data-testid":`new-location-button`,children:[n(f,{className:`h-3.5 w-3.5`}),a(`locations.newLocationButton.newLocation`,`New location`)]})}a();function Ft({busy:t,onCreate:r}){let{t:a}=Y(),[o,s]=i(!1),[c,l]=i(``),u=()=>{l(``),s(!1)},d=async()=>{let e=c.trim();e.length!==0&&(await r(e),u())};return o?e(`form`,{className:`flex flex-wrap items-center gap-2`,onSubmit:e=>{e.preventDefault(),d()},children:[n(q,{value:c,onChange:e=>l(e.target.value),onKeyDown:e=>{e.key===`Escape`&&u()},placeholder:a(`locations.newZoneButton.zonaGiornoZonaNotte`,`Zona giorno, Night zone…`),"aria-label":a(`locations.newZoneButton.newZoneName`,`New zone name`),className:`min-w-[12rem] flex-1`,autoFocus:!0}),e(K,{size:`sm`,type:`submit`,disabled:c.trim().length===0||t,children:[n(f,{className:`h-3.5 w-3.5`}),a(`common.add`,`Add`)]}),n(K,{size:`sm`,variant:`ghost`,type:`button`,onClick:u,"aria-label":a(`locations.newZoneButton.cancelNewZone`,`Cancel new zone`),children:n(ee,{className:`h-3.5 w-3.5`})})]}):e(K,{size:`sm`,type:`button`,onClick:()=>s(!0),"data-testid":`new-zone-button`,children:[n(f,{className:`h-3.5 w-3.5`}),a(`locations.newZoneButton.newZone`,`New zone`)]})}a();function It(e,t,n,r){let i=e.map(e=>({value:e.name,label:`${e.name} · ${String(e.count)}`}));return t===void 0?i:[...i,{value:n,label:`${r} · ${String(t)}`}]}function Lt({rooms:e,unassignedCount:r,value:i,unassignedValue:a,onChange:o}){let{t:s}=Y(),c=t(()=>It(e,r,a,s(`locations.roomPicker.unassigned`)),[e,r,a,s]);return n(`div`,{className:`max-w-sm`,"data-testid":`room-select`,children:n(we,{mode:`single`,singleDisplay:`field`,label:s(`locations.roomPicker.label`),placeholder:s(`locations.roomPicker.placeholder`),options:c,value:i,onChange:o,searchable:!0,testId:`room-select-control`,optionTestIdPrefix:`room-option`})})}a();var Rt={searchText:e=>[e.name],facetValue:e=>e.type};function zt({rows:r,fleet:a,locations:o,busy:s,emptyMessage:c,onAssign:l}){let{t:u}=Y(),d=ke(),f=U(),p=e=>d===null?e.name:xe(Z(e),`compact`,d,f),[m,h]=i([]),[g,_]=i(``),v=Le(r,Rt),y=v.rows,b=t(()=>y.map(e=>e.id),[y]),x=t(()=>m.filter(e=>b.includes(e)),[m,b]),S=y.length>0&&x.length===y.length,w=t(()=>{let e=new Map;for(let t of r)e.set(t.id,dt(a,t.id));return e},[r,a]),T=x.reduce((e,t)=>e+(w.get(t)??0),0),E=e=>h(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]),D=()=>h(S?[]:b),O=()=>{g.length===0||x.length===0||(l(x,g),h([]),_(``))},k=o.map(e=>({value:e,label:e})),A=[{key:`select`,width:`w-8`,headerRender:()=>n(De,{checked:S,onChange:D,"aria-label":S?u(`locations.unassignedTable.clearSelection`,`Clear selection`):u(`locations.unassignedTable.selectAllUnassignedDevices`,`Select all unassigned devices`)}),render:e=>n(De,{checked:x.includes(e.id),onChange:()=>E(e.id),"aria-label":u(`locations.unassignedTable.select`,`Select {{name}}`,{name:p(e)})})},{key:`name`,header:u(`locations.unassignedTable.device`,`Device`),sortValue:e=>e.name.toLowerCase(),render:t=>{let r=ot(t,o);return e(`span`,{className:`flex items-center gap-1.5`,children:[n($,{type:t.type}),n(X,{to:`/devices/${String(t.id)}`,className:`truncate text-xs text-foreground hover:underline`,children:n(W,{device:Z(t),form:`compact`})}),r!==null&&n(Ke,{variant:`warning`,children:u(`locations.unassignedTable.unknownRoom`,{room:r})})]})}},{key:`type`,header:u(`locations.unassignedTable.type`,`Type`),sortValue:e=>e.type,render:e=>n(`span`,{className:`text-xs text-foreground-muted`,children:e.type})},{key:`status`,header:u(`locations.unassignedTable.status`,`Status`),sortValue:e=>+!!e.online,render:t=>e(`span`,{className:`flex items-center gap-1.5`,children:[n(ht,{device:t}),n(`span`,{className:`text-xs text-foreground-muted`,children:t.online?u(`common.online`):u(`common.offline`)})]})},{key:`followers`,header:u(`locations.unassignedTable.accessoriesInTowCount`,`Accessories in tow`),align:`right`,sortValue:e=>w.get(e.id)??0,render:e=>n(`span`,{className:`tabular-nums text-xs text-foreground-muted`,children:w.get(e.id)??0})},{key:`assign`,header:u(`locations.unassignedTable.assignTo`,`Assign to`),align:`right`,notSortableReason:`This column is a control, not a value.`,render:e=>n(Pe,{"aria-label":u(`locations.unassignedTable.locationFor`,`Location for {{name}}`,{name:p(e)}),value:``,disabled:s||o.length===0,onChange:t=>{let n=t.target.value;n.length!==0&&l([e.id],n)},className:`max-w-[11rem]`,options:[{value:``,label:`—`},...k]})}];return e(`section`,{className:`space-y-2`,children:[e(`header`,{className:`flex flex-wrap items-baseline gap-2`,children:[n(`h2`,{className:C,children:u(`locations.unassignedTable.notInARoom`,`Not in a room`)}),n(`p`,{className:oe,children:u(`locations.unassignedTable.topLevelDevicesOnlyAccessories`,`Top-level devices only — accessories move with their parent.`)})]}),r.length>0&&n(Ue,{state:v.state,facets:v.facets,labels:{searchPlaceholder:u(`locations.filter.searchPlaceholder`),searchLabel:u(`locations.unassigned.searchLabel`),facetsLabel:u(`locations.filter.typesLabel`),clearLabel:u(`locations.filter.clear`)},onSearch:v.setSearch,onToggleFacet:v.toggleFacet,onClear:v.clear}),x.length>0&&e(`div`,{role:`group`,"aria-label":u(`locations.unassignedTable.bulkAssignment`,`Bulk assignment`),className:`flex flex-wrap items-center gap-2 rounded border border-primary/40 bg-primary/5 px-2 py-1.5`,children:[e(`span`,{className:`text-xs text-foreground`,children:[u(`locations.unassignedTable.selected`,{count:x.length}),T>0&&` · ${u(`locations.unassignedTable.accessoriesInTowCount`,{count:T})}`]}),n(Pe,{"aria-label":u(`locations.unassignedTable.assignSelectedDevicesTo`,`Assign selected devices to`),value:g,onChange:e=>_(e.target.value),className:`w-auto min-w-[10rem]`,options:[{value:``,label:u(`locations.unassignedTable.assignTo2`,`Assign to…`)},...k]}),n(K,{type:`button`,size:`sm`,onClick:O,disabled:s||g.length===0,children:u(`locations.unassignedTable.assign`,`Assign`)}),n(K,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>h([]),children:u(`locations.unassignedTable.clear`,`Clear`)})]}),n(G,{columns:A,rows:y,rowKey:e=>e.id,minWidthPx:720,emptyMessage:v.active?u(`locations.filter.noMatch`):c})]})}function Bt(e){return{id:e.id,parentDeviceId:e.parentDeviceId,location:e.location,type:e.type,stableId:e.stableId??``,...e.primaryChildEntityId===void 0?{}:{primaryChildEntityId:e.primaryChildEntityId},...e.role!==void 0&&e.role!==null?{role:e.role}:{},name:e.name}}function Vt(e,t){let n=t.map(Bt),r=[];for(let i of t)i.isCamera&&i.location===e&&r.push({deviceId:i.id,name:i.name,ids:le({selfId:i.id,selfLocation:i.location,candidates:n})});return{entries:r}}var Ht=`device-manager:linked-devices`;function Ut(e){return{deviceId:e.deviceId,slotRef:Ht,value:{slot:`linked-devices`,deviceIds:[...e.ids]}}}a();var Wt=`__unassigned__`;function Gt(){let{t:r}=Y(),a=o(),s=ie(),{data:c,isLoading:l}=Ve(),{data:u}=he(),{data:d}=He(),{data:f}=be(),{data:p,isLoading:m}=_e({projection:`slim`}),h=()=>{a.invalidateQueries({queryKey:[[`deviceManager`,`listLocations`]]}),a.invalidateQueries({queryKey:[[`deviceManager`,`listAll`]]}),a.invalidateQueries({queryKey:[[`deviceManager`,`listLocationIcons`]]}),a.invalidateQueries({queryKey:[[`deviceManager`,`listLocationDescriptions`]]}),a.invalidateQueries({queryKey:[[`deviceManager`,`listSiteZones`]]})},g=qe({onSuccess:h}),_=Ee({onSuccess:h}),v=je({onSuccess:h}),y=ge({onSuccess:h}),b=ye({onSuccess:h}),x=ve({onSuccess:h}),S=Ce({onSuccess:h}),C=Xe({onSuccess:h}),w=Oe({onSuccess:h}),T=Ge({onSuccess:h}),E=Ie(),D=t(()=>(p??[]).map(e=>({id:e.id,name:e.name,location:e.location??null,type:String(e.type),isCamera:e.isCamera,parentDeviceId:e.parentDeviceId,online:e.online,role:e.role??null,stableId:e.stableId,primaryChildEntityId:e.primaryChildEntityId??null})),[p]),O=c??[],k=t(()=>pt(D,O),[D,O]),[A,ee]=$e(),j=A.get(`tab`),M=j===`zones`||j===`camera-links`?j:`locations`,N=A.get(`room`),P=t(()=>lt(D,O),[D,O]),F=N===Wt,I=F?null:N!==null&&k.some(e=>e.name===N)?N:k[0]?.name??null,L=I===null?null:k.find(e=>e.name===I)??null,te=F?Wt:I??`__unassigned__`,R=I??k[0]?.name??null,ne=t(()=>k.map(e=>({name:e.name,count:e.members.length})),[k]),ae=e=>{ee(t=>{let n=new URLSearchParams(t);return n.set(`room`,e),n},{replace:!0})},z=l||m,B=v.isPending||_.isPending||g.isPending||b.isPending,oe=async e=>{await g.mutateAsync({name:e})},ce=async(e,t)=>{let n=t.trim();n.length===0||n===e||await y.mutateAsync({from:e,to:n})},le=async e=>{let t=Vt(e,D);if(t.entries.length===0){await s({title:r(`locations.rebuildLinkedDevices`,`Rebuild linked devices`),message:r(`locations.noCameraIsAssignedTo`,`No camera is assigned to “{{room}}”.`,{room:e}),confirmLabel:`OK`});return}let n=t.entries.map(e=>r(`locations.rebuildEntry`,{name:e.name,count:e.ids.length})).join(`
|
|
2
|
-
`);if(!await s({title:r(`locations.rebuildLinkedDevices`,`Rebuild linked devices`),message:r(`locations.replaceTheLinkedDeviceList`,`Replace the linked-device list of every camera in “{{room}}” with what the room contains? {{lines}} Anything linked by hand that is not in this room is lost.`,{room:e,lines:n}),confirmLabel:r(`locations.rebuild`,`Rebuild`),variant:`danger`}))return;let i=[];for(let e of t.entries)try{await E.mutateAsync(Ut(e))}catch(t){i.push(`• ${e.name}: ${t instanceof Error?t.message:String(t)}`)}h(),i.length>0&&await s({title:r(`locations.rebuildLinkedDevices`,`Rebuild linked devices`),message:r(`locations.notRebuilt`,`Not rebuilt: {{value1}}`,{value1:i.join(`
|
|
3
|
-
`)}),confirmLabel:`OK`})},ue=async(e,t)=>{let n=t>0?` ${String(t)} device(s) will become unassigned.`:``;await s({title:r(`locations.deleteLocation`,`Delete location`),message:r(`locations.deleteTheLocation`,`Delete the location “{{name}}”?{{extra}}`,{name:e,extra:n}),confirmLabel:r(`common.delete`,`Delete`),variant:`danger`})&&await _.mutateAsync({name:e,cascade:!0})},de=async e=>{await s({title:r(`locations.deleteZone`,`Delete zone`),message:r(`locations.deleteTheZoneTheRooms`,`Delete the zone “{{name}}”? The rooms in it are kept.`,{name:e}),confirmLabel:r(`common.delete`,`Delete`),variant:`danger`})&&await C.mutateAsync({name:e})},fe=async(e,t)=>{await b.mutateAsync({location:e,icon:t})},pe=async(e,t)=>{await x.mutateAsync({location:e,description:t})},V=f??[],me=async(e,t)=>{await T.mutateAsync({location:e,zone:t})},H=(e,t)=>{for(let n of e)v.mutate({deviceId:n,location:t})},[U,W]=i(null),xe=t(()=>D.filter(e=>e.parentDeviceId===null).map(e=>({id:e.id,name:e.name,type:e.type,location:e.location})),[D]),Se=n(Lt,{rooms:ne,...M===`locations`?{unassignedCount:P.length}:{},value:M===`locations`?te:R??``,unassignedValue:Wt,onChange:ae}),we=e(`div`,{className:`flex flex-col gap-3`,"data-testid":`locations-section`,children:[z&&n(`p`,{className:`text-xs text-foreground-subtle`,children:r(`locations.loadingLocationsAndDevices`,`Loading locations and devices…`)}),Se,F||L===null?n(zt,{rows:P,fleet:D,locations:O,busy:B,emptyMessage:z?r(`common.loading`,`Loading…`):r(`locations.everyTopLevelDeviceHas`,`Every top-level device has a room.`),onAssign:H}):n(At,{name:L.name,members:L.members,devices:D,busy:B,icon:Dt(u,se(L.name)),onPickIcon:e=>fe(L.name,e),description:St(d,se(L.name)),onSaveDescription:e=>pe(L.name,e),zones:V,zoneKey:Tt(V,se(L.name)),onChangeZone:e=>me(L.name,e),onRename:e=>ce(L.name,e),onDelete:()=>ue(L.name,it(D,L.name).length),onRebuildLinks:()=>le(L.name),onAddDevices:()=>W(L.name)},L.name),O.length===0&&!z&&n(`p`,{className:`text-xs text-foreground-subtle`,children:r(`locations.noLocationsYetAddFrontDoor`,`No locations yet. Add Front door, Hall, Kitchen…`)}),n(_t,{open:U!==null,title:r(`locations.room.addDialogTitle`,{room:U??``}),items:xe,listState:m?`pending`:`answered`,lockedIds:U===null?[]:(k.find(e=>e.name===U)?.members??[]).map(e=>e.id),lockedNote:r(`locations.room.alreadyHere`),suggestions:{heading:r(`locations.room.suggestedUnassigned`),ids:P.map(e=>e.id)},busy:v.isPending,onConfirm:e=>{U!==null&&H(e,U),W(null)},onClose:()=>W(null)})]}),Te=e(`div`,{className:`flex flex-col gap-3`,"data-testid":`camera-links-tab`,children:[Se,n(vt,{room:R,cameras:R===null?[]:it(D,R).filter(e=>e.isCamera),fleet:D})]});return n(et,{icon:re,title:r(`locations.locations`,`Locations`),subtitle:r(`locations.roomsAndAreasOfThe`,`Rooms and areas of the site. Assign any device here — storage disks are under Data → Storage.`),defaultSection:`locations`,sectionsLabel:`Locations sections`,actions:M===`zones`?n(Ft,{busy:S.isPending,onCreate:e=>S.mutateAsync({name:e})}):n(Pt,{busy:g.isPending,onCreate:oe}),sections:[{id:`locations`,label:r(`locations.locations`,`Locations`),content:we},{id:`camera-links`,label:r(`locations.cameraLinks`,`Camera links`),content:Te},{id:`zones`,label:r(`locations.zones`,`Zones`),content:n(Nt,{zones:V,busy:B,onRename:(e,t)=>w.mutateAsync({from:e,to:t}),onDelete:de,onPickIcon:(e,t)=>S.mutateAsync({name:e,icon:t})})}]})}export{Gt as LocationsPage};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./browser-BHo8W_uH.js","./rolldown-runtime-Cyuzqnbw.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{a as e}from"./rolldown-runtime-Cyuzqnbw.js";import{t}from"./vite-preload-helper-kNaey6uv.js";import{C as n,J as r,K as i,S as a,V as o,Y as s,a as c,et as l,t as u,x as d}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{Ht as f,Q as p,Vn as m,Wr as h,Zi as g,an as _,bi as v,br as y,dt as b,fr as x,hr as S,lr as C,pa as w,pn as T,ri as E,st as D,xi as O,zt as k}from"./player-overlays-B5FSaids.js";import{Jr as A,qr as j}from"./client-JLEP7nv7.js";import{s as M}from"./video-2nOnVl_R.js";import{t as N}from"./key-round-CBhTR29b.js";import{t as ee}from"./monitor-smartphone-tJnvQ6Wt.js";import{t as te}from"./unlink-CZPQIK73.js";import{Bd as P,Et as ne,Ks as re,Wr as F,Ws as I,Yr as L,dd as ie,lr as ae,mn as oe,ur as se}from"./src-IQsaq5W-.js";import{t as ce}from"./i18n-CXGP1uaw.js";import{t as R}from"./useTranslation-BJr-n0es.js";import"./mount-C44QyL85.js";import{_ as le,b as z,hr as B,pr as V,rr as H,v as U,y as W,yr as ue}from"./index-lH9UKmhf.js";import{t as de}from"./AdminSectionedPage-BG6w5-w1.js";import{t as fe}from"./AdminPage-CVSTxsAk.js";import{O as pe,T as me,_ as G,a as he,h as ge,k as _e,r as ve,t as K,v as ye}from"./SessionsList-CfuTFr66.js";l();var be=`${j}/connect`,q={public:0,mesh:1,lan:2,"lan-ipv6":3};function xe(e){switch(e.kind){case`public`:return e.interfaceKind===`vpn`?`mesh`:`public`;case`lan-ipv4`:return`lan`;case`lan-ipv6`:return`lan-ipv6`;case`custom`:return`public`;case`loopback`:case`app-link`:return null}}function J(e){return A(e)}function Se(e){return e.startsWith(`https://`)}function Ce(e){let t=e.flatMap(e=>{let t=xe(e),n=J(e.baseUrl);return t===null||n===null?[]:[{endpoint:e,tier:t,origin:n}]}).toSorted((e,t)=>q[e.tier]-q[t.tier]||Number(t.endpoint.plausible)-Number(e.endpoint.plausible)||e.endpoint.priority-t.endpoint.priority),n=new Set;return t.flatMap(({endpoint:e,tier:t,origin:r})=>n.has(r)?[]:(n.add(r),[{origin:r,label:e.label,tier:t,secure:Se(r),plausible:e.plausible}]))}function we(e,t,n=null){for(let r of[t,n]){if(r===null)continue;let t=J(r),n=e.find(e=>e.origin===t);if(n!==void 0)return n}return e[0]??null}function Te(e){let t=new URL(be);return t.searchParams.set(`hub`,e),t.toString()}var Ee=176,Y={scheme:`https`};function De(){let{t:e}=R(),t=re(Y),r=I(Y).data?.roles.publicEndpoint.resolved??null;return n(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[n(`div`,{className:`px-4 py-2.5 border-b border-border flex items-center gap-2`,children:[a(_,{className:`h-3.5 w-3.5 text-foreground-subtle`}),a(`div`,{className:`text-xs font-semibold text-foreground`,children:e(`connectPhone.title`)})]}),n(`div`,{className:`p-4 space-y-3`,children:[a(`p`,{className:`text-[11px] text-foreground-subtle`,children:e(`connectPhone.description`)}),t.isPending?n(`div`,{className:`flex items-center gap-2 text-[11px] text-foreground-subtle`,children:[a(x,{className:`h-3.5 w-3.5 animate-spin`}),e(`connectPhone.loading`)]}):t.isError?n(`div`,{className:`flex items-start gap-2 text-[11px] text-danger`,children:[a(k,{className:`h-3.5 w-3.5 mt-0.5 shrink-0`}),n(`div`,{className:`flex-1 min-w-0 space-y-1.5`,children:[a(`div`,{className:`break-words`,children:e(`connectPhone.error`,{message:t.error.message})}),a(L,{size:`sm`,variant:`ghost`,onClick:()=>void t.refetch(),children:e(`connectPhone.retry`)})]})]}):a(Oe,{candidates:Ce(t.data.endpoints),preferredOrigin:r})]})]})}function Oe({candidates:e,preferredOrigin:t}){let{t:r}=R(),[o,c]=s(null),l=we(e,o,t),u=i(()=>l?Te(l.origin):null,[l]);if(l===null||u===null)return a(`p`,{className:`text-[11px] text-foreground-subtle`,children:r(`connectPhone.empty`)});let d=e=>r(`connectPhone.tier.${e}`),f=e.map(e=>({value:e.origin,label:`${d(e.tier)} — ${e.origin}`}));return n(`div`,{className:`flex flex-col sm:flex-row gap-4`,children:[a(ae,{value:u,size:Ee,alt:r(`connectPhone.qrAlt`),className:`self-start`}),n(`div`,{className:`flex-1 min-w-0 space-y-3`,children:[n(`label`,{className:`block space-y-1`,children:[a(`span`,{className:`text-[11px] font-medium text-foreground`,children:r(`connectPhone.addressLabel`)}),a(ie,{value:l.origin,options:f,onChange:e=>c(e.target.value)}),n(`span`,{className:`block text-[10px] text-foreground-subtle`,children:[d(l.tier),` · `,l.label]})]}),!l.secure&&a(X,{text:r(`connectPhone.insecure`)}),!l.plausible&&a(X,{text:r(`connectPhone.implausible`)}),n(`div`,{className:`space-y-1`,children:[a(`span`,{className:`text-[11px] font-medium text-foreground`,children:r(`connectPhone.linkLabel`)}),n(`div`,{className:`flex items-center gap-1 rounded-md border border-border bg-background px-2 py-1`,children:[a(`code`,{className:`flex-1 min-w-0 font-mono text-[11px] text-foreground break-all select-all`,children:u}),a(oe,{value:u,srLabel:r(`connectPhone.linkLabel`)})]})]}),a(`p`,{className:`text-[11px] text-foreground-subtle`,children:r(`connectPhone.signInHint`)})]})]})}function X({text:e}){return n(`div`,{className:`flex items-start gap-2 rounded-md border border-warning/30 bg-warning/5 px-2.5 py-1.5 text-[11px] text-foreground`,children:[a(k,{className:`h-3.5 w-3.5 text-warning mt-0.5 shrink-0`}),a(`span`,{children:e})]})}l();function ke(e){return new Date(e).toLocaleDateString()}function Ae(){let{t:e}=R(),t=D(),i=P.useUtils(),c=P.auth.listLinkableProviders.useQuery(),l=P.auth.listOwnExternalIdentities.useQuery(),[u,d]=s(null),[f,m]=s(()=>z(window.location.search)),h=r(null),g=G(`Linking a sign-in account`),_=r(null);o(()=>()=>_.current?.(),[]);let[y,b]=s(null);o(()=>{if(f===null)return;let e=new URL(window.location.href);e.searchParams.delete(`linked`),e.searchParams.delete(`linkError`),window.history.replaceState({},``,e.pathname+e.search+e.hash)},[f]);let C=P.auth.beginExternalLink.useMutation({onSuccess:({url:e})=>{let t=h.current;if(h.current=null,t===null||t.closed){window.location.assign(e);return}let n=e=>{b(null),m(z(`?${e}`)),i.auth.listOwnExternalIdentities.invalidate()};_.current?.(),_.current=U(t,{onReturn:e=>{e.target===`profile`&&n(e.query)},onDone:e=>{e.target===`profile`&&n(e.query)},onClosed:()=>{_.current?.(),_.current=null,i.auth.listOwnExternalIdentities.invalidate()}}),t.location.href=p(W(e))},onError:e=>{h.current?.close(),h.current=null,b(null),d(e.message)}}),w=P.auth.unlinkOwnExternalIdentity.useMutation({onSuccess:()=>void i.auth.listOwnExternalIdentities.invalidate(),onError:e=>d(e.message)}),T=c.data??[],E=l.data??[],k=y!==null&&E.some(e=>e.provider===y);if(o(()=>{!k||y===null||(b(null),m({kind:`linked`,provider:y}))},[k,y]),T.length===0&&E.length===0)return null;let A=new Set(E.map(e=>e.provider)),j=e=>T.find(t=>t.provider===e)?.label??e,M=async(n,r)=>{await t({title:e(`users.linkedSignInsSection.unlinkSignInAccount`,`Unlink sign-in account`),message:e(`users.linkedSignInsSection.stopSigningInWithThis`,`Stop signing in with this {{label}} account?`,{label:r}),confirmLabel:e(`users.linkedSignInsSection.unlink`,`Unlink`),variant:`danger`})&&(d(null),w.mutate({provider:n.provider,subject:n.subject}))};return n(`div`,{"data-testid":`linked-sign-ins`,className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[g.dialog,n(`div`,{className:`px-4 py-2.5 border-b border-border flex items-center gap-2`,children:[a(S,{className:`h-3.5 w-3.5 text-foreground-subtle`}),a(`div`,{className:`text-xs font-semibold text-foreground`,children:e(`users.linkedSignInsSection.linkedSignInAccounts`,`Linked sign-in accounts`)})]}),n(`div`,{className:`p-4 space-y-3`,children:[a(`p`,{className:`text-[11px] text-foreground-subtle`,children:e(`users.linkedSignInsSection.signInWithAnExternal`,`Sign in with an external account instead of your password. Only accounts you link here can sign you in; your two-factor authentication still applies.`)}),f?.kind===`linked`&&n(`div`,{className:`flex items-center gap-2 rounded-md border border-emerald-500/30 bg-emerald-500/5 px-3 py-2 text-xs text-foreground`,children:[a(v,{className:`h-3.5 w-3.5 text-emerald-500 shrink-0`}),e(`users.linkedSignIns.linkedNotice`,{provider:j(f.provider)})]}),(f?.kind===`error`||u)&&n(`div`,{className:`flex items-center gap-2 rounded-md border border-danger/20 bg-danger/10 px-3 py-2 text-xs text-danger`,children:[a(O,{className:`h-3.5 w-3.5 shrink-0`}),u??(f?.kind===`error`?f.message:``)]}),E.length>0&&a(`ul`,{className:`divide-y divide-border rounded-md border border-border`,children:E.map(t=>{let r=t.providerLabel??t.provider;return n(`li`,{className:`flex items-center gap-3 px-3 py-2 text-xs`,children:[n(`div`,{className:`flex-1 min-w-0`,children:[n(`div`,{className:`font-medium text-foreground truncate`,children:[r,!t.available&&a(`span`,{className:`ml-2 rounded bg-foreground-subtle/15 px-1.5 py-0.5 text-[10px] font-normal text-foreground-subtle`,children:e(`users.linkedSignInsSection.providerUnavailable`,`provider unavailable`)})]}),a(`div`,{className:`text-[11px] text-foreground-subtle truncate`,children:e(`users.linkedSignIns.linkedOn`,{label:t.label??t.subject,date:ke(t.linkedAt)})})]}),n(`button`,{onClick:()=>void M(t,r),disabled:w.isPending,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] text-danger hover:bg-danger/10 disabled:opacity-50`,children:[a(te,{className:`h-3 w-3`}),e(`users.linkedSignInsSection.unlink`,`Unlink`)]})]},`${t.provider}|${t.subject}`)})}),a(`div`,{className:`flex flex-wrap gap-2`,children:T.filter(e=>!A.has(e.provider)).map(t=>n(`button`,{onClick:()=>{d(null),m(null),g.requestProof().then(e=>{e!==null&&(h.current=le(null),b(h.current===null?null:t.provider),C.mutate({provider:t.provider,reauthToken:e}))})},disabled:C.isPending,className:`inline-flex items-center gap-1.5 rounded border border-border px-2.5 py-1 text-[11px] font-medium text-foreground hover:bg-surface-hover disabled:opacity-50`,children:[C.isPending&&C.variables?.provider===t.provider?a(x,{className:`h-3 w-3 animate-spin`}):a(S,{className:`h-3 w-3`}),e(`users.linkedSignIns.link`,{provider:t.label})]},t.provider))})]})]})}l();function je({value:r,size:i=192}){let{t:c}=R(),[l,u]=s(null),[d,f]=s(null);if(o(()=>{let n=!1;return t(()=>import(`./browser-BHo8W_uH.js`).then(t=>e(t.default,1)).then(async e=>{if(n)return;let t=e.create;if(typeof t!=`function`){f(`qrcode.create() unavailable in installed version`);return}try{let e=t(r,{errorCorrectionLevel:`M`});n||u(e)}catch(e){n||f(e instanceof Error?e.message:`QR generation failed`)}}),__vite__mapDeps([0,1]),import.meta.url).catch(()=>{n||f(`qrcode library not installed`)}),()=>{n=!0}},[r]),d)return a(`div`,{className:`flex items-center justify-center text-[10px] text-foreground-subtle text-center p-4`,style:{width:i,height:i},children:c(`users.totpQrCode.qrRenderingUnavailableUseThe`,`QR rendering unavailable — use the secret below.`)});if(!l)return a(`div`,{className:`flex items-center justify-center text-[10px] text-foreground-subtle animate-pulse`,style:{width:i,height:i},children:c(`users.totpQrCode.generating`,`Generating…`)});let p=l.modules.size,m=i/p,h=[];for(let e=0;e<p;e++)for(let t=0;t<p;t++)l.modules.data[e*p+t]&&h.push(a(`rect`,{x:t*m,y:e*m,width:m,height:m,fill:`currentColor`},`${t}-${e}`));return n(`svg`,{width:i,height:i,viewBox:`0 0 ${i} ${i}`,className:`text-black`,children:[a(`rect`,{x:0,y:0,width:i,height:i,fill:`white`}),h]})}l();function Me(){let{t:e}=R(),t=b(),[r,i]=s(``),[o,c]=s(``),[l,d]=s(``),[f,p]=s(null),m=u({mutationFn:e=>t.changeOwnPassword(e),onSuccess:()=>{p({kind:`success`,msg:`Password updated.`}),i(``),c(``),d(``)},onError:e=>{p({kind:`error`,msg:e instanceof Error?e.message:`Update failed`})}}),h=o.length>0&&l.length>0&&o!==l,g=o.length>0&&o.length<8,_=r.length>=1&&o.length>=8&&o===l;return n(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[n(`div`,{className:`px-4 py-2.5 border-b border-border flex items-center gap-2`,children:[a(N,{className:`h-3.5 w-3.5 text-foreground-subtle`}),a(`div`,{className:`text-xs font-semibold text-foreground`,children:e(`systemPage.myAccess.changePassword`,`Change password`)})]}),n(`div`,{className:`p-4 space-y-3`,children:[a(Z,{label:e(`systemPage.myAccess.currentPassword`,`Current password`),value:r,onChange:i,autoComplete:`current-password`}),a(Z,{label:e(`systemPage.myAccess.newPassword`,`New password`),value:o,onChange:c,autoComplete:`new-password`,hint:e(`systemPage.myAccess.atLeast8Characters`,`At least 8 characters.`)}),a(Z,{label:e(`systemPage.myAccess.confirmNewPassword`,`Confirm new password`),value:l,onChange:d,autoComplete:`new-password`}),(h||g)&&a(`div`,{className:`text-[11px] text-danger`,children:h?e(`systemPage.myAccess.passwordsDoNotMatch`,`Passwords do not match.`):e(`systemPage.myAccess.newPasswordMustBeAt`,`New password must be at least 8 characters.`)}),f&&n(`div`,{className:`text-[11px] flex items-center gap-1 ${f.kind===`success`?`text-success`:`text-danger`}`,children:[f.kind===`success`?a(v,{className:`h-3 w-3`}):a(O,{className:`h-3 w-3`}),f.msg]}),a(`div`,{className:`flex justify-end`,children:n(L,{onClick:()=>{p(null),m.mutate({currentPassword:r,newPassword:o})},disabled:!_||m.isPending,children:[m.isPending?a(x,{className:`h-3 w-3 animate-spin`}):a(C,{className:`h-3 w-3`}),e(`systemPage.myAccess.updatePassword`,`Update password`)]})})]})]})}function Z({label:e,value:t,onChange:r,autoComplete:i,hint:o}){return n(`div`,{className:`space-y-1`,children:[a(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:e}),a(`input`,{type:`password`,value:t,onChange:e=>r(e.target.value),autoComplete:i,className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`}),o&&a(`div`,{className:`text-[10px] text-foreground-subtle`,children:o})]})}function Ne({username:e}){let{t}=R(),r=b(),l=c({queryKey:[`auth`,`getOwnTotpStatus`],queryFn:()=>r.getOwnTotpStatus()}),f=l.data,[p,m]=s(null),[h,g]=s(``),[y,S]=s(null),[C,w]=s(!1),T=u({mutationFn:()=>r.setupOwnTotp(),onSuccess:e=>{m({secret:e.secret,otpauthUrl:e.otpauthUrl}),g(``),S(null)},onError:e=>S(e instanceof Error?e.message:`Setup failed`)}),D=u({mutationFn:e=>r.confirmOwnTotp(e),onSuccess:()=>{m(null),g(``),S(null),l.refetch()},onError:e=>S(e instanceof Error?e.message:`Confirmation failed — code did not match`)}),k=G(`Turning off two-factor authentication`),A=u({mutationFn:async()=>{let e=await k.requestProof();return e===null?null:r.disableOwnTotp({reauthToken:e})},onSuccess:()=>{S(null),l.refetch()},onError:e=>S(e instanceof Error?e.message:`Disable failed`)});o(()=>{if(!C)return;let e=setTimeout(()=>w(!1),1500);return()=>clearTimeout(e)},[C]);let j=i(()=>l.isLoading?`loading`:p?`setup_in_progress`:f?.enabled?`enrolled`:`not_enrolled`,[l.isLoading,f?.enabled,p]);return n(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[k.dialog,n(`div`,{className:`px-4 py-2.5 border-b border-border flex items-center gap-2`,children:[a(_,{className:`h-3.5 w-3.5 text-foreground-subtle`}),a(`div`,{className:`text-xs font-semibold text-foreground`,children:t(`systemPage.myAccess.twoFactorAuthentication`,`Two-factor authentication`)})]}),n(`div`,{className:`p-4 space-y-3`,children:[j===`loading`&&n(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[a(x,{className:`h-3.5 w-3.5 animate-spin`}),t(`systemPage.myAccess.checkingStatus`,`Checking status…`)]}),j===`not_enrolled`&&n(d,{children:[a(`div`,{className:`text-xs text-foreground-subtle`,children:t(`systemPage.myAccess.2faIsnTActiveOn`,`2FA isn't active on your account. Enable it to require a 6-digit code from your authenticator app at every login.`)}),a(`div`,{className:`flex justify-end`,children:n(L,{onClick:()=>{S(null),T.mutate()},disabled:T.isPending,children:[T.isPending?a(x,{className:`h-3 w-3 animate-spin`}):a(_,{className:`h-3 w-3`}),t(`systemPage.myAccess.enable2fa`,`Enable 2FA`)]})})]}),j===`setup_in_progress`&&p&&n(d,{children:[a(`div`,{className:`text-[11px] text-foreground-subtle`,children:a(V,{i18nKey:`systemPage.myAccess.scanQr`,values:{username:e},components:{mono:a(`span`,{className:`font-mono`})}})}),n(`div`,{className:`flex flex-col items-center gap-3`,children:[a(`div`,{className:`rounded-lg border border-border bg-white p-3`,children:a(je,{value:p.otpauthUrl,size:180})}),n(`div`,{className:`w-full`,children:[a(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle mb-1`,children:t(`systemPage.myAccess.secretManualEntry`,`Secret (manual entry)`)}),n(`div`,{className:`flex items-center gap-2 rounded border border-border bg-surface-hover/30 px-2 py-1.5`,children:[a(`code`,{className:`text-[11px] font-mono text-foreground break-all flex-1`,children:p.secret}),n(L,{variant:`ghost`,onClick:()=>{p&&navigator.clipboard.writeText(p.secret).then(()=>w(!0))},children:[C?a(v,{className:`h-3 w-3 text-success`}):a(E,{className:`h-3 w-3`}),C?t(`systemPage.myAccess.copied`,`Copied`):t(`common.copy`,`Copy`)]})]})]})]}),n(`div`,{className:`space-y-1`,children:[a(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`6-digit code`}),a(`input`,{type:`text`,inputMode:`numeric`,autoComplete:`one-time-code`,placeholder:`123456`,value:h,onChange:e=>g(e.target.value.replace(/\D/g,``).slice(0,6)),className:`w-full rounded-md border border-border bg-surface px-3 py-2 text-center text-lg font-mono tracking-widest text-foreground focus:outline-none focus:ring-2 focus:ring-primary`})]}),y&&n(`div`,{className:`text-[11px] text-danger flex items-center gap-1`,children:[a(O,{className:`h-3 w-3`}),y]}),n(`div`,{className:`flex justify-end gap-2`,children:[a(L,{variant:`outline`,onClick:()=>{m(null),S(null),g(``)},children:t(`common.cancel`,`Cancel`)}),n(L,{onClick:()=>{S(null),D.mutate({code:h})},disabled:D.isPending||h.length!==6,children:[D.isPending?a(x,{className:`h-3 w-3 animate-spin`}):a(v,{className:`h-3 w-3`}),t(`common.confirm`,`Confirm`)]})]})]}),j===`enrolled`&&f&&n(d,{children:[n(`div`,{className:`rounded-md border border-success/30 bg-success/5 px-3 py-2.5 flex items-start gap-2.5`,children:[a(v,{className:`h-4 w-4 mt-0.5 text-success shrink-0`}),n(`div`,{className:`text-xs text-foreground space-y-0.5`,children:[a(`div`,{className:`font-medium`,children:t(`systemPage.myAccess.2faIsActive`,`2FA is active`)}),a(`div`,{className:`text-foreground-subtle`,children:t(`common.enrolledOn`,{when:f.confirmedAt?new Date(f.confirmedAt).toLocaleString():`—`})})]})]}),y&&n(`div`,{className:`text-[11px] text-danger flex items-center gap-1`,children:[a(O,{className:`h-3 w-3`}),y]}),a(`div`,{className:`flex justify-end`,children:n(L,{variant:`danger`,onClick:()=>{S(null),A.mutate()},disabled:A.isPending,children:[A.isPending?a(x,{className:`h-3 w-3 animate-spin`}):a(_,{className:`h-3 w-3`}),t(`systemPage.myAccess.disable2fa`,`Disable 2FA`)]})})]})]})]})}function Pe(){return F(`auth-webauthn/passkey-enrollment`)?a(se,{widgetId:`auth-webauthn/passkey-enrollment`,host:`dashboard`}):null}l();function Q(e){return e.message.length>0?e.message:ce.t(`auth.authAuditSection.requestFailed`)}function Fe(){let{t:e}=R(),{logout:t}=H(),r=D(),i=P.useUtils(),o=P.auth.listOwnSessions.useQuery(),[c,l]=s(null),u=P.auth.revokeOwnSession.useMutation({onSuccess:()=>void i.auth.listOwnSessions.invalidate(),onError:e=>l(`Sign out failed: ${Q(e)}`)}),d=P.auth.logout.useMutation({onSuccess:()=>t(),onError:e=>l(`Sign out failed: ${Q(e)}`)}),f=async t=>{await r({title:e(`auth.mySessionsSection.signOutThisSession`,`Sign out this session`),message:e(`auth.mySessionsSection.willHaveToSignIn`,`{{label}} will have to sign in again.`,{label:ye(t.client).label}),confirmLabel:e(`auth.mySessionsSection.signOut`,`Sign out`),variant:`danger`})&&(l(null),u.mutate({id:t.id}))},p=async()=>{await r({title:e(`auth.mySessionsSection.signOutEverywhere`,`Sign out everywhere`),message:e(`auth.mySessionsSection.everySessionOfYourAccount`,`Every session of your account ends, this browser included: you will be signed out here too and every device has to sign in again.`),confirmLabel:e(`auth.mySessionsSection.signOutEverywhere`,`Sign out everywhere`),variant:`danger`})&&(l(null),d.mutate({everywhere:!0}))};return n(`div`,{"data-testid":`my-sessions`,className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[n(`div`,{className:`px-4 py-2.5 border-b border-border flex items-center gap-2`,children:[a(ee,{className:`h-3.5 w-3.5 text-foreground-subtle`}),a(`div`,{className:`text-xs font-semibold text-foreground`,children:e(`auth.mySessionsSection.activeSessions`,`Active sessions`)})]}),n(`div`,{className:`p-4 space-y-3`,children:[a(`p`,{className:`text-[11px] text-foreground-subtle`,children:e(`auth.mySessionsSection.theBrowsersAndAppsSigned`,`The browsers and apps signed in to your account. Signing one out ends it at once.`)}),c!==null&&a(`div`,{className:`text-[11px] text-danger`,children:c}),a(K,{sessions:o.data??[],isLoading:o.isLoading,loadError:o.isError?o.error?.message??e(`auth.authAuditSection.requestFailed`):null,emptyText:`No active sessions.`,onRevoke:e=>void f(e),revokingId:u.isPending?u.variables?.id??null:null}),a(`div`,{className:`flex justify-end`,children:n(`button`,{onClick:()=>void p(),disabled:d.isPending,className:`inline-flex items-center gap-1.5 rounded border border-danger/40 px-2.5 py-1 text-[11px] font-medium text-danger hover:bg-danger/10 disabled:opacity-50`,children:[d.isPending?a(x,{className:`h-3 w-3 animate-spin`}):a(M,{className:`h-3 w-3`}),e(`auth.mySessionsSection.signOutEverywhere`,`Sign out everywhere`)]})})]})]})}l();var Ie=`You`;function Le(){let{t:e}=R(),t=D(),n=P.useUtils(),r=P.auth.listOwnDeviceCredentials.useQuery(),[o,c]=s(null),l=P.auth.revokeOwnDeviceCredential.useMutation({onSuccess:e=>{e.revoked||c(`That device could not be revoked - it may already be gone.`),n.auth.listOwnDeviceCredentials.invalidate()},onError:e=>c(`Revoke failed: ${e.message}`)}),u=i(()=>(r.data??[]).map(e=>ve(e,Ie)),[r.data]),d=async n=>{await t({title:e(`certificates.myDevicesSection.revoke`,`Revoke "{{name}}"?`,{name:n.name}),message:e(`certificates.myDevicesSection.theDeviceStopsSigningIn`,`The device stops signing in at once and its open sessions end. To use it again you have to pair it anew. This cannot be undone.`),confirmLabel:e(`certificates.myDevicesSection.revoke2`,`Revoke`),variant:`danger`})&&(c(null),l.mutate({id:n.id}))},f={label:e(`certificates.myDevicesSection.revoke2`,`Revoke`),icon:g,isAvailable:he,onRun:e=>void d(e),busyId:l.isPending?l.variables?.id??null:null,disabled:l.isPending};return a(pe,{id:`my-devices`,title:e(`certificates.myDevicesSection.myDevices`,`My devices`),icon:_,description:e(`certificates.myDevicesSection.phonesThatStaySignedIn`,`Phones that stay signed in to your account with a certificate. If one is lost, revoke it here and it is signed out at once.`),notice:_e(o),onDismissNotice:()=>c(null),children:a(me,{rows:u,label:e(`certificates.devicesCard.label`),isLoading:r.isPending,loadError:r.error===null?null:r.error.message||`Request failed`,emptyText:`No devices are signed in with a certificate.`,hideOwner:!0,expiresNone:`—`,action:f})})}var $={profile:`profile`,signIn:`sign-in`,sessions:`sessions`,tokens:`tokens`},Re=[`linked`,`linkError`],ze={view:{icon:h,cls:`bg-foreground-subtle/15 text-foreground-subtle`},create:{icon:m,cls:`bg-primary/15 text-primary`},delete:{icon:f,cls:`bg-danger/15 text-danger`}};function Be(){let{t:e}=R(),{user:t,logout:r}=H(),[i]=ue(),o=e(`system.myAccess`,`My access`);if(!t)return a(fe,{icon:T,title:o,children:a(`div`,{className:`text-xs text-foreground-subtle`,children:e(`systemPage.myAccess.notSignedIn`,`Not signed in.`)})});if(Re.some(e=>i.has(e))&&!i.has(`tab`)){let e=new URLSearchParams(i);return e.set(`tab`,$.signIn),a(B,{to:`?${e.toString()}`,replace:!0})}return a(de,{icon:T,title:o,subtitle:e(`systemPage.myAccess.subtitle`,`Your account, how you sign in, where you are signed in, and your tokens.`),sectionsLabel:e(`systemPage.myAccess.sectionsLabel`,`My access sections`),defaultSection:$.profile,actions:n(L,{variant:`outline`,onClick:r,children:[a(M,{className:`h-3 w-3`}),e(`systemPage.myAccess.signOut`,`Sign out`)]}),sections:[{id:$.profile,label:e(`systemPage.myAccess.sections.profile`,`Profile`),content:a(Ve,{user:t})},{id:$.signIn,label:e(`systemPage.myAccess.sections.signIn`,`Sign-in & security`),content:n(`div`,{className:`space-y-4`,children:[a(Me,{}),a(Ne,{username:t.username}),a(Pe,{}),a(Ae,{})]})},{id:$.sessions,label:e(`systemPage.myAccess.sections.sessions`,`Sessions & devices`),content:n(`div`,{className:`space-y-4`,children:[a(Fe,{}),a(Le,{}),a(De,{})]})},{id:$.tokens,label:e(`systemPage.myAccess.sections.tokens`,`Tokens`),content:a(ge,{ownOnly:!0})}]})}function Ve({user:e}){let{t}=R(),r=e.isAdmin,i=e.scopes??[];return n(`div`,{className:`space-y-4`,children:[n(`div`,{className:`rounded-lg border border-border bg-surface px-4 py-3 flex items-center gap-3`,children:[a(`div`,{className:`flex h-10 w-10 items-center justify-center rounded-full bg-primary/10 text-primary font-semibold text-base`,children:e.username.slice(0,1).toUpperCase()}),n(`div`,{className:`flex-1 min-w-0`,children:[a(`div`,{className:`text-sm font-semibold text-foreground truncate`,children:e.username}),n(`div`,{className:`text-[11px] text-foreground-subtle`,children:[r?t(`systemPage.myAccess.administrator`,`Administrator`):t(`systemPage.myAccess.user`,`User`),` `,a(V,{i18nKey:`systemPage.myAccess.sessionId`,values:{id:e.id.slice(0,8)},components:{mono:a(`span`,{className:`font-mono`})}})]})]})]}),r&&n(`div`,{className:`rounded-lg border border-primary/30 bg-primary/5 px-4 py-3 text-xs text-foreground flex items-start gap-2.5`,children:[a(y,{className:`h-4 w-4 text-primary mt-0.5 shrink-0`}),n(`div`,{children:[a(`div`,{className:`font-semibold text-foreground`,children:t(`systemPage.myAccess.unrestrictedAccess`,`Unrestricted access`)}),a(`p`,{className:`text-foreground-subtle mt-0.5`,children:t(`systemPage.myAccess.adminSessionsBypassThePer`,`Admin sessions bypass the per-call scope check. Every protected endpoint is reachable regardless of the list below.`)})]})]}),i.length>0&&a(He,{scopes:i})]})}function He({scopes:e}){let{t}=R(),r=w();return n(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[n(`div`,{className:`px-4 py-2 border-b border-border`,children:[a(`div`,{className:`text-xs font-semibold text-foreground`,children:t(`systemPage.myAccess.grantedScopes`,`Granted scopes`)}),a(`div`,{className:`text-[10px] text-foreground-subtle`,children:t(`systemPage.myAccess.bakedIntoYourSessionToken`,`Baked into your session token at login; sign out + back in to refresh after changes.`)})]}),n(`div`,{className:`grid grid-cols-[100px_1fr_240px] gap-3 px-4 py-2 text-[10px] uppercase tracking-wide text-foreground-subtle border-b border-border`,children:[a(`div`,{children:t(`systemPage.myAccess.type`,`Type`)}),a(`div`,{children:t(`systemPage.myAccess.target`,`Target`)}),a(`div`,{children:t(`systemPage.myAccess.access`,`Access`)})]}),a(`ul`,{className:`divide-y divide-border`,children:e.map((e,i)=>n(`li`,{className:`grid grid-cols-[100px_1fr_240px] gap-3 px-4 py-2.5 items-center text-xs`,children:[a(`span`,{className:`font-mono text-foreground-subtle`,children:e.type}),a(`span`,{className:`font-mono text-foreground`,children:e.type===`device`?ne(e.selector,r):e.target}),a(`div`,{className:`flex items-center gap-1`,children:[`view`,`create`,`delete`].map(r=>{let i=e.access.includes(r),{icon:o,cls:s}=ze[r];return n(`span`,{className:`inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] font-medium ${i?s:`bg-transparent text-foreground-subtle/40 line-through`}`,title:i?t(`systemPage.myAccess.can`,`Can {{a}}`,{a:r}):t(`systemPage.myAccess.cannot`,`Cannot {{a}}`,{a:r}),children:[a(o,{className:`h-3 w-3`}),r]},r)})})]},i))})]})}export{Be as MyAccessPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{C as e,J as t,K as n,R as r,S as i,V as a,W as o,Y as s,et as c,i as l,j as u,o as d,p as f,t as p}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{dt as m}from"./player-overlays-B5FSaids.js";import{Ja as h}from"./client-JLEP7nv7.js";import{Ci as g,Ja as _,Pi as v,gt as y,ta as ee,wi as te}from"./src-IQsaq5W-.js";import{t as ne}from"./useTranslation-BJr-n0es.js";import{F as re,I as ie,L as b,nr as x}from"./index-lH9UKmhf.js";c();var S=u(function({addonId:e,schema:s,serverValues:c,onImmediateSave:l,onStateChange:u,onAction:d,disabled:f},p){let m=x({schema:s,serverValues:c,onImmediateSave:r(t=>l(e,t),[e,l]),onDeferredSave:r(()=>{},[])});o(p,()=>({flush:()=>{let e={};for(let t of m.pendingKeys)e[t]=m.values[t];return m.handleDiscard(m.pendingKeys),e},discard:()=>m.resetAll()}),[m]);let h=m.pendingKeys,g=h.join(`|`),_=n(()=>h.map(e=>`${e}=${JSON.stringify(m.values[e])}`).join(`,`),[h,m.values]),v=t(u);a(()=>{v.current=u},[u]),a(()=>{let t={};for(let e of h)t[e]=m.values[e];v.current({addonId:e,pendingKeys:h,pendingValues:t})},[e,g,_]);let y=n(()=>{if(d)return(t,n,r)=>d(e,t,n,r)},[e,d]);return i(b,{schema:s,values:m.values,onChange:m.handleChange,disabled:f,onAction:y})});function C(e){return`perNode`in e&&e.perNode===!0}function w(e,t){if(e.type===`group`){let n=T(e.fields,t);return n.length>0?{...e,fields:n}:null}if(e.type===`sub-tabs`){let n=e.tabs.map(e=>({...e,fields:T(e.fields,t)})).filter(e=>e.fields.length>0);return n.length>0?{...e,tabs:n}:null}return C(e)===(t===`perNode`)?e:null}function T(e,t){let n=[];for(let r of e){let e=w(r,t);e!==null&&n.push(e)}return n}function ae(e,t){let n=[];for(let r of e.sections){let e=T(r.fields,t);e.length!==0&&n.push({...r,fields:e})}return{...e,sections:n}}function oe(e,t){let n=e??`general`;return t?.[n]??n}function E(e){return typeof e!=`object`||!e||!(`key`in e)?null:typeof e.key==`string`?e.key:null}function se(e,t){let n=t.fieldKeys===void 0?null:new Set(t.fieldKeys),r=[];for(let i of e){let e=n===null?i.fields:i.fields.filter(e=>{let t=E(e);return t!==null&&n.has(t)});e.length!==0&&r.push({...i,fields:e,...t.tabAliases===void 0?{}:{tab:oe(i.tab,t.tabAliases)},...t.hideSectionChrome===!0?{title:``,description:void 0}:{}})}return r}c();function D(e,t){if(e.type===`separator`||e.type===`info`||e.type===`button`)return e;if(e.type===`group`){let n=e.fields.map(e=>D(e,t));return{...e,fields:n}}let n=e;t[e.key]=n.value;let{value:r,...i}=n;return i}function O(e,t){return{...e,fields:e.fields.map(e=>D(e,t))}}function ce(e){let t={};return{schema:{...e.tabs?{tabs:e.tabs}:{},sections:e.sections.map(e=>O(e,t))},values:t}}function k({nodeId:a,addonIds:o,level:c,deviceId:u,capability:b,sectionIds:x,omitSectionIds:S,fieldKeys:C,hideSectionChrome:w,tabAliases:T,tabLabelOverrides:E,sectionTab:D,fieldScope:O,surface:k,emptyMessage:ue,extraTabs:A,schemaTabExtras:j,title:M,description:N,selfTabbed:de,activeTab:P,onActiveTabChange:fe}){let{t:F}=ne(),I=d(),L=m().trpcClient,R=te(),z=g(),pe=_(),me=ee(),B=de===!0||!!(A&&A.length>0),[he,ge]=s(null);if(c===`device`&&!u)throw Error(`NodeAddonsSettingsPanel: deviceId is required when level === "device"`);if(k!==void 0){if(c!==`global`||u!==void 0)throw Error(`NodeAddonsSettingsPanel: integration-level settings are addon-wide — they cannot be mounted at device level or with a deviceId. A second page, never a second scope.`);if(a!==null)throw Error(`NodeAddonsSettingsPanel: an integration has no node behind it — pass nodeId={null}. Received ${JSON.stringify(a)}.`);if(O!==void 0)throw Error("NodeAddonsSettingsPanel: integration-level settings arrive already cluster-scoped from core — remove `fieldScope` rather than restating it.")}let V=a??`hub`,H=l({queries:o.map(e=>({queryKey:[[`addonSettings`,k===void 0?c===`global`?`getGlobalSettings`:`getDeviceSettings`:`getIntegrationSettings`],{addonId:e,nodeId:V,deviceId:u??null,cap:b??null,scope:O??null}],queryFn:async()=>{let t=e=>e!==null&&O!==void 0?ae(e,O):e;return k===void 0?c===`global`?{addonId:e,result:t(await L.addonSettings.getGlobalSettings.query({addonId:e,nodeId:V,...b?{cap:b}:{}}))}:{addonId:e,result:t(await L.addonSettings.getDeviceSettings.query({addonId:e,deviceId:u,nodeId:V}))}:{addonId:e,result:await L.addonSettings.getIntegrationSettings.query({addonId:e,nodeId:V})}},placeholderData:f}))}),_e=H.some(e=>e.isLoading),ve=H.map(e=>{if(!e.data)return`-`;if(e.data.result===null)return`${e.data.addonId}:n`;let t=[];for(let n of e.data.result.sections){t.push(`s:${n.id}:${n.tab??`general`}`);for(let e of n.fields){if(!(`key`in e))continue;let n=`options`in e&&Array.isArray(e.options)?e.options.map(e=>e.value).join(`,`):``,r=e.value,i=r===void 0?``:typeof r==`string`?r:JSON.stringify(r);t.push(`f:${e.key}:${n}:${i}`)}}return`${e.data.addonId}:${t.join(`|`)}`}).join(`||`),U=n(()=>{let e=new Set;for(let t of H){let n=t.data?.result?.sections;if(n)for(let t of n)e.add(oe(t.tab,T))}return[...e]},[T,ve+`::`+H.map(e=>(e.data?.result?.sections??[]).map(e=>e.tab??`general`).join(`,`)).join(`::`)]),W=n(()=>new Map((A??[]).map(e=>[e.id,e])),[A]),G=n(()=>{if(!B)return[];let e=[...new Set([...U,...(A??[]).map(e=>e.id),...(j??[]).map(e=>e.tabId)])],t=e=>{let t=W.get(e);if(t?.order!==void 0)return t.order;let n=h[e];return n?n.order:50};return e.toSorted((e,n)=>{let r=t(e),i=t(n);return r===i?e.localeCompare(n):r-i})},[B,U,A,W,j]),ye=n(()=>{let e=new Map,t=e=>h[e]?.label??e.charAt(0).toUpperCase()+e.slice(1);for(let n of U)e.set(n,t(n));for(let n of j??[])e.has(n.tabId)||e.set(n.tabId,t(n.tabId));for(let t of A??[])e.set(t.id,t.label);for(let[t,n]of Object.entries(E??{}))e.set(t,n);return e},[U,A,j,E]),K=P===void 0?he:P,q=B?K&&G.includes(K)?K:G[0]??null:null,be=e=>{ge(e),fe?.(e)},xe=q!==null&&W.has(q),J=B?q&&!xe?q:void 0:D,{data:Se}=v(void 0),Ce=n(()=>{let e=new Map;for(let t of Se??[]){let n=t.manifest?.id;if(!n)continue;let r=t.manifest?.name??t.manifest?.packageDisplayName??n;e.set(n,r)}return e},[Se]),we=t(new Map),Y=n(()=>{let e=x?new Set(x):null,t=S?new Set(S):null,n=n=>!(e!==null&&!e.has(n)||t!==null&&t.has(n)),r=[];for(let e of H){if(!e.data)continue;let t=e.data.result??we.current.get(e.data.addonId)??null;if(e.data.result!==null&&we.current.set(e.data.addonId,e.data.result),t===null)continue;let{schema:i,values:a}=ce(t),o={...C===void 0?{}:{fieldKeys:C},...w===void 0?{}:{hideSectionChrome:w},...T===void 0?{}:{tabAliases:T}},s=se(i.sections.filter(e=>n(e.id)),o);if(s.length===0)continue;let c={...t,sections:se(t.sections.filter(e=>n(e.id)),o)},l={...i,sections:s};r.push({addonId:e.data.addonId,schemaWithValues:c,schema:l,serverValues:a})}return r},[ve,x,S,C,w,T]),[X,Te]=s(new Map),Ee=r(e=>{Te(t=>{let n=new Map(t);return n.set(e.addonId,e),n})},[]),Z=t(new Map),De=r(e=>t=>{t?Z.current.set(e,t):Z.current.delete(e)},[]),Oe=r(async(e,t)=>{c===`global`?await R.mutateAsync({addonId:e,nodeId:V,patch:t}):await z.mutateAsync({addonId:e,deviceId:u,nodeId:V,patch:t}),I.invalidateQueries({queryKey:[[`addonSettings`]]})},[R,z,V,c,u,I]),ke=r(async(e,t,n,r)=>{let i=V;try{switch(t){case`reprobe-hwaccel`:await pe.mutateAsync({nodeId:i}),I.invalidateQueries({queryKey:[[`addonSettings`]]});return;case`reprobe-audio-engine`:await me.mutateAsync({nodeId:i}),I.invalidateQueries({queryKey:[[`addonSettings`]]});return;default:{let n=await L.addons.custom.mutate({addonId:e,action:t,input:r});return I.invalidateQueries({queryKey:[[`addonSettings`]]}),n}}}catch(n){throw console.error(`[NodeAddonsSettingsPanel] action failed`,{addonId:e,action:t,err:n}),n}},[pe,me,V,I,L]),Ae=r((e,t)=>{Oe(e,t)},[Oe]),Q=p({mutationFn:async()=>{let e=[];for(let t of Y){let n=X.get(t.addonId);!n||n.pendingKeys.length===0||e.push({addonId:t.addonId,patch:n.pendingValues})}return e.length===0?{saved:[]}:{saved:await Promise.all(e.map(async({addonId:e,patch:t})=>(c===`global`?await R.mutateAsync({addonId:e,nodeId:V,patch:t}):await z.mutateAsync({addonId:e,deviceId:u,nodeId:V,patch:t}),e)))}},onSuccess:({saved:e})=>{for(let t of e)Z.current.get(t)?.discard();I.invalidateQueries({queryKey:[[`addonSettings`]]})}}),je=r(()=>{for(let e of Z.current.values())e.discard()},[]),Me=n(()=>{let e=0;for(let t of Y){let n=X.get(t.addonId);n&&(e+=n.pendingKeys.length)}return e},[Y,X]),Ne=n(()=>{let e=new Map;for(let t of Y){let n=X.get(t.addonId);if(!n||n.pendingKeys.length===0)continue;let r=new Set(n.pendingKeys);for(let n of t.schema.sections){let t=n.tab??`general`;for(let i of n.fields)`key`in i&&r.has(i.key)&&e.set(t,(e.get(t)??0)+1)}}return e},[Y,X]);if(_e)return i(`div`,{className:`h-24 rounded-lg border border-border bg-surface animate-pulse`});let $=q&&xe?W.get(q):void 0;if(!B&&Y.length===0)return i(`div`,{className:`text-[11px] text-foreground-subtle italic`,children:ue??F(`settings.nodeAddonsSettingsPanel.noAddonsIn`,{scope:o.length>0?`[${o.join(`, `)}]`:F(`settings.nodeAddonsSettingsPanel.theCurrentSelection`,`the current selection`),level:c})});let Pe=Q.isPending;return e(`div`,{className:`space-y-4`,children:[(M||N)&&e(`div`,{className:`border-b border-border pb-2`,children:[M&&i(`h2`,{className:`text-sm font-semibold text-foreground`,children:M}),N&&i(`p`,{className:`text-[11px] text-foreground-subtle mt-0.5`,children:N})]}),B&&i(re,{tabs:G.map(e=>({id:e,label:ye.get(e)??e})),activeId:q,onChange:be,pendingByTab:Ne}),Q.isError&&e(`div`,{className:`rounded-md border border-red-500/40 bg-red-500/10 px-3 py-2 text-[11px] text-red-400`,children:[F(`settings.nodeAddonsSettingsPanel.saveFailed`,`Save failed:`),` `,String(Q.error?.message??Q.error)]}),i(y,{tabKey:$?`extra:${q??``}`:`tab:${q??``}`,children:$?$.content:(()=>{let t=J?Y.reduce((e,t)=>e+t.schemaWithValues.sections.filter(e=>(e.tab??`general`)===J).length,0):0,n=!!J&&t<=1,r=Y.map(e=>({...e,renderedWithValues:{...e.schemaWithValues,sections:e.schemaWithValues.sections.filter(e=>J?(e.tab??`general`)===J:!0).map(e=>n?{...e,title:``,description:void 0}:e)}})).filter(e=>e.renderedWithValues.sections.length>0).toSorted((e,t)=>{let n=e=>{let t=1/0;for(let n of e)typeof n.order==`number`&&n.order<t&&(t=n.order);return t},r=n(e.renderedWithValues.sections),i=n(t.renderedWithValues.sections);return r===i?0:r-i}),a=(j??[]).filter(e=>e.tabId===J),o=a.filter(e=>(e.placement??`before`)===`before`),s=a.filter(e=>e.placement===`after`);return r.length===0&&a.length===0?i(`div`,{className:`text-[11px] text-foreground-subtle italic`,children:ue??F(`settings.nodeAddonsSettingsPanel.nothingToConfigureHereFor`,`Nothing to configure here for this node.`)}):e(`div`,{className:`space-y-6`,children:[o.map((e,t)=>i(`div`,{children:e.content},`extra-before-${t}`)),r.length>0&&i(le,{entries:r,paneStates:X,displayNames:Ce,disabled:Pe,setPaneRef:De,onPaneStateChange:Ee,onImmediateSave:Ae,onAction:ke,inline:B||!!D}),s.map((e,t)=>i(`div`,{children:e.content},`extra-after-${t}`))]})})()}),!_e&&i(ie,{pendingCount:Me,onSave:()=>Q.mutate(),onDiscard:je,saving:Pe})]})}function le({entries:t,paneStates:r,displayNames:o,disabled:c,setPaneRef:l,onPaneStateChange:u,onImmediateSave:d,onAction:f,inline:p}){let m=n(()=>[...t].toSorted((e,t)=>{if(e.addonId===`system-config`)return-1;if(t.addonId===`system-config`)return 1;let n=o.get(e.addonId)??e.addonId,r=o.get(t.addonId)??t.addonId;return n.localeCompare(r)}),[t,o]),[h,g]=s(m[0]?.addonId??``);a(()=>{m.length!==0&&(m.find(e=>e.addonId===h)||g(m[0].addonId))},[m,h]);let _=m.find(e=>e.addonId===h)??m[0];if(!_)return null;let v=n(()=>f?(e,t,n,r)=>f(e,t,n,r):void 0,[f]),y=e=>i(S,{ref:l(e.addonId),addonId:e.addonId,schema:e.renderedWithValues,serverValues:e.serverValues,onImmediateSave:d,onStateChange:u,onAction:v,disabled:c},e.addonId);return m.length===1||p?i(`div`,{className:`flex flex-col gap-4`,children:m.map(y)}):e(`div`,{className:`flex flex-col gap-3`,children:[i(`div`,{className:`flex flex-wrap items-center gap-1 border-b border-border shrink-0`,children:m.map(t=>{let n=o.get(t.addonId)??t.addonId,a=t.addonId===_.addonId,s=(r.get(t.addonId)?.pendingKeys.length??0)>0;return e(`button`,{type:`button`,onClick:()=>g(t.addonId),className:`relative px-3 py-1.5 text-xs font-medium rounded-t-md transition-colors -mb-px border-b-2 whitespace-nowrap ${a?`text-primary border-primary bg-primary/5`:`text-foreground-subtle border-transparent hover:text-foreground hover:bg-surface-hover`}`,children:[n,s&&i(`span`,{className:`ml-1.5 inline-flex h-1.5 w-1.5 rounded-full bg-amber-400`})]},t.addonId)})}),i(`div`,{className:`space-y-2`,children:m.map(e=>i(`div`,{style:e.addonId===_.addonId?void 0:{display:`none`},children:y(e)},e.addonId))})]})}export{k as t};
|