@camstack/addon-admin-ui 1.1.31 → 1.1.33

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 (78) hide show
  1. package/dist/assets/{AddLocationWizard-CoTQ1C0P.js → AddLocationWizard-Bb1KEhbs.js} +1 -1
  2. package/dist/assets/{AddonCollectionPage-Br_mtznf.js → AddonCollectionPage-BQeUbBVN.js} +1 -1
  3. package/dist/assets/{Addons-BW1fbKyX.js → Addons-DVlfv3ie.js} +1 -1
  4. package/dist/assets/{AdminTabs-65LS38O7.js → AdminTabs-jD4aT4VZ.js} +1 -1
  5. package/dist/assets/{BrokerForm-CJOIbxU1.js → BrokerForm-BKrDZ7V2.js} +1 -1
  6. package/dist/assets/{Capabilities-DVCIj63p.js → Capabilities-BDlExloe.js} +1 -1
  7. package/dist/assets/{CapabilityBadges-DHKu7X9M.js → CapabilityBadges-BoHKzNdB.js} +1 -1
  8. package/dist/assets/{Cluster-DXsPIAud.js → Cluster-DUV-CTPC.js} +1 -1
  9. package/dist/assets/{Dashboard-DoGVZOeG.js → Dashboard-CpXOL9sX.js} +1 -1
  10. package/dist/assets/{Data-AE4ujje6.js → Data-CAMBg2A9.js} +1 -1
  11. package/dist/assets/{DetectionIntelligence-9Y96FdEf.js → DetectionIntelligence-BaTg_nGu.js} +1 -1
  12. package/dist/assets/{DeviceDetail-PQfHJrSX.js → DeviceDetail-B2QGJv1o.js} +2 -2
  13. package/dist/assets/{Devices-CNp9pqiU.js → Devices-B7BKpRMe.js} +1 -1
  14. package/dist/assets/{EmbedPlayerPage-BY1XGljW.js → EmbedPlayerPage-BHu_AjMG.js} +1 -1
  15. package/dist/assets/{FormBuilder-CPSLjDeb.js → FormBuilder-CQF_y_BI.js} +1 -1
  16. package/dist/assets/{Identity-Bsaqp7-s.js → Identity-MMOFWetJ.js} +1 -1
  17. package/dist/assets/{IntegrationDetail-Cvr_93Re.js → IntegrationDetail-B-4B1ib8.js} +1 -1
  18. package/dist/assets/{Integrations-BuPQK_EH.js → Integrations-BR2MPBfF.js} +1 -1
  19. package/dist/assets/{Integrations-Y0ziVjly.js → Integrations-DrajAqMo.js} +1 -1
  20. package/dist/assets/{Logs-DkqRdR14.js → Logs-7eq1Ylpg.js} +1 -1
  21. package/dist/assets/{MotionZonesSettings-BtVUNK7D.js → MotionZonesSettings-Ci9ptw7k.js} +1 -1
  22. package/dist/assets/{MyAccess-C6qT1LES.js → MyAccess-Bb-VOtTD.js} +1 -1
  23. package/dist/assets/{Network-Cj8f56PJ.js → Network-D4tyc2LO.js} +1 -1
  24. package/dist/assets/{NodeAddonsSettingsPanel-CaMCtRtL.js → NodeAddonsSettingsPanel-CPQDiGUL.js} +1 -1
  25. package/dist/assets/{NotificationTargets-DO6tp_-o.js → NotificationTargets-CIG2krKX.js} +1 -1
  26. package/dist/assets/Pipeline-DPfrRb1r.js +1 -0
  27. package/dist/assets/{PrivacyMaskSettings-DfGtcPz_.js → PrivacyMaskSettings-RmoLio8l.js} +1 -1
  28. package/dist/assets/{ProviderIcon-B7VHX4h5.js → ProviderIcon-5UKnj0ml.js} +1 -1
  29. package/dist/assets/{ScanNetworkModal-k76UGIG5.js → ScanNetworkModal-BR1YchhY.js} +1 -1
  30. package/dist/assets/{Settings-B6QqX2do.js → Settings-Bj6gEjUi.js} +1 -1
  31. package/dist/assets/{Showroom-Cwko7Yni.js → Showroom-CN407CxR.js} +1 -1
  32. package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-pD0FKW7m.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-DKf7lPrN.js} +1 -1
  33. package/dist/assets/{build-cluster-graph-Ci-E0Tjd.js → build-cluster-graph-BS_JXKFR.js} +1 -1
  34. package/dist/assets/circle-check-big-C4U6tvtn.js +1 -0
  35. package/dist/assets/{copy-BqJTD0NL.js → copy-CcPHXe-n.js} +1 -1
  36. package/dist/assets/dist-DEGy5BmY.js +7 -0
  37. package/dist/assets/{dist-Bs1zChcu.js → dist-TNNImQWr.js} +1 -1
  38. package/dist/assets/{download-DRBhCGtf.js → download-CcFk5nYG.js} +1 -1
  39. package/dist/assets/{hostInit-Dmv2Dz_q.js → hostInit-C8t2JXO5.js} +1 -1
  40. package/dist/assets/index-2HwvWrOH.css +2 -0
  41. package/dist/assets/{index-CukLUOO-.js → index-BYgWJtf5.js} +3 -3
  42. package/dist/assets/{key-round-92fgndyk.js → key-round-TQn0w_dG.js} +1 -1
  43. package/dist/assets/{mf-entry-bootstrap-0-5e99685c.js → mf-entry-bootstrap-0-b66afa31.js} +2 -2
  44. package/dist/assets/{pencil-GseW53Af.js → pencil-D1CTOg1g.js} +1 -1
  45. package/dist/assets/{player-overlays-DACImv1W.js → player-overlays-DEJsZ4vG.js} +1 -1
  46. package/dist/assets/plus-DrLbwu0n.js +1 -0
  47. package/dist/assets/{radio-BDUnjOmb.js → radio-CzoEePni.js} +1 -1
  48. package/dist/assets/{refresh-cw-TV5MkG3n.js → refresh-cw-DDSHPs-V.js} +1 -1
  49. package/dist/assets/remoteEntry-DNq1lvEN.js +1 -0
  50. package/dist/assets/{rotate-ccw-DvDKOoJk.js → rotate-ccw-Pzaw7mWz.js} +1 -1
  51. package/dist/assets/rotate-cw-ByRfLyLz.js +1 -0
  52. package/dist/assets/search-UkoX7xbY.js +1 -0
  53. package/dist/assets/{server-BrxSxrRc.js → server-LYykgVAy.js} +1 -1
  54. package/dist/assets/{sparkles-BLSwH3NZ.js → sparkles-B0a6rPfh.js} +1 -1
  55. package/dist/assets/square-BQPPB1Xy.js +1 -0
  56. package/dist/assets/{square-check-big-DZGG97xQ.js → square-check-big-C5d9oxaD.js} +1 -1
  57. package/dist/assets/{src-3NEgkLWp.js → src-BLOkTPDQ.js} +10 -10
  58. package/dist/assets/src-Cu3jNb29.js +7 -0
  59. package/dist/assets/{upload-UD1RyugS.js → upload-DVSP-lTI.js} +1 -1
  60. package/dist/assets/useDevice-zkPtbbLX.js +1 -0
  61. package/dist/assets/{useEventInvalidation-C6mDyTBx.js → useEventInvalidation-DFTYybVh.js} +1 -1
  62. package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-CZAUwRYb.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-BdM04S1e.js} +2 -2
  63. package/dist/assets/{wifi-Bzb_4egH.js → wifi-BFz9o2wa.js} +1 -1
  64. package/dist/assets/{zap-ps4S9uq0.js → zap-Df269N-s.js} +1 -1
  65. package/dist/index.html +6 -6
  66. package/dist/server/addon.js +248 -4
  67. package/package.json +1 -1
  68. package/dist/assets/Pipeline-Bq-_taoo.js +0 -1
  69. package/dist/assets/circle-check-big-uwi7M0FF.js +0 -1
  70. package/dist/assets/dist-DozEYSra.js +0 -7
  71. package/dist/assets/index-7ucUNPxm.css +0 -2
  72. package/dist/assets/plus-D1FskUey.js +0 -1
  73. package/dist/assets/remoteEntry-Ci-8NIZN.js +0 -1
  74. package/dist/assets/rotate-cw-Dv3oho6L.js +0 -1
  75. package/dist/assets/search-CvffVaTb.js +0 -1
  76. package/dist/assets/square-D5hZ81IL.js +0 -1
  77. package/dist/assets/src-DAcus8MI.js +0 -7
  78. package/dist/assets/useDevice-B_z2JZ7g.js +0 -1
@@ -4629,7 +4629,7 @@ function _instanceof(cls, params = {}) {
4629
4629
  return inst;
4630
4630
  }
4631
4631
  //#endregion
4632
- //#region ../types/dist/sleep-BiDFW0E7.mjs
4632
+ //#region ../types/dist/sleep-CZDdRBua.mjs
4633
4633
  var EventCategory = /* @__PURE__ */ function(EventCategory) {
4634
4634
  EventCategory["SystemBoot"] = "system.boot";
4635
4635
  EventCategory["SystemAddonsReady"] = "system.addons-ready";
@@ -7233,7 +7233,16 @@ var DecoderStatsSchema = object({
7233
7233
  inputFps: number(),
7234
7234
  outputFps: number(),
7235
7235
  avgDecodeTimeMs: number(),
7236
- droppedFrames: number()
7236
+ droppedFrames: number(),
7237
+ /**
7238
+ * Pull-mode adaptive-fps telemetry (optional — only pull sessions run the
7239
+ * lag-driven controller; push sessions omit these). `lagMs` is the EWMA of
7240
+ * the decoder's real-time drift (rising = falling behind live); `adaptiveFps`
7241
+ * is the current lag-throttled emit rate (≤ `effectiveFps` ceiling).
7242
+ */
7243
+ lagMs: number().optional(),
7244
+ effectiveFps: number().optional(),
7245
+ adaptiveFps: number().optional()
7237
7246
  });
7238
7247
  var DecoderSessionConfigSchema = object({
7239
7248
  codec: string(),
@@ -7274,7 +7283,15 @@ var DecoderSessionConfigSchema = object({
7274
7283
  * other — `pullFrames` returns nothing for an `'shm'` session and
7275
7284
  * `pullHandles` returns nothing for a `'callback'` session.
7276
7285
  */
7277
- frameSink: _enum(["callback", "shm"]).default("callback")
7286
+ frameSink: _enum(["callback", "shm"]).default("callback"),
7287
+ /**
7288
+ * Per-camera decoder DEBUG facility. When `true`, a pull-mode session emits
7289
+ * a throttled (~1Hz) structured `decoder debug` line (effective/adaptive fps,
7290
+ * real-time lag, dropped-frame delta, avg decode time, hwaccel). Mirrors the
7291
+ * stream-broker's `streamingDebug` gate — off by default so production logs
7292
+ * stay quiet and the emit path pays zero per-frame cost when disabled.
7293
+ */
7294
+ debug: boolean().optional()
7278
7295
  });
7279
7296
  var EncodeProfileSchema = object({
7280
7297
  video: object({
@@ -9432,6 +9449,75 @@ DeviceType.Cover, method(object({ deviceId: number().int().nonnegative() }), _vo
9432
9449
  auth: "admin"
9433
9450
  });
9434
9451
  /**
9452
+ * Vendor-neutral day/night (IR-cut) control — the per-camera config cap
9453
+ * shared by reolink / hikvision / amcrest. Models the common firmware
9454
+ * surface: the IR-cut switching MODE plus the two knobs that gate it
9455
+ * (photocell `sensitivity` + `switchDelaySec`). Each vendor maps these
9456
+ * onto its own ISAPI / Baichuan / Dahua-CGI fields; the cap standardises
9457
+ * the shape so ONE derived-form renders every camera.
9458
+ *
9459
+ * Follows the D14 `deviceConfig` archetype (see `stream-params.cap.ts`):
9460
+ * `getOptions` advertises per-camera availability, `getStatus` (auto-
9461
+ * injected from `status`) reports the live values, and a single
9462
+ * `setSettings` mutation applies a partial change. No hand-written
9463
+ * settings-contribution methods — the framework derives the UI + save
9464
+ * routing from this surface.
9465
+ */
9466
+ /** IR-cut switching mode. `schedule` = time-of-day table configured on the camera. */
9467
+ var DayNightModeSchema = _enum([
9468
+ "auto",
9469
+ "day",
9470
+ "night",
9471
+ "schedule"
9472
+ ]);
9473
+ /** Normalized numeric range descriptor — `{ min, max, step }` per the
9474
+ * getOptions availability convention. Normalized values are 0–100. */
9475
+ var NormalizedRangeSchema$1 = object({
9476
+ min: number(),
9477
+ max: number(),
9478
+ step: number()
9479
+ });
9480
+ object({
9481
+ mode: DayNightModeSchema,
9482
+ /** IR-cut trigger sensitivity, NORMALIZED 0–100 (higher = switches to night sooner). */
9483
+ sensitivity: number().optional(),
9484
+ /** Delay before the IR-cut filter flips, in seconds. */
9485
+ switchDelaySec: number().optional(),
9486
+ lastFetchedAt: number()
9487
+ });
9488
+ /**
9489
+ * Per-camera availability descriptor — drives which controls the admin UI
9490
+ * renders. Booleans as `supportsX`; numeric ranges as `{ min, max, step }`
9491
+ * (normalized 0–100); the mode choice-set as an array. A provider returns
9492
+ * honest, camera-probed values — never hardcoded.
9493
+ */
9494
+ var DayNightOptionsSchema = object({
9495
+ /** Modes this camera accepts. Empty → the camera has no configurable day/night mode. */
9496
+ modes: array(DayNightModeSchema),
9497
+ supportsSensitivity: boolean(),
9498
+ /** Present when `supportsSensitivity` — the normalized 0–100 range. */
9499
+ sensitivity: NormalizedRangeSchema$1.optional(),
9500
+ supportsSwitchDelay: boolean(),
9501
+ /** Present when `supportsSwitchDelay` — the allowed delay range in seconds. */
9502
+ switchDelaySec: NormalizedRangeSchema$1.optional()
9503
+ });
9504
+ /**
9505
+ * Partial change to the day/night config — every field optional. A
9506
+ * provider ignores fields it does not support.
9507
+ */
9508
+ var DayNightSettingsPatchSchema = object({
9509
+ mode: DayNightModeSchema.optional(),
9510
+ sensitivity: number().optional(),
9511
+ switchDelaySec: number().optional()
9512
+ });
9513
+ DeviceType.Camera, method(object({ deviceId: number() }), DayNightOptionsSchema), method(object({
9514
+ deviceId: number(),
9515
+ settings: DayNightSettingsPatchSchema
9516
+ }), _void(), {
9517
+ kind: "mutation",
9518
+ auth: "admin"
9519
+ });
9520
+ /**
9435
9521
  * Identity envelope for a device's upstream-system metadata.
9436
9522
  *
9437
9523
  * Two jobs:
@@ -9787,6 +9873,130 @@ object({
9787
9873
  });
9788
9874
  DeviceType.Image;
9789
9875
  /**
9876
+ * Vendor-neutral image / picture-adjustment cap — the per-camera config
9877
+ * cap shared by reolink / hikvision / amcrest. Models the common ISP
9878
+ * surface: the four picture sliders (brightness / contrast / saturation /
9879
+ * sharpness), orientation (mirror / flip / rotate), white-balance,
9880
+ * exposure and backlight-compensation modes.
9881
+ *
9882
+ * NORMALIZATION: every slider is a normalized int 0–100. Vendors expose
9883
+ * these natively as 0–100 or 0–255 (or other ranges); each provider maps
9884
+ * its native range to/from this normalized 0–100 space so the cap surface
9885
+ * (and the derived form) is identical across cameras. `warmth` (manual
9886
+ * white-balance) is likewise normalized 0–100.
9887
+ *
9888
+ * Follows the D14 `deviceConfig` archetype (see `stream-params.cap.ts`):
9889
+ * `getOptions` advertises per-camera availability, `getStatus` (auto-
9890
+ * injected from `status`) reports the live values, and a single
9891
+ * `setSettings` mutation applies a partial change. No hand-written
9892
+ * settings-contribution methods — the framework derives the UI + save
9893
+ * routing from this surface.
9894
+ */
9895
+ /** Sensor/image rotation, degrees clockwise. */
9896
+ var ImageRotateSchema = _enum([
9897
+ "0",
9898
+ "90",
9899
+ "180",
9900
+ "270"
9901
+ ]);
9902
+ /** White-balance mode. `manual` unlocks the normalized `warmth` knob. */
9903
+ var WhiteBalanceModeSchema = _enum(["auto", "manual"]);
9904
+ /** Exposure mode. */
9905
+ var ExposureModeSchema = _enum(["auto", "manual"]);
9906
+ /**
9907
+ * Backlight-compensation mode:
9908
+ * - `off` — disabled
9909
+ * - `blc` — backlight compensation
9910
+ * - `wdr` — wide dynamic range
9911
+ * - `hlc` — highlight compensation
9912
+ */
9913
+ var BacklightModeSchema = _enum([
9914
+ "off",
9915
+ "blc",
9916
+ "wdr",
9917
+ "hlc"
9918
+ ]);
9919
+ /** Normalized numeric range descriptor — `{ min, max, step }` per the
9920
+ * getOptions availability convention. Slider values are normalized 0–100. */
9921
+ var NormalizedRangeSchema = object({
9922
+ min: number(),
9923
+ max: number(),
9924
+ step: number()
9925
+ });
9926
+ object({
9927
+ /** Normalized 0–100. */
9928
+ brightness: number().optional(),
9929
+ /** Normalized 0–100. */
9930
+ contrast: number().optional(),
9931
+ /** Normalized 0–100. */
9932
+ saturation: number().optional(),
9933
+ /** Normalized 0–100. */
9934
+ sharpness: number().optional(),
9935
+ mirror: boolean().optional(),
9936
+ flip: boolean().optional(),
9937
+ rotate: ImageRotateSchema.optional(),
9938
+ whiteBalance: WhiteBalanceModeSchema.optional(),
9939
+ /** Manual white-balance warmth, NORMALIZED 0–100. Meaningful only when `whiteBalance === 'manual'`. */
9940
+ warmth: number().optional(),
9941
+ exposureMode: ExposureModeSchema.optional(),
9942
+ backlightMode: BacklightModeSchema.optional(),
9943
+ lastFetchedAt: number()
9944
+ });
9945
+ /**
9946
+ * Per-camera availability descriptor — drives which controls the admin UI
9947
+ * renders. Booleans as `supportsX`; numeric ranges as `{ min, max, step }`
9948
+ * (the normalized 0–100 range); enums as arrays of supported values (empty
9949
+ * array → control hidden). A provider returns honest, camera-probed values
9950
+ * — never hardcoded.
9951
+ */
9952
+ var ImageSettingsOptionsSchema = object({
9953
+ supportsBrightness: boolean(),
9954
+ brightness: NormalizedRangeSchema.optional(),
9955
+ supportsContrast: boolean(),
9956
+ contrast: NormalizedRangeSchema.optional(),
9957
+ supportsSaturation: boolean(),
9958
+ saturation: NormalizedRangeSchema.optional(),
9959
+ supportsSharpness: boolean(),
9960
+ sharpness: NormalizedRangeSchema.optional(),
9961
+ supportsMirror: boolean(),
9962
+ supportsFlip: boolean(),
9963
+ /** Supported rotation values. Empty → rotation not configurable. */
9964
+ rotateOptions: array(ImageRotateSchema),
9965
+ /** Supported white-balance modes. Empty → white-balance not configurable. */
9966
+ whiteBalanceModes: array(WhiteBalanceModeSchema),
9967
+ supportsWarmth: boolean(),
9968
+ /** Present when `supportsWarmth` — the normalized 0–100 range. */
9969
+ warmth: NormalizedRangeSchema.optional(),
9970
+ /** Supported exposure modes. Empty → exposure not configurable. */
9971
+ exposureModes: array(ExposureModeSchema),
9972
+ /** Supported backlight modes. Empty → backlight-compensation not configurable. */
9973
+ backlightModes: array(BacklightModeSchema)
9974
+ });
9975
+ /**
9976
+ * Partial change to the image config — every field optional. Slider values
9977
+ * are normalized 0–100. A provider ignores fields it does not support.
9978
+ */
9979
+ var ImageSettingsPatchSchema = object({
9980
+ brightness: number().optional(),
9981
+ contrast: number().optional(),
9982
+ saturation: number().optional(),
9983
+ sharpness: number().optional(),
9984
+ mirror: boolean().optional(),
9985
+ flip: boolean().optional(),
9986
+ rotate: ImageRotateSchema.optional(),
9987
+ whiteBalance: WhiteBalanceModeSchema.optional(),
9988
+ warmth: number().optional(),
9989
+ exposureMode: ExposureModeSchema.optional(),
9990
+ backlightMode: BacklightModeSchema.optional()
9991
+ });
9992
+ DeviceType.Camera, method(object({ deviceId: number() }), ImageSettingsOptionsSchema), method(object({
9993
+ deviceId: number(),
9994
+ settings: ImageSettingsPatchSchema
9995
+ }), _void(), {
9996
+ kind: "mutation",
9997
+ auth: "admin"
9998
+ });
9999
+ /**
9790
10000
  * Robotic lawn-mower cap. Models HA `lawn_mower.*` entities — anything
9791
10001
  * with a mowing lifecycle plus a dock action.
9792
10002
  *
@@ -10681,6 +10891,16 @@ var RunnerCameraConfigSchema = object({
10681
10891
  * this gate is bypassed.
10682
10892
  */
10683
10893
  onboardMotionDrivesAnalyzer: boolean().default(true),
10894
+ /**
10895
+ * Master toggle for the occupancy re-check. When `false` (DEFAULT) the runner
10896
+ * never arms the periodic recheck timer, regardless of `occupancyRecheckSec` —
10897
+ * this is off by default because the recheck re-subscribes a detection session
10898
+ * every N seconds while `watching`, a major source of pull-decoder re-dial
10899
+ * churn (each cycle creates+tears a session → RTSP re-dial → latency). The
10900
+ * `occupancyRecheckSec` / `occupancyRecheckFrames` sliders only take effect
10901
+ * (and only render) when this is enabled.
10902
+ */
10903
+ occupancyRecheckEnabled: boolean().default(false),
10684
10904
  occupancyRecheckSec: number().min(occupancyRecheckSecField.min).max(occupancyRecheckSecField.max).default(occupancyRecheckSecField.default),
10685
10905
  occupancyRecheckFrames: number().min(occupancyRecheckFramesField.min).max(occupancyRecheckFramesField.max).default(occupancyRecheckFramesField.default),
10686
10906
  /**
@@ -18971,6 +19191,18 @@ Object.freeze({
18971
19191
  addonId: null,
18972
19192
  access: "view"
18973
19193
  },
19194
+ "dayNight.getOptions": {
19195
+ capName: "day-night",
19196
+ capScope: "device",
19197
+ addonId: null,
19198
+ access: "view"
19199
+ },
19200
+ "dayNight.setSettings": {
19201
+ capName: "day-night",
19202
+ capScope: "device",
19203
+ addonId: null,
19204
+ access: "create"
19205
+ },
18974
19206
  "decoder.createSession": {
18975
19207
  capName: "decoder",
18976
19208
  capScope: "system",
@@ -19901,6 +20133,18 @@ Object.freeze({
19901
20133
  addonId: null,
19902
20134
  access: "create"
19903
20135
  },
20136
+ "imageSettings.getOptions": {
20137
+ capName: "image-settings",
20138
+ capScope: "device",
20139
+ addonId: null,
20140
+ access: "view"
20141
+ },
20142
+ "imageSettings.setSettings": {
20143
+ capName: "image-settings",
20144
+ capScope: "device",
20145
+ addonId: null,
20146
+ access: "create"
20147
+ },
19904
20148
  "integrations.create": {
19905
20149
  capName: "integrations",
19906
20150
  capScope: "system",
@@ -22595,7 +22839,7 @@ var AdminUIAddon = class extends BaseAddon {
22595
22839
  capability: adminUiCapability,
22596
22840
  provider: {
22597
22841
  getStaticDir: async () => ({ staticDir: resolveAdminUiDistDir() }),
22598
- getVersion: async () => ({ version: "1.1.31" })
22842
+ getVersion: async () => ({ version: "1.1.33" })
22599
22843
  }
22600
22844
  }];
22601
22845
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-admin-ui",
3
- "version": "1.1.31",
3
+ "version": "1.1.33",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "CamStack Admin UI — Vite frontend build and server-side addon",
@@ -1 +0,0 @@
1
- import{Aa as e,Br as t,C as n,Ci as r,Di as i,Ei as a,Fr as o,Gr as s,Hr as c,Ia as l,Jr as u,Kr as d,Lr as f,Qi as p,Qr as m,Ra as h,Rr as g,T as _,Ti as v,Ur as y,Vr as b,Xr as x,Zr as S,_ as C,aa as w,ai as T,bi as E,ca as D,ci as O,da as k,di as A,ei as j,fi as M,ia as N,it as P,ki as ee,na as F,oi as I,ot as te,pi as ne,qr as re,ra as ie,ri as ae,sa as oe,si as se,ti as ce,ua as le,ui as ue,vi as de,xi as fe,yi as pe,zr as me}from"./src-3NEgkLWp.js";import{I as he,K as ge,Q as L,S as R,T as _e,W as z,a as ve,b as B,o as V,q as H,x as U,z as W}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DTufy7Ue.js";import{L as G,R as ye}from"./src-DAcus8MI.js";import{p as be}from"./player-overlays-DACImv1W.js";import{t as xe}from"./download-DRBhCGtf.js";import{i as Se,n as Ce,r as we,t as Te}from"./AddLocationWizard-CoTQ1C0P.js";import{n as Ee,r as De,t as Oe}from"./zap-ps4S9uq0.js";import{t as ke}from"./pencil-GseW53Af.js";import{t as Ae}from"./plus-D1FskUey.js";import{t as je}from"./refresh-cw-TV5MkG3n.js";import{t as Me}from"./search-CvffVaTb.js";import{t as Ne}from"./server-BrxSxrRc.js";import{t as Pe}from"./square-check-big-DZGG97xQ.js";import{t as Fe}from"./square-D5hZ81IL.js";import{A as Ie,F as Le,G as Re,M as ze,P as Be,V as Ve,i as He,j as Ue,k as K,o as We,s as Ge,w as Ke,x as q}from"./index-CukLUOO-.js";import{t as qe}from"./AdminPage-BwmGKnRf.js";import{r as Je}from"./useDevice-B_z2JZ7g.js";import{t as J}from"./useEventInvalidation-C6mDyTBx.js";import{a as Ye,c as Y,i as Xe,l as Ze,n as Qe,o as X,r as $e,s as et,t as tt}from"./build-cluster-graph-Ci-E0Tjd.js";import{n as nt}from"./format-size-CO9d3C3-.js";import{t as rt}from"./NodeAddonsSettingsPanel-CaMCtRtL.js";var it=Ve(`ellipsis-vertical`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`12`,cy:`5`,r:`1`,key:`gxeob9`}],[`circle`,{cx:`12`,cy:`19`,r:`1`,key:`lyex9k`}]]),at=Ve(`film`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M7 3v18`,key:`bbkbws`}],[`path`,{d:`M3 7.5h4`,key:`zfgn84`}],[`path`,{d:`M3 12h18`,key:`1i2n21`}],[`path`,{d:`M3 16.5h4`,key:`1230mu`}],[`path`,{d:`M17 3v18`,key:`in4fa5`}],[`path`,{d:`M17 7.5h4`,key:`myr1c1`}],[`path`,{d:`M17 16.5h4`,key:`go4c1d`}]]),ot=Ve(`flame`,[[`path`,{d:`M8.5 14.5A2.5 2.5 0 0 0 11 12c0-1.38-.5-2-1-3-1.072-2.143-.224-4.054 2-6 .5 2.5 2 4.9 4 6.5 2 1.6 3 3.5 3 5.5a7 7 0 1 1-14 0c0-1.153.433-2.294 1-3a2.5 2.5 0 0 0 2.5 2.5z`,key:`96xj49`}]]),st=Ve(`pin`,[[`path`,{d:`M12 17v5`,key:`bb1du9`}],[`path`,{d:`M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z`,key:`1nkz8b`}]]);L();function ct(e){return e}function lt(e,t){for(let[n,r]of Object.entries(e??{}))if(n===t)return r}function ut(e,t){return typeof e==`boolean`?e:ct(t)}function dt(e,t){return{decode:ut(lt(e,`decode`),t),pipeline:ut(lt(e,`detect`),t),audio:ut(lt(e,`audio`),t),ingest:ut(lt(e,`ingest`),t)}}function ft(e,t,n){let r=e?.find(e=>e.nodeId===t);return dt(r?.settings,n)}function pt({selectedNodeId:t,onSelect:n,refreshToken:r}){let{data:i}=o(void 0),{data:a}=T(void 0),{data:s}=I(void 0),c=new Map;for(let e of a??[])c.set(e.agentNodeId,(c.get(e.agentNodeId)??0)+1);let l=i??[],u=l.filter(e=>e.isOnline).length,d=l.filter(e=>!e.isOnline).length;return R(`div`,{className:`flex flex-col h-full`,children:[R(`button`,{type:`button`,onClick:()=>n(br),className:`flex items-center gap-3 px-4 py-3 border-b border-border text-left transition-colors ${t===`__cluster__`?`bg-primary/10 text-primary`:`text-foreground hover:bg-surface-hover`}`,children:[U(Ke,{className:`h-4 w-4 flex-shrink-0`}),R(`div`,{className:`min-w-0 flex-1`,children:[U(`div`,{className:`text-xs font-semibold truncate`,children:`Cluster`}),U(`div`,{className:`text-[10px] text-foreground-subtle`,children:`Balancer + failover + assignments`})]})]}),U(`div`,{className:`flex-1 overflow-y-auto`,children:l.map(r=>{let i=t===r.id,a=c.get(r.id)??0,o=r.isHub?Ne:K,l=ft(s,r.id,r.isHub),u=r.isOnline?null:h(Ze(r.lastSeen));return R(`button`,{type:`button`,onClick:()=>n(r.id),className:`flex items-center gap-3 w-full px-4 py-3 border-b border-border text-left transition-colors ${i?`bg-primary/10 text-primary`:`text-foreground hover:bg-surface-hover`}${r.isOnline?``:` opacity-60`}`,children:[U(o,{className:`h-4 w-4 flex-shrink-0`}),R(`div`,{className:`min-w-0 flex-1`,children:[R(`div`,{className:`flex items-center gap-2`,children:[U(`span`,{className:`text-xs font-semibold truncate`,children:r.name}),r.isHub&&U(`span`,{className:`text-[9px] uppercase tracking-wider text-foreground-subtle border border-border rounded px-1 py-0.5`,children:`hub`}),!r.isOnline&&U(`span`,{className:`h-1.5 w-1.5 rounded-full bg-destructive flex-shrink-0`}),r.isOnline&&U(`span`,{className:`h-1.5 w-1.5 rounded-full bg-success flex-shrink-0`})]}),R(`div`,{className:`text-[10px] text-foreground-subtle flex items-center gap-2 mt-0.5`,children:[R(`span`,{children:[r.cpuCores,` cores`]}),U(`span`,{children:`•`}),R(`span`,{children:[Math.round(r.memoryMB/1024),` GB`]}),a>0&&R(B,{children:[U(`span`,{children:`•`}),R(`span`,{className:`inline-flex items-center gap-0.5 text-foreground`,children:[U(Ee,{className:`h-2.5 w-2.5`}),a]})]}),!r.isOnline&&R(B,{children:[U(`span`,{children:`•`}),R(`span`,{className:`text-destructive`,children:[`offline`,u===null?``:` · ${u}`]})]})]}),R(`div`,{className:`mt-0.5 flex items-center gap-1`,children:[U(e,{variant:l.decode?`success`:`danger`,className:`px-1 py-0 text-[9px] leading-3`,title:l.decode?`Decode: enabled`:`Decode: not enabled (agent capability)`,children:`Dec`}),U(e,{variant:l.pipeline?`success`:`danger`,className:`px-1 py-0 text-[9px] leading-3`,title:l.pipeline?`Pipeline: enabled`:`Pipeline: not enabled (agent capability)`,children:`Pipe`}),U(e,{variant:l.audio?`success`:`danger`,className:`px-1 py-0 text-[9px] leading-3`,title:l.audio?`Audio: enabled`:`Audio: not enabled (agent capability)`,children:`Aud`})]})]})]},r.id)})}),R(`div`,{className:`px-4 py-2 border-t border-border text-[10px] text-foreground-subtle flex items-center justify-between`,children:[R(`span`,{children:[u,` online`]}),d>0&&R(`span`,{className:`text-destructive`,children:[d,` offline`]})]})]})}function mt({nodeId:e,refreshToken:t}){let{data:n}=o(void 0),r=n?.find(t=>t.id===e),i=ie(`pipeline.runner-load-snapshot`,t=>t.nodeId===e)?.load??null;return r?R(`div`,{className:`px-6 py-4 border-b border-border`,children:[R(`div`,{className:`flex items-center gap-2 mb-1`,children:[U(`h2`,{className:`text-base font-semibold text-foreground`,children:r.name}),r.isOnline?U(`span`,{className:`text-[10px] px-2 py-0.5 rounded-full bg-success/10 text-success`,children:`online`}):U(`span`,{className:`text-[10px] px-2 py-0.5 rounded-full bg-destructive/10 text-destructive`,children:`offline`}),r.isHub&&U(`span`,{className:`text-[9px] uppercase tracking-wider text-foreground-subtle border border-border rounded px-1 py-0.5`,children:`hub`})]}),R(`div`,{className:`text-[11px] text-foreground-subtle flex items-center gap-2 flex-wrap`,children:[U(`span`,{children:r.cpuModel??`CPU`}),U(`span`,{children:`•`}),R(`span`,{children:[r.cpuCores,` cores`]}),U(`span`,{children:`•`}),R(`span`,{children:[Math.round(r.memoryMB/1024),` GB`]}),i&&R(B,{children:[U(`span`,{children:`•`}),R(`span`,{children:[i.attachedCameras,` cameras (`,i.activeCameras,` active)`]}),U(`span`,{children:`•`}),R(`span`,{children:[i.avgInferenceTimeMs.toFixed(0),`ms avg inference`]}),U(`span`,{children:`•`}),R(`span`,{children:[`queue `,i.queueDepthTotal]}),i.hardware.hasGpu&&R(B,{children:[U(`span`,{children:`•`}),U(`span`,{className:`text-success`,children:`GPU`})]})]})]})]}):U(`div`,{className:`px-6 py-4 border-b border-border`,children:R(`div`,{className:`text-xs text-foreground-subtle`,children:[`Node not found: `,e]})})}function ht({refreshToken:e,nodeId:t}){let[n,r]=H(new Map),{nodes:i}=F();w(`pipeline.camera-metrics-snapshot`,e=>{let t=e.data;typeof t?.deviceId==`number`&&r(e=>{let n=new Map(e);return n.set(t.deviceId,t),n})});let{data:a}=m(void 0),o=z(()=>{let e=new Map;for(let t of a??[])e.set(t.nodeId,t.deviceCount);return e},[a]),s=z(()=>{let e=new Map,t=Date.now()-3e4;for(let r of n.values()){if(r.timestamp<t)continue;let n=r.nodeId??`hub`,i=e.get(n)??{attachedCameras:0,activeCameras:0,totalFps:0,totalInferenceWeighted:0,queueDepth:0};i.attachedCameras++,r.metrics.phase===`active`&&i.activeCameras++,i.totalFps+=r.metrics.actualFps,i.totalInferenceWeighted+=r.metrics.avgInferenceTimeMs,i.queueDepth+=r.metrics.queueDepth,e.set(n,i)}return e},[n]),c=z(()=>{let e=new Map;for(let t of i)e.set(t.id,t.shortName);return e},[i]),l=z(()=>{let e=0,t=0,n=0,r=0,a=0;for(let i of s.values())e+=i.attachedCameras,t+=i.activeCameras,n+=i.totalFps,r+=i.totalInferenceWeighted,a+=i.queueDepth;let o=e>0?r/e:0;return{totalAgents:i.length,onlineAgents:i.filter(e=>e.isOnline).length,attachedCameras:e,activeCameras:t,avgInferenceTimeMs:o,queueDepth:a,totalFps:n}},[s,i]);if(t){let e=s.get(t);return R(`div`,{className:`@container/liveload`,children:[U(`h3`,{className:`text-sm font-semibold text-foreground mb-2`,children:`Live load`}),R(`div`,{className:`grid grid-cols-2 @md/liveload:grid-cols-3 @3xl/liveload:grid-cols-5 gap-2 mb-3`,children:[U(Z,{label:`FPS`,value:e?e.totalFps.toFixed(1):`—`}),U(Z,{label:`Cameras`,value:e?`${e.activeCameras}/${e.attachedCameras}`:`—`}),U(Z,{label:`Avg infer ms`,value:e&&e.attachedCameras>0?(e.totalInferenceWeighted/e.attachedCameras).toFixed(0):`—`}),U(Z,{label:`Queue`,value:e?String(e.queueDepth):`—`}),U(Z,{label:`Audio`,value:String(o.get(t)??`—`)})]})]})}let u=[...s.entries()].toSorted(([e],[t])=>e===`hub`?-1:t===`hub`?1:e.localeCompare(t));return R(`div`,{className:`@container/liveload`,children:[U(`h3`,{className:`text-sm font-semibold text-foreground mb-2`,children:`Live load`}),R(`div`,{className:`grid grid-cols-2 @md/liveload:grid-cols-3 @3xl/liveload:grid-cols-5 gap-2 sm:gap-3 mb-3`,children:[U(Z,{label:`Total agents`,value:`${l.onlineAgents}/${l.totalAgents}`}),U(Z,{label:`Cameras`,value:`${l.activeCameras}/${l.attachedCameras}`}),U(Z,{label:`Total FPS`,value:l.totalFps.toFixed(1)}),U(Z,{label:`Avg inference ms`,value:l.avgInferenceTimeMs.toFixed(0)}),U(Z,{label:`Queue depth`,value:String(l.queueDepth)})]}),U(`div`,{className:`rounded-lg border border-border overflow-x-auto`,children:R(`table`,{className:`w-full text-xs min-w-[480px]`,children:[U(`thead`,{className:`bg-surface`,children:R(`tr`,{className:`text-foreground-subtle text-[10px] uppercase tracking-wider`,children:[U(`th`,{className:`text-left px-3 py-2`,children:`Agent`}),U(`th`,{className:`text-right px-3 py-2`,children:`FPS`}),U(`th`,{className:`text-right px-3 py-2`,children:`Cameras`}),U(`th`,{className:`text-right px-3 py-2`,children:`Inference ms`}),U(`th`,{className:`text-right px-3 py-2`,children:`Queue`}),U(`th`,{className:`text-right px-3 py-2`,children:`Audio`})]})}),R(`tbody`,{children:[u.map(([e,t])=>R(`tr`,{className:`border-t border-border`,children:[U(`td`,{className:`px-3 py-2 text-foreground font-medium`,children:c.get(e)??e}),U(`td`,{className:`px-3 py-2 text-right text-foreground`,children:t.totalFps.toFixed(1)}),U(`td`,{className:`px-3 py-2 text-right text-foreground`,children:t.attachedCameras}),U(`td`,{className:`px-3 py-2 text-right text-foreground`,children:t.attachedCameras>0?(t.totalInferenceWeighted/t.attachedCameras).toFixed(0):`—`}),U(`td`,{className:`px-3 py-2 text-right text-foreground`,children:t.queueDepth}),U(`td`,{className:`px-3 py-2 text-right text-foreground`,children:o.get(e)??`—`})]},e)),u.length===0&&U(`tr`,{children:U(`td`,{colSpan:6,className:`px-3 py-4 text-center text-foreground-subtle text-[11px]`,children:`No camera metrics received yet`})})]})]})})]})}function Z({label:e,value:t}){return R(`div`,{className:`rounded-lg border border-border bg-surface/60 p-3`,children:[U(`div`,{className:`text-[10px] uppercase tracking-wider text-foreground-subtle mb-1`,children:e}),U(`div`,{className:`text-lg font-semibold text-foreground`,children:t})]})}L();var gt={active:!1,pinned:!1,nodeId:null,reason:``},_t=[`pipeline.camera-assigned`,`pipeline.camera-unassigned`,`pipeline.camera-updated`,`agent.online`,`agent.offline`],vt={pipeline:K,decoder:at,audio:De},yt={pipeline:`Pipeline`,decoder:`Decoder`,audio:`Audio`};function bt({mode:e,nodeId:t,compact:n=!1}){if(e===`agent`&&!t)throw Error(`CameraAssignmentsTable: nodeId is required when mode === "agent"`);let r=V(),[i,a]=H(null),[o,c]=H(null),[l,u]=H(new Map);J([`pipelineOrchestrator`,`getPipelineAssignments`],_t),J([`pipelineOrchestrator`,`getDecoderAssignments`],_t),J([`pipelineOrchestrator`,`getAudioAssignments`],_t);let{data:f}=T(void 0),{data:p}=ae(void 0),{data:m}=S(void 0),{nodes:h}=F(),{data:g}=Je();w(`pipeline.camera-metrics-snapshot`,e=>{let t=e.data;typeof t.deviceId==`number`&&u(e=>{let n=new Map(e);return n.set(t.deviceId,t),n})}),W(()=>{if(l.size===0)return;let e=setInterval(()=>{u(e=>{let t=Date.now()-1e4,n=!1,r=new Map(e);for(let[i,a]of e)a.timestamp<t&&(r.delete(i),n=!0);return n?r:e})},5e3);return()=>clearInterval(e)},[l.size]);let v=z(()=>{let e=new Map;for(let t of g??[])e.set(t.id,t.name);return e},[g]),y=z(()=>{let n=new Map,r=e=>{let t=n.get(e);if(t)return t;let r={deviceId:e,deviceName:v.get(e)??`Device ${e}`,pipeline:gt,decoder:gt,audio:gt};return n.set(e,r),r};for(let i of f??[]){let a=r(i.deviceId);n.set(i.deviceId,{...a,pipeline:{active:e===`cluster`?!0:i.agentNodeId===t,pinned:i.pinned,nodeId:i.agentNodeId,reason:i.reason??``}})}for(let i of p??[]){let a=r(i.deviceId);n.set(i.deviceId,{...a,decoder:{active:e===`cluster`?!0:i.decoderNodeId===t,pinned:i.pinned,nodeId:i.decoderNodeId,reason:i.reason??``}})}for(let i of m??[]){let a=r(i.deviceId);n.set(i.deviceId,{...a,audio:{active:e===`cluster`?!0:i.nodeId===t,pinned:i.pinned,nodeId:i.nodeId,reason:`capacity`}})}let i=[...n.values()];return e===`agent`&&(i=i.filter(e=>e.pipeline.active||e.decoder.active||e.audio.active)),i.sort((e,t)=>e.deviceId-t.deviceId),i},[f,p,m,v,e,t]),b=z(()=>(h??[]).filter(e=>e.isOnline).map(e=>({id:e.id,name:e.name})),[h]),x=()=>{r.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getPipelineAssignments`]]}),r.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getDecoderAssignments`]]}),r.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getAudioAssignments`]]})},C=re({onSuccess:x}),D=E({onSuccess:x}),O=d({onSuccess:x}),k=pe({onSuccess:x}),A=s({onSuccess:x}),j=de({onSuccess:x}),M=(e,t,n)=>{t===`pipeline`?C.mutate({deviceId:e,agentNodeId:n}):t===`decoder`?O.mutate({deviceId:e,nodeId:n}):A.mutate({deviceId:e,nodeId:n}),a(null)},N=(e,t)=>{t===`pipeline`?D.mutate({deviceId:e}):t===`decoder`?k.mutate({deviceId:e}):j.mutate({deviceId:e}),a(null)};return U(`div`,{className:`rounded-lg border border-border overflow-x-auto`,children:R(`table`,{className:`w-full text-xs min-w-[640px]`,children:[U(`thead`,{className:`bg-surface`,children:R(`tr`,{className:`text-foreground-subtle text-[10px] uppercase tracking-wider`,children:[!n&&U(`th`,{className:`w-6`}),U(`th`,{className:`text-left px-3 py-2 align-middle`,children:`Camera`}),e===`cluster`?R(B,{children:[U(`th`,{className:`text-left px-3 py-2 align-middle`,children:`Auto | Pin`}),U(`th`,{className:`text-left px-3 py-2 align-middle`,children:`Resolved placement`})]}):R(B,{children:[U(`th`,{className:`text-left px-3 py-2 align-middle`,children:`Pipeline`}),U(`th`,{className:`text-left px-3 py-2 align-middle`,children:`Decoder`}),U(`th`,{className:`text-left px-3 py-2 align-middle`,children:`Audio`})]}),U(`th`,{className:`text-left px-3 py-2 align-middle`,children:`Status`})]})}),R(`tbody`,{children:[y.map(t=>{let r=l.get(t.deviceId),s=o===t.deviceId;return R(_e.Fragment,{children:[R(`tr`,{className:`border-t border-border align-middle relative`,children:[!n&&U(`td`,{className:`px-2 py-2 align-middle`,children:U(`button`,{type:`button`,onClick:()=>c(s?null:t.deviceId),className:`p-1 rounded hover:bg-surface-hover text-foreground-subtle`,"aria-label":s?`Collapse broker details`:`Expand broker details`,children:U(s?Be:ze,{className:`h-3.5 w-3.5`})})}),R(`td`,{className:`px-3 py-2 align-middle`,children:[U(`div`,{className:`text-foreground font-medium leading-tight`,children:t.deviceName}),R(`div`,{className:`text-[10px] text-foreground-subtle leading-tight`,children:[`#`,t.deviceId]})]}),e===`cluster`?R(B,{children:[U(`td`,{className:`px-3 py-2 align-middle`,children:U(xt,{state:t.pipeline,onlineNodes:b,pending:C.isPending||D.isPending,onChange:e=>{e===`auto`?N(t.deviceId,`pipeline`):M(t.deviceId,`pipeline`,e)}})}),U(`td`,{className:`px-3 py-2 align-middle`,children:U(St,{state:t.pipeline})})]}):R(B,{children:[U(Ct,{role:`pipeline`,state:t.pipeline,mode:e,deviceId:t.deviceId,onlineNodes:b,isMenuOpen:i?.deviceId===t.deviceId&&i.role===`pipeline`,onToggleMenu:()=>a(i?.deviceId===t.deviceId&&i.role===`pipeline`?null:{deviceId:t.deviceId,role:`pipeline`}),onCloseMenu:()=>a(null),onMove:e=>M(t.deviceId,`pipeline`,e),onUnpin:()=>N(t.deviceId,`pipeline`)}),U(Ct,{role:`decoder`,state:t.decoder,mode:e,deviceId:t.deviceId,onlineNodes:b,isMenuOpen:i?.deviceId===t.deviceId&&i.role===`decoder`,onToggleMenu:()=>a(i?.deviceId===t.deviceId&&i.role===`decoder`?null:{deviceId:t.deviceId,role:`decoder`}),onCloseMenu:()=>a(null),onMove:e=>M(t.deviceId,`decoder`,e),onUnpin:()=>N(t.deviceId,`decoder`)}),U(Ct,{role:`audio`,state:t.audio,mode:e,deviceId:t.deviceId,onlineNodes:b,isMenuOpen:i?.deviceId===t.deviceId&&i.role===`audio`,onToggleMenu:()=>a(i?.deviceId===t.deviceId&&i.role===`audio`?null:{deviceId:t.deviceId,role:`audio`}),onCloseMenu:()=>a(null),onMove:e=>M(t.deviceId,`audio`,e),onUnpin:()=>N(t.deviceId,`audio`)})]}),U(`td`,{className:`px-3 py-2 align-middle`,children:U(Et,{snap:r})})]}),s&&!n&&R(`tr`,{className:`bg-surface/50`,children:[U(`td`,{}),U(`td`,{colSpan:e===`cluster`?4:5,className:`px-3 py-2`,children:U(_,{widgetId:`stream-broker/stream-broker-panel`,host:`device-tab`,deviceId:t.deviceId,instanceId:`pipeline-row/${t.deviceId}`,config:{variant:`compact`,title:`Stream brokers & clients`}})})]})]},t.deviceId)}),y.length===0&&U(`tr`,{children:U(`td`,{colSpan:n?e===`cluster`?4:5:e===`cluster`?5:6,className:`px-3 py-4 text-center text-foreground-subtle text-[11px]`,children:e===`agent`?`No cameras assigned to this node`:`No cameras currently assigned`})})]})]})})}function xt({state:e,onlineNodes:t,pending:n,onChange:r}){let i=e.pinned&&e.nodeId?e.nodeId:`auto`,a=[...new Set([...e.nodeId?[e.nodeId]:[],...t.map(e=>e.id)])];return R(`select`,{value:i,disabled:n,"aria-label":`Pipeline placement pin`,onChange:e=>r(e.target.value),className:`rounded-md border border-border bg-background px-2 py-1 text-xs text-foreground`,children:[U(`option`,{value:`auto`,children:`Auto`}),a.map(e=>R(`option`,{value:e,children:[`Pin → `,t.find(t=>t.id===e)?.name??e]},e))]})}function St({state:e}){return!e.active||!e.nodeId?U(`span`,{className:`text-[10px] text-foreground-subtle italic`,children:`—`}):R(`div`,{className:`flex flex-col leading-tight`,children:[U(`span`,{className:`font-mono text-[11px] text-foreground`,children:e.nodeId}),U(`span`,{className:e.pinned?`text-amber-400 text-[10px]`:`text-foreground-subtle text-[10px]`,children:e.pinned?`pinned · manual`:`auto · ${e.reason||`capacity`}`})]})}function Ct({role:e,state:t,mode:n,onlineNodes:r,isMenuOpen:i,onToggleMenu:a,onCloseMenu:o,onMove:s,onUnpin:c}){let l=vt[e],u=r.filter(e=>e.id!==(t.nodeId??``)),d=(t.active||n===`cluster`)&&(u.length>0||t.pinned);return R(`td`,{className:`px-3 py-2 align-middle relative`,children:[R(`div`,{className:`flex items-center gap-2`,children:[U(n===`agent`?wt:Tt,{state:t,Icon:l}),U(`div`,{className:`ml-auto`,children:d&&U(`button`,{type:`button`,onClick:a,className:`p-1 rounded hover:bg-surface-hover`,"aria-label":`${yt[e]} actions`,children:U(it,{className:`h-3 w-3 text-foreground-subtle`})})})]}),i&&d&&U(Dt,{title:yt[e],targets:u,pinned:t.pinned,onMove:s,onUnpin:c,onClose:o})]})}function wt({state:e,Icon:t}){return R(`div`,{className:`flex items-center gap-1.5`,children:[U(e.active?Pe:Fe,{className:`h-3.5 w-3.5 ${e.active?`text-success`:`text-foreground-subtle/50`}`}),U(t,{className:`h-3 w-3 ${e.active?`text-foreground-subtle`:`text-foreground-subtle/40`}`}),e.pinned&&U(st,{className:`h-2.5 w-2.5 text-amber-400`})]})}function Tt({state:e,Icon:t}){return!e.active||!e.nodeId?R(`div`,{className:`flex items-center gap-1.5 text-foreground-subtle/60`,children:[U(t,{className:`h-3 w-3`}),U(`span`,{className:`text-[10px] italic`,children:`—`})]}):R(`div`,{className:`flex items-center gap-1.5 min-w-0`,children:[U(t,{className:`h-3 w-3 text-foreground-subtle shrink-0`}),R(`div`,{className:`flex flex-col leading-tight min-w-0`,children:[U(`span`,{className:`font-mono text-[11px] text-foreground truncate`,children:e.nodeId}),U(`span`,{className:`flex items-center gap-1 text-[10px]`,children:e.pinned?R(`span`,{className:`inline-flex items-center gap-0.5 text-amber-400`,children:[U(st,{className:`h-2.5 w-2.5`}),` manual`]}):R(`span`,{className:`text-foreground-subtle truncate`,children:[`auto · `,e.reason||`capacity`]})})]})]})}function Et({snap:e}){if(!e)return U(`span`,{className:`text-[10px] text-foreground-subtle italic`,children:`—`});let{phase:t,actualFps:n,avgInferenceTimeMs:r,queueDepth:i,configuredFps:a,droppedFrames:o}=e.metrics,s=l(t);return R(`div`,{className:`flex flex-col gap-0.5 font-mono text-[10px] tabular-nums leading-tight`,children:[R(`span`,{className:`inline-flex items-center gap-1 ${s.textColor}`,children:[U(C,{phase:t,className:`h-2.5 w-2.5`}),U(`span`,{className:`font-semibold uppercase tracking-wider`,children:s.label})]}),R(`span`,{className:`text-foreground-subtle`,children:[U(`span`,{className:`text-foreground`,children:n.toFixed(1)}),R(`span`,{children:[`/`,a.toFixed(0),` fps`]})]}),R(`span`,{className:`text-foreground-subtle`,children:[U(`span`,{className:`text-foreground`,children:r.toFixed(0)}),U(`span`,{children:` ms`}),i>0&&R(`span`,{className:`text-warning ml-1`,children:[`q`,i]})]}),R(`span`,{className:o>0?`text-warning`:`text-foreground-subtle`,children:[`drops `,U(`span`,{className:`text-foreground`,children:o})]})]})}function Dt({title:e,targets:t,pinned:n,onMove:r,onUnpin:i,onClose:a}){let o=ge(null);return W(()=>{let e=e=>{o.current?.contains(e.target)||a()};return window.addEventListener(`mousedown`,e),()=>window.removeEventListener(`mousedown`,e)},[a]),R(`div`,{ref:o,className:`absolute right-2 top-full mt-1 w-48 rounded-lg border border-border bg-surface shadow-lg z-20 text-left`,children:[U(`div`,{className:`px-3 py-1 text-[9px] uppercase tracking-wider text-foreground-subtle border-b border-border`,children:e}),t.length>0&&U(`div`,{className:`py-1`,children:t.map(e=>R(`button`,{type:`button`,onClick:()=>r(e.id),className:`block w-full text-left px-3 py-1 text-[11px] text-foreground hover:bg-surface-hover`,children:[`Move to `,e.name]},e.id))}),n&&R(`button`,{type:`button`,onClick:i,className:`block w-full text-left px-3 py-1.5 text-[11px] text-destructive hover:bg-destructive/10 border-t border-border`,children:[`Unpin `,e.toLowerCase()]}),t.length===0&&!n&&U(`div`,{className:`px-3 py-1.5 text-[10px] text-foreground-subtle italic`,children:`Already auto · no other nodes online`})]})}function Ot({nodeId:e,refreshToken:t}){return R(`div`,{className:`space-y-6`,children:[U(ht,{refreshToken:t,nodeId:e}),R(`div`,{children:[U(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Cameras on this node`}),R(`p`,{className:`text-[11px] text-foreground-subtle`,children:[`Checkboxes mark the roles currently running on `,e,`. Use the kebab to move a role to another node or unpin it; live KPIs come from the runner snapshot stream.`]})]}),U(bt,{mode:`agent`,nodeId:e,compact:!0})]})}L();function kt(e,t){let n=Math.max(0,t-e);return`${Math.floor(e/1e3)}s idle · ${Math.floor(n/1e3)}s left`}function At({nodeId:e,refreshToken:t}){let n=V(),i=c({onSettled:()=>{n.invalidateQueries({queryKey:[`pipelineExecutor`,`listLoadedEngines`]})}}),{data:a}=y({nodeId:e}),o=ie(`pipeline.engine-metrics-snapshot`,t=>t.nodeId===e)?.engines??a??null,s=o===null;J([`pipelineRunner`,`getLocalCameras`],[`pipeline.camera-assigned`,`pipeline.camera-unassigned`]);let{data:l}=r({nodeId:e}),{values:u}=N(`pipeline.camera-metrics-snapshot`,e=>e.deviceId,t=>t.nodeId===e),d=z(()=>u.filter(e=>e.metrics.phase===`active`).length,[u]),f=t=>{let n=l??[];n.length>0&&!window.confirm(`${n.length} camera(s) are dispatching through this engine. Killing it forces a respawn on the next frame. Continue?`)||i.mutate({nodeId:e,engine:t,force:n.length>0})};return R(`div`,{className:`space-y-6`,children:[R(`div`,{children:[U(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Inference engines on this node`}),R(`p`,{className:`text-[11px] text-foreground-subtle`,children:[(o??[]).length,` engine(s) resident in RAM. `,(l??[]).length,` `,`camera(s) attached, `,d,` actively dispatching frames. Refreshes every 5s.`]})]}),U(`div`,{className:`rounded-lg border border-border overflow-x-auto`,children:R(`table`,{className:`w-full text-xs min-w-[640px]`,children:[U(`thead`,{className:`bg-surface`,children:R(`tr`,{className:`text-foreground-subtle text-[10px] uppercase tracking-wider`,children:[U(`th`,{className:`text-left px-3 py-2 whitespace-nowrap`,children:`Kind`}),U(`th`,{className:`text-left px-3 py-2 whitespace-nowrap`,children:`Runtime / Backend / Device`}),U(`th`,{className:`text-left px-3 py-2`,children:`Models`}),U(`th`,{className:`text-right px-3 py-2 whitespace-nowrap`,children:`Pool PID`}),U(`th`,{className:`text-right px-3 py-2 whitespace-nowrap`,children:`Auto-kill`}),U(`th`,{className:`text-right px-3 py-2 whitespace-nowrap`,children:`In use`}),U(`th`,{className:`w-20`})]})}),R(`tbody`,{children:[s&&U(`tr`,{children:U(`td`,{colSpan:7,className:`px-3 py-4 text-center text-foreground-subtle text-[11px]`,children:`Loading…`})}),!s&&(o??[]).map(e=>{let t=e.kind===`warm-override`;return R(`tr`,{className:`border-t border-border ${t?`bg-amber-500/5`:``}`,children:[U(`td`,{className:`px-3 py-2`,children:R(`span`,{className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded-full text-[10px] font-medium ${t?`bg-amber-500/15 text-amber-400`:`bg-success/15 text-success`}`,children:[U(t?ot:K,{className:`h-3 w-3`}),t?`warm`:`runtime`]})}),U(`td`,{className:`px-3 py-2`,children:R(`span`,{className:`inline-flex items-center gap-1 text-[11px] text-sky-400`,children:[U(Oe,{className:`h-3 w-3`}),e.engine.runtime,`/`,e.engine.backend,e.engine.device?`/${e.engine.device}`:``,e.engine.format?` · ${e.engine.format}`:``]})}),U(`td`,{className:`px-3 py-2`,children:e.modelsLoaded.length===0?U(`span`,{className:`text-foreground-subtle text-[11px]`,children:`—`}):U(`div`,{className:`flex flex-wrap gap-1`,children:e.modelsLoaded.map(e=>U(`span`,{className:`inline-block rounded bg-surface px-1.5 py-0.5 text-[10px] font-mono text-foreground-subtle`,children:e},e))})}),U(`td`,{className:`px-3 py-2 text-right font-mono text-foreground`,children:e.poolPid??`—`}),U(`td`,{className:`px-3 py-2 text-right text-[11px]`,children:e.idleMs!==null&&e.idleTtlMs!==null?U(`span`,{className:`text-foreground-subtle`,children:kt(e.idleMs,e.idleTtlMs)}):U(`span`,{className:`text-foreground-subtle/50`,children:`never`})}),U(`td`,{className:`px-3 py-2 text-right text-foreground`,children:t?`—`:(l??[]).length}),U(`td`,{className:`px-3 py-2 text-right`,children:R(`button`,{type:`button`,disabled:i.isPending,onClick:()=>f(e.engine),className:`inline-flex items-center gap-1 px-2 py-1 rounded border border-destructive/30 text-destructive text-[11px] hover:bg-destructive/10 disabled:opacity-50`,children:[U(Ge,{className:`h-3 w-3`}),`Kill`]})})]},e.engineKey)}),!s&&(o??[]).length===0&&U(`tr`,{children:U(`td`,{colSpan:7,className:`px-3 py-4 text-center text-foreground-subtle text-[11px]`,children:`No engines resident — the factory spins up on the first pipeline run.`})})]})]})}),R(`div`,{className:`text-[10px] text-foreground-subtle leading-relaxed`,children:[U(`strong`,{className:`text-foreground`,children:`runtime`}),`: main camera-serving engine; never auto-killed while cameras attached. `,U(`strong`,{className:`text-foreground`,children:`warm`}),`: benchmark/test override held in cache for fast re-use; auto-disposed after the idle TTL.`]}),i.isError&&R(`div`,{className:`rounded-md border border-destructive/30 bg-destructive/5 px-3 py-2 text-[11px] text-destructive`,children:[`Kill failed:`,` `,i.error instanceof Error?i.error.message:`unknown`]})]})}L();var jt=new Set(ye);function Mt(e){return jt.has(e)}function Nt(e,t,n){return`${e}/${t}/${n}`}function Pt(e){return{coreml:`CoreML`,openvino:`OpenVINO`,onnx:`ONNX`}[e.format]??e.format.toUpperCase()}function Ft(e){return{coreml:`Apple Neural Engine / GPU — .mlpackage`,openvino:`Intel CPU / GPU / NPU — .xml`,onnx:`CPU, CUDA, Node.js — .onnx`}[e.format]??`.${e.format}`}function Q(e){return e.format}function It(e,t){let n=0,r=0,i=0;for(let a of e)for(let e of a.addons)for(let a of e.models){let e=a.formats[t];e&&(n++,e.downloaded&&(r++,i+=e.sizeMB))}return{total:n,downloaded:r,downloadedSizeMB:i}}function Lt({addonId:e,model:t,format:n,isActive:r,progress:i,errorMsg:a,onDownload:o,onDelete:s}){let c=t.formats[n];return c?R(`div`,{className:`flex items-center gap-3 px-4 py-3 border-b border-border/50 last:border-b-0 hover:bg-surface-hover/30 transition-colors`,children:[U(`div`,{className:`h-2 w-2 rounded-full shrink-0 ${c.downloaded?`bg-success`:`bg-foreground-subtle/30`}`}),R(`div`,{className:`flex-1 min-w-0`,children:[R(`div`,{className:`flex items-center gap-2`,children:[U(`span`,{className:`text-sm font-medium text-foreground`,children:t.name}),R(`span`,{className:`text-[10px] text-foreground-subtle font-mono`,children:[`(`,t.id,`)`]})]}),i&&i.progress>=0&&i.progress<100&&R(`div`,{className:`mt-1.5 flex items-center gap-2 max-w-xs`,children:[U(`div`,{className:`flex-1 h-1 bg-surface-hover rounded-full overflow-hidden`,children:U(`div`,{className:`bg-primary h-full rounded-full transition-all duration-300`,style:{width:`${i.progress}%`}})}),R(`span`,{className:`text-[9px] text-primary font-mono tabular-nums shrink-0`,children:[Math.round(i.progress),`%`]})]})]}),U(`span`,{className:`text-xs text-foreground-subtle tabular-nums shrink-0`,children:nt(c.sizeMB)}),a&&R(`span`,{className:`flex items-center gap-1 text-[10px] text-danger max-w-[160px] truncate shrink-0`,title:a,children:[U(Ue,{className:`h-3 w-3 shrink-0`}),a]}),c.downloaded?R(`button`,{onClick:s,disabled:r,className:`inline-flex items-center gap-1.5 px-3 py-1.5 text-[11px] font-medium rounded-md border border-danger/30 text-danger hover:bg-danger/10 disabled:opacity-50 transition-colors shrink-0`,children:[r?U(q,{className:`h-3 w-3 animate-spin`}):U(Ge,{className:`h-3 w-3`}),r?`Deleting...`:`Delete`]}):R(`button`,{onClick:o,disabled:r,className:`inline-flex items-center gap-1.5 px-3 py-1.5 text-[11px] font-medium rounded-md bg-primary text-primary-foreground hover:bg-primary/90 disabled:opacity-50 transition-colors shrink-0`,children:[r?U(q,{className:`h-3 w-3 animate-spin`}):U(xe,{className:`h-3 w-3`}),r?`Downloading...`:`Download`]})]}):null}function Rt({engines:e,activeEngine:t,viewEngine:n,onSelect:r}){let[i,a]=H(!1);return R(`div`,{className:`relative`,children:[R(`button`,{type:`button`,onClick:()=>a(!i),className:`flex items-center gap-2 rounded-lg border border-border bg-surface px-4 py-2.5 w-full text-left hover:bg-surface-hover transition-colors`,children:[U(K,{className:`h-4 w-4 text-primary shrink-0`}),R(`div`,{className:`flex-1 min-w-0`,children:[R(`div`,{className:`flex items-center gap-2`,children:[U(`span`,{className:`text-sm font-medium text-foreground`,children:Pt(n)}),Q(n)===Q(t)&&U(`span`,{className:`text-[9px] px-1.5 py-0.5 rounded-full bg-success/10 text-success font-medium`,children:`Active`})]}),U(`div`,{className:`text-[10px] text-foreground-subtle`,children:Ft(n)})]}),U(Be,{className:`h-4 w-4 text-foreground-subtle transition-transform ${i?`rotate-180`:``}`})]}),i&&U(`div`,{className:`absolute top-full left-0 right-0 mt-1 rounded-lg border border-border bg-surface shadow-lg z-50 overflow-hidden`,children:e.map(e=>{let i=Q(e)===Q(n),o=Q(e)===Q(t);return R(`button`,{type:`button`,onClick:()=>{r(e),a(!1)},className:`flex items-center gap-3 px-4 py-2.5 w-full text-left transition-colors ${i?`bg-primary/5`:`hover:bg-surface-hover`}`,children:[U(K,{className:`h-4 w-4 shrink-0 ${i?`text-primary`:`text-foreground-subtle`}`}),R(`div`,{className:`flex-1`,children:[R(`div`,{className:`flex items-center gap-2`,children:[U(`span`,{className:`text-sm font-medium ${i?`text-primary`:`text-foreground`}`,children:Pt(e)}),o&&U(`span`,{className:`text-[9px] px-1.5 py-0.5 rounded-full bg-success/10 text-success font-medium`,children:`Active`})]}),U(`div`,{className:`text-[10px] text-foreground-subtle`,children:Ft(e)})]}),i&&U(Ie,{className:`h-4 w-4 text-primary shrink-0`})]},Q(e))})})]})}function zt({embedded:e=!1,nodeId:n}={}){let r=V(),i=n??`hub`,[a,o]=H(null),[s,c]=H(new Set),[l,u]=H(new Map),[d,p]=H(new Map),[m,h]=H(``),{data:_=[]}=me({nodeId:i}),v=_.filter((e,t,n)=>n.findIndex(t=>t.format===e.format)===t),{data:y}=b({nodeId:i}),x=y,{data:S,isLoading:C}=t({nodeId:i}),T=g(),E=f();w(`model.download.progress`,e=>{let t=e.data,n=typeof t.modelId==`string`?t.modelId:void 0,i=typeof t.progress==`number`?t.progress:void 0,a=typeof t.totalMB==`number`?t.totalMB:0;n===void 0||i===void 0||(u(e=>{let t=new Map(e);return i===100||i===-1?t.delete(n):t.set(n,{modelId:n,progress:i,totalMB:a}),t}),i===100&&r.invalidateQueries({queryKey:[[`pipelineExecutor`,`getSchema`]]}))});let D=x??{runtime:`node`,backend:`cpu`,format:`onnx`},O=v.find(e=>e.format===a)??D,k=O.format,A=S?.slots??[],j=A.map(e=>({...e,addons:e.addons.map(e=>({...e,models:e.models.filter(e=>e.formats[k]!==void 0)})).filter(e=>e.models.length>0)})).filter(e=>e.addons.length>0),M=It(j,k),N=he(async(e,t,n)=>{if(!Mt(n))return;let a=Nt(e,t,n);c(e=>new Set([...e,a])),p(e=>{let t=new Map(e);return t.delete(a),t});try{await T.mutateAsync({addonId:e,modelId:t,format:n,nodeId:i}),r.invalidateQueries({queryKey:[[`pipelineExecutor`,`getSchema`]]})}catch(e){p(t=>new Map([...t,[a,e instanceof Error?e.message:`Download failed`]]))}finally{c(e=>{let t=new Set(e);return t.delete(a),t})}},[T,r,i]),P=he(async(e,t,n)=>{if(!Mt(n))return;let a=Nt(e,t,n);c(e=>new Set([...e,a])),p(e=>{let t=new Map(e);return t.delete(a),t});try{await E.mutateAsync({addonId:e,modelId:t,format:n,nodeId:i}),r.invalidateQueries({queryKey:[[`pipelineExecutor`,`getSchema`]]})}catch(e){p(t=>new Map([...t,[a,e instanceof Error?e.message:`Delete failed`]]))}finally{c(e=>{let t=new Set(e);return t.delete(a),t})}},[E,r,i]),ee=he(e=>{o(e.format)},[]),F=m.trim()?j.map(e=>({...e,addons:e.addons.map(e=>({...e,models:e.models.filter(t=>t.name.toLowerCase().includes(m.toLowerCase())||t.id.toLowerCase().includes(m.toLowerCase())||e.name.toLowerCase().includes(m.toLowerCase()))})).filter(e=>e.models.length>0)})).filter(e=>e.addons.length>0):j,I=R(B,{children:[C&&U(`div`,{className:`flex items-center justify-center py-16`,children:U(q,{className:`h-5 w-5 animate-spin text-foreground-subtle`})}),!C&&A.length===0&&R(`div`,{className:`flex flex-col items-center justify-center py-16 text-foreground-subtle`,children:[U(Se,{className:`h-8 w-8 mb-3 opacity-30`}),U(`span`,{className:`text-sm`,children:`No pipeline steps available`}),U(`span`,{className:`text-xs mt-1`,children:`Configure the detection pipeline to see available models.`})]}),!C&&A.length>0&&R(B,{children:[U(Rt,{engines:v,activeEngine:D,viewEngine:O,onSelect:ee}),R(`div`,{className:`flex items-center gap-4 text-xs text-foreground-subtle`,children:[R(`span`,{children:[U(`span`,{className:`font-semibold text-foreground tabular-nums`,children:M.total}),U(`span`,{className:`ml-1`,children:`compatible models`})]}),U(`span`,{className:`text-border`,children:`|`}),R(`span`,{children:[U(`span`,{className:`font-semibold text-success tabular-nums`,children:M.downloaded}),U(`span`,{className:`ml-1`,children:`downloaded`})]}),U(`span`,{className:`text-border`,children:`|`}),R(`span`,{className:`tabular-nums`,children:[nt(M.downloadedSizeMB),U(`span`,{className:`ml-1`,children:`on disk`})]})]}),M.total>5&&R(`div`,{className:`relative`,children:[U(Me,{className:`absolute left-3 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-foreground-subtle`}),U(`input`,{type:`text`,value:m,onChange:e=>h(e.target.value),placeholder:`Search models...`,className:`w-full pl-9 pr-3 py-2 text-sm rounded-lg border border-border bg-surface text-foreground placeholder:text-foreground-subtle/50 focus:outline-none focus:ring-1 focus:ring-primary`})]}),F.map(e=>{let t=e.addons.reduce((e,t)=>e+t.models.length,0),n=e.addons.reduce((e,t)=>e+t.models.filter(e=>e.formats[k]?.downloaded).length,0);return R(`div`,{children:[R(`div`,{className:`flex items-center gap-2 mb-2`,children:[U(`h2`,{className:`text-sm font-semibold text-foreground`,children:e.label}),U(`div`,{className:`flex-1 h-px bg-border`}),R(`span`,{className:`text-[10px] text-foreground-subtle tabular-nums`,children:[n,`/`,t]})]}),U(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:e.addons.map(e=>e.models.map(t=>{let n=Nt(e.id,t.id,k);return U(Lt,{addonId:e.id,model:t,format:k,isActive:s.has(n),progress:l.get(t.id),errorMsg:d.get(n),onDownload:()=>N(e.id,t.id,k),onDelete:()=>P(e.id,t.id,k)},`${e.id}/${t.id}`)}))})]},e.id)}),F.length===0&&U(`div`,{className:`text-center py-8 text-sm text-foreground-subtle`,children:m.trim()?R(B,{children:[`No models matching “`,m,`”`]}):R(B,{children:[`No models available for `,Pt(O),` format`]})})]})]});return e?U(`div`,{className:`space-y-4`,children:I}):U(qe,{children:I})}function Bt({nodeId:e,refreshToken:t}){return U(zt,{embedded:!0,nodeId:e})}var Vt=[{concern:`pipeline`,label:`Pipeline`,advisory:!1},{concern:`audio`,label:`Audio`,advisory:!1},{concern:`decode`,label:`Decode`,advisory:!0,advisoryNote:`Advisory: decode currently runs co-located with the stream source (hub). Pins are stored and take effect with Phase-2 stream load-balancing.`}];function Ht(e,t){return e.filter(e=>e.currentNodeId!==t)}var Ut=`This node is not decoder-enabled (enabledDecoderNodes). Pinning detection here strands frames (0 fps) until frame-source-aware placement ships. Enable decode on this node first, or pick a decoder-enabled node.`;function Wt(e,t,n){return t.includes(e)?{verdict:`ok`}:n?{verdict:`warn`,reason:Ut}:{verdict:`block`,reason:Ut}}L();var Gt=`pipeline-orchestrator`,Kt=`enabledDecoderNodes`;function qt(e,t){if(!e||typeof e!=`object`)return;let n=e.sections;if(Array.isArray(n))for(let e of n){if(!e||typeof e!=`object`)continue;let n=e.fields;if(Array.isArray(n))for(let e of n){if(!e||typeof e!=`object`)continue;let n=e;if(n.key!==t)continue;let r=n.value;return Array.isArray(r)&&r.every(e=>typeof e==`string`)?r:void 0}}}function Jt({nodeId:e,nodeName:t,concern:n,open:r,onClose:i}){let a=V(),o=Je(),c=T(void 0),l=ae(void 0),u=S(void 0),f=P({addonId:Gt}),p=re(),m=d(),h=s(),[g,_]=H(new Set),[v,y]=H(!1),[b,x]=H(null),[C,w]=H([]),[E,D]=H(null),O=Vt.find(e=>e.concern===n),k=z(()=>{let e=new Map;if(n===`pipeline`)for(let t of c.data??[])e.set(t.deviceId,t.agentNodeId);else if(n===`decode`)for(let t of l.data??[])e.set(t.deviceId,t.decoderNodeId);else for(let t of u.data??[])e.set(t.deviceId,t.nodeId);return e},[n,c.data,l.data,u.data]),A=z(()=>(o.data??[]).filter(e=>e.isCamera).map(e=>({deviceId:e.id,name:e.name,currentNodeId:k.get(e.id)??null})),[o.data,k]),j=z(()=>Ht(A,e),[A,e]),M=qt(f.data,Kt),N=n===`pipeline`?Wt(e,M??[],!1):{verdict:`ok`},[ee,F]=H(!1);if(!r)return null;let I=N.verdict===`block`,te=N.verdict===`warn`&&!ee,ne=g.size>0&&!v&&!I&&!te,ie=e=>{_(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},oe=j.length>0&&j.every(e=>g.has(e.deviceId)),se=()=>{_(oe?new Set:new Set(j.map(e=>e.deviceId)))},ce=async t=>{n===`pipeline`?await p.mutateAsync({deviceId:t,agentNodeId:e}):n===`decode`?await m.mutateAsync({deviceId:t,nodeId:e}):await h.mutateAsync({deviceId:t,nodeId:e})},le=new Map(A.map(e=>[e.deviceId,e.name]));return R(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center`,children:[U(`div`,{className:`absolute inset-0 bg-black/60`,onClick:i}),R(`div`,{className:`relative z-10 flex w-full max-w-2xl flex-col h-[80vh] rounded-xl border border-border bg-background shadow-2xl`,children:[R(`div`,{className:`flex items-center justify-between border-b border-border px-5 py-4 shrink-0`,children:[R(`div`,{className:`min-w-0`,children:[R(`h2`,{className:`text-sm font-semibold text-foreground`,children:[`Batch assign `,O?.label??n,` → `,t]}),R(`p`,{className:`text-[11px] text-foreground-subtle mt-0.5`,children:[`Pick the cameras whose `,O?.label.toLowerCase()??n,` should run on this node.`]})]}),U(`button`,{type:`button`,onClick:i,className:`rounded-md p-1 text-foreground-subtle hover:text-foreground hover:bg-surface-hover`,"aria-label":`Close`,children:U(He,{className:`h-4 w-4`})})]}),R(`div`,{className:`flex-1 min-h-0 px-5 py-3 flex flex-col gap-2 overflow-hidden`,children:[O?.advisory&&O.advisoryNote&&U(`div`,{className:`rounded-lg border border-warning/30 bg-warning/5 px-3 py-2 shrink-0`,children:R(`div`,{className:`flex items-start gap-2`,children:[U(We,{className:`h-3.5 w-3.5 text-warning mt-0.5 shrink-0`}),U(`p`,{className:`text-[11px] text-warning`,children:O.advisoryNote})]})}),N.verdict!==`ok`&&U(`div`,{className:`rounded-lg border border-destructive/30 bg-destructive/5 px-3 py-2 shrink-0`,children:R(`div`,{className:`flex items-start gap-2`,children:[U(We,{className:`h-3.5 w-3.5 text-destructive mt-0.5 shrink-0`}),R(`div`,{className:`min-w-0`,children:[U(`p`,{className:`text-[11px] text-destructive`,children:N.reason}),N.verdict===`warn`&&R(`label`,{className:`mt-1 flex items-center gap-1.5 text-[11px] text-foreground-subtle`,children:[U(`input`,{type:`checkbox`,checked:ee,onChange:e=>F(e.target.checked),className:`accent-primary`}),`I understand — assign anyway`]})]})]})}),j.length>0&&R(`label`,{className:`flex items-center gap-2 text-[11px] text-foreground-subtle shrink-0`,children:[U(`input`,{type:`checkbox`,"aria-label":`Select all`,checked:oe,onChange:se,className:`accent-primary`}),`Select all (`,j.length,`)`]}),U(`div`,{className:`flex-1 min-h-0 overflow-y-auto rounded-lg border border-border divide-y divide-border`,children:j.length===0?R(`div`,{className:`px-3 py-6 text-center text-[11px] text-foreground-subtle`,children:[`No eligible cameras — all cameras are already assigned to `,t,`.`]}):j.map(e=>R(`label`,{className:`flex items-center gap-2 px-3 py-2 text-xs text-foreground hover:bg-surface-hover cursor-pointer`,children:[U(`input`,{type:`checkbox`,"aria-label":`Select ${e.name}`,checked:g.has(e.deviceId),onChange:()=>ie(e.deviceId),className:`accent-primary`}),U(`span`,{className:`truncate`,children:e.name}),e.currentNodeId&&R(`span`,{className:`ml-auto text-[10px] text-foreground-subtle shrink-0`,children:[`on `,e.currentNodeId]})]},e.deviceId))}),(E!==null||C.length>0)&&R(`div`,{className:`space-y-1 text-[10px] shrink-0`,children:[E!==null&&E>0&&R(`p`,{className:`text-success`,children:[`Assigned `,E,` camera(s) to `,t,`.`]}),C.map(e=>R(`p`,{className:`text-destructive`,children:[e.name,`: `,e.message]},e.deviceId))]})]}),R(`div`,{className:`flex items-center justify-between border-t border-border px-5 py-3 shrink-0`,children:[U(`span`,{className:`text-[10px] text-foreground-subtle`,children:v&&b?`${b.done} / ${b.total}…`:``}),R(`div`,{className:`flex items-center gap-2`,children:[U(`button`,{type:`button`,onClick:i,className:`rounded-lg border border-border px-3 py-1.5 text-xs text-foreground-subtle hover:text-foreground`,children:`Close`}),R(`button`,{type:`button`,onClick:async()=>{let e=[...g];if(e.length===0)return;y(!0),w([]),D(null),x({done:0,total:e.length});let t=[],n=0;for(let r=0;r<e.length;r+=1){let i=e[r];try{await ce(i),n+=1}catch(e){t.push({deviceId:i,name:le.get(i)??String(i),message:e instanceof Error?e.message:String(e)})}x({done:r+1,total:e.length})}y(!1),w(t),D(n),_(new Set),a.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getPipelineAssignments`]]}),a.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getDecoderAssignments`]]}),a.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getAudioAssignments`]]})},disabled:!ne,className:`inline-flex items-center gap-1.5 rounded-lg bg-primary px-4 py-1.5 text-xs font-medium text-primary-foreground disabled:opacity-50 disabled:cursor-not-allowed`,children:[v&&U(q,{className:`h-3.5 w-3.5 animate-spin`}),`Assign `,g.size,` to `,t]})]})]})]})]})}L();function Yt({nodeId:e,title:t}){let{data:n}=Je(),{data:r}=T(void 0),i=z(()=>{let e=new Map;for(let t of n??[])e.set(t.id,t.name);return e},[n]),a=z(()=>{if(!e)return null;let t=new Set;for(let n of r??[])n.agentNodeId===e&&t.add(n.deviceId);return t},[e,r]),[o,s]=H(new Map);w(`pipeline.camera-metrics-snapshot`,t=>{let n=t.data;typeof n.deviceId==`number`&&(e&&n.nodeId!==e||s(e=>{let t=new Map(e);return t.set(n.deviceId,n),t}))}),W(()=>{if(o.size===0)return;let e=setInterval(()=>{s(e=>{let t=Date.now()-1e4,n=!1,r=new Map(e);for(let[i,a]of e)a.timestamp<t&&(r.delete(i),n=!0);return n?r:e})},5e3);return()=>clearInterval(e)},[o.size]);let c=z(()=>{let e=[];for(let t of o.values())a&&!a.has(t.deviceId)||e.push(t);return e.sort((e,t)=>e.deviceId-t.deviceId),e},[o,a]);return c.length===0?R(`div`,{className:`rounded-md border border-border bg-surface px-3 py-2 text-[11px] text-foreground-subtle italic`,children:[t??`Cameras`,`: no live snapshots yet`]}):R(`div`,{className:`rounded-md border border-border bg-surface px-3 py-2`,children:[R(`div`,{className:`flex items-center gap-2 mb-1.5`,children:[U(`span`,{className:`text-[10px] uppercase tracking-wider text-foreground-subtle`,children:t??`Cameras`}),U(`span`,{className:`text-[10px] text-foreground-subtle`,children:c.length})]}),U(`div`,{className:`flex flex-wrap gap-1.5`,children:c.map(e=>{let t=i.get(e.deviceId)??`#${e.deviceId}`,n=l(e.metrics.phase);return R(`div`,{title:`${t} · ${n.label} · ${e.metrics.actualFps.toFixed(1)} fps · ${e.metrics.avgInferenceTimeMs.toFixed(0)}ms infer · q=${e.metrics.queueDepth}`,className:`inline-flex items-center gap-1 rounded border px-1.5 py-0.5 text-[10px] ${n.badgeClass}`,children:[U(C,{phase:e.metrics.phase,className:`h-2.5 w-2.5`}),U(`span`,{className:`font-medium text-foreground/90 max-w-[120px] truncate`,children:t}),U(`span`,{className:`font-mono tabular-nums`,children:e.metrics.actualFps.toFixed(1)}),U(`span`,{className:`opacity-60`,children:`fps`})]},e.deviceId)})})]})}var Xt={key:`maxCameras`,type:`slider`,label:`Max cameras`,description:`Hard cap on cameras the balancer may assign to this node.`,min:1,max:64,step:1,showValue:!0,showStepper:!0,nullable:!0,nullLabel:`Unlimited`};L();var Zt=350;function Qt(e){return typeof e==`number`&&e>0?Math.floor(e):null}function $t({value:e,pending:t,errorMessage:r,onCommit:i}){let[a,o]=H(e);W(()=>{o(e)},[e]);let s=ge(i);return s.current=i,W(()=>{if(a===e)return;let t=setTimeout(()=>s.current(a),Zt);return()=>clearTimeout(t)},[a,e]),R(`div`,{className:`flex items-center gap-3 text-xs text-foreground`,children:[U(`div`,{className:`max-w-md flex-1`,children:U(n,{field:Xt,values:{maxCameras:a},disabled:t,onChange:(e,t)=>o(Qt(t))})}),t&&U(`span`,{className:`text-[10px] text-muted-foreground animate-pulse`,children:`Saving…`}),r&&R(`span`,{className:`text-[10px] text-destructive`,children:[`Save failed: `,r]})]})}L();var en=[`pipeline-orchestrator`],tn=[`decoder`];function nn(e,t){if(!e)return null;for(let n of e.slots)for(let e of n.addons)if(e.id===t)return e;return null}function rn({nodeId:e,refreshToken:n}){let r=V(),[i,a]=H(null),[s,c]=H(null),[l,u]=H(null),d=(o(void 0).data??[]).find(t=>t.id===e)?.name??e,f=t({nodeId:e},{refetchOnMount:`always`}),p=x({agentNodeId:e},{refetchOnMount:`always`}),m=()=>{r.invalidateQueries({queryKey:[[`addonSettings`]]}),r.invalidateQueries({queryKey:[[`pipelineOrchestrator`]]}),r.invalidateQueries({queryKey:[[`pipelineExecutor`]]})},h=ue({onSuccess:m}),g=ne({onSuccess:m}),_=f.data??null,v=p.data,y=_?.selectedEngine.format??`coreml`,b=z(()=>_?le(_):[],[_]),S=z(()=>[{agentNodeId:e,engineLabel:y}],[e,y]),C=(e,t)=>{let n=v?.addonDefaults[e];return!nn(_,e)?.models.some(e=>!!e.formats[y])||!n?{kind:`na`}:n.enabled?{kind:`enabled`,modelId:n.modelId}:{kind:`disabled`}},w=i&&_?nn(_,i.addonId):null,T=t=>{let n=v?.addonDefaults[t]??null;a({addonId:t,agentNodeId:e}),c(n)},E=(t,n)=>{if(!v)return;let r=v.addonDefaults[t],i=nn(_,t);if(!r&&!i)return;let a={enabled:n,modelId:r?.modelId??i?.defaultModelId??``,settings:r?.settings??{}};h.mutate({agentNodeId:e,defaults:{...v.addonDefaults,[t]:a}})},O=()=>{a(null),c(null)},A=()=>{!s||!i||!v||h.mutate({agentNodeId:e,defaults:{...v.addonDefaults,[i.addonId]:s}},{onSuccess:O})};if(f.isLoading||p.isLoading)return U(`div`,{className:`text-xs text-foreground-subtle animate-pulse`,children:`Loading pipeline…`});if(f.error)return R(`div`,{className:`text-xs text-red-400`,children:[`Failed to load catalog: `,String(f.error)]});if(!_)return U(`div`,{className:`text-xs text-foreground-subtle`,children:`Catalog unavailable for this node (runner offline?).`});let j=i!==null&&w!==null&&s!==null,M=p.data?.maxCameras??null;return R(`div`,{className:`relative h-full w-full space-y-3`,children:[U(Yt,{nodeId:e}),U($t,{value:M,pending:g.isPending,errorMessage:g.isError?g.error instanceof Error?g.error.message:`Unknown error`:null,onCommit:t=>g.mutate({agentNodeId:e,maxCameras:t})}),U(rt,{nodeId:e,addonIds:en,level:`global`,sectionIds:tn}),R(`div`,{className:`flex items-center gap-2 text-xs`,children:[U(`span`,{className:`font-medium text-muted-foreground`,children:`Batch assign:`}),U(`button`,{type:`button`,onClick:()=>u(`pipeline`),className:`rounded border border-border bg-surface px-2 py-0.5 text-xs hover:bg-surface-hover`,children:`Pipeline…`}),U(`button`,{type:`button`,onClick:()=>u(`audio`),className:`rounded border border-border bg-surface px-2 py-0.5 text-xs hover:bg-surface-hover`,children:`Audio…`}),U(`button`,{type:`button`,onClick:()=>u(`decode`),className:`rounded border border-border bg-surface px-2 py-0.5 text-xs text-foreground-subtle hover:bg-surface-hover`,children:`Decode… (advisory)`})]}),l&&U(Jt,{nodeId:e,nodeName:d,concern:l,open:l!==null,onClose:()=>u(null)}),U(`div`,{className:j?`pr-[360px]`:``,children:b.length>0?U(oe,{tree:b,agents:S,getCellState:C,onCellClick:T,selectedCell:i,onToggleEnabled:E}):U(`div`,{className:`text-xs text-foreground-subtle`,children:`Catalog empty.`})}),U(k,{open:j,onClose:O,title:w?.name??``,subtitle:i?`${i.agentNodeId} · ${y}`:``,footer:R(B,{children:[U(`button`,{type:`button`,className:`px-3 py-1 text-xs border border-border rounded bg-surface hover:bg-muted`,onClick:O,children:`Cancel`}),U(`button`,{type:`button`,disabled:!s||!i||h.isPending,className:`px-3 py-1 text-xs bg-primary text-primary-foreground rounded disabled:opacity-50`,onClick:A,children:h.isPending?`Saving…`:`Save`})]}),children:w&&s&&i&&U(D,{mode:`agent`,addon:w,agentDefault:s,agentNodeId:i.agentNodeId,engineFormat:y,onChangeAgentConfig:e=>c(e)})})]})}var an=[`detection-pipeline`,`audio-analyzer`,`pipeline-runner`],on=`decoder-nodeav`;function sn({nodeId:e,refreshToken:t}){let{data:n}=o(void 0),r=n?.find(t=>t.id===e)?.addons.find(e=>e.capabilities.includes(`decoder`))?.id??on,i=[...an,r];return R(`div`,{className:`flex flex-col h-full`,children:[U(mt,{nodeId:e,refreshToken:t}),U(`div`,{className:`flex-1 min-h-0 overflow-y-auto p-6`,children:U(rt,{nodeId:e,addonIds:i,level:`global`,extraTabs:[{id:`assignments`,label:`Assignments`,order:-10,content:U(Ot,{nodeId:e,refreshToken:t})},{id:`tree`,label:`Pipeline`,order:39,content:U(rn,{nodeId:e,refreshToken:t})},{id:`engines`,label:`Warm instances`,order:180,content:U(At,{nodeId:e,refreshToken:t})},{id:`models`,label:`Models`,order:200,content:U(Bt,{nodeId:e,refreshToken:t})}]})})]})}L();var cn=`pipeline-orchestrator`,ln=`recorder`,un=`recordingNodeId`,dn=[`ingestNode`,`recordingNode`,`audioNode`],fn=[`detect`,`decode`,`audio`,`ingest`];function pn(e,t){for(let n of e?.sections??[])for(let e of n.fields??[])if(e.key===t)return e.value}function mn(e,t){for(let[n,r]of Object.entries(e??{}))if(n===t)return r}function hn(e,t,n){let r=pn(e,t);return typeof r==`string`&&r.length>0?r:n}function gn(e,t,n){let r=pn(e,t);return typeof r==`number`&&Number.isFinite(r)?r:n}function _n(e){e.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`listAgentSettings`]]}),e.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getAgentSettings`]]}),e.invalidateQueries({queryKey:[[`addonSettings`,`getGlobalSettings`]]})}function vn(e){return e===`ingestNode`?`Ingest`:e===`recordingNode`?`Recording`:`Audio`}function yn(e,t){return t===`detect`?e.pipeline:e[t]}function bn({role:e,value:t,options:n,pending:r,onChange:i}){return R(`label`,{className:`flex flex-col gap-1 text-[11px] text-foreground-subtle`,children:[U(`span`,{className:`font-medium text-foreground`,children:vn(e)}),U(`select`,{value:t,disabled:r,onChange:t=>i(e,t.target.value),className:`rounded-md border border-border bg-background px-2 py-1 text-xs text-foreground`,children:n.map(e=>U(`option`,{value:e,children:e===`hub`?`hub (default)`:e},e))})]})}function xn({nodeId:e,weight:t,totalWeight:n,pending:r,onCommit:i}){let[a,o]=H(String(t));W(()=>{o(String(t))},[t]);let s=n>0?t/n:0,c=2*Math.PI*14,l=c*s,u=()=>{let t=Number(a);i(e,Number.isFinite(t)&&t>0?t:null)};return R(`div`,{className:`flex items-center gap-2`,children:[R(`svg`,{viewBox:`0 0 36 36`,className:`h-9 w-9 shrink-0`,"aria-hidden":`true`,children:[U(`circle`,{cx:`18`,cy:`18`,r:14,fill:`none`,className:`stroke-border`,strokeWidth:`4`}),U(`circle`,{cx:`18`,cy:`18`,r:14,fill:`none`,className:`stroke-primary`,strokeWidth:`4`,strokeDasharray:`${l} ${c-l}`,strokeLinecap:`round`,transform:`rotate(-90 18 18)`}),U(`text`,{x:`18`,y:`20`,textAnchor:`middle`,className:`fill-foreground text-[8px] font-bold`,children:Math.round(s*100)})]}),U(`input`,{"aria-label":`Detect weight for ${e}`,type:`number`,min:0,step:.25,value:a,disabled:r,onChange:e=>o(e.target.value),onBlur:u,onKeyDown:e=>{e.key===`Enter`&&u()},className:`w-20 rounded-md border border-border bg-background px-2 py-1 text-xs text-foreground`})]})}function Sn({nodeId:e,value:t,pending:n,onCommit:r}){let[i,a]=H(t===null?``:String(t));W(()=>{a(t===null?``:String(t))},[t]);let o=()=>{let t=Number(i);r(e,Number.isFinite(t)&&t>0?Math.floor(t):null)};return U(`input`,{"aria-label":`Max cameras for ${e}`,type:`number`,min:0,step:1,placeholder:`∞`,value:i,disabled:n,onChange:e=>a(e.target.value),onBlur:o,onKeyDown:e=>{e.key===`Enter`&&o()},className:`w-20 rounded-md border border-border bg-background px-2 py-1 text-xs text-foreground`})}function Cn(){let e=V(),{nodes:t}=F(),n=I(void 0),r=P({addonId:cn}),i=P({addonId:ln}),a=()=>_n(e),o=A({onSuccess:a}),s=M({onSuccess:a}),c=ne({onSuccess:a}),l=te({onSuccess:a}),u=z(()=>{let e=new Map;for(let t of n.data??[])e.set(t.nodeId,t.settings);return e},[n.data]),d=z(()=>t.map(e=>{let t=u.get(e.id),n=dt(t,e.isHub);return{id:e.id,name:e.name,isHub:e.isHub,isOnline:e.isOnline,settings:t,effective:n,weight:typeof mn(t,`detectWeight`)==`number`?Number(mn(t,`detectWeight`)):1}}),[t,u]),f=d.filter(e=>e.effective.pipeline).reduce((e,t)=>e+t.weight,0),p={ingestNode:hn(r.data,`ingestNode`,`hub`),recordingNode:hn(i.data,un,`hub`),audioNode:hn(r.data,`audioNode`,`hub`)},m=z(()=>{let e=t.filter(e=>e.isOnline).map(e=>e.id);return[...new Set([`hub`,...dn.map(e=>p[e]),...e])].filter(e=>e.length>0)},[t,p]),h=gn(r.data,`fpsMinThreshold`,0),g=h>0,_=(e,t,n)=>{o.mutate({agentNodeId:e,[t]:n})},v=(e,t)=>{if(e===`recordingNode`){l.mutate({addonId:ln,patch:{[un]:t}});return}l.mutate({addonId:cn,patch:{[e]:t}})},y=e=>{l.mutate({addonId:cn,patch:{fpsMinThreshold:e?Math.max(1,h):0}})};return R(`section`,{className:`rounded-lg border border-border bg-surface p-4 space-y-4`,children:[R(`div`,{className:`flex items-start justify-between gap-3`,children:[R(`div`,{children:[U(`h3`,{className:`text-sm font-semibold text-foreground`,children:`Table-board placement controls`}),U(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:`Enable node roles, tune relative detection weights, set camera ceilings, and choose singleton cluster roles. Weights are relative shares across detect-capable nodes.`})]}),(n.isLoading||r.isLoading||i.isLoading)&&U(q,{className:`h-4 w-4 animate-spin text-foreground-subtle`})]}),R(`div`,{className:`grid gap-3 @md/clustertab:grid-cols-4`,children:[dn.map(e=>U(bn,{role:e,value:p[e],options:m,pending:l.isPending,onChange:v},e)),R(`label`,{className:`flex items-center gap-2 rounded-md border border-border bg-background px-3 py-2 text-xs text-foreground`,children:[U(`input`,{type:`checkbox`,checked:g,disabled:l.isPending,onChange:e=>y(e.target.checked),className:`h-4 w-4`}),R(`span`,{className:`flex flex-col`,children:[U(`span`,{className:`font-medium`,children:`Enable low-fps relocate/shed`}),R(`span`,{className:`text-[10px] text-foreground-subtle`,children:[`fpsMinThreshold `,g?`${h} fps`:`disabled`]})]})]})]}),U(`div`,{className:`overflow-x-auto rounded-md border border-border`,children:R(`table`,{className:`w-full min-w-[760px] text-xs`,children:[U(`thead`,{className:`bg-background`,children:R(`tr`,{className:`text-[10px] uppercase tracking-wider text-foreground-subtle`,children:[U(`th`,{className:`px-3 py-2 text-left`,children:`Node`}),U(`th`,{className:`px-3 py-2 text-center`,children:`Detect`}),U(`th`,{className:`px-3 py-2 text-center`,children:`Decode`}),U(`th`,{className:`px-3 py-2 text-center`,children:`Audio`}),U(`th`,{className:`px-3 py-2 text-center`,children:`Ingest`}),U(`th`,{className:`px-3 py-2 text-left`,children:`Detect weight`}),U(`th`,{className:`px-3 py-2 text-left`,children:`Max cameras`})]})}),U(`tbody`,{children:d.map(e=>R(`tr`,{className:`border-t border-border ${e.isOnline?``:`opacity-50`}`,children:[R(`td`,{className:`px-3 py-2`,children:[U(`div`,{className:`font-medium text-foreground`,children:e.name}),R(`div`,{className:`font-mono text-[10px] text-foreground-subtle`,children:[e.id,e.isHub?` · hub`:``,e.isOnline?``:` · offline`]})]}),fn.map(t=>U(`td`,{className:`px-3 py-2 text-center`,children:U(`input`,{"aria-label":`${t} capability for ${e.id}`,type:`checkbox`,checked:yn(e.effective,t),disabled:o.isPending,onChange:n=>_(e.id,t,n.target.checked),className:`h-4 w-4`})},t)),U(`td`,{className:`px-3 py-2`,children:e.effective.pipeline?U(xn,{nodeId:e.id,weight:e.weight,totalWeight:f,pending:s.isPending,onCommit:(e,t)=>s.mutate({agentNodeId:e,detectWeight:t})}):U(`span`,{className:`text-[10px] text-foreground-subtle italic`,children:`Detect off`})}),U(`td`,{className:`px-3 py-2`,children:U(Sn,{nodeId:e.id,value:typeof mn(e.settings,`maxCameras`)==`number`?Number(mn(e.settings,`maxCameras`)):null,pending:c.isPending,onCommit:(e,t)=>c.mutate({agentNodeId:e,maxCameras:t})})})]},e.id))})]})})]})}L();function wn({refreshToken:e}){let t=V(),{data:n}=o(void 0),r=z(()=>tt(n??[]),[n]),i=O({onSuccess:()=>{t.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getPipelineAssignments`]]}),t.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getDecoderAssignments`]]}),t.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getAudioAssignments`]]})}});return R(`div`,{className:`space-y-6`,children:[U(ht,{refreshToken:e}),U(Cn,{}),R(`section`,{className:`rounded-lg border border-border bg-surface p-4 space-y-3`,children:[R(`div`,{children:[U(`h3`,{className:`text-sm font-semibold text-foreground`,children:`Cluster map`}),U(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:`React Flow topology map retained as the visual placement map; use the table-board above as the control surface.`})]}),U(`div`,{className:`h-[360px] rounded-md border border-border overflow-hidden bg-background`,children:U(Qe,{graph:r})})]}),R(`div`,{className:`flex flex-col gap-3 @md/clustertab:flex-row @md/clustertab:items-center @md/clustertab:justify-between`,children:[R(`div`,{className:`min-w-0`,children:[U(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Placement matrix`}),U(`p`,{className:`text-[11px] text-foreground-subtle`,children:`Pipeline · decoder · audio assignments per camera. Click the kebab to pin / unpin / move any role; expand the chevron for the per-camera broker drill-down.`})]}),R(`button`,{type:`button`,onClick:()=>i.mutate(void 0),disabled:i.isPending,className:`inline-flex items-center gap-1.5 rounded-lg bg-primary px-3 py-1.5 text-xs font-medium text-white hover:bg-primary/90 disabled:opacity-50 shrink-0 self-start @md/clustertab:self-auto whitespace-nowrap`,children:[U(Oe,{className:`h-3.5 w-3.5`}),i.isPending?`Rebalancing…`:`Rebalance pipelines`]})]}),U(bt,{mode:`cluster`})]})}var Tn=[`pipeline-orchestrator`];function En({refreshToken:e}){return U(`div`,{className:`space-y-4 max-w-3xl`,children:U(rt,{nodeId:`hub`,addonIds:Tn,level:`global`,title:`Cluster settings`,description:`Cluster-wide orchestration knobs: enabled nodes, load balancer thresholds, and failover policy. Per-camera pipelines live in Device Overrides; live cluster load is on the Assignments tab.`})})}L();function Dn({refreshToken:e}){let t=V(),{data:n,isLoading:r}=se(),[i,a]=H(null),[o,s]=H(``),[c,l]=H(``),d=()=>{t.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`listTemplates`]]})},f=fe({onSuccess:()=>{a(null),d()}}),p=u({onSuccess:d}),m=e=>{a(e.id),s(e.name),l(e.description??``)},h=()=>{a(null),s(``),l(``)},g=()=>{if(!i)return;let e=c.trim();f.mutate({id:i,name:o.trim()||`Untitled`,...e?{description:e}:{}})};if(r)return U(`div`,{className:`text-xs text-foreground-subtle animate-pulse`,children:`Loading templates…`});let _=[...n??[]].toSorted((e,t)=>e.name.localeCompare(t.name));return U(`div`,{className:`space-y-6 max-w-4xl`,children:R(`section`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[R(`div`,{className:`border-b border-border px-4 py-3 flex items-center justify-between`,children:[R(`div`,{children:[U(`h3`,{className:`text-sm font-semibold text-foreground`,children:`Templates`}),U(`p`,{className:`text-[11px] text-foreground-subtle mt-0.5`,children:`Curated pipeline presets operators can apply to any camera. Apply-time is a copy — future edits to a template don't retroactively change cameras that were seeded from it. Save a template from the device Pipeline tab.`})]}),R(`div`,{className:`text-[11px] text-foreground-subtle`,children:[_.length,` template`,_.length===1?``:`s`]})]}),_.length===0?R(`div`,{className:`px-4 py-8 text-xs text-foreground-subtle flex flex-col items-center gap-2`,children:[U(Ae,{className:`h-6 w-6 opacity-40`}),U(`div`,{children:`No templates yet. Create one from a device Pipeline tab ("Save as template").`})]}):U(`ul`,{className:`divide-y divide-border`,children:_.map(e=>{let t=i===e.id;return U(`li`,{className:`px-4 py-3 text-xs`,children:R(`div`,{className:`flex items-start gap-3`,children:[U(`div`,{className:`flex-1 min-w-0`,children:t?R(`div`,{className:`space-y-2`,children:[U(`input`,{className:`w-full rounded border border-border bg-surface-hover px-2 py-1 text-xs text-foreground focus:outline-none focus:border-primary`,value:o,onChange:e=>s(e.target.value),placeholder:`Template name`,autoFocus:!0}),U(`input`,{className:`w-full rounded border border-border bg-surface-hover px-2 py-1 text-[11px] text-foreground focus:outline-none focus:border-primary`,value:c,onChange:e=>l(e.target.value),placeholder:`Description (optional)`})]}):R(B,{children:[U(`div`,{className:`font-medium text-foreground`,children:e.name}),e.description&&U(`div`,{className:`text-foreground-subtle mt-0.5`,children:e.description}),R(`div`,{className:`mt-1 font-mono text-[10px] text-foreground-subtle`,children:[`engine `,e.config.engine.runtime,`/`,e.config.engine.backend,` ·`,` `,e.config.steps.length,` step(s)`,e.config.audio?.enabled?` · audio`:``,R(`span`,{className:`ml-2`,children:[`updated `,new Date(e.updatedAt).toLocaleString()]})]})]})}),U(`div`,{className:`flex items-center gap-1 shrink-0`,children:t?R(B,{children:[R(`button`,{type:`button`,onClick:g,disabled:f.isPending,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[11px] font-medium bg-primary text-white hover:bg-primary/90 disabled:opacity-50`,children:[U(Le,{className:`h-3 w-3`}),`Save`]}),R(`button`,{type:`button`,onClick:h,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[11px] text-foreground-subtle hover:bg-surface-hover`,children:[U(He,{className:`h-3 w-3`}),`Cancel`]})]}):R(B,{children:[U(`button`,{type:`button`,onClick:()=>m(e),title:`Rename`,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[11px] text-foreground-subtle hover:text-foreground hover:bg-surface-hover`,children:U(ke,{className:`h-3 w-3`})}),U(`button`,{type:`button`,onClick:()=>{confirm(`Delete template "${e.name}"?`)&&p.mutate({id:e.id})},disabled:p.isPending,title:`Delete`,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[11px] text-foreground-subtle hover:text-red-400 hover:bg-surface-hover disabled:opacity-50`,children:U(Ge,{className:`h-3 w-3`})})]})})]})},e.id)})})]})})}L();function On(e,t){if(!e)return null;for(let n of e.slots)for(let e of n.addons)if(e.id===t)return e;return null}function kn({nodeId:e,refreshToken:n}){let r=V(),i=be().trpcClient,[a,s]=H(null),[c,l]=H(null),u=I(void 0,{refetchOnMount:`always`});J([`nodes`,`topology`],[`agent.online`,`agent.offline`,`agent.unregistered`,`addon.installed`,`addon.uninstalled`,`addon.updated`]);let d=o(void 0,{refetchOnMount:`always`}),f=z(()=>{let e=new Set;for(let t of d.data??[])t.isOnline&&e.add(t.id);return e},[d.data]),p=t({nodeId:e},{refetchOnMount:`always`}),m=z(()=>(u.data??[]).filter(e=>f.has(e.nodeId)).map(e=>e.nodeId),[u.data,f]),h=ve({enabled:m.length>0,queryKey:[[`pipelineExecutor`,`getSchema`],`schema-by-agent`,m.join(`,`),n],queryFn:async()=>{let e={};for(let t of m)try{e[t]=(await i.pipelineExecutor.getSchema.query({nodeId:t})).selectedEngine.format}catch{e[t]=`coreml`}return e}}),g=ue({onSuccess:()=>{r.invalidateQueries({queryKey:[[`pipelineOrchestrator`]]}),r.invalidateQueries({queryKey:[[`pipelineExecutor`]]}),r.invalidateQueries({queryKey:[[`addonSettings`]]})}}),_=z(()=>p.data?le(p.data):[],[p.data]),v=z(()=>{let e=u.data??[],t=f;return(t.size===0?[]:e.filter(e=>t.has(e.nodeId))).map(e=>{let t=h.data?.[e.nodeId];return{agentNodeId:e.nodeId,engineLabel:t??`(engine unknown)`}})},[u.data,h.data,f]),y=(e,t)=>{let n=(u.data?.find(e=>e.nodeId===t))?.settings.addonDefaults[e],r=h.data?.[t];return!On(p.data??null,e)?.models.some(e=>r!==void 0&&!!e.formats[r])||!n?{kind:`na`}:n.enabled?{kind:`enabled`,modelId:n.modelId}:{kind:`disabled`}},b=a?u.data?.find(e=>e.nodeId===a.agentNodeId)??null:null,x=a&&p.data?On(p.data,a.addonId):null,S=a?h.data?.[a.agentNodeId]??`coreml`:`coreml`,C=()=>{s(null),l(null)},w=(e,t)=>{let n=(u.data?.find(e=>e.nodeId===t))?.settings.addonDefaults[e]??null;s({addonId:e,agentNodeId:t}),l(n)},T=()=>{!c||!a||!b||g.mutate({agentNodeId:a.agentNodeId,defaults:{...b.settings.addonDefaults,[a.addonId]:c}},{onSuccess:C})};if(u.isLoading||p.isLoading)return U(`div`,{className:`text-xs text-foreground-subtle animate-pulse`,children:`Loading agents…`});if(!p.data)return R(`div`,{className:`text-xs text-foreground-subtle`,children:[`Catalog unavailable for `,e,`.`]});let E=a!==null&&x!==null&&c!==null;return R(`div`,{className:`relative h-full w-full space-y-3`,children:[U(Yt,{title:`Cluster cameras`}),U(`div`,{className:E?`pr-[360px]`:``,children:_.length>0&&v.length>0?U(oe,{tree:_,agents:v,getCellState:y,onCellClick:w,selectedCell:a}):U(`div`,{className:`text-xs text-foreground-subtle`,children:`No agents or catalog empty.`})}),U(k,{open:E,onClose:C,title:x?.name??``,subtitle:a?`${a.agentNodeId} · ${S}`:``,footer:R(B,{children:[U(`button`,{type:`button`,className:`px-3 py-1 text-xs border border-border rounded bg-surface hover:bg-muted`,onClick:C,children:`Cancel`}),U(`button`,{type:`button`,disabled:!c||!a||g.isPending,className:`px-3 py-1 text-xs bg-primary text-primary-foreground rounded disabled:opacity-50`,onClick:T,children:g.isPending?`Saving…`:`Save`})]}),children:x&&c&&a&&U(D,{mode:`agent`,addon:x,agentDefault:c,agentNodeId:a.agentNodeId,engineFormat:S,onChangeAgentConfig:e=>l(e)})})]})}L();function An({types:e}){let t=V(),n=p(),{data:r}=i({}),o=a(),s=z(()=>o.data??[],[o.data]),[c,l]=H(null),[u,d]=H(null),f=()=>{t.invalidateQueries({queryKey:[[`storage`,`listLocations`]]})},m=ee({onSuccess:f}),h=v({onSuccess:f}),g=z(()=>{let e=new Map;for(let t of r??[]){let n=e.get(t.type);n?n.push(t):e.set(t.type,[t])}return e},[r]),_=e=>{e.isDefault||m.mutate({id:e.id,type:e.type,providerId:e.providerId,displayName:e.displayName,config:e.config,isDefault:!0})},y=async e=>{if(e.isDefault){await n({title:`Cannot delete default location`,message:`"${e.displayName}" is the default for type "${e.type}". Mark another as default first.`,confirmLabel:`OK`,variant:`warning`});return}await n({title:`Delete location "${e.displayName}"?`,message:`Removes the record; files on disk are untouched.`,confirmLabel:`Delete`,variant:`danger`})&&h.mutate({id:e.id})},b=e.map(e=>s.find(t=>t.id===e)).filter(e=>e!==void 0);return R(`div`,{className:`space-y-3`,children:[b.length===0?U(`p`,{className:`text-[11px] text-foreground-subtle italic`,children:`No storage locations declared for this purpose.`}):b.map(e=>U(we,{type:e.id,displayName:e.displayName,description:e.description,cardinality:e.cardinality,locations:g.get(e.id)??[],onAdd:e=>l(e),onEdit:e=>d(e),onDelete:e=>{y(e)},onSetDefault:e=>_(e)},e.id)),c!==null&&U(Te,{initialType:c,onClose:()=>l(null),onCreated:()=>{f(),l(null)}}),u!==null&&U(Ce,{location:u,onClose:()=>d(null),onSaved:()=>{f(),d(null)}})]})}L();var jn=`pipeline-analytics`;function Mn(e){for(let t of e?.sections??[])for(let e of t.fields??[])if(e.key===`postProcessingNodeId`&&typeof e.value==`string`)return e.value;return`hub`}function Nn(){let e=V(),{data:t}=o(void 0),{data:n,isLoading:r}=P({addonId:jn}),i=Mn(n),a=te({onSuccess:()=>{e.invalidateQueries({queryKey:[[`addonSettings`,`getGlobalSettings`]]})}}),s=z(()=>{let e=(t??[]).filter(e=>e.isOnline).map(e=>e.id);return[...new Set([`hub`,i,...e])].filter(Boolean)},[t,i]);return R(`div`,{className:`flex flex-col gap-6`,children:[R(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[U(`h3`,{className:`text-sm font-semibold text-foreground`,children:`Post-processing node`}),U(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:`The single node that runs detection post-processing (events, media, audio & motion). Every other node stays inert — no multi-node balancing. Takes effect on addon restart.`}),R(`div`,{className:`mt-3 flex items-center gap-2`,children:[r?U(q,{className:`h-4 w-4 animate-spin text-foreground-subtle`}):U(`select`,{value:i,onChange:e=>{e.target.value!==i&&a.mutate({addonId:jn,patch:{postProcessingNodeId:e.target.value}})},disabled:a.isPending,className:`rounded-md border border-border bg-surface px-2 py-1 text-xs text-foreground`,children:s.map(e=>U(`option`,{value:e,children:e===`hub`?`hub (default)`:e},e))}),a.isPending&&U(q,{className:`h-4 w-4 animate-spin text-primary`})]})]}),R(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[U(`h3`,{className:`mb-1 text-sm font-semibold text-foreground`,children:`Events folder`}),U(`p`,{className:`mb-3 text-[11px] text-foreground-subtle`,children:`Where event crops / full frames are stored. A single folder — no collection / equal-splitting.`}),U(An,{types:[`eventMedia`]})]})]})}L();var Pn=`recorder`;function Fn(e,t,n){for(let n of e?.sections??[])for(let e of n.fields??[])if(e.key===t&&typeof e.value==`string`)return e.value;return n}function In(){let e=V(),{data:t}=o(void 0),{data:n,isLoading:r}=P({addonId:Pn}),i=Fn(n,`recordingNodeId`,`hub`),a=te({onSuccess:()=>{e.invalidateQueries({queryKey:[[`addonSettings`,`getGlobalSettings`]]})}}),s=z(()=>{let e=(t??[]).filter(e=>e.isOnline).map(e=>e.id);return[...new Set([`hub`,i,...e])].filter(Boolean)},[t,i]);return R(`div`,{className:`flex flex-col gap-6`,children:[R(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[U(`h3`,{className:`text-sm font-semibold text-foreground`,children:`Recording node`}),U(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:`The single node that records (continuous & events) and serves playback. Every other node stays inert — no multi-node balancing. Takes effect on addon restart.`}),R(`div`,{className:`mt-3 flex items-center gap-2`,children:[r?U(q,{className:`h-4 w-4 animate-spin text-foreground-subtle`}):U(`select`,{value:i,onChange:e=>{e.target.value!==i&&a.mutate({addonId:Pn,patch:{recordingNodeId:e.target.value}})},disabled:a.isPending,className:`rounded-md border border-border bg-surface px-2 py-1 text-xs text-foreground`,children:s.map(e=>U(`option`,{value:e,children:e===`hub`?`hub (default)`:e},e))}),a.isPending&&U(q,{className:`h-4 w-4 animate-spin text-primary`})]}),i!==`hub`&&R(`p`,{className:`mt-2 text-[11px] text-amber-500`,children:[`The stream-broker is hub-only — an agent recorder pulls streams from the hub over the network. The hub's RTSP restream port must be reachable from`,` `,U(`span`,{className:`font-medium`,children:i}),`. If the auto-derived host doesn't work, set the recorder's`,U(`span`,{className:`font-medium`,children:` recordingHubHostname`}),` global setting.`]})]}),R(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[U(`h3`,{className:`mb-1 text-sm font-semibold text-foreground`,children:`Recordings folders`}),U(`p`,{className:`mb-3 text-[11px] text-foreground-subtle`,children:`Where recordings are stored. Multi-location collections — segments are split across the locations of a type. Add a location to grow capacity; mark one default per type.`}),U(An,{types:[`recordings`,`recordingsLow`]})]})]})}L();var Ln=[{id:`assignments`,label:`Assignments`},{id:`pipeline`,label:`Pipeline`},{id:`events`,label:`Events`},{id:`recording`,label:`Recording`},{id:`settings`,label:`Settings`},{id:`templates`,label:`Templates`}];function Rn({refreshToken:e}){let[t,n]=H(`assignments`),{data:r}=o(void 0),i=r?.find(e=>e.isHub&&e.isOnline)?.id??r?.find(e=>e.isOnline)?.id??null;return R(`div`,{className:`flex flex-col h-full`,children:[R(`div`,{className:`px-4 sm:px-6 py-4 border-b border-border`,children:[U(`h2`,{className:`text-base font-semibold text-foreground`,children:`Cluster Orchestration`}),U(`div`,{className:`text-[11px] text-foreground-subtle mt-1`,children:`Assignments with live load, cluster-wide settings, pipeline template library, per-camera pipeline overrides.`})]}),U(`div`,{className:`flex items-center gap-1 px-4 sm:px-6 border-b border-border overflow-x-auto`,children:Ln.map(e=>U(`button`,{type:`button`,onClick:()=>n(e.id),className:`shrink-0 whitespace-nowrap px-3 py-2 text-xs font-medium border-b-2 transition-colors ${t===e.id?`border-primary text-primary`:`border-transparent text-foreground-subtle hover:text-foreground`}`,children:e.label},e.id))}),R(`div`,{className:`flex-1 min-h-0 overflow-y-auto p-4 sm:p-6 @container/clustertab`,children:[t===`assignments`&&U(wn,{refreshToken:e}),t===`pipeline`&&(i?U(kn,{nodeId:i,refreshToken:e}):U(`div`,{className:`text-xs text-foreground-subtle`,children:`No online node available — schema unreachable.`})),t===`events`&&U(Nn,{}),t===`recording`&&U(In,{}),t===`settings`&&U(En,{refreshToken:e}),t===`templates`&&U(Dn,{refreshToken:e})]})]})}function zn(e){let{assignment:t,detection:n}=e;return n!==null&&n.provisioning.state===`failed`||t.detectionNodeId===null&&n===null?`error`:n!==null&&n.phase===`active`?`healthy`:`idle`}L();var Bn={healthy:`bg-green-500`,idle:`bg-yellow-400`,error:`bg-red-500`},Vn={healthy:`Healthy`,idle:`Idle`,error:`Error`};function Hn({health:e}){return U(`span`,{className:`inline-block h-2 w-2 rounded-full shrink-0 ${Bn[e]}`,title:Vn[e],"aria-label":Vn[e],role:`img`})}function Un({selectedDeviceId:e,onSelect:t}){let{data:n}=Je(),{data:r}=ce({}),i=z(()=>{let e=new Map;for(let t of r??[])e.set(t.deviceId,t);return e},[r]),a=z(()=>(n??[]).filter(e=>e.isCamera).map(e=>{let t=i.get(e.id);return{deviceId:e.id,name:e.name,health:t===void 0?`idle`:zn(t)}}),[n,i]);return a.length===0?U(`div`,{className:`px-4 py-6 text-center text-[11px] text-foreground-subtle italic`,children:`No cameras found`}):U(`ul`,{className:`divide-y divide-border`,children:a.map(n=>{let r=n.deviceId===e;return U(`li`,{children:R(`button`,{type:`button`,onClick:()=>t(n.deviceId),className:[`w-full flex items-center gap-2.5 px-4 py-3 text-left transition-colors`,r?`bg-surface-active text-foreground`:`hover:bg-surface-hover text-foreground-subtle hover:text-foreground`].join(` `),"aria-pressed":r,children:[U(Hn,{health:n.health}),R(`span`,{className:`flex-1 min-w-0`,children:[U(`span`,{className:`block truncate text-[12px] font-medium leading-tight`,children:n.name}),R(`span`,{className:`block text-[10px] text-foreground-subtle leading-tight mt-0.5`,children:[`#`,n.deviceId]})]})]})},n.deviceId)})})}var $={camera:0,source:200,broker:400,decoder:600,motion:800,detection:800,audio:800,recorder:800},Wn=120;function Gn(e,t){return e===null||t===null?!1:e!==t}function Kn(e){let t=e.profiles.reduce((e,t)=>e+t.subscribers,0),n=e.profiles.reduce((e,t)=>e+t.inFps,0),r=e.profiles.reduce((e,t)=>e+t.outFps,0);return`${t} subs · ${n.toFixed(1)}→${r.toFixed(1)} fps`}function qn(e){return`${e.actualFps.toFixed(1)} fps · q${e.queueDepth} · ${e.avgInferenceMs.toFixed(1)}ms`}function Jn(e){return`shm ${e.shm.getFrameHits+e.shm.getFrameMisses>0?Math.round(e.shm.getFrameHits/(e.shm.getFrameHits+e.shm.getFrameMisses)*100):0}% hit`}function Yn(e){let t=[],n=[],r={id:`camera`,kind:`camera`,nodeId:null,data:{deviceId:e.deviceId},position:{x:$.camera,y:0}};t.push(r);let i={id:`source`,kind:`source`,nodeId:null,data:{streams:e.source.streams},position:{x:$.source,y:0}};t.push(i),n.push({id:`camera->source`,source:`camera`,target:`source`,crossNode:!1});let a=e.broker;if(a!==null){let e={id:`broker`,kind:`broker`,nodeId:null,data:{profiles:a.profiles,webrtcSessions:a.webrtcSessions,rtspRestream:a.rtspRestream},position:{x:$.broker,y:0}};t.push(e),n.push({id:`source->broker`,source:`source`,target:`broker`,crossNode:!1})}let o=e.decoder;if(o!==null){let r={id:`decoder`,kind:`decoder`,nodeId:o.nodeId,data:{nodeId:o.nodeId,formats:o.formats,sessionCount:o.sessionCount,shm:o.shm},position:{x:$.decoder,y:0}};t.push(r);let i=a===null?`source`:`broker`,s=a===null?void 0:Kn(a),c=a===null?Jn(o):s;n.push({id:`${i}->decoder`,source:i,target:`decoder`,crossNode:Gn(null,o.nodeId),...c===void 0?{}:{label:c}});let l=0,u=e.motion;if(u!==null){let e={id:`motion`,kind:`motion`,nodeId:null,data:{enabled:u.enabled,fps:u.fps},position:{x:$.motion,y:l*Wn}};t.push(e),n.push({id:`decoder->motion`,source:`decoder`,target:`motion`,crossNode:!1}),l++}let d=e.detection;if(d!==null){let e={id:`detection`,kind:`detection`,nodeId:d.nodeId,data:{nodeId:d.nodeId,engine:d.engine,phase:d.phase,configuredFps:d.configuredFps,actualFps:d.actualFps,queueDepth:d.queueDepth,avgInferenceMs:d.avgInferenceMs,provisioning:d.provisioning},position:{x:$.detection,y:l*Wn}};t.push(e),n.push({id:`decoder->detection`,source:`decoder`,target:`detection`,crossNode:Gn(o.nodeId,d.nodeId),label:qn(d)}),l++}let f=e.audio;if(f!==null){let e={id:`audio`,kind:`audio`,nodeId:f.nodeId,data:{nodeId:f.nodeId,enabled:f.enabled},position:{x:$.audio,y:l*Wn}};t.push(e),n.push({id:`decoder->audio`,source:`decoder`,target:`audio`,crossNode:Gn(o.nodeId,f.nodeId)}),l++}let p=e.recording;if(p!==null){let e={id:`recorder`,kind:`recorder`,nodeId:null,data:{mode:p.mode,active:p.active,storageBytes:p.storageBytes},position:{x:$.recorder,y:l*Wn}};t.push(e),n.push({id:`decoder->recorder`,source:`decoder`,target:`recorder`,crossNode:!1})}}return{nodes:t,edges:n}}L();function Xn(e){let{data:t,isLoading:n}=j({deviceId:e}),[r,i]=H(void 0);return W(()=>{t!==void 0&&i(t)},[t]),w(G.PipelineCameraMetricsSnapshot,t=>{let n=t.data;n.deviceId===e&&i(e=>e===void 0||e.detection===null?e:{...e,detection:{...e.detection,phase:n.metrics.phase,actualFps:n.metrics.actualFps,queueDepth:n.metrics.queueDepth,avgInferenceMs:n.metrics.avgInferenceTimeMs}})}),w(G.PipelineEngineProvisioning,e=>{let t=e.data;i(n=>{if(n===void 0||n.detection===null)return n;let r=n.detection.nodeId??n.assignment?.detectionNodeId??null;return r===null||e.source.type!==`node`||e.source.id!==r?n:{...n,detection:{...n.detection,provisioning:{state:t.state,error:t.error}}}})}),w(G.MotionAnalysis,t=>{t.source.type!==`device`||t.source.id!==e||i(e=>e===void 0||e.motion===null?e:{...e,motion:{...e.motion,enabled:!0}})}),w(G.StreamBrokerMetricsSnapshot,t=>{let n=t.data;n.deviceId===e&&i(e=>e===void 0||e.broker===null?e:{...e,broker:{...e.broker,profiles:e.broker.profiles.map(e=>e.profile===n.profile?{...e,subscribers:n.stats.encodedSubscribers+n.stats.decodedSubscribers,inFps:n.stats.inputFps,outFps:n.stats.decodeFps}:e)}})}),w(G.PipelineAudioInferenceResult,t=>{t.data.deviceId===e&&i(e=>e===void 0||e.audio===null?e:{...e,audio:{...e.audio,enabled:!0}})}),w(G.RecordingStarted,t=>{t.data.deviceId===e&&i(e=>e===void 0||e.recording===null?e:{...e,recording:{...e.recording,active:!0}})}),w(G.RecordingStopped,t=>{t.data.deviceId===e&&i(e=>e===void 0||e.recording===null?e:{...e,recording:{...e.recording,active:!1}})}),{status:r,isLoading:n}}function Zn({data:e}){return R(`div`,{className:`border border-border rounded-lg bg-background shadow-sm min-w-[160px] px-3 py-2`,children:[U(X,{type:`source`,position:Y.Right}),R(`div`,{className:`flex items-center gap-2`,children:[U(`span`,{className:`h-2 w-2 rounded-full bg-green-500 shrink-0`,"aria-label":`healthy`}),R(`span`,{className:`text-sm font-semibold truncate`,children:[`Camera #`,e.deviceId]})]}),U(`div`,{className:`text-xs text-muted-foreground mt-1`,children:`source`})]})}function Qn(e){return e>0?`bg-green-500`:`bg-yellow-500`}function $n({data:e}){let t=e.streams[0],n=e.streams.length;return R(`div`,{className:`border border-border rounded-lg bg-background shadow-sm min-w-[160px] px-3 py-2`,children:[U(X,{type:`target`,position:Y.Left}),U(X,{type:`source`,position:Y.Right}),R(`div`,{className:`flex items-center gap-2`,children:[U(`span`,{className:`h-2 w-2 rounded-full shrink-0 ${Qn(n)}`,"aria-label":n>0?`healthy`:`idle`}),U(`span`,{className:`text-sm font-semibold`,children:`Source`}),R(`span`,{className:`text-xs text-muted-foreground`,children:[n,` streams`]})]}),t!==void 0&&R(`div`,{className:`text-xs text-muted-foreground mt-1`,children:[t.codec,` `,t.width,`×`,t.height,` `,t.fps,`fps`]})]})}function er(e){return e>0?`bg-green-500`:`bg-yellow-500`}function tr({data:e}){let t=e.profiles.reduce((e,t)=>e+t.subscribers,0),n=e.profiles.length;return R(`div`,{className:`border border-border rounded-lg bg-background shadow-sm min-w-[160px] px-3 py-2`,children:[U(X,{type:`target`,position:Y.Left}),U(X,{type:`source`,position:Y.Right}),R(`div`,{className:`flex items-center gap-2`,children:[U(`span`,{className:`h-2 w-2 rounded-full shrink-0 ${er(t)}`,"aria-label":t>0?`healthy`:`idle`}),U(`span`,{className:`text-sm font-semibold`,children:`Broker`}),R(`span`,{className:`text-xs text-muted-foreground`,children:[n,` profiles`]})]}),R(`div`,{className:`text-xs text-muted-foreground mt-1`,children:[t,` subs · WebRTC `,e.webrtcSessions,e.rtspRestream&&` · RTSP`]})]})}function nr(e){return e>0?`bg-green-500`:`bg-yellow-500`}function rr(e,t){let n=e+t;return n>0?Math.round(e/n*100):0}function ir({data:e}){let t=rr(e.shm.getFrameHits,e.shm.getFrameMisses),n=e.offline===!0;return R(`div`,{className:`border border-border rounded-lg bg-background shadow-sm min-w-[160px] px-3 py-2${n?` opacity-50`:``}`,children:[U(X,{type:`target`,position:Y.Left}),U(X,{type:`source`,position:Y.Right}),R(`div`,{className:`flex items-center gap-2`,children:[U(`span`,{className:`h-2 w-2 rounded-full shrink-0 ${nr(e.sessionCount)}`,"aria-label":e.sessionCount>0?`healthy`:`idle`}),U(`span`,{className:`text-sm font-semibold`,children:`Decoder`}),R(`span`,{className:`text-xs text-muted-foreground`,children:[`@`,e.nodeId]}),n&&U(`span`,{className:`text-[9px] font-semibold px-1 py-0.5 rounded bg-destructive/10 text-destructive`,"aria-label":`offline`,children:`offline`})]}),R(`div`,{className:`text-xs text-muted-foreground mt-1`,children:[e.formats.join(`, `),` · `,e.sessionCount,` sessions`]}),R(`div`,{className:`text-xs text-muted-foreground`,children:[`shm `,t,`% hit`]})]})}function ar(e){return e?`bg-green-500`:`bg-yellow-500`}function or({data:e}){return R(`div`,{className:`border border-border rounded-lg bg-background shadow-sm min-w-[160px] px-3 py-2`,children:[U(X,{type:`target`,position:Y.Left}),R(`div`,{className:`flex items-center gap-2`,children:[U(`span`,{className:`h-2 w-2 rounded-full shrink-0 ${ar(e.enabled)}`,"aria-label":e.enabled?`enabled`:`disabled`}),U(`span`,{className:`text-sm font-semibold`,children:`Motion`})]}),R(`div`,{className:`text-xs text-muted-foreground mt-1`,children:[e.enabled?`enabled`:`disabled`,` · `,e.fps,` fps`]})]})}function sr(e){return e.provisioning.state===`failed`?`bg-red-500`:e.phase===`active`?`bg-green-500`:(e.phase,`bg-yellow-500`)}function cr(e){return e===`ready`?`bg-green-500 text-white`:e===`failed`?`bg-red-500 text-white`:`bg-yellow-500 text-white`}function lr({data:e}){let t=e.offline===!0;return R(`div`,{className:`border border-border rounded-lg bg-background shadow-sm min-w-[180px] px-3 py-2${t?` opacity-50`:``}`,children:[U(X,{type:`target`,position:Y.Left}),R(`div`,{className:`flex items-center gap-2`,children:[U(`span`,{className:`h-2 w-2 rounded-full shrink-0 ${sr(e)}`,"aria-label":e.phase}),U(`span`,{className:`text-sm font-semibold`,children:`Detection`}),R(`span`,{className:`text-xs text-muted-foreground`,children:[`@`,e.nodeId]}),t&&U(`span`,{className:`text-[9px] font-semibold px-1 py-0.5 rounded bg-destructive/10 text-destructive`,"aria-label":`offline`,children:`offline`})]}),R(`div`,{className:`text-xs text-muted-foreground mt-1`,children:[e.engine.backend,`·`,e.engine.device,` · `,e.phase]}),R(`div`,{className:`text-xs text-muted-foreground`,children:[e.actualFps.toFixed(1),`/`,e.configuredFps,` fps · q`,e.queueDepth,` ·`,` `,e.avgInferenceMs.toFixed(1),`ms`]}),R(`div`,{className:`flex items-center gap-1 mt-1`,children:[U(`span`,{className:`text-[10px] font-semibold px-1.5 py-0.5 rounded ${cr(e.provisioning.state)}`,"aria-label":`provisioning ${e.provisioning.state}`,children:e.provisioning.state}),e.provisioning.state===`failed`&&e.provisioning.error!==void 0&&U(`span`,{className:`text-[10px] text-red-500 truncate`,children:e.provisioning.error})]})]})}function ur(e){return e?`bg-green-500`:`bg-yellow-500`}function dr({data:e}){let t=e.offline===!0;return R(`div`,{className:`border border-border rounded-lg bg-background shadow-sm min-w-[160px] px-3 py-2${t?` opacity-50`:``}`,children:[U(X,{type:`target`,position:Y.Left}),R(`div`,{className:`flex items-center gap-2`,children:[U(`span`,{className:`h-2 w-2 rounded-full shrink-0 ${ur(e.enabled)}`,"aria-label":e.enabled?`enabled`:`disabled`}),U(`span`,{className:`text-sm font-semibold`,children:`Audio`}),R(`span`,{className:`text-xs text-muted-foreground`,children:[`@`,e.nodeId]}),t&&U(`span`,{className:`text-[9px] font-semibold px-1 py-0.5 rounded bg-destructive/10 text-destructive`,"aria-label":`offline`,children:`offline`})]}),U(`div`,{className:`text-xs text-muted-foreground mt-1`,children:e.enabled?`enabled`:`disabled`})]})}function fr(e){return e.mode===`off`?`bg-red-500`:e.active?`bg-green-500`:`bg-yellow-500`}function pr(e){return e>=1073741824?`${(e/1073741824).toFixed(1)} GB`:`${(e/1048576).toFixed(1)} MB`}function mr({data:e}){return R(`div`,{className:`border border-border rounded-lg bg-background shadow-sm min-w-[160px] px-3 py-2`,children:[U(X,{type:`target`,position:Y.Left}),R(`div`,{className:`flex items-center gap-2`,children:[U(`span`,{className:`h-2 w-2 rounded-full shrink-0 ${fr(e)}`,"aria-label":e.active?`active`:e.mode===`off`?`off`:`inactive`}),U(`span`,{className:`text-sm font-semibold`,children:`Recorder`}),U(`span`,{className:`text-xs text-muted-foreground`,children:e.mode})]}),R(`div`,{className:`text-xs text-muted-foreground mt-1`,children:[e.active?`active`:`inactive`,` · `,pr(e.storageBytes)]})]})}L();var hr={camera:Zn,source:$n,broker:tr,decoder:ir,motion:or,detection:lr,audio:dr,recorder:mr},gr={stroke:`#f59e0b`,strokeWidth:2},_r={strokeWidth:1.5},vr=`camstack-pipeline-flow-layout`;function yr({deviceId:e}){let{status:t,isLoading:n}=Xn(e),{data:r}=o(void 0),i=z(()=>{let e=new Set;for(let t of r??[])t.isOnline||e.add(t.id);return e},[r]),{computedNodes:a,rfEdges:s}=z(()=>{if(t===void 0)return{computedNodes:[],rfEdges:[]};let e=Yn(t);return{computedNodes:e.nodes.map(e=>({id:e.id,type:e.kind,position:{x:e.position.x,y:e.position.y},data:{...e.data,offline:e.nodeId!==null&&i.has(e.nodeId)}})),rfEdges:e.edges.map(e=>({id:e.id,source:e.source,target:e.target,animated:e.crossNode,style:e.crossNode?gr:_r,label:e.label}))}},[t,i]),{nodes:c,onNodesChange:l,resetLayout:u}=$e(vr,a);return n?U(`div`,{className:`flex items-center justify-center h-full text-sm text-muted-foreground`,children:`Loading…`}):t===void 0?U(`div`,{className:`flex items-center justify-center h-full text-sm text-muted-foreground`,children:`No pipeline data`}):R(`div`,{className:`w-full h-full relative`,children:[U(`button`,{type:`button`,onClick:u,className:`absolute top-2 right-2 z-10 text-xs px-2 py-1 rounded border border-border bg-background hover:bg-muted`,title:`Restore the automatic layout, discarding dragged positions`,children:`Reset layout`}),R(et,{nodes:c,edges:s,onNodesChange:l,nodesDraggable:!0,nodeTypes:hr,fitView:!0,proOptions:{hideAttribution:!0},children:[U(Xe,{gap:20,size:1}),U(Ye,{showInteractive:!1})]})]})}L();var br=`__cluster__`;function xr(e){return e===`cameras`?`cameras`:`nodes`}function Sr(){let[e,t]=Re(),n=xr(e.get(`view`)),r=e.get(`node`)??`__cluster__`,i=e.get(`camera`),a=i===null?null:parseInt(i,10),[o,s]=H(0),[c,l]=H(!1);return W(()=>{n===`nodes`&&!e.get(`node`)&&t({view:`nodes`,node:br},{replace:!0})},[n,e,t]),R(`div`,{className:`flex flex-col h-full overflow-hidden`,children:[R(`div`,{className:`flex items-center justify-between gap-4 px-4 py-3 border-b border-border shrink-0`,children:[R(`div`,{className:`flex items-center gap-1 rounded-lg border border-border p-0.5 bg-surface`,children:[U(`button`,{type:`button`,onClick:()=>{t({view:`nodes`,node:r},{replace:!0})},className:[`px-3 py-1 rounded-md text-[11px] font-medium transition-colors`,n===`nodes`?`bg-background text-foreground shadow-sm`:`text-foreground-subtle hover:text-foreground`].join(` `),children:`Nodes`}),U(`button`,{type:`button`,onClick:()=>{let e={view:`cameras`};a!==null&&(e.camera=String(a)),t(e,{replace:!0})},className:[`px-3 py-1 rounded-md text-[11px] font-medium transition-colors`,n===`cameras`?`bg-background text-foreground shadow-sm`:`text-foreground-subtle hover:text-foreground`].join(` `),children:`Cameras`})]}),R(`button`,{type:`button`,onClick:()=>s(e=>e+1),title:`Refresh`,className:`inline-flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-[11px] font-medium border border-border text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,children:[U(je,{className:`h-3.5 w-3.5`}),`Refresh`]})]}),R(`button`,{type:`button`,onClick:()=>l(e=>!e),"aria-expanded":c,className:`md:hidden flex items-center justify-between gap-2 px-4 py-2 border-b border-border shrink-0 text-[11px] font-medium text-foreground-subtle hover:text-foreground transition-colors`,children:[R(`span`,{children:[c?`Hide`:`Show`,` `,n===`nodes`?`node list`:`camera list`]}),U(Be,{className:[`h-4 w-4 transition-transform`,c?`rotate-180`:``].join(` `)})]}),U(`div`,{className:`flex-1 flex flex-col md:flex-row overflow-hidden min-h-0`,children:n===`nodes`?R(B,{children:[U(`aside`,{className:[c?`block`:`hidden`,`md:block w-full md:w-72 shrink-0 border-b md:border-b-0 md:border-r border-border`,`max-h-[60vh] md:max-h-none overflow-y-auto`].join(` `),children:U(pt,{selectedNodeId:r,onSelect:e=>{t({view:`nodes`,node:e},{replace:!0}),l(!1)},refreshToken:o})}),U(`section`,{className:`flex-1 min-h-0 overflow-hidden`,children:r===`__cluster__`?U(Rn,{refreshToken:o}):U(sn,{nodeId:r,refreshToken:o})})]}):R(B,{children:[U(`aside`,{className:[c?`block`:`hidden`,`md:block w-full md:w-72 shrink-0 border-b md:border-b-0 md:border-r border-border`,`max-h-[60vh] md:max-h-none overflow-y-auto`].join(` `),children:U(Un,{selectedDeviceId:a,onSelect:e=>{t({view:`cameras`,camera:String(e)},{replace:!0}),l(!1)}})}),U(`section`,{className:`flex-1 min-h-0 overflow-hidden`,children:a!==null&&Number.isFinite(a)&&!Number.isNaN(a)?U(yr,{deviceId:a}):U(`div`,{className:`flex items-center justify-center h-full text-sm text-foreground-subtle`,children:`Select a camera to view its pipeline flow`})})]})})]})}export{Sr as PipelinePage};
@@ -1 +0,0 @@
1
- import{V as e}from"./index-CukLUOO-.js";var t=e(`circle-check-big`,[[`path`,{d:`M21.801 10A10 10 0 1 1 17 3.335`,key:`yps3ct`}],[`path`,{d:`m9 11 3 3L22 4`,key:`1pflzl`}]]);export{t};