@camstack/addon-admin-ui 1.2.291 → 1.2.292

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 (64) hide show
  1. package/dist/assets/{AddonCollectionPage-C9l7ftV0.js → AddonCollectionPage-Dw_s0tAu.js} +1 -1
  2. package/dist/assets/{Addons-TAyselNK.js → Addons-DeOTNmoh.js} +1 -1
  3. package/dist/assets/{AdminTabs-CDIoD5NP.js → AdminTabs-B7qQRc02.js} +1 -1
  4. package/dist/assets/{AiProfiles-Kf7NoHuq.js → AiProfiles-CzjABxBt.js} +1 -1
  5. package/dist/assets/{BrokerForm-DoQjILhI.js → BrokerForm-CUCaMcFq.js} +1 -1
  6. package/dist/assets/{Build-rTKtg_tx.js → Build-zDCFoO1o.js} +1 -1
  7. package/dist/assets/{Capabilities-PhNKP5DZ.js → Capabilities-B9kNGs2i.js} +1 -1
  8. package/dist/assets/{CapabilityBadges-yL7FrxsG.js → CapabilityBadges-mm-TP2-4.js} +1 -1
  9. package/dist/assets/{Cluster-DeKFim31.js → Cluster-CGe5b6yl.js} +1 -1
  10. package/dist/assets/{CompositionEditor-Bu6ufcCG.js → CompositionEditor-BVDKw1Gg.js} +1 -1
  11. package/dist/assets/{CompositionEditorPage-BekLUIPP.js → CompositionEditorPage-CdYmw-mN.js} +1 -1
  12. package/dist/assets/{Data-DZ4iVZ3r.js → Data-gT3xohDf.js} +1 -1
  13. package/dist/assets/{DetectionIntelligence-BAE1rpvx.js → DetectionIntelligence-BkRKwDje.js} +1 -1
  14. package/dist/assets/{DeviceAggregateSection-BEv0e5dZ.js → DeviceAggregateSection-C2uEmCok.js} +1 -1
  15. package/dist/assets/{DeviceDetail-DTzUAv1F.js → DeviceDetail-0QJGYULg.js} +1 -1
  16. package/dist/assets/{Devices-DnvCLFMr.js → Devices-BSr1bdFh.js} +1 -1
  17. package/dist/assets/{EmbedPlayerPage-DN8DYcVD.js → EmbedPlayerPage-Dlh708_N.js} +1 -1
  18. package/dist/assets/{Events-DIW0IfdN.js → Events-Dr_WAoza.js} +1 -1
  19. package/dist/assets/{FormBuilder-Bytus5Tf.js → FormBuilder-6IaHrdlA.js} +1 -1
  20. package/dist/assets/{Identity-DuejF2qu.js → Identity-CIfnhYiN.js} +1 -1
  21. package/dist/assets/{IntegrationDetail-ChJqGuPV.js → IntegrationDetail-R0QDmlI9.js} +1 -1
  22. package/dist/assets/{Integrations-BmXG4x-9.js → Integrations-7cffUbq3.js} +1 -1
  23. package/dist/assets/{Integrations-aQZGbD9Y.js → Integrations-DLQUvtxP.js} +1 -1
  24. package/dist/assets/{Locations-DpmnmMuB.js → Locations-Dr6R3uck.js} +1 -1
  25. package/dist/assets/{Logs-DPVRa9WP.js → Logs-BMYNs0yh.js} +1 -1
  26. package/dist/assets/{ModelLicenses-CdSE1ZrE.js → ModelLicenses-CuvFQmbU.js} +1 -1
  27. package/dist/assets/{MyAccess-Bkvp6GTW.js → MyAccess-CPmIAKtP.js} +1 -1
  28. package/dist/assets/{Network-Ds6N6CJ-.js → Network-BNDnM7h_.js} +1 -1
  29. package/dist/assets/{NodeAddonsSettingsPanel-skqKbqMj.js → NodeAddonsSettingsPanel-D9m0jYk9.js} +1 -1
  30. package/dist/assets/{NodeInferenceDevices-B2JedlHO.js → NodeInferenceDevices-B1Ep4Zlo.js} +1 -1
  31. package/dist/assets/{Notifications-BV-4IwuU.js → Notifications-VoQjr4oG.js} +1 -1
  32. package/dist/assets/{Pipeline-CAt-bvHB.js → Pipeline-DCQvGJPk.js} +1 -1
  33. package/dist/assets/{Plates-DzEWm4_s.js → Plates-DVY5is4q.js} +1 -1
  34. package/dist/assets/{ProviderIcon-BBtV-kNn.js → ProviderIcon-CXZJxx4S.js} +1 -1
  35. package/dist/assets/{Recordings-DdR7d9ou.js → Recordings-CN8Er5mw.js} +1 -1
  36. package/dist/assets/{ScanNetworkModal-ClrFcKCl.js → ScanNetworkModal-D1fVlqwM.js} +1 -1
  37. package/dist/assets/{Scenes-C9RWMuVR.js → Scenes-7GSmYBE_.js} +1 -1
  38. package/dist/assets/{Settings-ucmI8LXJ.js → Settings-C_YK-1WB.js} +1 -1
  39. package/dist/assets/{Showroom-Bdt-D63k.js → Showroom-D6fEOCY-.js} +1 -1
  40. package/dist/assets/{StorageLocationsPanel-4Tgyiymp.js → StorageLocationsPanel-CP4soml4.js} +1 -1
  41. package/dist/assets/{Terminal-BrAUK0eG.js → Terminal-DyfVYesh.js} +1 -1
  42. package/dist/assets/{Viewer-DQrms2_u.js → Viewer-BJIjxIRv.js} +1 -1
  43. package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-Dq0fVJWM.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-Cb9fHmff.js} +1 -1
  44. package/dist/assets/{authed-media-MbHpXS-m.js → authed-media-0-hZyKYF.js} +1 -1
  45. package/dist/assets/{debounced-invalidate-nyczfeAF.js → debounced-invalidate-KFSScH_S.js} +1 -1
  46. package/dist/assets/{device-integration-icon-fftDP3wp.js → device-integration-icon-GOXwaoFs.js} +1 -1
  47. package/dist/assets/{face-bbox-BDj6xgbi.js → face-bbox-DAY4Nlok.js} +1 -1
  48. package/dist/assets/{hostInit-BruU7SYo.js → hostInit-Ps1dtPIw.js} +1 -1
  49. package/dist/assets/{index-DrF3b0h3.js → index-xBLZKqTX.js} +3 -3
  50. package/dist/assets/{location-owned-usage-bz1tVRVt.js → location-owned-usage-CLcax6wn.js} +1 -1
  51. package/dist/assets/{mf-entry-bootstrap-0-ad4a1c50.js → mf-entry-bootstrap-0-9ae66e69.js} +2 -2
  52. package/dist/assets/remoteEntry-C40lUg7I.js +1 -0
  53. package/dist/assets/{src-BqkvLgRS.js → src-DxdTI837.js} +1 -1
  54. package/dist/assets/{use-scenes-feed-CoCQD-QZ.js → use-scenes-feed-SUwBnIQt.js} +1 -1
  55. package/dist/assets/{use-stationary-objects-BvLkAOl-.js → use-stationary-objects--DTNKUuW.js} +1 -1
  56. package/dist/assets/{useDevice-D541xOeQ.js → useDevice-ByIy3FMo.js} +1 -1
  57. package/dist/assets/useEventInvalidation-CnlNqWBt.js +1 -0
  58. package/dist/assets/{useNodeUrlSelection-DBqemZZ0.js → useNodeUrlSelection-Bt6smdEd.js} +1 -1
  59. package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-S6IHSmgw.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-emXFInOs.js} +2 -2
  60. package/dist/index.html +3 -3
  61. package/dist/server/addon.js +1 -1
  62. package/package.json +1 -1
  63. package/dist/assets/remoteEntry-BaEDGIXI.js +0 -1
  64. package/dist/assets/useEventInvalidation-DxM8yEtK.js +0 -1
@@ -1 +1 @@
1
- import{Q as e,S as t,W as n,a as r,q as i,t as a,x as o}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{at as s}from"./player-overlays-gbZ2vznV.js";import{Lu as c,Ru as l,an as u,nu as d,yl as f}from"./src-BqkvLgRS.js";import{t as p}from"./AdminPage-CiKtOLQm.js";e();var m={detection:`border-green-500`,detector:`border-green-500`,streaming:`border-blue-500`,decode:`border-blue-500`,decoder:`border-blue-500`,recording:`border-orange-500`,recorder:`border-orange-500`,transcoding:`border-purple-500`,transcoder:`border-purple-500`,restream:`border-cyan-500`,restreamer:`border-cyan-500`,storage:`border-yellow-500`,notification:`border-pink-500`,notifier:`border-pink-500`,faces:`border-indigo-500`},h={detection:`bg-green-500/5`,detector:`bg-green-500/5`,streaming:`bg-blue-500/5`,decode:`bg-blue-500/5`,decoder:`bg-blue-500/5`,recording:`bg-orange-500/5`,recorder:`bg-orange-500/5`,transcoding:`bg-purple-500/5`,transcoder:`bg-purple-500/5`,restream:`bg-cyan-500/5`,restreamer:`bg-cyan-500/5`,storage:`bg-yellow-500/5`,notification:`bg-pink-500/5`,notifier:`bg-pink-500/5`,faces:`bg-indigo-500/5`};function g({entry:e,actions:n}){let r=e.name.toLowerCase(),i=m[r]??`border-primary`,a=h[r]??`bg-primary/5`,s=e.providers.find(e=>e.active),c=n?.pendingCapability===e.name;return t(`div`,{className:`rounded-lg border-t-2 border border-border ${i} ${a} p-3 space-y-2`,children:[t(`div`,{className:`flex items-center justify-between gap-2`,children:[t(`span`,{className:`text-xs font-semibold text-foreground capitalize flex items-center gap-1.5`,children:[e.name,c&&o(d,{className:`h-3 w-3 animate-spin text-primary`})]}),o(`span`,{className:`rounded-full px-2 py-0.5 text-[10px] font-medium ${e.mode===`singleton`?`bg-primary/10 text-primary`:`bg-info/10 text-info`}`,children:e.mode})]}),e.mode===`singleton`?o(_,{entry:e,actions:n,activeProvider:s,isPending:c}):o(v,{entry:e,actions:n,isPending:c})]})}function _({entry:e,actions:n,activeProvider:r,isPending:i}){if(!n)return o(`div`,{children:r?t(`div`,{className:`flex items-center gap-1.5 text-[10px] text-foreground`,children:[o(c,{className:`h-3 w-3 text-green-400 shrink-0`}),o(`span`,{className:`font-medium`,children:r.addonName}),o(`span`,{className:`rounded-full bg-green-500/10 text-green-400 px-1.5 py-0.5 font-medium ml-auto`,children:`ACTIVE`})]}):o(`div`,{className:`text-[10px] text-foreground-subtle italic`,children:`No active provider`})});if(e.providers.length===0)return o(`div`,{className:`text-[10px] text-foreground-subtle italic`,children:`No providers`});let a=`__inherit__`;return t(`div`,{className:`space-y-2`,children:[o(`div`,{className:`space-y-1`,children:e.providers.map(r=>{let a=r.active;return t(`button`,{type:`button`,disabled:i||a,onClick:()=>n.onSelectSingleton(e.name,r.addonId),className:`flex w-full items-center gap-1.5 rounded px-1.5 py-1 text-[10px] text-left transition-colors ${a?`bg-green-500/10 text-foreground cursor-default`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground disabled:opacity-50`}`,children:[o(`span`,{className:`h-2.5 w-2.5 rounded-full border shrink-0 ${a?`border-green-400 bg-green-400`:`border-border`}`}),o(`span`,{className:`font-medium truncate`,children:r.addonName}),a&&o(`span`,{className:`rounded-full bg-green-500/10 text-green-400 px-1.5 py-0.5 font-medium ml-auto shrink-0`,children:`ACTIVE`})]},r.addonId)})}),e.perNode&&e.perNode.length>0&&o(`div`,{className:`space-y-2 pt-1 border-t border-border/40`,children:e.perNode.map(r=>{let s=r.hasOverride&&r.resolvedActive?r.resolvedActive:a,c=[{value:a,label:`Inherit global${r.resolvedActive?` (${r.resolvedActive})`:``}`},...r.providers.map(e=>({value:e,label:e}))],l=t=>{t===a?n.onClearNodeSingleton(e.name,r.nodeId):n.onSelectNodeSingleton(e.name,r.nodeId,t)},u=i;return t(`div`,{className:`space-y-0.5`,children:[t(`div`,{className:`text-[9px] font-semibold uppercase tracking-widest text-foreground-subtle/60 px-1.5`,children:[r.nodeId,r.hasOverride&&o(`span`,{className:`ml-1.5 rounded-full bg-primary/10 text-primary px-1 py-0.5 normal-case tracking-normal font-medium`,children:`override`})]}),c.map(e=>{let n=s===e.value;return t(`button`,{type:`button`,disabled:u||n,onClick:()=>l(e.value),className:`flex w-full items-center gap-1.5 rounded px-1.5 py-1 text-[10px] text-left transition-colors ${n?`bg-green-500/10 text-foreground cursor-default`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground disabled:opacity-50`}`,children:[o(`span`,{className:`h-2.5 w-2.5 rounded-full border shrink-0 ${n?`border-green-400 bg-green-400`:`border-border`}`}),o(`span`,{className:`font-medium truncate`,children:e.label}),n&&e.value!==a&&o(`span`,{className:`rounded-full bg-green-500/10 text-green-400 px-1.5 py-0.5 font-medium ml-auto shrink-0`,children:`ACTIVE`})]},e.value)})]},r.nodeId)})})]})}function v({entry:e,actions:n,isPending:r}){if(e.providers.length===0)return o(`div`,{className:`text-[10px] text-foreground-subtle italic`,children:`No providers`});if(!n)return o(`div`,{className:`space-y-1`,children:e.providers.map(e=>t(`div`,{className:`flex items-center justify-between gap-2 text-[10px]`,children:[o(`span`,{className:`text-foreground-subtle`,children:e.addonName}),e.active&&o(`span`,{className:`rounded-full bg-green-500/10 text-green-400 px-1.5 py-0.5 font-medium`,children:`ACTIVE`})]},e.addonId))});let i=e.providers.filter(e=>e.active).map(e=>e.addonId),a=(t,r)=>{let a=r?[...new Set([...i,t])]:i.filter(e=>e!==t);n.onToggleCollection(e.name,a)};return o(`div`,{className:`space-y-1`,children:e.providers.map(e=>t(`label`,{className:`flex items-center justify-between gap-2 text-[10px] rounded px-1.5 py-1 transition-colors ${r?`opacity-50`:`hover:bg-surface-hover cursor-pointer`}`,children:[t(`span`,{className:`flex items-center gap-1.5 min-w-0`,children:[o(`input`,{type:`checkbox`,checked:e.active,disabled:r,onChange:t=>a(e.addonId,t.target.checked),className:`h-3 w-3 accent-green-500 shrink-0`}),o(`span`,{className:`text-foreground truncate`,children:e.addonName})]}),e.active&&o(`span`,{className:`rounded-full bg-green-500/10 text-green-400 px-1.5 py-0.5 font-medium shrink-0`,children:`ACTIVE`})]},e.addonId))})}function y({capabilities:e,actions:t}){return e.length===0?o(`div`,{className:`text-xs text-foreground-subtle text-center py-8`,children:`No capabilities registered`}):o(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-3`,children:e.map(e=>o(g,{entry:e,actions:t},e.name))})}var b=[`capabilities`,`listCapabilities`];function x(e){return e===`singleton`||e===`collection`}function S(e){let t=e.indexOf(`@`);return t===-1?`${e} (hub)`:`${e.slice(0,t)} (${e.slice(t+1)})`}function C(e,t){return{name:e.name,mode:t,providers:e.providers.map(n=>({addonId:n,addonName:S(n),active:t===`singleton`?e.activeProvider===n:!e.disabledProviders.includes(n)})),...t===`singleton`&&e.perNode?{perNode:e.perNode}:{}}}function w(){let e=s(),[d,m]=i(null),[h,g]=i(null),_=r({queryKey:b,queryFn:()=>e.trpcClient.capabilities.listCapabilities.query()}),v=n(()=>{let e=(_.data??[]).flatMap(e=>x(e.mode)?[C(e,e.mode)]:[]),t=e.filter(e=>e.mode===`singleton`).toSorted((e,t)=>e.name.localeCompare(t.name)),n=e.filter(e=>e.mode===`collection`).toSorted((e,t)=>e.name.localeCompare(t.name));return[...t,...n]},[_.data]),S=n(()=>v.filter(e=>e.mode===`singleton`),[v]),w=n(()=>v.filter(e=>e.mode===`collection`),[v]),T=a({mutationFn:t=>e.trpcClient.capabilities.setActiveSingleton.mutate({capability:t.capName,addonId:t.addonId}),onMutate:e=>{m(e.capName),g(null)},onSuccess:async(e,t)=>{g({kind:`success`,message:`${t.capName} → ${t.addonId} is now active.`}),await _.refetch()},onError:(e,t)=>{g({kind:`error`,message:`Failed to set ${t.capName}: ${e instanceof Error?e.message:`unknown error`}`})},onSettled:()=>m(null)}),E=a({mutationFn:t=>e.trpcClient.capabilities.setActiveSingleton.mutate({capability:t.capName,addonId:t.addonId,nodeId:t.nodeId}),onMutate:e=>{m(e.capName),g(null)},onSuccess:async(e,t)=>{g({kind:`success`,message:`${t.capName} @ ${t.nodeId} → ${t.addonId}.`}),await _.refetch()},onError:(e,t)=>{g({kind:`error`,message:`Failed to set ${t.capName} @ ${t.nodeId}: ${e instanceof Error?e.message:`unknown error`}`})},onSettled:()=>m(null)}),D=a({mutationFn:t=>e.trpcClient.capabilities.clearSingletonNodeOverride.mutate({capability:t.capName,nodeId:t.nodeId}),onMutate:e=>{m(e.capName),g(null)},onSuccess:async(e,t)=>{g({kind:`success`,message:`${t.capName} @ ${t.nodeId} now inherits the global default.`}),await _.refetch()},onError:(e,t)=>{g({kind:`error`,message:`Failed to clear ${t.capName} @ ${t.nodeId}: ${e instanceof Error?e.message:`unknown error`}`})},onSettled:()=>m(null)}),O=a({mutationFn:t=>e.trpcClient.capabilities.setCollectionEnabledProviders.mutate({capability:t.capName,enabledAddonIds:[...t.enabledAddonIds]}),onMutate:e=>{m(e.capName),g(null)},onSuccess:async(e,t)=>{g({kind:`success`,message:`${t.capName}: ${t.enabledAddonIds.length} provider(s) enabled.`}),await _.refetch()},onError:(e,t)=>{g({kind:`error`,message:`Failed to update ${t.capName}: ${e instanceof Error?e.message:`unknown error`}`})},onSettled:()=>m(null)}),k={onSelectSingleton:(e,t)=>T.mutate({capName:e,addonId:t}),onSelectNodeSingleton:(e,t,n)=>E.mutate({capName:e,nodeId:t,addonId:n}),onClearNodeSingleton:(e,t)=>D.mutate({capName:e,nodeId:t}),onToggleCollection:(e,t)=>O.mutate({capName:e,enabledAddonIds:t}),pendingCapability:d};return t(p,{icon:f,title:`Capabilities`,subtitle:`Choose which provider is active for each system capability. Singleton caps pick exactly one provider; collection caps enable a set.`,children:[h&&t(`div`,{className:`flex items-center gap-2 rounded-md border px-3 py-2 text-xs ${h.kind===`success`?`border-green-500/30 bg-green-500/10 text-green-700 dark:text-green-300`:`border-danger/40 bg-danger/10 text-danger`}`,children:[h.kind===`success`?o(c,{className:`h-3.5 w-3.5 shrink-0`}):o(l,{className:`h-3.5 w-3.5 shrink-0`}),o(`span`,{children:h.message})]}),_.isLoading&&o(`div`,{className:`flex items-center justify-center py-16`,children:o(`div`,{className:`animate-spin h-6 w-6 border-2 border-primary border-t-transparent rounded-full`})}),_.isError&&!_.isLoading&&o(u,{title:`Failed to load capabilities`,message:_.error instanceof Error?_.error.message:`Unknown error`,onRetry:()=>void _.refetch()}),!_.isLoading&&!_.isError&&v.length===0&&o(`div`,{className:`text-xs text-foreground-subtle text-center py-16`,children:`No capabilities registered.`}),!_.isLoading&&!_.isError&&v.length>0&&t(`div`,{className:`space-y-6`,children:[S.length>0&&t(`section`,{className:`space-y-2`,children:[o(`h2`,{className:`text-[11px] font-semibold uppercase tracking-widest text-foreground-subtle/70`,children:`Singleton — pick one provider`}),o(y,{capabilities:S,actions:k})]}),w.length>0&&t(`section`,{className:`space-y-2`,children:[o(`h2`,{className:`text-[11px] font-semibold uppercase tracking-widest text-foreground-subtle/70`,children:`Collection — enable a set`}),o(y,{capabilities:w,actions:k})]})]})]})}export{w as CapabilitiesPage,w as default};
1
+ import{Q as e,S as t,W as n,a as r,q as i,t as a,x as o}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{at as s}from"./player-overlays-gbZ2vznV.js";import{Lu as c,Ru as l,an as u,nu as d,yl as f}from"./src-DxdTI837.js";import{t as p}from"./AdminPage-CiKtOLQm.js";e();var m={detection:`border-green-500`,detector:`border-green-500`,streaming:`border-blue-500`,decode:`border-blue-500`,decoder:`border-blue-500`,recording:`border-orange-500`,recorder:`border-orange-500`,transcoding:`border-purple-500`,transcoder:`border-purple-500`,restream:`border-cyan-500`,restreamer:`border-cyan-500`,storage:`border-yellow-500`,notification:`border-pink-500`,notifier:`border-pink-500`,faces:`border-indigo-500`},h={detection:`bg-green-500/5`,detector:`bg-green-500/5`,streaming:`bg-blue-500/5`,decode:`bg-blue-500/5`,decoder:`bg-blue-500/5`,recording:`bg-orange-500/5`,recorder:`bg-orange-500/5`,transcoding:`bg-purple-500/5`,transcoder:`bg-purple-500/5`,restream:`bg-cyan-500/5`,restreamer:`bg-cyan-500/5`,storage:`bg-yellow-500/5`,notification:`bg-pink-500/5`,notifier:`bg-pink-500/5`,faces:`bg-indigo-500/5`};function g({entry:e,actions:n}){let r=e.name.toLowerCase(),i=m[r]??`border-primary`,a=h[r]??`bg-primary/5`,s=e.providers.find(e=>e.active),c=n?.pendingCapability===e.name;return t(`div`,{className:`rounded-lg border-t-2 border border-border ${i} ${a} p-3 space-y-2`,children:[t(`div`,{className:`flex items-center justify-between gap-2`,children:[t(`span`,{className:`text-xs font-semibold text-foreground capitalize flex items-center gap-1.5`,children:[e.name,c&&o(d,{className:`h-3 w-3 animate-spin text-primary`})]}),o(`span`,{className:`rounded-full px-2 py-0.5 text-[10px] font-medium ${e.mode===`singleton`?`bg-primary/10 text-primary`:`bg-info/10 text-info`}`,children:e.mode})]}),e.mode===`singleton`?o(_,{entry:e,actions:n,activeProvider:s,isPending:c}):o(v,{entry:e,actions:n,isPending:c})]})}function _({entry:e,actions:n,activeProvider:r,isPending:i}){if(!n)return o(`div`,{children:r?t(`div`,{className:`flex items-center gap-1.5 text-[10px] text-foreground`,children:[o(c,{className:`h-3 w-3 text-green-400 shrink-0`}),o(`span`,{className:`font-medium`,children:r.addonName}),o(`span`,{className:`rounded-full bg-green-500/10 text-green-400 px-1.5 py-0.5 font-medium ml-auto`,children:`ACTIVE`})]}):o(`div`,{className:`text-[10px] text-foreground-subtle italic`,children:`No active provider`})});if(e.providers.length===0)return o(`div`,{className:`text-[10px] text-foreground-subtle italic`,children:`No providers`});let a=`__inherit__`;return t(`div`,{className:`space-y-2`,children:[o(`div`,{className:`space-y-1`,children:e.providers.map(r=>{let a=r.active;return t(`button`,{type:`button`,disabled:i||a,onClick:()=>n.onSelectSingleton(e.name,r.addonId),className:`flex w-full items-center gap-1.5 rounded px-1.5 py-1 text-[10px] text-left transition-colors ${a?`bg-green-500/10 text-foreground cursor-default`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground disabled:opacity-50`}`,children:[o(`span`,{className:`h-2.5 w-2.5 rounded-full border shrink-0 ${a?`border-green-400 bg-green-400`:`border-border`}`}),o(`span`,{className:`font-medium truncate`,children:r.addonName}),a&&o(`span`,{className:`rounded-full bg-green-500/10 text-green-400 px-1.5 py-0.5 font-medium ml-auto shrink-0`,children:`ACTIVE`})]},r.addonId)})}),e.perNode&&e.perNode.length>0&&o(`div`,{className:`space-y-2 pt-1 border-t border-border/40`,children:e.perNode.map(r=>{let s=r.hasOverride&&r.resolvedActive?r.resolvedActive:a,c=[{value:a,label:`Inherit global${r.resolvedActive?` (${r.resolvedActive})`:``}`},...r.providers.map(e=>({value:e,label:e}))],l=t=>{t===a?n.onClearNodeSingleton(e.name,r.nodeId):n.onSelectNodeSingleton(e.name,r.nodeId,t)},u=i;return t(`div`,{className:`space-y-0.5`,children:[t(`div`,{className:`text-[9px] font-semibold uppercase tracking-widest text-foreground-subtle/60 px-1.5`,children:[r.nodeId,r.hasOverride&&o(`span`,{className:`ml-1.5 rounded-full bg-primary/10 text-primary px-1 py-0.5 normal-case tracking-normal font-medium`,children:`override`})]}),c.map(e=>{let n=s===e.value;return t(`button`,{type:`button`,disabled:u||n,onClick:()=>l(e.value),className:`flex w-full items-center gap-1.5 rounded px-1.5 py-1 text-[10px] text-left transition-colors ${n?`bg-green-500/10 text-foreground cursor-default`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground disabled:opacity-50`}`,children:[o(`span`,{className:`h-2.5 w-2.5 rounded-full border shrink-0 ${n?`border-green-400 bg-green-400`:`border-border`}`}),o(`span`,{className:`font-medium truncate`,children:e.label}),n&&e.value!==a&&o(`span`,{className:`rounded-full bg-green-500/10 text-green-400 px-1.5 py-0.5 font-medium ml-auto shrink-0`,children:`ACTIVE`})]},e.value)})]},r.nodeId)})})]})}function v({entry:e,actions:n,isPending:r}){if(e.providers.length===0)return o(`div`,{className:`text-[10px] text-foreground-subtle italic`,children:`No providers`});if(!n)return o(`div`,{className:`space-y-1`,children:e.providers.map(e=>t(`div`,{className:`flex items-center justify-between gap-2 text-[10px]`,children:[o(`span`,{className:`text-foreground-subtle`,children:e.addonName}),e.active&&o(`span`,{className:`rounded-full bg-green-500/10 text-green-400 px-1.5 py-0.5 font-medium`,children:`ACTIVE`})]},e.addonId))});let i=e.providers.filter(e=>e.active).map(e=>e.addonId),a=(t,r)=>{let a=r?[...new Set([...i,t])]:i.filter(e=>e!==t);n.onToggleCollection(e.name,a)};return o(`div`,{className:`space-y-1`,children:e.providers.map(e=>t(`label`,{className:`flex items-center justify-between gap-2 text-[10px] rounded px-1.5 py-1 transition-colors ${r?`opacity-50`:`hover:bg-surface-hover cursor-pointer`}`,children:[t(`span`,{className:`flex items-center gap-1.5 min-w-0`,children:[o(`input`,{type:`checkbox`,checked:e.active,disabled:r,onChange:t=>a(e.addonId,t.target.checked),className:`h-3 w-3 accent-green-500 shrink-0`}),o(`span`,{className:`text-foreground truncate`,children:e.addonName})]}),e.active&&o(`span`,{className:`rounded-full bg-green-500/10 text-green-400 px-1.5 py-0.5 font-medium shrink-0`,children:`ACTIVE`})]},e.addonId))})}function y({capabilities:e,actions:t}){return e.length===0?o(`div`,{className:`text-xs text-foreground-subtle text-center py-8`,children:`No capabilities registered`}):o(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-3`,children:e.map(e=>o(g,{entry:e,actions:t},e.name))})}var b=[`capabilities`,`listCapabilities`];function x(e){return e===`singleton`||e===`collection`}function S(e){let t=e.indexOf(`@`);return t===-1?`${e} (hub)`:`${e.slice(0,t)} (${e.slice(t+1)})`}function C(e,t){return{name:e.name,mode:t,providers:e.providers.map(n=>({addonId:n,addonName:S(n),active:t===`singleton`?e.activeProvider===n:!e.disabledProviders.includes(n)})),...t===`singleton`&&e.perNode?{perNode:e.perNode}:{}}}function w(){let e=s(),[d,m]=i(null),[h,g]=i(null),_=r({queryKey:b,queryFn:()=>e.trpcClient.capabilities.listCapabilities.query()}),v=n(()=>{let e=(_.data??[]).flatMap(e=>x(e.mode)?[C(e,e.mode)]:[]),t=e.filter(e=>e.mode===`singleton`).toSorted((e,t)=>e.name.localeCompare(t.name)),n=e.filter(e=>e.mode===`collection`).toSorted((e,t)=>e.name.localeCompare(t.name));return[...t,...n]},[_.data]),S=n(()=>v.filter(e=>e.mode===`singleton`),[v]),w=n(()=>v.filter(e=>e.mode===`collection`),[v]),T=a({mutationFn:t=>e.trpcClient.capabilities.setActiveSingleton.mutate({capability:t.capName,addonId:t.addonId}),onMutate:e=>{m(e.capName),g(null)},onSuccess:async(e,t)=>{g({kind:`success`,message:`${t.capName} → ${t.addonId} is now active.`}),await _.refetch()},onError:(e,t)=>{g({kind:`error`,message:`Failed to set ${t.capName}: ${e instanceof Error?e.message:`unknown error`}`})},onSettled:()=>m(null)}),E=a({mutationFn:t=>e.trpcClient.capabilities.setActiveSingleton.mutate({capability:t.capName,addonId:t.addonId,nodeId:t.nodeId}),onMutate:e=>{m(e.capName),g(null)},onSuccess:async(e,t)=>{g({kind:`success`,message:`${t.capName} @ ${t.nodeId} → ${t.addonId}.`}),await _.refetch()},onError:(e,t)=>{g({kind:`error`,message:`Failed to set ${t.capName} @ ${t.nodeId}: ${e instanceof Error?e.message:`unknown error`}`})},onSettled:()=>m(null)}),D=a({mutationFn:t=>e.trpcClient.capabilities.clearSingletonNodeOverride.mutate({capability:t.capName,nodeId:t.nodeId}),onMutate:e=>{m(e.capName),g(null)},onSuccess:async(e,t)=>{g({kind:`success`,message:`${t.capName} @ ${t.nodeId} now inherits the global default.`}),await _.refetch()},onError:(e,t)=>{g({kind:`error`,message:`Failed to clear ${t.capName} @ ${t.nodeId}: ${e instanceof Error?e.message:`unknown error`}`})},onSettled:()=>m(null)}),O=a({mutationFn:t=>e.trpcClient.capabilities.setCollectionEnabledProviders.mutate({capability:t.capName,enabledAddonIds:[...t.enabledAddonIds]}),onMutate:e=>{m(e.capName),g(null)},onSuccess:async(e,t)=>{g({kind:`success`,message:`${t.capName}: ${t.enabledAddonIds.length} provider(s) enabled.`}),await _.refetch()},onError:(e,t)=>{g({kind:`error`,message:`Failed to update ${t.capName}: ${e instanceof Error?e.message:`unknown error`}`})},onSettled:()=>m(null)}),k={onSelectSingleton:(e,t)=>T.mutate({capName:e,addonId:t}),onSelectNodeSingleton:(e,t,n)=>E.mutate({capName:e,nodeId:t,addonId:n}),onClearNodeSingleton:(e,t)=>D.mutate({capName:e,nodeId:t}),onToggleCollection:(e,t)=>O.mutate({capName:e,enabledAddonIds:t}),pendingCapability:d};return t(p,{icon:f,title:`Capabilities`,subtitle:`Choose which provider is active for each system capability. Singleton caps pick exactly one provider; collection caps enable a set.`,children:[h&&t(`div`,{className:`flex items-center gap-2 rounded-md border px-3 py-2 text-xs ${h.kind===`success`?`border-green-500/30 bg-green-500/10 text-green-700 dark:text-green-300`:`border-danger/40 bg-danger/10 text-danger`}`,children:[h.kind===`success`?o(c,{className:`h-3.5 w-3.5 shrink-0`}):o(l,{className:`h-3.5 w-3.5 shrink-0`}),o(`span`,{children:h.message})]}),_.isLoading&&o(`div`,{className:`flex items-center justify-center py-16`,children:o(`div`,{className:`animate-spin h-6 w-6 border-2 border-primary border-t-transparent rounded-full`})}),_.isError&&!_.isLoading&&o(u,{title:`Failed to load capabilities`,message:_.error instanceof Error?_.error.message:`Unknown error`,onRetry:()=>void _.refetch()}),!_.isLoading&&!_.isError&&v.length===0&&o(`div`,{className:`text-xs text-foreground-subtle text-center py-16`,children:`No capabilities registered.`}),!_.isLoading&&!_.isError&&v.length>0&&t(`div`,{className:`space-y-6`,children:[S.length>0&&t(`section`,{className:`space-y-2`,children:[o(`h2`,{className:`text-[11px] font-semibold uppercase tracking-widest text-foreground-subtle/70`,children:`Singleton — pick one provider`}),o(y,{capabilities:S,actions:k})]}),w.length>0&&t(`section`,{className:`space-y-2`,children:[o(`h2`,{className:`text-[11px] font-semibold uppercase tracking-widest text-foreground-subtle/70`,children:`Collection — enable a set`}),o(y,{capabilities:w,actions:k})]})]})]})}export{w as CapabilitiesPage,w as default};
@@ -1 +1 @@
1
- import{S as e,x as t}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{pt as n,ut as r,vt as i,yt as a}from"./player-overlays-gbZ2vznV.js";import{$c as o,Dl as s,Eu as c,Fu as l,Gu as u,Il as d,Ju as f,Ll as p,Qu as m,Sl as h,Wc as g,hl as _,yu as v}from"./src-BqkvLgRS.js";var y=a(`map`,[[`path`,{d:`M14.106 5.553a2 2 0 0 0 1.788 0l3.659-1.83A1 1 0 0 1 21 4.619v12.764a1 1 0 0 1-.553.894l-4.553 2.277a2 2 0 0 1-1.788 0l-4.212-2.106a2 2 0 0 0-1.788 0l-3.659 1.83A1 1 0 0 1 3 19.381V6.618a1 1 0 0 1 .553-.894l4.553-2.277a2 2 0 0 1 1.788 0z`,key:`169xi5`}],[`path`,{d:`M15 5.764v15`,key:`1pn4in`}],[`path`,{d:`M9 3.236v15`,key:`1uimfh`}]]),b={streaming:{icon:o,label:`Streaming`},detection:{icon:v,label:`Detection`},recording:{icon:l,label:`Recording`},audio:{icon:r,label:`Audio`},snapshot:{icon:i,label:`Snapshot`},motion:{icon:g,label:`Motion`},ptz:{icon:s,label:`PTZ`},webrtc:{icon:p,label:`WebRTC`},onvif:{icon:h,label:`ONVIF`},analytics:{icon:c,label:`Analytics`},"battery-operated":{icon:m,label:`Battery`},"native-snapshot":{icon:i,label:`Native Snapshot`},"pan-tilt-zoom":{icon:s,label:`PTZ`},"two-way-audio":{icon:r,label:`Two-way Audio`},"doorbell-button":{icon:f,label:`Doorbell`},rebootable:{icon:d,label:`Rebootable`},"vacuum-has-map":{icon:y,label:`Map`},"vacuum-has-ai":{icon:_,label:`AI Obstacle`},"mower-has-map":{icon:y,label:`Map`},"mower-has-targeted-mowing":{icon:n,label:`Targeted Mowing`}},x=u;function S({capabilities:n,showLabels:r=!1}){return t(`div`,{className:`flex items-center gap-1 flex-wrap`,children:n.map(n=>{let i=b[n],a=i?.icon??x,o=i?.label??n;return e(`span`,{className:`inline-flex items-center gap-1 rounded-md bg-surface-hover px-1.5 py-0.5 text-[10px] text-foreground-subtle`,title:o,children:[t(a,{className:`h-3 w-3`}),r&&t(`span`,{children:o})]},n)})})}export{S as t};
1
+ import{S as e,x as t}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{pt as n,ut as r,vt as i,yt as a}from"./player-overlays-gbZ2vznV.js";import{$c as o,Dl as s,Eu as c,Fu as l,Gu as u,Il as d,Ju as f,Ll as p,Qu as m,Sl as h,Wc as g,hl as _,yu as v}from"./src-DxdTI837.js";var y=a(`map`,[[`path`,{d:`M14.106 5.553a2 2 0 0 0 1.788 0l3.659-1.83A1 1 0 0 1 21 4.619v12.764a1 1 0 0 1-.553.894l-4.553 2.277a2 2 0 0 1-1.788 0l-4.212-2.106a2 2 0 0 0-1.788 0l-3.659 1.83A1 1 0 0 1 3 19.381V6.618a1 1 0 0 1 .553-.894l4.553-2.277a2 2 0 0 1 1.788 0z`,key:`169xi5`}],[`path`,{d:`M15 5.764v15`,key:`1pn4in`}],[`path`,{d:`M9 3.236v15`,key:`1uimfh`}]]),b={streaming:{icon:o,label:`Streaming`},detection:{icon:v,label:`Detection`},recording:{icon:l,label:`Recording`},audio:{icon:r,label:`Audio`},snapshot:{icon:i,label:`Snapshot`},motion:{icon:g,label:`Motion`},ptz:{icon:s,label:`PTZ`},webrtc:{icon:p,label:`WebRTC`},onvif:{icon:h,label:`ONVIF`},analytics:{icon:c,label:`Analytics`},"battery-operated":{icon:m,label:`Battery`},"native-snapshot":{icon:i,label:`Native Snapshot`},"pan-tilt-zoom":{icon:s,label:`PTZ`},"two-way-audio":{icon:r,label:`Two-way Audio`},"doorbell-button":{icon:f,label:`Doorbell`},rebootable:{icon:d,label:`Rebootable`},"vacuum-has-map":{icon:y,label:`Map`},"vacuum-has-ai":{icon:_,label:`AI Obstacle`},"mower-has-map":{icon:y,label:`Map`},"mower-has-targeted-mowing":{icon:n,label:`Targeted Mowing`}},x=u;function S({capabilities:n,showLabels:r=!1}){return t(`div`,{className:`flex items-center gap-1 flex-wrap`,children:n.map(n=>{let i=b[n],a=i?.icon??x,o=i?.label??n;return e(`span`,{className:`inline-flex items-center gap-1 rounded-md bg-surface-hover px-1.5 py-0.5 text-[10px] text-foreground-subtle`,title:o,children:[t(a,{className:`h-3 w-3`}),r&&t(`span`,{children:o})]},n)})})}export{S as t};
@@ -1,4 +1,4 @@
1
- import{I as e,K as t,Q as n,S as r,V as i,W as a,b as o,o as s,q as c,x as l,z as u}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{_t as d,at as f,gt as p,st as m,yt as h}from"./player-overlays-gbZ2vznV.js";import{Al as g,As as _,Bc as v,Dn as y,En as b,Eu as x,Fl as S,Ga as C,Gc as w,Gu as ee,Il as T,Ka as E,La as D,Ll as O,Ms as te,No as k,Ns as ne,Ol as re,On as ie,Ra as ae,Tn as oe,Vu as se,Wa as ce,Wl as le,ad as A,dt as ue,ec as de,et as fe,js as pe,kl as me,nu as j,ol as he,qa as ge,ts as _e,tt as ve,ut as ye,vi as be,yn as xe,zc as Se}from"./src-BqkvLgRS.js";import{t as Ce}from"./hard-drive-download-BwgF6zZo.js";import{Bn as we}from"./src-4fqKwwai.js";import{l as M}from"./index-DrF3b0h3.js";import{t as N}from"./format-size-DIxKXxtj.js";import{t as Te}from"./NodeAddonsSettingsPanel-skqKbqMj.js";import{n as Ee,r as De,t as Oe}from"./useNodeUrlSelection-DBqemZZ0.js";var ke=h(`memory-stick`,[[`path`,{d:`M12 12v-2`,key:`fwoke6`}],[`path`,{d:`M12 18v-2`,key:`qj6yno`}],[`path`,{d:`M16 12v-2`,key:`heuere`}],[`path`,{d:`M16 18v-2`,key:`s1ct0w`}],[`path`,{d:`M2 11h1.5`,key:`15p63e`}],[`path`,{d:`M20 18v-2`,key:`12ehxp`}],[`path`,{d:`M20.5 11H22`,key:`khsy7a`}],[`path`,{d:`M4 18v-2`,key:`1c3oqr`}],[`path`,{d:`M8 12v-2`,key:`1mwtfd`}],[`path`,{d:`M8 18v-2`,key:`qcmpov`}],[`rect`,{x:`2`,y:`6`,width:`20`,height:`10`,rx:`2`,key:`1qcswk`}]]);n();function Ae(e){if(e<60)return`${e}s`;let t=Math.floor(e/60);if(t<60)return`${t}m`;let n=Math.floor(t/60);return n<24?`${n}h ${t%60}m`:`${Math.floor(n/24)}d ${n%24}h`}function je({state:e}){return l(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded-full ${e===`running`?`bg-success/10 text-success`:e===`crashed`||e===`failed`?`bg-destructive/10 text-destructive`:`bg-muted text-muted-foreground`}`,children:e})}var Me=[`trace`,`debug`,`info`,`warn`,`error`];function Ne({proc:e,nodeId:t,defaultExpanded:n,activePanel:i,onTogglePanel:a}){let o=e.services??[],s=o.length===1,[u,f]=c(s||n),[m,h]=c(null),[_,v]=c(`info`),x=e.name.includes(`(core)`),w=C(),T=E(),D=ge(),te=async e=>{h(e);try{await w.mutateAsync({nodeId:t,addonId:e})}catch(e){console.error(`Failed to restart addon:`,e)}finally{h(null)}},k=async()=>{h(e.name);try{await T.mutateAsync({nodeId:t,processName:e.name})}catch(e){console.error(`Failed to restart process:`,e)}finally{h(null)}},ne=async n=>{let r=`${t}/${e.name}`;try{await D.mutateAsync({nodeId:r,level:n}),v(n)}catch(e){console.error(`Failed to set log level:`,e)}};return r(`div`,{className:`border border-border/50 rounded-lg overflow-hidden`,children:[r(`div`,{role:s?void 0:`button`,tabIndex:s?void 0:0,onClick:s?void 0:()=>f(!u),onKeyDown:s?void 0:e=>{(e.key===`Enter`||e.key===` `)&&f(!u)},className:`flex items-center gap-2 w-full px-3 py-2 bg-muted/20 transition-colors text-left select-none ${s?``:`hover:bg-muted/40 cursor-pointer`}`,children:[s?l(`span`,{className:`h-3 w-3 shrink-0`}):l(u?d:p,{className:`h-3 w-3 text-muted-foreground shrink-0`}),x?l(re,{className:`h-3.5 w-3.5 text-primary shrink-0`}):l(ee,{className:`h-3.5 w-3.5 text-amber-500 shrink-0`}),l(`span`,{className:`text-xs font-semibold flex-1`,children:e.name}),r(`span`,{className:`text-[10px] text-muted-foreground tabular-nums`,children:[`PID `,e.pid]}),l(je,{state:e.state}),r(`span`,{className:`text-[10px] text-muted-foreground tabular-nums`,children:[e.cpuPercent,`% CPU`]}),l(`span`,{className:`text-[10px] text-muted-foreground tabular-nums`,children:N(e.memoryRss)}),l(`span`,{className:`text-[10px] text-muted-foreground tabular-nums`,children:Ae(e.uptimeSeconds)}),!x&&r(`div`,{className:`flex items-center gap-1`,onClick:e=>e.stopPropagation(),children:[r(oe,{children:[l(ie,{className:`text-[9px] px-1.5 py-0.5 rounded border border-border text-muted-foreground hover:text-foreground hover:bg-muted transition-colors font-mono`,title:`Set log level`,children:_}),l(b,{align:`end`,className:`min-w-[70px] py-0.5`,children:Me.map(e=>l(y,{onClick:()=>ne(e),className:`h-auto px-2 py-1 text-[10px] font-mono ${e===_?`text-primary font-semibold`:``}`,children:e},e))})]}),l(`button`,{onClick:k,disabled:m===e.name,className:`p-1 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50`,title:`Restart process`,children:l(S,{className:`h-3 w-3 ${m===e.name?`animate-spin`:``}`})})]})]}),u&&o.length>0&&l(`div`,{className:`divide-y divide-border/30`,children:o.map(e=>r(`div`,{children:[r(`div`,{className:`flex items-center gap-2 px-3 py-1.5 pl-9 hover:bg-muted/10 transition-colors`,children:[l(`div`,{className:`h-1.5 w-1.5 rounded-full shrink-0 ${e.status===`running`?`bg-success`:`bg-muted-foreground/30`}`}),l(`span`,{className:`text-xs font-medium flex-1 min-w-0 truncate`,children:e.addonId}),e.capabilities.length>0&&r(`div`,{className:`flex gap-1 flex-shrink-0`,children:[e.capabilities.slice(0,3).map(e=>l(`span`,{className:`text-[9px] px-1 py-0.5 rounded bg-blue-500/10 text-blue-400 truncate max-w-[80px]`,children:e},e)),e.capabilities.length>3&&r(`span`,{className:`text-[9px] text-muted-foreground`,children:[`+`,e.capabilities.length-3]})]}),r(`div`,{className:`flex items-center gap-1 shrink-0`,children:[l(`button`,{onClick:()=>a(e.addonId,`logs`),className:`p-0.5 rounded transition-colors ${i?.addonId===e.addonId&&i.type===`logs`?`bg-primary/10 text-primary`:`hover:bg-muted text-muted-foreground hover:text-foreground`}`,title:`Show logs for ${e.addonId}`,children:l(g,{className:`h-3 w-3`})}),l(`button`,{onClick:()=>a(e.addonId,`events`),className:`p-0.5 rounded transition-colors ${i?.addonId===e.addonId&&i.type===`events`?`bg-primary/10 text-primary`:`hover:bg-muted text-muted-foreground hover:text-foreground`}`,title:`Show events for ${e.addonId}`,children:l(O,{className:`h-3 w-3`})}),l(`button`,{onClick:()=>te(e.addonId),disabled:m===e.addonId,className:`p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50`,title:`Restart ${e.addonId}`,children:l(S,{className:`h-3 w-3 ${m===e.addonId?`animate-spin`:``}`})})]})]}),i?.addonId===e.addonId&&i.type===`logs`&&l(`div`,{className:`border-t border-border/40 bg-muted/5`,children:l(ve,{addonId:e.addonId,agentId:t,maxHeight:`max-h-48`,showFilters:!1,onClose:()=>a(e.addonId,`logs`)})}),i?.addonId===e.addonId&&i.type===`events`&&l(`div`,{className:`border-t border-border/40 bg-muted/5`,children:l(fe,{addonId:e.addonId,category:`addon.*`,maxHeight:`max-h-48`,onClose:()=>a(e.addonId,`events`)})})]},e.addonId))}),u&&o.length===0&&l(`div`,{className:`px-3 py-2 pl-9 text-[10px] text-muted-foreground`,children:`No services`})]})}function Pe({nodeId:e,processes:t}){let[n,r]=c(null),i=(e,t)=>{r(n=>n?.addonId===e&&n.type===t?null:{addonId:e,type:t})};return t.length===0?l(`div`,{className:`py-4 text-xs text-muted-foreground text-center`,children:`No processes on this node`}):l(`div`,{className:`space-y-2 py-1`,children:t.map((t,r)=>l(Ne,{proc:t,nodeId:e,defaultExpanded:r===0,activePanel:n,onTogglePanel:i},t.name))})}var Fe={system:0,managed:1,root:2};n();function Ie(e){return e<60?`${e}s`:e<3600?`${Math.floor(e/60)}m ${e%60}s`:e<86400?`${Math.floor(e/3600)}h ${Math.floor(e%3600/60)}m`:`${Math.floor(e/86400)}d ${Math.floor(e%86400/3600)}h`}function Le(e,t=80){return e.length<=t?e:`…${e.slice(e.length-t+1)}`}function Re({nodeId:e}){let t=s(),n=v(`metrics.node-processes-snapshot`,t=>t.nodeId===e),{data:i}=ae({nodeId:e}),o=n?.processes??i,c=a(()=>o?[...o]:[],[o]),u=a(()=>[{key:`classification`,header:`Class`,sortValue:e=>Fe[e.classification],render:e=>l(`span`,{className:`inline-block rounded-full px-1.5 py-0.5 text-[10px] font-medium ${e.classification===`root`?`bg-sky-500/20 text-sky-400`:e.classification===`system`?`bg-foreground-subtle/20 text-foreground-subtle`:`bg-success/20 text-success`}`,children:e.classification})},{key:`pid`,header:`PID`,align:`right`,sortValue:e=>e.pid,render:e=>l(`span`,{className:`font-mono`,children:e.pid})},{key:`ppid`,header:`PPID`,align:`right`,sortValue:e=>e.ppid,render:e=>l(`span`,{className:`font-mono text-foreground-subtle`,children:e.ppid})},{key:`addonId`,header:`Addon`,sortValue:e=>e.addonId,render:e=>l(`span`,{className:`text-foreground-subtle text-[11px]`,children:e.addonId??`—`})},{key:`command`,header:`Command`,nowrap:!1,render:e=>l(`span`,{className:`font-mono text-[10px] text-foreground-subtle break-all`,children:Le(e.command)})},{key:`cpuPercent`,header:`CPU%`,align:`right`,sortValue:e=>e.cpuPercent,render:e=>e.cpuPercent.toFixed(1)},{key:`memoryRssBytes`,header:`RSS`,align:`right`,sortValue:e=>e.memoryRssBytes,render:e=>N(e.memoryRssBytes)},{key:`uptimeSec`,header:`Uptime`,align:`right`,sortValue:e=>e.uptimeSec,render:e=>l(`span`,{className:`text-foreground-subtle`,children:Ie(e.uptimeSec)})}],[]);return r(`div`,{className:`space-y-4`,children:[l(`div`,{className:`flex items-start justify-end gap-4`,children:r(`button`,{type:`button`,onClick:()=>t.invalidateQueries({queryKey:[[`metricsProvider`,`listNodeProcesses`]]}),className:`inline-flex items-center gap-1 rounded border border-border px-2 py-1 text-[11px] text-foreground hover:bg-surface-hover`,children:[l(T,{className:`h-3 w-3`}),` Refresh`]})}),l(ye,{columns:u,rows:c,rowKey:e=>e.pid,minWidthPx:880,mobileMode:`scroll`,maxBodyHeight:ue,emptyMessage:`Scanning…`})]})}var P={width:320,height:64},F=.8,I=Math.ceil(8*F-3)+1,L=P.width+34,R=P.height+I+1+11,ze=I+P.height+1+3+Math.ceil(8*F),Be=[1,2,5,10],Ve=[1,2,4,8,16,32,64,128,256,512,1024],He=[1,1.5,2,2.5,3,4,5],z=[4,3,5,2],B=1e-9;function Ue(e,t){if(!Number.isFinite(e)||e<=0)return!1;if(t===`bytes`){if(!Number.isInteger(e))return!1;let t=e/1024**Math.floor(Math.log(e)/Math.log(1024));return He.some(e=>Math.abs(t-e)<B)}let n=e/10**Math.floor(Math.log10(e));return He.some(e=>Math.abs(n-e)<B)}function V(e,t,n){let r=0;for(let t of e)t!==null&&t>r&&(r=t);if(r<=t)return t;if(n===`bytes`){let e=1024**Math.floor(Math.log(r)/Math.log(1024));for(let t of Ve){let n=t*e;if(n>=r)return n}return 1024*e}let i=10**Math.floor(Math.log10(r));for(let e of Be){let t=e*i;if(t>=r)return t}return 10*i}function H(e,t){if(!Number.isFinite(e)||e<=0)return[];let n=z.find(n=>Ue(e/n,t))??z[z.length-1],r=e/n,i=[];for(let e=1;e<=n;e++)i.push(r*e);return i}var We=2.5;function U(e){return e*We}function W(e,t,n,r){if(e.length===0)return[];let i=e[0].atMs,a=e.at(-1).atMs-i,o=n<=0?1:n,s=r!==void 0&&r>0?r:null;return e.map((r,c)=>{let l=a>0?(r.atMs-i)/a*t.width:c/Math.max(1,e.length-1)*t.width,u=c>0?e[c-1]:void 0;return{x:l,y:r.value===null?null:t.height-Math.min(r.value,n)/o*t.height,gapBefore:s!==null&&u!==void 0&&r.atMs-u.atMs>s}})}function G(e){let t=[],n=!1;for(let r of e){if(r.y===null){n=!1;continue}r.gapBefore&&(n=!1),t.push(`${n?`L`:`M`}${r.x.toFixed(1)},${r.y.toFixed(1)}`),n=!0}return t.join(` `)}function K(e,t){let n=[],r=[],i=()=>{if(r.length<2){r=[];return}let e=r.map((e,t)=>`${t===0?`M`:`L`}${e.x.toFixed(1)},${e.top.toFixed(1)}`),t=[...r].reverse().map(e=>`L${e.x.toFixed(1)},${e.bottom.toFixed(1)}`);n.push(`${e.join(` `)} ${t.join(` `)} Z`),r=[]};for(let n=0;n<e.length;n++){let a=e[n],o=t[n];if(!a||!o||a.y===null||o.y===null){i();continue}(a.gapBefore||o.gapBefore)&&i(),r.push({x:a.x,top:a.y,bottom:o.y})}return i(),n.join(` `)}function Ge(e,t,n=3){if(e.length<2||n<2)return[];let r=e[0].atMs,i=e.at(-1).atMs-r;if(i<=0)return[];let a=[];for(let e=0;e<n;e++){let o=e/(n-1);a.push({atMs:r+i*o,x:o*t.width,anchor:e===0?`start`:e===n-1?`end`:`middle`})}return a}function Ke(e){return e.length<2?0:Math.max(0,e.at(-1).atMs-e[0].atMs)}function qe(e){let t=[];for(let n=1;n<e.length;n++){let r=e[n];r.gapBefore&&t.push({fromX:e[n-1].x,toX:r.x})}return t}function Je(e,t){if(e.length===0)return null;let n=0,r=1/0;for(let i=0;i<e.length;i++){let a=Math.abs(e[i].x-t);a<r&&(r=a,n=i)}return n}n();var q={main:`var(--load-series-main)`,gc:`var(--load-series-gc)`},Ye=`
1
+ import{I as e,K as t,Q as n,S as r,V as i,W as a,b as o,o as s,q as c,x as l,z as u}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{_t as d,at as f,gt as p,st as m,yt as h}from"./player-overlays-gbZ2vznV.js";import{Al as g,As as _,Bc as v,Dn as y,En as b,Eu as x,Fl as S,Ga as C,Gc as w,Gu as ee,Il as T,Ka as E,La as D,Ll as O,Ms as te,No as k,Ns as ne,Ol as re,On as ie,Ra as ae,Tn as oe,Vu as se,Wa as ce,Wl as le,ad as A,dt as ue,ec as de,et as fe,js as pe,kl as me,nu as j,ol as he,qa as ge,ts as _e,tt as ve,ut as ye,vi as be,yn as xe,zc as Se}from"./src-DxdTI837.js";import{t as Ce}from"./hard-drive-download-BwgF6zZo.js";import{Bn as we}from"./src-4fqKwwai.js";import{l as M}from"./index-xBLZKqTX.js";import{t as N}from"./format-size-DIxKXxtj.js";import{t as Te}from"./NodeAddonsSettingsPanel-D9m0jYk9.js";import{n as Ee,r as De,t as Oe}from"./useNodeUrlSelection-Bt6smdEd.js";var ke=h(`memory-stick`,[[`path`,{d:`M12 12v-2`,key:`fwoke6`}],[`path`,{d:`M12 18v-2`,key:`qj6yno`}],[`path`,{d:`M16 12v-2`,key:`heuere`}],[`path`,{d:`M16 18v-2`,key:`s1ct0w`}],[`path`,{d:`M2 11h1.5`,key:`15p63e`}],[`path`,{d:`M20 18v-2`,key:`12ehxp`}],[`path`,{d:`M20.5 11H22`,key:`khsy7a`}],[`path`,{d:`M4 18v-2`,key:`1c3oqr`}],[`path`,{d:`M8 12v-2`,key:`1mwtfd`}],[`path`,{d:`M8 18v-2`,key:`qcmpov`}],[`rect`,{x:`2`,y:`6`,width:`20`,height:`10`,rx:`2`,key:`1qcswk`}]]);n();function Ae(e){if(e<60)return`${e}s`;let t=Math.floor(e/60);if(t<60)return`${t}m`;let n=Math.floor(t/60);return n<24?`${n}h ${t%60}m`:`${Math.floor(n/24)}d ${n%24}h`}function je({state:e}){return l(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded-full ${e===`running`?`bg-success/10 text-success`:e===`crashed`||e===`failed`?`bg-destructive/10 text-destructive`:`bg-muted text-muted-foreground`}`,children:e})}var Me=[`trace`,`debug`,`info`,`warn`,`error`];function Ne({proc:e,nodeId:t,defaultExpanded:n,activePanel:i,onTogglePanel:a}){let o=e.services??[],s=o.length===1,[u,f]=c(s||n),[m,h]=c(null),[_,v]=c(`info`),x=e.name.includes(`(core)`),w=C(),T=E(),D=ge(),te=async e=>{h(e);try{await w.mutateAsync({nodeId:t,addonId:e})}catch(e){console.error(`Failed to restart addon:`,e)}finally{h(null)}},k=async()=>{h(e.name);try{await T.mutateAsync({nodeId:t,processName:e.name})}catch(e){console.error(`Failed to restart process:`,e)}finally{h(null)}},ne=async n=>{let r=`${t}/${e.name}`;try{await D.mutateAsync({nodeId:r,level:n}),v(n)}catch(e){console.error(`Failed to set log level:`,e)}};return r(`div`,{className:`border border-border/50 rounded-lg overflow-hidden`,children:[r(`div`,{role:s?void 0:`button`,tabIndex:s?void 0:0,onClick:s?void 0:()=>f(!u),onKeyDown:s?void 0:e=>{(e.key===`Enter`||e.key===` `)&&f(!u)},className:`flex items-center gap-2 w-full px-3 py-2 bg-muted/20 transition-colors text-left select-none ${s?``:`hover:bg-muted/40 cursor-pointer`}`,children:[s?l(`span`,{className:`h-3 w-3 shrink-0`}):l(u?d:p,{className:`h-3 w-3 text-muted-foreground shrink-0`}),x?l(re,{className:`h-3.5 w-3.5 text-primary shrink-0`}):l(ee,{className:`h-3.5 w-3.5 text-amber-500 shrink-0`}),l(`span`,{className:`text-xs font-semibold flex-1`,children:e.name}),r(`span`,{className:`text-[10px] text-muted-foreground tabular-nums`,children:[`PID `,e.pid]}),l(je,{state:e.state}),r(`span`,{className:`text-[10px] text-muted-foreground tabular-nums`,children:[e.cpuPercent,`% CPU`]}),l(`span`,{className:`text-[10px] text-muted-foreground tabular-nums`,children:N(e.memoryRss)}),l(`span`,{className:`text-[10px] text-muted-foreground tabular-nums`,children:Ae(e.uptimeSeconds)}),!x&&r(`div`,{className:`flex items-center gap-1`,onClick:e=>e.stopPropagation(),children:[r(oe,{children:[l(ie,{className:`text-[9px] px-1.5 py-0.5 rounded border border-border text-muted-foreground hover:text-foreground hover:bg-muted transition-colors font-mono`,title:`Set log level`,children:_}),l(b,{align:`end`,className:`min-w-[70px] py-0.5`,children:Me.map(e=>l(y,{onClick:()=>ne(e),className:`h-auto px-2 py-1 text-[10px] font-mono ${e===_?`text-primary font-semibold`:``}`,children:e},e))})]}),l(`button`,{onClick:k,disabled:m===e.name,className:`p-1 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50`,title:`Restart process`,children:l(S,{className:`h-3 w-3 ${m===e.name?`animate-spin`:``}`})})]})]}),u&&o.length>0&&l(`div`,{className:`divide-y divide-border/30`,children:o.map(e=>r(`div`,{children:[r(`div`,{className:`flex items-center gap-2 px-3 py-1.5 pl-9 hover:bg-muted/10 transition-colors`,children:[l(`div`,{className:`h-1.5 w-1.5 rounded-full shrink-0 ${e.status===`running`?`bg-success`:`bg-muted-foreground/30`}`}),l(`span`,{className:`text-xs font-medium flex-1 min-w-0 truncate`,children:e.addonId}),e.capabilities.length>0&&r(`div`,{className:`flex gap-1 flex-shrink-0`,children:[e.capabilities.slice(0,3).map(e=>l(`span`,{className:`text-[9px] px-1 py-0.5 rounded bg-blue-500/10 text-blue-400 truncate max-w-[80px]`,children:e},e)),e.capabilities.length>3&&r(`span`,{className:`text-[9px] text-muted-foreground`,children:[`+`,e.capabilities.length-3]})]}),r(`div`,{className:`flex items-center gap-1 shrink-0`,children:[l(`button`,{onClick:()=>a(e.addonId,`logs`),className:`p-0.5 rounded transition-colors ${i?.addonId===e.addonId&&i.type===`logs`?`bg-primary/10 text-primary`:`hover:bg-muted text-muted-foreground hover:text-foreground`}`,title:`Show logs for ${e.addonId}`,children:l(g,{className:`h-3 w-3`})}),l(`button`,{onClick:()=>a(e.addonId,`events`),className:`p-0.5 rounded transition-colors ${i?.addonId===e.addonId&&i.type===`events`?`bg-primary/10 text-primary`:`hover:bg-muted text-muted-foreground hover:text-foreground`}`,title:`Show events for ${e.addonId}`,children:l(O,{className:`h-3 w-3`})}),l(`button`,{onClick:()=>te(e.addonId),disabled:m===e.addonId,className:`p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50`,title:`Restart ${e.addonId}`,children:l(S,{className:`h-3 w-3 ${m===e.addonId?`animate-spin`:``}`})})]})]}),i?.addonId===e.addonId&&i.type===`logs`&&l(`div`,{className:`border-t border-border/40 bg-muted/5`,children:l(ve,{addonId:e.addonId,agentId:t,maxHeight:`max-h-48`,showFilters:!1,onClose:()=>a(e.addonId,`logs`)})}),i?.addonId===e.addonId&&i.type===`events`&&l(`div`,{className:`border-t border-border/40 bg-muted/5`,children:l(fe,{addonId:e.addonId,category:`addon.*`,maxHeight:`max-h-48`,onClose:()=>a(e.addonId,`events`)})})]},e.addonId))}),u&&o.length===0&&l(`div`,{className:`px-3 py-2 pl-9 text-[10px] text-muted-foreground`,children:`No services`})]})}function Pe({nodeId:e,processes:t}){let[n,r]=c(null),i=(e,t)=>{r(n=>n?.addonId===e&&n.type===t?null:{addonId:e,type:t})};return t.length===0?l(`div`,{className:`py-4 text-xs text-muted-foreground text-center`,children:`No processes on this node`}):l(`div`,{className:`space-y-2 py-1`,children:t.map((t,r)=>l(Ne,{proc:t,nodeId:e,defaultExpanded:r===0,activePanel:n,onTogglePanel:i},t.name))})}var Fe={system:0,managed:1,root:2};n();function Ie(e){return e<60?`${e}s`:e<3600?`${Math.floor(e/60)}m ${e%60}s`:e<86400?`${Math.floor(e/3600)}h ${Math.floor(e%3600/60)}m`:`${Math.floor(e/86400)}d ${Math.floor(e%86400/3600)}h`}function Le(e,t=80){return e.length<=t?e:`…${e.slice(e.length-t+1)}`}function Re({nodeId:e}){let t=s(),n=v(`metrics.node-processes-snapshot`,t=>t.nodeId===e),{data:i}=ae({nodeId:e}),o=n?.processes??i,c=a(()=>o?[...o]:[],[o]),u=a(()=>[{key:`classification`,header:`Class`,sortValue:e=>Fe[e.classification],render:e=>l(`span`,{className:`inline-block rounded-full px-1.5 py-0.5 text-[10px] font-medium ${e.classification===`root`?`bg-sky-500/20 text-sky-400`:e.classification===`system`?`bg-foreground-subtle/20 text-foreground-subtle`:`bg-success/20 text-success`}`,children:e.classification})},{key:`pid`,header:`PID`,align:`right`,sortValue:e=>e.pid,render:e=>l(`span`,{className:`font-mono`,children:e.pid})},{key:`ppid`,header:`PPID`,align:`right`,sortValue:e=>e.ppid,render:e=>l(`span`,{className:`font-mono text-foreground-subtle`,children:e.ppid})},{key:`addonId`,header:`Addon`,sortValue:e=>e.addonId,render:e=>l(`span`,{className:`text-foreground-subtle text-[11px]`,children:e.addonId??`—`})},{key:`command`,header:`Command`,nowrap:!1,render:e=>l(`span`,{className:`font-mono text-[10px] text-foreground-subtle break-all`,children:Le(e.command)})},{key:`cpuPercent`,header:`CPU%`,align:`right`,sortValue:e=>e.cpuPercent,render:e=>e.cpuPercent.toFixed(1)},{key:`memoryRssBytes`,header:`RSS`,align:`right`,sortValue:e=>e.memoryRssBytes,render:e=>N(e.memoryRssBytes)},{key:`uptimeSec`,header:`Uptime`,align:`right`,sortValue:e=>e.uptimeSec,render:e=>l(`span`,{className:`text-foreground-subtle`,children:Ie(e.uptimeSec)})}],[]);return r(`div`,{className:`space-y-4`,children:[l(`div`,{className:`flex items-start justify-end gap-4`,children:r(`button`,{type:`button`,onClick:()=>t.invalidateQueries({queryKey:[[`metricsProvider`,`listNodeProcesses`]]}),className:`inline-flex items-center gap-1 rounded border border-border px-2 py-1 text-[11px] text-foreground hover:bg-surface-hover`,children:[l(T,{className:`h-3 w-3`}),` Refresh`]})}),l(ye,{columns:u,rows:c,rowKey:e=>e.pid,minWidthPx:880,mobileMode:`scroll`,maxBodyHeight:ue,emptyMessage:`Scanning…`})]})}var P={width:320,height:64},F=.8,I=Math.ceil(8*F-3)+1,L=P.width+34,R=P.height+I+1+11,ze=I+P.height+1+3+Math.ceil(8*F),Be=[1,2,5,10],Ve=[1,2,4,8,16,32,64,128,256,512,1024],He=[1,1.5,2,2.5,3,4,5],z=[4,3,5,2],B=1e-9;function Ue(e,t){if(!Number.isFinite(e)||e<=0)return!1;if(t===`bytes`){if(!Number.isInteger(e))return!1;let t=e/1024**Math.floor(Math.log(e)/Math.log(1024));return He.some(e=>Math.abs(t-e)<B)}let n=e/10**Math.floor(Math.log10(e));return He.some(e=>Math.abs(n-e)<B)}function V(e,t,n){let r=0;for(let t of e)t!==null&&t>r&&(r=t);if(r<=t)return t;if(n===`bytes`){let e=1024**Math.floor(Math.log(r)/Math.log(1024));for(let t of Ve){let n=t*e;if(n>=r)return n}return 1024*e}let i=10**Math.floor(Math.log10(r));for(let e of Be){let t=e*i;if(t>=r)return t}return 10*i}function H(e,t){if(!Number.isFinite(e)||e<=0)return[];let n=z.find(n=>Ue(e/n,t))??z[z.length-1],r=e/n,i=[];for(let e=1;e<=n;e++)i.push(r*e);return i}var We=2.5;function U(e){return e*We}function W(e,t,n,r){if(e.length===0)return[];let i=e[0].atMs,a=e.at(-1).atMs-i,o=n<=0?1:n,s=r!==void 0&&r>0?r:null;return e.map((r,c)=>{let l=a>0?(r.atMs-i)/a*t.width:c/Math.max(1,e.length-1)*t.width,u=c>0?e[c-1]:void 0;return{x:l,y:r.value===null?null:t.height-Math.min(r.value,n)/o*t.height,gapBefore:s!==null&&u!==void 0&&r.atMs-u.atMs>s}})}function G(e){let t=[],n=!1;for(let r of e){if(r.y===null){n=!1;continue}r.gapBefore&&(n=!1),t.push(`${n?`L`:`M`}${r.x.toFixed(1)},${r.y.toFixed(1)}`),n=!0}return t.join(` `)}function K(e,t){let n=[],r=[],i=()=>{if(r.length<2){r=[];return}let e=r.map((e,t)=>`${t===0?`M`:`L`}${e.x.toFixed(1)},${e.top.toFixed(1)}`),t=[...r].reverse().map(e=>`L${e.x.toFixed(1)},${e.bottom.toFixed(1)}`);n.push(`${e.join(` `)} ${t.join(` `)} Z`),r=[]};for(let n=0;n<e.length;n++){let a=e[n],o=t[n];if(!a||!o||a.y===null||o.y===null){i();continue}(a.gapBefore||o.gapBefore)&&i(),r.push({x:a.x,top:a.y,bottom:o.y})}return i(),n.join(` `)}function Ge(e,t,n=3){if(e.length<2||n<2)return[];let r=e[0].atMs,i=e.at(-1).atMs-r;if(i<=0)return[];let a=[];for(let e=0;e<n;e++){let o=e/(n-1);a.push({atMs:r+i*o,x:o*t.width,anchor:e===0?`start`:e===n-1?`end`:`middle`})}return a}function Ke(e){return e.length<2?0:Math.max(0,e.at(-1).atMs-e[0].atMs)}function qe(e){let t=[];for(let n=1;n<e.length;n++){let r=e[n];r.gapBefore&&t.push({fromX:e[n-1].x,toX:r.x})}return t}function Je(e,t){if(e.length===0)return null;let n=0,r=1/0;for(let i=0;i<e.length;i++){let a=Math.abs(e[i].x-t);a<r&&(r=a,n=i)}return n}n();var q={main:`var(--load-series-main)`,gc:`var(--load-series-gc)`},Ye=`
2
2
  .load-chart-scope { --load-series-main: #2a78d6; --load-series-gc: #e87ba4; }
3
3
  @media (prefers-color-scheme: dark) {
4
4
  :root:not([data-theme="light"]) .load-chart-scope {
@@ -1 +1 @@
1
- import{G as e,I as t,K as n,Q as r,S as i,b as a,q as o,x as s,z as c}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{at as l}from"./player-overlays-gbZ2vznV.js";import{B as u,H as d,Rr as f,Vr as p,_i as m,an as h,c as g,cn as _,qi as v,tn as y,vi as b}from"./src-BqkvLgRS.js";import{An as x,On as S,Sn as C,Tt as w,_n as T,dn as ee,gn as E,hn as te,jn as D,kn as ne,ln as re,mn as ie,on as O,pn as ae,un as oe,vn as k,wt as se,xn as A}from"./src-4fqKwwai.js";import{l as j}from"./index-DrF3b0h3.js";r();function ce(e){return{target:{kind:`new`,type:e},name:``,features:[]}}function le(e){return{target:{kind:`existing`,device:e},name:``,features:[]}}function ue(e,t){return{target:e.target,name:t,features:e.features.flatMap(e=>e.kind===`fields`?[e]:[])}}function M(e,t,n){return{...e,features:e.features.map(e=>e.cap===t?n(e):e)}}function de(e,t){return Object.fromEntries(Object.entries(e).filter(([e])=>e!==t))}function fe(e,t){switch(t.type){case`set-new-type`:return e.target.kind===`new`?{...e,target:{...e.target,type:t.deviceType}}:e;case`set-new-role`:{if(e.target.kind!==`new`)return e;let{role:n,...r}=e.target;return{...e,target:t.role===null?r:{...r,role:t.role}}}case`set-name`:return{...e,name:t.name};case`add-feature`:return e.features.some(e=>e.cap===t.cap)?e:{...e,features:[...e.features,{kind:`fields`,cap:t.cap,fields:{}}]};case`remove-feature`:return{...e,features:e.features.filter(e=>e.cap!==t.cap)};case`set-field`:return M(e,t.cap,e=>({...e,fields:{...e.fields,[t.path]:t.source}}));case`clear-field`:return M(e,t.cap,e=>({...e,fields:de(e.fields,t.path)}));case`copy-feature`:return M(e,t.cap,e=>({...e,fields:{...e.fields,...Object.fromEntries(t.paths.map(e=>[e,{kind:`from`,source:t.from,cap:t.sourceCap,fieldPath:e}]))}}))}}function pe(e){let t=ee.safeParse({target:e.target,features:e.features});return t.success?{ok:!0,composition:t.data}:{ok:!1,problems:t.error.issues.map(e=>`${e.path.join(`.`)||`composition`}: ${e.message}`)}}function me(e){for(let t=1;;t++){let n=`s${t}`;if(!e.includes(n))return n}}function N(e){return{addonId:e.addonId,stableId:e.stableId}}function P(e){return new Map(e.map(e=>[T(N(e)),e]))}function he(e,t,n){return e.filter(e=>e.id!==n&&e.type!==C.Container&&t.includes(e.id)).toSorted((e,t)=>e.name.localeCompare(t.name))}function ge(e,t,n){let r=e?.features??[],i=r.findIndex(e=>e.cap===n.cap);return{target:e?.target??{kind:`existing`,device:t},features:i===-1?[...r,n]:r.map((e,t)=>t===i?n:e)}}function _e(e,t){let n=e.features.filter(e=>e.cap!==t);return n.length===0?null:{target:e.target,features:n}}function F(e,t){let n=e?.features.find(e=>e.cap===t);return n!==void 0&&n.kind===`fields`?n:null}function I(e){return Array.isArray(e)?e.map(I):typeof e!=`object`||!e?e:Object.fromEntries(Object.entries(e).toSorted(([e],[t])=>e.localeCompare(t)).map(([e,t])=>[e,I(t)]))}function L(e){return JSON.stringify(I(e))}function R(e,t){return L(e)===L(t)}function ve(e,t){switch(e.kind){case`pending`:return{kind:`refused`,reason:`the customization has not been read yet — try again`};case`unknown`:return{kind:`refused`,reason:`the customization could not be read: ${e.reason}`};case`not-loaded`:return{kind:`refused`,reason:`the customizations are not loaded yet: ${e.reason}`};case`none`:return t===null?{kind:`noop`}:{kind:`create`,input:{enabled:!0,composition:t}};case`present`:{let n=e.view.block.id;return t===null?{kind:`delete`,blockId:n}:L(t)===L(e.composition)?{kind:`noop`}:{kind:`update`,blockId:n,expectedUpdatedAt:e.view.block.updatedAt,composition:t}}}}function z(e,t){let n=e===`enum`?`string`:e,r=t.kind===`enum`?`string`:t.kind,i={source:t.source,cap:t.cap,fieldPath:t.fieldPath};return r===n?{kind:`from`,...i}:n===`number`&&r===`string`?{kind:`expression`,expr:`number(x)`,bindings:{x:{kind:`from`,...i}}}:null}function B(e){return{kind:`expression`,expr:e,bindings:{}}}function V(e){let t=z(`number`,e.percentage);return t===null?null:{kind:`fields`,cap:`battery`,fields:e.mode===`replace`?{percentage:t}:{percentage:t,charging:B(`"unknown"`),sleeping:B(`false`),lastUpdated:B(`now`)}}}var H=x.filter(e=>e!==`switch`&&e!==`motion`);function ye(e){let t=D[e.cap];return t===void 0||!H.includes(e.cap)?null:{kind:`fields`,cap:e.cap,fields:{[t]:{kind:`expression`,expr:`!v`,bindings:{v:{kind:`from`,source:e.self,cap:e.cap,fieldPath:t}}}}}}function be(e){return e.from===e.to||!w(e.from,e.to)?null:{kind:`fields`,cap:e.cap,fields:{[e.fieldPath]:{kind:`expression`,expr:`convert(v, ${JSON.stringify(e.from)}, ${JSON.stringify(e.to)})`,bindings:{v:{kind:`from`,source:e.self,cap:e.cap,fieldPath:e.fieldPath}}},...e.unitField===null?{}:{[e.unitField]:B(JSON.stringify(e.to))}}}}function xe(e,t){let n=z(`number`,t.remaining);if(n===null||!oe.test(t.key)||t.label.trim()===``)return null;let r={label:t.label.trim(),fields:{"remaining.value":n,"remaining.unit":B(JSON.stringify(t.unit))}};return{kind:`fields`,cap:`consumables`,...e?.enabled===void 0?{}:{enabled:e.enabled},fields:e?.fields??{lastChangedAt:B(`now`),lastFetchedAt:B(`now`)},items:{...e?.items,[t.key]:r}}}function Se(e){return e.toLowerCase().normalize(`NFD`).replace(/[\u0300-\u036f]/g,``).replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``).slice(0,48)}function Ce(e){let t=e.fields.lastPressedAt;if(t===void 0||t.kind!==`expression`)return[];let n=Object.entries(t.bindings).filter(([e])=>e.startsWith(`active`)).flatMap(([,e])=>e.kind===`from`?[e.source]:[]);return[...new Map(n.map(e=>[T(e),e])).values()]}function we(e){let t=e.fields.lastPressedAt;if(t===void 0||t.kind!==`expression`)return[];let n=t.bindings;return Object.entries(n).flatMap(([e,t])=>{if(!e.startsWith(`active`)||t.kind!==`from`)return[];let r=n[`changed${e.slice(6)}`];return r===void 0||r.kind!==`from`?[]:[{source:t.source,cap:t.cap,activeField:t.fieldPath,changedAtField:r.fieldPath}]})}function Te(e){if(e===void 0)return null;if(e.kind===`from`){let{kind:t,...n}=e;return{...n,kind:`number`}}if(e.kind!==`expression`||e.expr!==`number(x)`)return null;let t=e.bindings.x;if(t===void 0||t.kind!==`from`||Object.keys(e.bindings).length!==1)return null;let{kind:n,...r}=t;return{...r,kind:`string`}}function Ee(e,t){let n=Te(e.fields.percentage);if(n===null)return!1;let r=V({percentage:n,mode:t}),{enabled:i,...a}=e;return r!==null&&R(a,r)}function U(e){return e.map(e=>({id:e.id,name:e.name,addonId:e.addonId,stableId:e.stableId,location:e.location,type:e.type}))}function De(e,t,n){let r=t.trim().toLowerCase();return r===``?[]:e.filter(e=>!n.includes(e.id)&&[e.name,e.stableId,e.location??``].some(e=>e.toLowerCase().includes(r))).toSorted((e,t)=>e.name.localeCompare(t.name)).slice(0,20)}function W(e,t){let n=e;for(let e of t.split(`.`)){if(typeof n!=`object`||!n||Array.isArray(n))return;n=Object.getOwnPropertyDescriptor(n,e)?.value}return n}function Oe(e,t,n,r){return r===null?{kind:`from`,source:e,cap:t,fieldPath:n.path}:z(r,{source:e,cap:t,fieldPath:n.path,kind:n.kind})}function ke(e,t,n,r){let i={addonId:e.addonId,stableId:e.stableId};return t.caps.flatMap(e=>e.fields.filter(e=>e.item!==!0).map(t=>({cap:e.cap,path:t.path,kind:t.kind,value:n===null?void 0:W(n[e.cap],t.path),source:Oe(i,e.cap,t,r)})))}function G(e,t){return t?e===void 0?`—`:e===null?`null`:typeof e==`string`||typeof e==`number`||typeof e==`boolean`?String(e):JSON.stringify(e):`…`}var K=[];function q({title:e,targetKind:t,excludeDeviceIds:n=K,onPick:r,onCancel:a}){let{t:c}=j(),[l,u]=o(null);return i(`aside`,{"aria-label":e,className:`rounded-lg border border-border bg-surface p-3 flex flex-col gap-2`,children:[s(`h3`,{className:`text-xs font-semibold`,children:e}),l===null?s(Ae,{excludeDeviceIds:n,onSelect:u}):s(je,{device:l,targetKind:t,onPick:r,onBack:()=>u(null)}),s(`div`,{children:s(_,{variant:`ghost`,onClick:a,children:c(`customize.picker.cancel`)})})]})}function Ae({excludeDeviceIds:e,onSelect:t}){let{t:n}=j(),[r,c]=o(``),l=b({projection:`slim`});return i(a,{children:[i(`label`,{className:`flex flex-col gap-1 text-[11px]`,children:[n(`customize.picker.search`),s(`input`,{type:`search`,"aria-label":n(`customize.picker.search`),className:`px-1.5 py-0.5 text-[11px] bg-background border border-border rounded`,value:r,onChange:e=>c(e.target.value)})]}),l.status===`pending`&&s(`p`,{role:`status`,className:`text-[11px] text-foreground-subtle`,children:n(`customize.picker.loadingDevices`)}),l.status===`error`&&s(h,{title:n(`customize.picker.devicesFailed`),message:l.error?.message??``}),l.status===`success`&&s(`ul`,{className:`flex flex-col gap-1`,children:De(U(l.data),r,e).map(e=>s(`li`,{children:i(`button`,{type:`button`,className:`text-left text-[11px] hover:underline`,onClick:()=>t(e),children:[e.name,` `,i(`span`,{className:`text-foreground-subtle`,children:[`· `,e.stableId]})]})},e.id))})]})}function je({device:e,targetKind:t,onPick:n,onBack:r}){let{t:a}=j(),o=m({deviceId:e.id}),c=v({deviceId:e.id});if(o.status===`pending`)return s(`p`,{role:`status`,className:`text-[11px] text-foreground-subtle`,children:a(`customize.picker.loadingFields`)});if(o.status===`error`)return s(h,{title:a(`customize.picker.fieldsFailed`),message:o.error?.message??``});let l=ke(e,o.data,c.status===`success`?c.data:null,t),u=l.filter(e=>e.source===null).length,d={addonId:e.addonId,stableId:e.stableId};return i(`div`,{className:`flex flex-col gap-1`,children:[i(`button`,{type:`button`,className:`text-left text-[11px] text-primary`,onClick:r,children:[`← `,e.name]}),c.status===`error`&&s(`p`,{role:`alert`,className:`text-[10px] text-warning`,children:a(`customize.picker.valuesFailed`,{reason:c.error?.message??``})}),s(`ul`,{role:`listbox`,"aria-label":a(`customize.picker.fields`),className:`flex flex-col gap-1`,children:l.map(t=>{let r=t.source;if(r===null)return null;let a=()=>n({device:e,ref:d,cap:t.cap,path:t.path,kind:t.kind,source:r,value:t.value});return i(`li`,{role:`option`,"aria-selected":!1,tabIndex:0,className:`flex justify-between gap-2 text-[11px] cursor-pointer hover:bg-surface-hover rounded px-1`,onClick:a,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&a()},children:[i(`span`,{className:`font-mono`,children:[t.cap,`.`,t.path]}),s(`span`,{children:G(t.value,c.status===`success`)})]},`${t.cap}.${t.path}`)})}),u>0&&t!==null&&s(`p`,{className:`text-[10px] text-foreground-subtle`,children:a(`customize.picker.hidden`,{count:u,kind:a(`customize.kinds.${t}`)})})]})}var J=`integration`;function Y(e,t){switch(e.kind){case`from`:{let n=T(e.source);return`${t.get(n)??n} · ${e.cap}.${e.fieldPath}`}case`expression`:return e.expr;case`code`:return`code`}}function Me(e,t){if(e.kind===`unreachable`)return{kind:`unknown`,reason:e.error};if(e.state===null)return{kind:`unknown`,reason:`the composer has not reported this customization yet`};let n=e.state.fields.find(t);return n===void 0?{kind:`unknown`,reason:`the composer reports no value for this field`}:n.state===`unavailable`?{kind:`unavailable`,reason:n.reason??`unavailable`}:{kind:`value`,value:n.value,staleReason:n.state===`stale`?n.reason??`stale`:null}}function X(e,t,n,r){return{key:`${e.feature.cap}.${t}`,cap:e.feature.cap,field:t,origin:`composed`,mode:e.mode,from:Y(n,e.input.sourceNames),value:e.enabled?Me(e.input.state,r):{kind:`off`}}}function Ne(e){let t=e.feature.cap;return Object.entries(e.feature.fields).map(([n,r])=>X(e,n,r,e=>e.cap===t&&e.path===n&&e.item===void 0))}function Pe(e){let t=e.feature.cap;return Object.entries(e.feature.items??{}).flatMap(([n,r])=>Object.entries(r.fields).map(([r,i])=>X(e,ie(re,n,r),i,e=>e.cap===t&&e.path===r&&e.item?.arrayPath===`items`&&e.item.key===n)))}function Fe(e,t,n){if(e===null)return{kind:`unknown`,reason:`the device state could not be read`};let r=W(e[t],n),i=r===void 0?void 0:S(r);return i===void 0?{kind:`unknown`,reason:`not reported`}:{kind:`value`,value:i,staleReason:null}}function Ie(e){if(e.mode!==`replace`)return[];let t=e.feature.cap,n=new Set(Object.keys(e.feature.fields));return(e.input.nativeFields.get(t)??[]).filter(e=>!n.has(e)).map(n=>({key:`${t}.${n}`,cap:t,field:n,origin:`native`,mode:e.mode,from:J,value:Fe(e.input.snapshot,t,n)}))}function Le(e){return e.composition.features.flatMap(t=>{if(t.kind!==`fields`)return[];let n={feature:t,mode:e.nativeCaps.has(t.cap)?`replace`:`add`,enabled:ae(t),input:e};return[...Ne(n),...Pe(n),...Ie(n)]})}var Re={min:`min(a, b, …)`,max:`max(a, b, …)`,abs:`abs(x)`,floor:`floor(x)`,ceil:`ceil(x)`,sqrt:`sqrt(x)`,round:`round(x, digits?)`,pow:`pow(x, y)`,clamp:`clamp(x, lo, hi)`,avg:`avg(a, b, …)`,sum:`sum(a, b, …)`,coalesce:`coalesce(a, b, …)`,age:`age(now, ts)`,convert:`convert(x, "from", "to")`,any:`any(a, b, …)`,all:`all(a, b, …)`,within:`within(ts, ms)`,number:`number(x)`,latest:`latest(ts, …)`,rose:`rose(level, changedAt, debounceMs?)`,count:`count(x)`},Z=/[A-Za-z_][A-Za-z0-9_]*$/;function ze(e,t,n){let r=Z.exec(e.slice(0,t))?.[0]??``;if(r===``)return[];let i=n.filter(e=>e.startsWith(r)).toSorted().map(e=>({kind:`binding`,label:e,insert:e,hintKey:null})),a=`now`.startsWith(r)?[{kind:`now`,label:`now`,insert:`now`,hintKey:`compositionEditor.now`}]:[],o=[...ne].filter(e=>e.startsWith(r)).toSorted().map(e=>({kind:`builtin`,label:Re[e]??e,insert:`${e}(`,hintKey:`compositionEditor.builtins.${e}`}));return[...i,...a,...o].slice(0,8)}function Be(e,t,n){let r=t-(Z.exec(e.slice(0,t))?.[0]??``).length;return{text:`${e.slice(0,r)}${n.insert}${e.slice(t)}`,cursor:r+n.insert.length}}r();function Ve({label:e,value:t,bindings:r,onChange:a}){let{t:c}=j(),l=n(null),[u,d]=o(t.length),f=ze(t,u,r);return i(`div`,{className:`flex flex-col gap-1`,children:[i(`label`,{className:`flex flex-col gap-1 text-[11px]`,children:[e,s(`input`,{ref:l,className:`font-mono px-1.5 py-0.5 text-[11px] bg-background border border-border rounded`,value:t,onChange:e=>{a(e.target.value),d(e.target.selectionStart??e.target.value.length)},onSelect:e=>d(e.currentTarget.selectionStart??t.length)})]}),f.length>0&&s(`ul`,{role:`listbox`,"aria-label":c(`compositionEditor.suggestions`),className:`rounded border border-border bg-surface text-[11px]`,children:f.map(e=>i(`li`,{role:`option`,"aria-selected":!1,tabIndex:0,className:`flex justify-between gap-2 px-1 cursor-pointer hover:bg-surface-hover`,onClick:()=>{let n=Be(t,u,e);a(n.text),d(n.cursor),l.current?.focus()},children:[s(`span`,{className:`font-mono`,children:e.label}),e.hintKey!==null&&s(`span`,{className:`text-foreground-subtle`,children:c(e.hintKey)})]},`${e.kind}:${e.label}`))})]})}function He(e,t,n){if(e.kind===`code`)return{kind:`unavailable`,reason:`code fields arrive in slice 4`};if(e.kind===`expression`&&(O(e.expr,`rose`)||O(e.expr,`count`)))return{kind:`runtime-only`};let r=k(e).filter(e=>t.get(E(e.source,e.cap))?.kind!==`value`).map(te);if(r.length>0)return{kind:`waiting`,missing:r};let i=se({source:e,now:n,read:e=>{let n=t.get(E(e.source,e.cap)),r=n?.kind===`value`?W(n.slice,e.fieldPath):void 0,i=r===void 0?void 0:S(r);return i===void 0?{state:`unavailable`,reason:`${e.cap}.${e.fieldPath} is not reported`,fatal:!1}:{state:`fresh`,value:i}}});return i.state===`unavailable`?{kind:`unavailable`,reason:i.reason}:{kind:`value`,value:i.value,stale:i.reason}}r();function Ue({sliceKey:e,deviceId:t,capName:n,onReading:r}){let i=g(l().trpcClient,t,n);return c(()=>{r(e,i===void 0?{kind:`pending`}:{kind:`value`,slice:i})},[e,i,r]),null}function We(e,t){return[...new Map(k(e).map(e=>[E(e.source,e.cap),e]))].map(([e,n])=>({key:e,read:n,device:t.get(T(n.source))}))}function Ge({source:e}){let{t:n}=j(),r=b({projection:`slim`}),[a,c]=o(new Map),l=t((e,t)=>{c(n=>new Map([...n,[e,t]]))},[]),u=We(e,P(r.status===`success`?U(r.data):[])),d=r.status===`success`?u.filter(e=>e.device===void 0).map(e=>T(e.read.source)):[];return i(`div`,{className:`flex flex-wrap items-center gap-2 text-[11px]`,children:[u.map(e=>e.device===void 0?null:s(Ue,{sliceKey:e.key,deviceId:e.device.id,capName:e.read.cap,onReading:l},e.key)),s(`span`,{className:`text-foreground-subtle`,children:n(`compositionEditor.preview.label`)}),r.status===`error`?s(`span`,{className:`text-warning`,children:n(`compositionEditor.preview.devicesFailed`,{reason:r.error?.message??``})}):d.length>0?s(`span`,{className:`text-warning`,children:n(`compositionEditor.preview.unknownDevice`,{sources:d.join(`, `)})}):s(Ke,{preview:He(e,a,Date.now())})]})}function Ke({preview:e}){let{t}=j();switch(e.kind){case`value`:return i(`strong`,{children:[`→ `,G(e.value,!0),e.stale===null?``:` (${e.stale})`]});case`unavailable`:return s(`span`,{className:`text-warning`,children:e.reason});case`waiting`:return s(`span`,{className:`text-foreground-subtle`,children:t(`compositionEditor.preview.waiting`,{sources:e.missing.join(`, `)})});case`runtime-only`:return s(`span`,{className:`text-foreground-subtle`,children:t(`compositionEditor.preview.runtimeOnly`)})}}r();function qe({path:e,kind:t,required:n,source:r,onSet:c,onClear:l,sourceNames:u}){let{t:d}=j(),[f,p]=o(`idle`),m=r?.kind===`expression`?r:null;return i(`div`,{className:`flex flex-col gap-1 rounded border border-border p-2`,children:[i(`div`,{className:`flex flex-wrap items-center gap-2`,children:[s(`span`,{className:`font-mono text-[11px]`,children:e}),i(`span`,{className:`text-[10px] text-foreground-subtle`,children:[d(`customize.kinds.${t}`),n?` · ${d(`compositionEditor.required`)}`:``]}),s(_,{size:`sm`,variant:`outline`,onClick:()=>p(`take`),children:d(`compositionEditor.takeFrom`)}),s(_,{size:`sm`,variant:`outline`,"aria-pressed":m!==null,onClick:()=>c(m??{kind:`expression`,expr:`null`,bindings:{}}),children:d(`compositionEditor.formula`)}),r!==void 0&&s(_,{size:`sm`,variant:`ghost`,onClick:l,children:d(`compositionEditor.clear`)})]}),r?.kind===`from`&&s(`span`,{className:`text-[11px]`,children:Y(r,u)}),m!==null&&i(a,{children:[s(Ve,{label:d(`compositionEditor.formulaFor`,{path:e}),value:m.expr,bindings:Object.keys(m.bindings),onChange:e=>c({...m,expr:e})}),s(`ul`,{className:`text-[11px] flex flex-col gap-0.5`,children:Object.entries(m.bindings).map(([e,t])=>i(`li`,{className:`flex gap-2`,children:[s(`span`,{className:`font-mono`,children:e}),s(`span`,{children:t.kind===`from`?Y(t,u):JSON.stringify(t.value)})]},e))}),s(_,{size:`sm`,variant:`ghost`,onClick:()=>p(`add-binding`),children:d(`compositionEditor.addSource`)})]}),f!==`idle`&&s(q,{title:d(f===`take`?`compositionEditor.takeFrom`:`compositionEditor.addSource`),targetKind:f===`take`?t:null,onCancel:()=>p(`idle`),onPick:e=>{if(f===`take`)c(e.source);else if(m!==null){let t=me(Object.keys(m.bindings));c({...m,bindings:{...m.bindings,[t]:{kind:`from`,source:e.ref,cap:e.cap,fieldPath:e.path}}})}p(`idle`)}}),r!==void 0&&s(Ge,{source:r})]})}r();function Q(e){return e===null||e.kind===`known`?null:e}function Je({draft:e,deviceType:t,nativeCaps:n,targetFields:r,dispatch:c}){let{t:l}=j(),u=f({deviceType:t}),d=b({projection:`slim`}),p=new Map([...P(d.status===`success`?U(d.data):[])].map(([e,t])=>[e,t.name])),[m,h]=o(null),g=Q(n)??Q(r),v=n?.kind===`known`?n.value:new Set,x=new Set(e.features.map(e=>e.cap)),S=u.status===`success`?u.data.caps.filter(e=>!x.has(e.cap)&&!v.has(e.cap)):[],C=[...v].filter(e=>!x.has(e)),w=e=>v.has(e)?((r?.kind===`known`?r.value.caps.find(t=>t.cap===e):void 0)?.fields??[]).filter(e=>e.item!==!0&&!e.path.includes(`.`)).map(e=>({path:e.path,kind:e.kind,required:!1})):((u.status===`success`?u.data.caps.find(t=>t.cap===e):void 0)?.fields??[]).map(e=>({path:e.path,kind:e.kind,required:e.required}));return g===null?i(a,{children:[i(`section`,{"aria-labelledby":`editor-features`,className:`flex flex-col gap-2`,children:[s(`h2`,{id:`editor-features`,className:`text-sm font-semibold`,children:l(`compositionEditor.steps.features`)}),u.status===`pending`&&s(`p`,{role:`status`,className:`text-[11px] text-foreground-subtle`,children:l(`customize.presets.checking`)}),u.status===`error`&&s(`p`,{role:`alert`,className:`text-[11px] text-warning`,children:l(`customize.presets.unknown`,{reason:u.error?.message??``})}),i(`div`,{className:`flex flex-wrap gap-1`,children:[e.features.map(e=>i(`span`,{className:`flex items-center gap-1 rounded border border-border px-1.5 text-[11px]`,children:[e.cap,s(y,{variant:v.has(e.cap)?`default`:`info`,children:v.has(e.cap)?l(`compositionEditor.replaces`):l(`customize.fields.added`)}),s(`button`,{type:`button`,"aria-label":l(`compositionEditor.removeFeature`,{cap:e.cap}),onClick:()=>c({type:`remove-feature`,cap:e.cap}),children:`×`})]},e.cap)),S.map(e=>i(_,{size:`sm`,variant:`outline`,onClick:()=>c({type:`add-feature`,cap:e.cap}),children:[`+ `,e.cap]},e.cap)),C.map(e=>s(_,{size:`sm`,variant:`ghost`,onClick:()=>c({type:`add-feature`,cap:e}),children:l(`compositionEditor.replaceIn`,{cap:e})},e))]})]}),e.features.map(e=>i(`section`,{"aria-label":l(`compositionEditor.steps.fieldsOf`,{cap:e.cap}),className:`flex flex-col gap-2`,children:[i(`div`,{className:`flex items-center justify-between`,children:[s(`h2`,{className:`text-sm font-semibold`,children:l(`compositionEditor.steps.fieldsOf`,{cap:e.cap})}),s(_,{size:`sm`,variant:`outline`,onClick:()=>h(e.cap),children:l(`compositionEditor.copyFeature`)})]}),m===e.cap&&s(q,{title:l(`compositionEditor.copyFeature`),targetKind:null,onCancel:()=>h(null),onPick:t=>{c({type:`copy-feature`,cap:e.cap,from:t.ref,sourceCap:t.cap,paths:w(e.cap).map(e=>e.path)}),h(null)}}),w(e.cap).map(t=>s(qe,{path:t.path,kind:t.kind,required:t.required,source:e.fields[t.path],onSet:n=>c({type:`set-field`,cap:e.cap,path:t.path,source:n}),onClear:()=>c({type:`clear-field`,cap:e.cap,path:t.path}),sourceNames:p},t.path))]},e.cap))]}):i(`section`,{"aria-labelledby":`editor-features`,className:`flex flex-col gap-2`,children:[s(`h2`,{id:`editor-features`,className:`text-sm font-semibold`,children:l(`compositionEditor.steps.features`)}),s(`p`,{role:`status`,className:`text-[11px] text-foreground-subtle`,children:g.kind===`unknown`?g.reason:l(`customize.fields.reading`)})]})}var $=`px-1.5 py-0.5 text-[11px] bg-background border border-border rounded`;function Ye({draft:e,targetName:t,dispatch:n}){let{t:r}=j(),a=e.target;return i(`section`,{"aria-labelledby":`editor-target`,className:`flex flex-col gap-2`,children:[s(`h2`,{id:`editor-target`,className:`text-sm font-semibold`,children:r(`compositionEditor.steps.target`)}),a.kind===`existing`?s(`p`,{className:`text-[11px]`,children:r(`compositionEditor.existingTarget`,{name:t??`${a.device.addonId}/${a.device.stableId}`})}):i(`div`,{className:`grid grid-cols-3 gap-2`,children:[i(`label`,{className:`flex flex-col gap-1 text-[11px]`,children:[r(`customize.identity.type`),s(`select`,{className:$,value:a.type,onChange:e=>{let t=Object.values(C).find(t=>t===e.target.value);t!==void 0&&n({type:`set-new-type`,deviceType:t})},children:Object.values(C).map(e=>s(`option`,{value:e,children:d(e).label},e))})]}),i(`label`,{className:`flex flex-col gap-1 text-[11px]`,children:[r(`customize.identity.role`),i(`select`,{className:$,value:a.role??``,onChange:e=>n({type:`set-new-role`,role:Object.values(A).find(t=>t===e.target.value)??null}),children:[s(`option`,{value:``,children:r(`customize.identity.noRole`)}),Object.values(A).map(e=>s(`option`,{value:e,children:u(e).label},e))]})]}),i(`label`,{className:`flex flex-col gap-1 text-[11px]`,children:[r(`compositionEditor.name`),s(`input`,{className:$,value:e.name,onChange:e=>n({type:`set-name`,name:e.target.value})})]})]})]})}r();function Xe({draft:e,blockId:t,saving:n,onSave:r,onCancel:a}){let{t:l}=j(),u=p(),d=pe(e),f=d.ok?JSON.stringify(d.composition):``,[m,h]=o({key:``,state:{kind:`checking`}});c(()=>{if(!d.ok)return;let e=d.composition,n=setTimeout(()=>{u.mutateAsync({composition:e,...t===null?{}:{blockId:t}}).then(e=>h({key:f,state:e.ok?{kind:`ok`}:{kind:`refused`,problems:e.problems}})).catch(e=>h({key:f,state:{kind:`unknown`,reason:e instanceof Error?e.message:String(e)}}))},500);return()=>clearTimeout(n)},[f,t]);let g=d.ok?m.key===f?m.state:{kind:`checking`}:{kind:`invalid-draft`,problems:d.problems};return i(`section`,{"aria-labelledby":`editor-verify`,className:`flex flex-col gap-2`,children:[s(`h2`,{id:`editor-verify`,className:`text-sm font-semibold`,children:l(`compositionEditor.steps.verify`)}),g.kind===`checking`&&s(`p`,{role:`status`,className:`text-[11px] text-foreground-subtle`,children:l(`compositionEditor.verify.checking`)}),g.kind===`ok`&&s(`p`,{className:`text-[11px] text-success`,children:l(`compositionEditor.verify.ok`)}),g.kind===`unknown`&&s(`p`,{role:`alert`,className:`text-[11px] text-warning`,children:l(`compositionEditor.verify.unknown`,{reason:g.reason})}),(g.kind===`invalid-draft`||g.kind===`refused`)&&s(`ul`,{role:`alert`,className:`flex flex-col gap-1 text-[11px] text-danger`,children:g.kind===`invalid-draft`?g.problems.map(e=>s(`li`,{children:e},e)):g.problems.map(e=>i(`li`,{children:[s(`span`,{className:`font-mono`,children:e.path}),` — `,e.message]},`${e.path}:${e.code}`))}),i(`div`,{className:`flex gap-2`,children:[s(_,{variant:`ghost`,onClick:a,children:l(`compositionEditor.cancel`)}),s(_,{disabled:g.kind!==`ok`||n||!d.ok,onClick:()=>d.ok&&r(d.composition),children:l(`compositionEditor.save`)})]})]})}r();function Ze({initial:t,blockId:n,deviceType:r,targetName:a=null,nativeCaps:c,targetFields:l,save:u,onCancel:d}){let[f,p]=e(fe,t),[m,h]=o(!1),[g,_]=o(null),v=f.target.kind===`new`?f.target.type:r,y=async e=>{h(!0);let t=await u(e,f.name);h(!1),_(t.kind===`refused`?t.reason:null)};return i(`div`,{className:`flex flex-col gap-4`,children:[s(Ye,{draft:f,targetName:a,dispatch:p}),s(Je,{draft:f,deviceType:v,nativeCaps:c,targetFields:l,dispatch:p}),s(Xe,{draft:f,blockId:n,saving:m,onSave:e=>void y(e),onCancel:d}),g!==null&&s(`p`,{role:`alert`,className:`text-[11px] text-danger break-words`,children:g})]})}export{he as C,ce as D,le as E,P as S,ue as T,F as _,G as a,ge as b,H as c,be as d,Ce as f,Se as g,Ee as h,q as i,V as l,ye as m,J as n,W as o,we as p,Le as r,U as s,Ze as t,xe as u,ve as v,N as w,_e as x,R as y};
1
+ import{G as e,I as t,K as n,Q as r,S as i,b as a,q as o,x as s,z as c}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{at as l}from"./player-overlays-gbZ2vznV.js";import{B as u,H as d,Rr as f,Vr as p,_i as m,an as h,c as g,cn as _,qi as v,tn as y,vi as b}from"./src-DxdTI837.js";import{An as x,On as S,Sn as C,Tt as w,_n as T,dn as ee,gn as E,hn as te,jn as D,kn as ne,ln as re,mn as ie,on as O,pn as ae,un as oe,vn as k,wt as se,xn as A}from"./src-4fqKwwai.js";import{l as j}from"./index-xBLZKqTX.js";r();function ce(e){return{target:{kind:`new`,type:e},name:``,features:[]}}function le(e){return{target:{kind:`existing`,device:e},name:``,features:[]}}function ue(e,t){return{target:e.target,name:t,features:e.features.flatMap(e=>e.kind===`fields`?[e]:[])}}function M(e,t,n){return{...e,features:e.features.map(e=>e.cap===t?n(e):e)}}function de(e,t){return Object.fromEntries(Object.entries(e).filter(([e])=>e!==t))}function fe(e,t){switch(t.type){case`set-new-type`:return e.target.kind===`new`?{...e,target:{...e.target,type:t.deviceType}}:e;case`set-new-role`:{if(e.target.kind!==`new`)return e;let{role:n,...r}=e.target;return{...e,target:t.role===null?r:{...r,role:t.role}}}case`set-name`:return{...e,name:t.name};case`add-feature`:return e.features.some(e=>e.cap===t.cap)?e:{...e,features:[...e.features,{kind:`fields`,cap:t.cap,fields:{}}]};case`remove-feature`:return{...e,features:e.features.filter(e=>e.cap!==t.cap)};case`set-field`:return M(e,t.cap,e=>({...e,fields:{...e.fields,[t.path]:t.source}}));case`clear-field`:return M(e,t.cap,e=>({...e,fields:de(e.fields,t.path)}));case`copy-feature`:return M(e,t.cap,e=>({...e,fields:{...e.fields,...Object.fromEntries(t.paths.map(e=>[e,{kind:`from`,source:t.from,cap:t.sourceCap,fieldPath:e}]))}}))}}function pe(e){let t=ee.safeParse({target:e.target,features:e.features});return t.success?{ok:!0,composition:t.data}:{ok:!1,problems:t.error.issues.map(e=>`${e.path.join(`.`)||`composition`}: ${e.message}`)}}function me(e){for(let t=1;;t++){let n=`s${t}`;if(!e.includes(n))return n}}function N(e){return{addonId:e.addonId,stableId:e.stableId}}function P(e){return new Map(e.map(e=>[T(N(e)),e]))}function he(e,t,n){return e.filter(e=>e.id!==n&&e.type!==C.Container&&t.includes(e.id)).toSorted((e,t)=>e.name.localeCompare(t.name))}function ge(e,t,n){let r=e?.features??[],i=r.findIndex(e=>e.cap===n.cap);return{target:e?.target??{kind:`existing`,device:t},features:i===-1?[...r,n]:r.map((e,t)=>t===i?n:e)}}function _e(e,t){let n=e.features.filter(e=>e.cap!==t);return n.length===0?null:{target:e.target,features:n}}function F(e,t){let n=e?.features.find(e=>e.cap===t);return n!==void 0&&n.kind===`fields`?n:null}function I(e){return Array.isArray(e)?e.map(I):typeof e!=`object`||!e?e:Object.fromEntries(Object.entries(e).toSorted(([e],[t])=>e.localeCompare(t)).map(([e,t])=>[e,I(t)]))}function L(e){return JSON.stringify(I(e))}function R(e,t){return L(e)===L(t)}function ve(e,t){switch(e.kind){case`pending`:return{kind:`refused`,reason:`the customization has not been read yet — try again`};case`unknown`:return{kind:`refused`,reason:`the customization could not be read: ${e.reason}`};case`not-loaded`:return{kind:`refused`,reason:`the customizations are not loaded yet: ${e.reason}`};case`none`:return t===null?{kind:`noop`}:{kind:`create`,input:{enabled:!0,composition:t}};case`present`:{let n=e.view.block.id;return t===null?{kind:`delete`,blockId:n}:L(t)===L(e.composition)?{kind:`noop`}:{kind:`update`,blockId:n,expectedUpdatedAt:e.view.block.updatedAt,composition:t}}}}function z(e,t){let n=e===`enum`?`string`:e,r=t.kind===`enum`?`string`:t.kind,i={source:t.source,cap:t.cap,fieldPath:t.fieldPath};return r===n?{kind:`from`,...i}:n===`number`&&r===`string`?{kind:`expression`,expr:`number(x)`,bindings:{x:{kind:`from`,...i}}}:null}function B(e){return{kind:`expression`,expr:e,bindings:{}}}function V(e){let t=z(`number`,e.percentage);return t===null?null:{kind:`fields`,cap:`battery`,fields:e.mode===`replace`?{percentage:t}:{percentage:t,charging:B(`"unknown"`),sleeping:B(`false`),lastUpdated:B(`now`)}}}var H=x.filter(e=>e!==`switch`&&e!==`motion`);function ye(e){let t=D[e.cap];return t===void 0||!H.includes(e.cap)?null:{kind:`fields`,cap:e.cap,fields:{[t]:{kind:`expression`,expr:`!v`,bindings:{v:{kind:`from`,source:e.self,cap:e.cap,fieldPath:t}}}}}}function be(e){return e.from===e.to||!w(e.from,e.to)?null:{kind:`fields`,cap:e.cap,fields:{[e.fieldPath]:{kind:`expression`,expr:`convert(v, ${JSON.stringify(e.from)}, ${JSON.stringify(e.to)})`,bindings:{v:{kind:`from`,source:e.self,cap:e.cap,fieldPath:e.fieldPath}}},...e.unitField===null?{}:{[e.unitField]:B(JSON.stringify(e.to))}}}}function xe(e,t){let n=z(`number`,t.remaining);if(n===null||!oe.test(t.key)||t.label.trim()===``)return null;let r={label:t.label.trim(),fields:{"remaining.value":n,"remaining.unit":B(JSON.stringify(t.unit))}};return{kind:`fields`,cap:`consumables`,...e?.enabled===void 0?{}:{enabled:e.enabled},fields:e?.fields??{lastChangedAt:B(`now`),lastFetchedAt:B(`now`)},items:{...e?.items,[t.key]:r}}}function Se(e){return e.toLowerCase().normalize(`NFD`).replace(/[\u0300-\u036f]/g,``).replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``).slice(0,48)}function Ce(e){let t=e.fields.lastPressedAt;if(t===void 0||t.kind!==`expression`)return[];let n=Object.entries(t.bindings).filter(([e])=>e.startsWith(`active`)).flatMap(([,e])=>e.kind===`from`?[e.source]:[]);return[...new Map(n.map(e=>[T(e),e])).values()]}function we(e){let t=e.fields.lastPressedAt;if(t===void 0||t.kind!==`expression`)return[];let n=t.bindings;return Object.entries(n).flatMap(([e,t])=>{if(!e.startsWith(`active`)||t.kind!==`from`)return[];let r=n[`changed${e.slice(6)}`];return r===void 0||r.kind!==`from`?[]:[{source:t.source,cap:t.cap,activeField:t.fieldPath,changedAtField:r.fieldPath}]})}function Te(e){if(e===void 0)return null;if(e.kind===`from`){let{kind:t,...n}=e;return{...n,kind:`number`}}if(e.kind!==`expression`||e.expr!==`number(x)`)return null;let t=e.bindings.x;if(t===void 0||t.kind!==`from`||Object.keys(e.bindings).length!==1)return null;let{kind:n,...r}=t;return{...r,kind:`string`}}function Ee(e,t){let n=Te(e.fields.percentage);if(n===null)return!1;let r=V({percentage:n,mode:t}),{enabled:i,...a}=e;return r!==null&&R(a,r)}function U(e){return e.map(e=>({id:e.id,name:e.name,addonId:e.addonId,stableId:e.stableId,location:e.location,type:e.type}))}function De(e,t,n){let r=t.trim().toLowerCase();return r===``?[]:e.filter(e=>!n.includes(e.id)&&[e.name,e.stableId,e.location??``].some(e=>e.toLowerCase().includes(r))).toSorted((e,t)=>e.name.localeCompare(t.name)).slice(0,20)}function W(e,t){let n=e;for(let e of t.split(`.`)){if(typeof n!=`object`||!n||Array.isArray(n))return;n=Object.getOwnPropertyDescriptor(n,e)?.value}return n}function Oe(e,t,n,r){return r===null?{kind:`from`,source:e,cap:t,fieldPath:n.path}:z(r,{source:e,cap:t,fieldPath:n.path,kind:n.kind})}function ke(e,t,n,r){let i={addonId:e.addonId,stableId:e.stableId};return t.caps.flatMap(e=>e.fields.filter(e=>e.item!==!0).map(t=>({cap:e.cap,path:t.path,kind:t.kind,value:n===null?void 0:W(n[e.cap],t.path),source:Oe(i,e.cap,t,r)})))}function G(e,t){return t?e===void 0?`—`:e===null?`null`:typeof e==`string`||typeof e==`number`||typeof e==`boolean`?String(e):JSON.stringify(e):`…`}var K=[];function q({title:e,targetKind:t,excludeDeviceIds:n=K,onPick:r,onCancel:a}){let{t:c}=j(),[l,u]=o(null);return i(`aside`,{"aria-label":e,className:`rounded-lg border border-border bg-surface p-3 flex flex-col gap-2`,children:[s(`h3`,{className:`text-xs font-semibold`,children:e}),l===null?s(Ae,{excludeDeviceIds:n,onSelect:u}):s(je,{device:l,targetKind:t,onPick:r,onBack:()=>u(null)}),s(`div`,{children:s(_,{variant:`ghost`,onClick:a,children:c(`customize.picker.cancel`)})})]})}function Ae({excludeDeviceIds:e,onSelect:t}){let{t:n}=j(),[r,c]=o(``),l=b({projection:`slim`});return i(a,{children:[i(`label`,{className:`flex flex-col gap-1 text-[11px]`,children:[n(`customize.picker.search`),s(`input`,{type:`search`,"aria-label":n(`customize.picker.search`),className:`px-1.5 py-0.5 text-[11px] bg-background border border-border rounded`,value:r,onChange:e=>c(e.target.value)})]}),l.status===`pending`&&s(`p`,{role:`status`,className:`text-[11px] text-foreground-subtle`,children:n(`customize.picker.loadingDevices`)}),l.status===`error`&&s(h,{title:n(`customize.picker.devicesFailed`),message:l.error?.message??``}),l.status===`success`&&s(`ul`,{className:`flex flex-col gap-1`,children:De(U(l.data),r,e).map(e=>s(`li`,{children:i(`button`,{type:`button`,className:`text-left text-[11px] hover:underline`,onClick:()=>t(e),children:[e.name,` `,i(`span`,{className:`text-foreground-subtle`,children:[`· `,e.stableId]})]})},e.id))})]})}function je({device:e,targetKind:t,onPick:n,onBack:r}){let{t:a}=j(),o=m({deviceId:e.id}),c=v({deviceId:e.id});if(o.status===`pending`)return s(`p`,{role:`status`,className:`text-[11px] text-foreground-subtle`,children:a(`customize.picker.loadingFields`)});if(o.status===`error`)return s(h,{title:a(`customize.picker.fieldsFailed`),message:o.error?.message??``});let l=ke(e,o.data,c.status===`success`?c.data:null,t),u=l.filter(e=>e.source===null).length,d={addonId:e.addonId,stableId:e.stableId};return i(`div`,{className:`flex flex-col gap-1`,children:[i(`button`,{type:`button`,className:`text-left text-[11px] text-primary`,onClick:r,children:[`← `,e.name]}),c.status===`error`&&s(`p`,{role:`alert`,className:`text-[10px] text-warning`,children:a(`customize.picker.valuesFailed`,{reason:c.error?.message??``})}),s(`ul`,{role:`listbox`,"aria-label":a(`customize.picker.fields`),className:`flex flex-col gap-1`,children:l.map(t=>{let r=t.source;if(r===null)return null;let a=()=>n({device:e,ref:d,cap:t.cap,path:t.path,kind:t.kind,source:r,value:t.value});return i(`li`,{role:`option`,"aria-selected":!1,tabIndex:0,className:`flex justify-between gap-2 text-[11px] cursor-pointer hover:bg-surface-hover rounded px-1`,onClick:a,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&a()},children:[i(`span`,{className:`font-mono`,children:[t.cap,`.`,t.path]}),s(`span`,{children:G(t.value,c.status===`success`)})]},`${t.cap}.${t.path}`)})}),u>0&&t!==null&&s(`p`,{className:`text-[10px] text-foreground-subtle`,children:a(`customize.picker.hidden`,{count:u,kind:a(`customize.kinds.${t}`)})})]})}var J=`integration`;function Y(e,t){switch(e.kind){case`from`:{let n=T(e.source);return`${t.get(n)??n} · ${e.cap}.${e.fieldPath}`}case`expression`:return e.expr;case`code`:return`code`}}function Me(e,t){if(e.kind===`unreachable`)return{kind:`unknown`,reason:e.error};if(e.state===null)return{kind:`unknown`,reason:`the composer has not reported this customization yet`};let n=e.state.fields.find(t);return n===void 0?{kind:`unknown`,reason:`the composer reports no value for this field`}:n.state===`unavailable`?{kind:`unavailable`,reason:n.reason??`unavailable`}:{kind:`value`,value:n.value,staleReason:n.state===`stale`?n.reason??`stale`:null}}function X(e,t,n,r){return{key:`${e.feature.cap}.${t}`,cap:e.feature.cap,field:t,origin:`composed`,mode:e.mode,from:Y(n,e.input.sourceNames),value:e.enabled?Me(e.input.state,r):{kind:`off`}}}function Ne(e){let t=e.feature.cap;return Object.entries(e.feature.fields).map(([n,r])=>X(e,n,r,e=>e.cap===t&&e.path===n&&e.item===void 0))}function Pe(e){let t=e.feature.cap;return Object.entries(e.feature.items??{}).flatMap(([n,r])=>Object.entries(r.fields).map(([r,i])=>X(e,ie(re,n,r),i,e=>e.cap===t&&e.path===r&&e.item?.arrayPath===`items`&&e.item.key===n)))}function Fe(e,t,n){if(e===null)return{kind:`unknown`,reason:`the device state could not be read`};let r=W(e[t],n),i=r===void 0?void 0:S(r);return i===void 0?{kind:`unknown`,reason:`not reported`}:{kind:`value`,value:i,staleReason:null}}function Ie(e){if(e.mode!==`replace`)return[];let t=e.feature.cap,n=new Set(Object.keys(e.feature.fields));return(e.input.nativeFields.get(t)??[]).filter(e=>!n.has(e)).map(n=>({key:`${t}.${n}`,cap:t,field:n,origin:`native`,mode:e.mode,from:J,value:Fe(e.input.snapshot,t,n)}))}function Le(e){return e.composition.features.flatMap(t=>{if(t.kind!==`fields`)return[];let n={feature:t,mode:e.nativeCaps.has(t.cap)?`replace`:`add`,enabled:ae(t),input:e};return[...Ne(n),...Pe(n),...Ie(n)]})}var Re={min:`min(a, b, …)`,max:`max(a, b, …)`,abs:`abs(x)`,floor:`floor(x)`,ceil:`ceil(x)`,sqrt:`sqrt(x)`,round:`round(x, digits?)`,pow:`pow(x, y)`,clamp:`clamp(x, lo, hi)`,avg:`avg(a, b, …)`,sum:`sum(a, b, …)`,coalesce:`coalesce(a, b, …)`,age:`age(now, ts)`,convert:`convert(x, "from", "to")`,any:`any(a, b, …)`,all:`all(a, b, …)`,within:`within(ts, ms)`,number:`number(x)`,latest:`latest(ts, …)`,rose:`rose(level, changedAt, debounceMs?)`,count:`count(x)`},Z=/[A-Za-z_][A-Za-z0-9_]*$/;function ze(e,t,n){let r=Z.exec(e.slice(0,t))?.[0]??``;if(r===``)return[];let i=n.filter(e=>e.startsWith(r)).toSorted().map(e=>({kind:`binding`,label:e,insert:e,hintKey:null})),a=`now`.startsWith(r)?[{kind:`now`,label:`now`,insert:`now`,hintKey:`compositionEditor.now`}]:[],o=[...ne].filter(e=>e.startsWith(r)).toSorted().map(e=>({kind:`builtin`,label:Re[e]??e,insert:`${e}(`,hintKey:`compositionEditor.builtins.${e}`}));return[...i,...a,...o].slice(0,8)}function Be(e,t,n){let r=t-(Z.exec(e.slice(0,t))?.[0]??``).length;return{text:`${e.slice(0,r)}${n.insert}${e.slice(t)}`,cursor:r+n.insert.length}}r();function Ve({label:e,value:t,bindings:r,onChange:a}){let{t:c}=j(),l=n(null),[u,d]=o(t.length),f=ze(t,u,r);return i(`div`,{className:`flex flex-col gap-1`,children:[i(`label`,{className:`flex flex-col gap-1 text-[11px]`,children:[e,s(`input`,{ref:l,className:`font-mono px-1.5 py-0.5 text-[11px] bg-background border border-border rounded`,value:t,onChange:e=>{a(e.target.value),d(e.target.selectionStart??e.target.value.length)},onSelect:e=>d(e.currentTarget.selectionStart??t.length)})]}),f.length>0&&s(`ul`,{role:`listbox`,"aria-label":c(`compositionEditor.suggestions`),className:`rounded border border-border bg-surface text-[11px]`,children:f.map(e=>i(`li`,{role:`option`,"aria-selected":!1,tabIndex:0,className:`flex justify-between gap-2 px-1 cursor-pointer hover:bg-surface-hover`,onClick:()=>{let n=Be(t,u,e);a(n.text),d(n.cursor),l.current?.focus()},children:[s(`span`,{className:`font-mono`,children:e.label}),e.hintKey!==null&&s(`span`,{className:`text-foreground-subtle`,children:c(e.hintKey)})]},`${e.kind}:${e.label}`))})]})}function He(e,t,n){if(e.kind===`code`)return{kind:`unavailable`,reason:`code fields arrive in slice 4`};if(e.kind===`expression`&&(O(e.expr,`rose`)||O(e.expr,`count`)))return{kind:`runtime-only`};let r=k(e).filter(e=>t.get(E(e.source,e.cap))?.kind!==`value`).map(te);if(r.length>0)return{kind:`waiting`,missing:r};let i=se({source:e,now:n,read:e=>{let n=t.get(E(e.source,e.cap)),r=n?.kind===`value`?W(n.slice,e.fieldPath):void 0,i=r===void 0?void 0:S(r);return i===void 0?{state:`unavailable`,reason:`${e.cap}.${e.fieldPath} is not reported`,fatal:!1}:{state:`fresh`,value:i}}});return i.state===`unavailable`?{kind:`unavailable`,reason:i.reason}:{kind:`value`,value:i.value,stale:i.reason}}r();function Ue({sliceKey:e,deviceId:t,capName:n,onReading:r}){let i=g(l().trpcClient,t,n);return c(()=>{r(e,i===void 0?{kind:`pending`}:{kind:`value`,slice:i})},[e,i,r]),null}function We(e,t){return[...new Map(k(e).map(e=>[E(e.source,e.cap),e]))].map(([e,n])=>({key:e,read:n,device:t.get(T(n.source))}))}function Ge({source:e}){let{t:n}=j(),r=b({projection:`slim`}),[a,c]=o(new Map),l=t((e,t)=>{c(n=>new Map([...n,[e,t]]))},[]),u=We(e,P(r.status===`success`?U(r.data):[])),d=r.status===`success`?u.filter(e=>e.device===void 0).map(e=>T(e.read.source)):[];return i(`div`,{className:`flex flex-wrap items-center gap-2 text-[11px]`,children:[u.map(e=>e.device===void 0?null:s(Ue,{sliceKey:e.key,deviceId:e.device.id,capName:e.read.cap,onReading:l},e.key)),s(`span`,{className:`text-foreground-subtle`,children:n(`compositionEditor.preview.label`)}),r.status===`error`?s(`span`,{className:`text-warning`,children:n(`compositionEditor.preview.devicesFailed`,{reason:r.error?.message??``})}):d.length>0?s(`span`,{className:`text-warning`,children:n(`compositionEditor.preview.unknownDevice`,{sources:d.join(`, `)})}):s(Ke,{preview:He(e,a,Date.now())})]})}function Ke({preview:e}){let{t}=j();switch(e.kind){case`value`:return i(`strong`,{children:[`→ `,G(e.value,!0),e.stale===null?``:` (${e.stale})`]});case`unavailable`:return s(`span`,{className:`text-warning`,children:e.reason});case`waiting`:return s(`span`,{className:`text-foreground-subtle`,children:t(`compositionEditor.preview.waiting`,{sources:e.missing.join(`, `)})});case`runtime-only`:return s(`span`,{className:`text-foreground-subtle`,children:t(`compositionEditor.preview.runtimeOnly`)})}}r();function qe({path:e,kind:t,required:n,source:r,onSet:c,onClear:l,sourceNames:u}){let{t:d}=j(),[f,p]=o(`idle`),m=r?.kind===`expression`?r:null;return i(`div`,{className:`flex flex-col gap-1 rounded border border-border p-2`,children:[i(`div`,{className:`flex flex-wrap items-center gap-2`,children:[s(`span`,{className:`font-mono text-[11px]`,children:e}),i(`span`,{className:`text-[10px] text-foreground-subtle`,children:[d(`customize.kinds.${t}`),n?` · ${d(`compositionEditor.required`)}`:``]}),s(_,{size:`sm`,variant:`outline`,onClick:()=>p(`take`),children:d(`compositionEditor.takeFrom`)}),s(_,{size:`sm`,variant:`outline`,"aria-pressed":m!==null,onClick:()=>c(m??{kind:`expression`,expr:`null`,bindings:{}}),children:d(`compositionEditor.formula`)}),r!==void 0&&s(_,{size:`sm`,variant:`ghost`,onClick:l,children:d(`compositionEditor.clear`)})]}),r?.kind===`from`&&s(`span`,{className:`text-[11px]`,children:Y(r,u)}),m!==null&&i(a,{children:[s(Ve,{label:d(`compositionEditor.formulaFor`,{path:e}),value:m.expr,bindings:Object.keys(m.bindings),onChange:e=>c({...m,expr:e})}),s(`ul`,{className:`text-[11px] flex flex-col gap-0.5`,children:Object.entries(m.bindings).map(([e,t])=>i(`li`,{className:`flex gap-2`,children:[s(`span`,{className:`font-mono`,children:e}),s(`span`,{children:t.kind===`from`?Y(t,u):JSON.stringify(t.value)})]},e))}),s(_,{size:`sm`,variant:`ghost`,onClick:()=>p(`add-binding`),children:d(`compositionEditor.addSource`)})]}),f!==`idle`&&s(q,{title:d(f===`take`?`compositionEditor.takeFrom`:`compositionEditor.addSource`),targetKind:f===`take`?t:null,onCancel:()=>p(`idle`),onPick:e=>{if(f===`take`)c(e.source);else if(m!==null){let t=me(Object.keys(m.bindings));c({...m,bindings:{...m.bindings,[t]:{kind:`from`,source:e.ref,cap:e.cap,fieldPath:e.path}}})}p(`idle`)}}),r!==void 0&&s(Ge,{source:r})]})}r();function Q(e){return e===null||e.kind===`known`?null:e}function Je({draft:e,deviceType:t,nativeCaps:n,targetFields:r,dispatch:c}){let{t:l}=j(),u=f({deviceType:t}),d=b({projection:`slim`}),p=new Map([...P(d.status===`success`?U(d.data):[])].map(([e,t])=>[e,t.name])),[m,h]=o(null),g=Q(n)??Q(r),v=n?.kind===`known`?n.value:new Set,x=new Set(e.features.map(e=>e.cap)),S=u.status===`success`?u.data.caps.filter(e=>!x.has(e.cap)&&!v.has(e.cap)):[],C=[...v].filter(e=>!x.has(e)),w=e=>v.has(e)?((r?.kind===`known`?r.value.caps.find(t=>t.cap===e):void 0)?.fields??[]).filter(e=>e.item!==!0&&!e.path.includes(`.`)).map(e=>({path:e.path,kind:e.kind,required:!1})):((u.status===`success`?u.data.caps.find(t=>t.cap===e):void 0)?.fields??[]).map(e=>({path:e.path,kind:e.kind,required:e.required}));return g===null?i(a,{children:[i(`section`,{"aria-labelledby":`editor-features`,className:`flex flex-col gap-2`,children:[s(`h2`,{id:`editor-features`,className:`text-sm font-semibold`,children:l(`compositionEditor.steps.features`)}),u.status===`pending`&&s(`p`,{role:`status`,className:`text-[11px] text-foreground-subtle`,children:l(`customize.presets.checking`)}),u.status===`error`&&s(`p`,{role:`alert`,className:`text-[11px] text-warning`,children:l(`customize.presets.unknown`,{reason:u.error?.message??``})}),i(`div`,{className:`flex flex-wrap gap-1`,children:[e.features.map(e=>i(`span`,{className:`flex items-center gap-1 rounded border border-border px-1.5 text-[11px]`,children:[e.cap,s(y,{variant:v.has(e.cap)?`default`:`info`,children:v.has(e.cap)?l(`compositionEditor.replaces`):l(`customize.fields.added`)}),s(`button`,{type:`button`,"aria-label":l(`compositionEditor.removeFeature`,{cap:e.cap}),onClick:()=>c({type:`remove-feature`,cap:e.cap}),children:`×`})]},e.cap)),S.map(e=>i(_,{size:`sm`,variant:`outline`,onClick:()=>c({type:`add-feature`,cap:e.cap}),children:[`+ `,e.cap]},e.cap)),C.map(e=>s(_,{size:`sm`,variant:`ghost`,onClick:()=>c({type:`add-feature`,cap:e}),children:l(`compositionEditor.replaceIn`,{cap:e})},e))]})]}),e.features.map(e=>i(`section`,{"aria-label":l(`compositionEditor.steps.fieldsOf`,{cap:e.cap}),className:`flex flex-col gap-2`,children:[i(`div`,{className:`flex items-center justify-between`,children:[s(`h2`,{className:`text-sm font-semibold`,children:l(`compositionEditor.steps.fieldsOf`,{cap:e.cap})}),s(_,{size:`sm`,variant:`outline`,onClick:()=>h(e.cap),children:l(`compositionEditor.copyFeature`)})]}),m===e.cap&&s(q,{title:l(`compositionEditor.copyFeature`),targetKind:null,onCancel:()=>h(null),onPick:t=>{c({type:`copy-feature`,cap:e.cap,from:t.ref,sourceCap:t.cap,paths:w(e.cap).map(e=>e.path)}),h(null)}}),w(e.cap).map(t=>s(qe,{path:t.path,kind:t.kind,required:t.required,source:e.fields[t.path],onSet:n=>c({type:`set-field`,cap:e.cap,path:t.path,source:n}),onClear:()=>c({type:`clear-field`,cap:e.cap,path:t.path}),sourceNames:p},t.path))]},e.cap))]}):i(`section`,{"aria-labelledby":`editor-features`,className:`flex flex-col gap-2`,children:[s(`h2`,{id:`editor-features`,className:`text-sm font-semibold`,children:l(`compositionEditor.steps.features`)}),s(`p`,{role:`status`,className:`text-[11px] text-foreground-subtle`,children:g.kind===`unknown`?g.reason:l(`customize.fields.reading`)})]})}var $=`px-1.5 py-0.5 text-[11px] bg-background border border-border rounded`;function Ye({draft:e,targetName:t,dispatch:n}){let{t:r}=j(),a=e.target;return i(`section`,{"aria-labelledby":`editor-target`,className:`flex flex-col gap-2`,children:[s(`h2`,{id:`editor-target`,className:`text-sm font-semibold`,children:r(`compositionEditor.steps.target`)}),a.kind===`existing`?s(`p`,{className:`text-[11px]`,children:r(`compositionEditor.existingTarget`,{name:t??`${a.device.addonId}/${a.device.stableId}`})}):i(`div`,{className:`grid grid-cols-3 gap-2`,children:[i(`label`,{className:`flex flex-col gap-1 text-[11px]`,children:[r(`customize.identity.type`),s(`select`,{className:$,value:a.type,onChange:e=>{let t=Object.values(C).find(t=>t===e.target.value);t!==void 0&&n({type:`set-new-type`,deviceType:t})},children:Object.values(C).map(e=>s(`option`,{value:e,children:d(e).label},e))})]}),i(`label`,{className:`flex flex-col gap-1 text-[11px]`,children:[r(`customize.identity.role`),i(`select`,{className:$,value:a.role??``,onChange:e=>n({type:`set-new-role`,role:Object.values(A).find(t=>t===e.target.value)??null}),children:[s(`option`,{value:``,children:r(`customize.identity.noRole`)}),Object.values(A).map(e=>s(`option`,{value:e,children:u(e).label},e))]})]}),i(`label`,{className:`flex flex-col gap-1 text-[11px]`,children:[r(`compositionEditor.name`),s(`input`,{className:$,value:e.name,onChange:e=>n({type:`set-name`,name:e.target.value})})]})]})]})}r();function Xe({draft:e,blockId:t,saving:n,onSave:r,onCancel:a}){let{t:l}=j(),u=p(),d=pe(e),f=d.ok?JSON.stringify(d.composition):``,[m,h]=o({key:``,state:{kind:`checking`}});c(()=>{if(!d.ok)return;let e=d.composition,n=setTimeout(()=>{u.mutateAsync({composition:e,...t===null?{}:{blockId:t}}).then(e=>h({key:f,state:e.ok?{kind:`ok`}:{kind:`refused`,problems:e.problems}})).catch(e=>h({key:f,state:{kind:`unknown`,reason:e instanceof Error?e.message:String(e)}}))},500);return()=>clearTimeout(n)},[f,t]);let g=d.ok?m.key===f?m.state:{kind:`checking`}:{kind:`invalid-draft`,problems:d.problems};return i(`section`,{"aria-labelledby":`editor-verify`,className:`flex flex-col gap-2`,children:[s(`h2`,{id:`editor-verify`,className:`text-sm font-semibold`,children:l(`compositionEditor.steps.verify`)}),g.kind===`checking`&&s(`p`,{role:`status`,className:`text-[11px] text-foreground-subtle`,children:l(`compositionEditor.verify.checking`)}),g.kind===`ok`&&s(`p`,{className:`text-[11px] text-success`,children:l(`compositionEditor.verify.ok`)}),g.kind===`unknown`&&s(`p`,{role:`alert`,className:`text-[11px] text-warning`,children:l(`compositionEditor.verify.unknown`,{reason:g.reason})}),(g.kind===`invalid-draft`||g.kind===`refused`)&&s(`ul`,{role:`alert`,className:`flex flex-col gap-1 text-[11px] text-danger`,children:g.kind===`invalid-draft`?g.problems.map(e=>s(`li`,{children:e},e)):g.problems.map(e=>i(`li`,{children:[s(`span`,{className:`font-mono`,children:e.path}),` — `,e.message]},`${e.path}:${e.code}`))}),i(`div`,{className:`flex gap-2`,children:[s(_,{variant:`ghost`,onClick:a,children:l(`compositionEditor.cancel`)}),s(_,{disabled:g.kind!==`ok`||n||!d.ok,onClick:()=>d.ok&&r(d.composition),children:l(`compositionEditor.save`)})]})]})}r();function Ze({initial:t,blockId:n,deviceType:r,targetName:a=null,nativeCaps:c,targetFields:l,save:u,onCancel:d}){let[f,p]=e(fe,t),[m,h]=o(!1),[g,_]=o(null),v=f.target.kind===`new`?f.target.type:r,y=async e=>{h(!0);let t=await u(e,f.name);h(!1),_(t.kind===`refused`?t.reason:null)};return i(`div`,{className:`flex flex-col gap-4`,children:[s(Ye,{draft:f,targetName:a,dispatch:p}),s(Je,{draft:f,deviceType:v,nativeCaps:c,targetFields:l,dispatch:p}),s(Xe,{draft:f,blockId:n,saving:m,onSave:e=>void y(e),onCancel:d}),g!==null&&s(`p`,{role:`alert`,className:`text-[11px] text-danger break-words`,children:g})]})}export{he as C,ce as D,le as E,P as S,ue as T,F as _,G as a,ge as b,H as c,be as d,Ce as f,Se as g,Ee as h,q as i,V as l,ye as m,J as n,W as o,we as p,Le as r,U as s,Ze as t,xe as u,ve as v,N as w,_e as x,R as y};
@@ -1 +1 @@
1
- import{x as e}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{Br as t,Ir as n,Pr as r,an as i}from"./src-BqkvLgRS.js";import{t as a}from"./boxes-CNe0g7jU.js";import{Sn as o,an as s}from"./src-4fqKwwai.js";import{a as c,d as l,f as u,l as d,o as f,p}from"./index-DrF3b0h3.js";import{t as m}from"./AdminPage-CiKtOLQm.js";import{D as h,T as g,t as _}from"./CompositionEditor-Bu6ufcCG.js";var v=`new`;function y(e){return e instanceof Error?e.message:String(e)}function b(e){let t=e.trim();return t===``?{}:{name:t}}function x(){let{blockId:x}=p(),{t:S}=d(),C=u(),w=r(),T=t(),E=x===void 0||x===v,D=n({blockId:x??``},{enabled:!E}),O=t=>e(m,{icon:a,title:S(`compositionEditor.pageTitle`),children:t});if(E)return O(e(_,{initial:h(o.Sensor),blockId:null,deviceType:o.Sensor,nativeCaps:null,targetFields:null,onCancel:()=>C(-1),save:async(e,t)=>{try{let{block:n}=await w.mutateAsync({block:{...b(t),enabled:!0,composition:e}});return C(c(n.id),{replace:!0}),{kind:`saved`}}catch(e){return{kind:`refused`,reason:y(e)}}}}));if(D.status===`pending`)return O(e(`p`,{role:`status`,children:S(`compositionEditor.loading`)}));if(D.status===`error`)return O(e(i,{title:S(`compositionEditor.loadFailed`),message:D.error.message}));if(D.data.state===`not-loaded`)return O(e(`p`,{role:`status`,children:S(`customize.status.notLoaded`,{reason:D.data.reason})}));let k=D.data.view;if(k===null)return O(e(`p`,{children:S(`compositionEditor.notFound`,{blockId:x})}));let A=s(k.block);if(A===null)return O(e(`p`,{children:S(`compositionEditor.notComposition`)}));if(A.target.kind===`existing`){let t=k.state.kind===`answered`?k.state.state?.deviceId??null:null;return O(t===null?e(`p`,{children:S(`compositionEditor.customizationUnknownDevice`)}):e(l,{className:`text-primary`,to:f(t),children:S(`compositionEditor.openOnDevice`)}))}return O(e(_,{initial:g(A,k.block.name),blockId:k.block.id,deviceType:A.target.type,nativeCaps:null,targetFields:null,onCancel:()=>C(-1),save:async(e,t)=>{try{return await T.mutateAsync({blockId:k.block.id,expectedUpdatedAt:k.block.updatedAt,block:{...b(t),composition:e}}),await D.refetch(),{kind:`saved`}}catch(e){return{kind:`refused`,reason:y(e)}}}},`${k.block.id}@${k.block.updatedAt}`))}export{x as CompositionEditorPage};
1
+ import{x as e}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{Br as t,Ir as n,Pr as r,an as i}from"./src-DxdTI837.js";import{t as a}from"./boxes-CNe0g7jU.js";import{Sn as o,an as s}from"./src-4fqKwwai.js";import{a as c,d as l,f as u,l as d,o as f,p}from"./index-xBLZKqTX.js";import{t as m}from"./AdminPage-CiKtOLQm.js";import{D as h,T as g,t as _}from"./CompositionEditor-BVDKw1Gg.js";var v=`new`;function y(e){return e instanceof Error?e.message:String(e)}function b(e){let t=e.trim();return t===``?{}:{name:t}}function x(){let{blockId:x}=p(),{t:S}=d(),C=u(),w=r(),T=t(),E=x===void 0||x===v,D=n({blockId:x??``},{enabled:!E}),O=t=>e(m,{icon:a,title:S(`compositionEditor.pageTitle`),children:t});if(E)return O(e(_,{initial:h(o.Sensor),blockId:null,deviceType:o.Sensor,nativeCaps:null,targetFields:null,onCancel:()=>C(-1),save:async(e,t)=>{try{let{block:n}=await w.mutateAsync({block:{...b(t),enabled:!0,composition:e}});return C(c(n.id),{replace:!0}),{kind:`saved`}}catch(e){return{kind:`refused`,reason:y(e)}}}}));if(D.status===`pending`)return O(e(`p`,{role:`status`,children:S(`compositionEditor.loading`)}));if(D.status===`error`)return O(e(i,{title:S(`compositionEditor.loadFailed`),message:D.error.message}));if(D.data.state===`not-loaded`)return O(e(`p`,{role:`status`,children:S(`customize.status.notLoaded`,{reason:D.data.reason})}));let k=D.data.view;if(k===null)return O(e(`p`,{children:S(`compositionEditor.notFound`,{blockId:x})}));let A=s(k.block);if(A===null)return O(e(`p`,{children:S(`compositionEditor.notComposition`)}));if(A.target.kind===`existing`){let t=k.state.kind===`answered`?k.state.state?.deviceId??null:null;return O(t===null?e(`p`,{children:S(`compositionEditor.customizationUnknownDevice`)}):e(l,{className:`text-primary`,to:f(t),children:S(`compositionEditor.openOnDevice`)}))}return O(e(_,{initial:g(A,k.block.name),blockId:k.block.id,deviceType:A.target.type,nativeCaps:null,targetFields:null,onCancel:()=>C(-1),save:async(e,t)=>{try{return await T.mutateAsync({blockId:k.block.id,expectedUpdatedAt:k.block.updatedAt,block:{...b(t),composition:e}}),await D.refetch(),{kind:`saved`}}catch(e){return{kind:`refused`,reason:y(e)}}}},`${k.block.id}@${k.block.updatedAt}`))}export{x as CompositionEditorPage};
@@ -1 +1 @@
1
- import{I as e,Q as t,S as n,W as r,b as i,o as a,q as o,x as s,z as c}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{Z as l,_t as u,gt as d,st as f,yt as p}from"./player-overlays-gbZ2vznV.js";import{Cr as m,Cs as h,Cu as g,Fl as _,Fs as v,Gc as y,Hl as b,Is as x,Iu as S,Ls as C,Mu as w,Ps as T,Sr as E,Ul as D,Wl as O,Xn as k,Xs as A,_r as j,br as M,ed as N,fr as P,gr as F,hr as ee,ju as te,mr as ne,nd as re,nu as I,pr as ie,rd as ae,uu as oe,vr as se,xr as ce,yn as L,yr as R}from"./src-BqkvLgRS.js";import{t as z}from"./archive-BUE32U7F.js";import{t as B}from"./circle-slash-fCLxXnZu.js";import{a as V,c as H,l as U,n as W,o as G,s as le,t as ue,u as de}from"./location-owned-usage-bz1tVRVt.js";import{t as fe}from"./hard-drive-download-BwgF6zZo.js";import"./index-DrF3b0h3.js";import{t as K}from"./AdminPage-CiKtOLQm.js";import{n as pe}from"./authed-media-MbHpXS-m.js";import{t as me}from"./AdminTabs-CDIoD5NP.js";import{t as q}from"./format-size-DIxKXxtj.js";var he=p(`calendar-clock`,[[`path`,{d:`M16 14v2.2l1.6 1`,key:`fo4ql5`}],[`path`,{d:`M16 2v4`,key:`4m81vk`}],[`path`,{d:`M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5`,key:`1osxxc`}],[`path`,{d:`M3 10h5`,key:`r794hk`}],[`path`,{d:`M8 2v4`,key:`1cmpym`}],[`circle`,{cx:`16`,cy:`16`,r:`6`,key:`qoo3c4`}]]),ge=p(`cloud-upload`,[[`path`,{d:`M12 13v8`,key:`1l5pq0`}],[`path`,{d:`M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242`,key:`1pljnt`}],[`path`,{d:`m8 17 4-4 4 4`,key:`1quai1`}]]);t();function _e(){let e=a(),t=L(),{data:i,isLoading:c,isError:l}=C({}),u=x(),d=r(()=>u.data??[],[u.data]),{data:f}=h({},{refetchOnWindowFocus:!1}),p=r(()=>ue(i??[],f?.locations),[i,f?.locations]),{data:m}=v({},{refetchOnWindowFocus:!1}),g=r(()=>V(m),[m]),[_,y]=o(null),[b,S]=o(null),w=T({onSuccess:()=>{e.invalidateQueries({queryKey:[[`storage`,`listLocations`]]})}}),E=A({onSuccess:()=>{e.invalidateQueries({queryKey:[[`storage`,`listLocations`]]})}}),D=async(e,n)=>{U(n)&&!await t({title:`Disable "${e.displayName}"?`,message:`${H(n).consequence}\n\nNothing is deleted — set the location back to Read-only or Active to bring its footage back.`,confirmLabel:`Disable`,variant:`danger`})||E.mutate(le(e,{mode:n}))},O=async e=>{if(await t({title:`Delete location "${e.displayName}"?`,message:`This removes the location record. Files on disk are not deleted; the underlying directory or remote path stays untouched.`,confirmLabel:`Delete`,variant:`danger`}))try{await w.mutateAsync({id:e.id})}catch(n){await t({title:`Delete anyway?`,message:`${n instanceof Error?n.message:String(n)}\n\nForcing the delete removes the record only. Anything still on that location becomes unreachable — index rows naming it stop resolving, and playback of those segments goes silently black rather than erroring.`,confirmLabel:`Force delete`,variant:`danger`})&&w.mutate({id:e.id,force:!0})}},k=r(()=>{let e=new Map;for(let t of i??[]){let n=e.get(t.type);n?n.push(t):e.set(t.type,[t])}return e},[i]),j=c||u.isLoading,M=l||u.isError;return n(K,{children:[j&&s(`div`,{className:`text-xs text-foreground-subtle animate-pulse`,children:`Loading locations…`}),M&&s(`div`,{className:`text-xs text-danger`,children:`Failed to load storage locations.`}),!j&&!M&&n(`div`,{className:`space-y-3`,children:[d.length===0&&s(`div`,{className:`rounded-lg border border-border bg-surface px-3 py-4 text-center text-[11px] text-foreground-subtle italic`,children:`No storage locations declared by any installed addon.`}),d.map(e=>s(W,{type:e.id,displayName:e.displayName,description:e.description,cardinality:e.cardinality,locations:k.get(e.id)??[],onAdd:e=>y(e),onEdit:e=>S(e),onDelete:e=>{O(e)},ownedBytesById:p,drainById:g,onSetMode:(e,t)=>{D(e,t)}},e.id))]}),_!==null&&s(de,{initialType:_,onClose:()=>y(null),onCreated:()=>{e.invalidateQueries({queryKey:[[`storage`,`listLocations`]]}),y(null)}}),b!==null&&s(G,{location:b,onClose:()=>S(null),onSaved:()=>{e.invalidateQueries({queryKey:[[`storage`,`listLocations`]]}),S(null)}})]})}t();var ve=[[`backup`,`listDestinations`]],ye=[`backup`,`listArchives`];function be({destinationId:t,restoreSupported:i,onOpenRestoreWizard:c}){let l=a(),u=L(),{data:d,isLoading:p,isError:m}=F({destinationId:t}),h=d??[],v=ie({onSuccess:()=>{l.invalidateQueries({queryKey:[[...ye]]}),l.invalidateQueries({queryKey:ve})}}),y=e(async e=>{await u({title:`Delete this archive?`,message:`Permanently deletes "${e.label??e.id}" and frees ${q(e.sizeBytes)}.`,confirmLabel:`Delete`,variant:`danger`})&&v.mutate({destinationId:t,backupId:e.id})},[u,t,v]),[b,x]=o(null),S=e(async e=>{x(e.id);try{let n=await pe(xe(t,e.id)),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`${e.label??e.id}.tar.gz`,document.body.appendChild(i),i.click(),i.remove(),URL.revokeObjectURL(r)}finally{x(null)}},[t]),C=r(()=>[...h].toSorted((e,t)=>t.createdAt-e.createdAt),[h]);return p?s(`div`,{className:`text-xs text-foreground-subtle animate-pulse py-2`,children:`Loading archives…`}):m?s(`div`,{className:`text-xs text-danger py-2`,children:`Failed to read manifest for this destination`}):C.length===0?s(`div`,{className:`text-xs text-foreground-subtle italic py-2`,children:`No archives at this destination yet.`}):s(`div`,{className:`rounded border border-border bg-surface overflow-x-auto`,children:n(`table`,{className:`w-full text-xs min-w-[640px]`,children:[s(`thead`,{children:n(`tr`,{className:`text-foreground-subtle bg-background/30`,children:[s(`th`,{className:`text-left px-3 py-1.5 font-medium`,children:`When`}),s(`th`,{className:`text-left px-3 py-1.5 font-medium`,children:`Label`}),s(`th`,{className:`text-left px-3 py-1.5 font-medium`,children:`Includes`}),s(`th`,{className:`text-right px-3 py-1.5 font-medium`,children:`Size`}),s(`th`,{className:`text-right px-3 py-1.5 font-medium w-52`,children:`Actions`})]})}),s(`tbody`,{children:C.map(e=>n(`tr`,{className:`border-t border-border hover:bg-primary/5`,children:[s(`td`,{className:`px-3 py-1.5 text-foreground tabular-nums`,children:Se(e.createdAt)}),s(`td`,{className:`px-3 py-1.5 text-foreground`,children:e.label??s(`span`,{className:`text-foreground-subtle italic`,children:`—`})}),s(`td`,{className:`px-3 py-1.5 text-foreground-subtle`,children:e.locations.join(`, `)}),s(`td`,{className:`px-3 py-1.5 text-foreground text-right tabular-nums`,children:q(e.sizeBytes)}),s(`td`,{className:`px-3 py-1.5`,children:n(`div`,{className:`flex items-center justify-end gap-1`,children:[n(`button`,{onClick:()=>{S(e)},disabled:b===e.id,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-foreground-subtle hover:text-foreground hover:bg-primary/10 disabled:opacity-50`,title:`Download archive`,children:[b===e.id?s(I,{className:`h-3 w-3 animate-spin`}):s(g,{className:`h-3 w-3`}),`Download`]}),i&&c&&n(`button`,{onClick:()=>c({destinationId:t,archiveId:e.id}),className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-primary hover:bg-primary/10`,title:`Restore from this archive`,children:[s(_,{className:`h-3 w-3`}),`Restore`]}),s(`button`,{onClick:()=>{y(e)},disabled:v.isPending,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-danger hover:bg-danger/10 disabled:opacity-50`,title:`Delete archive`,children:v.isPending?s(I,{className:`h-3 w-3 animate-spin`}):s(f,{className:`h-3 w-3`})})]})})]},e.id))})]})})}function xe(e,t){return l(`/api/backup/download/${encodeURIComponent(e)}/${encodeURIComponent(t)}`)}function Se(e){return new Date(e).toLocaleString(void 0,{day:`2-digit`,month:`short`,year:`numeric`,hour:`2-digit`,minute:`2-digit`})}t();var J=[[`backup`,`listSchedules`]];function Ce({onEdit:e,onOpenRestoreWizard:t}){let{data:i,isLoading:a,isError:c}=R(),l=i??[],u=j().data??[],d=r(()=>{let e=new Map;for(let t of u)e.set(t.id,t);return e},[u]),[f,p]=o(null),m=e=>{p(t=>t===e?null:e)};return a?s(`div`,{className:`text-xs text-foreground-subtle animate-pulse`,children:`Loading backup entries…`}):c?s(`div`,{className:`text-xs text-danger`,children:`Failed to load backup entries`}):l.length===0?s(`div`,{className:`rounded-lg border border-border bg-surface px-4 py-8 text-center`,children:s(`p`,{className:`text-xs text-foreground-subtle`,children:`No backup entries yet. Create one to schedule backups across one or more storage locations.`})}):s(`div`,{className:`rounded-lg border border-border bg-surface overflow-x-auto`,children:n(`table`,{className:`w-full text-xs min-w-[820px]`,children:[s(`thead`,{children:n(`tr`,{className:`text-foreground-subtle border-b border-border bg-background/40`,children:[s(`th`,{className:`text-left px-3 py-2 font-medium w-6`}),s(`th`,{className:`text-left px-3 py-2 font-medium`,children:`Entry`}),s(`th`,{className:`text-left px-3 py-2 font-medium w-20`,children:`Enabled`}),s(`th`,{className:`text-left px-3 py-2 font-medium`,children:`Locations`}),s(`th`,{className:`text-left px-3 py-2 font-medium w-24`,children:`Retention`}),s(`th`,{className:`text-left px-3 py-2 font-medium w-48`,children:`Schedule`}),s(`th`,{className:`text-right px-3 py-2 font-medium w-52`,children:`Actions`})]})}),s(`tbody`,{children:l.map(n=>s(we,{row:n,destById:d,isOpen:f===n.id,onToggle:()=>m(n.id),onEdit:()=>e(n),...t?{onOpenRestoreWizard:t}:{}},n.id))})]})})}function we({row:t,destById:l,isOpen:p,onToggle:h,onEdit:g,onOpenRestoreWizard:_}){let v=a(),y=L(),b=m({onSuccess:()=>{v.invalidateQueries({queryKey:J})}}),x=ne({onSuccess:()=>{v.invalidateQueries({queryKey:J})}}),S=E({onMutate:()=>{v.invalidateQueries({queryKey:[[`backup`,`listRuns`]]})},onSuccess:()=>{v.invalidateQueries({queryKey:[[`backup`,`listArchives`]]}),v.invalidateQueries({queryKey:[[`backup`,`listDestinations`]]}),v.invalidateQueries({queryKey:[[`backup`,`listRuns`]]})}}),[C,w]=o(String(t.retentionCount));c(()=>{w(String(t.retentionCount))},[t.retentionCount]);let T=r(()=>({id:t.id,label:t.label,cron:t.cron,locationIds:[...t.locationIds],retentionCount:t.retentionCount,...t.dataSources?{dataSources:[...t.dataSources]}:{}}),[t]),k=e(e=>{b.mutate({...T,enabled:e})},[b,T]),A=e(()=>{let e=Number.parseInt(C,10);if(Number.isNaN(e)||e<1){w(String(t.retentionCount));return}e!==t.retentionCount&&b.mutate({...T,enabled:t.enabled,retentionCount:e})},[b,T,C,t.retentionCount,t.enabled]),j=e(()=>{t.locationIds.length!==0&&S.mutate({destinations:[...t.locationIds],...t.dataSources&&t.dataSources.length>0?{locations:[...t.dataSources]}:{},label:t.label,retentionCount:t.retentionCount})},[S,t]),M=e(async()=>{await y({title:`Delete backup entry?`,message:`"${t.label||t.id}" will stop running. Existing archives are kept.`,confirmLabel:`Delete`,variant:`warning`})&&x.mutate({id:t.id})},[y,x,t.id,t.label]),N=t.cron.trim().length>0,P=b.isPending||x.isPending;return n(i,{children:[n(`tr`,{className:`border-t border-border first:border-t-0 hover:bg-primary/5`,children:[s(`td`,{className:`px-2 py-2`,children:s(`button`,{onClick:h,className:`inline-flex items-center justify-center rounded p-1 text-foreground-subtle hover:bg-primary/10 hover:text-foreground`,title:p?`Hide archives`:`Show archives`,children:s(p?u:d,{className:`h-3.5 w-3.5`})})}),s(`td`,{className:`px-3 py-2`,children:n(`button`,{onClick:g,className:`text-left hover:underline focus:outline-none`,children:[s(`div`,{className:`text-foreground font-medium`,children:t.label||`(unnamed)`}),t.lastRunAt!==void 0&&n(`div`,{className:`text-[10px] text-foreground-subtle mt-0.5`,children:[`last run `,new Date(t.lastRunAt).toLocaleString()]})]})}),s(`td`,{className:`px-3 py-2`,children:s(`label`,{className:`inline-flex items-center cursor-pointer`,children:s(`input`,{type:`checkbox`,className:`accent-primary`,checked:t.enabled,disabled:P,onChange:e=>k(e.target.checked)})})}),s(`td`,{className:`px-3 py-2`,children:n(`div`,{className:`flex flex-wrap gap-1`,children:[t.locationIds.length===0&&s(`span`,{className:`text-[11px] text-danger italic`,children:`No locations`}),t.locationIds.map(e=>s(`span`,{className:`inline-flex items-center rounded border border-border bg-background px-1.5 py-0.5 text-[10px] text-foreground`,title:e,children:l.get(e)?.displayName??e},e))]})}),s(`td`,{className:`px-3 py-2`,children:s(`input`,{type:`number`,min:1,max:1e3,value:C,disabled:P,onChange:e=>w(e.target.value),onBlur:A,onKeyDown:e=>{e.key===`Enter`&&e.target.blur(),e.key===`Escape`&&w(String(t.retentionCount))},className:`w-16 rounded border border-border bg-background px-2 py-1 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`})}),s(`td`,{className:`px-3 py-2`,children:n(`button`,{onClick:g,className:`group flex flex-col items-start gap-0.5 text-left`,title:`Edit schedule`,children:[n(`span`,{className:`inline-flex items-center gap-1`,children:[s(he,{className:`h-3 w-3 text-foreground-subtle group-hover:text-foreground`}),s(`span`,{className:`font-mono text-[11px] text-foreground`,children:N?t.cron:`Manual`})]}),N&&t.nextRunAt!==void 0&&n(`span`,{className:`text-[10px] text-foreground-subtle`,children:[`next `,new Date(t.nextRunAt).toLocaleString()]})]})}),s(`td`,{className:`px-3 py-2`,children:n(`div`,{className:`flex items-center justify-end gap-1.5`,children:[n(`button`,{onClick:j,disabled:S.isPending||t.locationIds.length===0,className:`inline-flex items-center gap-1 rounded bg-primary px-2 py-1 text-[11px] font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50`,title:`Run this entry now`,children:[S.isPending?s(I,{className:`h-3 w-3 animate-spin`}):s(D,{className:`h-3 w-3`}),`Run now`]}),s(`button`,{onClick:g,className:`inline-flex items-center justify-center rounded border border-border p-1 text-foreground-subtle hover:text-foreground hover:bg-primary/5`,title:`Edit entry`,children:s(O,{className:`h-3 w-3`})}),s(`button`,{onClick:()=>{M()},disabled:P,className:`inline-flex items-center justify-center rounded border border-border p-1 text-foreground-subtle hover:text-danger hover:border-danger/40 disabled:opacity-50`,title:`Delete entry`,children:s(f,{className:`h-3 w-3`})})]})})]}),p&&s(`tr`,{className:`border-t border-border bg-background/30`,children:n(`td`,{colSpan:7,className:`px-4 py-3 space-y-4`,children:[t.locationIds.length===0&&s(`p`,{className:`text-xs text-foreground-subtle italic`,children:`This entry has no locations selected.`}),t.locationIds.map(e=>n(`div`,{className:`space-y-1.5`,children:[s(`div`,{className:`text-[11px] font-medium text-foreground-subtle`,children:l.get(e)?.displayName??e}),s(be,{destinationId:e,restoreSupported:l.get(e)?.restoreSupported??!0,..._?{onOpenRestoreWizard:_}:{}})]},e))]})})]})}t();var Y=[{id:`manual`,label:`Manual only`,cron:``},{id:`hourly`,label:`Every hour`,cron:`0 * * * *`,description:`On the hour`},{id:`every-3h`,label:`Every 3 hours`,cron:`0 */3 * * *`,description:`00:00, 03:00, 06:00, 09:00 …`},{id:`every-6h`,label:`Every 6 hours`,cron:`0 */6 * * *`,description:`00:00, 06:00, 12:00, 18:00`},{id:`daily-3am`,label:`Daily at 03:00`,cron:`0 3 * * *`,description:`Every night at 3 AM`},{id:`weekly-sun`,label:`Weekly Sunday 03:00`,cron:`0 3 * * 0`,description:`Sunday morning at 3 AM`}];function Te(e){let t=e.trim();for(let e of Y)if(e.cron===t)return e.id;return`custom`}function Ee({value:e,onChange:t,previewCount:r=5,disabled:i=!1}){let a=Te(e),[l,u]=o(a===`custom`);c(()=>{a!==`custom`&&u(!1)},[a]);let d=ke(e,250),f=M({cron:d,count:r},{enabled:d.trim().length>0}),p=f.data??null,m=e=>{u(!1),t(e.cron)},h=l||a===`custom`;return n(`div`,{className:`space-y-3`,children:[n(`div`,{className:`space-y-1`,children:[s(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Schedule preset`}),n(`div`,{className:`flex flex-wrap gap-1.5`,children:[Y.map(e=>s(`button`,{type:`button`,onClick:()=>m(e),disabled:i,className:`rounded border px-2 py-1 text-[11px] transition-colors disabled:opacity-50 `+(!l&&a===e.id?`border-primary bg-primary/10 text-primary`:`border-border bg-background text-foreground-subtle hover:bg-primary/5 hover:text-foreground`),title:e.description??e.label,children:e.label},e.id)),s(`button`,{type:`button`,onClick:()=>{u(!0),e.trim().length===0&&t(`0 3 * * *`)},disabled:i,className:`rounded border px-2 py-1 text-[11px] transition-colors disabled:opacity-50 `+(h?`border-primary bg-primary/10 text-primary`:`border-border bg-background text-foreground-subtle hover:bg-primary/5 hover:text-foreground`),children:`Custom…`})]})]}),h&&n(`div`,{className:`space-y-1`,children:[s(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Cron expression (5-field POSIX)`}),s(`input`,{type:`text`,value:e,onChange:e=>t(e.target.value),disabled:i,placeholder:`0 3 * * *`,spellCheck:!1,className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs font-mono text-foreground placeholder:text-foreground-subtle focus:outline-none focus:ring-1 focus:ring-primary`}),n(`p`,{className:`text-[10px] text-foreground-subtle`,children:[`Format: `,s(`span`,{className:`font-mono`,children:`minute hour day-of-month month day-of-week`}),` · all times server-local`]})]}),s(De,{cron:d,preview:p,loading:f.isFetching})]})}function De({cron:e,preview:t,loading:r}){return r&&t===null?n(`div`,{className:`flex items-center gap-2 rounded border border-border bg-background/40 px-3 py-2 text-[11px] text-foreground-subtle`,children:[s(I,{className:`h-3 w-3 animate-spin`}),`Validating…`]}):t===null?null:t.ok?t.nextRuns.length===0?s(`div`,{className:`rounded border border-border bg-background/40 px-3 py-2 text-[11px] text-foreground-subtle`,children:`No future runs match this expression.`}):n(`div`,{className:`space-y-1`,children:[s(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Next runs`}),s(`ul`,{className:`rounded border border-border bg-background/40 divide-y divide-border`,children:t.nextRuns.map((e,t)=>n(`li`,{className:`flex items-center justify-between px-3 py-1.5 text-[11px]`,children:[s(`span`,{className:`text-foreground tabular-nums`,children:new Date(e).toLocaleString()}),s(`span`,{className:`text-foreground-subtle text-[10px] tabular-nums`,children:Oe(e)})]},`${e}-${t}`))})]}):s(`div`,{className:`rounded border border-danger/40 bg-danger/10 px-3 py-2 text-[11px] text-danger`,children:t.error??`Invalid cron expression`})}function Oe(e){let t=e-Date.now();if(t<=0)return`now`;let n=Math.floor(t/1e3);if(n<60)return`in ${n}s`;let r=Math.floor(n/60);if(r<60)return`in ${r}m`;let i=Math.floor(r/60);return i<24?`in ${i}h`:`in ${Math.floor(i/24)}d`}function ke(e,t){let[n,i]=o(e),a=r(()=>e,[e]);return c(()=>{let e=setTimeout(()=>i(a),t);return()=>clearTimeout(e)},[a,t]),n}t();var Ae=[[`backup`,`listSchedules`]];function je({entry:e,onClose:t,onSaved:i}){let c=a(),l=j(),u=l.data??[],[d,f]=o(e?.label??``),[p,h]=o(e?.cron??`0 3 * * *`),[g,_]=o(e?.enabled??!0),[v,b]=o(String(e?.retentionCount??7)),[x,S]=o(new Set(e?.locationIds??[])),C=m({onSuccess:()=>{c.invalidateQueries({queryKey:Ae}),i()}}),w=e=>{S(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},T=Number.parseInt(v,10),E=r(()=>d.trim().length>0&&x.size>0&&!Number.isNaN(T)&&T>=1&&T<=1e3,[d,x,T]),D=()=>{E&&C.mutate({...e?{id:e.id}:{},label:d.trim(),cron:p.trim(),enabled:g,locationIds:Array.from(x),retentionCount:T})},O=C.error instanceof Error?C.error.message:null;return s(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-background/80 backdrop-blur-sm`,onClick:t,children:n(`div`,{className:`w-full max-w-lg rounded-xl border border-border bg-surface shadow-2xl max-h-[90vh] overflow-y-auto`,onClick:e=>e.stopPropagation(),children:[n(`div`,{className:`flex items-start justify-between border-b border-border px-4 py-3 sticky top-0 bg-surface`,children:[s(`h2`,{className:`text-sm font-semibold text-foreground`,children:e?`Edit backup entry`:`New backup entry`}),s(`button`,{onClick:t,className:`text-foreground-subtle hover:text-foreground`,children:s(y,{className:`h-4 w-4`})})]}),n(`div`,{className:`p-4 space-y-4`,children:[n(`div`,{className:`space-y-1`,children:[s(`label`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wide`,children:`Name`}),s(`input`,{type:`text`,value:d,onChange:e=>f(e.target.value),placeholder:`Nightly offsite`,className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground placeholder:text-foreground-subtle focus:outline-none focus:ring-1 focus:ring-primary`})]}),n(`div`,{className:`space-y-1.5`,children:[n(`label`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wide`,children:[`Locations (`,x.size,` selected)`]}),l.isLoading&&n(`div`,{className:`flex items-center gap-2 px-1 py-2 text-xs text-foreground-subtle`,children:[s(I,{className:`h-3.5 w-3.5 animate-spin`}),`Loading locations…`]}),!l.isLoading&&u.length===0&&s(`div`,{className:`rounded border border-border bg-background px-3 py-2 text-xs text-foreground-subtle italic`,children:"No `backups` storage locations configured. Add one in Settings → Storage first."}),u.length>0&&s(`div`,{className:`rounded border border-border bg-background divide-y divide-border max-h-52 overflow-y-auto`,children:u.map(e=>n(`label`,{className:`flex items-center justify-between px-3 py-2 text-xs hover:bg-primary/5 cursor-pointer`,children:[n(`div`,{className:`flex items-center gap-2`,children:[s(`input`,{type:`checkbox`,checked:x.has(e.id),onChange:()=>w(e.id),className:`accent-primary`}),s(`span`,{className:`text-foreground`,children:e.displayName})]}),n(`div`,{className:`flex items-center gap-1.5`,children:[s(`span`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle bg-surface border border-border rounded px-1.5 py-0.5`,children:e.kind}),s(`span`,{className:`text-[10px] text-foreground-subtle font-mono`,children:e.id})]})]},e.id))})]}),n(`div`,{className:`grid grid-cols-2 gap-3`,children:[n(`div`,{className:`space-y-1`,children:[s(`label`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wide`,children:`Retention (archives kept)`}),s(`input`,{type:`number`,min:1,max:1e3,value:v,onChange:e=>b(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`})]}),n(`div`,{className:`space-y-1`,children:[s(`label`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wide`,children:`Enabled`}),n(`label`,{className:`inline-flex items-center gap-2 py-1.5 cursor-pointer`,children:[s(`input`,{type:`checkbox`,checked:g,onChange:e=>_(e.target.checked),className:`accent-primary`}),s(`span`,{className:`text-xs text-foreground-subtle`,children:`Run on schedule`})]})]})]}),n(`div`,{className:`space-y-1.5 border-t border-border pt-3`,children:[s(`label`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wide`,children:`Schedule`}),s(Ee,{value:p,onChange:h,disabled:C.isPending})]}),O&&s(`div`,{className:`rounded border border-danger/40 bg-danger/10 px-3 py-2 text-[11px] text-danger`,children:O})]}),n(`div`,{className:`flex justify-end gap-2 border-t border-border px-4 py-3 sticky bottom-0 bg-surface`,children:[s(`button`,{onClick:t,className:`rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground`,children:`Cancel`}),n(`button`,{onClick:D,disabled:!E||C.isPending,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:[C.isPending&&s(I,{className:`h-3.5 w-3.5 animate-spin`}),e?`Save`:`Create entry`]})]})]})})}t();var Me=2e3,Ne=5e3;function X(e){return e.state===`queued`||e.state===`running`}function Pe(e){if(e.state===`queued`)return{title:`Cancel queued backup run?`,message:`This run has not started. Cancelling removes it from the queue — nothing has been written, nothing is deleted.`,confirmLabel:`Cancel run`,variant:`warning`};let t=e.completedDestinationIds.length;return{title:`Stop this backup run?`,message:`The half-written staging archive is deleted and the destination currently uploading discards its partial copy. ${t>0?`${t===1?`The 1 destination`:`The ${t} destinations`} that already completed KEEP${t===1?`S`:``} the archive.`:`No destination has completed yet, so nothing will be kept.`}`,confirmLabel:`Stop run`,variant:`danger`}}function Fe(){let t=L(),[n,r]=o(null),i=se(void 0,{refetchInterval:e=>(e.state.data??[]).some(X)?Me:Ne}),a=P({onSettled:()=>{r(null),i.refetch()}}),c=e(async e=>{await t(Pe(e))&&(r(e.id),a.mutate({runId:e.id}))},[t,a]);return s(Ie,{queryState:i.isError?`error`:i.data===void 0?`pending`:`ready`,runs:i.data??[],cancelingId:n,onCancelRequest:e=>{c(e)},now:Date.now()})}function Ie({queryState:e,runs:t,cancelingId:r,onCancelRequest:i,now:a}){let o=e===`ready`&&t.some(X),c=t.filter(e=>e.state===`running`),l=t.filter(e=>e.state===`queued`),u=t.filter(e=>!X(e)),d=[...c,...l,...u];return n(`section`,{className:`rounded-lg border border-border bg-surface`,children:[n(`div`,{className:`flex items-center gap-2 px-3 py-2 border-b border-border`,children:[s(`h2`,{className:`text-xs font-semibold text-foreground`,children:`Runs`}),o&&n(`span`,{className:`inline-flex items-center gap-1 text-[10px] font-medium text-primary`,title:`A backup run is in progress`,children:[s(`span`,{className:`h-1.5 w-1.5 rounded-full bg-primary animate-pulse`}),`live`]}),s(`span`,{className:`ml-auto text-[10px] text-foreground-subtle`,children:`One run executes at a time — queued runs wait in line.`})]}),e===`pending`&&s(`div`,{className:`px-3 py-2.5 text-xs text-foreground-subtle animate-pulse`,children:`Checking for backup runs…`}),e===`error`&&s(`div`,{className:`px-3 py-2.5 text-xs text-danger`,children:`Could not read backup runs — the orchestrator did not answer.`}),e===`ready`&&t.length===0&&s(`div`,{className:`px-3 py-2.5 text-xs text-foreground-subtle italic`,children:`No backup runs yet. Runs appear here the moment one starts — manual or scheduled.`}),e===`ready`&&t.length>0&&s(`div`,{className:`overflow-x-auto`,children:n(`table`,{className:`w-full text-xs min-w-[720px]`,children:[s(`thead`,{children:n(`tr`,{className:`text-foreground-subtle bg-background/30`,children:[s(`th`,{className:`text-left px-3 py-1.5 font-medium`,children:`Run`}),s(`th`,{className:`text-left px-3 py-1.5 font-medium`,children:`State`}),s(`th`,{className:`text-left px-3 py-1.5 font-medium`,children:`Progress`}),s(`th`,{className:`text-left px-3 py-1.5 font-medium`,children:`Destinations`}),s(`th`,{className:`text-left px-3 py-1.5 font-medium`,children:`Timing`}),s(`th`,{className:`text-right px-3 py-1.5 font-medium w-28`,children:`Actions`})]})}),s(`tbody`,{children:d.map(e=>s(Le,{run:e,canceling:r===e.id,onCancelRequest:i,now:a},e.id))})]})})]})}function Le({run:e,canceling:t,onCancelRequest:r,now:i}){let a=X(e);return n(`tr`,{className:`border-t border-border hover:bg-primary/5 align-top`,children:[n(`td`,{className:`px-3 py-2`,children:[s(`div`,{className:`text-foreground`,children:e.label??s(`span`,{className:`text-foreground-subtle italic`,children:`manual`})}),s(`div`,{className:`text-[10px] text-foreground-subtle font-mono`,title:e.id,children:e.id.slice(0,8)})]}),n(`td`,{className:`px-3 py-2`,children:[s(Re,{run:e}),e.state===`failed`&&e.error!==void 0&&s(`div`,{className:`mt-1 text-[10px] text-danger max-w-56 truncate`,title:e.error,children:e.error})]}),s(`td`,{className:`px-3 py-2`,children:s(ze,{run:e})}),s(`td`,{className:`px-3 py-2`,children:s(Be,{run:e})}),s(`td`,{className:`px-3 py-2 text-foreground-subtle tabular-nums`,children:s(Ve,{run:e,now:i})}),s(`td`,{className:`px-3 py-2`,children:s(`div`,{className:`flex justify-end`,children:a&&n(`button`,{onClick:()=>r(e),disabled:t,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-danger hover:bg-danger/10 disabled:opacity-50`,title:e.state===`queued`?`Remove this run from the queue before it starts`:`Stop this run — the half-written archive is discarded`,children:[t?s(I,{className:`h-3 w-3 animate-spin`}):s(N,{className:`h-3 w-3`}),e.state===`queued`?`Cancel`:`Stop`]})})})]})}function Re({run:e}){switch(e.state){case`queued`:return n(`span`,{className:`inline-flex items-center gap-1 rounded bg-foreground-subtle/10 px-1.5 py-0.5 text-[10px] font-medium text-foreground-subtle`,children:[s(te,{className:`h-3 w-3`}),`Queued`]});case`running`:return n(`span`,{className:`inline-flex items-center gap-1 rounded bg-primary/10 px-1.5 py-0.5 text-[10px] font-medium text-primary`,children:[s(I,{className:`h-3 w-3 animate-spin`}),e.phase===`uploading`?`Uploading`:`Building archive`]});case`succeeded`:return n(`span`,{className:`inline-flex items-center gap-1 rounded bg-success/10 px-1.5 py-0.5 text-[10px] font-medium text-success`,children:[s(S,{className:`h-3 w-3`}),`Succeeded`]});case`failed`:return n(`span`,{className:`inline-flex items-center gap-1 rounded bg-danger/10 px-1.5 py-0.5 text-[10px] font-medium text-danger`,children:[s(w,{className:`h-3 w-3`}),`Failed`]});case`cancelled`:return n(`span`,{className:`inline-flex items-center gap-1 rounded bg-amber-500/10 px-1.5 py-0.5 text-[10px] font-medium text-amber-700 dark:text-amber-300`,title:`Stopped before completing every destination — not a success`,children:[s(B,{className:`h-3 w-3`}),`Stopped`]})}}function ze({run:e}){if(e.state===`queued`)return s(`span`,{className:`text-foreground-subtle`,children:e.queuePosition===void 0?s(`span`,{className:`italic`,children:`waiting its turn`}):n(`span`,{className:`inline-flex items-center gap-1`,children:[s(`span`,{className:e.queuePosition===1?`rounded bg-primary/10 px-1.5 py-0.5 text-[10px] font-medium text-primary`:`rounded bg-foreground-subtle/10 px-1.5 py-0.5 text-[10px] font-medium`,children:He(e.queuePosition)}),`in line`]})});if(e.state===`running`&&e.phase===`building`)return n(`span`,{className:`inline-flex items-center gap-1.5 text-foreground`,children:[s(fe,{className:`h-3 w-3 text-primary`}),s(`span`,{className:`tabular-nums font-medium animate-pulse`,children:q(e.stagedBytes)}),s(`span`,{className:`text-foreground-subtle`,children:`staged so far`})]});if(e.state===`running`){let t=e.archiveSizeBytes;return n(`span`,{className:`inline-flex items-center gap-1.5 text-foreground`,children:[s(ge,{className:`h-3 w-3 text-primary`}),n(`span`,{className:`tabular-nums font-medium`,children:[q(e.uploadedBytes),t===void 0?``:` / ${q(t)}`]}),s(`span`,{className:`text-foreground-subtle`,children:`to current destination`})]})}let t=e.archiveSizeBytes??(e.stagedBytes>0?e.stagedBytes:void 0);return t===void 0?s(`span`,{className:`text-foreground-subtle italic`,children:`—`}):n(`span`,{className:`tabular-nums text-foreground`,children:[q(t),` archive`]})}function Be({run:e}){let t=e.destinationIds.length,r=e.completedDestinationIds.length,i=e.failedDestinationIds.length;return t===0?s(`span`,{className:`text-foreground-subtle italic`,children:`not resolved yet`}):n(`div`,{className:`flex flex-col gap-0.5`,children:[n(`span`,{className:`text-foreground-subtle`,title:e.destinationIds.join(`, `),children:[t,` target`,t===1?``:`s`]}),n(`span`,{className:`inline-flex items-center gap-2 text-[10px]`,children:[r>0&&n(`span`,{className:`text-success`,title:`Kept their archive: ${e.completedDestinationIds.join(`, `)}`,children:[`✓ `,r,` completed`]}),i>0&&n(`span`,{className:`text-danger`,title:`Failed: ${e.failedDestinationIds.join(`, `)}`,children:[`✗ `,i,` failed`]})]})]})}function Ve({run:e,now:t}){return e.state===`queued`?n(`span`,{children:[`queued `,Z(t-e.requestedAt),` ago`]}):e.startedAt===void 0?s(`span`,{children:`—`}):e.finishedAt===void 0?n(`span`,{children:[`running for `,Z(t-e.startedAt)]}):n(`div`,{className:`flex flex-col gap-0.5`,children:[s(`span`,{children:Q(e.finishedAt)}),n(`span`,{className:`text-[10px]`,children:[`took `,Z(e.finishedAt-e.startedAt)]})]})}function He(e){if(e<=1)return`next`;let t=e%100;if(t>=11&&t<=13)return`${e}th`;switch(e%10){case 1:return`${e}st`;case 2:return`${e}nd`;case 3:return`${e}rd`;default:return`${e}th`}}function Z(e){let t=Math.max(0,Math.floor(e/1e3));if(t<60)return`${t}s`;let n=Math.floor(t/60);return n<60?`${n}m ${String(t%60).padStart(2,`0`)}s`:`${Math.floor(n/60)}h ${String(n%60).padStart(2,`0`)}m`}function Q(e){return new Date(e).toLocaleString(void 0,{day:`2-digit`,month:`short`,hour:`2-digit`,minute:`2-digit`})}t();var Ue=[[`backup`,`list`]];function We({initialDestinationId:e,initialArchiveId:t,onClose:i,onScheduled:l}){let u=a(),[d,f]=o(e&&t?2:1),[p,m]=o(e),[h,g]=o(t),[v,b]=o(new Set),{data:x}=j(),S=x??[],{data:C,isLoading:w}=F({destinationId:p??``},{enabled:!!p}),T=C??[];c(()=>{if(p!==void 0)return;let e=S.filter(e=>e.restoreSupported);e.length===1&&m(e[0].id)},[p,S]);let{data:E}=ee({destinationId:p??``,backupId:h??``},{enabled:!!p&&!!h}),D=r(()=>E?.locations??[],[E]);c(()=>{D.length!==0&&b(e=>e.size===0?new Set(D):e)},[D]);let O=ce({onSuccess:()=>{u.invalidateQueries({queryKey:Ue}),l(),i()}}),k=e=>{b(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},A=!!p&&!!h,M=v.size>0,N=A&&M&&!O.isPending,P=()=>{!p||!h||O.mutate({destinationId:p,backupId:h,locations:[...v]})};return s(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-background/80 backdrop-blur-sm`,onClick:i,children:n(`div`,{className:`w-full max-w-md rounded-xl border border-border bg-surface shadow-2xl`,onClick:e=>e.stopPropagation(),children:[n(`div`,{className:`flex items-start justify-between border-b border-border px-4 py-3`,children:[n(`div`,{className:`space-y-0.5`,children:[s(`h2`,{className:`text-sm font-semibold text-foreground`,children:`Restore Backup`}),n(`p`,{className:`text-xs text-foreground-subtle`,children:[`Step `,d,` of 3 —`,` `,d===1?`pick source`:d===2?`pick locations`:`confirm`]})]}),s(`button`,{onClick:i,className:`text-foreground-subtle hover:text-foreground`,children:s(y,{className:`h-4 w-4`})})]}),d===1&&s(Ge,{destinations:S,destinationId:p,onPickDestination:e=>{m(e),g(void 0),b(new Set)},archives:T,archivesLoading:w,archiveId:h,onPickArchive:g}),d===2&&s(Ke,{locations:D,picked:v,onToggle:k}),d===3&&s(qe,{destinationName:S.find(e=>e.id===p)?.displayName??p??``,archive:T.find(e=>e.id===h),picked:[...v]}),n(`div`,{className:`flex justify-between gap-2 border-t border-border px-4 py-3`,children:[s(`div`,{children:d>1&&n(`button`,{onClick:()=>f(e=>e===3?2:1),className:`inline-flex items-center gap-1 rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground`,children:[s(ae,{className:`h-3 w-3`}),`Back`]})}),n(`div`,{className:`flex items-center gap-2`,children:[s(`button`,{onClick:i,className:`rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground`,children:`Cancel`}),d<3?n(`button`,{disabled:d===1&&!A||d===2&&!M,onClick:()=>f(e=>e===1?2:3),className:`inline-flex items-center gap-1 rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50`,children:[`Next`,s(re,{className:`h-3 w-3`})]}):n(`button`,{onClick:P,disabled:!N,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:[O.isPending?s(I,{className:`h-3.5 w-3.5 animate-spin`}):s(_,{className:`h-3.5 w-3.5`}),`Schedule Restore`]})]})]})]})})}function Ge({destinations:e,destinationId:t,onPickDestination:r,archives:i,archivesLoading:a,archiveId:o,onPickArchive:c}){let l=e.filter(e=>e.restoreSupported);return n(`div`,{className:`p-4 space-y-3`,children:[n(`div`,{className:`space-y-1.5`,children:[s(`label`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wide`,children:`Destination`}),n(`select`,{value:t??``,onChange:e=>r(e.target.value),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`,children:[s(`option`,{value:``,disabled:!0,children:`Select destination…`}),l.map(e=>n(`option`,{value:e.id,children:[e.displayName,` (`,e.kind,`)`]},e.id))]})]}),n(`div`,{className:`space-y-1.5`,children:[s(`label`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wide`,children:`Archive`}),!t&&s(`div`,{className:`text-xs text-foreground-subtle italic`,children:`Pick a destination first.`}),t&&a&&s(`div`,{className:`text-xs text-foreground-subtle animate-pulse`,children:`Reading archives…`}),t&&!a&&i.length===0&&s(`div`,{className:`text-xs text-foreground-subtle italic`,children:`No archives available at this destination.`}),t&&i.length>0&&s(`div`,{className:`rounded border border-border bg-background divide-y divide-border max-h-64 overflow-y-auto`,children:i.map(e=>{let t=o===e.id;return n(`label`,{className:`flex items-center justify-between px-3 py-2 text-xs cursor-pointer ${t?`bg-primary/10`:`hover:bg-primary/5`}`,children:[n(`div`,{className:`flex items-center gap-2`,children:[s(`input`,{type:`radio`,name:`archive`,checked:t,onChange:()=>c(e.id),className:`accent-primary`}),n(`div`,{children:[s(`div`,{className:`font-medium text-foreground`,children:e.label??e.id}),s(`div`,{className:`text-[10px] text-foreground-subtle`,children:new Date(e.createdAt).toLocaleString()})]})]}),s(`span`,{className:`text-[10px] text-foreground-subtle tabular-nums`,children:q(e.sizeBytes)})]},e.id)})})]})]})}function Ke({locations:e,picked:t,onToggle:r}){return e.length===0?s(`div`,{className:`p-4`,children:s(`div`,{className:`text-xs text-foreground-subtle`,children:`Loading archive manifest… If this persists, the archive may predate manifests — restoring will apply everything in the tarball.`})}):n(`div`,{className:`p-4 space-y-3`,children:[s(`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:`Selected entries will overwrite live data on the next server restart. Unchecked entries stay current.`}),n(`div`,{className:`space-y-1.5`,children:[s(`label`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wide`,children:`Apply`}),s(`div`,{className:`rounded border border-border bg-background divide-y divide-border max-h-64 overflow-y-auto`,children:e.map(e=>n(`label`,{className:`flex items-center gap-2 px-3 py-2 text-xs hover:bg-primary/5 cursor-pointer`,children:[s(`input`,{type:`checkbox`,checked:t.has(e),onChange:()=>r(e),className:`accent-primary`}),s(`span`,{className:`font-mono text-foreground`,children:e}),s(`span`,{className:`ml-auto text-[10px] text-foreground-subtle`,children:Ye(e)})]},e))})]})]})}function qe({destinationName:e,archive:t,picked:r}){return n(`div`,{className:`p-4 space-y-3 text-xs`,children:[s(`div`,{className:`rounded border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-amber-700 dark:text-amber-300`,children:`Restore is applied at next server boot. Active connections will drop when you restart.`}),n(`dl`,{className:`space-y-1.5`,children:[s($,{term:`Destination`,value:e}),s($,{term:`Archive`,value:t?.label??t?.id??`—`}),t&&s($,{term:`Created`,value:`${new Date(t.createdAt).toLocaleString()} · ${q(t.sizeBytes)}`}),s($,{term:`Locations`,value:r.length>0?r.join(`, `):`— (full archive)`})]})]})}function $({term:e,value:t}){return n(`div`,{className:`flex justify-between gap-3`,children:[s(`dt`,{className:`text-foreground-subtle`,children:e}),s(`dd`,{className:`text-foreground font-mono text-right truncate`,children:t})]})}var Je={db:`Database`,addons:`Addon configs`,"addons-data":`Addon data`,tls:`TLS certificates`,cache:`Cache`,data:`Top-level data`};function Ye(e){return Je[e]??``}t();function Xe(){let e=L(),t=k(),[r,i]=o(null),[a,c]=o(!1),[l,u]=o(!1),[d,f]=o(void 0),p=async()=>{await e({title:`Restart server now?`,message:`Active connections will drop and the apply-backup hook will run before boot.`,confirmLabel:`Restart`,variant:`warning`})&&t.mutate({confirm:!0})};return n(K,{children:[n(`div`,{className:`flex items-center justify-end gap-2 flex-wrap`,children:[n(`button`,{onClick:()=>c(!0),className:`inline-flex items-center gap-1.5 rounded-lg bg-surface border border-border px-3 py-1.5 text-xs font-medium text-foreground hover:bg-primary/5 hover:border-primary/30`,children:[s(_,{className:`h-3.5 w-3.5`}),`Restore…`]}),n(`button`,{onClick:()=>f(null),className:`inline-flex items-center gap-1.5 rounded-lg bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90`,children:[s(b,{className:`h-3.5 w-3.5`}),`New entry`]})]}),l&&s(`div`,{className:`rounded-lg border border-amber-500/30 bg-amber-500/10 px-3 py-2.5 text-xs text-amber-700 dark:text-amber-300`,children:n(`div`,{className:`flex items-center justify-between gap-3`,children:[n(`div`,{className:`flex items-center gap-2`,children:[s(_,{className:`h-3.5 w-3.5`}),s(`span`,{children:`Restore scheduled. Restart the server to apply.`})]}),n(`button`,{onClick:()=>{p()},disabled:t.isPending,className:`inline-flex items-center gap-1.5 rounded bg-amber-500/20 px-2 py-1 font-medium text-amber-800 dark:text-amber-200 hover:bg-amber-500/30 disabled:opacity-50`,children:[t.isPending?s(I,{className:`h-3.5 w-3.5 animate-spin`}):s(_,{className:`h-3.5 w-3.5`}),`Restart Now`]})]})}),s(Fe,{}),s(Ce,{onEdit:e=>f(e),onOpenRestoreWizard:e=>i(e)}),d!==void 0&&s(je,{entry:d,onClose:()=>f(void 0),onSaved:()=>f(void 0)}),(r||a)&&s(We,{...r?{initialDestinationId:r.destinationId,initialArchiveId:r.archiveId}:{},onClose:()=>{i(null),c(!1)},onScheduled:()=>u(!0)})]})}function Ze(){return s(`div`,{className:`flex flex-col p-4`,children:s(me,{tabs:[{id:`storage`,label:`Storage`,icon:oe,content:s(_e,{})},{id:`backup`,label:`Backup`,icon:z,content:s(Xe,{})}]})})}export{Ze as DataPage};
1
+ import{I as e,Q as t,S as n,W as r,b as i,o as a,q as o,x as s,z as c}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{Z as l,_t as u,gt as d,st as f,yt as p}from"./player-overlays-gbZ2vznV.js";import{Cr as m,Cs as h,Cu as g,Fl as _,Fs as v,Gc as y,Hl as b,Is as x,Iu as S,Ls as C,Mu as w,Ps as T,Sr as E,Ul as D,Wl as O,Xn as k,Xs as A,_r as j,br as M,ed as N,fr as P,gr as F,hr as ee,ju as te,mr as ne,nd as re,nu as I,pr as ie,rd as ae,uu as oe,vr as se,xr as ce,yn as L,yr as R}from"./src-DxdTI837.js";import{t as z}from"./archive-BUE32U7F.js";import{t as B}from"./circle-slash-fCLxXnZu.js";import{a as V,c as H,l as U,n as W,o as G,s as le,t as ue,u as de}from"./location-owned-usage-CLcax6wn.js";import{t as fe}from"./hard-drive-download-BwgF6zZo.js";import"./index-xBLZKqTX.js";import{t as K}from"./AdminPage-CiKtOLQm.js";import{n as pe}from"./authed-media-0-hZyKYF.js";import{t as me}from"./AdminTabs-B7qQRc02.js";import{t as q}from"./format-size-DIxKXxtj.js";var he=p(`calendar-clock`,[[`path`,{d:`M16 14v2.2l1.6 1`,key:`fo4ql5`}],[`path`,{d:`M16 2v4`,key:`4m81vk`}],[`path`,{d:`M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5`,key:`1osxxc`}],[`path`,{d:`M3 10h5`,key:`r794hk`}],[`path`,{d:`M8 2v4`,key:`1cmpym`}],[`circle`,{cx:`16`,cy:`16`,r:`6`,key:`qoo3c4`}]]),ge=p(`cloud-upload`,[[`path`,{d:`M12 13v8`,key:`1l5pq0`}],[`path`,{d:`M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242`,key:`1pljnt`}],[`path`,{d:`m8 17 4-4 4 4`,key:`1quai1`}]]);t();function _e(){let e=a(),t=L(),{data:i,isLoading:c,isError:l}=C({}),u=x(),d=r(()=>u.data??[],[u.data]),{data:f}=h({},{refetchOnWindowFocus:!1}),p=r(()=>ue(i??[],f?.locations),[i,f?.locations]),{data:m}=v({},{refetchOnWindowFocus:!1}),g=r(()=>V(m),[m]),[_,y]=o(null),[b,S]=o(null),w=T({onSuccess:()=>{e.invalidateQueries({queryKey:[[`storage`,`listLocations`]]})}}),E=A({onSuccess:()=>{e.invalidateQueries({queryKey:[[`storage`,`listLocations`]]})}}),D=async(e,n)=>{U(n)&&!await t({title:`Disable "${e.displayName}"?`,message:`${H(n).consequence}\n\nNothing is deleted — set the location back to Read-only or Active to bring its footage back.`,confirmLabel:`Disable`,variant:`danger`})||E.mutate(le(e,{mode:n}))},O=async e=>{if(await t({title:`Delete location "${e.displayName}"?`,message:`This removes the location record. Files on disk are not deleted; the underlying directory or remote path stays untouched.`,confirmLabel:`Delete`,variant:`danger`}))try{await w.mutateAsync({id:e.id})}catch(n){await t({title:`Delete anyway?`,message:`${n instanceof Error?n.message:String(n)}\n\nForcing the delete removes the record only. Anything still on that location becomes unreachable — index rows naming it stop resolving, and playback of those segments goes silently black rather than erroring.`,confirmLabel:`Force delete`,variant:`danger`})&&w.mutate({id:e.id,force:!0})}},k=r(()=>{let e=new Map;for(let t of i??[]){let n=e.get(t.type);n?n.push(t):e.set(t.type,[t])}return e},[i]),j=c||u.isLoading,M=l||u.isError;return n(K,{children:[j&&s(`div`,{className:`text-xs text-foreground-subtle animate-pulse`,children:`Loading locations…`}),M&&s(`div`,{className:`text-xs text-danger`,children:`Failed to load storage locations.`}),!j&&!M&&n(`div`,{className:`space-y-3`,children:[d.length===0&&s(`div`,{className:`rounded-lg border border-border bg-surface px-3 py-4 text-center text-[11px] text-foreground-subtle italic`,children:`No storage locations declared by any installed addon.`}),d.map(e=>s(W,{type:e.id,displayName:e.displayName,description:e.description,cardinality:e.cardinality,locations:k.get(e.id)??[],onAdd:e=>y(e),onEdit:e=>S(e),onDelete:e=>{O(e)},ownedBytesById:p,drainById:g,onSetMode:(e,t)=>{D(e,t)}},e.id))]}),_!==null&&s(de,{initialType:_,onClose:()=>y(null),onCreated:()=>{e.invalidateQueries({queryKey:[[`storage`,`listLocations`]]}),y(null)}}),b!==null&&s(G,{location:b,onClose:()=>S(null),onSaved:()=>{e.invalidateQueries({queryKey:[[`storage`,`listLocations`]]}),S(null)}})]})}t();var ve=[[`backup`,`listDestinations`]],ye=[`backup`,`listArchives`];function be({destinationId:t,restoreSupported:i,onOpenRestoreWizard:c}){let l=a(),u=L(),{data:d,isLoading:p,isError:m}=F({destinationId:t}),h=d??[],v=ie({onSuccess:()=>{l.invalidateQueries({queryKey:[[...ye]]}),l.invalidateQueries({queryKey:ve})}}),y=e(async e=>{await u({title:`Delete this archive?`,message:`Permanently deletes "${e.label??e.id}" and frees ${q(e.sizeBytes)}.`,confirmLabel:`Delete`,variant:`danger`})&&v.mutate({destinationId:t,backupId:e.id})},[u,t,v]),[b,x]=o(null),S=e(async e=>{x(e.id);try{let n=await pe(xe(t,e.id)),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`${e.label??e.id}.tar.gz`,document.body.appendChild(i),i.click(),i.remove(),URL.revokeObjectURL(r)}finally{x(null)}},[t]),C=r(()=>[...h].toSorted((e,t)=>t.createdAt-e.createdAt),[h]);return p?s(`div`,{className:`text-xs text-foreground-subtle animate-pulse py-2`,children:`Loading archives…`}):m?s(`div`,{className:`text-xs text-danger py-2`,children:`Failed to read manifest for this destination`}):C.length===0?s(`div`,{className:`text-xs text-foreground-subtle italic py-2`,children:`No archives at this destination yet.`}):s(`div`,{className:`rounded border border-border bg-surface overflow-x-auto`,children:n(`table`,{className:`w-full text-xs min-w-[640px]`,children:[s(`thead`,{children:n(`tr`,{className:`text-foreground-subtle bg-background/30`,children:[s(`th`,{className:`text-left px-3 py-1.5 font-medium`,children:`When`}),s(`th`,{className:`text-left px-3 py-1.5 font-medium`,children:`Label`}),s(`th`,{className:`text-left px-3 py-1.5 font-medium`,children:`Includes`}),s(`th`,{className:`text-right px-3 py-1.5 font-medium`,children:`Size`}),s(`th`,{className:`text-right px-3 py-1.5 font-medium w-52`,children:`Actions`})]})}),s(`tbody`,{children:C.map(e=>n(`tr`,{className:`border-t border-border hover:bg-primary/5`,children:[s(`td`,{className:`px-3 py-1.5 text-foreground tabular-nums`,children:Se(e.createdAt)}),s(`td`,{className:`px-3 py-1.5 text-foreground`,children:e.label??s(`span`,{className:`text-foreground-subtle italic`,children:`—`})}),s(`td`,{className:`px-3 py-1.5 text-foreground-subtle`,children:e.locations.join(`, `)}),s(`td`,{className:`px-3 py-1.5 text-foreground text-right tabular-nums`,children:q(e.sizeBytes)}),s(`td`,{className:`px-3 py-1.5`,children:n(`div`,{className:`flex items-center justify-end gap-1`,children:[n(`button`,{onClick:()=>{S(e)},disabled:b===e.id,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-foreground-subtle hover:text-foreground hover:bg-primary/10 disabled:opacity-50`,title:`Download archive`,children:[b===e.id?s(I,{className:`h-3 w-3 animate-spin`}):s(g,{className:`h-3 w-3`}),`Download`]}),i&&c&&n(`button`,{onClick:()=>c({destinationId:t,archiveId:e.id}),className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-primary hover:bg-primary/10`,title:`Restore from this archive`,children:[s(_,{className:`h-3 w-3`}),`Restore`]}),s(`button`,{onClick:()=>{y(e)},disabled:v.isPending,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-danger hover:bg-danger/10 disabled:opacity-50`,title:`Delete archive`,children:v.isPending?s(I,{className:`h-3 w-3 animate-spin`}):s(f,{className:`h-3 w-3`})})]})})]},e.id))})]})})}function xe(e,t){return l(`/api/backup/download/${encodeURIComponent(e)}/${encodeURIComponent(t)}`)}function Se(e){return new Date(e).toLocaleString(void 0,{day:`2-digit`,month:`short`,year:`numeric`,hour:`2-digit`,minute:`2-digit`})}t();var J=[[`backup`,`listSchedules`]];function Ce({onEdit:e,onOpenRestoreWizard:t}){let{data:i,isLoading:a,isError:c}=R(),l=i??[],u=j().data??[],d=r(()=>{let e=new Map;for(let t of u)e.set(t.id,t);return e},[u]),[f,p]=o(null),m=e=>{p(t=>t===e?null:e)};return a?s(`div`,{className:`text-xs text-foreground-subtle animate-pulse`,children:`Loading backup entries…`}):c?s(`div`,{className:`text-xs text-danger`,children:`Failed to load backup entries`}):l.length===0?s(`div`,{className:`rounded-lg border border-border bg-surface px-4 py-8 text-center`,children:s(`p`,{className:`text-xs text-foreground-subtle`,children:`No backup entries yet. Create one to schedule backups across one or more storage locations.`})}):s(`div`,{className:`rounded-lg border border-border bg-surface overflow-x-auto`,children:n(`table`,{className:`w-full text-xs min-w-[820px]`,children:[s(`thead`,{children:n(`tr`,{className:`text-foreground-subtle border-b border-border bg-background/40`,children:[s(`th`,{className:`text-left px-3 py-2 font-medium w-6`}),s(`th`,{className:`text-left px-3 py-2 font-medium`,children:`Entry`}),s(`th`,{className:`text-left px-3 py-2 font-medium w-20`,children:`Enabled`}),s(`th`,{className:`text-left px-3 py-2 font-medium`,children:`Locations`}),s(`th`,{className:`text-left px-3 py-2 font-medium w-24`,children:`Retention`}),s(`th`,{className:`text-left px-3 py-2 font-medium w-48`,children:`Schedule`}),s(`th`,{className:`text-right px-3 py-2 font-medium w-52`,children:`Actions`})]})}),s(`tbody`,{children:l.map(n=>s(we,{row:n,destById:d,isOpen:f===n.id,onToggle:()=>m(n.id),onEdit:()=>e(n),...t?{onOpenRestoreWizard:t}:{}},n.id))})]})})}function we({row:t,destById:l,isOpen:p,onToggle:h,onEdit:g,onOpenRestoreWizard:_}){let v=a(),y=L(),b=m({onSuccess:()=>{v.invalidateQueries({queryKey:J})}}),x=ne({onSuccess:()=>{v.invalidateQueries({queryKey:J})}}),S=E({onMutate:()=>{v.invalidateQueries({queryKey:[[`backup`,`listRuns`]]})},onSuccess:()=>{v.invalidateQueries({queryKey:[[`backup`,`listArchives`]]}),v.invalidateQueries({queryKey:[[`backup`,`listDestinations`]]}),v.invalidateQueries({queryKey:[[`backup`,`listRuns`]]})}}),[C,w]=o(String(t.retentionCount));c(()=>{w(String(t.retentionCount))},[t.retentionCount]);let T=r(()=>({id:t.id,label:t.label,cron:t.cron,locationIds:[...t.locationIds],retentionCount:t.retentionCount,...t.dataSources?{dataSources:[...t.dataSources]}:{}}),[t]),k=e(e=>{b.mutate({...T,enabled:e})},[b,T]),A=e(()=>{let e=Number.parseInt(C,10);if(Number.isNaN(e)||e<1){w(String(t.retentionCount));return}e!==t.retentionCount&&b.mutate({...T,enabled:t.enabled,retentionCount:e})},[b,T,C,t.retentionCount,t.enabled]),j=e(()=>{t.locationIds.length!==0&&S.mutate({destinations:[...t.locationIds],...t.dataSources&&t.dataSources.length>0?{locations:[...t.dataSources]}:{},label:t.label,retentionCount:t.retentionCount})},[S,t]),M=e(async()=>{await y({title:`Delete backup entry?`,message:`"${t.label||t.id}" will stop running. Existing archives are kept.`,confirmLabel:`Delete`,variant:`warning`})&&x.mutate({id:t.id})},[y,x,t.id,t.label]),N=t.cron.trim().length>0,P=b.isPending||x.isPending;return n(i,{children:[n(`tr`,{className:`border-t border-border first:border-t-0 hover:bg-primary/5`,children:[s(`td`,{className:`px-2 py-2`,children:s(`button`,{onClick:h,className:`inline-flex items-center justify-center rounded p-1 text-foreground-subtle hover:bg-primary/10 hover:text-foreground`,title:p?`Hide archives`:`Show archives`,children:s(p?u:d,{className:`h-3.5 w-3.5`})})}),s(`td`,{className:`px-3 py-2`,children:n(`button`,{onClick:g,className:`text-left hover:underline focus:outline-none`,children:[s(`div`,{className:`text-foreground font-medium`,children:t.label||`(unnamed)`}),t.lastRunAt!==void 0&&n(`div`,{className:`text-[10px] text-foreground-subtle mt-0.5`,children:[`last run `,new Date(t.lastRunAt).toLocaleString()]})]})}),s(`td`,{className:`px-3 py-2`,children:s(`label`,{className:`inline-flex items-center cursor-pointer`,children:s(`input`,{type:`checkbox`,className:`accent-primary`,checked:t.enabled,disabled:P,onChange:e=>k(e.target.checked)})})}),s(`td`,{className:`px-3 py-2`,children:n(`div`,{className:`flex flex-wrap gap-1`,children:[t.locationIds.length===0&&s(`span`,{className:`text-[11px] text-danger italic`,children:`No locations`}),t.locationIds.map(e=>s(`span`,{className:`inline-flex items-center rounded border border-border bg-background px-1.5 py-0.5 text-[10px] text-foreground`,title:e,children:l.get(e)?.displayName??e},e))]})}),s(`td`,{className:`px-3 py-2`,children:s(`input`,{type:`number`,min:1,max:1e3,value:C,disabled:P,onChange:e=>w(e.target.value),onBlur:A,onKeyDown:e=>{e.key===`Enter`&&e.target.blur(),e.key===`Escape`&&w(String(t.retentionCount))},className:`w-16 rounded border border-border bg-background px-2 py-1 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`})}),s(`td`,{className:`px-3 py-2`,children:n(`button`,{onClick:g,className:`group flex flex-col items-start gap-0.5 text-left`,title:`Edit schedule`,children:[n(`span`,{className:`inline-flex items-center gap-1`,children:[s(he,{className:`h-3 w-3 text-foreground-subtle group-hover:text-foreground`}),s(`span`,{className:`font-mono text-[11px] text-foreground`,children:N?t.cron:`Manual`})]}),N&&t.nextRunAt!==void 0&&n(`span`,{className:`text-[10px] text-foreground-subtle`,children:[`next `,new Date(t.nextRunAt).toLocaleString()]})]})}),s(`td`,{className:`px-3 py-2`,children:n(`div`,{className:`flex items-center justify-end gap-1.5`,children:[n(`button`,{onClick:j,disabled:S.isPending||t.locationIds.length===0,className:`inline-flex items-center gap-1 rounded bg-primary px-2 py-1 text-[11px] font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50`,title:`Run this entry now`,children:[S.isPending?s(I,{className:`h-3 w-3 animate-spin`}):s(D,{className:`h-3 w-3`}),`Run now`]}),s(`button`,{onClick:g,className:`inline-flex items-center justify-center rounded border border-border p-1 text-foreground-subtle hover:text-foreground hover:bg-primary/5`,title:`Edit entry`,children:s(O,{className:`h-3 w-3`})}),s(`button`,{onClick:()=>{M()},disabled:P,className:`inline-flex items-center justify-center rounded border border-border p-1 text-foreground-subtle hover:text-danger hover:border-danger/40 disabled:opacity-50`,title:`Delete entry`,children:s(f,{className:`h-3 w-3`})})]})})]}),p&&s(`tr`,{className:`border-t border-border bg-background/30`,children:n(`td`,{colSpan:7,className:`px-4 py-3 space-y-4`,children:[t.locationIds.length===0&&s(`p`,{className:`text-xs text-foreground-subtle italic`,children:`This entry has no locations selected.`}),t.locationIds.map(e=>n(`div`,{className:`space-y-1.5`,children:[s(`div`,{className:`text-[11px] font-medium text-foreground-subtle`,children:l.get(e)?.displayName??e}),s(be,{destinationId:e,restoreSupported:l.get(e)?.restoreSupported??!0,..._?{onOpenRestoreWizard:_}:{}})]},e))]})})]})}t();var Y=[{id:`manual`,label:`Manual only`,cron:``},{id:`hourly`,label:`Every hour`,cron:`0 * * * *`,description:`On the hour`},{id:`every-3h`,label:`Every 3 hours`,cron:`0 */3 * * *`,description:`00:00, 03:00, 06:00, 09:00 …`},{id:`every-6h`,label:`Every 6 hours`,cron:`0 */6 * * *`,description:`00:00, 06:00, 12:00, 18:00`},{id:`daily-3am`,label:`Daily at 03:00`,cron:`0 3 * * *`,description:`Every night at 3 AM`},{id:`weekly-sun`,label:`Weekly Sunday 03:00`,cron:`0 3 * * 0`,description:`Sunday morning at 3 AM`}];function Te(e){let t=e.trim();for(let e of Y)if(e.cron===t)return e.id;return`custom`}function Ee({value:e,onChange:t,previewCount:r=5,disabled:i=!1}){let a=Te(e),[l,u]=o(a===`custom`);c(()=>{a!==`custom`&&u(!1)},[a]);let d=ke(e,250),f=M({cron:d,count:r},{enabled:d.trim().length>0}),p=f.data??null,m=e=>{u(!1),t(e.cron)},h=l||a===`custom`;return n(`div`,{className:`space-y-3`,children:[n(`div`,{className:`space-y-1`,children:[s(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Schedule preset`}),n(`div`,{className:`flex flex-wrap gap-1.5`,children:[Y.map(e=>s(`button`,{type:`button`,onClick:()=>m(e),disabled:i,className:`rounded border px-2 py-1 text-[11px] transition-colors disabled:opacity-50 `+(!l&&a===e.id?`border-primary bg-primary/10 text-primary`:`border-border bg-background text-foreground-subtle hover:bg-primary/5 hover:text-foreground`),title:e.description??e.label,children:e.label},e.id)),s(`button`,{type:`button`,onClick:()=>{u(!0),e.trim().length===0&&t(`0 3 * * *`)},disabled:i,className:`rounded border px-2 py-1 text-[11px] transition-colors disabled:opacity-50 `+(h?`border-primary bg-primary/10 text-primary`:`border-border bg-background text-foreground-subtle hover:bg-primary/5 hover:text-foreground`),children:`Custom…`})]})]}),h&&n(`div`,{className:`space-y-1`,children:[s(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Cron expression (5-field POSIX)`}),s(`input`,{type:`text`,value:e,onChange:e=>t(e.target.value),disabled:i,placeholder:`0 3 * * *`,spellCheck:!1,className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs font-mono text-foreground placeholder:text-foreground-subtle focus:outline-none focus:ring-1 focus:ring-primary`}),n(`p`,{className:`text-[10px] text-foreground-subtle`,children:[`Format: `,s(`span`,{className:`font-mono`,children:`minute hour day-of-month month day-of-week`}),` · all times server-local`]})]}),s(De,{cron:d,preview:p,loading:f.isFetching})]})}function De({cron:e,preview:t,loading:r}){return r&&t===null?n(`div`,{className:`flex items-center gap-2 rounded border border-border bg-background/40 px-3 py-2 text-[11px] text-foreground-subtle`,children:[s(I,{className:`h-3 w-3 animate-spin`}),`Validating…`]}):t===null?null:t.ok?t.nextRuns.length===0?s(`div`,{className:`rounded border border-border bg-background/40 px-3 py-2 text-[11px] text-foreground-subtle`,children:`No future runs match this expression.`}):n(`div`,{className:`space-y-1`,children:[s(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Next runs`}),s(`ul`,{className:`rounded border border-border bg-background/40 divide-y divide-border`,children:t.nextRuns.map((e,t)=>n(`li`,{className:`flex items-center justify-between px-3 py-1.5 text-[11px]`,children:[s(`span`,{className:`text-foreground tabular-nums`,children:new Date(e).toLocaleString()}),s(`span`,{className:`text-foreground-subtle text-[10px] tabular-nums`,children:Oe(e)})]},`${e}-${t}`))})]}):s(`div`,{className:`rounded border border-danger/40 bg-danger/10 px-3 py-2 text-[11px] text-danger`,children:t.error??`Invalid cron expression`})}function Oe(e){let t=e-Date.now();if(t<=0)return`now`;let n=Math.floor(t/1e3);if(n<60)return`in ${n}s`;let r=Math.floor(n/60);if(r<60)return`in ${r}m`;let i=Math.floor(r/60);return i<24?`in ${i}h`:`in ${Math.floor(i/24)}d`}function ke(e,t){let[n,i]=o(e),a=r(()=>e,[e]);return c(()=>{let e=setTimeout(()=>i(a),t);return()=>clearTimeout(e)},[a,t]),n}t();var Ae=[[`backup`,`listSchedules`]];function je({entry:e,onClose:t,onSaved:i}){let c=a(),l=j(),u=l.data??[],[d,f]=o(e?.label??``),[p,h]=o(e?.cron??`0 3 * * *`),[g,_]=o(e?.enabled??!0),[v,b]=o(String(e?.retentionCount??7)),[x,S]=o(new Set(e?.locationIds??[])),C=m({onSuccess:()=>{c.invalidateQueries({queryKey:Ae}),i()}}),w=e=>{S(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},T=Number.parseInt(v,10),E=r(()=>d.trim().length>0&&x.size>0&&!Number.isNaN(T)&&T>=1&&T<=1e3,[d,x,T]),D=()=>{E&&C.mutate({...e?{id:e.id}:{},label:d.trim(),cron:p.trim(),enabled:g,locationIds:Array.from(x),retentionCount:T})},O=C.error instanceof Error?C.error.message:null;return s(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-background/80 backdrop-blur-sm`,onClick:t,children:n(`div`,{className:`w-full max-w-lg rounded-xl border border-border bg-surface shadow-2xl max-h-[90vh] overflow-y-auto`,onClick:e=>e.stopPropagation(),children:[n(`div`,{className:`flex items-start justify-between border-b border-border px-4 py-3 sticky top-0 bg-surface`,children:[s(`h2`,{className:`text-sm font-semibold text-foreground`,children:e?`Edit backup entry`:`New backup entry`}),s(`button`,{onClick:t,className:`text-foreground-subtle hover:text-foreground`,children:s(y,{className:`h-4 w-4`})})]}),n(`div`,{className:`p-4 space-y-4`,children:[n(`div`,{className:`space-y-1`,children:[s(`label`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wide`,children:`Name`}),s(`input`,{type:`text`,value:d,onChange:e=>f(e.target.value),placeholder:`Nightly offsite`,className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground placeholder:text-foreground-subtle focus:outline-none focus:ring-1 focus:ring-primary`})]}),n(`div`,{className:`space-y-1.5`,children:[n(`label`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wide`,children:[`Locations (`,x.size,` selected)`]}),l.isLoading&&n(`div`,{className:`flex items-center gap-2 px-1 py-2 text-xs text-foreground-subtle`,children:[s(I,{className:`h-3.5 w-3.5 animate-spin`}),`Loading locations…`]}),!l.isLoading&&u.length===0&&s(`div`,{className:`rounded border border-border bg-background px-3 py-2 text-xs text-foreground-subtle italic`,children:"No `backups` storage locations configured. Add one in Settings → Storage first."}),u.length>0&&s(`div`,{className:`rounded border border-border bg-background divide-y divide-border max-h-52 overflow-y-auto`,children:u.map(e=>n(`label`,{className:`flex items-center justify-between px-3 py-2 text-xs hover:bg-primary/5 cursor-pointer`,children:[n(`div`,{className:`flex items-center gap-2`,children:[s(`input`,{type:`checkbox`,checked:x.has(e.id),onChange:()=>w(e.id),className:`accent-primary`}),s(`span`,{className:`text-foreground`,children:e.displayName})]}),n(`div`,{className:`flex items-center gap-1.5`,children:[s(`span`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle bg-surface border border-border rounded px-1.5 py-0.5`,children:e.kind}),s(`span`,{className:`text-[10px] text-foreground-subtle font-mono`,children:e.id})]})]},e.id))})]}),n(`div`,{className:`grid grid-cols-2 gap-3`,children:[n(`div`,{className:`space-y-1`,children:[s(`label`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wide`,children:`Retention (archives kept)`}),s(`input`,{type:`number`,min:1,max:1e3,value:v,onChange:e=>b(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`})]}),n(`div`,{className:`space-y-1`,children:[s(`label`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wide`,children:`Enabled`}),n(`label`,{className:`inline-flex items-center gap-2 py-1.5 cursor-pointer`,children:[s(`input`,{type:`checkbox`,checked:g,onChange:e=>_(e.target.checked),className:`accent-primary`}),s(`span`,{className:`text-xs text-foreground-subtle`,children:`Run on schedule`})]})]})]}),n(`div`,{className:`space-y-1.5 border-t border-border pt-3`,children:[s(`label`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wide`,children:`Schedule`}),s(Ee,{value:p,onChange:h,disabled:C.isPending})]}),O&&s(`div`,{className:`rounded border border-danger/40 bg-danger/10 px-3 py-2 text-[11px] text-danger`,children:O})]}),n(`div`,{className:`flex justify-end gap-2 border-t border-border px-4 py-3 sticky bottom-0 bg-surface`,children:[s(`button`,{onClick:t,className:`rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground`,children:`Cancel`}),n(`button`,{onClick:D,disabled:!E||C.isPending,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:[C.isPending&&s(I,{className:`h-3.5 w-3.5 animate-spin`}),e?`Save`:`Create entry`]})]})]})})}t();var Me=2e3,Ne=5e3;function X(e){return e.state===`queued`||e.state===`running`}function Pe(e){if(e.state===`queued`)return{title:`Cancel queued backup run?`,message:`This run has not started. Cancelling removes it from the queue — nothing has been written, nothing is deleted.`,confirmLabel:`Cancel run`,variant:`warning`};let t=e.completedDestinationIds.length;return{title:`Stop this backup run?`,message:`The half-written staging archive is deleted and the destination currently uploading discards its partial copy. ${t>0?`${t===1?`The 1 destination`:`The ${t} destinations`} that already completed KEEP${t===1?`S`:``} the archive.`:`No destination has completed yet, so nothing will be kept.`}`,confirmLabel:`Stop run`,variant:`danger`}}function Fe(){let t=L(),[n,r]=o(null),i=se(void 0,{refetchInterval:e=>(e.state.data??[]).some(X)?Me:Ne}),a=P({onSettled:()=>{r(null),i.refetch()}}),c=e(async e=>{await t(Pe(e))&&(r(e.id),a.mutate({runId:e.id}))},[t,a]);return s(Ie,{queryState:i.isError?`error`:i.data===void 0?`pending`:`ready`,runs:i.data??[],cancelingId:n,onCancelRequest:e=>{c(e)},now:Date.now()})}function Ie({queryState:e,runs:t,cancelingId:r,onCancelRequest:i,now:a}){let o=e===`ready`&&t.some(X),c=t.filter(e=>e.state===`running`),l=t.filter(e=>e.state===`queued`),u=t.filter(e=>!X(e)),d=[...c,...l,...u];return n(`section`,{className:`rounded-lg border border-border bg-surface`,children:[n(`div`,{className:`flex items-center gap-2 px-3 py-2 border-b border-border`,children:[s(`h2`,{className:`text-xs font-semibold text-foreground`,children:`Runs`}),o&&n(`span`,{className:`inline-flex items-center gap-1 text-[10px] font-medium text-primary`,title:`A backup run is in progress`,children:[s(`span`,{className:`h-1.5 w-1.5 rounded-full bg-primary animate-pulse`}),`live`]}),s(`span`,{className:`ml-auto text-[10px] text-foreground-subtle`,children:`One run executes at a time — queued runs wait in line.`})]}),e===`pending`&&s(`div`,{className:`px-3 py-2.5 text-xs text-foreground-subtle animate-pulse`,children:`Checking for backup runs…`}),e===`error`&&s(`div`,{className:`px-3 py-2.5 text-xs text-danger`,children:`Could not read backup runs — the orchestrator did not answer.`}),e===`ready`&&t.length===0&&s(`div`,{className:`px-3 py-2.5 text-xs text-foreground-subtle italic`,children:`No backup runs yet. Runs appear here the moment one starts — manual or scheduled.`}),e===`ready`&&t.length>0&&s(`div`,{className:`overflow-x-auto`,children:n(`table`,{className:`w-full text-xs min-w-[720px]`,children:[s(`thead`,{children:n(`tr`,{className:`text-foreground-subtle bg-background/30`,children:[s(`th`,{className:`text-left px-3 py-1.5 font-medium`,children:`Run`}),s(`th`,{className:`text-left px-3 py-1.5 font-medium`,children:`State`}),s(`th`,{className:`text-left px-3 py-1.5 font-medium`,children:`Progress`}),s(`th`,{className:`text-left px-3 py-1.5 font-medium`,children:`Destinations`}),s(`th`,{className:`text-left px-3 py-1.5 font-medium`,children:`Timing`}),s(`th`,{className:`text-right px-3 py-1.5 font-medium w-28`,children:`Actions`})]})}),s(`tbody`,{children:d.map(e=>s(Le,{run:e,canceling:r===e.id,onCancelRequest:i,now:a},e.id))})]})})]})}function Le({run:e,canceling:t,onCancelRequest:r,now:i}){let a=X(e);return n(`tr`,{className:`border-t border-border hover:bg-primary/5 align-top`,children:[n(`td`,{className:`px-3 py-2`,children:[s(`div`,{className:`text-foreground`,children:e.label??s(`span`,{className:`text-foreground-subtle italic`,children:`manual`})}),s(`div`,{className:`text-[10px] text-foreground-subtle font-mono`,title:e.id,children:e.id.slice(0,8)})]}),n(`td`,{className:`px-3 py-2`,children:[s(Re,{run:e}),e.state===`failed`&&e.error!==void 0&&s(`div`,{className:`mt-1 text-[10px] text-danger max-w-56 truncate`,title:e.error,children:e.error})]}),s(`td`,{className:`px-3 py-2`,children:s(ze,{run:e})}),s(`td`,{className:`px-3 py-2`,children:s(Be,{run:e})}),s(`td`,{className:`px-3 py-2 text-foreground-subtle tabular-nums`,children:s(Ve,{run:e,now:i})}),s(`td`,{className:`px-3 py-2`,children:s(`div`,{className:`flex justify-end`,children:a&&n(`button`,{onClick:()=>r(e),disabled:t,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-danger hover:bg-danger/10 disabled:opacity-50`,title:e.state===`queued`?`Remove this run from the queue before it starts`:`Stop this run — the half-written archive is discarded`,children:[t?s(I,{className:`h-3 w-3 animate-spin`}):s(N,{className:`h-3 w-3`}),e.state===`queued`?`Cancel`:`Stop`]})})})]})}function Re({run:e}){switch(e.state){case`queued`:return n(`span`,{className:`inline-flex items-center gap-1 rounded bg-foreground-subtle/10 px-1.5 py-0.5 text-[10px] font-medium text-foreground-subtle`,children:[s(te,{className:`h-3 w-3`}),`Queued`]});case`running`:return n(`span`,{className:`inline-flex items-center gap-1 rounded bg-primary/10 px-1.5 py-0.5 text-[10px] font-medium text-primary`,children:[s(I,{className:`h-3 w-3 animate-spin`}),e.phase===`uploading`?`Uploading`:`Building archive`]});case`succeeded`:return n(`span`,{className:`inline-flex items-center gap-1 rounded bg-success/10 px-1.5 py-0.5 text-[10px] font-medium text-success`,children:[s(S,{className:`h-3 w-3`}),`Succeeded`]});case`failed`:return n(`span`,{className:`inline-flex items-center gap-1 rounded bg-danger/10 px-1.5 py-0.5 text-[10px] font-medium text-danger`,children:[s(w,{className:`h-3 w-3`}),`Failed`]});case`cancelled`:return n(`span`,{className:`inline-flex items-center gap-1 rounded bg-amber-500/10 px-1.5 py-0.5 text-[10px] font-medium text-amber-700 dark:text-amber-300`,title:`Stopped before completing every destination — not a success`,children:[s(B,{className:`h-3 w-3`}),`Stopped`]})}}function ze({run:e}){if(e.state===`queued`)return s(`span`,{className:`text-foreground-subtle`,children:e.queuePosition===void 0?s(`span`,{className:`italic`,children:`waiting its turn`}):n(`span`,{className:`inline-flex items-center gap-1`,children:[s(`span`,{className:e.queuePosition===1?`rounded bg-primary/10 px-1.5 py-0.5 text-[10px] font-medium text-primary`:`rounded bg-foreground-subtle/10 px-1.5 py-0.5 text-[10px] font-medium`,children:He(e.queuePosition)}),`in line`]})});if(e.state===`running`&&e.phase===`building`)return n(`span`,{className:`inline-flex items-center gap-1.5 text-foreground`,children:[s(fe,{className:`h-3 w-3 text-primary`}),s(`span`,{className:`tabular-nums font-medium animate-pulse`,children:q(e.stagedBytes)}),s(`span`,{className:`text-foreground-subtle`,children:`staged so far`})]});if(e.state===`running`){let t=e.archiveSizeBytes;return n(`span`,{className:`inline-flex items-center gap-1.5 text-foreground`,children:[s(ge,{className:`h-3 w-3 text-primary`}),n(`span`,{className:`tabular-nums font-medium`,children:[q(e.uploadedBytes),t===void 0?``:` / ${q(t)}`]}),s(`span`,{className:`text-foreground-subtle`,children:`to current destination`})]})}let t=e.archiveSizeBytes??(e.stagedBytes>0?e.stagedBytes:void 0);return t===void 0?s(`span`,{className:`text-foreground-subtle italic`,children:`—`}):n(`span`,{className:`tabular-nums text-foreground`,children:[q(t),` archive`]})}function Be({run:e}){let t=e.destinationIds.length,r=e.completedDestinationIds.length,i=e.failedDestinationIds.length;return t===0?s(`span`,{className:`text-foreground-subtle italic`,children:`not resolved yet`}):n(`div`,{className:`flex flex-col gap-0.5`,children:[n(`span`,{className:`text-foreground-subtle`,title:e.destinationIds.join(`, `),children:[t,` target`,t===1?``:`s`]}),n(`span`,{className:`inline-flex items-center gap-2 text-[10px]`,children:[r>0&&n(`span`,{className:`text-success`,title:`Kept their archive: ${e.completedDestinationIds.join(`, `)}`,children:[`✓ `,r,` completed`]}),i>0&&n(`span`,{className:`text-danger`,title:`Failed: ${e.failedDestinationIds.join(`, `)}`,children:[`✗ `,i,` failed`]})]})]})}function Ve({run:e,now:t}){return e.state===`queued`?n(`span`,{children:[`queued `,Z(t-e.requestedAt),` ago`]}):e.startedAt===void 0?s(`span`,{children:`—`}):e.finishedAt===void 0?n(`span`,{children:[`running for `,Z(t-e.startedAt)]}):n(`div`,{className:`flex flex-col gap-0.5`,children:[s(`span`,{children:Q(e.finishedAt)}),n(`span`,{className:`text-[10px]`,children:[`took `,Z(e.finishedAt-e.startedAt)]})]})}function He(e){if(e<=1)return`next`;let t=e%100;if(t>=11&&t<=13)return`${e}th`;switch(e%10){case 1:return`${e}st`;case 2:return`${e}nd`;case 3:return`${e}rd`;default:return`${e}th`}}function Z(e){let t=Math.max(0,Math.floor(e/1e3));if(t<60)return`${t}s`;let n=Math.floor(t/60);return n<60?`${n}m ${String(t%60).padStart(2,`0`)}s`:`${Math.floor(n/60)}h ${String(n%60).padStart(2,`0`)}m`}function Q(e){return new Date(e).toLocaleString(void 0,{day:`2-digit`,month:`short`,hour:`2-digit`,minute:`2-digit`})}t();var Ue=[[`backup`,`list`]];function We({initialDestinationId:e,initialArchiveId:t,onClose:i,onScheduled:l}){let u=a(),[d,f]=o(e&&t?2:1),[p,m]=o(e),[h,g]=o(t),[v,b]=o(new Set),{data:x}=j(),S=x??[],{data:C,isLoading:w}=F({destinationId:p??``},{enabled:!!p}),T=C??[];c(()=>{if(p!==void 0)return;let e=S.filter(e=>e.restoreSupported);e.length===1&&m(e[0].id)},[p,S]);let{data:E}=ee({destinationId:p??``,backupId:h??``},{enabled:!!p&&!!h}),D=r(()=>E?.locations??[],[E]);c(()=>{D.length!==0&&b(e=>e.size===0?new Set(D):e)},[D]);let O=ce({onSuccess:()=>{u.invalidateQueries({queryKey:Ue}),l(),i()}}),k=e=>{b(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},A=!!p&&!!h,M=v.size>0,N=A&&M&&!O.isPending,P=()=>{!p||!h||O.mutate({destinationId:p,backupId:h,locations:[...v]})};return s(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-background/80 backdrop-blur-sm`,onClick:i,children:n(`div`,{className:`w-full max-w-md rounded-xl border border-border bg-surface shadow-2xl`,onClick:e=>e.stopPropagation(),children:[n(`div`,{className:`flex items-start justify-between border-b border-border px-4 py-3`,children:[n(`div`,{className:`space-y-0.5`,children:[s(`h2`,{className:`text-sm font-semibold text-foreground`,children:`Restore Backup`}),n(`p`,{className:`text-xs text-foreground-subtle`,children:[`Step `,d,` of 3 —`,` `,d===1?`pick source`:d===2?`pick locations`:`confirm`]})]}),s(`button`,{onClick:i,className:`text-foreground-subtle hover:text-foreground`,children:s(y,{className:`h-4 w-4`})})]}),d===1&&s(Ge,{destinations:S,destinationId:p,onPickDestination:e=>{m(e),g(void 0),b(new Set)},archives:T,archivesLoading:w,archiveId:h,onPickArchive:g}),d===2&&s(Ke,{locations:D,picked:v,onToggle:k}),d===3&&s(qe,{destinationName:S.find(e=>e.id===p)?.displayName??p??``,archive:T.find(e=>e.id===h),picked:[...v]}),n(`div`,{className:`flex justify-between gap-2 border-t border-border px-4 py-3`,children:[s(`div`,{children:d>1&&n(`button`,{onClick:()=>f(e=>e===3?2:1),className:`inline-flex items-center gap-1 rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground`,children:[s(ae,{className:`h-3 w-3`}),`Back`]})}),n(`div`,{className:`flex items-center gap-2`,children:[s(`button`,{onClick:i,className:`rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground`,children:`Cancel`}),d<3?n(`button`,{disabled:d===1&&!A||d===2&&!M,onClick:()=>f(e=>e===1?2:3),className:`inline-flex items-center gap-1 rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50`,children:[`Next`,s(re,{className:`h-3 w-3`})]}):n(`button`,{onClick:P,disabled:!N,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:[O.isPending?s(I,{className:`h-3.5 w-3.5 animate-spin`}):s(_,{className:`h-3.5 w-3.5`}),`Schedule Restore`]})]})]})]})})}function Ge({destinations:e,destinationId:t,onPickDestination:r,archives:i,archivesLoading:a,archiveId:o,onPickArchive:c}){let l=e.filter(e=>e.restoreSupported);return n(`div`,{className:`p-4 space-y-3`,children:[n(`div`,{className:`space-y-1.5`,children:[s(`label`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wide`,children:`Destination`}),n(`select`,{value:t??``,onChange:e=>r(e.target.value),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`,children:[s(`option`,{value:``,disabled:!0,children:`Select destination…`}),l.map(e=>n(`option`,{value:e.id,children:[e.displayName,` (`,e.kind,`)`]},e.id))]})]}),n(`div`,{className:`space-y-1.5`,children:[s(`label`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wide`,children:`Archive`}),!t&&s(`div`,{className:`text-xs text-foreground-subtle italic`,children:`Pick a destination first.`}),t&&a&&s(`div`,{className:`text-xs text-foreground-subtle animate-pulse`,children:`Reading archives…`}),t&&!a&&i.length===0&&s(`div`,{className:`text-xs text-foreground-subtle italic`,children:`No archives available at this destination.`}),t&&i.length>0&&s(`div`,{className:`rounded border border-border bg-background divide-y divide-border max-h-64 overflow-y-auto`,children:i.map(e=>{let t=o===e.id;return n(`label`,{className:`flex items-center justify-between px-3 py-2 text-xs cursor-pointer ${t?`bg-primary/10`:`hover:bg-primary/5`}`,children:[n(`div`,{className:`flex items-center gap-2`,children:[s(`input`,{type:`radio`,name:`archive`,checked:t,onChange:()=>c(e.id),className:`accent-primary`}),n(`div`,{children:[s(`div`,{className:`font-medium text-foreground`,children:e.label??e.id}),s(`div`,{className:`text-[10px] text-foreground-subtle`,children:new Date(e.createdAt).toLocaleString()})]})]}),s(`span`,{className:`text-[10px] text-foreground-subtle tabular-nums`,children:q(e.sizeBytes)})]},e.id)})})]})]})}function Ke({locations:e,picked:t,onToggle:r}){return e.length===0?s(`div`,{className:`p-4`,children:s(`div`,{className:`text-xs text-foreground-subtle`,children:`Loading archive manifest… If this persists, the archive may predate manifests — restoring will apply everything in the tarball.`})}):n(`div`,{className:`p-4 space-y-3`,children:[s(`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:`Selected entries will overwrite live data on the next server restart. Unchecked entries stay current.`}),n(`div`,{className:`space-y-1.5`,children:[s(`label`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wide`,children:`Apply`}),s(`div`,{className:`rounded border border-border bg-background divide-y divide-border max-h-64 overflow-y-auto`,children:e.map(e=>n(`label`,{className:`flex items-center gap-2 px-3 py-2 text-xs hover:bg-primary/5 cursor-pointer`,children:[s(`input`,{type:`checkbox`,checked:t.has(e),onChange:()=>r(e),className:`accent-primary`}),s(`span`,{className:`font-mono text-foreground`,children:e}),s(`span`,{className:`ml-auto text-[10px] text-foreground-subtle`,children:Ye(e)})]},e))})]})]})}function qe({destinationName:e,archive:t,picked:r}){return n(`div`,{className:`p-4 space-y-3 text-xs`,children:[s(`div`,{className:`rounded border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-amber-700 dark:text-amber-300`,children:`Restore is applied at next server boot. Active connections will drop when you restart.`}),n(`dl`,{className:`space-y-1.5`,children:[s($,{term:`Destination`,value:e}),s($,{term:`Archive`,value:t?.label??t?.id??`—`}),t&&s($,{term:`Created`,value:`${new Date(t.createdAt).toLocaleString()} · ${q(t.sizeBytes)}`}),s($,{term:`Locations`,value:r.length>0?r.join(`, `):`— (full archive)`})]})]})}function $({term:e,value:t}){return n(`div`,{className:`flex justify-between gap-3`,children:[s(`dt`,{className:`text-foreground-subtle`,children:e}),s(`dd`,{className:`text-foreground font-mono text-right truncate`,children:t})]})}var Je={db:`Database`,addons:`Addon configs`,"addons-data":`Addon data`,tls:`TLS certificates`,cache:`Cache`,data:`Top-level data`};function Ye(e){return Je[e]??``}t();function Xe(){let e=L(),t=k(),[r,i]=o(null),[a,c]=o(!1),[l,u]=o(!1),[d,f]=o(void 0),p=async()=>{await e({title:`Restart server now?`,message:`Active connections will drop and the apply-backup hook will run before boot.`,confirmLabel:`Restart`,variant:`warning`})&&t.mutate({confirm:!0})};return n(K,{children:[n(`div`,{className:`flex items-center justify-end gap-2 flex-wrap`,children:[n(`button`,{onClick:()=>c(!0),className:`inline-flex items-center gap-1.5 rounded-lg bg-surface border border-border px-3 py-1.5 text-xs font-medium text-foreground hover:bg-primary/5 hover:border-primary/30`,children:[s(_,{className:`h-3.5 w-3.5`}),`Restore…`]}),n(`button`,{onClick:()=>f(null),className:`inline-flex items-center gap-1.5 rounded-lg bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90`,children:[s(b,{className:`h-3.5 w-3.5`}),`New entry`]})]}),l&&s(`div`,{className:`rounded-lg border border-amber-500/30 bg-amber-500/10 px-3 py-2.5 text-xs text-amber-700 dark:text-amber-300`,children:n(`div`,{className:`flex items-center justify-between gap-3`,children:[n(`div`,{className:`flex items-center gap-2`,children:[s(_,{className:`h-3.5 w-3.5`}),s(`span`,{children:`Restore scheduled. Restart the server to apply.`})]}),n(`button`,{onClick:()=>{p()},disabled:t.isPending,className:`inline-flex items-center gap-1.5 rounded bg-amber-500/20 px-2 py-1 font-medium text-amber-800 dark:text-amber-200 hover:bg-amber-500/30 disabled:opacity-50`,children:[t.isPending?s(I,{className:`h-3.5 w-3.5 animate-spin`}):s(_,{className:`h-3.5 w-3.5`}),`Restart Now`]})]})}),s(Fe,{}),s(Ce,{onEdit:e=>f(e),onOpenRestoreWizard:e=>i(e)}),d!==void 0&&s(je,{entry:d,onClose:()=>f(void 0),onSaved:()=>f(void 0)}),(r||a)&&s(We,{...r?{initialDestinationId:r.destinationId,initialArchiveId:r.archiveId}:{},onClose:()=>{i(null),c(!1)},onScheduled:()=>u(!0)})]})}function Ze(){return s(`div`,{className:`flex flex-col p-4`,children:s(me,{tabs:[{id:`storage`,label:`Storage`,icon:oe,content:s(_e,{})},{id:`backup`,label:`Backup`,icon:z,content:s(Xe,{})}]})})}export{Ze as DataPage};