@camstack/addon-admin-ui 1.2.499 → 1.2.500

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.
Files changed (45) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/assets/{Addons-PTfAXTcl.js → Addons-DjKk-3re.js} +1 -1
  3. package/dist/assets/{AdminSectionedPage-BYs8ku8k.js → AdminSectionedPage-BYasKmzd.js} +1 -1
  4. package/dist/assets/AiProfiles-BmS2uUBj.js +3 -0
  5. package/dist/assets/{BrokerEditorDialog-CONeUoQZ.js → BrokerEditorDialog-CNMt87kl.js} +1 -1
  6. package/dist/assets/{Build-64GFrVBv.js → Build-BxF8Guqd.js} +1 -1
  7. package/dist/assets/{Calendars-Cr9FOfbM.js → Calendars-CUux6gnd.js} +1 -1
  8. package/dist/assets/{Cluster-CaDZt6wf.js → Cluster-hP45su9T.js} +1 -1
  9. package/dist/assets/{CompositionBlockEditor-Cu_GMMSI.js → CompositionBlockEditor-D4fhvRsn.js} +1 -1
  10. package/dist/assets/{CompositionEditorPage-DHmZe045.js → CompositionEditorPage-_5dpQ0bG.js} +1 -1
  11. package/dist/assets/{Data-CLUboL1k.js → Data-CgesRJ0M.js} +1 -1
  12. package/dist/assets/{DeviceDetail-PeXgC7D7.js → DeviceDetail-CwKEje0w.js} +1 -1
  13. package/dist/assets/{DeviceDoActionFields-CTqHC6sW.js → DeviceDoActionFields-Cig6Ev4x.js} +1 -1
  14. package/dist/assets/{Devices-72RGQIZG.js → Devices--aUHeXog.js} +1 -1
  15. package/dist/assets/{HelperWizard-pM6WaJkS.js → HelperWizard-G_0cfzWY.js} +1 -1
  16. package/dist/assets/{History-Dw72vHO6.js → History-DgYqsbtN.js} +1 -1
  17. package/dist/assets/{Identity-CPnY-pTg.js → Identity-DiD-Odk_.js} +1 -1
  18. package/dist/assets/{IntegrationDetail-DCuJRrDX.js → IntegrationDetail-4Ra0TOxT.js} +1 -1
  19. package/dist/assets/{IntegrationHub-AlH87vBq.js → IntegrationHub-DE5vhHxF.js} +1 -1
  20. package/dist/assets/{Integrations-CEyrrglP.js → Integrations-BFPIzd2F.js} +1 -1
  21. package/dist/assets/{Integrations-UhKXHXBR.js → Integrations-CQa0MONn.js} +1 -1
  22. package/dist/assets/{Library-BGe2f4pB.js → Library-8C3VA_9-.js} +1 -1
  23. package/dist/assets/{Locations-BjT72gvn.js → Locations-Bo6LSDPv.js} +1 -1
  24. package/dist/assets/{Logs-C_7aqJhI.js → Logs-DBrd9ijs.js} +1 -1
  25. package/dist/assets/{MyAccess-Bo_FOLPs.js → MyAccess-nJnTNo27.js} +1 -1
  26. package/dist/assets/{Network-BX6Y8dwk.js → Network-Bu8KAssr.js} +1 -1
  27. package/dist/assets/{NodeAddonsSettingsPanel-2TqELGQC.js → NodeAddonsSettingsPanel-DvExWrRR.js} +1 -1
  28. package/dist/assets/{Notifications-T_G8vhSu.js → Notifications-C2nq0ANt.js} +1 -1
  29. package/dist/assets/{Pipeline-BRYPZ_2h.js → Pipeline-LhKt9FPQ.js} +1 -1
  30. package/dist/assets/{Recordings-CqsVLa2F.js → Recordings-DqnaHtRy.js} +1 -1
  31. package/dist/assets/{ScanNetworkModal-DAFJTCNh.js → ScanNetworkModal-C2jPGEtr.js} +1 -1
  32. package/dist/assets/{SessionsList-zyzKyjyE.js → SessionsList-q9C8nDf2.js} +1 -1
  33. package/dist/assets/{Showroom-DHXru4Aa.js → Showroom-krcfWnQP.js} +1 -1
  34. package/dist/assets/{System-qySy6YJm.js → System-jcF3z2IP.js} +1 -1
  35. package/dist/assets/{Terminal-B6xVGljU.js → Terminal-BIsbIA8B.js} +1 -1
  36. package/dist/assets/{device-integration-icon-DeM12QWn.js → device-integration-icon-CGvicRSz.js} +1 -1
  37. package/dist/assets/{index-D_AGxR1C.js → index-hw1sXUcO.js} +2 -2
  38. package/dist/assets/{location-owned-usage-Bx1OkT8H.js → location-owned-usage-DBWjuZ1q.js} +1 -1
  39. package/dist/assets/{mf-entry-bootstrap-0-6afad399.js → mf-entry-bootstrap-0-1934b2aa.js} +1 -1
  40. package/dist/assets/{step-inspector-model-BxKcZWYu.js → step-inspector-model-DPjYDzKA.js} +1 -1
  41. package/dist/assets/{useNodeUrlSelection-CO3V-rVN.js → useNodeUrlSelection-kkHa09df.js} +1 -1
  42. package/dist/index.html +2 -2
  43. package/dist/server/addon.js +1 -1
  44. package/package.json +1 -1
  45. package/dist/assets/AiProfiles-BaIX3xlW.js +0 -3
@@ -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,Di as l,Fn as u,Gr as d,Ht as f,Mn as p,Or as m,Ti as h,Vn as g,dt as _,fr as v,gt as y,st as b}from"./player-overlays-DmlN4sZb.js";import{Da as x}from"./client-Gv3pB3LY.js";import{t as S}from"./archive-BXVJNilF.js";import{t as C}from"./eraser-CVudvbRZ.js";import{t as w}from"./hard-drive-download-D7rFyG82.js";import{Yr as T,_i as E,_r as ee,bn as D,dr as te,eu as O,fr as ne,fu as re,gr as ie,hr as k,pr as ae,vt as oe}from"./src-DWX1wfhS.js";import{t as A}from"./i18n-D0vRhk5m.js";import{t as j}from"./useTranslation-BJr-n0es.js";import{P as se,ur as ce}from"./index-D_AGxR1C.js";import{t as M}from"./format-size-DIxKXxtj.js";o();function N(e){let t=e.trim().toLowerCase();return t.length===0?``:t.replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``)}function P(e,t){let n=N(t);return`${e}:${n.length>0?n:`default`}`}var F=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`]),I=[`recordings`,`data`,`mnt`,`media`,`Volumes`];function L(e){let t=I.findIndex(t=>t===`recordings`?e.startsWith(t):e===t);return t===-1?I.length:t}function le(e){return e.filter(e=>!e.name.startsWith(`.`)&&!F.has(e.name)).toSorted((e,t)=>{let n=L(e.name)-L(t.name);return n===0?e.name.localeCompare(t.name):n}).map(e=>e.path)}function ue({nodeId:t,value:o,onChange:s}){let{t:c}=j(),l=_().trpcClient,[u,d]=a([]),[f,p]=a(o),[m,h]=a(null),[g,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(le(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`)})]}),g&&r(`div`,{className:`text-[10px] text-red-400`,children:g})]})}o();function R({initialType:n,onClose:i,onCreated:o}){let{t:c}=j(),l=s(),u=_().trpcClient,[d,f]=a(`picker`),[p,m]=a(n),[g,y]=a(null),[b,x]=a({}),[S,C]=a(``),[w,T]=a(null),[E,D]=a(!1),[k,A]=a(`hub`),[M,N]=a(null),[F,I]=a(!1),L=e=>x(t=>({...t,basePath:e})),le=typeof b.basePath==`string`?b.basePath:``,R=O(),z=t(()=>{let e=R.data;return Array.isArray(e)?e:[]},[R.data]),B=R.isLoading,V=re({onSuccess:()=>{l.invalidateQueries({queryKey:[[`storage`,`listLocations`]]}),o()}}),H=t(()=>w!==null&&w.length>0?w:P(p,S),[p,S,w]),de=async()=>{if(g){I(!0),N(null);try{N(await(e=>u.storage.testConfig.query(e))({providerId:g.providerId,config:b}))}catch(e){N({ok:!1,error:e instanceof Error?e.message:String(e)})}finally{I(!1)}}};return r(te,{open:!0,onOpenChange:e=>!e&&i(),children:e(ae,{width:`md`,placement:`sheet-on-mobile`,scroll:`body`,children:[e(ie,{children:[r(ee,{children:{picker:`Add Location — Pick provider`,config:`Add Location — ${g?.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(ne,{children:[d===`picker`&&e(`div`,{className:`space-y-2`,children:[B&&r(`div`,{className:`text-xs text-foreground-subtle animate-pulse`,children:c(`storage.addLocationWizard.loadingProviders`,`Loading providers…`)}),!B&&z.length===0&&r(`div`,{className:`rounded border border-border bg-background px-3 py-4 text-center text-xs text-foreground-subtle`,children:r(ce,{i18nKey:`storage.addLocationWizard.noProvider`,values:{type:p},components:{code:r(`code`,{className:`font-mono`})}})}),z.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(h,{className:`h-4 w-4 text-foreground-subtle flex-shrink-0`})]},t.providerId))]}),d===`config`&&g&&e(`div`,{className:`space-y-3`,children:[r(se,{schema:g.configSchema,values:b,onChange:x}),g.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(oe,{selectedNodeId:k,onSelect:A,alwaysShow:!0}),r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:c(`storage.addLocationWizard.path`,`Path`)}),r(ue,{nodeId:k,value:le,onChange:L})]}),M&&r(`div`,{className:`rounded border px-3 py-2 text-[11px] ${M.ok?`border-success/30 bg-success/5 text-success`:`border-danger/30 bg-danger/5 text-danger`}`,children:M.ok?c(`storage.addLocationWizard.connectionOk`,`Connection OK.`):c(`storage.addLocationWizard.testFailed`,`Test failed: {{value1}}`,{value1:M.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:()=>{de()},disabled:F,className:`rounded border border-border px-3 py-1.5 text-xs text-foreground hover:bg-primary/10 disabled:opacity-50`,children:F?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`&&g&&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:g.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:H,onChange:e=>T(e.target.value),placeholder:P(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.`)})]})]}),V.isError&&r(`div`,{className:`rounded border border-danger/30 bg-danger/5 text-danger px-3 py-2 text-[11px]`,children:V.error instanceof Error?V.error.message:String(V.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),N(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:()=>{g&&V.mutate({id:H,type:p,displayName:S.trim(),providerId:g.providerId,config:b,enabled:E,nodeId:g.nodeLocal?k:void 0})},disabled:V.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:[V.isPending?r(v,{className:`h-3.5 w-3.5 animate-spin`}):null,V.isPending?c(`storage.addLocationWizard.saving`,`Saving…`):c(`common.save`,`Save`)]})]})]})]})]})]})})}function z(e){return x(e)}function B(e){return e===`active`}var V=[{mode:`active`,get label(){return A.t(`helpers.locationMode.activeLabel`)},get consequence(){return A.t(`helpers.locationMode.activeConsequence`)},requiresConfirmation:!1},{mode:`readonly`,get label(){return A.t(`helpers.locationMode.readonlyLabel`)},get consequence(){return A.t(`helpers.locationMode.readonlyConsequence`)},requiresConfirmation:!1},{mode:`drain`,get label(){return A.t(`helpers.locationMode.drainLabel`)},get consequence(){return A.t(`helpers.locationMode.drainConsequence`)},requiresConfirmation:!1},{mode:`disabled`,get label(){return A.t(`helpers.locationMode.disabledLabel`)},get consequence(){return A.t(`helpers.locationMode.disabledConsequence`)},requiresConfirmation:!0}];function H(e){return V.find(t=>t.mode===e)??V[0]}function de(e){return H(e).requiresConfirmation}var fe=`Blocked: this is the last location of its type still accepting writes — new data would have nowhere to go.`;function U(e,t,n){return B(n)||!B(z(e))||t.some(t=>t.id!==e.id&&B(z(t)))?{blocked:!1,reason:``}:{blocked:!0,reason:fe}}function pe(e,t){return{active:U(e,t,`active`).reason,readonly:U(e,t,`readonly`).reason,drain:U(e,t,`drain`).reason,disabled:U(e,t,`disabled`).reason}}function me(e,t,n){return!(n===`single`||t.length<=1||B(z(e))&&t.filter(e=>B(z(e))).length<=1)}function he(e){return e===`active`?{enabled:!0,readOnly:!1}:e===`readonly`?{enabled:!1,readOnly:!1}:{enabled:!1,readOnly:!0}}function W(e,t){let n={...t.config??e.config};t.mode!==void 0&&(he(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:he(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`?A.t(`helpers.locationProtection.unitGb`):A.t(`helpers.locationProtection.unitPercent`)}function Ce(e,t=10){let n=e.value===null?A.t(`helpers.locationProtection.targetDefault`,{percent:String(t)}):e.unit===`gb`?A.t(`helpers.locationProtection.targetGb`,{value:String(e.value)}):A.t(`helpers.locationProtection.targetPercent`,{value:String(e.value)});return A.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}=j(),[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}=j(),l=s(),u=_().trpcClient,[d,f]=a({...n.config}),[p,m]=a(n.displayName),[h,g]=a(null),[y,b]=a(!1),x=O(),S=t(()=>{let e=x.data;return Array.isArray(e)?e.find(e=>e.providerId===n.providerId)??null:null},[x.data,n.providerId]),C=re({onSuccess:()=>{l.invalidateQueries({queryKey:[[`storage`,`listLocations`]]}),o()}}),w=S?.shouldSaveDiskSpace===!0,E=S?.nodeLocal===!0,[D,A]=a(typeof n.nodeId==`string`?n.nodeId:`hub`),M=typeof d.basePath==`string`?d.basePath:``,N=e=>f(t=>({...t,basePath:e})),P=S?.minFreePercent??10,F=async()=>{b(!0),g(null);try{g(await(e=>u.storage.testConfig.query(e))({providerId:n.providerId,locationId:n.id,config:d}))}catch(e){g({ok:!1,error:e instanceof Error?e.message:String(e)})}finally{b(!1)}};return r(te,{open:!0,onOpenChange:e=>!e&&i(),children:e(ae,{width:`md`,placement:`sheet-on-mobile`,scroll:`body`,children:[e(ie,{children:[r(ee,{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(ne,{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(se,{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(oe,{selectedNodeId:D,onSelect:A,alwaysShow:!0}),r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:c(`storage.editLocationModal.path`,`Path`)}),r(ue,{nodeId:D,value:M,onChange:N})]}),w&&r(Ee,{config:d,defaultPercent:P,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(ce,{i18nKey:`storage.editLocationModal.providerGone`,values:{id:n.providerId},components:{code:r(`code`,{className:`font-mono`})}})}),h&&r(`div`,{className:`rounded border px-3 py-2 text-[11px] ${h.ok?`border-success/30 bg-success/5 text-success`:`border-danger/30 bg-danger/5 text-danger`}`,children:h.ok?c(`storage.editLocationModal.connectionOk`,`Connection OK.`):c(`storage.editLocationModal.testFailed`,`Test failed: {{value1}}`,{value1:h.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(k,{className:`justify-between`,children:[r(T,{variant:`outline`,size:`sm`,onClick:i,children:c(`common.cancel`,`Cancel`)}),e(`div`,{className:`flex items-center gap-2`,children:[r(T,{variant:`outline`,size:`sm`,onClick:()=>{F()},disabled:y||!S,children:y?c(`storage.editLocationModal.testing`,`Testing…`):c(`storage.editLocationModal.testConnection`,`Test connection`)}),e(T,{size:`sm`,onClick:()=>{C.mutate(W(n,{displayName:p.trim(),config:d,nodeId:E?D:n.nodeId}))},disabled:C.isPending||p.trim().length===0,children:[C.isPending?r(v,{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}=j();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:M(n.ownedBytes);return{kind:`unknown`,owned:e,summary:e===null?A.t(`helpers.locationCapacityBar.unknownSummary`):A.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:M(r),freeTotal:M(a),freeTotalPercent:X(a/r),used:M(p),usedPercent:X(p/r),free:M(u),freePercent:X(u/r),reserve:s===0?null:A.t(`helpers.locationCapacityBar.reserveKept`,{size:M(s)}),owned:f===null||_===null?null:A.t(`helpers.locationCapacityBar.ownedOfRecordings`,{size:M(f),percent:X(_)}),cap:v===null?null:v.reason===`drain`?A.t(`helpers.locationCapacityBar.capDrain`,{size:M(v.bytes)}):A.t(`helpers.locationCapacityBar.capCap`,{size:M(v.bytes)})},S=[A.t(`helpers.locationCapacityBar.summaryFree`,{free:x.freeTotal,total:x.total,percent:x.freeTotalPercent}),x.owned===null?null:A.t(`helpers.locationCapacityBar.summaryOwned`,{owned:x.owned}),x.reserve===null?null:l?A.t(`helpers.locationCapacityBar.summaryReserveShort`,{reserve:x.reserve}):x.reserve,x.cap===null?null:b?A.t(`helpers.locationCapacityBar.summaryCapBelow`,{cap:x.cap}):x.cap].filter(e=>e!==null).join(` · `),C=[];return c>0&&C.push({segment:`reserve`,label:A.t(`helpers.locationCapacityBar.legendKeptFree`),value:M(s),alarming:l}),x.owned!==null&&C.push({segment:`owned`,label:A.t(`helpers.locationCapacityBar.legendCamstack`),value:x.owned,alarming:!1}),C.push({segment:`used`,label:f===null?A.t(`helpers.locationCapacityBar.legendUsed`):A.t(`helpers.locationCapacityBar.legendOtherData`),value:`${x.used} (${x.usedPercent})`,alarming:g===`critical`}),C.push({segment:`free`,label:A.t(`helpers.locationCapacityBar.legendFree`),value:`${x.free} (${x.freePercent})`,alarming:l}),v!==null&&C.push({segment:`cap`,label:v.reason===`drain`?A.t(`helpers.locationCapacityBar.legendDrainTarget`):A.t(`helpers.locationCapacityBar.legendCap`),value:A.t(`helpers.locationCapacityBar.legendCapValue`,{size:M(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}=j(),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,z(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!B(z(e))}function $e(e,t){return Xe(e.type)===null||!Qe(e)?!1:t.some(t=>t.id!==e.id&&B(z(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}=j(),o=b(),s=E(),c=Ze(t.type),[l,u]=a(null),[d,f]=a(null),[p,m]=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 h=l!==null&&l.locationId===t.id,g=h&&l.running,_=h&&l.phase!==`idle`,x=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),m(!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{m(!1)}}},S=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:[g?e(`button`,{type:`button`,onClick:()=>void S(),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(y,{className:`h-3 w-3`}),n(`common.cancel`,`Cancel`)]}):e(`button`,{type:`button`,onClick:()=>void x(),disabled:p,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:[p?r(v,{className:`h-3 w-3 animate-spin`}):r(C,{className:`h-3 w-3`}),n(`storage.locationDiscardControl.discardLeftovers`,`Discard leftovers`)]}),_&&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||h&&l?.error)&&r(`p`,{className:`text-[10px] text-danger leading-tight`,children:d??l?.error})]})}o();var ot={active:p,readonly:S,drain:w,disabled:d},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}=j(),o=H(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(l,{className:`h-3 w-3 ${n?`rotate-180`:``}`})]})}function lt({mode:t,blockedReasons:n,onSelect:a,onDismiss:o}){let{t:s}=j();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(y,{className:`h-3 w-3`})})]}),V.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:u,ownedBytes:d}){let{t:p}=j(),[m,h]=a(!1),_=ut(t.config),v=z(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:d??null}),u!==void 0&&r(Ie,{drain:u})]})]}),e(`div`,{className:`flex flex-wrap items-center gap-1 shrink-0`,children:[r(it,{location:t,siblings:l}),r(ct,{mode:v,open:m,onToggle:()=>{h(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(g,{className:`h-3 w-3`}),p(`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:p(`storage.locationCard.deleteLocation`,`Delete location`),children:r(f,{className:`h-3 w-3`})})]}),m&&r(lt,{mode:v,blockedReasons:s,onSelect:e=>o(t,e),onDismiss:()=>{h(!1)}})]})}o();function ft({type:n,displayName:i,description:a,cardinality:o,locations:s,onAdd:l,onEdit:d,onDelete:f,onSetMode:p,ownedBytesById:h,drainById:g}){let{t:_}=j(),v=t(()=>{let e=[...s];return e.sort((e,t)=>{let n=B(z(e));return n===B(z(t))?e.displayName.localeCompare(t.displayName):n?-1:1}),e},[s]);return e(D,{headingId:`storage-location-${n}`,title:i,icon:m,testId:`storage-location-group-${n}`,actions:o===`multi`?e(T,{size:`sm`,type:`button`,onClick:()=>l(n),children:[r(u,{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:me(e,v,o),onEdit:d,onDelete:f,onSetMode:p,blockedReasons:pe(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,H as c,Be as i,de as l,ft as n,De as o,q as r,W as s,gt as t,R 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,Di as l,Fn as u,Gr as d,Ht as f,Mn as p,Or as m,Ti as h,Vn as g,dt as _,fr as v,gt as y,st as b}from"./player-overlays-DmlN4sZb.js";import{Da as x}from"./client-Gv3pB3LY.js";import{t as S}from"./archive-BXVJNilF.js";import{t as C}from"./eraser-CVudvbRZ.js";import{t as w}from"./hard-drive-download-D7rFyG82.js";import{Yr as T,_i as E,_r as ee,bn as D,dr as te,eu as O,fr as ne,fu as re,gr as ie,hr as k,pr as ae,vt as oe}from"./src-DWX1wfhS.js";import{t as A}from"./i18n-D0vRhk5m.js";import{t as j}from"./useTranslation-BJr-n0es.js";import{P as se,ur as ce}from"./index-hw1sXUcO.js";import{t as M}from"./format-size-DIxKXxtj.js";o();function N(e){let t=e.trim().toLowerCase();return t.length===0?``:t.replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``)}function P(e,t){let n=N(t);return`${e}:${n.length>0?n:`default`}`}var F=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`]),I=[`recordings`,`data`,`mnt`,`media`,`Volumes`];function L(e){let t=I.findIndex(t=>t===`recordings`?e.startsWith(t):e===t);return t===-1?I.length:t}function le(e){return e.filter(e=>!e.name.startsWith(`.`)&&!F.has(e.name)).toSorted((e,t)=>{let n=L(e.name)-L(t.name);return n===0?e.name.localeCompare(t.name):n}).map(e=>e.path)}function ue({nodeId:t,value:o,onChange:s}){let{t:c}=j(),l=_().trpcClient,[u,d]=a([]),[f,p]=a(o),[m,h]=a(null),[g,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(le(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`)})]}),g&&r(`div`,{className:`text-[10px] text-red-400`,children:g})]})}o();function R({initialType:n,onClose:i,onCreated:o}){let{t:c}=j(),l=s(),u=_().trpcClient,[d,f]=a(`picker`),[p,m]=a(n),[g,y]=a(null),[b,x]=a({}),[S,C]=a(``),[w,T]=a(null),[E,D]=a(!1),[k,A]=a(`hub`),[M,N]=a(null),[F,I]=a(!1),L=e=>x(t=>({...t,basePath:e})),le=typeof b.basePath==`string`?b.basePath:``,R=O(),z=t(()=>{let e=R.data;return Array.isArray(e)?e:[]},[R.data]),B=R.isLoading,V=re({onSuccess:()=>{l.invalidateQueries({queryKey:[[`storage`,`listLocations`]]}),o()}}),H=t(()=>w!==null&&w.length>0?w:P(p,S),[p,S,w]),de=async()=>{if(g){I(!0),N(null);try{N(await(e=>u.storage.testConfig.query(e))({providerId:g.providerId,config:b}))}catch(e){N({ok:!1,error:e instanceof Error?e.message:String(e)})}finally{I(!1)}}};return r(te,{open:!0,onOpenChange:e=>!e&&i(),children:e(ae,{width:`md`,placement:`sheet-on-mobile`,scroll:`body`,children:[e(ie,{children:[r(ee,{children:{picker:`Add Location — Pick provider`,config:`Add Location — ${g?.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(ne,{children:[d===`picker`&&e(`div`,{className:`space-y-2`,children:[B&&r(`div`,{className:`text-xs text-foreground-subtle animate-pulse`,children:c(`storage.addLocationWizard.loadingProviders`,`Loading providers…`)}),!B&&z.length===0&&r(`div`,{className:`rounded border border-border bg-background px-3 py-4 text-center text-xs text-foreground-subtle`,children:r(ce,{i18nKey:`storage.addLocationWizard.noProvider`,values:{type:p},components:{code:r(`code`,{className:`font-mono`})}})}),z.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(h,{className:`h-4 w-4 text-foreground-subtle flex-shrink-0`})]},t.providerId))]}),d===`config`&&g&&e(`div`,{className:`space-y-3`,children:[r(se,{schema:g.configSchema,values:b,onChange:x}),g.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(oe,{selectedNodeId:k,onSelect:A,alwaysShow:!0}),r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:c(`storage.addLocationWizard.path`,`Path`)}),r(ue,{nodeId:k,value:le,onChange:L})]}),M&&r(`div`,{className:`rounded border px-3 py-2 text-[11px] ${M.ok?`border-success/30 bg-success/5 text-success`:`border-danger/30 bg-danger/5 text-danger`}`,children:M.ok?c(`storage.addLocationWizard.connectionOk`,`Connection OK.`):c(`storage.addLocationWizard.testFailed`,`Test failed: {{value1}}`,{value1:M.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:()=>{de()},disabled:F,className:`rounded border border-border px-3 py-1.5 text-xs text-foreground hover:bg-primary/10 disabled:opacity-50`,children:F?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`&&g&&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:g.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:H,onChange:e=>T(e.target.value),placeholder:P(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.`)})]})]}),V.isError&&r(`div`,{className:`rounded border border-danger/30 bg-danger/5 text-danger px-3 py-2 text-[11px]`,children:V.error instanceof Error?V.error.message:String(V.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),N(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:()=>{g&&V.mutate({id:H,type:p,displayName:S.trim(),providerId:g.providerId,config:b,enabled:E,nodeId:g.nodeLocal?k:void 0})},disabled:V.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:[V.isPending?r(v,{className:`h-3.5 w-3.5 animate-spin`}):null,V.isPending?c(`storage.addLocationWizard.saving`,`Saving…`):c(`common.save`,`Save`)]})]})]})]})]})]})})}function z(e){return x(e)}function B(e){return e===`active`}var V=[{mode:`active`,get label(){return A.t(`helpers.locationMode.activeLabel`)},get consequence(){return A.t(`helpers.locationMode.activeConsequence`)},requiresConfirmation:!1},{mode:`readonly`,get label(){return A.t(`helpers.locationMode.readonlyLabel`)},get consequence(){return A.t(`helpers.locationMode.readonlyConsequence`)},requiresConfirmation:!1},{mode:`drain`,get label(){return A.t(`helpers.locationMode.drainLabel`)},get consequence(){return A.t(`helpers.locationMode.drainConsequence`)},requiresConfirmation:!1},{mode:`disabled`,get label(){return A.t(`helpers.locationMode.disabledLabel`)},get consequence(){return A.t(`helpers.locationMode.disabledConsequence`)},requiresConfirmation:!0}];function H(e){return V.find(t=>t.mode===e)??V[0]}function de(e){return H(e).requiresConfirmation}var fe=`Blocked: this is the last location of its type still accepting writes — new data would have nowhere to go.`;function U(e,t,n){return B(n)||!B(z(e))||t.some(t=>t.id!==e.id&&B(z(t)))?{blocked:!1,reason:``}:{blocked:!0,reason:fe}}function pe(e,t){return{active:U(e,t,`active`).reason,readonly:U(e,t,`readonly`).reason,drain:U(e,t,`drain`).reason,disabled:U(e,t,`disabled`).reason}}function me(e,t,n){return!(n===`single`||t.length<=1||B(z(e))&&t.filter(e=>B(z(e))).length<=1)}function he(e){return e===`active`?{enabled:!0,readOnly:!1}:e===`readonly`?{enabled:!1,readOnly:!1}:{enabled:!1,readOnly:!0}}function W(e,t){let n={...t.config??e.config};t.mode!==void 0&&(he(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:he(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`?A.t(`helpers.locationProtection.unitGb`):A.t(`helpers.locationProtection.unitPercent`)}function Ce(e,t=10){let n=e.value===null?A.t(`helpers.locationProtection.targetDefault`,{percent:String(t)}):e.unit===`gb`?A.t(`helpers.locationProtection.targetGb`,{value:String(e.value)}):A.t(`helpers.locationProtection.targetPercent`,{value:String(e.value)});return A.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}=j(),[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}=j(),l=s(),u=_().trpcClient,[d,f]=a({...n.config}),[p,m]=a(n.displayName),[h,g]=a(null),[y,b]=a(!1),x=O(),S=t(()=>{let e=x.data;return Array.isArray(e)?e.find(e=>e.providerId===n.providerId)??null:null},[x.data,n.providerId]),C=re({onSuccess:()=>{l.invalidateQueries({queryKey:[[`storage`,`listLocations`]]}),o()}}),w=S?.shouldSaveDiskSpace===!0,E=S?.nodeLocal===!0,[D,A]=a(typeof n.nodeId==`string`?n.nodeId:`hub`),M=typeof d.basePath==`string`?d.basePath:``,N=e=>f(t=>({...t,basePath:e})),P=S?.minFreePercent??10,F=async()=>{b(!0),g(null);try{g(await(e=>u.storage.testConfig.query(e))({providerId:n.providerId,locationId:n.id,config:d}))}catch(e){g({ok:!1,error:e instanceof Error?e.message:String(e)})}finally{b(!1)}};return r(te,{open:!0,onOpenChange:e=>!e&&i(),children:e(ae,{width:`md`,placement:`sheet-on-mobile`,scroll:`body`,children:[e(ie,{children:[r(ee,{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(ne,{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(se,{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(oe,{selectedNodeId:D,onSelect:A,alwaysShow:!0}),r(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:c(`storage.editLocationModal.path`,`Path`)}),r(ue,{nodeId:D,value:M,onChange:N})]}),w&&r(Ee,{config:d,defaultPercent:P,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(ce,{i18nKey:`storage.editLocationModal.providerGone`,values:{id:n.providerId},components:{code:r(`code`,{className:`font-mono`})}})}),h&&r(`div`,{className:`rounded border px-3 py-2 text-[11px] ${h.ok?`border-success/30 bg-success/5 text-success`:`border-danger/30 bg-danger/5 text-danger`}`,children:h.ok?c(`storage.editLocationModal.connectionOk`,`Connection OK.`):c(`storage.editLocationModal.testFailed`,`Test failed: {{value1}}`,{value1:h.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(k,{className:`justify-between`,children:[r(T,{variant:`outline`,size:`sm`,onClick:i,children:c(`common.cancel`,`Cancel`)}),e(`div`,{className:`flex items-center gap-2`,children:[r(T,{variant:`outline`,size:`sm`,onClick:()=>{F()},disabled:y||!S,children:y?c(`storage.editLocationModal.testing`,`Testing…`):c(`storage.editLocationModal.testConnection`,`Test connection`)}),e(T,{size:`sm`,onClick:()=>{C.mutate(W(n,{displayName:p.trim(),config:d,nodeId:E?D:n.nodeId}))},disabled:C.isPending||p.trim().length===0,children:[C.isPending?r(v,{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}=j();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:M(n.ownedBytes);return{kind:`unknown`,owned:e,summary:e===null?A.t(`helpers.locationCapacityBar.unknownSummary`):A.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:M(r),freeTotal:M(a),freeTotalPercent:X(a/r),used:M(p),usedPercent:X(p/r),free:M(u),freePercent:X(u/r),reserve:s===0?null:A.t(`helpers.locationCapacityBar.reserveKept`,{size:M(s)}),owned:f===null||_===null?null:A.t(`helpers.locationCapacityBar.ownedOfRecordings`,{size:M(f),percent:X(_)}),cap:v===null?null:v.reason===`drain`?A.t(`helpers.locationCapacityBar.capDrain`,{size:M(v.bytes)}):A.t(`helpers.locationCapacityBar.capCap`,{size:M(v.bytes)})},S=[A.t(`helpers.locationCapacityBar.summaryFree`,{free:x.freeTotal,total:x.total,percent:x.freeTotalPercent}),x.owned===null?null:A.t(`helpers.locationCapacityBar.summaryOwned`,{owned:x.owned}),x.reserve===null?null:l?A.t(`helpers.locationCapacityBar.summaryReserveShort`,{reserve:x.reserve}):x.reserve,x.cap===null?null:b?A.t(`helpers.locationCapacityBar.summaryCapBelow`,{cap:x.cap}):x.cap].filter(e=>e!==null).join(` · `),C=[];return c>0&&C.push({segment:`reserve`,label:A.t(`helpers.locationCapacityBar.legendKeptFree`),value:M(s),alarming:l}),x.owned!==null&&C.push({segment:`owned`,label:A.t(`helpers.locationCapacityBar.legendCamstack`),value:x.owned,alarming:!1}),C.push({segment:`used`,label:f===null?A.t(`helpers.locationCapacityBar.legendUsed`):A.t(`helpers.locationCapacityBar.legendOtherData`),value:`${x.used} (${x.usedPercent})`,alarming:g===`critical`}),C.push({segment:`free`,label:A.t(`helpers.locationCapacityBar.legendFree`),value:`${x.free} (${x.freePercent})`,alarming:l}),v!==null&&C.push({segment:`cap`,label:v.reason===`drain`?A.t(`helpers.locationCapacityBar.legendDrainTarget`):A.t(`helpers.locationCapacityBar.legendCap`),value:A.t(`helpers.locationCapacityBar.legendCapValue`,{size:M(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}=j(),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,z(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!B(z(e))}function $e(e,t){return Xe(e.type)===null||!Qe(e)?!1:t.some(t=>t.id!==e.id&&B(z(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}=j(),o=b(),s=E(),c=Ze(t.type),[l,u]=a(null),[d,f]=a(null),[p,m]=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 h=l!==null&&l.locationId===t.id,g=h&&l.running,_=h&&l.phase!==`idle`,x=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),m(!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{m(!1)}}},S=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:[g?e(`button`,{type:`button`,onClick:()=>void S(),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(y,{className:`h-3 w-3`}),n(`common.cancel`,`Cancel`)]}):e(`button`,{type:`button`,onClick:()=>void x(),disabled:p,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:[p?r(v,{className:`h-3 w-3 animate-spin`}):r(C,{className:`h-3 w-3`}),n(`storage.locationDiscardControl.discardLeftovers`,`Discard leftovers`)]}),_&&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||h&&l?.error)&&r(`p`,{className:`text-[10px] text-danger leading-tight`,children:d??l?.error})]})}o();var ot={active:p,readonly:S,drain:w,disabled:d},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}=j(),o=H(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(l,{className:`h-3 w-3 ${n?`rotate-180`:``}`})]})}function lt({mode:t,blockedReasons:n,onSelect:a,onDismiss:o}){let{t:s}=j();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(y,{className:`h-3 w-3`})})]}),V.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:u,ownedBytes:d}){let{t:p}=j(),[m,h]=a(!1),_=ut(t.config),v=z(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:d??null}),u!==void 0&&r(Ie,{drain:u})]})]}),e(`div`,{className:`flex flex-wrap items-center gap-1 shrink-0`,children:[r(it,{location:t,siblings:l}),r(ct,{mode:v,open:m,onToggle:()=>{h(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(g,{className:`h-3 w-3`}),p(`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:p(`storage.locationCard.deleteLocation`,`Delete location`),children:r(f,{className:`h-3 w-3`})})]}),m&&r(lt,{mode:v,blockedReasons:s,onSelect:e=>o(t,e),onDismiss:()=>{h(!1)}})]})}o();function ft({type:n,displayName:i,description:a,cardinality:o,locations:s,onAdd:l,onEdit:d,onDelete:f,onSetMode:p,ownedBytesById:h,drainById:g}){let{t:_}=j(),v=t(()=>{let e=[...s];return e.sort((e,t)=>{let n=B(z(e));return n===B(z(t))?e.displayName.localeCompare(t.displayName):n?-1:1}),e},[s]);return e(D,{headingId:`storage-location-${n}`,title:i,icon:m,testId:`storage-location-group-${n}`,actions:o===`multi`?e(T,{size:`sm`,type:`button`,onClick:()=>l(n),children:[r(u,{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:me(e,v,o),onEdit:d,onDelete:f,onSetMode:p,blockedReasons:pe(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,H as c,Be as i,de as l,ft as n,De as o,q as r,W as s,gt as t,R as u};
@@ -16,4 +16,4 @@ const __mfImport = (src) =>
16
16
  await __mfHostInit.__tla;
17
17
  const { initHost } = __mfHostInit;
18
18
  await initHost();
19
- })().then(() => __mfImport("./index-D_AGxR1C.js"));
19
+ })().then(() => __mfImport("./index-hw1sXUcO.js"));
@@ -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{Wa as r,br as i,da as a,fa as o,wr as s}from"./client-Gv3pB3LY.js";import{$n as c,Xn as l,Zn as u,er as d,ir as f,rr as p}from"./src-DWX1wfhS.js";import{t as m}from"./i18n-D0vRhk5m.js";import{gr as h}from"./index-D_AGxR1C.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 ee(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 te(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 ne(e){return e.state===`unreadable`&&s.state===`unreadable`&&e.reason===s.reason}function S(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 ne(e)?[]:[{code:`camera-sensors-unreadable`,severity:`warning`,message:m.t(`helpers.cameraCardModel.sensorsUnreadable`,{reason:e.reason})}];let t=e.sensors.flatMap(e=>{let t=S(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=r(e),n=e=>{let n=t.get(e);if(n!==void 0)return n.value??n.default},i=new Set;for(let[e,n]of t)N(n.value,n.default)&&i.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:i}}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)} · ${p(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:c({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=c({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!a(e)||n===void 0?!1:o(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=i(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 u(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,te 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,ee as y};
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{Wa as r,br as i,da as a,fa as o,wr as s}from"./client-Gv3pB3LY.js";import{$n as c,Xn as l,Zn as u,er as d,ir as f,rr as p}from"./src-DWX1wfhS.js";import{t as m}from"./i18n-D0vRhk5m.js";import{gr as h}from"./index-hw1sXUcO.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 ee(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 te(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 ne(e){return e.state===`unreadable`&&s.state===`unreadable`&&e.reason===s.reason}function S(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 ne(e)?[]:[{code:`camera-sensors-unreadable`,severity:`warning`,message:m.t(`helpers.cameraCardModel.sensorsUnreadable`,{reason:e.reason})}];let t=e.sensors.flatMap(e=>{let t=S(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=r(e),n=e=>{let n=t.get(e);if(n!==void 0)return n.value??n.default},i=new Set;for(let[e,n]of t)N(n.value,n.default)&&i.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:i}}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)} · ${p(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:c({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=c({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!a(e)||n===void 0?!1:o(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=i(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 u(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,te 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,ee 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{zt as a}from"./player-overlays-DmlN4sZb.js";import{gr as o,ur as s}from"./index-D_AGxR1C.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};
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{zt as a}from"./player-overlays-DmlN4sZb.js";import{gr as o,ur as s}from"./index-hw1sXUcO.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,7 +136,7 @@
136
136
  })
137
137
  })()
138
138
  </script>
139
- <script type="module" crossorigin src="./assets/mf-entry-bootstrap-0-6afad399.js"></script>
139
+ <script type="module" crossorigin src="./assets/mf-entry-bootstrap-0-1934b2aa.js"></script>
140
140
  <link rel="modulepreload" crossorigin href="./assets/__vite-browser-external-BlMfPwfH.js">
141
141
  <link rel="modulepreload" crossorigin href="./assets/client-Gv3pB3LY.js">
142
142
  <link rel="modulepreload" crossorigin href="./assets/player-overlays-DmlN4sZb.js">
@@ -147,7 +147,7 @@
147
147
  <link rel="modulepreload" crossorigin href="./assets/mount-Bf0X4ydS.js">
148
148
  <link rel="modulepreload" crossorigin href="./assets/addon-icons-context-BOriiEsT.js">
149
149
  <link rel="stylesheet" crossorigin href="./assets/index-BPZW59_u.css">
150
- <link rel="modulepreload" crossorigin href="./assets/hostInit-DI-nfbwk.js"><link rel="modulepreload" crossorigin href="./assets/index-D_AGxR1C.js"><link rel="modulepreload" crossorigin href="./assets/remoteEntry-BXlJ18mT.js"><link rel="modulepreload" crossorigin href="./assets/_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-D7ATU8Xn.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>
150
+ <link rel="modulepreload" crossorigin href="./assets/hostInit-DI-nfbwk.js"><link rel="modulepreload" crossorigin href="./assets/index-hw1sXUcO.js"><link rel="modulepreload" crossorigin href="./assets/remoteEntry-BXlJ18mT.js"><link rel="modulepreload" crossorigin href="./assets/_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-D7ATU8Xn.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`
@@ -84036,7 +84036,7 @@ var AdminUIAddon = class extends BaseAddon {
84036
84036
  capability: adminUiCapability,
84037
84037
  provider: {
84038
84038
  getStaticDir: async () => ({ staticDir: resolveAdminUiDistDir() }),
84039
- getVersion: async () => ({ version: "1.2.499" })
84039
+ getVersion: async () => ({ version: "1.2.500" })
84040
84040
  }
84041
84041
  }];
84042
84042
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-admin-ui",
3
- "version": "1.2.499",
3
+ "version": "1.2.500",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Admin UI — Vite frontend build and server-side addon",
@@ -1,3 +0,0 @@
1
- import{C as e,J as t,K as n,R as r,S as i,V as a,Y as o,a as s,et as c,t 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{D as d,En as f,Fn as p,G as m,Ht as h,L as g,Li as _,Ni as v,Pn as y,Pr as b,Q as x,Ri as S,Vn as C,Xr as w,_n as T,ai as E,dt as D,fr as O,gt as ee,na as k,ni as A,rn as j,st as M,tn as N,vn as P}from"./player-overlays-DmlN4sZb.js";import{$a as te,Br as F,zr as I}from"./client-Gv3pB3LY.js";import{n as L,t as ne}from"./send-DC9n_ItK.js";import{t as R}from"./message-square-plus-BxGpiezi.js";import{Cn as z,Dr as B,Er as V,Fr as re,Hn as H,Or as U,Qn as ie,Sn as W,Tr as G,Wn as ae,Yr as K,_o as oe,ad as q,bn as J,bt as Y,ed as se,ft as ce,mt as le,ni as X,od as ue,or as de,rt as fe,xt as pe}from"./src-DWX1wfhS.js";import{t as Z}from"./i18n-D0vRhk5m.js";import{t as Q}from"./useTranslation-BJr-n0es.js";import"./mount-Bf0X4ydS.js";import{S as me,gr as he}from"./index-D_AGxR1C.js";import{t as ge}from"./AdminSectionedPage-BYs8ku8k.js";import{t as _e}from"./AdminPage-CdqsBsG5.js";c();var ve=`__redacted__`,ye=[`llm`,`listProfiles`],be=[`llm`,`listProfileKinds`],xe=[`llm`,`getDefaults`],Se=[`llm`,`listRuntimeNodes`],Ce=[`llm`,`listModelCatalog`],we=[`llm`,`getUsage`],Te=[{purpose:`vision`,visionOnly:!0},{purpose:`text`,visionOnly:!1}],Ee=new Map([[`cloud`,E],[`plug`,y],[`cpu`,A],[`server`,T],[`sparkles`,j]]);function De(e){return Ee.get(e)??S}function Oe(e){return typeof e==`string`&&e.length>0?e:void 0}function ke(e){if(typeof e==`number`&&Number.isFinite(e))return e;if(typeof e==`string`&&e.trim()!==``){let t=Number(e);return Number.isFinite(t)?t:void 0}}function Ae(e){return e===!0}function je(e){let t=new Map;for(let n of e){let e=t.get(n.addonId)??[];e.push(n),t.set(n.addonId,e)}return[...t.entries()].map(([e,t])=>({addonId:e,kinds:t}))}var Me={deviceNotEligible:{key:`ai.appleNotEligible`,tone:`default`},appleIntelligenceNotEnabled:{key:`ai.appleIntelligenceOff`,tone:`warning`},modelNotReady:{key:`ai.appleModelNotReady`,tone:`warning`},osTooOld:{key:`ai.appleOsTooOld`,tone:`default`},helperMissing:{key:`ai.appleHelperMissing`,tone:`danger`},helperCrashed:{key:`ai.appleHelperCrashed`,tone:`danger`}};function Ne(e){let t=t=>({nodeId:e.nodeId,selectable:!1,labelKey:`ai.appleUnknown`,labelDefault:Z.t(`ai.appleUnknown`),detail:t,tone:`default`});if(!e.reachable)return t(e.error??null);let n=e.apple;if(n===void 0)return t(null);switch(n.state){case`available`:return{nodeId:e.nodeId,selectable:!0,labelKey:`ai.appleAvailable`,labelDefault:Z.t(`ai.appleAvailable`),detail:Z.t(n.imageInput?`helpers.aiPage.appleDetailImages`:`helpers.aiPage.appleDetailText`,{version:n.osVersion}),tone:`success`};case`unavailable`:{let t=Me[n.reason];return{nodeId:e.nodeId,selectable:!1,labelKey:t.key,labelDefault:Z.t(t.key),detail:n.detail,tone:t.tone}}case`unsupported-platform`:return{nodeId:e.nodeId,selectable:!1,labelKey:`ai.appleNotMac`,labelDefault:Z.t(`ai.appleNotMac`),detail:n.platform,tone:`default`};case`unknown`:return t(n.error)}}var Pe={ready:`success`,downloading:`info`,starting:`info`,stopped:`danger`,crashed:`danger`,failed:`danger`},Fe={ready:`ai.stateReady`,downloading:`ai.stateDownloading`,starting:`ai.stateStarting`,stopped:`ai.stateStopped`,crashed:`ai.stateCrashed`,failed:`ai.stateFailed`};function Ie(e){return e.reachable?e.status===void 0?`ai.stateReady`:Fe[e.status.state]:`ai.unreachable`}function Le(e){return e.reachable?e.status===void 0?`success`:Pe[e.status.state]:`danger`}function Re(e){if(!e.reachable)return[];let t=[],n=e.apple;if(n?.state===`available`)t.push({id:`apple`,labelKey:`ai.featureApple`,tone:`success`,detail:Ne(e).detail}),n.imageInput&&t.push({id:`apple-images`,labelKey:`ai.featureAppleImages`,tone:`success`,detail:null});else if(n?.state===`unavailable`){let n=Ne(e);t.push({id:`apple`,labelKey:`ai.featureApple`,tone:n.tone,detail:n.labelDefault})}let r=e.status?.vramBytes;return r!==void 0&&r>0&&t.push({id:`gpu`,labelKey:`ai.featureGpu`,tone:`info`,detail:null}),t}function ze(){return{temperature:[{type:`slider`,key:`temperature`,label:Z.t(`helpers.aiProfileForm.temperature`),min:0,max:2,step:.1,showValue:!0,showStepper:!0,nullable:!0,nullLabel:`Provider default`,description:Z.t(`helpers.aiProfileForm.temperatureHint`)}],topP:[{type:`slider`,key:`topP`,label:Z.t(`helpers.aiProfileForm.topP`),min:0,max:1,step:.05,showValue:!0,showStepper:!0,nullable:!0,nullLabel:`Provider default`}],topK:[{type:`number`,key:`topK`,label:Z.t(`helpers.aiProfileForm.topK`),min:1}],maxTokens:[{type:`number`,key:`maxTokens`,label:Z.t(`helpers.aiProfileForm.maxTokens`),min:1}],contextLength:[{type:`number`,key:`contextLength`,label:Z.t(`helpers.aiProfileForm.contextLength`),min:512,unit:`tokens`,description:Z.t(`helpers.aiProfileForm.contextLengthHint`)}],systemPrompt:[{type:`textarea`,key:`systemPrompt`,label:Z.t(`helpers.aiProfileForm.systemPrompt`),rows:4,maxLength:4e3,span:2,description:Z.t(`helpers.aiProfileForm.systemPromptHint`)}],timeoutMs:[{type:`number`,key:`timeoutMs`,label:Z.t(`helpers.aiProfileForm.timeoutTotal`),min:1e3,default:F.totalMs,unit:`ms`,description:Z.t(`helpers.aiProfileForm.timeoutTotalHint`)}],connectTimeoutMs:[{type:`number`,key:`connectTimeoutMs`,label:Z.t(`helpers.aiProfileForm.timeoutConnect`),min:500,default:F.connectMs,unit:`ms`,description:Z.t(`helpers.aiProfileForm.timeoutConnectHint`)}],firstTokenTimeoutMs:[{type:`number`,key:`firstTokenTimeoutMs`,label:Z.t(`helpers.aiProfileForm.timeoutFirstToken`),min:1e3,default:F.firstTokenMs,unit:`ms`,description:Z.t(`helpers.aiProfileForm.timeoutFirstTokenHint`)}],idleTimeoutMs:[{type:`number`,key:`idleTimeoutMs`,label:Z.t(`helpers.aiProfileForm.timeoutIdle`),min:1e3,default:F.idleMs,unit:`ms`,description:Z.t(`helpers.aiProfileForm.timeoutIdleHint`)}],retry:[{type:`boolean`,key:`retryEnabled`,label:Z.t(`helpers.aiProfileForm.retry`),description:Z.t(`helpers.aiProfileForm.retryHint`)},{type:`number`,key:`retryMaxAttempts`,label:Z.t(`helpers.aiProfileForm.retryMaxAttempts`),min:1,max:5,default:1,showWhen:{field:`retryEnabled`,equals:!0}}],toolsEnabled:[{type:`boolean`,key:`toolsEnabled`,label:Z.t(`helpers.aiProfileForm.toolsEnabled`),description:Z.t(`helpers.aiProfileForm.toolsEnabledHint`)}]}}var Be=[`temperature`,`topP`,`topK`,`maxTokens`,`contextLength`,`systemPrompt`],Ve=[`timeoutMs`,`connectTimeoutMs`,`firstTokenTimeoutMs`,`idleTimeoutMs`,`retry`,`toolsEnabled`];function He(e,t){let n=ze();return t.filter(t=>e.includes(t)).flatMap(e=>n[e])}function Ue(e){let t=He(e,Be);return t.length===0?null:{sections:[{id:`generation`,title:Z.t(`helpers.aiProfileForm.generation`),fields:t}]}}function We(e){let t=He(e,Ve);return t.length===0?null:{sections:[{id:`bounds`,title:Z.t(`helpers.aiProfileForm.bounds`),fields:t}]}}function Ge(e){return e===null?{}:{temperature:e.temperature,topP:e.topP,topK:e.topK,maxTokens:e.maxTokens,contextLength:e.contextLength,systemPrompt:e.systemPrompt,timeoutMs:e.timeoutMs,connectTimeoutMs:e.connectTimeoutMs,firstTokenTimeoutMs:e.firstTokenTimeoutMs,idleTimeoutMs:e.idleTimeoutMs,retryEnabled:e.retry.enabled,retryMaxAttempts:e.retry.maxAttempts,toolsEnabled:e.toolsEnabled}}function Ke(e,t){return{...e.features,...t?.features}}function qe(e,t){return t===null?e.modelCatalog===`static`?e.staticModels??[]:[]:t}function Je(e,t,n){let r=e.profileFields,i=n.common,a=(e,t,n)=>r.includes(e)?ke(i[e])??t:n??t,o=e=>r.includes(e)?ke(i[e]):t?.[e],s=o(`temperature`),c=o(`topP`),l=o(`topK`),u=o(`maxTokens`),d=o(`contextLength`),f=r.includes(`systemPrompt`)?Oe(i.systemPrompt):t?.systemPrompt;return{id:t?.id??crypto.randomUUID(),name:n.name,kind:e.kind,addonId:e.addonId.length>0?e.addonId:`ai`,enabled:t?.enabled??!0,model:n.model,supportsVision:n.supportsVision,timeoutMs:a(`timeoutMs`,F.totalMs,t?.timeoutMs),connectTimeoutMs:a(`connectTimeoutMs`,F.connectMs,t?.connectTimeoutMs),firstTokenTimeoutMs:a(`firstTokenTimeoutMs`,F.firstTokenMs,t?.firstTokenTimeoutMs),idleTimeoutMs:a(`idleTimeoutMs`,F.idleMs,t?.idleTimeoutMs),retry:r.includes(`retry`)?{enabled:Ae(i.retryEnabled),maxAttempts:ke(i.retryMaxAttempts)??1}:t?.retry??{enabled:!1,maxAttempts:1},toolsEnabled:r.includes(`toolsEnabled`)?Ae(i.toolsEnabled):t?.toolsEnabled??!1,...s===void 0?{}:{temperature:s},...c===void 0?{}:{topP:c},...l===void 0?{}:{topK:l},...u===void 0?{}:{maxTokens:u},...d===void 0?{}:{contextLength:d},...f===void 0?{}:{systemPrompt:f},providerConfig:n.providerConfig}}var Ye=2e3;function $(e){return Z.t(`system.aiModelPicker.sizeGb`,{value:(e/1e9).toFixed(2)})}function Xe(e){return e===null?``:e.model.kind===`catalog`?`catalog:${e.model.catalogId}`:e.model.kind===`path`?`node:${e.modelId}`:`custom`}function Ze({nodeId:t,value:r,onChange:a}){let{t:c}=Q(),u=D(),[d,f]=o(``),[p,m]=o(null),[h,g]=o(!1),_=s({queryKey:Ce,queryFn:()=>u.trpcClient.llm.listModelCatalog.query({})}),v=s({queryKey:[`llm`,`listNodeModels`,t],queryFn:()=>u.trpcClient.llm.listNodeModels.query({nodeId:t})}),y=l({mutationFn:e=>u.trpcClient.llm.resolveModelRef.mutate(e),onSuccess:e=>{m(e),g(!1),e.ok&&a({model:e.model,modelId:e.label,supportsVision:e.purpose===`vision`})}}),b=l({mutationFn:e=>u.trpcClient.llm.installModel.mutate({nodeId:t,model:e}),onSuccess:()=>{g(!0),v.refetch()}}),x=s({queryKey:Se,enabled:b.isPending,refetchInterval:b.isPending?Ye:!1,queryFn:()=>u.trpcClient.llm.listRuntimeNodes.query({})}).data?.find(e=>e.nodeId===t)?.status?.download,S=n(()=>{let e=(_.data??[]).map(e=>({value:`catalog:${e.id}`,label:`${e.label} · ${e.quantization} · ${$(e.sizeBytes)}`})),n=(v.data??[]).filter(e=>e.catalogId===void 0&&e.path!==void 0).map(e=>({value:`node:${e.file}`,label:c(`ai.onNode`,`{{file}} · {{size}} · on {{node}}`,{file:e.file,size:$(e.sizeBytes),node:t})})),r=p?.ok===!0?[{value:`custom`,label:`${p.label} · ${$(p.totalBytes)}`}]:[];return[{value:``,label:c(`ai.selectModel`,`Select a model…`)},...e,...n,...r]},[_.data,v.data,p,t,c]),C=e=>{if(e===``){a(null);return}if(e===`custom`){if(p?.ok!==!0)return;a({model:p.model,modelId:p.label,supportsVision:p.purpose===`vision`});return}if(e.startsWith(`catalog:`)){let t=e.slice(8),n=_.data?.find(e=>e.id===t);a({model:{kind:`catalog`,catalogId:t},modelId:t,supportsVision:n?.purpose===`vision`});return}let t=e.slice(5),n=v.data?.find(e=>e.file===t);n?.path!==void 0&&a({model:{kind:`path`,path:n.path},modelId:t,supportsVision:!1})},T=e=>{d.trim()!==``&&y.mutate({ref:d.trim(),...e===void 0?{}:{maxBytes:e}})};return e(`div`,{className:`space-y-3`,children:[i(pe,{label:c(`ai.model`,`Model`),required:!0,children:i(se,{id:`ai-model`,"aria-label":c(`ai.model`,`Model`),value:Xe(r),options:S,onChange:e=>C(e.target.value)})}),i(pe,{label:c(`ai.hfTitle`,`Add a model from Hugging Face`),description:c(`ai.hfHint`,`Paste a GGUF file URL, or type org/repo — add :QUANT (e.g. unsloth/Qwen3.6-35B-A3B-GGUF:UD-Q4_K_M) when the repo publishes more than one quantization.`),children:e(`div`,{className:`flex gap-2`,children:[i(q,{"aria-label":c(`ai.hfTitle`,`Add a model from Hugging Face`),value:d,onChange:e=>f(e.target.value),placeholder:c(`system.aiModelPicker.unslothQwen3635bA3b`,`unsloth/Qwen3.6-35B-A3B-GGUF:UD-Q4_K_M`),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),T())}}),e(K,{size:`sm`,variant:`secondary`,type:`button`,disabled:d.trim()===``||y.isPending,onClick:()=>T(),children:[y.isPending?i(O,{className:`h-3.5 w-3.5 animate-spin`}):i(P,{className:`h-3.5 w-3.5`}),c(`ai.hfCheck`,`Check`)]})]})}),y.isError&&i(G,{message:y.error instanceof Error?y.error.message:c(`common.error`,`Error`)}),p?.ok===!1&&i(G,{message:p.message,action:e(`div`,{className:`flex flex-wrap items-center gap-1`,children:[(p.candidates??[]).map(e=>i(K,{size:`sm`,variant:`outline`,type:`button`,onClick:()=>{let t=`${d.trim().split(`:`)[0]??``}:${e}`;f(t),y.mutate({ref:t})},children:e},e)),p.requiredBytes!==void 0&&i(K,{size:`sm`,variant:`secondary`,type:`button`,onClick:()=>T(p.requiredBytes),children:c(`ai.hfOverride`,`Install anyway ({{size}})`,{size:$(p.requiredBytes)})})]})}),p?.ok===!0&&e(`div`,{className:`space-y-2 rounded-md border border-border bg-surface p-2.5`,children:[e(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[i(`span`,{className:`text-[11px] font-medium text-foreground`,children:p.label}),i(X,{variant:p.purpose===`vision`?`info`:`default`,children:p.purpose}),i(X,{variant:`default`,children:$(p.totalBytes)})]}),p.extraFilenames.length>0&&i(`p`,{className:`text-[10px] text-foreground-subtle`,children:c(`ai.hfExtras`,`Also downloads: {{files}}`,{files:p.extraFilenames.join(`, `)})}),e(`div`,{className:`flex items-center gap-2`,children:[e(K,{size:`sm`,type:`button`,disabled:b.isPending||h,onClick:()=>b.mutate(p.model),children:[b.isPending?i(O,{className:`h-3.5 w-3.5 animate-spin`}):i(w,{className:`h-3.5 w-3.5`}),h?c(`ai.hfInstalled`,`Downloaded`):c(`ai.hfInstall`,`Download to {{node}}`,{node:t})]}),x!==void 0&&i(`span`,{className:`text-[10px] text-foreground-subtle`,children:x.phase===`verifying`?c(`ai.hfVerifying`,`verifying {{file}}…`,{file:x.file}):c(`ai.hfDownloading`,`{{file}} ({{index}}/{{count}}) — {{done}}{{total}}`,{file:x.file,index:x.fileIndex,count:x.fileCount,done:$(x.downloadedBytes),total:x.totalBytes===void 0?``:` / ${$(x.totalBytes)}`})})]}),b.isError&&i(G,{message:b.error instanceof Error?b.error.message:c(`common.error`,`Error`)})]})]})}function Qe({value:t,onChange:n}){let{t:r}=Q(),a=D(),o=s({queryKey:Se,queryFn:()=>a.trpcClient.llm.listRuntimeNodes.query({})});return e(`div`,{children:[i(`div`,{className:`mb-1 text-[11px] font-medium text-foreground`,children:r(`ai.appleNode`,`Mac that runs it`)}),o.isPending&&e(`div`,{className:`flex items-center gap-1.5 text-[11px] text-foreground-subtle`,children:[i(O,{className:`h-3.5 w-3.5 animate-spin`}),r(`ai.appleAsking`,`Asking the nodes…`)]}),o.isError&&i(`p`,{className:`text-[11px] text-danger`,children:o.error instanceof Error?o.error.message:r(`ai.runtimesFailed`,`Failed to read runtime nodes`)}),o.isSuccess&&o.data.length===0&&i(`p`,{className:`text-[11px] text-foreground-subtle`,children:r(`ai.noRuntimes`,`No node advertises the llm-runtime capability.`)}),o.isSuccess&&o.data.length>0&&i(`div`,{role:`radiogroup`,className:`space-y-1.5`,children:o.data.map(a=>{let o=Ne(a),s=o.nodeId===t;return e(`button`,{type:`button`,role:`radio`,"aria-checked":s,disabled:!o.selectable&&!s,onClick:()=>n(o.nodeId),className:`flex w-full items-center justify-between gap-2 rounded-md border px-3 py-2 text-left text-xs transition-colors disabled:cursor-not-allowed disabled:opacity-60 ${s?`border-primary bg-primary/10`:`border-border bg-surface hover:bg-surface-hover`}`,children:[e(`span`,{className:`min-w-0`,children:[i(`span`,{className:`block font-medium text-foreground`,children:o.nodeId}),o.detail!==null&&i(`span`,{className:`block truncate text-[10px] text-foreground-subtle`,children:o.detail})]}),i(X,{variant:o.tone,children:r(o.labelKey,o.labelDefault)})]},o.nodeId)})}),i(`p`,{className:`mt-1.5 text-[10px] leading-relaxed text-foreground-subtle`,children:r(`ai.appleHint`,`Text only for now — notification titles and summaries. Apple refuses prompts framed as surveillance; when it does, the next profile in the chain answers instead.`)})]})}function $e(e,t){let n=e[t];return typeof n==`string`&&n.length>0?n:null}function et({providerConfig:e,onProviderConfigChange:t}){return i(Qe,{value:$e(e,`nodeId`),onChange:n=>t({...e,nodeId:n})})}function tt({providerConfig:e,onProviderConfigChange:t,model:n,onModelChange:r}){let a=I.safeParse(e.model),o=a.success?{model:a.data,modelId:n.id,supportsVision:n.supportsVision}:null;return i(Ze,{nodeId:$e(e,`nodeId`)??`hub`,value:o,onChange:n=>{if(n===null){let{model:n,...i}=e;t(i),r({id:``,supportsVision:!1});return}t({...e,model:n.model}),r({id:n.modelId,supportsVision:n.supportsVision})}})}var nt=new Map([[`ai/apple-node`,et],[`ai/managed-model`,tt]]);function rt(e){return nt.get(e)??null}c();function it({kind:e,className:t}){return i(De(e.icon),{className:t,"aria-hidden":!0})}function at({kinds:e,onPick:t,onCancel:r}){let{t:a}=Q(),o=n(()=>je(e),[e]),s=n(()=>new Map(e.map(e=>[`${e.addonId}:${e.kind}`,e])),[e]);return i(le,{open:!0,onClose:r,title:a(`ai.chooseKind`,`Choose a profile type`),width:`lg`,testId:`ai-kind-picker`,children:i(Y,{emptyMessage:a(`ai.noKinds`,`No AI provider is installed.`),onPick:e=>{let n=s.get(e);n!==void 0&&t(n)},groups:o.map(e=>({id:e.addonId,label:e.addonId,tiles:e.kinds.map(t=>({key:`${e.addonId}:${t.kind}`,label:t.label,testId:`ai-kind-${t.kind}`,icon:i(it,{kind:t,className:`h-5 w-5 text-foreground-subtle`})}))}))})})}function ot(e){return(e?.sections??[]).flatMap(e=>e.fields)}function st(...e){let t={};for(let n of e)for(let e of ot(n))`default`in e&&e.default!==void 0&&(t[e.key]=e.default);return t}function ct(e){return e==null?!1:typeof e==`string`?e.trim().length>0:!0}function lt(e,t){return ot(e).filter(e=>`required`in e&&e.required===!0&&!ct(t[e.key])).map(e=>`label`in e&&typeof e.label==`string`?e.label:e.key)}var ut={auth:{key:`ai.listAuth`,fallback:`Credentials refused`},network:{key:`ai.listNetwork`,fallback:`Endpoint unreachable`},unsupported:{key:`ai.listUnsupported`,fallback:`No model list`},invalid:{key:`ai.listInvalid`,fallback:`Connection incomplete`}};function dt(e,t){if(t!==null)return{id:t.model,supportsVision:t.supportsVision};let n=e.modelCatalog===`static`&&e.staticModels?.length===1?e.staticModels?.[0]:void 0;return{id:n?.id??``,supportsVision:Ke(e,n).vision}}function ft({kind:t,existing:r,onSave:a,onCancel:s,onChangeKind:c,saving:p,error:m}){let{t:h}=Q(),_=D(),[v,y]=o(r?.name??t.label),[b,x]=o(()=>r===null?st(t.connectionSchema,t.advancedSchema):{...r.providerConfig}),[S,C]=o(()=>Ge(r)),[w,T]=o(()=>dt(t,r)),[E,ee]=o(!1),A=t.providerWidgets??[],j=A.filter(e=>e.placement===`connection`),M=A.find(e=>e.placement===`model`)??null,N=n(()=>[...te(t.connectionSchema)].some(e=>r?.providerConfig[e]===ve),[r,t.connectionSchema]),P=l({mutationFn:()=>_.trpcClient.llm.listModels.mutate({addonId:t.addonId,kind:t.kind,connection:b,...r===null?{}:{profileId:r.id}}),onSuccess:e=>{e.ok&&T(n=>{let r=e.models.find(e=>e.id===n.id);return r===void 0?n:{id:n.id,supportsVision:Ke(t,r).vision}})}}),F=qe(t,P.data?.ok===!0?P.data.models:null),I=F.find(e=>e.id===w.id),L=Ke(t,I),ne=Ue(t.profileFields),R=We(t.profileFields),z=lt(t.connectionSchema,b),B=A.some(e=>(e.requires??[]).some(e=>!ct(b[e]))),V=t.modelCatalog===`fetch`&&M===null,re=ot(t.connectionSchema).length>0||j.length>0,U=e=>{T({id:e,supportsVision:Ke(t,F.find(t=>t.id===e)).vision})},W=p||v.trim()===``||w.id.trim()===``||z.length>0||B,ae=()=>{a(Je(t,r,{name:v.trim(),model:w.id.trim(),supportsVision:t.visionEditable?w.supportsVision:!1,common:S,providerConfig:b}))},oe=r===null?h(`ai.newProfile`,`New {{kind}} profile`,{kind:t.label}):h(`ai.editProfile`,`Edit {{name}}`,{name:r.name}),Y=e=>{let n=rt(e);return n===null?i(G,{variant:`warning`,message:h(`ai.unknownWidget`,`This provider needs an editor part this build does not have ({{id}}).`,{id:e})}):i(n,{descriptor:t,providerConfig:b,onProviderConfigChange:x,model:w,onModelChange:T},e)};return i(le,{open:!0,onClose:s,title:oe,error:m,width:`lg`,testId:`ai-profile-editor`,footer:e(u,{children:[z.length>0&&i(X,{variant:`warning`,children:h(`ai.missingRequired`,`required: {{fields}}`,{fields:z.join(`, `)})}),z.length===0&&B&&i(X,{variant:`warning`,children:h(`ai.completeProvider`,`complete the provider settings`)}),z.length===0&&!B&&w.id.trim()===``&&i(X,{variant:`warning`,children:h(`ai.pickModelFirst`,`pick a model`)}),e(K,{size:`sm`,type:`button`,disabled:W,onClick:ae,children:[p&&i(O,{className:`h-3.5 w-3.5 animate-spin`}),r===null?h(`ai.createProfile`,`Create profile`):h(`ai.saveChanges`,`Save changes`)]})]}),children:e(`div`,{className:g,children:[e(`div`,{className:`flex flex-wrap items-center gap-2`,"data-testid":`ai-editor-provider`,children:[i(it,{kind:t,className:`h-4 w-4 text-foreground-subtle`}),i(`span`,{className:`text-xs font-medium text-foreground`,children:t.label}),i(X,{variant:`neutral`,children:t.addonId}),c!==void 0&&e(K,{size:`sm`,variant:`ghost`,type:`button`,onClick:c,children:[i(k,{className:`h-3.5 w-3.5`}),h(`ai.changeKind`,`Change type`)]})]}),i(pe,{label:h(`ai.name`,`Name`),required:!0,children:i(q,{id:`ai-profile-name`,"aria-label":h(`ai.name`,`Name`),value:v,onChange:e=>y(e.target.value),placeholder:t.label})}),re&&i(J,{headingId:`ai-editor-connection`,title:h(`ai.sectionConnection`,`Connection`),actions:V?e(K,{size:`sm`,variant:`secondary`,type:`button`,disabled:P.isPending,onClick:()=>P.mutate(),"data-testid":`ai-verify-models`,children:[P.isPending?i(O,{className:`h-3.5 w-3.5 animate-spin`}):i(f,{className:`h-3.5 w-3.5`}),h(`ai.verifyModels`,`Verify & load models`)]}):void 0,children:e(`div`,{className:`p-2 sm:p-3 lg:p-4 space-y-3`,children:[ot(t.connectionSchema).length>0&&i(de,{bare:!0,schema:t.connectionSchema,values:b,onChange:x}),j.map(e=>Y(e.id)),N&&i(`p`,{className:`text-[10px] text-foreground-subtle`,children:h(`ai.secretHint`,`A stored API key is never shown. Leave it as-is to keep it; type a new value to replace it.`)}),P.data?.ok===!0&&i(X,{variant:`success`,"data-testid":`ai-models-found`,children:h(`ai.modelsFound`,`{{count}} models found`,{count:P.data.models.length})}),P.data?.ok===!1&&i(G,{title:h(ut[P.data.code]?.key??`ai.listNetwork`,ut[P.data.code]?.fallback??`Endpoint unreachable`),message:P.data.message}),P.isError&&i(G,{message:P.error instanceof Error?P.error.message:h(`common.error`,`Error`)})]})}),i(J,{headingId:`ai-editor-model`,title:h(`ai.sectionModel`,`Model`),children:e(`div`,{className:`${d} space-y-3`,children:[M===null?e(u,{children:[F.length>0&&i(se,{id:`ai-model-pick`,"aria-label":h(`ai.selectModel`,`Select a model…`),value:I===void 0?``:I.id,options:[{value:``,label:h(`ai.selectModel`,`Select a model…`)},...F.map(e=>({value:e.id,label:e.label??e.id}))],onChange:e=>{e.target.value!==``&&U(e.target.value)}}),i(pe,{label:h(`ai.customModel`,`Model id`),description:h(`ai.customModelHint`,`Pick one from the list, or type any model id the provider accepts.`),required:!0,children:i(q,{id:`ai-model-id`,"aria-label":h(`ai.customModel`,`Model id`),value:w.id,onChange:e=>T({...w,id:e.target.value}),placeholder:F[0]?.id??`model-id`})})]}):Y(M.id),e(`div`,{className:`flex flex-wrap items-center gap-1.5`,"data-testid":`ai-model-features`,children:[(w.supportsVision||!t.visionEditable&&L.vision)&&i(X,{variant:`info`,children:h(`ai.featureVision`,`vision`)}),L.tools&&i(X,{variant:`neutral`,children:h(`ai.featureTools`,`tools`)}),L.streaming&&i(X,{variant:`neutral`,children:h(`ai.featureStreaming`,`streaming`)})]}),t.visionEditable&&i(pe,{orientation:`horizontal`,label:h(`ai.supportsVision`,`Supports vision`),description:h(`ai.supportsVisionHint`,`A vision call against a text-only profile is refused, never downgraded.`),children:i(H,{checked:w.supportsVision,onCheckedChange:e=>T({...w,supportsVision:e}),"aria-label":h(`ai.supportsVision`,`Supports vision`)})})]})}),ne!==null&&i(J,{headingId:`ai-editor-generation`,title:h(`ai.sectionGeneration`,`Generation`),children:i(`div`,{className:`p-2 sm:p-3 lg:p-4`,children:i(de,{bare:!0,schema:ne,values:S,onChange:C})})}),(R!==null||t.advancedSchema!==void 0)&&i(ie,{expanded:E,onExpandedChange:ee,header:i(`span`,{className:`text-[11px] font-semibold uppercase tracking-wider text-foreground-subtle`,children:h(`ai.sectionAdvanced`,`Advanced`)}),children:e(`div`,{className:`p-2 sm:p-3 lg:p-4 space-y-3`,children:[R!==null&&i(de,{bare:!0,schema:R,values:S,onChange:C}),t.advancedSchema!==void 0&&i(de,{bare:!0,schema:t.advancedSchema,values:b,onChange:x})]})})]})})}c();function pt(t){return[{key:`name`,header:t.t(`ai.colProfile`,`Profile`),render:n=>{let r=t.kindByName.get(n.kind);return e(`span`,{className:`flex items-center gap-2`,children:[i(`span`,{className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-md bg-surface`,title:r?.label??n.kind,children:r===void 0?i(`span`,{className:`text-xs text-foreground-subtle`,children:`?`}):i(it,{kind:r,className:`h-4 w-4 text-foreground-subtle`})}),e(`span`,{className:`min-w-0`,children:[i(`span`,{className:`block truncate font-medium text-foreground`,children:n.name}),t.testResult?.id===n.id&&i(`span`,{className:`block truncate ${t.testResult.ok?`text-success`:`text-danger`}`,children:t.testResult.text})]})]})}},{key:`kind`,header:t.t(`ai.colKind`,`Kind`),nowrap:!0,render:e=>i(`span`,{className:`text-foreground-muted`,children:t.kindByName.get(e.kind)?.label??e.kind})},{key:`model`,header:t.t(`ai.colModel`,`Model`),render:e=>i(`span`,{className:`text-foreground`,children:e.model})},{key:`vision`,header:t.t(`ai.colVision`,`Vision`),align:`center`,nowrap:!0,render:e=>e.supportsVision?i(X,{variant:`info`,style:`outline`,children:t.t(`ai.vision`,`vision`)}):i(`span`,{className:`text-foreground-subtle`,children:`—`})},{key:`node`,header:t.t(`ai.colNode`,`Node`),nowrap:!0,render:e=>typeof e.providerConfig.nodeId==`string`?i(X,{variant:`default`,children:e.providerConfig.nodeId}):i(`span`,{className:`text-foreground-subtle`,children:`—`})},{key:`enabled`,header:t.t(`ai.colOn`,`On`),align:`center`,nowrap:!0,render:e=>i(H,{checked:e.enabled,onCheckedChange:()=>t.onToggle(e),"aria-label":Z.t(`system.aiProfilesTab.toggle`,`toggle {{name}}`,{name:e.name})})},{key:`actions`,header:``,align:`right`,nowrap:!0,render:n=>e(`span`,{className:`flex items-center justify-end gap-1`,children:[i(K,{size:`sm`,variant:`ghost`,type:`button`,onClick:()=>t.onTest(n),"aria-label":t.t(`ai.test`,`Test`),title:t.t(`ai.test`,`Test`),children:t.testingId===n.id?i(O,{className:`h-3.5 w-3.5 animate-spin`}):i(ne,{className:`h-3.5 w-3.5`})}),i(K,{size:`sm`,variant:`ghost`,type:`button`,disabled:!t.kindByName.has(n.kind),onClick:()=>t.onEdit(n),"aria-label":t.t(`common.edit`,`Edit`),title:t.t(`common.edit`,`Edit`),children:i(C,{className:`h-3.5 w-3.5`})}),i(K,{size:`sm`,variant:`ghost`,type:`button`,onClick:()=>t.onDelete(n),"aria-label":t.t(`common.delete`,`Delete`),title:t.t(`common.delete`,`Delete`),children:i(h,{className:`h-3.5 w-3.5 text-danger`})})]})}]}function mt(){let{t}=Q(),c=D(),{state:u,openEdit:f,close:p}=ce(),m=M(),[h,_]=o(null),[v,y]=o(null),[b,x]=o(null),S=s({queryKey:ye,queryFn:()=>c.trpcClient.llm.listProfiles.query({})}),C=s({queryKey:be,queryFn:async()=>(await c.trpcClient.llm.listProfileKinds.query({})).map(({connectionSchema:e,advancedSchema:t,...n})=>({...n,connectionSchema:e,...t===void 0?{}:{advancedSchema:t}}))}),w=()=>{S.refetch()},T=r(()=>{_(null),x(null),p()},[p]);a(()=>{u.mode===`closed`&&_(null)},[u.mode]);let E=l({mutationFn:e=>c.trpcClient.llm.upsertProfile.mutate({profile:e}),onSuccess:()=>{T(),w()},onError:e=>x(e instanceof Error?e.message:t(`ai.saveFailed`,`Save failed`))}),O=l({mutationFn:e=>c.trpcClient.llm.deleteProfile.mutate({addonId:e.addonId,profileId:e.id}),onSuccess:w}),ee=l({mutationFn:e=>c.trpcClient.llm.testProfile.mutate({addonId:e.addonId,profileId:e.id}),onSuccess:(e,t)=>y({id:t.id,ok:e.ok,text:e.ok?Z.t(`system.aiProfilesTab.testOk`,{text:e.text,tokens:e.usage.outputTokens,ms:e.latencyMs}):`${e.code}: ${e.message}`})}),k=S.data??[],A=n(()=>C.data??[],[C.data]),N=n(()=>{let e=new Map;for(let t of A)e.set(t.kind,t);return e},[A]),P=u.mode===`edit`?k.find(e=>e.id===u.id)??null:null,te=P===null?null:N.get(P.kind)??null,F=u.mode===`new`&&h===null,I=u.mode===`new`?h:te,L=u.mode===`edit`?P:null,ne=I!==null&&(u.mode===`new`||L!==null),R=async e=>{await m({title:t(`ai.deleteProfileTitle`,`Delete profile?`),message:t(`ai.deleteProfileMessage`,`Delete "{{name}}". Features that name it will no longer get an answer from it.`,{name:e.name}),confirmLabel:t(`common.delete`,`Delete`),variant:`danger`})&&O.mutate(e)};return e(`div`,{className:g,children:[i(ht,{profiles:k}),i(J,{headingId:`ai-profiles-list`,title:t(`ai.profilesList`,`Profiles`),children:S.isPending?e(`div`,{className:`${d} space-y-2`,"data-testid":`ai-profiles-loading`,children:[i(U,{className:`h-8 w-full`}),i(U,{className:`h-8 w-full`}),i(U,{className:`h-8 w-full`})]}):S.isError?i(`div`,{className:d,children:i(G,{title:t(`ai.loadFailed`,`Failed to load profiles`),message:S.error instanceof Error?S.error.message:t(`common.error`,`Error`),onRetry:()=>void S.refetch()})}):k.length===0?i(V,{icon:j,title:t(`ai.noProfilesTitle`,`No AI profiles yet`),description:t(`ai.noProfiles`,`No AI profiles yet. Click "Add profile" to configure one.`)}):i(W,{columns:pt({kindByName:N,testResult:v,testingId:ee.isPending?ee.variables?.id??null:null,t,onToggle:e=>E.mutate({...e,enabled:!e.enabled}),onTest:e=>ee.mutate(e),onEdit:e=>{N.has(e.kind)&&(x(null),_(null),f(e.id))},onDelete:e=>void R(e)}),rows:k,rowKey:e=>e.id,minWidthPx:760,bordered:!1,maxBodyHeight:z})}),F&&i(at,{kinds:A,onCancel:T,onPick:e=>{x(null),_(e)}}),ne&&I!==null&&i(ft,{kind:I,existing:L,saving:E.isPending,error:b,onSave:e=>E.mutate(e),onCancel:T,...u.mode===`new`?{onChangeKind:()=>{x(null),_(null)}}:{}})]})}function ht({profiles:t}){let{t:n}=Q(),r=D(),a=s({queryKey:xe,queryFn:()=>r.trpcClient.llm.getDefaults.query({})}),o=l({mutationFn:e=>r.trpcClient.llm.setDefault.mutate({selector:{purpose:e.purpose},profileId:e.profileId}),onSuccess:()=>{a.refetch()}}),c=e=>(a.data??[]).find(t=>`purpose`in t.selector&&t.selector.purpose===e)?.profileId??``,u=e=>e===`vision`?n(`ai.defaultVision`,`Default vision profile`):n(`ai.defaultText`,`Default text profile`);return i(J,{headingId:`ai-profiles-defaults`,title:n(`ai.defaultsTitle`,`Defaults`),children:i(`div`,{className:`${d} grid gap-4 sm:grid-cols-2`,children:Te.map(({purpose:r,visionOnly:a})=>{let s=a?t.filter(e=>e.supportsVision):t,l=c(r),d=t.find(e=>e.id===l);return e(`div`,{children:[i(ae,{className:`mb-1 block`,htmlFor:`llm-default-${r}`,children:u(r)}),i(se,{id:`llm-default-${r}`,"aria-label":u(r),value:l,onChange:e=>o.mutate({purpose:r,profileId:e.target.value===``?null:e.target.value}),options:[{value:``,label:n(`ai.none`,`None`)},...l!==``&&!s.some(e=>e.id===l)?[{value:l,label:d?.name??l}]:[],...s.map(e=>({value:e.id,label:`${e.name} · ${e.model}`}))]}),l!==``&&d===void 0&&i(`p`,{className:`mt-1 text-xs text-danger`,children:n(`ai.defaultMissing`,`This default names a profile that no longer exists.`)}),d!==void 0&&!d.enabled&&i(`p`,{className:`mt-1 text-xs text-warning`,children:n(`ai.defaultDisabled`,`This default profile is disabled — callers resolve to no profile.`)}),o.error!=null&&i(`p`,{className:`mt-1 text-xs text-danger`,children:String(o.error)})]},r)})})})}c();var gt=5e3;function _t(e){return Z.t(`system.aiRuntimes.sizeGb`,{value:(e/1e9).toFixed(1)})}function vt(){let{t}=Q(),r=D(),a=s({queryKey:Se,refetchInterval:gt,queryFn:()=>r.trpcClient.llm.listRuntimeNodes.query({})}),o=n(()=>[{key:`node`,header:t(`ai.colNode`,`Node`),render:e=>i(`span`,{className:`font-medium text-foreground`,children:e.nodeId})},{key:`state`,header:t(`ai.colState`,`State`),nowrap:!0,render:n=>e(`span`,{className:`flex items-center gap-1.5`,children:[i(X,{variant:Le(n),children:t(Ie(n))}),n.status?.downloadProgress!==void 0&&i(X,{variant:`info`,children:`${String(Math.round(n.status.downloadProgress*100))}%`})]})},{key:`model`,header:t(`ai.colModel`,`Model`),render:e=>i(`span`,{className:`text-foreground`,children:e.status?.modelId??`—`})},{key:`disk`,header:t(`ai.colDisk`,`On disk`),align:`right`,nowrap:!0,render:e=>i(`span`,{className:`tabular-nums text-foreground-muted`,children:e.disk===void 0?`—`:_t(e.disk.modelsBytes)})},{key:`features`,header:t(`ai.colFeature`,`Feature`),render:n=>{let r=Re(n);if(r.length===0)return i(`span`,{className:`text-foreground-subtle`,children:`—`});let a=r.flatMap(e=>e.detail===null?[]:[e.detail]);return e(`span`,{className:`flex flex-col items-start gap-0.5`,children:[i(`span`,{className:`flex flex-wrap gap-1`,children:r.map(e=>i(X,{variant:e.tone,children:t(e.labelKey)},e.id))}),a.length>0&&i(`span`,{className:`text-foreground-subtle`,children:a.join(` · `)})]})}},{key:`error`,header:t(`ai.colError`,`Error`),render:e=>e.error===void 0?i(`span`,{className:`text-foreground-subtle`,children:`—`}):i(`span`,{className:`text-danger`,children:e.error})}],[t]),c=a.data??[];return i(J,{headingId:`ai-runtimes-list`,title:t(`ai.runtimesList`,`Nodes`),children:a.isPending?e(`div`,{className:`${d} space-y-2`,"data-testid":`ai-runtimes-loading`,children:[i(U,{className:`h-8 w-full`}),i(U,{className:`h-8 w-full`})]}):a.isError?i(`div`,{className:d,children:i(G,{title:t(`ai.runtimesFailed`,`Failed to read runtime nodes`),message:a.error instanceof Error?a.error.message:t(`common.error`,`Error`),onRetry:()=>void a.refetch()})}):c.length===0?i(V,{icon:T,title:t(`ai.noRuntimesTitle`,`No runtime nodes`),description:t(`ai.noRuntimes`,`No node advertises the llm-runtime capability.`)}):i(W,{columns:o,rows:c,rowKey:e=>e.nodeId,minWidthPx:760,bordered:!1,maxBodyHeight:z})})}var yt=x(`/addon/ai/test-chat`),bt=x(`/addon/ai/test-chat/chats`),xt=6e5;function St(e){let t=e.firstTokenTimeoutMs;if(!(typeof t!=`number`||!Number.isFinite(t)||t<=0))return Math.min(Math.round(t),xt)}function Ct(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function wt(e){if(!Ct(e))return null;let t=e.kind;return t!==`snapshot`&&t!==`track`||typeof e.mimeType!=`string`||typeof e.sizeBytes!=`number`?null:{kind:t,mimeType:e.mimeType,sizeBytes:e.sizeBytes,...typeof e.mediaKind==`string`?{mediaKind:e.mediaKind}:{},...typeof e.capturedAt==`number`?{capturedAt:e.capturedAt}:{},...typeof e.thumbnailBase64==`string`?{thumbnailBase64:e.thumbnailBase64}:{}}}var Tt=[`resolving-image`,`connecting`,`first-token-wait`,`streaming`];function Et(e){let t;try{t=JSON.parse(e)}catch{return null}if(!Ct(t))return null;switch(t.kind){case`status`:{let e=Tt.find(e=>e===t.phase);return e===void 0?null:{kind:`status`,phase:e}}case`meta`:return typeof t.profileName!=`string`||typeof t.model!=`string`?null:{kind:`meta`,profileName:t.profileName,model:t.model,mediaSent:wt(t.mediaSent),streamed:t.streamed===!0,firstTokenTimeoutMs:typeof t.firstTokenTimeoutMs==`number`?t.firstTokenTimeoutMs:0};case`token`:return typeof t.text==`string`?{kind:`token`,text:t.text}:null;case`done`:return{kind:`done`,inputTokens:typeof t.inputTokens==`number`?t.inputTokens:0,outputTokens:typeof t.outputTokens==`number`?t.outputTokens:0,latencyMs:typeof t.latencyMs==`number`?t.latencyMs:0,truncated:t.truncated===!0,...typeof t.conversationId==`string`?{conversationId:t.conversationId}:{}};case`error`:return{kind:`error`,code:typeof t.code==`string`?t.code:`adapter-error`,message:typeof t.message==`string`?t.message:Z.t(`helpers.aiTestChat.providerError`)};default:return null}}async function*Dt(e){let t=e.getReader(),n=new TextDecoder,r=``;try{for(;;){let{done:e,value:i}=await t.read();if(e)break;r+=n.decode(i,{stream:!0});let a=r.indexOf(`
2
- `);for(;a>=0;){let e=r.slice(0,a).trim();if(r=r.slice(a+1),e.length>0){let t=Et(e);t!==null&&(yield t)}a=r.indexOf(`
3
- `)}}let e=r.trim();if(e.length>0){let t=Et(e);t!==null&&(yield t)}}finally{t.releaseLock()}}function Ot(e){return e.filter(e=>e.failed!==!0&&e.content.length>0).map(e=>({role:e.role,content:e.content}))}function kt(e){return e.thumbnailBase64===void 0||e.thumbnailBase64.length===0?null:`data:${e.mimeType};base64,${e.thumbnailBase64}`}function At(e){return e.messages.map((t,n)=>{let r=t.mediaSent??void 0;return{id:`${e.id}-${String(n)}`,role:t.role,content:t.content,...t.attachment===void 0?{}:{attachmentRef:t.attachment,attachmentKind:t.attachment.kind},...r===void 0?{}:{attachment:r}}})}function jt(e){let t=e.sizeBytes<1024*1024?`${(e.sizeBytes/1024).toFixed(0)} KB`:`${(e.sizeBytes/(1024*1024)).toFixed(1)} MB`,n=[e.kind===`snapshot`?`camera snapshot`:`track best-shot`,t];return e.mediaKind!==void 0&&n.push(e.mediaKind),e.capturedAt!==void 0&&n.push(new Date(e.capturedAt).toLocaleTimeString()),n.join(` · `)}function Mt(e,t){switch(e){case`resolving-image`:return Z.t(`helpers.aiTestChat.phaseImage`);case`connecting`:return Z.t(`helpers.aiTestChat.phaseConnecting`);case`first-token-wait`:return t>0?Z.t(`helpers.aiTestChat.phaseWaitUpTo`,{seconds:Math.round(t/1e3)}):Z.t(`helpers.aiTestChat.phaseWait`);case`streaming`:return Z.t(`helpers.aiTestChat.phaseAnswering`)}}c();var Nt=[`pipelineAnalytics`,`listRecentTracks`,`ai-test`],Pt=360*60*1e3,Ft=40,It=160,Lt={phase:`connecting`,firstTokenTimeoutMs:0,text:``,mediaSent:null};function Rt(){let{t:c}=Q(),l=D(),[u,f]=o(``),[p,m]=o(``),[y,b]=o(``),[x,S]=o([]),[C,w]=o(null),[T,E]=o(`none`),[O,k]=o(`throwaway`),[A,j]=o(null),[M,P]=o([]),[te,F]=o(null),[I,L]=o(null),z=t(null);a(()=>()=>z.current?.abort(),[]);let B=r(async()=>{let e=await fetch(bt,{credentials:`same-origin`});e.ok&&P((await e.json()).chats??[])},[]);a(()=>{O===`persistent`&&B()},[O,B]);let V=s({queryKey:ye,queryFn:()=>l.trpcClient.llm.listProfiles.query({})}),re=n(()=>(V.data??[]).filter(e=>e.enabled),[V.data]),H=re.find(e=>e.id===u)??null,U=I!==null,ie=r(async(e,t)=>{let n=new AbortController;z.current=n,F(null);let r=St(H??{});L({...Lt,firstTokenTimeoutMs:r??0});let i=``,a=null,o,s=null,l=null,d;try{let c=await fetch(yt,{method:`POST`,headers:{"content-type":`application/json`},credentials:`same-origin`,signal:n.signal,body:JSON.stringify({profileId:u,messages:e,...p.trim()===``?{}:{system:p.trim()},...t===void 0?{}:{attachment:t},...r===void 0?{}:{firstTokenTimeoutMs:r},...O===`persistent`?{persist:!0,...A===null?{}:{conversationId:A}}:{}})});if(!c.ok||c.body===null){let e=await c.text().catch(()=>``);throw Error(e.length>0?e:`HTTP ${String(c.status)}`)}for await(let e of Dt(c.body))switch(e.kind){case`status`:L(t=>({...t??Lt,phase:e.phase}));break;case`meta`:a=e.mediaSent,o=e.model,L(t=>({...t??Lt,firstTokenTimeoutMs:e.firstTokenTimeoutMs,mediaSent:e.mediaSent}));break;case`token`:i+=e.text,L(e=>({...e??Lt,text:i}));break;case`done`:l={outputTokens:e.outputTokens,latencyMs:e.latencyMs},d=e.conversationId;break;case`error`:s=`${e.code}: ${e.message}`;break}}catch(e){n.signal.aborted||F(e instanceof Error?e.message:c(`common.error`,`Error`))}finally{z.current=null,L(null)}d!==void 0&&(j(d),B());let f=n.signal.aborted&&i.length>0;s===null&&i.length===0&&!f||S(e=>[...e,{id:`a-${String(Date.now())}`,role:`assistant`,content:s??i,...s===null?{}:{failed:!0},...a===null?{}:{attachment:a},...o!==void 0&&s===null?{model:o}:{},...l===null?{}:l}])},[O,A,H,u,B,p,c]),W=r(()=>{let e=y.trim();if(e===``||u===``||U)return;let t={id:`u-${String(Date.now())}`,role:`user`,content:e,...C===null?{}:{attachmentLabel:C.label,attachmentKind:C.ref.kind}},n=[...x,t];S(n),b(``);let r=C?.ref;w(null),E(`none`),ie(O===`persistent`&&A!==null?[{role:`user`,content:e}]:Ot(n),r)},[O,A,y,C,u,ie,U,x]),oe=()=>z.current?.abort(),Y=()=>{z.current?.abort(),S([]),w(null),b(``),F(null),L(null),j(null)},ce=async e=>{z.current?.abort();let t=await fetch(`${bt}/${e}`,{credentials:`same-origin`});if(!t.ok)return;let n=await t.json();j(e),S(At(n)),L(null),F(null)};return e(`div`,{className:g,children:[i(J,{headingId:`ai-test-setup`,title:c(`ai.testSetup`,`Setup`),children:e(`div`,{className:`${d} space-y-3`,children:[e(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[e(`div`,{children:[i(ae,{className:`mb-1 block`,htmlFor:`ai-test-profile`,children:c(`ai.profile`,`Profile`)}),i(se,{id:`ai-test-profile`,value:u,onChange:e=>f(e.target.value),options:[{value:``,label:c(`ai.selectProfile`,`Select a profile…`)},...re.map(e=>({value:e.id,label:`${e.name} · ${e.model}${e.supportsVision?` · vision`:``}`}))]}),re.length===0&&!V.isLoading&&i(`p`,{className:`mt-1 text-xs text-foreground-subtle`,children:c(`ai.noEnabledProfiles`,`No enabled profile. Add one on the Profiles tab.`)})]}),e(`div`,{children:[i(ae,{className:`mb-1 block`,htmlFor:`ai-test-system`,children:c(`ai.systemPrompt`,`System prompt (optional)`)}),i(q,{id:`ai-test-system`,value:p,onChange:e=>m(e.target.value),placeholder:c(`ai.systemPlaceholder`,`Answer in one short sentence.`)})]})]}),i(fe,{label:c(`ai.chatMode`,`Conversation mode`),value:O,options:[{value:`throwaway`,label:c(`ai.throwawayMode`,`Throwaway`)},{value:`persistent`,label:c(`ai.saveConversation`,`Save conversation`)}],onChange:e=>{k(e),e===`throwaway`&&j(null)}}),O===`persistent`&&e(`div`,{className:`space-y-2`,children:[i(`p`,{className:`text-xs text-foreground-subtle`,children:c(`ai.testSubtitlePersistent`,`Conversations are saved for you and can be reopened. Throwaway mode is still available.`)}),e(K,{size:`sm`,variant:`secondary`,type:`button`,onClick:Y,children:[i(R,{className:`h-3.5 w-3.5`}),c(`ai.newChat`,`New chat`)]}),M.length>0&&i(`div`,{className:`max-h-36 divide-y divide-border overflow-y-auto rounded-md border border-border`,children:M.map(e=>i(`button`,{type:`button`,onClick:()=>void ce(e.id),className:`flex w-full px-2.5 py-1.5 text-left text-xs hover:bg-surface-hover ${e.id===A?`bg-primary/10`:``}`,children:i(`span`,{className:`min-w-0 flex-1 truncate text-foreground`,children:e.title})},e.id))})]}),i(`p`,{className:`text-xs text-foreground-subtle`,children:c(`ai.streamNote`,`The answer streams as the model produces it. A cold model can take a while to load — the status line says which phase it is in.`)}),H!==null&&!H.supportsVision&&i(`p`,{className:`text-xs text-warning`,children:c(`ai.notVision`,`This profile is not vision-capable — an attached image will be refused before anything is read.`)})]})}),te!==null&&i(G,{title:c(`ai.chatFailed`,`The test call failed`),message:te}),e(J,{headingId:`ai-test-conversation`,title:c(`ai.testConversation`,`Conversation`),actions:e(K,{size:`sm`,variant:`ghost`,type:`button`,disabled:x.length===0&&C===null,onClick:Y,children:[i(h,{className:`h-3.5 w-3.5`}),c(`ai.clearChat`,`Clear`)]}),children:[i(zt,{turns:x,live:I}),e(`div`,{className:`${d} space-y-2 border-t border-border`,children:[C!==null&&e(`div`,{className:`flex items-center gap-2 rounded-md border border-border bg-background px-2.5 py-1.5`,children:[C.ref.kind===`snapshot`?i(v,{className:`h-3.5 w-3.5 text-foreground-subtle`}):i(_,{className:`h-3.5 w-3.5 text-foreground-subtle`}),i(`span`,{className:`min-w-0 flex-1 truncate text-xs text-foreground`,children:C.label}),i(ue,{size:`sm`,variant:`ghost`,type:`button`,icon:ee,"aria-label":c(`ai.removeAttachment`,`Remove attachment`),onClick:()=>w(null)})]}),e(`div`,{className:`flex flex-wrap items-center gap-2`,children:[e(K,{size:`sm`,variant:T===`snapshot`?`primary`:`outline`,type:`button`,onClick:()=>E(T===`snapshot`?`none`:`snapshot`),children:[i(v,{className:`h-3.5 w-3.5`}),c(`ai.attachSnapshot`,`Camera snapshot`)]}),e(K,{size:`sm`,variant:T===`track`?`primary`:`outline`,type:`button`,onClick:()=>E(T===`track`?`none`:`track`),children:[i(_,{className:`h-3.5 w-3.5`}),c(`ai.attachTrack`,`Recent track`)]})]}),T===`snapshot`&&i(Ht,{onPick:(e,t)=>{w({ref:{kind:`snapshot`,deviceId:e.id},label:c(`ai.snapshotOf`,`Snapshot of {{name}}`,{name:t})}),E(`none`)}}),T===`track`&&i(Wt,{onPick:(e,t)=>{w({ref:{kind:`track`,trackId:e.trackId,deviceId:e.deviceId},label:c(`ai.trackOf`,`{{class}} on {{name}}`,{class:e.label??e.className,name:t})}),E(`none`)}}),e(`div`,{className:`flex items-center gap-2`,children:[i(q,{value:y,onChange:e=>b(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),W())},placeholder:c(`ai.messagePlaceholder`,`Ask the model something…`),"aria-label":c(`ai.message`,`Message`)}),U?e(K,{size:`sm`,variant:`secondary`,type:`button`,onClick:oe,children:[i(N,{className:`h-3.5 w-3.5`}),c(`ai.stop`,`Stop`)]}):e(K,{size:`sm`,type:`button`,disabled:y.trim()===``||u===``,onClick:W,children:[i(ne,{className:`h-3.5 w-3.5`}),c(`ai.send`,`Send`)]})]})]})]})]})}function zt({turns:t,live:n}){let{t:r}=Q();return t.length===0&&n===null?i(V,{icon:L,title:r(`ai.chatEmptyTitle`,`No messages yet`),description:r(`ai.chatEmpty`,`Pick a profile, optionally attach a camera snapshot or a recent track, and send a message. Nothing here is saved.`)}):e(`div`,{className:`max-h-[50vh] space-y-2 overflow-y-auto ${d}`,children:[t.map(e=>i(Bt,{turn:e},e.id)),n!==null&&e(`div`,{className:`space-y-1`,children:[n.mediaSent!==null&&i(Vt,{attachment:n.mediaSent}),n.text.length>0&&i(Bt,{turn:{id:`live`,role:`assistant`,content:n.text},streaming:!0}),e(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[i(O,{className:`h-3.5 w-3.5 animate-spin`}),Mt(n.phase,n.firstTokenTimeoutMs)]})]})]})}function Bt({turn:t,streaming:n=!1}){let{t:r}=Q(),a=t.role===`user`,o=t.failed===!0?`border-danger/40 bg-danger/10`:`border-border bg-surface`;return i(`div`,{className:`flex ${a?`justify-end`:`justify-start`}`,children:e(`div`,{className:`max-w-[85%] rounded-lg border px-3 py-2 ${a?`border-primary/40 bg-primary/10`:o}`,children:[e(`p`,{className:`whitespace-pre-wrap break-words text-xs text-foreground`,children:[t.content,n&&i(`span`,{className:`ml-0.5 animate-pulse text-primary`,children:`▌`})]}),t.attachment!==void 0&&i(Vt,{attachment:t.attachment}),t.attachmentLabel!==void 0&&e(`p`,{className:`mt-1 flex items-center gap-1 text-[10px] text-foreground-subtle`,children:[t.attachmentKind===`track`?i(_,{className:`h-3 w-3`}):i(v,{className:`h-3 w-3`}),t.attachmentLabel]}),t.attachment!==void 0&&e(`p`,{className:`mt-1 flex items-center gap-1 text-[10px] text-foreground-subtle`,children:[t.attachment.kind===`snapshot`?i(v,{className:`h-3 w-3`}):i(_,{className:`h-3 w-3`}),jt(t.attachment)]}),t.model!==void 0&&i(`p`,{className:`mt-1 text-[10px] text-foreground-subtle`,children:r(`system.aiTestChat.tokMs`,`{{model}} · {{value2}} tok · {{value3}} ms`,{model:t.model,value2:String(t.outputTokens??0),value3:String(t.latencyMs??0)})})]})})}function Vt({attachment:e}){let{t}=Q(),n=kt(e);return n===null?null:i(`img`,{src:n,alt:t(`system.aiTestChat.sentToTheModel`,`sent to the model`),className:`mt-1 max-h-32 rounded-md border border-border object-contain`})}function Ht({onPick:e}){let{t}=Q(),n=oe({isCamera:!0,projection:`slim`}),r=(n.data??[]).filter(e=>!e.disabled);return n.isLoading?i(O,{className:`h-4 w-4 animate-spin text-foreground-subtle`}):r.length===0?i(`p`,{className:`text-[11px] text-foreground-subtle`,children:t(`ai.noCameras`,`No camera found.`)}):i(`div`,{className:`grid max-h-56 grid-cols-2 gap-2 overflow-y-auto sm:grid-cols-4`,children:r.map(t=>i(Ut,{device:t,onPick:e},t.id))})}function Ut({device:t,onPick:n}){let{t:r}=Q(),a=re(t,`compact`),{src:o}=m(t.id,{width:It});return e(`button`,{type:`button`,onClick:()=>n(t,a),className:`overflow-hidden rounded-md border border-border bg-surface text-left transition-colors hover:border-primary/50`,children:[i(`span`,{className:`block aspect-video w-full bg-background-elevated`,children:o!==null&&i(`img`,{src:o,alt:``,className:`h-full w-full object-cover`,loading:`lazy`})}),e(`span`,{className:`flex items-center gap-1 px-2 py-1`,children:[!t.online&&i(X,{variant:`warning`,children:r(`common.off`)}),i(`span`,{className:`truncate text-[10px] text-foreground`,children:a})]})]})}function Wt({onPick:t}){let{t:r}=Q(),a=D(),o=oe({isCamera:!0,projection:`slim`}),c=n(()=>(o.data??[]).map(e=>e.id),[o.data]),l=n(()=>{let e=new Map;for(let t of o.data??[])e.set(t.id,t.name);return e},[o.data]),u=s({queryKey:[...Nt,c.length],enabled:c.length>0,queryFn:()=>a.trpcClient.pipelineAnalytics.listRecentTracks.query({deviceIds:[...c],since:Date.now()-Pt,limit:Ft,projection:`slim`})});if(o.isLoading||u.isLoading)return i(O,{className:`h-4 w-4 animate-spin text-foreground-subtle`});let d=u.data?.tracks??[];return d.length===0?i(`p`,{className:`text-[11px] text-foreground-subtle`,children:r(`ai.noTracks`,`No track in the last 6 hours.`)}):i(`div`,{className:`max-h-56 divide-y divide-border overflow-y-auto rounded-md border border-border`,children:d.map(n=>e(`button`,{type:`button`,onClick:()=>t(n,l.get(n.deviceId)??String(n.deviceId)),className:`flex w-full items-center gap-2 px-2.5 py-1.5 text-left text-[11px] hover:bg-surface-hover`,children:[i(_,{className:`h-3.5 w-3.5 shrink-0 text-foreground-subtle`}),i(`span`,{className:`min-w-0 flex-1 truncate text-foreground`,children:n.label??n.className}),i(`span`,{className:`shrink-0 text-foreground-subtle`,children:l.get(n.deviceId)??n.deviceId}),i(`span`,{className:`shrink-0 text-foreground-subtle`,children:new Date(n.lastSeen).toLocaleTimeString()})]},n.trackId))})}c();var Gt=1440*60*1e3,Kt=[1,7,30,90];function qt(){let{t}=Q(),r=D(),[a,c]=o(7),l=n(()=>{let e=new Date;return e.setHours(0,0,0,0),e.getTime()-(a-1)*Gt},[a]),u=s({queryKey:ye,queryFn:()=>r.trpcClient.llm.listProfiles.query({})}),f=s({queryKey:[...we,a],queryFn:()=>r.trpcClient.llm.getUsage.query({since:l})}),p=n(()=>{let e=new Map;for(let t of u.data??[])e.set(t.id,t.name);return e},[u.data]),m=n(()=>[{key:`day`,header:t(`ai.colDay`,`Day`),nowrap:!0,render:e=>i(`span`,{className:`tabular-nums`,children:e.day})},{key:`consumer`,header:t(`ai.colConsumer`,`Consumer`),nowrap:!0,render:e=>i(`span`,{className:`text-foreground`,children:e.consumer})},{key:`profile`,header:t(`ai.colProfile`,`Profile`),render:e=>i(`span`,{className:`text-foreground`,children:p.get(e.profileId)??e.profileId})},{key:`calls`,header:t(`ai.colCalls`,`Calls`),align:`right`,nowrap:!0,render:e=>i(`span`,{className:`tabular-nums`,children:String(e.calls)})},{key:`okErr`,header:t(`ai.colOkErr`,`OK / err`),align:`right`,nowrap:!0,render:e=>i(`span`,{className:`tabular-nums ${e.errorCalls>0?`text-danger`:``}`,children:`${String(e.okCalls)} / ${String(e.errorCalls)}`})},{key:`tokens`,header:t(`ai.colTokens`,`In / out tok`),align:`right`,nowrap:!0,render:e=>i(`span`,{className:`tabular-nums`,children:`${String(e.inputTokens)} / ${String(e.outputTokens)}`})},{key:`latency`,header:t(`ai.colAvgMs`,`Avg ms`),align:`right`,nowrap:!0,render:e=>i(`span`,{className:`tabular-nums`,children:String(Math.round(e.avgLatencyMs))})}],[p,t]),h=f.data??[],g=i(`div`,{className:`w-36`,children:i(se,{"aria-label":t(`ai.window`,`Window`),value:String(a),options:Kt.map(e=>({value:String(e),label:t(`ai.lastDays`,`Last {{days}} days`,{days:e})})),onChange:e=>c(Number(e.target.value))})});return i(J,{headingId:`ai-usage-list`,title:t(`ai.usageList`,`Rollup`),actions:g,children:f.isPending?e(`div`,{className:`${d} space-y-2`,"data-testid":`ai-usage-loading`,children:[i(U,{className:`h-8 w-full`}),i(U,{className:`h-8 w-full`}),i(U,{className:`h-8 w-full`})]}):f.isError?i(`div`,{className:d,children:i(G,{title:t(`ai.usageFailed`,`Failed to read usage`),message:f.error instanceof Error?f.error.message:t(`common.error`,`Error`),onRetry:()=>void f.refetch()})}):h.length===0?i(V,{icon:b,title:t(`ai.noUsage`,`No AI calls in this window.`)}):i(W,{columns:m,rows:h,rowKey:e=>`${e.day}|${e.consumer}|${e.profileId}`,minWidthPx:720,bordered:!1,maxBodyHeight:z})})}var Jt=`llm`,Yt=[`profiles`,`runtimes`,`usage`,`test`],Xt=[`new`,`edit`];function Zt(e){return Yt.some(t=>t===e)}function Qt(){let{t}=Q(),n=B(Jt),[r]=he(),{openNew:a}=ce(),o=me(`/system/ai`,{t,isAdmin:!0})??{icon:j,title:t(`system.ai`,`AI`)};if(n!==`present`)return i(_e,{icon:o.icon,title:o.title,children:i($t,{presence:n})});let s=r.get(`tab`),c=Zt(s)?s:`profiles`,l={profiles:t(`ai.profilesSubtitle`,`One row = one usable model endpoint. The defaults below decide who answers when a feature names no profile.`),runtimes:t(`ai.runtimesSubtitle`,`Nodes advertising the llm-runtime capability: what each has loaded, what it is downloading, and how much model data sits on its disk.`),usage:t(`ai.usageSubtitle`,`Server-side rollup per day, consumer and profile — never raw call rows. Errors are counted, so a profile that always fails is visible here before a feature reports it.`),test:t(`ai.testSubtitle`,`A throwaway conversation with one profile. Attach a live camera snapshot or a recent track to check the model can actually read a picture. Nothing is saved — only the usage row.`)},u=c===`profiles`?e(K,{size:`sm`,type:`button`,"data-testid":`ai-add-profile`,onClick:a,children:[i(p,{className:`h-3.5 w-3.5`}),t(`ai.addProfile`,`Add profile`)]}):void 0;return i(ge,{icon:o.icon,title:o.title,subtitle:l[c],actions:u,defaultSection:`profiles`,sectionsLabel:`${o.title} sections`,sections:[{id:`profiles`,label:t(`ai.tabProfiles`,`Profiles`),content:i(mt,{}),ownedParams:Xt},{id:`runtimes`,label:t(`ai.tabRuntimes`,`Runtimes`),content:i(vt,{})},{id:`usage`,label:t(`ai.tabUsage`,`Usage`),content:i(qt,{})},{id:`test`,label:t(`ai.tabTest`,`Test`),content:i(Rt,{})}]})}function $t({presence:t}){let{t:n}=Q();return t===`pending`?e(`div`,{className:`space-y-3`,"data-testid":`ai-presence-pending`,children:[i(U,{className:`h-8 w-64`}),i(U,{className:`h-40 w-full`})]}):t===`unknown`?i(G,{title:n(`ai.presenceUnknownTitle`,`Could not check whether AI is installed`),message:n(`ai.presenceUnknown`,`The hub did not answer the capability check. Reload the page to try again.`)}):i(V,{icon:j,title:n(`ai.absentTitle`,`AI is not installed`),description:n(`ai.absentDescription`,`Install the AI addon from System → Addons to add model profiles.`)})}export{Qt as AiProfilesPage,Qt as default};