@camstack/addon-admin-ui 1.2.477 → 1.2.479
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/Addons-2bVk9gQP.js +5 -0
- package/dist/assets/{AdminSectionedPage-DtiHBXGC.js → AdminSectionedPage-5g5LDrXG.js} +1 -1
- package/dist/assets/{AiProfiles-7FToWDqj.js → AiProfiles-CjexfGhj.js} +1 -1
- package/dist/assets/{BrokerForm-D5-q8F_8.js → BrokerForm-Behibhry.js} +1 -1
- package/dist/assets/{Build-DwW5kYsa.js → Build-EtMIMKRO.js} +3 -3
- package/dist/assets/{Calendars-BhMRY6EV.js → Calendars-DH3P_u96.js} +1 -1
- package/dist/assets/{Cluster-z11q6anB.js → Cluster-CFnD0vXf.js} +1 -1
- package/dist/assets/{CompositionBlockEditor-CElNVsCR.js → CompositionBlockEditor-BsmLsHO7.js} +1 -1
- package/dist/assets/{CompositionEditorPage-NzgZB76B.js → CompositionEditorPage-DbFLOjT0.js} +1 -1
- package/dist/assets/{Data-D_U-HkwO.js → Data-DaycWn5V.js} +2 -2
- package/dist/assets/{DeviceDetail-D89wXQHP.js → DeviceDetail-DABbOvpp.js} +2 -2
- package/dist/assets/{DeviceDoActionFields-Bj4gX0r-.js → DeviceDoActionFields-DESERgis.js} +1 -1
- package/dist/assets/{Devices-BnhDZU3y.js → Devices-e9WRZF8o.js} +1 -1
- package/dist/assets/{HelperWizard-CrXHYd19.js → HelperWizard-B5Evcb8G.js} +1 -1
- package/dist/assets/{History-BsJBR2zt.js → History-CUBYC5vJ.js} +1 -1
- package/dist/assets/{Identity-B_6I_sCY.js → Identity-YiQC97gk.js} +1 -1
- package/dist/assets/IntegrationDetail-LZqy5tnJ.js +1 -0
- package/dist/assets/{IntegrationHub-CSaA690G.js → IntegrationHub-oKQf8Hqh.js} +1 -1
- package/dist/assets/Integrations-Bb8hbB7-.js +1 -0
- package/dist/assets/Integrations-CSF7awEo.js +1 -0
- package/dist/assets/{Library-3dGkOQB5.js → Library-CLum5n0h.js} +1 -1
- package/dist/assets/{Locations-Bh5GRDCv.js → Locations-CyGnajVJ.js} +1 -1
- package/dist/assets/{Logs-diqSxXEc.js → Logs-DTwpZ7zU.js} +1 -1
- package/dist/assets/{MyAccess-BqulMSGv.js → MyAccess--2ZT-HhR.js} +1 -1
- package/dist/assets/{Network-C8Gpb2Vn.js → Network-DAts0LIq.js} +1 -1
- package/dist/assets/{NodeAddonsSettingsPanel-Dq6sGWkR.js → NodeAddonsSettingsPanel-96SuINk0.js} +1 -1
- package/dist/assets/{Notifications-C5w5t75z.js → Notifications-BLt2f-nc.js} +1 -1
- package/dist/assets/{Pipeline-CjumfHMc.js → Pipeline-Bn9VYb0p.js} +1 -1
- package/dist/assets/{Recordings-DE76fgEt.js → Recordings-vrFJrZh0.js} +1 -1
- package/dist/assets/ScanNetworkModal-u-7qAdO5.js +1 -0
- package/dist/assets/{SessionsList-Ca-zN1Fi.js → SessionsList-DJR70bvB.js} +1 -1
- package/dist/assets/{Showroom-B9HZ38O5.js → Showroom-CK5L2uo3.js} +1 -1
- package/dist/assets/{System-CHEbMPI_.js → System-Bp5NGMuQ.js} +1 -1
- package/dist/assets/{Terminal-CWFZuQLg.js → Terminal-BnNXFsMP.js} +1 -1
- package/dist/assets/{assignment-candidates-BcnFMc1B.js → assignment-candidates-BMhC6h3l.js} +1 -1
- package/dist/assets/{board-model-gmvqxkjB.js → board-model--9Jw6SCm.js} +1 -1
- package/dist/assets/{device-integration-icon-0oWIIjcP.js → device-integration-icon-CdgkjIk4.js} +1 -1
- package/dist/assets/{format-CIO4xeN9.js → format-fYneBFV6.js} +1 -1
- package/dist/assets/i18n-D0o08mg-.js +1 -0
- package/dist/assets/{index-D4ZlWCxy.css → index-D4id__eL.css} +1 -1
- package/dist/assets/index-D_Tm4B7S.js +4 -0
- package/dist/assets/{linked-devices-model-BoOq02QT.js → linked-devices-model-DMEJU3bE.js} +1 -1
- package/dist/assets/{location-owned-usage-IF2k-L3A.js → location-owned-usage-BqMUhVoi.js} +1 -1
- package/dist/assets/{mf-entry-bootstrap-0-f45a46c2.js → mf-entry-bootstrap-0-e328376a.js} +1 -1
- package/dist/assets/{step-inspector-model-CyqFN-LU.js → step-inspector-model-G2bS8NkA.js} +1 -1
- package/dist/assets/{useNodeUrlSelection-DGV2ltbG.js → useNodeUrlSelection-XYqqUh3q.js} +1 -1
- package/dist/index.html +4 -4
- package/dist/server/addon.js +1 -1
- package/package.json +1 -1
- package/dist/assets/Addons-CbHidHOJ.js +0 -5
- package/dist/assets/IntegrationDetail-B9L7AfYy.js +0 -1
- package/dist/assets/Integrations-B-KtSB_m.js +0 -1
- package/dist/assets/Integrations-CMW4LOX-.js +0 -1
- package/dist/assets/ScanNetworkModal-DXzDOpxk.js +0 -1
- package/dist/assets/i18n-xhwARoF0.js +0 -1
- package/dist/assets/index-C3uCLHv0.js +0 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./i18n-
|
|
1
|
+
import{t as e}from"./i18n-D0o08mg-.js";import{t}from"./assignment-candidates-BMhC6h3l.js";function n(e){return e.slot===`linked-devices`}function r(t){if(t.status===`error`)return{kind:`unknown`,reason:t.error?.message??e.t(`helpers.customize.requestFailed`)};if(t.status===`pending`||t.data===void 0)return{kind:`pending`};for(let e of t.data)if(e.state===`ok`&&e.slot===`linked-devices`&&n(e.value))return{kind:`present`,slot:e,value:e.value};let r=t.data.find(e=>e.state===`unreachable`);return r!==void 0&&r.state===`unreachable`?{kind:`unknown`,reason:r.reason}:{kind:`absent`}}function i(e,t){let n=t.trackedDeviceIds??[],r=e=>t=>({deviceId:t.deviceId,name:t.name,health:t.health,implied:e,tracked:n.includes(t.deviceId)});return[...e.sources.map(r(!1)),...(e.impliedSources??[]).map(r(!0))]}function a(e,t){let n=new Set([...e.sources,...e.impliedSources??[]].map(e=>e.deviceId));return(t.trackedDeviceIds??[]).filter(e=>!n.has(e))}function o(e,t){return{...e,deviceIds:[...e.deviceIds,...t.filter(t=>!e.deviceIds.includes(t))]}}function s(e,t){return{...e,deviceIds:e.deviceIds.filter(e=>e!==t),...e.trackedDeviceIds===void 0?{}:{trackedDeviceIds:e.trackedDeviceIds.filter(e=>e!==t)}}}function c(e,t,n){let r=e.trackedDeviceIds??[],i=n?[...r.filter(e=>e!==t),t]:r.filter(e=>e!==t);return{...e,trackedDeviceIds:i}}function l(e,n,r){return e.flatMap(e=>{let i=n.get(e.deviceId);return r.has(e.deviceId)||i===void 0?[]:[{deviceId:e.deviceId,ref:{addonId:i.addonId,stableId:i.stableId},name:e.parentName===null?e.name:`${e.parentName} · ${e.name}`,detail:t(i.integration,e.location),meta:e.type,caps:[],value:null}]})}export{o as a,a as i,i as n,c as o,r,s,l as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{C as e,K as t,R as n,S as r,V as i,Y as a,et as o,o 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{D as c,En as l,Fn as u,It as d,Sr as f,dt as p,kn as m,or as h,ot as g,xi as _,yi as v,zr as y}from"./player-overlays-Dbv95cvz.js";import{ia as b}from"./client-DvJxGh2F.js";import{t as x}from"./archive-Brq5E-qM.js";import{t as S}from"./eraser-Bs0PJaPY.js";import{t as C}from"./hard-drive-download-iRJR_Xj9.js";import{Jl as ee,Kr as w,Sn as T,Wr as E,_r as D,bt as te,hr as ne,mi as O,mr as re,ou as ie,pr as ae,vr as k,yr as A}from"./src-DntJrWmU.js";import{t as j}from"./i18n-xhwARoF0.js";import{t as M}from"./useTranslation-BJr-n0es.js";import{P as oe,lr as se}from"./index-C3uCLHv0.js";import{t as N}from"./format-size-DIxKXxtj.js";o();function P(e){let t=e.trim().toLowerCase();return t.length===0?``:t.replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``)}function F(e,t){let n=P(t);return`${e}:${n.length>0?n:`default`}`}var I=new Set([`proc`,`sys`,`dev`,`run`,`boot`,`lost+found`,`snap`,`bin`,`sbin`,`lib`,`lib32`,`lib64`,`libx32`,`usr`,`etc`,`var`,`opt`,`tmp`,`srv`,`root`,`System`,`Library`,`Applications`,`cores`,`private`]),L=[`recordings`,`data`,`mnt`,`media`,`Volumes`];function R(e){let t=L.findIndex(t=>t===`recordings`?e.startsWith(t):e===t);return t===-1?L.length:t}function ce(e){return e.filter(e=>!e.name.startsWith(`.`)&&!I.has(e.name)).toSorted((e,t)=>{let n=R(e.name)-R(t.name);return n===0?e.name.localeCompare(t.name):n}).map(e=>e.path)}function le({nodeId:t,value:o,onChange:s}){let{t:c}=M(),l=g().trpcClient,[u,d]=a([]),[f,p]=a(o),[m,h]=a(null),[_,v]=a(null),[y,b]=a(``),x=n(async(e,n)=>{v(null);try{let r=await l.filesystemBrowse.browse.query({nodeId:t,path:e});h(r),p(r.path),n&&s(r.path)}catch(e){v(e instanceof Error?e.message:`browse failed`)}},[l,t,s]);i(()=>{p(o),(async()=>{let e=await l.filesystemBrowse.browse.query({nodeId:t,path:`/`}).then(e=>e).catch(()=>null);if(e){d(ce(e.entries)),await x(o.startsWith(`/`)?o:`/`,!1);return}try{let e=await l.filesystemBrowse.listAllowedRoots.query({nodeId:t});d(e),await x(o&&e.some(e=>o.startsWith(e))?o:e[0]??``,!1)}catch(e){d([]),h(null),v(e instanceof Error&&/not available on node/i.test(e.message)?`This node can't be browsed remotely. Enter the path manually.`:e instanceof Error?e.message:`browse unavailable`)}})()},[t]);let S=async()=>{if(!(!y.trim()||!m)){v(null);try{let e=`${m.path.replace(/\/+$/,``)}/${y.trim()}`;await l.filesystemBrowse.createDir.mutate({nodeId:t,path:e}),b(``),await x(m.path,!0)}catch(e){v(e instanceof Error?e.message:`create failed`)}}},C=e=>`${(e/1e9).toFixed(1)} GB`;return e(`div`,{className:`space-y-2 rounded border border-border p-2`,children:[r(`div`,{className:`flex flex-wrap gap-1`,children:u.map(e=>r(`button`,{onClick:()=>void x(e,!0),className:`rounded border border-border px-2 py-0.5 text-[10px] font-mono hover:border-primary/40`,children:e},e))}),r(`input`,{value:f,onChange:e=>{p(e.target.value),s(e.target.value)},placeholder:`/absolute/path`,className:`w-full rounded border border-border bg-background px-2 py-1 text-[11px] font-mono`}),m&&r(`div`,{className:`text-[10px] text-foreground-subtle`,children:c(`storage.pathBrowser.free`,{free:C(m.freeBytes),total:C(m.totalBytes)})}),r(`div`,{className:`max-h-40 space-y-0.5 overflow-y-auto`,children:m?.entries.map(t=>e(`button`,{onClick:()=>void x(t.path,!0),className:`block w-full truncate rounded px-2 py-1 text-left text-xs hover:bg-primary/5`,children:[`📁 `,t.name]},t.path))}),e(`div`,{className:`flex gap-1`,children:[r(`input`,{value:y,onChange:e=>b(e.target.value),placeholder:c(`storage.pathBrowser.newFolder`,`new folder`),className:`flex-1 rounded border border-border bg-background px-2 py-1 text-xs`}),r(`button`,{onClick:()=>void S(),className:`rounded border border-border px-2 py-1 text-xs hover:border-primary/40`,children:c(`storage.pathBrowser.create`,`Create`)})]}),_&&r(`div`,{className:`text-[10px] text-red-400`,children:_})]})}o();function z({initialType:n,onClose:i,onCreated:o}){let{t:c}=M(),l=s(),u=g().trpcClient,[d,f]=a(`picker`),[p,m]=a(n),[_,y]=a(null),[b,x]=a({}),[S,C]=a(``),[w,T]=a(null),[E,D]=a(!1),[O,j]=a(`hub`),[N,P]=a(null),[I,L]=a(!1),R=e=>x(t=>({...t,basePath:e})),ce=typeof b.basePath==`string`?b.basePath:``,z=ee(),B=t(()=>{let e=z.data;return Array.isArray(e)?e:[]},[z.data]),V=z.isLoading,H=ie({onSuccess:()=>{l.invalidateQueries({queryKey:[[`storage`,`listLocations`]]}),o()}}),U=t(()=>w!==null&&w.length>0?w:F(p,S),[p,S,w]),ue=async()=>{if(_){L(!0),P(null);try{P(await(e=>u.storage.testConfig.query(e))({providerId:_.providerId,config:b}))}catch(e){P({ok:!1,error:e instanceof Error?e.message:String(e)})}finally{L(!1)}}};return r(ae,{open:!0,onOpenChange:e=>!e&&i(),children:e(ne,{width:`md`,placement:`sheet-on-mobile`,scroll:`body`,children:[e(k,{children:[r(A,{children:{picker:`Add Location — Pick provider`,config:`Add Location — ${_?.displayName??``}`,naming:`Add Location — Name`}[d]}),e(`p`,{className:`text-xs text-foreground-subtle`,children:[c(`storage.addLocationWizard.type`,`Type:`),` `,r(`span`,{className:`font-mono`,children:p})]})]}),e(re,{children:[d===`picker`&&e(`div`,{className:`space-y-2`,children:[V&&r(`div`,{className:`text-xs text-foreground-subtle animate-pulse`,children:c(`storage.addLocationWizard.loadingProviders`,`Loading providers…`)}),!V&&B.length===0&&r(`div`,{className:`rounded border border-border bg-background px-3 py-4 text-center text-xs text-foreground-subtle`,children:r(se,{i18nKey:`storage.addLocationWizard.noProvider`,values:{type:p},components:{code:r(`code`,{className:`font-mono`})}})}),B.map(t=>e(`button`,{onClick:()=>{y(t),f(`config`)},className:`flex w-full items-center gap-3 rounded-lg border border-border bg-background p-3 text-left hover:border-primary/40 hover:bg-primary/5 transition-colors`,children:[e(`div`,{className:`flex-1 min-w-0`,children:[r(`p`,{className:`text-xs font-semibold text-foreground`,children:t.displayName}),r(`p`,{className:`text-[10px] text-foreground-subtle font-mono mt-0.5 truncate`,children:t.providerId})]}),r(v,{className:`h-4 w-4 text-foreground-subtle flex-shrink-0`})]},t.providerId))]}),d===`config`&&_&&e(`div`,{className:`space-y-3`,children:[r(oe,{schema:_.configSchema,values:b,onChange:x}),_.nodeLocal&&e(`div`,{className:`space-y-2`,children:[r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:c(`storage.addLocationWizard.node`,`Node`)}),r(te,{selectedNodeId:O,onSelect:j,alwaysShow:!0}),r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:c(`storage.addLocationWizard.path`,`Path`)}),r(le,{nodeId:O,value:ce,onChange:R})]}),N&&r(`div`,{className:`rounded border px-3 py-2 text-[11px] ${N.ok?`border-success/30 bg-success/5 text-success`:`border-danger/30 bg-danger/5 text-danger`}`,children:N.ok?c(`storage.addLocationWizard.connectionOk`,`Connection OK.`):c(`storage.addLocationWizard.testFailed`,`Test failed: {{value1}}`,{value1:N.error??`unknown error`})}),e(`div`,{className:`flex items-center justify-between pt-1`,children:[r(`button`,{onClick:()=>f(`picker`),className:`rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground`,children:c(`common.back`,`Back`)}),e(`div`,{className:`flex items-center gap-2`,children:[r(`button`,{onClick:()=>{ue()},disabled:I,className:`rounded border border-border px-3 py-1.5 text-xs text-foreground hover:bg-primary/10 disabled:opacity-50`,children:I?c(`storage.addLocationWizard.testing`,`Testing…`):c(`storage.addLocationWizard.testConnection`,`Test connection`)}),r(`button`,{onClick:()=>f(`naming`),className:`rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90`,children:c(`common.next`,`Next`)})]})]})]}),d===`naming`&&_&&e(`div`,{className:`space-y-3`,children:[e(`div`,{className:`space-y-1`,children:[r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:c(`storage.addLocationWizard.displayName`,`Display name`)}),r(`input`,{type:`text`,value:S,onChange:e=>C(e.target.value),placeholder:c(`storage.addLocationWizard.on`,`{{type}} on {{displayName}}`,{type:p,displayName:_.displayName}),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`})]}),e(`div`,{className:`space-y-1`,children:[e(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:[c(`storage.addLocationWizard.idLabel`),` `,r(`span`,{className:`lowercase tracking-normal text-foreground-subtle`,children:c(`storage.addLocationWizard.autoDerivedOverrideIfNeeded`,`— auto-derived; override if needed`)})]}),r(`input`,{type:`text`,value:U,onChange:e=>T(e.target.value),placeholder:F(p,S),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground font-mono focus:outline-none focus:ring-1 focus:ring-primary`}),e(`p`,{className:`text-[10px] text-foreground-subtle`,children:[c(`storage.addLocationWizard.format`,`Format:`),` `,r(`code`,{className:`font-mono`,children:c(`storage.addLocationWizard.typeSlug`,`<type>:<slug>`)}),`. Lowercase letters, digits, and hyphens only.`]})]}),e(`label`,{className:`flex items-start gap-2 rounded border border-border bg-background px-3 py-2 cursor-pointer hover:bg-primary/5`,children:[r(`input`,{type:`checkbox`,checked:E,onChange:e=>D(e.target.checked),className:`accent-primary mt-0.5`}),e(`div`,{className:`space-y-0.5`,children:[r(`div`,{className:`text-xs font-medium text-foreground`,children:c(`storage.addLocationWizard.enableImmediately`,`Enable immediately`)}),r(`div`,{className:`text-[10px] text-foreground-subtle`,children:c(`storage.addLocationWizard.aDisabledLocationReceivesNo`,`A disabled location receives no writes until enabled — reads and age-based retention still work, nothing new lands here. Leave this off to register the disk now and start using it later.`)})]})]}),H.isError&&r(`div`,{className:`rounded border border-danger/30 bg-danger/5 text-danger px-3 py-2 text-[11px]`,children:H.error instanceof Error?H.error.message:String(H.error)}),e(`div`,{className:`flex items-center justify-between pt-1`,children:[r(`button`,{onClick:()=>f(`config`),className:`rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground`,children:c(`common.back`,`Back`)}),e(`div`,{className:`flex items-center gap-2`,children:[r(`button`,{onClick:()=>{m(n),y(null),x({}),C(``),T(null),D(!1),P(null),f(`picker`)},className:`rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground`,children:c(`common.reset`,`Reset`)}),e(`button`,{onClick:()=>{_&&H.mutate({id:U,type:p,displayName:S.trim(),providerId:_.providerId,config:b,enabled:E,nodeId:_.nodeLocal?O:void 0})},disabled:H.isPending||S.trim().length===0,className:`inline-flex items-center gap-1.5 rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50`,children:[H.isPending?r(h,{className:`h-3.5 w-3.5 animate-spin`}):null,H.isPending?c(`storage.addLocationWizard.saving`,`Saving…`):c(`common.save`,`Save`)]})]})]})]})]})]})})}function B(e){return b(e)}function V(e){return e===`active`}var H=[{mode:`active`,get label(){return j.t(`helpers.locationMode.activeLabel`)},get consequence(){return j.t(`helpers.locationMode.activeConsequence`)},requiresConfirmation:!1},{mode:`readonly`,get label(){return j.t(`helpers.locationMode.readonlyLabel`)},get consequence(){return j.t(`helpers.locationMode.readonlyConsequence`)},requiresConfirmation:!1},{mode:`drain`,get label(){return j.t(`helpers.locationMode.drainLabel`)},get consequence(){return j.t(`helpers.locationMode.drainConsequence`)},requiresConfirmation:!1},{mode:`disabled`,get label(){return j.t(`helpers.locationMode.disabledLabel`)},get consequence(){return j.t(`helpers.locationMode.disabledConsequence`)},requiresConfirmation:!0}];function U(e){return H.find(t=>t.mode===e)??H[0]}function ue(e){return U(e).requiresConfirmation}var de=`Blocked: this is the last location of its type still accepting writes — new data would have nowhere to go.`;function W(e,t,n){return V(n)||!V(B(e))||t.some(t=>t.id!==e.id&&V(B(t)))?{blocked:!1,reason:``}:{blocked:!0,reason:de}}function fe(e,t){return{active:W(e,t,`active`).reason,readonly:W(e,t,`readonly`).reason,drain:W(e,t,`drain`).reason,disabled:W(e,t,`disabled`).reason}}function pe(e,t,n){return!(n===`single`||t.length<=1||V(B(e))&&t.filter(e=>V(B(e))).length<=1)}function me(e){return e===`active`?{enabled:!0,readOnly:!1}:e===`readonly`?{enabled:!1,readOnly:!1}:{enabled:!1,readOnly:!0}}function he(e,t){let n={...t.config??e.config};t.mode!==void 0&&(me(t.mode).readOnly?n.readOnly=!0:delete n.readOnly);let r={id:e.id,type:e.type,displayName:t.displayName??e.displayName,providerId:e.providerId,config:n,isSystem:e.isSystem},i=t.nodeId??e.nodeId,a=i===void 0?r:{...r,nodeId:i};return t.mode===void 0?e.enabled===void 0?a:{...a,enabled:e.enabled}:{...a,mode:t.mode,enabled:me(t.mode).enabled}}var ge=1024**3;function G(e){return typeof e==`number`&&Number.isFinite(e)?e:null}function _e(e){let t=G(e.minFreeGb);if(t!==null)return{unit:`gb`,value:t};let n=G(e.minFreePercent);return n===null?{unit:`percent`,value:null}:{unit:`percent`,value:n}}function ve(e,t){return G(e[t===`gb`?`minFreeGb`:`minFreePercent`])}function ye(e,t){let n={...e};return delete n.minFreePercent,delete n.minFreeGb,t.value===null?n:t.unit===`gb`?{...n,minFreeGb:t.value}:{...n,minFreePercent:t.value}}function be(e,t){let n=e.trim();if(n===``)return null;let r=Number(n);return Number.isFinite(r)?t===`percent`?Math.min(100,Math.max(0,r)):Math.max(0,r):null}function xe(e,t,n=10){if(e.unit===`gb`&&e.value!==null)return e.value*ge;let r=e.value??n;return t===null||t<=0?null:t*Math.min(100,Math.max(0,r))/100}function Se(e){return e===`gb`?j.t(`helpers.locationProtection.unitGb`):j.t(`helpers.locationProtection.unitPercent`)}function Ce(e,t=10){let n=e.value===null?j.t(`helpers.locationProtection.targetDefault`,{percent:String(t)}):e.unit===`gb`?j.t(`helpers.locationProtection.targetGb`,{value:String(e.value)}):j.t(`helpers.locationProtection.targetPercent`,{value:String(e.value)});return j.t(`helpers.locationProtection.helpText`,{target:n,percent:String(t)})}function we(e){return G(e.maxUsedGb)}function Te(e,t){let n=G(e.maxUsedGb);return n===null||n<0?null:{bytes:n*ge,reason:t===`drain`?`drain`:`legacy`}}o();function Ee({config:t,defaultPercent:n=10,onChange:i}){let{t:o}=M(),[s,c]=a(()=>_e(t).unit),l=ve(t,s),u={unit:s,value:l},d=we(t),f=e=>{c(e),i(ye(t,{unit:e,value:null}))},p=e=>{i(ye(t,{unit:s,value:be(e,s)}))};return e(`div`,{className:`space-y-1`,children:[r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:o(`storage.protectionPolicyField.protectedFreeSpace`,`Protected free space`)}),e(`div`,{className:`flex items-center gap-2`,children:[e(`select`,{"aria-label":o(`storage.protectionPolicyField.protectionUnit`,`Protection unit`),value:s,onChange:e=>{f(e.target.value===`gb`?`gb`:`percent`)},className:`rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`,children:[r(`option`,{value:`percent`,children:o(`storage.protectionPolicyField.ofTheVolume`,`% of the volume`)}),r(`option`,{value:`gb`,children:o(`storage.protectionPolicyField.gbOfFreeSpace`,`GB of free space`)})]}),r(`input`,{type:`number`,"aria-label":Se(s),min:0,max:s===`percent`?100:void 0,value:l===null?``:l,placeholder:s===`percent`?String(n):o(`common.defaultWord`),onChange:e=>{p(e.target.value)},className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`})]}),r(`p`,{className:`text-[10px] text-foreground-subtle`,children:Ce(u,n)}),d!==null&&r(`p`,{className:`text-[10px] text-foreground-subtle italic`,children:o(`storage.protectionPolicyField.legacyMax`,{gb:d})})]})}o();function De({location:n,onClose:i,onSaved:o}){let{t:c}=M(),l=s(),u=g().trpcClient,[d,f]=a({...n.config}),[p,m]=a(n.displayName),[_,v]=a(null),[y,b]=a(!1),x=ee(),S=t(()=>{let e=x.data;return Array.isArray(e)?e.find(e=>e.providerId===n.providerId)??null:null},[x.data,n.providerId]),C=ie({onSuccess:()=>{l.invalidateQueries({queryKey:[[`storage`,`listLocations`]]}),o()}}),T=S?.shouldSaveDiskSpace===!0,E=S?.nodeLocal===!0,[O,j]=a(typeof n.nodeId==`string`?n.nodeId:`hub`),N=typeof d.basePath==`string`?d.basePath:``,P=e=>f(t=>({...t,basePath:e})),F=S?.minFreePercent??10,I=async()=>{b(!0),v(null);try{v(await(e=>u.storage.testConfig.query(e))({providerId:n.providerId,locationId:n.id,config:d}))}catch(e){v({ok:!1,error:e instanceof Error?e.message:String(e)})}finally{b(!1)}};return r(ae,{open:!0,onOpenChange:e=>!e&&i(),children:e(ne,{width:`md`,placement:`sheet-on-mobile`,scroll:`body`,children:[e(k,{children:[r(A,{children:c(`storage.editLocationModal.title`,{name:n.displayName})}),e(`p`,{className:`text-xs text-foreground-subtle`,children:[r(`span`,{className:`font-mono`,children:n.id}),` ·`,` `,S?.displayName??n.providerId]})]}),e(re,{className:`space-y-3`,children:[e(`div`,{className:`space-y-1`,children:[r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:c(`storage.editLocationModal.displayName`,`Display name`)}),r(`input`,{type:`text`,value:p,onChange:e=>m(e.target.value),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`})]}),S&&r(oe,{schema:S.configSchema,values:d,onChange:f}),E&&e(`div`,{className:`space-y-2`,children:[r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:c(`storage.editLocationModal.node`,`Node`)}),r(te,{selectedNodeId:O,onSelect:j,alwaysShow:!0}),r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:c(`storage.editLocationModal.path`,`Path`)}),r(le,{nodeId:O,value:N,onChange:P})]}),T&&r(Ee,{config:d,defaultPercent:F,onChange:f}),!S&&!x.isLoading&&r(`div`,{className:`rounded border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-[11px] text-amber-700 dark:text-amber-300`,children:r(se,{i18nKey:`storage.editLocationModal.providerGone`,values:{id:n.providerId},components:{code:r(`code`,{className:`font-mono`})}})}),_&&r(`div`,{className:`rounded border px-3 py-2 text-[11px] ${_.ok?`border-success/30 bg-success/5 text-success`:`border-danger/30 bg-danger/5 text-danger`}`,children:_.ok?c(`storage.editLocationModal.connectionOk`,`Connection OK.`):c(`storage.editLocationModal.testFailed`,`Test failed: {{value1}}`,{value1:_.error??`unknown error`})}),C.isError&&r(`div`,{className:`rounded border border-danger/30 bg-danger/5 text-danger px-3 py-2 text-[11px]`,children:C.error instanceof Error?C.error.message:String(C.error)})]}),e(D,{className:`justify-between`,children:[r(w,{variant:`outline`,size:`sm`,onClick:i,children:c(`common.cancel`,`Cancel`)}),e(`div`,{className:`flex items-center gap-2`,children:[r(w,{variant:`outline`,size:`sm`,onClick:()=>{I()},disabled:y||!S,children:y?c(`storage.editLocationModal.testing`,`Testing…`):c(`storage.editLocationModal.testConnection`,`Test connection`)}),e(w,{size:`sm`,onClick:()=>{C.mutate(he(n,{displayName:p.trim(),config:d,nodeId:E?O:n.nodeId}))},disabled:C.isPending||p.trim().length===0,children:[C.isPending?r(h,{className:`h-3.5 w-3.5 animate-spin`}):null,C.isPending?c(`storage.editLocationModal.saving`,`Saving…`):c(`common.save`,`Save`)]})]})]})]})})}function Oe(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function K(e){return typeof e==`number`&&Number.isFinite(e)?e:null}function ke(e){if(!Oe(e))return null;let t=e.locationId;if(typeof t!=`string`||t.length===0)return null;let n=K(e.startedAtMs),r=K(e.startBytes),i=K(e.bytesRemaining);return n===null||r===null||i===null||typeof e.drained!=`boolean`?null:{locationId:t,startedAtMs:n,startBytes:r,bytesRemaining:i,drained:e.drained,estimatedEmptyAtMs:K(e.estimatedEmptyAtMs)}}function Ae(e){let t=new Map;if(!Array.isArray(e))return t;for(let n of e){let e=ke(n);e!==null&&t.set(e.locationId,e)}return t}function je(e){if(e.startBytes<=0||e.bytesRemaining>e.startBytes)return null;let t=e.startBytes-e.bytesRemaining;return Math.min(1,Math.max(0,t/e.startBytes))}function Me(e,t){return e?t===void 0?{kind:`unreported`}:t.drained||t.bytesRemaining<=0?{kind:`drained`}:{kind:`draining`,bytesRemaining:t.bytesRemaining,drainedFraction:je(t),estimatedEmptyAtMs:t.estimatedEmptyAtMs}:{kind:`idle`}}function Ne(e){return e.mode===`drain`?!0:e.config.readOnly===!0}function Pe(e){return`${(e/1024**3).toFixed(e>=100*1024**3?0:1)} GB`}function Fe(e){return new Date(e).toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`})}function Ie({drain:t}){let{t:n}=M();if(t.kind===`idle`)return null;if(t.kind===`unreported`)return r(`span`,{"data-testid":`drain-unreported`,className:`text-[10px] text-foreground-subtle`,title:n(`storage.drainProgressLine.thisLocationIsDrainingThe`,`This location is draining. The hub has not reported how much is left yet — either the drain has just been set, or this hub predates the drain-progress report.`),children:n(`storage.drainProgressLine.drainingRemainingNotReportedYet`,`Draining · remaining not reported yet`)});if(t.kind===`drained`)return r(`span`,{"data-testid":`drain-done`,className:`text-[10px] text-success`,title:n(`storage.drainProgressLine.everythingThatWasHereHas`,`Everything that was here has been moved. The location is still in drain mode — it receives no new writes until you change that.`),children:n(`storage.drainProgressLine.drainedNothingLeftToMove`,`Drained · nothing left to move`)});let i=t.drainedFraction===null?null:Math.round(t.drainedFraction*100);return e(`span`,{"data-testid":`drain-progress`,className:`flex items-center gap-1.5 text-[10px] text-foreground-subtle tabular-nums`,children:[i!==null&&r(`span`,{"data-testid":`drain-bar`,className:`inline-block h-1 w-10 rounded-full bg-border overflow-hidden`,role:`progressbar`,"aria-label":n(`storage.drainProgressLine.drainProgress`,`Drain progress`),"aria-valuenow":i,"aria-valuemin":0,"aria-valuemax":100,children:r(`span`,{className:`block h-full bg-warning`,style:{width:`${i}%`}})}),e(`span`,{children:[n(`storage.drainProgressLine.left`,{size:Pe(t.bytesRemaining)}),i!==null&&` · ${n(`storage.drainProgressLine.moved`,{percent:i})}`]}),t.estimatedEmptyAtMs===null?r(`span`,{"data-testid":`drain-eta-absent`,title:n(`storage.drainProgressLine.theDrainIsPacedBy`,`The drain is paced by how fast this class of data is still growing, and that has not been observed yet. There is no date to give.`),children:n(`storage.drainProgressLine.emptyTimeNotKnownYet`,`· empty time not known yet`)}):e(`span`,{"data-testid":`drain-eta`,children:[`·`,` `,n(`storage.drainProgressLine.empty`,{when:Fe(t.estimatedEmptyAtMs)})]})]})}var Le=[`ok`,`warn`,`critical`];function Re(e){return e>=.95?`critical`:e>=.85?`warn`:`ok`}function ze(e){return Math.min(1,Math.max(0,e))}function q(e){let{availableBytes:t,totalBytes:n}=e;if(n===null||n<=0||t===null)return null;let r=ze((n-t)/n);return{fraction:r,severity:Re(r),recordingsFraction:ze(e.usedBytes/n),freeBytes:t,totalBytes:n}}function Be(e){if(e.length===0)return null;let t=0,n=0,r=0,i=0,a=null;for(let o of e){let e=q(o);if(e===null){n+=1;continue}t+=1,r+=e.totalBytes,i+=e.freeBytes,(a===null||Le.indexOf(e.severity)>Le.indexOf(a))&&(a=e.severity)}return{knownVolumes:t,unknownVolumes:n,totalBytes:r,freeBytes:i,severity:a}}function J(e){return Math.min(1,Math.max(0,e))}function Y(e){return Math.round(J(e)*1e3)/10}function X(e){return`${String(Math.round(J(e)*100))}%`}function Ve(e,t,n={}){let{totalBytes:r,availableBytes:i}=e;if(r===null||r<=0||i===null){let e=n.ownedBytes===void 0||n.ownedBytes===null||!Number.isFinite(n.ownedBytes)||n.ownedBytes<0?null:N(n.ownedBytes);return{kind:`unknown`,owned:e,summary:e===null?j.t(`helpers.locationCapacityBar.unknownSummary`):j.t(`helpers.locationCapacityBar.unknownSummaryOwned`,{size:e})}}let a=Math.min(Math.max(i,0),r),o=r-a,s=t===null||t<=0?0:t,c=Math.min(s,a),l=s>a,u=a-c,d=n.ownedBytes,f=d==null||!Number.isFinite(d)||d<0?null:Math.min(d,o),p=o-(f??0),m=q({usedBytes:f??o,availableBytes:a,totalBytes:r}),h=m===null?J(o/r):m.fraction,g=m===null?Re(h):m.severity,_=f===null?null:m===null?J(f/r):m.recordingsFraction,v=n.cap??null,y=v===null?null:J((c+v.bytes)/r),b=v!==null&&f!==null&&f>v.bytes,x={total:N(r),freeTotal:N(a),freeTotalPercent:X(a/r),used:N(p),usedPercent:X(p/r),free:N(u),freePercent:X(u/r),reserve:s===0?null:j.t(`helpers.locationCapacityBar.reserveKept`,{size:N(s)}),owned:f===null||_===null?null:j.t(`helpers.locationCapacityBar.ownedOfRecordings`,{size:N(f),percent:X(_)}),cap:v===null?null:v.reason===`drain`?j.t(`helpers.locationCapacityBar.capDrain`,{size:N(v.bytes)}):j.t(`helpers.locationCapacityBar.capCap`,{size:N(v.bytes)})},S=[j.t(`helpers.locationCapacityBar.summaryFree`,{free:x.freeTotal,total:x.total,percent:x.freeTotalPercent}),x.owned===null?null:j.t(`helpers.locationCapacityBar.summaryOwned`,{owned:x.owned}),x.reserve===null?null:l?j.t(`helpers.locationCapacityBar.summaryReserveShort`,{reserve:x.reserve}):x.reserve,x.cap===null?null:b?j.t(`helpers.locationCapacityBar.summaryCapBelow`,{cap:x.cap}):x.cap].filter(e=>e!==null).join(` · `),C=[];return c>0&&C.push({segment:`reserve`,label:j.t(`helpers.locationCapacityBar.legendKeptFree`),value:N(s),alarming:l}),x.owned!==null&&C.push({segment:`owned`,label:j.t(`helpers.locationCapacityBar.legendCamstack`),value:x.owned,alarming:!1}),C.push({segment:`used`,label:f===null?j.t(`helpers.locationCapacityBar.legendUsed`):j.t(`helpers.locationCapacityBar.legendOtherData`),value:`${x.used} (${x.usedPercent})`,alarming:g===`critical`}),C.push({segment:`free`,label:j.t(`helpers.locationCapacityBar.legendFree`),value:`${x.free} (${x.freePercent})`,alarming:l}),v!==null&&C.push({segment:`cap`,label:v.reason===`drain`?j.t(`helpers.locationCapacityBar.legendDrainTarget`):j.t(`helpers.locationCapacityBar.legendCap`),value:j.t(`helpers.locationCapacityBar.legendCapValue`,{size:N(v.bytes)}),alarming:b}),{kind:`known`,severity:g,legend:C,segments:{reservePercent:Y(c/r),ownedPercent:f===null?null:Y(f/r),usedPercent:Y(p/r),freePercent:Y(u/r),capPercent:y===null?null:Y(y)},labels:x,reserveExceedsFree:l,capBelowOwned:b,summary:S}}var He={ok:`bg-primary`,warn:`bg-amber-500`,critical:`bg-danger`},Z={reserve:`bg-danger/40`,owned:`bg-foreground/50`,free:`bg-border`,cap:`bg-foreground`};function Ue(e,t){return e===`used`?He[t]:Z[e]}function We({location:t,ownedBytes:n}){let{t:i}=M(),a=t.capacity??null,o=xe(_e(t.config),a?.totalBytes??null),s=Ve({totalBytes:a?.totalBytes??null,availableBytes:a?.availableBytes??null},o,{ownedBytes:n??null,cap:Te(t.config,B(t))});return s.kind===`unknown`?r(`div`,{className:`text-[10px] text-foreground-subtle italic`,title:s.summary,children:s.owned===null?i(`storage.locationCapacityBar.capacityUnknown`,`Capacity unknown`):i(`storage.locationCapacityBar.capacityUnknownCamstackHolds`,`Capacity unknown · CamStack holds {{owned}}`,{owned:s.owned})}):e(`div`,{className:`mt-1 space-y-1`,title:s.summary,children:[e(`div`,{className:`relative flex h-2 w-full max-w-md overflow-hidden rounded-full bg-border`,children:[s.segments.reservePercent>0&&r(`div`,{className:Z.reserve,style:{width:`${String(s.segments.reservePercent)}%`}}),s.segments.ownedPercent!==null&&r(`div`,{className:Z.owned,style:{width:`${String(s.segments.ownedPercent)}%`}}),r(`div`,{className:He[s.severity],style:{width:`${String(s.segments.usedPercent)}%`}}),r(`div`,{className:Z.free,style:{width:`${String(s.segments.freePercent)}%`}}),s.segments.capPercent!==null&&r(`div`,{className:`absolute inset-y-0 w-px ${s.capBelowOwned?`bg-danger`:Z.cap}`,style:{left:`${String(s.segments.capPercent)}%`}})]}),r(`ul`,{className:`flex flex-wrap items-center gap-x-3 gap-y-0.5`,children:s.legend.map(t=>e(`li`,{className:`flex items-center gap-1`,children:[r(`span`,{"aria-hidden":`true`,className:`inline-block h-2 w-2 shrink-0 rounded-sm ${Ue(t.segment,s.severity)}`}),e(`span`,{className:`text-[10px] tabular-nums ${t.alarming?`text-danger`:`text-foreground-subtle`}`,children:[t.label,` `,t.value]})]},t.segment))})]})}var Ge={eventMedia:[`events`],recordingsLow:[`low`],recordings:[`high`,`mid`]},Ke={eventMedia:`pipeline-analytics`,recordingsLow:`recorder`,recordings:`recorder`},qe=`storage.discardLocation`,Je=`storage.discardLocationStatus`,Ye=`storage.discardLocationCancel`;function Xe(e){return Ge[e]??null}function Ze(e){return Ke[e]??null}function Qe(e){return!V(B(e))}function $e(e,t){return Xe(e.type)===null||!Qe(e)?!1:t.some(t=>t.id!==e.id&&V(B(t)))}var et=new Set([`idle`,`scanning`,`wiping-fs`,`wiping-db`,`cascading`,`complete`,`cancelled`,`error`]);function Q(e){return typeof e==`number`&&Number.isFinite(e)?e:null}function $(e){return typeof e==`string`?e:null}function tt(e){if(typeof e!=`object`||!e)return null;let t=e;if(typeof t.running!=`boolean`)return null;let n=t.phase;if(typeof n!=`string`||!et.has(n))return null;let r=Q(t.camerasTotal),i=Q(t.camerasDone),a=Q(t.foldersRemoved),o=Q(t.dbRowsDeleted),s=Q(t.ownersCascaded);return r===null||i===null||a===null||o===null||s===null?null:{running:t.running,locationId:$(t.locationId),jobId:$(t.jobId),phase:n,camerasTotal:r,camerasDone:i,foldersRemoved:a,dbRowsDeleted:o,ownersCascaded:s,detail:$(t.detail)??``,startedAtMs:Q(t.startedAtMs),finishedAtMs:Q(t.finishedAtMs),error:$(t.error)}}function nt(e){if(e.phase===`complete`)return 100;if(e.phase===`cancelled`||e.phase===`error`||e.phase===`idle`)return e.camerasTotal>0?Math.min(99,Math.round(e.camerasDone/e.camerasTotal*100)):0;if(e.camerasTotal>0){let t=e.camerasDone/e.camerasTotal*85;return e.phase===`wiping-db`?Math.min(95,Math.round(t+8)):e.phase===`cascading`?Math.min(99,Math.round(t+12)):Math.min(85,Math.round(t))}return e.phase===`scanning`?2:5}o();var rt=2e3;function it({location:e,siblings:t}){return $e(e,t)?r(at,{location:e}):null}function at({location:t}){let{t:n}=M(),o=E(),s=O(),c=Ze(t.type),[l,u]=a(null),[d,f]=a(null),[m,g]=a(!1);if(i(()=>{if(c===null)return;let e=!1,t=async()=>{try{let t=await s.mutateAsync({addonId:c,action:Je,input:{}});if(e)return;u(tt(t))}catch{}};t();let n=setInterval(()=>void t(),rt);return()=>{e=!0,clearInterval(n)}},[c,t.id]),c===null)return null;let _=l!==null&&l.locationId===t.id,v=_&&l.running,y=_&&l.phase!==`idle`,b=async()=>{if(await o({title:n(`storage.locationDiscardControl.discardLeftoversOn`,`Discard leftovers on "{{displayName}}"?`,{displayName:t.displayName}),message:n(`storage.locationDiscardControl.permanentlyDeletesLeftoverFilesAnd`,`Permanently deletes leftover files and records on this location. Other locations are not affected. This cannot be undone and may take hours.`),confirmLabel:n(`storage.locationDiscardControl.discardLeftovers`,`Discard leftovers`),variant:`danger`})){f(null),g(!0);try{await s.mutateAsync({addonId:c,action:qe,input:{locationId:t.id}}),u(tt(await s.mutateAsync({addonId:c,action:Je,input:{}})))}catch(e){f(e instanceof Error?e.message:String(e))}finally{g(!1)}}},x=async()=>{try{await s.mutateAsync({addonId:c,action:Ye,input:{}})}catch(e){f(e instanceof Error?e.message:String(e))}};return e(`div`,{className:`flex flex-col gap-1 min-w-[9rem] max-w-[16rem]`,children:[v?e(`button`,{type:`button`,onClick:()=>void x(),className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-danger border border-danger/40 hover:bg-danger/10`,children:[r(p,{className:`h-3 w-3`}),n(`common.cancel`,`Cancel`)]}):e(`button`,{type:`button`,onClick:()=>void b(),disabled:m,title:n(`storage.locationDiscardControl.permanentlyDeleteLeftoverFilesOn`,`Permanently delete leftover files on this location. Other locations are not affected.`),className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-danger border border-danger/40 hover:bg-danger/10 disabled:opacity-50`,children:[m?r(h,{className:`h-3 w-3 animate-spin`}):r(S,{className:`h-3 w-3`}),n(`storage.locationDiscardControl.discardLeftovers`,`Discard leftovers`)]}),y&&l!==null&&e(`div`,{className:`space-y-0.5`,children:[r(`div`,{className:`h-1 rounded bg-border overflow-hidden`,children:r(`div`,{className:`h-full bg-primary transition-[width] duration-300`,style:{width:`${nt(l)}%`}})}),e(`p`,{className:`text-[10px] text-foreground-subtle leading-tight`,children:[l.phase,l.camerasTotal>0?` · ${n(`storage.locationDiscardControl.camsProgress`,{done:l.camerasDone,total:l.camerasTotal})}`:``,l.dbRowsDeleted>0?` · ${n(`storage.locationDiscardControl.rowsDeleted`,{count:l.dbRowsDeleted})}`:``,l.detail?` · ${l.detail}`:``]})]}),(d||_&&l?.error)&&r(`p`,{className:`text-[10px] text-danger leading-tight`,children:d??l?.error})]})}o();var ot={active:l,readonly:x,drain:C,disabled:y},st={active:`border-success/30 text-success hover:bg-success/10`,readonly:`border-border text-foreground-subtle hover:text-foreground hover:bg-primary/10`,drain:`border-warning/40 text-warning hover:bg-warning/10`,disabled:`border-danger/40 text-danger hover:bg-danger/10`};function ct({mode:t,open:n,onToggle:i}){let{t:a}=M(),o=U(t),s=ot[t];return e(`button`,{type:`button`,"aria-expanded":n,"aria-label":a(`storage.locationModeSelector.locationState`,`Location state`),onClick:i,title:o.consequence,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium border ${st[t]}`,children:[r(s,{className:`h-3 w-3`}),o.label,r(_,{className:`h-3 w-3 ${n?`rotate-180`:``}`})]})}function lt({mode:t,blockedReasons:n,onSelect:a,onDismiss:o}){let{t:s}=M();return i(()=>{let e=e=>{e.key===`Escape`&&o()};return window.addEventListener(`keydown`,e),()=>{window.removeEventListener(`keydown`,e)}},[o]),e(`div`,{className:`w-full basis-full rounded-lg border border-border bg-background p-1`,role:`group`,"aria-label":s(`storage.locationModeSelector.locationStateChoices`,`Location state choices`),children:[e(`div`,{className:`flex items-center justify-between px-2 py-1`,children:[r(`span`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:s(`storage.locationModeSelector.locationState`,`Location state`)}),r(`button`,{type:`button`,"aria-label":s(`storage.locationModeSelector.closeLocationStateChoices`,`Close location state choices`),onClick:o,className:`text-foreground-subtle hover:text-foreground`,children:r(p,{className:`h-3 w-3`})})]}),H.map(i=>{let c=n[i.mode],l=c!==``,u=ot[i.mode],d=i.mode===t;return e(`button`,{type:`button`,role:`radio`,"aria-checked":d,"aria-label":i.label,disabled:l,onClick:()=>{l||(o(),d||a(i.mode))},className:`flex w-full flex-col items-start gap-0.5 rounded px-2 py-1.5 text-left ${l?`cursor-not-allowed opacity-60`:d?`bg-primary/10`:`hover:bg-primary/5`}`,children:[e(`span`,{className:`flex items-center gap-1.5 text-[11px] font-medium text-foreground`,children:[r(u,{className:`h-3 w-3`}),i.label,d&&r(`span`,{className:`text-[9px] uppercase text-primary`,children:s(`common.current`)})]}),r(`span`,{className:`text-[10px] leading-snug text-foreground-subtle`,children:i.consequence}),l&&r(`span`,{className:`text-[10px] leading-snug text-warning`,children:c})]},i.mode)})]})}o();function ut(e){let t=e.basePath;if(typeof t==`string`&&t.length>0)return t;let n=Object.keys(e);return n.length===0?``:n.join(`, `)}function dt({location:t,onEdit:n,onDelete:i,onSetMode:o,blockedReasons:s,canDelete:c,siblings:l=[],drain:f,ownedBytes:p}){let{t:m}=M(),[h,g]=a(!1),_=ut(t.config),v=B(t);return e(`div`,{className:`flex flex-wrap items-start gap-x-3 gap-y-2 px-3 py-2 border-t border-border first:border-t-0 hover:bg-primary/5`,children:[e(`div`,{className:`flex items-start gap-2 min-w-0 flex-1 basis-72`,children:[r(`div`,{className:`shrink-0 sm:w-32`,"data-testid":`location-badge-slot`,children:r(`span`,{className:`inline-block text-[10px] uppercase tracking-wide text-foreground-subtle bg-background border border-border rounded px-1.5 py-0.5 font-mono`,children:t.providerId})}),e(`div`,{className:`min-w-0 flex-1`,children:[r(`div`,{className:`text-xs font-medium text-foreground truncate`,children:t.displayName}),_&&r(`div`,{className:`text-[10px] text-foreground-subtle truncate font-mono`,children:_}),r(We,{location:t,ownedBytes:p??null}),f!==void 0&&r(Ie,{drain:f})]})]}),e(`div`,{className:`flex flex-wrap items-center gap-1 shrink-0`,children:[r(it,{location:t,siblings:l}),r(ct,{mode:v,open:h,onToggle:()=>{g(e=>!e)}}),e(`button`,{onClick:()=>n(t),className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-foreground-subtle border border-border hover:text-foreground hover:bg-primary/10`,children:[r(u,{className:`h-3 w-3`}),m(`common.edit`,`Edit`)]}),c&&r(`button`,{onClick:()=>i(t),className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-danger hover:bg-danger/10`,title:m(`storage.locationCard.deleteLocation`,`Delete location`),children:r(d,{className:`h-3 w-3`})})]}),h&&r(lt,{mode:v,blockedReasons:s,onSelect:e=>o(t,e),onDismiss:()=>{g(!1)}})]})}o();function ft({type:n,displayName:i,description:a,cardinality:o,locations:s,onAdd:l,onEdit:u,onDelete:d,onSetMode:p,ownedBytesById:h,drainById:g}){let{t:_}=M(),v=t(()=>{let e=[...s];return e.sort((e,t)=>{let n=V(B(e));return n===V(B(t))?e.displayName.localeCompare(t.displayName):n?-1:1}),e},[s]);return e(T,{headingId:`storage-location-${n}`,title:i,icon:f,testId:`storage-location-group-${n}`,actions:o===`multi`?e(w,{size:`sm`,type:`button`,onClick:()=>l(n),children:[r(m,{className:`h-3 w-3`}),_(`common.add`,`Add`)]}):void 0,children:[e(`div`,{className:`${c} space-y-2`,children:[e(`div`,{className:`space-y-0.5`,children:[r(`span`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle bg-background border border-border rounded px-1.5 py-0.5 font-mono`,children:n}),a!==void 0&&a!==``&&r(`p`,{className:`text-[11px] leading-relaxed text-foreground-subtle`,children:a}),o===`single`&&r(`p`,{className:`text-[10px] text-foreground-subtle italic`,children:_(`storage.locationGroup.singleOneLocationPerType`,`Single — one location per type. Edit the existing entry; it can't be split.`)})]}),v.length===0&&r(`div`,{className:`py-2 text-center text-[11px] text-foreground-subtle italic`,children:o===`multi`?_(`storage.locationGroup.noLocationRegisteredClickAdd`,`No location registered. Click "Add" to register one.`):_(`storage.locationGroup.noLocationRegisteredYetShould`,`No location registered yet — should be auto-seeded at next boot.`)})]}),v.length>0&&r(`div`,{className:`border-t border-border`,children:v.map(e=>r(dt,{location:e,cardinality:o,canDelete:pe(e,v,o),onEdit:u,onDelete:d,onSetMode:p,blockedReasons:fe(e,v),ownedBytes:h?.get(e.id)??null,drain:Me(Ne(e),g?.get(e.id)),siblings:v},e.id))})]})}var pt=[`recordings`,`recordingsLow`];function mt(e){return e.locationIds!==void 0&&e.locationIds.length>0?e.locationIds:e.locationId===null?[]:[e.locationId]}function ht(e,t){if(t===void 0||!pt.includes(e.type))return null;let n=t.find(t=>mt(t).includes(e.id));return n===void 0||!Number.isFinite(n.usedBytes)||n.usedBytes<0?null:n.usedBytes}function gt(e,t){let n=new Map;for(let r of e){let e=ht(r,t);e!==null&&n.set(r.id,e)}return n}export{Ae as a,U as c,Be as i,ue as l,ft as n,De as o,q as r,he as s,gt as t,z as u};
|
|
1
|
+
import{C as e,K as t,R as n,S as r,V as i,Y as a,et as o,o 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{D as c,En as l,Fn as u,It as d,Sr as f,dt as p,kn as m,or as h,ot as g,xi as _,yi as v,zr as y}from"./player-overlays-Dbv95cvz.js";import{ia as b}from"./client-DvJxGh2F.js";import{t as x}from"./archive-Brq5E-qM.js";import{t as S}from"./eraser-Bs0PJaPY.js";import{t as C}from"./hard-drive-download-iRJR_Xj9.js";import{Jl as ee,Kr as w,Sn as T,Wr as E,_r as D,bt as te,hr as ne,mi as O,mr as re,ou as ie,pr as ae,vr as k,yr as A}from"./src-DntJrWmU.js";import{t as j}from"./i18n-D0o08mg-.js";import{t as M}from"./useTranslation-BJr-n0es.js";import{P as oe,lr as se}from"./index-D_Tm4B7S.js";import{t as N}from"./format-size-DIxKXxtj.js";o();function P(e){let t=e.trim().toLowerCase();return t.length===0?``:t.replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``)}function F(e,t){let n=P(t);return`${e}:${n.length>0?n:`default`}`}var I=new Set([`proc`,`sys`,`dev`,`run`,`boot`,`lost+found`,`snap`,`bin`,`sbin`,`lib`,`lib32`,`lib64`,`libx32`,`usr`,`etc`,`var`,`opt`,`tmp`,`srv`,`root`,`System`,`Library`,`Applications`,`cores`,`private`]),L=[`recordings`,`data`,`mnt`,`media`,`Volumes`];function R(e){let t=L.findIndex(t=>t===`recordings`?e.startsWith(t):e===t);return t===-1?L.length:t}function ce(e){return e.filter(e=>!e.name.startsWith(`.`)&&!I.has(e.name)).toSorted((e,t)=>{let n=R(e.name)-R(t.name);return n===0?e.name.localeCompare(t.name):n}).map(e=>e.path)}function le({nodeId:t,value:o,onChange:s}){let{t:c}=M(),l=g().trpcClient,[u,d]=a([]),[f,p]=a(o),[m,h]=a(null),[_,v]=a(null),[y,b]=a(``),x=n(async(e,n)=>{v(null);try{let r=await l.filesystemBrowse.browse.query({nodeId:t,path:e});h(r),p(r.path),n&&s(r.path)}catch(e){v(e instanceof Error?e.message:`browse failed`)}},[l,t,s]);i(()=>{p(o),(async()=>{let e=await l.filesystemBrowse.browse.query({nodeId:t,path:`/`}).then(e=>e).catch(()=>null);if(e){d(ce(e.entries)),await x(o.startsWith(`/`)?o:`/`,!1);return}try{let e=await l.filesystemBrowse.listAllowedRoots.query({nodeId:t});d(e),await x(o&&e.some(e=>o.startsWith(e))?o:e[0]??``,!1)}catch(e){d([]),h(null),v(e instanceof Error&&/not available on node/i.test(e.message)?`This node can't be browsed remotely. Enter the path manually.`:e instanceof Error?e.message:`browse unavailable`)}})()},[t]);let S=async()=>{if(!(!y.trim()||!m)){v(null);try{let e=`${m.path.replace(/\/+$/,``)}/${y.trim()}`;await l.filesystemBrowse.createDir.mutate({nodeId:t,path:e}),b(``),await x(m.path,!0)}catch(e){v(e instanceof Error?e.message:`create failed`)}}},C=e=>`${(e/1e9).toFixed(1)} GB`;return e(`div`,{className:`space-y-2 rounded border border-border p-2`,children:[r(`div`,{className:`flex flex-wrap gap-1`,children:u.map(e=>r(`button`,{onClick:()=>void x(e,!0),className:`rounded border border-border px-2 py-0.5 text-[10px] font-mono hover:border-primary/40`,children:e},e))}),r(`input`,{value:f,onChange:e=>{p(e.target.value),s(e.target.value)},placeholder:`/absolute/path`,className:`w-full rounded border border-border bg-background px-2 py-1 text-[11px] font-mono`}),m&&r(`div`,{className:`text-[10px] text-foreground-subtle`,children:c(`storage.pathBrowser.free`,{free:C(m.freeBytes),total:C(m.totalBytes)})}),r(`div`,{className:`max-h-40 space-y-0.5 overflow-y-auto`,children:m?.entries.map(t=>e(`button`,{onClick:()=>void x(t.path,!0),className:`block w-full truncate rounded px-2 py-1 text-left text-xs hover:bg-primary/5`,children:[`📁 `,t.name]},t.path))}),e(`div`,{className:`flex gap-1`,children:[r(`input`,{value:y,onChange:e=>b(e.target.value),placeholder:c(`storage.pathBrowser.newFolder`,`new folder`),className:`flex-1 rounded border border-border bg-background px-2 py-1 text-xs`}),r(`button`,{onClick:()=>void S(),className:`rounded border border-border px-2 py-1 text-xs hover:border-primary/40`,children:c(`storage.pathBrowser.create`,`Create`)})]}),_&&r(`div`,{className:`text-[10px] text-red-400`,children:_})]})}o();function z({initialType:n,onClose:i,onCreated:o}){let{t:c}=M(),l=s(),u=g().trpcClient,[d,f]=a(`picker`),[p,m]=a(n),[_,y]=a(null),[b,x]=a({}),[S,C]=a(``),[w,T]=a(null),[E,D]=a(!1),[O,j]=a(`hub`),[N,P]=a(null),[I,L]=a(!1),R=e=>x(t=>({...t,basePath:e})),ce=typeof b.basePath==`string`?b.basePath:``,z=ee(),B=t(()=>{let e=z.data;return Array.isArray(e)?e:[]},[z.data]),V=z.isLoading,H=ie({onSuccess:()=>{l.invalidateQueries({queryKey:[[`storage`,`listLocations`]]}),o()}}),U=t(()=>w!==null&&w.length>0?w:F(p,S),[p,S,w]),ue=async()=>{if(_){L(!0),P(null);try{P(await(e=>u.storage.testConfig.query(e))({providerId:_.providerId,config:b}))}catch(e){P({ok:!1,error:e instanceof Error?e.message:String(e)})}finally{L(!1)}}};return r(ae,{open:!0,onOpenChange:e=>!e&&i(),children:e(ne,{width:`md`,placement:`sheet-on-mobile`,scroll:`body`,children:[e(k,{children:[r(A,{children:{picker:`Add Location — Pick provider`,config:`Add Location — ${_?.displayName??``}`,naming:`Add Location — Name`}[d]}),e(`p`,{className:`text-xs text-foreground-subtle`,children:[c(`storage.addLocationWizard.type`,`Type:`),` `,r(`span`,{className:`font-mono`,children:p})]})]}),e(re,{children:[d===`picker`&&e(`div`,{className:`space-y-2`,children:[V&&r(`div`,{className:`text-xs text-foreground-subtle animate-pulse`,children:c(`storage.addLocationWizard.loadingProviders`,`Loading providers…`)}),!V&&B.length===0&&r(`div`,{className:`rounded border border-border bg-background px-3 py-4 text-center text-xs text-foreground-subtle`,children:r(se,{i18nKey:`storage.addLocationWizard.noProvider`,values:{type:p},components:{code:r(`code`,{className:`font-mono`})}})}),B.map(t=>e(`button`,{onClick:()=>{y(t),f(`config`)},className:`flex w-full items-center gap-3 rounded-lg border border-border bg-background p-3 text-left hover:border-primary/40 hover:bg-primary/5 transition-colors`,children:[e(`div`,{className:`flex-1 min-w-0`,children:[r(`p`,{className:`text-xs font-semibold text-foreground`,children:t.displayName}),r(`p`,{className:`text-[10px] text-foreground-subtle font-mono mt-0.5 truncate`,children:t.providerId})]}),r(v,{className:`h-4 w-4 text-foreground-subtle flex-shrink-0`})]},t.providerId))]}),d===`config`&&_&&e(`div`,{className:`space-y-3`,children:[r(oe,{schema:_.configSchema,values:b,onChange:x}),_.nodeLocal&&e(`div`,{className:`space-y-2`,children:[r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:c(`storage.addLocationWizard.node`,`Node`)}),r(te,{selectedNodeId:O,onSelect:j,alwaysShow:!0}),r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:c(`storage.addLocationWizard.path`,`Path`)}),r(le,{nodeId:O,value:ce,onChange:R})]}),N&&r(`div`,{className:`rounded border px-3 py-2 text-[11px] ${N.ok?`border-success/30 bg-success/5 text-success`:`border-danger/30 bg-danger/5 text-danger`}`,children:N.ok?c(`storage.addLocationWizard.connectionOk`,`Connection OK.`):c(`storage.addLocationWizard.testFailed`,`Test failed: {{value1}}`,{value1:N.error??`unknown error`})}),e(`div`,{className:`flex items-center justify-between pt-1`,children:[r(`button`,{onClick:()=>f(`picker`),className:`rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground`,children:c(`common.back`,`Back`)}),e(`div`,{className:`flex items-center gap-2`,children:[r(`button`,{onClick:()=>{ue()},disabled:I,className:`rounded border border-border px-3 py-1.5 text-xs text-foreground hover:bg-primary/10 disabled:opacity-50`,children:I?c(`storage.addLocationWizard.testing`,`Testing…`):c(`storage.addLocationWizard.testConnection`,`Test connection`)}),r(`button`,{onClick:()=>f(`naming`),className:`rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90`,children:c(`common.next`,`Next`)})]})]})]}),d===`naming`&&_&&e(`div`,{className:`space-y-3`,children:[e(`div`,{className:`space-y-1`,children:[r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:c(`storage.addLocationWizard.displayName`,`Display name`)}),r(`input`,{type:`text`,value:S,onChange:e=>C(e.target.value),placeholder:c(`storage.addLocationWizard.on`,`{{type}} on {{displayName}}`,{type:p,displayName:_.displayName}),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`})]}),e(`div`,{className:`space-y-1`,children:[e(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:[c(`storage.addLocationWizard.idLabel`),` `,r(`span`,{className:`lowercase tracking-normal text-foreground-subtle`,children:c(`storage.addLocationWizard.autoDerivedOverrideIfNeeded`,`— auto-derived; override if needed`)})]}),r(`input`,{type:`text`,value:U,onChange:e=>T(e.target.value),placeholder:F(p,S),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground font-mono focus:outline-none focus:ring-1 focus:ring-primary`}),e(`p`,{className:`text-[10px] text-foreground-subtle`,children:[c(`storage.addLocationWizard.format`,`Format:`),` `,r(`code`,{className:`font-mono`,children:c(`storage.addLocationWizard.typeSlug`,`<type>:<slug>`)}),`. Lowercase letters, digits, and hyphens only.`]})]}),e(`label`,{className:`flex items-start gap-2 rounded border border-border bg-background px-3 py-2 cursor-pointer hover:bg-primary/5`,children:[r(`input`,{type:`checkbox`,checked:E,onChange:e=>D(e.target.checked),className:`accent-primary mt-0.5`}),e(`div`,{className:`space-y-0.5`,children:[r(`div`,{className:`text-xs font-medium text-foreground`,children:c(`storage.addLocationWizard.enableImmediately`,`Enable immediately`)}),r(`div`,{className:`text-[10px] text-foreground-subtle`,children:c(`storage.addLocationWizard.aDisabledLocationReceivesNo`,`A disabled location receives no writes until enabled — reads and age-based retention still work, nothing new lands here. Leave this off to register the disk now and start using it later.`)})]})]}),H.isError&&r(`div`,{className:`rounded border border-danger/30 bg-danger/5 text-danger px-3 py-2 text-[11px]`,children:H.error instanceof Error?H.error.message:String(H.error)}),e(`div`,{className:`flex items-center justify-between pt-1`,children:[r(`button`,{onClick:()=>f(`config`),className:`rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground`,children:c(`common.back`,`Back`)}),e(`div`,{className:`flex items-center gap-2`,children:[r(`button`,{onClick:()=>{m(n),y(null),x({}),C(``),T(null),D(!1),P(null),f(`picker`)},className:`rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground`,children:c(`common.reset`,`Reset`)}),e(`button`,{onClick:()=>{_&&H.mutate({id:U,type:p,displayName:S.trim(),providerId:_.providerId,config:b,enabled:E,nodeId:_.nodeLocal?O:void 0})},disabled:H.isPending||S.trim().length===0,className:`inline-flex items-center gap-1.5 rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50`,children:[H.isPending?r(h,{className:`h-3.5 w-3.5 animate-spin`}):null,H.isPending?c(`storage.addLocationWizard.saving`,`Saving…`):c(`common.save`,`Save`)]})]})]})]})]})]})})}function B(e){return b(e)}function V(e){return e===`active`}var H=[{mode:`active`,get label(){return j.t(`helpers.locationMode.activeLabel`)},get consequence(){return j.t(`helpers.locationMode.activeConsequence`)},requiresConfirmation:!1},{mode:`readonly`,get label(){return j.t(`helpers.locationMode.readonlyLabel`)},get consequence(){return j.t(`helpers.locationMode.readonlyConsequence`)},requiresConfirmation:!1},{mode:`drain`,get label(){return j.t(`helpers.locationMode.drainLabel`)},get consequence(){return j.t(`helpers.locationMode.drainConsequence`)},requiresConfirmation:!1},{mode:`disabled`,get label(){return j.t(`helpers.locationMode.disabledLabel`)},get consequence(){return j.t(`helpers.locationMode.disabledConsequence`)},requiresConfirmation:!0}];function U(e){return H.find(t=>t.mode===e)??H[0]}function ue(e){return U(e).requiresConfirmation}var de=`Blocked: this is the last location of its type still accepting writes — new data would have nowhere to go.`;function W(e,t,n){return V(n)||!V(B(e))||t.some(t=>t.id!==e.id&&V(B(t)))?{blocked:!1,reason:``}:{blocked:!0,reason:de}}function fe(e,t){return{active:W(e,t,`active`).reason,readonly:W(e,t,`readonly`).reason,drain:W(e,t,`drain`).reason,disabled:W(e,t,`disabled`).reason}}function pe(e,t,n){return!(n===`single`||t.length<=1||V(B(e))&&t.filter(e=>V(B(e))).length<=1)}function me(e){return e===`active`?{enabled:!0,readOnly:!1}:e===`readonly`?{enabled:!1,readOnly:!1}:{enabled:!1,readOnly:!0}}function he(e,t){let n={...t.config??e.config};t.mode!==void 0&&(me(t.mode).readOnly?n.readOnly=!0:delete n.readOnly);let r={id:e.id,type:e.type,displayName:t.displayName??e.displayName,providerId:e.providerId,config:n,isSystem:e.isSystem},i=t.nodeId??e.nodeId,a=i===void 0?r:{...r,nodeId:i};return t.mode===void 0?e.enabled===void 0?a:{...a,enabled:e.enabled}:{...a,mode:t.mode,enabled:me(t.mode).enabled}}var ge=1024**3;function G(e){return typeof e==`number`&&Number.isFinite(e)?e:null}function _e(e){let t=G(e.minFreeGb);if(t!==null)return{unit:`gb`,value:t};let n=G(e.minFreePercent);return n===null?{unit:`percent`,value:null}:{unit:`percent`,value:n}}function ve(e,t){return G(e[t===`gb`?`minFreeGb`:`minFreePercent`])}function ye(e,t){let n={...e};return delete n.minFreePercent,delete n.minFreeGb,t.value===null?n:t.unit===`gb`?{...n,minFreeGb:t.value}:{...n,minFreePercent:t.value}}function be(e,t){let n=e.trim();if(n===``)return null;let r=Number(n);return Number.isFinite(r)?t===`percent`?Math.min(100,Math.max(0,r)):Math.max(0,r):null}function xe(e,t,n=10){if(e.unit===`gb`&&e.value!==null)return e.value*ge;let r=e.value??n;return t===null||t<=0?null:t*Math.min(100,Math.max(0,r))/100}function Se(e){return e===`gb`?j.t(`helpers.locationProtection.unitGb`):j.t(`helpers.locationProtection.unitPercent`)}function Ce(e,t=10){let n=e.value===null?j.t(`helpers.locationProtection.targetDefault`,{percent:String(t)}):e.unit===`gb`?j.t(`helpers.locationProtection.targetGb`,{value:String(e.value)}):j.t(`helpers.locationProtection.targetPercent`,{value:String(e.value)});return j.t(`helpers.locationProtection.helpText`,{target:n,percent:String(t)})}function we(e){return G(e.maxUsedGb)}function Te(e,t){let n=G(e.maxUsedGb);return n===null||n<0?null:{bytes:n*ge,reason:t===`drain`?`drain`:`legacy`}}o();function Ee({config:t,defaultPercent:n=10,onChange:i}){let{t:o}=M(),[s,c]=a(()=>_e(t).unit),l=ve(t,s),u={unit:s,value:l},d=we(t),f=e=>{c(e),i(ye(t,{unit:e,value:null}))},p=e=>{i(ye(t,{unit:s,value:be(e,s)}))};return e(`div`,{className:`space-y-1`,children:[r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:o(`storage.protectionPolicyField.protectedFreeSpace`,`Protected free space`)}),e(`div`,{className:`flex items-center gap-2`,children:[e(`select`,{"aria-label":o(`storage.protectionPolicyField.protectionUnit`,`Protection unit`),value:s,onChange:e=>{f(e.target.value===`gb`?`gb`:`percent`)},className:`rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`,children:[r(`option`,{value:`percent`,children:o(`storage.protectionPolicyField.ofTheVolume`,`% of the volume`)}),r(`option`,{value:`gb`,children:o(`storage.protectionPolicyField.gbOfFreeSpace`,`GB of free space`)})]}),r(`input`,{type:`number`,"aria-label":Se(s),min:0,max:s===`percent`?100:void 0,value:l===null?``:l,placeholder:s===`percent`?String(n):o(`common.defaultWord`),onChange:e=>{p(e.target.value)},className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`})]}),r(`p`,{className:`text-[10px] text-foreground-subtle`,children:Ce(u,n)}),d!==null&&r(`p`,{className:`text-[10px] text-foreground-subtle italic`,children:o(`storage.protectionPolicyField.legacyMax`,{gb:d})})]})}o();function De({location:n,onClose:i,onSaved:o}){let{t:c}=M(),l=s(),u=g().trpcClient,[d,f]=a({...n.config}),[p,m]=a(n.displayName),[_,v]=a(null),[y,b]=a(!1),x=ee(),S=t(()=>{let e=x.data;return Array.isArray(e)?e.find(e=>e.providerId===n.providerId)??null:null},[x.data,n.providerId]),C=ie({onSuccess:()=>{l.invalidateQueries({queryKey:[[`storage`,`listLocations`]]}),o()}}),T=S?.shouldSaveDiskSpace===!0,E=S?.nodeLocal===!0,[O,j]=a(typeof n.nodeId==`string`?n.nodeId:`hub`),N=typeof d.basePath==`string`?d.basePath:``,P=e=>f(t=>({...t,basePath:e})),F=S?.minFreePercent??10,I=async()=>{b(!0),v(null);try{v(await(e=>u.storage.testConfig.query(e))({providerId:n.providerId,locationId:n.id,config:d}))}catch(e){v({ok:!1,error:e instanceof Error?e.message:String(e)})}finally{b(!1)}};return r(ae,{open:!0,onOpenChange:e=>!e&&i(),children:e(ne,{width:`md`,placement:`sheet-on-mobile`,scroll:`body`,children:[e(k,{children:[r(A,{children:c(`storage.editLocationModal.title`,{name:n.displayName})}),e(`p`,{className:`text-xs text-foreground-subtle`,children:[r(`span`,{className:`font-mono`,children:n.id}),` ·`,` `,S?.displayName??n.providerId]})]}),e(re,{className:`space-y-3`,children:[e(`div`,{className:`space-y-1`,children:[r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:c(`storage.editLocationModal.displayName`,`Display name`)}),r(`input`,{type:`text`,value:p,onChange:e=>m(e.target.value),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`})]}),S&&r(oe,{schema:S.configSchema,values:d,onChange:f}),E&&e(`div`,{className:`space-y-2`,children:[r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:c(`storage.editLocationModal.node`,`Node`)}),r(te,{selectedNodeId:O,onSelect:j,alwaysShow:!0}),r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:c(`storage.editLocationModal.path`,`Path`)}),r(le,{nodeId:O,value:N,onChange:P})]}),T&&r(Ee,{config:d,defaultPercent:F,onChange:f}),!S&&!x.isLoading&&r(`div`,{className:`rounded border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-[11px] text-amber-700 dark:text-amber-300`,children:r(se,{i18nKey:`storage.editLocationModal.providerGone`,values:{id:n.providerId},components:{code:r(`code`,{className:`font-mono`})}})}),_&&r(`div`,{className:`rounded border px-3 py-2 text-[11px] ${_.ok?`border-success/30 bg-success/5 text-success`:`border-danger/30 bg-danger/5 text-danger`}`,children:_.ok?c(`storage.editLocationModal.connectionOk`,`Connection OK.`):c(`storage.editLocationModal.testFailed`,`Test failed: {{value1}}`,{value1:_.error??`unknown error`})}),C.isError&&r(`div`,{className:`rounded border border-danger/30 bg-danger/5 text-danger px-3 py-2 text-[11px]`,children:C.error instanceof Error?C.error.message:String(C.error)})]}),e(D,{className:`justify-between`,children:[r(w,{variant:`outline`,size:`sm`,onClick:i,children:c(`common.cancel`,`Cancel`)}),e(`div`,{className:`flex items-center gap-2`,children:[r(w,{variant:`outline`,size:`sm`,onClick:()=>{I()},disabled:y||!S,children:y?c(`storage.editLocationModal.testing`,`Testing…`):c(`storage.editLocationModal.testConnection`,`Test connection`)}),e(w,{size:`sm`,onClick:()=>{C.mutate(he(n,{displayName:p.trim(),config:d,nodeId:E?O:n.nodeId}))},disabled:C.isPending||p.trim().length===0,children:[C.isPending?r(h,{className:`h-3.5 w-3.5 animate-spin`}):null,C.isPending?c(`storage.editLocationModal.saving`,`Saving…`):c(`common.save`,`Save`)]})]})]})]})})}function Oe(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function K(e){return typeof e==`number`&&Number.isFinite(e)?e:null}function ke(e){if(!Oe(e))return null;let t=e.locationId;if(typeof t!=`string`||t.length===0)return null;let n=K(e.startedAtMs),r=K(e.startBytes),i=K(e.bytesRemaining);return n===null||r===null||i===null||typeof e.drained!=`boolean`?null:{locationId:t,startedAtMs:n,startBytes:r,bytesRemaining:i,drained:e.drained,estimatedEmptyAtMs:K(e.estimatedEmptyAtMs)}}function Ae(e){let t=new Map;if(!Array.isArray(e))return t;for(let n of e){let e=ke(n);e!==null&&t.set(e.locationId,e)}return t}function je(e){if(e.startBytes<=0||e.bytesRemaining>e.startBytes)return null;let t=e.startBytes-e.bytesRemaining;return Math.min(1,Math.max(0,t/e.startBytes))}function Me(e,t){return e?t===void 0?{kind:`unreported`}:t.drained||t.bytesRemaining<=0?{kind:`drained`}:{kind:`draining`,bytesRemaining:t.bytesRemaining,drainedFraction:je(t),estimatedEmptyAtMs:t.estimatedEmptyAtMs}:{kind:`idle`}}function Ne(e){return e.mode===`drain`?!0:e.config.readOnly===!0}function Pe(e){return`${(e/1024**3).toFixed(e>=100*1024**3?0:1)} GB`}function Fe(e){return new Date(e).toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`})}function Ie({drain:t}){let{t:n}=M();if(t.kind===`idle`)return null;if(t.kind===`unreported`)return r(`span`,{"data-testid":`drain-unreported`,className:`text-[10px] text-foreground-subtle`,title:n(`storage.drainProgressLine.thisLocationIsDrainingThe`,`This location is draining. The hub has not reported how much is left yet — either the drain has just been set, or this hub predates the drain-progress report.`),children:n(`storage.drainProgressLine.drainingRemainingNotReportedYet`,`Draining · remaining not reported yet`)});if(t.kind===`drained`)return r(`span`,{"data-testid":`drain-done`,className:`text-[10px] text-success`,title:n(`storage.drainProgressLine.everythingThatWasHereHas`,`Everything that was here has been moved. The location is still in drain mode — it receives no new writes until you change that.`),children:n(`storage.drainProgressLine.drainedNothingLeftToMove`,`Drained · nothing left to move`)});let i=t.drainedFraction===null?null:Math.round(t.drainedFraction*100);return e(`span`,{"data-testid":`drain-progress`,className:`flex items-center gap-1.5 text-[10px] text-foreground-subtle tabular-nums`,children:[i!==null&&r(`span`,{"data-testid":`drain-bar`,className:`inline-block h-1 w-10 rounded-full bg-border overflow-hidden`,role:`progressbar`,"aria-label":n(`storage.drainProgressLine.drainProgress`,`Drain progress`),"aria-valuenow":i,"aria-valuemin":0,"aria-valuemax":100,children:r(`span`,{className:`block h-full bg-warning`,style:{width:`${i}%`}})}),e(`span`,{children:[n(`storage.drainProgressLine.left`,{size:Pe(t.bytesRemaining)}),i!==null&&` · ${n(`storage.drainProgressLine.moved`,{percent:i})}`]}),t.estimatedEmptyAtMs===null?r(`span`,{"data-testid":`drain-eta-absent`,title:n(`storage.drainProgressLine.theDrainIsPacedBy`,`The drain is paced by how fast this class of data is still growing, and that has not been observed yet. There is no date to give.`),children:n(`storage.drainProgressLine.emptyTimeNotKnownYet`,`· empty time not known yet`)}):e(`span`,{"data-testid":`drain-eta`,children:[`·`,` `,n(`storage.drainProgressLine.empty`,{when:Fe(t.estimatedEmptyAtMs)})]})]})}var Le=[`ok`,`warn`,`critical`];function Re(e){return e>=.95?`critical`:e>=.85?`warn`:`ok`}function ze(e){return Math.min(1,Math.max(0,e))}function q(e){let{availableBytes:t,totalBytes:n}=e;if(n===null||n<=0||t===null)return null;let r=ze((n-t)/n);return{fraction:r,severity:Re(r),recordingsFraction:ze(e.usedBytes/n),freeBytes:t,totalBytes:n}}function Be(e){if(e.length===0)return null;let t=0,n=0,r=0,i=0,a=null;for(let o of e){let e=q(o);if(e===null){n+=1;continue}t+=1,r+=e.totalBytes,i+=e.freeBytes,(a===null||Le.indexOf(e.severity)>Le.indexOf(a))&&(a=e.severity)}return{knownVolumes:t,unknownVolumes:n,totalBytes:r,freeBytes:i,severity:a}}function J(e){return Math.min(1,Math.max(0,e))}function Y(e){return Math.round(J(e)*1e3)/10}function X(e){return`${String(Math.round(J(e)*100))}%`}function Ve(e,t,n={}){let{totalBytes:r,availableBytes:i}=e;if(r===null||r<=0||i===null){let e=n.ownedBytes===void 0||n.ownedBytes===null||!Number.isFinite(n.ownedBytes)||n.ownedBytes<0?null:N(n.ownedBytes);return{kind:`unknown`,owned:e,summary:e===null?j.t(`helpers.locationCapacityBar.unknownSummary`):j.t(`helpers.locationCapacityBar.unknownSummaryOwned`,{size:e})}}let a=Math.min(Math.max(i,0),r),o=r-a,s=t===null||t<=0?0:t,c=Math.min(s,a),l=s>a,u=a-c,d=n.ownedBytes,f=d==null||!Number.isFinite(d)||d<0?null:Math.min(d,o),p=o-(f??0),m=q({usedBytes:f??o,availableBytes:a,totalBytes:r}),h=m===null?J(o/r):m.fraction,g=m===null?Re(h):m.severity,_=f===null?null:m===null?J(f/r):m.recordingsFraction,v=n.cap??null,y=v===null?null:J((c+v.bytes)/r),b=v!==null&&f!==null&&f>v.bytes,x={total:N(r),freeTotal:N(a),freeTotalPercent:X(a/r),used:N(p),usedPercent:X(p/r),free:N(u),freePercent:X(u/r),reserve:s===0?null:j.t(`helpers.locationCapacityBar.reserveKept`,{size:N(s)}),owned:f===null||_===null?null:j.t(`helpers.locationCapacityBar.ownedOfRecordings`,{size:N(f),percent:X(_)}),cap:v===null?null:v.reason===`drain`?j.t(`helpers.locationCapacityBar.capDrain`,{size:N(v.bytes)}):j.t(`helpers.locationCapacityBar.capCap`,{size:N(v.bytes)})},S=[j.t(`helpers.locationCapacityBar.summaryFree`,{free:x.freeTotal,total:x.total,percent:x.freeTotalPercent}),x.owned===null?null:j.t(`helpers.locationCapacityBar.summaryOwned`,{owned:x.owned}),x.reserve===null?null:l?j.t(`helpers.locationCapacityBar.summaryReserveShort`,{reserve:x.reserve}):x.reserve,x.cap===null?null:b?j.t(`helpers.locationCapacityBar.summaryCapBelow`,{cap:x.cap}):x.cap].filter(e=>e!==null).join(` · `),C=[];return c>0&&C.push({segment:`reserve`,label:j.t(`helpers.locationCapacityBar.legendKeptFree`),value:N(s),alarming:l}),x.owned!==null&&C.push({segment:`owned`,label:j.t(`helpers.locationCapacityBar.legendCamstack`),value:x.owned,alarming:!1}),C.push({segment:`used`,label:f===null?j.t(`helpers.locationCapacityBar.legendUsed`):j.t(`helpers.locationCapacityBar.legendOtherData`),value:`${x.used} (${x.usedPercent})`,alarming:g===`critical`}),C.push({segment:`free`,label:j.t(`helpers.locationCapacityBar.legendFree`),value:`${x.free} (${x.freePercent})`,alarming:l}),v!==null&&C.push({segment:`cap`,label:v.reason===`drain`?j.t(`helpers.locationCapacityBar.legendDrainTarget`):j.t(`helpers.locationCapacityBar.legendCap`),value:j.t(`helpers.locationCapacityBar.legendCapValue`,{size:N(v.bytes)}),alarming:b}),{kind:`known`,severity:g,legend:C,segments:{reservePercent:Y(c/r),ownedPercent:f===null?null:Y(f/r),usedPercent:Y(p/r),freePercent:Y(u/r),capPercent:y===null?null:Y(y)},labels:x,reserveExceedsFree:l,capBelowOwned:b,summary:S}}var He={ok:`bg-primary`,warn:`bg-amber-500`,critical:`bg-danger`},Z={reserve:`bg-danger/40`,owned:`bg-foreground/50`,free:`bg-border`,cap:`bg-foreground`};function Ue(e,t){return e===`used`?He[t]:Z[e]}function We({location:t,ownedBytes:n}){let{t:i}=M(),a=t.capacity??null,o=xe(_e(t.config),a?.totalBytes??null),s=Ve({totalBytes:a?.totalBytes??null,availableBytes:a?.availableBytes??null},o,{ownedBytes:n??null,cap:Te(t.config,B(t))});return s.kind===`unknown`?r(`div`,{className:`text-[10px] text-foreground-subtle italic`,title:s.summary,children:s.owned===null?i(`storage.locationCapacityBar.capacityUnknown`,`Capacity unknown`):i(`storage.locationCapacityBar.capacityUnknownCamstackHolds`,`Capacity unknown · CamStack holds {{owned}}`,{owned:s.owned})}):e(`div`,{className:`mt-1 space-y-1`,title:s.summary,children:[e(`div`,{className:`relative flex h-2 w-full max-w-md overflow-hidden rounded-full bg-border`,children:[s.segments.reservePercent>0&&r(`div`,{className:Z.reserve,style:{width:`${String(s.segments.reservePercent)}%`}}),s.segments.ownedPercent!==null&&r(`div`,{className:Z.owned,style:{width:`${String(s.segments.ownedPercent)}%`}}),r(`div`,{className:He[s.severity],style:{width:`${String(s.segments.usedPercent)}%`}}),r(`div`,{className:Z.free,style:{width:`${String(s.segments.freePercent)}%`}}),s.segments.capPercent!==null&&r(`div`,{className:`absolute inset-y-0 w-px ${s.capBelowOwned?`bg-danger`:Z.cap}`,style:{left:`${String(s.segments.capPercent)}%`}})]}),r(`ul`,{className:`flex flex-wrap items-center gap-x-3 gap-y-0.5`,children:s.legend.map(t=>e(`li`,{className:`flex items-center gap-1`,children:[r(`span`,{"aria-hidden":`true`,className:`inline-block h-2 w-2 shrink-0 rounded-sm ${Ue(t.segment,s.severity)}`}),e(`span`,{className:`text-[10px] tabular-nums ${t.alarming?`text-danger`:`text-foreground-subtle`}`,children:[t.label,` `,t.value]})]},t.segment))})]})}var Ge={eventMedia:[`events`],recordingsLow:[`low`],recordings:[`high`,`mid`]},Ke={eventMedia:`pipeline-analytics`,recordingsLow:`recorder`,recordings:`recorder`},qe=`storage.discardLocation`,Je=`storage.discardLocationStatus`,Ye=`storage.discardLocationCancel`;function Xe(e){return Ge[e]??null}function Ze(e){return Ke[e]??null}function Qe(e){return!V(B(e))}function $e(e,t){return Xe(e.type)===null||!Qe(e)?!1:t.some(t=>t.id!==e.id&&V(B(t)))}var et=new Set([`idle`,`scanning`,`wiping-fs`,`wiping-db`,`cascading`,`complete`,`cancelled`,`error`]);function Q(e){return typeof e==`number`&&Number.isFinite(e)?e:null}function $(e){return typeof e==`string`?e:null}function tt(e){if(typeof e!=`object`||!e)return null;let t=e;if(typeof t.running!=`boolean`)return null;let n=t.phase;if(typeof n!=`string`||!et.has(n))return null;let r=Q(t.camerasTotal),i=Q(t.camerasDone),a=Q(t.foldersRemoved),o=Q(t.dbRowsDeleted),s=Q(t.ownersCascaded);return r===null||i===null||a===null||o===null||s===null?null:{running:t.running,locationId:$(t.locationId),jobId:$(t.jobId),phase:n,camerasTotal:r,camerasDone:i,foldersRemoved:a,dbRowsDeleted:o,ownersCascaded:s,detail:$(t.detail)??``,startedAtMs:Q(t.startedAtMs),finishedAtMs:Q(t.finishedAtMs),error:$(t.error)}}function nt(e){if(e.phase===`complete`)return 100;if(e.phase===`cancelled`||e.phase===`error`||e.phase===`idle`)return e.camerasTotal>0?Math.min(99,Math.round(e.camerasDone/e.camerasTotal*100)):0;if(e.camerasTotal>0){let t=e.camerasDone/e.camerasTotal*85;return e.phase===`wiping-db`?Math.min(95,Math.round(t+8)):e.phase===`cascading`?Math.min(99,Math.round(t+12)):Math.min(85,Math.round(t))}return e.phase===`scanning`?2:5}o();var rt=2e3;function it({location:e,siblings:t}){return $e(e,t)?r(at,{location:e}):null}function at({location:t}){let{t:n}=M(),o=E(),s=O(),c=Ze(t.type),[l,u]=a(null),[d,f]=a(null),[m,g]=a(!1);if(i(()=>{if(c===null)return;let e=!1,t=async()=>{try{let t=await s.mutateAsync({addonId:c,action:Je,input:{}});if(e)return;u(tt(t))}catch{}};t();let n=setInterval(()=>void t(),rt);return()=>{e=!0,clearInterval(n)}},[c,t.id]),c===null)return null;let _=l!==null&&l.locationId===t.id,v=_&&l.running,y=_&&l.phase!==`idle`,b=async()=>{if(await o({title:n(`storage.locationDiscardControl.discardLeftoversOn`,`Discard leftovers on "{{displayName}}"?`,{displayName:t.displayName}),message:n(`storage.locationDiscardControl.permanentlyDeletesLeftoverFilesAnd`,`Permanently deletes leftover files and records on this location. Other locations are not affected. This cannot be undone and may take hours.`),confirmLabel:n(`storage.locationDiscardControl.discardLeftovers`,`Discard leftovers`),variant:`danger`})){f(null),g(!0);try{await s.mutateAsync({addonId:c,action:qe,input:{locationId:t.id}}),u(tt(await s.mutateAsync({addonId:c,action:Je,input:{}})))}catch(e){f(e instanceof Error?e.message:String(e))}finally{g(!1)}}},x=async()=>{try{await s.mutateAsync({addonId:c,action:Ye,input:{}})}catch(e){f(e instanceof Error?e.message:String(e))}};return e(`div`,{className:`flex flex-col gap-1 min-w-[9rem] max-w-[16rem]`,children:[v?e(`button`,{type:`button`,onClick:()=>void x(),className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-danger border border-danger/40 hover:bg-danger/10`,children:[r(p,{className:`h-3 w-3`}),n(`common.cancel`,`Cancel`)]}):e(`button`,{type:`button`,onClick:()=>void b(),disabled:m,title:n(`storage.locationDiscardControl.permanentlyDeleteLeftoverFilesOn`,`Permanently delete leftover files on this location. Other locations are not affected.`),className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-danger border border-danger/40 hover:bg-danger/10 disabled:opacity-50`,children:[m?r(h,{className:`h-3 w-3 animate-spin`}):r(S,{className:`h-3 w-3`}),n(`storage.locationDiscardControl.discardLeftovers`,`Discard leftovers`)]}),y&&l!==null&&e(`div`,{className:`space-y-0.5`,children:[r(`div`,{className:`h-1 rounded bg-border overflow-hidden`,children:r(`div`,{className:`h-full bg-primary transition-[width] duration-300`,style:{width:`${nt(l)}%`}})}),e(`p`,{className:`text-[10px] text-foreground-subtle leading-tight`,children:[l.phase,l.camerasTotal>0?` · ${n(`storage.locationDiscardControl.camsProgress`,{done:l.camerasDone,total:l.camerasTotal})}`:``,l.dbRowsDeleted>0?` · ${n(`storage.locationDiscardControl.rowsDeleted`,{count:l.dbRowsDeleted})}`:``,l.detail?` · ${l.detail}`:``]})]}),(d||_&&l?.error)&&r(`p`,{className:`text-[10px] text-danger leading-tight`,children:d??l?.error})]})}o();var ot={active:l,readonly:x,drain:C,disabled:y},st={active:`border-success/30 text-success hover:bg-success/10`,readonly:`border-border text-foreground-subtle hover:text-foreground hover:bg-primary/10`,drain:`border-warning/40 text-warning hover:bg-warning/10`,disabled:`border-danger/40 text-danger hover:bg-danger/10`};function ct({mode:t,open:n,onToggle:i}){let{t:a}=M(),o=U(t),s=ot[t];return e(`button`,{type:`button`,"aria-expanded":n,"aria-label":a(`storage.locationModeSelector.locationState`,`Location state`),onClick:i,title:o.consequence,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium border ${st[t]}`,children:[r(s,{className:`h-3 w-3`}),o.label,r(_,{className:`h-3 w-3 ${n?`rotate-180`:``}`})]})}function lt({mode:t,blockedReasons:n,onSelect:a,onDismiss:o}){let{t:s}=M();return i(()=>{let e=e=>{e.key===`Escape`&&o()};return window.addEventListener(`keydown`,e),()=>{window.removeEventListener(`keydown`,e)}},[o]),e(`div`,{className:`w-full basis-full rounded-lg border border-border bg-background p-1`,role:`group`,"aria-label":s(`storage.locationModeSelector.locationStateChoices`,`Location state choices`),children:[e(`div`,{className:`flex items-center justify-between px-2 py-1`,children:[r(`span`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:s(`storage.locationModeSelector.locationState`,`Location state`)}),r(`button`,{type:`button`,"aria-label":s(`storage.locationModeSelector.closeLocationStateChoices`,`Close location state choices`),onClick:o,className:`text-foreground-subtle hover:text-foreground`,children:r(p,{className:`h-3 w-3`})})]}),H.map(i=>{let c=n[i.mode],l=c!==``,u=ot[i.mode],d=i.mode===t;return e(`button`,{type:`button`,role:`radio`,"aria-checked":d,"aria-label":i.label,disabled:l,onClick:()=>{l||(o(),d||a(i.mode))},className:`flex w-full flex-col items-start gap-0.5 rounded px-2 py-1.5 text-left ${l?`cursor-not-allowed opacity-60`:d?`bg-primary/10`:`hover:bg-primary/5`}`,children:[e(`span`,{className:`flex items-center gap-1.5 text-[11px] font-medium text-foreground`,children:[r(u,{className:`h-3 w-3`}),i.label,d&&r(`span`,{className:`text-[9px] uppercase text-primary`,children:s(`common.current`)})]}),r(`span`,{className:`text-[10px] leading-snug text-foreground-subtle`,children:i.consequence}),l&&r(`span`,{className:`text-[10px] leading-snug text-warning`,children:c})]},i.mode)})]})}o();function ut(e){let t=e.basePath;if(typeof t==`string`&&t.length>0)return t;let n=Object.keys(e);return n.length===0?``:n.join(`, `)}function dt({location:t,onEdit:n,onDelete:i,onSetMode:o,blockedReasons:s,canDelete:c,siblings:l=[],drain:f,ownedBytes:p}){let{t:m}=M(),[h,g]=a(!1),_=ut(t.config),v=B(t);return e(`div`,{className:`flex flex-wrap items-start gap-x-3 gap-y-2 px-3 py-2 border-t border-border first:border-t-0 hover:bg-primary/5`,children:[e(`div`,{className:`flex items-start gap-2 min-w-0 flex-1 basis-72`,children:[r(`div`,{className:`shrink-0 sm:w-32`,"data-testid":`location-badge-slot`,children:r(`span`,{className:`inline-block text-[10px] uppercase tracking-wide text-foreground-subtle bg-background border border-border rounded px-1.5 py-0.5 font-mono`,children:t.providerId})}),e(`div`,{className:`min-w-0 flex-1`,children:[r(`div`,{className:`text-xs font-medium text-foreground truncate`,children:t.displayName}),_&&r(`div`,{className:`text-[10px] text-foreground-subtle truncate font-mono`,children:_}),r(We,{location:t,ownedBytes:p??null}),f!==void 0&&r(Ie,{drain:f})]})]}),e(`div`,{className:`flex flex-wrap items-center gap-1 shrink-0`,children:[r(it,{location:t,siblings:l}),r(ct,{mode:v,open:h,onToggle:()=>{g(e=>!e)}}),e(`button`,{onClick:()=>n(t),className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-foreground-subtle border border-border hover:text-foreground hover:bg-primary/10`,children:[r(u,{className:`h-3 w-3`}),m(`common.edit`,`Edit`)]}),c&&r(`button`,{onClick:()=>i(t),className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-danger hover:bg-danger/10`,title:m(`storage.locationCard.deleteLocation`,`Delete location`),children:r(d,{className:`h-3 w-3`})})]}),h&&r(lt,{mode:v,blockedReasons:s,onSelect:e=>o(t,e),onDismiss:()=>{g(!1)}})]})}o();function ft({type:n,displayName:i,description:a,cardinality:o,locations:s,onAdd:l,onEdit:u,onDelete:d,onSetMode:p,ownedBytesById:h,drainById:g}){let{t:_}=M(),v=t(()=>{let e=[...s];return e.sort((e,t)=>{let n=V(B(e));return n===V(B(t))?e.displayName.localeCompare(t.displayName):n?-1:1}),e},[s]);return e(T,{headingId:`storage-location-${n}`,title:i,icon:f,testId:`storage-location-group-${n}`,actions:o===`multi`?e(w,{size:`sm`,type:`button`,onClick:()=>l(n),children:[r(m,{className:`h-3 w-3`}),_(`common.add`,`Add`)]}):void 0,children:[e(`div`,{className:`${c} space-y-2`,children:[e(`div`,{className:`space-y-0.5`,children:[r(`span`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle bg-background border border-border rounded px-1.5 py-0.5 font-mono`,children:n}),a!==void 0&&a!==``&&r(`p`,{className:`text-[11px] leading-relaxed text-foreground-subtle`,children:a}),o===`single`&&r(`p`,{className:`text-[10px] text-foreground-subtle italic`,children:_(`storage.locationGroup.singleOneLocationPerType`,`Single — one location per type. Edit the existing entry; it can't be split.`)})]}),v.length===0&&r(`div`,{className:`py-2 text-center text-[11px] text-foreground-subtle italic`,children:o===`multi`?_(`storage.locationGroup.noLocationRegisteredClickAdd`,`No location registered. Click "Add" to register one.`):_(`storage.locationGroup.noLocationRegisteredYetShould`,`No location registered yet — should be auto-seeded at next boot.`)})]}),v.length>0&&r(`div`,{className:`border-t border-border`,children:v.map(e=>r(dt,{location:e,cardinality:o,canDelete:pe(e,v,o),onEdit:u,onDelete:d,onSetMode:p,blockedReasons:fe(e,v),ownedBytes:h?.get(e.id)??null,drain:Me(Ne(e),g?.get(e.id)),siblings:v},e.id))})]})}var pt=[`recordings`,`recordingsLow`];function mt(e){return e.locationIds!==void 0&&e.locationIds.length>0?e.locationIds:e.locationId===null?[]:[e.locationId]}function ht(e,t){if(t===void 0||!pt.includes(e.type))return null;let n=t.find(t=>mt(t).includes(e.id));return n===void 0||!Number.isFinite(n.usedBytes)||n.usedBytes<0?null:n.usedBytes}function gt(e,t){let n=new Map;for(let r of e){let e=ht(r,t);e!==null&&n.set(r.id,e)}return n}export{Ae as a,U as c,Be as i,ue as l,ft as n,De as o,q as r,he as s,gt as t,z as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{K as e,R as t,et as n}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{Hi as r,Ui as i,fr as a,gr as o,xa as s}from"./client-DvJxGh2F.js";import{$n as c,Qn as l,ar as u,nr as d,or as f,tr as p}from"./src-DntJrWmU.js";import{t as m}from"./i18n-
|
|
1
|
+
import{K as e,R as t,et as n}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{Hi as r,Ui as i,fr as a,gr as o,xa as s}from"./client-DvJxGh2F.js";import{$n as c,Qn as l,ar as u,nr as d,or as f,tr as p}from"./src-DntJrWmU.js";import{t as m}from"./i18n-D0o08mg-.js";import{hr as h}from"./index-D_Tm4B7S.js";n();var g=`step`,_=[g,`acc`];function v(e,t){return`${e}/${t}`}function y(e,t,n){let r=n.step!==null&&e.includes(n.step),i=n.acc!==null&&t.includes(n.acc);return{stepId:r?n.step:null,acceleratorId:i?n.acc:null,staleStepId:n.step!==null&&n.step!==``&&!r&&e.length>0?n.step:null}}var b=`armed:`;function x(e){return e.assignment.reasons.detection?.startsWith(b)===!0}function S(e){let{assignment:t,detection:n}=e;return n!==null&&n.provisioning.state===`failed`||t.detectionNodeId===null&&n===null&&!x(e)?`error`:n!==null&&n.phase===`active`?`healthy`:`idle`}function ee(e){let t=[],n=[],{assignment:r,detection:i,broker:a}=e;i!==null&&i.provisioning.state===`failed`&&t.push({code:`provisioning-failed`,severity:`error`,message:i.provisioning.error!==void 0&&i.provisioning.error.length>0?m.t(`helpers.cameraCardModel.provisioningFailedWith`,{error:i.provisioning.error}):m.t(`helpers.cameraCardModel.provisioningFailed`)}),i!==null&&i.phase===`active`&&i.actualFps===0&&t.push({code:`detection-black-hole`,severity:`error`,message:m.t(`helpers.cameraCardModel.blackHole`)}),r.detectionNodeId===null&&i===null&&!x(e)&&n.push({code:`unassigned`,severity:`warning`,message:m.t(`helpers.cameraCardModel.unassigned`)});let o=e.degraded??[];if(o.length>0){let e=[...new Set(o.map(e=>e.stage))].join(`, `);n.push({code:`status-unreadable`,severity:`warning`,message:m.t(`helpers.cameraCardModel.statusUnreadable`,{stages:e})})}n.push(...C(e.cameraSensors));for(let e of a?.profiles??[])e.status===`streaming`&&e.inFps===0&&n.push({code:`broker-stalled`,severity:`warning`,message:m.t(`helpers.cameraCardModel.brokerStalled`,{profile:e.profile})});return[...t,...n]}function te(e){return e.state===`unreadable`&&o.state===`unreadable`&&e.reason===o.reason}function ne(e){switch(e.state){case`ready`:return null;case`missing`:return{code:`camera-sensor-missing`,severity:`warning`,message:m.t(`helpers.cameraCardModel.sensorMissing`,{addonId:e.addonId,stableId:e.stableId})};case`offline`:return{code:`camera-sensor-offline`,severity:`warning`,message:m.t(`helpers.cameraCardModel.sensorOffline`,{name:e.name,deviceId:e.deviceId,reason:e.reason})};case`unsupported`:return{code:`camera-sensor-unsupported`,severity:`warning`,message:m.t(`helpers.cameraCardModel.sensorUnsupported`,{name:e.name,deviceId:e.deviceId,reason:e.reason})};case`unreadable`:return{code:`camera-sensor-unreadable`,severity:`warning`,message:m.t(`helpers.cameraCardModel.sensorUnreadable`,{addonId:e.addonId,stableId:e.stableId,reason:e.reason})}}}function C(e){if(e===void 0||e.state===`not-configured`)return[];if(e.state===`unreadable`)return te(e)?[]:[{code:`camera-sensors-unreadable`,severity:`warning`,message:m.t(`helpers.cameraCardModel.sensorsUnreadable`,{reason:e.reason})}];let t=e.sensors.flatMap(e=>{let t=ne(e);return t===null?[]:[t]}),n=e.notForwarded===void 0?t:[w(e.notForwarded),...t];return e.notEnforced===void 0?n:[{code:`camera-sensors-not-enforced`,severity:`warning`,message:m.t(`helpers.cameraCardModel.notEnforced`)},...n]}function w(e){return{code:`camera-sensors-not-forwarded`,severity:`warning`,message:e===`onboard-not-listed`?m.t(`helpers.cameraCardModel.notForwardedOnboard`):m.t(`helpers.cameraCardModel.notForwardedNoDetection`)}}function T(e){return e===void 0?m.t(`helpers.cameraCardModel.summaryUnavailable`):e.state===`not-configured`?m.t(`helpers.cameraCardModel.summaryNone`):e.state===`unreadable`?m.t(`helpers.cameraCardModel.summaryUnknown`,{reason:e.reason}):e.sensors.map(D).join(`, `)}function E(e){return e.mode===`in-addition`?``:` · ${e.mode}`}function D(e){return`${O(e)}${E(e)}`}function O(e){switch(e.state){case`ready`:return`${e.name} (#${e.deviceId})`;case`offline`:return`${e.name} (#${e.deviceId}) — ${e.reason}`;case`unsupported`:return m.t(`helpers.cameraCardModel.summaryUnsupported`,{name:e.name,deviceId:e.deviceId});case`missing`:case`unreadable`:return`${e.addonId}/${e.stableId} — ${e.state}`}}function k(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function A(e){return typeof e==`string`&&e.length>0?e:null}function j(e){return typeof e==`number`&&Number.isFinite(e)?e:null}function M(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function N(e,t){return e==null?!1:JSON.stringify(e)!==JSON.stringify(t??null)}var P={detectionMode:null,detectionStreamProfile:null,detectionFps:null,motionSources:[],motionFps:null,motionCooldownMs:null,motionStreamProfile:null,audioMode:null,pipelineNodeId:null,decoderNodeId:null,audioNodeId:null,overriddenKeys:new Set};function F(e){if(!k(e)||!Array.isArray(e.sections))return P;let t=s(e),n=e=>{let n=t.get(e);if(n!==void 0)return n.value??n.default},r=new Set;for(let[e,n]of t)N(n.value,n.default)&&r.add(e);return{detectionMode:A(n(`detectionMode`)),detectionStreamProfile:A(n(`detectionStreamProfile`)),detectionFps:j(n(`detectionFps`)),motionSources:M(n(`motionSources`)),motionFps:j(n(`motionFps`)),motionCooldownMs:j(n(`motionCooldownMs`)),motionStreamProfile:A(n(`motionStreamProfile`)),audioMode:A(n(`audioMode`)),pipelineNodeId:A(n(`pipelineNodeId`)),decoderNodeId:A(n(`decoderNodeId`)),audioNodeId:A(n(`audioNodeId`)),overriddenKeys:r}}function I(e,t=0){let n=[];for(let r of e)n.push({addonId:r.addonId,modelId:r.modelId??null,enabled:r.enabled,depth:t}),r.children!==void 0&&r.children.length>0&&n.push(...I(r.children,t+1));return n}function L(n,r){let[i,a]=h(),o=i.get(g),s=i.get(`acc`),c=e(()=>y(n,r,{step:o,acc:s}),[n,r,o,s]),l=t(e=>{a(t=>{let n=new URLSearchParams(t);return e(n),n},{replace:!0})},[a]);return{selection:c,open:t(e=>l(t=>{t.set(g,e.stepId),e.acceleratorId===void 0?t.delete(`acc`):t.set(`acc`,e.acceleratorId)}),[l]),close:t(()=>l(e=>{e.delete(g),e.delete(`acc`)}),[l])}}function R(e,t){for(let n of e?.slots??[])for(let e of n.addons)if(e.id===t)return e;return null}function z(e){return e.split(`.`)[0]??e}function B(e,t,n){return{id:v(e,n.key),nodeId:e,deviceKey:n.key,device:n,label:`${z(t)} · ${u(n)}`,shortLabel:`${z(t)} · ${f(n)}`,nodeLabel:z(t),disabled:!n.enabled}}function V(e,t,n,r=!1){return n.filter(e=>r||e.enabled).map(n=>B(e,t,n))}function H(e,t,n){return{modelId:p({catalog:e,device:t.device,base:n.nodePin}),source:n.nodePin===void 0?`default`:`node`}}function U(e,t){let n=R(e,`object-detection`);if(n===null)return;let r=p({catalog:n,device:t.device,base:t.device.steps?.[`object-detection`]?.modelId});if(r===void 0)return;let i=n.models.find(e=>e.id===r);return{modelId:r,name:i?.name??r,supplies:i?.suppliesSteps??[]}}function W(e,t,n){return!r(e)||n===void 0?!1:i(e,t,n.supplies).effective}function G(e,t){return e!==null&&d(e.models,t.device.format)}function K(e){return G(e.addon,e.acc)?e.clusterModelId===void 0?{kind:`enabled`,modelId:e.model.modelId??`Auto`,...e.rootName===void 0?{}:{suppliedByRoot:e.rootName},...e.jumpTo===void 0?{}:{jumpTo:e.jumpTo}}:{kind:`enabled`,modelId:e.clusterModelId,clusterWide:!0}:e.gatedOn?e.jumpTo===void 0?{kind:`skip`}:{kind:`skip`,jumpTo:e.jumpTo}:{kind:`na`}}function q(e){if(e===null)return[];let t=(e.configSchema??[]).flatMap(e=>`label`in e&&typeof e.label==`string`?[e.label]:[]),n=a(e.id).map(e=>e.label);return[...new Set([...t,...n])]}function J(e){return e.flatMap(e=>[{node:e,depth:0},...J(e.children).map(e=>({node:e.node,depth:e.depth+1}))])}function Y(e){return c(e)}function X(e){return{nodeFields:Y(e),acceleratorFields:Z(e)}}function Z(e){return e.flatMap(e=>{if(e.type===`group`){let t=Z(e.fields);return t.length>0?[{...e,fields:[...t]}]:[]}return l(e)?[e]:[]})}function Q(e){return e.some(e=>e.type===`group`?Q(e.fields):l(e))}function $(e,t){return e.flatMap(e=>{let n=$(e.children,t);return t.has(e.addonId)||n.length>0?[{...e,children:n}]:[]})}export{F as _,J as a,_ as b,U as c,q as d,H as f,ee as g,T as h,R as i,G as l,L as m,K as n,Q as o,W as p,$ as r,V as s,Y as t,X as u,I as v,S as y};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{C as e,K as t,R as n,S as r,et as i}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{Nt as a}from"./player-overlays-Dbv95cvz.js";import{
|
|
1
|
+
import{C as e,K as t,R as n,S as r,et as i}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{Nt as a}from"./player-overlays-Dbv95cvz.js";import{hr as o,lr as s}from"./index-D_Tm4B7S.js";function c({staleNodeId:t,shownNodeName:n}){return t===null?null: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(a,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-warning`}),r(`span`,{children:r(s,{i18nKey:`shared.staleNodeNotice.notice`,values:{id:t,name:n},components:{b:r(`span`,{className:`font-medium text-foreground`})}})})]})}i();var l=`node`;function u(e){return[...e].toSorted((e,t)=>e.isHub===t.isHub?e.isOnline===t.isOnline?e.name.localeCompare(t.name):e.isOnline?-1:1:e.isHub?-1:1)}function d(e,t){let n=u(e),r=n[0]??null;if(r===null)return{node:null,outcome:`empty`,staleNodeId:null};if(t===null||t.length===0)return{node:r,outcome:`default`,staleNodeId:null};let i=n.find(e=>e.id===t);return i===void 0?{node:r,outcome:`stale`,staleNodeId:t}:{node:i,outcome:`requested`,staleNodeId:null}}function f(e){let[r,i]=o(),a=r.get(l);return{selection:t(()=>d(e,a),[e,a]),selectNode:n(e=>{let t=new URLSearchParams(r);t.set(l,e),i(t,{replace:!0})},[r,i]),requestedNodeId:a}}export{c as n,f as t};
|
package/dist/index.html
CHANGED
|
@@ -136,18 +136,18 @@
|
|
|
136
136
|
})
|
|
137
137
|
})()
|
|
138
138
|
</script>
|
|
139
|
-
<script type="module" crossorigin src="./assets/mf-entry-bootstrap-0-
|
|
139
|
+
<script type="module" crossorigin src="./assets/mf-entry-bootstrap-0-e328376a.js"></script>
|
|
140
140
|
<link rel="modulepreload" crossorigin href="./assets/__vite-browser-external-BlMfPwfH.js">
|
|
141
141
|
<link rel="modulepreload" crossorigin href="./assets/client-DvJxGh2F.js">
|
|
142
142
|
<link rel="modulepreload" crossorigin href="./assets/player-overlays-Dbv95cvz.js">
|
|
143
143
|
<link rel="modulepreload" crossorigin href="./assets/src-DntJrWmU.js">
|
|
144
144
|
<link rel="modulepreload" crossorigin href="./assets/useTranslation-BJr-n0es.js">
|
|
145
|
-
<link rel="modulepreload" crossorigin href="./assets/i18n-
|
|
145
|
+
<link rel="modulepreload" crossorigin href="./assets/i18n-D0o08mg-.js">
|
|
146
146
|
<link rel="modulepreload" crossorigin href="./assets/video-D7jv0spx.js">
|
|
147
147
|
<link rel="modulepreload" crossorigin href="./assets/mount-CUPf26ML.js">
|
|
148
148
|
<link rel="modulepreload" crossorigin href="./assets/addon-icons-context-lrP_33gc.js">
|
|
149
|
-
<link rel="stylesheet" crossorigin href="./assets/index-
|
|
150
|
-
<link rel="modulepreload" crossorigin href="./assets/hostInit-DB6u6qxU.js"><link rel="modulepreload" crossorigin href="./assets/index-
|
|
149
|
+
<link rel="stylesheet" crossorigin href="./assets/index-D4id__eL.css">
|
|
150
|
+
<link rel="modulepreload" crossorigin href="./assets/hostInit-DB6u6qxU.js"><link rel="modulepreload" crossorigin href="./assets/index-D_Tm4B7S.js"><link rel="modulepreload" crossorigin href="./assets/remoteEntry-CVuKB7K_.js"><link rel="modulepreload" crossorigin href="./assets/_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-QiJARN9B.js"><link rel="modulepreload" crossorigin href="./assets/_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js"><link rel="modulepreload" crossorigin href="./assets/_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_trpc_mf_1_client__loadShare__.js-8kv6pj9W.js"><link rel="modulepreload" crossorigin href="./assets/_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_trpc_mf_1_react_mf_2_query__loadShare__.js-DzoL8nR8.js"><link rel="modulepreload" crossorigin href="./assets/_virtual_mf___mfe_internal__admin_ui_host__loadShare__react_mf_2_dom__loadShare__.js-BPba2g2p.js"><link rel="modulepreload" crossorigin href="./assets/_virtual_mf___mfe_internal__admin_ui_host__loadShare__react_mf_2_dom_mf_1_client__loadShare__.js-ZBKFTPET.js"></head>
|
|
151
151
|
<body>
|
|
152
152
|
<div id="root"></div>
|
|
153
153
|
<!-- Lock the app shell at 1x zoom. iOS Safari ignores `user-scalable=no`
|
package/dist/server/addon.js
CHANGED
|
@@ -82940,7 +82940,7 @@ var AdminUIAddon = class extends BaseAddon {
|
|
|
82940
82940
|
capability: adminUiCapability,
|
|
82941
82941
|
provider: {
|
|
82942
82942
|
getStaticDir: async () => ({ staticDir: resolveAdminUiDistDir() }),
|
|
82943
|
-
getVersion: async () => ({ version: "1.2.
|
|
82943
|
+
getVersion: async () => ({ version: "1.2.479" })
|
|
82944
82944
|
}
|
|
82945
82945
|
}];
|
|
82946
82946
|
}
|
package/package.json
CHANGED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import{B as e,C as t,J as n,K as r,R as i,S as a,V as o,Y as s,et as c,o as l,x 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{It as d,Nt as f,Ot as p,Q as m,Rn as h,Si as g,Tn as _,Wr as v,ai as y,bn as b,dt as x,fn as S,or as C,pi as ee,pn as w,tn as T,un as E,vi as te,xi as ne}from"./player-overlays-Dbv95cvz.js";import{Na as re}from"./client-DvJxGh2F.js";import{i as D,l as ie}from"./video-D7jv0spx.js";import{$r as O,$s as ae,$u as oe,Ai as se,Bn as k,Di as A,Ei as ce,Fi as le,Hn as j,Ii as M,Ju as N,Kr as P,Li as ue,Mi as F,Ni as de,Oi as fe,Si as I,Ti as pe,Un as L,Ur as R,Vn as z,Wr as me,_d as B,_i as V,_r as he,bi as H,bt as ge,gi as U,hi as _e,hr as W,ji as ve,kt as ye,md as be,mr as xe,nn as G,pi as Se,pr as K,tn as Ce,vi as we,vr as Te,wi as Ee,xi as De,yi as Oe,yr as q}from"./src-DntJrWmU.js";import{t as J}from"./useTranslation-BJr-n0es.js";import"./mount-CUPf26ML.js";import{fr as Y,lr as X,mr as ke}from"./index-C3uCLHv0.js";import{t as Ae}from"./AdminPage-3JxWocN3.js";import{t as je}from"./NodeAddonsSettingsPanel-Dq6sGWkR.js";import{n as Z,t as Me}from"./useNodeUrlSelection-DGV2ltbG.js";function Ne(e){if(e===void 0)return null;switch(e.state){case`failed`:case`refused`:case`missing`:case`crashed`:return{kind:e.state,...e.reason===void 0?{}:{reason:e.reason}};default:return null}}c();var Pe={queued:{icon:y,bg:`bg-muted text-foreground-subtle`,labelKey:`addons.addonRowBadge.queued`},updating:{icon:C,bg:`bg-primary/10 text-primary`,labelKey:`addons.addonRowBadge.updating`,spin:!0},"done-pending-restart":{icon:b,bg:`bg-amber-500/10 text-amber-700`,labelKey:`addons.addonRowBadge.pendingRestart`},done:{icon:g,bg:`bg-success/10 text-success`,labelKey:`addons.addonRowBadge.done`},failed:{icon:D,bg:`bg-danger/10 text-danger`,labelKey:`addons.addonRowBadge.failed`}};function Fe({item:e}){let{t:n}=J(),r=Pe[e.status],i=r.icon;return t(`span`,{className:`inline-flex items-center gap-1 px-1.5 py-0.5 text-[10px] rounded ${r.bg}`,title:e.error,children:[a(i,{className:`w-2.5 h-2.5 ${r.spin?`animate-spin`:``}`}),n(r.labelKey)]})}var Ie=new Set([`completed`,`failed`,`partially-failed`,`cancelled`]),Q=new Set([`done`,`failed`,`skipped`]);function Le(e){return!Q.has(e.phase)&&!Ie.has(e.jobState)}function Re(e,t){let n=new Map,r=[...e].sort((e,t)=>e.createdAtMs-t.createdAtMs);for(let e of r){let r=Ie.has(e.state);for(let i of e.tasks)r&&i.finishedAtMs!==null&&t-i.finishedAtMs>6e4||n.set(i.packageName,{jobId:e.jobId,packageName:i.packageName,phase:i.phase,fromVersion:i.fromVersion,toVersion:i.toVersion,error:i.error,jobState:e.state,finishedAtMs:i.finishedAtMs})}return n}function ze(){let{data:e}=pe({activeOnly:!0},{refetchOnWindowFocus:!1,refetchInterval:e=>(e.state.data?.length??0)>0?3e3:!1}),{map:t}=B(re.AddonsJobProgress,e=>e.job.jobId);return r(()=>{let n=new Map;for(let t of e??[])n.set(t.jobId,t);for(let[e,r]of t)n.set(e,r.job);return Re([...n.values()],Date.now())},[e,t])}var Be={queued:{icon:y,cls:`bg-muted text-foreground-subtle`,labelKey:`addons.jobProgress.queued`},fetching:{icon:C,cls:`bg-primary/10 text-primary`,labelKey:`addons.jobProgress.fetching`,spin:!0},staged:{icon:C,cls:`bg-primary/10 text-primary`,labelKey:`addons.jobProgress.staged`,spin:!0},validating:{icon:C,cls:`bg-primary/10 text-primary`,labelKey:`addons.jobProgress.validating`,spin:!0},applying:{icon:C,cls:`bg-primary/10 text-primary`,labelKey:`addons.jobProgress.applying`,spin:!0},restarting:{icon:C,cls:`bg-amber-500/10 text-amber-600 dark:text-amber-400`,labelKey:`addons.jobProgress.restarting`,spin:!0},applied:{icon:C,cls:`bg-primary/10 text-primary`,labelKey:`addons.jobProgress.finalizing`,spin:!0},done:{icon:g,cls:`bg-success/10 text-success`,labelKey:`addons.jobProgress.updated`},failed:{icon:D,cls:`bg-danger/10 text-danger`,labelKey:`addons.jobProgress.failed`},skipped:{icon:T,cls:`bg-muted text-foreground-subtle`,labelKey:`addons.jobProgress.skipped`}};function Ve({progress:e}){let{t:n}=J(),r=Be[e.phase],i=r.icon,o=e.error??`${e.packageName}: ${e.fromVersion??`?`} → ${e.toVersion}`;return t(`span`,{"data-testid":`addon-job-progress`,className:`inline-flex items-center gap-1 px-1.5 py-0.5 text-[10px] rounded shrink-0 ${r.cls}`,title:o,children:[a(i,{className:`w-2.5 h-2.5 ${r.spin?`animate-spin`:``}`}),n(r.labelKey),t(`span`,{className:`font-mono`,children:[`→ `,e.toVersion]})]})}function He(e,t){return e.filter(e=>e.packageName===t).slice().sort((e,t)=>e.isHub===t.isHub?e.nodeName.localeCompare(t.nodeName):e.isHub?-1:1)}function Ue(e){let t=e.version===null?``:` ${e.version}`,n=e.isOnline?``:` (offline: removed when it reconnects)`;return`- ${e.nodeName}${t}${n}`}function We(e,t,n){let r=[`${e} will be uninstalled from ${t.length} node(s). Its runners stop, its capabilities are deregistered and its code is deleted:`,...t.map(Ue)];return n.length>0&&r.push(`Could not ask: ${n.join(`, `)} — not included.`),r.push(`This cannot be undone.`),r.join(`
|
|
2
|
-
`)}function Ge(e,t,n){let r=[`${e} will be uninstalled from ${t}: its runners stop and its code is deleted.`];return n.length>0&&r.push(`It stays installed on: ${n.map(e=>e.nodeName).join(`, `)}. Use "Everywhere" to remove it from every node.`),r.push(`This cannot be undone.`),r.join(`
|
|
3
|
-
`)}var Ke={uninstalled:`uninstalled`,"not-installed":`was not installed`,refused:`REFUSED`,failed:`FAILED`,"pending-reconnect":`offline — removed when it reconnects`};function qe(e,t){let n=[];for(let r of e.results){let e=r.runnersStopped.length>0?` (stopped ${r.runnersStopped.join(`, `)})`:``;n.push(`${t(r.nodeId)}: ${Ke[r.outcome]}${e}`),r.error!==void 0&&n.push(` ${r.error}`);for(let e of r.warnings)n.push(` ${e}`)}return n.join(`
|
|
4
|
-
`)}var Je={},Ye=3e4,Xe=`inline-flex items-center gap-1 rounded-md px-2 py-1 text-[10px] font-medium border border-border text-foreground-subtle hover:text-red-400 hover:border-red-500/30 hover:bg-red-500/10 disabled:opacity-50 transition-colors`;function Ze({packageName:e,displayName:n,selectedNode:r,hideNodeAction:i,disabled:o}){let{t:s}=J(),c=l(),u=me(),f=R(),p=Ee(Je,{staleTime:Ye}),m=p.data?.installations??[],h=(p.data?.unreachable??[]).map(e=>e.nodeId),g=He(m,e),_=e=>g.find(t=>t.nodeId===e)?.nodeName??(e===r.id?r.name:e),v=M({onSettled:()=>{c.invalidateQueries({queryKey:[[`addons`]]}),c.invalidateQueries({queryKey:[[`addonPages`]]}),c.invalidateQueries({queryKey:[[`capabilities`]]}),c.invalidateQueries({queryKey:[[`nodes`]]})}}),y=async e=>{await f({title:e.success?s(`addons.addonUninstallControls.uninstalled`,`{{displayName}} uninstalled`,{displayName:n}):s(`addons.addonUninstallControls.notEveryNodeWasCleaned`,`{{displayName}}: not every node was cleaned`,{displayName:n}),message:qe(e,_),variant:e.success?`default`:`danger`})},b=async t=>{try{await y(await v.mutateAsync({packageName:e,...t}))}catch(e){await f({title:s(`addons.addonUninstallControls.uninstallFailed`,`Uninstall {{displayName}} failed`,{displayName:n}),message:e instanceof Error?e.message:String(e),variant:`danger`})}},x=async()=>{let e=g.filter(e=>e.nodeId!==r.id);await u({title:s(`addons.addonUninstallControls.uninstallFrom`,`Uninstall {{displayName}} from {{name}}?`,{displayName:n,name:r.name}),message:Ge(n,r.name,e),confirmLabel:s(`addons.addonUninstallControls.uninstall`,`Uninstall`),variant:`danger`})&&await b(r.isHub?{}:{nodeId:r.id})},S=async()=>{let t=(await p.refetch()).data;if(t===void 0){await f({title:s(`addons.addonUninstallControls.cannotListTheNodes`,`Cannot list the nodes`),message:s(`addons.addonUninstallControls.theHubDidNotAnswer`,`The hub did not answer which nodes have this package — nothing was removed.`),variant:`danger`});return}let r=He(t.installations,e);await u({title:s(`addons.addonUninstallControls.uninstallEverywhere`,`Uninstall {{displayName}} everywhere?`,{displayName:n}),message:We(n,r,t.unreachable.map(e=>e.nodeId)),confirmLabel:s(`addons.addonUninstallControls.uninstallFromNodeS`,`Uninstall from {{length}} node(s)`,{length:r.length}),variant:`danger`})&&await b({everywhere:!0})},C=v.isPending||o===!0;return t(`div`,{className:`flex items-center gap-1.5`,children:[i!==!0&&t(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),x()},disabled:C,className:Xe,title:s(`addons.addonUninstallControls.uninstallFrom2`,`Uninstall from {{name}}`,{name:r.name}),children:[a(d,{className:`h-3 w-3`}),v.isPending?s(`addons.addonUninstallControls.removing`,`Removing...`):s(`addons.addonUninstallControls.uninstall`,`Uninstall`)]}),(g.length>1||i===!0||h.length>0)&&t(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),S()},disabled:C,className:Xe,title:s(`addons.addonUninstallControls.uninstallFromEveryNodeThat`,`Uninstall from every node that has it`),children:[a(ie,{className:`h-3 w-3`}),g.length>0?s(`addons.uninstallControls.everywhereCount`,{count:g.length}):s(`addons.uninstallControls.everywhere`)]})]})}function Qe(e){return typeof e.deprecated==`string`&&e.deprecated.length>0}function $e(e,t){return t?e:e.filter(e=>e.distTags.includes(`latest`)||!Qe(e))}function et(e){return e.length-$e(e,!1).length}c();function tt({packageName:e,currentVersion:n,installSource:r,onInstall:i,onClose:o,onSelect:c,selectedVersion:l}){let{t:d}=J(),f=r===`upload`||r===`local`,[m,h]=s(!1),{data:_,isLoading:y,isError:b}=H({name:e}),S=_?$e(_,m):[],ee=_?et(_):0;return t(`div`,{className:`fixed z-50 w-72 rounded-lg border border-border bg-surface shadow-xl overflow-hidden`,style:{top:`auto`,bottom:`auto`},ref:e=>{if(!e)return;let t=e.parentElement?.getBoundingClientRect();if(!t)return;let n=window.innerHeight-t.bottom,r=t.top;n<280&&r>n?(e.style.bottom=`${window.innerHeight-t.top+4}px`,e.style.top=`auto`):(e.style.top=`${t.bottom+4}px`,e.style.bottom=`auto`),e.style.right=`${window.innerWidth-t.right}px`},onClick:e=>e.stopPropagation(),children:[t(`div`,{className:`flex items-center justify-between px-3 py-2 border-b border-border`,children:[a(`span`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle font-medium`,children:d(`addons.versionPicker.versions`,`Versions`)}),a(`button`,{type:`button`,onClick:o,className:`text-foreground-subtle hover:text-foreground`,children:a(x,{className:`h-3 w-3`})})]}),f&&t(`div`,{className:`flex items-start gap-2 px-3 py-2 border-b border-border bg-cyan-500/10 text-[10px]`,children:[a(p,{className:`h-3 w-3 mt-0.5 text-cyan-500 shrink-0`}),t(`div`,{className:`text-cyan-700 dark:text-cyan-200`,children:[a(`span`,{className:`font-semibold`,children:d(`addons.versionPicker.inPlace`,{kind:r===`upload`?d(`addons.versionPicker.uploadedCopy`,`Uploaded copy`):d(`addons.versionPicker.localCopy`,`Local copy`)})}),` `,a(X,{i18nKey:`addons.versionPicker.reinstall`,values:{version:n},components:{mono:a(`span`,{className:`font-mono`})}})]})]}),y&&t(`div`,{className:`flex items-center justify-center gap-2 py-6 text-[10px] text-foreground-subtle`,children:[a(C,{className:`h-3.5 w-3.5 animate-spin`}),d(`addons.versionPicker.loadingVersions`,`Loading versions...`)]}),b&&a(`div`,{className:`px-3 py-4 text-center text-[10px] text-danger`,children:d(`addons.versionPicker.registryError`,`Could not load versions from the registry.`)}),S.length>0&&a(`div`,{className:`max-h-64 overflow-auto divide-y divide-border`,children:S.map(e=>{let r=e.version===n,o=c!==void 0&&e.version===l,s=/-(alpha|beta|rc|dev|canary|next)/i.test(e.version),f=t(u,{children:[a(`span`,{className:`font-mono flex-1 text-left ${r?`text-primary font-semibold`:s?`text-amber-400`:`text-foreground`}`,children:e.version}),r&&a(`span`,{className:`text-[9px] rounded-full px-1.5 py-0.5 font-medium bg-primary/10 text-primary`,children:d(`common.current`)}),e.distTags.map(e=>a(`span`,{className:`text-[9px] rounded-full px-1.5 py-0.5 font-medium ${e===`latest`?`bg-emerald-500/15 text-emerald-400`:e===`beta`?`bg-amber-500/15 text-amber-400`:`bg-gray-500/15 text-gray-400`}`,children:e},e)),Qe(e)&&a(`span`,{className:`text-[9px] text-red-400 line-through`,children:d(`common.deprecated`)}),a(`span`,{className:`text-[9px] text-foreground-subtle shrink-0`,children:new Date(e.publishedAt).toLocaleDateString()})]});return c?t(`button`,{type:`button`,"aria-label":d(`addons.versionPicker.select`,`Select {{version}}`,{version:e.version}),onClick:()=>c(e.version),className:`w-full flex items-center gap-2 px-3 py-2 text-[11px] ${o?`bg-primary/5`:`hover:bg-surface-hover`} transition-colors`,children:[f,o?a(g,{className:`h-3 w-3 text-primary shrink-0`}):a(`span`,{className:`w-3 shrink-0`})]},e.version):t(`div`,{className:`flex items-center gap-2 px-3 py-2 text-[11px] ${r?`bg-primary/5`:`hover:bg-surface-hover`} transition-colors`,children:[f,a(`button`,{type:`button`,onClick:()=>i(e.version),className:`shrink-0 rounded p-0.5 hover:bg-primary/20 text-foreground-subtle hover:text-primary transition-colors`,title:r?d(`addons.versionPicker.reInstallFromNpm`,`Re-install {{version}} from npm`,{version:e.version}):d(`addons.versionPicker.install`,`Install {{version}}`,{version:e.version}),children:a(v,{className:`h-3 w-3`})})]},e.version)})}),!y&&!b&&_&&_.length===0&&a(`div`,{className:`py-4 text-center text-[10px] text-foreground-subtle`,children:d(`addons.versionPicker.noVersionsFound`,`No versions found`)}),ee>0&&a(P,{type:`button`,variant:`ghost`,size:`sm`,className:`h-auto w-full justify-start rounded-none border-t border-border px-3 py-2 text-left text-[10px] font-normal text-foreground-subtle`,onClick:()=>h(e=>!e),children:m?d(`addons.versionPicker.hideOlder`,`Hide older versions`):d(`addons.versionPicker.showOlder`,`Show older versions ({{count}})`,{count:ee})})]})}c();var nt=`device-export`;function rt(e){return e.capabilities.some(e=>(typeof e==`string`?e:e.name)===nt)}function it(e){return e!==`local`&&e!==`upload`}function at({isBundle:e,installSource:n,addonId:r,iconPath:i,color:o}){let[c,l]=s(!1),u=o?{backgroundColor:`${o.startsWith(`#`)?o:`#${o}`}26`}:void 0,d=e?`bg-indigo-500/20 text-indigo-700 dark:text-indigo-300`:`bg-purple-500/20 text-purple-700 dark:text-purple-300`,f=r&&i?m(`/api/addon-assets/${r}/${i}`):null,g=!!f&&!c;return t(`div`,{className:`relative flex-shrink-0`,children:[a(`div`,{className:`h-8 w-8 rounded-md flex items-center justify-center ${u?``:d}`,style:u,children:g?a(`img`,{src:f,alt:r,className:`h-4 w-4`,onError:()=>l(!0)}):a(e?h:_,{className:`h-3.5 w-3.5`})}),n===`local`&&a(`span`,{className:`absolute -top-1.5 -left-1.5 text-[7px] font-bold leading-none bg-orange-500 text-white px-1 py-0.5 rounded -rotate-12 shadow-sm`,children:`DEV`}),it(n)&&a(`span`,{className:`absolute -top-1 -left-1 w-4 h-4 rounded bg-[#cb3837] flex items-center justify-center -rotate-12 shadow-sm`,children:a(`svg`,{viewBox:`0 0 780 250`,className:`w-[11px] h-[11px]`,children:a(`path`,{fill:`#fff`,d:`M240 250h100V50h100v200h340V0H0v250z`})})}),n===`upload`&&a(`span`,{className:`absolute -top-1.5 -left-1.5 flex items-center justify-center h-4 w-4 rounded bg-cyan-500 -rotate-12 shadow-sm`,children:a(p,{className:`h-2.5 w-2.5 text-white`})})]})}function ot({version:e,availableUpdate:n,selectedVersion:r,isUpdating:i,installSource:o,disabled:s,onUpdate:c,onOpenPicker:l,children:u}){let{t:d}=J();if(i)return t(`span`,{className:`inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[10px] font-medium border border-blue-500/30 bg-blue-500/10 text-blue-400 shrink-0`,children:[a(C,{className:`h-3 w-3 animate-spin`}),d(`addons.addonCard.updating`,`Updating…`)]});if(n){let i=r??n;return t(`div`,{className:`relative inline-flex items-center gap-1 shrink-0`,children:[c&&t(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),c()},disabled:s,className:`inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[10px] font-semibold border border-blue-500/30 bg-blue-500/10 text-blue-400 hover:bg-blue-500/20 disabled:opacity-50 disabled:cursor-not-allowed transition-colors`,title:d(`addons.addonCard.updateTo`,`Update to {{target}}`,{target:i}),children:[a(v,{className:`h-3 w-3`}),d(`addons.addonCard.update`,`Update`)]}),t(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),l()},disabled:s,"aria-label":d(`addons.addonCard.selectVersionToInstall`,`Select version to install`),title:d(`addons.addonCard.installedUpdateAvailableSelectedTap`,`Installed {{version}} — update available. Selected {{target}}; tap to choose another version.`,{version:e,target:i}),className:`inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[10px] font-bold font-mono border border-amber-500/40 bg-amber-500/15 text-amber-500 hover:bg-amber-500/25 animate-pulse disabled:opacity-50 disabled:cursor-not-allowed transition-colors`,children:[a(`span`,{className:`font-normal opacity-70`,children:e}),a(`span`,{className:`font-normal opacity-70`,children:`→`}),i,a(ne,{className:`h-3 w-3`})]}),u]})}return t(`div`,{className:`relative inline-flex items-center gap-1 shrink-0`,children:[t(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),l()},disabled:s,className:[`inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[10px] font-bold font-mono border transition-colors disabled:opacity-50 disabled:cursor-not-allowed`,o===`local`?`border-orange-500/30 bg-orange-500/10 text-orange-400 hover:bg-orange-500/20`:`border-emerald-500/30 bg-emerald-500/10 text-emerald-400 hover:bg-emerald-500/20`].join(` `),title:d(`addons.addonCard.versionTapToViewAll`,`Version {{version}} — tap to view all versions`,{version:e}),children:[e,a(ne,{className:`h-3 w-3 opacity-50`})]}),u]})}function st({addonId:e}){let t=l(),{data:n=`inherit`}=U({addonId:e}),r=F({onSuccess:()=>{t.invalidateQueries({queryKey:[[`addons`,`getAddonAutoUpdate`]]})}});return a(`div`,{className:`flex rounded-lg border border-border overflow-hidden text-[10px] font-medium`,children:[`inherit`,`off`,`latest`,`beta`].map(t=>a(`button`,{type:`button`,onClick:n=>{n.stopPropagation(),r.mutate({addonId:e,channel:t})},disabled:r.isPending,className:`px-2.5 py-1 transition-colors capitalize ${n===t?t===`inherit`?`bg-gray-700/50 text-gray-700 dark:text-gray-300`:t===`off`?`bg-gray-700 text-gray-700 dark:text-gray-300`:t===`latest`?`bg-blue-500/20 text-blue-400`:`bg-amber-500/20 text-amber-400`:`bg-transparent text-foreground-subtle hover:bg-surface-hover`} ${t===`inherit`?``:`border-l border-border`}`,children:t},t))})}var ct={id:`hub`,name:`Hub`,isHub:!0};function lt({addon:e,clusterStatus:n,hideVersion:r,availableUpdate:i,onUpdate:c,isUpdating:d,jobProgress:f,bundle:p,bulkItem:m,disabledByBulk:g,isSystem:_,selectedNode:v}){let{t:y}=J(),[S,C]=s(!1),[ee,T]=s(!1),[re,ie]=s(null);o(()=>{ie(null)},[i]);let O=re??i,[ae,oe]=s(!1),[k,A]=s(!1),[ce,le]=s(`logs`),j=l(),M=Y(),{manifest:N}=e,ue=!p&&!N.protected&&N.removable!==!1,F=!!p,de=p?.displayName??N.name,I=p?.packageName??N.packageName,pe=p?.version??N.packageVersion??N.version,L=p?.installSource??e.installSource,R=p?p.bundle?.description??p.addons[0]?.manifest.description:N.description,z=fe({onSuccess:()=>{j.invalidateQueries({queryKey:[[`addons`]]})}}),me=De({onSuccess:()=>{j.invalidateQueries({queryKey:[[`addons`]]}),j.invalidateQueries({queryKey:[[`addonPages`]]}),j.invalidateQueries({queryKey:[[`capabilities`]]}),j.invalidateQueries({queryKey:[[`integrations`]]})}}),B=se({onSuccess:()=>{j.invalidateQueries({queryKey:[[`addons`]]}),j.invalidateQueries({queryKey:[[`alerts`]]})}}),V=e.health,H=V?.phase===`failed`&&!V.inGracePeriod,ge=H&&V?.nextRetryAt&&!V.retrying,U=Ne(e.process);return t(`div`,{className:`rounded-md border bg-surface overflow-hidden ${H?`border-red-500/50`:`border-border`}`,children:[H&&V&&t(`div`,{className:`bg-danger/10 border-b border-danger/30 px-3 py-2 flex items-start gap-2`,children:[a(D,{className:`h-4 w-4 text-danger shrink-0 mt-0.5`}),t(`div`,{className:`flex-1 min-w-0`,children:[a(`div`,{className:`text-xs font-semibold text-danger`,children:y(`addons.addonCard.failedToLoad`,{attempt:V.retryCount})}),a(`div`,{className:`text-[11px] text-foreground mt-0.5 break-words font-mono`,children:V.lastError?.message??y(`addons.addonCard.unknownError`,`Unknown error`)}),ge&&V.nextRetryAt&&a(`div`,{className:`text-[10px] text-foreground-subtle mt-1`,children:y(`addons.addonCard.autoRetryAt`,{time:new Date(V.nextRetryAt).toLocaleTimeString()})})]}),t(`button`,{type:`button`,disabled:B.isPending||V.retrying,onClick:e=>{e.stopPropagation(),B.mutate({packageName:I})},className:`inline-flex items-center gap-1.5 rounded-md px-2.5 py-1 text-[11px] font-semibold border border-red-400/40 bg-red-400/10 text-red-700 dark:text-red-300 hover:bg-red-400/20 disabled:opacity-50 disabled:cursor-not-allowed transition-colors shrink-0`,title:y(`addons.addonCard.resetRetryCounterAndForce`,`Reset retry counter and force immediate reload`),children:[a(b,{className:`h-3 w-3 ${B.isPending||V.retrying?`animate-spin`:``}`}),y(`addons.addonCard.retryNow`,`Retry now`)]})]}),U!==null&&t(`div`,{className:`bg-danger/10 border-b border-danger/30 px-3 py-2 flex items-start gap-2`,children:[a(D,{className:`h-4 w-4 text-danger shrink-0 mt-0.5`}),t(`div`,{className:`flex-1 min-w-0`,children:[a(`div`,{className:`text-xs font-semibold text-danger`,children:y(`addons.addonCard.processProblem.${U.kind}`)}),U.reason!==void 0&&a(`div`,{className:`text-[11px] text-foreground mt-0.5 break-words font-mono`,children:U.reason})]})]}),t(`div`,{className:`flex items-start gap-2.5 px-3 py-2`,children:[a(at,{isBundle:F||!!N.components&&N.components.length>1,installSource:L,addonId:F?p.addons[0]?.manifest.id:N.id,iconPath:F?p.bundle?.icon??p.addons[0]?.manifest.icon:N.icon,color:F?p.addons[0]?.manifest.color:N.color}),t(`div`,{className:`flex-1 min-w-0`,children:[t(`div`,{className:`flex items-start justify-between gap-2`,children:[a(`span`,{className:`text-xs font-semibold text-foreground truncate min-w-0`,children:de}),!r&&a(ot,{version:pe,availableUpdate:i,...O===void 0?{}:{selectedVersion:O},isUpdating:d,installSource:L,disabled:g,...c&&O!==void 0?{onUpdate:()=>c(O)}:{},onOpenPicker:()=>T(e=>!e),children:ee&&a(tt,{packageName:I,currentVersion:pe,...L?{installSource:L}:{},...i!==void 0&&O!==void 0?{selectedVersion:O,onSelect:e=>{ie(e),T(!1)}}:{},onInstall:e=>{T(!1),me.mutate({packageName:I,version:e})},onClose:()=>T(!1)})})]}),t(`div`,{className:`flex flex-wrap items-center gap-x-1.5 gap-y-1 mt-0.5`,children:[I!==de&&a(`span`,{className:`text-[10px] text-foreground-subtle font-mono truncate max-w-full`,children:I}),F&&t(`span`,{className:`text-[10px] rounded-full bg-primary/10 text-primary px-2 py-0.5 font-medium shrink-0 inline-flex items-center gap-1`,children:[a(h,{className:`h-3 w-3`}),p.addons.length]}),_&&t(`span`,{className:`text-[10px] rounded-full bg-amber-500/15 text-amber-700 dark:text-amber-300 px-2 py-0.5 font-medium shrink-0 inline-flex items-center gap-1`,title:y(`addons.addonCard.systemPackageUpdatingRestartsThe`,`System package — updating restarts the hub`),children:[a(b,{className:`h-3 w-3`}),y(`addons.addonCard.system`,`System`)]}),m!=null&&a(Fe,{item:m}),f!=null&&a(Ve,{progress:f})]}),R&&a(`p`,{className:`text-[10px] text-foreground-subtle mt-1 line-clamp-1`,children:R}),!F&&e.process&&t(`div`,{className:`flex flex-wrap items-center gap-1.5 mt-1`,children:[a(`span`,{className:`text-[9px] rounded-full px-1.5 py-0.5 font-medium ${e.process.mode===`forked`?`bg-blue-500/15 text-blue-400`:`bg-gray-500/15 text-gray-400`}`,children:e.process.mode===`forked`?y(`addons.addonCard.forked`):y(`addons.addonCard.inProcess`)}),e.process.pid!=null&&t(`span`,{className:`text-[9px] font-mono text-foreground-subtle`,children:[`PID `,e.process.pid]}),a(`span`,{className:`text-[9px] rounded-full px-1.5 py-0.5 font-medium ${e.process.state===`running`?`bg-emerald-500/15 text-emerald-400`:U===null?`bg-gray-500/15 text-gray-400`:`bg-red-500/15 text-red-400`}`,children:e.process.state})]})]})]}),!F&&t(`div`,{className:`flex items-center gap-1 px-3 py-1 border-t border-border/50 bg-surface-hover/20`,children:[t(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),z.mutate({addonId:N.id})},disabled:z.isPending||g,className:`inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[10px] font-medium border border-border text-foreground-subtle hover:text-blue-400 hover:border-blue-500/30 hover:bg-blue-500/10 disabled:opacity-50 transition-colors`,children:[a(b,{className:`h-3 w-3 ${z.isPending?`animate-spin`:``}`}),y(`addons.addonCard.restart`,`Restart`)]}),t(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),oe(e=>!e)},className:`inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[10px] font-medium border transition-colors ${ae?`border-primary/30 bg-primary/10 text-primary`:`border-border text-foreground-subtle hover:text-foreground hover:border-primary/30 hover:bg-primary/10`}`,children:[a(w,{className:`h-3 w-3`}),y(`addons.addonCard.logs`,`Logs`)]}),!F&&t(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),A(!0)},className:`inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[10px] font-medium border transition-colors ${k?`border-primary/30 bg-primary/10 text-primary`:`border-border text-foreground-subtle hover:text-foreground hover:border-primary/30 hover:bg-primary/10`}`,children:[a(E,{className:`h-3 w-3`}),y(`addons.addonCard.settings`,`Settings`)]}),a(`div`,{className:`flex-1`}),ue&&a(Ze,{packageName:N.packageName,displayName:N.name,selectedNode:v??ct,disabled:g})]}),n&&n.nodes.length>1&&!F&&t(`div`,{className:`border-t border-border px-3 py-1.5 bg-muted/10`,children:[a(`div`,{className:`text-[10px] font-medium text-foreground-subtle mb-1.5`,children:y(`addons.addonCard.clusterDeployment`,`Cluster Deployment`)}),a(`div`,{className:`space-y-1`,children:n.nodes.map(e=>t(`div`,{className:`flex items-center gap-2 text-[10px]`,children:[a(`div`,{className:`h-1.5 w-1.5 rounded-full shrink-0 ${e.status===`offline`?`bg-muted-foreground/30`:e.synced?`bg-success`:`bg-amber-500`}`}),a(`span`,{className:`font-medium text-foreground min-w-[60px]`,children:e.name}),a(`span`,{className:`font-mono text-foreground-subtle`,children:e.version}),!e.synced&&e.status!==`offline`&&a(`span`,{className:`text-[9px] px-1 py-0.5 rounded bg-amber-500/10 text-amber-400 border border-amber-500/20`,children:y(`addons.addonCard.outdated`)}),e.status===`offline`&&a(`span`,{className:`text-[9px] px-1 py-0.5 rounded bg-muted text-muted-foreground`,children:y(`common.offline`)}),e.synced&&e.status!==`offline`&&a(`span`,{className:`text-[9px] text-success`,children:y(`common.synced`)})]},e.nodeId))})]}),ae&&!F&&t(`div`,{className:`border-t border-border`,children:[t(`div`,{className:`flex items-center px-3 py-0.5 bg-surface-hover/20 border-b border-border/50`,children:[t(`div`,{className:`flex rounded border border-border overflow-hidden text-[9px]`,children:[a(`button`,{type:`button`,onClick:()=>le(`logs`),className:`px-2 py-0.5 transition-colors ${ce===`logs`?`bg-primary/10 text-primary`:`text-foreground-subtle hover:bg-surface-hover`}`,children:y(`addons.addonCard.logs`,`Logs`)}),a(`button`,{type:`button`,onClick:()=>le(`events`),className:`px-2 py-0.5 border-l border-border transition-colors ${ce===`events`?`bg-primary/10 text-primary`:`text-foreground-subtle hover:bg-surface-hover`}`,children:y(`addons.addonCard.events`,`Events`)})]}),a(`div`,{className:`flex-1`}),a(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),oe(!1)},className:`text-foreground-subtle hover:text-foreground`,children:a(x,{className:`h-3.5 w-3.5`})})]}),ce===`logs`&&a(G,{addonId:N.id,maxHeight:`max-h-64`,showFilters:!1}),ce===`events`&&a(Ce,{addonId:N.id,category:`addon.*`,maxHeight:`max-h-64`})]}),F&&t(u,{children:[a(`button`,{type:`button`,onClick:()=>C(e=>!e),className:`w-full flex items-center justify-center border-t border-border py-1 hover:bg-surface-hover/50 transition-colors`,children:a(S?te:ne,{className:`h-3.5 w-3.5 text-foreground-subtle`})}),S&&a(`div`,{className:`border-t border-border px-2.5 py-1.5 space-y-1.5`,children:p.addons.map(e=>a(lt,{addon:e,hideVersion:!0},e.manifest.id))})]}),k&&!F&&a(K,{open:!0,onOpenChange:e=>!e&&A(!1),children:t(W,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,children:[a(Te,{children:t(q,{className:`flex items-center gap-2`,children:[a(E,{className:`h-4 w-4 text-primary`}),y(`addons.addonCard.settingsTitle`,{name:de})]})}),t(xe,{className:`space-y-4`,children:[a(`div`,{className:`text-[10px] text-foreground-subtle mb-2`,children:y(`addons.addonCard.clusterWideSettingsOneValue`,`Cluster-wide settings — one value for every node. Per-node settings live under Cluster → the node → Settings.`)}),a(je,{nodeId:null,addonIds:[N.id],level:`global`,fieldScope:`cluster`,emptyMessage:y(`addons.addonCard.thisAddonExposesNoCluster`,`This addon exposes no cluster-wide settings. Anything it can configure is per-node — open it from Cluster → the node → Settings.`)}),rt(N)&&t(`div`,{children:[a(`div`,{className:`text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2`,children:y(`addons.addonCard.deviceExport`,`Device export`)}),a(ye,{addonId:N.id,onOpenDevice:e=>M(`/devices/${e}`)})]}),it(L)&&t(`div`,{children:[a(`div`,{className:`text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2`,children:y(`addons.addonCard.autoUpdate`,`Auto-Update`)}),a(st,{addonId:N.id})]}),N.components&&N.components.length>0&&t(`div`,{children:[a(`div`,{className:`text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2`,children:y(`addons.addonCard.components`,{count:N.components.length})}),a(`div`,{className:`flex flex-wrap gap-1`,children:N.components.map(e=>a(`span`,{className:`text-[10px] rounded bg-background border border-border px-1.5 py-0.5 text-foreground-subtle font-mono`,children:e},e))})]})]}),a(he,{children:a(P,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>A(!1),children:y(`common.close`,`Close`)})})]})})]})}c();var ut=`.tgz,.tar.gz,.zip`;function dt({onUploadSuccess:e}){let{t:r}=J(),[o,c]=s(!1),l=n(null),d=i(async t=>{c(!0);let n=new FormData;n.append(`file`,t);let r=localStorage.getItem(`camstack_admin_token`)??``;try{(await(await fetch(m(`/api/addons/upload`),{method:`POST`,headers:{Authorization:`Bearer ${r}`},body:n})).json()).success&&e()}finally{c(!1)}},[e]);return t(u,{children:[a(`input`,{ref:l,type:`file`,accept:ut,onChange:i(e=>{let t=e.target.files?.[0];t&&d(t),e.target.value=``},[d]),className:`hidden`}),t(`button`,{type:`button`,onClick:()=>l.current?.click(),disabled:o,className:`flex items-center gap-1.5 px-3 py-1.5 text-xs rounded-md bg-surface hover:bg-surface-hover border border-border disabled:opacity-50 transition-colors`,children:[o?a(C,{className:`w-3.5 h-3.5 animate-spin`}):a(p,{className:`w-3.5 h-3.5`}),o?r(`addons.addonUploadZone.uploading`,`Uploading...`):r(`addons.addonUploadZone.upload`,`Upload`)]})]})}var ft=/```[^\n]*\n([\s\S]*?)```/g;function pt(e){let t=[],n=0;for(let r of e.matchAll(ft)){let i=r.index??0;i>n&&t.push({kind:`text`,body:e.slice(n,i)}),t.push({kind:`code`,body:r[1]??``}),n=i+r[0].length}return n<e.length&&t.push({kind:`text`,body:e.slice(n)}),t}function mt(e){let t=e.trim();return t.startsWith(`https://`)||t.startsWith(`http://`)?t:null}function ht(e,t){let n=[],r=/(\*\*[^*]+\*\*|`[^`]+`|\[[^\]]+\]\([^)]+\))/g,i=0,o=0;for(let s of e.matchAll(r)){let r=s.index??0;r>i&&n.push(e.slice(i,r));let c=s[0],l=`${t}-${o}`;if(o+=1,c.startsWith(`**`))n.push(a(`strong`,{children:c.slice(2,-2)},l));else if(c.startsWith("`"))n.push(a(`code`,{className:`font-mono text-[0.9em]`,children:c.slice(1,-1)},l));else{let e=/^\[([^\]]+)\]\(([^)]+)\)$/.exec(c),t=e?.[1]??c,r=e?mt(e[2]??``):null;n.push(r?a(`a`,{href:r,target:`_blank`,rel:`noreferrer noopener`,className:`text-primary underline`,children:t},l):a(`span`,{children:t},l))}i=r+c.length}return i<e.length&&n.push(e.slice(i)),n}function gt(e,t){let n=e.split(`
|
|
5
|
-
`),r=[],i=[],o=[],s=0,c=()=>{if(i.length===0)return;let e=i.join(` `).trim();i=[],e.length!==0&&(r.push(a(`p`,{className:`mb-2 last:mb-0`,children:ht(e,`${t}-p-${s}`)},`${t}-p-${s}`)),s+=1)},l=()=>{if(o.length===0)return;let e=o;o=[],r.push(a(`ul`,{className:`mb-2 list-disc pl-4 last:mb-0`,children:e.map((e,n)=>a(`li`,{children:ht(e,`${t}-li-${s}-${n}`)},`${t}-li-${s}-${n}`))},`${t}-ul-${s}`)),s+=1};for(let e of n){let n=/^(#{1,3})\s+(.*)$/.exec(e),u=/^\s*[-*]\s+(.*)$/.exec(e);if(n){c(),l();let e=n[1]?.length??1,i=ht(n[2]??``,`${t}-h-${s}`),o=e===1?`text-sm font-semibold mb-2`:`text-xs font-semibold mb-1.5 mt-2`;r.push(a(e===1?`h3`:`h4`,{className:o,children:i},`${t}-h-${s}`)),s+=1;continue}if(u){c(),o=[...o,u[1]??``];continue}if(e.trim().length===0){c(),l();continue}l(),i=[...i,e.trim()]}return c(),l(),r}function _t({markdown:e}){return a(`div`,{className:`text-xs text-foreground leading-relaxed`,children:pt(e).map((e,t)=>e.kind===`code`?a(`pre`,{className:`mb-2 overflow-auto rounded-md bg-surface-hover p-2 font-mono text-[10px] last:mb-0`,children:e.body.replace(/\n$/,``)},`code-${t}`):a(`div`,{children:gt(e.body,`b${t}`)},`text-${t}`))})}c();function vt(e){return e.replace(/^@camstack\/(addon-)?/,``)}function yt(e,t,n){let r=$e(e,n);return r.some(e=>e.version===t)?r:[{version:t,distTags:[],deprecated:void 0},...r]}function bt({pending:e,failed:n,body:r,missing:i}){let{t:o}=J();return e?t(`div`,{className:`flex items-center gap-2 py-6 text-xs text-foreground-subtle`,children:[a(C,{className:`h-3.5 w-3.5 animate-spin`}),o(`addons.installDialog.loadingDocument`,`Loading…`)]}):n||r===void 0?a(`p`,{className:`py-4 text-xs text-danger`,children:o(`addons.installDialog.couldNotLoadDocument`,`Could not load this file from the registry.`)}):r.status===`ok`&&r.markdown!==void 0?a(_t,{markdown:r.markdown}):r.status===`error`?a(`p`,{className:`py-4 text-xs text-danger`,children:o(`addons.installDialog.documentError`,`Could not load this file. {{message}}`,{message:r.message??``})}):a(`p`,{className:`py-4 text-xs text-foreground-subtle`,children:i})}function xt({target:e,installing:n,installError:r,onClose:i,onInstall:o}){let{t:c}=J(),[l,u]=s(e.version),[d,f]=s(!1),p=H({name:e.name}),m=Oe({name:e.name,version:l}),h=p.data??[],g=et(h),_=yt(h,l,d),v=m.data;return a(K,{open:!0,onOpenChange:e=>!e&&i(),children:t(W,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,children:[a(Te,{children:a(q,{children:c(`addons.installDialog.title`,`Install {{name}}`,{name:vt(e.name)})})}),t(xe,{className:`space-y-3`,children:[a(`p`,{className:`font-mono text-[10px] text-foreground-subtle`,children:e.name}),e.description.length>0&&a(`p`,{className:`text-xs text-foreground`,children:e.description}),t(`div`,{className:`space-y-1.5`,children:[a(`span`,{className:`text-[10px] text-foreground-subtle`,children:c(`addons.installDialog.version`,`Version`)}),a(N,{"aria-label":c(`addons.installDialog.version`,`Version`),value:l,options:_.map(e=>({value:e.version,label:Qe(e)?c(`addons.installDialog.deprecatedVersion`,`{{version}} (deprecated)`,{version:e.version}):e.version})),onChange:e=>u(e.target.value)}),p.isError&&a(`p`,{className:`text-[10px] text-danger`,children:c(`addons.versionPicker.registryError`,`Could not load versions from the registry.`)}),g>0&&a(P,{type:`button`,variant:`ghost`,size:`sm`,className:`h-auto justify-start px-0 text-[10px] font-normal text-foreground-subtle underline`,onClick:()=>f(e=>!e),children:d?c(`addons.versionPicker.hideOlder`,`Hide older versions`):c(`addons.versionPicker.showOlder`,`Show older versions ({{count}})`,{count:g})})]}),t(k,{defaultValue:`readme`,children:[t(j,{children:[a(L,{value:`readme`,children:c(`addons.installDialog.readme`,`README`)}),a(L,{value:`changelog`,children:c(`addons.installDialog.changelog`,`CHANGELOG`)})]}),a(z,{value:`readme`,children:a(`div`,{className:`max-h-80 overflow-auto rounded-md border border-border bg-background p-3`,children:a(bt,{pending:m.isPending,failed:m.isError,body:v?.readme,missing:c(`addons.installDialog.missingReadme`,`This package has no README.`)})})}),a(z,{value:`changelog`,children:a(`div`,{className:`max-h-80 overflow-auto rounded-md border border-border bg-background p-3`,children:a(bt,{pending:m.isPending,failed:m.isError,body:v?.changelog,missing:c(`addons.installDialog.missingChangelog`,`This package has no CHANGELOG.`)})})})]}),r!=null&&r.length>0&&a(`p`,{className:`text-xs text-danger`,children:r})]}),t(he,{children:[a(P,{type:`button`,variant:`outline`,size:`sm`,onClick:i,children:c(`common.cancel`,`Cancel`)}),a(P,{type:`button`,size:`sm`,disabled:n||l.length===0,onClick:()=>o(e.name,l),children:n?a(C,{className:`h-3.5 w-3.5 animate-spin`}):c(`addons.installDialog.install`,`Install`)})]})]})})}var St=new Set([`@camstack/system`,`@camstack/types`,`@camstack/sdk`,`@camstack/ui-library`,`@camstack/addon-agent-ui`]);function Ct(e,t){let n=new Map;for(let r of e){if(r.isHub||r.onHub||St.has(r.packageName)||!t.isHub&&r.nodeId!==t.id)continue;let e=n.get(r.packageName)??[];e.push(r),n.set(r.packageName,e)}return[...n].map(([e,t])=>({packageName:e,rows:t})).sort((e,t)=>e.packageName.localeCompare(t.packageName))}function wt({selectedNode:e}){let{t:n}=J(),{data:r}=Ee(Je,{staleTime:Ye});if(r===void 0)return null;let i=Ct(r.installations,e),o=r.unreachable.filter(t=>e.isHub||t.nodeId===e.id);return i.length===0&&o.length===0?null:t(`div`,{className:`rounded-lg border border-warning/30 bg-warning/5 px-3 py-2.5 space-y-2`,children:[t(`div`,{className:`flex items-center gap-2 text-[11px] font-semibold text-foreground`,children:[a(f,{className:`h-3.5 w-3.5 text-warning`}),e.isHub?n(`addons.nodeOnlyPackagesPanel.installedOnAgentsButNot`,`Installed on agents but not on the hub`):n(`addons.nodeOnlyPackagesPanel.installedOnButNotOn`,`Installed on {{name}} but not on the hub`,{name:e.name})]}),o.length>0&&a(`div`,{className:`text-[10px] text-foreground-subtle`,children:n(`addons.nodeOnlyPackagesPanel.unreachable`,{nodes:o.map(e=>e.nodeId).join(`, `)})}),i.map(n=>t(`div`,{className:`flex items-center justify-between gap-3 flex-wrap rounded-md border border-border bg-surface px-3 py-2`,children:[t(`div`,{className:`min-w-0`,children:[a(`div`,{className:`text-xs font-mono text-foreground break-all`,children:n.packageName}),a(`div`,{className:`text-[10px] text-foreground-subtle`,children:n.rows.map(e=>`${e.nodeName}${e.version===null?``:` ${e.version}`}${e.isOnline?``:` (offline)`}`).join(` · `)})]}),a(Ze,{packageName:n.packageName,displayName:n.packageName,selectedNode:e,hideNodeAction:e.isHub})]},n.packageName))]})}function Tt({addon:e,installing:n,onInstall:r}){let{t:i}=J();return t(`div`,{className:`flex items-center gap-3 px-3 py-2 hover:bg-surface-hover transition-colors`,children:[a(`div`,{className:`w-6 h-6 rounded-md bg-primary/10 flex items-center justify-center text-primary text-[9px] font-bold shrink-0`,children:e.name.replace(`@camstack/addon-`,``).charAt(0).toUpperCase()}),t(`div`,{className:`flex-1 min-w-0`,children:[t(`div`,{className:`flex items-baseline gap-2 min-w-0`,children:[a(`span`,{className:`text-[11px] font-semibold break-words`,children:e.name.replace(/^@camstack\/(addon-)?/,``)}),t(`span`,{className:`text-[10px] text-foreground-subtle shrink-0`,children:[`v`,e.version]})]}),a(`div`,{className:`font-mono text-[9px] text-foreground-subtle/80 truncate`,children:e.name}),e.description&&a(`div`,{className:`text-[10px] text-foreground-subtle truncate`,children:e.description})]}),e.installed?a(O,{variant:`success`,icon:a(g,{className:`h-3 w-3`}),children:e.installedVersion??i(`system.capabilityCatalog.installed`,`Installed`)}):t(P,{size:`sm`,onClick:()=>r(e),disabled:n,className:`shrink-0`,children:[n?a(C,{className:`h-3 w-3 animate-spin`}):a(v,{className:`h-3 w-3`}),i(`system.capabilityCatalog.install`,`Install`)]})]})}function Et({capability:e,installing:n,onInstall:r}){let{t:i}=J(),{data:o,isPending:s,isError:c}=ve({capability:e}),l;if(c)l=a(`div`,{className:`px-3 py-2 text-xs text-danger`,children:i(`system.capabilityCatalog.couldNotSearchTheNpm`,`Could not search the npm catalog right now. Try again in a moment.`)});else if(s||o===void 0)l=t(`div`,{className:`flex items-center gap-2 px-3 py-2 text-xs text-foreground-subtle`,children:[a(C,{className:`h-3 w-3 animate-spin`}),i(`system.capabilityCatalog.searchingTheNpmCatalog`,`Searching the npm catalog…`)]});else{let t=o.filter(e=>!e.installed);l=t.length===0?a(`div`,{className:`px-3 py-2 text-xs text-foreground-subtle`,children:o.length===0?i(`system.capabilityCatalog.noPublishedAddonDeclaresThe`,`No published addon declares the "{{capability}}" capability.`,{capability:e}):i(`system.capabilityCatalog.everyPublishedAddonThatDeclares`,`Every published addon that declares "{{capability}}" is already installed.`,{capability:e})}):a(`div`,{className:`divide-y divide-border`,children:t.map(e=>a(Tt,{addon:e,installing:n,onInstall:r},e.name))})}return t(`section`,{className:`rounded-md border border-border bg-surface overflow-hidden`,"aria-label":i(`system.capabilityCatalog.availableToInstall`,`Available to install`),children:[a(`h2`,{className:`px-3 py-1.5 text-[10px] uppercase tracking-wide text-foreground-subtle border-b border-border`,children:i(`system.capabilityCatalog.availableToInstall`,`Available to install`)}),l]})}c();function Dt(e){return e===`npm`||e===`dev`?e:null}var Ot=`rounded-full border border-primary bg-primary/10 px-2 py-0.5 text-[10px] text-foreground`,kt=`rounded-full border border-border px-2 py-0.5 text-[10px] text-foreground-muted hover:bg-surface-hover`,At=[{seconds:900,label:`15m`},{seconds:3600,label:`1h`},{seconds:21600,label:`6h`},{seconds:43200,label:`12h`},{seconds:86400,label:`24h`}],jt=new Set([`@camstack/system`,`@camstack/types`,`@camstack/sdk`,`@camstack/shm-ring`,`@camstack/ui-library`]);function Mt(e){return e!==void 0&&jt.has(e)}var Nt={id:`hub`,name:`Hub`,isHub:!0,isOnline:!0};function Pt(e,t){let n=e??`hub-only`;return n===`any-node`?!0:n===`hub-only`?t:!t}function Ft(e){return e===`local`?`dev`:`npm`}function It(e){let t=e;if(!t?.manifest)return null;let n={...t.manifest,name:t.manifest.name??t.manifest.id,version:t.manifest.version??`0.0.0`,capabilities:t.manifest.capabilities??[]},r=t.process,i=r?{pid:r.pid,mode:r.mode===`forked`?`forked`:`in-process`,state:r.state??`unknown`,...r.reason===void 0?{}:{reason:r.reason}}:void 0,a=t.health,o=t.declaration?.execution,s=t.manifest.execution,c=o?.placement??s?.placement;return{manifest:n,enabled:!0,source:t.source,installSource:t.installSource,installedOn:[],...i?{process:i}:{},hasBackup:t.hasBackup,...a?{health:a}:{},...c?{placement:c}:{}}}function Lt(e){let t=new Map,n=[];for(let r of e){let e=r.manifest.packageName;if(!e){n.push(r);continue}let i=t.get(e);if(i)i.addons.push(r);else{let n=r.manifest.bundle,i={packageName:e,displayName:n?.displayName??r.manifest.packageDisplayName??r.manifest.name,version:r.manifest.packageVersion,addons:[r],...r.installSource===void 0?{}:{installSource:r.installSource},...n===void 0?{}:{bundle:n}};t.set(e,i)}}let r=[];for(let e of t.values())e.bundle!==void 0||e.addons.length>=2?r.push({bundle:e,representative:e.addons[0]}):r.push(e.addons[0]);return r.push(...n),r}function $(e){return`bundle`in e}function Rt({addons:c,clusterStatus:u,selectedNode:d,onRefresh:f,listPhase:p}){let{t:m}=J(),h=l(),[g,_]=s(``),y=e(g),[x,w]=s(!1),T=n(null);o(()=>{if(!x)return;let e=e=>{T.current&&!T.current.contains(e.target)&&w(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[x]);let{data:E}=ce({nodeId:d.id}),te=r(()=>{let e=new Map;for(let t of E??[])e.set(t.name,t.latestVersion);return e},[E]),ne=r(()=>(E??[]).filter(e=>!e.isSystem).length,[E]),[re,D]=s(()=>new Set),[ie,O]=s(()=>new Map),ae=i(e=>{D(t=>new Set(t).add(e))},[]),se=i(e=>{D(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),n})},[]),k=i((e,t)=>{O(n=>new Map(n).set(e,t))},[]),A=i(e=>{O(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n})},[]),j=ue({onMutate:e=>{ae(e.name),A(e.name)},onSuccess:(e,t)=>{se(t.name);let n=e;if(n&&n.success===!1){k(t.name,n.error??`Update failed (no error message returned by server)`);return}h.invalidateQueries({queryKey:[[`addons`]]}),h.invalidateQueries({queryKey:[[`addons`,`listUpdates`]]})},onError:(e,t)=>{se(t.name),k(t.name,e instanceof Error?e.message:String(e))}}),M=ze(),N=n(new Set);o(()=>{let e=new Set;for(let[t,n]of M)Le(n)&&e.add(t);let t=[...N.current].some(t=>!e.has(t));N.current=e,t&&(h.invalidateQueries({queryKey:[[`addons`]]}),h.invalidateQueries({queryKey:[[`addons`,`listUpdates`]]}))},[M,h]);let{data:P}=V(void 0),F=Se({onSuccess:()=>{h.invalidateQueries({queryKey:[[`addons`,`getAutoUpdateSettings`]]})}}),fe=de({onSuccess:()=>{h.invalidateQueries({queryKey:[[`addons`,`getAutoUpdateSettings`]]})}}),{data:I,isFetching:pe}=ve({query:y||void 0},{enabled:x}),L=le(),{data:R}=we(void 0),z=R?.requestedAt,[B,he]=s(null),[H,ge]=s(!1);o(()=>{if(R?.kind===`framework-bulk-update`&&R.requestedAt!==B){he(R.requestedAt),ge(!0);let e=window.setTimeout(()=>ge(!1),6e3);return()=>window.clearTimeout(e)}},[z,B,R]),me();let U=i(async()=>{let e=(E??[]).filter(e=>!e.isSystem);if(e.length!==0){if(!d.isHub){for(let t of e)await j.mutateAsync({name:t.name,version:t.latestVersion,nodeId:d.id});return}await L.mutateAsync({kind:`update`,targets:e.map(e=>({name:e.name,version:e.latestVersion})),nodeIds:[d.id]})}},[E,d.id,d.isHub,L,j]),[_e,W]=s(null),[ye,be]=s(null),xe=e=>{be(null),W(e)},G=De({onSuccess:()=>{W(null),be(null),h.invalidateQueries({queryKey:[[`addons`]]}),h.invalidateQueries({queryKey:[[`addonPages`]]}),h.invalidateQueries({queryKey:[[`capabilities`]]}),h.invalidateQueries({queryKey:[[`integrations`]]})},onError:e=>{be(e instanceof Error?e.message:`Install failed`)}}),[K,Ce]=s(`type`),[Te,Ee]=s(()=>typeof window>`u`?`grouped`:window.localStorage.getItem(`camstack.addons.viewMode`)===`flat`?`flat`:`grouped`),Oe=e=>{Ee(e),typeof window<`u`&&window.localStorage.setItem(`camstack.addons.viewMode`,e)},[q,Y]=ke(),X=q.get(`capability`),Ae=q.get(`updatable`)===`1`,je=q.get(`error`)===`1`,Z=Dt(q.get(`source`)),Me=i(e=>{let t=new URLSearchParams(q);e?t.set(`updatable`,`1`):t.delete(`updatable`),Y(t,{replace:!0})},[q,Y]),Pe=i(e=>{let t=new URLSearchParams(q);e?t.set(`error`,`1`):t.delete(`error`),Y(t,{replace:!0})},[q,Y]),Fe=i(e=>{let t=new URLSearchParams(q);e===null?t.delete(`source`):t.set(`source`,e),Y(t,{replace:!0})},[q,Y]),Ie=r(()=>c.filter(e=>Ne(e.process)!==null).length,[c]),Q=r(()=>{let e=c.filter(e=>!Mt(e.manifest.packageName));return d.isHub||(e=e.filter(e=>Pt(e.placement,d.isHub))),X&&(e=e.filter(e=>(e.manifest.capabilities??[]).some(e=>(typeof e==`string`?e:e.name)===X))),Ae&&(e=e.filter(e=>{let t=e.manifest.packageName;return t!==void 0&&te.has(t)})),Z!==null&&(e=e.filter(e=>Ft(e.installSource)===Z)),je&&(e=e.filter(e=>Ne(e.process)!==null)),e},[c,d.isHub,X,Ae,Z,je,te]),Re=()=>{let e=new URLSearchParams(q);e.delete(`capability`),Y(e,{replace:!0})},Be=Te===`flat`?Q:Lt(Q),Ve=r(()=>{let e=[...Be];switch(K){case`type`:e.sort((e,t)=>{let n=+!$(e),r=+!$(t);if(n!==r)return n-r;let i=$(e)?e.bundle.displayName:e.manifest.name,a=$(t)?t.bundle.displayName:t.manifest.name;return i.localeCompare(a)});break;case`name`:e.sort((e,t)=>{let n=$(e)?e.bundle.displayName:e.manifest.name,r=$(t)?t.bundle.displayName:t.manifest.name;return n.localeCompare(r)});break;case`source`:e.sort((e,t)=>{let n=$(e)?e.bundle.installSource??``:e.installSource??``,r=$(t)?t.bundle.installSource??``:t.installSource??``;return n.localeCompare(r)});break}return e},[Be,K]);return t(`div`,{className:`space-y-3`,children:[[...ie.entries()].map(([e,n])=>a(`div`,{className:`rounded-md border border-danger/30 bg-danger/5 px-2.5 py-1.5 text-[11px]`,children:t(`div`,{className:`flex items-start justify-between gap-3`,children:[t(`div`,{className:`space-y-0.5`,children:[a(`div`,{className:`font-medium text-danger`,children:m(`systemPage.addons.updateFailed`,{name:e})}),a(`div`,{className:`text-foreground-subtle font-mono`,children:n})]}),a(`button`,{type:`button`,onClick:()=>A(e),className:`text-foreground-subtle hover:text-foreground text-[10px]`,children:m(`common.dismiss`)})]})},e)),t(`div`,{className:`flex items-center gap-x-2 gap-y-1.5 flex-wrap`,children:[t(`div`,{className:`flex items-center gap-1.5`,children:[a(`span`,{className:`text-[10px] text-foreground-subtle`,children:m(`admin.system.addons.sort`,`Sort:`)}),t(`select`,{value:K,onChange:e=>Ce(e.target.value),className:`rounded-md border border-border bg-surface px-2 py-1 text-[11px] text-foreground focus:outline-none focus:border-primary/50`,children:[a(`option`,{value:`type`,children:m(`admin.system.addons.bundlesFirst`,`Bundles first`)}),a(`option`,{value:`name`,children:m(`admin.system.addons.name`,`Name`)}),a(`option`,{value:`source`,children:m(`admin.system.addons.installSource`,`Install source`)})]})]}),t(`div`,{className:`flex items-center gap-1.5`,children:[a(`span`,{className:`text-[10px] text-foreground-subtle`,children:m(`admin.system.addons.view`,`View:`)}),a(`div`,{className:`flex rounded-md border border-border overflow-hidden text-[10px] font-medium`,children:[`grouped`,`flat`].map(e=>a(`button`,{type:`button`,onClick:()=>Oe(e),className:`px-2 py-1 transition-colors capitalize ${Te===e?`bg-primary/10 text-primary`:`bg-transparent text-foreground-subtle hover:bg-surface-hover`}`,title:e===`grouped`?m(`admin.system.addons.groupMultiAddonPackagesInto`,`Group multi-addon packages into a bundle card`):m(`admin.system.addons.showEveryAddonAsIts`,`Show every addon as its own card`),children:e},e))})]}),d.isHub&&t(`div`,{className:`flex items-center gap-1.5`,children:[a(b,{className:`h-3 w-3 text-foreground-subtle`}),a(`span`,{className:`text-[10px] text-foreground-subtle`,children:m(`admin.system.addons.autoUpdate`,`Auto-Update:`)}),a(`div`,{className:`flex rounded-md border border-border overflow-hidden text-[10px] font-medium`,children:[`off`,`latest`,`beta`].map(e=>a(`button`,{type:`button`,onClick:()=>F.mutate({channel:e}),disabled:F.isPending,className:`px-2 py-1 transition-colors capitalize ${P?.channel===e?e===`off`?`bg-gray-700 text-gray-200`:e===`latest`?`bg-blue-500/20 text-blue-400`:`bg-amber-500/20 text-amber-400`:`bg-transparent text-foreground-subtle hover:bg-surface-hover`} ${e===`off`?``:`border-l border-border`}`,children:e},e))})]}),d.isHub&&t(`div`,{className:`flex items-center gap-1.5`,children:[a(`span`,{className:`text-[10px] text-foreground-subtle`,children:m(`admin.system.addons.checkEvery`,`Check every:`)}),a(`select`,{className:`rounded-md border border-border bg-transparent px-1.5 py-1 text-[10px] font-medium text-foreground-subtle`,value:P?.updateCheckIntervalSeconds??21600,disabled:fe.isPending||P===void 0,onChange:e=>{P!==void 0&&fe.mutate({channel:P.channel,updateCheckIntervalSeconds:Number(e.target.value)})},children:At.map(e=>a(`option`,{value:e.seconds,children:e.label},e.seconds))})]}),ne>0&&t(`button`,{type:`button`,onClick:()=>void U(),disabled:L.isPending,className:`flex items-center gap-1 px-2 py-1 text-[11px] rounded-md bg-blue-500/10 text-blue-400 hover:bg-blue-500/20 border border-blue-500/30 disabled:opacity-50 transition-colors font-medium`,children:[L.isPending?a(C,{className:`w-3 h-3 animate-spin`}):a(v,{className:`w-3 h-3`}),L.isPending?m(`admin.system.addons.updating`,`Updating…`):m(`admin.system.addons.updateAll`,`Update All ({{nonSystemUpdateCount}})`,{nonSystemUpdateCount:ne})]})]}),t(`div`,{className:`flex flex-wrap items-center gap-1.5`,role:`group`,"aria-label":m(`admin.system.addons.filterInstalledAddons`,`Filter installed addons`),children:[a(`span`,{className:`text-[10px] text-foreground-subtle`,children:m(`admin.system.addons.filter`,`Filter:`)}),[{id:`updatable`,label:m(`admin.system.addons.updatable`,`Updatable`),pressed:Ae,toggle:()=>Me(!Ae)},{id:`error`,label:m(`admin.system.addons.inError`,`In error ({{count}})`,{count:Ie}),pressed:je,toggle:()=>Pe(!je)},{id:`npm`,label:`npm`,pressed:Z===`npm`,toggle:()=>Fe(Z===`npm`?null:`npm`)},{id:`dev`,label:m(`admin.system.addons.dev`,`Dev`),pressed:Z===`dev`,toggle:()=>Fe(Z===`dev`?null:`dev`)}].map(e=>a(`button`,{type:`button`,"aria-pressed":e.pressed,onClick:e.toggle,className:e.pressed?Ot:kt,children:e.label},e.id))]}),t(`div`,{className:`flex flex-col gap-1.5 sm:flex-row sm:items-center sm:gap-2`,children:[t(`div`,{className:`relative flex-1 min-w-0 sm:min-w-[200px]`,ref:T,children:[a(oe,{type:`text`,value:g,onChange:e=>{_(e.target.value),w(!0)},onFocus:()=>w(!0),placeholder:m(`admin.system.addons.searchAddonsOnNpm`,`Search addons on npm...`),"aria-label":m(`admin.system.addons.searchAddonsOnNpm2`,`Search addons on npm`),disabled:L.isPending,leftSlot:a(S,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),rightSlot:pe?a(C,{className:`h-3 w-3 animate-spin`}):void 0}),x&&I&&I.length>0&&t(`div`,{className:`absolute left-0 right-0 top-full mt-1 z-40 rounded-md border border-border bg-surface shadow-xl overflow-hidden`,children:[I.length>0&&a(`div`,{className:`px-3 py-1.5 text-[10px] uppercase tracking-wide text-foreground-subtle border-b border-border`,children:m(`systemPage.addons.npmResults`,{count:I.length})}),I&&I.length>0&&a(`div`,{className:`max-h-72 overflow-auto divide-y divide-border`,children:I.map(e=>a(Tt,{addon:e,installing:G.isPending,onInstall:e=>xe({name:e.name,version:e.version,description:e.description})},e.name))})]})]}),a(dt,{onUploadSuccess:()=>{h.invalidateQueries({queryKey:[[`addons`]]}),f()}})]}),X&&t(`div`,{className:`flex items-center gap-2 px-2.5 py-1.5 rounded-md bg-primary/10 border border-primary/30 text-xs`,children:[a(`span`,{className:`text-foreground-subtle`,children:m(`admin.system.addons.filteringByCapability`,`Filtering by capability:`)}),a(`span`,{className:`font-mono text-primary font-semibold`,children:X}),a(`button`,{type:`button`,onClick:Re,className:`ml-auto text-xs text-foreground-subtle hover:text-foreground underline`,children:m(`admin.system.addons.clear`,`Clear`)})]}),X&&a(Et,{capability:X,installing:G.isPending,onInstall:e=>xe({name:e.name,version:e.version,description:e.description})}),X&&Q.length>0&&a(`h2`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:m(`admin.system.addons.installed`,`Installed`)}),H&&t(`div`,{className:`fixed top-[calc(env(safe-area-inset-top)+1rem)] right-[calc(env(safe-area-inset-right)+1rem)] z-50 flex items-start gap-2 px-3 py-2.5 rounded-md border border-green-500/30 bg-green-500/10 shadow-lg backdrop-blur-sm max-w-sm pointer-events-auto`,children:[a(ee,{className:`w-4 h-4 shrink-0 mt-0.5 text-green-400`}),t(`div`,{children:[a(`div`,{className:`text-[11px] font-semibold text-foreground`,children:m(`admin.system.addons.bulkUpdateCompleted`,`Bulk update completed`)}),a(`div`,{className:`text-[10px] text-foreground-subtle mt-0.5`,children:m(`admin.system.addons.systemPackagesUpdatedHubRestarted`,`System packages updated — hub restarted successfully.`)})]})]}),p===`pending`&&t(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[a(C,{className:`h-3 w-3 animate-spin`}),m(`admin.system.addons.loadingInstalled`,`Loading installed addons…`)]}),p===`error`&&a(`div`,{className:`text-xs text-danger`,children:m(`admin.system.addons.failedToLoadAddons`,`Failed to load addons`)}),p===`ready`&&Q.length===0&&a(`div`,{className:`text-xs text-foreground-subtle`,children:c.length===0?m(`admin.system.addons.noAddonsInstalled`,`No addons installed`):X?m(`admin.system.addons.noInstalledAddonDeclaresThe`,`No installed addon declares the "{{capabilityFilter}}" capability. Any addon you can install appears under "Available to install" above.`,{capabilityFilter:X}):m(`admin.system.addons.noAddonsCompatibleWithPlacement`,`No addons compatible with {{name}} (placement filter active)`,{name:d.name})}),a(`div`,{className:`space-y-1.5`,children:p===`ready`&&Ve.map(e=>{let t=$(e)?e.bundle.packageName:e.manifest.packageName,n=te.get(t),r=$(e)?e.representative:e,i=n?e=>j.mutate({name:t,version:e,nodeId:d.id}):void 0,o=M.get(t)??null,s=o!==null&&Le(o);return a(lt,{addon:r,clusterStatus:u?.[r.manifest.id],bundle:$(e)?e.bundle:void 0,availableUpdate:n,isUpdating:re.has(t)||s,jobProgress:o,onUpdate:i,disabledByBulk:L.isPending,selectedNode:d},$(e)?t:e.manifest.id)})}),_e!==null&&a(xt,{target:_e,installing:G.isPending,installError:ye,onClose:()=>W(null),onInstall:(e,t)=>G.mutate({packageName:e,version:t})})]})}function zt(){let{t:e}=J(),r=l(),{data:i}=ae(void 0),{nodes:s}=be(),{selection:c,selectNode:u,requestedNodeId:d}=Me(s.length>0?s:[Nt]),f=c.node??Nt,p=f.id,m=s.length>0?c.staleNodeId:null,{data:h,isLoading:g,isError:_}=I({nodeId:p}),v=_e(),y=A(),x=v.isPending||y.isPending,S=async()=>{await v.mutateAsync({nodeId:p}),await y.mutateAsync(),r.invalidateQueries({queryKey:[[`addons`]]})},C=n(v);C.current=v;let ee=n(d??`hub`);o(()=>{C.current.mutate({nodeId:ee.current})},[]);let w=(h??[]).map(It).filter(e=>e!==null);return t(Ae,{children:[t(`div`,{className:`flex items-center justify-between gap-2 flex-wrap`,children:[a(ge,{selectedNodeId:p,onSelect:u}),t(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[!g&&!_&&a(`span`,{className:`text-[10px] rounded-full bg-primary/10 text-primary px-2 py-0.5 font-medium`,children:e(`systemPage.addons.installedCount`,{count:w.length})}),t(`button`,{type:`button`,onClick:()=>void S(),disabled:x,className:`inline-flex items-center gap-1 px-2 py-1 text-[11px] rounded-md bg-surface hover:bg-surface-hover border border-border disabled:opacity-50 transition-colors`,title:e(`admin.system.addons.reFetchAddonsCheckNpm`,`Re-fetch addons + check npm for new versions`),children:[a(b,{className:`w-3 h-3 ${x?`animate-spin`:``}`}),e(`admin.system.addons.checkForUpdates`,`Check for updates`)]})]})]}),a(Z,{staleNodeId:m,shownNodeName:f.name}),a(wt,{selectedNode:f}),a(Rt,{addons:w,clusterStatus:i,selectedNode:f,onRefresh:()=>void S(),listPhase:g?`pending`:_?`error`:`ready`})]})}export{zt as AddonsPage};
|
|
@@ -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{Cn as l,It as u,Nt as d,Rr as f,Si as p,Xi as m,bn as h,dt as g,ht as _,kn as v,or as y,ot as b,pi as x,pn as S,sa as C,si as w,un as ee,vn as T,xi as te,yi as E,zr as D}from"./player-overlays-Dbv95cvz.js";import{Li as O}from"./client-DvJxGh2F.js";import{t as k}from"./search-x-CKQw--aU.js";import{$a as A,Dn as j,Ga as M,Ja as ne,Ka as N,Mt as re,Oi as P,Pt as F,Qa as I,So as L,Wa as R,Wn as z,Xa as B,_n as V,bo as H,cs as U,ds as W,fo as ie,hr as G,io as ae,jt as oe,li as K,ls as q,mr as se,nn as ce,os as le,pd as ue,pr as de,ps as fe,qa as pe,ro as me,so as he,sr as ge,ss as J,ud as Y,ui as _e,us as ve,vr as ye,yr as be,zo as xe}from"./src-DntJrWmU.js";import{t as X}from"./useTranslation-BJr-n0es.js";import{n as Se}from"./addon-icons-context-lrP_33gc.js";import{P as Ce,fr as we,lr as Te,mr as Ee,pr as De}from"./index-C3uCLHv0.js";import{t as Oe}from"./device-integration-icon-0oWIIjcP.js";import{n as ke,r as Ae,t as je}from"./ScanNetworkModal-DXzDOpxk.js";import{t as Me}from"./NodeAddonsSettingsPanel-Dq6sGWkR.js";s();function Z(e){let t=[];for(let n of e)n.type===`probe`&&t.push(n.key),n.type===`group`&&`fields`in n&&t.push(...Z(n.fields));return t}function Ne(e,t,i){let[a,s]=o(`idle`),[c,l]=o({}),u=n(()=>{let t=[];for(let n of e.sections)t.push(...Z(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 Pe(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(...Pe(n.fields));return t}function Fe(e){return e==null?!0:typeof e==`string`?e.trim()===``:!1}function Ie(e,t={}){for(let n of e){if(n.type===`group`&&`fields`in n){Ie(n.fields,t);continue}`key`in n&&n.key&&`default`in n&&n.default!==void 0&&(t[n.key]=n.default)}return t}function Le(){return typeof crypto<`u`&&typeof crypto.randomUUID==`function`?`probe-${crypto.randomUUID()}`:`probe-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function Re({open:t,integrationId:s,addonId:l,onClose:u}){let{t:f}=X(),p=c(),[m,h]=o({}),[v,b]=o(!1),[x,C]=o(null),[w,ee]=o(Le),T=H({addonId:l},{enabled:t}),E=T.data?.deviceType??null,D=he({addonId:l,type:E??O.Camera},{enabled:t&&T.isSuccess&&E!==null}),k=D.data??null;a(()=>{t&&(h(k?Ie(k.sections.flatMap(e=>e.fields)):{}),ee(Le()),b(!1),C(null))},[t,s,k]);let A=n(()=>({...m,_probeRequestId:w}),[m,w]),j=I({onSuccess:()=>{p.invalidateQueries({queryKey:[[`deviceManager`]]})}}),M=xe(),ne=r(async(e,t)=>{b(!0);let n=await M.mutateAsync({addonId:l,type:E??O.Camera,key:e,value:t,formValues:A});return n.status===`ok`&&n.suggestedValues&&h(e=>{let t=!1,r={...e};for(let[i,a]of Object.entries(n.suggestedValues??{}))Fe(e[i])&&!Fe(a)&&(r[i]=a,t=!0);return t?r:e}),n},[M,l,A,E]),{testAllStatus:N,hasProbeFields:re,probeResults:P,handleTestAll:F,clearProbeResult:L}=Ne(k??{sections:[]},m,ne);async function R(e){C(null);try{await j.mutateAsync({addonId:l,type:E??O.Camera,config:m,integrationId:s}),e?h(k?Ie(k.sections.flatMap(e=>e.fields)):{}):u()}catch(e){C(e instanceof Error?e.message:String(e))}}if(!t)return null;let z=Pe((k?.sections??[]).flatMap(e=>e.fields)).filter(e=>Fe(m[e])),B=z.length===0,V=T.isLoading||E!==null&&D.isLoading,U=T.isError||T.isSuccess&&E===null||D.isError||D.isSuccess&&k===null;return e(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center`,children:[i(`div`,{className:`absolute inset-0 bg-black/60`,onClick:u}),e(`div`,{className:`relative z-10 flex w-full max-w-2xl flex-col max-h-[calc(90dvh-2*max(env(safe-area-inset-top),env(safe-area-inset-bottom)))] rounded-xl border border-border bg-background shadow-2xl`,children:[e(`div`,{className:`flex items-center justify-between border-b border-border px-5 py-4 shrink-0`,children:[i(`h2`,{className:`text-sm font-semibold text-foreground`,children:f(`integrations.addDevice`)}),i(`button`,{onClick:u,className:`rounded-md p-1 text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,children:i(g,{className:`h-4 w-4`})})]}),i(`div`,{className:`flex-1 min-h-0 overflow-y-auto px-5 py-4 space-y-3`,children:V?i(`div`,{className:`flex items-center justify-center py-8`,children:i(y,{className:`h-5 w-5 animate-spin text-primary`})}):U?e(`div`,{className:`flex items-start gap-3 rounded-lg border border-destructive/40 bg-destructive/10 px-4 py-3`,children:[i(d,{className:`h-4 w-4 text-destructive mt-0.5 shrink-0`}),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(Te,{i18nKey:`integrations.addDeviceDialog.notReady`,values:{addonId:l},components:{mono:i(`span`,{className:`font-mono`})}})})]})]}):i(Ce,{schema:k,values:m,onChange:h,onTestField:ne,probeResults:P,onClearProbe:L})}),!U&&!V&&e(`div`,{className:`border-t border-border bg-surface/50 shrink-0`,children:[e(`button`,{type:`button`,onClick:()=>b(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(S,{className:`h-3.5 w-3.5`}),f(`integrations.addDeviceDialog.testLogs`,`Test logs`),i(`span`,{className:`font-mono text-[9px] opacity-60`,children:w.slice(0,14)})]}),i(te,{className:`h-3.5 w-3.5 transition-transform ${v?`rotate-180`:``}`})]}),v&&i(`div`,{className:`border-t border-border max-h-64 overflow-hidden`,children:i(ce,{addonId:l,requestId:w,limit:50,maxHeight:`max-h-64`,showFilters:!1,showScope:!1,className:`border-0 rounded-none`})})]}),!U&&!V&&(x||z.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(d,{className:`h-3.5 w-3.5 text-destructive mt-0.5 shrink-0`}),i(`p`,{className:`text-[11px] text-destructive`,children:x||f(`integrations.addDeviceDialog.required`,`Required: {{value1}}`,{value1:z.join(`, `)})})]})}),e(`div`,{className:`flex items-center justify-between border-t border-border px-5 py-3 shrink-0`,children:[e(`div`,{className:`flex items-center gap-2`,children:[i(`button`,{onClick:u,className:`rounded-lg border border-border px-3 py-1.5 text-xs text-foreground-subtle hover:text-foreground transition-colors`,children:f(`integrations.cancel`)}),!U&&re&&e(`button`,{type:`button`,onClick:F,disabled:N===`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:[N===`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:()=>R(!0),disabled:U||!B||j.isPending,className:`rounded-lg border border-border px-3 py-1.5 text-xs text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50`,children:f(`integrations.saveAndNew`)}),i(`button`,{onClick:()=>R(!1),disabled:U||!B||j.isPending,className:`rounded-lg bg-primary px-4 py-1.5 text-xs font-medium text-primary-foreground shadow-sm disabled:opacity-50`,children:j.isPending?f(`integrations.saving`):f(`integrations.save`)})]})]})]})]})}var Q=1500;function ze({addonId:t,integrationId:n,jobId:r,onFinished:a}){let{t:o}=X(),s=R(),c=(pe({addonId:t,integrationId:n},{refetchInterval:e=>(e.state.data??[]).some(e=>e.state===`running`)?Q:!1}).data??[]).find(e=>e.jobId===r);if(!c)return null;let l=c.state===`running`,u=c.processed,f=c.total>0?Math.round(u/c.total*100):0;!l&&c.finishedAt!==null&&a();let p=[`${u}/${c.total} ${o(`integrations.adoptJobProcessed`,{defaultValue:`processed`})}`];c.adopted>0&&p.push(`${c.adopted} ${o(`integrations.adoptJobAdded`,{defaultValue:`added`})}`),c.alreadyAdopted>0&&p.push(`${c.alreadyAdopted} ${o(`integrations.adoptJobSkipped`,{defaultValue:`already there`})}`),c.failed>0&&p.push(`${c.failed} ${o(`integrations.adoptJobFailed`,{defaultValue:`failed`})}`);let m=p.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(d,{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(x,{className:`h-3.5 w-3.5 text-primary shrink-0`}),i(`p`,{className:`text-[11px] text-foreground`,children:m}),l&&i(`button`,{onClick:()=>s.mutate({jobId:r}),className:`ml-auto rounded-lg border border-border px-2 py-1 text-[11px] text-foreground-subtle hover:text-foreground transition-colors`,children:o(`integrations.adoptJobCancel`,{defaultValue:`Stop`})})]}),i(`div`,{className:`h-1 w-full rounded-full bg-border overflow-hidden`,children:i(`div`,{className:`h-full bg-primary transition-all`,style:{width:`${f}%`},role:`progressbar`,"aria-valuenow":f,"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 Be(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 $=`devices`;function Ve(e){return{id:$,label:e(`integrations.adoptDevicesModal.defaultFilter`),isDefault:!0}}var He=2e4,Ue=100;function We({addonId:n,integrationId:s,onClose:l}){let u=C(),{t:f}=X(),m=c(),[h,_]=o(new Set),[v,b]=o(new Set),[x,S]=o(new Map),[w,ee]=o(null),{data:te}=U(),E=(te??[]).find(e=>e.addonId===n)?.supportsLocationImport??!1,[D,O]=o(!0),k=M({addonId:n,integrationId:s}).data?.filters,A=k&&k.length>0?k:[Ve(f)],[j,re]=o(A.find(e=>e.isDefault)?.id??(A.some(e=>e.id===$)?$:A[0].id)),P=j!==$,F=ne(),I=N({addonId:n,integrationId:s,page:1,pageSize:He,filter:j}),L=I.refetch,R=F.mutate,z=r(()=>{R({addonId:n,integrationId:s},{onSettled:()=>{L()}})},[R,n,s,L]),V=t(null);a(()=>{let e=`${n}::${s}`;V.current===e||I.isLoading||(V.current=e,(I.data?.candidates.length??0)===0&&z())},[n,s,I.isLoading,I.data,z]);let H=F.isPending,W=F.isError?F.error instanceof Error?F.error.message:String(F.error):null,ie=typeof F.data?.lastError==`string`&&F.data.lastError.length>0?F.data.lastError:null,G=I.data?.candidates??[],ae=I.isError?I.error instanceof Error?I.error.message:String(I.error):null,K=B(),[q,se]=o(null),ce=r(e=>{e.alreadyAdopted||_(t=>{let n=new Set(t);return n.has(e.childNativeId)?n.delete(e.childNativeId):n.add(e.childNativeId),n})},[]),le=r(e=>{b(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),de=r((e,t)=>{S(n=>{let r=new Map(n),i=r.get(e)?.hiddenChildIds??new Set,a=new Set(i);return a.has(t)?a.delete(t):a.add(t),a.size===0?r.delete(e):r.set(e,{hiddenChildIds:a}),r})},[]),fe=r(e=>{let t={};for(let n of e){let e=x.get(n);e&&e.hiddenChildIds.size>0&&(t[n]={hiddenChildIds:[...e.hiddenChildIds]})}return Object.keys(t).length>0?t:void 0},[x]),pe=r(async()=>{ee(null);let e=[...h];if(e.length!==0)try{let t=fe(e),{jobId:r}=await K.mutateAsync({addonId:n,integrationId:s,filter:j,childNativeIds:e,...t?{perCandidate:t}:{},...E?{importLocations:D}:{}});se(r),_(new Set),S(new Map)}catch(e){ee(e instanceof Error?e.message:String(e))}},[h,fe,K,n,s,j,E,D]),me=t(null),he=r(()=>{q===null||me.current===q||(me.current=q,L(),m.invalidateQueries({queryKey:[[`integrations`]]}),m.invalidateQueries({queryKey:[[`deviceManager`]]}))},[q,L,m]),ge=r(e=>{re(e),_(new Set),b(new Set),S(new Map),ee(null)},[]),J=h.size,_e=q!==null&&J===0&&!K.isPending;return e(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center`,children:[i(`div`,{className:`absolute inset-0 bg-black/60`,onClick:l}),e(`div`,{className:`relative z-10 flex w-full max-w-3xl flex-col h-[85vh] rounded-xl border border-border bg-background shadow-2xl`,children:[e(`div`,{className:`flex items-center justify-between border-b border-border px-5 py-4 shrink-0`,children:[e(`div`,{className:`min-w-0`,children:[i(`h2`,{className:`text-sm font-semibold text-foreground`,children:f(`integrations.adoptDevices`,{defaultValue:`Adopt devices`})}),i(`p`,{className:`text-[11px] text-foreground-subtle mt-0.5`,children:f(`integrations.adoptDevicesHint`,{defaultValue:`Preview the candidate devices and add the ones you want.`})})]}),e(`div`,{className:`flex items-center gap-3 shrink-0`,children:[E&&e(`label`,{className:`flex items-center gap-1.5 cursor-pointer text-[11px] text-foreground-subtle hover:text-foreground transition-colors`,children:[i(`input`,{type:`checkbox`,checked:D,onChange:e=>O(e.target.checked),className:`accent-primary`}),f(`integrations.importLocations`,{defaultValue:`Import locations from the integration`})]}),i(`button`,{onClick:l,className:`rounded-md p-1 text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,"aria-label":f(`common.close`,`Close`),children:i(g,{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:[(W??ae??ie)&&G.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(d,{className:`h-3.5 w-3.5 text-destructive mt-0.5 shrink-0`}),e(`div`,{className:`min-w-0`,children:[i(`p`,{className:`text-xs font-medium text-destructive`,children:f(`integrations.adoptRefreshFailed`,{defaultValue:`Could not discover devices.`})}),i(`p`,{className:`text-[11px] text-destructive/90 mt-0.5`,children:W??ae??ie})]})]})}),A.length>1&&i(Ge,{filters:A,activeFilter:j,onSelect:ge}),i(`div`,{className:`flex-1 min-h-0`,children:i(oe,{mode:`generic`,items:G,pageSize:Ue,getKey:e=>e.childNativeId,getSearchText:Be,getFilterType:e=>e.type,filterOptions:Y(u),filterLabel:f(`integrations.adoptColType`,{defaultValue:`Type`}),isLoading:I.isLoading||H&&G.length===0,searchPlaceholder:f(`integrations.adoptSearch`,{defaultValue:`Search candidates…`}),emptyLabel:(W??ae??ie)&&G.length===0?``:f(`integrations.adoptNoCandidates`,{defaultValue:`No candidate devices found.`}),toolbar:e(`button`,{type:`button`,onClick:z,disabled:H,title:f(`integrations.adoptRefreshTitle`,{defaultValue:`Re-scan Home Assistant for devices`}),className:`inline-flex items-center gap-1.5 rounded-lg border border-border bg-surface px-2.5 py-1.5 text-xs text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-60 shrink-0`,children:[i(T,{className:`h-3.5 w-3.5 ${H?`animate-spin`:``}`}),f(`integrations.adoptRefresh`,{defaultValue:`Refresh`})]}),columns:[{key:`name`,header:f(`integrations.adoptColName`,{defaultValue:`Name`}),headerClassName:`w-[55%]`,cell:e=>i(Ke,{candidate:e,expandable:!P,expanded:v.has(e.childNativeId),onToggleExpand:()=>le(e.childNativeId),adoptedLabel:f(`integrations.adoptAlready`,{defaultValue:`Adopted`})})},{key:`type`,header:f(`integrations.adoptColType`,{defaultValue:`Type`}),headerClassName:`w-[30%] hidden sm:table-cell`,cellClassName:`hidden sm:table-cell`,cell:t=>{let n=ue(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:()=>ce(e),disabled:e.alreadyAdopted,"aria-label":h.has(e.childNativeId)?f(`integrations.adoptDevicesModal.deselect`,`Deselect`):f(`integrations.adoptDevicesModal.select`,`Select`),className:`inline-flex h-5 w-5 items-center justify-center rounded border ${h.has(e.childNativeId)?`border-primary bg-primary`:`border-border`} ${e.alreadyAdopted?`cursor-not-allowed opacity-50`:``}`,children:h.has(e.childNativeId)&&i(p,{className:`h-3 w-3 text-primary-foreground`})})})}],isExpanded:e=>!P&&v.has(e.childNativeId),renderExpanded:P?void 0:e=>i(qe,{candidate:e,hiddenChildIds:x.get(e.childNativeId)?.hiddenChildIds??new Set,onToggleChildHidden:t=>de(e.childNativeId,t)}),rowClassName:e=>e.alreadyAdopted?`opacity-60`:h.has(e.childNativeId)?`bg-primary/5`:``})})]}),w&&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(d,{className:`h-3.5 w-3.5 text-destructive mt-0.5 shrink-0`}),i(`p`,{className:`text-[11px] text-destructive`,children:w})]})}),q!==null&&i(ze,{addonId:n,integrationId:s,jobId:q,onFinished:he}),e(`div`,{className:`flex items-center justify-between border-t border-border px-5 py-3 shrink-0`,children:[i(`div`,{}),e(`div`,{className:`flex items-center gap-2`,children:[i(`button`,{onClick:l,className:`rounded-lg border border-border px-3 py-1.5 text-xs text-foreground-subtle hover:text-foreground transition-colors`,children:f(`integrations.cancel`,{defaultValue:`Cancel`})}),e(`button`,{onClick:_e?l:pe,disabled:!_e&&(J===0||K.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:[K.isPending&&i(y,{className:`h-3.5 w-3.5 animate-spin`}),_e?f(`integrations.close`,{defaultValue:`Close`}):f(`integrations.addSelected`,{defaultValue:`Add selected`}),!_e&&J>0?` (${J})`:``]})]})]})]})]})}function Ge({filters:e,activeFilter:t,onSelect:n}){let{t:r}=X();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 Ke({candidate:t,expandable:n,expanded:r,onToggleExpand:a,adoptedLabel:o}){let{t:s}=X(),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?te:E,{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 qe({candidate:t,hiddenChildIds:n,onToggleChildHidden:r}){let{t:a}=X(),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?D:f,{className:`h-3 w-3`})})]},t.childNativeId)})})}s();function Je(e){let t=[];for(let n of e){if(n.type===`group`){t.push(...Je(n.fields));continue}`key`in n&&typeof n.key==`string`&&t.push(n.key)}return t}function Ye(e,t){if(!e)return{};let n=new Set(e.sections.flatMap(e=>Je(e.fields))),r={};for(let e of n)Object.prototype.hasOwnProperty.call(t,e)&&(r[e]=t[e]);return r}function Xe(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 Ze({integrationId:t,addonId:r,name:a,kind:o,mode:s,brokerKind:l,canTest:u=!1,trpc:d,onClose:f}){let{t:p}=X(),m=c(),{data:h,isLoading:g}=q({id:t},{enabled:s===`account`||s===`broker`}),_=n(()=>{let e=h?.brokerId;return typeof e==`string`?e:null},[h]),{data:v,isLoading:b}=K({addonId:r,nodeId:`hub`},{enabled:s===`account`}),x=n(()=>v?Xe(v):null,[v]),S=W(),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(G,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,children:[i(ye,{children:e(be,{children:[p(`integrations.editConfig`,{defaultValue:`Edit configuration`}),` — `,a]})}),i(se,{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(Ae,{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(ke,{addonId:r,configSchema:x,canTest:u,initialName:a,initialConfig:Ye(x,h??{}),submitLabel:p(`integrations.save`,{defaultValue:`Save`}),hideName:!0,onSave:({config:e,secretKeys:t})=>C(e,t),onBack:f}):i(ge,{trpc:d,addonId:r,nodeId:`hub`,title:a})})]})})}function Qe(e){return e==null?!1:e.sections.some(e=>e.fields.length>0)}s();function $e(){let{t}=X(),{integrationId:s}=De(),d=c(),f=we(),[p,g]=Ee(),_=b(),[x,C]=o(!1),[w,T]=o(!1),[te,E]=o(!1),[D,O]=o(!1),{data:M,isLoading:ne}=J({id:s??``},{enabled:!!s}),{data:N}=K({addonId:M?.addonId??``,nodeId:`hub`},{enabled:!!M?.addonId}),{data:I,isSuccess:R}=U(),B=n(()=>{let e=M?.addonId;return!e||!R?null:(I??[]).find(t=>t.addonId===e)?.kind===`device-adoption`?`device-adoption`:`device-provider`},[I,M?.addonId,R]),{data:H}=me({}),W=n(()=>(H?.providers??[]).some(e=>e.addonId===M?.addonId),[H,M?.addonId]),q=B!==null,ue=M?.info?.fixed===!0,pe=q?B===`device-adoption`?t(`integrations.adoptDevices`,{defaultValue:`Adopt devices`}):t(`integrations.addDevice`):t(`integrations.addDeviceLoading`,{defaultValue:`Loading…`}),he=n(()=>{let e=M?.addonId;return!e||!R?null:(I??[]).find(t=>t.addonId===e)?.brokerKind??null},[I,M?.addonId,R]),ge=n(()=>{let e=M?.addonId;return!e||!R?!1:(I??[]).find(t=>t.addonId===e)?.canTest===!0},[I,M?.addonId,R]),Y=n(()=>{let e=M?.addonId;return!e||!R?null:(I??[]).find(t=>t.addonId===e)?.mode??null},[I,M?.addonId,R]);a(()=>{p.get(`add`)===`1`&&q&&(C(!0),g(e=>{let t=new URLSearchParams(e);return t.delete(`add`),t},{replace:!0}))},[p,q,g]);let xe=N!=null&&Array.isArray(N.sections)&&N.sections.some(e=>e.fields.length>0),{data:Se}=_e({addonId:M?.addonId??``,nodeId:`hub`},{enabled:!!M?.addonId&&Y!==`account`}),Ce=Y!==null&&Y!==`account`&&Qe(Se),Te=n(()=>M?.addonId?[M.addonId]:[],[M?.addonId]),{data:ke}=ie({projection:`slim`},{refetchInterval:3e4}),Ae=[[`integrations`,`get`],{input:{id:s??``},type:`query`}],Z=fe({onMutate:async e=>{await d.cancelQueries({queryKey:Ae});let t=d.getQueryData(Ae);return t!=null&&d.setQueryData(Ae,{...t,enabled:e.enabled}),{previous:t}},onError:(e,t,n)=>{let r=n;r?.previous!=null&&d.setQueryData(Ae,r.previous)},onSettled:()=>{d.invalidateQueries({queryKey:[[`integrations`]]}),d.invalidateQueries({queryKey:[[`deviceManager`]]})}}),Ne=le({onSuccess:()=>{d.invalidateQueries({queryKey:[[`integrations`]]}),d.invalidateQueries({queryKey:[[`deviceManager`]]}),f(`/integrations`)}}),Pe=P({onSuccess:()=>{d.invalidateQueries({queryKey:[[`integrations`]]}),d.invalidateQueries({queryKey:[[`deviceManager`]]})}}),Fe=L({onSuccess:()=>{d.invalidateQueries({queryKey:[[`deviceManager`]]})}}),Ie=A({onSuccess:()=>{d.invalidateQueries({queryKey:[[`deviceManager`]]})}}),Le=ae({onSuccess:()=>{d.invalidateQueries({queryKey:[[`deviceManager`]]})}}),Q=n(()=>ke??[],[ke]),ze=n(()=>{let e=new Map;for(let t of Q)e.set(t.id,{id:t.id,name:t.name??t.stableId??`#${String(t.id)}`});return e},[Q]),Be=r(e=>ze.get(e)??null,[ze]),{data:$}=ve(void 0),Ve=n(()=>re($),[$]),He=r(e=>f(`/devices/${String(e)}`),[f]),Ue=n(()=>{let e=M?.id;return e?Q.filter(t=>{let n=Ve(t);return n.kind===`resolved`&&n.integration.id===e}):[]},[Q,M?.id,Ve]),Ge=n(()=>$===void 0?null:F(Ue).length,[$,Ue])??`…`;return ne?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`})]}):M?e(`div`,{className:`p-4 space-y-4 overflow-x-hidden`,children:[i(j,{items:[{label:t(`integrationDetail.integrations`,`Integrations`),onClick:()=>f(`/integrations`)},{label:M.name}]}),e(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[e(`div`,{className:`flex items-center gap-3 min-w-0`,children:[i(et,{addonId:M.addonId}),e(`div`,{className:`min-w-0`,children:[i(`h1`,{className:`text-lg font-semibold text-foreground truncate`,children:M.name}),e(`p`,{className:`text-[11px] text-foreground-subtle mt-0.5 truncate`,children:[M.addonId,` · `,Ge,` `,t(`integrations.devices`)]})]})]}),e(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[W&&e(`button`,{onClick:()=>T(!0),className:`flex items-center gap-1.5 rounded-lg border border-border bg-surface px-2.5 py-1.5 text-xs font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,title:t(`integrationDetail.scanTheNetworkForDevices`,`Scan the network for devices (incl. a different subnet)`),children:[i(l,{className:`h-3.5 w-3.5`}),t(`integrationDetail.scanNetwork`,`Scan network`)]}),!ue&&e(`button`,{onClick:()=>C(!0),disabled:!q,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:pe,children:[i(v,{className:`h-3.5 w-3.5`}),pe]}),e(`div`,{className:`inline-flex items-center gap-2 rounded-lg border px-3 py-1.5 transition-colors ${Z.isPending?`opacity-60`:``} ${M.enabled?`border-success/30 bg-success/5`:`border-border bg-surface`}`,title:t(`integrations.toggleHint`,{defaultValue:`Click to toggle`}),children:[i(z,{checked:M.enabled,onCheckedChange:e=>Z.mutate({id:s,enabled:e}),disabled:Z.isPending,"aria-label":M.enabled?t(`integrationDetail.disableIntegration`,`Disable integration`):t(`integrationDetail.enableIntegration`,`Enable integration`)}),i(`span`,{className:`text-[11px] font-medium ${M.enabled?`text-success`:`text-foreground-subtle`}`,children:M.enabled?t(`integrationDetail.enabled`,`Enabled`):t(`integrationDetail.disabled`,`Disabled`)}),Z.isPending&&i(y,{className:`h-3 w-3 animate-spin text-foreground-subtle`})]}),Y!==`standalone`&&(xe||B===`device-adoption`)&&e(`button`,{onClick:()=>E(!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(ee,{className:`h-3 w-3`}),t(`integrations.config`)]}),e(`button`,{onClick:()=>O(!0),className:`flex items-center gap-1.5 rounded-lg border border-border bg-surface px-3 py-1.5 text-[11px] text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,title:t(`integrations.logs`,{defaultValue:`View logs`}),children:[i(S,{className:`h-3 w-3`}),t(`integrations.logs`,{defaultValue:`Logs`})]}),i(V,{label:t(`integrationDetail.restart`,`Restart`),icon:h,title:t(`integrationDetail.restart2`,`Restart "{{name}}"?`,{name:M.name}),description:t(`integrationDetail.restartingTheAddonWillBriefly`,`Restarting the addon will briefly disconnect every device backed by it ({{topLevelCountLabel}} active). Streams will reconnect automatically.`,{topLevelCountLabel:Ge}),confirmLabel:t(`integrationDetail.restart`,`Restart`),triggerVariant:`outline`,confirmVariant:`danger`,disabled:Pe.isPending,action:()=>Pe.mutateAsync({addonId:M.addonId})}),!ue&&s&&i(V,{label:t(`integrations.delete`,{defaultValue:`Delete`}),icon:u,title:t(`integrations.deleteTitle`,{defaultValue:`Delete integration?`}),description:t(`integrations.deleteWarning`,{defaultValue:`This removes the integration "{{name}}" and its {{count}} device(s). The addon will restart. This cannot be undone.`,name:M.name,count:Ge}),confirmLabel:t(`integrations.confirmDelete`,{defaultValue:`Delete integration`}),triggerVariant:`outline`,confirmVariant:`danger`,className:`border-danger bg-danger/10 text-danger hover:bg-danger hover:text-background`,disabled:Ne.isPending,action:()=>Ne.mutateAsync({id:s})})]})]}),Ce&&i(Me,{nodeId:null,addonIds:Te,level:`global`,surface:`integration`,title:t(`integrations.settings`,{defaultValue:`Settings`})}),i(oe,{context:`integration-detail`,devices:Q,trpc:_.trpcClient,integrationOf:Ve,forceIntegrationId:M.id,urlScope:`root`,lsKey:`integration-detail:${M.addonId}`,resolveIntegrationIcon:Oe,resolveParent:Be,onNavigate:He,batchActions:{remove:Fe.mutate,disable:Ie.mutate,enable:Le.mutate},...ue?{}:{onDeleteDevice:e=>Fe.mutate({deviceId:e.id})}}),x&&s&&B===`device-adoption`&&i(We,{addonId:M.addonId,integrationId:s,onClose:()=>C(!1)}),x&&s&&B===`device-provider`&&i(Re,{open:x,integrationId:s,addonId:M.addonId,onClose:()=>C(!1)}),w&&M&&i(je,{open:w,scope:{addonId:M.addonId,label:M.name},onClose:()=>T(!1)}),te&&s&&B!==null&&Y!==null&&i(Ze,{integrationId:s,addonId:M.addonId,name:M.name,kind:B,mode:Y,brokerKind:he,canTest:ge,trpc:_.trpcClient,onClose:()=>E(!1)}),D&&i(de,{open:!0,onOpenChange:e=>!e&&O(!1),children:e(G,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,className:`md:max-w-5xl md:h-[80vh]`,children:[i(ye,{className:`mb-0`,children:e(be,{className:`flex items-center gap-2 min-w-0`,children:[i(S,{className:`h-4 w-4 text-primary shrink-0`}),i(`span`,{className:`truncate`,children:M.name}),e(`span`,{className:`text-[10px] text-foreground-subtle font-mono truncate font-normal`,children:[M.addonId,s?` · ${s}`:``]})]})}),i(se,{className:`min-h-0 overflow-hidden p-0`,children:i(ce,{addonId:M.addonId,limit:200,maxHeight:`max-h-full`,showScope:!1,className:`h-full border-0 rounded-none`})})]})})]}):e(`div`,{className:`flex flex-col items-center justify-center py-20 px-6 text-center gap-4`,children:[i(`div`,{className:`flex h-12 w-12 items-center justify-center rounded-full bg-foreground-subtle/10`,children:i(k,{className:`h-6 w-6 text-foreground-subtle`})}),e(`div`,{className:`space-y-1 max-w-sm`,children:[i(`h2`,{className:`text-sm font-semibold text-foreground`,children:t(`integrations.integrationNotFound`,{defaultValue:`Integration not found`})}),i(`p`,{className:`text-[11px] text-foreground-subtle`,children:t(`integrations.integrationNotFoundHint`,{defaultValue:`The integration "{{id}}" does not exist. It may have been deleted, or the URL may be wrong.`,id:s??``})})]}),e(`button`,{onClick:()=>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(m,{className:`h-3 w-3`}),t(`integrations.backToList`,{defaultValue:`Back to integrations`})]})]})}function et({addonId:e}){let t=Se(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{$e as IntegrationDetailPage};
|