@camstack/addon-admin-ui 1.2.120 → 1.2.122

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 (118) hide show
  1. package/dist/assets/AddLocationWizard-DN0aFv_r.js +1 -0
  2. package/dist/assets/{AddonCollectionPage-DP3xO6SM.js → AddonCollectionPage-BDrM-bi7.js} +1 -1
  3. package/dist/assets/Addons-BHJcpdJ-.js +1 -0
  4. package/dist/assets/{AdminTabs-CWEa6lxu.js → AdminTabs-B-DTEeo0.js} +1 -1
  5. package/dist/assets/{AiProfiles-DRsR3twK.js → AiProfiles-Bih3GsbW.js} +2 -2
  6. package/dist/assets/{BrokerForm-DZvpOz2t.js → BrokerForm-DkTbh7e9.js} +1 -1
  7. package/dist/assets/{Build-BOm-p24w.js → Build-BP4fixrD.js} +4 -4
  8. package/dist/assets/{Capabilities-Bf45hSb9.js → Capabilities-v3ciWeJW.js} +1 -1
  9. package/dist/assets/{CapabilityBadges-DFomLheZ.js → CapabilityBadges-CLTWAVNu.js} +1 -1
  10. package/dist/assets/Cluster-rJJOcazu.js +11 -0
  11. package/dist/assets/Data-BZzuA9x6.js +1 -0
  12. package/dist/assets/{DetectionIntelligence-BewRfI5g.js → DetectionIntelligence-D4C2W-48.js} +1 -1
  13. package/dist/assets/{DeviceAggregateSection-B8d1ttwK.js → DeviceAggregateSection-Db0LhcGe.js} +1 -1
  14. package/dist/assets/DeviceDetail-UtKZwbux.js +2 -0
  15. package/dist/assets/{Devices-C_J1PG_S.js → Devices-hW8DXlvS.js} +1 -1
  16. package/dist/assets/{EmbedPlayerPage-CEh82zWX.js → EmbedPlayerPage-Dyhw73FF.js} +1 -1
  17. package/dist/assets/Events-dVdiz1V-.js +1 -0
  18. package/dist/assets/{FormBuilder-CCyg_30_.js → FormBuilder-BP2OntiX.js} +1 -1
  19. package/dist/assets/Identity-WGacdktR.js +1 -0
  20. package/dist/assets/IntegrationDetail-BP5Xam5L.js +1 -0
  21. package/dist/assets/Integrations-CeMKkD7M.js +1 -0
  22. package/dist/assets/Integrations-Dh9ZRz4E.js +1 -0
  23. package/dist/assets/{Logs-BxrfPbr6.js → Logs-Bz5wv5Qq.js} +1 -1
  24. package/dist/assets/{MotionZonesSettings-CdemhWhc.js → MotionZonesSettings--3TXO6vq.js} +1 -1
  25. package/dist/assets/{MyAccess-rfHA9QRX.js → MyAccess-DJbTo1Af.js} +1 -1
  26. package/dist/assets/Network-cjqbvhNs.js +1 -0
  27. package/dist/assets/{NodeAddonsSettingsPanel-BbdhEikK.js → NodeAddonsSettingsPanel-BipJ2NAz.js} +1 -1
  28. package/dist/assets/{NodeInferenceDevices-BA4AvFSy.js → NodeInferenceDevices-CgtlXT45.js} +1 -1
  29. package/dist/assets/Notifications-Czo2o5b5.js +1 -0
  30. package/dist/assets/Pipeline-Bbmikduo.js +1 -0
  31. package/dist/assets/Plates-h_Z_xuvh.js +1 -0
  32. package/dist/assets/{PrivacyMaskSettings-DKaOBD7I.js → PrivacyMaskSettings-8V46Jdgm.js} +1 -1
  33. package/dist/assets/{ProviderIcon-C1SY--6Z.js → ProviderIcon-CKFlb9NC.js} +1 -1
  34. package/dist/assets/Recordings-CyeFU3i9.js +1 -0
  35. package/dist/assets/{ScanNetworkModal-CkKXaASr.js → ScanNetworkModal-B7LGMcDr.js} +1 -1
  36. package/dist/assets/{SceneMonitorEditor-D6QFhj6_.js → SceneMonitorEditor-DZd4dDVQ.js} +1 -1
  37. package/dist/assets/{Scenes-nzqmq3E_.js → Scenes-D6D5QAMW.js} +1 -1
  38. package/dist/assets/{Settings-DmR-y-lo.js → Settings-DT7nLsPy.js} +1 -1
  39. package/dist/assets/{Showroom-GJaAdxge.js → Showroom-DDzYd3AF.js} +1 -1
  40. package/dist/assets/{Terminal-SMJsDxD3.js → Terminal-D3n_uL2U.js} +5 -5
  41. package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-B1yKKlRb.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-YbPw2VQX.js} +1 -1
  42. package/dist/assets/{bell-ring-B8CPJsI_.js → bell-ring-C_bZ8IoR.js} +1 -1
  43. package/dist/assets/{boxes-BO9PDasW.js → boxes-BAFsgFOP.js} +1 -1
  44. package/dist/assets/circle-check-big-DuuIo-l7.js +1 -0
  45. package/dist/assets/{circle-x-BEeBoyIR.js → circle-x-BmzsLDtE.js} +1 -1
  46. package/dist/assets/clock-xyxm0Vrl.js +1 -0
  47. package/dist/assets/{copy-DgkH27Wp.js → copy-CD-KIahX.js} +1 -1
  48. package/dist/assets/{debounced-invalidate-BPgv7urB.js → debounced-invalidate-CyVKCjeP.js} +1 -1
  49. package/dist/assets/{dist-CyUtTvQp.js → dist-BU1WIKGl.js} +1 -1
  50. package/dist/assets/dist-D8HjVQmi.js +349 -0
  51. package/dist/assets/{download-ChPOQTM7.js → download-F5TwZ1QT.js} +1 -1
  52. package/dist/assets/{face-bbox-DYhU07MB.js → face-bbox-COl_xNUu.js} +1 -1
  53. package/dist/assets/{hostInit-4nJRa4cE.js → hostInit-BymnDQUp.js} +1 -1
  54. package/dist/assets/index-BGPx1Wue.css +2 -0
  55. package/dist/assets/index-BRCxCK68.js +4 -0
  56. package/dist/assets/{key-round-B0Xn9Yjt.js → key-round-J-NFrhgM.js} +1 -1
  57. package/dist/assets/{layers-tAo2_7kJ.js → layers-C_lSBqn_.js} +1 -1
  58. package/dist/assets/{mf-entry-bootstrap-0-f8228165.js → mf-entry-bootstrap-0-d5c55f05.js} +2 -2
  59. package/dist/assets/{pencil-uWNwJNLv.js → pencil-DPWl5tLj.js} +1 -1
  60. package/dist/assets/play-BJyEu2-A.js +1 -0
  61. package/dist/assets/{player-overlays-CXg0hhE6.js → player-overlays-CxHvyzBL.js} +1 -1
  62. package/dist/assets/plus-y8WmfmHp.js +1 -0
  63. package/dist/assets/power-Ck186zUF.js +1 -0
  64. package/dist/assets/{radio-B2Ey6CU_.js → radio-BhphTUWO.js} +1 -1
  65. package/dist/assets/{refresh-cw-Bc7sN4NG.js → refresh-cw-CuaHjcq3.js} +1 -1
  66. package/dist/assets/remoteEntry-ClB9u5zx.js +1 -0
  67. package/dist/assets/rotate-ccw-BJsfKt0-.js +1 -0
  68. package/dist/assets/rotate-cw-CiA7cZdt.js +1 -0
  69. package/dist/assets/{send-k49_GbSQ.js → send-DX8bQrru.js} +1 -1
  70. package/dist/assets/{server-hj9nrAEV.js → server-DD1xVy9e.js} +1 -1
  71. package/dist/assets/{shield-BDHcGLyd.js → shield-Cu3-d7ee.js} +1 -1
  72. package/dist/assets/square-CuFP0Uhg.js +1 -0
  73. package/dist/assets/{square-check-big-BDI8demC.js → square-check-big-BozZrI7m.js} +1 -1
  74. package/dist/assets/src-BVvs1Rok.js +349 -0
  75. package/dist/assets/src-CoTJVD7e.js +67 -0
  76. package/dist/assets/{undo-2-CIYAu2-S.js → undo-2-D33lbdQW.js} +1 -1
  77. package/dist/assets/use-scenes-feed-DqeDE69y.js +1 -0
  78. package/dist/assets/useEventInvalidation-DsypM9SU.js +1 -0
  79. package/dist/assets/{useNodeUrlSelection-Qqj3vhRX.js → useNodeUrlSelection-Dumcs9MP.js} +1 -1
  80. package/dist/assets/{video--oQgXab3.js → video-C5L4OAcP.js} +1 -1
  81. package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-T5nrky73.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-Bf6u6B3K.js} +2 -2
  82. package/dist/assets/{wifi--ujzZRuQ.js → wifi-BSOzXDhI.js} +1 -1
  83. package/dist/assets/{zap-I5L6iIx1.js → zap-D9dFxZiG.js} +1 -1
  84. package/dist/index.html +6 -6
  85. package/dist/server/addon.js +283 -5
  86. package/package.json +1 -1
  87. package/dist/assets/AddLocationWizard-4tqarwDa.js +0 -1
  88. package/dist/assets/Addons-Dn3BsUiH.js +0 -1
  89. package/dist/assets/Cluster-3tVwxwtg.js +0 -11
  90. package/dist/assets/Data-Dga_gZJa.js +0 -1
  91. package/dist/assets/DeviceDetail-CVtzUGLM.js +0 -2
  92. package/dist/assets/Events-JRIOdVcm.js +0 -1
  93. package/dist/assets/Identity-BZcLgE2n.js +0 -1
  94. package/dist/assets/IntegrationDetail-Ckm2INyi.js +0 -1
  95. package/dist/assets/Integrations-BgYbl7ny.js +0 -1
  96. package/dist/assets/Integrations-Bi5H7cYT.js +0 -1
  97. package/dist/assets/Network-BgC3msZy.js +0 -1
  98. package/dist/assets/Notifications-Bu5PLj4y.js +0 -1
  99. package/dist/assets/Pipeline-D722tZEW.js +0 -1
  100. package/dist/assets/Plates-ByHorRzI.js +0 -1
  101. package/dist/assets/Recordings-CA2d3Y9X.js +0 -1
  102. package/dist/assets/circle-check-big-Dp32y98z.js +0 -1
  103. package/dist/assets/clock-VR-g6-6X.js +0 -1
  104. package/dist/assets/dist-Okm6znYF.js +0 -349
  105. package/dist/assets/index-CChcWx2e.css +0 -2
  106. package/dist/assets/index-fcpGbsCa.js +0 -4
  107. package/dist/assets/play-GnEjunvs.js +0 -1
  108. package/dist/assets/plus-BSMCkEaa.js +0 -1
  109. package/dist/assets/power-DqOV8y7N.js +0 -1
  110. package/dist/assets/remoteEntry-BHE-czLb.js +0 -1
  111. package/dist/assets/rotate-ccw-su9Ag1p3.js +0 -1
  112. package/dist/assets/rotate-cw-BzcYJDMV.js +0 -1
  113. package/dist/assets/square-htLjVnEj.js +0 -1
  114. package/dist/assets/src-2_PdZDlW.js +0 -67
  115. package/dist/assets/src-7nQ9U_oz.js +0 -349
  116. package/dist/assets/star-2GlelgRj.js +0 -1
  117. package/dist/assets/use-scenes-feed-BZvnS8B9.js +0 -1
  118. package/dist/assets/useEventInvalidation-2YNos8NI.js +0 -1
@@ -8021,6 +8021,20 @@ var RelocateJobSchema = object({
8021
8021
  * in its row, not in its name, so `MediaRelocateEngine` never reconciles one.
8022
8022
  */
8023
8023
  rowsReconciled: number().int().nonnegative().optional(),
8024
+ /**
8025
+ * Rows this run FORGOT because the file they name is not on disk.
8026
+ *
8027
+ * The mover derived the path from the row's own fields and `stat`ed it; an
8028
+ * ENOENT there is a per-path confirmation that the segment is gone (D296),
8029
+ * and the durable row is dropped through the same channel eviction uses. It
8030
+ * is reported for the same reason `rowsReconciled` is: this is a durable
8031
+ * mutation nobody asked for, and a migration that quietly erases hour rows is
8032
+ * the same failure as one that quietly skips them (D295).
8033
+ *
8034
+ * The production drain of 2026-08-30 would have reported 11 074 here — the
8035
+ * ledger claimed 5.65 GB of footage that no longer existed.
8036
+ */
8037
+ rowsForgotten: number().int().nonnegative().optional(),
8024
8038
  startedAt: number(),
8025
8039
  finishedAt: number().nullable(),
8026
8040
  error: string().nullable()
@@ -8384,6 +8398,91 @@ var RelocateResidueSchema = object({
8384
8398
  segments: number().int().nonnegative(),
8385
8399
  bytes: number().int().nonnegative()
8386
8400
  }).nullable();
8401
+ /**
8402
+ * Ask one location whether its durable hour rows describe the disk — the walk
8403
+ * (D319).
8404
+ *
8405
+ * `apply` DEFAULTS TO FALSE and that default is the product: the operator's
8406
+ * missing tool is the question, and the dry run is how they sanity-check the
8407
+ * destructive run before authorising it.
8408
+ */
8409
+ var LedgerWalkInputSchema = object({
8410
+ locationId: string().min(1),
8411
+ /** Forget the confirmed-absent rows, rather than only counting them. */
8412
+ apply: boolean().optional(),
8413
+ /** Narrow to one camera. */
8414
+ deviceId: number().int().positive().optional(),
8415
+ /** Narrow to these recording profiles; empty/absent = every profile. */
8416
+ profiles: array(string().min(1)).optional()
8417
+ });
8418
+ /** Why a whole walk did nothing. Every one leaves the ledger untouched. */
8419
+ var LedgerWalkRefusalSchema = _enum([
8420
+ "location-unknown",
8421
+ "source-writable",
8422
+ "no-ledger",
8423
+ "archive-unreadable",
8424
+ "anchor-absent",
8425
+ "anchor-unreadable",
8426
+ "anchor-moved"
8427
+ ]);
8428
+ _enum([
8429
+ "live-tail",
8430
+ "listing-error",
8431
+ "path-mismatch",
8432
+ "durable-refused"
8433
+ ]);
8434
+ /** Every skip reason, always present, always a number — so a reason that never
8435
+ * fired reports as zero rather than absent and the report shape is constant
8436
+ * between passes. Spelled out rather than `z.record` for exactly that. */
8437
+ var LedgerWalkSkipCountsSchema = object({
8438
+ "live-tail": number().int().nonnegative(),
8439
+ "listing-error": number().int().nonnegative(),
8440
+ "path-mismatch": number().int().nonnegative(),
8441
+ "durable-refused": number().int().nonnegative()
8442
+ });
8443
+ /** One camera's share of a walk, so a report names cameras and not rows. */
8444
+ var LedgerWalkDeviceReportSchema = object({
8445
+ deviceId: number().int(),
8446
+ hoursWalked: number().int().nonnegative(),
8447
+ hoursMissing: number().int().nonnegative(),
8448
+ ghostSegments: number().int().nonnegative(),
8449
+ ghostBytes: number().int().nonnegative(),
8450
+ forgottenSegments: number().int().nonnegative(),
8451
+ orphanFiles: number().int().nonnegative()
8452
+ });
8453
+ /**
8454
+ * What one walk claimed, listed, found and (only when armed) forgot.
8455
+ *
8456
+ * `archiveSegments` is the **M** and `segmentsClaimed` the **N** (D295), so a
8457
+ * walk that saw a fraction of the location is visible in its own report rather
8458
+ * than in the absence of one.
8459
+ */
8460
+ var LedgerWalkReportSchema = object({
8461
+ locationId: string(),
8462
+ applied: boolean(),
8463
+ refused: LedgerWalkRefusalSchema.nullable(),
8464
+ archiveSegments: number().int().nonnegative().nullable(),
8465
+ archiveBytes: number().int().nonnegative().nullable(),
8466
+ hoursClaimed: number().int().nonnegative(),
8467
+ hoursWalked: number().int().nonnegative(),
8468
+ hoursMissing: number().int().nonnegative(),
8469
+ /** `readdir` calls issued — the cost, stated in the unit that is paid. */
8470
+ listings: number().int().nonnegative(),
8471
+ segmentsClaimed: number().int().nonnegative(),
8472
+ ghostSegments: number().int().nonnegative(),
8473
+ ghostBytes: number().int().nonnegative(),
8474
+ ghostHoursWhole: number().int().nonnegative(),
8475
+ forgottenSegments: number().int().nonnegative(),
8476
+ forgottenBytes: number().int().nonnegative(),
8477
+ /** Files under a claimed hour that no durable row names. Never deleted. */
8478
+ orphanFiles: number().int().nonnegative(),
8479
+ orphanSample: array(string()).readonly(),
8480
+ hoursSkipped: number().int().nonnegative(),
8481
+ skippedByReason: LedgerWalkSkipCountsSchema,
8482
+ /** The walk stopped at its per-pass hour bound with claims unwalked. */
8483
+ bounded: boolean(),
8484
+ byDevice: array(LedgerWalkDeviceReportSchema).readonly()
8485
+ });
8387
8486
  /** How many rows a media pass would still act on against a given target — the
8388
8487
  * media lane's denominator AND its residue, from ONE derivation so the two can
8389
8488
  * never disagree. `null` = the count could not be taken. */
@@ -18657,13 +18756,15 @@ var ListGroupsPageSchema = object({
18657
18756
  groups: array(AnalyticsGroupRecordSchema).readonly(),
18658
18757
  nextCursor: string().nullable()
18659
18758
  });
18759
+ var KEY_EVENTS_DEFAULT_LIMIT = 50;
18760
+ var KEY_EVENTS_MAX_LIMIT = 200;
18660
18761
  var KeyEventQueryInput = object({
18661
18762
  deviceId: number(),
18662
18763
  /** Window lower bound (track firstSeen ≥ since). */
18663
18764
  since: number(),
18664
18765
  /** Window upper bound (track firstSeen ≤ until). */
18665
18766
  until: number(),
18666
- limit: number().int().min(1).max(200).default(50),
18767
+ limit: number().int().min(1).max(KEY_EVENTS_MAX_LIMIT).default(KEY_EVENTS_DEFAULT_LIMIT),
18667
18768
  /** Drop tracks scoring below this importance. */
18668
18769
  minImportance: number().min(0).max(1).optional(),
18669
18770
  /** Restrict to a single class (e.g. 'person'). */
@@ -18685,6 +18786,32 @@ var KeyEventSchema = object({
18685
18786
  ...TrackFlagFields,
18686
18787
  ...TrackRetrainFields
18687
18788
  });
18789
+ /** `getKeyEvents`' window and filters, asked of a SET of cameras at once. */
18790
+ var KeyEventBatchQueryInput = object({
18791
+ deviceIds: array(number()).min(1).max(200),
18792
+ since: number(),
18793
+ until: number(),
18794
+ /** Applied PER CAMERA, exactly as `getKeyEvents.limit` is — never a total
18795
+ * across the set, which would let a busy camera starve a quiet one of its
18796
+ * rows and change what the merged feed contains. */
18797
+ limit: number().int().min(1).max(KEY_EVENTS_MAX_LIMIT).default(KEY_EVENTS_DEFAULT_LIMIT),
18798
+ minImportance: number().min(0).max(1).optional(),
18799
+ classFilter: string().optional()
18800
+ });
18801
+ /**
18802
+ * One camera's key events in a batch answer.
18803
+ *
18804
+ * The row exists for every requested id. `getKeyEvents` degrades to `[]` on
18805
+ * error rather than throwing, so a camera whose store read failed and one with
18806
+ * no events in the window were ALREADY indistinguishable per camera — the
18807
+ * batch does not make that worse, and the row keeps the deviceId the single
18808
+ * method's output never carried (the caller used to stamp it from the fan-out
18809
+ * key, which only worked because there was one query per camera).
18810
+ */
18811
+ var KeyEventsForDeviceSchema = object({
18812
+ deviceId: number(),
18813
+ events: array(KeyEventSchema).readonly()
18814
+ });
18688
18815
  object({
18689
18816
  trackId: string(),
18690
18817
  className: string(),
@@ -18904,6 +19031,47 @@ var RebuildStatusSchema = object({
18904
19031
  /** Present when the pass ended by throwing. */
18905
19032
  error: string().nullable()
18906
19033
  });
19034
+ /**
19035
+ * Acknowledgement that a debug-media reclaim STARTED.
19036
+ *
19037
+ * The pass is paced at ~2 MB/s over a standing 100 GB — tens of minutes — so
19038
+ * it runs detached and this returns immediately. Awaiting it is how the
19039
+ * `addons.custom` door hit the 60 s UDS deadline while the walk carried on
19040
+ * with no status. Poll {@link pipelineAnalyticsCapability.methods.getMediaReclaimStatus}.
19041
+ */
19042
+ var MediaReclaimStartResultSchema = object({
19043
+ started: boolean(),
19044
+ /** True when a pass was already running; the new request is ignored. */
19045
+ alreadyRunning: boolean()
19046
+ });
19047
+ var MediaReclaimInputSchema = object({
19048
+ mode: _enum(["report", "reclaim"]).default("report"),
19049
+ scopes: array(_enum(["motion-still", "track-filmstrip"])).min(1).optional(),
19050
+ deviceIds: array(number().int()).min(1).optional(),
19051
+ restart: boolean().optional(),
19052
+ pageSize: number().int().min(50).max(5e3).optional(),
19053
+ maxRowsPerDevice: number().int().min(1).max(5e5).optional(),
19054
+ maxReclaimPerDevice: number().int().min(1).max(5e5).optional(),
19055
+ maxBytesPerRun: number().int().min(1).optional(),
19056
+ budgetMinutes: number().int().min(1).max(720).optional(),
19057
+ throttleBytesPerSec: number().int().min(64 * 1024).optional(),
19058
+ graceMinutes: number().int().min(1).max(10080).optional()
19059
+ });
19060
+ var MediaReclaimStatusSchema = object({
19061
+ running: boolean(),
19062
+ mode: _enum(["report", "reclaim"]).nullable(),
19063
+ totalExamined: number(),
19064
+ totalEligible: number(),
19065
+ totalReclaimed: number(),
19066
+ totalBytesReclaimed: number(),
19067
+ totalRefused: number(),
19068
+ /** Device+scope windows finished in this pass. */
19069
+ devicesDone: number(),
19070
+ complete: boolean().nullable(),
19071
+ startedAtMs: number().nullable(),
19072
+ finishedAtMs: number().nullable(),
19073
+ error: string().nullable()
19074
+ });
18907
19075
  var ReplayFrameInputSchema = object({
18908
19076
  timestamp: number(),
18909
19077
  frame: PipelineRunResultBridge
@@ -18954,7 +19122,7 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
18954
19122
  until: number().optional(),
18955
19123
  kinds: array(string()).optional(),
18956
19124
  limit: number().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT)
18957
- }), array(SensorEventSchema).readonly()), method(KeyEventQueryInput, array(KeyEventSchema).readonly()), method(object({
19125
+ }), array(SensorEventSchema).readonly()), method(KeyEventQueryInput, array(KeyEventSchema).readonly()), method(KeyEventBatchQueryInput, array(KeyEventsForDeviceSchema).readonly()), method(object({
18958
19126
  deviceId: number(),
18959
19127
  since: number(),
18960
19128
  until: number(),
@@ -19045,6 +19213,12 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
19045
19213
  }), method(OpsLogQueryInputSchema, array(OpsLogEntrySchema).readonly(), {
19046
19214
  kind: "query",
19047
19215
  auth: "admin"
19216
+ }), method(MediaReclaimInputSchema, MediaReclaimStartResultSchema, {
19217
+ kind: "mutation",
19218
+ auth: "admin"
19219
+ }), method(object({}), MediaReclaimStatusSchema, {
19220
+ kind: "query",
19221
+ auth: "admin"
19048
19222
  }), method(object({ deviceIds: array(number()).optional() }), TrainingExportSummarySchema, {
19049
19223
  kind: "query",
19050
19224
  auth: "admin"
@@ -26606,6 +26780,9 @@ method(object({
26606
26780
  }), method(RelocateResidueInputSchema, RelocateResidueSchema, {
26607
26781
  kind: "query",
26608
26782
  auth: "admin"
26783
+ }), method(LedgerWalkInputSchema, LedgerWalkReportSchema, {
26784
+ kind: "mutation",
26785
+ auth: "admin"
26609
26786
  }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
26610
26787
  kind: "mutation",
26611
26788
  auth: "admin"
@@ -26997,7 +27174,26 @@ var SceneMonitorStatusSchema = object({
26997
27174
  monitors: array(SceneMonitorSchema),
26998
27175
  lastFetchedAt: number()
26999
27176
  });
27000
- DeviceType.Camera, method(object({ deviceId: number() }), SceneMonitorStatusSchema), method(object({
27177
+ /**
27178
+ * One camera's row in a `listScenesBatch` answer.
27179
+ *
27180
+ * `status` is NULLABLE and the nullability is the whole point. `scene-monitor`
27181
+ * is a `defaultActive` wrapper, so every camera is asked; a camera whose
27182
+ * provider is absent (pipeline-analytics not deployed, the post-processing node
27183
+ * down) cannot answer, and that is not the same fact as a camera with no scenes
27184
+ * configured. Fanned out per camera the difference was visible — one query
27185
+ * errored while the others resolved — and a batch that returned only the rows
27186
+ * it managed would have destroyed it, silently, by making an unreachable camera
27187
+ * indistinguishable from one that answered `monitors: []`.
27188
+ *
27189
+ * So: EVERY requested deviceId gets a row. `status: null` means "this camera
27190
+ * could not be read"; `status.monitors: []` means "read, and it has none".
27191
+ */
27192
+ var SceneMonitorStatusForDeviceSchema = object({
27193
+ deviceId: number(),
27194
+ status: SceneMonitorStatusSchema.nullable()
27195
+ });
27196
+ DeviceType.Camera, method(object({ deviceId: number() }), SceneMonitorStatusSchema), method(object({ deviceIds: array(number()).min(1).max(200) }), array(SceneMonitorStatusForDeviceSchema).readonly()), method(object({
27001
27197
  deviceId: number(),
27002
27198
  label: string(),
27003
27199
  roi: MaskRectShapeSchema,
@@ -28321,6 +28517,27 @@ var CameraOccupancySnapshotSchema = object({
28321
28517
  stationaryObjects: array(StationaryObjectSchema).readonly().optional()
28322
28518
  });
28323
28519
  /**
28520
+ * One camera's row in a `getCurrentSnapshotBatch` answer.
28521
+ *
28522
+ * THREE outcomes, and the single-camera method could only express two of them
28523
+ * because `snapshot: null` was already spoken for:
28524
+ *
28525
+ * - `read: 'read'`, `snapshot` present — the live occupancy reading.
28526
+ * - `read: 'read'`, `snapshot: null` — read, and this camera has no reading
28527
+ * yet: no frame since boot, and no parked-object registry to hydrate from.
28528
+ * - `read: 'unreadable'` — the owner could not answer for this
28529
+ * camera. `snapshot` is null, and it does NOT mean "nothing parked here".
28530
+ *
28531
+ * Collapsing the last two is the failure this field exists to prevent: a
28532
+ * hydration that threw would otherwise render as an empty Stationary section,
28533
+ * which is a definite claim about a camera nobody could read.
28534
+ */
28535
+ var CameraOccupancySnapshotForDeviceSchema = object({
28536
+ deviceId: number(),
28537
+ read: _enum(["read", "unreadable"]),
28538
+ snapshot: CameraOccupancySnapshotSchema.nullable()
28539
+ });
28540
+ /**
28324
28541
  * Time-series resolution. The history methods return one bucket per
28325
28542
  * step over the requested range. Smaller resolutions cost more
28326
28543
  * memory + bandwidth; bound to discrete steps so caller cannot ask
@@ -28344,7 +28561,7 @@ var HistoryPointSchema = object({
28344
28561
  /** Object count averaged over the bucket (rounded to nearest integer). */
28345
28562
  count: number().int().nonnegative()
28346
28563
  });
28347
- DeviceType.Camera, method(object({ deviceId: number() }), CameraOccupancySnapshotSchema.nullable()), method(object({
28564
+ DeviceType.Camera, method(object({ deviceId: number() }), CameraOccupancySnapshotSchema.nullable()), method(object({ deviceIds: array(number()).min(1).max(200) }), array(CameraOccupancySnapshotForDeviceSchema).readonly()), method(object({
28348
28565
  deviceId: number(),
28349
28566
  zoneId: string(),
28350
28567
  className: string().optional()
@@ -31649,6 +31866,18 @@ Object.freeze({
31649
31866
  addonId: null,
31650
31867
  access: "view"
31651
31868
  },
31869
+ "pipelineAnalytics.getKeyEventsBatch": {
31870
+ capName: "pipeline-analytics",
31871
+ capScope: "device",
31872
+ addonId: null,
31873
+ access: "view"
31874
+ },
31875
+ "pipelineAnalytics.getMediaReclaimStatus": {
31876
+ capName: "pipeline-analytics",
31877
+ capScope: "device",
31878
+ addonId: null,
31879
+ access: "view"
31880
+ },
31652
31881
  "pipelineAnalytics.getMotionEvents": {
31653
31882
  capName: "pipeline-analytics",
31654
31883
  capScope: "device",
@@ -31823,6 +32052,12 @@ Object.freeze({
31823
32052
  addonId: null,
31824
32053
  access: "create"
31825
32054
  },
32055
+ "pipelineAnalytics.reclaimDebugMedia": {
32056
+ capName: "pipeline-analytics",
32057
+ capScope: "device",
32058
+ addonId: null,
32059
+ access: "create"
32060
+ },
31826
32061
  "pipelineAnalytics.reconcileFromDisk": {
31827
32062
  capName: "pipeline-analytics",
31828
32063
  capScope: "device",
@@ -32825,6 +33060,12 @@ Object.freeze({
32825
33060
  addonId: null,
32826
33061
  access: "view"
32827
33062
  },
33063
+ "recording.reconcileLedgerAgainstDisk": {
33064
+ capName: "recording",
33065
+ capScope: "system",
33066
+ addonId: null,
33067
+ access: "create"
33068
+ },
32828
33069
  "recording.refreshStorageLocationsForMigration": {
32829
33070
  capName: "recording",
32830
33071
  capScope: "system",
@@ -32951,6 +33192,12 @@ Object.freeze({
32951
33192
  addonId: null,
32952
33193
  access: "view"
32953
33194
  },
33195
+ "sceneMonitor.listScenesBatch": {
33196
+ capName: "scene-monitor",
33197
+ capScope: "device",
33198
+ addonId: null,
33199
+ access: "view"
33200
+ },
32954
33201
  "sceneMonitor.recheckNow": {
32955
33202
  capName: "scene-monitor",
32956
33203
  capScope: "device",
@@ -34307,6 +34554,12 @@ Object.freeze({
34307
34554
  addonId: null,
34308
34555
  access: "view"
34309
34556
  },
34557
+ "zoneAnalytics.getCurrentSnapshotBatch": {
34558
+ capName: "zone-analytics",
34559
+ capScope: "device",
34560
+ addonId: null,
34561
+ access: "view"
34562
+ },
34310
34563
  "zoneAnalytics.getUnzonedHistory": {
34311
34564
  capName: "zone-analytics",
34312
34565
  capScope: "device",
@@ -35311,6 +35564,11 @@ Object.freeze({
35311
35564
  form: "single",
35312
35565
  optional: false
35313
35566
  }],
35567
+ "pipelineAnalytics.getKeyEventsBatch": [{
35568
+ name: "deviceIds",
35569
+ form: "array",
35570
+ optional: false
35571
+ }],
35314
35572
  "pipelineAnalytics.getMotionEvents": [{
35315
35573
  name: "deviceId",
35316
35574
  form: "single",
@@ -35416,6 +35674,11 @@ Object.freeze({
35416
35674
  form: "single",
35417
35675
  optional: true
35418
35676
  }],
35677
+ "pipelineAnalytics.reclaimDebugMedia": [{
35678
+ name: "deviceIds",
35679
+ form: "array",
35680
+ optional: true
35681
+ }],
35419
35682
  "pipelineAnalytics.reconcileFromDisk": [{
35420
35683
  name: "deviceId",
35421
35684
  form: "single",
@@ -35751,6 +36014,11 @@ Object.freeze({
35751
36014
  form: "single",
35752
36015
  optional: false
35753
36016
  }],
36017
+ "recording.reconcileLedgerAgainstDisk": [{
36018
+ name: "deviceId",
36019
+ form: "single",
36020
+ optional: true
36021
+ }],
35754
36022
  "recording.relocateFootage": [{
35755
36023
  name: "deviceId",
35756
36024
  form: "single",
@@ -35816,6 +36084,11 @@ Object.freeze({
35816
36084
  form: "single",
35817
36085
  optional: false
35818
36086
  }],
36087
+ "sceneMonitor.listScenesBatch": [{
36088
+ name: "deviceIds",
36089
+ form: "array",
36090
+ optional: false
36091
+ }],
35819
36092
  "sceneMonitor.recheckNow": [{
35820
36093
  name: "deviceId",
35821
36094
  form: "single",
@@ -36077,6 +36350,11 @@ Object.freeze({
36077
36350
  form: "single",
36078
36351
  optional: false
36079
36352
  }],
36353
+ "zoneAnalytics.getCurrentSnapshotBatch": [{
36354
+ name: "deviceIds",
36355
+ form: "array",
36356
+ optional: false
36357
+ }],
36080
36358
  "zoneAnalytics.getUnzonedHistory": [{
36081
36359
  name: "deviceId",
36082
36360
  form: "single",
@@ -36628,7 +36906,7 @@ var AdminUIAddon = class extends BaseAddon {
36628
36906
  capability: adminUiCapability,
36629
36907
  provider: {
36630
36908
  getStaticDir: async () => ({ staticDir: resolveAdminUiDistDir() }),
36631
- getVersion: async () => ({ version: "1.2.120" })
36909
+ getVersion: async () => ({ version: "1.2.122" })
36632
36910
  }
36633
36911
  }];
36634
36912
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-admin-ui",
3
- "version": "1.2.120",
3
+ "version": "1.2.122",
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-CXg0hhE6.js";import{Uo as u,Zo as d,g as f}from"./src-2_PdZDlW.js";import{t as p}from"./FormBuilder-CCyg_30_.js";import{t as m}from"./pencil-uWNwJNLv.js";import{t as h}from"./plus-BSMCkEaa.js";import{t as g}from"./power-DqOV8y7N.js";import{t as _}from"./star-2GlelgRj.js";import{C as v,I as y,K as b,o as x,r as S}from"./index-fcpGbsCa.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-CXg0hhE6.js";import{$i as f,An as p,Bn as ee,Bs as m,C as h,Cn as g,Dn as _,En as v,Fn as y,Hn as te,In as b,J as x,Ln as S,Mn as C,Nn as ne,On as w,Rn as re,Rs as T,Sn as E,Tn as ie,Vn as ae,g as D,jn as oe,q as se,un as ce,wn as le,xn as ue}from"./src-2_PdZDlW.js";import{Vt as O}from"./src-7nQ9U_oz.js";import{t as k}from"./clock-VR-g6-6X.js";import{t as A}from"./download-ChPOQTM7.js";import{t as de}from"./plus-BSMCkEaa.js";import{t as j}from"./refresh-cw-Bc7sN4NG.js";import{C as M,J as N,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 ge,z}from"./index-fcpGbsCa.js";import{t as B}from"./AdminPage-CCD07UMs.js";import{t as V}from"./NodeAddonsSettingsPanel-BbdhEikK.js";import{r as H,t as U}from"./useNodeUrlSelection-Qqj3vhRX.js";var _e=P(`chevron-up`,[[`path`,{d:`m18 15-6-6-6 6`,key:`153udz`}]]),ve=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`}]]),ye=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`}]]),W=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}=m(O.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:k,cls:`bg-muted text-foreground-subtle`,label:`queued`},fetching:{icon:M,cls:`bg-primary/10 text-primary`,label:`fetching`,spin:!0},staged:{icon:M,cls:`bg-primary/10 text-primary`,label:`staged`,spin:!0},validating:{icon:M,cls:`bg-primary/10 text-primary`,label:`validating`,spin:!0},applying:{icon:M,cls:`bg-primary/10 text-primary`,label:`applying`,spin:!0},restarting:{icon:M,cls:`bg-amber-500/10 text-amber-600 dark:text-amber-400`,label:`restarting`,spin:!0},applied:{icon:M,cls:`bg-primary/10 text-primary`,label:`finalizing`,spin:!0},done:{icon:z,cls:`bg-success/10 text-success`,label:`updated`},failed:{icon:ve,cls:`bg-danger/10 text-danger`,label:`failed`},skipped:{icon:W,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}=v({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(ge,{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(M,{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(z,{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(z,{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(A,{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:k,bg:`bg-muted text-foreground-subtle`,label:`queued`},updating:{icon:M,bg:`bg-primary/10 text-primary`,label:`updating`,spin:!0},"done-pending-restart":{icon:j,bg:`bg-amber-500/10 text-amber-700`,label:`pending restart`},done:{icon:z,bg:`bg-success/10 text-success`,label:`done`},failed:{icon:ve,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?ye: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(M,{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(A,{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`}=g({addonId:e}),r=S({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:ee,bundle:m,bulkItem:g,disabledByBulk:v,isSystem:te}){let[b,S]=c(!1),[C,w]=c(!1),[re,T]=c(!1),[E,ie]=c(null);u(()=>{ie(null)},[a]);let D=E??a,[oe,le]=c(!1),[ue,O]=c(!1),[k,A]=c(`logs`),M=s(),P=d(),fe=N(),pe=ce(),{manifest:I}=e,R=e.installedOn??[],z=!m&&!I.protected&&I.removable!==!1,B=!!m,H=m?.displayName??I.name,U=m?.packageName??I.packageName,W=m?.version??I.packageVersion??I.version,G=m?.installSource??e.installSource,K=m?m.bundle?.description??m.addons[0]?.manifest.description:I.description,q=ae({onSuccess:()=>{M.invalidateQueries({queryKey:[[`addons`]]}),M.invalidateQueries({queryKey:[[`addonPages`]]}),M.invalidateQueries({queryKey:[[`capabilities`]]})}}),J=ne({onSuccess:()=>{M.invalidateQueries({queryKey:[[`addons`]]})}}),be=_({onSuccess:()=>{M.invalidateQueries({queryKey:[[`addons`]]}),M.invalidateQueries({queryKey:[[`addonPages`]]}),M.invalidateQueries({queryKey:[[`capabilities`]]}),M.invalidateQueries({queryKey:[[`integrations`]]})}}),xe=y({onSuccess:()=>{M.invalidateQueries({queryKey:[[`addons`]]}),M.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(ve,{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:U})},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(j,{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:B||!!I.components&&I.components.length>1,installSource:G,addonId:B?m.addons[0]?.manifest.id:I.id,iconPath:B?m.bundle?.icon??m.addons[0]?.manifest.icon:I.icon,color:B?m.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:H}),!r&&l(Ee,{version:W,availableUpdate:a,...D===void 0?{}:{selectedVersion:D},isUpdating:p,installSource:G,disabled:v,...f&&D!==void 0?{onUpdate:()=>f(D)}:{},onOpenPicker:()=>T(e=>!e),children:re&&l(Ce,{packageName:U,currentVersion:W,...G?{installSource:G}:{},...a!==void 0&&D!==void 0?{selectedVersion:D,onSelect:e=>{ie(e),T(!1)}}:{},onInstall:e=>{T(!1),be.mutate({packageName:U,version:e})},onClose:()=>T(!1)})})]}),i(`div`,{className:`flex flex-wrap items-center gap-x-1.5 gap-y-1 mt-0.5`,children:[U!==H&&l(`span`,{className:`text-[10px] text-foreground-subtle font-mono truncate max-w-full`,children:U}),B&&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(ye,{className:`h-3 w-3`}),m.addons.length]}),te&&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(j,{className:`h-3 w-3`}),`System`]}),g!=null&&l(Z,{item:g}),ee!=null&&l(Se,{progress:ee})]}),K&&l(`p`,{className:`text-[10px] text-foreground-subtle mt-1 line-clamp-1`,children:K}),!B&&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})]})]})]}),!B&&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||v,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(j,{className:`h-3 w-3 ${J.isPending?`animate-spin`:``}`}),`Restart`]}),i(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),le(e=>!e)},className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-[10px] font-medium border transition-colors ${oe?`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`]}),!B&&i(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),O(!0)},className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-[10px] font-medium border transition-colors ${ue?`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`}),z&&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||v,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&&!B&&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))})]}),oe&&!B&&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:()=>A(`logs`),className:`px-2 py-0.5 transition-colors ${k===`logs`?`bg-primary/10 text-primary`:`text-foreground-subtle hover:bg-surface-hover`}`,children:`Logs`}),l(`button`,{type:`button`,onClick:()=>A(`events`),className:`px-2 py-0.5 border-l border-border transition-colors ${k===`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(),le(!1)},className:`text-foreground-subtle hover:text-foreground`,children:l(ge,{className:`h-3.5 w-3.5`})})]}),k===`logs`&&l(x,{addonId:I.id,maxHeight:`max-h-64`,showFilters:!1}),k===`events`&&l(se,{addonId:I.id,category:`addon.*`,maxHeight:`max-h-64`})]}),B&&i(o,{children:[l(`button`,{type:`button`,onClick:()=>S(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(b?_e:F,{className:`h-3.5 w-3.5 text-foreground-subtle`})}),b&&l(`div`,{className:`border-t border-border px-3 py-2 space-y-2`,children:m.addons.map(e=>l(Oe,{addon:e,agents:t,hideVersion:!0},e.manifest.id))})]}),ue&&!B&&l(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm p-4`,onClick:()=>O(!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:[H,` Settings`]})]}),l(`button`,{onClick:()=>O(!1),className:`text-foreground-subtle hover:text-foreground transition-colors p-1 rounded`,children:l(ge,{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(V,{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(h,{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(),w(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(de,{className:`h-3 w-3`}),`Add agent`]}),C&&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(),w(!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:()=>O(!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(M,{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 m=s(),[h,g]=c(``),v=r(h),[y,x]=c(!1),S=t(null);u(()=>{if(!y)return;let e=e=>{S.current&&!S.current.contains(e.target)&&x(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[y]);let{data:C}=oe({nodeId:d.id}),ne=a(()=>{let e=new Map;for(let t of C??[])e.set(t.name,t.latestVersion);return e},[C]),w=a(()=>(C??[]).filter(e=>!e.isSystem).length,[C]),[T,E]=c(()=>new Set),[ae,D]=c(()=>new Map),se=e(e=>{E(t=>new Set(t).add(e))},[]),O=e(e=>{E(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),n})},[]),k=e((e,t)=>{D(n=>new Map(n).set(e,t))},[]),de=e(e=>{D(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n})},[]),N=te({onMutate:e=>{se(e.name),de(e.name)},onSuccess:(e,t)=>{O(t.name);let n=e;if(n&&n.success===!1){k(t.name,n.error??`Update failed (no error message returned by server)`);return}m.invalidateQueries({queryKey:[[`addons`]]}),m.invalidateQueries({queryKey:[[`addons`,`listUpdates`]]})},onError:(e,t)=>{O(t.name),k(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&&(m.invalidateQueries({queryKey:[[`addons`]]}),m.invalidateQueries({queryKey:[[`addons`,`listUpdates`]]}))},[P,m]);let{data:I}=le(void 0),me=ue({onSuccess:()=>{m.invalidateQueries({queryKey:[[`addons`,`getAutoUpdateSettings`]]})}}),he=re({onSuccess:()=>{m.invalidateQueries({queryKey:[[`addons`,`getAutoUpdateSettings`]]})}}),{data:L,isFetching:ge}=b({query:v||void 0},{enabled:y}),B=ee(),{data:V}=ie(void 0),H=V?.requestedAt,[U,_e]=c(null),[ve,ye]=c(!1);u(()=>{if(V?.kind===`framework-bulk-update`&&V.requestedAt!==U){_e(V.requestedAt),ye(!0);let e=window.setTimeout(()=>ye(!1),6e3);return()=>window.clearTimeout(e)}},[H,U,V]),ce();let W=e(async()=>{let e=(C??[]).filter(e=>!e.isSystem);if(e.length!==0){if(!d.isHub){for(let t of e)await N.mutateAsync({name:t.name,version:t.latestVersion,nodeId:d.id});return}await B.mutateAsync({kind:`update`,targets:e.map(e=>({name:e.name,version:e.latestVersion})),nodeIds:[d.id]})}},[C,d.id,d.isHub,B,N]),G=_({onSuccess:()=>{m.invalidateQueries({queryKey:[[`addons`]]}),m.invalidateQueries({queryKey:[[`addonPages`]]}),m.invalidateQueries({queryKey:[[`capabilities`]]}),m.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:[[...ae.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:()=>de(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(j,{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))})]}),w>0&&i(`button`,{type:`button`,onClick:()=>void W(),disabled:B.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:[B.isPending?l(M,{className:`w-3 h-3 animate-spin`}):l(A,{className:`w-3 h-3`}),B.isPending?`Updating…`:`Update All (${w})`]}),i(`button`,{type:`button`,onClick:f,disabled:p||B.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(j,{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:S,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:h,onChange:e=>{g(e.target.value),x(!0)},onFocus:()=>x(!0),placeholder:`Search addons on npm...`,disabled:B.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`}),ge&&l(M,{className:`absolute right-2.5 top-1/2 -translate-y-1/2 h-3 w-3 text-foreground-subtle animate-spin`}),y&&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(z,{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(M,{className:`h-3 w-3 animate-spin`}):l(A,{className:`h-3 w-3`}),`Install`]})]},e.name))})]})]}),l(Ae,{onUploadSuccess:()=>{m.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`})]}),ve&&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=ne.get(t),r=$(e)?e.representative:e,i=n?e=>N.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:T.has(t)||s,jobProgress:a,onUpdate:i,disabledByBulk:B.isPending},$(e)?t:e.manifest.id)})})]})}function ze(){let e=s(),{data:n,isLoading:r,isError:a}=w(),{data:o}=f(void 0),{nodes:c}=T(),{selection:d,selectNode:p,requestedNodeId:ee}=U(c.length>0?c:[Pe]),m=d.node??Pe,h=m.id,g=c.length>0?d.staleNodeId:null,_=E(),v=C(),y=_.isPending||v.isPending,te=async()=>{await _.mutateAsync({nodeId:h}),await v.mutateAsync(),e.invalidateQueries({queryKey:[[`addons`]]})},b=t(_);b.current=_;let x=t(ee??`hub`);u(()=>{b.current.mutate({nodeId:x.current})},[]);let S=(n??[]).map(Ie).filter(e=>e!==null);return i(B,{children:[i(`div`,{className:`flex items-center justify-between gap-3 flex-wrap`,children:[l(D,{selectedNodeId:h,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:[S.length,` installed`]}),i(`button`,{type:`button`,onClick:()=>void te(),disabled:y,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(j,{className:`w-3 h-3 ${y?`animate-spin`:``}`}),`Check for updates`]})]})]}),l(H,{staleNodeId:g,shownNodeName:m.name}),!m.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:m.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:S,clusterStatus:o,selectedNode:m,onRefresh:()=>void te(),isRefreshing:y})]})}export{ze as AddonsPage};