@camstack/addon-admin-ui 1.2.121 → 1.2.127

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 (126) hide show
  1. package/dist/assets/AddLocationWizard-3sT-DMaJ.js +1 -0
  2. package/dist/assets/{AddonCollectionPage-CqgSQxQ5.js → AddonCollectionPage-41xhdmM7.js} +1 -1
  3. package/dist/assets/Addons-DwleOQd8.js +1 -0
  4. package/dist/assets/{AdminTabs-Bnpekf9L.js → AdminTabs-DnuMKpd8.js} +1 -1
  5. package/dist/assets/AiProfiles-CGAfatYZ.js +3 -0
  6. package/dist/assets/{BrokerForm-Cp-QCiwW.js → BrokerForm-WvOUXeSt.js} +1 -1
  7. package/dist/assets/{Build-DK4nAd1G.js → Build-DwAbV0PG.js} +4 -4
  8. package/dist/assets/{Capabilities-DjmiW556.js → Capabilities-ZsatHESX.js} +1 -1
  9. package/dist/assets/{CapabilityBadges-CjczBoDi.js → CapabilityBadges-DzGDZShO.js} +1 -1
  10. package/dist/assets/Cluster-DzQOOkXK.js +11 -0
  11. package/dist/assets/Data-D3_zgnDz.js +1 -0
  12. package/dist/assets/DetectionIntelligence-d2H1dkUY.js +1 -0
  13. package/dist/assets/{DeviceAggregateSection-CtNus-Z9.js → DeviceAggregateSection-CzxEN3i0.js} +1 -1
  14. package/dist/assets/DeviceDetail-nzf-cEtq.js +2 -0
  15. package/dist/assets/{Devices-C9AhNeGU.js → Devices-Bafa2OgD.js} +1 -1
  16. package/dist/assets/{EmbedPlayerPage-gbryRNIt.js → EmbedPlayerPage-BhE1SPhY.js} +1 -1
  17. package/dist/assets/Events-D435h41g.js +1 -0
  18. package/dist/assets/FormBuilder-t4HNEelp.js +1 -0
  19. package/dist/assets/Identity-DSh11HN_.js +1 -0
  20. package/dist/assets/IntegrationDetail-DS7Bfmel.js +1 -0
  21. package/dist/assets/Integrations-Bbv8-5n4.js +1 -0
  22. package/dist/assets/Integrations-C8SqgVyg.js +1 -0
  23. package/dist/assets/Locations-BYTMzoPl.js +1 -0
  24. package/dist/assets/{Logs-DAI2eKrC.js → Logs-onBiVe8m.js} +1 -1
  25. package/dist/assets/{MotionZonesSettings-Cx8Fgga9.js → MotionZonesSettings-CV25fIL3.js} +1 -1
  26. package/dist/assets/MyAccess-DOzRe6nI.js +2 -0
  27. package/dist/assets/Network-Cdma5Bdm.js +1 -0
  28. package/dist/assets/NodeAddonsSettingsPanel-CEwSbCcC.js +1 -0
  29. package/dist/assets/{NodeInferenceDevices-DEeOhTqE.js → NodeInferenceDevices-BfiYaoMW.js} +1 -1
  30. package/dist/assets/Notifications-CVjVdaWP.js +1 -0
  31. package/dist/assets/Pipeline-gv6HuBdN.js +1 -0
  32. package/dist/assets/Plates-CtCNoBVE.js +1 -0
  33. package/dist/assets/{PrivacyMaskSettings--DN9Cj1J.js → PrivacyMaskSettings-mXRfQOka.js} +1 -1
  34. package/dist/assets/{ProviderIcon-B7xnPSGY.js → ProviderIcon-CQ8hdjJj.js} +1 -1
  35. package/dist/assets/Recordings-CZhmUHDp.js +1 -0
  36. package/dist/assets/{ScanNetworkModal-BkuLL5Hb.js → ScanNetworkModal-DFoLAaun.js} +1 -1
  37. package/dist/assets/{SceneMonitorEditor-CKZcEP_n.js → SceneMonitorEditor-DqLZlggP.js} +1 -1
  38. package/dist/assets/{Scenes-UJ6HwN5-.js → Scenes-Dz3VM-iW.js} +1 -1
  39. package/dist/assets/Settings--s9v2p9z.js +1 -0
  40. package/dist/assets/{Showroom-D134TM7C.js → Showroom-DV7vP0NC.js} +1 -1
  41. package/dist/assets/StorageLocationsPanel-BMIZ1rrk.js +1 -0
  42. package/dist/assets/{Terminal-DaXvlDS6.js → Terminal-DEBl2n9s.js} +3 -3
  43. package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-7GR589xa.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-JOjlCnsu.js} +1 -1
  44. package/dist/assets/{bell-ring-6mWtb-XF.js → bell-ring-BdTHGAfC.js} +1 -1
  45. package/dist/assets/{boxes-C5NTL0ET.js → boxes-D1hLoZDP.js} +1 -1
  46. package/dist/assets/circle-check-big-BTcAARaz.js +1 -0
  47. package/dist/assets/{circle-x-CFWnmyvU.js → circle-x-ZrVi-H1h.js} +1 -1
  48. package/dist/assets/clock-D_X5DIAb.js +1 -0
  49. package/dist/assets/{copy-tqbIiAtY.js → copy-C_sQGSwQ.js} +1 -1
  50. package/dist/assets/{debounced-invalidate-BvbZ9j3z.js → debounced-invalidate-BMwxuj5D.js} +1 -1
  51. package/dist/assets/{dist-D-XW9v3T.js → dist-CzkzZvif.js} +1 -1
  52. package/dist/assets/dist-DDgMbk22.js +349 -0
  53. package/dist/assets/{download-CBTHh5Td.js → download-CTOVuY2h.js} +1 -1
  54. package/dist/assets/{face-bbox-DK3crsBr.js → face-bbox-amOTfTnN.js} +1 -1
  55. package/dist/assets/hard-drive-CxmNfMiO.js +1 -0
  56. package/dist/assets/{hostInit-uOc4KuW6.js → hostInit-CL6Xzmdz.js} +1 -1
  57. package/dist/assets/index-C2qANwGH.js +4 -0
  58. package/dist/assets/index-D_MSJcqI.css +2 -0
  59. package/dist/assets/{key-round-Cp0w9XS6.js → key-round-BonGLdGb.js} +1 -1
  60. package/dist/assets/{layers-R56RBx5J.js → layers-DT4FJH01.js} +1 -1
  61. package/dist/assets/{mf-entry-bootstrap-0-3f5d688b.js → mf-entry-bootstrap-0-24a9f5d5.js} +2 -2
  62. package/dist/assets/{pencil-Dppq_R1x.js → pencil-D8sGx4N3.js} +1 -1
  63. package/dist/assets/play-BXktmQ1c.js +1 -0
  64. package/dist/assets/{player-overlays-MJd9eRlM.js → player-overlays-D4QhWJq_.js} +1 -1
  65. package/dist/assets/plus-fc_pUvBV.js +1 -0
  66. package/dist/assets/power-C4vMrI4O.js +1 -0
  67. package/dist/assets/{radio-Den8nSQU.js → radio-BjYOLZMg.js} +1 -1
  68. package/dist/assets/{refresh-cw-Budztdr-.js → refresh-cw-BgBMqc9L.js} +1 -1
  69. package/dist/assets/remoteEntry-BjCTG3ek.js +1 -0
  70. package/dist/assets/rotate-ccw-4MSenrow.js +1 -0
  71. package/dist/assets/rotate-cw-umGpO-r8.js +1 -0
  72. package/dist/assets/rule-device-filter-BucaBSBx.js +1 -0
  73. package/dist/assets/{send-BZ9zOH2R.js → send-DxrVh6f5.js} +1 -1
  74. package/dist/assets/{server-DhDeuLAj.js → server-B20C4Re8.js} +1 -1
  75. package/dist/assets/{shield-CDajPz7k.js → shield-grKh8xpN.js} +1 -1
  76. package/dist/assets/{square-check-big-B9gVi10Z.js → square-check-big-DmXTbL5t.js} +1 -1
  77. package/dist/assets/square-mihnysY8.js +1 -0
  78. package/dist/assets/src-2StymAPR.js +349 -0
  79. package/dist/assets/{src-DwTflGqD.js → src-C6lLjGTf.js} +17 -17
  80. package/dist/assets/{undo-2-3EmEvFIS.js → undo-2-DLzWcffC.js} +1 -1
  81. package/dist/assets/{use-scenes-feed-julJoDvZ.js → use-scenes-feed-DlmH-sG6.js} +1 -1
  82. package/dist/assets/useEventInvalidation-DX_gaoED.js +1 -0
  83. package/dist/assets/{useNodeUrlSelection-Dsk2NydD.js → useNodeUrlSelection-4UMCh_9w.js} +1 -1
  84. package/dist/assets/{video-BlZPfhfO.js → video-2CCaQywy.js} +1 -1
  85. package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-CokdarDJ.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-BRFZ1Nk7.js} +2 -2
  86. package/dist/assets/{wifi-obpV41fJ.js → wifi-d5m34Ek8.js} +1 -1
  87. package/dist/assets/{zap-B8NXR1Yj.js → zap-DRQYK2sM.js} +1 -1
  88. package/dist/index.html +6 -6
  89. package/dist/server/addon.js +224 -8
  90. package/package.json +1 -1
  91. package/dist/assets/AddLocationWizard--mkj3ETu.js +0 -1
  92. package/dist/assets/Addons-Bf2kB7FO.js +0 -1
  93. package/dist/assets/AiProfiles-Dx9QzfkB.js +0 -3
  94. package/dist/assets/Cluster-CWDTyv3x.js +0 -11
  95. package/dist/assets/Data-CC__xt_7.js +0 -1
  96. package/dist/assets/DetectionIntelligence-DOLcWM0z.js +0 -1
  97. package/dist/assets/DeviceDetail-BBK_biJu.js +0 -2
  98. package/dist/assets/Events-zTFK1o8o.js +0 -1
  99. package/dist/assets/FormBuilder-C_1-Y69Y.js +0 -1
  100. package/dist/assets/Identity-CVqxKTJo.js +0 -1
  101. package/dist/assets/IntegrationDetail-CnTI0i1_.js +0 -1
  102. package/dist/assets/Integrations-1V80f5GH.js +0 -1
  103. package/dist/assets/Integrations-CWQzB2G-.js +0 -1
  104. package/dist/assets/MyAccess-lmd0GUa4.js +0 -2
  105. package/dist/assets/Network-DL7vgvPz.js +0 -1
  106. package/dist/assets/NodeAddonsSettingsPanel-CF38Xfjd.js +0 -1
  107. package/dist/assets/Notifications-DyHxI0OV.js +0 -1
  108. package/dist/assets/Pipeline-D2AK3bq-.js +0 -1
  109. package/dist/assets/Plates-FJGFRHwS.js +0 -1
  110. package/dist/assets/Recordings-DuMD9mO7.js +0 -1
  111. package/dist/assets/Settings-Bsfr9POB.js +0 -1
  112. package/dist/assets/circle-check-big-DADKFm5x.js +0 -1
  113. package/dist/assets/clock-Cl7hHyqW.js +0 -1
  114. package/dist/assets/dist-DYkLn2xO.js +0 -349
  115. package/dist/assets/index-CChcWx2e.css +0 -2
  116. package/dist/assets/index-D-9Wyuju.js +0 -4
  117. package/dist/assets/play-CRkSis2D.js +0 -1
  118. package/dist/assets/plus-BgigjkU9.js +0 -1
  119. package/dist/assets/power-BCS2t-Wx.js +0 -1
  120. package/dist/assets/remoteEntry-DdFdvgxU.js +0 -1
  121. package/dist/assets/rotate-ccw-C_FPsgtu.js +0 -1
  122. package/dist/assets/rotate-cw-Ci2EV6Gc.js +0 -1
  123. package/dist/assets/square-BVwnxCbL.js +0 -1
  124. package/dist/assets/src-0iNMzZ2l.js +0 -349
  125. package/dist/assets/star-B4ylQ-n9.js +0 -1
  126. package/dist/assets/useEventInvalidation-DSpypyuO.js +0 -1
@@ -8099,6 +8099,13 @@ var MediaRelocateModeSchema = _enum([
8099
8099
  ]);
8100
8100
  var RelocateMediaInputSchema = object({
8101
8101
  toLocationId: string(),
8102
+ /**
8103
+ * Restrict the pass to rows currently on this location. Omitted / `'*'` =
8104
+ * every row that is not already on `toLocationId` (the historical
8105
+ * behaviour). A named source is what a from→to migration needs: without it
8106
+ * "move events off disk 2" also emptied disk 1.
8107
+ */
8108
+ fromLocationId: string().optional(),
8102
8109
  throttleMbps: number().min(1).max(1e3).optional(),
8103
8110
  /** Omitted = `move`, the pre-existing behaviour. */
8104
8111
  mode: MediaRelocateModeSchema.optional()
@@ -8166,6 +8173,19 @@ var StorageMigrationDestinationsSchema = object({
8166
8173
  galleryMedia: string().min(1).optional()
8167
8174
  }).refine((value) => Object.keys(value).length > 0, { message: "select at least one storage class" });
8168
8175
  /**
8176
+ * Optional named source per class. Omitted = the class's current default
8177
+ * (the historical behaviour). A named source that is NOT the default is a
8178
+ * drain of that disk: bytes move, the default stays, and the source is
8179
+ * disabled when the move finishes.
8180
+ */
8181
+ var StorageMigrationSourcesSchema = object({
8182
+ recordings: string().min(1).optional(),
8183
+ recordingsLow: string().min(1).optional(),
8184
+ eventMedia: string().min(1).optional(),
8185
+ backups: string().min(1).optional(),
8186
+ galleryMedia: string().min(1).optional()
8187
+ }).optional();
8188
+ /**
8169
8189
  * How a migration sequences the cutover against the byte move.
8170
8190
  *
8171
8191
  * - `blocking` — the historical order: pause, move every byte, repoint,
@@ -8187,6 +8207,8 @@ var StorageMigrationModeSchema = _enum(["blocking", "nonBlocking"]);
8187
8207
  /** Shared input for planning and starting an orchestrated storage migration. */
8188
8208
  var StorageMigrationInputSchema = object({
8189
8209
  destinations: StorageMigrationDestinationsSchema,
8210
+ /** Omitted = each class's current default. */
8211
+ sources: StorageMigrationSourcesSchema,
8190
8212
  throttleMbps: number().min(1).max(1e3).optional(),
8191
8213
  /** Omitted = `blocking`, which stays the default. */
8192
8214
  mode: StorageMigrationModeSchema.optional()
@@ -8266,6 +8288,13 @@ var StorageMigrationMoveSchema = object({
8266
8288
  storageClass: StorageMigrationClassSchema,
8267
8289
  fromLocationId: string(),
8268
8290
  toLocationId: string(),
8291
+ /**
8292
+ * True when `from` was NOT the class default at plan time. The move still
8293
+ * copies bytes, but the default is left alone and the source is disabled
8294
+ * once the copy verifies. Absent on jobs planned before this field existed
8295
+ * — those jobs always repointed, which is `false`.
8296
+ */
8297
+ freezeSource: boolean().optional(),
8269
8298
  moverJobId: string().nullable(),
8270
8299
  state: RelocateJobStateSchema.nullable(),
8271
8300
  error: string().nullable(),
@@ -8279,6 +8308,7 @@ var StorageMigrationJobSchema = object({
8279
8308
  * can tell a seconds-long cutover from a thirty-hour one. */
8280
8309
  mode: StorageMigrationModeSchema,
8281
8310
  destinations: StorageMigrationDestinationsSchema,
8311
+ sources: StorageMigrationSourcesSchema,
8282
8312
  throttleMbps: number(),
8283
8313
  moves: array(StorageMigrationMoveSchema),
8284
8314
  pauseLeaseId: string().nullable(),
@@ -8304,6 +8334,7 @@ var StorageMigrationFindingSchema = object({
8304
8334
  });
8305
8335
  var StorageMigrationPlanSchema = object({
8306
8336
  destinations: StorageMigrationDestinationsSchema,
8337
+ sources: StorageMigrationSourcesSchema,
8307
8338
  /** The mode this plan was built for. A plan is only valid for its mode: the
8308
8339
  * `eventMedia` seal gate and the single-cardinality refusal both depend on
8309
8340
  * it. */
@@ -8311,7 +8342,8 @@ var StorageMigrationPlanSchema = object({
8311
8342
  moves: array(object({
8312
8343
  storageClass: StorageMigrationClassSchema,
8313
8344
  fromLocationId: string(),
8314
- toLocationId: string()
8345
+ toLocationId: string(),
8346
+ freezeSource: boolean().optional()
8315
8347
  })),
8316
8348
  findings: array(StorageMigrationFindingSchema)
8317
8349
  });
@@ -8489,10 +8521,51 @@ var LedgerWalkReportSchema = object({
8489
8521
  var RelocatableMediaCountSchema = object({ rows: number().int().nonnegative() }).nullable();
8490
8522
  var RelocatableMediaCountInputSchema = object({
8491
8523
  toLocationId: string().min(1),
8524
+ /** Restrict the count to one source; omitted / `'*'` = every non-target row. */
8525
+ fromLocationId: string().optional(),
8492
8526
  /** Omitted = `move`. */
8493
8527
  mode: MediaRelocateModeSchema.optional()
8494
8528
  });
8495
8529
  /**
8530
+ * Operator cleanup of leftover analytics rows, optional debug media, and
8531
+ * ghost ledger entries on frozen footage locations.
8532
+ *
8533
+ * A pass is tens of minutes on a standing backlog. The hub method RETURNS
8534
+ * `{ jobId }` immediately; progress is `cleanupStatus`. Awaiting the work
8535
+ * is how `addons.custom` hit the 60 s UDS deadline while reclaim continued
8536
+ * with no operator-visible status.
8537
+ */
8538
+ var StorageCleanupPhaseSchema = _enum([
8539
+ "orphans",
8540
+ "debug-media",
8541
+ "ghost-ledger",
8542
+ "done",
8543
+ "failed",
8544
+ "cancelled"
8545
+ ]);
8546
+ var StorageCleanupInputSchema = object({
8547
+ /** Also walk motion stills / track filmstrips. Off by default. */
8548
+ includeDebugMedia: boolean().optional() });
8549
+ var StorageCleanupJobSchema = object({
8550
+ jobId: string(),
8551
+ phase: StorageCleanupPhaseSchema,
8552
+ includeDebugMedia: boolean(),
8553
+ orphansReclaimed: number().int().nonnegative(),
8554
+ orphanBytesReclaimed: number().int().nonnegative(),
8555
+ debugMediaReclaimed: number().int().nonnegative(),
8556
+ debugMediaBytesReclaimed: number().int().nonnegative(),
8557
+ ghostsForgotten: number().int().nonnegative(),
8558
+ ghostBytesForgotten: number().int().nonnegative(),
8559
+ /** Short operator-facing line: current collection, pass, or location. */
8560
+ detail: string().nullable(),
8561
+ cancelRequested: boolean(),
8562
+ startedAt: number(),
8563
+ updatedAt: number(),
8564
+ finishedAt: number().nullable(),
8565
+ error: string().nullable()
8566
+ });
8567
+ var StorageCleanupStatusInputSchema = object({ jobId: string().optional() });
8568
+ /**
8496
8569
  * `StorageLocationType` — an addon-declared id that identifies the *kind* of
8497
8570
  * storage a location serves. Defined here (not in `capabilities/storage.cap.ts`)
8498
8571
  * so the persisted record schema and the consumer-facing cap can both consume it
@@ -8520,11 +8593,10 @@ var StorageLocationTypeSchema = string().regex(/^[a-z][a-zA-Z0-9-]*$/);
8520
8593
  * The default location for a type uses `id === <type>:default` by
8521
8594
  * convention (the bare type ref like `'backups'` resolves to it).
8522
8595
  *
8523
- * `isSystem: true` marks a location as orchestrator-seeded and
8524
- * undeletable. The bootstrap-installed defaults (one per type) carry
8525
- * this flag; operator-added locations don't. Editing the config of
8526
- * a system location is allowed (path migration, provider swap) but
8527
- * deleting it is rejected at the cap level.
8596
+ * `isSystem` is a legacy persisted flag. Seed still creates the initial
8597
+ * `<type>:default` locations; the flag is no longer a lock, a badge, or a
8598
+ * prune selector. New writes leave it false. Deletion is gated on uniqueness
8599
+ * / last-enabled, not on this bit.
8528
8600
  */
8529
8601
  var StorageLocationSchema = object({
8530
8602
  id: string().regex(/^[a-z][a-zA-Z0-9-]*:[a-zA-Z0-9-]+$/),
@@ -19031,6 +19103,47 @@ var RebuildStatusSchema = object({
19031
19103
  /** Present when the pass ended by throwing. */
19032
19104
  error: string().nullable()
19033
19105
  });
19106
+ /**
19107
+ * Acknowledgement that a debug-media reclaim STARTED.
19108
+ *
19109
+ * The pass is paced at ~2 MB/s over a standing 100 GB — tens of minutes — so
19110
+ * it runs detached and this returns immediately. Awaiting it is how the
19111
+ * `addons.custom` door hit the 60 s UDS deadline while the walk carried on
19112
+ * with no status. Poll {@link pipelineAnalyticsCapability.methods.getMediaReclaimStatus}.
19113
+ */
19114
+ var MediaReclaimStartResultSchema = object({
19115
+ started: boolean(),
19116
+ /** True when a pass was already running; the new request is ignored. */
19117
+ alreadyRunning: boolean()
19118
+ });
19119
+ var MediaReclaimInputSchema = object({
19120
+ mode: _enum(["report", "reclaim"]).default("report"),
19121
+ scopes: array(_enum(["motion-still", "track-filmstrip"])).min(1).optional(),
19122
+ deviceIds: array(number().int()).min(1).optional(),
19123
+ restart: boolean().optional(),
19124
+ pageSize: number().int().min(50).max(5e3).optional(),
19125
+ maxRowsPerDevice: number().int().min(1).max(5e5).optional(),
19126
+ maxReclaimPerDevice: number().int().min(1).max(5e5).optional(),
19127
+ maxBytesPerRun: number().int().min(1).optional(),
19128
+ budgetMinutes: number().int().min(1).max(720).optional(),
19129
+ throttleBytesPerSec: number().int().min(64 * 1024).optional(),
19130
+ graceMinutes: number().int().min(1).max(10080).optional()
19131
+ });
19132
+ var MediaReclaimStatusSchema = object({
19133
+ running: boolean(),
19134
+ mode: _enum(["report", "reclaim"]).nullable(),
19135
+ totalExamined: number(),
19136
+ totalEligible: number(),
19137
+ totalReclaimed: number(),
19138
+ totalBytesReclaimed: number(),
19139
+ totalRefused: number(),
19140
+ /** Device+scope windows finished in this pass. */
19141
+ devicesDone: number(),
19142
+ complete: boolean().nullable(),
19143
+ startedAtMs: number().nullable(),
19144
+ finishedAtMs: number().nullable(),
19145
+ error: string().nullable()
19146
+ });
19034
19147
  var ReplayFrameInputSchema = object({
19035
19148
  timestamp: number(),
19036
19149
  frame: PipelineRunResultBridge
@@ -19172,6 +19285,12 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
19172
19285
  }), method(OpsLogQueryInputSchema, array(OpsLogEntrySchema).readonly(), {
19173
19286
  kind: "query",
19174
19287
  auth: "admin"
19288
+ }), method(MediaReclaimInputSchema, MediaReclaimStartResultSchema, {
19289
+ kind: "mutation",
19290
+ auth: "admin"
19291
+ }), method(object({}), MediaReclaimStatusSchema, {
19292
+ kind: "query",
19293
+ auth: "admin"
19175
19294
  }), method(object({ deviceIds: array(number()).optional() }), TrainingExportSummarySchema, {
19176
19295
  kind: "query",
19177
19296
  auth: "admin"
@@ -21142,7 +21261,13 @@ method(StorageMigrationInputSchema, StorageMigrationPlanSchema, { auth: "admin"
21142
21261
  }), method(object({}), array(StorageMigrationMoverSchema).readonly(), { auth: "admin" }), method(object({}), array(StorageMigrationResidueSchema).readonly(), { auth: "admin" }), method(StorageMigrationDrainInputSchema, object({ jobId: string() }), {
21143
21262
  kind: "mutation",
21144
21263
  auth: "admin"
21145
- });
21264
+ }), method(StorageCleanupInputSchema, object({ jobId: string() }), {
21265
+ kind: "mutation",
21266
+ auth: "admin"
21267
+ }), method(StorageCleanupStatusInputSchema, StorageCleanupJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
21268
+ kind: "mutation",
21269
+ auth: "admin"
21270
+ }), method(object({}), array(StorageMigrationJobSchema).readonly(), { auth: "admin" });
21146
21271
  var ProviderInfoSchema = discriminatedUnion("shouldSaveDiskSpace", [object({
21147
21272
  providerId: string().min(1),
21148
21273
  displayName: string().min(1),
@@ -26520,6 +26645,33 @@ var RecordingRebalanceInputSchema = object({
26520
26645
  minMoveGb: number().min(0).optional()
26521
26646
  });
26522
26647
  /**
26648
+ * Operator-facing placement of one camera onto a recordings location.
26649
+ *
26650
+ * `pinLocationId` is the operator instruction: a location id, or `null` for
26651
+ * Auto (the planner may move this camera). `locationId` is where high/mid
26652
+ * currently write — the plan, which may disagree with the pin when Auto.
26653
+ */
26654
+ var RecordingDevicePlacementSchema = object({
26655
+ deviceId: number().int(),
26656
+ profile: string(),
26657
+ locationId: string()
26658
+ });
26659
+ var RecordingDevicePinSchema = object({
26660
+ deviceId: number().int(),
26661
+ /** Recordings-class location this camera is pinned to. */
26662
+ locationId: string()
26663
+ });
26664
+ var RecordingPlacementViewSchema = object({
26665
+ assignments: array(RecordingDevicePlacementSchema),
26666
+ pins: array(RecordingDevicePinSchema),
26667
+ defaultLocations: record(string(), string())
26668
+ });
26669
+ var RecordingSetDevicePlacementInputSchema = object({
26670
+ deviceId: number().int(),
26671
+ /** `null` = Auto. Otherwise a `recordings:*` location id. */
26672
+ locationId: string().nullable()
26673
+ });
26674
+ /**
26523
26675
  * Result of locating footage at a wall-clock instant for one device/profile.
26524
26676
  * `segment` carries the covering segment's window; `gap` reports the forward
26525
26677
  * nearest covered edge (`null` past the end of footage / when none exists)
@@ -26745,6 +26897,12 @@ method(object({
26745
26897
  }), method(RecordingRebalanceInputSchema, RecordingRebalancePlanSchema, {
26746
26898
  kind: "mutation",
26747
26899
  auth: "admin"
26900
+ }), method(object({}), RecordingPlacementViewSchema, {
26901
+ kind: "query",
26902
+ auth: "admin"
26903
+ }), method(RecordingSetDevicePlacementInputSchema, object({ ok: literal(true) }), {
26904
+ kind: "mutation",
26905
+ auth: "admin"
26748
26906
  });
26749
26907
  /**
26750
26908
  * `recording-export` cap — render a footage time range into a single downloadable
@@ -31825,6 +31983,12 @@ Object.freeze({
31825
31983
  addonId: null,
31826
31984
  access: "view"
31827
31985
  },
31986
+ "pipelineAnalytics.getMediaReclaimStatus": {
31987
+ capName: "pipeline-analytics",
31988
+ capScope: "device",
31989
+ addonId: null,
31990
+ access: "view"
31991
+ },
31828
31992
  "pipelineAnalytics.getMotionEvents": {
31829
31993
  capName: "pipeline-analytics",
31830
31994
  capScope: "device",
@@ -31999,6 +32163,12 @@ Object.freeze({
31999
32163
  addonId: null,
32000
32164
  access: "create"
32001
32165
  },
32166
+ "pipelineAnalytics.reclaimDebugMedia": {
32167
+ capName: "pipeline-analytics",
32168
+ capScope: "device",
32169
+ addonId: null,
32170
+ access: "create"
32171
+ },
32002
32172
  "pipelineAnalytics.reconcileFromDisk": {
32003
32173
  capName: "pipeline-analytics",
32004
32174
  capScope: "device",
@@ -32923,6 +33093,12 @@ Object.freeze({
32923
33093
  addonId: null,
32924
33094
  access: "view"
32925
33095
  },
33096
+ "recording.getPlacement": {
33097
+ capName: "recording",
33098
+ capScope: "system",
33099
+ addonId: null,
33100
+ access: "view"
33101
+ },
32926
33102
  "recording.getPlaybackManifest": {
32927
33103
  capName: "recording",
32928
33104
  capScope: "system",
@@ -33049,6 +33225,12 @@ Object.freeze({
33049
33225
  addonId: null,
33050
33226
  access: "create"
33051
33227
  },
33228
+ "recording.setDevicePlacement": {
33229
+ capName: "recording",
33230
+ capScope: "system",
33231
+ addonId: null,
33232
+ access: "create"
33233
+ },
33052
33234
  "recording.startStorageMigrationMove": {
33053
33235
  capName: "recording",
33054
33236
  capScope: "system",
@@ -33493,12 +33675,36 @@ Object.freeze({
33493
33675
  addonId: null,
33494
33676
  access: "create"
33495
33677
  },
33678
+ "storageMigration.cleanupCancel": {
33679
+ capName: "storage-migration",
33680
+ capScope: "system",
33681
+ addonId: null,
33682
+ access: "create"
33683
+ },
33684
+ "storageMigration.cleanupStart": {
33685
+ capName: "storage-migration",
33686
+ capScope: "system",
33687
+ addonId: null,
33688
+ access: "create"
33689
+ },
33690
+ "storageMigration.cleanupStatus": {
33691
+ capName: "storage-migration",
33692
+ capScope: "system",
33693
+ addonId: null,
33694
+ access: "view"
33695
+ },
33496
33696
  "storageMigration.drain": {
33497
33697
  capName: "storage-migration",
33498
33698
  capScope: "system",
33499
33699
  addonId: null,
33500
33700
  access: "create"
33501
33701
  },
33702
+ "storageMigration.history": {
33703
+ capName: "storage-migration",
33704
+ capScope: "system",
33705
+ addonId: null,
33706
+ access: "view"
33707
+ },
33502
33708
  "storageMigration.movers": {
33503
33709
  capName: "storage-migration",
33504
33710
  capScope: "system",
@@ -35615,6 +35821,11 @@ Object.freeze({
35615
35821
  form: "single",
35616
35822
  optional: true
35617
35823
  }],
35824
+ "pipelineAnalytics.reclaimDebugMedia": [{
35825
+ name: "deviceIds",
35826
+ form: "array",
35827
+ optional: true
35828
+ }],
35618
35829
  "pipelineAnalytics.reconcileFromDisk": [{
35619
35830
  name: "deviceId",
35620
35831
  form: "single",
@@ -35980,6 +36191,11 @@ Object.freeze({
35980
36191
  form: "single",
35981
36192
  optional: false
35982
36193
  }],
36194
+ "recording.setDevicePlacement": [{
36195
+ name: "deviceId",
36196
+ form: "single",
36197
+ optional: false
36198
+ }],
35983
36199
  "recording.startStorageMigrationMove": [{
35984
36200
  name: "deviceId",
35985
36201
  form: "single",
@@ -36842,7 +37058,7 @@ var AdminUIAddon = class extends BaseAddon {
36842
37058
  capability: adminUiCapability,
36843
37059
  provider: {
36844
37060
  getStaticDir: async () => ({ staticDir: resolveAdminUiDistDir() }),
36845
- getVersion: async () => ({ version: "1.2.121" })
37061
+ getVersion: async () => ({ version: "1.2.127" })
36846
37062
  }
36847
37063
  }];
36848
37064
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-admin-ui",
3
- "version": "1.2.121",
3
+ "version": "1.2.127",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Admin UI — Vite frontend build and server-side addon",
@@ -1 +0,0 @@
1
- import{I as e,Q as t,S as n,W as r,a 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{Q as l}from"./player-overlays-MJd9eRlM.js";import{Ho as u,Xo as d,g as f}from"./src-DwTflGqD.js";import{t as p}from"./FormBuilder-C_1-Y69Y.js";import{t as m}from"./pencil-Dppq_R1x.js";import{t as h}from"./plus-BgigjkU9.js";import{t as g}from"./power-BCS2t-Wx.js";import{t as _}from"./star-B4ylQ-n9.js";import{C as v,I as y,K as b,o as x,r as S}from"./index-D-9Wyuju.js";var C=b(`hard-drive`,[[`line`,{x1:`22`,x2:`2`,y1:`12`,y2:`12`,key:`1y58io`}],[`path`,{d:`M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z`,key:`oot6mr`}],[`line`,{x1:`6`,x2:`6.01`,y1:`16`,y2:`16`,key:`sgf278`}],[`line`,{x1:`10`,x2:`10.01`,y1:`16`,y2:`16`,key:`1l4acy`}]]);t();function w(e){return e.enabled!==!1}function T(e){return e.isDefault}function E(e,t){let n={id:e.id,type:e.type,displayName:t.displayName??e.displayName,providerId:e.providerId,config:e.config,isDefault:t.isDefault??e.isDefault,isSystem:e.isSystem},r=e.nodeId===void 0?n:{...n,nodeId:e.nodeId},i=t.enabled??e.enabled;return i===void 0?r:{...r,enabled:i}}function D(e){return`${(e/1024**3).toFixed(e>=100*1024**3?0:1)} GB`}function O({location:e}){let t=e.capacity;return t==null?null:n(`span`,{className:`text-[10px] text-foreground-subtle tabular-nums`,children:[D(t.availableBytes),` free of `,D(t.totalBytes)]})}function k(e){let t=e.basePath;if(typeof t==`string`&&t.length>0)return t;let n=Object.keys(e);return n.length===0?``:n.join(`, `)}function A({location:e,cardinality:t,onEdit:r,onDelete:i,onSetDefault:a,onToggleEnabled:o}){let c=k(e.config),l=w(e),u=T(e);return n(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2 px-3 py-2 border-t border-border first:border-t-0 hover:bg-primary/5`,children:[n(`div`,{className:`flex flex-wrap items-center gap-2 min-w-0 flex-1 basis-64`,children:[s(`div`,{className:`w-[88px] shrink-0`,children:e.isDefault?n(`span`,{className:`inline-flex items-center gap-0.5 rounded bg-primary/10 border border-primary/20 px-1.5 py-0.5 text-[10px] font-semibold text-primary uppercase tracking-wide`,title:`Default location for this type`,children:[s(_,{className:`h-2.5 w-2.5 fill-primary`}),`Default`]}):n(`button`,{onClick:()=>a(e),className:`inline-flex items-center gap-0.5 rounded border border-border px-1.5 py-0.5 text-[10px] font-medium text-foreground-subtle hover:text-foreground hover:bg-primary/10 hover:border-primary/30 uppercase tracking-wide`,title:`Promote to default for this type`,children:[s(_,{className:`h-2.5 w-2.5`}),`Set default`]})}),s(`span`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle bg-background border border-border rounded px-1.5 py-0.5 font-mono`,children:e.providerId}),!l&&s(`span`,{className:`text-[10px] uppercase tracking-wide text-warning bg-warning/10 border border-warning/30 rounded px-1.5 py-0.5`,title:`Disabled — nothing new is written here. Existing data stays readable and is still pruned by age.`,children:`disabled`}),e.isSystem&&s(`span`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle bg-background border border-border rounded px-1.5 py-0.5`,title:`System-managed location — cannot be deleted; edit config to relocate`,children:`system`}),e.config.readOnly===!0&&s(`span`,{className:`text-[10px] uppercase tracking-wide text-warning bg-warning/10 border border-warning/30 rounded px-1.5 py-0.5`,title:`Drain mode — reads and age retention continue; nothing new is written here and disk-pressure eviction skips it`,children:`read-only`}),n(`div`,{className:`min-w-0`,children:[s(`div`,{className:`text-xs font-medium text-foreground truncate`,children:e.displayName}),n(`div`,{className:`flex flex-wrap items-center gap-x-2`,children:[c&&s(`span`,{className:`text-[10px] text-foreground-subtle truncate font-mono`,children:c}),s(O,{location:e})]})]})]}),n(`div`,{className:`flex flex-wrap items-center gap-1 shrink-0`,children:[n(`button`,{type:`button`,role:`switch`,"aria-label":`Writes enabled`,"aria-checked":l,disabled:u,onClick:()=>o(e,!l),title:u?`The default location of a type is always enabled — it is the fallback every balancing consumer falls back to. Promote another location to default first.`:l?`Enabled — balancing consumers may write new data here. Click to stop new writes.`:`Disabled — no new data is written here. Existing data stays readable. Click to enable.`,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium border disabled:cursor-not-allowed ${l?`border-success/30 text-success hover:bg-success/10`:`border-warning/40 text-warning hover:bg-warning/10`}`,children:[s(g,{className:`h-3 w-3`}),l?`Enabled`:`Disabled`]}),!e.isDefault&&n(`button`,{onClick:()=>a(e),className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-foreground-subtle border border-border hover:text-foreground hover:bg-primary/10`,title:`Set as default for this type`,children:[s(_,{className:`h-3 w-3`}),`Set default`]}),n(`button`,{onClick:()=>r(e),className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-foreground-subtle border border-border hover:text-foreground hover:bg-primary/10`,children:[s(m,{className:`h-3 w-3`}),`Edit`]}),!e.isSystem&&t!==`single`&&s(`button`,{onClick:()=>i(e),className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-danger hover:bg-danger/10`,title:`Delete location`,children:s(x,{className:`h-3 w-3`})})]})]})}function j({type:e,displayName:t,description:i,cardinality:a,locations:o,onAdd:c,onEdit:l,onDelete:u,onSetDefault:d,onToggleEnabled:f}){let p=r(()=>{let e=[...o];return e.sort((e,t)=>e.isDefault===t.isDefault?e.displayName.localeCompare(t.displayName):e.isDefault?-1:1),e},[o]);return n(`div`,{className:`rounded-lg border border-border bg-surface`,children:[n(`div`,{className:`flex items-start justify-between border-b border-border px-3 py-2`,children:[n(`div`,{className:`space-y-0.5`,children:[n(`div`,{className:`flex items-center gap-2`,children:[s(`span`,{className:`text-sm font-semibold text-foreground capitalize`,children:t}),s(`span`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle bg-background border border-border rounded px-1.5 py-0.5 font-mono`,children:e})]}),i&&s(`p`,{className:`text-[11px] text-foreground-subtle`,children:i}),a===`single`&&s(`p`,{className:`text-[10px] text-foreground-subtle italic`,children:`Single — one location per type. Edit the existing entry; it can't be split.`})]}),a===`multi`&&n(`button`,{onClick:()=>c(e),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`,children:[s(h,{className:`h-3 w-3`}),`Add`]})]}),p.length===0?s(`div`,{className:`px-3 py-4 text-center text-[11px] text-foreground-subtle italic`,children:a===`multi`?`No location registered. Click "Add" to register one.`:`No location registered yet — should be auto-seeded at next boot.`}):s(`div`,{children:p.map(e=>s(A,{location:e,cardinality:a,onEdit:l,onDelete:u,onSetDefault:d,onToggleEnabled:f},e.id))})]})}var M=new Set([`proc`,`sys`,`dev`,`run`,`boot`,`lost+found`,`snap`,`bin`,`sbin`,`lib`,`lib32`,`lib64`,`libx32`,`usr`,`etc`,`var`,`opt`,`tmp`,`srv`,`root`,`System`,`Library`,`Applications`,`cores`,`private`]),N=[`recordings`,`data`,`mnt`,`media`,`Volumes`];function P(e){let t=N.findIndex(t=>t===`recordings`?e.startsWith(t):e===t);return t===-1?N.length:t}function F(e){return e.filter(e=>!e.name.startsWith(`.`)&&!M.has(e.name)).toSorted((e,t)=>{let n=P(e.name)-P(t.name);return n===0?e.name.localeCompare(t.name):n}).map(e=>e.path)}t();function I({nodeId:t,value:r,onChange:i}){let a=l().trpcClient,[u,d]=o([]),[f,p]=o(r),[m,h]=o(null),[g,_]=o(null),[v,y]=o(``),b=e(async(e,n)=>{_(null);try{let r=await a.filesystemBrowse.browse.query({nodeId:t,path:e});h(r),p(r.path),n&&i(r.path)}catch(e){_(e instanceof Error?e.message:`browse failed`)}},[a,t,i]);c(()=>{p(r),(async()=>{let e=await a.filesystemBrowse.browse.query({nodeId:t,path:`/`}).then(e=>e).catch(()=>null);if(e){d(F(e.entries)),await b(r.startsWith(`/`)?r:`/`,!1);return}try{let e=await a.filesystemBrowse.listAllowedRoots.query({nodeId:t});d(e),await b(r&&e.some(e=>r.startsWith(e))?r:e[0]??``,!1)}catch(e){d([]),h(null),_(e instanceof Error&&/not available on node/i.test(e.message)?`This node can't be browsed remotely. Enter the path manually.`:e instanceof Error?e.message:`browse unavailable`)}})()},[t]);let x=async()=>{if(!(!v.trim()||!m)){_(null);try{let e=`${m.path.replace(/\/+$/,``)}/${v.trim()}`;await a.filesystemBrowse.createDir.mutate({nodeId:t,path:e}),y(``),await b(m.path,!0)}catch(e){_(e instanceof Error?e.message:`create failed`)}}},S=e=>`${(e/1e9).toFixed(1)} GB`;return n(`div`,{className:`space-y-2 rounded border border-border p-2`,children:[s(`div`,{className:`flex flex-wrap gap-1`,children:u.map(e=>s(`button`,{onClick:()=>void b(e,!0),className:`rounded border border-border px-2 py-0.5 text-[10px] font-mono hover:border-primary/40`,children:e},e))}),s(`input`,{value:f,onChange:e=>{p(e.target.value),i(e.target.value)},placeholder:`/absolute/path`,className:`w-full rounded border border-border bg-background px-2 py-1 text-[11px] font-mono`}),m&&n(`div`,{className:`text-[10px] text-foreground-subtle`,children:[S(m.freeBytes),` free / `,S(m.totalBytes)]}),s(`div`,{className:`max-h-40 space-y-0.5 overflow-y-auto`,children:m?.entries.map(e=>n(`button`,{onClick:()=>void b(e.path,!0),className:`block w-full truncate rounded px-2 py-1 text-left text-xs hover:bg-primary/5`,children:[`📁 `,e.name]},e.path))}),n(`div`,{className:`flex gap-1`,children:[s(`input`,{value:v,onChange:e=>y(e.target.value),placeholder:`new folder`,className:`flex-1 rounded border border-border bg-background px-2 py-1 text-xs`}),s(`button`,{onClick:()=>void x(),className:`rounded border border-border px-2 py-1 text-xs hover:border-primary/40`,children:`Create`})]}),g&&s(`div`,{className:`text-[10px] text-red-400`,children:g})]})}t();function L({location:e,onClose:t,onSaved:c}){let m=a(),h=l().trpcClient,[g,_]=o({...e.config}),[y,b]=o(e.displayName),[x,C]=o(null),[w,T]=o(!1),E=u(),D=r(()=>{let t=E.data;return Array.isArray(t)?t.find(t=>t.providerId===e.providerId)??null:null},[E.data,e.providerId]),O=d({onSuccess:()=>{m.invalidateQueries({queryKey:[[`storage`,`listLocations`]]}),c()}}),k=D?.shouldSaveDiskSpace===!0,A=D?.nodeLocal===!0,[j,M]=o(typeof e.nodeId==`string`?e.nodeId:`hub`),N=typeof g.basePath==`string`?g.basePath:``,P=e=>_(t=>({...t,basePath:e})),F=g.readOnly===!0,L=i({queryKey:[`storage`,`listLocations`,`ro-guard`],queryFn:()=>h.storage.listLocations.query({})}),R=(L.data??[]).filter(t=>t.type===e.type&&t.id!==e.id&&t.config.readOnly!==!0).length,z=!F&&L.data!==void 0&&R===0,B=e=>_(t=>{let n={...t};return delete n.readOnly,e?{...n,readOnly:!0}:n}),V=typeof g.maxUsedGb==`number`?g.maxUsedGb:``,H=e=>{let t=e.trim(),n=t===``?void 0:Number(t);_(e=>{let t={...e};return n===void 0||!Number.isFinite(n)||n<=0?delete t.maxUsedGb:t.maxUsedGb=n,t})},U=typeof g.minFreePercent==`number`?g.minFreePercent:``,W=e=>{let t=e.trim(),n=t===``?void 0:Number(t);_(e=>{let t={...e};return n===void 0||!Number.isFinite(n)?delete t.minFreePercent:t.minFreePercent=Math.min(100,Math.max(0,n)),t})},G=async()=>{T(!0),C(null);try{C(await(e=>h.storage.testConfig.query(e))({providerId:e.providerId,locationId:e.id,config:g}))}catch(e){C({ok:!1,error:e instanceof Error?e.message:String(e)})}finally{T(!1)}};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-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:[n(`h2`,{className:`text-sm font-semibold text-foreground`,children:[`Edit `,e.displayName]}),n(`p`,{className:`text-xs text-foreground-subtle`,children:[s(`span`,{className:`font-mono`,children:e.id}),` ·`,` `,D?.displayName??e.providerId]})]}),s(`button`,{onClick:t,className:`text-foreground-subtle hover:text-foreground`,children:s(S,{className:`h-4 w-4`})})]}),n(`div`,{className:`p-4 space-y-3 max-h-[60vh] overflow-y-auto`,children:[n(`div`,{className:`space-y-1`,children:[s(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Display name`}),s(`input`,{type:`text`,value:y,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`})]}),D&&s(p,{schema:D.configSchema,values:g,onChange:_}),n(`div`,{className:`space-y-1`,children:[n(`label`,{className:`flex items-center gap-2 text-xs ${z?`text-foreground-subtle cursor-not-allowed`:`text-foreground cursor-pointer`}`,children:[s(`input`,{type:`checkbox`,checked:F,disabled:z,onChange:e=>B(e.target.checked),className:`accent-primary`}),`Read-only (drain mode)`]}),s(`p`,{className:`text-[10px] text-foreground-subtle`,children:z?`Blocked: this is the last writable location of its type — new footage would have nowhere to go.`:`Reads and age-based retention continue; nothing new is written here and disk-pressure eviction skips it. Use it to slowly decommission a disk.`})]}),A&&n(`div`,{className:`space-y-2`,children:[s(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Node`}),s(f,{selectedNodeId:j,onSelect:M,alwaysShow:!0}),s(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Path`}),s(I,{nodeId:j,value:N,onChange:P})]}),k&&n(`div`,{className:`space-y-1`,children:[s(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Min free disk %`}),s(`input`,{type:`number`,min:0,max:100,value:U,placeholder:D?.minFreePercent==null?``:String(D.minFreePercent),onChange:e=>W(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(`p`,{className:`text-[10px] text-foreground-subtle`,children:[`When free space on this volume drops below this %, the oldest data stored here is evicted to reclaim space.`,D?.minFreePercent==null?` Empty = use the default.`:` Empty = use the default (${D.minFreePercent}%).`]}),s(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Max used (GB)`}),s(`input`,{type:`number`,min:1,value:V,placeholder:`unlimited`,onChange:e=>H(e.target.value),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`}),s(`p`,{className:`text-[10px] text-foreground-subtle`,children:`Hard cap on the TOTAL bytes evictable data (recordings) may occupy on this location, independent of disk free space — oldest footage is evicted past it. Empty = unlimited.`})]}),!D&&!E.isLoading&&n(`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:[`Provider `,s(`code`,{className:`font-mono`,children:e.providerId}),` is no longer registered. Field schema unavailable; raw config is preserved on save.`]}),x&&s(`div`,{className:`rounded border px-3 py-2 text-[11px] ${x.ok?`border-success/30 bg-success/5 text-success`:`border-danger/30 bg-danger/5 text-danger`}`,children:x.ok?`Connection OK.`:`Test failed: ${x.error??`unknown error`}`}),O.isError&&s(`div`,{className:`rounded border border-danger/30 bg-danger/5 text-danger px-3 py-2 text-[11px]`,children:O.error instanceof Error?O.error.message:String(O.error)})]}),n(`div`,{className:`flex items-center justify-between gap-2 border-t border-border px-4 py-3`,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(`div`,{className:`flex items-center gap-2`,children:[s(`button`,{onClick:()=>{G()},disabled:w||!D,className:`rounded border border-border px-3 py-1.5 text-xs text-foreground hover:bg-primary/10 disabled:opacity-50`,children:w?`Testing…`:`Test connection`}),n(`button`,{onClick:()=>{O.mutate({id:e.id,type:e.type,providerId:e.providerId,isDefault:e.isDefault,displayName:y.trim(),config:g,nodeId:A?j:void 0})},disabled:O.isPending||y.trim().length===0,className:`inline-flex items-center gap-1.5 rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50`,children:[O.isPending?s(v,{className:`h-3.5 w-3.5 animate-spin`}):null,O.isPending?`Saving…`:`Save`]})]})]})]})})}function R(e){let t=e.trim().toLowerCase();return t.length===0?``:t.replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``)}function z(e,t){let n=R(t);return`${e}:${n.length>0?n:`default`}`}t();function B({initialType:e,onClose:t,onCreated:i}){let c=a(),m=l().trpcClient,[h,g]=o(`picker`),[_,b]=o(e),[x,C]=o(null),[w,T]=o({}),[E,D]=o(``),[O,k]=o(null),[A,j]=o(!1),[M,N]=o(!1),[P,F]=o(`hub`),[L,R]=o(null),[B,V]=o(!1),H=e=>T(t=>({...t,basePath:e})),U=typeof w.basePath==`string`?w.basePath:``,W=u(),G=r(()=>{let e=W.data;return Array.isArray(e)?e:[]},[W.data]),K=W.isLoading,q=d({onSuccess:()=>{c.invalidateQueries({queryKey:[[`storage`,`listLocations`]]}),i()}}),J=r(()=>O!==null&&O.length>0?O:z(_,E),[_,E,O]),Y=async()=>{if(x){V(!0),R(null);try{R(await(e=>m.storage.testConfig.query(e))({providerId:x.providerId,config:w}))}catch(e){R({ok:!1,error:e instanceof Error?e.message:String(e)})}finally{V(!1)}}};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-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:{picker:`Add Location — Pick provider`,config:`Add Location — ${x?.displayName??``}`,naming:`Add Location — Name & defaults`}[h]}),n(`p`,{className:`text-xs text-foreground-subtle`,children:[`Type: `,s(`span`,{className:`font-mono`,children:_})]})]}),s(`button`,{onClick:t,className:`text-foreground-subtle hover:text-foreground`,children:s(S,{className:`h-4 w-4`})})]}),h===`picker`&&n(`div`,{className:`p-4 space-y-2`,children:[K&&s(`div`,{className:`text-xs text-foreground-subtle animate-pulse`,children:`Loading providers…`}),!K&&G.length===0&&n(`div`,{className:`rounded border border-border bg-background px-3 py-4 text-center text-xs text-foreground-subtle`,children:[`No storage-provider supports type "`,_,`". Install a compatible addon (e.g.`,` `,s(`code`,{className:`font-mono`,children:`remote-storage`}),`) to enable it.`]}),G.map(e=>n(`button`,{onClick:()=>{C(e),g(`config`)},className:`flex w-full items-center gap-3 rounded-lg border border-border bg-background p-3 text-left hover:border-primary/40 hover:bg-primary/5 transition-colors`,children:[n(`div`,{className:`flex-1 min-w-0`,children:[s(`p`,{className:`text-xs font-semibold text-foreground`,children:e.displayName}),s(`p`,{className:`text-[10px] text-foreground-subtle font-mono mt-0.5 truncate`,children:e.providerId})]}),s(y,{className:`h-4 w-4 text-foreground-subtle flex-shrink-0`})]},e.providerId))]}),h===`config`&&x&&n(`div`,{className:`p-4 space-y-3 max-h-[60vh] overflow-y-auto`,children:[s(p,{schema:x.configSchema,values:w,onChange:T}),x.nodeLocal&&n(`div`,{className:`space-y-2`,children:[s(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Node`}),s(f,{selectedNodeId:P,onSelect:F,alwaysShow:!0}),s(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Path`}),s(I,{nodeId:P,value:U,onChange:H})]}),L&&s(`div`,{className:`rounded border px-3 py-2 text-[11px] ${L.ok?`border-success/30 bg-success/5 text-success`:`border-danger/30 bg-danger/5 text-danger`}`,children:L.ok?`Connection OK.`:`Test failed: ${L.error??`unknown error`}`}),n(`div`,{className:`flex items-center justify-between pt-1`,children:[s(`button`,{onClick:()=>g(`picker`),className:`rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground`,children:`Back`}),n(`div`,{className:`flex items-center gap-2`,children:[s(`button`,{onClick:()=>{Y()},disabled:B,className:`rounded border border-border px-3 py-1.5 text-xs text-foreground hover:bg-primary/10 disabled:opacity-50`,children:B?`Testing…`:`Test connection`}),s(`button`,{onClick:()=>g(`naming`),className:`rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90`,children:`Next`})]})]})]}),h===`naming`&&x&&n(`div`,{className:`p-4 space-y-3`,children:[n(`div`,{className:`space-y-1`,children:[s(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Display name`}),s(`input`,{type:`text`,value:E,onChange:e=>D(e.target.value),placeholder:`${_} on ${x.displayName}`,className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`})]}),n(`div`,{className:`space-y-1`,children:[n(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:[`Id`,` `,s(`span`,{className:`lowercase tracking-normal text-foreground-subtle`,children:`— auto-derived; override if needed`})]}),s(`input`,{type:`text`,value:J,onChange:e=>k(e.target.value),placeholder:z(_,E),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground font-mono focus:outline-none focus:ring-1 focus:ring-primary`}),n(`p`,{className:`text-[10px] text-foreground-subtle`,children:[`Format: `,s(`code`,{className:`font-mono`,children:`<type>:<slug>`}),`. Lowercase letters, digits, and hyphens only.`]})]}),n(`label`,{className:`flex items-start gap-2 rounded border border-border bg-background px-3 py-2 cursor-pointer hover:bg-primary/5`,children:[s(`input`,{type:`checkbox`,checked:A,onChange:e=>j(e.target.checked),className:`accent-primary mt-0.5`}),n(`div`,{className:`space-y-0.5`,children:[n(`div`,{className:`text-xs font-medium text-foreground`,children:[`Mark as default for type "`,_,`"`]}),n(`div`,{className:`text-[10px] text-foreground-subtle`,children:[`Setting this as default will demote the current default for this type. References like `,n(`code`,{className:`font-mono`,children:[`"`,_,`"`]}),` resolve to whichever location is the default.`]})]})]}),n(`label`,{className:`flex items-start gap-2 rounded border border-border bg-background px-3 py-2 cursor-pointer hover:bg-primary/5`,children:[s(`input`,{type:`checkbox`,checked:M,onChange:e=>N(e.target.checked),className:`accent-primary mt-0.5`}),n(`div`,{className:`space-y-0.5`,children:[s(`div`,{className:`text-xs font-medium text-foreground`,children:`Enable immediately`}),s(`div`,{className:`text-[10px] text-foreground-subtle`,children:`A disabled location receives no writes until enabled — reads and age-based retention still work, nothing new lands here. Leave this off to register the disk now and start using it later.`})]})]}),q.isError&&s(`div`,{className:`rounded border border-danger/30 bg-danger/5 text-danger px-3 py-2 text-[11px]`,children:q.error instanceof Error?q.error.message:String(q.error)}),n(`div`,{className:`flex items-center justify-between pt-1`,children:[s(`button`,{onClick:()=>g(`config`),className:`rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground`,children:`Back`}),n(`div`,{className:`flex items-center gap-2`,children:[s(`button`,{onClick:()=>{b(e),C(null),T({}),D(``),k(null),j(!1),N(!1),R(null),g(`picker`)},className:`rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground`,children:`Reset`}),n(`button`,{onClick:()=>{x&&q.mutate({id:J,type:_,displayName:E.trim(),providerId:x.providerId,config:w,isDefault:A,enabled:M,nodeId:x.nodeLocal?P:void 0})},disabled:q.isPending||E.trim().length===0,className:`inline-flex items-center gap-1.5 rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50`,children:[q.isPending?s(v,{className:`h-3.5 w-3.5 animate-spin`}):null,q.isPending?`Saving…`:`Save`]})]})]})]})]})})}export{C as a,E as i,L as n,j as r,B as t};
@@ -1 +0,0 @@
1
- import{I as e,K as t,Q as n,R as r,S 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{Q as d}from"./player-overlays-MJd9eRlM.js";import{$i as f,An as p,Bn as m,Bs as h,C as g,Cn as _,Dn as v,En as y,Fn as b,Hn as x,In as S,J as C,Ln as w,Ls as T,Mn as ee,Nn as te,On as ne,Rn as E,Sn as D,Tn as re,Vn as ie,g as O,jn as ae,q as oe,un as se,wn as ce,xn as le}from"./src-DwTflGqD.js";import{Bt as k}from"./src-0iNMzZ2l.js";import{t as A}from"./clock-Cl7hHyqW.js";import{t as j}from"./download-CBTHh5Td.js";import{t as ue}from"./plus-BgigjkU9.js";import{t as M}from"./refresh-cw-Budztdr-.js";import{C as N,J as de,K as P,P as fe,R as F,X as pe,_ as I,f as me,m as he,o as L,p as R,r as z,z as B}from"./index-D-9Wyuju.js";import{t as V}from"./AdminPage-CCD07UMs.js";import{t as H}from"./NodeAddonsSettingsPanel-CF38Xfjd.js";import{r as U,t as W}from"./useNodeUrlSelection-Dsk2NydD.js";var ge=P(`chevron-up`,[[`path`,{d:`m18 15-6-6-6 6`,key:`153udz`}]]),_e=P(`octagon-alert`,[[`path`,{d:`M12 16h.01`,key:`1drbdi`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M15.312 2a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586l-4.688-4.688A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2z`,key:`1fd625`}]]),ve=P(`package`,[[`path`,{d:`M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z`,key:`1a0edw`}],[`path`,{d:`M12 22V12`,key:`d0xqtd`}],[`polyline`,{points:`3.29 7 12 12 20.71 7`,key:`ousv84`}],[`path`,{d:`m7.5 4.27 9 5.15`,key:`1c824w`}]]),ye=P(`skip-forward`,[[`polygon`,{points:`5 4 15 12 5 20 5 4`,key:`16p6eg`}],[`line`,{x1:`19`,x2:`19`,y1:`5`,y2:`19`,key:`futhcm`}]]),G=P(`upload`,[[`path`,{d:`M12 3v12`,key:`1x0j5s`}],[`path`,{d:`m17 8-5-5-5 5`,key:`7q97r8`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}]]);n();var K=new Set([`completed`,`failed`,`partially-failed`,`cancelled`]),q=new Set([`done`,`failed`,`skipped`]);function J(e){return!q.has(e.phase)&&!K.has(e.jobState)}function be(e,t){let n=new Map,r=[...e].sort((e,t)=>e.createdAtMs-t.createdAtMs);for(let e of r){let r=K.has(e.state);for(let i of e.tasks)r&&i.finishedAtMs!==null&&t-i.finishedAtMs>6e4||n.set(i.packageName,{jobId:e.jobId,packageName:i.packageName,phase:i.phase,fromVersion:i.fromVersion,toVersion:i.toVersion,error:i.error,jobState:e.state,finishedAtMs:i.finishedAtMs})}return n}function xe(){let{data:e}=p({activeOnly:!0},{refetchOnWindowFocus:!1,refetchInterval:e=>(e.state.data?.length??0)>0?3e3:!1}),{map:t}=h(k.AddonsJobProgress,e=>e.job.jobId);return a(()=>{let n=new Map;for(let t of e??[])n.set(t.jobId,t);for(let[e,r]of t)n.set(e,r.job);return be([...n.values()],Date.now())},[e,t])}var Y={queued:{icon:A,cls:`bg-muted text-foreground-subtle`,label:`queued`},fetching:{icon:N,cls:`bg-primary/10 text-primary`,label:`fetching`,spin:!0},staged:{icon:N,cls:`bg-primary/10 text-primary`,label:`staged`,spin:!0},validating:{icon:N,cls:`bg-primary/10 text-primary`,label:`validating`,spin:!0},applying:{icon:N,cls:`bg-primary/10 text-primary`,label:`applying`,spin:!0},restarting:{icon:N,cls:`bg-amber-500/10 text-amber-600 dark:text-amber-400`,label:`restarting`,spin:!0},applied:{icon:N,cls:`bg-primary/10 text-primary`,label:`finalizing`,spin:!0},done:{icon:B,cls:`bg-success/10 text-success`,label:`updated`},failed:{icon:_e,cls:`bg-danger/10 text-danger`,label:`failed`},skipped:{icon:ye,cls:`bg-muted text-foreground-subtle`,label:`skipped`}};function Se({progress:e}){let t=Y[e.phase],n=t.icon,r=e.error??`${e.packageName}: ${e.fromVersion??`?`} → ${e.toVersion}`;return i(`span`,{"data-testid":`addon-job-progress`,className:`inline-flex items-center gap-1 px-1.5 py-0.5 text-[10px] rounded shrink-0 ${t.cls}`,title:r,children:[l(n,{className:`w-2.5 h-2.5 ${t.spin?`animate-spin`:``}`}),t.label,i(`span`,{className:`font-mono`,children:[`→ `,e.toVersion]})]})}function Ce({packageName:e,currentVersion:t,installSource:n,onInstall:r,onClose:a,onSelect:s,selectedVersion:c}){let u=n===`upload`||n===`local`,{data:d,isLoading:f}=y({name:e});return i(`div`,{className:`fixed z-50 w-72 rounded-lg border border-border bg-surface shadow-xl overflow-hidden`,style:{top:`auto`,bottom:`auto`},ref:e=>{if(!e)return;let t=e.parentElement?.getBoundingClientRect();if(!t)return;let n=window.innerHeight-t.bottom,r=t.top;n<280&&r>n?(e.style.bottom=`${window.innerHeight-t.top+4}px`,e.style.top=`auto`):(e.style.top=`${t.bottom+4}px`,e.style.bottom=`auto`),e.style.right=`${window.innerWidth-t.right}px`},onClick:e=>e.stopPropagation(),children:[i(`div`,{className:`flex items-center justify-between px-3 py-2 border-b border-border`,children:[l(`span`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle font-medium`,children:`Versions`}),l(`button`,{type:`button`,onClick:a,className:`text-foreground-subtle hover:text-foreground`,children:l(z,{className:`h-3 w-3`})})]}),u&&i(`div`,{className:`flex items-start gap-2 px-3 py-2 border-b border-border bg-cyan-500/10 text-[10px]`,children:[l(G,{className:`h-3 w-3 mt-0.5 text-cyan-500 shrink-0`}),i(`div`,{className:`text-cyan-700 dark:text-cyan-200`,children:[i(`span`,{className:`font-semibold`,children:[n===`upload`?`Uploaded copy`:`Local copy`,` in place.`]}),` `,`Re-install `,l(`span`,{className:`font-mono`,children:t}),` from npm to track upstream releases again.`]})]}),f&&i(`div`,{className:`flex items-center justify-center gap-2 py-6 text-[10px] text-foreground-subtle`,children:[l(N,{className:`h-3.5 w-3.5 animate-spin`}),`Loading versions...`]}),d&&l(`div`,{className:`max-h-64 overflow-auto divide-y divide-border`,children:d.map(e=>{let n=e.version===t,a=s!==void 0&&e.version===c,d=/-(alpha|beta|rc|dev|canary|next)/i.test(e.version),f=i(o,{children:[l(`span`,{className:`font-mono flex-1 text-left ${n?`text-primary font-semibold`:d?`text-amber-400`:`text-foreground`}`,children:e.version}),n&&l(`span`,{className:`text-[9px] rounded-full px-1.5 py-0.5 font-medium bg-primary/10 text-primary`,children:`current`}),e.distTags.map(e=>l(`span`,{className:`text-[9px] rounded-full px-1.5 py-0.5 font-medium ${e===`latest`?`bg-emerald-500/15 text-emerald-400`:e===`beta`?`bg-amber-500/15 text-amber-400`:`bg-gray-500/15 text-gray-400`}`,children:e},e)),e.deprecated&&l(`span`,{className:`text-[9px] text-red-400 line-through`,children:`deprecated`}),l(`span`,{className:`text-[9px] text-foreground-subtle shrink-0`,children:new Date(e.publishedAt).toLocaleDateString()})]});return s?i(`button`,{type:`button`,"aria-label":`Select ${e.version}`,onClick:()=>s(e.version),className:`w-full flex items-center gap-2 px-3 py-2 text-[11px] ${a?`bg-primary/5`:`hover:bg-surface-hover`} transition-colors`,children:[f,a?l(B,{className:`h-3 w-3 text-primary shrink-0`}):l(`span`,{className:`w-3 shrink-0`})]},e.version):i(`div`,{className:`flex items-center gap-2 px-3 py-2 text-[11px] ${n?`bg-primary/5`:`hover:bg-surface-hover`} transition-colors`,children:[f,n&&!u?l(B,{className:`h-3 w-3 text-primary shrink-0`}):l(`button`,{type:`button`,onClick:()=>r(e.version),className:`shrink-0 rounded p-0.5 hover:bg-primary/20 text-foreground-subtle hover:text-primary transition-colors`,title:n?`Re-install ${e.version} from npm`:`Install ${e.version}`,children:l(j,{className:`h-3 w-3`})})]},e.version)})}),d&&d.length===0&&l(`div`,{className:`py-4 text-center text-[10px] text-foreground-subtle`,children:`No versions found`})]})}var X={queued:{icon:A,bg:`bg-muted text-foreground-subtle`,label:`queued`},updating:{icon:N,bg:`bg-primary/10 text-primary`,label:`updating`,spin:!0},"done-pending-restart":{icon:M,bg:`bg-amber-500/10 text-amber-700`,label:`pending restart`},done:{icon:B,bg:`bg-success/10 text-success`,label:`done`},failed:{icon:_e,bg:`bg-danger/10 text-danger`,label:`failed`}};function Z({item:e}){let t=X[e.status],n=t.icon;return i(`span`,{className:`inline-flex items-center gap-1 px-1.5 py-0.5 text-[10px] rounded ${t.bg}`,title:e.error,children:[l(n,{className:`w-2.5 h-2.5 ${t.spin?`animate-spin`:``}`}),t.label]})}n();var Q=`device-export`;function we(e){return e.capabilities.some(e=>(typeof e==`string`?e:e.name)===Q)}function Te({isBundle:e,installSource:t,addonId:n,iconPath:r,color:a}){let[o,s]=c(!1),u=a?{backgroundColor:`${a.startsWith(`#`)?a:`#${a}`}26`}:void 0,d=e?`bg-indigo-500/20 text-indigo-700 dark:text-indigo-300`:`bg-purple-500/20 text-purple-700 dark:text-purple-300`,f=n&&r?`/api/addon-assets/${n}/${r}`:null,p=!!f&&!o;return i(`div`,{className:`relative flex-shrink-0`,children:[l(`div`,{className:`h-9 w-9 rounded-lg flex items-center justify-center ${u?``:d}`,style:u,children:p?l(`img`,{src:f,alt:n,className:`h-5 w-5`,onError:()=>s(!0)}):l(e?ve:I,{className:`h-4 w-4`})}),t===`local`&&l(`span`,{className:`absolute -top-1.5 -left-1.5 text-[7px] font-bold leading-none bg-orange-500 text-white px-1 py-0.5 rounded -rotate-12 shadow-sm`,children:`DEV`}),t===`npm`&&l(`span`,{className:`absolute -top-1 -left-1 w-4 h-4 rounded bg-[#cb3837] flex items-center justify-center -rotate-12 shadow-sm`,children:l(`svg`,{viewBox:`0 0 780 250`,className:`w-[11px] h-[11px]`,children:l(`path`,{fill:`#fff`,d:`M240 250h100V50h100v200h340V0H0v250z`})})}),t===`upload`&&l(`span`,{className:`absolute -top-1.5 -left-1.5 flex items-center justify-center h-4 w-4 rounded bg-cyan-500 -rotate-12 shadow-sm`,children:l(G,{className:`h-2.5 w-2.5 text-white`})})]})}function Ee({version:e,availableUpdate:t,selectedVersion:n,isUpdating:r,installSource:a,disabled:o,onUpdate:s,onOpenPicker:c,children:u}){if(r)return i(`span`,{className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-[10px] font-medium border border-blue-500/30 bg-blue-500/10 text-blue-400 shrink-0`,children:[l(N,{className:`h-3 w-3 animate-spin`}),`Updating…`]});if(t){let r=n??t;return i(`div`,{className:`relative inline-flex items-center gap-1 shrink-0`,children:[s&&i(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),s()},disabled:o,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-[10px] font-semibold border border-blue-500/30 bg-blue-500/10 text-blue-400 hover:bg-blue-500/20 disabled:opacity-50 disabled:cursor-not-allowed transition-colors`,title:`Update to ${r}`,children:[l(j,{className:`h-3 w-3`}),`Update`]}),i(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),c()},disabled:o,"aria-label":`Select version to install`,title:`Installed ${e} — update available. Selected ${r}; tap to choose another version.`,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-[10px] font-bold font-mono border border-amber-500/40 bg-amber-500/15 text-amber-500 hover:bg-amber-500/25 animate-pulse disabled:opacity-50 disabled:cursor-not-allowed transition-colors`,children:[l(`span`,{className:`font-normal opacity-70`,children:e}),l(`span`,{className:`font-normal opacity-70`,children:`→`}),r,l(F,{className:`h-3 w-3`})]}),u]})}return i(`div`,{className:`relative inline-flex items-center gap-1 shrink-0`,children:[i(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),c()},disabled:o,className:[`inline-flex items-center gap-1 rounded-md px-2 py-1 text-[10px] font-bold font-mono border transition-colors disabled:opacity-50 disabled:cursor-not-allowed`,a===`local`?`border-orange-500/30 bg-orange-500/10 text-orange-400 hover:bg-orange-500/20`:`border-emerald-500/30 bg-emerald-500/10 text-emerald-400 hover:bg-emerald-500/20`].join(` `),title:`Version ${e} — tap to view all versions`,children:[e,l(F,{className:`h-3 w-3 opacity-50`})]}),u]})}function De({addonId:e}){let t=s(),{data:n=`inherit`}=_({addonId:e}),r=w({onSuccess:()=>{t.invalidateQueries({queryKey:[[`addons`,`getAddonAutoUpdate`]]})}});return l(`div`,{className:`flex rounded-lg border border-border overflow-hidden text-[10px] font-medium`,children:[`inherit`,`off`,`latest`,`beta`].map(t=>l(`button`,{type:`button`,onClick:n=>{n.stopPropagation(),r.mutate({addonId:e,channel:t})},disabled:r.isPending,className:`px-2.5 py-1 transition-colors capitalize ${n===t?t===`inherit`?`bg-gray-700/50 text-gray-700 dark:text-gray-300`:t===`off`?`bg-gray-700 text-gray-700 dark:text-gray-300`:t===`latest`?`bg-blue-500/20 text-blue-400`:`bg-amber-500/20 text-amber-400`:`bg-transparent text-foreground-subtle hover:bg-surface-hover`} ${t===`inherit`?``:`border-l border-border`}`,children:t},t))})}function Oe({addon:e,agents:t=[],clusterStatus:n,hideVersion:r,availableUpdate:a,onUpdate:f,isUpdating:p,jobProgress:m,bundle:h,bulkItem:_,disabledByBulk:y,isSystem:x}){let[S,w]=c(!1),[T,ee]=c(!1),[ne,E]=c(!1),[D,re]=c(null);u(()=>{re(null)},[a]);let O=D??a,[ae,ce]=c(!1),[le,k]=c(!1),[A,j]=c(`logs`),N=s(),P=d(),fe=de(),pe=se(),{manifest:I}=e,R=e.installedOn??[],B=!h&&!I.protected&&I.removable!==!1,V=!!h,U=h?.displayName??I.name,W=h?.packageName??I.packageName,ye=h?.version??I.packageVersion??I.version,G=h?.installSource??e.installSource,K=h?h.bundle?.description??h.addons[0]?.manifest.description:I.description,q=ie({onSuccess:()=>{N.invalidateQueries({queryKey:[[`addons`]]}),N.invalidateQueries({queryKey:[[`addonPages`]]}),N.invalidateQueries({queryKey:[[`capabilities`]]})}}),J=te({onSuccess:()=>{N.invalidateQueries({queryKey:[[`addons`]]})}}),be=v({onSuccess:()=>{N.invalidateQueries({queryKey:[[`addons`]]}),N.invalidateQueries({queryKey:[[`addonPages`]]}),N.invalidateQueries({queryKey:[[`capabilities`]]}),N.invalidateQueries({queryKey:[[`integrations`]]})}}),xe=b({onSuccess:()=>{N.invalidateQueries({queryKey:[[`addons`]]}),N.invalidateQueries({queryKey:[[`alerts`]]})}}),Y=e.health,X=Y?.phase===`failed`&&!Y.inGracePeriod,Q=X&&Y?.nextRetryAt&&!Y.retrying;return i(`div`,{className:`rounded-lg border bg-surface overflow-hidden ${X?`border-red-500/50`:`border-border`}`,children:[X&&Y&&i(`div`,{className:`bg-danger/10 border-b border-danger/30 px-4 py-2.5 flex items-start gap-2.5`,children:[l(_e,{className:`h-4 w-4 text-danger shrink-0 mt-0.5`}),i(`div`,{className:`flex-1 min-w-0`,children:[i(`div`,{className:`text-xs font-semibold text-danger`,children:[`Failed to load (attempt #`,Y.retryCount,`)`]}),l(`div`,{className:`text-[11px] text-foreground mt-0.5 break-words font-mono`,children:Y.lastError?.message??`Unknown error`}),Q&&Y.nextRetryAt&&i(`div`,{className:`text-[10px] text-foreground-subtle mt-1`,children:[`Auto-retry at `,new Date(Y.nextRetryAt).toLocaleTimeString()]})]}),i(`button`,{type:`button`,disabled:xe.isPending||Y.retrying,onClick:e=>{e.stopPropagation(),xe.mutate({packageName:W})},className:`inline-flex items-center gap-1.5 rounded-md px-2.5 py-1 text-[11px] font-semibold border border-red-400/40 bg-red-400/10 text-red-700 dark:text-red-300 hover:bg-red-400/20 disabled:opacity-50 disabled:cursor-not-allowed transition-colors shrink-0`,title:`Reset retry counter and force immediate reload`,children:[l(M,{className:`h-3 w-3 ${xe.isPending||Y.retrying?`animate-spin`:``}`}),`Retry now`]})]}),i(`div`,{className:`flex items-start gap-3 px-4 py-3`,children:[l(Te,{isBundle:V||!!I.components&&I.components.length>1,installSource:G,addonId:V?h.addons[0]?.manifest.id:I.id,iconPath:V?h.bundle?.icon??h.addons[0]?.manifest.icon:I.icon,color:V?h.addons[0]?.manifest.color:I.color}),i(`div`,{className:`flex-1 min-w-0`,children:[i(`div`,{className:`flex items-start justify-between gap-2`,children:[l(`span`,{className:`text-sm font-semibold text-foreground truncate min-w-0`,children:U}),!r&&l(Ee,{version:ye,availableUpdate:a,...O===void 0?{}:{selectedVersion:O},isUpdating:p,installSource:G,disabled:y,...f&&O!==void 0?{onUpdate:()=>f(O)}:{},onOpenPicker:()=>E(e=>!e),children:ne&&l(Ce,{packageName:W,currentVersion:ye,...G?{installSource:G}:{},...a!==void 0&&O!==void 0?{selectedVersion:O,onSelect:e=>{re(e),E(!1)}}:{},onInstall:e=>{E(!1),be.mutate({packageName:W,version:e})},onClose:()=>E(!1)})})]}),i(`div`,{className:`flex flex-wrap items-center gap-x-1.5 gap-y-1 mt-0.5`,children:[W!==U&&l(`span`,{className:`text-[10px] text-foreground-subtle font-mono truncate max-w-full`,children:W}),V&&i(`span`,{className:`text-[10px] rounded-full bg-primary/10 text-primary px-2 py-0.5 font-medium shrink-0 inline-flex items-center gap-1`,children:[l(ve,{className:`h-3 w-3`}),h.addons.length]}),x&&i(`span`,{className:`text-[10px] rounded-full bg-amber-500/15 text-amber-700 dark:text-amber-300 px-2 py-0.5 font-medium shrink-0 inline-flex items-center gap-1`,title:`System package — updating restarts the hub`,children:[l(M,{className:`h-3 w-3`}),`System`]}),_!=null&&l(Z,{item:_}),m!=null&&l(Se,{progress:m})]}),K&&l(`p`,{className:`text-[10px] text-foreground-subtle mt-1 line-clamp-1`,children:K}),!V&&e.process&&i(`div`,{className:`flex flex-wrap items-center gap-1.5 mt-1`,children:[l(`span`,{className:`text-[9px] rounded-full px-1.5 py-0.5 font-medium ${e.process.mode===`forked`?`bg-blue-500/15 text-blue-400`:`bg-gray-500/15 text-gray-400`}`,children:e.process.mode===`forked`?`forked`:`in-process`}),e.process.pid!=null&&i(`span`,{className:`text-[9px] font-mono text-foreground-subtle`,children:[`PID `,e.process.pid]}),l(`span`,{className:`text-[9px] rounded-full px-1.5 py-0.5 font-medium ${e.process.state===`running`?`bg-emerald-500/15 text-emerald-400`:e.process.state===`crashed`||e.process.state===`failed`?`bg-red-500/15 text-red-400`:`bg-gray-500/15 text-gray-400`}`,children:e.process.state})]})]})]}),!V&&i(`div`,{className:`flex items-center gap-1 px-4 py-1.5 border-t border-border/50 bg-surface-hover/20`,children:[i(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),J.mutate({addonId:I.id})},disabled:J.isPending||y,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-[10px] font-medium border border-border text-foreground-subtle hover:text-blue-400 hover:border-blue-500/30 hover:bg-blue-500/10 disabled:opacity-50 transition-colors`,children:[l(M,{className:`h-3 w-3 ${J.isPending?`animate-spin`:``}`}),`Restart`]}),i(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),ce(e=>!e)},className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-[10px] font-medium border transition-colors ${ae?`border-primary/30 bg-primary/10 text-primary`:`border-border text-foreground-subtle hover:text-foreground hover:border-primary/30 hover:bg-primary/10`}`,children:[l(he,{className:`h-3 w-3`}),`Logs`]}),!V&&i(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),k(!0)},className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-[10px] font-medium border transition-colors ${le?`border-primary/30 bg-primary/10 text-primary`:`border-border text-foreground-subtle hover:text-foreground hover:border-primary/30 hover:bg-primary/10`}`,children:[l(me,{className:`h-3 w-3`}),`Settings`]}),l(`div`,{className:`flex-1`}),B&&i(`button`,{type:`button`,onClick:async e=>{e.stopPropagation(),await pe({title:`Uninstall ${I.name}?`,message:`This will remove the addon package and all its data. This action cannot be undone.`,confirmLabel:`Uninstall`,variant:`danger`})&&q.mutate({packageName:I.packageName})},disabled:q.isPending||y,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-[10px] font-medium border border-border text-foreground-subtle hover:text-red-400 hover:border-red-500/30 hover:bg-red-500/10 disabled:opacity-50 transition-colors`,children:[l(L,{className:`h-3 w-3`}),q.isPending?`Removing...`:`Uninstall`]})]}),n&&n.nodes.length>1&&!V&&i(`div`,{className:`border-t border-border px-4 py-2 bg-muted/10`,children:[l(`div`,{className:`text-[10px] font-medium text-foreground-subtle mb-1.5`,children:`Cluster Deployment`}),l(`div`,{className:`space-y-1`,children:n.nodes.map(e=>i(`div`,{className:`flex items-center gap-2 text-[10px]`,children:[l(`div`,{className:`h-1.5 w-1.5 rounded-full shrink-0 ${e.status===`offline`?`bg-muted-foreground/30`:e.synced?`bg-success`:`bg-amber-500`}`}),l(`span`,{className:`font-medium text-foreground min-w-[60px]`,children:e.name}),l(`span`,{className:`font-mono text-foreground-subtle`,children:e.version}),!e.synced&&e.status!==`offline`&&l(`span`,{className:`text-[9px] px-1 py-0.5 rounded bg-amber-500/10 text-amber-400 border border-amber-500/20`,children:`outdated`}),e.status===`offline`&&l(`span`,{className:`text-[9px] px-1 py-0.5 rounded bg-muted text-muted-foreground`,children:`offline`}),e.synced&&e.status!==`offline`&&l(`span`,{className:`text-[9px] text-success`,children:`synced`})]},e.nodeId))})]}),ae&&!V&&i(`div`,{className:`border-t border-border`,children:[i(`div`,{className:`flex items-center px-4 py-1 bg-surface-hover/20 border-b border-border/50`,children:[i(`div`,{className:`flex rounded border border-border overflow-hidden text-[9px]`,children:[l(`button`,{type:`button`,onClick:()=>j(`logs`),className:`px-2 py-0.5 transition-colors ${A===`logs`?`bg-primary/10 text-primary`:`text-foreground-subtle hover:bg-surface-hover`}`,children:`Logs`}),l(`button`,{type:`button`,onClick:()=>j(`events`),className:`px-2 py-0.5 border-l border-border transition-colors ${A===`events`?`bg-primary/10 text-primary`:`text-foreground-subtle hover:bg-surface-hover`}`,children:`Events`})]}),l(`div`,{className:`flex-1`}),l(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),ce(!1)},className:`text-foreground-subtle hover:text-foreground`,children:l(z,{className:`h-3.5 w-3.5`})})]}),A===`logs`&&l(C,{addonId:I.id,maxHeight:`max-h-64`,showFilters:!1}),A===`events`&&l(oe,{addonId:I.id,category:`addon.*`,maxHeight:`max-h-64`})]}),V&&i(o,{children:[l(`button`,{type:`button`,onClick:()=>w(e=>!e),className:`w-full flex items-center justify-center border-t border-border py-1 hover:bg-surface-hover/50 transition-colors`,children:l(S?ge:F,{className:`h-3.5 w-3.5 text-foreground-subtle`})}),S&&l(`div`,{className:`border-t border-border px-3 py-2 space-y-2`,children:h.addons.map(e=>l(Oe,{addon:e,agents:t,hideVersion:!0},e.manifest.id))})]}),le&&!V&&l(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm p-4`,onClick:()=>k(!1),children:i(`div`,{className:`w-full max-w-lg max-h-[80vh] rounded-xl border border-border bg-surface shadow-2xl flex flex-col overflow-hidden`,onClick:e=>e.stopPropagation(),children:[i(`div`,{className:`flex items-center justify-between px-5 py-3 border-b border-border flex-shrink-0`,children:[i(`div`,{className:`flex items-center gap-2`,children:[l(me,{className:`h-4 w-4 text-primary`}),i(`h2`,{className:`text-sm font-semibold text-foreground`,children:[U,` Settings`]})]}),l(`button`,{onClick:()=>k(!1),className:`text-foreground-subtle hover:text-foreground transition-colors p-1 rounded`,children:l(z,{className:`h-4 w-4`})})]}),i(`div`,{className:`flex-1 overflow-y-auto px-5 py-4 space-y-4`,children:[l(`div`,{className:`text-[10px] text-foreground-subtle mb-2`,children:`Cluster-wide settings — one value for every node. Per-node settings live under Cluster → the node → Settings.`}),l(H,{nodeId:null,addonIds:[I.id],level:`global`,fieldScope:`cluster`,emptyMessage:`This addon exposes no cluster-wide settings. Anything it can configure is per-node — open it from Cluster → the node → Settings.`}),we(I)&&i(`div`,{children:[l(`div`,{className:`text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2`,children:`Device export`}),l(g,{addonId:I.id,trpc:P.trpcClient,onOpenDevice:e=>fe(`/devices/${e}`)})]}),G===`npm`&&i(`div`,{children:[l(`div`,{className:`text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2`,children:`Auto-Update`}),l(De,{addonId:I.id})]}),I.components&&I.components.length>0&&i(`div`,{children:[i(`div`,{className:`text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2`,children:[`Components (`,I.components.length,`)`]}),l(`div`,{className:`flex flex-wrap gap-1`,children:I.components.map(e=>l(`span`,{className:`text-[10px] rounded bg-background border border-border px-1.5 py-0.5 text-foreground-subtle font-mono`,children:e},e))})]}),t.length>=2&&i(`div`,{children:[l(`div`,{className:`text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2`,children:`Installed on`}),i(`div`,{className:`flex items-center gap-1.5 flex-wrap`,children:[R.length===0&&l(`span`,{className:`text-[10px] text-foreground-subtle`,children:`Hub (local)`}),R.map(e=>l(`span`,{className:`rounded-full bg-surface-hover border border-border px-2 py-0.5 text-[10px] text-foreground-subtle`,children:e},e)),i(`div`,{className:`relative`,children:[i(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),ee(e=>!e)},className:`inline-flex items-center gap-1 rounded-full border border-dashed border-border px-2 py-0.5 text-[10px] text-foreground-subtle hover:text-foreground hover:border-primary transition-colors`,title:`Install on more agents`,children:[l(ue,{className:`h-3 w-3`}),`Add agent`]}),T&&i(`div`,{className:`absolute left-0 top-full mt-1 z-10 min-w-[160px] rounded-md border border-border bg-surface shadow-lg overflow-hidden`,children:[t.filter(e=>!e.isHub&&!R.includes(e.name)).map(e=>l(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),ee(!1)},className:`w-full text-left px-3 py-1.5 text-[10px] text-foreground hover:bg-surface-hover transition-colors`,children:e.name},e.id)),t.filter(e=>!e.isHub&&!R.includes(e.name)).length===0&&l(`div`,{className:`px-3 py-1.5 text-[10px] text-foreground-subtle`,children:`No available agents`})]})]})]})]})]}),l(`div`,{className:`flex items-center justify-end px-5 py-3 border-t border-border flex-shrink-0`,children:l(`button`,{type:`button`,onClick:()=>k(!1),className:`rounded-lg border border-border px-3 py-1.5 text-xs font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,children:`Close`})})]})})]})}n();var ke=`.tgz,.tar.gz,.zip`;function Ae({onUploadSuccess:n}){let[r,a]=c(!1),s=t(null),u=e(async e=>{a(!0);let t=new FormData;t.append(`file`,e);let r=localStorage.getItem(`camstack_admin_token`)??``;try{(await(await fetch(`/api/addons/upload`,{method:`POST`,headers:{Authorization:`Bearer ${r}`},body:t})).json()).success&&n()}finally{a(!1)}},[n]);return i(o,{children:[l(`input`,{ref:s,type:`file`,accept:ke,onChange:e(e=>{let t=e.target.files?.[0];t&&u(t),e.target.value=``},[u]),className:`hidden`}),i(`button`,{type:`button`,onClick:()=>s.current?.click(),disabled:r,className:`flex items-center gap-1.5 px-3 py-1.5 text-xs rounded-md bg-surface hover:bg-surface-hover border border-border disabled:opacity-50 transition-colors`,children:[r?l(N,{className:`w-3.5 h-3.5 animate-spin`}):l(G,{className:`w-3.5 h-3.5`}),r?`Uploading...`:`Upload`]})]})}n();var je=[{seconds:900,label:`15m`},{seconds:3600,label:`1h`},{seconds:21600,label:`6h`},{seconds:43200,label:`12h`},{seconds:86400,label:`24h`}],Me=new Set([`@camstack/system`,`@camstack/types`,`@camstack/sdk`,`@camstack/shm-ring`,`@camstack/ui-library`]);function Ne(e){return e!==void 0&&Me.has(e)}var Pe={id:`hub`,name:`Hub`,isHub:!0,isOnline:!0};function Fe(e,t){let n=e??`hub-only`;return n===`any-node`?!0:n===`hub-only`?t:!t}function Ie(e){let t=e;if(!t?.manifest)return null;let n={...t.manifest,name:t.manifest.name??t.manifest.id,version:t.manifest.version??`0.0.0`,capabilities:t.manifest.capabilities??[]},r=t.process,i=r?{pid:r.pid,mode:r.mode===`forked`?`forked`:`in-process`,state:r.state??`unknown`}:void 0,a=t.health,o=t.declaration?.execution,s=t.manifest.execution,c=o?.placement??s?.placement;return{manifest:n,enabled:!0,source:t.source,installSource:t.installSource,installedOn:[],...i?{process:i}:{},hasBackup:t.hasBackup,...a?{health:a}:{},...c?{placement:c}:{}}}function Le(e){let t=new Map,n=[];for(let r of e){let e=r.manifest.packageName;if(!e){n.push(r);continue}let i=t.get(e);if(i)i.addons.push(r);else{let n=r.manifest.bundle,i={packageName:e,displayName:n?.displayName??r.manifest.packageDisplayName??r.manifest.name,version:r.manifest.packageVersion,addons:[r],...r.installSource===void 0?{}:{installSource:r.installSource},...n===void 0?{}:{bundle:n}};t.set(e,i)}}let r=[];for(let e of t.values())e.bundle!==void 0||e.addons.length>=2?r.push({bundle:e,representative:e.addons[0]}):r.push(e.addons[0]);return r.push(...n),r}function $(e){return`bundle`in e}function Re({addons:n,clusterStatus:o,selectedNode:d,onRefresh:f,isRefreshing:p}){let h=s(),[g,_]=c(``),y=r(g),[b,C]=c(!1),w=t(null);u(()=>{if(!b)return;let e=e=>{w.current&&!w.current.contains(e.target)&&C(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[b]);let{data:T}=ae({nodeId:d.id}),ee=a(()=>{let e=new Map;for(let t of T??[])e.set(t.name,t.latestVersion);return e},[T]),te=a(()=>(T??[]).filter(e=>!e.isSystem).length,[T]),[ne,D]=c(()=>new Set),[ie,O]=c(()=>new Map),oe=e(e=>{D(t=>new Set(t).add(e))},[]),k=e(e=>{D(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),n})},[]),A=e((e,t)=>{O(n=>new Map(n).set(e,t))},[]),ue=e(e=>{O(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n})},[]),de=x({onMutate:e=>{oe(e.name),ue(e.name)},onSuccess:(e,t)=>{k(t.name);let n=e;if(n&&n.success===!1){A(t.name,n.error??`Update failed (no error message returned by server)`);return}h.invalidateQueries({queryKey:[[`addons`]]}),h.invalidateQueries({queryKey:[[`addons`,`listUpdates`]]})},onError:(e,t)=>{k(t.name),A(t.name,e instanceof Error?e.message:String(e))}}),P=xe(),F=t(new Set);u(()=>{let e=new Set;for(let[t,n]of P)J(n)&&e.add(t);let t=[...F.current].some(t=>!e.has(t));F.current=e,t&&(h.invalidateQueries({queryKey:[[`addons`]]}),h.invalidateQueries({queryKey:[[`addons`,`listUpdates`]]}))},[P,h]);let{data:I}=ce(void 0),me=le({onSuccess:()=>{h.invalidateQueries({queryKey:[[`addons`,`getAutoUpdateSettings`]]})}}),he=E({onSuccess:()=>{h.invalidateQueries({queryKey:[[`addons`,`getAutoUpdateSettings`]]})}}),{data:L,isFetching:z}=S({query:y||void 0},{enabled:b}),V=m(),{data:H}=re(void 0),U=H?.requestedAt,[W,ge]=c(null),[_e,ve]=c(!1);u(()=>{if(H?.kind===`framework-bulk-update`&&H.requestedAt!==W){ge(H.requestedAt),ve(!0);let e=window.setTimeout(()=>ve(!1),6e3);return()=>window.clearTimeout(e)}},[U,W,H]),se();let ye=e(async()=>{let e=(T??[]).filter(e=>!e.isSystem);if(e.length!==0){if(!d.isHub){for(let t of e)await de.mutateAsync({name:t.name,version:t.latestVersion,nodeId:d.id});return}await V.mutateAsync({kind:`update`,targets:e.map(e=>({name:e.name,version:e.latestVersion})),nodeIds:[d.id]})}},[T,d.id,d.isHub,V,de]),G=v({onSuccess:()=>{h.invalidateQueries({queryKey:[[`addons`]]}),h.invalidateQueries({queryKey:[[`addonPages`]]}),h.invalidateQueries({queryKey:[[`capabilities`]]}),h.invalidateQueries({queryKey:[[`integrations`]]})}}),[K,q]=c(`type`),[be,Y]=c(()=>typeof window>`u`?`grouped`:window.localStorage.getItem(`camstack.addons.viewMode`)===`flat`?`flat`:`grouped`),Se=e=>{Y(e),typeof window<`u`&&window.localStorage.setItem(`camstack.addons.viewMode`,e)},[Ce,X]=pe(),Z=Ce.get(`capability`),Q=a(()=>{let e=n.filter(e=>!Ne(e.manifest.packageName));return d.isHub||(e=e.filter(e=>Fe(e.placement,d.isHub))),Z&&(e=e.filter(e=>(e.manifest.capabilities??[]).some(e=>(typeof e==`string`?e:e.name)===Z))),e},[n,d.isHub,Z]),we=()=>{let e=new URLSearchParams(Ce);e.delete(`capability`),X(e,{replace:!0})},Te=be===`flat`?Q:Le(Q),Ee=a(()=>{let e=[...Te];switch(K){case`type`:e.sort((e,t)=>{let n=+!$(e),r=+!$(t);if(n!==r)return n-r;let i=$(e)?e.bundle.displayName:e.manifest.name,a=$(t)?t.bundle.displayName:t.manifest.name;return i.localeCompare(a)});break;case`name`:e.sort((e,t)=>{let n=$(e)?e.bundle.displayName:e.manifest.name,r=$(t)?t.bundle.displayName:t.manifest.name;return n.localeCompare(r)});break;case`source`:e.sort((e,t)=>{let n=$(e)?e.bundle.installSource??``:e.installSource??``,r=$(t)?t.bundle.installSource??``:t.installSource??``;return n.localeCompare(r)});break}return e},[Te,K]);return i(`div`,{className:`space-y-4`,children:[[...ie.entries()].map(([e,t])=>l(`div`,{className:`rounded-md border border-danger/30 bg-danger/5 px-3 py-2 text-[11px]`,children:i(`div`,{className:`flex items-start justify-between gap-3`,children:[i(`div`,{className:`space-y-0.5`,children:[i(`div`,{className:`font-medium text-danger`,children:[`Failed to update `,e]}),l(`div`,{className:`text-foreground-subtle font-mono`,children:t})]}),l(`button`,{type:`button`,onClick:()=>ue(e),className:`text-foreground-subtle hover:text-foreground text-[10px]`,children:`dismiss`})]})},e)),i(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[i(`div`,{className:`flex items-center gap-1.5`,children:[l(`span`,{className:`text-[10px] text-foreground-subtle`,children:`Sort:`}),i(`select`,{value:K,onChange:e=>q(e.target.value),className:`rounded-md border border-border bg-surface px-2 py-1.5 text-[11px] text-foreground focus:outline-none focus:border-primary/50`,children:[l(`option`,{value:`type`,children:`Bundles first`}),l(`option`,{value:`name`,children:`Name`}),l(`option`,{value:`source`,children:`Install source`})]})]}),i(`div`,{className:`flex items-center gap-1.5`,children:[l(`span`,{className:`text-[10px] text-foreground-subtle`,children:`View:`}),l(`div`,{className:`flex rounded-md border border-border overflow-hidden text-[10px] font-medium`,children:[`grouped`,`flat`].map(e=>l(`button`,{type:`button`,onClick:()=>Se(e),className:`px-2.5 py-1.5 transition-colors capitalize ${be===e?`bg-primary/10 text-primary`:`bg-transparent text-foreground-subtle hover:bg-surface-hover`}`,title:e===`grouped`?`Group multi-addon packages into a bundle card`:`Show every addon as its own card`,children:e},e))})]}),d.isHub&&i(`div`,{className:`flex items-center gap-1.5`,children:[l(M,{className:`h-3 w-3 text-foreground-subtle`}),l(`span`,{className:`text-[10px] text-foreground-subtle`,children:`Auto-Update:`}),l(`div`,{className:`flex rounded-md border border-border overflow-hidden text-[10px] font-medium`,children:[`off`,`latest`,`beta`].map(e=>l(`button`,{type:`button`,onClick:()=>me.mutate({channel:e}),disabled:me.isPending,className:`px-2.5 py-1.5 transition-colors capitalize ${I?.channel===e?e===`off`?`bg-gray-700 text-gray-200`:e===`latest`?`bg-blue-500/20 text-blue-400`:`bg-amber-500/20 text-amber-400`:`bg-transparent text-foreground-subtle hover:bg-surface-hover`} ${e===`off`?``:`border-l border-border`}`,children:e},e))})]}),d.isHub&&i(`div`,{className:`flex items-center gap-1.5`,children:[l(`span`,{className:`text-[10px] text-foreground-subtle`,children:`Check every:`}),l(`select`,{className:`rounded-md border border-border bg-transparent px-1.5 py-1 text-[10px] font-medium text-foreground-subtle`,value:I?.updateCheckIntervalSeconds??21600,disabled:he.isPending||I===void 0,onChange:e=>{I!==void 0&&he.mutate({channel:I.channel,updateCheckIntervalSeconds:Number(e.target.value)})},children:je.map(e=>l(`option`,{value:e.seconds,children:e.label},e.seconds))})]}),te>0&&i(`button`,{type:`button`,onClick:()=>void ye(),disabled:V.isPending,className:`flex items-center gap-1.5 px-2.5 py-1.5 text-[11px] rounded-md bg-blue-500/10 text-blue-400 hover:bg-blue-500/20 border border-blue-500/30 disabled:opacity-50 transition-colors font-medium`,children:[V.isPending?l(N,{className:`w-3 h-3 animate-spin`}):l(j,{className:`w-3 h-3`}),V.isPending?`Updating…`:`Update All (${te})`]}),i(`button`,{type:`button`,onClick:f,disabled:p||V.isPending,className:`flex items-center gap-1.5 px-2.5 py-1.5 text-[11px] rounded-md bg-surface hover:bg-surface-hover border border-border disabled:opacity-50 transition-colors`,children:[l(M,{className:`w-3 h-3 ${p?`animate-spin`:``}`}),`Refresh`]})]}),i(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center sm:gap-3`,children:[i(`div`,{className:`relative flex-1 min-w-0 sm:min-w-[200px]`,ref:w,children:[l(R,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-foreground-subtle`}),l(`input`,{type:`text`,value:g,onChange:e=>{_(e.target.value),C(!0)},onFocus:()=>C(!0),placeholder:`Search addons on npm...`,disabled:V.isPending,className:`w-full rounded-lg border border-border bg-background pl-9 pr-3 py-2 text-xs text-foreground placeholder:text-foreground-subtle focus:outline-none focus:ring-1 focus:ring-primary disabled:opacity-50 disabled:cursor-not-allowed`}),z&&l(N,{className:`absolute right-2.5 top-1/2 -translate-y-1/2 h-3 w-3 text-foreground-subtle animate-spin`}),b&&L&&L.length>0&&i(`div`,{className:`absolute left-0 right-0 top-full mt-1 z-40 rounded-lg border border-border bg-surface shadow-xl overflow-hidden`,children:[L.length>0&&i(`div`,{className:`px-3 py-1.5 text-[10px] uppercase tracking-wide text-foreground-subtle border-b border-border`,children:[`npm results (`,L.length,`)`]}),L&&L.length>0&&l(`div`,{className:`max-h-72 overflow-auto divide-y divide-border`,children:L.map(e=>i(`div`,{className:`flex items-center gap-3 px-3 py-2 hover:bg-surface-hover transition-colors`,children:[l(`div`,{className:`w-6 h-6 rounded-md bg-primary/10 flex items-center justify-center text-primary text-[9px] font-bold shrink-0`,children:e.name.replace(`@camstack/addon-`,``).charAt(0).toUpperCase()}),i(`div`,{className:`flex-1 min-w-0`,children:[i(`div`,{className:`flex items-baseline gap-2 min-w-0`,children:[l(`span`,{className:`text-[11px] font-semibold break-words`,children:e.name.replace(/^@camstack\/(addon-)?/,``)}),i(`span`,{className:`text-[10px] text-foreground-subtle shrink-0`,children:[`v`,e.version]})]}),l(`div`,{className:`font-mono text-[9px] text-foreground-subtle/80 truncate`,children:e.name}),e.description&&l(`div`,{className:`text-[10px] text-foreground-subtle truncate`,children:e.description})]}),e.installed?i(`span`,{className:`inline-flex items-center gap-1 px-2 py-1 text-[10px] font-medium rounded-md border border-emerald-500/30 bg-emerald-500/10 text-emerald-400 shrink-0`,children:[l(B,{className:`h-3 w-3`}),e.installedVersion??`Installed`]}):i(`button`,{type:`button`,onClick:()=>G.mutate({packageName:e.name}),disabled:G.isPending,className:`inline-flex items-center gap-1 px-2 py-1 text-[10px] font-medium rounded-md bg-primary text-primary-foreground hover:bg-primary/90 disabled:opacity-50 transition-colors shrink-0`,children:[G.isPending?l(N,{className:`h-3 w-3 animate-spin`}):l(j,{className:`h-3 w-3`}),`Install`]})]},e.name))})]})]}),l(Ae,{onUploadSuccess:()=>{h.invalidateQueries({queryKey:[[`addons`]]}),f()}})]}),Z&&i(`div`,{className:`flex items-center gap-2 px-3 py-2 rounded-lg bg-primary/10 border border-primary/30 text-sm`,children:[l(`span`,{className:`text-foreground-subtle`,children:`Filtering by capability:`}),l(`span`,{className:`font-mono text-primary font-semibold`,children:Z}),l(`button`,{type:`button`,onClick:we,className:`ml-auto text-xs text-foreground-subtle hover:text-foreground underline`,children:`Clear`})]}),_e&&i(`div`,{className:`fixed top-[calc(env(safe-area-inset-top)+1rem)] right-[calc(env(safe-area-inset-right)+1rem)] z-50 flex items-start gap-2 px-3 py-2.5 rounded-md border border-green-500/30 bg-green-500/10 shadow-lg backdrop-blur-sm max-w-sm pointer-events-auto`,children:[l(fe,{className:`w-4 h-4 shrink-0 mt-0.5 text-green-400`}),i(`div`,{children:[l(`div`,{className:`text-[11px] font-semibold text-foreground`,children:`Bulk update completed`}),l(`div`,{className:`text-[10px] text-foreground-subtle mt-0.5`,children:`System packages updated — hub restarted successfully.`})]})]}),Q.length===0&&l(`div`,{className:`text-xs text-foreground-subtle`,children:n.length===0?`No addons installed`:Z?`No installed addons declare the "${Z}" capability. Browse the npm catalog above to find a compatible addon.`:`No addons compatible with ${d.name} (placement filter active)`}),l(`div`,{className:`space-y-2`,children:Ee.map(e=>{let t=$(e)?e.bundle.packageName:e.manifest.packageName,n=ee.get(t),r=$(e)?e.representative:e,i=n?e=>de.mutate({name:t,version:e,nodeId:d.id}):void 0,a=P.get(t)??null,s=a!==null&&J(a);return l(Oe,{addon:r,clusterStatus:o?.[r.manifest.id],bundle:$(e)?e.bundle:void 0,availableUpdate:n,isUpdating:ne.has(t)||s,jobProgress:a,onUpdate:i,disabledByBulk:V.isPending},$(e)?t:e.manifest.id)})})]})}function ze(){let e=s(),{data:n,isLoading:r,isError:a}=ne(),{data:o}=f(void 0),{nodes:c}=T(),{selection:d,selectNode:p,requestedNodeId:m}=W(c.length>0?c:[Pe]),h=d.node??Pe,g=h.id,_=c.length>0?d.staleNodeId:null,v=D(),y=ee(),b=v.isPending||y.isPending,x=async()=>{await v.mutateAsync({nodeId:g}),await y.mutateAsync(),e.invalidateQueries({queryKey:[[`addons`]]})},S=t(v);S.current=v;let C=t(m??`hub`);u(()=>{S.current.mutate({nodeId:C.current})},[]);let w=(n??[]).map(Ie).filter(e=>e!==null);return i(V,{children:[i(`div`,{className:`flex items-center justify-between gap-3 flex-wrap`,children:[l(O,{selectedNodeId:g,onSelect:p}),i(`div`,{className:`flex items-center gap-3 flex-wrap`,children:[!r&&!a&&i(`span`,{className:`text-[10px] rounded-full bg-primary/10 text-primary px-2 py-0.5 font-medium`,children:[w.length,` installed`]}),i(`button`,{type:`button`,onClick:()=>void x(),disabled:b,className:`inline-flex items-center gap-1.5 px-2.5 py-1.5 text-[11px] rounded-md bg-surface hover:bg-surface-hover border border-border disabled:opacity-50 transition-colors`,title:`Re-fetch addons + check npm for new versions`,children:[l(M,{className:`w-3 h-3 ${b?`animate-spin`:``}`}),`Check for updates`]})]})]}),l(U,{staleNodeId:_,shownNodeName:h.name}),!h.isHub&&i(`div`,{className:`rounded-md border border-warning/30 bg-warning/5 px-3 py-2 text-[11px] text-foreground-subtle`,children:[`Showing only addons compatible with`,` `,l(`span`,{className:`font-medium text-foreground`,children:h.name}),` — agents only run`,` `,l(`code`,{className:`font-mono`,children:`agent-only`}),` and`,` `,l(`code`,{className:`font-mono`,children:`any-node`}),` addons. Install / uninstall is hub-driven; agents auto-sync from the hub.`]}),r&&l(`div`,{className:`text-xs text-foreground-subtle animate-pulse`,children:`Loading…`}),a&&l(`div`,{className:`text-xs text-danger`,children:`Failed to load addons`}),!r&&!a&&l(Re,{addons:w,clusterStatus:o,selectedNode:h,onRefresh:()=>void x(),isRefreshing:b})]})}export{ze as AddonsPage};