@camstack/addon-admin-ui 1.2.51 → 1.2.53
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.
- package/dist/assets/{AddLocationWizard-DNy5Mpkx.js → AddLocationWizard-CTZRH8Z5.js} +1 -1
- package/dist/assets/{AddonCollectionPage-BJnHA6Yr.js → AddonCollectionPage-D-p4HN2Y.js} +1 -1
- package/dist/assets/{Addons-Cx7V8zJb.js → Addons-hLgZ2H01.js} +1 -1
- package/dist/assets/{AdminTabs-DDdG-sMf.js → AdminTabs-DyjWcTkF.js} +1 -1
- package/dist/assets/{AiProfiles-Cp3cneae.js → AiProfiles-5buIYxWX.js} +1 -1
- package/dist/assets/{BrokerForm-K-dcLKZI.js → BrokerForm-D-nVBA-o.js} +1 -1
- package/dist/assets/{Build-AVaTYSvX.js → Build-gYggCQtz.js} +5 -5
- package/dist/assets/{Capabilities-C1fnI28W.js → Capabilities-BNz3VrvR.js} +1 -1
- package/dist/assets/{CapabilityBadges-Cr4n7U9J.js → CapabilityBadges-Dy-fCgkC.js} +1 -1
- package/dist/assets/{Cluster-PVE8gXDb.js → Cluster-79wiomQQ.js} +1 -1
- package/dist/assets/{Data-C49zrG4_.js → Data-CxIEICSc.js} +1 -1
- package/dist/assets/DetectionIntelligence-Bow03mZW.js +1 -0
- package/dist/assets/DeviceAggregateSection-D3GgzLed.js +1 -0
- package/dist/assets/DeviceDetail-xGas7OKY.js +2 -0
- package/dist/assets/{Devices-BS4wjono.js → Devices-BQFYrt_N.js} +1 -1
- package/dist/assets/EmbedPlayerPage-C-lzc6gT.js +1 -0
- package/dist/assets/Events-CVnzxEgV.js +1 -0
- package/dist/assets/{FormBuilder-DLUFwW44.js → FormBuilder-9AyvljDu.js} +1 -1
- package/dist/assets/{Identity-9ZXwQ8Qj.js → Identity-DdsiRBNP.js} +1 -1
- package/dist/assets/{IntegrationDetail-wgWm0f_a.js → IntegrationDetail-Dmbq_Wgu.js} +1 -1
- package/dist/assets/{Integrations-D1Nfik-a.js → Integrations-2hJS885p.js} +1 -1
- package/dist/assets/{Integrations-SvM59zTM.js → Integrations-Dy6aGdNk.js} +1 -1
- package/dist/assets/{Logs-Bs6Rv2Ue.js → Logs-2uU6ZNE6.js} +1 -1
- package/dist/assets/{MotionZonesSettings-kfj2QnsS.js → MotionZonesSettings-TAZs0iQF.js} +1 -1
- package/dist/assets/{MyAccess-hIeekqXv.js → MyAccess-DcPz5T-h.js} +1 -1
- package/dist/assets/{Network-DOM164N5.js → Network-BOtKpCey.js} +1 -1
- package/dist/assets/NodeAddonsSettingsPanel-BEd9xkul.js +1 -0
- package/dist/assets/{NodeInferenceDevices-B5Bgeva1.js → NodeInferenceDevices-Bo3q56ME.js} +1 -1
- package/dist/assets/Notifications-CwTETm0t.js +1 -0
- package/dist/assets/Pipeline-DhHsaSYf.js +1 -0
- package/dist/assets/{Plates-DYkITuuM.js → Plates-VOllqnia.js} +1 -1
- package/dist/assets/PrivacyMaskSettings-CyiOeki9.js +1 -0
- package/dist/assets/{ProviderIcon-vnOQu4D_.js → ProviderIcon-lr-CBThV.js} +1 -1
- package/dist/assets/{Recordings-DH6ez1Es.js → Recordings-cNKeFWdX.js} +1 -1
- package/dist/assets/{ScanNetworkModal-CwMfO7lF.js → ScanNetworkModal-C8eQs-oa.js} +1 -1
- package/dist/assets/{Settings-DPImfbkR.js → Settings-DUnGk-Ze.js} +1 -1
- package/dist/assets/{Showroom-BeepOPUy.js → Showroom-CXqbw81j.js} +1 -1
- package/dist/assets/{Terminal-B82c1yAn.js → Terminal-DCg-c08F.js} +2 -2
- package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-wu1e72UY.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-BwtyD_uY.js} +1 -1
- package/dist/assets/bell-ring-Bva0sp7P.js +1 -0
- package/dist/assets/{boxes-B7U_g34P.js → boxes-DaaA1U2C.js} +1 -1
- package/dist/assets/{build-cluster-graph-xMKW01JX.js → build-cluster-graph-DmatAPiL.js} +1 -1
- package/dist/assets/circle-check-big-B89lSUUk.js +1 -0
- package/dist/assets/{circle-x-BJrsiGED.js → circle-x-DukPu47a.js} +1 -1
- package/dist/assets/clock-DhfaWKQT.js +1 -0
- package/dist/assets/{copy-CbIxHx6V.js → copy-CDwMOr_d.js} +1 -1
- package/dist/assets/{debounced-invalidate-BWVZIfGh.js → debounced-invalidate-DdpdBiw5.js} +1 -1
- package/dist/assets/{dist-CK2-8PIG.js → dist-C61wZXG_.js} +1 -1
- package/dist/assets/dist-DqDvuSSn.js +345 -0
- package/dist/assets/{download-BuRZXNAu.js → download-BgcYzk2Q.js} +1 -1
- package/dist/assets/{face-bbox-l0r3wxrB.js → face-bbox-CwWXxJeF.js} +1 -1
- package/dist/assets/{hard-drive-C0ZMQERE.js → hard-drive-DBS5CobV.js} +1 -1
- package/dist/assets/{hostInit-CZjykJiy.js → hostInit-BRYz12QA.js} +1 -1
- package/dist/assets/index-fyPDUdJN.js +4 -0
- package/dist/assets/{key-round-ByTafiD4.js → key-round-zsF7PT11.js} +1 -1
- package/dist/assets/{mf-entry-bootstrap-0-7ce16675.js → mf-entry-bootstrap-0-5949baa8.js} +2 -2
- package/dist/assets/{pencil-BxEumTq9.js → pencil-DoFsGHJs.js} +1 -1
- package/dist/assets/play-Bhpu49mx.js +1 -0
- package/dist/assets/{player-overlays-DinWO-iY.js → player-overlays-C-3liTTP.js} +1 -1
- package/dist/assets/plus-C9xW_jEC.js +1 -0
- package/dist/assets/power-dfEFBp4-.js +1 -0
- package/dist/assets/{radio-CxrlOtbH.js → radio-BLrBPWuP.js} +1 -1
- package/dist/assets/{refresh-cw-DB5OvXUG.js → refresh-cw-DcXpV7xr.js} +1 -1
- package/dist/assets/remoteEntry-Cyq1R_C0.js +1 -0
- package/dist/assets/rotate-ccw-CkObSlR8.js +1 -0
- package/dist/assets/rotate-cw-DMKQK91h.js +1 -0
- package/dist/assets/search-CBZXGB7v.js +1 -0
- package/dist/assets/{send-pgjPnGAN.js → send-lVWoIHYN.js} +1 -1
- package/dist/assets/{server-DsrrDrbP.js → server-CrysozOm.js} +1 -1
- package/dist/assets/square-C1CVou2Z.js +1 -0
- package/dist/assets/{square-check-big-DUS4_d2a.js → square-check-big-CItT96VK.js} +1 -1
- package/dist/assets/src-9rmmBstM.js +345 -0
- package/dist/assets/src-BFsyqPDw.js +67 -0
- package/dist/assets/{undo-2-CaoR3oN8.js → undo-2-BJ4kacMc.js} +1 -1
- package/dist/assets/{upload-Daxobvp0.js → upload-Cug_X6EC.js} +1 -1
- package/dist/assets/{useEventInvalidation-BuGmF-ta.js → useEventInvalidation-BwhFlT4Q.js} +1 -1
- package/dist/assets/{video-B5xcnORf.js → video-CDgzsesk.js} +1 -1
- package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-B-pSXqXs.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-B8LLmlIG.js} +2 -2
- package/dist/assets/{wifi-B7sFkP2k.js → wifi-B6L90xdN.js} +1 -1
- package/dist/assets/{zap-khmquTMk.js → zap-RxnCgRQ7.js} +1 -1
- package/dist/index.html +5 -5
- package/dist/server/addon.js +140 -36
- package/package.json +1 -1
- package/dist/assets/DetectionIntelligence-BJYtPF7e.js +0 -1
- package/dist/assets/DeviceAggregateSection-DgOxdPpF.js +0 -1
- package/dist/assets/DeviceDetail-DGf2HDVz.js +0 -2
- package/dist/assets/EmbedPlayerPage-D__4YSNi.js +0 -1
- package/dist/assets/Events-DTfEa8Xp.js +0 -1
- package/dist/assets/NodeAddonsSettingsPanel-612ENZmF.js +0 -1
- package/dist/assets/Notifications-wnbYqx8i.js +0 -1
- package/dist/assets/Pipeline-overMmnx.js +0 -1
- package/dist/assets/PrivacyMaskSettings-IJQHYGp1.js +0 -1
- package/dist/assets/circle-check-big-DbbuCHA7.js +0 -1
- package/dist/assets/clock-BzQeAJLI.js +0 -1
- package/dist/assets/dist-V9rU1EMp.js +0 -345
- package/dist/assets/index-DSr9rXmX.js +0 -4
- package/dist/assets/play-pHCxem5A.js +0 -1
- package/dist/assets/plus-BMSMXTLJ.js +0 -1
- package/dist/assets/power-9X4iJTM0.js +0 -1
- package/dist/assets/remoteEntry-DNPsGym2.js +0 -1
- package/dist/assets/rotate-ccw-DYs2JMeO.js +0 -1
- package/dist/assets/rotate-cw-WDm6QfVu.js +0 -1
- package/dist/assets/search-CHhIsfkX.js +0 -1
- package/dist/assets/square-tm1n9gYQ.js +0 -1
- package/dist/assets/src-BEXY7p5t.js +0 -345
- package/dist/assets/src-DdYzDsDP.js +0 -67
package/dist/server/addon.js
CHANGED
|
@@ -12961,7 +12961,23 @@ var NotificationActionSchema = object({
|
|
|
12961
12961
|
* else — see `notification-center/action-token.ts` for what that does and
|
|
12962
12962
|
* does not buy.
|
|
12963
12963
|
*/
|
|
12964
|
-
destructive: boolean().optional()
|
|
12964
|
+
destructive: boolean().optional(),
|
|
12965
|
+
/**
|
|
12966
|
+
* How the tap should REACH the url.
|
|
12967
|
+
*
|
|
12968
|
+
* `navigate` (absent, and every button authored before this field) opens it:
|
|
12969
|
+
* the phone leaves the notification and shows whatever the callback returns.
|
|
12970
|
+
* That is right for a button whose answer the operator wants to read.
|
|
12971
|
+
*
|
|
12972
|
+
* `background` fires it as a POST and stays put. It exists for the buttons
|
|
12973
|
+
* whose whole point is not to interrupt — "silence this for 30 minutes" is
|
|
12974
|
+
* an answer to the notification, and being thrown into a browser tab to
|
|
12975
|
+
* confirm it costs more attention than the notification did. A backend that
|
|
12976
|
+
* cannot do a background call renders it as an ordinary link (the adapters
|
|
12977
|
+
* fall back rather than dropping the button), so this is a preference, never
|
|
12978
|
+
* a requirement.
|
|
12979
|
+
*/
|
|
12980
|
+
mode: _enum(["navigate", "background"]).optional()
|
|
12965
12981
|
});
|
|
12966
12982
|
/**
|
|
12967
12983
|
* The canonical notification. `body` is the only hard field (Apprise model).
|
|
@@ -13962,6 +13978,9 @@ var NcSystemEventConditionSchema = object({
|
|
|
13962
13978
|
nodeIds: array(string().min(1)).min(1).optional(),
|
|
13963
13979
|
packageNames: array(string().min(1)).min(1).optional()
|
|
13964
13980
|
});
|
|
13981
|
+
/** Hard ceiling on a window (24h). A snooze that could not expire would be an
|
|
13982
|
+
* outage the operator asked for once and forgot. */
|
|
13983
|
+
var NC_SNOOZE_MAX_MINUTES = 1440;
|
|
13965
13984
|
/** Weekly schedule — OR of windows; absence on the rule = always active. */
|
|
13966
13985
|
var NcScheduleSchema = object({
|
|
13967
13986
|
windows: array(object({
|
|
@@ -14338,15 +14357,15 @@ var NcConditionsSchema = object({
|
|
|
14338
14357
|
* (an `immediate` rule naming an `audio-*` class, one notification per
|
|
14339
14358
|
* classified sample) stays exactly as it was for rules that already use it.
|
|
14340
14359
|
*
|
|
14341
|
-
*
|
|
14342
|
-
* rather than an
|
|
14343
|
-
* (`camstack/src/data/notification-center.ts`, guarded by
|
|
14344
|
-
* `scripts/check-viewer-condition-mirror.ts`) and its rule editor
|
|
14360
|
+
* In {@link NC_CONDITION_CATALOG} since P2, and the ORDER it got there is the
|
|
14361
|
+
* rule rather than an accident: the viewer mirrors the descriptor enums BY
|
|
14362
|
+
* HAND (`camstack/src/data/notification-center.ts`, guarded by
|
|
14363
|
+
* `scripts/check-viewer-condition-mirror.ts`) and its rule editor strips the
|
|
14345
14364
|
* condition fields it does not know when a rule is saved from the phone.
|
|
14346
14365
|
* Publishing an editor for a condition the app cannot round-trip is how an
|
|
14347
|
-
* operator loses a rule's conditions by opening it — so the
|
|
14348
|
-
*
|
|
14349
|
-
*
|
|
14366
|
+
* operator loses a rule's conditions by opening it — so the viewer mirror
|
|
14367
|
+
* (P3, shipped) went FIRST, and the descriptor an editor renders from
|
|
14368
|
+
* follows here.
|
|
14350
14369
|
*/
|
|
14351
14370
|
audio: NcAudioConditionSchema.optional()
|
|
14352
14371
|
});
|
|
@@ -14582,6 +14601,30 @@ var NcRuleInputSchema = object({
|
|
|
14582
14601
|
*/
|
|
14583
14602
|
snoozeAllowGlobal: boolean().optional(),
|
|
14584
14603
|
/**
|
|
14604
|
+
* The snooze durations THIS rule's notification offers as buttons, in
|
|
14605
|
+
* minutes.
|
|
14606
|
+
*
|
|
14607
|
+
* Three states, and all three are distinct — which is exactly why this is
|
|
14608
|
+
* `.optional()` and never `.default()`. A Zod default does not run on the
|
|
14609
|
+
* addon cap path (three production failures in one day), so a schema default
|
|
14610
|
+
* would collapse the first two:
|
|
14611
|
+
*
|
|
14612
|
+
* | value | meaning |
|
|
14613
|
+
* | --- | --- |
|
|
14614
|
+
* | absent | the operator never said ⇒ {@link NC_DEFAULT_SNOOZE_MINUTES} |
|
|
14615
|
+
* | `[]` | **no snooze buttons on this rule** — the explicit override |
|
|
14616
|
+
* | a list | these choices, de-duplicated and sorted, at most four |
|
|
14617
|
+
*
|
|
14618
|
+
* `.max(4)` because the notifier's own action budget is small (ntfy allows
|
|
14619
|
+
* three buttons in total) and a rule that spent it all on snooze choices
|
|
14620
|
+
* would push its own tap-through actions off the notification.
|
|
14621
|
+
*
|
|
14622
|
+
* An empty list is NOT an alarm exemption: a rule the alarm is about, or
|
|
14623
|
+
* that arms the panel, is exempt automatically and cannot be silenced by a
|
|
14624
|
+
* window from anywhere (D133).
|
|
14625
|
+
*/
|
|
14626
|
+
snoozeOptions: array(number().int().min(1).max(NC_SNOOZE_MAX_MINUTES)).max(4).optional(),
|
|
14627
|
+
/**
|
|
14585
14628
|
* Devices this rule ACTUATES — arm the alarm, open a gate, turn on a light.
|
|
14586
14629
|
*
|
|
14587
14630
|
* This is what makes the rule set the alarm's trigger set without the alarm
|
|
@@ -14681,6 +14724,7 @@ var NcConditionDescriptorSchema = object({
|
|
|
14681
14724
|
"device",
|
|
14682
14725
|
"package",
|
|
14683
14726
|
"occupancy",
|
|
14727
|
+
"audio",
|
|
14684
14728
|
"system"
|
|
14685
14729
|
]),
|
|
14686
14730
|
label: string(),
|
|
@@ -14699,6 +14743,7 @@ var NcConditionDescriptorSchema = object({
|
|
|
14699
14743
|
"crossingSelect",
|
|
14700
14744
|
"polygonDraw",
|
|
14701
14745
|
"occupancy",
|
|
14746
|
+
"audio",
|
|
14702
14747
|
"deviceState",
|
|
14703
14748
|
"systemEvent"
|
|
14704
14749
|
]),
|
|
@@ -14850,7 +14895,20 @@ var NcSnoozeInputSchema = object({
|
|
|
14850
14895
|
ruleId: string().optional(),
|
|
14851
14896
|
/** Required when `scope: 'device'`. */
|
|
14852
14897
|
deviceId: number().int().optional(),
|
|
14853
|
-
|
|
14898
|
+
/**
|
|
14899
|
+
* Narrow the window to these subject classes — "the cat, not the person".
|
|
14900
|
+
*
|
|
14901
|
+
* ORTHOGONAL to `scope`, deliberately, and absent means EVERY class: that is
|
|
14902
|
+
* what every window authored before this field meant, so no persisted row
|
|
14903
|
+
* changes meaning and no client has to learn anything to keep working.
|
|
14904
|
+
*
|
|
14905
|
+
* It is what makes the window's real key `(deviceId, classes[])` and lets it
|
|
14906
|
+
* cross rules (D133): the operator points at a camera and a kind of thing,
|
|
14907
|
+
* not at whichever of their four rules happened to produce the notification
|
|
14908
|
+
* they are dismissing.
|
|
14909
|
+
*/
|
|
14910
|
+
classes: array(string().min(1)).min(1).optional(),
|
|
14911
|
+
durationMinutes: number().int().min(1).max(NC_SNOOZE_MAX_MINUTES),
|
|
14854
14912
|
/**
|
|
14855
14913
|
* Silence this for EVERY recipient, not just the caller. Permission is
|
|
14856
14914
|
* checked server-side (the rule's `snoozeAllowGlobal`, or admin for the
|
|
@@ -14875,6 +14933,10 @@ var NcSnoozeSchema = object({
|
|
|
14875
14933
|
scope: NcSnoozeScopeSchema,
|
|
14876
14934
|
ruleId: string().optional(),
|
|
14877
14935
|
deviceId: number().int().optional(),
|
|
14936
|
+
/** Subject classes this window covers. ABSENT = every class — see
|
|
14937
|
+
* {@link NcSnoozeInputSchema.shape.classes}. Lives in the JSON blob and has
|
|
14938
|
+
* no SQLite column: nothing queries a window by class. */
|
|
14939
|
+
classes: array(string().min(1)).min(1).optional(),
|
|
14878
14940
|
startedAt: number(),
|
|
14879
14941
|
/** Exclusive: at exactly this instant the snooze is over. Expiry is a
|
|
14880
14942
|
* COMPARISON, not a job — no sweeper can leave the operator silenced. */
|
|
@@ -23577,13 +23639,24 @@ method(object({
|
|
|
23577
23639
|
/** Playback-speed multiplier for the render (1 = realtime). */
|
|
23578
23640
|
var ExportSpeedSchema = number().min(.25).max(32);
|
|
23579
23641
|
/**
|
|
23580
|
-
* One dense interval, in SECONDS FROM THE EXPORT'S OWN `fromMs`.
|
|
23642
|
+
* One dense interval, in WALL-CLOCK SECONDS FROM THE EXPORT'S OWN `fromMs`.
|
|
23643
|
+
*
|
|
23644
|
+
* **Wall clock, not ffmpeg's `t`** — and the recorder translates. A caller
|
|
23645
|
+
* derives these bounds from things that happened at a TIME (a track's
|
|
23646
|
+
* `firstSeen`), while `t` runs over the source playlist: the concatenation of
|
|
23647
|
+
* every segment present for the range, with each recording GAP removed. The
|
|
23648
|
+
* two agree only on a window that recorded without one interruption, and only
|
|
23649
|
+
* the render side knows the segments, so the translation lives there
|
|
23650
|
+
* (`export-dense-map.ts`, addon-pipeline).
|
|
23651
|
+
*
|
|
23652
|
+
* It was not always so. These seconds were fed to `between(t,…)` verbatim, and
|
|
23653
|
+
* on a 10 h window holding 29,393 s of footage every range landed late by the
|
|
23654
|
+
* gap accumulated before it — up to 6,607 s, well past EOF. Nothing matched,
|
|
23655
|
+
* the video was a uniform timelapse, and the log line reported the five ranges
|
|
23656
|
+
* that had been ASKED for (2026-08-13, export `57d14363`, camera 615).
|
|
23581
23657
|
*
|
|
23582
|
-
* Relative and not absolute epoch
|
|
23583
|
-
*
|
|
23584
|
-
* playlist. Handing it absolute epochs would make every call site responsible
|
|
23585
|
-
* for the same subtraction, and the one that forgot would emit a filter that
|
|
23586
|
-
* selects nothing — silently, as a uniform timelapse.
|
|
23658
|
+
* Relative and not absolute epoch, because an absolute epoch would make every
|
|
23659
|
+
* call site responsible for the same subtraction.
|
|
23587
23660
|
*/
|
|
23588
23661
|
var ExportDenseRangeSchema = object({
|
|
23589
23662
|
fromSec: number().nonnegative(),
|
|
@@ -30436,6 +30509,7 @@ Object.freeze({
|
|
|
30436
30509
|
"network-access": "ingress",
|
|
30437
30510
|
"smtp-provider": "email"
|
|
30438
30511
|
});
|
|
30512
|
+
new Map(AUDIO_MACRO_LABELS.flatMap((macro) => macro.icon === void 0 ? [] : [[macro.id, macro.icon]]));
|
|
30439
30513
|
new Set(["devices", "classes"]);
|
|
30440
30514
|
/**
|
|
30441
30515
|
* TimelapseRule — the STANDALONE scheduled timelapse producer's rule model.
|
|
@@ -30713,25 +30787,32 @@ object({
|
|
|
30713
30787
|
var NativeLeaseAdmissionSchema = _enum(["all", "inferred"]);
|
|
30714
30788
|
object({
|
|
30715
30789
|
/**
|
|
30716
|
-
* How
|
|
30790
|
+
* How many delivered frames the worker HOLDS at once, waiting for each one's
|
|
30791
|
+
* detection result.
|
|
30717
30792
|
*
|
|
30718
|
-
*
|
|
30719
|
-
*
|
|
30720
|
-
*
|
|
30721
|
-
*
|
|
30722
|
-
*
|
|
30793
|
+
* This replaced a TTL on 2026-08-13, and the replacement is the whole point:
|
|
30794
|
+
* a time window was never related to the event the pixels were waiting for.
|
|
30795
|
+
* A held frame now lives from delivery until the runner has its `FrameResult`
|
|
30796
|
+
* — at which moment the runner cuts the subject tiles it actually wanted and
|
|
30797
|
+
* releases the frame. The bound exists only so a runner that stops answering
|
|
30798
|
+
* cannot pin RAM: above it the OLDEST held frame is dropped and counted.
|
|
30799
|
+
*
|
|
30800
|
+
* Sizing: the steady state is `inferenceLatency × deliveredFps`, measured at
|
|
30801
|
+
* 40-160 ms × ≤25 fps = 1-4 frames. The default leaves headroom for a hiccup
|
|
30802
|
+
* without ever approaching the old resident set (43 frames × 24.9 MB at 4K).
|
|
30803
|
+
* Raising it does not buy hit rate — it buys tolerance for a slow runner, and
|
|
30804
|
+
* `holdOverflow` on the metrics line is what says you need it.
|
|
30723
30805
|
*/
|
|
30724
|
-
|
|
30806
|
+
holdFrames: number().int().min(1).max(64),
|
|
30725
30807
|
/**
|
|
30726
30808
|
* Hard per-decode-worker RAM ceiling for retained native frames, in MB.
|
|
30727
30809
|
*
|
|
30728
|
-
*
|
|
30729
|
-
*
|
|
30730
|
-
*
|
|
30731
|
-
*
|
|
30732
|
-
*
|
|
30733
|
-
*
|
|
30734
|
-
* rather than giving RAM back — lower this knob if RAM is what you wanted.
|
|
30810
|
+
* Since 2026-08-13 this is a SAFETY ceiling and nothing else: `holdFrames`
|
|
30811
|
+
* is what decides how much is held, and the ceiling is the number above which
|
|
30812
|
+
* something is wrong. Before that it was the effective cap — at 1024 MB with
|
|
30813
|
+
* a 2 800 ms TTL a 4K camera sat pinned at `leaseMb:1020, leaseFrames:43`
|
|
30814
|
+
* with the TTL expiring nothing, which is exactly the confusion the hold
|
|
30815
|
+
* removes. `leaseMb` / `leaseFrames` still say what is resident.
|
|
30735
30816
|
* `0` DISABLES the lease entirely and falls the worker back to the tiny
|
|
30736
30817
|
* leak-prone GPU surface ring (~85% crop miss; that is what the lease exists
|
|
30737
30818
|
* to replace).
|
|
@@ -30757,22 +30838,45 @@ object({
|
|
|
30757
30838
|
* there is the signal that some caller names frames outside the inference set
|
|
30758
30839
|
* and that this must go back to `all`.
|
|
30759
30840
|
*/
|
|
30760
|
-
admission: NativeLeaseAdmissionSchema
|
|
30841
|
+
admission: NativeLeaseAdmissionSchema,
|
|
30842
|
+
/**
|
|
30843
|
+
* RAM ceiling per decode worker, in MB, for the SUBJECT TILES — the
|
|
30844
|
+
* compressed native crops the worker cuts at the moment a frame's detection
|
|
30845
|
+
* result arrives, and keeps long after the frame itself is freed.
|
|
30846
|
+
*
|
|
30847
|
+
* This is the knob that replaced the old retention window, and it buys about
|
|
30848
|
+
* three orders of magnitude more of it: a tile is one subject at native
|
|
30849
|
+
* resolution, JPEG-encoded (~60-120 KB on a 4K person), against ~24.9 MB for
|
|
30850
|
+
* the frame it was cut from. A frame on which nothing was detected costs
|
|
30851
|
+
* nothing at all, which is the real change — the old lease paid per FRAME and
|
|
30852
|
+
* was interrogated per SUBJECT.
|
|
30853
|
+
*
|
|
30854
|
+
* `0` DISABLES tiles, leaving only the hold window and the ≤640 RAM
|
|
30855
|
+
* fallback — i.e. the pre-2026-08-13 miss profile. Set it there only to
|
|
30856
|
+
* reproduce that.
|
|
30857
|
+
*/
|
|
30858
|
+
tileBudgetMb: number().int().min(0).max(1024)
|
|
30761
30859
|
});
|
|
30762
30860
|
/**
|
|
30763
|
-
* The values in force when the operator has set nothing
|
|
30764
|
-
*
|
|
30765
|
-
*
|
|
30861
|
+
* The values in force when the operator has set nothing.
|
|
30862
|
+
*
|
|
30863
|
+
* `budgetMb` stays at 1024 on the day the hold landed, deliberately: it stopped
|
|
30864
|
+
* being the retention window and became the OOM ceiling, and lowering a ceiling
|
|
30865
|
+
* in the same change that redefines it would make a regression and a retune
|
|
30866
|
+
* indistinguishable. Cut it once `tileHits` / `holdOverflow` have been read on
|
|
30867
|
+
* live traffic.
|
|
30766
30868
|
*/
|
|
30767
30869
|
var DEFAULT_NATIVE_LEASE_SETTINGS = {
|
|
30768
|
-
|
|
30870
|
+
holdFrames: 8,
|
|
30769
30871
|
budgetMb: 1024,
|
|
30770
30872
|
activityMs: 15e3,
|
|
30873
|
+
tileBudgetMb: 64,
|
|
30771
30874
|
admission: "inferred"
|
|
30772
30875
|
};
|
|
30773
|
-
DEFAULT_NATIVE_LEASE_SETTINGS.
|
|
30876
|
+
DEFAULT_NATIVE_LEASE_SETTINGS.holdFrames;
|
|
30774
30877
|
DEFAULT_NATIVE_LEASE_SETTINGS.budgetMb;
|
|
30775
30878
|
DEFAULT_NATIVE_LEASE_SETTINGS.activityMs;
|
|
30879
|
+
DEFAULT_NATIVE_LEASE_SETTINGS.tileBudgetMb;
|
|
30776
30880
|
DEFAULT_NATIVE_LEASE_SETTINGS.admission;
|
|
30777
30881
|
//#endregion
|
|
30778
30882
|
//#region src/server/addon.ts
|
|
@@ -30793,7 +30897,7 @@ var AdminUIAddon = class extends BaseAddon {
|
|
|
30793
30897
|
capability: adminUiCapability,
|
|
30794
30898
|
provider: {
|
|
30795
30899
|
getStaticDir: async () => ({ staticDir: resolveAdminUiDistDir() }),
|
|
30796
|
-
getVersion: async () => ({ version: "1.2.
|
|
30900
|
+
getVersion: async () => ({ version: "1.2.53" })
|
|
30797
30901
|
}
|
|
30798
30902
|
}];
|
|
30799
30903
|
}
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{$n as e,$o as t,Jn as n,Mn as r,Qn as i,Qo as a,Xn as o,Xo as s,Yn as c,Zn as l,Zo as u,_o as d,ar as f,as as p,cs as m,er as h,es as g,ir as _,nr as v,qn as y,rr as b,ss as x,tr as S,ts as C,wo as w}from"./src-DdYzDsDP.js";import{K as T,Q as E,S as D,W as O,b as k,o as A,q as j,x as M,z as N}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DTufy7Ue.js";import{tt as P}from"./src-BEXY7p5t.js";import{a as F,i as I,n as L,r as R,t as z}from"./face-bbox-l0r3wxrB.js";import{a as ee,c as te,f as B,i as ne,l as re,m as V,n as H,o as ie,p as U,r as ae,s as oe,t as se,u as ce}from"./debounced-invalidate-BWVZIfGh.js";import{t as W}from"./pencil-BxEumTq9.js";import{t as G}from"./plus-BMSMXTLJ.js";import{t as le}from"./refresh-cw-DB5OvXUG.js";import{t as ue}from"./square-check-big-DUS4_d2a.js";import{t as de}from"./square-tm1n9gYQ.js";import{t as K}from"./undo-2-CaoR3oN8.js";import{I as q,L as fe,P as pe,S as J,W as me,h as Y,i as X,l as he,s as Z}from"./index-DSr9rXmX.js";import{t as Q}from"./AdminPage-Dq33XE9j.js";import{r as ge,t as _e}from"./authed-media-B8T1dsFh.js";var ve=me(`user-round`,[[`circle`,{cx:`12`,cy:`8`,r:`5`,key:`1hypcn`}],[`path`,{d:`M20 21a8 8 0 0 0-16 0`,key:`rfgkzh`}]]);E();var $=[[`faceGallery`]];function ye({identityId:t}){let n=A(),{data:r,isLoading:i}=e({identityId:t}),a=S();function o(e){a.mutate({identityId:t,sampleId:e.id},{onSettled:()=>{n.invalidateQueries({queryKey:$})}})}return i?D(`div`,{className:`flex items-center gap-2 py-3 text-xs text-foreground-subtle`,children:[M(J,{className:`h-3.5 w-3.5 animate-spin`}),`Loading samples…`]}):!r||r.length===0?M(`p`,{className:`py-2 text-xs text-foreground-subtle`,children:`No samples yet.`}):M(`div`,{className:`mt-2 grid grid-cols-4 gap-2 sm:grid-cols-6 md:grid-cols-8`,children:r.map(e=>D(`div`,{className:`group relative aspect-square overflow-hidden rounded-md border border-border bg-surface`,children:[e.base64?M(`img`,{src:`data:image/jpeg;base64,${e.base64}`,alt:`Sample`,className:`h-full w-full object-cover`}):M(`div`,{className:`flex h-full w-full items-center justify-center text-foreground-subtle`,children:M(ve,{className:`h-6 w-6`})}),M(`button`,{type:`button`,onClick:()=>o(e),disabled:a.isPending,className:`absolute inset-0 flex items-center justify-center bg-black/50 opacity-0 transition-opacity group-hover:opacity-100 disabled:cursor-not-allowed`,"aria-label":`Remove sample`,children:M(X,{className:`h-4 w-4 text-white`})})]},e.id))})}function be({identity:e,expanded:n,onToggle:r}){let i=A(),[c,l]=j(``),[d,f]=j(!1),[h,_]=j(!1),y=v(),b=o();function S(){l(e.name),f(!0)}function w(){f(!1),l(``)}function T(){let t=c.trim();if(!t||t===e.name){w();return}y.mutate({id:e.id,name:t},{onSettled:()=>{i.invalidateQueries({queryKey:$}),w()}})}function E(){b.mutate({id:e.id},{onSettled:()=>{i.invalidateQueries({queryKey:$}),_(!1)}})}return D(`div`,{className:`rounded-md border border-border bg-surface`,children:[D(`div`,{className:`flex items-center gap-2 px-3 py-2`,children:[M(`div`,{className:`h-8 w-8 shrink-0 overflow-hidden rounded-full border border-border bg-surface-hover`,children:e.coverBase64?M(`img`,{src:`data:image/jpeg;base64,${e.coverBase64}`,alt:e.name,className:`h-full w-full object-cover`}):M(`div`,{className:`flex h-full w-full items-center justify-center`,children:M(ve,{className:`h-4 w-4 text-foreground-subtle`})})}),M(`div`,{className:`flex flex-1 min-w-0 items-center gap-2`,children:d?D(k,{children:[M(p,{value:c,onChange:e=>l(e.target.value),onKeyDown:e=>{e.key===`Enter`&&T(),e.key===`Escape`&&w()},className:`h-6 text-xs`,autoFocus:!0}),M(`button`,{type:`button`,onClick:T,disabled:y.isPending,className:`text-success hover:text-success/80 disabled:opacity-50`,"aria-label":`Confirm rename`,children:M(fe,{className:`h-3.5 w-3.5`})}),M(`button`,{type:`button`,onClick:w,className:`text-foreground-subtle hover:text-foreground`,"aria-label":`Cancel rename`,children:M(X,{className:`h-3.5 w-3.5`})})]}):M(`span`,{className:`truncate text-sm font-medium text-foreground`,children:e.name})}),M(x,{variant:`default`,className:`text-[10px]`,children:e.sampleCount}),!d&&D(`div`,{className:`flex items-center gap-1`,children:[M(`button`,{type:`button`,onClick:S,className:`p-1 rounded hover:bg-surface-hover text-foreground-subtle hover:text-foreground`,"aria-label":`Rename`,children:M(W,{className:`h-3.5 w-3.5`})}),M(`button`,{type:`button`,onClick:()=>_(!0),className:`p-1 rounded hover:bg-danger/10 text-foreground-subtle hover:text-danger`,"aria-label":`Delete`,children:M(Z,{className:`h-3.5 w-3.5`})})]}),M(`button`,{type:`button`,onClick:r,className:`p-1 rounded hover:bg-surface-hover text-foreground-subtle`,"aria-label":n?`Collapse`:`Expand`,children:M(n?q:pe,{className:`h-3.5 w-3.5`})})]}),n&&M(`div`,{className:`border-t border-border px-3 pb-3 pt-2`,children:M(ye,{identityId:e.id})}),M(s,{open:h,onOpenChange:e=>!e&&_(!1),children:D(u,{children:[D(g,{children:[M(C,{children:`Delete person`}),D(a,{children:[`Delete `,M(`strong`,{children:e.name}),` and all their samples? This cannot be undone.`]})]}),D(t,{children:[M(m,{variant:`secondary`,onClick:()=>_(!1),children:`Cancel`}),D(m,{variant:`danger`,onClick:E,disabled:b.isPending,children:[b.isPending?M(J,{className:`h-3.5 w-3.5 animate-spin`}):null,`Delete`]})]})]})})]})}function xe(){let e=A(),[t,r]=j(``),i=n();function a(){let n=t.trim();n&&i.mutate({name:n},{onSettled:()=>{e.invalidateQueries({queryKey:$}),r(``)}})}return D(`div`,{className:`flex items-center gap-2 pt-2`,children:[M(p,{placeholder:`New person name…`,value:t,onChange:e=>r(e.target.value),onKeyDown:e=>{e.key===`Enter`&&a()},className:`h-7 text-xs flex-1`}),D(m,{variant:`primary`,size:`sm`,onClick:a,disabled:i.isPending||!t.trim(),children:[i.isPending?M(J,{className:`h-3.5 w-3.5 animate-spin`}):M(G,{className:`h-3.5 w-3.5`}),`Add`]})]})}function Se(){let{data:e,isLoading:t}=i(),[n,r]=j(null);function a(e){r(t=>t===e?null:e)}return t?D(`div`,{className:`flex items-center gap-2 py-4 text-xs text-foreground-subtle`,children:[M(J,{className:`h-4 w-4 animate-spin`}),`Loading people…`]}):D(`div`,{className:`space-y-2`,children:[(!e||e.length===0)&&M(`p`,{className:`py-2 text-xs text-foreground-subtle`,children:`No people enrolled yet. Add one below.`}),e?.map(e=>M(be,{identity:e,expanded:n===e.id,onToggle:()=>a(e.id)},e.id)),M(xe,{})]})}function Ce(e){let t=e.cropUrl!==void 0&&e.cropUrl.length>0,n=e.base64!==void 0&&e.base64.length>0;return!t&&!n}function we(e){return e.filter(Ce).map(e=>e.faceId)}function Te(e){let t=0;for(let n of e)Ce(n)&&(t+=1);return t}function Ee(e){return e==null?null:e.cropUrl!==void 0&&e.cropUrl.length>0?e.cropUrl:e.base64!==void 0&&e.base64.length>0?`data:image/jpeg;base64,${e.base64}`:null}E();var De=[[`faceGallery`]];function Oe({faceIds:e,identities:r,onDone:i}){let o=A(),c=y(),l=n(),[d,f]=j(``),[h,_]=j(!1),[v,b]=j(null),x=e!==null&&e.length>0,S=e?.length??0;function w(){_(!1),f(``),b(null)}function T(){w(),i()}function E(t){!e||e.length===0||c.mutate({faceIds:[...e],identityId:t},{onSettled:()=>{o.invalidateQueries({queryKey:De}),T()}})}function O(){!e||!d.trim()||l.mutate({name:d.trim()},{onSuccess:e=>{e?.id&&E(e.id)},onError:()=>{o.invalidateQueries({queryKey:De}),T()}})}let k=c.isPending||l.isPending;return M(s,{open:x,onOpenChange:e=>!e&&T(),children:D(u,{children:[D(g,{children:[M(C,{children:S>1?`Assign ${String(S)} faces to person`:`Assign face to person`}),M(a,{children:`Select an existing person or create a new one.`})]}),M(`div`,{className:`space-y-1 max-h-56 overflow-y-auto`,children:r.map(e=>D(`button`,{type:`button`,onClick:()=>b(e.id),className:`w-full rounded-md px-3 py-2 text-left text-xs transition-colors ${v===e.id?`bg-primary/12 text-primary`:`hover:bg-surface-hover text-foreground`}`,children:[M(`span`,{className:`font-medium`,children:e.name}),D(`span`,{className:`ml-2 text-foreground-subtle`,children:[e.sampleCount,` samples`]})]},e.id))}),h?M(`div`,{className:`flex items-center gap-2 pt-2 border-t border-border`,children:M(p,{placeholder:`New person name…`,value:d,onChange:e=>f(e.target.value),onKeyDown:e=>{e.key===`Enter`&&O()},autoFocus:!0,className:`flex-1`})}):M(`button`,{type:`button`,onClick:()=>{b(null),_(!0)},className:`mt-2 w-full rounded-md border border-dashed border-border px-3 py-2 text-left text-xs text-foreground-subtle hover:border-primary hover:text-primary transition-colors`,children:`+ New person…`}),D(t,{children:[M(m,{variant:`secondary`,onClick:T,disabled:k,children:`Cancel`}),h?D(m,{variant:`primary`,onClick:O,disabled:k||!d.trim(),children:[k&&M(J,{className:`h-3.5 w-3.5 animate-spin`}),`Create & assign`]}):D(m,{variant:`primary`,onClick:()=>v&&E(v),disabled:k||!v,children:[k&&M(J,{className:`h-3.5 w-3.5 animate-spin`}),`Assign`,S>1?` ${String(S)}`:``]})]})]})})}E();function ke(e){let[t,n]=j(null),[r,i]=j(null),[a,o]=j(!1);return N(()=>{if(n(null),i(null),o(!1),!e)return;let t=!1,r=null;return(async()=>{try{let i=await ge(`${_e}/${encodeURIComponent(e)}`);if(t)return;r=URL.createObjectURL(i),n(r)}catch{t||o(!0)}})(),()=>{t=!0,r&&URL.revokeObjectURL(r)}},[e]),N(()=>{if(!t)return;let e=new Image;return e.onload=()=>i({width:e.naturalWidth,height:e.naturalHeight}),e.onerror=()=>o(!0),e.src=t,()=>{e.onload=null,e.onerror=null}},[t]),{frameSrc:t,naturalWidth:r?.width??null,naturalHeight:r?.height??null,failed:a}}function Ae(e){let t=e.filter(e=>e.base64.length>0);return t.length===0?null:t.find(e=>/crop|face/i.test(e.kind))??t[0]}function je({label:e,value:t}){return D(`div`,{className:`flex items-baseline justify-between gap-3 py-1.5 border-b border-border/60 last:border-0`,children:[M(`span`,{className:`shrink-0 text-[11px] uppercase tracking-wide text-foreground-subtle`,children:e}),M(`span`,{className:`min-w-0 truncate text-right text-xs font-medium text-foreground`,children:t})]})}function Me({box:e}){return M(`div`,{className:`pointer-events-none absolute rounded-[3px] border-2 border-primary shadow-[0_0_0_9999px_rgba(0,0,0,0.28)]`,style:{left:`${String(e.x*100)}%`,top:`${String(e.y*100)}%`,width:`${String(e.width*100)}%`,height:`${String(e.height*100)}%`},children:M(`span`,{className:`absolute -top-4 left-0 rounded bg-primary px-1 text-[9px] font-semibold uppercase tracking-wide text-white`,children:`Face`})})}function Ne({face:e,cameraName:t,onClose:n,onAssign:r,onUnassign:i,onDelete:a,actionsPending:o}){let{data:c,isFetching:d}=l({faceId:e?.faceId??``},{enabled:e!==null}),[f,p]=j(`frame`),{frameSrc:h,naturalWidth:g,naturalHeight:_,failed:v}=ke(e?.keyFrameMediaKey),y=O(()=>{let t=Ae(c??[]);return t?`data:image/jpeg;base64,${t.base64}`:Ee(e)},[c,e]),b=O(()=>!e?.faceBbox||g===null||_===null?null:z(e.faceBbox,g,_),[e?.faceBbox,g,_]);if(e===null)return null;let x=typeof e.keyFrameMediaKey==`string`&&e.keyFrameMediaKey.length>0&&!v,S=x&&f===`frame`,C=e.assigned?e.identityName??`Assigned`:e.recognizedIdentityId?`${e.identityName??`Recognized`} (suggested)`:`Unassigned`;return M(s,{open:!0,onOpenChange:e=>!e&&n(),children:D(u,{width:`lg`,placement:`sheet-on-mobile`,"aria-label":`Face detail`,className:`flex max-h-[92dvh] flex-col gap-0 overflow-hidden p-0 bottom-0 left-0 right-0 top-auto w-full max-w-full translate-x-0 translate-y-0 rounded-b-none md:bottom-auto md:left-1/2 md:right-auto md:top-1/2 md:w-[calc(100vw-2rem)] md:max-w-xl md:-translate-x-1/2 md:-translate-y-1/2 md:rounded-lg md:max-h-[calc(100dvh-2rem)]`,children:[D(`header`,{className:`flex shrink-0 items-start justify-between gap-2 border-b border-border px-4 py-3`,children:[D(`div`,{className:`min-w-0`,children:[M(`div`,{className:`truncate text-sm font-semibold text-foreground`,children:`Face detail`}),M(`div`,{className:`mt-0.5 truncate text-[11px] text-foreground-subtle`,children:t})]}),M(`button`,{type:`button`,onClick:n,className:`rounded p-1 text-foreground-subtle hover:bg-surface-hover hover:text-foreground`,"aria-label":`Close`,children:M(X,{className:`h-4 w-4`})})]}),D(`div`,{className:`min-h-0 flex-1 space-y-3 overflow-y-auto overscroll-contain px-4 py-3`,children:[x&&D(`div`,{className:`flex items-center gap-1 rounded-md border border-border p-0.5 text-xs`,children:[D(`button`,{type:`button`,onClick:()=>p(`frame`),className:`flex flex-1 items-center justify-center gap-1 rounded px-2 py-1 transition-colors ${f===`frame`?`bg-primary/12 font-medium text-primary`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,children:[M(I,{className:`h-3.5 w-3.5`}),` Full frame`]}),D(`button`,{type:`button`,onClick:()=>p(`crop`),className:`flex flex-1 items-center justify-center gap-1 rounded px-2 py-1 transition-colors ${f===`crop`?`bg-primary/12 font-medium text-primary`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,children:[M(F,{className:`h-3.5 w-3.5`}),` Crop`]})]}),S&&h?M(`div`,{className:`overflow-hidden rounded-lg border border-border bg-background`,children:M(H,{src:h,alt:`Full frame with detected face`,fit:`natural`,className:`w-full`,overlay:b?M(Me,{box:b}):void 0})}):y?D(`div`,{className:`relative aspect-square w-full overflow-hidden rounded-lg border border-border`,children:[M(H,{src:y,alt:`Detected face`,className:`h-full w-full`}),d&&M(`div`,{className:`absolute right-2 top-2 rounded-full bg-black/50 p-1 text-white`,children:M(J,{className:`h-3.5 w-3.5 animate-spin`})})]}):D(`div`,{className:`flex aspect-square w-full flex-col items-center justify-center gap-1.5 rounded-lg border border-border bg-warning/5 text-foreground-subtle`,children:[M(V,{className:`h-8 w-8 text-warning/70`}),M(`span`,{className:`text-[11px] font-medium uppercase tracking-wide text-warning/80`,children:`No image`}),M(`span`,{className:`px-6 text-center text-[10px] text-foreground-subtle`,children:`The crop media for this face could not be resolved (a pre-fix orphan). Safe to delete.`})]}),D(`div`,{className:`rounded-lg border border-border bg-surface px-3 py-1`,children:[M(je,{label:`Camera`,value:t}),M(je,{label:`Captured`,value:U(e.timestamp)}),M(je,{label:`Track`,value:e.trackId}),M(je,{label:`Identity`,value:C})]})]}),D(`footer`,{className:`flex shrink-0 items-center justify-end gap-2 border-t border-border px-4 py-3 pb-[max(0.75rem,env(safe-area-inset-bottom))]`,children:[e.assigned?D(m,{variant:`secondary`,onClick:()=>i(e.faceId),disabled:o,children:[M(L,{className:`h-3.5 w-3.5`}),` Detach`]}):D(m,{variant:`primary`,onClick:()=>r(e.faceId),disabled:o,children:[M(R,{className:`h-3.5 w-3.5`}),` Assign`]}),D(m,{variant:`secondary`,onClick:()=>a(e.faceId),disabled:o,children:[M(Z,{className:`h-3.5 w-3.5`}),` Delete`]})]})]})})}function Pe(e,t){let n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n}function Fe(e,t){return e.faceIds.filter(e=>!t.has(e))}function Ie(e,t){return e.faceIds.filter(e=>t(e))}E();var Le=[[`faceGallery`]],Re=20,ze=.3,Be=.9,Ve=.05,He=.5,Ue=2,We=10,Ge=2;function Ke({cluster:e,face:t,active:n,onSelect:r}){let i=Ee(t);return D(`button`,{type:`button`,onClick:r,className:`flex shrink-0 flex-col items-center gap-1.5 rounded-md border p-2 text-center transition-colors md:w-full md:flex-row md:gap-2.5 md:text-left ${n?`border-primary bg-primary/8`:`border-border bg-surface hover:bg-surface-hover`}`,children:[M(`div`,{className:`h-24 w-24 shrink-0 overflow-hidden rounded bg-surface-hover`,children:i===null?M(V,{className:`h-24 w-24 p-6 text-foreground-subtle`}):M(`img`,{src:i,alt:``,loading:`lazy`,decoding:`async`,className:`h-24 w-24 object-cover`})}),D(`span`,{className:`w-24 text-[11px] leading-tight text-foreground-subtle md:w-auto`,children:[e.size,` faces · `,Math.round(e.cohesion*100),`% alike`]})]})}function qe({face:e,cameraName:t,nowMs:n,excluded:r,onToggleExclude:i,onDelete:a,deletePending:o}){let s=Ee(e);return D(`div`,{className:`relative flex flex-col rounded-md border bg-surface overflow-hidden transition-opacity ${r?`border-border opacity-40 grayscale`:`border-border`}`,children:[D(`div`,{className:`aspect-square relative overflow-hidden bg-surface-hover`,children:[s===null?D(`div`,{className:`flex h-full w-full flex-col items-center justify-center gap-1 bg-warning/5 text-foreground-subtle`,children:[M(V,{className:`h-7 w-7 text-warning/70`}),M(`span`,{className:`text-[9px] font-medium uppercase tracking-wide text-warning/80`,children:`No crop`})]}):M(H,{src:s,alt:`Face from ${t}`,className:`h-full w-full`}),M(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),i()},className:`absolute right-1 top-1 z-10 rounded-full bg-black/50 p-1.5 text-white hover:bg-black/70`,"aria-label":r?`Include face`:`Exclude face`,title:r?`Include`:`Exclude`,children:M(r?K:X,{className:`h-3.5 w-3.5`})})]}),D(`div`,{className:`min-w-0 px-2 pt-1.5 space-y-0.5`,children:[M(`p`,{className:`text-[10px] font-medium text-foreground truncate`,title:t,children:t}),M(`p`,{className:`text-[10px] text-foreground-subtle truncate`,children:B(e.timestamp,n)})]}),M(`div`,{className:`mt-1 flex items-center justify-end border-t border-border/60 px-1 py-0.5`,children:M(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),a()},disabled:o,className:`rounded p-1.5 text-foreground-subtle transition-colors hover:bg-danger/10 hover:text-danger disabled:opacity-40`,"aria-label":`Delete face`,title:`Delete face`,children:o?M(J,{className:`h-4 w-4 animate-spin`}):M(Z,{className:`h-4 w-4`})})})]})}function Je({open:e,onClose:t,byId:n,cameraName:r,nowMs:i,identities:a,selectMany:o}){let l=A(),f=d(),p=c(),[h,g]=j(He),[_,v]=j(Ge),[y,x]=j(null),[S,C]=j({}),[w,T]=j(null),{data:E,isFetching:P,refetch:F}=b({threshold:h,minClusterSize:_,limit:Re},{enabled:e}),I=E??[];N(()=>{C({})},[h,_]),N(()=>{if(I.length===0){x(null);return}I.some(e=>e.representativeFaceId===y)||x(I[0]?.representativeFaceId??null)},[I]);let L=O(()=>I.find(e=>e.representativeFaceId===y)??null,[I,y]),z=L?S[L.representativeFaceId]??new Set:new Set,ee=O(()=>L?Ie(L,e=>n.has(e)):[],[L,n]),te=L?L.faceIds.length-ee.length:0,B=L?Fe({...L,faceIds:ee},z):[];function ne(e){if(!L)return;let t=L.representativeFaceId;C(n=>({...n,[t]:Pe(n[t]??new Set,e)}))}function re(){l.invalidateQueries({queryKey:Le})}async function V(e){await f({title:`Delete face`,message:`Permanently deletes this face crop. This cannot be undone.`,confirmLabel:`Delete`,variant:`danger`})&&p.mutate({faceId:e},{onSettled:re})}function H(){T(null),t()}function ie(){B.length!==0&&(o(B),H())}return D(s,{open:e,onOpenChange:e=>!e&&H(),children:[D(u,{placement:`sheet-on-mobile`,width:`lg`,"aria-label":`Look-alike groups`,className:`flex max-h-[92dvh] flex-col gap-0 overflow-hidden p-0 md:max-w-4xl`,children:[D(`header`,{className:`flex shrink-0 flex-col gap-2 border-b border-border px-4 py-3`,children:[D(`div`,{className:`flex items-center justify-between gap-2`,children:[D(`div`,{className:`flex items-center gap-1.5 text-sm font-semibold text-foreground`,children:[M(he,{className:`h-4 w-4 text-primary`}),` Look-alike groups`]}),M(`button`,{type:`button`,onClick:H,className:`rounded p-1 text-foreground-subtle hover:bg-surface-hover hover:text-foreground`,"aria-label":`Close`,children:M(X,{className:`h-4 w-4`})})]}),D(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-2`,children:[D(`label`,{className:`flex items-center gap-2 text-[11px] text-foreground-subtle`,children:[`Threshold`,M(`input`,{type:`range`,min:ze,max:Be,step:Ve,value:h,onChange:e=>g(Number(e.target.value)),className:`h-1.5 w-28 cursor-pointer accent-primary`}),M(`span`,{className:`w-8 shrink-0 text-right font-mono text-[11px] tabular-nums text-foreground`,children:h.toFixed(2)})]}),D(`label`,{className:`flex items-center gap-2 text-[11px] text-foreground-subtle`,children:[`Min size`,M(`input`,{type:`number`,min:Ue,max:We,step:1,value:_,onChange:e=>v(Math.min(We,Math.max(Ue,Number(e.target.value)||Ue))),className:`w-12 rounded border border-border bg-background px-1.5 py-0.5 text-xs text-foreground`})]}),D(m,{variant:`secondary`,onClick:()=>{C({}),F()},disabled:P,children:[P?M(J,{className:`h-3.5 w-3.5 animate-spin`}):M(le,{className:`h-3.5 w-3.5`}),`Re-analyze`]})]})]}),M(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 overflow-hidden px-4 py-3 md:flex-row`,children:P&&I.length===0?D(`div`,{className:`flex flex-1 items-center justify-center gap-2 py-8 text-xs text-foreground-subtle`,children:[M(J,{className:`h-4 w-4 animate-spin`}),` Finding similar faces…`]}):I.length===0?M(`div`,{className:`flex flex-1 items-center justify-center py-8 text-xs text-foreground-subtle`,children:`No look-alike groups at this threshold.`}):D(k,{children:[M(`div`,{className:`flex gap-2 overflow-x-auto pb-1 md:hidden`,children:I.map(e=>M(Ke,{cluster:e,face:n.get(e.representativeFaceId),active:e.representativeFaceId===y,onSelect:()=>x(e.representativeFaceId)},e.representativeFaceId))}),M(`div`,{className:`hidden shrink-0 flex-col gap-2 overflow-y-auto md:flex md:w-56`,children:I.map(e=>M(Ke,{cluster:e,face:n.get(e.representativeFaceId),active:e.representativeFaceId===y,onSelect:()=>x(e.representativeFaceId)},e.representativeFaceId))}),M(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:L&&D(k,{children:[te>0&&D(`p`,{className:`mb-2 text-[11px] text-foreground-subtle`,children:[te,` not loaded — excluded from actions`]}),M(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(13rem,1fr))] gap-2`,children:ee.map(e=>{let t=n.get(e);return t?M(qe,{face:t,cameraName:r(t.deviceId),nowMs:i,excluded:z.has(e),onToggleExclude:()=>ne(e),onDelete:()=>void V(e),deletePending:p.isPending&&p.variables?.faceId===e},e):null})})]})})]})}),D(`footer`,{className:`flex shrink-0 items-center justify-end gap-2 border-t border-border px-4 py-3 pb-[max(0.75rem,env(safe-area-inset-bottom))]`,children:[M(m,{variant:`secondary`,onClick:ie,disabled:B.length===0,children:`Select in gallery`}),D(m,{variant:`primary`,onClick:()=>T(B),disabled:B.length===0,children:[M(R,{className:`h-3.5 w-3.5`}),` Adopt (`,B.length,`)`]})]})]}),M(Oe,{faceIds:w,identities:a,onDone:()=>T(null)})]})}E();var Ye=[[`faceGallery`]],Xe=500,Ze=120;function Qe({face:e,cameraName:t,nowMs:n,selected:r,onToggleSelect:i,onAssign:a,onOpenDetail:o}){let s=A(),l=_(),u=c(),d=()=>{s.invalidateQueries({queryKey:Ye})},f=()=>o(e.faceId),p=Ee(e);return D(`div`,{className:`relative flex flex-col rounded-md border bg-surface overflow-hidden ${r?`border-primary ring-1 ring-primary`:`border-border`}`,children:[D(`div`,{className:`aspect-square relative overflow-hidden bg-surface-hover`,children:[p===null?D(`button`,{type:`button`,onClick:f,className:`flex h-full w-full flex-col items-center justify-center gap-1 bg-warning/5 text-foreground-subtle`,title:`No crop image — the face's crop media is missing (a pre-fix orphan). Safe to delete.`,children:[M(V,{className:`h-7 w-7 text-warning/70`}),M(`span`,{className:`text-[9px] font-medium uppercase tracking-wide text-warning/80`,children:`No crop`})]}):M(`img`,{src:p,alt:`Face from ${t}`,onClick:f,loading:`lazy`,decoding:`async`,className:`h-full w-full cursor-zoom-in object-cover`}),M(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),i(e.faceId)},className:`absolute left-0 top-0 z-10 rounded-br-md bg-black/50 p-1.5 text-white hover:bg-black/70`,"aria-label":r?`Deselect`:`Select`,children:r?M(ue,{className:`h-4 w-4 text-primary`}):M(de,{className:`h-4 w-4`})})]}),D(`div`,{className:`min-w-0 px-2 pt-1.5 space-y-0.5`,children:[M(`p`,{className:`text-[10px] font-medium text-foreground truncate`,title:t,children:t}),M(`p`,{className:`text-[10px] text-foreground-subtle truncate`,children:B(e.timestamp,n)}),e.identityName&&M(`p`,{className:`text-[10px] font-medium text-primary truncate`,title:e.identityName,children:e.identityName})]}),D(`div`,{className:`mt-1 flex items-center gap-0.5 border-t border-border/60 px-1 py-0.5`,children:[e.assigned?M(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),l.mutate({faceId:e.faceId},{onSettled:d})},disabled:l.isPending,className:`rounded p-1.5 text-foreground-subtle transition-colors hover:bg-warning/10 hover:text-warning disabled:opacity-40`,"aria-label":`Detach face`,title:`Detach`,children:l.isPending?M(J,{className:`h-4 w-4 animate-spin`}):M(L,{className:`h-4 w-4`})}):M(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),a(e.faceId)},className:`rounded p-1.5 text-foreground-subtle transition-colors hover:bg-primary/10 hover:text-primary`,"aria-label":`Assign face to person`,title:`Assign to person`,children:M(R,{className:`h-4 w-4`})}),M(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),u.mutate({faceId:e.faceId},{onSettled:d})},disabled:u.isPending,className:`ml-auto rounded p-1.5 text-foreground-subtle transition-colors hover:bg-danger/10 hover:text-danger disabled:opacity-40`,"aria-label":`Delete face`,title:`Delete face`,children:u.isPending?M(J,{className:`h-4 w-4 animate-spin`}):M(Z,{className:`h-4 w-4`})})]})]})}var $e=[{label:`All`,value:`all`},{label:`Unassigned`,value:`unassigned`},{label:`Recognized`,value:`recognized`}];function et(){let e=A(),[t,n]=j(`all`),[a,o]=j(oe),[s,l]=j(new Set),[u,d]=j(new Set),[p,g]=j(null),[v,b]=j(!1),[x,S]=j(null),{data:C,isLoading:w}=h({limit:Xe,filter:t,includeCrops:!1},{refetchInterval:3e4}),{data:T=[]}=i(),{data:E}=r({}),N=y(),P=_(),F=f(),I=c(),z=Date.now(),B=C??[],H=O(()=>{let e=new Map;for(let t of E??[])e.set(t.id,t.name);return e},[E]),U=e=>H.get(e)??`Camera #${String(e)}`,se=O(()=>te(B).map(e=>({id:e,name:U(e)})).sort((e,t)=>e.name.localeCompare(t.name)),[B,H]),W=O(()=>re(ce(B,a),s),[B,a,s]),G=ie(W,Ze,O(()=>JSON.stringify([t,a.fromMs,a.toMs,[...s].sort((e,t)=>e-t)]),[t,a.fromMs,a.toMs,s])),le=O(()=>new Map(B.map(e=>[e.faceId,e])),[B]),ue=O(()=>Te(W),[W]),de=x===null?null:le.get(x)??null,K=()=>{e.invalidateQueries({queryKey:Ye})},q=()=>d(new Set);function fe(e){d(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}function pe(e){d(t=>{let n=new Set(t);for(let t of e)n.add(t);return n})}function me(){pe(we(W))}let Y=[...u],Q=N.isPending||F.isPending||I.isPending,ge=P.isPending||I.isPending;function _e(){Y.length!==0&&F.mutate({faceIds:Y},{onSettled:()=>{K(),q()}})}function ve(){Y.length!==0&&Promise.allSettled(Y.map(e=>I.mutateAsync({faceId:e}))).then(()=>{K(),q()})}function $(e){S(null),g([e])}function ye(e){P.mutate({faceId:e},{onSettled:K}),S(null)}function be(e){I.mutate({faceId:e},{onSettled:K}),S(null)}let xe=W.length!==B.length;return D(`div`,{className:`relative space-y-3`,children:[D(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[M(`div`,{className:`flex items-center gap-1`,children:$e.map(e=>M(`button`,{type:`button`,onClick:()=>n(e.value),className:`rounded-md px-2.5 py-1 text-xs transition-colors ${t===e.value?`bg-primary/12 text-primary font-medium`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,children:e.label},e.value))}),M(ae,{onChange:o}),M(ne,{cameras:se,selected:s,onChange:l}),D(`button`,{type:`button`,onClick:()=>b(!0),className:`flex items-center gap-1 rounded-md px-2.5 py-1 text-xs transition-colors ${v?`bg-primary/12 text-primary font-medium`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,children:[M(he,{className:`h-3.5 w-3.5`}),` Similar groups`]}),!w&&ue>0&&D(`button`,{type:`button`,onClick:me,className:`ml-auto flex items-center gap-1 rounded-md px-2.5 py-1 text-xs text-warning/90 transition-colors hover:bg-warning/10`,title:`Select every visible face whose crop image is missing so you can delete the orphans in one pass`,children:[M(V,{className:`h-3.5 w-3.5`}),` Select `,ue,` crop-less`]}),!w&&M(`span`,{className:`text-[10px] text-foreground-subtle ${ue>0?`ml-2`:`ml-auto`}`,children:xe?`${String(W.length)} of ${String(B.length)} faces`:`${String(W.length)} face${W.length===1?``:`s`}`})]}),u.size>0&&D(`div`,{className:`flex flex-wrap items-center gap-2 rounded-md border border-primary/40 bg-primary/8 px-3 py-2`,children:[D(`span`,{className:`text-xs font-medium text-foreground`,children:[u.size,` selected`]}),D(`div`,{className:`ml-auto flex flex-wrap items-center gap-1.5`,children:[D(m,{variant:`primary`,onClick:()=>g(Y),disabled:Q,children:[M(R,{className:`h-3.5 w-3.5`}),` Assign`]}),D(m,{variant:`secondary`,onClick:_e,disabled:Q,children:[F.isPending?M(J,{className:`h-3.5 w-3.5 animate-spin`}):M(L,{className:`h-3.5 w-3.5`}),` `,`Detach`]}),D(m,{variant:`secondary`,onClick:ve,disabled:Q,children:[M(Z,{className:`h-3.5 w-3.5`}),` Delete`]}),M(m,{variant:`ghost`,onClick:q,disabled:Q,children:M(X,{className:`h-3.5 w-3.5`})})]})]}),w&&D(`div`,{className:`flex items-center gap-2 py-4 text-xs text-foreground-subtle`,children:[M(J,{className:`h-4 w-4 animate-spin`}),` Loading faces…`]}),!w&&W.length===0&&M(`p`,{className:`py-4 text-xs text-foreground-subtle`,children:B.length>0?`No faces match the current date / camera filters.`:`No faces found for this filter.`}),!w&&W.length>0&&D(k,{children:[M(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(6.5rem,1fr))] gap-2`,children:G.pageItems.map(e=>M(Qe,{face:e,cameraName:U(e.deviceId),nowMs:z,selected:u.has(e.faceId),onToggleSelect:fe,onAssign:e=>g([e]),onOpenDetail:S},e.faceId))}),M(ee,{currentPage:G.page,totalItems:G.totalItems,pageSize:G.pageSize,onPageChange:G.setPage,itemNoun:`faces`})]}),M(Ne,{face:de,cameraName:de?U(de.deviceId):``,onClose:()=>S(null),onAssign:$,onUnassign:ye,onDelete:be,actionsPending:ge}),M(Oe,{faceIds:p,identities:T,onDone:()=>{g(null),q()}}),M(Je,{open:v,onClose:()=>b(!1),byId:le,cameraName:U,nowMs:z,identities:T,selectMany:pe})]})}E();var tt=[[`faceGallery`]],nt=2e3;function rt(){let e=A(),t=T(e);t.current=e;let n=T(void 0);n.current||=se({delayMs:nt,invalidate:()=>{t.current.invalidateQueries({queryKey:tt})}}),N(()=>()=>n.current?.cancel(),[]),w(P.PipelineAnalyticsFaceGalleryChanged,()=>{n.current?.trigger()})}function it(){return rt(),M(Q,{icon:Y,title:`Faces`,subtitle:`Manage enrolled identities and assign detected face crops to people.`,children:D(`section`,{className:`space-y-3`,children:[D(`div`,{children:[M(`h2`,{className:`text-sm font-semibold text-foreground mb-1`,children:`People`}),M(`p`,{className:`text-xs text-foreground-subtle mb-3`,children:`Enrolled identities used for face recognition. Expand a row to view or remove training samples.`}),M(Se,{})]}),D(`div`,{className:`pt-4 border-t border-border`,children:[M(`h2`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Recent detected faces`}),M(`p`,{className:`text-xs text-foreground-subtle mb-3`,children:`Face crops captured by the detection pipeline. Assign them to a person to build recognition training data.`}),M(et,{})]})]})})}export{it as DetectionIntelligencePage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{Fa as e,Gn as t,Kn as n,On as r,Pa as i,Rn as a,kn as o}from"./src-DdYzDsDP.js";import{I as s,K as c,Q as l,S as u,W as d,o as f,q as p,x as m}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DTufy7Ue.js";import{X as h}from"./src-BEXY7p5t.js";import{t as g}from"./FormBuilder-DLUFwW44.js";import{S as _,r as v}from"./index-DSr9rXmX.js";import{n as y,r as b,t as x}from"./SchemaTabBar-BrF8ZUiR.js";import{t as S}from"./StableTabPanel-p16epZGa.js";l();function C({schema:e,values:t,pendingKeys:n,onChange:r,onAction:i,onSave:a,onDiscard:o,disabled:s,activeSubTab:c,onSubTabChange:l,flattenTabs:f=!1,deviceId:h}){let _=e.tabs??[],v=d(()=>{let t=new Map;for(let n of e.sections){let e=n.tab??`general`,r=t.get(e)??[];r.push(n),t.set(e,r)}return t},[e.sections]),b=new Set(_.map(e=>e.id)),C=[..._,...[...v.keys()].filter(e=>!b.has(e)).map(e=>({id:e,label:e,icon:`wrench`,order:100}))],w=C[0]?.id??`general`,[T,E]=p(w),D=l!==void 0,O=new Set(C.map(e=>e.id)),k=D?c&&O.has(c)?c:w:O.has(T)?T:w,A=e=>{D?l(e):E(e)},j=v.get(k)??[],M={sections:j.length<=1?j.length===1?[{...j[0],title:``}]:j:j.every(e=>!e.title)?[{...j[0],title:``,fields:j.flatMap(e=>e.fields)}]:j},N=m(y,{pendingCount:n.length,onSave:()=>a(n),onDiscard:()=>o(n),saving:s});if(f||C.length<=1)return u(`div`,{className:`flex flex-col gap-3`,children:[m(g,{schema:e,values:t,onChange:r,onAction:i,disabled:s,deviceId:h}),N]});let P=new Map,F=new Map;for(let[e,t]of v){P.set(e,t.length);let r=new Set,i=e=>{for(let t of e)if(`key`in t&&typeof t.key==`string`&&r.add(t.key),t.type===`group`)i(t.fields);else if(t.type===`sub-tabs`)for(let e of t.tabs)i(e.fields)};for(let e of t)i(e.fields);let a=n.filter(e=>r.has(e)).length;a>0&&F.set(e,a)}return u(`div`,{className:`flex flex-col gap-3`,children:[m(x,{tabs:C.map(e=>({id:e.id,label:e.label})),activeId:k,onChange:A,countByTab:P,pendingByTab:F}),m(S,{tabKey:k,children:m(g,{schema:M,values:t,onChange:r,onAction:i,disabled:s,deviceId:h})}),N]})}var w=`device-export`,T=`export`,E=`Export`;function D(e){return e.type===`separator`||e.type===`info`||e.type===`object-array`||e.type===`widget`||e.type===`addon-action-button`||e.type===`device-action-button`?!1:e.type===`group`?e.fields.some(D):e.type===`sub-tabs`?e.tabs.some(e=>e.fields.some(D)):e.writerCapName===w}function O(e){return e.tab===`export`?!0:e.fields.some(D)}l();function k(e,t){return t&&t===`admin`?e:!0}function A(e){if(!e)return null;let t={sections:[...e.sections].toSorted((e,t)=>{let n=e.tab??`general`,r=t.tab??`general`;return n===r?O(e)&&O(t)?e.id.localeCompare(t.id):(e.order??0)-(t.order??0):n.localeCompare(r)})};return e.tabs?{...t,tabs:e.tabs}:t}function j(e){return e.type===`separator`||e.type===`info`||e.type===`button`||e.type===`widget`||e.type===`addon-action-button`||e.type===`device-action-button`}function M(e){return e.key}function N(e){if(!j(e))return e.value}function P(e){return j(e)?null:e}function F(e,t){for(let n of e)if(t(n),n.type===`group`)F(n.fields,t);else if(n.type===`sub-tabs`)for(let e of n.tabs)F(e.fields,t)}function I(e){if(!e)return{};let t={};for(let n of e.sections)F(n.fields,e=>{let n=M(e);n!==null&&(t[n]=N(e))});return t}function L(e,t){if(!e)return null;let n=null;for(let r of e.sections)if(F(r.fields,e=>{if(n!==null||M(e)!==t)return;let r=P(e);r&&r.writerCapName&&r.writerAddonId&&(n={capName:r.writerCapName,addonId:r.writerAddonId})}),n!==null)break;return n}function R(e){return{...e,fields:e.fields.map(z)}}function z(e){return e.type===`separator`||e.type===`info`||e.type===`button`||e.type===`object-array`?e:{...e,readonlyField:!0}}function B(e,t){return e&&{...e,sections:e.sections.map(e=>({...e,fields:e.fields.map(e=>{let n=P(e);return n?k(t,n.minRole)?e:z(e):e})}))}}function V({deviceId:l,sectionFilter:p,activeSubTab:g,onSubTabChange:y,flattenSubTabs:x,subTabGrouping:S}){let w=f(),{user:T}=v(),E=T?.isAdmin===!0,D=c(!1),{data:k,isLoading:j}=o({deviceId:l},{refetchInterval:()=>D.current?!1:2500,enabled:Number.isFinite(l)}),{data:M}=r({deviceId:l},{enabled:Number.isFinite(l)}),N=k?.settings??null,P=k?.live??null,F=d(()=>{if(!N&&!P)return null;let e=N?.sections??[],t=(P?.sections??[]).map(R),n=[...e,...t],r=p?n.filter(p):n.filter(e=>e.location!==`top-tab`&&!O(e));if(r.length===0)return null;if(S){let e=r.map(e=>({...e,tab:S.groupOf(e)})),t=new Set(e.map(e=>e.tab)),n=S.tabs.filter(e=>t.has(e.id));return n.length>0?{tabs:n,sections:e}:{sections:e}}let i=new Set;for(let e of r)i.add(e.tab??`general`);let a=[...N?.tabs??[],...(P?.tabs??[]).filter(e=>!(N?.tabs??[]).some(t=>t.id===e.id))].filter(e=>i.has(e.id));return a.length>0?{tabs:a,sections:r}:{sections:r}},[N,P,p,S]),z=d(()=>A(F),[F]),V=d(()=>B(z,E),[z,E]),H=d(()=>I(V),[V]),U=e(),W=i(),G=t(),K=a(),q=n({onSuccess:()=>{w.invalidateQueries({queryKey:[[`deviceManager`,`getDeviceAggregate`]]})}}),J={isPending:q.isPending,mutate:e=>{q.mutate({deviceId:l,changes:[...e]})}},Y=b({schema:V,serverValues:H,onImmediateSave:s(e=>{let t=Object.entries(e).map(([e,t])=>{let n=L(V,e);return n?{writerCapName:n.capName,writerAddonId:n.addonId,key:e,value:t}:null}).filter(e=>e!==null);t.length>0&&J.mutate(t)},[V,J]),onDeferredSave:s(e=>{let t=Object.entries(e).map(([e,t])=>{let n=L(V,e);return n?{writerCapName:n.capName,writerAddonId:n.addonId,key:e,value:t}:null}).filter(e=>e!==null);t.length>0&&J.mutate(t)},[V,J])}),{values:X,pendingKeys:Z,handleChange:Q,handleSave:$,handleDiscard:ee}=Y;if(D.current=Y.editingPaused,j)return u(`div`,{className:`flex items-center justify-center py-12 text-foreground-subtle`,children:[m(_,{className:`h-4 w-4 animate-spin mr-2`}),m(`span`,{className:`text-xs`,children:`Loading device aggregate…`})]});if(!V||V.sections.length===0)return m(`div`,{className:`text-xs text-foreground-subtle italic py-4 text-center`,children:`No aggregate contributions for this device.`});async function te(e,t,n){if(e===`regenerate-rtsp-token`){let e=[`rtspUrl:`,`regenerateToken:`].find(e=>t.startsWith(e));if(!e)throw Error(`regenerate-rtsp-token: unrecognised key "${t}" (expected "rtspUrl:<streamId>" or "regenerateToken:<streamId>")`);let n=t.slice(e.length);if(!n)throw Error(`regenerate-rtsp-token: key "${t}" has no streamId after prefix`);let r=h(l,n);await U.mutateAsync({brokerId:r}),w.invalidateQueries({queryKey:[[`deviceManager`,`getDeviceAggregate`]]});return}if(e===`test-probe`){if(!M)return{status:`error`,error:`Device metadata not loaded yet`};try{return await G.mutateAsync({addonId:M.addonId,type:M.type,key:t,value:n})}catch(e){return{status:`error`,error:e instanceof Error?e.message:String(e)}}}if(e===`refresh-probe`){if(!t.startsWith(`probedInfo:`))throw Error(`refresh-probe: unrecognised key "${t}" (expected "probedInfo:<streamId>")`);let e=t.slice(11);if(!e)throw Error(`refresh-probe: key "${t}" has no streamId after prefix`);let n=h(l,e),r=await W.mutateAsync({brokerId:n});return w.invalidateQueries({queryKey:[[`deviceManager`,`getDeviceAggregate`]]}),r}if(e===`device-custom-action`){let e=await K.mutateAsync({deviceId:l,action:t,input:n});return w.invalidateQueries({queryKey:[[`deviceManager`,`getDeviceAggregate`]]}),e}throw Error(`[device-aggregate] unknown action "${e}"`)}return m(C,{schema:V,values:X,pendingKeys:Z,onChange:Q,onAction:te,onSave:$,onDiscard:ee,disabled:J.isPending,activeSubTab:g,onSubTabChange:y,flattenTabs:x,deviceId:l})}export{O as i,T as n,E as r,V as t};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{$ as e,Ao as t,Bn as n,Bo as r,D as i,Do as a,E as o,Ei as s,Eo as c,Fo as l,H as u,Hi as d,Hn as f,Ho as p,Io as m,Ir as h,J as g,Ln as _,Lo as v,M as y,Mi as b,Mo as x,N as S,Nn as C,O as w,On as T,P as E,Pn as ee,Po as te,Q as ne,Ro as re,T as D,Tn as O,U as ie,Ui as ae,Un as k,Ur as A,V as j,Vn as M,Wn as N,X as oe,Y as se,Yi as ce,Z as le,_o as ue,_r as P,a as de,at as fe,ba as F,cn as I,et as L,f as pe,g as me,ga as he,gn as ge,gr as _e,gs as ve,hi as ye,hs as R,i as be,it as xe,jn as Se,jo as Ce,ki as we,kn as Te,ko as Ee,l as De,m as Oe,mo as ke,ms as Ae,n as je,nt as Me,o as Ne,ot as Pe,p as Fe,po as Ie,ps as Le,q as Re,r as ze,sn as Be,u as Ve,ua as He,ur as Ue,vr as We,wi as Ge,wn as Ke,wt as qe,y as Je,yn as Ye,zn as Xe,zo as Ze,zt as Qe}from"./src-DdYzDsDP.js";import{I as z,K as B,Q as V,S as H,W as U,a as $e,b as et,o as W,q as G,t as tt,x as K,z as q}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DTufy7Ue.js";import{$ as nt,M as rt,P as J,Q as it,Z as at,a as ot,i as st}from"./src-BEXY7p5t.js";import{c as ct,k as lt,p as Y,r as ut,t as dt,u as ft}from"./player-overlays-DinWO-iY.js";import{t as pt}from"./CapabilityBadges-Cr4n7U9J.js";import{t as mt}from"./boxes-B7U_g34P.js";import{t as ht}from"./ProviderIcon-vnOQu4D_.js";import{a as gt,c as _t,l as vt,n as yt,o as bt}from"./NodeInferenceDevices-B5Bgeva1.js";import{n as xt}from"./FormBuilder-DLUFwW44.js";import{t as St}from"./pencil-BxEumTq9.js";import{t as Ct}from"./power-9X4iJTM0.js";import{t as wt}from"./refresh-cw-DB5OvXUG.js";import{t as Tt}from"./rotate-ccw-DYs2JMeO.js";import{t as Et}from"./rotate-cw-WDm6QfVu.js";import{t as Dt}from"./server-DsrrDrbP.js";import{t as Ot}from"./wifi-B7sFkP2k.js";import{A as kt,J as At,K as jt,L as Mt,S as Nt,U as Pt,V as Ft,W as X,a as It,c as Lt,d as Rt,i as zt,j as Bt,m as Vt,q as Ht,s as Ut,t as Wt,v as Gt,y as Kt,z as qt}from"./index-DSr9rXmX.js";import{t as Jt}from"./useEventInvalidation-BuGmF-ta.js";import{t as Yt}from"./StatusBadge-Dcr2bw58.js";import{i as Xt,n as Zt,r as Qt,t as $t}from"./DeviceAggregateSection-DgOxdPpF.js";var en=X(`circle-help`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,key:`1u773s`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),tn=X(`disc`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`circle`,{cx:`12`,cy:`12`,r:`2`,key:`1c9p78`}]]),nn=X(`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`}]]),rn=X(`hand`,[[`path`,{d:`M18 11V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2`,key:`1fvzgz`}],[`path`,{d:`M14 10V4a2 2 0 0 0-2-2a2 2 0 0 0-2 2v2`,key:`1kc0my`}],[`path`,{d:`M10 10.5V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2v8`,key:`10h0bg`}],[`path`,{d:`M18 8a2 2 0 1 1 4 0v6a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 15`,key:`1s1gnw`}]]),an=X(`link-2`,[[`path`,{d:`M9 17H7A5 5 0 0 1 7 7h2`,key:`8i5ue5`}],[`path`,{d:`M15 7h2a5 5 0 1 1 0 10h-2`,key:`1b9ql8`}],[`line`,{x1:`8`,x2:`16`,y1:`12`,y2:`12`,key:`1jonct`}]]),on=X(`mouse-pointer-click`,[[`path`,{d:`M14 4.1 12 6`,key:`ita8i4`}],[`path`,{d:`m5.1 8-2.9-.8`,key:`1go3kf`}],[`path`,{d:`m6 12-1.9 2`,key:`mnht97`}],[`path`,{d:`M7.2 2.2 8 5.1`,key:`1cfko1`}],[`path`,{d:`M9.037 9.69a.498.498 0 0 1 .653-.653l11 4.5a.5.5 0 0 1-.074.949l-4.349 1.041a1 1 0 0 0-.74.739l-1.04 4.35a.5.5 0 0 1-.95.074z`,key:`s0h3yz`}]]),sn=X(`scan-eye`,[[`path`,{d:`M3 7V5a2 2 0 0 1 2-2h2`,key:`aa7l1z`}],[`path`,{d:`M17 3h2a2 2 0 0 1 2 2v2`,key:`4qcy5o`}],[`path`,{d:`M21 17v2a2 2 0 0 1-2 2h-2`,key:`6vwrx8`}],[`path`,{d:`M7 21H5a2 2 0 0 1-2-2v-2`,key:`ioqczr`}],[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`path`,{d:`M18.944 12.33a1 1 0 0 0 0-.66 7.5 7.5 0 0 0-13.888 0 1 1 0 0 0 0 .66 7.5 7.5 0 0 0 13.888 0`,key:`11ak4c`}]]),cn=X(`volume-2`,[[`path`,{d:`M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z`,key:`uqj9uw`}],[`path`,{d:`M16 9a5 5 0 0 1 0 6`,key:`1q6k2b`}],[`path`,{d:`M19.364 18.364a9 9 0 0 0 0-12.728`,key:`ijwkga`}]]);V();var ln=[{id:`object-detection`,label:`Object detection`,costWhenOff:`No detections, tracks or detection-driven notifications for this camera.`,capName:it},{id:`audio-analysis`,label:`Audio analysis`,costWhenOff:`No audio events (glass, alarm, speech) and no audio-driven notifications.`,capName:at}],un=`Recording`,dn=`Nothing new is written to disk — live still works, existing footage is kept.`;function fn(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 pn(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 mn(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 hn(e){let t=ln.map(t=>fn(t,e)),n={id:`recording`,label:un,costWhenOff:dn,on:e.recordingEnabled,available:e.recordingEnabled!==null,capName:null,wrapperAddonId:null};return[...t,n]}var gn={"object-detection":sn,"audio-analysis":nn,recording:tn};function _n(e){if(typeof e!=`object`||!e)return!1;let t={...e};return typeof t.enabled==`boolean`&&Array.isArray(t.bands)}function vn(e){if(typeof e!=`object`||!e)return!1;let t={...e};return typeof t.deviceId==`number`&&Array.isArray(t.entries)}function yn(e){return vn(e)?e.entries:null}function bn(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 xn({deviceId:e}){let t=W(),n=Number.isFinite(e),[i,a]=G(null),[o,s]=G(!1),c=O({deviceId:e},{enabled:n}),l=C({deviceType:J.Camera},{enabled:n}),u=he({deviceId:e},{enabled:n,retry:!1});Jt([`deviceManager`,`getBindings`],[`capability.binding-changed`]);let d=[[`deviceManager`,`getBindings`],{input:{deviceId:e}}],f=[[`recording`,`getDeviceConfig`],{input:{deviceId:e}}],m=u.data,h=_n(m)?m:null,g=hn({bindings:yn(c.data),bindable:bn(l.data),recordingEnabled:h===null?null:h.enabled}),_=N({onError:(n,r)=>{let i=r.capName===g[1]?.capName?`audio-analysis`:`object-detection`;console.error(`[CameraFunctionSwitches] wrapper write failed — reverting`,{tags:{deviceId:e},meta:{capName:r.capName,error:n instanceof Error?n.message:String(n)}}),t.invalidateQueries({queryKey:[[`deviceManager`,`getBindings`]]}),a({id:i,message:n instanceof Error?n.message:String(n)})},onSuccess:()=>{a(null),t.invalidateQueries({queryKey:[[`deviceManager`]]}),t.invalidateQueries({queryKey:[[`pipelineOrchestrator`]]})}}),v=F({onError:n=>{console.error(`[CameraFunctionSwitches] recording write failed — reverting`,{tags:{deviceId:e},meta:{error:n instanceof Error?n.message:String(n)}}),t.invalidateQueries({queryKey:[[`recording`,`getDeviceConfig`]]}),a({id:`recording`,message:n instanceof Error?n.message:String(n)})},onSuccess:()=>{a(null),t.invalidateQueries({queryKey:[[`recording`]]}),t.invalidateQueries({queryKey:[[`pipelineOrchestrator`]]})}}),y=z(n=>{if(!n.available||n.on===null)return;let r=!n.on;if(n.id===`recording`){if(h===null)return;t.setQueryData(f,{...h,enabled:r}),v.mutate({deviceId:e,config:{...h,enabled:r}});return}let{capName:i,wrapperAddonId:a}=n;if(i===null||a===null)return;let o=t.getQueryData(d);vn(o)&&t.setQueryData(d,pn(o,i,a,r)),_.mutate({deviceId:e,capName:i,wrapperAddonId:a,active:r})},[d,e,t,h,f,v,_]),b=mn(g,p()),x=e=>i?.id===e.id?i.message:null;return b.layout===`menu`?H(re,{open:o,onOpenChange:s,children:[H(r,{"aria-label":`Camera functions`,title:b.summary,className:`inline-flex items-center gap-1 rounded-lg border px-2 py-1.5 text-[11px] font-medium transition-colors ${i===null?b.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:[K(Rt,{className:`h-3.5 w-3.5`}),b.offIds.length>0&&H(`span`,{className:`rounded bg-warning/20 px-1 text-[9px] font-semibold uppercase tracking-wide`,children:[b.offIds.length,` off`]})]}),H(Ze,{className:`left-auto right-0 mt-1 min-w-[240px] p-1`,children:[K(`div`,{className:`px-2 py-1 text-[10px] uppercase tracking-wider text-foreground-subtle`,children:`Camera functions`}),K(`ul`,{className:`space-y-0.5`,children:g.map(e=>K(`li`,{children:K(Sn,{state:e,failure:x(e),onToggle:()=>y(e)})},e.id))})]})]}):K(`div`,{className:`flex items-center gap-1`,children:g.map(e=>K(Cn,{state:e,failure:x(e),onToggle:()=>y(e)},e.id))})}function Sn({state:e,failure:t,onToggle:n}){let r=gn[e.id],i=e.on===null,a=e.on===!1;return H(`button`,{type:`button`,role:`switch`,"aria-label":e.label,"aria-checked":e.on===!0,disabled:!e.available,onClick:n,title:i?`${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:[K(r,{className:`h-3.5 w-3.5 shrink-0 mt-0.5 ${t===null?i?`text-foreground-subtle/50`:a?`text-warning`:`text-success`:`text-danger`}`}),H(`span`,{className:`flex-1 min-w-0`,children:[K(`span`,{className:`block leading-tight`,children:e.label}),K(`span`,{className:`block mt-0.5 text-[10px] text-foreground-subtle leading-tight`,children:t===null?i?`Unknown`:e.costWhenOff:`Write failed: ${t}`})]}),K(`span`,{className:`shrink-0 rounded px-1 py-0.5 text-[9px] font-semibold uppercase tracking-wide ${i?`bg-surface-hover text-foreground-subtle/60`:a?`bg-warning/20 text-warning`:`bg-success/20 text-success`}`,children:i?`—`:a?`off`:`on`})]})}function Cn({state:e,failure:t,onToggle:n}){let r=gn[e.id],i=e.on===null,a=e.on===!1,o=i?`${e.label} — state unknown; the source that owns it did not answer.`:a?`${e.label} is OFF. ${e.costWhenOff}`:`${e.label} is on. Turning it off: ${e.costWhenOff}`;return H(`button`,{type:`button`,role:`switch`,"aria-label":e.label,"aria-checked":e.on===!0,disabled:!e.available,onClick:n,title:t===null?o:`${o} — 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?i?`border-dashed border-border text-foreground-subtle/50`:a?`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:[K(r,{className:`h-3.5 w-3.5`}),K(`span`,{className:`hidden lg:inline`,children:e.label}),a&&K(`span`,{className:`rounded bg-warning/20 px-1 text-[9px] font-semibold uppercase tracking-wide`,children:`off`})]})}function wn({parentDeviceId:t}){let{t:n}=Wt(),r=jt(),i=Y(),{data:a,isLoading:o,isError:s}=bt(t),{data:c}=T({deviceId:t},{enabled:Number.isFinite(t)});if(o)return K(`div`,{className:`rounded-lg border border-border bg-surface p-3`,children:K(`p`,{className:`text-[10px] text-foreground-subtle`,children:n(`common.loading`,{defaultValue:`Loading…`})})});if(s)return K(`div`,{className:`rounded-lg border border-border bg-surface p-3`,children:K(`p`,{className:`text-[10px] text-warning`,children:n(`integrations.childrenLoadError`,{defaultValue:`Failed to load children`})})});let l=(a??[]).filter(e=>e.display?.hidden!==!0);if(l.length===0)return null;let u=se(c?.stableId??``,l,c?.childLayout),d=u.ungrouped,f=e=>r(`/devices/${String(e)}`),p=c?.name??``,m=(t,n)=>K(Re,{trpc:i.trpcClient,device:{...n,name:e(n,p)},variant:`minimal`,onNavigate:f},t),h=d.some(e=>!!e.role),_=d.some(e=>!e.role),v=h&&!_?n(`device.accessories`,{defaultValue:`Accessories`}):!h&&_?n(`device.adoptedDevices`,{defaultValue:`Adopted devices`}):n(`device.children`,{defaultValue:`Children`}),y=d.length>0?H(`div`,{className:`rounded-lg border border-border bg-surface p-3`,children:[K(`div`,{className:`text-[10px] font-semibold uppercase tracking-wide text-foreground-subtle mb-1.5`,children:v}),K(`div`,{className:`space-y-1`,children:d.map(e=>m(e.id,e))})]}):null,b=u.disabledSection===void 0?null:K(g,{title:n(`device.disabledSection`,{defaultValue:`Disabled`}),count:u.disabledSection.children.length,defaultOpen:!1,children:K(`div`,{className:`opacity-60 space-y-1`,children:u.disabledSection.children.map(e=>m(e.id,e))})},u.disabledSection.title);return u.sections.length===0?b===null?y:H(`div`,{className:`space-y-2`,children:[y,b]}):H(`div`,{className:`space-y-2`,children:[u.sections.map(e=>K(g,{title:e.title,count:e.children.length,defaultOpen:e.defaultOpen,children:e.children.map(e=>m(e.id,e))},e.title)),y,b]})}function Tn({deviceId:e}){let t=Y(),{data:n,isLoading:r}=gt(e),{data:i,isLoading:a}=bt(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?K(`div`,{className:`h-full min-h-32 w-full animate-pulse rounded-lg bg-surface`,"aria-hidden":`true`}):K(`div`,{className:`flex h-full w-full flex-col`,children:K(u,{trpc:t.trpcClient,children:s,linkDeviceId:c,primaryChildEntityId:l})})}V();function En({dev:e,busy:t,setBusy:n}){let r=e?.motionTrigger,i=ft(e?.state.motionTrigger),[a,o]=G(!1);if(!r)return null;let s=i?.enabled===!0,c=i!==void 0,l=async()=>{if(t||!c)return;let e=!s;n(!0),o(!0);try{await r.setMotionTrigger({enabled:e})}finally{n(!1),o(!1)}};return H(`button`,{type:`button`,onClick:()=>{l()},disabled:t||!c,title:c?s?`Disable trigger on motion`:`Enable trigger on motion`:`Awaiting state…`,"aria-pressed":s,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 ${s?`border-primary/50 bg-primary/15 text-primary`:`border-border bg-surface text-foreground-subtle hover:text-foreground`}`,children:[K(Pt,{className:`h-3 w-3`}),K(`span`,{children:a?s?`Disabling…`:`Enabling…`:c?s?`On motion: on`:`On motion: off`:`On motion: …`})]})}V();function Z({deviceId:e,deviceType:t,features:n}){let r=Y(),i=fe(t)?.HeroCard??Ie,a=ct(r.trpcClient,e),o=ft(a?.state.deviceStatus),[s,c]=G(!1),l=o!==void 0&&o.online===!1,u=l?o.lastChangedAt:null;return H(`div`,{className:`flex h-full w-full flex-col items-stretch gap-3 p-3 sm:p-4`,children:[l?K(`div`,{className:`flex justify-center`,children:K(ie,{lastChangedAt:u})}):null,K(i,{trpc:r.trpcClient,deviceId:e,features:n}),K(`div`,{className:`flex justify-center`,children:K(En,{dev:a,busy:s,setBusy:c})})]})}function Dn({deviceId:e,features:t}){return K(`div`,{className:`flex h-full w-full flex-col items-stretch gap-3 p-3 sm:p-4`,children:K(ke,{trpc:Y().trpcClient,deviceId:e,features:t})})}function On({deviceId:e,features:t}){return K(`div`,{className:`flex h-full w-full flex-col items-stretch p-3 sm:p-4`,children:K(Ie,{trpc:Y().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 An(e){if(!e)return null;let t=kn(e.data);return t===null?e.eventType:`Button ${String(t)} · ${e.eventType}`}var jn=1e3,Mn=60*jn,Nn=60*Mn,Pn=24*Nn;function Fn(e,t){if(e==null||e<=0)return`—`;let n=t-e;return n<jn?`just now`:n<Mn?`${String(Math.floor(n/jn))}s ago`:n<Nn?`${String(Math.floor(n/Mn))}m ago`:n<Pn?`${String(Math.floor(n/Nn))}h ago`:`${String(Math.floor(n/Pn))}d ago`}V();var In=1500,Ln=15e3,Rn=1e3;function zn({deviceId:e}){let t=ct(Y().trpcClient,e)?.state.eventEmitter,n=ft(t);q(()=>{if(!t)return;t.refresh();let e=setInterval(()=>{t.refresh()},Ln);return()=>{clearInterval(e)}},[t]);let r=n?.lastEvent??null,i=r?.seq??null,a=B(null),[o,s]=G(!1);q(()=>{if(i===null)return;let e=a.current;if(a.current=i,e===null||e===i)return;s(!0);let t=setTimeout(()=>{s(!1)},In);return()=>{clearTimeout(t)}},[i]);let[c,l]=G(()=>Date.now());q(()=>{let e=setInterval(()=>{l(Date.now())},Rn);return()=>{clearInterval(e)}},[]);let u=An(r),d=n?.eventTypes??[],f=n?.eventCountSinceStart??0,p=n!==void 0,m=kn(r?.data);return H(`div`,{className:`flex h-full w-full flex-col items-center justify-center gap-3 p-4`,children:[K(`div`,{"data-testid":`event-emitter-indicator`,"data-flashing":String(o),className:`flex h-24 w-24 items-center justify-center rounded-full border-2 transition-all ${o?`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:u??`No press recorded`,children:K(o?on:rn,{className:`h-10 w-10`})}),H(`div`,{className:`text-center`,children:[m!==null&&K(`div`,{className:`text-xs font-semibold uppercase tracking-wide text-primary`,children:`Button ${String(m)}`}),K(`div`,{"data-testid":`event-emitter-headline`,className:`text-sm font-semibold ${u?`text-foreground`:`text-foreground-subtle`}`,children:u??(p?`No press recorded`:`Awaiting state…`)}),K(`div`,{className:`text-[10px] text-foreground-subtle mt-0.5`,children:r?Fn(r.timestamp,c):`Waiting for the first event`})]}),d.length>0&&K(`div`,{className:`flex max-w-full flex-wrap justify-center gap-1`,children:d.map(e=>K(`span`,{"data-testid":`event-emitter-chip`,className:`rounded-full border px-2 py-0.5 text-[10px] font-medium ${e===r?.eventType?`border-primary bg-primary/15 text-primary`:`border-border bg-surface text-foreground-subtle`}`,children:e},e))}),K(`div`,{className:`text-[10px] text-foreground-subtle`,children:`${String(f)} ${f===1?`event`:`events`} since start`})]})}function Bn({deviceName:e,deviceType:t,provider:n,isOnline:r,features:i}){return H(`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:[K(ht,{type:n,size:`lg`}),H(`div`,{children:[K(`div`,{className:`text-sm font-semibold text-foreground`,children:e}),K(`div`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wider mt-0.5`,children:t})]}),H(`div`,{className:`flex items-center gap-2 flex-wrap justify-center`,children:[K(Yt,{status:r?`online`:`offline`}),i.length>0&&K(pt,{capabilities:i})]}),K(`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.`})]})}V();function Vn({deviceId:e}){let t=W(),n=Be({deviceId:e},{refetchInterval:1e4,retry:!1}),r=I({onSuccess:()=>{t.invalidateQueries({queryKey:[[`deviceDiscovery`,`listDiscovered`]]}),t.invalidateQueries({queryKey:[[`deviceDiscovery`,`getStatus`]]})}}),i=U(()=>Hn(n.data??[]),[n.data]);return H(`div`,{className:`flex h-full w-full flex-col gap-3 p-3 sm:p-4`,children:[H(`div`,{className:`flex flex-wrap items-stretch gap-2 sm:gap-3`,children:[K(Un,{label:`Discovered`,value:i.total,icon:K(Gt,{className:`h-3.5 w-3.5`})}),K(Un,{label:`Adopted`,value:i.adopted,accent:`success`}),K(Un,{label:`Available`,value:i.available,accent:i.available>0?`primary`:void 0}),H(`button`,{type:`button`,onClick:()=>{r.mutateAsync({deviceId:e}).catch(()=>{})},disabled:r.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:[r.isPending?K(Nt,{className:`h-3.5 w-3.5 animate-spin`}):K(wt,{className:`h-3.5 w-3.5`}),K(`span`,{className:`hidden sm:inline`,children:`Discover`})]})]}),H(`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:[K(Wn,{icon:K(Ot,{className:`h-3 w-3 text-emerald-500`}),label:`${i.online} online`}),K(Wn,{icon:K(Kt,{className:`h-3 w-3 text-amber-500`}),label:`${i.sleeping} sleeping`}),K(Wn,{icon:K(It,{className:`h-3 w-3 text-destructive`}),label:`${i.offline} offline`}),i.unknown>0?K(Wn,{icon:K(en,{className:`h-3 w-3 text-foreground-subtle`}),label:`${i.unknown} unknown`}):null]})]})}function Hn(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 Un({label:e,value:t,icon:n,accent:r}){return H(`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 ${r===`success`?`bg-emerald-500/10 border-emerald-500/30 text-emerald-500`:r===`primary`?`bg-primary/10 border-primary/30 text-primary`:`bg-surface-hover border-border text-foreground`}`,children:[H(`div`,{className:`flex items-center gap-1.5 text-[10px] uppercase tracking-wider opacity-70 truncate`,children:[n,K(`span`,{className:`truncate`,children:e})]}),K(`div`,{className:`text-xl sm:text-2xl font-semibold tabular-nums leading-none`,children:t})]})}function Wn({icon:e,label:t}){return H(`span`,{className:`inline-flex items-center gap-1`,children:[e,K(`span`,{children:t})]})}var Gn={[J.Switch]:Z,[J.Siren]:Z,[J.Light]:Z,[J.Sensor]:Z,[J.Button]:Z,[J.Hub]:Vn,[J.Cover]:Dn,[J.Valve]:Z,[J.Humidifier]:Z,[J.WaterHeater]:Z,[J.Container]:Tn,[J.Lock]:Z,[J.Fan]:Z,[J.Thermostat]:Z,[J.Climate]:Z,[J.MediaPlayer]:Z,[J.Control]:Z,[J.AlarmPanel]:Z,[J.EventEmitter]:zn,[J.Notifier]:On,[J.Script]:Z,[J.Automation]:Z,[J.Presence]:Z,[J.Update]:Z,[J.Vacuum]:Z,[J.LawnMower]:Z,[J.Weather]:Z,[J.Image]:Z,[J.PetFeeder]:Z};function Kn(e){return Gn[e]??Bn}function qn(e){return K(Kn(e.deviceType),{...e})}function Jn(e){return de(Y().trpcClient,e)}V();function Yn(e){let[t,n]=G(`idle`),[r,i]=G(null),a=B(null),o=B(null),s=B(null),c=B(!0),l=P(),u=_e(),d=We(),f=z(()=>{if(a.current){try{a.current.close()}catch{}a.current=null}if(o.current){for(let e of o.current.getTracks())try{e.stop()}catch{}o.current=null}s.current=null},[]),p=z(async()=>{if(t===`idle`)return;n(`stopping`);let r=s.current;if(r&&e!==null)try{await Promise.race([d.mutateAsync({deviceId:e,sessionId:r}),new Promise((e,t)=>setTimeout(()=>t(Error(`server stopSession timeout`)),2e3))])}catch(e){console.warn(`[intercom] server stopSession failed (continuing teardown)`,e)}f(),c.current&&(n(`idle`),i(null))},[t,e,d,f]),m=z(async()=>{if(e===null||t!==`idle`&&t!==`error`)return;i(null);let r=null,f=null,m=null;try{n(`requesting-mic`),r=await navigator.mediaDevices.getUserMedia({audio:!0,video:!1}),o.current=r,n(`starting`);let t=await l.mutateAsync({deviceId:e});m=t.sessionId,s.current=m,n(`connecting`),f=new RTCPeerConnection,a.current=f,f.oniceconnectionstatechange=()=>{if(!c.current)return;let e=f.iceConnectionState;e===`connected`||e===`completed`?n(`talking`):(e===`failed`||e===`closed`||e===`disconnected`)&&c.current&&(i(e===`failed`?`WebRTC connection failed`:null),p())};for(let e of r.getAudioTracks())f.addTrack(e,r);await f.setRemoteDescription({type:`offer`,sdp:t.sdpOffer});let d=await f.createAnswer();await f.setLocalDescription(d);let h=f.localDescription?.sdp??d.sdp??``;await u.mutateAsync({deviceId:e,sessionId:m,sdpAnswer:h})}catch(t){let l=t instanceof Error?t.message:String(t);if(console.warn(`[intercom] start failed`,t),f)try{f.close()}catch{}if(r)for(let e of r.getTracks())try{e.stop()}catch{}if(a.current=null,o.current=null,m!==null)try{await d.mutateAsync({deviceId:e,sessionId:m})}catch{}s.current=null,c.current&&(i(l),n(`error`))}},[e,t,l,u,d,p]);return q(()=>(c.current=!0,()=>{c.current=!1;let t=s.current;if(t!==null&&e!==null&&d.mutate({deviceId:e,sessionId:t}),a.current){try{a.current.close()}catch{}a.current=null}if(o.current){for(let e of o.current.getTracks())try{e.stop()}catch{}o.current=null}s.current=null}),[e]),{state:t,error:r,start:m,stop:p,isTalking:t===`talking`}}V();var Xn=0;function Q(){return++Xn}function Zn(e){switch(e.type){case`system`:return`system`;case`device`:return`#${e.deviceId}`;case`provider`:return e.providerId;case`addon`:return e.addonId}}function Qn(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 $n(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 er(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 tr({scope:e,greeting:t,className:n}){let r=Y(),[i,a]=G(()=>{let n=[];return t&&n.push({id:Q(),kind:`info`,text:t}),n.push({id:Q(),kind:`info`,text:`scope: ${Zn(e)} — type help or context for available commands`}),n}),[o,s]=G(``),[c,l]=G([]),[u,d]=G(-1),f=B(null),p=B(null);q(()=>{let e=p.current;e&&(e.scrollTop=e.scrollHeight)},[i]);let m=z(()=>{f.current?.focus()},[]),h=tt({mutationFn:t=>r.trpcClient.repl.execute.mutate({code:t,scope:e}),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`;a(e=>[...e,{id:Q(),kind:r?`error`:`result`,text:n}])},onError:e=>{let t=e instanceof Error?e.message:String(e);a(e=>[...e,{id:Q(),kind:`error`,text:t}])}});function g(t){let n=t.trim();if(n){if(n===`clear`){a([{id:Q(),kind:`info`,text:`scope: ${Zn(e)}`}]),s(``);return}if(n===`help`){a(t=>[...t,{id:Q(),kind:`input`,text:`> ${n}`},...Qn(e).map(e=>({id:Q(),kind:`info`,text:e}))]),s(``);return}if(n===`context`){a(t=>[...t,{id:Q(),kind:`input`,text:`> ${n}`},...er(e).map(e=>({id:Q(),kind:`info`,text:e}))]),s(``);return}if(n===`examples`){a(t=>[...t,{id:Q(),kind:`input`,text:`> ${n}`},...$n(e).map(e=>({id:Q(),kind:`info`,text:e}))]),s(``);return}l(e=>[...e,n]),d(-1),a(e=>[...e,{id:Q(),kind:`input`,text:`> ${n}`}]),s(``),h.mutate(n)}}function _(t){if(t.key===`Enter`){t.preventDefault(),g(o);return}if(t.key===`ArrowUp`){if(t.preventDefault(),c.length===0)return;let e=u===-1?c.length-1:Math.max(0,u-1);d(e),s(c[e]??``);return}if(t.key===`ArrowDown`){if(t.preventDefault(),u===-1)return;let e=u+1;e>=c.length?(d(-1),s(``)):(d(e),s(c[e]??``));return}t.ctrlKey&&t.key===`l`&&(t.preventDefault(),a([{id:Q(),kind:`info`,text:`scope: ${Zn(e)}`}]))}let v={input:`text-zinc-300`,result:`text-emerald-300`,error:`text-red-300`,info:`text-zinc-400`};return H(`div`,{className:`flex flex-col bg-[#0c0a09] rounded-lg border border-border overflow-hidden font-mono text-xs ${n??``}`,onClick:m,children:[H(`div`,{ref:p,className:`flex-1 overflow-y-auto p-3 space-y-1 min-h-[120px]`,children:[i.map(e=>K(`pre`,{className:`whitespace-pre-wrap break-words leading-relaxed ${v[e.kind]}`,children:e.text},e.id)),h.isPending&&K(`span`,{className:`text-zinc-500 animate-pulse`,children:`…thinking`})]}),H(`div`,{className:`flex items-center gap-2 border-t border-zinc-800 px-3 py-2 bg-[#0c0a09]`,children:[K(`span`,{className:`text-emerald-400 flex-shrink-0 select-none font-bold`,children:`>`}),K(`input`,{ref:f,value:o,onChange:e=>s(e.target.value),onKeyDown:_,disabled:h.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`})]})]})}function nr({deviceId:e,intercomAvailable:t=!1}){let n=Y(),r=typeof window<`u`?window.location.origin:``,i=Number.isFinite(e),a=Jn(i?e:null),{streams:o,pipelineMetrics:s,createSession:c,sendAnswer:l,handleOffer:u,getIceServers:d,addIceCandidate:f,getIceCandidates:p,closeSession:m,getSessionState:h}=be(n.trpcClient,i?e:null),g=le(i?e:null,{width:sr}),_=Yn(i&&t?e:null),v=_.state===`requesting-mic`||_.state===`starting`||_.state===`connecting`||_.state===`stopping`,y=_.isTalking||v,b=()=>{_.state===`idle`||_.state===`error`?_.start():_.state!==`stopping`&&_.stop()},x=ut(),S=w(),C=typeof window<`u`?window.localStorage.getItem(`camstack_admin_token`):null,T=x.length>0?K(et,{children:x.map(e=>K(`div`,{className:`absolute inset-0`,children:e.node},e.id))}):null;return K(Je,{serverUrl:r,createSession:c,sendAnswer:l,handleOffer:u,getIceServers:d,addIceCandidate:f,getIceCandidates:p,closeSession:m,getSessionState:h,...S.request?{playbackUrl:S.request.url,playbackAuthToken:C,...S.request.label?{playbackLabel:S.request.label}:{},onExitPlayback:()=>S.clear()}:{},streams:o,pipelineMetrics:s,phase:a.phase,detections:a,defaultShowDetections:!0,defaultShowMotion:!0,showPlayStop:!0,snapshotSrc:g.src,...g.src?{posterUrl:g.src}:{},snapshotLoading:g.loading,onRefreshSnapshot:g.refresh,intercomAvailable:t,intercomShown:y,onIntercomToggle:b,extraOverlay:T,chromeless:!0,className:`h-full`})}function rr({deviceId:e,containerDeviceId:t}){return Number.isFinite(e)?K(`div`,{className:`flex flex-col h-full`,children:K(me,{...t===void 0?{deviceId:e}:{containerDeviceId:t},limit:50,maxHeight:`max-h-full`,showScope:!1,showFilters:!1})}):H(`div`,{className:`flex items-center justify-center h-full text-[11px] text-foreground-subtle italic`,children:[`Device #`,e,` not loaded.`]})}function ir({deviceId:e}){if(!Number.isFinite(e))return H(`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 K(tr,{scope:{type:`device`,deviceId:e},greeting:t,className:`h-full border-0 rounded-none`})}function ar({deviceId:e}){return Number.isFinite(e)?K(`div`,{className:`flex flex-col h-full overflow-y-auto`,children:K(Oe,{deviceId:e,limit:50,maxHeight:`max-h-full`})}):H(`div`,{className:`flex items-center justify-center h-full text-[11px] text-foreground-subtle italic`,children:[`Device #`,e,` not loaded.`]})}function or({deviceId:e}){return Number.isFinite(e)?K(`div`,{className:`flex flex-col h-full overflow-y-auto`,children:K(pe,{deviceId:e,limit:50,maxHeight:`max-h-full`})}):H(`div`,{className:`flex items-center justify-center h-full text-[11px] text-foreground-subtle italic`,children:[`Device #`,e,` not loaded.`]})}var sr=960;function cr({deviceId:e}){let t=W(),n=Number.isFinite(e),{data:r}=T({deviceId:e},{enabled:n}),i=typeof r?.type==`string`?r.type:`camera`;Jt([`deviceManager`,`getBindings`],[`capability.binding-changed`]);let{data:a,isLoading:o,isError:s,error:c}=O({deviceId:e},{enabled:n}),{data:l}=C({deviceType:i},{enabled:!!i}),u=N({onSuccess:()=>{t.invalidateQueries({queryKey:[[`deviceManager`,`getBindings`]]})}});if(o)return K(`div`,{className:`p-4`,children:K(`div`,{className:`h-20 rounded-lg border border-border bg-surface animate-pulse`})});if(s)return H(`div`,{className:`p-4 text-xs text-red-400`,children:[`Failed to load bindings: `,c instanceof Error?c.message:String(c)]});let d=new Map,f={};for(let e of l??[])f[e.capName]=e.wrappers;for(let e of a?.entries??[])d.set(e.capName,{...e,wrappers:f[e.capName]??[]});for(let e of l??[])d.has(e.capName)||d.set(e.capName,{capName:e.capName,kind:`unbound`,providerAddonId:``,providerNodeId:``,nativeAddonId:``,wrappers:e.wrappers});let p=[...d.values()].toSorted((e,t)=>e.capName.localeCompare(t.capName));if(p.length===0)return H(`div`,{className:`flex flex-col items-center justify-center gap-2 p-8 text-foreground-subtle`,children:[K(mt,{className:`h-8 w-8 opacity-40`}),K(`p`,{className:`text-xs`,children:`No capability providers applicable to this device yet.`}),K(`p`,{className:`text-[10px] opacity-60`,children:`Native providers show up here as soon as the owning addon registers them.`})]});let m=p.filter(e=>e.kind!==`unbound`).length;return H(`div`,{className:`flex flex-col gap-3 p-1`,children:[H(`div`,{className:`text-[11px] text-foreground-subtle`,children:[K(`span`,{className:`font-medium text-foreground`,children:m}),` of `,p.length,` capabilit`,p.length===1?`y`:`ies`,` bound — rows marked `,K(`em`,{children:`unbound`}),` have a wrapper available you can activate.`]}),K(Ce,{columns:[{key:`capability`,header:`Capability`,render:e=>K(`span`,{className:`font-mono text-foreground`,children:e.capName})},{key:`kind`,header:`Kind`,render:e=>K(lr,{kind:e.kind})},{key:`provider`,header:`Active Provider`,render:e=>K(`span`,{className:`font-mono text-foreground-subtle`,children:e.providerAddonId||K(`span`,{className:`opacity-40`,children:`—`})})},{key:`node`,header:`Node`,render:e=>e.providerNodeId?K(ur,{nodeId:e.providerNodeId}):K(`span`,{className:`text-[10px] opacity-40`,children:`—`})},{key:`native`,header:`Native`,render:e=>K(`span`,{className:`font-mono text-foreground-subtle`,children:e.nativeAddonId||K(`span`,{className:`opacity-40`,children:`—`})})},{key:`wrapper`,header:`Wrapper`,render:t=>{let n=t.kind===`wrapped`?t.providerAddonId:null;return K(dr,{wrappers:t.wrappers,activeWrapperId:n,disabled:u.isPending,onPick:r=>{let i=n===r;u.mutate({deviceId:e,capName:t.capName,wrapperAddonId:r,active:!i})}})}}],rows:p,rowKey:e=>e.capName,minWidthPx:720})]})}function lr({kind:e}){return e===`native`?H(`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:[K(Dt,{className:`h-3 w-3`}),`native`]}):e===`wrapped`?H(`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:[K(vt,{className:`h-3 w-3`}),`wrapped`]}):e===`linked`?H(`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:[K(an,{className:`h-3 w-3`}),`linked`]}):H(`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:[K(_t,{className:`h-3 w-3`}),`unbound`]})}function ur({nodeId:e}){return K(`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 dr({wrappers:e,activeWrapperId:t,disabled:n,onPick:r}){return e.length===0?K(`span`,{className:`text-[10px] opacity-40`,children:`none available`}):K(`div`,{className:`flex flex-wrap gap-1`,children:e.map(e=>{let i=e===t;return H(`button`,{disabled:n,onClick:()=>r(e),title:i?`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 ${i?`border-primary/40 bg-primary/10 text-primary`:`border-border text-foreground-subtle hover:text-foreground hover:bg-surface-hover`}`,children:[K(i?Mt:Tt,{className:`h-3 w-3`}),e]},e)})})}function fr({deviceId:e,activeSubTab:t,onSubTabChange:n}){return K(`div`,{className:`flex flex-col gap-3`,children:K($t,{deviceId:e,activeSubTab:t,onSubTabChange:n})})}V();var pr=new Set([`package-detection`]);function mr(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 hr(e){return e?e.modelId!==void 0||e.settings!==void 0:!1}function gr({deviceId:e,refreshToken:n}){let r=W(),i=Y().trpcClient,[o,l]=G(null),[u,f]=G(null),[p,m]=G(null),h=Ge({deviceId:e},{refetchOnMount:`always`}),g=s({deviceId:e},{refetchOnMount:`always`}),_=b(void 0,{refetchOnMount:`always`});Jt([`nodes`,`topology`],[`agent.online`,`agent.offline`,`agent.unregistered`,`addon.installed`,`addon.uninstalled`]);let v=A(void 0,{refetchOnMount:`always`}),y=U(()=>{let e=new Set;for(let t of v.data??[])t.isOnline&&e.add(t.id);return e},[v.data]),x=U(()=>(_.data??[]).filter(e=>y.has(e.nodeId)).map(e=>e.nodeId),[_.data,y]),S=x[0]??``,C=ye({nodeId:S},{enabled:S!==``,refetchOnMount:`always`}),w=$e({enabled:x.length>0,queryKey:[[`pipelineOrchestrator`,`getNodeInferenceDevices`],`device-step`,x.join(`,`),n],queryFn:async()=>{let e={};for(let t of x)try{e[t]=(await i.pipelineOrchestrator.getNodeInferenceDevices.query({nodeId:t})).devices}catch{e[t]=[]}return e}}),T=()=>{r.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getCameraSettings`]]}),r.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getCameraStepOverrides`]]})},E=d({onSuccess:T}),ee=ae({onSuccess:T}),te=U(()=>C.data?Ee(C.data):[],[C.data]),ne=U(()=>{let e=_.data??[],t=y.size===0?[]:e.filter(e=>y.has(e.nodeId)),n=[];for(let e of t){let t=(w.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:yt(r).label});else n.push({agentNodeId:e.nodeId,engineLabel:t[0]?.format??`(engine unknown)`})}return n},[_.data,w.data,y]),re=(e,t)=>w.data?.[e]?.find(e=>e.key===t)??null,D=e=>{if(e.deviceKey!==void 0)return e.deviceKey;let t=w.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},O=(e,t,n)=>g.data?.[e]?.[t]?.[n]??null,ie=e=>{if(pr.has(e))return{kind:`zone-driven`};let t=mr(C.data??null,e)?.enabledByDefault??!0,n=h.data?.stepToggles?.[e];return{kind:`gate`,effectiveOn:n??t,defaultOn:t,explicit:n!==void 0}},k=(e,t)=>{let n=mr(C.data??null,e);if(n)return Ae(n,t)},j=(e,t)=>{let n=ie(e),r=n.kind===`gate`?n.effectiveOn:!1,i=mr(C.data??null,e),a=D(t),o=a===null?null:re(t.agentNodeId,a);if(!ve(i?.models??[],o?.format))return r?{kind:`skip`}:{kind:`na`};let s=a===null?null:O(t.agentNodeId,a,e),c=o?.steps?.[e];return{kind:`enabled`,modelId:(i?R({catalog:i,device:o,override:s?.modelId,base:c?.modelId}):void 0)??`Auto`,overridden:hr(s)}},M=o&&C.data?mr(C.data,o.addonId):null,N=o?re(o.agentNodeId,o.deviceKey):null,oe=N?.format??`coreml`,se=o?hr(O(o.agentNodeId,o.deviceKey,o.addonId)):!1,ce=o?k(o.addonId,N):void 0,le=U(()=>{if(!o||!N)return null;let e=N.steps?.[o.addonId];return{enabled:!0,...e?.modelId===void 0?{}:{modelId:e.modelId},settings:e?.settings??{}}},[o,N]),ue=()=>{l(null),f(null)},P=(e,t)=>{let n=D(t);n!==null&&(l({addonId:e,agentNodeId:t.agentNodeId,deviceKey:n}),f(O(t.agentNodeId,n,e)))},de=(t,n)=>{ee.mutate({deviceId:e,addonId:t,enabled:n})},fe=()=>{o&&E.mutate({deviceId:e,agentNodeId:o.agentNodeId,deviceKey:o.deviceKey,addonId:o.addonId,patch:u},{onSuccess:ue})},F=()=>{o&&E.mutate({deviceId:e,agentNodeId:o.agentNodeId,deviceKey:o.deviceKey,addonId:o.addonId,patch:null},{onSuccess:ue})};if(_.isLoading||S!==``&&C.isLoading)return K(`div`,{className:`text-xs text-foreground-subtle animate-pulse p-4`,children:`Loading pipeline…`});if(ne.length===0)return K(`div`,{className:`text-xs text-foreground-subtle p-4`,children:`No online agents.`});if(!C.data)return K(`div`,{className:`text-xs text-foreground-subtle p-4`,children:`Catalog unavailable.`});let I=o!==null&&M!==null&&N!==null;return H(`div`,{className:`relative h-full w-full space-y-3`,children:[H(`div`,{className:`rounded-md border border-border bg-muted/20 px-3 py-2 text-[11px] leading-relaxed text-foreground-subtle`,children:[K(`span`,{className:`font-medium text-foreground`,children:`Gate`}),` (col 1) decides whether this camera runs a step — independent of nodes. Each`,` `,K(`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 `,K(`span`,{className:`text-amber-500`,children:`⚠ skip`}),` `,`and won't run there.`]}),H(`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:[K(`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.`]}),K(`div`,{className:I?`md:pr-[360px]`:``,children:te.length>0?K(c,{tree:te,agents:ne,gateFor:ie,getCellState:j,onCellClick:P,selectedCell:o,onSetGate:de,gateBusy:ee.isPending,fallbackNodeId:p,onFallbackNodeChange:m}):K(`div`,{className:`text-xs text-foreground-subtle`,children:`Catalog empty.`})}),K(t,{open:I,onClose:ue,title:M?.name??``,subtitle:o&&N?`${o.agentNodeId} · ${yt(N).label} · ${N.format}`:``,footer:H(et,{children:[K(`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||E.isPending,onClick:F,children:`Clear override`}),K(`div`,{className:`flex-1`}),K(`button`,{type:`button`,className:`px-3 py-1 text-xs border border-border rounded bg-surface hover:bg-muted`,onClick:ue,children:`Cancel`}),K(`button`,{type:`button`,disabled:!o||!le||E.isPending,className:`px-3 py-1 text-xs bg-primary text-primary-foreground rounded disabled:opacity-50`,onClick:fe,children:E.isPending?`Saving…`:`Save`})]}),children:M&&o&&le?K(a,{mode:`device`,addon:M,agentDefault:le,agentNodeId:o.agentNodeId,currentPatch:u,engineFormat:oe,effectiveModelId:ce,onChangePatch:f}):K(`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 _r=[{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`}],vr={"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 yr(e){return vr[e]??`object-detection`}V();var br=`steps`,xr=`settings`,Sr=new Set([br,xr]);function Cr(e){return e.location===`top-tab`&&(e.tab===`detection-pipeline`||e.tab===`zones`)}function wr({deviceId:e,activeSubTab:t,onSubTabChange:n}){return H(te,{value:t&&Sr.has(t)?t:br,onValueChange:z(e=>{n?.(e)},[n]),className:`flex flex-col`,children:[H(m,{className:`flex-shrink-0`,children:[K(v,{value:br,children:`Steps`}),K(v,{value:xr,children:`Settings`})]}),K(l,{value:br,children:K(gr,{deviceId:e,refreshToken:0})}),K(l,{value:xr,children:K($t,{deviceId:e,sectionFilter:Cr,subTabGrouping:{groupOf:e=>yr(e.id),tabs:_r}})})]})}function $({label:e,value:t}){return H(`div`,{className:`${lt} flex items-start gap-2 sm:gap-3`,children:[K(`span`,{className:`w-20 sm:w-28 flex-shrink-0 text-[11px] text-foreground-subtle`,children:e}),K(`div`,{className:`flex-1 min-w-0 text-[11px] text-foreground`,children:t})]})}V();function Tr({deviceId:e,initialName:t}){let n=W(),[r,i]=G(!1),[a,o]=G(t),[s,c]=G(!1),l=B(null);q(()=>{r||o(t)},[t,r]),q(()=>{r&&l.current?.focus()},[r]);let u=M({onSuccess:()=>{n.invalidateQueries({queryKey:[[`deviceManager`,`getDevice`]]}),n.invalidateQueries({queryKey:[[`deviceManager`,`listAll`]]}),n.invalidateQueries({queryKey:[[`deviceManager`,`getDeviceAggregate`]]})}}),d=async()=>{let n=a.trim();if(n.length===0||n===t){i(!1),o(t);return}c(!0);try{await u.mutateAsync({deviceId:e,name:n}),i(!1)}catch{}finally{c(!1)}},f=()=>{o(t),i(!1)};return r?K($,{label:`Name`,value:H(`div`,{className:`flex items-center gap-1`,children:[K(`input`,{ref:l,type:`text`,value:a,onChange:e=>o(e.target.value),onKeyDown:e=>{e.key===`Enter`?d():e.key===`Escape`&&f()},disabled:s,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`}),K(`button`,{type:`button`,onClick:()=>void d(),disabled:s,className:`p-0.5 rounded hover:bg-success/10 text-success disabled:opacity-50`,"aria-label":`Save`,children:K(Mt,{className:`h-3 w-3`})}),K(`button`,{type:`button`,onClick:f,disabled:s,className:`p-0.5 rounded hover:bg-danger/10 text-danger disabled:opacity-50`,"aria-label":`Cancel`,children:K(zt,{className:`h-3 w-3`})})]})}):K($,{label:`Name`,value:H(`div`,{className:`flex items-center gap-2 group`,children:[K(`span`,{className:`truncate`,children:t}),K(`button`,{type:`button`,onClick:()=>i(!0),className:`p-0.5 rounded text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,"aria-label":`Edit name`,children:K(St,{className:`h-3.5 w-3.5`})})]})})}V();function Er({deviceId:e,initialLocation:t}){let r=W(),[i,a]=G(!1),[o,s]=G(t??``),[c,l]=G(!1),u=B(null),{data:d}=ee(void 0,{enabled:i}),f=d??[];q(()=>{i||s(t??``)},[t,i]),q(()=>{i&&u.current?.focus()},[i]);let p=n({onSuccess:()=>{r.invalidateQueries({queryKey:[[`deviceManager`,`getDevice`]]}),r.invalidateQueries({queryKey:[[`deviceManager`,`listAll`]]}),r.invalidateQueries({queryKey:[[`deviceManager`,`getDeviceAggregate`]]}),r.invalidateQueries({queryKey:[[`deviceManager`,`listLocations`]]})}}),m=U(()=>{let e=o.trim().toLowerCase();return e.length===0?f:f.filter(t=>t.toLowerCase()!==e&&t.toLowerCase().includes(e))},[f,o]),h=o.trim().length>0&&!f.some(e=>e.toLowerCase()===o.trim().toLowerCase()),g=async n=>{let r=(n??o).trim(),i=r.length===0?null:r;if(i===(t??null)){a(!1);return}l(!0);try{await p.mutateAsync({deviceId:e,location:i}),a(!1)}catch{}finally{l(!1)}},_=()=>{s(t??``),a(!1)};return i?K($,{label:`Location`,value:H(`div`,{className:`relative`,children:[H(`div`,{className:`flex items-center gap-1`,children:[K(`input`,{ref:u,type:`text`,value:o,onChange:e=>s(e.target.value),onKeyDown:e=>{e.key===`Enter`?g():e.key===`Escape`&&_()},disabled:c,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`}),K(`button`,{type:`button`,onClick:()=>void g(),disabled:c,className:`p-0.5 rounded hover:bg-success/10 text-success disabled:opacity-50`,"aria-label":`Save`,children:K(Mt,{className:`h-3 w-3`})}),K(`button`,{type:`button`,onClick:_,disabled:c,className:`p-0.5 rounded hover:bg-danger/10 text-danger disabled:opacity-50`,"aria-label":`Cancel`,children:K(zt,{className:`h-3 w-3`})})]}),(m.length>0||h)&&H(`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:[m.map(e=>H(`button`,{type:`button`,onClick:()=>{s(e),g(e)},className:`w-full flex items-center gap-2 px-2 py-1 text-left text-[11px] hover:bg-surface-hover`,children:[K(xt,{className:`h-3 w-3 text-foreground-subtle flex-shrink-0`}),K(`span`,{className:`truncate`,children:e})]},e)),h&&H(`button`,{type:`button`,onClick:()=>void g(),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:[K(`span`,{className:`text-foreground-subtle`,children:`Create`}),H(`span`,{className:`font-medium truncate`,children:[`"`,o.trim(),`"`]})]})]})]})}):K($,{label:`Location`,value:H(`div`,{className:`flex items-center gap-2 group`,children:[t?K(`span`,{className:`truncate`,children:t}):K(`span`,{className:`italic text-foreground-subtle`,children:`unset`}),K(`button`,{type:`button`,onClick:()=>a(!0),className:`p-0.5 rounded text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,"aria-label":`Edit location`,children:K(St,{className:`h-3.5 w-3.5`})})]})})}V();function Dr({deviceId:e}){let t=W(),{data:n}=gt(e),{data:r}=bt(e),[i,a]=G(null),o=f({onSuccess:()=>{a(null),t.invalidateQueries({queryKey:[[`deviceManager`]]})},onError:e=>{a(`Could not change primary child: ${e.message}`)}});if(n==null||String(n.type??``)!==J.Container)return null;let s=(r??[]).map(e=>({id:e.id,stableId:e.stableId,type:e.type,name:e.name,...e.sourceInfo?{sourceInfo:{id:e.sourceInfo.id}}:{}}));if(s.length<=1)return null;let c=xe(s,typeof n.linkDeviceId==`number`?n.linkDeviceId:null,typeof n.primaryChildEntityId==`string`?n.primaryChildEntityId:null);return H(et,{children:[K($,{label:`Primary child`,value:K(j,{childrenList:s,selectedId:c===null?s[0].id:c.id,onSetPrimary:t=>o.mutate({deviceId:e,primaryChildEntityId:t}),disabled:o.isPending})}),i!==null&&K(`p`,{role:`alert`,className:`px-3 sm:px-4 py-1.5 text-[11px] text-danger`,children:i})]})}V();var Or=[`manufacturer`,`model`,`hardware`,`firmware`,`serialNumber`,`uid`,`mac`,`itemNo`];function kr(e){return e.replace(/([a-z])([A-Z])/g,`$1 $2`).replace(/^./,e=>e.toUpperCase())}function Ar(e){return e==null?`—`:typeof e==`string`||typeof e==`number`||typeof e==`boolean`?String(e):JSON.stringify(e)}function jr(){let e=S(),t=E(),{data:n}=T({deviceId:e??0},{enabled:e!==null}),{data:r}=O({deviceId:e??0},{enabled:e!==null}),i=n??t??null,[a,o]=G(`identity`);if(e===null||!i)return null;let s=String(i.stableId??``),c=String(i.name??``),l=String(i.type??``),u=String(i.addonId??``),d=i.features??[],f=new Set([`device-status`,`feature-probe`,`device-ops`]),p=(r?.entries??[]).filter(e=>e.kind===`native`&&!f.has(e.capName)).map(e=>e.capName),m=d.length>0?d:p,h=i.location??null,g=i.metadata??null,_=g!==null&&Object.keys(g).length>0;return H(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[H(`div`,{className:`border-b border-border px-3 sm:px-4 py-2 flex items-center justify-between gap-3`,children:[K(`h2`,{className:`text-[11px] font-semibold text-foreground uppercase tracking-wider`,children:`Device Info`}),_&&H(`div`,{className:`flex items-center gap-1 rounded-md bg-surface-hover p-0.5`,children:[K(Mr,{active:a===`identity`,onClick:()=>o(`identity`),label:`Identity`}),K(Mr,{active:a===`hardware`,onClick:()=>o(`hardware`),label:`Hardware`})]})]}),(!_||a===`identity`)&&H(`div`,{className:`divide-y divide-border`,children:[K($,{label:`ID`,value:H(`span`,{className:`font-mono text-[11px] text-foreground`,children:[`#${e}`,H(`span`,{className:`ml-1.5 text-foreground-subtle`,children:[`(`,s,`)`]})]})}),K(Tr,{deviceId:e,initialName:c}),K(Er,{deviceId:e,initialLocation:h}),K(Dr,{deviceId:e}),K($,{label:`Type`,value:l}),K($,{label:`Provider`,value:K(ht,{type:u,size:`sm`,showLabel:!0})}),K($,{label:`Capabilities`,value:m.length>0?K(pt,{capabilities:m,showLabels:!0}):K(`span`,{className:`text-[11px] text-foreground-subtle`,children:`None`})})]}),_&&a===`hardware`&&K(Nr,{metadata:g})]})}function Mr({active:e,onClick:t,label:n}){return K(`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 Nr({metadata:e}){let t=Or.filter(t=>t in e),n=Object.keys(e).filter(e=>!Or.includes(e)).toSorted(),r=[...t,...n];return H(`div`,{children:[K(`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.`}),K(`div`,{className:`divide-y divide-border`,children:r.map(t=>K($,{label:kr(t),value:K(`span`,{className:`font-mono text-[11px] text-foreground break-all`,children:Ar(e[t])})},t))})]})}V();function Pr({deviceId:e}){let[t,n]=G(null),r=ge({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 H(`div`,{className:`rounded-lg border border-border bg-surface px-4 py-3`,children:[H(`div`,{className:`flex items-center justify-between gap-3`,children:[H(`div`,{children:[K(`h2`,{className:`text-xs font-semibold uppercase tracking-wider text-foreground`,children:`Re-sync`}),K(`p`,{className:`mt-0.5 text-[11px] text-foreground-subtle`,children:`Re-align this device's type, role, capabilities and units with its source.`})]}),H(`button`,{type:`button`,disabled:r.isPending,onClick:()=>{n(null),r.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:[K(wt,{className:`h-3 w-3 ${r.isPending?`animate-spin`:``}`}),r.isPending?`Re-syncing…`:`Re-sync`]})]}),t!==null&&K(`p`,{className:`mt-2 text-[11px] text-foreground-subtle`,children:t})]})}V();var Fr={icon:``,label:``,unit:``,precision:``,hidden:!1};function Ir(e){return{icon:e?.icon??``,label:e?.label??``,unit:e?.unit??``,precision:e?.precision===void 0?``:String(e.precision),hidden:e?.hidden===!0}}function Lr(e){if(typeof e!=`object`||!e)return;let t=e.unit;return typeof t==`string`?t:void 0}function Rr(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 zr({deviceId:e}){let t=Y(),n=W(),{data:r}=T({deviceId:e},{enabled:e>0}),i=typeof r?.role==`string`?r.role:null,a=i===null?void 0:Pe[i],o=a?.kind===`numeric`,s=je(t.trpcClient,e,i??``),c=a?.kind===`numeric`?a.canonicalUnit:void 0,l=Lr(s)??c,u=l===void 0?void 0:st(l),d=U(()=>u===void 0?[]:ot(u),[u]),[f,p]=G(null),m=f??Ir(r?.display),h=Xe({onSuccess:()=>{n.invalidateQueries({queryKey:[[`deviceManager`]]})}}),{data:g}=Se({},{staleTime:6e4}),_=k({onSuccess:()=>{n.invalidateQueries({queryKey:[[`deviceManager`]]})}});if(r===void 0||i===null)return null;let v=e=>{p({...m,...e})},y=()=>{h.mutate({deviceId:e,display:Rr(m)})},b=()=>{p(Fr),h.mutate({deviceId:e,display:null})},x=()=>{let e={...m.icon===``?{}:{icon:m.icon},...m.unit===``?{}:{unit:m.unit},...m.precision.trim()!==``&&Number.isFinite(Number.parseInt(m.precision,10))?{precision:Number.parseInt(m.precision,10)}:{}},t={...g?.defaults,[i]:e};_.mutate({defaults:t})},S=Me(i).label,C=Object.keys(L);return H(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[K(`div`,{className:`border-b border-border px-4 py-2`,children:K(`h2`,{className:`text-xs font-semibold text-foreground uppercase tracking-wider`,children:`Display`})}),H(`div`,{className:`p-4 space-y-3`,children:[H(`label`,{className:`block`,children:[K(`span`,{className:`text-[11px] text-foreground-subtle`,children:`Icon`}),H(`select`,{className:`mt-1 w-full rounded border border-border bg-surface px-2 py-1 text-sm text-foreground`,value:m.icon,onChange:e=>v({icon:e.target.value}),children:[H(`option`,{value:``,children:[`Default (`,S,`)`]}),C.map(e=>K(`option`,{value:e,children:e},e))]})]}),H(`label`,{className:`block`,children:[K(`span`,{className:`text-[11px] text-foreground-subtle`,children:`Label`}),K(`input`,{type:`text`,className:`mt-1 w-full rounded border border-border bg-surface px-2 py-1 text-sm text-foreground`,placeholder:S,value:m.label,onChange:e=>v({label:e.target.value})})]}),o&&H(`div`,{className:`grid grid-cols-2 gap-3`,children:[H(`label`,{className:`block`,children:[K(`span`,{className:`text-[11px] text-foreground-subtle`,children:`Unit`}),H(`select`,{className:`mt-1 w-full rounded border border-border bg-surface px-2 py-1 text-sm text-foreground`,value:m.unit,onChange:e=>v({unit:e.target.value}),disabled:d.length===0,children:[H(`option`,{value:``,children:[`Source`,l?` (${l})`:``]}),d.map(e=>K(`option`,{value:e,children:e},e))]})]}),H(`label`,{className:`block`,children:[K(`span`,{className:`text-[11px] text-foreground-subtle`,children:`Precision`}),K(`input`,{type:`number`,min:0,max:10,step:1,className:`mt-1 w-full rounded border border-border bg-surface px-2 py-1 text-sm text-foreground`,placeholder:`inherit`,value:m.precision,onChange:e=>v({precision:e.target.value})})]})]}),H(`label`,{className:`flex items-center gap-2`,children:[K(`input`,{type:`checkbox`,checked:m.hidden,onChange:e=>v({hidden:e.target.checked})}),K(`span`,{className:`text-sm text-foreground`,children:`Hide from device lists`})]}),H(`div`,{className:`flex flex-wrap items-center gap-2 pt-1`,children:[K(`button`,{type:`button`,className:`rounded bg-primary px-3 py-1 text-sm font-medium text-primary-foreground disabled:opacity-50`,onClick:y,disabled:h.isPending,children:`Save`}),K(`button`,{type:`button`,className:`rounded border border-border px-3 py-1 text-sm text-foreground-subtle`,onClick:b,disabled:h.isPending,children:`Reset`}),H(`button`,{type:`button`,className:`rounded border border-border px-3 py-1 text-sm text-foreground-subtle`,onClick:x,disabled:_.isPending,title:`Apply this unit / precision / icon as the default for every ${S} sensor`,children:[`Set as default for all `,S,` sensors`]})]})]})]})}function Br(e){return e<1e3?`${e.toFixed(0)} kbps`:`${(e/1e3).toFixed(1)} Mbps`}function Vr({device:e}){let t=jt(),n=typeof e.id==`number`?e.id:null,r=String(e.type??``),i=r===J.Camera,a=r===J.Hub,o=typeof e.role==`string`&&e.role.length>0,s=e.features??[],c=s.includes(rt.Resyncable),{data:l}=h({deviceId:n??0},{enabled:n!==null&&i,refetchInterval:5e3}),u=l?.streams??{},d=Object.entries(u),f=s.includes(rt.DoorbellButton),p=ze(f?{deviceId:n??void 0,historyLimit:10}:void 0),m=p.latest?Date.now()-p.latest.timestamp<3e4:!1;return H(`div`,{className:`space-y-5`,children:[a&&n!==null&&K(Fe,{deviceId:n,onOpenChild:e=>t(`/devices/${e}`)}),c&&n!==null&&K(Pr,{deviceId:n}),i&&n!==null&&K(D,{widgetId:`pipeline-orchestrator/pipeline-quick-stats`,host:`device-tab`,deviceId:n}),f&&K(Ve,{history:p.history,latestIsFresh:m}),i&&n!==null&&K(D,{widgetId:`stream-broker/stream-broker-panel`,host:`device-tab`,deviceId:n}),i&&d.length>0&&H(`div`,{className:`@container rounded-lg border border-border bg-surface overflow-hidden`,style:{containerType:`inline-size`},children:[K(`div`,{className:`border-b border-border px-4 py-2`,children:K(`h2`,{className:`text-xs font-semibold text-foreground uppercase tracking-wider`,children:`Stream Network`})}),K(`div`,{className:`divide-y divide-border`,children:d.map(([e,t])=>H(`div`,{className:`px-4 py-2.5`,children:[H(`div`,{className:`flex items-center gap-2 mb-2`,children:[K(Ot,{className:`h-3 w-3 text-foreground-subtle`}),K(`span`,{className:`text-[11px] font-medium text-foreground`,children:e})]}),H(`div`,{className:`grid grid-cols-2 @[640px]:grid-cols-4 gap-2`,children:[K(Hr,{label:`Nominal`,value:Br(t.nominalBitrateKbps??0)}),K(Hr,{label:`Observed`,value:Br(t.observedBitrateKbps??0)}),K(Hr,{label:`Peak`,value:Br(t.peakBitrateKbps??0)}),K(Hr,{label:`Packet Loss`,value:`${(t.packetLossPercent??0).toFixed(2)}%`,warning:(t.packetLossPercent??0)>1})]})]},e))})]}),K(jr,{}),o&&n!==null&&K(zr,{deviceId:n})]})}function Hr({label:e,value:t,warning:n}){return H(`div`,{children:[K(`p`,{className:`text-[10px] text-foreground-subtle`,children:e}),K(`p`,{className:`text-xs font-medium ${n?`text-warning`:`text-foreground`}`,children:t})]})}V();var Ur=[{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 Wr(e){let t=e===J.Camera;return Ur.filter(e=>t||!e.cameraOnly).map(({id:e,label:t})=>({id:e,label:t}))}var Gr=[{id:`logs`,icon:Vt,label:`Logs`},{id:`repl`,icon:Lt,label:`REPL`},{id:`events`,icon:Ft,label:`Events`},{id:`state`,icon:kt,label:`State`}];function Kr(){let e=Ht(),t=Number(e.deviceId),n=Number.isFinite(t),r=jt(),a=W(),s=ue(),c=Y(),[l,u]=At(),d=l.get(`tab`)??`overview`,f=l.get(`sub`),[m,h]=G(`logs`),g=`device-detail.left-col-width-px`,[v,b]=G(()=>{if(typeof window>`u`)return null;let e=window.localStorage.getItem(g),t=e?Number(e):NaN;return Number.isFinite(t)&&t>0?t:null}),S=B(v);S.current=v;function C(e){e.preventDefault();let t=e.clientX,n=e.currentTarget.previousElementSibling?.getBoundingClientRect().width??v??0,r=Math.max(330,Math.floor(window.innerWidth*.7)),i=e=>{b(Math.max(280,Math.min(r,n+(e.clientX-t))))},a=()=>{document.removeEventListener(`mousemove`,i),document.removeEventListener(`mouseup`,a);let e=S.current;if(e!==null)try{window.localStorage.setItem(g,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:w,isLoading:E,isError:ee}=T({deviceId:t},{enabled:n,refetchInterval:5e3,retry:1}),{data:te}=Te({deviceId:t},{enabled:n}),re=U(()=>{let e=te?.settings?.sections??[],t=te?.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(Xt)&&r.add(Zt),[...r].map(e=>e===`export`?{id:e,label:Qt,isAddonContrib:!0}:{id:e,label:nt[e]?.label??e,isAddonContrib:!0})},[te]),D=w,O=String(D?.name??e.deviceId??`Device`),ie=D?.online===!0,ae=ie?`online`:`offline`,k=String(D?.addonId??`rtsp`),A=D?.features??[],j=D?.type,M=j===J.Camera,{data:N}=bt(n?t:0),se=j===J.Container,le=U(()=>(N??[]).map(e=>({id:e.id,stableId:e.stableId,type:e.type,...e.sourceInfo?{sourceInfo:{id:e.sourceInfo.id}}:{}})),[N]),P=U(()=>se?xe(le,typeof D?.linkDeviceId==`number`?D.linkDeviceId:null,typeof D?.primaryChildEntityId==`string`?D.primaryChildEntityId:null)?.id??null:null,[se,le,D?.linkDeviceId,D?.primaryChildEntityId]),{data:de}=Te({deviceId:P??0},{enabled:P!==null}),fe=U(()=>{if(P===null)return[];let e=de?.settings?.sections??[],t=de?.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:nt[e]?.label??e,isAddonContrib:!0,childDeviceId:P}))},[P,de]),F=typeof D?.parentDeviceId==`number`?D.parentDeviceId:null,{data:I}=T({deviceId:F??0},{enabled:F!==null}),L=p(),pe=D?.disabled!==!0,me=U(()=>{let e=new Set,t=[];for(let n of[...Wr(j),...re,...fe])e.has(n.id)||(e.add(n.id),t.push(n));return t},[j,re,fe]),he=U(()=>me.some(e=>e.id===d)?d:`overview`,[me,d]),ge=z(e=>{u(t=>{let n=new URLSearchParams(t);return e===`overview`?n.delete(`tab`):n.set(`tab`,e),n.delete(`sub`),n},{replace:!0})},[u]),_e=z(e=>{u(t=>{let n=new URLSearchParams(t);return n.set(`sub`,e),n},{replace:!0})},[u]),ve=(N??[]).length>0,ye=U(()=>Gr.filter(({featureGate:e})=>!e||A.includes(e)),[A]),{data:R}=Ue({addonId:k},{enabled:!!k&&k!==`rtsp`}),be=_({onSuccess:()=>{a.invalidateQueries({queryKey:[[`deviceManager`]]}),r(R?.id?`/integrations/${R.id}`:`/integrations`)}}),Se=Ke({onSuccess:()=>{a.invalidateQueries({queryKey:[[`deviceManager`]]})}}),Ce=Ye({onSuccess:()=>{a.invalidateQueries({queryKey:[[`deviceManager`]]})}}),Ee=He(),Oe=qe({onSuccess:()=>{a.invalidateQueries({queryKey:[[`deviceManager`]]})}}),ke=A.includes(rt.Rebootable),Ae=A.includes(rt.BatteryOperated),je=ne(c.trpcClient,Ae&&n?t:null),[Me,Pe]=G(!1),Fe=ct(c.trpcClient,n?t:null),Ie=async()=>{if(!(Me||!Fe)){Pe(!0);try{await Fe.snapshot?.invalidateCache({});let e=await Fe.snapshot?.getSnapshot({});if(!e)return;let t=`data:${e.contentType};base64,${e.base64}`,n=e.contentType.includes(`png`)?`png`:`jpg`,r=O.replace(/[^a-zA-Z0-9_.-]+/g,`_`),i=new Date().toISOString().replace(/[:.]/g,`-`),a=document.createElement(`a`);a.href=t,a.download=`${r}-${i}.${n}`,document.body.appendChild(a),a.click(),document.body.removeChild(a)}finally{Pe(!1)}}},Le=Se.isPending||Ce.isPending,{data:Re}=we({deviceId:t},{enabled:n,refetchInterval:1e4}),ze=Re?.agentNodeId??null,Be=typeof ze==`string`&&ze.length>0&&!ze.startsWith(`addon:`)?ze:void 0,{data:Ve}=ce({deviceId:t,...Be?{nodeId:Be}:{}},{enabled:n,refetchInterval:3e3,retry:!1}),{data:We}=Qe({deviceId:t},{enabled:n,refetchInterval:3e3,retry:!1}),Ge=We?.level?.dbfs??null;function Je(){if(!n)return null;switch(he){case`overview`:return K(Vr,{device:D??{}});case`config`:return K(fr,{deviceId:t,activeSubTab:f,onSubTabChange:_e});case`detection-pipeline`:return K(wr,{deviceId:t,activeSubTab:f,onSubTabChange:_e});case`bindings`:return K(cr,{deviceId:t});default:{let e=he,n=re.some(t=>t.id===e),r=fe.find(t=>t.id===e);if(!n&&r===void 0)return null;let i=r?.childDeviceId??t;if(e===`export`)return K($t,{deviceId:t,sectionFilter:Xt,activeSubTab:f,onSubTabChange:_e});let a=K($t,{deviceId:i,sectionFilter:t=>t.location===`top-tab`&&(t.tab===e||e===`detection-pipeline`&&t.tab===`zones`),flattenSubTabs:e===`detection-pipeline`,activeSubTab:f,onSubTabChange:_e});return r!==void 0&&i!==t?K(y,{deviceId:i,children:a}):a}}}return n?E?H(`div`,{className:`flex flex-col h-full`,children:[H(`div`,{className:`border-b border-border bg-surface px-6 py-4`,children:[K(`div`,{className:`h-4 w-48 rounded bg-surface-hover animate-pulse mb-3`}),K(`div`,{className:`h-8 w-64 rounded bg-surface-hover animate-pulse`})]}),K(`div`,{className:`flex-1 p-6`,children:K(`div`,{className:`h-40 rounded-lg border border-border bg-surface animate-pulse`})})]}):ee||!w?H(`div`,{className:`flex flex-col items-center justify-center h-full gap-3 text-foreground-subtle`,children:[K(`p`,{className:`text-lg font-semibold text-foreground`,children:`Device not found`}),H(`p`,{className:`text-xs`,children:[`No device with ID`,` `,H(`code`,{className:`font-mono bg-surface px-1.5 py-0.5 rounded text-[11px]`,children:[`#`,t]})]}),K(`button`,{onClick:()=>r(`/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`})]}):H(`div`,{className:`absolute inset-0 flex flex-col overflow-hidden`,children:[H(`div`,{className:`border-b border-border bg-surface px-6 py-3 flex-shrink-0`,children:[K(`div`,{className:`mb-2`,children:K(x,{items:[{label:`Integrations`,onClick:()=>r(`/integrations`)},{label:R?.name??k,onClick:()=>R?.id&&r(`/integrations/${R.id}`)},{label:O}]})}),H(`div`,{className:`flex items-center gap-2 sm:gap-3`,children:[K(ht,{type:k,size:`lg`}),H(`div`,{className:`min-w-0 flex-1`,children:[H(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[K(`h1`,{className:`text-sm sm:text-base font-semibold text-foreground truncate`,children:O}),K(Yt,{status:ae}),Ae&&K(oe,{status:je,variant:`full`})]}),F!==null&&I&&H(`button`,{type:`button`,onClick:()=>r(`/devices/${F}`),className:`text-[10px] text-foreground-subtle hover:text-primary transition-colors mt-0.5 inline-flex items-center gap-1`,title:`Open parent device ${I.name}`,children:[K(`span`,{children:`↑`}),K(`span`,{className:`truncate`,children:String(I.name??`Device #${F}`)})]}),K(`div`,{className:`hidden md:flex items-center gap-3 mt-0.5 text-[10px] text-foreground-subtle`,children:A.length>0&&K(pt,{capabilities:A})})]}),Ve&&K(`div`,{className:`hidden lg:flex`,children:K(qr,{metrics:Ve,dbfs:Ge})}),H(`div`,{className:`flex items-center gap-1 shrink-0`,children:[H(`button`,{onClick:async()=>{pe?await s({title:`Disable "${O}"?`,message:`The device will stop processing streams and events. You can re-enable it later.`,confirmLabel:`Disable`,variant:`danger`})&&Ce.mutate({deviceId:t}):Se.mutate({deviceId:t})},disabled:Le,title:pe?`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 ${pe?`border-success/30 text-success hover:bg-success/10`:`border-border text-foreground-subtle/50 hover:text-foreground hover:bg-surface-hover`}`,children:[K(Ct,{className:`h-3.5 w-3.5`}),K(`span`,{className:`hidden sm:inline`,children:Le?`Updating…`:pe?`Enabled`:`Disabled`})]}),K(`div`,{className:`hidden sm:block h-5 w-px bg-border mx-1`}),M&&H(et,{children:[K(xn,{deviceId:t}),K(`div`,{className:`hidden sm:block h-5 w-px bg-border mx-1`})]}),K(De,{triggerClassName:`ml-1`,items:[{id:`snapshot`,label:`Take snapshot`,description:`Fetch a fresh frame and download it.`,icon:qt,disabled:Me,onClick:()=>{Ie()}},{id:`reboot`,label:`Reboot device`,description:`Camera goes offline for ~30 seconds.`,icon:Et,hidden:!ke,disabled:Ee.isPending,danger:!0,onClick:async()=>{await s({title:`Reboot "${O}"?`,message:`The camera will go offline for around 30 seconds while the firmware reboots.`,confirmLabel:`Reboot`,variant:`danger`})&&Ee.mutate({deviceId:t})}},{id:`restart-addon`,label:`Restart addon`,description:`Bounces every device served by ${R?.name??k}.`,icon:wt,disabled:Oe.isPending,danger:!0,onClick:async()=>{await s({title:`Restart "${R?.name??k}"?`,message:`Restarting the addon will briefly disconnect every device served by it (not just "${O}"). Streams will reconnect automatically.`,confirmLabel:`Restart`,variant:`danger`})&&Oe.mutate({addonId:k})}},{id:`delete`,label:`Delete device`,description:`Remove the device and all its settings.`,icon:Ut,separatorBefore:!0,disabled:be.isPending,danger:!0,onClick:async()=>{await s({title:`Delete "${O}"?`,message:`This will remove the device and all its settings. This action cannot be undone.`,confirmLabel:`Delete`,variant:`danger`})&&be.mutate({deviceId:t})}}]})]})]})]}),K(y,{deviceId:t,device:D??void 0,children:K(i,{children:K(o,{children:K(dt,{children:K(Ne,{children:H(`main`,{className:L?`flex-1 overflow-y-auto flex flex-col`:`flex-1 min-h-0 overflow-hidden flex flex-row`,children:[H(`div`,{className:L?`flex flex-col bg-surface`:`${v===null?`w-1/2 lg:w-1/3`:``} flex-shrink-0 flex flex-col bg-surface min-h-0 overflow-hidden`,style:!L&&v!==null?{width:`${String(v)}px`}:void 0,children:[K(`div`,{className:M?`flex-shrink-0 border-b border-border-subtle bg-black`:L?`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:M?K(nr,{deviceId:t,intercomAvailable:A.includes(rt.TwoWayAudio)}):K(qn,{deviceId:t,deviceName:O,deviceType:j??`unknown`,provider:k,isOnline:ie,features:A})}),H(`div`,{className:L?`flex flex-col border-b border-border`:`flex-1 min-h-0 flex flex-col overflow-hidden`,children:[K(`div`,{className:`flex-shrink-0 border-b border-border-subtle px-2 py-1.5`,children:K(`div`,{className:`flex gap-1 overflow-x-auto -mx-1 px-1 pb-0.5`,children:ye.map(({id:e,label:t,icon:n})=>H(`button`,{onClick:()=>h(e),title:t,className:`flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium transition-colors flex-shrink-0 ${m===e?`bg-primary/15 text-primary`:`text-foreground-subtle hover:text-foreground hover:bg-surface-hover`}`,children:[K(n,{className:`h-3 w-3`}),t]},e))})}),H(`div`,{className:L?`h-72 overflow-hidden`:`flex-1 min-h-0 overflow-hidden`,children:[m===`logs`&&K(rr,{deviceId:t,containerDeviceId:j===`container`?t:void 0}),m===`repl`&&K(ir,{deviceId:t}),m===`events`&&K(ar,{deviceId:t}),m===`state`&&K(or,{deviceId:t})]})]})]}),!L&&K(`div`,{role:`separator`,"aria-orientation":`vertical`,title:`Drag to resize`,onMouseDown:C,className:`flex-shrink-0 w-1 cursor-col-resize bg-border hover:bg-primary/40 transition-colors group relative z-10`,children:K(`span`,{className:`absolute inset-y-0 -left-1 -right-1`})}),H(`div`,{className:L?`flex flex-col`:`flex-1 min-w-0 min-h-0 flex flex-col overflow-hidden`,children:[K(`div`,{className:`flex-shrink-0 border-b border-border bg-surface px-4`,children:K(`div`,{className:`flex flex-nowrap overflow-x-auto md:flex-wrap md:overflow-x-visible items-center gap-0`,children:me.map(e=>{let t=he===e.id;return H(`button`,{onClick:()=>ge(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&&K(`span`,{className:`absolute bottom-0 left-0 right-0 h-0.5 rounded-full bg-primary`})]},e.id)})})}),H(`div`,{className:L?`p-3 flex flex-col gap-3`:`flex-1 min-h-0 overflow-y-auto p-4 flex flex-col gap-3`,children:[he===`overview`&&ve&&K(wn,{parentDeviceId:t}),Je()]})]})]})})})})})})]}):H(`div`,{className:`flex flex-col items-center justify-center h-full gap-3 text-foreground-subtle`,children:[K(`p`,{className:`text-lg font-semibold text-foreground`,children:`Invalid device id`}),H(`p`,{className:`text-xs`,children:[`The URL segment`,` `,K(`code`,{className:`font-mono bg-surface px-1.5 py-0.5 rounded text-[11px]`,children:e.deviceId}),` `,`is not a number.`]}),K(`button`,{onClick:()=>r(`/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 qr({metrics:e,dbfs:t}){let n=Le(e.phase??`idle`);return H(`div`,{className:`flex items-center gap-3 flex-shrink-0`,children:[H(`div`,{className:`flex items-center gap-1.5`,children:[K(`span`,{className:`h-1.5 w-1.5 rounded-full ${n.dotClass}`}),K(`span`,{className:`text-[10px] font-medium ${n.textColor}`,children:n.label})]}),K(`div`,{className:`h-3 w-px bg-border`}),H(`div`,{className:`flex items-center gap-1 text-[10px] text-foreground-subtle`,children:[K(Pt,{className:`h-3 w-3`}),K(`span`,{className:`text-foreground tabular-nums`,children:(e.actualFps??0).toFixed(1)}),K(`span`,{children:`fps`})]}),H(`div`,{className:`flex items-center gap-1 text-[10px] text-foreground-subtle`,children:[K(Bt,{className:`h-3 w-3`}),K(`span`,{className:`text-foreground tabular-nums`,children:(e.avgInferenceTimeMs??0).toFixed(0)}),K(`span`,{children:`ms`})]}),H(`div`,{className:`flex items-center gap-1 text-[10px] text-foreground-subtle`,title:`Current audio level (dBFS)`,children:[K(cn,{className:`h-3 w-3`}),K(`span`,{className:`text-foreground tabular-nums`,children:t==null?`—`:t.toFixed(0)}),K(`span`,{children:`dB`})]}),(e.queueDepth??0)>0&&H(`span`,{className:`text-[10px] text-warning tabular-nums`,children:[`q:`,e.queueDepth]})]})}export{Kr as DeviceDetailPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{L as e,To as t,b as n,i as r}from"./src-DdYzDsDP.js";import{Q as i,S as a,W as o,d as s,q as c,u 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-DTufy7Ue.js";import{Y as f}from"./src-BEXY7p5t.js";import{A as p,D as m,E as h,M as g,v as _,w as v}from"./__vite-browser-external-DQHwpgVa.js";import{d as y}from"./player-overlays-DinWO-iY.js";i();var b=g([m({kind:v(`adaptive`)}),m({kind:v(`profile`),profile:f})]),x=m({serverUrl:p().min(1),token:p().min(1),deviceId:h().int().nonnegative(),target:b,muted:_()});function S(e,t){let n=t===void 0?{type:`state`,state:e}:{type:`state`,state:e,message:t};window.ReactNativeWebView?.postMessage(JSON.stringify(n))}function C(e){switch(e){case`playing`:return`playing`;case`error`:return`error`;case`connecting`:case`disconnected`:case`idle`:return`connecting`}}function w(e){return e.kind===`adaptive`?{kind:`adaptive`}:{kind:`profile`,profile:e.profile}}function T(e){return e.kind===`adaptive`?`embed:adaptive`:`embed:profile:${e.profile}`}function E(){let e=window.__CAMSTACK_EMBED__;if(e==null)return{ok:!1,error:`window.__CAMSTACK_EMBED__ is not set`};let t=x.safeParse(e);return t.success?{ok:!0,config:t.data}:{ok:!1,error:t.error.issues.map(e=>`${e.path.join(`.`)||`(root)`}: ${e.message}`).join(`; `)}}function D({message:e}){return d(()=>{S(`error`,e)},[e]),a(`div`,{style:{position:`fixed`,inset:0,display:`flex`,alignItems:`center`,justifyContent:`center`,background:`#000`,color:`#f87171`,fontFamily:`system-ui, sans-serif`,fontSize:13,padding:16,textAlign:`center`},children:[`Embed config error: `,e]})}function O({system:e,deviceId:t,initialTarget:i,initialMuted:a}){let[s,l]=c(i),[f,p]=c(a),{handleOffer:m,getIceServers:h,addIceCandidate:g,getIceCandidates:_,closeSession:v,getSessionState:y}=r(e.trpcClient,t),x=o(()=>w(s),[s]),E=o(()=>(e,t)=>m(x,e,t),[m,x]),D=o(()=>(e,t,n)=>m(n,t,e),[m]);d(()=>(window.__camstackEmbed={setMuted:e=>p(e),setTarget:e=>{let t=b.safeParse(e);t.success&&l(t.data)}},()=>{window.__camstackEmbed&&delete window.__camstackEmbed}),[]);let O=T(s);return u(`div`,{style:{position:`fixed`,inset:0,width:`100vw`,height:`100vh`,background:`#000`},children:u(n,{serverUrl:e.serverUrl,streamKey:O,autoPlay:!0,muted:f,showControls:!1,className:`w-full h-full`,handleOffer:E,reoffer:D,getSessionState:y,getIceServers:h,addIceCandidate:g,getIceCandidates:_,closeSession:v,onStateChange:e=>S(C(e)),onError:e=>S(`error`,e)},O)})}function k(){let n=o(()=>E(),[]),r=o(()=>n.ok?{system:e({serverUrl:n.config.serverUrl,token:n.config.token}),queryClient:new s({defaultOptions:{queries:{retry:!1,refetchOnWindowFocus:!1}}})}:null,[n]);return d(()=>{if(r)return()=>{r.system.close()}},[r]),n.ok?r?u(y,{system:r.system,children:u(l,{client:r.queryClient,children:u(t.Provider,{client:r.system.trpcClient,queryClient:r.queryClient,children:u(O,{system:r.system,deviceId:n.config.deviceId,initialTarget:n.config.target,initialMuted:n.config.muted})})})}):u(D,{message:`Failed to initialise the embed player`}):u(D,{message:n.error})}export{k as EmbedPlayerPage};
|