@camstack/addon-admin-ui 1.2.211 → 1.2.213

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 (91) hide show
  1. package/dist/assets/{AddonCollectionPage-Dh1jIX2X.js → AddonCollectionPage-DZpgo_dH.js} +1 -1
  2. package/dist/assets/{Addons-CYe51kaT.js → Addons-DVTDjH2L.js} +1 -1
  3. package/dist/assets/{AdminTabs-Z-tEGMT7.js → AdminTabs-BhF-e7Yr.js} +1 -1
  4. package/dist/assets/{AiProfiles-COA5XqcA.js → AiProfiles-cVbbqy-g.js} +2 -2
  5. package/dist/assets/{BrokerForm-BwdFojNK.js → BrokerForm-BVi_KkFR.js} +1 -1
  6. package/dist/assets/{Build-ClJOyaib.js → Build-Cz49N4eI.js} +3 -3
  7. package/dist/assets/{Capabilities-UPCKBcYj.js → Capabilities-Dkziktzm.js} +1 -1
  8. package/dist/assets/CapabilityBadges-_NNrhBO9.js +1 -0
  9. package/dist/assets/{Cluster-BPO06mXq.js → Cluster-DnWTS9Dd.js} +2 -2
  10. package/dist/assets/{Data-BTN5hJ1C.js → Data-D7IThOuJ.js} +1 -1
  11. package/dist/assets/{DetectionIntelligence-DdIpCKfA.js → DetectionIntelligence-3kyJyVqe.js} +1 -1
  12. package/dist/assets/{DeviceAggregateSection-ebT0fjdy.js → DeviceAggregateSection-COI2_VWV.js} +1 -1
  13. package/dist/assets/DeviceDetail-Dmzy6AjD.js +2 -0
  14. package/dist/assets/{Devices-Ca8f04aj.js → Devices-D7ZKbPxT.js} +1 -1
  15. package/dist/assets/{EmbedPlayerPage-CLsmv_oY.js → EmbedPlayerPage-Bmgt0Ue_.js} +1 -1
  16. package/dist/assets/{Events-B7bvDEDa.js → Events-Buhsl6rD.js} +1 -1
  17. package/dist/assets/{FormBuilder-DiXkXGnq.js → FormBuilder-D8Q5DVBo.js} +1 -1
  18. package/dist/assets/{Identity-Bb2fHzTM.js → Identity-CpSVKEiU.js} +1 -1
  19. package/dist/assets/{IntegrationDetail-D0XRl0pg.js → IntegrationDetail-BP2mUhdh.js} +1 -1
  20. package/dist/assets/{Integrations-BJL8QhRB.js → Integrations-CSzSIQpy.js} +1 -1
  21. package/dist/assets/{Integrations-BjxcDtm5.js → Integrations-D8s_frRf.js} +1 -1
  22. package/dist/assets/{Locations-Boa15dav.js → Locations-LrzsmBE-.js} +1 -1
  23. package/dist/assets/{Logs-CV_43NFw.js → Logs-Cu0Hkh2A.js} +1 -1
  24. package/dist/assets/MotionZonesSettings-BiAGsr5r.js +1 -0
  25. package/dist/assets/{MyAccess-DnYhunwB.js → MyAccess-Dv0ckMsw.js} +1 -1
  26. package/dist/assets/{Network-DUREzmfy.js → Network-W5rj0hIb.js} +1 -1
  27. package/dist/assets/{NodeAddonsSettingsPanel-DX-_5hqg.js → NodeAddonsSettingsPanel-BK3mMfkN.js} +1 -1
  28. package/dist/assets/{NodeInferenceDevices-q5gpemLH.js → NodeInferenceDevices-jIT4TOIy.js} +1 -1
  29. package/dist/assets/{Notifications-_ncMPWHS.js → Notifications-wbrfaAe4.js} +1 -1
  30. package/dist/assets/{Pipeline-BwpkeOPx.js → Pipeline-Bv9cS8CP.js} +1 -1
  31. package/dist/assets/{Plates-Xq5V84Yk.js → Plates-wvCcFo9u.js} +1 -1
  32. package/dist/assets/PrivacyMaskSettings-Bm_cm4Ez.js +1 -0
  33. package/dist/assets/{ProviderIcon-RcyRCpwL.js → ProviderIcon-0zoOaaFD.js} +1 -1
  34. package/dist/assets/{Recordings-y9V9fgLK.js → Recordings-erk3VDwd.js} +1 -1
  35. package/dist/assets/{ScanNetworkModal-Di9dOoyb.js → ScanNetworkModal-DKIxhrJk.js} +1 -1
  36. package/dist/assets/{SceneMonitorEditor-DfWv7MW6.js → SceneMonitorEditor-Cm1_9209.js} +1 -1
  37. package/dist/assets/{Scenes-DPmMNAF_.js → Scenes-L7LCkjqy.js} +1 -1
  38. package/dist/assets/{Settings-x5IOFIk4.js → Settings-CFkzlf0_.js} +1 -1
  39. package/dist/assets/{Showroom-Uqkchveb.js → Showroom-Bfw3oS6L.js} +1 -1
  40. package/dist/assets/{StorageLocationsPanel-oj3qKwsY.js → StorageLocationsPanel-BBHo6JM3.js} +1 -1
  41. package/dist/assets/{Terminal-DMbw4lox.js → Terminal-C0zU5pFy.js} +1 -1
  42. package/dist/assets/{Viewer-BE0rCk7E.js → Viewer-Da8Spkkl.js} +1 -1
  43. package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-BXALhirf.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-AljWtTMR.js} +1 -1
  44. package/dist/assets/{authed-media-B4sv3G7D.js → authed-media-DvQdxTUc.js} +1 -1
  45. package/dist/assets/{bell-off-BBo4kutk.js → bell-off-6xEwqVzJ.js} +1 -1
  46. package/dist/assets/{boxes-Bg9iqtyH.js → boxes-B7kNLelh.js} +1 -1
  47. package/dist/assets/circle-slash--GGol-T9.js +1 -0
  48. package/dist/assets/{debounced-invalidate-CginxchA.js → debounced-invalidate-CQPyWocr.js} +1 -1
  49. package/dist/assets/{dist-CzoIn3cG.js → dist-DWzDC1T8.js} +1 -1
  50. package/dist/assets/dist-Dl3E57s2.js +349 -0
  51. package/dist/assets/{face-bbox-D9V_tLDk.js → face-bbox-DUZG_QP9.js} +1 -1
  52. package/dist/assets/{hard-drive-download-B9_mWvrk.js → hard-drive-download-CjICR_3r.js} +1 -1
  53. package/dist/assets/{hostInit-CsEZLkcq.js → hostInit-CVy552ti.js} +1 -1
  54. package/dist/assets/index-BFpVtoWO.js +4 -0
  55. package/dist/assets/index-CfOA-EYv.css +2 -0
  56. package/dist/assets/{key-round-bsrGF3KU.js → key-round-C-KKSFg6.js} +1 -1
  57. package/dist/assets/{layers-BxvBcSbK.js → layers-jDvevbCl.js} +1 -1
  58. package/dist/assets/{location-owned-usage-DNlfyCt1.js → location-owned-usage-B75IZFVF.js} +1 -1
  59. package/dist/assets/{mf-entry-bootstrap-0-b0208c6d.js → mf-entry-bootstrap-0-163cf22c.js} +2 -2
  60. package/dist/assets/player-overlays-C64C5sp1.js +1 -0
  61. package/dist/assets/remoteEntry-DPWrrM7B.js +1 -0
  62. package/dist/assets/{send-C22DdO9M.js → send-LQeZq7ZP.js} +1 -1
  63. package/dist/assets/{settings-2-Csv9HD2i.js → settings-2-CAoxWnYU.js} +1 -1
  64. package/dist/assets/{square-check-big-D46wUa5R.js → square-check-big-WyVmnSdy.js} +1 -1
  65. package/dist/assets/src-Bqn0Lh4Q.js +349 -0
  66. package/dist/assets/src-DvETVhyy.js +67 -0
  67. package/dist/assets/{use-scenes-feed-DTI0L0XP.js → use-scenes-feed-Dpx4O083.js} +1 -1
  68. package/dist/assets/{use-stationary-objects-BhlIRr4y.js → use-stationary-objects-CxwfCEMe.js} +1 -1
  69. package/dist/assets/useEventInvalidation-C_4Khxpz.js +1 -0
  70. package/dist/assets/{useNodeUrlSelection-CnhjejAb.js → useNodeUrlSelection-DgvtPUJc.js} +1 -1
  71. package/dist/assets/user-round-B7LijIij.js +1 -0
  72. package/dist/assets/{video-BnWAdQdw.js → video-aqsZgai-.js} +1 -1
  73. package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-_w9bn027.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-C5II-XR4.js} +2 -2
  74. package/dist/index.html +6 -6
  75. package/dist/server/addon.js +210 -8
  76. package/package.json +1 -1
  77. package/dist/assets/CapabilityBadges-B8jx5YjN.js +0 -1
  78. package/dist/assets/DeviceDetail-egKMaafR.js +0 -2
  79. package/dist/assets/MotionZonesSettings-CE_Ld2DB.js +0 -1
  80. package/dist/assets/PrivacyMaskSettings-Bv6FE9rb.js +0 -1
  81. package/dist/assets/circle-slash-CMIlCEyU.js +0 -1
  82. package/dist/assets/dist-Dd2EZOIl.js +0 -349
  83. package/dist/assets/grid-2x2-G4yOYg6v.js +0 -1
  84. package/dist/assets/index-7NRboinb.css +0 -2
  85. package/dist/assets/index-j_wfe7m1.js +0 -4
  86. package/dist/assets/player-overlays-qQtL3R3x.js +0 -1
  87. package/dist/assets/remoteEntry-8rDXSjWr.js +0 -1
  88. package/dist/assets/src-7IUwldLv.js +0 -349
  89. package/dist/assets/src-BmWsPY_X.js +0 -67
  90. package/dist/assets/useEventInvalidation-Di2L5Q4I.js +0 -1
  91. package/dist/assets/user-round-D8PF17Sf.js +0 -1
@@ -5361,7 +5361,7 @@ var ZodIssueCode = {
5361
5361
  var ZodFirstPartyTypeKind;
5362
5362
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5363
5363
  //#endregion
5364
- //#region ../types/dist/sleep-BDR76Ykr.mjs
5364
+ //#region ../types/dist/sleep-vl6nBE8d.mjs
5365
5365
  /**
5366
5366
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5367
5367
  * window to float samples (D455).
@@ -28705,14 +28705,81 @@ DeviceType.Camera, method(object({ deviceId: number() }), PrivacyMaskOptionsSche
28705
28705
  kind: "mutation",
28706
28706
  auth: "admin"
28707
28707
  });
28708
+ /**
28709
+ * What a preset id DOES on this camera.
28710
+ *
28711
+ * On several PTZ firmwares the preset namespace is shared: low ids are stored
28712
+ * positions, a reserved band triggers camera FUNCTIONS. The dispensa camera
28713
+ * (Hikvision) returns its own reserved band in the preset list, named by the
28714
+ * firmware:
28715
+ *
28716
+ * 34 Back to origin · 39 Day mode · 40 Night mode · 46 Day/Night Auto Mode
28717
+ * 92 Set manual limits · 93 Save manual limits · 94 Remote reboot
28718
+ * 95 Call OSD menu
28719
+ *
28720
+ * We used to hand all of these to the UI as ordinary presets. Saving over one
28721
+ * is what produced `PUT /ISAPI/PTZCtrl/channels/1/presets/34 -> HTTP 500`: the
28722
+ * camera refusing to let "Back to origin" be overwritten, surfaced to the
28723
+ * operator as a transport failure.
28724
+ *
28725
+ * A function preset stays fully usable as a DESTINATION -- `goToPreset('34')`
28726
+ * is the single most useful thing that camera can do. Only `savePreset` and
28727
+ * `deletePreset` are gated.
28728
+ */
28729
+ var PtzPresetFunctionSchema = _enum([
28730
+ "home",
28731
+ "day-mode",
28732
+ "night-mode",
28733
+ "day-night-auto",
28734
+ "set-limits",
28735
+ "save-limits",
28736
+ "reboot",
28737
+ "osd-menu"
28738
+ ]);
28708
28739
  var PtzPresetSchema = object({
28709
28740
  id: string(),
28710
- name: string()
28741
+ name: string(),
28742
+ /**
28743
+ * The firmware function this id performs, when the provider KNOWS the id is
28744
+ * reserved. `null` = an ordinary stored position, OR a reserved id this
28745
+ * provider does not recognise -- the two are told apart by `writable`.
28746
+ */
28747
+ fn: PtzPresetFunctionSchema.nullable(),
28748
+ /**
28749
+ * Whether `savePreset` / `deletePreset` may target this id. A provider sets
28750
+ * it false only for a band it KNOWS is reserved; where the firmware is not
28751
+ * documented it stays true and a refusal comes from the camera, named.
28752
+ */
28753
+ writable: boolean()
28711
28754
  });
28755
+ /**
28756
+ * Where the head is pointing -- per axis, and `null` when the driver cannot
28757
+ * read it.
28758
+ *
28759
+ * It used to be three REQUIRED numbers, which left a provider that cannot read
28760
+ * position no way to say so. All four said `0`:
28761
+ *
28762
+ * reolink `return { pan: 0, tilt: 0, zoom: 0 }` "until a position-query
28763
+ * path lands upstream"
28764
+ * hikvision stub, "firmware-dependent and frequently absent"
28765
+ * amcrest stub, "no generic absolute-position read for this model family"
28766
+ * onvif throws
28767
+ *
28768
+ * So every consumer asking where a camera points was told "perfectly centred"
28769
+ * by four cameras that had never looked. That is D393 -- a measurement that
28770
+ * FAILED is `null`, never `0`, and the type says so all the way to the
28771
+ * decision -- the same shape as the unreadable `statfs` folded into "0 bytes of
28772
+ * headroom", which evacuated a healthy disk.
28773
+ *
28774
+ * D393 also says to check for a narrower structural TWIN of the result type.
28775
+ * There is one: `PtzStatusSchema` extends this, so the lie had already
28776
+ * propagated into `getStatus`, which is the surface `getPosition`'s own comment
28777
+ * tells callers to migrate to.
28778
+ */
28712
28779
  var PtzPositionSchema = object({
28713
- pan: number(),
28714
- tilt: number(),
28715
- zoom: number()
28780
+ pan: number().nullable(),
28781
+ tilt: number().nullable(),
28782
+ zoom: number().nullable()
28716
28783
  });
28717
28784
  var PtzMoveCommandSchema = object({
28718
28785
  pan: number().optional(),
@@ -28731,7 +28798,72 @@ var PtzOptionsSchema = object({
28731
28798
  maxPresets: number().optional(),
28732
28799
  /** Whether the camera exposes a controllable autofocus toggle
28733
28800
  * (boolean `hasX` per the getOptions availability convention). */
28734
- hasAutofocus: boolean()
28801
+ hasAutofocus: boolean(),
28802
+ /**
28803
+ * How many distinct speeds this camera's NATIVE scale offers.
28804
+ *
28805
+ * The cap's `speed` is normalized 0..1 and each provider maps it down --
28806
+ * Baichuan 1..63, Dahua 1..8, ISAPI's percentage -100..100. The normalized
28807
+ * value hides how coarse that really is: asking an amcrest for `0.37` is
28808
+ * meaningless, because it has eight steps and three of them round to the
28809
+ * same one. A loop that tunes its own gain has to know the granularity of
28810
+ * the knob it is turning.
28811
+ *
28812
+ * `null` = the driver does not know, or the scale is continuous (ONVIF takes
28813
+ * a float). Never a made-up number.
28814
+ */
28815
+ speedSteps: number().int().positive().nullable(),
28816
+ /**
28817
+ * How long ONE `move` pulse runs on this driver, ms.
28818
+ *
28819
+ * `move` is a self-terminating burst everywhere, but every provider hardcoded
28820
+ * its own duration in private -- 200 reolink, 350 amcrest, 500 hikvision,
28821
+ * 1000 onvif -- so no caller could read it. It is the DENOMINATOR of "how far
28822
+ * did the head travel per pulse": without it a measured displacement has no
28823
+ * gain to be divided into.
28824
+ *
28825
+ * `null` = the driver cannot say.
28826
+ */
28827
+ moveImpulseMs: number().int().positive().nullable()
28828
+ });
28829
+ /**
28830
+ * Which preset `goHome` goes to, and WHO decided.
28831
+ *
28832
+ * `goHome` used to be three vendor "conventions" written in three comments --
28833
+ * Reolink preset 0, Hikvision preset '1', Dahua preset 1 -- and on this fleet
28834
+ * not one of the three cameras honours its own:
28835
+ *
28836
+ * 592 Videocamera camera Daniel (reolink) preset 0 holds "stanza"
28837
+ * 1438 Videocamera dispensa (hikvision) preset 1 holds "Credenza"
28838
+ * 3836 Videocamera studio (amcrest) preset 1 holds "Preset1"
28839
+ *
28840
+ * So `goHome` meant "go wherever the operator happened to save in slot 0 or 1",
28841
+ * and two of the three swallowed the failure in a bare `catch`. For autotrack
28842
+ * this is the HOTTEST path -- it runs every time a subject is released -- so it
28843
+ * needs an answer that is true per camera and audible when it is missing.
28844
+ *
28845
+ * `source` is what makes it honest:
28846
+ * - `operator` -- picked in the UI, stored by the provider.
28847
+ * - `firmware` -- the camera itself named a preset `fn: 'home'` (Hikvision's
28848
+ * "Back to origin"), adopted as the default with nothing to configure.
28849
+ * - `native` -- the driver homes WITHOUT a preset at all. ONVIF does:
28850
+ * `goHome` is `ptzAbsoluteMove({x:0, y:0, zoom:0})`. `presetId` is null and
28851
+ * that is not a failure -- there is nothing to pick, and the UI must offer
28852
+ * no picker.
28853
+ * - `none` -- nothing is configured and the camera names nothing.
28854
+ * `goHome` REFUSES rather than moving the head somewhere arbitrary.
28855
+ *
28856
+ * `source === 'none'` is the refusal condition, NOT `presetId === null`: the
28857
+ * native case has no preset and homes perfectly well.
28858
+ */
28859
+ var PtzHomePresetSchema = object({
28860
+ presetId: string().nullable(),
28861
+ source: _enum([
28862
+ "operator",
28863
+ "firmware",
28864
+ "native",
28865
+ "none"
28866
+ ])
28735
28867
  });
28736
28868
  DeviceType.Camera, method(PtzMoveCommandSchema.extend({ deviceId: number() }), _void(), { kind: "mutation" }), method(PtzMoveCommandSchema.extend({ deviceId: number() }), _void(), { kind: "mutation" }), method(object({ deviceId: number() }), _void(), { kind: "mutation" }), method(object({ deviceId: number() }), array(PtzPresetSchema)), method(object({
28737
28869
  deviceId: number(),
@@ -28749,7 +28881,22 @@ DeviceType.Camera, method(PtzMoveCommandSchema.extend({ deviceId: number() }), _
28749
28881
  }), _void(), {
28750
28882
  kind: "mutation",
28751
28883
  auth: "admin"
28752
- }), method(object({ deviceId: number() }), PtzOptionsSchema), method(object({ deviceId: number() }), _void(), { kind: "mutation" }), method(object({ deviceId: number() }), PtzPositionSchema), method(object({
28884
+ }), method(object({ deviceId: number() }), PtzOptionsSchema), method(object({ deviceId: number() }), _void(), { kind: "mutation" }), method(object({ deviceId: number() }), PtzHomePresetSchema), method(object({
28885
+ deviceId: number(),
28886
+ presetId: string().nullable()
28887
+ }), _void(), {
28888
+ kind: "mutation",
28889
+ auth: "admin"
28890
+ }), method(object({ deviceId: number() }), _void(), {
28891
+ kind: "mutation",
28892
+ auth: "admin"
28893
+ }), method(object({ deviceId: number() }), number().int().nullable()), method(object({
28894
+ deviceId: number(),
28895
+ seconds: number().int().min(0).max(3600)
28896
+ }), _void(), {
28897
+ kind: "mutation",
28898
+ auth: "admin"
28899
+ }), method(object({ deviceId: number() }), PtzPositionSchema), method(object({
28753
28900
  deviceId: number(),
28754
28901
  enabled: boolean()
28755
28902
  }), _void(), { kind: "mutation" });
@@ -35752,6 +35899,12 @@ Object.freeze({
35752
35899
  addonId: null,
35753
35900
  access: "create"
35754
35901
  },
35902
+ "ptz.captureHomeHere": {
35903
+ capName: "ptz",
35904
+ capScope: "device",
35905
+ addonId: null,
35906
+ access: "create"
35907
+ },
35755
35908
  "ptz.continuousMove": {
35756
35909
  capName: "ptz",
35757
35910
  capScope: "device",
@@ -35764,6 +35917,18 @@ Object.freeze({
35764
35917
  addonId: null,
35765
35918
  access: "delete"
35766
35919
  },
35920
+ "ptz.getHomePreset": {
35921
+ capName: "ptz",
35922
+ capScope: "device",
35923
+ addonId: null,
35924
+ access: "view"
35925
+ },
35926
+ "ptz.getHomeReturnSeconds": {
35927
+ capName: "ptz",
35928
+ capScope: "device",
35929
+ addonId: null,
35930
+ access: "view"
35931
+ },
35767
35932
  "ptz.getOptions": {
35768
35933
  capName: "ptz",
35769
35934
  capScope: "device",
@@ -35812,6 +35977,18 @@ Object.freeze({
35812
35977
  addonId: null,
35813
35978
  access: "create"
35814
35979
  },
35980
+ "ptz.setHomePreset": {
35981
+ capName: "ptz",
35982
+ capScope: "device",
35983
+ addonId: null,
35984
+ access: "create"
35985
+ },
35986
+ "ptz.setHomeReturnSeconds": {
35987
+ capName: "ptz",
35988
+ capScope: "device",
35989
+ addonId: null,
35990
+ access: "create"
35991
+ },
35815
35992
  "ptz.stop": {
35816
35993
  capName: "ptz",
35817
35994
  capScope: "device",
@@ -38975,6 +39152,11 @@ Object.freeze({
38975
39152
  form: "single",
38976
39153
  optional: false
38977
39154
  }],
39155
+ "ptz.captureHomeHere": [{
39156
+ name: "deviceId",
39157
+ form: "single",
39158
+ optional: false
39159
+ }],
38978
39160
  "ptz.continuousMove": [{
38979
39161
  name: "deviceId",
38980
39162
  form: "single",
@@ -38985,6 +39167,16 @@ Object.freeze({
38985
39167
  form: "single",
38986
39168
  optional: false
38987
39169
  }],
39170
+ "ptz.getHomePreset": [{
39171
+ name: "deviceId",
39172
+ form: "single",
39173
+ optional: false
39174
+ }],
39175
+ "ptz.getHomeReturnSeconds": [{
39176
+ name: "deviceId",
39177
+ form: "single",
39178
+ optional: false
39179
+ }],
38988
39180
  "ptz.getOptions": [{
38989
39181
  name: "deviceId",
38990
39182
  form: "single",
@@ -39025,6 +39217,16 @@ Object.freeze({
39025
39217
  form: "single",
39026
39218
  optional: false
39027
39219
  }],
39220
+ "ptz.setHomePreset": [{
39221
+ name: "deviceId",
39222
+ form: "single",
39223
+ optional: false
39224
+ }],
39225
+ "ptz.setHomeReturnSeconds": [{
39226
+ name: "deviceId",
39227
+ form: "single",
39228
+ optional: false
39229
+ }],
39028
39230
  "ptz.stop": [{
39029
39231
  name: "deviceId",
39030
39232
  form: "single",
@@ -40078,7 +40280,7 @@ var AdminUIAddon = class extends BaseAddon {
40078
40280
  capability: adminUiCapability,
40079
40281
  provider: {
40080
40282
  getStaticDir: async () => ({ staticDir: resolveAdminUiDistDir() }),
40081
- getVersion: async () => ({ version: "1.2.211" })
40283
+ getVersion: async () => ({ version: "1.2.213" })
40082
40284
  }
40083
40285
  }];
40084
40286
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-admin-ui",
3
- "version": "1.2.211",
3
+ "version": "1.2.213",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Admin UI — Vite frontend build and server-side addon",
@@ -1 +0,0 @@
1
- import{S as e,x as t}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{gt as n,ht as r,ut as i}from"./player-overlays-qQtL3R3x.js";import{$c as a,Ic as o,Kc as s,Vc as c,au as l,el as u,jl as d,nu as f,ql as p,su as m,vc as h,zl as g}from"./src-BmWsPY_X.js";import{t as _}from"./grid-2x2-G4yOYg6v.js";import{t as v}from"./video-BnWAdQdw.js";var y=n(`map`,[[`path`,{d:`M14.106 5.553a2 2 0 0 0 1.788 0l3.659-1.83A1 1 0 0 1 21 4.619v12.764a1 1 0 0 1-.553.894l-4.553 2.277a2 2 0 0 1-1.788 0l-4.212-2.106a2 2 0 0 0-1.788 0l-3.659 1.83A1 1 0 0 1 3 19.381V6.618a1 1 0 0 1 .553-.894l4.553-2.277a2 2 0 0 1 1.788 0z`,key:`169xi5`}],[`path`,{d:`M15 5.764v15`,key:`1pn4in`}],[`path`,{d:`M9 3.236v15`,key:`1uimfh`}]]),b={streaming:{icon:v,label:`Streaming`},detection:{icon:d,label:`Detection`},recording:{icon:p,label:`Recording`},audio:{icon:i,label:`Audio`},snapshot:{icon:r,label:`Snapshot`},motion:{icon:h,label:`Motion`},ptz:{icon:s,label:`PTZ`},webrtc:{icon:u,label:`WebRTC`},onvif:{icon:c,label:`ONVIF`},analytics:{icon:g,label:`Analytics`},"battery-operated":{icon:m,label:`Battery`},"native-snapshot":{icon:r,label:`Native Snapshot`},"pan-tilt-zoom":{icon:s,label:`PTZ`},"two-way-audio":{icon:i,label:`Two-way Audio`},"doorbell-button":{icon:l,label:`Doorbell`},rebootable:{icon:a,label:`Rebootable`},"vacuum-has-map":{icon:y,label:`Map`},"vacuum-has-ai":{icon:o,label:`AI Obstacle`},"mower-has-map":{icon:y,label:`Map`},"mower-has-targeted-mowing":{icon:_,label:`Targeted Mowing`}},x=f;function S({capabilities:n,showLabels:r=!1}){return t(`div`,{className:`flex items-center gap-1 flex-wrap`,children:n.map(n=>{let i=b[n],a=i?.icon??x,o=i?.label??n;return e(`span`,{className:`inline-flex items-center gap-1 rounded-md bg-surface-hover px-1.5 py-0.5 text-[10px] text-foreground-subtle`,title:o,children:[t(a,{className:`h-3 w-3`}),r&&t(`span`,{children:o})]},n)})})}export{S as t};
@@ -1,2 +0,0 @@
1
- import{I as e,K as t,Q as n,S as r,W as i,a,b as o,o as s,q as c,t as l,x as u,z as d}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{G as f,X as p,at as m,gt as h,ht as g,lt as _,o as v,q as y,r as b,s as x,st as S,t as C,y as w}from"./player-overlays-qQtL3R3x.js";import{$c as T,$l as E,$t as D,A as O,B as k,Bt as ee,Cc as A,D as j,Do as te,Ea as ne,Eo as re,Er as M,Fr as N,G as P,H as F,I as ie,J as ae,Ji as I,Jl as L,Jo as oe,Jr as se,Jt as R,K as z,Kl as B,M as ce,No as le,O as V,P as H,Qc as ue,Qr as U,Qt as de,Rc as fe,Rl as W,Rr as pe,Rt as me,Sc as G,Ta as K,Tr as he,Ur as ge,V as _e,Vi as ve,Vt as ye,W as be,Wr as q,X as xe,Xr as Se,Y as J,Yc as Ce,Yi as we,Zr as Te,Zt as Ee,_i as De,_l as Oe,_t as ke,_u as Ae,a as je,an as Me,ao as Ne,au as Pe,b as Fe,bt as Ie,c as Le,cl as Re,ct as ze,d as Be,dl as Ve,el as He,es as Ue,f as We,fc as Ge,fi as Ke,ft as qe,gt as Je,ht as Ye,i as Xe,in as Ze,is as Qe,j as $e,k as et,l as tt,ll as nt,ln as rt,lt as it,mo as at,mt as ot,nl as st,nt as ct,o as lt,oi as ut,ol as dt,on as ft,ou as pt,pi as mt,pl as ht,pt as gt,q as _t,qc as vt,qi as yt,qr as Y,r as bt,ri as xt,rt as St,s as Ct,so as wt,ti as Tt,tr as Et,u as Dt,ul as Ot,uo as kt,ut as At,v as jt,vi as Mt,vl as Nt,vt as Pt,wc as Ft,wl as It,x as Lt,xi as Rt,y as zt,ya as Bt,yc as Vt,yi as Ht,z as Ut,zl as Wt,zn as Gt,zt as Kt}from"./src-BmWsPY_X.js";import{t as qt}from"./bell-off-BBo4kutk.js";import{t as Jt}from"./boxes-Bg9iqtyH.js";import{t as Yt}from"./ProviderIcon-RcyRCpwL.js";import{t as Xt}from"./circle-slash-CMIlCEyU.js";import{c as Zt,n as Qt,s as $t}from"./NodeInferenceDevices-q5gpemLH.js";import{t as en}from"./layers-BxvBcSbK.js";import{t as tn}from"./CapabilityBadges-B8jx5YjN.js";import{Jt as nn,Xt as rn,Yt as an,a as on,bt as X,i as sn,qt as cn,vt as ln}from"./src-7IUwldLv.js";import{a as un,c as dn,n as fn,o as pn,s as mn,u as hn}from"./index-j_wfe7m1.js";import{t as gn}from"./authed-media-B4sv3G7D.js";import"./useEventInvalidation-Di2L5Q4I.js";import{t as _n}from"./StatusBadge-CeptlsPG.js";import{t as vn}from"./use-stationary-objects-BhlIRr4y.js";import{i as yn,n as bn,r as xn,t as Sn}from"./DeviceAggregateSection-ebT0fjdy.js";var Cn=h(`arrow-left-right`,[[`path`,{d:`M8 3 4 7l4 4`,key:`9rb6wj`}],[`path`,{d:`M4 7h16`,key:`6tx8e3`}],[`path`,{d:`m16 21 4-4-4-4`,key:`siv7j2`}],[`path`,{d:`M20 17H4`,key:`h6l3hr`}]]),wn=h(`disc`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`circle`,{cx:`12`,cy:`12`,r:`2`,key:`1c9p78`}]]),Tn=h(`ear`,[[`path`,{d:`M6 8.5a6.5 6.5 0 1 1 13 0c0 6-6 6-6 10a3.5 3.5 0 1 1-7 0`,key:`1dfaln`}],[`path`,{d:`M15 8.5a2.5 2.5 0 0 0-5 0v1a2 2 0 1 1 0 4`,key:`1qnva7`}]]);n();var En=[{id:`object-detection`,label:`Object detection`,costWhenOff:`No detections, tracks or detection-driven notifications for this camera.`,capName:an},{id:`audio-analysis`,label:`Audio analysis`,costWhenOff:`No audio events (glass, alarm, speech) and no audio-driven notifications.`,capName:cn}],Dn=`Recording`,On=`Nothing new is written to disk — live still works, existing footage is kept.`;function kn(e,t){let{bindings:n,bindable:r}=t,i=n===null?void 0:n.find(t=>t.capName===e.capName&&t.kind===`wrapped`),a=r?.find(t=>t.capName===e.capName)?.wrappers[0],o=i!==void 0&&i.providerAddonId!==``?i.providerAddonId:a??null,s=n===null?null:i!==void 0;return{id:e.id,label:e.label,costWhenOff:e.costWhenOff,on:s,available:s!==null&&o!==null,capName:e.capName,wrapperAddonId:o}}function An(e,t,n,r){let i=e.entries.filter(e=>e.capName!==t);return r?{...e,entries:[...i,{capName:t,kind:`wrapped`,providerAddonId:n}]}:{...e,entries:i}}function jn(e,t){let n=e.filter(e=>e.on===!1).map(e=>e.id),r=e.filter(e=>e.on===null).map(e=>e.id),i=t=>t.map(t=>e.find(e=>e.id===t)?.label??t).join(`, `),a=[];return n.length>0&&a.push(`Off: ${i(n)}`),r.length>0&&a.push(`Unknown: ${i(r)}`),{layout:t?`menu`:`inline`,offIds:n,unknownIds:r,summary:a.length===0?`All camera functions on`:a.join(` · `)}}function Mn(e){let t=En.map(t=>kn(t,e)),n={id:`recording`,label:Dn,costWhenOff:On,on:e.recordingEnabled,available:e.recordingEnabled!==null,capName:null,wrapperAddonId:null};return[...t,n]}var Nn={"object-detection":hn,"audio-analysis":Tn,recording:wn};function Pn(e){if(typeof e!=`object`||!e)return!1;let t={...e};return typeof t.enabled==`boolean`&&Array.isArray(t.bands)}function Fn(e){if(typeof e!=`object`||!e)return!1;let t={...e};return typeof t.deviceId==`number`&&Array.isArray(t.entries)}function In(e){return Fn(e)?e.entries:null}function Ln(e){if(!Array.isArray(e))return null;let t=[];for(let n of e){if(typeof n!=`object`||!n)continue;let e={...n},r=e.capName,i=e.wrappers;typeof r!=`string`||!Array.isArray(i)||t.push({capName:r,wrappers:i.filter(e=>typeof e==`string`)})}return t}function Rn({deviceId:t}){let n=s(),i=Number.isFinite(t),[a,o]=c(null),[l,d]=c(!1),f=q({deviceId:t},{enabled:i}),p=U({deviceType:X.Camera},{enabled:i}),m=Ue({deviceId:t},{enabled:i,retry:!1});bt([`deviceManager`,`getBindings`],[`capability.binding-changed`]);let h=[[`deviceManager`,`getBindings`],{input:{deviceId:t}}],g=[[`recording`,`getDeviceConfig`],{input:{deviceId:t}}],_=m.data,v=Pn(_)?_:null,y=Mn({bindings:In(f.data),bindable:Ln(p.data),recordingEnabled:v===null?null:v.enabled}),b=Rt({onError:(e,r)=>{let i=r.capName===y[1]?.capName?`audio-analysis`:`object-detection`;console.error(`[CameraFunctionSwitches] wrapper write failed — reverting`,{tags:{deviceId:t},meta:{capName:r.capName,error:e instanceof Error?e.message:String(e)}}),n.invalidateQueries({queryKey:[[`deviceManager`,`getBindings`]]}),o({id:i,message:e instanceof Error?e.message:String(e)})},onSuccess:()=>{o(null),n.invalidateQueries({queryKey:[[`deviceManager`]]}),n.invalidateQueries({queryKey:[[`pipelineOrchestrator`]]})}}),x=Qe({onError:e=>{console.error(`[CameraFunctionSwitches] recording write failed — reverting`,{tags:{deviceId:t},meta:{error:e instanceof Error?e.message:String(e)}}),n.invalidateQueries({queryKey:[[`recording`,`getDeviceConfig`]]}),o({id:`recording`,message:e instanceof Error?e.message:String(e)})},onSuccess:()=>{o(null),n.invalidateQueries({queryKey:[[`recording`]]}),n.invalidateQueries({queryKey:[[`pipelineOrchestrator`]]})}}),S=e(e=>{if(!e.available||e.on===null)return;let r=!e.on;if(e.id===`recording`){if(v===null)return;n.setQueryData(g,{...v,enabled:r}),x.mutate({deviceId:t,config:{...v,enabled:r}});return}let{capName:i,wrapperAddonId:a}=e;if(i===null||a===null)return;let o=n.getQueryData(h);Fn(o)&&n.setQueryData(h,An(o,i,a,r)),b.mutate({deviceId:t,capName:i,wrapperAddonId:a,active:r})},[h,t,n,v,g,x,b]),C=jn(y,Ie()),w=e=>a?.id===e.id?a.message:null;return C.layout===`menu`?r(Je,{open:l,onOpenChange:d,children:[r(Pt,{"aria-label":`Camera functions`,title:C.summary,className:`inline-flex items-center gap-1 rounded-lg border px-2 py-1.5 text-[11px] font-medium transition-colors ${a===null?C.offIds.length>0?`border-warning/40 text-warning hover:bg-warning/10`:`border-border text-foreground-subtle hover:text-foreground hover:bg-surface-hover`:`border-danger/50 text-danger bg-danger/5`}`,children:[u(fe,{className:`h-3.5 w-3.5`}),C.offIds.length>0&&r(`span`,{className:`rounded bg-warning/20 px-1 text-[9px] font-semibold uppercase tracking-wide`,children:[C.offIds.length,` off`]})]}),r(ke,{className:`left-auto right-0 mt-1 min-w-[240px] p-1`,children:[u(`div`,{className:`px-2 py-1 text-[10px] uppercase tracking-wider text-foreground-subtle`,children:`Camera functions`}),u(`ul`,{className:`space-y-0.5`,children:y.map(e=>u(`li`,{children:u(zn,{state:e,failure:w(e),onToggle:()=>S(e)})},e.id))})]})]}):u(`div`,{className:`flex items-center gap-1`,children:y.map(e=>u(Bn,{state:e,failure:w(e),onToggle:()=>S(e)},e.id))})}function zn({state:e,failure:t,onToggle:n}){let i=Nn[e.id],a=e.on===null,o=e.on===!1;return r(`button`,{type:`button`,role:`switch`,"aria-label":e.label,"aria-checked":e.on===!0,disabled:!e.available,onClick:n,title:a?`${e.label} — state unknown; the source that owns it did not answer.`:t===null?e.costWhenOff:`Last write failed: ${t}`,className:`flex w-full items-start gap-2 rounded-md px-2 py-1.5 text-left text-[12px] text-foreground transition-colors hover:bg-surface-hover disabled:opacity-40 disabled:cursor-not-allowed`,children:[u(i,{className:`h-3.5 w-3.5 shrink-0 mt-0.5 ${t===null?a?`text-foreground-subtle/50`:o?`text-warning`:`text-success`:`text-danger`}`}),r(`span`,{className:`flex-1 min-w-0`,children:[u(`span`,{className:`block leading-tight`,children:e.label}),u(`span`,{className:`block mt-0.5 text-[10px] text-foreground-subtle leading-tight`,children:t===null?a?`Unknown`:e.costWhenOff:`Write failed: ${t}`})]}),u(`span`,{className:`shrink-0 rounded px-1 py-0.5 text-[9px] font-semibold uppercase tracking-wide ${a?`bg-surface-hover text-foreground-subtle/60`:o?`bg-warning/20 text-warning`:`bg-success/20 text-success`}`,children:a?`—`:o?`off`:`on`})]})}function Bn({state:e,failure:t,onToggle:n}){let i=Nn[e.id],a=e.on===null,o=e.on===!1,s=a?`${e.label} — state unknown; the source that owns it did not answer.`:o?`${e.label} is OFF. ${e.costWhenOff}`:`${e.label} is on. Turning it off: ${e.costWhenOff}`;return r(`button`,{type:`button`,role:`switch`,"aria-label":e.label,"aria-checked":e.on===!0,disabled:!e.available,onClick:n,title:t===null?s:`${s} — last write failed: ${t}`,className:`inline-flex items-center gap-1 rounded-lg border px-1.5 sm:px-2 py-1.5 text-[11px] font-medium transition-colors disabled:cursor-not-allowed ${t===null?a?`border-dashed border-border text-foreground-subtle/50`:o?`border-warning/40 text-warning hover:bg-warning/10`:`border-success/30 text-success hover:bg-success/10`:`border-danger/50 text-danger bg-danger/5`}`,children:[u(i,{className:`h-3.5 w-3.5`}),u(`span`,{className:`hidden lg:inline`,children:e.label}),o&&u(`span`,{className:`rounded bg-warning/20 px-1 text-[9px] font-semibold uppercase tracking-wide`,children:`off`})]})}function Vn({parentDeviceId:e}){let{t}=fn(),n=un(),i=m(),{data:a,isLoading:o,isError:s}=Zt(e),{data:c}=Y({deviceId:e},{enabled:Number.isFinite(e)});if(o)return u(`div`,{className:`rounded-lg border border-border bg-surface p-3`,children:u(`p`,{className:`text-[10px] text-foreground-subtle`,children:t(`common.loading`,{defaultValue:`Loading…`})})});if(s)return u(`div`,{className:`rounded-lg border border-border bg-surface p-3`,children:u(`p`,{className:`text-[10px] text-warning`,children:t(`integrations.childrenLoadError`,{defaultValue:`Failed to load children`})})});let l=(a??[]).filter(e=>e.display?.hidden!==!0);if(l.length===0)return null;let d=et(c?.stableId??``,l,c?.childLayout),f=d.ungrouped,p=e=>n(`/devices/${String(e)}`),h=c?.name??``,g=(e,t)=>u(j,{trpc:i.trpcClient,device:{...t,name:ce(t,h)},variant:`minimal`,onNavigate:p},e),_=f.some(e=>!!e.role),v=f.some(e=>!e.role),y=_&&!v?t(`device.accessories`,{defaultValue:`Accessories`}):!_&&v?t(`device.adoptedDevices`,{defaultValue:`Adopted devices`}):t(`device.children`,{defaultValue:`Children`}),b=f.length>0?r(`div`,{className:`rounded-lg border border-border bg-surface p-3`,children:[u(`div`,{className:`text-[10px] font-semibold uppercase tracking-wide text-foreground-subtle mb-1.5`,children:y}),u(`div`,{className:`space-y-1`,children:f.map(e=>g(e.id,e))})]}):null,x=d.disabledSection===void 0?null:u(V,{title:t(`device.disabledSection`,{defaultValue:`Disabled`}),count:d.disabledSection.children.length,defaultOpen:!1,children:u(`div`,{className:`opacity-60 space-y-1`,children:d.disabledSection.children.map(e=>g(e.id,e))})},d.disabledSection.title);if(d.sections.length===0)return x===null?b:r(`div`,{className:`space-y-2`,children:[b,x]});let S=v&&!_;return r(`div`,{className:`space-y-2`,children:[S?b:null,d.sections.map(e=>u(V,{title:e.title,count:e.children.length,defaultOpen:e.defaultOpen,children:e.children.map(e=>g(e.id,e))},e.title)),S?null:b,x]})}function Hn({deviceId:e}){let t=m(),{data:n,isLoading:r}=$t(e),{data:i,isLoading:a}=Zt(e),o=r||a,s=(i??[]).map(e=>({id:e.id,stableId:e.stableId,type:e.type,name:e.name,features:e.features,...e.sourceInfo?{sourceInfo:{id:e.sourceInfo.id}}:{}})),c=typeof n?.linkDeviceId==`number`?n.linkDeviceId:null,l=typeof n?.primaryChildEntityId==`string`?n.primaryChildEntityId:null;return o?u(`div`,{className:`h-full min-h-32 w-full animate-pulse rounded-lg bg-surface`,"aria-hidden":`true`}):u(`div`,{className:`flex h-full w-full flex-col`,children:u(k,{trpc:t.trpcClient,children:s,linkDeviceId:c,primaryChildEntityId:l})})}n();function Un({dev:e,busy:t,setBusy:n}){let i=e?.motionTrigger,a=y(e?.state.motionTrigger),[o,s]=c(!1);if(!i)return null;let l=a?.enabled===!0,d=a!==void 0,f=async()=>{if(t||!d)return;let e=!l;n(!0),s(!0);try{await i.setMotionTrigger({enabled:e})}finally{n(!1),s(!1)}};return r(`button`,{type:`button`,onClick:()=>{f()},disabled:t||!d,title:d?l?`Disable trigger on motion`:`Enable trigger on motion`:`Awaiting state…`,"aria-pressed":l,className:`inline-flex items-center gap-1.5 rounded-full border px-2.5 py-1 text-[11px] font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-50 ${l?`border-primary/50 bg-primary/15 text-primary`:`border-border bg-surface text-foreground-subtle hover:text-foreground`}`,children:[u(Ae,{className:`h-3 w-3`}),u(`span`,{children:o?l?`Disabling…`:`Enabling…`:d?l?`On motion: on`:`On motion: off`:`On motion: …`})]})}n();function Z({deviceId:e,deviceType:t,features:n}){let i=m(),a=be(t)?.HeroCard??P,o=f(i.trpcClient,e),s=y(o?.state.deviceStatus),[l,d]=c(!1),p=s!==void 0&&s.online===!1,h=p?s.lastChangedAt:null;return r(`div`,{className:`flex h-full w-full flex-col items-stretch gap-3 p-3 sm:p-4`,children:[p?u(`div`,{className:`flex justify-center`,children:u(F,{lastChangedAt:h})}):null,u(a,{trpc:i.trpcClient,deviceId:e,features:n}),u(`div`,{className:`flex justify-center`,children:u(Un,{dev:o,busy:l,setBusy:d})})]})}function Wn({deviceId:e,features:t}){return u(`div`,{className:`flex h-full w-full flex-col items-stretch gap-3 p-3 sm:p-4`,children:u(z,{trpc:m().trpcClient,deviceId:e,features:t})})}function Gn({deviceId:e,features:t}){return u(`div`,{className:`flex h-full w-full flex-col items-stretch p-3 sm:p-4`,children:u(P,{trpc:m().trpcClient,deviceId:e,features:t})})}function Kn(e){if(!e)return null;let t=e.channel;return typeof t!=`number`||!Number.isInteger(t)||t<0?null:t}function qn(e){if(!e)return null;let t=Kn(e.data);return t===null?e.eventType:`Button ${String(t)} · ${e.eventType}`}var Jn=1e3,Yn=60*Jn,Xn=60*Yn,Zn=24*Xn;function Qn(e,t){if(e==null||e<=0)return`—`;let n=t-e;return n<Jn?`just now`:n<Yn?`${String(Math.floor(n/Jn))}s ago`:n<Xn?`${String(Math.floor(n/Yn))}m ago`:n<Zn?`${String(Math.floor(n/Xn))}h ago`:`${String(Math.floor(n/Zn))}d ago`}n();var $n=1500,er=15e3,tr=1e3;function nr({deviceId:e}){let n=f(m().trpcClient,e)?.state.eventEmitter,i=y(n);d(()=>{if(!n)return;n.refresh();let e=setInterval(()=>{n.refresh()},er);return()=>{clearInterval(e)}},[n]);let a=i?.lastEvent??null,o=a?.seq??null,s=t(null),[l,p]=c(!1);d(()=>{if(o===null)return;let e=s.current;if(s.current=o,e===null||e===o)return;p(!0);let t=setTimeout(()=>{p(!1)},$n);return()=>{clearTimeout(t)}},[o]);let[h,g]=c(()=>Date.now());d(()=>{let e=setInterval(()=>{g(Date.now())},tr);return()=>{clearInterval(e)}},[]);let _=qn(a),v=i?.eventTypes??[],b=i?.eventCountSinceStart??0,x=i!==void 0,S=Kn(a?.data);return r(`div`,{className:`flex h-full w-full flex-col items-center justify-center gap-3 p-4`,children:[u(`div`,{"data-testid":`event-emitter-indicator`,"data-flashing":String(l),className:`flex h-24 w-24 items-center justify-center rounded-full border-2 transition-all ${l?`border-primary bg-primary/20 text-primary shadow-lg shadow-primary/30 scale-105`:`border-border bg-surface text-foreground-subtle`}`,"aria-live":`polite`,title:_??`No press recorded`,children:u(l?nt:It,{className:`h-10 w-10`})}),r(`div`,{className:`text-center`,children:[S!==null&&u(`div`,{className:`text-xs font-semibold uppercase tracking-wide text-primary`,children:`Button ${String(S)}`}),u(`div`,{"data-testid":`event-emitter-headline`,className:`text-sm font-semibold ${_?`text-foreground`:`text-foreground-subtle`}`,children:_??(x?`No press recorded`:`Awaiting state…`)}),u(`div`,{className:`text-[10px] text-foreground-subtle mt-0.5`,children:a?Qn(a.timestamp,h):`Waiting for the first event`})]}),v.length>0&&u(`div`,{className:`flex max-w-full flex-wrap justify-center gap-1`,children:v.map(e=>u(`span`,{"data-testid":`event-emitter-chip`,className:`rounded-full border px-2 py-0.5 text-[10px] font-medium ${e===a?.eventType?`border-primary bg-primary/15 text-primary`:`border-border bg-surface text-foreground-subtle`}`,children:e},e))}),u(`div`,{className:`text-[10px] text-foreground-subtle`,children:`${String(b)} ${b===1?`event`:`events`} since start`})]})}function rr({deviceName:e,deviceType:t,provider:n,isOnline:i,features:a}){return r(`div`,{className:`flex h-full w-full flex-col items-center justify-center gap-3 rounded-lg border border-dashed border-border bg-surface p-6 text-center`,children:[u(Yt,{type:n,size:`lg`}),r(`div`,{children:[u(`div`,{className:`text-sm font-semibold text-foreground`,children:e}),u(`div`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wider mt-0.5`,children:t})]}),r(`div`,{className:`flex items-center gap-2 flex-wrap justify-center`,children:[u(_n,{status:i?`online`:`offline`}),a.length>0&&u(tn,{capabilities:a})]}),u(`div`,{className:`text-[10px] text-foreground-subtle italic max-w-xs mt-1`,children:`No live view for this device type. Use the Config tab or the shortcut row to interact.`})]})}n();function ir({deviceId:e}){let t=s(),n=he({deviceId:e},{refetchInterval:1e4,retry:!1}),a=M({onSuccess:()=>{t.invalidateQueries({queryKey:[[`deviceDiscovery`,`listDiscovered`]]}),t.invalidateQueries({queryKey:[[`deviceDiscovery`,`getStatus`]]})}}),o=i(()=>ar(n.data??[]),[n.data]);return r(`div`,{className:`flex h-full w-full flex-col gap-3 p-3 sm:p-4`,children:[r(`div`,{className:`flex flex-wrap items-stretch gap-2 sm:gap-3`,children:[u(or,{label:`Discovered`,value:o.total,icon:u(Re,{className:`h-3.5 w-3.5`})}),u(or,{label:`Adopted`,value:o.adopted,accent:`success`}),u(or,{label:`Available`,value:o.available,accent:o.available>0?`primary`:void 0}),r(`button`,{type:`button`,onClick:()=>{a.mutateAsync({deviceId:e}).catch(()=>{})},disabled:a.isPending,className:`inline-flex items-center justify-center gap-1.5 rounded-lg border border-border px-3 py-2 text-xs font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50 self-stretch shrink-0`,children:[a.isPending?u(Oe,{className:`h-3.5 w-3.5 animate-spin`}):u(T,{className:`h-3.5 w-3.5`}),u(`span`,{className:`hidden sm:inline`,children:`Discover`})]})]}),r(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px] text-foreground-subtle border-t border-border-subtle pt-2`,children:[u(sr,{icon:u(G,{className:`h-3 w-3 text-emerald-500`}),label:`${o.online} online`}),u(sr,{icon:u(Ot,{className:`h-3 w-3 text-amber-500`}),label:`${o.sleeping} sleeping`}),u(sr,{icon:u(A,{className:`h-3 w-3 text-destructive`}),label:`${o.offline} offline`}),o.unknown>0?u(sr,{icon:u(B,{className:`h-3 w-3 text-foreground-subtle`}),label:`${o.unknown} unknown`}):null]})]})}function ar(e){let t={total:e.length,adopted:0,available:0,online:0,sleeping:0,offline:0,unknown:0};for(let n of e)n.alreadyAdopted?t.adopted+=1:t.available+=1,t[n.status]+=1;return t}function or({label:e,value:t,icon:n,accent:i}){return r(`div`,{className:`flex flex-1 basis-[140px] min-w-0 flex-col gap-1 rounded-lg border px-2 py-1.5 sm:px-3 sm:py-2 ${i===`success`?`bg-emerald-500/10 border-emerald-500/30 text-emerald-500`:i===`primary`?`bg-primary/10 border-primary/30 text-primary`:`bg-surface-hover border-border text-foreground`}`,children:[r(`div`,{className:`flex items-center gap-1.5 text-[10px] uppercase tracking-wider opacity-70 truncate`,children:[n,u(`span`,{className:`truncate`,children:e})]}),u(`div`,{className:`text-xl sm:text-2xl font-semibold tabular-nums leading-none`,children:t})]})}function sr({icon:e,label:t}){return r(`span`,{className:`inline-flex items-center gap-1`,children:[e,u(`span`,{children:t})]})}var cr={[X.Switch]:Z,[X.Siren]:Z,[X.Light]:Z,[X.Sensor]:Z,[X.Button]:Z,[X.Hub]:ir,[X.Cover]:Wn,[X.Valve]:Z,[X.Humidifier]:Z,[X.WaterHeater]:Z,[X.Container]:Hn,[X.Lock]:Z,[X.Fan]:Z,[X.Thermostat]:Z,[X.Climate]:Z,[X.MediaPlayer]:Z,[X.Control]:Z,[X.AlarmPanel]:Z,[X.EventEmitter]:nr,[X.Notifier]:Gn,[X.Script]:Z,[X.Automation]:Z,[X.Presence]:Z,[X.Update]:Z,[X.Vacuum]:Z,[X.LawnMower]:Z,[X.Weather]:Z,[X.Image]:Z,[X.PetFeeder]:Z};function lr(e){return cr[e]??rr}function ur(e){return u(lr(e.deviceType),{...e})}function dr(e){return Ct(m().trpcClient,e)}n();function fr(n){let[r,i]=c(`idle`),[a,o]=c(null),s=t(null),l=t(null),u=t(null),f=t(!0),p=I(),m=yt(),h=we(),g=e(()=>{if(s.current){try{s.current.close()}catch{}s.current=null}if(l.current){for(let e of l.current.getTracks())try{e.stop()}catch{}l.current=null}u.current=null},[]),_=e(async()=>{if(r===`idle`)return;i(`stopping`);let e=u.current;if(e&&n!==null)try{await Promise.race([h.mutateAsync({deviceId:n,sessionId:e}),new Promise((e,t)=>setTimeout(()=>t(Error(`server stopSession timeout`)),2e3))])}catch(e){console.warn(`[intercom] server stopSession failed (continuing teardown)`,e)}g(),f.current&&(i(`idle`),o(null))},[r,n,h,g]),v=e(async()=>{if(n===null||r!==`idle`&&r!==`error`)return;o(null);let e=null,t=null,a=null;try{i(`requesting-mic`),e=await navigator.mediaDevices.getUserMedia({audio:!0,video:!1}),l.current=e,i(`starting`);let r=await p.mutateAsync({deviceId:n});a=r.sessionId,u.current=a,i(`connecting`),t=new RTCPeerConnection,s.current=t,t.oniceconnectionstatechange=()=>{if(!f.current)return;let e=t.iceConnectionState;e===`connected`||e===`completed`?i(`talking`):(e===`failed`||e===`closed`||e===`disconnected`)&&f.current&&(o(e===`failed`?`WebRTC connection failed`:null),_())};for(let n of e.getAudioTracks())t.addTrack(n,e);await t.setRemoteDescription({type:`offer`,sdp:r.sdpOffer});let c=await t.createAnswer();await t.setLocalDescription(c);let d=t.localDescription?.sdp??c.sdp??``;await m.mutateAsync({deviceId:n,sessionId:a,sdpAnswer:d})}catch(r){let c=r instanceof Error?r.message:String(r);if(console.warn(`[intercom] start failed`,r),t)try{t.close()}catch{}if(e)for(let t of e.getTracks())try{t.stop()}catch{}if(s.current=null,l.current=null,a!==null)try{await h.mutateAsync({deviceId:n,sessionId:a})}catch{}u.current=null,f.current&&(o(c),i(`error`))}},[n,r,p,m,h,_]);return d(()=>(f.current=!0,()=>{f.current=!1;let e=u.current;if(e!==null&&n!==null&&h.mutate({deviceId:n,sessionId:e}),s.current){try{s.current.close()}catch{}s.current=null}if(l.current){for(let e of l.current.getTracks())try{e.stop()}catch{}l.current=null}u.current=null}),[n]),{state:r,error:a,start:v,stop:_,isTalking:r===`talking`}}n();var pr=0;function Q(){return++pr}function mr(e){switch(e.type){case`system`:return`system`;case`device`:return`#${e.deviceId}`;case`provider`:return e.providerId;case`addon`:return e.addonId}}function hr(e){return[``,`Commands`,` help Show this help`,` examples Show usage examples for the current scope`,` context Show every available variable + full API surface`,` clear Clear terminal (also Ctrl+L)`,``,`Shortcuts`,` Enter Execute expression`,` Arrow Up/Down Navigate command history`,` Ctrl+L Clear terminal`,``,`Try: ${{system:` sm.summary() // fleet overview`,device:` device.state.battery.value?.sleeping // sync read`,provider:` devices.map(d => d.name)`,addon:` manifest.version`}[e.type]}`,``,`Top-level objects: sm (SystemMirror), DeviceType, Math, JSON, Date, …`]}function gr(e){switch(e.type){case`device`:return[``,`── State (sync, zero round-trip) ─────────────────────────`,` device.state.battery.value`,` device.state.battery.value?.percentage`,` device.state.motion.value?.detected`,``,`── Actions (async, through wrapper chain) ────────────────`,` await device.snapshot.getSnapshot({})`,` await device.ptz.move({ direction: 'left', steps: 1 })`,` await device.switch.setState({ on: true })`,``,`── Wait for condition ───────────────────────────────────`,` await sm.waitForState(deviceId, 'battery', s => !s.sleeping, 30_000)`,``,`── Subscribe to changes ─────────────────────────────────`,` const off = device.state.battery.subscribe(s => console.log(s))`,``,`── Quick info ───────────────────────────────────────────`,` info.name device name`,` info.addonId owning addon`,` sm.dump(deviceId) full debug dump`];case`system`:return[``,`── Lookups ──────────────────────────────────────────────`,` sm.getDeviceById(8)`,` sm.getDeviceByName('Sala da pranzo')`,` sm.getDevicesByAddon('reolink')`,` sm.getDevicesByType(DeviceType.Camera)`,``,`── Filters (typed query) ────────────────────────────────`,` sm.query({ addonId: 'reolink', online: true })`,` sm.query({ caps: ['battery', 'snapshot'] })`,` sm.query({ name: /^Cam-/ })`,``,`── Cross-device ─────────────────────────────────────────`,` sm.whereState('battery', s => s.percentage < 20).length`,` sm.mapState('battery', s => s.percentage)`,` sm.countByCap('snapshot')`,``,`── Batch action ─────────────────────────────────────────`,` await sm.invokeCap('snapshot', 'getSnapshot', {}, { parallelism: 4 })`,``,`── Listen ───────────────────────────────────────────────`,` sm.listenCap('motion', (id, s) => console.log(id, s))`,` sm.onDeviceAdded((id, info) => console.log('+', info.name))`,``,`── Diagnostics ──────────────────────────────────────────`,` sm.summary()`,` sm.dump(8)`];case`provider`:return[``,` devices.map(d => d.name)`,` await getIntegration()`,` sm.getDevicesByAddon('<this-addon-id>').length`];case`addon`:return[``,` manifest.name`,` manifest.version`,` declaration`]}}function _r(e){let t=[``,`Scope: ${e.type}`,``];switch(e.type){case`system`:return[...t,`Primary API — sm (SystemMirror):`,` sm.getDeviceById(id) DeviceProxy | null (sync)`,` sm.getDeviceByName(name) DeviceProxy | null`,` sm.getDeviceByStableId(sid) DeviceProxy | null`,` sm.getAllDevices() readonly DeviceProxy[]`,` sm.getDeviceInfo(id) DeviceInfo | null`,` sm.summary() fleet stats`,``,`Filters — sm.query({...}):`,` sm.query({ addonId: 'reolink', online: true })`,` sm.query({ caps: ['battery', 'snapshot'] }) // ALL caps required`,` sm.query({ anyCap: ['ptz', 'motion'] }) // ANY cap`,` sm.query({ name: { contains: 'sala' } }) // case-insensitive`,` sm.query({ name: /^Cam-\\d+$/ })`,` sm.query({ type: DeviceType.Camera })`,` sm.query({ parentDeviceId: 8 }) // accessories of cam 8`,` sm.query({ where: (info, dev) => dev.state.battery.value?.sleeping })`,``,`State queries:`,` sm.whereState('battery', s => s.percentage < 20)`,` sm.mapState('battery', s => s.percentage)`,` sm.findState('motion', s => s.detected)`,` sm.countByCap('snapshot')`,``,`Listeners (return unsubscribe fn):`,` sm.listen((id, cap, slice) => …) // every state change`,` sm.listenCap('motion', (id, slice) => …)`,` sm.listenDevice(8, (id, cap, slice) => …)`,` sm.onDeviceAdded((id, info) => …)`,` sm.onDeviceRemoved((id, info) => …)`,``,`Wait primitives:`,` await sm.waitForState(8, 'battery', s => !s.sleeping, 30_000)`,` await sm.waitForDevice(99, 30_000)`,``,`Batch:`,` await sm.invokeCap('snapshot', 'getSnapshot', {}, { parallelism: 4 })`,` await sm.forEachCap('reboot', d => d.reboot.reboot({}))`,``,`Diagnostics:`,` sm.dump(8) debug dump (one device)`,` sm.dump() full fleet dump`,` sm.summary() breakdown by cap/addon/type`,``,`Legacy: deviceRegistry, addonRegistry, eventBus, devices(), addons()`];case`device`:return[...t,`Pre-bound variables:`,` device DeviceProxy for this device (sync state + async methods)`,` deviceId number`,` info DeviceInfo metadata (name, addonId, type, online, …)`,` sm SystemMirror (full cluster view)`,` rawDevice legacy IDevice instance (escape hatch)`,``,`Reactive state (sync, zero round-trip):`,` device.state.battery.value BatteryStatus | undefined`,` device.state.battery.value?.sleeping`,` device.state.battery.value?.percentage`,` device.state.motion.value?.detected`,` device.state.switch.value?.on`,` device.state.brightness.value?.percentage`,` device.state.doorbell.value?.lastPressedAt`,``,`Cap actions (async, through wrapper chain):`,` await device.snapshot.getSnapshot({})`,` await device.snapshot.getSnapshot({ streamId: 'high' })`,` await device.ptz.move({ direction: 'left', steps: 1 })`,` await device.ptz.goToPreset({ presetId: 'home' })`,` await device.switch.setState({ on: true })`,` await device.brightness.setBrightness({ percentage: 60 })`,` await device.reboot.reboot({})`,``,`Subscribe to slice changes:`,` const off = device.state.battery.subscribe(s => console.log(s))`,` // off() to unsubscribe`,``,`Wait for a state condition:`,` await sm.waitForState(deviceId, 'battery', s => !s.sleeping, 30_000)`,``,`Diagnostics:`,` info.name device name`,` info.addonId which addon owns it`,` info.online transport health`,` sm.dump(deviceId) full debug dump (binding + state + info)`];case`provider`:return[...t,`Pre-bound variables:`,` devices Devices belonging to this provider (raw IDevice[])`,` getIntegration() Integration metadata`,``,`For typed device access use the SystemMirror:`,` await getSystemMirror()`,` sm.getDevicesByAddon('this-addon-id')`];case`addon`:return[...t,`Pre-bound variables:`,` manifest { name, version, ... }`,` declaration addon declaration`,` source addon source location`,``,`Examples:`,` manifest.name`,` manifest.version`]}}function vr({scope:n,greeting:i,className:a}){let o=m(),[s,f]=c(()=>{let e=[];return i&&e.push({id:Q(),kind:`info`,text:i}),e.push({id:Q(),kind:`info`,text:`scope: ${mr(n)} — type help or context for available commands`}),e}),[p,h]=c(``),[g,_]=c([]),[v,y]=c(-1),b=t(null),x=t(null);d(()=>{let e=x.current;e&&(e.scrollTop=e.scrollHeight)},[s]);let S=e(()=>{b.current?.focus()},[]),C=l({mutationFn:e=>o.trpcClient.repl.execute.mutate({code:e,scope:n}),onSuccess:e=>{let t=e??{},n=typeof t.output==`string`?t.output:e==null?`undefined`:typeof e==`string`?e:JSON.stringify(e,null,2),r=t.type===`error`;f(e=>[...e,{id:Q(),kind:r?`error`:`result`,text:n}])},onError:e=>{let t=e instanceof Error?e.message:String(e);f(e=>[...e,{id:Q(),kind:`error`,text:t}])}});function w(e){let t=e.trim();if(t){if(t===`clear`){f([{id:Q(),kind:`info`,text:`scope: ${mr(n)}`}]),h(``);return}if(t===`help`){f(e=>[...e,{id:Q(),kind:`input`,text:`> ${t}`},...hr(n).map(e=>({id:Q(),kind:`info`,text:e}))]),h(``);return}if(t===`context`){f(e=>[...e,{id:Q(),kind:`input`,text:`> ${t}`},..._r(n).map(e=>({id:Q(),kind:`info`,text:e}))]),h(``);return}if(t===`examples`){f(e=>[...e,{id:Q(),kind:`input`,text:`> ${t}`},...gr(n).map(e=>({id:Q(),kind:`info`,text:e}))]),h(``);return}_(e=>[...e,t]),y(-1),f(e=>[...e,{id:Q(),kind:`input`,text:`> ${t}`}]),h(``),C.mutate(t)}}function T(e){if(e.key===`Enter`){e.preventDefault(),w(p);return}if(e.key===`ArrowUp`){if(e.preventDefault(),g.length===0)return;let t=v===-1?g.length-1:Math.max(0,v-1);y(t),h(g[t]??``);return}if(e.key===`ArrowDown`){if(e.preventDefault(),v===-1)return;let t=v+1;t>=g.length?(y(-1),h(``)):(y(t),h(g[t]??``));return}e.ctrlKey&&e.key===`l`&&(e.preventDefault(),f([{id:Q(),kind:`info`,text:`scope: ${mr(n)}`}]))}let E={input:`text-zinc-300`,result:`text-emerald-300`,error:`text-red-300`,info:`text-zinc-400`};return r(`div`,{className:`flex flex-col bg-[#0c0a09] rounded-lg border border-border overflow-hidden font-mono text-xs ${a??``}`,onClick:S,children:[r(`div`,{ref:x,className:`flex-1 overflow-y-auto p-3 space-y-1 min-h-[120px]`,children:[s.map(e=>u(`pre`,{className:`whitespace-pre-wrap break-words leading-relaxed ${E[e.kind]}`,children:e.text},e.id)),C.isPending&&u(`span`,{className:`text-zinc-500 animate-pulse`,children:`…thinking`})]}),r(`div`,{className:`flex items-center gap-2 border-t border-zinc-800 px-3 py-2 bg-[#0c0a09]`,children:[u(`span`,{className:`text-emerald-400 flex-shrink-0 select-none font-bold`,children:`>`}),u(`input`,{ref:b,value:p,onChange:e=>h(e.target.value),onKeyDown:T,disabled:C.isPending,placeholder:`device.state.battery.value`,autoFocus:!0,className:`flex-1 bg-transparent text-zinc-100 placeholder:text-zinc-600 focus:outline-none caret-emerald-400 disabled:opacity-50`,spellCheck:!1,autoComplete:`off`,autoCorrect:`off`,autoCapitalize:`off`})]})]})}n();function yr({deviceId:e,intercomAvailable:t=!1}){let n=m(),r=typeof window<`u`?p():``,a=Number.isFinite(e),s=dr(a?e:null),c=vn(a?[e]:[]),l=i(()=>{if(!a)return;let e=[];for(let t of c.rows){let n=lt(t);n!==null&&e.push(n)}return e},[a,c.rows]),{streams:d,pipelineMetrics:f,createSession:h,sendAnswer:g,handleOffer:_,getIceServers:v,addIceCandidate:y,getIceCandidates:S,closeSession:C,getSessionState:w}=je(n.trpcClient,a?e:null),T=x(a?e:null,{width:wr}),E=fr(a&&t?e:null),O=E.state===`requesting-mic`||E.state===`starting`||E.state===`connecting`||E.state===`stopping`,k=E.isTalking||O,ee=()=>{E.state===`idle`||E.state===`error`?E.start():E.state!==`stopping`&&E.stop()},A=b(),j=D(),te=typeof window<`u`?window.localStorage.getItem(`camstack_admin_token`):null,ne=A.length>0?u(o,{children:A.map(e=>u(`div`,{className:`absolute inset-0`,children:e.node},e.id))}):null;return u(Dt,{serverUrl:r,createSession:h,sendAnswer:g,handleOffer:_,getIceServers:v,addIceCandidate:y,getIceCandidates:S,closeSession:C,getSessionState:w,...j.request?{playbackUrl:j.request.url,playbackAuthToken:te,...j.request.label?{playbackLabel:j.request.label}:{},onExitPlayback:()=>j.clear()}:{},streams:d,pipelineMetrics:f,phase:s.phase,detections:s,...l===void 0?{}:{stationaryObjects:l},defaultShowDetections:!0,defaultShowMotion:!0,showPlayStop:!0,snapshotSrc:T.src,...T.src?{posterUrl:T.src}:{},snapshotLoading:T.loading,onRefreshSnapshot:T.refresh,intercomAvailable:t,intercomShown:k,onIntercomToggle:ee,extraOverlay:ne,chromeless:!0,className:`h-full`})}function br({deviceId:e,containerDeviceId:t}){return Number.isFinite(e)?u(`div`,{className:`flex flex-col h-full`,children:u(xe,{...t===void 0?{deviceId:e}:{containerDeviceId:t},limit:50,maxHeight:`max-h-full`,showScope:!1,showFilters:!1})}):r(`div`,{className:`flex items-center justify-center h-full text-[11px] text-foreground-subtle italic`,children:[`Device #`,e,` not loaded.`]})}function xr({deviceId:e}){if(!Number.isFinite(e))return r(`div`,{className:`flex items-center justify-center h-full text-[11px] text-foreground-subtle italic`,children:[`Device #`,e,` not loaded.`]});let t=[`CamStack REPL — device #${e}`,``,` device.state.battery.value sync state read`,` await device.snapshot.getSnapshot({}) cap action`,``,` type 'examples' for more, 'context' for the full API`].join(`
2
- `);return u(vr,{scope:{type:`device`,deviceId:e},greeting:t,className:`h-full border-0 rounded-none`})}function Sr({deviceId:e}){return Number.isFinite(e)?u(`div`,{className:`flex flex-col h-full overflow-y-auto`,children:u(J,{deviceId:e,limit:50,maxHeight:`max-h-full`})}):r(`div`,{className:`flex items-center justify-center h-full text-[11px] text-foreground-subtle italic`,children:[`Device #`,e,` not loaded.`]})}function Cr({deviceId:e}){return Number.isFinite(e)?u(`div`,{className:`flex flex-col h-full overflow-y-auto`,children:u(ae,{deviceId:e,limit:50,maxHeight:`max-h-full`})}):r(`div`,{className:`flex items-center justify-center h-full text-[11px] text-foreground-subtle italic`,children:[`Device #`,e,` not loaded.`]})}var wr=960,Tr=`overview`;function Er(e,t){return e.some(e=>e.id===t)?t:Tr}function Dr({deviceId:e}){let t=s(),n=Number.isFinite(e),{data:i}=Y({deviceId:e},{enabled:n}),a=typeof i?.type==`string`?i.type:`camera`;bt([`deviceManager`,`getBindings`],[`capability.binding-changed`]);let{data:o,isLoading:c,isError:l,error:d}=q({deviceId:e},{enabled:n}),{data:f}=U({deviceType:a},{enabled:!!a}),p=Rt({onSuccess:()=>{t.invalidateQueries({queryKey:[[`deviceManager`,`getBindings`]]})}});if(c)return u(`div`,{className:`p-4`,children:u(`div`,{className:`h-20 rounded-lg border border-border bg-surface animate-pulse`})});if(l)return r(`div`,{className:`p-4 text-xs text-red-400`,children:[`Failed to load bindings: `,d instanceof Error?d.message:String(d)]});let m=new Map,h={};for(let e of f??[])h[e.capName]=e.wrappers;for(let e of o?.entries??[])m.set(e.capName,{...e,wrappers:h[e.capName]??[]});for(let e of f??[])m.has(e.capName)||m.set(e.capName,{capName:e.capName,kind:`unbound`,providerAddonId:``,providerNodeId:``,nativeAddonId:``,wrappers:e.wrappers});let g=[...m.values()].toSorted((e,t)=>e.capName.localeCompare(t.capName));if(g.length===0)return r(`div`,{className:`flex flex-col items-center justify-center gap-2 p-8 text-foreground-subtle`,children:[u(Jt,{className:`h-8 w-8 opacity-40`}),u(`p`,{className:`text-xs`,children:`No capability providers applicable to this device yet.`}),u(`p`,{className:`text-[10px] opacity-60`,children:`Native providers show up here as soon as the owning addon registers them.`})]});let _=g.filter(e=>e.kind!==`unbound`).length;return r(`div`,{className:`flex flex-col gap-3 p-1`,children:[r(`div`,{className:`text-[11px] text-foreground-subtle`,children:[u(`span`,{className:`font-medium text-foreground`,children:_}),` of `,g.length,` capabilit`,g.length===1?`y`:`ies`,` bound — rows marked `,u(`em`,{children:`unbound`}),` have a wrapper available you can activate.`]}),u(St,{columns:[{key:`capability`,header:`Capability`,render:e=>u(`span`,{className:`font-mono text-foreground`,children:e.capName})},{key:`kind`,header:`Kind`,render:e=>u(Or,{kind:e.kind})},{key:`provider`,header:`Active Provider`,render:e=>u(`span`,{className:`font-mono text-foreground-subtle`,children:e.providerAddonId||u(`span`,{className:`opacity-40`,children:`—`})})},{key:`node`,header:`Node`,render:e=>e.providerNodeId?u(kr,{nodeId:e.providerNodeId}):u(`span`,{className:`text-[10px] opacity-40`,children:`—`})},{key:`native`,header:`Native`,render:e=>u(`span`,{className:`font-mono text-foreground-subtle`,children:e.nativeAddonId||u(`span`,{className:`opacity-40`,children:`—`})})},{key:`wrapper`,header:`Wrapper`,render:t=>{let n=t.kind===`wrapped`?t.providerAddonId:null;return u(Ar,{wrappers:t.wrappers,activeWrapperId:n,disabled:p.isPending,onPick:r=>{let i=n===r;p.mutate({deviceId:e,capName:t.capName,wrapperAddonId:r,active:!i})}})}}],rows:g,rowKey:e=>e.capName,minWidthPx:720})]})}function Or({kind:e}){return e===`native`?r(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-success/30 text-success bg-success/5 px-1.5 py-0.5 text-[10px] font-medium`,children:[u(vt,{className:`h-3 w-3`}),`native`]}):e===`wrapped`?r(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-primary/30 text-primary bg-primary/5 px-1.5 py-0.5 text-[10px] font-medium`,children:[u(en,{className:`h-3 w-3`}),`wrapped`]}):e===`linked`?r(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-warning/30 text-warning bg-warning/5 px-1.5 py-0.5 text-[10px] font-medium`,children:[u(Nt,{className:`h-3 w-3`}),`linked`]}):r(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-border text-foreground-subtle/70 px-1.5 py-0.5 text-[10px] font-medium`,children:[u(Ve,{className:`h-3 w-3`}),`unbound`]})}function kr({nodeId:e}){return u(`span`,{className:`inline-flex items-center rounded-md border border-border px-1.5 py-0.5 font-mono text-[10px] ${e===`hub`?`text-foreground-subtle`:`text-foreground`}`,children:e})}function Ar({wrappers:e,activeWrapperId:t,disabled:n,onPick:i}){return e.length===0?u(`span`,{className:`text-[10px] opacity-40`,children:`none available`}):u(`div`,{className:`flex flex-wrap gap-1`,children:e.map(e=>{let a=e===t;return r(`button`,{disabled:n,onClick:()=>i(e),title:a?`Click to deactivate (revert to native)`:`Activate wrapper ${e}`,className:`inline-flex items-center gap-1 rounded-md border px-1.5 py-0.5 font-mono text-[10px] transition-colors disabled:opacity-50 ${a?`border-primary/40 bg-primary/10 text-primary`:`border-border text-foreground-subtle hover:text-foreground hover:bg-surface-hover`}`,children:[u(a?E:_,{className:`h-3 w-3`}),e]},e)})})}function jr({deviceId:e,activeSubTab:t,onSubTabChange:n}){return u(`div`,{className:`flex flex-col gap-3`,children:u(Sn,{deviceId:e,activeSubTab:t,onSubTabChange:n})})}n();var Mr=new Set([`package-detection`]);function Nr(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 Pr(e){return e?e.modelId!==void 0||e.settings!==void 0:!1}function Fr({deviceId:e,refreshToken:t}){let n=s(),l=m().trpcClient,[d,f]=c(null),[p,h]=c(null),[g,_]=c(null),v=Ne({deviceId:e},{refetchOnMount:`always`}),y=wt({deviceId:e},{refetchOnMount:`always`}),b=at(void 0,{refetchOnMount:`always`});bt([`nodes`,`topology`],[`agent.online`,`agent.offline`,`agent.unregistered`,`addon.installed`,`addon.uninstalled`]);let{nodes:x}=Ge(),S=i(()=>{let e=new Set;for(let t of x)t.isOnline&&e.add(t.id);return e},[x]),C=i(()=>(b.data??[]).filter(e=>S.has(e.nodeId)).map(e=>e.nodeId),[b.data,S]),w=a({enabled:C.length>0,queryKey:[[`pipelineExecutor`,`getSchema`],`device-step-schemas`,C.join(`,`),t],queryFn:async()=>{let e={};for(let t of C)try{e[t]=await l.pipelineExecutor.getSchema.query({nodeId:t})}catch{}return e}}),T=e=>w.data?.[e]??null,E=i(()=>{let e=C[0];if(e!==void 0){let t=w.data?.[e];if(t)return t}return Object.values(w.data??{})[0]??null},[C,w.data]),D=a({enabled:C.length>0,queryKey:[[`pipelineOrchestrator`,`getNodeInferenceDevices`],`device-step`,C.join(`,`),t],queryFn:async()=>{let e={};for(let t of C)try{e[t]=(await l.pipelineOrchestrator.getNodeInferenceDevices.query({nodeId:t})).devices}catch{e[t]=[]}return e}}),O=()=>{n.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getCameraSettings`]]}),n.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getCameraStepOverrides`]]})},k=re({onSuccess:O}),A=te({onSuccess:O}),j=i(()=>E?Be(E):[],[E]),ne=i(()=>{let e=b.data??[],t=S.size===0?[]:e.filter(e=>S.has(e.nodeId)),n=[];for(let e of t){let t=(D.data?.[e.nodeId]??[]).filter(e=>e.enabled&&e.available);if(t.length>=2)for(let r of t)n.push({agentNodeId:e.nodeId,engineLabel:r.format,deviceKey:r.key,deviceLabel:Qt(r).label});else n.push({agentNodeId:e.nodeId,engineLabel:t[0]?.format??`(engine unknown)`})}return n},[b.data,D.data,S]),M=(e,t)=>D.data?.[e]?.find(e=>e.key===t)??null,N=e=>{if(e.deviceKey!==void 0)return e.deviceKey;let t=D.data?.[e.agentNodeId]??[],n=t.filter(e=>e.enabled&&e.available);return n.length>=1?n[0].key:t.find(e=>e.available)?.key??t[0]?.key??null},P=(e,t,n)=>y.data?.[e]?.[t]?.[n]??null,F=e=>{if(Mr.has(e))return{kind:`zone-driven`};let t=Nr(E,e)?.enabledByDefault??!0,n=v.data?.stepToggles?.[e];return{kind:`gate`,effectiveOn:n??t,defaultOn:t,explicit:n!==void 0}},ie=(e,t,n)=>{let r=Nr(T(n),e);if(r)return Kt(r,t)},ae=(e,t)=>{let n=F(e),r=n.kind===`gate`?n.effectiveOn:!1,i=Nr(T(t.agentNodeId),e),a=N(t),o=a===null?null:M(t.agentNodeId,a);if(!ye(i?.models??[],o?.format))return r?{kind:`skip`}:{kind:`na`};let s=a===null?null:P(t.agentNodeId,a,e),c=o?.steps?.[e];return{kind:`enabled`,modelId:(i?ee({catalog:i,device:o,override:s?.modelId,base:c?.modelId}):void 0)??`Auto`,overridden:Pr(s)}},I=d===null?null:Nr(T(d.agentNodeId),d.addonId),L=d?M(d.agentNodeId,d.deviceKey):null,oe=L?.format??`coreml`,se=d?Pr(P(d.agentNodeId,d.deviceKey,d.addonId)):!1,R=d?ie(d.addonId,L,d.agentNodeId):void 0,z=i(()=>{if(!d||!L)return null;let e=L.steps?.[d.addonId];return{enabled:!0,...e?.modelId===void 0?{}:{modelId:e.modelId},settings:e?.settings??{}}},[d,L]),B=()=>{f(null),h(null)},ce=(e,t)=>{let n=N(t);n!==null&&(f({addonId:e,agentNodeId:t.agentNodeId,deviceKey:n}),h(P(t.agentNodeId,n,e)))},le=(t,n)=>{A.mutate({deviceId:e,addonId:t,enabled:n})},V=()=>{d&&k.mutate({deviceId:e,agentNodeId:d.agentNodeId,deviceKey:d.deviceKey,addonId:d.addonId,patch:p},{onSuccess:B})},H=()=>{d&&k.mutate({deviceId:e,agentNodeId:d.agentNodeId,deviceKey:d.deviceKey,addonId:d.addonId,patch:null},{onSuccess:B})};if(b.isLoading||C.length>0&&w.isLoading)return u(`div`,{className:`text-xs text-foreground-subtle animate-pulse p-4`,children:`Loading pipeline…`});if(ne.length===0)return u(`div`,{className:`text-xs text-foreground-subtle p-4`,children:`No online agents.`});if(!E)return u(`div`,{className:`text-xs text-foreground-subtle p-4`,children:`Catalog unavailable.`});let ue=d!==null&&I!==null&&L!==null;return r(`div`,{className:`relative h-full w-full space-y-3`,children:[r(`div`,{className:`rounded-md border border-border bg-muted/20 px-3 py-2 text-[11px] leading-relaxed text-foreground-subtle`,children:[u(`span`,{className:`font-medium text-foreground`,children:`Gate`}),` (col 1) decides whether this camera runs a step — independent of nodes. Each`,` `,u(`span`,{className:`font-medium text-foreground`,children:`node column`}),` shows the model that node runs; click a cell to pin a per-camera model override for that accelerator. A gated-on step with no model on a device shows a clickable `,u(`span`,{className:`text-amber-500`,children:`⚠ skip`}),` `,`and won't run there.`]}),r(`div`,{className:`rounded-md border border-sky-500/25 bg-sky-500/[0.06] px-3 py-2 text-[11px] leading-relaxed text-foreground-subtle`,children:[u(`span`,{className:`font-medium text-sky-400`,children:`Placement is dynamic.`}),` When a node has multiple inference accelerators, each session is balanced across them per-session at dispatch time — these device columns show each accelerator's effective model (override ?? device default), not a fixed assignment.`]}),u(`div`,{className:ue?`md:pr-[360px]`:``,children:j.length>0?u(Lt,{tree:j,agents:ne,gateFor:F,getCellState:ae,onCellClick:ce,selectedCell:d,onSetGate:le,gateBusy:A.isPending,fallbackNodeId:g,onFallbackNodeChange:_}):u(`div`,{className:`text-xs text-foreground-subtle`,children:`Catalog empty.`})}),u(We,{open:ue,onClose:B,title:I?.name??``,subtitle:d&&L?`${d.agentNodeId} · ${Qt(L).label} · ${L.format}`:``,footer:r(o,{children:[u(`button`,{type:`button`,className:`px-3 py-1 text-xs border border-border rounded bg-surface hover:bg-muted text-foreground-subtle disabled:opacity-50`,disabled:!se||k.isPending,onClick:H,children:`Clear override`}),u(`div`,{className:`flex-1`}),u(`button`,{type:`button`,className:`px-3 py-1 text-xs border border-border rounded bg-surface hover:bg-muted`,onClick:B,children:`Cancel`}),u(`button`,{type:`button`,disabled:!d||!z||k.isPending,className:`px-3 py-1 text-xs bg-primary text-primary-foreground rounded disabled:opacity-50`,onClick:V,children:k.isPending?`Saving…`:`Save`})]}),children:I&&d&&z?u(me,{mode:`device`,addon:I,agentDefault:z,agentNodeId:d.agentNodeId,currentPatch:p,engineFormat:oe,effectiveModelId:R,onChangePatch:h}):u(`div`,{className:`rounded-md border border-amber-500/40 bg-amber-500/10 px-3 py-2 text-[11px] text-amber-300`,children:`This accelerator is no longer reported by the node, so there is nothing to provision here.`})})]})}var Ir=[{id:`object-detection`,label:`Object detection`,icon:`scan-search`},{id:`tracking`,label:`Tracking`,icon:`route`},{id:`motion`,label:`Motion`,icon:`activity`},{id:`stationary`,label:`Stationary`,icon:`square-parking`},{id:`zones`,label:`Zones`,icon:`shapes`},{id:`audio`,label:`Audio`,icon:`volume-2`},{id:`cluster`,label:`Cluster`,icon:`server`}],Lr={"pipeline-object-detection":`object-detection`,"detection-sensitivity":`object-detection`,"onboard-object-detection":`object-detection`,tracking:`tracking`,"tracking-core":`tracking`,"motion-tuning":`motion`,"stationary-objects":`stationary`,occupancy:`stationary`,zones:`zones`,"pipeline-audio":`audio`,"cluster-assignment":`cluster`,"orchestrator-live":`cluster`};function Rr(e){return Lr[e]??`object-detection`}n();var zr=`steps`,Br=`settings`,Vr=new Set([zr,Br]);function Hr(e){return e.location===`top-tab`&&(e.tab===`detection-pipeline`||e.tab===`zones`)}function Ur({deviceId:t,activeSubTab:n,onSubTabChange:i}){return r(qe,{value:n&&Vr.has(n)?n:zr,onValueChange:e(e=>{i?.(e)},[i]),className:`flex flex-col`,children:[r(ot,{className:`flex-shrink-0`,children:[u(Ye,{value:zr,children:`Steps`}),u(Ye,{value:Br,children:`Settings`})]}),u(gt,{value:zr,children:u(Fr,{deviceId:t,refreshToken:0})}),u(gt,{value:Br,children:u(Sn,{deviceId:t,sectionFilter:Hr,subTabGrouping:{groupOf:e=>Rr(e.id),tabs:Ir}})})]})}function $({label:e,value:t}){return r(`div`,{className:`${w} flex items-start gap-2 sm:gap-3`,children:[u(`span`,{className:`w-20 sm:w-28 flex-shrink-0 text-[11px] text-foreground-subtle`,children:e}),u(`div`,{className:`flex-1 min-w-0 text-[11px] text-foreground`,children:t})]})}n();function Wr({deviceId:e,initialName:n}){let i=s(),[a,o]=c(!1),[l,f]=c(n),[p,m]=c(!1),h=t(null);d(()=>{a||f(n)},[n,a]),d(()=>{a&&h.current?.focus()},[a]);let g=De({onSuccess:()=>{i.invalidateQueries({queryKey:[[`deviceManager`,`getDevice`]]}),i.invalidateQueries({queryKey:[[`deviceManager`,`listAll`]]}),i.invalidateQueries({queryKey:[[`deviceManager`,`getDeviceAggregate`]]})}}),_=async()=>{let t=l.trim();if(t.length===0||t===n){o(!1),f(n);return}m(!0);try{await g.mutateAsync({deviceId:e,name:t}),o(!1)}catch{}finally{m(!1)}},v=()=>{f(n),o(!1)};return a?u($,{label:`Name`,value:r(`div`,{className:`flex items-center gap-1`,children:[u(`input`,{ref:h,type:`text`,value:l,onChange:e=>f(e.target.value),onKeyDown:e=>{e.key===`Enter`?_():e.key===`Escape`&&v()},disabled:p,className:`flex-1 min-w-0 px-1.5 py-0.5 text-[11px] bg-background border border-border rounded focus:outline-none focus:border-primary`}),u(`button`,{type:`button`,onClick:()=>void _(),disabled:p,className:`p-0.5 rounded hover:bg-success/10 text-success disabled:opacity-50`,"aria-label":`Save`,children:u(E,{className:`h-3 w-3`})}),u(`button`,{type:`button`,onClick:v,disabled:p,className:`p-0.5 rounded hover:bg-danger/10 text-danger disabled:opacity-50`,"aria-label":`Cancel`,children:u(Vt,{className:`h-3 w-3`})})]})}):u($,{label:`Name`,value:r(`div`,{className:`flex items-center gap-2 group`,children:[u(`span`,{className:`truncate`,children:n}),u(`button`,{type:`button`,onClick:()=>o(!0),className:`p-0.5 rounded text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,"aria-label":`Edit name`,children:u(dt,{className:`h-3.5 w-3.5`})})]})})}n();function Gr({deviceId:e,initialLocation:n}){let a=s(),[o,l]=c(!1),[f,p]=c(n??``),[m,h]=c(!1),g=t(null),{data:_}=Tt(void 0,{enabled:o}),v=_??[];d(()=>{o||p(n??``)},[n,o]),d(()=>{o&&g.current?.focus()},[o]);let y=mt({onSuccess:()=>{a.invalidateQueries({queryKey:[[`deviceManager`,`getDevice`]]}),a.invalidateQueries({queryKey:[[`deviceManager`,`listAll`]]}),a.invalidateQueries({queryKey:[[`deviceManager`,`getDeviceAggregate`]]}),a.invalidateQueries({queryKey:[[`deviceManager`,`listLocations`]]})}}),b=i(()=>{let e=f.trim().toLowerCase();return e.length===0?v:v.filter(t=>t.toLowerCase()!==e&&t.toLowerCase().includes(e))},[v,f]),x=f.trim().length>0&&!v.some(e=>e.toLowerCase()===f.trim().toLowerCase()),S=async t=>{let r=(t??f).trim(),i=r.length===0?null:r;if(i===(n??null)){l(!1);return}h(!0);try{await y.mutateAsync({deviceId:e,location:i}),l(!1)}catch{}finally{h(!1)}},C=()=>{p(n??``),l(!1)};return o?u($,{label:`Location`,value:r(`div`,{className:`relative`,children:[r(`div`,{className:`flex items-center gap-1`,children:[u(`input`,{ref:g,type:`text`,value:f,onChange:e=>p(e.target.value),onKeyDown:e=>{e.key===`Enter`?S():e.key===`Escape`&&C()},disabled:m,placeholder:`Room / area (or leave empty to clear)`,className:`flex-1 min-w-0 px-1.5 py-0.5 text-[11px] bg-background border border-border rounded focus:outline-none focus:border-primary`}),u(`button`,{type:`button`,onClick:()=>void S(),disabled:m,className:`p-0.5 rounded hover:bg-success/10 text-success disabled:opacity-50`,"aria-label":`Save`,children:u(E,{className:`h-3 w-3`})}),u(`button`,{type:`button`,onClick:C,disabled:m,className:`p-0.5 rounded hover:bg-danger/10 text-danger disabled:opacity-50`,"aria-label":`Cancel`,children:u(Vt,{className:`h-3 w-3`})})]}),(b.length>0||x)&&r(`div`,{className:`absolute z-10 left-0 right-0 mt-0.5 max-h-40 overflow-y-auto rounded-md border border-border bg-surface shadow-md`,children:[b.map(e=>r(`button`,{type:`button`,onClick:()=>{p(e),S(e)},className:`w-full flex items-center gap-2 px-2 py-1 text-left text-[11px] hover:bg-surface-hover`,children:[u(ht,{className:`h-3 w-3 text-foreground-subtle flex-shrink-0`}),u(`span`,{className:`truncate`,children:e})]},e)),x&&r(`button`,{type:`button`,onClick:()=>void S(),className:`w-full flex items-center gap-2 px-2 py-1 text-left text-[11px] hover:bg-surface-hover border-t border-border`,children:[u(`span`,{className:`text-foreground-subtle`,children:`Create`}),r(`span`,{className:`font-medium truncate`,children:[`"`,f.trim(),`"`]})]})]})]})}):u($,{label:`Location`,value:r(`div`,{className:`flex items-center gap-2 group`,children:[n?u(`span`,{className:`truncate`,children:n}):u(`span`,{className:`italic text-foreground-subtle`,children:`unset`}),u(`button`,{type:`button`,onClick:()=>l(!0),className:`p-0.5 rounded text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,"aria-label":`Edit location`,children:u(dt,{className:`h-3.5 w-3.5`})})]})})}n();function Kr({deviceId:e}){let t=s(),{data:n}=$t(e),{data:i}=Zt(e),[a,l]=c(null),d=Mt({onSuccess:()=>{l(null),t.invalidateQueries({queryKey:[[`deviceManager`]]})},onError:e=>{l(`Could not change primary child: ${e.message}`)}});if(n==null||String(n.type??``)!==X.Container)return null;let f=(i??[]).map(e=>({id:e.id,stableId:e.stableId,type:e.type,name:e.name,...e.sourceInfo?{sourceInfo:{id:e.sourceInfo.id}}:{}}));if(f.length<=1)return null;let p=_e(f,typeof n.linkDeviceId==`number`?n.linkDeviceId:null,typeof n.primaryChildEntityId==`string`?n.primaryChildEntityId:null);return r(o,{children:[u($,{label:`Primary child`,value:u(Ut,{childrenList:f,selectedId:p===null?f[0].id:p.id,onSetPrimary:t=>d.mutate({deviceId:e,primaryChildEntityId:t}),disabled:d.isPending})}),a!==null&&u(`p`,{role:`alert`,className:`px-3 sm:px-4 py-1.5 text-[11px] text-danger`,children:a})]})}n();var qr=[`manufacturer`,`model`,`hardware`,`firmware`,`serialNumber`,`uid`,`mac`,`itemNo`];function Jr(e){return e.replace(/([a-z])([A-Z])/g,`$1 $2`).replace(/^./,e=>e.toUpperCase())}function Yr(e){return e==null?`—`:typeof e==`string`||typeof e==`number`||typeof e==`boolean`?String(e):JSON.stringify(e)}function Xr(){let e=Me(),t=ft(),{data:n}=Y({deviceId:e??0},{enabled:e!==null}),{data:i}=q({deviceId:e??0},{enabled:e!==null}),a=n??t??null,[o,s]=c(`identity`);if(e===null||!a)return null;let l=String(a.stableId??``),d=String(a.name??``),f=String(a.type??``),p=String(a.addonId??``),m=a.features??[],h=new Set([`device-status`,`feature-probe`,`device-ops`]),g=(i?.entries??[]).filter(e=>e.kind===`native`&&!h.has(e.capName)).map(e=>e.capName),_=m.length>0?m:g,v=a.location??null,y=a.metadata??null,b=y!==null&&Object.keys(y).length>0;return r(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[r(`div`,{className:`border-b border-border px-3 sm:px-4 py-2 flex items-center justify-between gap-3`,children:[u(`h2`,{className:`text-[11px] font-semibold text-foreground uppercase tracking-wider`,children:`Device Info`}),b&&r(`div`,{className:`flex items-center gap-1 rounded-md bg-surface-hover p-0.5`,children:[u(Zr,{active:o===`identity`,onClick:()=>s(`identity`),label:`Identity`}),u(Zr,{active:o===`hardware`,onClick:()=>s(`hardware`),label:`Hardware`})]})]}),(!b||o===`identity`)&&r(`div`,{className:`divide-y divide-border`,children:[u($,{label:`ID`,value:r(`span`,{className:`font-mono text-[11px] text-foreground`,children:[`#${e}`,r(`span`,{className:`ml-1.5 text-foreground-subtle`,children:[`(`,l,`)`]})]})}),u(Wr,{deviceId:e,initialName:d}),u(Gr,{deviceId:e,initialLocation:v}),u(Kr,{deviceId:e}),u($,{label:`Type`,value:f}),u($,{label:`Provider`,value:u(Yt,{type:p,size:`sm`,showLabel:!0})}),u($,{label:`Capabilities`,value:_.length>0?u(tn,{capabilities:_,showLabels:!0}):u(`span`,{className:`text-[11px] text-foreground-subtle`,children:`None`})})]}),b&&o===`hardware`&&u(Qr,{metadata:y})]})}function Zr({active:e,onClick:t,label:n}){return u(`button`,{type:`button`,onClick:t,className:`px-2 py-0.5 rounded text-[10px] font-medium transition-colors ${e?`bg-surface text-foreground shadow-sm`:`text-foreground-subtle hover:text-foreground`}`,children:n})}function Qr({metadata:e}){let t=qr.filter(t=>t in e),n=Object.keys(e).filter(e=>!qr.includes(e)).toSorted(),i=[...t,...n];return r(`div`,{children:[u(`div`,{className:`px-3 sm:px-4 py-1.5 text-[10px] text-foreground-subtle border-b border-border bg-surface-subtle/40`,children:`Auto-populated by the driver on every connect. Read-only.`}),u(`div`,{className:`divide-y divide-border`,children:i.map(t=>u($,{label:Jr(t),value:u(`span`,{className:`font-mono text-[11px] text-foreground break-all`,children:Yr(e[t])})},t))})]})}var $r=`Notifications`,ei=`This camera never notifies — no rule, no target, no alarm. Existing events, tracks and recordings are unaffected.`;function ti(e){let{mutedDeviceIds:t,deviceId:n}=e,r=t===null?null:!t.includes(n),i=e.pendingOn??null;return{label:$r,on:r===null?null:i??r,available:r!==null,costWhenOff:ei}}function ni(e,t){return!e.available||e.on===null?null:{deviceId:t,muted:e.on}}n();function ri(e){if(typeof e!=`object`||!e)return null;let t={...e}.mutedDeviceIds;return Array.isArray(t)?t.filter(e=>typeof e==`number`):null}function ii({deviceId:t}){let n=s(),i=Number.isFinite(t),[a,o]=c(null),[l,d]=c(null),f=ti({mutedDeviceIds:ri(K({},{enabled:i}).data),deviceId:t,pendingOn:l}),p=ne({onError:e=>{console.error(`[DeviceNotificationMute] mute write failed — reverting`,{tags:{deviceId:t},meta:{error:e instanceof Error?e.message:String(e)}}),d(null),o(e instanceof Error?e.message:String(e)),n.invalidateQueries({queryKey:[[`notificationRules`,`listDeviceMutes`]]})},onSuccess:()=>{o(null),d(null),n.invalidateQueries({queryKey:[[`notificationRules`]]})}}),m=e(()=>{let e=ni(f,t);e!==null&&(d(!e.muted),p.mutate(e))},[t,p,f]),h=f.on===null,g=f.on===!1,_=g?qt:pt;return r(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[r(`div`,{className:`border-b border-border px-4 py-2 flex items-center justify-between gap-2`,children:[u(`h2`,{className:`text-xs font-semibold text-foreground uppercase tracking-wider`,children:`Notifications`}),g&&u(`span`,{className:`rounded bg-warning/20 px-1.5 py-0.5 text-[9px] font-semibold uppercase tracking-wide text-warning`,children:`muted`})]}),r(`div`,{className:`px-4 py-3 flex items-start gap-3`,children:[r(`button`,{type:`button`,role:`switch`,"aria-label":f.label,"aria-checked":f.on===!0,disabled:!f.available||p.isPending,onClick:m,title:h?`Notification mute — state unknown; the notification centre did not answer.`:g?`Muted. ${f.costWhenOff}`:`Notifying. Muting it: ${f.costWhenOff}`,className:`inline-flex items-center gap-1.5 rounded-lg border px-2 py-1.5 text-[11px] font-medium transition-colors disabled:cursor-not-allowed ${a===null?h?`border-dashed border-border text-foreground-subtle/50`:g?`border-warning/40 text-warning hover:bg-warning/10`:`border-success/30 text-success hover:bg-success/10`:`border-danger/50 text-danger bg-danger/5`}`,children:[u(_,{className:`h-3.5 w-3.5`}),u(`span`,{children:h?`Unknown`:g?`Muted`:`Notifying`})]}),u(`p`,{className:`flex-1 text-[11px] leading-relaxed text-foreground-subtle`,children:a===null?h?`The notification centre did not answer, so this device’s mute state is unknown.`:f.costWhenOff:`Write failed: ${a}`})]})]})}function ai(e,t){return{switchId:e,label:nn[e].label,detail:t===void 0||t.length===0?null:t}}function oi(e){let t=new Map;for(let n of e.switches)n.deviceId===e.sourceId&&(t.has(n.switchId)||t.set(n.switchId,n));return t}function si(e){let t=oi(e),n=new Set(e.sourceStillLive),r=e.sourceStillLive.map(e=>ai(e,t.get(e)?.detail)),i=[...t.values()].filter(e=>e.outcome===`not-offered`&&!n.has(e.switchId)).map(e=>ai(e.switchId,e.detail));return{inheritedId:e.sourceId,retiredId:e.targetId,swapped:e.swapped,verdict:r.length===0?`quiet`:`still-live`,stillLive:r,neverOffered:i}}n();function ci(e,t){return e.filter(e=>e.isCamera&&e.id!==t).map(e=>({id:e.id,name:e.name})).toSorted((e,t)=>e.name.localeCompare(t.name))}function li({deviceId:e,deviceName:t}){let{t:n}=fn(),a=rt(),[o,s]=c(null),l=Te({isCamera:!0,projection:`slim`}),d=xt(),f=l.data!==void 0,p=i(()=>l.data===void 0?[]:ci(l.data,e),[l.data,e]),m=p.find(e=>e.id===o)??null,h=d.data===void 0?null:si(d.data),g=d.error===null?null:d.error.message,_=async()=>{m===null||m.id===e||await a({title:n(`deviceMigrate.confirmTitle`,`Replace “{{source}}” with “{{target}}”?`,{source:t,target:m.name}),message:n(`deviceMigrate.confirmMessage`,`“{{target}}” takes over number {{sourceId}}. That number is what every recording, event, rule, zone and home-automation export of “{{source}}” is filed under, so all of it follows the number to the new hardware and keeps working. “{{source}}” is switched off and handed number {{targetId}} in exchange. This swaps two device identities and cannot be undone from here.`,{source:t,target:m.name,sourceId:e,targetId:m.id}),confirmLabel:n(`deviceMigrate.confirmAction`,`Migrate`),variant:`danger`})&&d.mutate({sourceId:e,targetId:m.id})};return r(`div`,{className:`rounded-lg border border-border bg-surface px-4 py-3`,children:[r(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[r(`div`,{className:`min-w-0`,children:[u(`h2`,{className:`text-xs font-semibold uppercase tracking-wider text-foreground`,children:n(`deviceMigrate.title`,`Migrate to…`)}),u(`p`,{className:`mt-0.5 text-[11px] text-foreground-subtle`,children:n(`deviceMigrate.subtitle`,`Replace this camera with other hardware you have already adopted. The new camera inherits number {{deviceId}}, so recordings, rules and integrations follow it.`,{deviceId:e})})]}),r(`div`,{className:`flex shrink-0 items-center gap-2`,children:[r(`select`,{"aria-label":n(`deviceMigrate.pickerLabel`,`Replacement camera`),className:`rounded-md border border-border bg-background px-2 py-1.5 text-xs text-foreground disabled:opacity-50`,disabled:!f||p.length===0||d.isPending,value:o===null?``:String(o),onChange:e=>{let t=e.target.value;s(t===``?null:Number(t))},children:[u(`option`,{value:``,children:f?n(`deviceMigrate.pickerPlaceholder`,`Select a camera…`):n(`deviceMigrate.pickerPending`,`Reading the fleet…`)}),p.map(e=>r(`option`,{value:String(e.id),children:[e.name,` (#`,e.id,`)`]},e.id))]}),r(`button`,{type:`button`,disabled:m===null||d.isPending,onClick:()=>{_()},className:`inline-flex shrink-0 items-center gap-1.5 rounded-md border border-border bg-background px-3 py-1.5 text-xs font-medium text-foreground hover:bg-surface disabled:opacity-50`,children:[u(Cn,{className:`h-3 w-3`}),d.isPending?n(`deviceMigrate.running`,`Migrating…`):n(`deviceMigrate.action`,`Migrate`)]})]})]}),f&&p.length===0&&u(`p`,{className:`mt-2 text-[11px] text-foreground-subtle`,children:n(`deviceMigrate.noTargets`,`No other camera is adopted, so there is nothing to migrate to.`)}),g!==null&&u(`p`,{className:`mt-2 text-[11px] text-danger`,children:n(`deviceMigrate.failed`,`Migration failed: {{error}}`,{error:g})}),h!==null&&u(ui,{report:h})]})}function ui({report:e}){let{t}=fn(),n=e.verdict===`quiet`;return r(`div`,{className:`mt-3 space-y-2 border-t border-border pt-3`,children:[u(`p`,{className:`text-[11px] text-foreground-subtle`,children:t(`deviceMigrate.swapped`,`The replacement now answers on number {{inheritedId}}; the old camera was handed number {{retiredId}}.`,{inheritedId:e.inheritedId,retiredId:e.retiredId})}),n?r(`div`,{className:`flex items-start gap-2 rounded-md border border-success/30 bg-success/5 px-3 py-2`,children:[u(L,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-success`}),u(`p`,{className:`text-[11px] leading-relaxed text-foreground`,children:t(`deviceMigrate.quiet`,`Every function on the replaced camera was switched off — the old hardware is quiet.`)})]}):r(`div`,{className:`rounded-md border border-warning/40 bg-warning/5 px-3 py-2`,children:[r(`div`,{className:`flex items-start gap-2`,children:[u(He,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-warning`}),u(`p`,{className:`text-[11px] leading-relaxed text-foreground`,children:t(`deviceMigrate.stillLive`,`The replaced camera could not be reached, so these functions are STILL RUNNING on the old hardware. Nothing here failed to migrate — but until you unplug it or reach it physically, it can still produce data.`)})]}),u(`ul`,{className:`mt-2 space-y-1 pl-5`,children:e.stillLive.map(e=>r(`li`,{className:`text-[11px] text-foreground`,children:[u(`span`,{className:`font-medium`,children:e.label}),e.detail!==null&&r(`span`,{className:`text-foreground-subtle`,children:[` — `,e.detail]})]},e.switchId))})]}),e.neverOffered.length>0&&r(`div`,{className:`rounded-md border border-border px-3 py-2`,children:[r(`div`,{className:`flex items-start gap-2`,children:[u(Xt,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-foreground-subtle`}),u(`p`,{className:`text-[11px] leading-relaxed text-foreground-subtle`,children:t(`deviceMigrate.neverOffered`,`The replaced camera never offered these, so there was nothing to switch off. They are not running.`)})]}),u(`ul`,{className:`mt-2 space-y-1 pl-5`,children:e.neverOffered.map(e=>u(`li`,{className:`text-[11px] text-foreground-subtle`,children:e.label},e.switchId))})]})]})}n();function di({deviceId:e}){let[t,n]=c(null),i=N({onSuccess:e=>{n(e.changed?`Re-aligned with source — ${e.rebuiltChildren} child${e.rebuiltChildren===1?``:`ren`} rebuilt.`:`Already up to date.`)},onError:e=>n(`Re-sync failed: ${e.message}`)});return r(`div`,{className:`rounded-lg border border-border bg-surface px-4 py-3`,children:[r(`div`,{className:`flex items-center justify-between gap-3`,children:[r(`div`,{children:[u(`h2`,{className:`text-xs font-semibold uppercase tracking-wider text-foreground`,children:`Re-sync`}),u(`p`,{className:`mt-0.5 text-[11px] text-foreground-subtle`,children:`Re-align this device's type, role, capabilities and units with its source.`})]}),r(`button`,{type:`button`,disabled:i.isPending,onClick:()=>{n(null),i.mutate({camDeviceId:e})},className:`inline-flex shrink-0 items-center gap-1.5 rounded-md border border-border bg-background px-3 py-1.5 text-xs font-medium text-foreground hover:bg-surface disabled:opacity-50`,children:[u(T,{className:`h-3 w-3 ${i.isPending?`animate-spin`:``}`}),i.isPending?`Re-syncing…`:`Re-sync`]})]}),t!==null&&u(`p`,{className:`mt-2 text-[11px] text-foreground-subtle`,children:t})]})}n();var fi=`w-full min-w-0 px-1.5 py-0.5 text-[11px] bg-background border border-border rounded focus:outline-none focus:border-primary disabled:opacity-50`,pi={icon:``,label:``,unit:``,precision:``,hidden:!1};function mi(e){return{icon:e?.icon??``,label:e?.label??``,unit:e?.unit??``,precision:e?.precision===void 0?``:String(e.precision),hidden:e?.hidden===!0}}function hi(e){if(typeof e!=`object`||!e)return;let t=e.unit;return typeof t==`string`?t:void 0}function gi(e){let t=e.precision.trim()===``?void 0:Number.parseInt(e.precision,10),n={...e.icon===``?{}:{icon:e.icon},...e.label.trim()===``?{}:{label:e.label.trim()},...e.unit===``?{}:{unit:e.unit},...t!==void 0&&Number.isFinite(t)?{precision:t}:{},...e.hidden?{hidden:!0}:{}};return Object.keys(n).length===0?null:n}function _i({deviceId:e}){let t=m(),n=s(),{data:a}=Y({deviceId:e},{enabled:e>0}),l=typeof a?.role==`string`?a.role:null,d=l===null?void 0:_t[l],f=d?.kind===`numeric`,p=Le(t.trpcClient,e,l??``),h=d?.kind===`numeric`?d.canonicalUnit:void 0,g=hi(p)??h,_=g===void 0?void 0:sn(g),v=i(()=>_===void 0?[]:on(_),[_]),[y,b]=c(null),x=y??mi(a?.display),S=Ke({onSuccess:()=>{n.invalidateQueries({queryKey:[[`deviceManager`]]})}}),{data:C}=Se({},{staleTime:6e4}),w=Ht({onSuccess:()=>{n.invalidateQueries({queryKey:[[`deviceManager`]]})}});if(a===void 0||l===null)return null;let T=e=>{b({...x,...e})},E=()=>{S.mutate({deviceId:e,display:gi(x)})},D=()=>{b(pi),S.mutate({deviceId:e,display:null})},O=()=>{let e={...x.icon===``?{}:{icon:x.icon},...x.unit===``?{}:{unit:x.unit},...x.precision.trim()!==``&&Number.isFinite(Number.parseInt(x.precision,10))?{precision:Number.parseInt(x.precision,10)}:{}},t={...C?.defaults,[l]:e};w.mutate({defaults:t})},k=ie(l).label,ee=Object.keys(H);return r(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[u(`div`,{className:`border-b border-border px-3 sm:px-4 py-2`,children:u(`h2`,{className:`text-[11px] font-semibold text-foreground uppercase tracking-wider`,children:`Display`})}),r(`div`,{className:`divide-y divide-border`,children:[u($,{label:`Icon`,value:r(`select`,{className:fi,value:x.icon,onChange:e=>T({icon:e.target.value}),children:[r(`option`,{value:``,children:[`Default (`,k,`)`]}),ee.map(e=>u(`option`,{value:e,children:e},e))]})}),u($,{label:`Label`,value:u(`input`,{type:`text`,className:fi,placeholder:k,value:x.label,onChange:e=>T({label:e.target.value})})}),f&&r(o,{children:[u($,{label:`Unit`,value:r(`select`,{className:fi,value:x.unit,onChange:e=>T({unit:e.target.value}),disabled:v.length===0,children:[r(`option`,{value:``,children:[`Source`,g?` (${g})`:``]}),v.map(e=>u(`option`,{value:e,children:e},e))]})}),u($,{label:`Precision`,value:u(`input`,{type:`number`,min:0,max:10,step:1,className:fi,placeholder:`inherit`,value:x.precision,onChange:e=>T({precision:e.target.value})})})]}),u($,{label:`Hidden`,value:r(`label`,{className:`flex items-center gap-2`,children:[u(`input`,{type:`checkbox`,checked:x.hidden,onChange:e=>T({hidden:e.target.checked})}),u(`span`,{className:`text-[11px] text-foreground`,children:`Hide from device lists`})]})})]}),r(`div`,{className:`border-t border-border px-3 sm:px-4 py-2 flex flex-wrap items-center gap-2`,children:[u(`button`,{type:`button`,className:`rounded bg-primary px-3 py-1 text-[11px] font-medium text-primary-foreground disabled:opacity-50`,onClick:E,disabled:S.isPending,children:`Save`}),u(`button`,{type:`button`,className:`rounded border border-border px-3 py-1 text-[11px] text-foreground-subtle`,onClick:D,disabled:S.isPending,children:`Reset`}),r(`button`,{type:`button`,className:`rounded border border-border px-3 py-1 text-[11px] text-foreground-subtle`,onClick:O,disabled:w.isPending,title:`Apply this unit / precision / icon as the default for every ${k} sensor`,children:[`Set as default for all `,k,` sensors`]})]})]})}function vi(e){return e<1e3?`${e.toFixed(0)} kbps`:`${(e/1e3).toFixed(1)} Mbps`}function yi({device:e}){let t=un(),n=typeof e.id==`number`?e.id:null,i=String(e.type??``),a=i===X.Camera,o=i===X.Hub,s=typeof e.role==`string`&&e.role.length>0,c=e.features??[],l=c.includes(ln.Resyncable),{data:d}=Bt({deviceId:n??0},{enabled:n!==null&&a,refetchInterval:5e3}),f=d?.streams??{},p=Object.entries(f),m=c.includes(ln.DoorbellButton),h=Xe(m?{deviceId:n??void 0,historyLimit:10}:void 0),g=h.latest?Date.now()-h.latest.timestamp<3e4:!1;return r(`div`,{className:`space-y-5`,children:[o&&n!==null&&u(Fe,{deviceId:n,onOpenChild:e=>t(`/devices/${e}`)}),l&&n!==null&&u(di,{deviceId:n}),a&&n!==null&&u(li,{deviceId:n,deviceName:String(e.name??``)}),n!==null&&u(ii,{deviceId:n}),a&&n!==null&&u(R,{widgetId:`pipeline-orchestrator/pipeline-quick-stats`,host:`device-tab`,deviceId:n}),m&&u(zt,{history:h.history,latestIsFresh:g}),a&&n!==null&&u(R,{widgetId:`stream-broker/stream-broker-panel`,host:`device-tab`,deviceId:n}),a&&p.length>0&&r(`div`,{className:`@container rounded-lg border border-border bg-surface overflow-hidden`,style:{containerType:`inline-size`},children:[u(`div`,{className:`border-b border-border px-4 py-2`,children:u(`h2`,{className:`text-xs font-semibold text-foreground uppercase tracking-wider`,children:`Stream Network`})}),u(`div`,{className:`divide-y divide-border`,children:p.map(([e,t])=>r(`div`,{className:`px-4 py-2.5`,children:[r(`div`,{className:`flex items-center gap-2 mb-2`,children:[u(G,{className:`h-3 w-3 text-foreground-subtle`}),u(`span`,{className:`text-[11px] font-medium text-foreground`,children:e})]}),r(`div`,{className:`grid grid-cols-2 @[640px]:grid-cols-4 gap-2`,children:[u(bi,{label:`Nominal`,value:vi(t.nominalBitrateKbps??0)}),u(bi,{label:`Observed`,value:vi(t.observedBitrateKbps??0)}),u(bi,{label:`Peak`,value:vi(t.peakBitrateKbps??0)}),u(bi,{label:`Packet Loss`,value:`${(t.packetLossPercent??0).toFixed(2)}%`,warning:(t.packetLossPercent??0)>1})]})]},e))})]}),u(Xr,{}),s&&n!==null&&u(_i,{deviceId:n})]})}function bi({label:e,value:t,warning:n}){return r(`div`,{children:[u(`p`,{className:`text-[10px] text-foreground-subtle`,children:e}),u(`p`,{className:`text-xs font-medium ${n?`text-warning`:`text-foreground`}`,children:t})]})}function xi({provider:e,integrationId:t,name:n}){let r=un(),i=t===null?`/integrations`:`/integrations/${t}`,a=n===null?`Open integrations`:`Open integration ${n}`;return u(`button`,{type:`button`,onClick:()=>r(i),className:`shrink-0 rounded-md transition-opacity hover:opacity-80 focus:outline-none focus-visible:ring-1 focus-visible:ring-primary/50`,title:a,"aria-label":a,children:u(Yt,{type:e,size:`lg`})})}n();var Si=[{id:`overview`,label:`Overview`,cameraOnly:!1},{id:`config`,label:`Config`,cameraOnly:!1},{id:`detection-pipeline`,label:`Detection pipeline`,cameraOnly:!0},{id:`bindings`,label:`Bindings`,cameraOnly:!0}];function Ci(e){let t=e===X.Camera;return Si.filter(e=>t||!e.cameraOnly).map(({id:e,label:t})=>({id:e,label:t}))}var wi=[{id:`logs`,icon:Ce,label:`Logs`},{id:`repl`,icon:dn,label:`REPL`},{id:`events`,icon:Pe,label:`Events`},{id:`state`,icon:W,label:`State`}];function Ti(){let n=pn(),a=Number(n.deviceId),l=Number.isFinite(a),d=un(),f=s(),p=rt(),h=m(),[_,y]=mn(),b=_.get(`tab`)??`overview`,x=_.get(`sub`),[w,E]=c(`logs`),D=`device-detail.left-col-width-px`,[k,ee]=c(()=>{if(typeof window>`u`)return null;let e=window.localStorage.getItem(D),t=e?Number(e):NaN;return Number.isFinite(t)&&t>0?t:null}),A=t(k);A.current=k;function j(e){e.preventDefault();let t=e.clientX,n=e.currentTarget.previousElementSibling?.getBoundingClientRect().width??k??0,r=Math.max(330,Math.floor(window.innerWidth*.7)),i=e=>{ee(Math.max(280,Math.min(r,n+(e.clientX-t))))},a=()=>{document.removeEventListener(`mousemove`,i),document.removeEventListener(`mouseup`,a);let e=A.current;if(e!==null)try{window.localStorage.setItem(D,String(Math.round(e)))}catch{}document.body.style.userSelect=``,document.body.style.cursor=``};document.body.style.userSelect=`none`,document.body.style.cursor=`col-resize`,document.addEventListener(`mousemove`,i),document.addEventListener(`mouseup`,a)}let{data:te,isLoading:ne,isError:re}=Y({deviceId:a},{enabled:l,refetchInterval:5e3,retry:1}),{data:M}=se({deviceId:a},{enabled:l}),N=i(()=>{let e=M?.settings?.sections??[],t=M?.live?.sections??[],n=[...e,...t],r=new Set;for(let e of n)e.location===`top-tab`&&e.tab&&r.add(e.tab===`zones`?`detection-pipeline`:e.tab);return n.some(yn)&&r.add(bn),[...r].map(e=>e===`export`?{id:e,label:xn,isAddonContrib:!0}:{id:e,label:rn[e]?.label??e,isAddonContrib:!0})},[M]),P=te,F=String(P?.name??n.deviceId??`Device`),ie=P?.online===!0,ae=ie?`online`:`offline`,I=String(P?.addonId??`rtsp`),L=P?.features??[],R=P?.type,z=R===X.Camera,{data:B}=Zt(l?a:0),ce=R===X.Container,V=i(()=>(B??[]).map(e=>({id:e.id,stableId:e.stableId,type:e.type,...e.sourceInfo?{sourceInfo:{id:e.sourceInfo.id}}:{}})),[B]),H=i(()=>ce?_e(V,typeof P?.linkDeviceId==`number`?P.linkDeviceId:null,typeof P?.primaryChildEntityId==`string`?P.primaryChildEntityId:null)?.id??null:null,[ce,V,P?.linkDeviceId,P?.primaryChildEntityId]),{data:U}=se({deviceId:H??0},{enabled:H!==null}),fe=i(()=>{if(H===null)return[];let e=U?.settings?.sections??[],t=U?.live?.sections??[],n=new Set;for(let r of[...e,...t])r.location===`top-tab`&&r.tab&&n.add(r.tab);return[...n].map(e=>({id:e,label:rn[e]?.label??e,isAddonContrib:!0,childDeviceId:H}))},[H,U]),W=typeof P?.parentDeviceId==`number`?P.parentDeviceId:null,{data:me}=Y({deviceId:W??0},{enabled:W!==null}),G=Ie(),K=P?.disabled!==!0,he=i(()=>{let e=new Set,t=[];for(let n of[...Ci(R),...N,...fe])e.has(n.id)||(e.add(n.id),t.push(n));return t},[R,N,fe]),ye=i(()=>Er(he,b),[he,b]),be=e(e=>{y(t=>{let n=new URLSearchParams(t);return e===`overview`?n.delete(`tab`):n.set(`tab`,e),n.delete(`sub`),n},{replace:!0})},[y]),q=e(e=>{y(t=>{let n=new URLSearchParams(t);return n.set(`sub`,e),n},{replace:!0})},[y]),xe=(B??[]).length>0,Se=i(()=>wi.filter(({featureGate:e})=>!e||L.includes(e)),[L]),{data:J}=ve({addonId:I},{enabled:!!I&&I!==`rtsp`}),Ce=ut({onSuccess:()=>{f.invalidateQueries({queryKey:[[`deviceManager`]]}),d(J?.id?`/integrations/${J.id}`:`/integrations`)}}),we=ge({onSuccess:()=>{f.invalidateQueries({queryKey:[[`deviceManager`]]})}}),Te=pe({onSuccess:()=>{f.invalidateQueries({queryKey:[[`deviceManager`]]})}}),De=oe(),Oe=Gt({onSuccess:()=>{f.invalidateQueries({queryKey:[[`deviceManager`]]})}}),ke=L.includes(ln.Rebootable),Ae=L.includes(ln.BatteryOperated),je=$e(h.trpcClient,Ae&&l?a:null),Me=O(h.trpcClient,l?a:null),[Ne,Pe]=c(!1),Fe=async()=>{if(!Ne){Pe(!0);try{let e=F.replace(/[^a-zA-Z0-9_.-]+/g,`_`),t=new Date().toISOString().replace(/[:.]/g,`-`);await gn(`${v}/${String(a)}.jpg?force=1`,`${e}-${t}.jpg`)}finally{Pe(!1)}}},Le=we.isPending||Te.isPending,{data:Re}=kt({deviceId:a},{enabled:l,refetchInterval:1e4}),Be=Re?.agentNodeId??null,Ve=typeof Be==`string`&&Be.length>0&&!Be.startsWith(`addon:`)?Be:void 0,{data:He}=le({deviceId:a,...Ve?{nodeId:Ve}:{}},{enabled:l,refetchInterval:3e3,retry:!1}),{data:Ue}=Et({deviceId:a},{enabled:l,refetchInterval:3e3,retry:!1}),We=Ue?.level?.dbfs??null;function Ge(){if(!l)return null;switch(ye){case`overview`:return u(yi,{device:P??{}});case`config`:return u(jr,{deviceId:a,activeSubTab:x,onSubTabChange:q});case`detection-pipeline`:return u(Ur,{deviceId:a,activeSubTab:x,onSubTabChange:q});case`bindings`:return u(Dr,{deviceId:a});default:{let e=ye,t=N.some(t=>t.id===e),n=fe.find(t=>t.id===e);if(!t&&n===void 0)return null;let r=n?.childDeviceId??a;if(e===`export`)return u(Sn,{deviceId:a,sectionFilter:yn,activeSubTab:x,onSubTabChange:q});let i=u(Sn,{deviceId:r,sectionFilter:t=>t.location===`top-tab`&&(t.tab===e||e===`detection-pipeline`&&t.tab===`zones`),flattenSubTabs:e===`detection-pipeline`,activeSubTab:x,onSubTabChange:q});return n!==void 0&&r!==a?u(Ze,{deviceId:r,children:i}):i}}}return l?ne?r(`div`,{className:`flex flex-col h-full`,children:[r(`div`,{className:`border-b border-border bg-surface px-6 py-4`,children:[u(`div`,{className:`h-4 w-48 rounded bg-surface-hover animate-pulse mb-3`}),u(`div`,{className:`h-8 w-64 rounded bg-surface-hover animate-pulse`})]}),u(`div`,{className:`flex-1 p-6`,children:u(`div`,{className:`h-40 rounded-lg border border-border bg-surface animate-pulse`})})]}):re||!te?r(`div`,{className:`flex flex-col items-center justify-center h-full gap-3 text-foreground-subtle`,children:[u(`p`,{className:`text-lg font-semibold text-foreground`,children:`Device not found`}),r(`p`,{className:`text-xs`,children:[`No device with ID`,` `,r(`code`,{className:`font-mono bg-surface px-1.5 py-0.5 rounded text-[11px]`,children:[`#`,a]})]}),u(`button`,{onClick:()=>d(`/integrations`),className:`mt-2 rounded-lg bg-primary px-4 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 transition-colors`,children:`Back to Integrations`})]}):r(`div`,{className:`absolute inset-0 flex flex-col overflow-clip`,children:[r(`div`,{className:`border-b border-border bg-surface px-6 py-3 flex-shrink-0`,children:[u(`div`,{className:`mb-2`,children:u(ze,{items:[{label:`Integrations`,onClick:()=>d(`/integrations`)},{label:J?.name??I,onClick:()=>J?.id&&d(`/integrations/${J.id}`)},{label:F}]})}),r(`div`,{className:`flex items-center gap-2 sm:gap-3`,children:[u(xi,{provider:I,integrationId:J?.id??null,name:J?.name??null}),r(`div`,{className:`min-w-0 flex-1`,children:[r(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[u(`h1`,{className:`text-sm sm:text-base font-semibold text-foreground truncate`,children:F}),u(_n,{status:ae}),Ae&&u(At,{status:je,variant:`full`}),u(it,{status:Me})]}),W!==null&&me&&r(`button`,{type:`button`,onClick:()=>d(`/devices/${W}`),className:`text-[10px] text-foreground-subtle hover:text-primary transition-colors mt-0.5 inline-flex items-center gap-1`,title:`Open parent device ${me.name}`,children:[u(`span`,{children:`↑`}),u(`span`,{className:`truncate`,children:String(me.name??`Device #${W}`)})]}),u(`div`,{className:`hidden md:flex items-center gap-3 mt-0.5 text-[10px] text-foreground-subtle`,children:L.length>0&&u(tn,{capabilities:L})})]}),He&&u(`div`,{className:`hidden lg:flex`,children:u(Ei,{metrics:He,dbfs:We})}),r(`div`,{className:`flex items-center gap-1 shrink-0`,children:[r(`button`,{onClick:async()=>{K?await p({title:`Disable "${F}"?`,message:`The device will stop processing streams and events. You can re-enable it later.`,confirmLabel:`Disable`,variant:`danger`})&&Te.mutate({deviceId:a}):we.mutate({deviceId:a})},disabled:Le,title:K?`Disable device`:`Enable device`,className:`inline-flex items-center gap-1.5 rounded-lg px-2 sm:px-2.5 py-1.5 text-[11px] font-medium border transition-colors disabled:opacity-50 ${K?`border-success/30 text-success hover:bg-success/10`:`border-border text-foreground-subtle/50 hover:text-foreground hover:bg-surface-hover`}`,children:[u(st,{className:`h-3.5 w-3.5`}),u(`span`,{className:`hidden sm:inline`,children:Le?`Updating…`:K?`Enabled`:`Disabled`})]}),u(`div`,{className:`hidden sm:block h-5 w-px bg-border mx-1`}),z&&r(o,{children:[u(Rn,{deviceId:a}),u(`div`,{className:`hidden sm:block h-5 w-px bg-border mx-1`})]}),u(jt,{triggerClassName:`ml-1`,items:[{id:`snapshot`,label:`Take snapshot`,description:`Fetch a fresh frame and download it.`,icon:g,disabled:Ne,onClick:()=>{Fe()}},{id:`reboot`,label:`Reboot device`,description:`Camera goes offline for ~30 seconds.`,icon:ue,hidden:!ke,disabled:De.isPending,danger:!0,onClick:async()=>{await p({title:`Reboot "${F}"?`,message:`The camera will go offline for around 30 seconds while the firmware reboots.`,confirmLabel:`Reboot`,variant:`danger`})&&De.mutate({deviceId:a})}},{id:`restart-addon`,label:`Restart addon`,description:`Bounces every device served by ${J?.name??I}.`,icon:T,disabled:Oe.isPending,danger:!0,onClick:async()=>{await p({title:`Restart "${J?.name??I}"?`,message:`Restarting the addon will briefly disconnect every device served by it (not just "${F}"). Streams will reconnect automatically.`,confirmLabel:`Restart`,variant:`danger`})&&Oe.mutate({addonId:I})}},{id:`delete`,label:`Delete device`,description:`Remove the device and all its settings.`,icon:S,separatorBefore:!0,disabled:Ce.isPending,danger:!0,onClick:async()=>{await p({title:`Delete "${F}"?`,message:`This will remove the device and all its settings. This action cannot be undone.`,confirmLabel:`Delete`,variant:`danger`})&&Ce.mutate({deviceId:a})}}]})]})]})]}),u(Ze,{deviceId:a,device:P??void 0,children:u(de,{children:u(Ee,{children:u(C,{children:u(tt,{children:r(`main`,{className:G?`flex-1 overflow-y-auto flex flex-col`:`flex-1 min-h-0 overflow-hidden flex flex-row`,children:[r(`div`,{className:G?`flex flex-col bg-surface`:`${k===null?`w-1/2 lg:w-1/3`:``} flex-shrink-0 flex flex-col bg-surface min-h-0 overflow-hidden`,style:!G&&k!==null?{width:`${String(k)}px`}:void 0,children:[u(`div`,{className:z?`flex-shrink-0 border-b border-border-subtle bg-black`:G?`flex-shrink-0 border-b border-border-subtle bg-surface`:`max-h-[55%] shrink-0 overflow-y-auto border-b border-border-subtle bg-surface`,children:z?u(yr,{deviceId:a,intercomAvailable:L.includes(ln.TwoWayAudio)}):u(ur,{deviceId:a,deviceName:F,deviceType:R??`unknown`,provider:I,isOnline:ie,features:L})}),r(`div`,{className:G?`flex flex-col border-b border-border`:`flex-1 min-h-0 flex flex-col overflow-hidden`,children:[u(`div`,{className:`flex-shrink-0 border-b border-border-subtle px-2 py-1.5`,children:u(`div`,{className:`flex gap-1 overflow-x-auto -mx-1 px-1 pb-0.5`,children:Se.map(({id:e,label:t,icon:n})=>r(`button`,{onClick:()=>E(e),title:t,className:`flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium transition-colors flex-shrink-0 ${w===e?`bg-primary/15 text-primary`:`text-foreground-subtle hover:text-foreground hover:bg-surface-hover`}`,children:[u(n,{className:`h-3 w-3`}),t]},e))})}),r(`div`,{className:G?`h-72 overflow-hidden`:`flex-1 min-h-0 overflow-hidden`,children:[w===`logs`&&u(br,{deviceId:a,containerDeviceId:R===`container`?a:void 0}),w===`repl`&&u(xr,{deviceId:a}),w===`events`&&u(Sr,{deviceId:a}),w===`state`&&u(Cr,{deviceId:a})]})]})]}),!G&&u(`div`,{role:`separator`,"aria-orientation":`vertical`,title:`Drag to resize`,onMouseDown:j,className:`flex-shrink-0 w-1 cursor-col-resize bg-border hover:bg-primary/40 transition-colors group relative z-10`,children:u(`span`,{className:`absolute inset-y-0 -left-1 -right-1`})}),r(`div`,{className:G?`flex flex-col`:`flex-1 min-w-0 min-h-0 flex flex-col overflow-hidden`,children:[u(`div`,{className:`flex-shrink-0 border-b border-border bg-surface px-4`,children:u(`div`,{className:`flex flex-nowrap overflow-x-auto md:flex-wrap md:overflow-x-visible items-center gap-0`,children:he.map(e=>{let t=ye===e.id;return r(`button`,{onClick:()=>be(e.id),className:`relative flex-shrink-0 px-3 py-2 text-xs font-medium transition-colors ${t?`text-primary`:`text-foreground-subtle hover:text-foreground`}`,children:[e.label,t&&u(`span`,{className:`absolute bottom-0 left-0 right-0 h-0.5 rounded-full bg-primary`})]},e.id)})})}),r(`div`,{className:G?`p-3 flex flex-col gap-3`:`flex-1 min-h-0 overflow-y-auto p-4 flex flex-col gap-3`,children:[ye===`overview`&&xe&&u(Vn,{parentDeviceId:a}),Ge()]})]})]})})})})})})]}):r(`div`,{className:`flex flex-col items-center justify-center h-full gap-3 text-foreground-subtle`,children:[u(`p`,{className:`text-lg font-semibold text-foreground`,children:`Invalid device id`}),r(`p`,{className:`text-xs`,children:[`The URL segment`,` `,u(`code`,{className:`font-mono bg-surface px-1.5 py-0.5 rounded text-[11px]`,children:n.deviceId}),` `,`is not a number.`]}),u(`button`,{onClick:()=>d(`/integrations`),className:`mt-2 rounded-lg bg-primary px-4 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 transition-colors`,children:`Back to Integrations`})]})}function Ei({metrics:e,dbfs:t}){let n=ct(e.phase??`idle`);return r(`div`,{className:`flex items-center gap-3 flex-shrink-0`,children:[r(`div`,{className:`flex items-center gap-1.5`,children:[u(`span`,{className:`h-1.5 w-1.5 rounded-full ${n.dotClass}`}),u(`span`,{className:`text-[10px] font-medium ${n.textColor}`,children:n.label})]}),u(`div`,{className:`h-3 w-px bg-border`}),r(`div`,{className:`flex items-center gap-1 text-[10px] text-foreground-subtle`,children:[u(Ae,{className:`h-3 w-3`}),u(`span`,{className:`text-foreground tabular-nums`,children:(e.actualFps??0).toFixed(1)}),u(`span`,{children:`fps`})]}),r(`div`,{className:`flex items-center gap-1 text-[10px] text-foreground-subtle`,children:[u(Wt,{className:`h-3 w-3`}),u(`span`,{className:`text-foreground tabular-nums`,children:(e.avgInferenceTimeMs??0).toFixed(0)}),u(`span`,{children:`ms`})]}),r(`div`,{className:`flex items-center gap-1 text-[10px] text-foreground-subtle`,title:`Current audio level (dBFS)`,children:[u(Ft,{className:`h-3 w-3`}),u(`span`,{className:`text-foreground tabular-nums`,children:t==null?`—`:t.toFixed(0)}),u(`span`,{children:`dB`})]}),(e.queueDepth??0)>0&&r(`span`,{className:`text-[10px] text-warning tabular-nums`,children:[`q:`,e.queueDepth]})]})}export{Ti as DeviceDetailPage};
@@ -1 +0,0 @@
1
- import{I as e,K as t,Q as n,S as r,W as i,b as a,q as o,x as s,z as ee}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{G as c,M as l,W as te,Y as u,at as d,n as f}from"./player-overlays-qQtL3R3x.js";import{t as p}from"./grid-2x2-G4yOYg6v.js";import{MaskShapeCanvas as m}from"./MaskShapeCanvas-Dcpby34M.js";n();var h=110,g=`motion-zones`,_=0,v=[1,2,3],y=1,b=`rounded-md border border-border bg-surface px-2 py-1 text-[11px] font-medium text-foreground-subtle hover:bg-surface-hover disabled:opacity-40 transition-colors`,x=`rounded-md border border-primary/50 bg-primary/15 px-2.5 py-1 text-[11px] font-medium text-primary hover:bg-primary/25 disabled:opacity-40 transition-colors`;function S(e,t,n){let r=t*n,i=Array.from({length:r});for(let t=0;t<r;t+=1)i[t]=e[t]===!0;return i}function ne(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(e[n]!==t[n])return!1;return!0}function C(e,t){return Math.ceil(e/t)}function w(e,t,n){return Math.min(n-1,Math.floor((e+.5)/t*n))}function T(e,t,n,r){let i=C(t,r),a=C(n,r),o=Array.from({length:i*a},()=>!1);for(let r=0;r<n;r+=1){let s=w(r,n,a);for(let n=0;n<t;n+=1)e[r*t+n]===!0&&(o[s*i+w(n,t,i)]=!0)}return o}function E(e,t,n,r){let i=C(t,r),a=C(n,r),o=Array.from({length:t*n},()=>!1);for(let r=0;r<n;r+=1){let s=w(r,n,a);for(let n=0;n<t;n+=1)o[r*t+n]=e[s*i+w(n,t,i)]===!0}return o}function D({deviceId:n}){let w=c(d().trpcClient,n),[D,O]=o(null),[k,A]=o(!1),[j,M]=o(null),[N,P]=o(null),[F,I]=o(y),[L,R]=o(!1),[z,B]=o(!1),V=t(!1);ee(()=>{if(!w)return;let e=!1;return V.current=!1,O(null),A(!1),M(null),P(null),I(y),B(!1),(async()=>{try{let t=await w.motionZones?.getOptions({});if(e)return;if(!t)throw Error(`device proxy not ready`);if(O(t),V.current)return;let n=await w.motionZones?.getStatus({});if(e)return;if(!n)throw Error(`device proxy not ready`);V.current=!0;let r=n.regions.find(e=>e.shape.kind===`grid`),i=S(r?r.shape.cells:[],t.grid.width,t.grid.height);P(i),M(T(i,t.grid.width,t.grid.height,y))}catch(t){if(e)return;te(t)?A(!0):console.error(`Motion Zones load failed`,t)}})(),()=>{e=!0}},[w]);let H=D?D.grid.width:0,U=D?D.grid.height:0,W=C(H,F),G=C(U,F),K=i(()=>j&&D?E(j,H,U,F):null,[j,D,H,U,F]),q=i(()=>K!==null&&N!==null&&!ne(K,N),[K,N]),J=i(()=>K?K.reduce((e,t)=>t?e+1:e,0):0,[K]),Y=H*U,X=W*G,Z=e(e=>{X>0&&M(Array.from({length:X},()=>e))},[X]),re=e(()=>{M(e=>e&&e.map(e=>!e))},[]),ie=e(()=>{N&&D&&M(T(N,H,U,F))},[N,D,H,U,F]),ae=e(e=>{e===F||!D||M(t=>{if(!t)return I(e),t;let n=T(E(t,H,U,F),H,U,e);return I(e),n})},[F,D,H,U]),Q=i(()=>D&&j?[{id:_,shape:{kind:`grid`,gridWidth:W,gridHeight:G,cells:[...j]}}]:[],[D,j,W,G]),$=e((e,t)=>{t.kind===`grid`&&M(t.cells)},[]),oe=e(async()=>{if(!(!w||!j||!D)){R(!0);try{let e=E(j,D.grid.width,D.grid.height,F),t={kind:`grid`,gridWidth:D.grid.width,gridHeight:D.grid.height,cells:e};await w.motionZones?.setZone({patch:{regions:[{id:_,enabled:!0,shape:t}]}});let n=await w.motionZones?.getStatus({});if(n){let e=n.regions.find(e=>e.shape.kind===`grid`),t=S(e?e.shape.cells:[],D.grid.width,D.grid.height);P(t),M(T(t,D.grid.width,D.grid.height,F))}}catch(e){console.error(`Motion Zones save failed`,e)}finally{R(!1)}}},[w,j,D,F]);return f(i(()=>z&&!k&&D&&j?{id:g,order:h,node:s(m,{transparent:!0,items:Q,supportedShapes:[`grid`],grid:{width:W,height:G},selectedId:_,onSelect:()=>{},onShapeChange:$,onDrawComplete:()=>{},drawingKind:null})}:null,[z,k,D,j,Q,$,W,G])),w?s(u,{title:`Motion Zones`,icon:s(p,{className:`h-3.5 w-3.5 text-foreground-subtle`}),children:s(`div`,{className:`flex flex-col gap-3`,children:k?s(`p`,{className:`${l} leading-relaxed`,children:`This camera doesn't expose an on-board motion zones grid.`}):!k&&D!==null&&j!==null?r(a,{children:[r(`p`,{className:`${l} leading-relaxed`,children:[`Toggle `,s(`strong`,{className:`text-foreground`,children:`Edit grid`}),` to paint the region directly on the live frame, then `,s(`strong`,{className:`text-foreground`,children:`Save`}),` to push the mask to the camera. Pick a bigger`,` `,s(`strong`,{className:`text-foreground`,children:`Cell size`}),` for quicker, broad-stroke painting — it's resampled to the camera's native `,D.grid.width,`×`,D.grid.height,` grid on save (×1 is the finest).`]}),r(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[s(`button`,{type:`button`,onClick:()=>B(e=>!e),disabled:L,"aria-pressed":z,className:z?x:b,children:z?`Done editing`:`Edit grid`}),s(`button`,{type:`button`,onClick:()=>Z(!0),disabled:L,className:b,children:`All on`}),s(`button`,{type:`button`,onClick:()=>Z(!1),disabled:L,className:b,children:`All off`}),s(`button`,{type:`button`,onClick:re,disabled:L,className:b,children:`Invert`}),r(`div`,{className:`flex items-center gap-1 ml-1`,role:`group`,"aria-label":`Cell size`,children:[s(`span`,{className:`${l} mr-0.5`,children:`Cell size`}),v.map(e=>r(`button`,{type:`button`,onClick:()=>ae(e),disabled:L,"aria-pressed":F===e,title:e===1?`Camera grid ${H}×${U} (finest)`:`${C(H,e)}×${C(U,e)} painting grid · cells ×${e} bigger`,className:F===e?x:b,children:[`×`,e]},e))]}),r(`span`,{className:`${l} ml-1 tabular-nums`,children:[J,` / `,Y,` cells · `,D.grid.width,`×`,D.grid.height,F===1?``:` · paint ${W}×${G}`]}),s(`span`,{className:`flex-1`}),s(`button`,{type:`button`,onClick:ie,disabled:L||!q,className:`rounded-md border border-border bg-surface px-2 py-1 text-[11px] text-foreground-subtle hover:bg-surface-hover disabled:opacity-40 transition-colors`,children:`Revert`}),s(`button`,{type:`button`,onClick:()=>void oe(),disabled:L||!q,className:x,children:L?`Saving…`:`Save`})]})]}):s(`p`,{className:`${l} leading-relaxed`,children:`Loading the camera's grid…`})})}):null}export{D as MotionZonesSettings};
@@ -1 +0,0 @@
1
- import{I as e,K as t,Q as n,S as r,W as i,b as ee,q as a,x as o,z as s}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{G as te,M as c,W as ne,Y as re,at as ie,ct as l,ft as ae,gt as u,n as oe,st as se,ut as ce}from"./player-overlays-qQtL3R3x.js";import{MaskShapeCanvas as le}from"./MaskShapeCanvas-Dcpby34M.js";var ue=u(`hexagon`,[[`path`,{d:`M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z`,key:`yt0hxn`}]]),de=u(`mic-off`,[[`path`,{d:`M12 19v3`,key:`npa21l`}],[`path`,{d:`M15 9.34V5a3 3 0 0 0-5.68-1.33`,key:`1gzdoj`}],[`path`,{d:`M16.95 16.95A7 7 0 0 1 5 12v-2`,key:`cqa7eg`}],[`path`,{d:`M18.89 13.23A7 7 0 0 0 19 12v-2`,key:`16hl24`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M9 9v3a3 3 0 0 0 5.12 2.12`,key:`r2i35w`}]]);n();var d=`Microphone`,f=`The camera encodes no audio at all — live view, recordings, exports and the audio analyzer are all silent.`;function p(e){let t=e.supportsAudioMute===!0,n=t?e.audioEnabled:null,r=e.pendingOn??null;return{label:d,supported:t,on:n===null?null:r??n,available:t&&n!==null,costWhenOff:f}}function m(e){return!e.available||e.on===null?null:{enabled:!e.on}}var fe=120,pe=`privacy-mask`,h=`rounded-md border border-border bg-surface px-2 py-1 text-[11px] font-medium text-foreground-subtle hover:bg-surface-hover disabled:opacity-40 transition-colors`,g=`rounded-md border border-primary/50 bg-primary/15 px-2.5 py-1 text-[11px] font-medium text-primary hover:bg-primary/25 disabled:opacity-40 transition-colors`;function _(e){return e.kind===`rect`||e.kind===`polygon`?e:null}function me(e){let t=new Set(e.map(e=>e.id)),n=0;for(;t.has(n);)n+=1;return n}function he(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(JSON.stringify(e[n])!==JSON.stringify(t[n]))return!1;return!0}function v({deviceId:n}){let u=te(ie().trpcClient,n),[d,f]=a(null),[v,y]=a(!1),[b,x]=a(!1),[S,C]=a(null),[w,T]=a(null),[E,D]=a(!1),[O,k]=a(!1),[A,j]=a(null),[M,N]=a(null),[ge,P]=a(null),[F,I]=a(null),[L,R]=a(null),z=t(!1);s(()=>{if(!u)return;let e=!1;return z.current=!1,f(null),y(!1),x(!1),C(null),T(null),k(!1),j(null),N(null),P(null),I(null),R(null),(async()=>{try{let t=await u.privacyMask?.getOptions({});if(e)return;if(!t)throw Error(`device proxy not ready`);if(f(t),z.current)return;let n=await u.privacyMask?.getStatus({});if(e)return;if(!n)throw Error(`device proxy not ready`);if(n.regions===null){x(!0),P(n.audioEnabled);return}z.current=!0;let r={enabled:n.enabled,regions:n.regions};T(r),C(r),P(n.audioEnabled)}catch(t){if(e)return;ne(t)?y(!0):console.error(`Privacy Mask load failed`,t)}})(),()=>{e=!0}},[u]);let B=i(()=>S!==null&&w!==null&&(S.enabled!==w.enabled||!he(S.regions,w.regions)),[S,w]),V=S?S.regions.length:0,H=d?d.maxRegions:0,U=t(0);s(()=>{U.current=H},[H]);let W=H>0&&V>=H,_e=e(()=>{C(e=>e&&{...e,enabled:!e.enabled})},[]),G=e(e=>{j(typeof e==`number`?e:null)},[]),K=i(()=>S?S.regions.map(e=>({id:e.id,shape:e.shape,enabled:e.enabled,label:`Zone ${String(e.id)}`})):[],[S]),q=e((e,t)=>{let n=_(t);n&&C(t=>t&&{...t,regions:t.regions.map(t=>t.id===e?{...t,shape:n}:t)})},[]),J=e(e=>{let t=_(e);t&&(N(null),C(e=>{if(!e)return e;let n=U.current;if(n>0&&e.regions.length>=n)return e;let r=me(e.regions),i={id:r,enabled:!0,shape:t};return j(r),{...e,regions:[...e.regions,i]}}))},[]),Y=e(e=>{k(!0),j(null),N(e)},[]),ve=e(e=>{k(!0),N(null),j(e)},[]),X=e(e=>{j(t=>t===e?null:t),C(t=>t&&{...t,regions:t.regions.filter(t=>t.id!==e)})},[]),ye=e(()=>{N(null),j(null),w&&C({enabled:w.enabled,regions:w.regions})},[w]),be=e(async()=>{if(!(!u||!S)){D(!0);try{await u.privacyMask?.setMask({patch:{enabled:S.enabled,regions:[...S.regions]}});let e=await u.privacyMask?.getStatus({});if(e&&e.regions!==null){let t={enabled:e.enabled,regions:e.regions};T(t),C(t)}}catch(e){console.error(`Privacy Mask save failed`,e)}finally{D(!1)}}},[u,S]),Z=p({supportsAudioMute:d===null?null:d.supportsAudioMute,audioEnabled:ge,pendingOn:F}),xe=e(async()=>{let e=m(Z);if(!(!u||e===null)){I(e.enabled),R(null);try{await u.privacyMask?.setAudioEnabled(e);let t=await u.privacyMask?.getStatus({});t&&P(t.audioEnabled)}catch(e){console.error(`Privacy microphone write failed — reverting`,e),R(e instanceof Error?e.message:String(e))}finally{I(null)}}},[u,Z]),Se=e(()=>{k(e=>(e&&(N(null),j(null)),!e))},[]),Q=d?.supportedShapes??[];oe(i(()=>O&&!v&&d&&S?{id:pe,order:fe,node:o(le,{transparent:!0,items:K,supportedShapes:Q,polygonVertices:d.polygonVertices,selectedId:A,onSelect:G,onShapeChange:q,onDrawComplete:J,drawingKind:M})}:null,[O,v,d,S,K,Q,A,G,q,J,M]));let Ce=d?.supportedShapes.includes(`rect`)??!1,we=d?.supportedShapes.includes(`polygon`)??!1,$=d!==null&&(d.maxRegions<=0||d.supportedShapes.length===0);return u?o(re,{title:`Privacy Mask`,icon:o(ae,{className:`h-3.5 w-3.5 text-foreground-subtle`}),children:r(`div`,{className:`flex flex-col gap-3`,children:[v||$?o(`p`,{className:`${c} leading-relaxed`,children:`This camera doesn't support an on-board privacy mask.`}):b?o(`p`,{className:`${c} leading-relaxed`,children:`This camera hasn't answered, so what it currently masks is unknown — the editor stays closed rather than showing an empty frame you could save over. A battery camera answers once it wakes; otherwise check that it is reachable.`}):!v&&!$&&!b&&d!==null&&S!==null?r(ee,{children:[r(`p`,{className:`${c} leading-relaxed`,children:[`Toggle `,o(`strong`,{className:`text-foreground`,children:`Edit mask`}),` to draw blanked-out zones on the live frame, then `,o(`strong`,{className:`text-foreground`,children:`Save`}),` to push them to the camera. Drag a rectangle to move, its corner to resize; drag polygon vertices, click an edge midpoint to add one, or right-click a vertex to remove it.`]}),r(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[o(`button`,{type:`button`,onClick:Se,disabled:E,"aria-pressed":O,className:O?g:h,children:O?`Done editing`:`Edit mask`}),o(`button`,{type:`button`,onClick:_e,disabled:E,"aria-pressed":S.enabled,className:S.enabled?g:h,children:S.enabled?`Mask on`:`Mask off`}),Ce&&o(`button`,{type:`button`,onClick:()=>Y(`rect`),disabled:E||W,"aria-pressed":M===`rect`,className:M===`rect`?g:h,title:W?`Maximum zones reached`:`Add a rectangle zone`,children:`+ Rect`}),we&&o(`button`,{type:`button`,onClick:()=>Y(`polygon`),disabled:E||W,"aria-pressed":M===`polygon`,className:M===`polygon`?g:h,title:W?`Maximum zones reached`:`Add a polygon zone`,children:`+ Polygon`}),r(`span`,{className:`${c} ml-1 tabular-nums`,children:[V,` / `,H,` zones`]}),o(`span`,{className:`flex-1`}),o(`button`,{type:`button`,onClick:ye,disabled:E||!B,className:`rounded-md border border-border bg-surface px-2 py-1 text-[11px] text-foreground-subtle hover:bg-surface-hover disabled:opacity-40 transition-colors`,children:`Revert`}),o(`button`,{type:`button`,onClick:()=>void be(),disabled:E||!B,className:g,children:E?`Saving…`:`Save`})]}),V>0?o(`div`,{className:`flex flex-col gap-1`,children:S.regions.map(e=>{let t=A===e.id,n=e.shape.kind===`polygon`?ue:l;return r(`div`,{className:`flex items-center gap-2 rounded-md border px-2 py-1 transition-colors ${t?`border-primary/50 bg-primary/10`:`border-border bg-surface`}`,children:[r(`button`,{type:`button`,onClick:()=>ve(e.id),disabled:E,className:`flex flex-1 items-center gap-2 text-left text-[11px] font-medium text-foreground-subtle hover:text-foreground disabled:opacity-40 transition-colors`,children:[o(n,{className:`h-3.5 w-3.5 shrink-0`}),r(`span`,{children:[`Zone `,e.id]}),o(`span`,{className:`text-foreground-faint capitalize`,children:e.shape.kind})]}),o(`button`,{type:`button`,onClick:()=>X(e.id),disabled:E,"aria-label":`Delete zone ${String(e.id)}`,title:`Delete zone`,className:`inline-flex h-6 w-6 items-center justify-center rounded border border-border bg-surface text-foreground-subtle hover:border-red-400/40 hover:bg-red-500/10 hover:text-red-400 disabled:opacity-40 transition-colors`,children:o(se,{className:`h-3.5 w-3.5`})})]},e.id)})}):null]}):o(`p`,{className:`${c} leading-relaxed`,children:`Loading the camera's privacy mask…`}),Z.supported&&r(`div`,{className:`flex items-start gap-3 rounded-md border border-border bg-surface px-2 py-2`,children:[o(`button`,{type:`button`,role:`switch`,"aria-label":Z.label,"aria-checked":Z.on===!0,disabled:!Z.available||F!==null,onClick:()=>void xe(),title:Z.on===null?`Microphone — state unknown; the camera did not answer.`:Z.on?`The camera is capturing sound. Turning it off: ${Z.costWhenOff}`:`The camera is silent. ${Z.costWhenOff}`,className:Z.on===!1||Z.on===null?h:g,children:r(`span`,{className:`inline-flex items-center gap-1.5`,children:[Z.on===!1?o(de,{className:`h-3.5 w-3.5`}):o(ce,{className:`h-3.5 w-3.5`}),Z.on===null?`Microphone unknown`:Z.on?`Microphone on`:`Microphone off`]})}),o(`p`,{className:`text-[10px] text-foreground-subtle flex-1 leading-relaxed`,children:L===null?Z.on===null?`The camera did not report its microphone, so this state is unknown.`:Z.costWhenOff:`Write failed: ${L}`})]})]})}):null}export{v as PrivacyMaskSettings};
@@ -1 +0,0 @@
1
- import{gt as e}from"./player-overlays-qQtL3R3x.js";var t=e(`circle-slash`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`9`,x2:`15`,y1:`15`,y2:`9`,key:`1dfufj`}]]);export{t};