@camstack/addon-agent-ui 1.2.247 → 1.2.248
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/addon.js +166 -103
- package/dist/assets/{MotionZonesSettings-BvVGNQfm.js → MotionZonesSettings-B0KTSP8u.js} +1 -1
- package/dist/assets/{PrivacyMaskSettings-CqmJRsY0.js → PrivacyMaskSettings-fUcXnui9.js} +1 -1
- package/dist/assets/{SceneMonitorEditor-D9LPLGDI.js → SceneMonitorEditor-BZgFVsrx.js} +1 -1
- package/dist/assets/{index-Ds0hKW0X.js → index-Ba-k94Iy.js} +12 -12
- package/dist/index.html +1 -1
- package/package.json +1 -1
package/dist/addon.js
CHANGED
|
@@ -5415,7 +5415,7 @@ var ZodIssueCode = {
|
|
|
5415
5415
|
var ZodFirstPartyTypeKind;
|
|
5416
5416
|
ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
|
|
5417
5417
|
//#endregion
|
|
5418
|
-
//#region ../types/dist/sleep-
|
|
5418
|
+
//#region ../types/dist/sleep-yKL5gfrH.mjs
|
|
5419
5419
|
/**
|
|
5420
5420
|
* The audio chunk plane's byte format, and the ONE expansion from a coded
|
|
5421
5421
|
* window to float samples (D455).
|
|
@@ -7798,9 +7798,9 @@ function normalizeAddonInitResult(result) {
|
|
|
7798
7798
|
return result;
|
|
7799
7799
|
}
|
|
7800
7800
|
/**
|
|
7801
|
-
* The share-view scope kinds a
|
|
7802
|
-
* and validates them (`
|
|
7803
|
-
* list); a data plane names the kinds it ACCEPTS in `share`.
|
|
7801
|
+
* The share-view scope kinds a share-link token can carry. The hub mints
|
|
7802
|
+
* and validates them (`ShareViewGrantSchema` builds its
|
|
7803
|
+
* enum from this list); a data plane names the kinds it ACCEPTS in `share`.
|
|
7804
7804
|
*/
|
|
7805
7805
|
var SHARE_VIEW_KINDS = ["grid-view", "events-view"];
|
|
7806
7806
|
/** The wire shape of {@link PeerBytesTicket} — see the type for what it is. */
|
|
@@ -12427,7 +12427,7 @@ var ConvertResultSchema = object({
|
|
|
12427
12427
|
* `super_admin` — collapsed onto the single boolean because every
|
|
12428
12428
|
* non-admin caller is governed by the same scope-check rules; the
|
|
12429
12429
|
* distinction was only ever used to route role-specific procedures
|
|
12430
|
-
* which we no longer have. CLI / webhook integrations are `
|
|
12430
|
+
* which we no longer have. CLI / webhook integrations are tokens (`auth.mintToken`)
|
|
12431
12431
|
* with `isAdmin: false` + an explicit scope list.
|
|
12432
12432
|
*/
|
|
12433
12433
|
/** Per-method access flavour. Materialised on every cap method via codegen. */
|
|
@@ -12616,10 +12616,12 @@ var AddonRoutesScopeSchema = object({
|
|
|
12616
12616
|
type: literal("addon-routes"),
|
|
12617
12617
|
access: array(MethodAccessSchema).min(1)
|
|
12618
12618
|
});
|
|
12619
|
+
var PreferencesSelfScopeSchema = object({ type: literal("preferences-self") });
|
|
12619
12620
|
var CredentialScopeSchema = union([
|
|
12620
12621
|
literal("*"),
|
|
12621
12622
|
ShareViewScopeSchema,
|
|
12622
12623
|
AddonRoutesScopeSchema,
|
|
12624
|
+
PreferencesSelfScopeSchema,
|
|
12623
12625
|
TokenScopeSchema
|
|
12624
12626
|
]);
|
|
12625
12627
|
object({
|
|
@@ -12628,6 +12630,55 @@ object({
|
|
|
12628
12630
|
jti: string().min(16),
|
|
12629
12631
|
scopes: array(CredentialScopeSchema).min(1)
|
|
12630
12632
|
});
|
|
12633
|
+
var PreferenceNamespaceSchema = string().regex(/^[a-z][a-z0-9.-]{0,63}$/);
|
|
12634
|
+
/** A namespace's value: a JSON object, opaque to the hub. */
|
|
12635
|
+
var PreferenceValueSchema = record(string(), unknown());
|
|
12636
|
+
var PreferenceDeviceIdSchema = string().min(1).max(64);
|
|
12637
|
+
/** A stored row, as the owner reads it. */
|
|
12638
|
+
var PreferenceRowSchema = object({
|
|
12639
|
+
namespace: PreferenceNamespaceSchema,
|
|
12640
|
+
value: PreferenceValueSchema,
|
|
12641
|
+
/** Starts at 1, +1 on every write of this namespace. A delete ends the row and its count. */
|
|
12642
|
+
revision: number().int().positive(),
|
|
12643
|
+
updatedAt: number().int(),
|
|
12644
|
+
/** The client id the last writer sent; `null` when it sent none. */
|
|
12645
|
+
updatedByDevice: PreferenceDeviceIdSchema.nullable()
|
|
12646
|
+
});
|
|
12647
|
+
object({
|
|
12648
|
+
/** Absent: every namespace the caller holds. */
|
|
12649
|
+
namespaces: array(PreferenceNamespaceSchema).max(32).optional() });
|
|
12650
|
+
object({ rows: array(PreferenceRowSchema) });
|
|
12651
|
+
object({
|
|
12652
|
+
namespace: PreferenceNamespaceSchema,
|
|
12653
|
+
value: PreferenceValueSchema,
|
|
12654
|
+
/**
|
|
12655
|
+
* The revision the edit was based on. Absent: last write wins. `0`: the
|
|
12656
|
+
* namespace must not exist yet. Any other value that is not the current
|
|
12657
|
+
* revision answers `conflict` and writes nothing.
|
|
12658
|
+
*/
|
|
12659
|
+
baseRevision: number().int().nonnegative().optional(),
|
|
12660
|
+
deviceId: PreferenceDeviceIdSchema.optional()
|
|
12661
|
+
});
|
|
12662
|
+
discriminatedUnion("status", [object({
|
|
12663
|
+
status: literal("saved"),
|
|
12664
|
+
row: PreferenceRowSchema
|
|
12665
|
+
}), object({
|
|
12666
|
+
status: literal("conflict"),
|
|
12667
|
+
current: PreferenceRowSchema.nullable()
|
|
12668
|
+
})]);
|
|
12669
|
+
object({ namespace: PreferenceNamespaceSchema });
|
|
12670
|
+
object({
|
|
12671
|
+
/** `false` when the namespace did not exist. */
|
|
12672
|
+
deleted: boolean() });
|
|
12673
|
+
object({
|
|
12674
|
+
/** The revision the client holds per namespace; a namespace it does not list is new to it. */
|
|
12675
|
+
revisionByNamespace: record(PreferenceNamespaceSchema, number().int().nonnegative()).refine((map) => Object.keys(map).length <= 32, { message: `at most 32 namespaces` }) });
|
|
12676
|
+
object({
|
|
12677
|
+
/** Every row whose revision differs from the client's, and every row it did not list. */
|
|
12678
|
+
rows: array(PreferenceRowSchema),
|
|
12679
|
+
/** Namespaces the client listed that no longer exist. */
|
|
12680
|
+
deleted: array(PreferenceNamespaceSchema)
|
|
12681
|
+
});
|
|
12631
12682
|
_enum(["new-session", "step-up"]);
|
|
12632
12683
|
/** The languages the hub's app landing pages are written in (D858). */
|
|
12633
12684
|
var AppPageLangSchema = _enum(["en", "it"]);
|
|
@@ -39506,38 +39557,37 @@ method(LlmRuntimeCompleteInputSchema, LlmGenerateResultSchema, {
|
|
|
39506
39557
|
auth: "admin",
|
|
39507
39558
|
timeoutMs: AI_CAP_TRANSPORT_TIMEOUT_MS
|
|
39508
39559
|
});
|
|
39560
|
+
var LlmProfileKindSchema = string().regex(/^[a-z0-9][a-z0-9-]{0,63}$/, "a kind id is lower-case letters, digits and dashes");
|
|
39561
|
+
/** What a model (or, by default, every model of a kind) can do. */
|
|
39562
|
+
var LlmModelFeaturesSchema = object({
|
|
39563
|
+
vision: boolean(),
|
|
39564
|
+
tools: boolean(),
|
|
39565
|
+
streaming: boolean()
|
|
39566
|
+
});
|
|
39567
|
+
/** One model a provider offers. `features` overrides the kind's defaults, per field. */
|
|
39568
|
+
var LlmModelInfoSchema = object({
|
|
39569
|
+
id: string(),
|
|
39570
|
+
label: string().optional(),
|
|
39571
|
+
contextLength: number().int().positive().optional(),
|
|
39572
|
+
features: LlmModelFeaturesSchema.partial().optional()
|
|
39573
|
+
});
|
|
39509
39574
|
/**
|
|
39510
|
-
*
|
|
39511
|
-
*
|
|
39512
|
-
*
|
|
39513
|
-
*
|
|
39514
|
-
* (hub-placed); the cap stays open for future providers.
|
|
39515
|
-
*
|
|
39516
|
-
* Profiles are ROWS (data), not addons: one row = one usable model endpoint.
|
|
39517
|
-
* `apiKey` is a password field — providers REDACT it on read and merge on
|
|
39518
|
-
* write; a stored key NEVER round-trips to a client.
|
|
39575
|
+
* The provider-specific part of a profile, validated by the provider that owns
|
|
39576
|
+
* the kind (`upsertProfile` refuses what it does not accept). A field its
|
|
39577
|
+
* `connectionSchema` declares `type: 'password'` is a secret: it is held in the
|
|
39578
|
+
* keychain, never in the row, and reads back as the redaction marker.
|
|
39519
39579
|
*/
|
|
39520
|
-
var
|
|
39521
|
-
"openai-compatible",
|
|
39522
|
-
"openai",
|
|
39523
|
-
"anthropic",
|
|
39524
|
-
"google",
|
|
39525
|
-
"managed-local",
|
|
39526
|
-
"apple-foundation"
|
|
39527
|
-
]);
|
|
39580
|
+
var LlmProviderConfigSchema = record(string(), unknown());
|
|
39528
39581
|
var LlmProfileSchema = object({
|
|
39529
39582
|
id: string(),
|
|
39530
39583
|
name: string(),
|
|
39584
|
+
/** The provider-declared kind (`LlmProfileKindDescriptor.kind`). */
|
|
39531
39585
|
kind: LlmProfileKindSchema,
|
|
39532
39586
|
/** Stamped by the provider — keeps the fanned catalog routable. */
|
|
39533
39587
|
addonId: string(),
|
|
39534
39588
|
enabled: boolean(),
|
|
39535
39589
|
/** Vendor model id, or the managed runtime's loaded model. */
|
|
39536
39590
|
model: string(),
|
|
39537
|
-
/** Required for openai-compatible; override for cloud kinds. */
|
|
39538
|
-
baseUrl: string().optional(),
|
|
39539
|
-
/** ConfigUISchema type:'password' — never round-trips (spec §5). */
|
|
39540
|
-
apiKey: string().optional(),
|
|
39541
39591
|
/** Vision on/off. A vision call against a `false` profile is REFUSED, never
|
|
39542
39592
|
* degraded to text — that shipped once and produced a confident answer to a
|
|
39543
39593
|
* question about a picture nobody sent. */
|
|
@@ -39545,15 +39595,11 @@ var LlmProfileSchema = object({
|
|
|
39545
39595
|
temperature: number().min(0).max(2).optional(),
|
|
39546
39596
|
/** Nucleus sampling. Every wire we speak has it. */
|
|
39547
39597
|
topP: number().min(0).max(1).optional(),
|
|
39548
|
-
/** Top-k sampling. Carried only by the wires that have it —
|
|
39549
|
-
*
|
|
39550
|
-
* `top_p` and no `top_k`). The profile editor hides the field wherever it
|
|
39551
|
-
* would change nothing; `KINDS_WITH_TOP_K` is the single owner of that list. */
|
|
39598
|
+
/** Top-k sampling. Carried only by the wires that have it — a kind offers the
|
|
39599
|
+
* field in its editor only when its descriptor lists it in `profileFields`. */
|
|
39552
39600
|
topK: number().int().positive().optional(),
|
|
39553
39601
|
maxTokens: number().int().positive().optional(),
|
|
39554
|
-
/** Prompt context window. Advisory for cloud kinds (they enforce their own)
|
|
39555
|
-
* for `managed-local` it is the llama.cpp `--ctx-size` the runtime starts
|
|
39556
|
-
* the model with, so it is the one field that changes a PROCESS. */
|
|
39602
|
+
/** Prompt context window. Advisory for cloud kinds (they enforce their own). */
|
|
39557
39603
|
contextLength: number().int().positive().optional(),
|
|
39558
39604
|
/** Default system prompt. A caller's `system` REPLACES it (never appends —
|
|
39559
39605
|
* two system prompts fighting is worse than either alone). */
|
|
@@ -39579,16 +39625,37 @@ var LlmProfileSchema = object({
|
|
|
39579
39625
|
* library; the REGISTRY of callable tools is ours and is empty in v1, so a
|
|
39580
39626
|
* `true` here buys the wiring, not behaviour, until tools are registered. */
|
|
39581
39627
|
toolsEnabled: boolean().default(false),
|
|
39582
|
-
|
|
39583
|
-
|
|
39584
|
-
|
|
39585
|
-
|
|
39586
|
-
|
|
39587
|
-
|
|
39588
|
-
|
|
39589
|
-
|
|
39590
|
-
|
|
39591
|
-
|
|
39628
|
+
/** Everything the kind's provider owns (endpoint, key, node, runtime…). */
|
|
39629
|
+
providerConfig: LlmProviderConfigSchema.default({})
|
|
39630
|
+
});
|
|
39631
|
+
/**
|
|
39632
|
+
* The common profile fields a kind's editor offers. The editor owns how each
|
|
39633
|
+
* one is drawn; the provider says which of them mean something on its wire.
|
|
39634
|
+
*/
|
|
39635
|
+
var LlmProfileFieldSchema = _enum([
|
|
39636
|
+
"temperature",
|
|
39637
|
+
"topP",
|
|
39638
|
+
"topK",
|
|
39639
|
+
"maxTokens",
|
|
39640
|
+
"contextLength",
|
|
39641
|
+
"systemPrompt",
|
|
39642
|
+
"timeoutMs",
|
|
39643
|
+
"connectTimeoutMs",
|
|
39644
|
+
"firstTokenTimeoutMs",
|
|
39645
|
+
"idleTimeoutMs",
|
|
39646
|
+
"retry",
|
|
39647
|
+
"toolsEnabled"
|
|
39648
|
+
]);
|
|
39649
|
+
/**
|
|
39650
|
+
* A provider-drawn part of the editor, by a generic widget id the admin UI
|
|
39651
|
+
* registers (`ai/apple-node`). `placement: 'model'` replaces the generic model
|
|
39652
|
+
* picker: that widget owns the model choice.
|
|
39653
|
+
*/
|
|
39654
|
+
var LlmProviderWidgetSchema = object({
|
|
39655
|
+
id: string(),
|
|
39656
|
+
placement: _enum(["connection", "model"]),
|
|
39657
|
+
/** `providerConfig` keys this widget must fill before the profile can be saved. */
|
|
39658
|
+
requires: array(string()).optional()
|
|
39592
39659
|
});
|
|
39593
39660
|
/** ConfigUISchema tree passed through untyped on the wire (the
|
|
39594
39661
|
* notification-output `ConfigSchemaPassthrough` precedent at
|
|
@@ -39597,11 +39664,56 @@ var ConfigSchemaPassthrough$3 = unknown();
|
|
|
39597
39664
|
var LlmProfileKindDescriptorSchema = object({
|
|
39598
39665
|
kind: LlmProfileKindSchema,
|
|
39599
39666
|
label: string(),
|
|
39667
|
+
/** A generic icon name (`cloud`, `plug`, `cpu`) — never a glyph or a logo. */
|
|
39600
39668
|
icon: string(),
|
|
39601
39669
|
/** Stamped by each provider so the concat-fanned catalog stays routable. */
|
|
39602
39670
|
addonId: string(),
|
|
39603
|
-
|
|
39671
|
+
/** The provider's own fields (`providerConfig`); `password` fields are keychain-held. */
|
|
39672
|
+
connectionSchema: ConfigSchemaPassthrough$3,
|
|
39673
|
+
/** Provider fields that belong under "Advanced" (extra headers, runtime tuning). */
|
|
39674
|
+
advancedSchema: ConfigSchemaPassthrough$3.optional(),
|
|
39675
|
+
/** The kind's defaults; a model from `listModels` may override any of them. */
|
|
39676
|
+
features: LlmModelFeaturesSchema,
|
|
39677
|
+
/** `false` = the provider stamps `supportsVision` itself (from what a node reports). */
|
|
39678
|
+
visionEditable: boolean(),
|
|
39679
|
+
/** Where the model list comes from: `listModels`, `staticModels`, or nowhere. */
|
|
39680
|
+
modelCatalog: _enum([
|
|
39681
|
+
"fetch",
|
|
39682
|
+
"static",
|
|
39683
|
+
"none"
|
|
39684
|
+
]),
|
|
39685
|
+
staticModels: array(LlmModelInfoSchema).optional(),
|
|
39686
|
+
/** The common fields that mean something on this kind's wire. */
|
|
39687
|
+
profileFields: array(LlmProfileFieldSchema),
|
|
39688
|
+
providerWidgets: array(LlmProviderWidgetSchema).optional()
|
|
39604
39689
|
});
|
|
39690
|
+
/**
|
|
39691
|
+
* `listModels` input. `connection` is an UNSAVED draft of `providerConfig`
|
|
39692
|
+
* (the editor's form); with `profileId` too, a secret the draft leaves
|
|
39693
|
+
* untouched (absent or the redaction marker) is resolved server-side from the
|
|
39694
|
+
* stored profile — the browser never receives it.
|
|
39695
|
+
*/
|
|
39696
|
+
var LlmListModelsInputSchema = object({
|
|
39697
|
+
addonId: string(),
|
|
39698
|
+
kind: LlmProfileKindSchema,
|
|
39699
|
+
profileId: string().optional(),
|
|
39700
|
+
connection: LlmProviderConfigSchema.optional()
|
|
39701
|
+
});
|
|
39702
|
+
var LlmListModelsErrorCodeSchema = _enum([
|
|
39703
|
+
"auth",
|
|
39704
|
+
"network",
|
|
39705
|
+
"unsupported",
|
|
39706
|
+
"invalid"
|
|
39707
|
+
]);
|
|
39708
|
+
/** A RESULT, never a throw: "wrong key" is an answer the editor renders inline. */
|
|
39709
|
+
var LlmListModelsResultSchema = discriminatedUnion("ok", [object({
|
|
39710
|
+
ok: literal(true),
|
|
39711
|
+
models: array(LlmModelInfoSchema)
|
|
39712
|
+
}), object({
|
|
39713
|
+
ok: literal(false),
|
|
39714
|
+
code: LlmListModelsErrorCodeSchema,
|
|
39715
|
+
message: string()
|
|
39716
|
+
})]);
|
|
39605
39717
|
var LlmDefaultSelectorSchema = union([object({ consumer: string() }), object({ purpose: _enum(["text", "vision"]) })]);
|
|
39606
39718
|
var LlmDefaultSchema = object({
|
|
39607
39719
|
selector: LlmDefaultSelectorSchema,
|
|
@@ -39701,7 +39813,10 @@ method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, {
|
|
|
39701
39813
|
kind: "mutation",
|
|
39702
39814
|
auth: "admin",
|
|
39703
39815
|
timeoutMs: AI_CAP_TRANSPORT_TIMEOUT_MS
|
|
39704
|
-
}), method(
|
|
39816
|
+
}), method(LlmListModelsInputSchema, LlmListModelsResultSchema, {
|
|
39817
|
+
kind: "mutation",
|
|
39818
|
+
auth: "admin"
|
|
39819
|
+
}), method(object({}), array(LlmDefaultSchema)), method(object({
|
|
39705
39820
|
selector: LlmDefaultSelectorSchema,
|
|
39706
39821
|
profileId: string().nullable()
|
|
39707
39822
|
}), _void(), {
|
|
@@ -60696,26 +60811,6 @@ var ApiKeySummarySchema = object({
|
|
|
60696
60811
|
createdAt: number(),
|
|
60697
60812
|
lastUsedAt: number().optional()
|
|
60698
60813
|
});
|
|
60699
|
-
var ScopedTokenSummarySchema = object({
|
|
60700
|
-
id: string(),
|
|
60701
|
-
userId: string(),
|
|
60702
|
-
name: string(),
|
|
60703
|
-
tokenPrefix: string(),
|
|
60704
|
-
scopes: array(TokenScopeSchema),
|
|
60705
|
-
expiresAt: number().nullish(),
|
|
60706
|
-
lastUsedAt: number().nullish(),
|
|
60707
|
-
createdAt: number()
|
|
60708
|
-
});
|
|
60709
|
-
var CreateScopedTokenInputSchema = object({
|
|
60710
|
-
userId: string(),
|
|
60711
|
-
name: string(),
|
|
60712
|
-
scopes: array(TokenScopeSchema),
|
|
60713
|
-
expiresAt: number().optional()
|
|
60714
|
-
});
|
|
60715
|
-
var CreateScopedTokenResultSchema = object({
|
|
60716
|
-
token: string(),
|
|
60717
|
-
record: ScopedTokenSummarySchema
|
|
60718
|
-
});
|
|
60719
60814
|
var OauthSessionSummarySchema = object({
|
|
60720
60815
|
id: string(),
|
|
60721
60816
|
userId: string(),
|
|
@@ -60737,11 +60832,11 @@ var TotpStatusSchema = object({
|
|
|
60737
60832
|
confirmedAt: number().nullable()
|
|
60738
60833
|
});
|
|
60739
60834
|
/**
|
|
60740
|
-
* user-management — singleton capability for user accounts
|
|
60741
|
-
*
|
|
60835
|
+
* user-management — singleton capability for user accounts and the
|
|
60836
|
+
* legacy API-key rows.
|
|
60742
60837
|
*
|
|
60743
60838
|
* v2 model: every method gated by `auth: 'admin'`. Admin-only delegation
|
|
60744
|
-
* — the subset check on `setUserScopes`
|
|
60839
|
+
* — the subset check on `setUserScopes` is moot
|
|
60745
60840
|
* because non-admins never reach these. If/when we open non-admin
|
|
60746
60841
|
* delegation, structural caller-scope subset check goes inside the
|
|
60747
60842
|
* provider.
|
|
@@ -60798,15 +60893,7 @@ method(_void(), array(UserSummarySchema), { auth: "admin" }), method(CreateUserI
|
|
|
60798
60893
|
kind: "mutation",
|
|
60799
60894
|
auth: "admin",
|
|
60800
60895
|
access: "delete"
|
|
60801
|
-
}), method(
|
|
60802
|
-
kind: "mutation",
|
|
60803
|
-
auth: "admin",
|
|
60804
|
-
access: "create"
|
|
60805
|
-
}), method(object({ id: string() }), object({ success: literal(true) }), {
|
|
60806
|
-
kind: "mutation",
|
|
60807
|
-
auth: "admin",
|
|
60808
|
-
access: "delete"
|
|
60809
|
-
}), method(object({ token: string() }), ScopedTokenSummarySchema.nullable(), { access: "view" }), method(object({ userId: string() }), array(ScopedTokenSummarySchema), { auth: "admin" }), method(object({ userId: string() }), TotpSetupResultSchema, {
|
|
60896
|
+
}), method(object({ userId: string() }), TotpSetupResultSchema, {
|
|
60810
60897
|
kind: "mutation",
|
|
60811
60898
|
auth: "admin",
|
|
60812
60899
|
access: "create"
|
|
@@ -64962,7 +65049,7 @@ Object.freeze({
|
|
|
64962
65049
|
capName: "llm",
|
|
64963
65050
|
capScope: "system",
|
|
64964
65051
|
addonId: null,
|
|
64965
|
-
access: "
|
|
65052
|
+
access: "create"
|
|
64966
65053
|
},
|
|
64967
65054
|
"llm.listNodeModels": {
|
|
64968
65055
|
capName: "llm",
|
|
@@ -69626,12 +69713,6 @@ Object.freeze({
|
|
|
69626
69713
|
addonId: null,
|
|
69627
69714
|
access: "create"
|
|
69628
69715
|
},
|
|
69629
|
-
"userManagement.createScopedToken": {
|
|
69630
|
-
capName: "user-management",
|
|
69631
|
-
capScope: "system",
|
|
69632
|
-
addonId: null,
|
|
69633
|
-
access: "create"
|
|
69634
|
-
},
|
|
69635
69716
|
"userManagement.createUser": {
|
|
69636
69717
|
capName: "user-management",
|
|
69637
69718
|
capScope: "system",
|
|
@@ -69680,12 +69761,6 @@ Object.freeze({
|
|
|
69680
69761
|
addonId: null,
|
|
69681
69762
|
access: "view"
|
|
69682
69763
|
},
|
|
69683
|
-
"userManagement.listScopedTokens": {
|
|
69684
|
-
capName: "user-management",
|
|
69685
|
-
capScope: "system",
|
|
69686
|
-
addonId: null,
|
|
69687
|
-
access: "view"
|
|
69688
|
-
},
|
|
69689
69764
|
"userManagement.listUsers": {
|
|
69690
69765
|
capName: "user-management",
|
|
69691
69766
|
capScope: "system",
|
|
@@ -69740,12 +69815,6 @@ Object.freeze({
|
|
|
69740
69815
|
addonId: null,
|
|
69741
69816
|
access: "delete"
|
|
69742
69817
|
},
|
|
69743
|
-
"userManagement.revokeScopedToken": {
|
|
69744
|
-
capName: "user-management",
|
|
69745
|
-
capScope: "system",
|
|
69746
|
-
addonId: null,
|
|
69747
|
-
access: "delete"
|
|
69748
|
-
},
|
|
69749
69818
|
"userManagement.setupTotp": {
|
|
69750
69819
|
capName: "user-management",
|
|
69751
69820
|
capScope: "system",
|
|
@@ -69776,12 +69845,6 @@ Object.freeze({
|
|
|
69776
69845
|
addonId: null,
|
|
69777
69846
|
access: "view"
|
|
69778
69847
|
},
|
|
69779
|
-
"userManagement.validateScopedToken": {
|
|
69780
|
-
capName: "user-management",
|
|
69781
|
-
capScope: "system",
|
|
69782
|
-
addonId: null,
|
|
69783
|
-
access: "view"
|
|
69784
|
-
},
|
|
69785
69848
|
"userManagement.verifyTotp": {
|
|
69786
69849
|
capName: "user-management",
|
|
69787
69850
|
capScope: "system",
|
|
@@ -74119,7 +74182,7 @@ var AgentUIAddon = class extends BaseAddon {
|
|
|
74119
74182
|
capability: adminUiCapability,
|
|
74120
74183
|
provider: {
|
|
74121
74184
|
getStaticDir: async () => ({ staticDir: path.resolve(__dirname) }),
|
|
74122
|
-
getVersion: async () => ({ version: "1.2.
|
|
74185
|
+
getVersion: async () => ({ version: "1.2.248" })
|
|
74123
74186
|
}
|
|
74124
74187
|
}];
|
|
74125
74188
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,i as t,l as n,n as r,o as i}from"./scheduler-0XZJE03d.js";import{C as a,c as o,d as s,h as c,l,p as u,t as ee}from"./index-
|
|
1
|
+
import{a as e,i as t,l as n,n as r,o as i}from"./scheduler-0XZJE03d.js";import{C as a,c as o,d as s,h as c,l,p as u,t as ee}from"./index-Ba-k94Iy.js";import{MaskShapeCanvas as d}from"./MaskShapeCanvas-BTvl6Rin.js";var f=a(`grid-2x2`,[[`path`,{d:`M12 3v18`,key:`108xh3`}],[`path`,{d:`M3 12h18`,key:`1i2n21`}],[`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,key:`h1oib`}]]),p=n(i(),1),m=n(e(),1),h=110,g=`motion-zones`,_=0,te=[1,2,3],v=1,y=`rounded-md border border-border bg-surface px-2 py-1 text-[11px] font-medium text-foreground-subtle hover:bg-surface-hover disabled:opacity-40 transition-colors`,b=`rounded-md border border-primary/50 bg-primary/15 px-2.5 py-1 text-[11px] font-medium text-primary hover:bg-primary/25 disabled:opacity-40 transition-colors`;function x(e,t,n){let r=t*n,i=Array.from({length:r});for(let t=0;t<r;t+=1)i[t]=e[t]===!0;return i}function S(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(e[n]!==t[n])return!1;return!0}function C(e,t){return Math.ceil(e/t)}function w(e,t,n){return Math.min(n-1,Math.floor((e+.5)/t*n))}function T(e,t,n,r){let i=C(t,r),a=C(n,r),o=Array.from({length:i*a},()=>!1);for(let r=0;r<n;r+=1){let s=w(r,n,a);for(let n=0;n<t;n+=1)e[r*t+n]===!0&&(o[s*i+w(n,t,i)]=!0)}return o}function E(e,t,n,r){let i=C(t,r),a=C(n,r),o=Array.from({length:t*n},()=>!1);for(let r=0;r<n;r+=1){let s=w(r,n,a);for(let n=0;n<t;n+=1)o[r*t+n]=e[s*i+w(n,t,i)]===!0}return o}function D({deviceId:e}){let n=t(),i=s(c().trpcClient,e),[a,w]=(0,p.useState)(null),[D,O]=(0,p.useState)(!1),[k,A]=(0,p.useState)(null),[j,M]=(0,p.useState)(null),[N,P]=(0,p.useState)(v),[F,I]=(0,p.useState)(!1),[L,R]=(0,p.useState)(!1),z=(0,p.useRef)(!1);(0,p.useEffect)(()=>{if(!i)return;let e=!1;return z.current=!1,w(null),O(!1),A(null),M(null),P(v),R(!1),(async()=>{try{let t=await i.motionZones?.getOptions({});if(e)return;if(!t)throw Error(`device proxy not ready`);if(w(t),z.current)return;let n=await i.motionZones?.getStatus({});if(e)return;if(!n)throw Error(`device proxy not ready`);z.current=!0;let r=n.regions.find(e=>e.shape.kind===`grid`),a=x(r?r.shape.cells:[],t.grid.width,t.grid.height);M(a),A(T(a,t.grid.width,t.grid.height,v))}catch(t){if(e)return;l(t)?O(!0):console.error(`Motion Zones load failed`,t)}})(),()=>{e=!0}},[i]);let B=a?a.grid.width:0,V=a?a.grid.height:0,H=C(B,N),U=C(V,N),W=(0,p.useMemo)(()=>k&&a?E(k,B,V,N):null,[k,a,B,V,N]),G=(0,p.useMemo)(()=>W!==null&&j!==null&&!S(W,j),[W,j]),K=(0,p.useMemo)(()=>W?W.reduce((e,t)=>t?e+1:e,0):0,[W]),q=B*V,J=H*U,Y=(0,p.useCallback)(e=>{J>0&&A(Array.from({length:J},()=>e))},[J]),X=(0,p.useCallback)(()=>{A(e=>e&&e.map(e=>!e))},[]),Z=(0,p.useCallback)(()=>{j&&a&&A(T(j,B,V,N))},[j,a,B,V,N]),ne=(0,p.useCallback)(e=>{e===N||!a||A(t=>{if(!t)return P(e),t;let n=T(E(t,B,V,N),B,V,e);return P(e),n})},[N,a,B,V]),Q=(0,p.useMemo)(()=>a&&k?[{id:_,shape:{kind:`grid`,gridWidth:H,gridHeight:U,cells:[...k]}}]:[],[a,k,H,U]),$=(0,p.useCallback)((e,t)=>{t.kind===`grid`&&A(t.cells)},[]),re=(0,p.useCallback)(async()=>{if(!(!i||!k||!a)){I(!0);try{let e=E(k,a.grid.width,a.grid.height,N),t={kind:`grid`,gridWidth:a.grid.width,gridHeight:a.grid.height,cells:e};await i.motionZones?.setZone({patch:{regions:[{id:_,enabled:!0,shape:t}]}});let n=await i.motionZones?.getStatus({});if(n){let e=n.regions.find(e=>e.shape.kind===`grid`),t=x(e?e.shape.cells:[],a.grid.width,a.grid.height);M(t),A(T(t,a.grid.width,a.grid.height,N))}}catch(e){console.error(`Motion Zones save failed`,e)}finally{I(!1)}}},[i,k,a,N]);ee((0,p.useMemo)(()=>L&&!D&&a&&k?{id:g,order:h,node:(0,m.jsx)(d,{transparent:!0,items:Q,supportedShapes:[`grid`],grid:{width:H,height:U},selectedId:_,onSelect:()=>{},onShapeChange:$,onDrawComplete:()=>{},drawingKind:null})}:null,[L,D,a,k,Q,$,H,U]));let ie=!D&&a!==null&&k!==null;return i?(0,m.jsx)(u,{title:n(`uiLibrary.motionZones.title`,`Motion Zones`),icon:(0,m.jsx)(f,{className:`h-3.5 w-3.5 text-foreground-subtle`}),children:(0,m.jsx)(`div`,{className:`flex flex-col gap-3`,children:D?(0,m.jsx)(`p`,{className:`${o} leading-relaxed`,children:n(`uiLibrary.motionZones.unsupported`,`This camera doesn't expose an on-board motion zones grid.`)}):ie?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(`p`,{className:`${o} leading-relaxed`,children:(0,m.jsx)(r,{uiKey:`uiLibrary.motionZones.intro`,fallback:`Toggle <0>Edit grid</0> to paint the region directly on the live frame, then <1>Save</1> to push the mask to the camera. Pick a bigger <2>Cell size</2> for quicker, broad-stroke painting — it's resampled to the camera's native {{width}}×{{height}} grid on save (×1 is the finest).`,components:[(0,m.jsx)(`strong`,{className:`text-foreground`},`e`),(0,m.jsx)(`strong`,{className:`text-foreground`},`s`),(0,m.jsx)(`strong`,{className:`text-foreground`},`c`)],values:{width:a.grid.width,height:a.grid.height}})}),(0,m.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,m.jsx)(`button`,{type:`button`,onClick:()=>R(e=>!e),disabled:F,"aria-pressed":L,className:L?b:y,children:L?n(`uiLibrary.motionZones.doneEditing`,`Done editing`):n(`uiLibrary.motionZones.editGrid`,`Edit grid`)}),(0,m.jsx)(`button`,{type:`button`,onClick:()=>Y(!0),disabled:F,className:y,children:n(`uiLibrary.motionZones.allOn`,`All on`)}),(0,m.jsx)(`button`,{type:`button`,onClick:()=>Y(!1),disabled:F,className:y,children:n(`uiLibrary.motionZones.allOff`,`All off`)}),(0,m.jsx)(`button`,{type:`button`,onClick:X,disabled:F,className:y,children:n(`uiLibrary.motionZones.invert`,`Invert`)}),(0,m.jsxs)(`div`,{className:`flex items-center gap-1 ml-1`,role:`group`,"aria-label":n(`uiLibrary.motionZones.cellSize`,`Cell size`),children:[(0,m.jsx)(`span`,{className:`${o} mr-0.5`,children:n(`uiLibrary.motionZones.cellSize`,`Cell size`)}),te.map(e=>(0,m.jsxs)(`button`,{type:`button`,onClick:()=>ne(e),disabled:F,"aria-pressed":N===e,title:e===1?n(`uiLibrary.motionZones.cameraGrid`,`Camera grid {{width}}×{{height}} (finest)`,{width:B,height:V}):n(`uiLibrary.motionZones.paintingGrid`,`{{width}}×{{height}} painting grid · cells ×{{factor}} bigger`,{width:C(B,e),height:C(V,e),factor:e}),className:N===e?b:y,children:[`×`,e]},e))]}),(0,m.jsxs)(`span`,{className:`${o} ml-1 tabular-nums`,children:[n(`uiLibrary.motionZones.cells`,`{{active}} / {{total}} cells · {{width}}×{{height}}`,{active:K,total:q,width:a.grid.width,height:a.grid.height}),N===1?``:n(`uiLibrary.motionZones.paintSuffix`,` · paint {{width}}×{{height}}`,{width:H,height:U})]}),(0,m.jsx)(`span`,{className:`flex-1`}),(0,m.jsx)(`button`,{type:`button`,onClick:Z,disabled:F||!G,className:`rounded-md border border-border bg-surface px-2 py-1 text-[11px] text-foreground-subtle hover:bg-surface-hover disabled:opacity-40 transition-colors`,children:n(`uiLibrary.motionZones.revert`,`Revert`)}),(0,m.jsx)(`button`,{type:`button`,onClick:()=>void re(),disabled:F||!G,className:b,children:F?n(`uiLibrary.motionZones.saving`,`Saving…`):n(`uiLibrary.motionZones.save`,`Save`)})]})]}):(0,m.jsx)(`p`,{className:`${o} leading-relaxed`,children:n(`uiLibrary.motionZones.loading`,`Loading the camera's grid…`)})})}):null}export{D as MotionZonesSettings};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,i as t,l as n,n as r,o as i}from"./scheduler-0XZJE03d.js";import{C as a,_ as ee,c as o,d as te,g as ne,h as s,l as c,p as re,t as l,x as u,y as d}from"./index-Ds0hKW0X.js";import{MaskShapeCanvas as ie}from"./MaskShapeCanvas-BTvl6Rin.js";var ae=a(`hexagon`,[[`path`,{d:`M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z`,key:`yt0hxn`}]]),oe=a(`mic-off`,[[`path`,{d:`M12 19v3`,key:`npa21l`}],[`path`,{d:`M15 9.34V5a3 3 0 0 0-5.68-1.33`,key:`1gzdoj`}],[`path`,{d:`M16.95 16.95A7 7 0 0 1 5 12v-2`,key:`cqa7eg`}],[`path`,{d:`M18.89 13.23A7 7 0 0 0 19 12v-2`,key:`16hl24`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M9 9v3a3 3 0 0 0 5.12 2.12`,key:`r2i35w`}]]),f=n(i(),1),p=`Microphone`,m=`The camera encodes no audio at all — live view, recordings, exports and the audio analyzer are all silent.`;function se(e){let t=e.supportsAudioMute===!0,n=t?e.audioEnabled:null,r=e.pendingOn??null;return{label:p,supported:t,on:n===null?null:r??n,available:t&&n!==null,costWhenOff:m}}function ce(e){return!e.available||e.on===null?null:{enabled:!e.on}}var h=n(e(),1),le=120,ue=`privacy-mask`,g=`rounded-md border border-border bg-surface px-2 py-1 text-[11px] font-medium text-foreground-subtle hover:bg-surface-hover disabled:opacity-40 transition-colors`,_=`rounded-md border border-primary/50 bg-primary/15 px-2.5 py-1 text-[11px] font-medium text-primary hover:bg-primary/25 disabled:opacity-40 transition-colors`;function v(e){return e.kind===`rect`||e.kind===`polygon`?e:null}function de(e){let t=new Set(e.map(e=>e.id)),n=0;for(;t.has(n);)n+=1;return n}function fe(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(JSON.stringify(e[n])!==JSON.stringify(t[n]))return!1;return!0}function y({deviceId:e}){let n=t(),i=te(s().trpcClient,e),[a,p]=(0,f.useState)(null),[m,y]=(0,f.useState)(!1),[b,x]=(0,f.useState)(!1),[S,C]=(0,f.useState)(null),[w,T]=(0,f.useState)(null),[E,D]=(0,f.useState)(!1),[O,k]=(0,f.useState)(!1),[A,j]=(0,f.useState)(null),[M,N]=(0,f.useState)(null),[pe,P]=(0,f.useState)(null),[F,I]=(0,f.useState)(null),[L,R]=(0,f.useState)(null),z=(0,f.useRef)(!1);(0,f.useEffect)(()=>{if(!i)return;let e=!1;return z.current=!1,p(null),y(!1),x(!1),C(null),T(null),k(!1),j(null),N(null),P(null),I(null),R(null),(async()=>{try{let t=await i.privacyMask?.getOptions({});if(e)return;if(!t)throw Error(`device proxy not ready`);if(p(t),z.current)return;let n=await i.privacyMask?.getStatus({});if(e)return;if(!n)throw Error(`device proxy not ready`);if(n.regions===null){x(!0),P(n.audioEnabled);return}z.current=!0;let r={enabled:n.enabled,regions:n.regions};T(r),C(r),P(n.audioEnabled)}catch(t){if(e)return;c(t)?y(!0):console.error(`Privacy Mask load failed`,t)}})(),()=>{e=!0}},[i]);let B=(0,f.useMemo)(()=>S!==null&&w!==null&&(S.enabled!==w.enabled||!fe(S.regions,w.regions)),[S,w]),V=S?S.regions.length:0,H=a?a.maxRegions:0,U=(0,f.useRef)(0);(0,f.useEffect)(()=>{U.current=H},[H]);let W=H>0&&V>=H,me=(0,f.useCallback)(()=>{C(e=>e&&{...e,enabled:!e.enabled})},[]),G=(0,f.useCallback)(e=>{j(typeof e==`number`?e:null)},[]),K=(0,f.useMemo)(()=>S?S.regions.map(e=>({id:e.id,shape:e.shape,enabled:e.enabled,label:n(`uiLibrary.privacyMaskSettings.zoneN`,`Zone {{id}}`,{id:e.id})})):[],[S,n]),q=(0,f.useCallback)((e,t)=>{let n=v(t);n&&C(t=>t&&{...t,regions:t.regions.map(t=>t.id===e?{...t,shape:n}:t)})},[]),J=(0,f.useCallback)(e=>{let t=v(e);t&&(N(null),C(e=>{if(!e)return e;let n=U.current;if(n>0&&e.regions.length>=n)return e;let r=de(e.regions),i={id:r,enabled:!0,shape:t};return j(r),{...e,regions:[...e.regions,i]}}))},[]),Y=(0,f.useCallback)(e=>{k(!0),j(null),N(e)},[]),he=(0,f.useCallback)(e=>{k(!0),N(null),j(e)},[]),ge=(0,f.useCallback)(e=>{j(t=>t===e?null:t),C(t=>t&&{...t,regions:t.regions.filter(t=>t.id!==e)})},[]),_e=(0,f.useCallback)(()=>{N(null),j(null),w&&C({enabled:w.enabled,regions:w.regions})},[w]),X=(0,f.useCallback)(async()=>{if(!(!i||!S)){D(!0);try{await i.privacyMask?.setMask({patch:{enabled:S.enabled,regions:[...S.regions]}});let e=await i.privacyMask?.getStatus({});if(e&&e.regions!==null){let t={enabled:e.enabled,regions:e.regions};T(t),C(t)}}catch(e){console.error(`Privacy Mask save failed`,e)}finally{D(!1)}}},[i,S]),Z=se({supportsAudioMute:a===null?null:a.supportsAudioMute,audioEnabled:pe,pendingOn:F}),ve=(0,f.useCallback)(async()=>{let e=ce(Z);if(!(!i||e===null)){I(e.enabled),R(null);try{await i.privacyMask?.setAudioEnabled(e);let t=await i.privacyMask?.getStatus({});t&&P(t.audioEnabled)}catch(e){console.error(`Privacy microphone write failed — reverting`,e),R(e instanceof Error?e.message:String(e))}finally{I(null)}}},[i,Z]),ye=(0,f.useCallback)(()=>{k(e=>(e&&(N(null),j(null)),!e))},[]),Q=a?.supportedShapes??[];l((0,f.useMemo)(()=>O&&!m&&a&&S?{id:ue,order:le,node:(0,h.jsx)(ie,{transparent:!0,items:K,supportedShapes:Q,polygonVertices:a.polygonVertices,selectedId:A,onSelect:G,onShapeChange:q,onDrawComplete:J,drawingKind:M})}:null,[O,m,a,S,K,Q,A,G,q,J,M]));let be=a?.supportedShapes.includes(`rect`)??!1,xe=a?.supportedShapes.includes(`polygon`)??!1,$=a!==null&&(a.maxRegions<=0||a.supportedShapes.length===0),Se=!m&&!$&&!b&&a!==null&&S!==null;return i?(0,h.jsx)(re,{title:n(`uiLibrary.privacyMaskSettings.title`,`Privacy Mask`),icon:(0,h.jsx)(u,{className:`h-3.5 w-3.5 text-foreground-subtle`}),children:(0,h.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[m||$?(0,h.jsx)(`p`,{className:`${o} leading-relaxed`,children:n(`uiLibrary.privacyMaskSettings.unsupported`,`This camera doesn't support an on-board privacy mask.`)}):b?(0,h.jsx)(`p`,{className:`${o} leading-relaxed`,children:n(`uiLibrary.privacyMaskSettings.unreadable`,`This camera hasn't answered, so what it currently masks is unknown — the editor stays closed rather than showing an empty frame you could save over. A battery camera answers once it wakes; otherwise check that it is reachable.`)}):Se?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`p`,{className:`${o} leading-relaxed`,children:(0,h.jsx)(r,{uiKey:`uiLibrary.privacyMaskSettings.help`,fallback:`Toggle <0>Edit mask</0> to draw blanked-out zones on the live frame, then <1>Save</1> to push them to the camera. Drag a rectangle to move, its corner to resize; drag polygon vertices, click an edge midpoint to add one, or right-click a vertex to remove it.`,components:[(0,h.jsx)(`strong`,{className:`text-foreground`},`edit`),(0,h.jsx)(`strong`,{className:`text-foreground`},`save`)]})}),(0,h.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,h.jsx)(`button`,{type:`button`,onClick:ye,disabled:E,"aria-pressed":O,className:O?_:g,children:O?n(`uiLibrary.privacyMaskSettings.doneEditing`,`Done editing`):n(`uiLibrary.privacyMaskSettings.editMask`,`Edit mask`)}),(0,h.jsx)(`button`,{type:`button`,onClick:me,disabled:E,"aria-pressed":S.enabled,className:S.enabled?_:g,children:S.enabled?n(`uiLibrary.privacyMaskSettings.maskOn`,`Mask on`):n(`uiLibrary.privacyMaskSettings.maskOff`,`Mask off`)}),be&&(0,h.jsx)(`button`,{type:`button`,onClick:()=>Y(`rect`),disabled:E||W,"aria-pressed":M===`rect`,className:M===`rect`?_:g,title:W?n(`uiLibrary.privacyMaskSettings.maxZones`,`Maximum zones reached`):n(`uiLibrary.privacyMaskSettings.addRect`,`Add a rectangle zone`),children:n(`uiLibrary.privacyMaskSettings.rectButton`,`+ Rect`)}),xe&&(0,h.jsx)(`button`,{type:`button`,onClick:()=>Y(`polygon`),disabled:E||W,"aria-pressed":M===`polygon`,className:M===`polygon`?_:g,title:W?n(`uiLibrary.privacyMaskSettings.maxZones`,`Maximum zones reached`):n(`uiLibrary.privacyMaskSettings.addPolygon`,`Add a polygon zone`),children:n(`uiLibrary.privacyMaskSettings.polygonButton`,`+ Polygon`)}),(0,h.jsx)(`span`,{className:`${o} ml-1 tabular-nums`,children:n(`uiLibrary.privacyMaskSettings.zoneCount`,`{{active}} / {{max}} zones`,{active:V,max:H})}),(0,h.jsx)(`span`,{className:`flex-1`}),(0,h.jsx)(`button`,{type:`button`,onClick:_e,disabled:E||!B,className:`rounded-md border border-border bg-surface px-2 py-1 text-[11px] text-foreground-subtle hover:bg-surface-hover disabled:opacity-40 transition-colors`,children:n(`uiLibrary.privacyMaskSettings.revert`,`Revert`)}),(0,h.jsx)(`button`,{type:`button`,onClick:()=>void X(),disabled:E||!B,className:_,children:E?n(`uiLibrary.privacyMaskSettings.saving`,`Saving…`):n(`uiLibrary.privacyMaskSettings.save`,`Save`)})]}),V>0?(0,h.jsx)(`div`,{className:`flex flex-col gap-1`,children:S.regions.map(e=>{let t=A===e.id,r=e.shape.kind===`polygon`?ae:ee;return(0,h.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border px-2 py-1 transition-colors ${t?`border-primary/50 bg-primary/10`:`border-border bg-surface`}`,children:[(0,h.jsxs)(`button`,{type:`button`,onClick:()=>he(e.id),disabled:E,className:`flex flex-1 items-center gap-2 text-left text-[11px] font-medium text-foreground-subtle hover:text-foreground disabled:opacity-40 transition-colors`,children:[(0,h.jsx)(r,{className:`h-3.5 w-3.5 shrink-0`}),(0,h.jsx)(`span`,{children:n(`uiLibrary.privacyMaskSettings.zoneN`,`Zone {{id}}`,{id:e.id})}),(0,h.jsx)(`span`,{className:`text-foreground-faint capitalize`,children:e.shape.kind})]}),(0,h.jsx)(`button`,{type:`button`,onClick:()=>ge(e.id),disabled:E,"aria-label":n(`uiLibrary.privacyMaskSettings.deleteZoneN`,`Delete zone {{id}}`,{id:e.id}),title:n(`uiLibrary.privacyMaskSettings.deleteZone`,`Delete zone`),className:`inline-flex h-6 w-6 items-center justify-center rounded border border-border bg-surface text-foreground-subtle hover:border-red-400/40 hover:bg-red-500/10 hover:text-red-400 disabled:opacity-40 transition-colors`,children:(0,h.jsx)(ne,{className:`h-3.5 w-3.5`})})]},e.id)})}):null]}):(0,h.jsx)(`p`,{className:`${o} leading-relaxed`,children:n(`uiLibrary.privacyMaskSettings.loading`,`Loading the camera's privacy mask…`)}),Z.supported&&(0,h.jsxs)(`div`,{className:`flex items-start gap-3 rounded-md border border-border bg-surface px-2 py-2`,children:[(0,h.jsx)(`button`,{type:`button`,role:`switch`,"aria-label":Z.label,"aria-checked":Z.on===!0,disabled:!Z.available||F!==null,onClick:()=>void ve(),title:Z.on===null?n(`uiLibrary.privacyMaskSettings.micTitleUnknown`,`Microphone — state unknown; the camera did not answer.`):Z.on?n(`uiLibrary.privacyMaskSettings.micTitleOn`,`The camera is capturing sound. Turning it off: {{cost}}`,{cost:Z.costWhenOff}):n(`uiLibrary.privacyMaskSettings.micTitleOff`,`The camera is silent. {{cost}}`,{cost:Z.costWhenOff}),className:Z.on===!1||Z.on===null?g:_,children:(0,h.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[Z.on===!1?(0,h.jsx)(oe,{className:`h-3.5 w-3.5`}):(0,h.jsx)(d,{className:`h-3.5 w-3.5`}),Z.on===null?n(`uiLibrary.privacyMaskSettings.micUnknown`,`Microphone unknown`):Z.on?n(`uiLibrary.privacyMaskSettings.micOn`,`Microphone on`):n(`uiLibrary.privacyMaskSettings.micOff`,`Microphone off`)]})}),(0,h.jsx)(`p`,{className:`text-[10px] text-foreground-subtle flex-1 leading-relaxed`,children:L===null?Z.on===null?n(`uiLibrary.privacyMaskSettings.micNotReported`,`The camera did not report its microphone, so this state is unknown.`):Z.costWhenOff:n(`uiLibrary.privacyMaskSettings.writeFailed`,`Write failed: {{reason}}`,{reason:L})})]})]})}):null}export{y as PrivacyMaskSettings};
|
|
1
|
+
import{a as e,i as t,l as n,n as r,o as i}from"./scheduler-0XZJE03d.js";import{C as a,_ as ee,c as o,d as te,g as ne,h as s,l as c,p as re,t as l,x as u,y as d}from"./index-Ba-k94Iy.js";import{MaskShapeCanvas as ie}from"./MaskShapeCanvas-BTvl6Rin.js";var ae=a(`hexagon`,[[`path`,{d:`M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z`,key:`yt0hxn`}]]),oe=a(`mic-off`,[[`path`,{d:`M12 19v3`,key:`npa21l`}],[`path`,{d:`M15 9.34V5a3 3 0 0 0-5.68-1.33`,key:`1gzdoj`}],[`path`,{d:`M16.95 16.95A7 7 0 0 1 5 12v-2`,key:`cqa7eg`}],[`path`,{d:`M18.89 13.23A7 7 0 0 0 19 12v-2`,key:`16hl24`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M9 9v3a3 3 0 0 0 5.12 2.12`,key:`r2i35w`}]]),f=n(i(),1),p=`Microphone`,m=`The camera encodes no audio at all — live view, recordings, exports and the audio analyzer are all silent.`;function se(e){let t=e.supportsAudioMute===!0,n=t?e.audioEnabled:null,r=e.pendingOn??null;return{label:p,supported:t,on:n===null?null:r??n,available:t&&n!==null,costWhenOff:m}}function ce(e){return!e.available||e.on===null?null:{enabled:!e.on}}var h=n(e(),1),le=120,ue=`privacy-mask`,g=`rounded-md border border-border bg-surface px-2 py-1 text-[11px] font-medium text-foreground-subtle hover:bg-surface-hover disabled:opacity-40 transition-colors`,_=`rounded-md border border-primary/50 bg-primary/15 px-2.5 py-1 text-[11px] font-medium text-primary hover:bg-primary/25 disabled:opacity-40 transition-colors`;function v(e){return e.kind===`rect`||e.kind===`polygon`?e:null}function de(e){let t=new Set(e.map(e=>e.id)),n=0;for(;t.has(n);)n+=1;return n}function fe(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(JSON.stringify(e[n])!==JSON.stringify(t[n]))return!1;return!0}function y({deviceId:e}){let n=t(),i=te(s().trpcClient,e),[a,p]=(0,f.useState)(null),[m,y]=(0,f.useState)(!1),[b,x]=(0,f.useState)(!1),[S,C]=(0,f.useState)(null),[w,T]=(0,f.useState)(null),[E,D]=(0,f.useState)(!1),[O,k]=(0,f.useState)(!1),[A,j]=(0,f.useState)(null),[M,N]=(0,f.useState)(null),[pe,P]=(0,f.useState)(null),[F,I]=(0,f.useState)(null),[L,R]=(0,f.useState)(null),z=(0,f.useRef)(!1);(0,f.useEffect)(()=>{if(!i)return;let e=!1;return z.current=!1,p(null),y(!1),x(!1),C(null),T(null),k(!1),j(null),N(null),P(null),I(null),R(null),(async()=>{try{let t=await i.privacyMask?.getOptions({});if(e)return;if(!t)throw Error(`device proxy not ready`);if(p(t),z.current)return;let n=await i.privacyMask?.getStatus({});if(e)return;if(!n)throw Error(`device proxy not ready`);if(n.regions===null){x(!0),P(n.audioEnabled);return}z.current=!0;let r={enabled:n.enabled,regions:n.regions};T(r),C(r),P(n.audioEnabled)}catch(t){if(e)return;c(t)?y(!0):console.error(`Privacy Mask load failed`,t)}})(),()=>{e=!0}},[i]);let B=(0,f.useMemo)(()=>S!==null&&w!==null&&(S.enabled!==w.enabled||!fe(S.regions,w.regions)),[S,w]),V=S?S.regions.length:0,H=a?a.maxRegions:0,U=(0,f.useRef)(0);(0,f.useEffect)(()=>{U.current=H},[H]);let W=H>0&&V>=H,me=(0,f.useCallback)(()=>{C(e=>e&&{...e,enabled:!e.enabled})},[]),G=(0,f.useCallback)(e=>{j(typeof e==`number`?e:null)},[]),K=(0,f.useMemo)(()=>S?S.regions.map(e=>({id:e.id,shape:e.shape,enabled:e.enabled,label:n(`uiLibrary.privacyMaskSettings.zoneN`,`Zone {{id}}`,{id:e.id})})):[],[S,n]),q=(0,f.useCallback)((e,t)=>{let n=v(t);n&&C(t=>t&&{...t,regions:t.regions.map(t=>t.id===e?{...t,shape:n}:t)})},[]),J=(0,f.useCallback)(e=>{let t=v(e);t&&(N(null),C(e=>{if(!e)return e;let n=U.current;if(n>0&&e.regions.length>=n)return e;let r=de(e.regions),i={id:r,enabled:!0,shape:t};return j(r),{...e,regions:[...e.regions,i]}}))},[]),Y=(0,f.useCallback)(e=>{k(!0),j(null),N(e)},[]),he=(0,f.useCallback)(e=>{k(!0),N(null),j(e)},[]),ge=(0,f.useCallback)(e=>{j(t=>t===e?null:t),C(t=>t&&{...t,regions:t.regions.filter(t=>t.id!==e)})},[]),_e=(0,f.useCallback)(()=>{N(null),j(null),w&&C({enabled:w.enabled,regions:w.regions})},[w]),X=(0,f.useCallback)(async()=>{if(!(!i||!S)){D(!0);try{await i.privacyMask?.setMask({patch:{enabled:S.enabled,regions:[...S.regions]}});let e=await i.privacyMask?.getStatus({});if(e&&e.regions!==null){let t={enabled:e.enabled,regions:e.regions};T(t),C(t)}}catch(e){console.error(`Privacy Mask save failed`,e)}finally{D(!1)}}},[i,S]),Z=se({supportsAudioMute:a===null?null:a.supportsAudioMute,audioEnabled:pe,pendingOn:F}),ve=(0,f.useCallback)(async()=>{let e=ce(Z);if(!(!i||e===null)){I(e.enabled),R(null);try{await i.privacyMask?.setAudioEnabled(e);let t=await i.privacyMask?.getStatus({});t&&P(t.audioEnabled)}catch(e){console.error(`Privacy microphone write failed — reverting`,e),R(e instanceof Error?e.message:String(e))}finally{I(null)}}},[i,Z]),ye=(0,f.useCallback)(()=>{k(e=>(e&&(N(null),j(null)),!e))},[]),Q=a?.supportedShapes??[];l((0,f.useMemo)(()=>O&&!m&&a&&S?{id:ue,order:le,node:(0,h.jsx)(ie,{transparent:!0,items:K,supportedShapes:Q,polygonVertices:a.polygonVertices,selectedId:A,onSelect:G,onShapeChange:q,onDrawComplete:J,drawingKind:M})}:null,[O,m,a,S,K,Q,A,G,q,J,M]));let be=a?.supportedShapes.includes(`rect`)??!1,xe=a?.supportedShapes.includes(`polygon`)??!1,$=a!==null&&(a.maxRegions<=0||a.supportedShapes.length===0),Se=!m&&!$&&!b&&a!==null&&S!==null;return i?(0,h.jsx)(re,{title:n(`uiLibrary.privacyMaskSettings.title`,`Privacy Mask`),icon:(0,h.jsx)(u,{className:`h-3.5 w-3.5 text-foreground-subtle`}),children:(0,h.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[m||$?(0,h.jsx)(`p`,{className:`${o} leading-relaxed`,children:n(`uiLibrary.privacyMaskSettings.unsupported`,`This camera doesn't support an on-board privacy mask.`)}):b?(0,h.jsx)(`p`,{className:`${o} leading-relaxed`,children:n(`uiLibrary.privacyMaskSettings.unreadable`,`This camera hasn't answered, so what it currently masks is unknown — the editor stays closed rather than showing an empty frame you could save over. A battery camera answers once it wakes; otherwise check that it is reachable.`)}):Se?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`p`,{className:`${o} leading-relaxed`,children:(0,h.jsx)(r,{uiKey:`uiLibrary.privacyMaskSettings.help`,fallback:`Toggle <0>Edit mask</0> to draw blanked-out zones on the live frame, then <1>Save</1> to push them to the camera. Drag a rectangle to move, its corner to resize; drag polygon vertices, click an edge midpoint to add one, or right-click a vertex to remove it.`,components:[(0,h.jsx)(`strong`,{className:`text-foreground`},`edit`),(0,h.jsx)(`strong`,{className:`text-foreground`},`save`)]})}),(0,h.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,h.jsx)(`button`,{type:`button`,onClick:ye,disabled:E,"aria-pressed":O,className:O?_:g,children:O?n(`uiLibrary.privacyMaskSettings.doneEditing`,`Done editing`):n(`uiLibrary.privacyMaskSettings.editMask`,`Edit mask`)}),(0,h.jsx)(`button`,{type:`button`,onClick:me,disabled:E,"aria-pressed":S.enabled,className:S.enabled?_:g,children:S.enabled?n(`uiLibrary.privacyMaskSettings.maskOn`,`Mask on`):n(`uiLibrary.privacyMaskSettings.maskOff`,`Mask off`)}),be&&(0,h.jsx)(`button`,{type:`button`,onClick:()=>Y(`rect`),disabled:E||W,"aria-pressed":M===`rect`,className:M===`rect`?_:g,title:W?n(`uiLibrary.privacyMaskSettings.maxZones`,`Maximum zones reached`):n(`uiLibrary.privacyMaskSettings.addRect`,`Add a rectangle zone`),children:n(`uiLibrary.privacyMaskSettings.rectButton`,`+ Rect`)}),xe&&(0,h.jsx)(`button`,{type:`button`,onClick:()=>Y(`polygon`),disabled:E||W,"aria-pressed":M===`polygon`,className:M===`polygon`?_:g,title:W?n(`uiLibrary.privacyMaskSettings.maxZones`,`Maximum zones reached`):n(`uiLibrary.privacyMaskSettings.addPolygon`,`Add a polygon zone`),children:n(`uiLibrary.privacyMaskSettings.polygonButton`,`+ Polygon`)}),(0,h.jsx)(`span`,{className:`${o} ml-1 tabular-nums`,children:n(`uiLibrary.privacyMaskSettings.zoneCount`,`{{active}} / {{max}} zones`,{active:V,max:H})}),(0,h.jsx)(`span`,{className:`flex-1`}),(0,h.jsx)(`button`,{type:`button`,onClick:_e,disabled:E||!B,className:`rounded-md border border-border bg-surface px-2 py-1 text-[11px] text-foreground-subtle hover:bg-surface-hover disabled:opacity-40 transition-colors`,children:n(`uiLibrary.privacyMaskSettings.revert`,`Revert`)}),(0,h.jsx)(`button`,{type:`button`,onClick:()=>void X(),disabled:E||!B,className:_,children:E?n(`uiLibrary.privacyMaskSettings.saving`,`Saving…`):n(`uiLibrary.privacyMaskSettings.save`,`Save`)})]}),V>0?(0,h.jsx)(`div`,{className:`flex flex-col gap-1`,children:S.regions.map(e=>{let t=A===e.id,r=e.shape.kind===`polygon`?ae:ee;return(0,h.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border px-2 py-1 transition-colors ${t?`border-primary/50 bg-primary/10`:`border-border bg-surface`}`,children:[(0,h.jsxs)(`button`,{type:`button`,onClick:()=>he(e.id),disabled:E,className:`flex flex-1 items-center gap-2 text-left text-[11px] font-medium text-foreground-subtle hover:text-foreground disabled:opacity-40 transition-colors`,children:[(0,h.jsx)(r,{className:`h-3.5 w-3.5 shrink-0`}),(0,h.jsx)(`span`,{children:n(`uiLibrary.privacyMaskSettings.zoneN`,`Zone {{id}}`,{id:e.id})}),(0,h.jsx)(`span`,{className:`text-foreground-faint capitalize`,children:e.shape.kind})]}),(0,h.jsx)(`button`,{type:`button`,onClick:()=>ge(e.id),disabled:E,"aria-label":n(`uiLibrary.privacyMaskSettings.deleteZoneN`,`Delete zone {{id}}`,{id:e.id}),title:n(`uiLibrary.privacyMaskSettings.deleteZone`,`Delete zone`),className:`inline-flex h-6 w-6 items-center justify-center rounded border border-border bg-surface text-foreground-subtle hover:border-red-400/40 hover:bg-red-500/10 hover:text-red-400 disabled:opacity-40 transition-colors`,children:(0,h.jsx)(ne,{className:`h-3.5 w-3.5`})})]},e.id)})}):null]}):(0,h.jsx)(`p`,{className:`${o} leading-relaxed`,children:n(`uiLibrary.privacyMaskSettings.loading`,`Loading the camera's privacy mask…`)}),Z.supported&&(0,h.jsxs)(`div`,{className:`flex items-start gap-3 rounded-md border border-border bg-surface px-2 py-2`,children:[(0,h.jsx)(`button`,{type:`button`,role:`switch`,"aria-label":Z.label,"aria-checked":Z.on===!0,disabled:!Z.available||F!==null,onClick:()=>void ve(),title:Z.on===null?n(`uiLibrary.privacyMaskSettings.micTitleUnknown`,`Microphone — state unknown; the camera did not answer.`):Z.on?n(`uiLibrary.privacyMaskSettings.micTitleOn`,`The camera is capturing sound. Turning it off: {{cost}}`,{cost:Z.costWhenOff}):n(`uiLibrary.privacyMaskSettings.micTitleOff`,`The camera is silent. {{cost}}`,{cost:Z.costWhenOff}),className:Z.on===!1||Z.on===null?g:_,children:(0,h.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[Z.on===!1?(0,h.jsx)(oe,{className:`h-3.5 w-3.5`}):(0,h.jsx)(d,{className:`h-3.5 w-3.5`}),Z.on===null?n(`uiLibrary.privacyMaskSettings.micUnknown`,`Microphone unknown`):Z.on?n(`uiLibrary.privacyMaskSettings.micOn`,`Microphone on`):n(`uiLibrary.privacyMaskSettings.micOff`,`Microphone off`)]})}),(0,h.jsx)(`p`,{className:`text-[10px] text-foreground-subtle flex-1 leading-relaxed`,children:L===null?Z.on===null?n(`uiLibrary.privacyMaskSettings.micNotReported`,`The camera did not report its microphone, so this state is unknown.`):Z.costWhenOff:n(`uiLibrary.privacyMaskSettings.writeFailed`,`Write failed: {{reason}}`,{reason:L})})]})]})}):null}export{y as PrivacyMaskSettings};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,i as t,l as n,n as r,o as i}from"./scheduler-0XZJE03d.js";import{C as a,S as o,a as s,b as c,c as l,d as u,f as d,g as f,h as p,i as m,l as h,m as g,n as _,o as v,r as ee,s as y,u as b,v as x}from"./index-Ds0hKW0X.js";import{MaskShapeCanvas as S}from"./MaskShapeCanvas-BTvl6Rin.js";var C=a(`settings-2`,[[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`path`,{d:`M19 7h-9`,key:`6i9tg`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]),w=n(i(),1),T=n(e(),1),E=g(`/addon/pipeline-analytics/event-media`);function D(e){return`${E}/m/${e}`}function O(e){let t=new Map;for(let n of e.states)n.references.forEach((e,r)=>{let i=t.get(e.condition)??[];i.push({stateId:n.id,index:r,reference:e}),t.set(e.condition,i)});return[...t.entries()].map(([e,t])=>({condition:e,tiles:[...t].sort((e,t)=>t.reference.capturedAt-e.reference.capturedAt)})).sort((e,t)=>e.condition.localeCompare(t.condition))}function k(e){return e.states.reduce((e,t)=>e+t.references.length,0)}var A=`rounded border border-danger/50 bg-danger/10 px-1 py-0.5 text-[10px] font-medium text-danger hover:bg-danger/20 disabled:opacity-40 transition-colors`;function j({monitor:e,disabled:n,onDelete:r}){let i=t(),a=O(e),o=k(e),[s,c]=(0,w.useState)(null);return a.length===0?(0,T.jsx)(`p`,{className:`${l} leading-relaxed`,children:i(`uiLibrary.sceneReferenceGallery.empty`,`No photographs captured yet. Press “Capture daylight” to take the one this scene will judge everything against.`)}):(0,T.jsx)(`div`,{className:`flex flex-col gap-2`,children:a.map(e=>(0,T.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,T.jsxs)(`p`,{className:`text-[10px] font-semibold uppercase tracking-wide text-foreground-subtle`,children:[y(e.condition,i),` · `,e.tiles.length]}),(0,T.jsx)(`ul`,{className:`flex flex-wrap gap-1.5`,children:e.tiles.map(t=>{let a=`${t.stateId}:${String(t.index)}`,u=o===1,d=s===a;return(0,T.jsxs)(`li`,{className:`flex w-24 flex-col gap-1 rounded-md border border-border p-1`,children:[(0,T.jsx)(M,{reference:t.reference}),(0,T.jsx)(`span`,{className:`${l} tabular-nums`,children:N(t.reference.capturedAt)}),(0,T.jsxs)(`button`,{type:`button`,className:A,disabled:n,"aria-label":i(`uiLibrary.sceneReferenceGallery.deleteLabel`,`Delete the {{variant}} photograph from {{date}}`,{variant:y(e.condition,i).toLowerCase(),date:N(t.reference.capturedAt)}),onClick:()=>{if(u&&!d){c(a);return}c(null),r({stateId:t.stateId,index:t.index})},children:[(0,T.jsx)(f,{className:`mr-1 inline h-3 w-3`}),d?i(`uiLibrary.sceneReferenceGallery.confirm`,`Confirm`):i(`uiLibrary.sceneReferenceGallery.delete`,`Delete`)]}),d&&(0,T.jsx)(`p`,{className:`text-[10px] leading-snug text-warning`,children:i(`uiLibrary.sceneReferenceGallery.lastWarning`,`This is the only photograph this scene has. Delete it and the scene no longer knows what normal looks like — it stops judging until you capture again.`)})]},a)})})]},e.condition))})}function M({reference:e}){let n=t(),[r,i]=(0,w.useState)(!1),a=e.thumbnailMediaId;return a===void 0||r?(0,T.jsxs)(`div`,{className:`flex h-16 w-full flex-col items-center justify-center gap-0.5 rounded bg-surface text-foreground-subtle`,title:n(`uiLibrary.sceneReferenceGallery.missingPicture`,`The picture for this reference is no longer stored. The reference itself is intact and still being scored against.`),children:[(0,T.jsx)(c,{className:`h-4 w-4`}),(0,T.jsx)(`span`,{className:`text-[9px]`,children:n(`uiLibrary.sceneReferenceGallery.noPicture`,`no picture`)})]}):(0,T.jsx)(`img`,{src:D(a),alt:``,loading:`lazy`,className:`h-16 w-full rounded object-cover`,onError:()=>i(!0)})}function N(e){let t=new Date(e);return`${t.toLocaleDateString()} ${t.toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}`}var P=`rounded-md border border-border bg-surface px-2 py-1 text-[11px] text-foreground focus:border-primary focus:outline-none disabled:opacity-50`,F=`text-[10px] font-medium text-foreground-subtle`,I=`flex flex-col gap-2 rounded-md border border-border bg-surface/40 p-2`,L=`text-[10px] font-semibold uppercase tracking-wide text-foreground-subtle`,R=5,z=3600;function B(e,t){switch(e){case`periodic`:return t(`uiLibrary.sceneSettingsForm.triggerHintPeriodic`,`Only on the clock. Predictable, and it notices a change even on a camera nothing ever moves in front of.`);case`on-motion`:return t(`uiLibrary.sceneSettingsForm.triggerHintOnMotion`,`Only after the camera has been still again for the quiet window below. Cheapest, but a change nobody walks past is never seen.`);case`both`:return t(`uiLibrary.sceneSettingsForm.triggerHintBoth`,`Both — the clock is the safety net that lets the motion path miss. This is the right answer for almost every scene.`)}}function V(e,t){switch(e){case`skip`:return t(`uiLibrary.sceneSettingsForm.uncoveredHintSkip`,`Sit that light out. No verdict, no alarm, no flag touched — it picks itself back up when a light it knows returns. This is why the night capture is optional.`);case`judge-anyway`:return t(`uiLibrary.sceneSettingsForm.uncoveredHintJudge`,`Compare against the references you do have. Only correct when the two lights genuinely look alike (a floodlit driveway, an indoor lamp) — against a real infrared frame it will report a change that did not happen.`)}}function H(e){return{label:e.label,checkIntervalSec:e.checkIntervalSec??60,threshold:e.check.mode===`similarity`?e.check.threshold:.8,hysteresisCount:e.check.hysteresisCount,quietSeconds:e.quietSeconds,minObservationSpacingSec:e.minObservationSpacingSec,confirmPrompt:e.confirm?.prompt??``}}function U({monitor:e,disabled:n,onPatch:i}){let a=t(),[o,s]=(0,w.useState)(()=>H(e)),[c,u]=(0,w.useState)(!1);(0,w.useEffect)(()=>{c||s(H(e))},[e,c]);let d=e=>{u(!1),i(e)},f=t=>e.check.mode===`similarity`?{mode:`similarity`,threshold:t.threshold??e.check.threshold,hysteresisCount:t.hysteresisCount??e.check.hysteresisCount}:{...e.check,hysteresisCount:t.hysteresisCount??e.check.hysteresisCount},p=e.confirm?.enabled===!0,m=e.check.mode===`similarity`?e.check.threshold:null;return(0,T.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,T.jsxs)(`div`,{className:I,children:[(0,T.jsx)(`p`,{className:L,children:a(`uiLibrary.sceneSettingsForm.whatItWatches`,`What it watches`)}),(0,T.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,T.jsx)(`span`,{className:F,children:a(`uiLibrary.sceneSettingsForm.name`,`Name`)}),(0,T.jsx)(`input`,{type:`text`,value:o.label,disabled:n,className:P,onFocus:()=>u(!0),onChange:e=>s(t=>({...t,label:e.target.value})),onBlur:()=>{let t=o.label.trim();t.length>0&&t!==e.label?d({label:t}):u(!1)}})]}),(0,T.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,T.jsx)(`input`,{type:`checkbox`,checked:e.enabled,disabled:n,onChange:e=>d({enabled:e.target.checked})}),(0,T.jsx)(`span`,{className:F,children:a(`uiLibrary.sceneSettingsForm.watching`,`Watching`)})]}),(0,T.jsx)(`p`,{className:l,children:a(`uiLibrary.sceneSettingsForm.watchingHint`,`Turned off, the scene keeps its region, its references and its flag — it simply stops checking. Nothing is lost by pausing one for a while.`)}),(0,T.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,T.jsx)(`span`,{className:F,children:a(`uiLibrary.sceneSettingsForm.whenToLook`,`When to look`)}),(0,T.jsxs)(`select`,{value:e.triggerMode,disabled:n,className:P,onChange:e=>{let t=e.target.value;(t===`periodic`||t===`on-motion`||t===`both`)&&d({triggerMode:t})},children:[(0,T.jsx)(`option`,{value:`both`,children:a(`uiLibrary.sceneSettingsForm.triggerBoth`,`On the clock and after motion settles`)}),(0,T.jsx)(`option`,{value:`periodic`,children:a(`uiLibrary.sceneSettingsForm.triggerPeriodic`,`On the clock only`)}),(0,T.jsx)(`option`,{value:`on-motion`,children:a(`uiLibrary.sceneSettingsForm.triggerOnMotion`,`After motion settles only`)})]})]}),(0,T.jsx)(`p`,{className:l,children:B(e.triggerMode,a)}),(0,T.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,T.jsx)(`span`,{className:F,children:a(`uiLibrary.sceneSettingsForm.checkEvery`,`Check every (seconds)`)}),(0,T.jsx)(`input`,{type:`number`,min:R,max:z,value:o.checkIntervalSec,disabled:n,className:P,onFocus:()=>u(!0),onChange:e=>s(t=>({...t,checkIntervalSec:Number(e.target.value)||0})),onBlur:()=>{let t=W(o.checkIntervalSec,R,z);t===e.checkIntervalSec?u(!1):d({checkIntervalSec:t})}})]}),(0,T.jsx)(`p`,{className:l,children:a(`uiLibrary.sceneSettingsForm.intervalHint`,`60 s suits “is the bin still out”. Every check costs one photograph and one encode, so going below about 30 s buys latency you almost never need and multiplies the cost by the number of scenes you own.`)})]}),(0,T.jsxs)(`div`,{className:I,children:[(0,T.jsx)(`p`,{className:L,children:a(`uiLibrary.sceneSettingsForm.howSure`,`How sure it has to be`)}),e.check.mode===`similarity`&&(0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,T.jsx)(`span`,{className:F,children:(0,T.jsx)(r,{uiKey:`uiLibrary.sceneSettingsForm.matchThreshold`,fallback:`Match threshold — <0>{{value}}</0>`,components:[(0,T.jsx)(`span`,{className:`tabular-nums`},`value`)],values:{value:o.threshold.toFixed(2)}})}),(0,T.jsx)(`input`,{type:`range`,min:.3,max:.99,step:.01,value:o.threshold,disabled:n,onFocus:()=>u(!0),onChange:e=>s(t=>({...t,threshold:Number(e.target.value)})),onMouseUp:()=>{o.threshold===m?u(!1):d({check:f({threshold:o.threshold})})},onBlur:()=>{o.threshold===m?u(!1):d({check:f({threshold:o.threshold})})}})]}),(0,T.jsx)(`p`,{className:`text-[10px] text-foreground-subtle`,children:a(`uiLibrary.sceneSettingsForm.thresholdHint`,`How closely the region still has to resemble the photograph to count as unchanged. Higher means fussier: at 0.95 a passing cloud can read as a change; at 0.60 the bin can be taken and the scene will shrug. 0.80 is a sensible start — if it cries wolf, lower it; if it misses the thing you care about, raise it.`)})]}),(0,T.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,T.jsx)(`span`,{className:F,children:a(`uiLibrary.sceneSettingsForm.agreeingChecks`,`Agreeing checks before it changes its mind`)}),(0,T.jsx)(`input`,{type:`number`,min:1,max:10,value:o.hysteresisCount,disabled:n,className:P,onFocus:()=>u(!0),onChange:e=>s(t=>({...t,hysteresisCount:Number(e.target.value)||1})),onBlur:()=>{let t=W(o.hysteresisCount,1,10);t===e.check.hysteresisCount?u(!1):d({check:f({hysteresisCount:t})})}})]}),(0,T.jsx)(`p`,{className:l,children:a(`uiLibrary.sceneSettingsForm.agreeingHint`,`One bad photograph must never be able to flip a scene. 3 agreeing checks at 60 s is about four minutes of latency and is what makes the answer trustworthy — leaving a state costs exactly the same as entering one.`)}),(0,T.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,T.jsx)(`span`,{className:F,children:a(`uiLibrary.sceneSettingsForm.quietFor`,`Quiet for (seconds) before a check counts`)}),(0,T.jsx)(`input`,{type:`number`,min:0,max:3600,value:o.quietSeconds,disabled:n,className:P,onFocus:()=>u(!0),onChange:e=>s(t=>({...t,quietSeconds:Number(e.target.value)||0})),onBlur:()=>{let t=W(o.quietSeconds,0,3600);t===e.quietSeconds?u(!1):d({quietSeconds:t})}})]}),(0,T.jsx)(`p`,{className:l,children:a(`uiLibrary.sceneSettingsForm.quietHint`,`A check taken while something is moving is a photograph of the van parked in front of the bin, so it is discarded rather than merely delayed. 0 disables the gate.`)}),(0,T.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,T.jsx)(`span`,{className:F,children:a(`uiLibrary.sceneSettingsForm.minGap`,`Minimum gap between counted checks (seconds)`)}),(0,T.jsx)(`input`,{type:`number`,min:0,max:3600,value:o.minObservationSpacingSec,disabled:n,className:P,onFocus:()=>u(!0),onChange:e=>s(t=>({...t,minObservationSpacingSec:Number(e.target.value)||0})),onBlur:()=>{let t=W(o.minObservationSpacingSec,0,3600);t===e.minObservationSpacingSec?u(!1):d({minObservationSpacingSec:t})}})]}),(0,T.jsx)(`p`,{className:l,children:a(`uiLibrary.sceneSettingsForm.minGapHint`,`Spreads the agreeing checks over real time instead of letting three adjacent polls inside one long occlusion be mistaken for three independent opinions.`)})]}),(0,T.jsxs)(`div`,{className:I,children:[(0,T.jsx)(`p`,{className:L,children:a(`uiLibrary.sceneSettingsForm.lighting`,`Lighting`)}),(0,T.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,T.jsx)(`span`,{className:F,children:a(`uiLibrary.sceneSettingsForm.noReference`,`When a light has no reference of its own`)}),(0,T.jsxs)(`select`,{value:e.onUncoveredCondition,disabled:n,className:P,onChange:e=>{let t=e.target.value;(t===`skip`||t===`judge-anyway`)&&d({onUncoveredCondition:t})},children:[(0,T.jsx)(`option`,{value:`skip`,children:a(`uiLibrary.sceneSettingsForm.uncoveredSkip`,`Skip the check (recommended)`)}),(0,T.jsx)(`option`,{value:`judge-anyway`,children:a(`uiLibrary.sceneSettingsForm.uncoveredJudge`,`Judge against the other light anyway`)})]})]}),(0,T.jsx)(`p`,{className:l,children:V(e.onUncoveredCondition,a)})]}),(0,T.jsxs)(`div`,{className:I,children:[(0,T.jsx)(`p`,{className:L,children:a(`uiLibrary.sceneSettingsForm.whatYouGetTold`,`What you get told`)}),(0,T.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,T.jsx)(`span`,{className:F,children:a(`uiLibrary.sceneSettingsForm.notificationsFollow`,`Notifications follow`)}),(0,T.jsxs)(`select`,{value:e.emit,disabled:n,className:P,onChange:e=>{let t=e.target.value;(t===`latched`||t===`live`)&&d({emit:t})},children:[(0,T.jsx)(`option`,{value:`latched`,children:a(`uiLibrary.sceneSettingsForm.emitLatched`,`The flag — told once, still visible at breakfast`)}),(0,T.jsx)(`option`,{value:`live`,children:a(`uiLibrary.sceneSettingsForm.emitLive`,`The live state — follows the region as it changes`)})]})]}),(0,T.jsx)(`p`,{className:l,children:a(`uiLibrary.sceneSettingsForm.emitHint`,`“Is the bin gone” is a flag: you want to be told once and still see it later. “Is the gate open” is a live state.`)}),(0,T.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,T.jsx)(`input`,{type:`checkbox`,checked:e.autoRestore,disabled:n,onChange:e=>d({autoRestore:e.target.checked})}),(0,T.jsx)(`span`,{className:F,children:a(`uiLibrary.sceneSettingsForm.autoRestore`,`Clear the flag by itself when things look normal again`)})]}),(0,T.jsx)(`p`,{className:l,children:a(`uiLibrary.sceneSettingsForm.autoRestoreHint`,`Off by default, so an alarm never silently clears itself. The “back to normal” moment is recorded either way, so an automation can still react to it.`)})]}),(0,T.jsxs)(`div`,{className:I,children:[(0,T.jsx)(`p`,{className:L,children:a(`uiLibrary.sceneSettingsForm.aiDoubleCheck`,`AI double-check`)}),(0,T.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,T.jsx)(`input`,{type:`checkbox`,checked:p,disabled:n||o.confirmPrompt.trim().length===0,onChange:e=>d(e.target.checked?{confirm:{...G(o.confirmPrompt.trim()),enabled:!0}}:{confirm:null})}),(0,T.jsx)(`span`,{className:F,children:a(`uiLibrary.sceneSettingsForm.askVision`,`Ask a vision model before changing the answer`)})]}),(0,T.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,T.jsx)(`span`,{className:F,children:a(`uiLibrary.sceneSettingsForm.question`,`The question to ask`)}),(0,T.jsx)(`input`,{type:`text`,value:o.confirmPrompt,placeholder:a(`uiLibrary.sceneSettingsForm.questionPlaceholder`,`e.g. Is the wheelie bin still there?`),disabled:n,className:P,onFocus:()=>u(!0),onChange:e=>s(t=>({...t,confirmPrompt:e.target.value})),onBlur:()=>{let t=o.confirmPrompt.trim();t.length>0&&t!==e.confirm?.prompt?d({confirm:{...G(t),enabled:p}}):u(!1)}})]}),(0,T.jsx)(`p`,{className:l,children:(0,T.jsx)(r,{uiKey:`uiLibrary.sceneSettingsForm.confirmHint`,fallback:`The model is asked <0>only</0> when the region has already changed enough to flip the answer — roughly twice a week for a bin, not once a minute. It reasons about the object rather than the pixels, so rain, shadows and a repositioned bin stop counting as the thing being taken. If it cannot be reached, the change is held rather than announced.`,components:[(0,T.jsx)(`strong`,{},`only`)]})})]})]})}function W(e,t,n){return Math.min(n,Math.max(t,e))}function G(e){return{enabled:!1,prompt:e,timeoutMs:8e3,maxImagePx:448,onTimeout:`hold`}}var K=`rounded-md border border-border bg-surface px-2 py-1 text-[11px] font-medium text-foreground-subtle hover:bg-surface-hover disabled:opacity-40 transition-colors`,q=`rounded-md border border-primary/50 bg-primary/15 px-2.5 py-1 text-[11px] font-medium text-primary hover:bg-primary/25 disabled:opacity-40 transition-colors`,J=`rounded-md border border-danger/50 bg-danger/10 px-2 py-1 text-[11px] font-medium text-danger hover:bg-danger/20 disabled:opacity-40 transition-colors`,Y={alarm:`border-danger/50 bg-danger/15 text-danger`,ok:`border-success/50 bg-success/15 text-success`,unknown:`border-border bg-surface text-foreground-subtle`},X=.8,Z=3;function Q({deviceId:e}){let n=t(),r=u(p().trpcClient,e),i=d(r?.state.sceneMonitor),a=b(e,{width:640}),[c,g]=(0,w.useState)(null),[E,D]=(0,w.useState)(!1),[O,k]=(0,w.useState)(null),[A,M]=(0,w.useState)(null),[N,P]=(0,w.useState)(null),[F,I]=(0,w.useState)(null),[L,R]=(0,w.useState)(!1),[z,B]=(0,w.useState)(null),[V,H]=(0,w.useState)(``),W=(0,w.useRef)(!0);(0,w.useEffect)(()=>(W.current=!0,()=>{W.current=!1}),[]);let G=(0,w.useCallback)(async()=>{if(r)try{let e=await r.sceneMonitor?.listScenes({});if(!W.current)return;e&&g(e)}catch(e){if(!W.current)return;h(e)?D(!0):M(e instanceof Error?e.message:String(e))}},[r]);(0,w.useEffect)(()=>{g(null),D(!1),M(null),G()},[G]);let Q=i?.monitors??c?.monitors??[],te=Date.now(),$=(0,w.useCallback)(async(e,t)=>{k(e),M(null);try{await t(),await G()}catch(e){W.current&&M(e instanceof Error?e.message:String(e))}finally{W.current&&k(null)}},[G]),ne=(0,w.useMemo)(()=>{let e=Q.map(e=>({id:e.id,shape:e.roi,label:e.label,enabled:e.enabled}));return z===null?e:[...e,{id:`__draft__`,shape:z,label:n(`uiLibrary.sceneMonitor.newSceneLabel`,`New scene`)}]},[Q,z,n]),re=(0,w.useCallback)((e,t)=>{if(t.kind===`rect`){if(e===`__draft__`){B(t);return}$(`roi-${String(e)}`,async()=>r?.sceneMonitor?.updateScene({monitorId:String(e),patch:{roi:t}}))}},[r,$]),ie=(0,w.useCallback)(e=>{e.kind===`rect`&&B(e)},[]),ae=(0,w.useCallback)(async()=>{z===null||V.trim().length===0||(await $(`create`,async()=>{await r?.sceneMonitor?.createScene({label:V.trim(),roi:z,check:{mode:`similarity`,threshold:X,hysteresisCount:Z}})}),B(null),H(``),R(!1))},[r,z,V,$]);return r?(0,T.jsx)(`div`,{className:`flex flex-col gap-3`,children:E?(0,T.jsx)(`p`,{className:`${l} leading-relaxed`,children:n(`uiLibrary.sceneMonitor.unsupported`,`Scene monitoring is not available for this camera.`)}):(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(`p`,{className:`${l} leading-relaxed`,children:n(`uiLibrary.sceneMonitor.intro`,`A scene watches one region of this camera and tells you when it stops looking like the picture you captured. Draw a box around the thing you care about — a wheelie bin, a gate, a parking space — then capture what “normal” looks like. Daylight is enough to start: the night reference is optional, and without it the scene simply sits the infrared hours out instead of reporting a problem.`)}),(0,T.jsx)(`div`,{className:`relative overflow-hidden rounded-md border border-border`,children:(0,T.jsx)(S,{items:ne,supportedShapes:[`rect`],selectedId:N??(z===null?null:`__draft__`),onSelect:e=>P(e===null?null:String(e)),onShapeChange:re,onDrawComplete:ie,drawingKind:L&&z===null?`rect`:null,backdrop:a.src===null?null:(0,T.jsx)(`img`,{src:a.src,alt:``,className:`h-full w-full object-contain`,draggable:!1})})}),(0,T.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,T.jsx)(`button`,{type:`button`,className:L?q:K,"aria-pressed":L,onClick:()=>{R(e=>!e),B(null)},disabled:O!==null,children:L?n(`uiLibrary.sceneMonitor.cancel`,`Cancel`):n(`uiLibrary.sceneMonitor.newScene`,`+ New scene`)}),(0,T.jsx)(`button`,{type:`button`,className:K,onClick:a.refresh,disabled:O!==null,children:n(`uiLibrary.sceneMonitor.refresh`,`Refresh frame`)})]}),L&&(0,T.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-md border border-border bg-surface p-2`,children:[(0,T.jsx)(`p`,{className:`text-[10px] text-foreground-subtle`,children:z===null?n(`uiLibrary.sceneMonitor.draftHint`,`Click on the frame to drop a box, then drag its corner to fit it around the thing you want watched.`):n(`uiLibrary.sceneMonitor.nameHint`,`Name it, then create. You capture what “normal” looks like next.`)}),z!==null&&s(z)&&(0,T.jsx)(`p`,{className:`text-[11px] leading-relaxed text-warning`,children:n(`uiLibrary.sceneMonitor.tooLarge`,`That box covers most of the frame. A scene that big is dominated by the weather, the sky and passing cars — it will quietly stop noticing the thing you actually care about. Draw it tighter.`)}),(0,T.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,T.jsx)(`input`,{type:`text`,value:V,onChange:e=>H(e.target.value),placeholder:n(`uiLibrary.sceneMonitor.placeholder`,`e.g. Immondizia prelevata`),className:`flex-1 rounded-md border border-border bg-surface px-2 py-1 text-[12px] text-foreground`}),(0,T.jsx)(`button`,{type:`button`,className:q,onClick:()=>void ae(),disabled:z===null||V.trim().length===0||O!==null,children:n(`uiLibrary.sceneMonitor.create`,`Create`)})]})]}),A!==null&&(0,T.jsx)(`p`,{className:`text-[11px] leading-relaxed text-danger`,children:A}),Q.length===0?(0,T.jsx)(`p`,{className:`${l} leading-relaxed`,children:n(`uiLibrary.sceneMonitor.empty`,`No scenes on this camera yet.`)}):(0,T.jsx)(`ul`,{className:`flex flex-col gap-2`,children:Q.map(e=>{let t=ee(e,n);return(0,T.jsxs)(`li`,{className:`flex flex-col gap-1.5 rounded-md border p-2 ${N===e.id?`border-primary/50`:`border-border`}`,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,T.jsx)(`button`,{type:`button`,className:`flex-1 text-left text-[12px] font-medium text-foreground`,onClick:()=>P(e.id),children:e.label}),(0,T.jsx)(`span`,{className:`rounded border px-1.5 py-0.5 text-[10px] font-medium ${Y[t.tone]}`,children:t.text})]}),(0,T.jsx)(`p`,{className:`${l} leading-relaxed`,children:v(e,te,n)}),(0,T.jsx)(`p`,{className:`${l} tabular-nums`,children:m(e,n)}),(0,T.jsx)(j,{monitor:e,disabled:O!==null,onDelete:({stateId:t,index:n})=>void $(`refdel-${e.id}-${t}-${String(n)}`,async()=>r.sceneMonitor?.deleteReference({monitorId:e.id,stateId:t,index:n}))}),(0,T.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[_.map(t=>{let i=t===`ir`;return(0,T.jsxs)(`button`,{type:`button`,className:K,disabled:O!==null,title:i?n(`uiLibrary.sceneMonitor.optionalTitle`,`Optional. Without a night reference the checks in infrared are simply skipped — the scene keeps working in daylight and nothing is reported as broken.`):n(`uiLibrary.sceneMonitor.captureTitle`,`Take a fresh photo now and store it as the {{variant}} reference`,{variant:y(t,n).toLowerCase()}),onClick:()=>void $(`cap-${e.id}-${t}`,async()=>r.sceneMonitor?.captureReference({monitorId:e.id,condition:t})),children:[(0,T.jsx)(o,{className:`mr-1 inline h-3 w-3`}),n(`uiLibrary.sceneMonitor.capture`,`Capture {{variant}}`,{variant:y(t,n).toLowerCase()}),i&&(0,T.jsx)(`span`,{className:`ml-1 text-foreground-subtle/70`,children:n(`uiLibrary.sceneMonitor.optional`,`(optional)`)})]},t)}),(0,T.jsxs)(`button`,{type:`button`,className:q,disabled:O!==null||e.states.length===0,title:n(`uiLibrary.sceneMonitor.resetTitle`,`Clear the flag and re-photograph what normal looks like right now`),onClick:()=>void $(`reset-${e.id}`,async()=>r.sceneMonitor?.resetScene({monitorId:e.id})),children:[(0,T.jsx)(x,{className:`mr-1 inline h-3 w-3`}),n(`uiLibrary.sceneMonitor.reset`,`Reset`)]}),(0,T.jsx)(`button`,{type:`button`,className:K,disabled:O!==null,onClick:()=>void $(`check-${e.id}`,async()=>r.sceneMonitor?.recheckNow({monitorId:e.id})),children:n(`uiLibrary.sceneMonitor.checkNow`,`Check now`)}),(0,T.jsxs)(`button`,{type:`button`,className:F===e.id?q:K,"aria-pressed":F===e.id,"aria-label":n(`uiLibrary.sceneMonitor.settingsFor`,`Settings for {{label}}`,{label:e.label}),disabled:O!==null,onClick:()=>I(t=>t===e.id?null:e.id),children:[(0,T.jsx)(C,{className:`mr-1 inline h-3 w-3`}),n(`uiLibrary.sceneMonitor.settings`,`Settings`)]}),(0,T.jsx)(`button`,{type:`button`,className:J,disabled:O!==null,onClick:()=>void $(`del-${e.id}`,async()=>r.sceneMonitor?.deleteScene({monitorId:e.id})),children:(0,T.jsx)(f,{className:`h-3 w-3`})})]}),F===e.id&&(0,T.jsx)(U,{monitor:e,disabled:O!==null,onPatch:t=>void $(`tune-${e.id}`,async()=>r.sceneMonitor?.updateScene({monitorId:e.id,patch:t}))})]},e.id)})})]})}):null}export{Q as SceneMonitorEditor};
|
|
1
|
+
import{a as e,i as t,l as n,n as r,o as i}from"./scheduler-0XZJE03d.js";import{C as a,S as o,a as s,b as c,c as l,d as u,f as d,g as f,h as p,i as m,l as h,m as g,n as _,o as v,r as ee,s as y,u as b,v as x}from"./index-Ba-k94Iy.js";import{MaskShapeCanvas as S}from"./MaskShapeCanvas-BTvl6Rin.js";var C=a(`settings-2`,[[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`path`,{d:`M19 7h-9`,key:`6i9tg`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]),w=n(i(),1),T=n(e(),1),E=g(`/addon/pipeline-analytics/event-media`);function D(e){return`${E}/m/${e}`}function O(e){let t=new Map;for(let n of e.states)n.references.forEach((e,r)=>{let i=t.get(e.condition)??[];i.push({stateId:n.id,index:r,reference:e}),t.set(e.condition,i)});return[...t.entries()].map(([e,t])=>({condition:e,tiles:[...t].sort((e,t)=>t.reference.capturedAt-e.reference.capturedAt)})).sort((e,t)=>e.condition.localeCompare(t.condition))}function k(e){return e.states.reduce((e,t)=>e+t.references.length,0)}var A=`rounded border border-danger/50 bg-danger/10 px-1 py-0.5 text-[10px] font-medium text-danger hover:bg-danger/20 disabled:opacity-40 transition-colors`;function j({monitor:e,disabled:n,onDelete:r}){let i=t(),a=O(e),o=k(e),[s,c]=(0,w.useState)(null);return a.length===0?(0,T.jsx)(`p`,{className:`${l} leading-relaxed`,children:i(`uiLibrary.sceneReferenceGallery.empty`,`No photographs captured yet. Press “Capture daylight” to take the one this scene will judge everything against.`)}):(0,T.jsx)(`div`,{className:`flex flex-col gap-2`,children:a.map(e=>(0,T.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,T.jsxs)(`p`,{className:`text-[10px] font-semibold uppercase tracking-wide text-foreground-subtle`,children:[y(e.condition,i),` · `,e.tiles.length]}),(0,T.jsx)(`ul`,{className:`flex flex-wrap gap-1.5`,children:e.tiles.map(t=>{let a=`${t.stateId}:${String(t.index)}`,u=o===1,d=s===a;return(0,T.jsxs)(`li`,{className:`flex w-24 flex-col gap-1 rounded-md border border-border p-1`,children:[(0,T.jsx)(M,{reference:t.reference}),(0,T.jsx)(`span`,{className:`${l} tabular-nums`,children:N(t.reference.capturedAt)}),(0,T.jsxs)(`button`,{type:`button`,className:A,disabled:n,"aria-label":i(`uiLibrary.sceneReferenceGallery.deleteLabel`,`Delete the {{variant}} photograph from {{date}}`,{variant:y(e.condition,i).toLowerCase(),date:N(t.reference.capturedAt)}),onClick:()=>{if(u&&!d){c(a);return}c(null),r({stateId:t.stateId,index:t.index})},children:[(0,T.jsx)(f,{className:`mr-1 inline h-3 w-3`}),d?i(`uiLibrary.sceneReferenceGallery.confirm`,`Confirm`):i(`uiLibrary.sceneReferenceGallery.delete`,`Delete`)]}),d&&(0,T.jsx)(`p`,{className:`text-[10px] leading-snug text-warning`,children:i(`uiLibrary.sceneReferenceGallery.lastWarning`,`This is the only photograph this scene has. Delete it and the scene no longer knows what normal looks like — it stops judging until you capture again.`)})]},a)})})]},e.condition))})}function M({reference:e}){let n=t(),[r,i]=(0,w.useState)(!1),a=e.thumbnailMediaId;return a===void 0||r?(0,T.jsxs)(`div`,{className:`flex h-16 w-full flex-col items-center justify-center gap-0.5 rounded bg-surface text-foreground-subtle`,title:n(`uiLibrary.sceneReferenceGallery.missingPicture`,`The picture for this reference is no longer stored. The reference itself is intact and still being scored against.`),children:[(0,T.jsx)(c,{className:`h-4 w-4`}),(0,T.jsx)(`span`,{className:`text-[9px]`,children:n(`uiLibrary.sceneReferenceGallery.noPicture`,`no picture`)})]}):(0,T.jsx)(`img`,{src:D(a),alt:``,loading:`lazy`,className:`h-16 w-full rounded object-cover`,onError:()=>i(!0)})}function N(e){let t=new Date(e);return`${t.toLocaleDateString()} ${t.toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}`}var P=`rounded-md border border-border bg-surface px-2 py-1 text-[11px] text-foreground focus:border-primary focus:outline-none disabled:opacity-50`,F=`text-[10px] font-medium text-foreground-subtle`,I=`flex flex-col gap-2 rounded-md border border-border bg-surface/40 p-2`,L=`text-[10px] font-semibold uppercase tracking-wide text-foreground-subtle`,R=5,z=3600;function B(e,t){switch(e){case`periodic`:return t(`uiLibrary.sceneSettingsForm.triggerHintPeriodic`,`Only on the clock. Predictable, and it notices a change even on a camera nothing ever moves in front of.`);case`on-motion`:return t(`uiLibrary.sceneSettingsForm.triggerHintOnMotion`,`Only after the camera has been still again for the quiet window below. Cheapest, but a change nobody walks past is never seen.`);case`both`:return t(`uiLibrary.sceneSettingsForm.triggerHintBoth`,`Both — the clock is the safety net that lets the motion path miss. This is the right answer for almost every scene.`)}}function V(e,t){switch(e){case`skip`:return t(`uiLibrary.sceneSettingsForm.uncoveredHintSkip`,`Sit that light out. No verdict, no alarm, no flag touched — it picks itself back up when a light it knows returns. This is why the night capture is optional.`);case`judge-anyway`:return t(`uiLibrary.sceneSettingsForm.uncoveredHintJudge`,`Compare against the references you do have. Only correct when the two lights genuinely look alike (a floodlit driveway, an indoor lamp) — against a real infrared frame it will report a change that did not happen.`)}}function H(e){return{label:e.label,checkIntervalSec:e.checkIntervalSec??60,threshold:e.check.mode===`similarity`?e.check.threshold:.8,hysteresisCount:e.check.hysteresisCount,quietSeconds:e.quietSeconds,minObservationSpacingSec:e.minObservationSpacingSec,confirmPrompt:e.confirm?.prompt??``}}function U({monitor:e,disabled:n,onPatch:i}){let a=t(),[o,s]=(0,w.useState)(()=>H(e)),[c,u]=(0,w.useState)(!1);(0,w.useEffect)(()=>{c||s(H(e))},[e,c]);let d=e=>{u(!1),i(e)},f=t=>e.check.mode===`similarity`?{mode:`similarity`,threshold:t.threshold??e.check.threshold,hysteresisCount:t.hysteresisCount??e.check.hysteresisCount}:{...e.check,hysteresisCount:t.hysteresisCount??e.check.hysteresisCount},p=e.confirm?.enabled===!0,m=e.check.mode===`similarity`?e.check.threshold:null;return(0,T.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,T.jsxs)(`div`,{className:I,children:[(0,T.jsx)(`p`,{className:L,children:a(`uiLibrary.sceneSettingsForm.whatItWatches`,`What it watches`)}),(0,T.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,T.jsx)(`span`,{className:F,children:a(`uiLibrary.sceneSettingsForm.name`,`Name`)}),(0,T.jsx)(`input`,{type:`text`,value:o.label,disabled:n,className:P,onFocus:()=>u(!0),onChange:e=>s(t=>({...t,label:e.target.value})),onBlur:()=>{let t=o.label.trim();t.length>0&&t!==e.label?d({label:t}):u(!1)}})]}),(0,T.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,T.jsx)(`input`,{type:`checkbox`,checked:e.enabled,disabled:n,onChange:e=>d({enabled:e.target.checked})}),(0,T.jsx)(`span`,{className:F,children:a(`uiLibrary.sceneSettingsForm.watching`,`Watching`)})]}),(0,T.jsx)(`p`,{className:l,children:a(`uiLibrary.sceneSettingsForm.watchingHint`,`Turned off, the scene keeps its region, its references and its flag — it simply stops checking. Nothing is lost by pausing one for a while.`)}),(0,T.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,T.jsx)(`span`,{className:F,children:a(`uiLibrary.sceneSettingsForm.whenToLook`,`When to look`)}),(0,T.jsxs)(`select`,{value:e.triggerMode,disabled:n,className:P,onChange:e=>{let t=e.target.value;(t===`periodic`||t===`on-motion`||t===`both`)&&d({triggerMode:t})},children:[(0,T.jsx)(`option`,{value:`both`,children:a(`uiLibrary.sceneSettingsForm.triggerBoth`,`On the clock and after motion settles`)}),(0,T.jsx)(`option`,{value:`periodic`,children:a(`uiLibrary.sceneSettingsForm.triggerPeriodic`,`On the clock only`)}),(0,T.jsx)(`option`,{value:`on-motion`,children:a(`uiLibrary.sceneSettingsForm.triggerOnMotion`,`After motion settles only`)})]})]}),(0,T.jsx)(`p`,{className:l,children:B(e.triggerMode,a)}),(0,T.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,T.jsx)(`span`,{className:F,children:a(`uiLibrary.sceneSettingsForm.checkEvery`,`Check every (seconds)`)}),(0,T.jsx)(`input`,{type:`number`,min:R,max:z,value:o.checkIntervalSec,disabled:n,className:P,onFocus:()=>u(!0),onChange:e=>s(t=>({...t,checkIntervalSec:Number(e.target.value)||0})),onBlur:()=>{let t=W(o.checkIntervalSec,R,z);t===e.checkIntervalSec?u(!1):d({checkIntervalSec:t})}})]}),(0,T.jsx)(`p`,{className:l,children:a(`uiLibrary.sceneSettingsForm.intervalHint`,`60 s suits “is the bin still out”. Every check costs one photograph and one encode, so going below about 30 s buys latency you almost never need and multiplies the cost by the number of scenes you own.`)})]}),(0,T.jsxs)(`div`,{className:I,children:[(0,T.jsx)(`p`,{className:L,children:a(`uiLibrary.sceneSettingsForm.howSure`,`How sure it has to be`)}),e.check.mode===`similarity`&&(0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,T.jsx)(`span`,{className:F,children:(0,T.jsx)(r,{uiKey:`uiLibrary.sceneSettingsForm.matchThreshold`,fallback:`Match threshold — <0>{{value}}</0>`,components:[(0,T.jsx)(`span`,{className:`tabular-nums`},`value`)],values:{value:o.threshold.toFixed(2)}})}),(0,T.jsx)(`input`,{type:`range`,min:.3,max:.99,step:.01,value:o.threshold,disabled:n,onFocus:()=>u(!0),onChange:e=>s(t=>({...t,threshold:Number(e.target.value)})),onMouseUp:()=>{o.threshold===m?u(!1):d({check:f({threshold:o.threshold})})},onBlur:()=>{o.threshold===m?u(!1):d({check:f({threshold:o.threshold})})}})]}),(0,T.jsx)(`p`,{className:`text-[10px] text-foreground-subtle`,children:a(`uiLibrary.sceneSettingsForm.thresholdHint`,`How closely the region still has to resemble the photograph to count as unchanged. Higher means fussier: at 0.95 a passing cloud can read as a change; at 0.60 the bin can be taken and the scene will shrug. 0.80 is a sensible start — if it cries wolf, lower it; if it misses the thing you care about, raise it.`)})]}),(0,T.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,T.jsx)(`span`,{className:F,children:a(`uiLibrary.sceneSettingsForm.agreeingChecks`,`Agreeing checks before it changes its mind`)}),(0,T.jsx)(`input`,{type:`number`,min:1,max:10,value:o.hysteresisCount,disabled:n,className:P,onFocus:()=>u(!0),onChange:e=>s(t=>({...t,hysteresisCount:Number(e.target.value)||1})),onBlur:()=>{let t=W(o.hysteresisCount,1,10);t===e.check.hysteresisCount?u(!1):d({check:f({hysteresisCount:t})})}})]}),(0,T.jsx)(`p`,{className:l,children:a(`uiLibrary.sceneSettingsForm.agreeingHint`,`One bad photograph must never be able to flip a scene. 3 agreeing checks at 60 s is about four minutes of latency and is what makes the answer trustworthy — leaving a state costs exactly the same as entering one.`)}),(0,T.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,T.jsx)(`span`,{className:F,children:a(`uiLibrary.sceneSettingsForm.quietFor`,`Quiet for (seconds) before a check counts`)}),(0,T.jsx)(`input`,{type:`number`,min:0,max:3600,value:o.quietSeconds,disabled:n,className:P,onFocus:()=>u(!0),onChange:e=>s(t=>({...t,quietSeconds:Number(e.target.value)||0})),onBlur:()=>{let t=W(o.quietSeconds,0,3600);t===e.quietSeconds?u(!1):d({quietSeconds:t})}})]}),(0,T.jsx)(`p`,{className:l,children:a(`uiLibrary.sceneSettingsForm.quietHint`,`A check taken while something is moving is a photograph of the van parked in front of the bin, so it is discarded rather than merely delayed. 0 disables the gate.`)}),(0,T.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,T.jsx)(`span`,{className:F,children:a(`uiLibrary.sceneSettingsForm.minGap`,`Minimum gap between counted checks (seconds)`)}),(0,T.jsx)(`input`,{type:`number`,min:0,max:3600,value:o.minObservationSpacingSec,disabled:n,className:P,onFocus:()=>u(!0),onChange:e=>s(t=>({...t,minObservationSpacingSec:Number(e.target.value)||0})),onBlur:()=>{let t=W(o.minObservationSpacingSec,0,3600);t===e.minObservationSpacingSec?u(!1):d({minObservationSpacingSec:t})}})]}),(0,T.jsx)(`p`,{className:l,children:a(`uiLibrary.sceneSettingsForm.minGapHint`,`Spreads the agreeing checks over real time instead of letting three adjacent polls inside one long occlusion be mistaken for three independent opinions.`)})]}),(0,T.jsxs)(`div`,{className:I,children:[(0,T.jsx)(`p`,{className:L,children:a(`uiLibrary.sceneSettingsForm.lighting`,`Lighting`)}),(0,T.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,T.jsx)(`span`,{className:F,children:a(`uiLibrary.sceneSettingsForm.noReference`,`When a light has no reference of its own`)}),(0,T.jsxs)(`select`,{value:e.onUncoveredCondition,disabled:n,className:P,onChange:e=>{let t=e.target.value;(t===`skip`||t===`judge-anyway`)&&d({onUncoveredCondition:t})},children:[(0,T.jsx)(`option`,{value:`skip`,children:a(`uiLibrary.sceneSettingsForm.uncoveredSkip`,`Skip the check (recommended)`)}),(0,T.jsx)(`option`,{value:`judge-anyway`,children:a(`uiLibrary.sceneSettingsForm.uncoveredJudge`,`Judge against the other light anyway`)})]})]}),(0,T.jsx)(`p`,{className:l,children:V(e.onUncoveredCondition,a)})]}),(0,T.jsxs)(`div`,{className:I,children:[(0,T.jsx)(`p`,{className:L,children:a(`uiLibrary.sceneSettingsForm.whatYouGetTold`,`What you get told`)}),(0,T.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,T.jsx)(`span`,{className:F,children:a(`uiLibrary.sceneSettingsForm.notificationsFollow`,`Notifications follow`)}),(0,T.jsxs)(`select`,{value:e.emit,disabled:n,className:P,onChange:e=>{let t=e.target.value;(t===`latched`||t===`live`)&&d({emit:t})},children:[(0,T.jsx)(`option`,{value:`latched`,children:a(`uiLibrary.sceneSettingsForm.emitLatched`,`The flag — told once, still visible at breakfast`)}),(0,T.jsx)(`option`,{value:`live`,children:a(`uiLibrary.sceneSettingsForm.emitLive`,`The live state — follows the region as it changes`)})]})]}),(0,T.jsx)(`p`,{className:l,children:a(`uiLibrary.sceneSettingsForm.emitHint`,`“Is the bin gone” is a flag: you want to be told once and still see it later. “Is the gate open” is a live state.`)}),(0,T.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,T.jsx)(`input`,{type:`checkbox`,checked:e.autoRestore,disabled:n,onChange:e=>d({autoRestore:e.target.checked})}),(0,T.jsx)(`span`,{className:F,children:a(`uiLibrary.sceneSettingsForm.autoRestore`,`Clear the flag by itself when things look normal again`)})]}),(0,T.jsx)(`p`,{className:l,children:a(`uiLibrary.sceneSettingsForm.autoRestoreHint`,`Off by default, so an alarm never silently clears itself. The “back to normal” moment is recorded either way, so an automation can still react to it.`)})]}),(0,T.jsxs)(`div`,{className:I,children:[(0,T.jsx)(`p`,{className:L,children:a(`uiLibrary.sceneSettingsForm.aiDoubleCheck`,`AI double-check`)}),(0,T.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,T.jsx)(`input`,{type:`checkbox`,checked:p,disabled:n||o.confirmPrompt.trim().length===0,onChange:e=>d(e.target.checked?{confirm:{...G(o.confirmPrompt.trim()),enabled:!0}}:{confirm:null})}),(0,T.jsx)(`span`,{className:F,children:a(`uiLibrary.sceneSettingsForm.askVision`,`Ask a vision model before changing the answer`)})]}),(0,T.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,T.jsx)(`span`,{className:F,children:a(`uiLibrary.sceneSettingsForm.question`,`The question to ask`)}),(0,T.jsx)(`input`,{type:`text`,value:o.confirmPrompt,placeholder:a(`uiLibrary.sceneSettingsForm.questionPlaceholder`,`e.g. Is the wheelie bin still there?`),disabled:n,className:P,onFocus:()=>u(!0),onChange:e=>s(t=>({...t,confirmPrompt:e.target.value})),onBlur:()=>{let t=o.confirmPrompt.trim();t.length>0&&t!==e.confirm?.prompt?d({confirm:{...G(t),enabled:p}}):u(!1)}})]}),(0,T.jsx)(`p`,{className:l,children:(0,T.jsx)(r,{uiKey:`uiLibrary.sceneSettingsForm.confirmHint`,fallback:`The model is asked <0>only</0> when the region has already changed enough to flip the answer — roughly twice a week for a bin, not once a minute. It reasons about the object rather than the pixels, so rain, shadows and a repositioned bin stop counting as the thing being taken. If it cannot be reached, the change is held rather than announced.`,components:[(0,T.jsx)(`strong`,{},`only`)]})})]})]})}function W(e,t,n){return Math.min(n,Math.max(t,e))}function G(e){return{enabled:!1,prompt:e,timeoutMs:8e3,maxImagePx:448,onTimeout:`hold`}}var K=`rounded-md border border-border bg-surface px-2 py-1 text-[11px] font-medium text-foreground-subtle hover:bg-surface-hover disabled:opacity-40 transition-colors`,q=`rounded-md border border-primary/50 bg-primary/15 px-2.5 py-1 text-[11px] font-medium text-primary hover:bg-primary/25 disabled:opacity-40 transition-colors`,J=`rounded-md border border-danger/50 bg-danger/10 px-2 py-1 text-[11px] font-medium text-danger hover:bg-danger/20 disabled:opacity-40 transition-colors`,Y={alarm:`border-danger/50 bg-danger/15 text-danger`,ok:`border-success/50 bg-success/15 text-success`,unknown:`border-border bg-surface text-foreground-subtle`},X=.8,Z=3;function Q({deviceId:e}){let n=t(),r=u(p().trpcClient,e),i=d(r?.state.sceneMonitor),a=b(e,{width:640}),[c,g]=(0,w.useState)(null),[E,D]=(0,w.useState)(!1),[O,k]=(0,w.useState)(null),[A,M]=(0,w.useState)(null),[N,P]=(0,w.useState)(null),[F,I]=(0,w.useState)(null),[L,R]=(0,w.useState)(!1),[z,B]=(0,w.useState)(null),[V,H]=(0,w.useState)(``),W=(0,w.useRef)(!0);(0,w.useEffect)(()=>(W.current=!0,()=>{W.current=!1}),[]);let G=(0,w.useCallback)(async()=>{if(r)try{let e=await r.sceneMonitor?.listScenes({});if(!W.current)return;e&&g(e)}catch(e){if(!W.current)return;h(e)?D(!0):M(e instanceof Error?e.message:String(e))}},[r]);(0,w.useEffect)(()=>{g(null),D(!1),M(null),G()},[G]);let Q=i?.monitors??c?.monitors??[],te=Date.now(),$=(0,w.useCallback)(async(e,t)=>{k(e),M(null);try{await t(),await G()}catch(e){W.current&&M(e instanceof Error?e.message:String(e))}finally{W.current&&k(null)}},[G]),ne=(0,w.useMemo)(()=>{let e=Q.map(e=>({id:e.id,shape:e.roi,label:e.label,enabled:e.enabled}));return z===null?e:[...e,{id:`__draft__`,shape:z,label:n(`uiLibrary.sceneMonitor.newSceneLabel`,`New scene`)}]},[Q,z,n]),re=(0,w.useCallback)((e,t)=>{if(t.kind===`rect`){if(e===`__draft__`){B(t);return}$(`roi-${String(e)}`,async()=>r?.sceneMonitor?.updateScene({monitorId:String(e),patch:{roi:t}}))}},[r,$]),ie=(0,w.useCallback)(e=>{e.kind===`rect`&&B(e)},[]),ae=(0,w.useCallback)(async()=>{z===null||V.trim().length===0||(await $(`create`,async()=>{await r?.sceneMonitor?.createScene({label:V.trim(),roi:z,check:{mode:`similarity`,threshold:X,hysteresisCount:Z}})}),B(null),H(``),R(!1))},[r,z,V,$]);return r?(0,T.jsx)(`div`,{className:`flex flex-col gap-3`,children:E?(0,T.jsx)(`p`,{className:`${l} leading-relaxed`,children:n(`uiLibrary.sceneMonitor.unsupported`,`Scene monitoring is not available for this camera.`)}):(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(`p`,{className:`${l} leading-relaxed`,children:n(`uiLibrary.sceneMonitor.intro`,`A scene watches one region of this camera and tells you when it stops looking like the picture you captured. Draw a box around the thing you care about — a wheelie bin, a gate, a parking space — then capture what “normal” looks like. Daylight is enough to start: the night reference is optional, and without it the scene simply sits the infrared hours out instead of reporting a problem.`)}),(0,T.jsx)(`div`,{className:`relative overflow-hidden rounded-md border border-border`,children:(0,T.jsx)(S,{items:ne,supportedShapes:[`rect`],selectedId:N??(z===null?null:`__draft__`),onSelect:e=>P(e===null?null:String(e)),onShapeChange:re,onDrawComplete:ie,drawingKind:L&&z===null?`rect`:null,backdrop:a.src===null?null:(0,T.jsx)(`img`,{src:a.src,alt:``,className:`h-full w-full object-contain`,draggable:!1})})}),(0,T.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,T.jsx)(`button`,{type:`button`,className:L?q:K,"aria-pressed":L,onClick:()=>{R(e=>!e),B(null)},disabled:O!==null,children:L?n(`uiLibrary.sceneMonitor.cancel`,`Cancel`):n(`uiLibrary.sceneMonitor.newScene`,`+ New scene`)}),(0,T.jsx)(`button`,{type:`button`,className:K,onClick:a.refresh,disabled:O!==null,children:n(`uiLibrary.sceneMonitor.refresh`,`Refresh frame`)})]}),L&&(0,T.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-md border border-border bg-surface p-2`,children:[(0,T.jsx)(`p`,{className:`text-[10px] text-foreground-subtle`,children:z===null?n(`uiLibrary.sceneMonitor.draftHint`,`Click on the frame to drop a box, then drag its corner to fit it around the thing you want watched.`):n(`uiLibrary.sceneMonitor.nameHint`,`Name it, then create. You capture what “normal” looks like next.`)}),z!==null&&s(z)&&(0,T.jsx)(`p`,{className:`text-[11px] leading-relaxed text-warning`,children:n(`uiLibrary.sceneMonitor.tooLarge`,`That box covers most of the frame. A scene that big is dominated by the weather, the sky and passing cars — it will quietly stop noticing the thing you actually care about. Draw it tighter.`)}),(0,T.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,T.jsx)(`input`,{type:`text`,value:V,onChange:e=>H(e.target.value),placeholder:n(`uiLibrary.sceneMonitor.placeholder`,`e.g. Immondizia prelevata`),className:`flex-1 rounded-md border border-border bg-surface px-2 py-1 text-[12px] text-foreground`}),(0,T.jsx)(`button`,{type:`button`,className:q,onClick:()=>void ae(),disabled:z===null||V.trim().length===0||O!==null,children:n(`uiLibrary.sceneMonitor.create`,`Create`)})]})]}),A!==null&&(0,T.jsx)(`p`,{className:`text-[11px] leading-relaxed text-danger`,children:A}),Q.length===0?(0,T.jsx)(`p`,{className:`${l} leading-relaxed`,children:n(`uiLibrary.sceneMonitor.empty`,`No scenes on this camera yet.`)}):(0,T.jsx)(`ul`,{className:`flex flex-col gap-2`,children:Q.map(e=>{let t=ee(e,n);return(0,T.jsxs)(`li`,{className:`flex flex-col gap-1.5 rounded-md border p-2 ${N===e.id?`border-primary/50`:`border-border`}`,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,T.jsx)(`button`,{type:`button`,className:`flex-1 text-left text-[12px] font-medium text-foreground`,onClick:()=>P(e.id),children:e.label}),(0,T.jsx)(`span`,{className:`rounded border px-1.5 py-0.5 text-[10px] font-medium ${Y[t.tone]}`,children:t.text})]}),(0,T.jsx)(`p`,{className:`${l} leading-relaxed`,children:v(e,te,n)}),(0,T.jsx)(`p`,{className:`${l} tabular-nums`,children:m(e,n)}),(0,T.jsx)(j,{monitor:e,disabled:O!==null,onDelete:({stateId:t,index:n})=>void $(`refdel-${e.id}-${t}-${String(n)}`,async()=>r.sceneMonitor?.deleteReference({monitorId:e.id,stateId:t,index:n}))}),(0,T.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[_.map(t=>{let i=t===`ir`;return(0,T.jsxs)(`button`,{type:`button`,className:K,disabled:O!==null,title:i?n(`uiLibrary.sceneMonitor.optionalTitle`,`Optional. Without a night reference the checks in infrared are simply skipped — the scene keeps working in daylight and nothing is reported as broken.`):n(`uiLibrary.sceneMonitor.captureTitle`,`Take a fresh photo now and store it as the {{variant}} reference`,{variant:y(t,n).toLowerCase()}),onClick:()=>void $(`cap-${e.id}-${t}`,async()=>r.sceneMonitor?.captureReference({monitorId:e.id,condition:t})),children:[(0,T.jsx)(o,{className:`mr-1 inline h-3 w-3`}),n(`uiLibrary.sceneMonitor.capture`,`Capture {{variant}}`,{variant:y(t,n).toLowerCase()}),i&&(0,T.jsx)(`span`,{className:`ml-1 text-foreground-subtle/70`,children:n(`uiLibrary.sceneMonitor.optional`,`(optional)`)})]},t)}),(0,T.jsxs)(`button`,{type:`button`,className:q,disabled:O!==null||e.states.length===0,title:n(`uiLibrary.sceneMonitor.resetTitle`,`Clear the flag and re-photograph what normal looks like right now`),onClick:()=>void $(`reset-${e.id}`,async()=>r.sceneMonitor?.resetScene({monitorId:e.id})),children:[(0,T.jsx)(x,{className:`mr-1 inline h-3 w-3`}),n(`uiLibrary.sceneMonitor.reset`,`Reset`)]}),(0,T.jsx)(`button`,{type:`button`,className:K,disabled:O!==null,onClick:()=>void $(`check-${e.id}`,async()=>r.sceneMonitor?.recheckNow({monitorId:e.id})),children:n(`uiLibrary.sceneMonitor.checkNow`,`Check now`)}),(0,T.jsxs)(`button`,{type:`button`,className:F===e.id?q:K,"aria-pressed":F===e.id,"aria-label":n(`uiLibrary.sceneMonitor.settingsFor`,`Settings for {{label}}`,{label:e.label}),disabled:O!==null,onClick:()=>I(t=>t===e.id?null:e.id),children:[(0,T.jsx)(C,{className:`mr-1 inline h-3 w-3`}),n(`uiLibrary.sceneMonitor.settings`,`Settings`)]}),(0,T.jsx)(`button`,{type:`button`,className:J,disabled:O!==null,onClick:()=>void $(`del-${e.id}`,async()=>r.sceneMonitor?.deleteScene({monitorId:e.id})),children:(0,T.jsx)(f,{className:`h-3 w-3`})})]}),F===e.id&&(0,T.jsx)(U,{monitor:e,disabled:O!==null,onPatch:t=>void $(`tune-${e.id}`,async()=>r.sceneMonitor?.updateScene({monitorId:e.id,patch:t}))})]},e.id)})})]})}):null}export{Q as SceneMonitorEditor};
|