iobroker.agent-dvr 0.7.0 → 0.8.1
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/README.de.md +23 -1
- package/README.md +25 -11
- package/admin/webcomponents/agent-dvr-live.js +36 -0
- package/admin/webcomponents/agent-dvr-live.json +209 -0
- package/admin/webcomponents/agent-dvr-overview.js +36 -0
- package/admin/webcomponents/agent-dvr-overview.json +256 -0
- package/admin/webcomponents/agent-dvr-recordings.js +36 -0
- package/admin/webcomponents/agent-dvr-recordings.json +399 -0
- package/build/main.js +82 -0
- package/build/main.js.map +2 -2
- package/io-package.json +51 -40
- package/package.json +11 -4
package/README.de.md
CHANGED
|
@@ -16,6 +16,17 @@ Verbindet ioBroker mit [AgentDVR](https://www.ispyconnect.com): erkennt automati
|
|
|
16
16
|
- ioBroker mit `iobroker.web` Adapter
|
|
17
17
|
- **AgentDVR ≥ 7.8.0.0** — ältere Versionen haben eine Regression im `streamFile.cgi`-Endpunkt (fehlerhafte Chunked-Kodierung, falscher MIME-Typ), die die Wiedergabe von Aufzeichnungen im integrierten Dashboard verhindert. Der Entwickler hat bestätigt, dass der Fix in Version 7.8.0.0 enthalten ist.
|
|
18
18
|
|
|
19
|
+
## Highlights
|
|
20
|
+
|
|
21
|
+
### Web-Komponenten für AURA, vis-2 und devices
|
|
22
|
+
Aufnahmen-Galerie, Live-Kachel und Live-Übersicht gibt es auch als Web-Komponenten (`@iobroker/web-components`). AURA (ab 0.106.0, empfohlen ab 0.112.0), vis-2 (ab 2.20.7) und der Geräte-Adapter devices (ab 4.3.0) bieten sie in ihrer Widget-Auswahl an – ohne HTML-Bindung. Sie zeichnen direkt im Browser statt die HTML-Datenpunkte anzuzeigen, ein Aktualisieren schließt daher nie einen offenen Player.
|
|
23
|
+
- **Agent DVR Aufnahmen** – die Aufnahmen-Galerie einer Kamera, mit Suche und Tag-Filter, eingebautem Player oder externer Player-URL
|
|
24
|
+
- **Agent DVR Live-Kamera** – die Live-Kachel einer Kamera; das Vorschaubild erneuert sich im Browser, ein Klick öffnet den Livestream
|
|
25
|
+
- **Agent DVR Live-Übersicht** – die Live-Kacheln aller Kameras einer Instanz
|
|
26
|
+
- **Quelle**: entweder *Widget aus den Adapter-Einstellungen* (alle Einstellungen des Widget-Tabs der Instanz) oder *Eigene Einstellungen hier* – jede Widget-Einstellung der Instanz (Modus, Anzahl, Thumbnail-Größe, Tags, Sortierung, Suche, Standard-Tag, kompaktes Layout, Player, Seitenverhältnis, Aktualisierungsintervall, Farben, Eckenradius) pro Widget
|
|
27
|
+
- übernimmt auf Wunsch die Farben aus dem Theme der Visualisierung
|
|
28
|
+
- braucht keine Zugangsdaten: Bilder und Videos nutzen dieselben AgentDVR-Links wie die HTML-Widgets; die Daten kommen aus `widget_config` und `<cam>.widget_data`
|
|
29
|
+
|
|
19
30
|
## Funktionen
|
|
20
31
|
|
|
21
32
|
- Automatische Erkennung aller AgentDVR-Kameras beim Start (Mikrofone ausgenommen)
|
|
@@ -385,6 +396,7 @@ Dieser Adapter speichert deine AgentDVR-Admin-Zugangsdaten und stellt `system.co
|
|
|
385
396
|
| `<cam>.events.*` | verschieden | R | Metadaten der letzten Aufnahme — erfordert „Ereignis-Datenpunkte" |
|
|
386
397
|
| `<cam>.widget_recordings` | string | R | HTML-Aufnahmegalerie — erfordert „Galerie-Widget" |
|
|
387
398
|
| `<cam>.widget_live` | string | R | HTML-Live-Einzelkachel der Kamera — erfordert „Galerie-Widget"; Standbild wird bei jedem Adapter-Poll aktualisiert |
|
|
399
|
+
| `<cam>.widget_data` | string | R | Aufnahmen als JSON für die Web-Komponenten (die letzten 500) — erfordert „Galerie-Widget" oder „Ereignis-Datenpunkte" |
|
|
388
400
|
|
|
389
401
|
## Webhook
|
|
390
402
|
|
|
@@ -432,6 +444,7 @@ Dateien: `<namespace>/<cam>/grab1.jpg` … `grab3.jpg` (z. B. `agent-dvr.0/cam_8
|
|
|
432
444
|
| Datenpunkt | Typ | R/W | Beschreibung |
|
|
433
445
|
|-----------|-----|-----|-------------|
|
|
434
446
|
| `widget_live_overview` | string | R | HTML-Kachelraster aller Kameras — Standbilder werden bei jedem Adapter-Poll aktualisiert |
|
|
447
|
+
| `widget_config` | string | R | Widget-Einstellungen, Kameras und Texte als JSON für die Web-Komponenten (immer geschrieben, ohne Zugangsdaten) |
|
|
435
448
|
|
|
436
449
|
## Bilder für VIS und Skripte
|
|
437
450
|
|
|
@@ -457,6 +470,8 @@ Die URLs aus `urls.*` und `events.last.*` zeigen direkt auf AgentDVR. Sie funkti
|
|
|
457
470
|
| `<cam>.events.new` | neue Aufnahme gelistet | Vorschaubild der Aufnahme |
|
|
458
471
|
| `<cam>.events.detected_<tag>` | KI-Tag einer neuen Aufnahme, z. B. `detected_people` — auch wenn AgentDVR den Tag erst später ergänzt | nur bei Personen benachrichtigen |
|
|
459
472
|
|
|
473
|
+
> **`events.webhook` nicht für das gespeicherte Alarmfoto verwenden.** Der Webhook-Puls kommt, *bevor* das neue Foto abgeholt und gespeichert ist. In diesem Moment zeigen `alertPhotos.grab1` / `uri1` / `url1` noch auf das Foto des **vorherigen** Alarms — ein Fernseher oder eine Telegram-Nachricht zeigt dann ein altes Bild (unter Umständen Stunden alt). Für alles, was `alertPhotos.*` nutzt, immer auf `alertPhotos.ts1` triggern. `events.webhook` ist nur für Skripte gedacht, die sich in diesem Moment selbst ein Bild holen (z. B. `urls.photo` oder einen eigenen Kamera-Snapshot).
|
|
474
|
+
|
|
460
475
|
Als Bedingung **„größer als letzter“** (Blockly) bzw. `change: 'gt'` verwenden. Der Adapter schreibt seine Datenpunkte bei jedem Poll neu, „wurde aktualisiert“ löst deshalb bei jedem Poll aus. `status.alerted` ist meist zu kurz, um von einem Poll gesehen zu werden, und taugt nicht als Trigger.
|
|
461
476
|
|
|
462
477
|
### Telegram
|
|
@@ -486,7 +501,7 @@ Die Alarmfotos liefert die Web-Instanz aus — der fertige Link steht in `<cam>.
|
|
|
486
501
|
http://<iobroker>:<webport>/agent-dvr.0/photos/<cam>/grab1.jpg
|
|
487
502
|
```
|
|
488
503
|
|
|
489
|
-
z. B. `http://192.168.1.10:8082/agent-dvr.0/photos/cam_8_Reolink/grab1.jpg` (ebenso `grab2.jpg`, `grab3.jpg`). In einem Bild-Widget verwenden und bei Änderung von `alertPhotos.ts1` neu laden. Für ein Livebild `urls.snapshot` oder `urls.photo` mit Aktualisierungsintervall nehmen.
|
|
504
|
+
z. B. `http://192.168.1.10:8082/agent-dvr.0/photos/cam_8_Reolink/grab1.jpg` (ebenso `grab2.jpg`, `grab3.jpg`). In einem Bild-Widget verwenden und bei Änderung von `alertPhotos.ts1` neu laden. Das gilt auch, wenn der Link an einen Fernseher oder eine andere App geschickt wird: auf `alertPhotos.ts1` senden, nicht auf `events.webhook` — sonst lädt die App das vorherige Foto. Für ein Livebild `urls.snapshot` oder `urls.photo` mit Aktualisierungsintervall nehmen.
|
|
490
505
|
|
|
491
506
|
## Changelog
|
|
492
507
|
|
|
@@ -494,6 +509,13 @@ z. B. `http://192.168.1.10:8082/agent-dvr.0/photos/cam_8_Reolink/grab1.jpg` (ebe
|
|
|
494
509
|
Placeholder for the next version (at the beginning of the line):
|
|
495
510
|
### **WORK IN PROGRESS**
|
|
496
511
|
-->
|
|
512
|
+
### 0.8.1 (2026-11-12)
|
|
513
|
+
* (ipod86) fix: Live-Übersicht (Web-Komponente) passt ihre Kacheln an die Widget-Größe an (kein Scrollen, kein Leerraum); Option „An die Widget-Größe anpassen“
|
|
514
|
+
* (ipod86) chore: Beschreibung und Suchbegriffe nennen die Widgets für vis-2 und AURA
|
|
515
|
+
|
|
516
|
+
### 0.8.0 (2026-11-12)
|
|
517
|
+
* (ipod86) feat: Web-Komponenten für AURA (ab 0.106.0), vis-2 (ab 2.20.7) und devices (ab 4.3.0) – Aufnahmen-Galerie, Live-Kachel und Live-Übersicht, mit den Widget-Einstellungen des Adapters oder eigenen
|
|
518
|
+
|
|
497
519
|
### 0.7.0 (2026-10-29)
|
|
498
520
|
* (ipod86) feat: `alertPhotos.url1–3` mit festem http(s)-Link zu jedem Foto, für TV-/Kiosk-Apps, die nur Web-Links annehmen; Web-Instanz wählbar, Links folgen Änderungen an den Web-Instanzen
|
|
499
521
|
* (ipod86) feat: `<cam>.events.webhookParams` mit allen Parametern des letzten Webhook-Aufrufs als JSON
|
package/README.md
CHANGED
|
@@ -21,6 +21,17 @@ Connects ioBroker to [AgentDVR](https://www.ispyconnect.com): auto-discovers all
|
|
|
21
21
|
- ioBroker with `iobroker.web` adapter
|
|
22
22
|
- **AgentDVR ≥ 7.8.0.0** — earlier versions have a regression in the `streamFile.cgi` endpoint (malformed chunked encoding, wrong MIME type) that prevents recording playback in the built-in dashboard. The developer has confirmed the fix is included in 7.8.0.0.
|
|
23
23
|
|
|
24
|
+
## Highlights
|
|
25
|
+
|
|
26
|
+
### Web components for AURA, vis-2 and devices
|
|
27
|
+
The recordings gallery, the live tile and the live overview are also available as web components (`@iobroker/web-components`). AURA (0.106.0+, 0.112.0+ recommended), vis-2 (2.20.7+) and the devices adapter (4.3.0+) list them in their widget palette — no HTML binding needed. They draw natively in the browser instead of showing the HTML data points, so a refresh never closes an open player.
|
|
28
|
+
- **Agent DVR recordings** — the recordings gallery of a camera, with search and tag filter, built-in player or external player URL
|
|
29
|
+
- **Agent DVR live camera** — the live tile of one camera; the snapshot refreshes in the browser, a click opens the live stream
|
|
30
|
+
- **Agent DVR live overview** — the live tiles of all cameras of an instance
|
|
31
|
+
- **Source**: either *Widget from the adapter settings* (all settings of the Widget tab of the instance) or *Own settings here* — every widget setting of the instance (mode, count, thumbnail size, tags, sort, search, default tag, compact layout, player, aspect ratio, refresh interval, colors, border radius) per widget
|
|
32
|
+
- optionally takes the colors of the visualization's theme
|
|
33
|
+
- needs no credentials: the images and videos use the same AgentDVR links as the HTML widgets; data comes from `widget_config` and `<cam>.widget_data`
|
|
34
|
+
|
|
24
35
|
## Features
|
|
25
36
|
|
|
26
37
|
- Auto-discovery of all AgentDVR cameras on startup (microphones excluded)
|
|
@@ -390,6 +401,7 @@ This adapter stores your AgentDVR admin credentials and exposes `system.control.
|
|
|
390
401
|
| `<cam>.events.*` | various | R | Latest recording metadata — requires "Event data points" |
|
|
391
402
|
| `<cam>.widget_recordings` | string | R | HTML recording gallery — requires "Gallery widget" |
|
|
392
403
|
| `<cam>.widget_live` | string | R | HTML single-camera live tile — requires "Gallery widget"; snapshot refreshes on each adapter poll |
|
|
404
|
+
| `<cam>.widget_data` | string | R | Recordings as JSON for the web components (latest 500) — requires "Gallery widget" or "Event data points" |
|
|
393
405
|
|
|
394
406
|
## Webhook
|
|
395
407
|
|
|
@@ -437,6 +449,7 @@ Files: `<namespace>/<cam>/grab1.jpg` … `grab3.jpg` (e.g. `agent-dvr.0/cam_8_Re
|
|
|
437
449
|
| Data point | Type | R/W | Description |
|
|
438
450
|
|-----------|------|-----|-------------|
|
|
439
451
|
| `widget_live_overview` | string | R | HTML tile grid of all cameras — snapshot refreshes on each adapter poll |
|
|
452
|
+
| `widget_config` | string | R | Widget settings, cameras and texts as JSON for the web components (always written, no credentials) |
|
|
440
453
|
|
|
441
454
|
## Getting images for VIS and scripts
|
|
442
455
|
|
|
@@ -462,6 +475,8 @@ The `urls.*` and `events.last.*` URLs point directly to AgentDVR. They work in t
|
|
|
462
475
|
| `<cam>.events.new` | new recording listed | thumbnail of the recording |
|
|
463
476
|
| `<cam>.events.detected_<tag>` | AI tag of a new recording, e.g. `detected_people` — also when AgentDVR adds the tag later | notify on persons only |
|
|
464
477
|
|
|
478
|
+
> **Do not use `events.webhook` for the stored alert photo.** The webhook pulse comes *before* the new photo is fetched and saved. At that moment `alertPhotos.grab1` / `uri1` / `url1` still point to the photo of the **previous** alert — a TV or Telegram message then shows an old image (possibly hours old). For anything that uses `alertPhotos.*` always trigger on `alertPhotos.ts1`. `events.webhook` is only meant for scripts that fetch an image themselves at that moment (e.g. `urls.photo` or their own camera snapshot).
|
|
479
|
+
|
|
465
480
|
Use **"greater than previous"** (Blockly) or `change: 'gt'` as condition. The adapter rewrites its states on every poll, so "was updated" fires every poll. `status.alerted` is usually too short to be seen by a poll and is not a reliable trigger.
|
|
466
481
|
|
|
467
482
|
### Telegram
|
|
@@ -491,14 +506,22 @@ The alert photos are served by the web instance — the ready-made link is in `<
|
|
|
491
506
|
http://<iobroker>:<webport>/agent-dvr.0/photos/<cam>/grab1.jpg
|
|
492
507
|
```
|
|
493
508
|
|
|
494
|
-
e.g. `http://192.168.1.10:8082/agent-dvr.0/photos/cam_8_Reolink/grab1.jpg` (also `grab2.jpg`, `grab3.jpg`). Use it in an image widget and refresh it on changes of `alertPhotos.ts1`. For a live image use `urls.snapshot` or `urls.photo` with a refresh interval.
|
|
509
|
+
e.g. `http://192.168.1.10:8082/agent-dvr.0/photos/cam_8_Reolink/grab1.jpg` (also `grab2.jpg`, `grab3.jpg`). Use it in an image widget and refresh it on changes of `alertPhotos.ts1`. The same applies when you push the link to a TV or another app: send it on `alertPhotos.ts1`, not on `events.webhook` — otherwise the app loads the previous photo. For a live image use `urls.snapshot` or `urls.photo` with a refresh interval.
|
|
495
510
|
|
|
496
511
|
## Changelog
|
|
512
|
+
### 0.8.1 (2026-11-12)
|
|
513
|
+
* (ipod86) fix: live overview web component fits its tiles to the widget size (no scrolling, no empty space); option "Fit to the widget size"
|
|
514
|
+
* (ipod86) chore: description and keywords mention the widgets for vis-2 and AURA
|
|
515
|
+
|
|
516
|
+
### 0.8.0 (2026-11-12)
|
|
517
|
+
* (ipod86) feat: web components for AURA (0.106.0+), vis-2 (2.20.7+) and devices (4.3.0+) – recordings gallery, live tile and live overview, with the adapter's widget settings or own ones
|
|
518
|
+
|
|
497
519
|
### 0.7.0 (2026-10-29)
|
|
498
520
|
* (ipod86) feat: `alertPhotos.url1–3` with a fixed http(s) link to each photo, for TV/kiosk apps that only accept web links; web instance selectable, links follow changes of the web instances
|
|
499
521
|
* (ipod86) feat: `<cam>.events.webhookParams` with all parameters of the latest webhook call as JSON
|
|
500
522
|
|
|
501
523
|
<!-- markdownlint-disable-next-line MD024 -->
|
|
524
|
+
|
|
502
525
|
### 0.6.0 (2026-10-29)
|
|
503
526
|
* (ipod86) chore: clearer adapter title ("Agent DVR – Cameras & Recordings") and keywords
|
|
504
527
|
* (ipod86) fix: `events.detected_*` now also fires when AgentDVR adds the AI tag (e.g. `people`) to a recording after it was first listed
|
|
@@ -508,6 +531,7 @@ e.g. `http://192.168.1.10:8082/agent-dvr.0/photos/cam_8_Reolink/grab1.jpg` (also
|
|
|
508
531
|
* (ipod86) feat: `alertPhotos.uri1–3` with the `iobfile://` URI of each photo, sendable directly with Telegram 6
|
|
509
532
|
|
|
510
533
|
<!-- markdownlint-disable-next-line MD024 -->
|
|
534
|
+
|
|
511
535
|
### 0.5.5 (2026-10-08)
|
|
512
536
|
* (ipod86) fix: live preview video no longer gets stretched/distorted — AgentDVR's live stream squishes the full picture into a fixed container format regardless of the camera's actual aspect ratio; now corrected (`object-fit:fill`) instead of shown distorted
|
|
513
537
|
* (ipod86) feat: configurable live-tile refresh interval (`widgetLiveRefreshSec`) — trade thumbnail freshness against keeping an open video modal open, since rewriting the widget's HTML state resets it
|
|
@@ -517,16 +541,6 @@ e.g. `http://192.168.1.10:8082/agent-dvr.0/photos/cam_8_Reolink/grab1.jpg` (also
|
|
|
517
541
|
|
|
518
542
|
<!-- markdownlint-disable-next-line MD024 -->
|
|
519
543
|
|
|
520
|
-
### 0.5.4 (2026-10-08)
|
|
521
|
-
* (ipod86) fix: single-camera live widget snapshot never refreshed (missing cache-busting timestamp + signature-based dedup skipped rewriting the state)
|
|
522
|
-
* (ipod86) fix: live video element now receives the correct aspect ratio instead of the browser's default placeholder box before playback starts
|
|
523
|
-
* (ipod86) fix: live/recording video no longer gets stretched to fill a mismatched aspect-ratio box — degrades to letterboxing (`object-fit:contain`) instead
|
|
524
|
-
|
|
525
|
-
<!-- markdownlint-disable-next-line MD024 -->
|
|
526
|
-
|
|
527
|
-
### 0.5.3 (2026-10-04)
|
|
528
|
-
* (ipod86) fix: clear ensuredFolders cache on object deletion to prevent stale "no existing object" warnings for rediscovered drives/cameras
|
|
529
|
-
|
|
530
544
|
[Older changelog entries in CHANGELOG_OLD.md](CHANGELOG_OLD.md)
|
|
531
545
|
|
|
532
546
|
## License
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
var De=Object.defineProperty;var he=n=>{throw TypeError(n)};var Be=(n,t,e)=>t in n?De(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e;var te=(n,t,e)=>Be(n,typeof t!="symbol"?t+"":t,e),ne=(n,t,e)=>t.has(n)||he("Cannot "+e);var a=(n,t,e)=>(ne(n,t,"read from private field"),e?e.call(n):t.get(n)),y=(n,t,e)=>t.has(n)?he("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(n):t.set(n,e),v=(n,t,e,i)=>(ne(n,t,"write to private field"),i?i.call(n,e):t.set(n,e),e),f=(n,t,e)=>(ne(n,t,"access private method"),e);var me="iob-dialog-close";var ge="iob-change";function K(n){return!!n.form}var be=["header","staticText","divider"];function w(n,t){return n==null?"":typeof n=="object"?n[t]||n.en||Object.values(n).find(e=>!!e)||"":String(n)}function X(n){let t={};for(let[e,i]of Object.entries(n.items||{}))i&&!be.includes(i.type)&&(t[e]=i.type);return t}function xe(n){return typeof n=="string"?n:typeof n=="number"||typeof n=="boolean"?n.toString():JSON.stringify(n)}function Pe(n,t){if(t!=null)switch(n){case"number":case"slider":{if(typeof t=="number")return Number.isFinite(t)?t:void 0;let e=xe(t).trim().replace(",",".");if(!e)return;let i=Number(e);return Number.isFinite(i)?i:void 0}case"checkbox":return t===!0||t==="true"||t===1||t==="1";default:return xe(t)}}function J(n,t){let e={};for(let[i,r]of Object.entries(n)){let o=Pe(r,t[i]);o!==void 0&&(e[i]=o)}return e}var we='"Roboto", "Helvetica", "Arial", sans-serif',Ve=Object.freeze({type:"light",primary:"#3399CC",primaryContrast:"#FFFFFF",secondary:"#164477",secondaryContrast:"#FFFFFF",background:"#FFFFFF",paper:"#FFFFFF",text:"rgba(0, 0, 0, 0.87)",textSecondary:"rgba(0, 0, 0, 0.6)",divider:"rgba(0, 0, 0, 0.12)",error:"#D32F2F",warning:"#ED6C02",info:"#0288D1",success:"#2E7D32",fontFamily:we,fontSize:14,borderRadius:4}),He=Object.freeze({type:"dark",primary:"#4DABF5",primaryContrast:"rgba(0, 0, 0, 0.87)",secondary:"#436A93",secondaryContrast:"#FFFFFF",background:"#121212",paper:"#121212",text:"#FFFFFF",textSecondary:"rgba(255, 255, 255, 0.7)",divider:"rgba(255, 255, 255, 0.12)",error:"#F44336",warning:"#FFA726",info:"#29B6F6",success:"#66BB6A",fontFamily:we,fontSize:14,borderRadius:4}),ie=["primary","primaryContrast","secondary","secondaryContrast","background","paper","text","textSecondary","divider","error","warning","info","success","fontFamily"],re=["fontSize","borderRadius"];function ye(n){return{...n==="dark"?He:Ve}}function P(n){if(!n||typeof n!="object")return ye(typeof n=="string"?n:"light");let t=n,e=ye(typeof t.type=="string"?t.type:"light");for(let i of ie){let r=t[i];typeof r=="string"&&r.trim()&&(e[i]=r.trim())}for(let i of re){let r=t[i],o=typeof r=="string"?parseFloat(r):r;typeof o=="number"&&Number.isFinite(o)&&o>=0&&(e[i]=o)}return e}function Se(n,t){return n.type===t.type&&ie.every(e=>n[e]===t[e])&&re.every(e=>n[e]===t[e])}function ve(n){return`--iob-${n.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}`}function Y(n){let t={};for(let e of ie)t[ve(e)]=n[e];for(let e of re)t[ve(e)]=`${n[e]}px`;return t["color-scheme"]=n.type,t}var Ee={ok:{en:"OK","zh-cn":"\u786E\u5B9A"},cancel:{en:"Cancel",de:"Abbrechen",ru:"\u041E\u0442\u043C\u0435\u043D\u0430",pt:"Cancelar",nl:"Annuleren",fr:"Annuler",it:"Annulla",es:"Cancelar",pl:"Anuluj",uk:"\u0421\u043A\u0430\u0441\u0443\u0432\u0430\u0442\u0438","zh-cn":"\u53D6\u6D88"},close:{en:"Close",de:"Schlie\xDFen",ru:"\u0417\u0430\u043A\u0440\u044B\u0442\u044C",pt:"Fechar",nl:"Sluiten",fr:"Fermer",it:"Chiudi",es:"Cerrar",pl:"Zamknij",uk:"\u0417\u0430\u043A\u0440\u0438\u0442\u0438","zh-cn":"\u5173\u95ED"}},We=`
|
|
2
|
+
dialog {
|
|
3
|
+
box-sizing: border-box;
|
|
4
|
+
width: 480px;
|
|
5
|
+
max-width: calc(100vw - 32px);
|
|
6
|
+
max-height: calc(100vh - 32px);
|
|
7
|
+
padding: 0;
|
|
8
|
+
border: 0;
|
|
9
|
+
border-radius: calc(var(--iob-border-radius) * 2);
|
|
10
|
+
background: var(--iob-paper);
|
|
11
|
+
color: var(--iob-text);
|
|
12
|
+
font-family: var(--iob-font-family);
|
|
13
|
+
font-size: var(--iob-font-size);
|
|
14
|
+
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
|
|
15
|
+
}
|
|
16
|
+
/* as the dialogs of MUI: a dark paper gets lighter the higher it lies */
|
|
17
|
+
dialog.dark { background-image: linear-gradient(rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.16)); }
|
|
18
|
+
dialog::backdrop { background: rgba(0, 0, 0, 0.5); }
|
|
19
|
+
dialog:focus { outline: none; }
|
|
20
|
+
form { display: flex; flex-direction: column; height: 100%; max-height: inherit; margin: 0; }
|
|
21
|
+
header { display: flex; align-items: center; gap: 8px; padding: 12px 8px 12px 16px; font-size: 1.15em; font-weight: 500; }
|
|
22
|
+
header span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
23
|
+
.body { flex: 1; min-height: 0; padding: 0 16px 16px; overflow: auto; display: flex; flex-direction: column; gap: 12px; }
|
|
24
|
+
footer { display: flex; justify-content: flex-end; gap: 8px; padding: 0 16px 16px; }
|
|
25
|
+
button { font: inherit; padding: 6px 16px; border-radius: var(--iob-border-radius); border: 1px solid var(--iob-primary); background: transparent; color: var(--iob-primary); cursor: pointer; }
|
|
26
|
+
button.primary { background: var(--iob-primary); color: var(--iob-primary-contrast); }
|
|
27
|
+
button.close { border: 0; padding: 2px 8px; font-size: 1.4em; line-height: 1; color: var(--iob-text-secondary); }
|
|
28
|
+
label { display: flex; flex-direction: column; gap: 4px; }
|
|
29
|
+
label.check { flex-direction: row; align-items: center; gap: 8px; }
|
|
30
|
+
input, select, textarea { font: inherit; accent-color: var(--iob-primary); }
|
|
31
|
+
.help { color: var(--iob-text-secondary); font-size: 0.85em; }
|
|
32
|
+
h3 { margin: 4px 0 0; font-size: 1em; }
|
|
33
|
+
p { margin: 0; }
|
|
34
|
+
hr { width: 100%; border: 0; border-top: 1px solid var(--iob-divider); margin: 0; }
|
|
35
|
+
[hidden] { display: none !important; }
|
|
36
|
+
`;function Ce(n){if(!n)return null;try{let t=new Function("data",`return (${n});`);return e=>{try{return!!t(e)}catch{return!1}}}catch{return null}}function oe(n){return typeof n=="string"?n:typeof n=="number"||typeof n=="boolean"?String(n):""}function Ge(n){let{input:t,setting:e}=n;if(t)return t instanceof HTMLInputElement&&t.type==="checkbox"?t.checked:t instanceof HTMLSelectElement?e.options?.[t.selectedIndex]?.value:t.value}function Ue(n,t,e,i,r){let o={name:t,setting:e,box:n.createElement("div"),hidden:Ce(e.hidden),disabled:Ce(e.disabled)},m=w(e.label,r);switch(e.type){case"header":return o.box=n.createElement("h3"),o.box.textContent=w(e.text,r)||m,o;case"staticText":return o.box=n.createElement("p"),o.box.textContent=w(e.text,r)||m,o;case"divider":return o.box=n.createElement("hr"),o;default:break}let u=n.createElement("label");o.box=u;let l=n.createElement("span");if(l.textContent=m||t,e.type==="checkbox"){let s=n.createElement("input");s.type="checkbox",s.checked=i===!0||i==="true",u.className="check",u.append(s,l),o.input=s}else if(e.type==="select"){let s=n.createElement("select");for(let d of e.options||[]){let p=n.createElement("option");p.textContent=w(d.label,r),s.append(p)}let h=(e.options||[]).findIndex(d=>String(d.value)===oe(i));s.selectedIndex=h===-1?0:h,u.append(l,s),o.input=s}else if(e.type==="text"&&(e.minRows||1)>1){let s=n.createElement("textarea");s.rows=e.minRows||2,s.value=oe(i),u.append(l,s),o.input=s}else{let s=n.createElement("input"),h=oe(i);switch(e.type){case"number":case"slider":s.type=e.type==="slider"?"range":"number",e.min!==void 0&&(s.min=String(e.min)),e.max!==void 0&&(s.max=String(e.max)),s.step=e.step!==void 0?String(e.step):"any";break;case"password":s.type="password";break;case"color":s.type=!h||/^#[0-9a-f]{6}$/i.test(h)?"color":"text";break;default:s.type="text";break}if(s.value=h,s.type==="range"){let d=n.createElement("output");d.textContent=s.value,s.addEventListener("input",()=>d.textContent=s.value),l.append(": ",d)}u.append(l,s),o.input=s}if(e.help){let s=n.createElement("span");s.className="help",s.textContent=w(e.help,r),u.append(s)}return o}function ke(n,t={}){let e=t.lang||"en",i=document,r=C=>Ee[C][e]||Ee[C].en||C,o=i.createElement("div");o.setAttribute("data-iob-dialog","");let m=o.attachShadow({mode:"open"}),u=i.createElement("style");u.textContent=We;let l=i.createElement("dialog"),s=P(t.theme);l.className=s.type==="dark"?"dark":"";for(let[C,O]of Object.entries(Y(s)))l.style.setProperty(C,O);n.width&&(l.style.width=`${n.width}px`),n.height&&(l.style.height=`${n.height}px`);let h=i.createElement("form"),d=i.createElement("header"),p=i.createElement("span");p.textContent=w(n.title,e);let b=i.createElement("button");b.type="button",b.className="close",b.title=r("close"),b.setAttribute("aria-label",r("close")),b.textContent="\xD7",d.append(p,b);let S=i.createElement("div");return S.className="body",h.append(d,S),l.append(h),m.append(u,l),new Promise(C=>{let O=!1,B=_=>{O||(O=!0,l.open&&l.close(),o.remove(),C(_))};if(b.addEventListener("click",()=>B(null)),l.addEventListener("close",()=>B(null)),h.addEventListener("submit",_=>_.preventDefault()),K(n)){let _={},W=[];for(let[x,E]of Object.entries(n.form.items||{})){let Ie=n.data?.[x]??E.default,ue=Ue(i,x,E,Ie,e);W.push(ue),S.append(ue.box)}let de=()=>{for(let x of W)x.input&&(_[x.name]=Ge(x));return _},ee=()=>{let x=de();for(let E of W)E.box.hidden=E.hidden?E.hidden(x):!1,E.input&&(E.input.disabled=E.disabled?E.disabled(x):!1)};h.addEventListener("input",ee),h.addEventListener("change",ee),ee();let pe=W.find(x=>x.input&&!x.box.hidden&&!x.input.disabled);pe?.input&&(pe.input.autofocus=!0);let fe=i.createElement("footer"),G=i.createElement("button");G.type="button",G.textContent=w(n.cancel,e)||r("cancel"),G.addEventListener("click",()=>B(null));let U=i.createElement("button");U.type="submit",U.className="primary",U.textContent=w(n.ok,e)||r("ok"),fe.append(G,U),h.append(fe),h.addEventListener("submit",()=>B(J(X(n.form),de())))}else S.append(n.element),l.addEventListener(me,_=>B(_.detail??null));i.body.append(o),l.showModal(),(!m.activeElement||m.activeElement===b)&&(l.tabIndex=-1,l.focus())})}function Te(n){return[...new Set(n.filter(t=>typeof t=="string"&&!!t))]}var Ke=["socket","dialogs","theme","editMode","settings","value"],k,A,$,T,z,M,g,I,D,H,c,se,R,V,Fe,_e,ae,ce,j,Z=class extends HTMLElement{constructor(){super(...arguments);y(this,c);te(this,"states",{});te(this,"objects",{});y(this,k,null);y(this,A,{});y(this,$,P("light"));y(this,T,!1);y(this,z,null);y(this,M);y(this,g,null);y(this,I,!1);y(this,D,(e,i)=>{a(this,g)?.states.includes(e)&&(this.states[e]=i||null,f(this,c,j).call(this))});y(this,H,(e,i)=>{a(this,g)?.objects.includes(e)&&(this.objects[e]=i||null,f(this,c,R).call(this))})}get socket(){return a(this,k)}set socket(e){v(this,k,e||null),f(this,c,R).call(this)}get settings(){return a(this,A)}set settings(e){v(this,A,e||{}),f(this,c,R).call(this)}get theme(){return a(this,$)}set theme(e){let i=P(e);Se(i,a(this,$))||(v(this,$,i),f(this,c,se).call(this),f(this,c,j).call(this))}get editMode(){return a(this,T)}set editMode(e){let i=!!e;i!==a(this,T)&&(v(this,T,i),f(this,c,j).call(this))}get dialogs(){return a(this,z)}set dialogs(e){v(this,z,e||null)}get value(){return a(this,M)}set value(e){e!==a(this,M)&&(v(this,M,e),f(this,c,j).call(this))}connectedCallback(){for(let e of Ke)if(Object.prototype.hasOwnProperty.call(this,e)){let i=this[e];delete this[e],this[e]=i}f(this,c,se).call(this),f(this,c,R).call(this)}disconnectedCallback(){f(this,c,ce).call(this)}getStateIds(e){return[]}getObjectIds(e){return[]}get systemLang(){return a(this,k)?.systemLang||"en"}text(e){return w(e,this.systemLang)}setState(e,i){return a(this,k)&&!a(this,T)?a(this,k).setState(e,i):Promise.resolve()}changeValue(e){return a(this,T)||this.emit(ge,e)?!1:(this.value=e,!0)}emit(e,i){return this.dispatchEvent(new CustomEvent(e,{detail:i,bubbles:!0,composed:!0,cancelable:!0}))}async openDialog(e){if(a(this,T))return null;let i=a(this,z)?await a(this,z).open(e):await ke(e,{lang:this.systemLang,theme:a(this,$)});return K(e)?i&&typeof i=="object"?J(X(e.form),i):null:i??null}};k=new WeakMap,A=new WeakMap,$=new WeakMap,T=new WeakMap,z=new WeakMap,M=new WeakMap,g=new WeakMap,I=new WeakMap,D=new WeakMap,H=new WeakMap,c=new WeakSet,se=function(){for(let[e,i]of Object.entries(Y(a(this,$))))this.style.setProperty(e,i)},R=function(){if(!this.isConnected)return;let e=a(this,k),i=e?Te(this.getStateIds(a(this,A))):[],r=e?Te(this.getObjectIds(a(this,A))):[];a(this,g)&&a(this,g).socket!==e&&f(this,c,ce).call(this);let o=a(this,g)?.states||[],m=a(this,g)?.objects||[],u=o.filter(d=>!i.includes(d)),l=m.filter(d=>!r.includes(d)),s=i.filter(d=>!o.includes(d)),h=r.filter(d=>!m.includes(d));e&&u.length&&e.unsubscribeState(u,a(this,D)),e&&l.length&&f(this,c,ae).call(this,e,l);for(let d of u)delete this.states[d];for(let d of[...u,...l])!i.includes(d)&&!r.includes(d)&&delete this.objects[d];v(this,g,e&&(i.length||r.length)?{socket:e,states:i,objects:r}:null),e&&s.length&&f(this,c,Fe).call(this,e,s),e&&h.length&&f(this,c,_e).call(this,e,h),f(this,c,j).call(this)},V=function(e,i,r){return a(this,g)?.socket===e&&a(this,g)[i].includes(r)},Fe=function(e,i){e.subscribeState(i,a(this,D)).catch(r=>console.warn(`<${this.localName}>: cannot subscribe ${i.join(", ")}: ${r}`));for(let r of i)e.getState(r).then(o=>{f(this,c,V).call(this,e,"states",r)&&this.states[r]===void 0&&(this.states[r]=o||null,f(this,c,j).call(this))}).catch(()=>{}),e.getObject(r).then(o=>{f(this,c,V).call(this,e,"states",r)&&!f(this,c,V).call(this,e,"objects",r)&&(this.objects[r]=o||null,f(this,c,j).call(this))}).catch(()=>{})},_e=function(e,i){e.subscribeObject(i,a(this,H)).catch(r=>console.warn(`<${this.localName}>: cannot subscribe the objects ${i.join(", ")}: ${r}`));for(let r of i)e.getObject(r).then(o=>{f(this,c,V).call(this,e,"objects",r)&&(this.objects[r]=o||null,f(this,c,R).call(this))}).catch(()=>{})},ae=function(e,i){e.unsubscribeObject(i,a(this,H)).catch(()=>{})},ce=function(){if(a(this,g)){let{socket:e,states:i,objects:r}=a(this,g);i.length&&e.unsubscribeState(i,a(this,D)),r.length&&f(this,c,ae).call(this,e,r),v(this,g,null)}this.states={},this.objects={}},j=function(){a(this,I)||(v(this,I,!0),queueMicrotask(()=>{v(this,I,!1),this.isConnected&&this.render()}))};function je(n,t){let e=typeof n=="string"?n:n.tag;customElements.get(e)||customElements.define(e,t)}var N={widgetMode:"nojs",count:50,thumbSize:"medium",minCol:150,maxModalWidth:900,showTags:!0,tagPosition:"bottom-left",sortNewest:!0,showSearch:!0,defaultTag:"",compact:!1,playerUrl:"",liveAspect:"",liveRefreshSec:0,colorCardBg:"rgba(127,127,127,0.15)",colorTagBg:"rgba(0,0,0,0.55)",colorTagText:"#ffffff",colorAccent:"#8ab4f8",colorModalBg:"#1c1c1e",borderRadius:8},Xe={small:120,medium:180,large:240},L={pickWidget:{en:"Please choose a widget in the settings.",de:"Bitte in den Einstellungen ein Widget ausw\xE4hlen."},pickCamera:{en:"Please choose a camera in the settings.",de:"Bitte in den Einstellungen eine Kamera ausw\xE4hlen."},pickInstance:{en:"Please choose an agent-dvr instance in the settings.",de:"Bitte in den Einstellungen eine agent-dvr-Instanz ausw\xE4hlen."},waiting:{en:"Waiting for data of the adapter \u2026",de:"Warte auf Daten des Adapters \u2026"},noCamera:{en:"Camera not found",de:"Kamera nicht gefunden"},noCameras:{en:"No cameras",de:"Keine Kameras"}},$e={en:{noRecordings:"No recordings",search:"Search \u2026",all:"All",download:"Download",live:"LIVE"},de:{noRecordings:"Keine Aufnahmen",search:"Suche \u2026",all:"Alle",download:"Herunterladen",live:"LIVE"}};function F(n){return String(n??"").replace(/[&<>"]/g,t=>({"&":"&","<":"<",">":">",'"':"""})[t])}function Le(n){let t=String(n||"").replace(/^system\.adapter\./,"").split(".");return{instance:t.length>=2?`${t[0]}.${t[1]}`:"",camera:t.length>=3&&/^cam_/.test(t[2])?t[2]:""}}function Oe(n){let t=n&&n.val;if(typeof t!="string"||!t)return null;try{return JSON.parse(t)}catch{return null}}function Ae(n,t){if(n.mode==="custom"){let e={...N};for(let[i,r]of Object.entries(n))r!=null&&(e[i]=r);return e.minCol=Xe[e.thumbSize]||Number(e.minCol)||150,e}return!t||!t.settings?null:{...N,...t.settings}}function ze(n,t){return{...$e[t]||$e.en,...n&&n.labels||{}}}function Ne(n,t,e){let i=n.compact?6:12,r=`${Math.max(0,Number(n.borderRadius)||0)}px`,o=t?{card:"color-mix(in srgb, var(--iob-text, currentColor) 10%, transparent)",tagBg:"var(--iob-primary)",tagText:"var(--iob-primary-contrast)",accent:"var(--iob-primary)",modal:"var(--iob-paper)",info:"var(--iob-text)"}:{card:n.colorCardBg||N.colorCardBg,tagBg:n.colorTagBg||N.colorTagBg,tagText:n.colorTagText||N.colorTagText,accent:n.colorAccent||N.colorAccent,modal:n.colorModalBg||N.colorModalBg,info:"#fff"};return`:host{display:block;width:100%;height:100%;overflow:hidden;color:inherit;font:inherit}.root{--adv-card-bg:${o.card};--adv-tag-bg:${o.tagBg};--adv-tag-color:${o.tagText};--adv-accent:${o.accent};--adv-radius:${r};width:100%;height:100%;box-sizing:border-box;overflow:auto;${e?"pointer-events:none;":""}}.bar{display:flex;flex-wrap:wrap;gap:8px;align-items:center;margin-bottom:10px}.search{flex:1 1 160px;min-width:120px;padding:6px 10px;border-radius:8px;border:1px solid rgba(127,127,127,.4);background:rgba(127,127,127,.08);color:inherit;font:inherit}.tags{display:flex;flex-wrap:wrap;gap:6px}.tagbtn{padding:4px 10px;border-radius:999px;border:1px solid rgba(127,127,127,.4);background:transparent;color:inherit;cursor:pointer;font:inherit;font-size:.8rem}.tagbtn.on{background:var(--adv-accent);color:${t?"var(--iob-primary-contrast)":"#fff"};border-color:var(--adv-accent)}.grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(${Number(n.minCol)||150}px,1fr));gap:${i}px}.fitted{overflow:hidden;display:flex;align-items:center;justify-content:center}.fitted .grid{justify-content:center;align-content:center}.cell{display:flex;flex-direction:column;cursor:pointer;min-width:0}.img{position:relative;display:block;border-radius:var(--adv-radius);overflow:hidden;background:var(--adv-card-bg)}.img img{width:100%;height:auto;display:block}.img.fix img{height:100%;object-fit:cover}.tag{position:absolute;background:var(--adv-tag-bg);color:var(--adv-tag-color);font-size:.6rem;padding:2px 4px;border-radius:3px;line-height:1;max-width:85%;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.play{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;opacity:0;transition:opacity .15s;background:rgba(0,0,0,.2)}.play::before{content:"";border-style:solid;border-width:11px 0 11px 18px;border-color:transparent transparent transparent #fff;filter:drop-shadow(0 1px 2px rgba(0,0,0,.6))}.cell:hover .play{opacity:1}.cap{font-size:${n.compact?".65rem":".72rem"};margin-top:${n.compact?2:4}px;line-height:1.25;opacity:.85;overflow:hidden;text-overflow:ellipsis}.empty,.msg{padding:24px;text-align:center;opacity:.7}.single{height:100%;display:flex;flex-direction:column}.single .cell{flex:1 1 auto;min-height:0}.single .img{flex:1 1 auto;min-height:0}.single .img img{width:100%;height:100%;object-fit:contain}dialog{border:0;padding:12px;border-radius:14px;background:${o.modal};max-width:min(92vw,${Number(n.maxModalWidth)||900}px);width:min(92vw,${Number(n.maxModalWidth)||900}px);box-sizing:border-box;box-shadow:0 16px 48px rgba(0,0,0,.55),0 0 0 1px rgba(255,255,255,.08);overflow:visible}dialog::backdrop{background:rgba(0,0,0,.35)}.box{position:relative;display:flex;flex-direction:column;gap:8px}video{width:100%;max-height:80vh;border-radius:8px;background:#000;display:block;object-fit:contain}.close{position:absolute;top:6px;right:6px;width:32px;height:32px;border-radius:50%;background:rgba(0,0,0,.65);color:#fff;display:flex;align-items:center;justify-content:center;cursor:pointer;font-size:15px;z-index:2;border:2px solid rgba(255,255,255,.35)}.info{color:${o.info};font-size:.8rem;text-align:center}.info a{color:var(--adv-accent)}`}function Re(n){let t=document.createElement("dialog");t.innerHTML='<div class="box"><span class="close" role="button" aria-label="close">✕</span><video controls preload="none" playsinline></video><div class="info"></div></div>';let e=t.querySelector("video"),i=t.querySelector(".info"),r=()=>t.open&&t.close();return t.querySelector(".close").addEventListener("click",r),t.addEventListener("click",o=>o.target===t&&r()),t.addEventListener("close",()=>{try{e.pause()}catch{}e.removeAttribute("src"),e.removeAttribute("style");try{e.load()}catch{}}),n.appendChild(t),{el:t,open(o,m,u){u&&(e.style.aspectRatio=u.replace("/"," / "),e.style.objectFit="fill"),e.setAttribute("src",o),i.innerHTML=m,t.open||t.showModal(),e.play&&e.play().catch(()=>{})}}}function Me(n,t,e){let i=n.aspect||t.liveAspect||"",r=i?String(i).replace("/"," / "):"";return`<div class="cell" data-cam="${F(n.id)}"><span class="img${r?" fix":""}"${r?` style="aspect-ratio:${F(r)}"`:""}><img class="snap" alt="" src="${F(`${n.snapshot}&ts=${Date.now()}`)}" data-base="${F(n.snapshot)}"><span class="tag" style="top:5px;left:5px">● ${F(e.live)}</span><span class="play"></span></span><span class="cap">${F(n.name)}</span></div>`}var Q=class{constructor(t){this.root=t,this.timer=null,this.sec=0}set(t){t=Math.max(0,Number(t)||0),!(t===this.sec&&(this.timer||!t))&&(this.stop(),this.sec=t,t>0&&(this.timer=setInterval(()=>{for(let e of this.root.querySelectorAll("img.snap")){let i=e.getAttribute("data-base");i&&(e.src=`${i}&ts=${Date.now()}`)}},t*1e3)))}stop(){clearInterval(this.timer),this.timer=null,this.sec=0}};var q=class extends Z{constructor(){super(),this.attachShadow({mode:"open"}),this.shadowRoot.innerHTML='<style></style><div class="root"></div>',this._player=Re(this.shadowRoot),this._timer=new Q(this.shadowRoot),this._key="",this._cams=[],this._cfg=null}_target(t){return{instance:"",camera:"",missing:L.pickInstance}}_single(){return!1}getStateIds(t){let e=this._target(t);return e.instance?[`${e.instance}.widget_config`]:[]}render(){let t=this.settings||{},e=this._target(t),i=this.shadowRoot.querySelector(".root"),r=e.instance?Oe(this.states[`${e.instance}.widget_config`]):null,o=Ae(t,r),m=this.shadowRoot.querySelector("style"),u=Ne(o||{},!!t.follow,this.editMode);if(m.textContent!==u&&(m.textContent=u),e.missing)return this._msg(i,this.text(e.missing));if(!o||!r||!Array.isArray(r.cameras))return this._msg(i,this.text(L.waiting));let l=e.camera?r.cameras.filter(p=>p.id===e.camera):r.cameras,s=JSON.stringify([o,l,r.labels,this.systemLang]);if(this._timer.set(o.liveRefreshSec),s===this._key)return;if(this._key=s,this._cfg=o,this._cams=l,!l.length)return this._msg(i,this.text(e.camera?L.noCamera:L.noCameras));let h=ze(r,this.systemLang),d=l.map(p=>Me(p,o,h)).join("");if(i.innerHTML=this._single()?`<div class="single">${d}</div>`:`<div class="grid">${d}</div>`,this._single()){let p=i.querySelector(".img");p&&p.removeAttribute("style"),p&&p.classList.remove("fix")}for(let p of i.querySelectorAll(".cell"))p.addEventListener("click",()=>this._open(p.getAttribute("data-cam")));this._fit()}_fits(){return!this._single()&&(this.settings||{}).fit!==!1}_fit(){let t=this.shadowRoot.querySelector(".root"),e=t&&t.querySelector(".grid");if(!this._fits()||!e){t&&t.classList.remove("fitted");return}!this._ro&&typeof ResizeObserver<"u"&&(this._ro=new ResizeObserver(()=>this._fit()),this._ro.observe(t));let i=getComputedStyle(t),r=t.clientWidth-parseFloat(i.paddingLeft)-parseFloat(i.paddingRight),o=t.clientHeight-parseFloat(i.paddingTop)-parseFloat(i.paddingBottom),m=e.children.length;if(!m||r<=0||o<=0)return;let u=parseFloat(getComputedStyle(e).rowGap)||8,l=e.querySelector(".cap"),s=l?l.getBoundingClientRect().height+(parseFloat(getComputedStyle(l).marginTop)||0):0,h=0;for(let p of this._cams){let b=String(p.aspect||this._cfg.liveAspect||"16/9").split(/[/:x]/),S=Number(b[1])/Number(b[0]);h=Math.max(h,S>0&&isFinite(S)?S:9/16)}let d={cols:1,w:0};for(let p=1;p<=m;p++){let b=Math.ceil(m/p),S=(r-(p-1)*u)/p,C=((o-(b-1)*u)/b-s)/h,O=Math.floor(Math.min(S,C));O>d.w&&(d={cols:p,w:O})}if(d.w<40){t.classList.remove("fitted"),e.style.gridTemplateColumns="";return}t.classList.add("fitted"),e.style.gridTemplateColumns=`repeat(${d.cols}, ${d.w}px)`}_msg(t,e){this._key="",this._timer.stop(),t.innerHTML=`<div class="msg">${F(e)}</div>`}_open(t){let e=this._cams.find(i=>i.id===t);!e||this.editMode||this._player.open(e.live,`${F(e.name)} · Live`,e.aspect||this._cfg.liveAspect||"")}connectedCallback(){super.connectedCallback&&super.connectedCallback(),this._key=""}disconnectedCallback(){super.disconnectedCallback&&super.disconnectedCallback(),this._timer.stop(),this._player.el.open&&this._player.el.close(),this._ro&&this._ro.disconnect(),this._ro=null}};var le=class extends q{_target(t){let e=Le(t.mode==="custom"?t.camera:t.widget),i=e.instance&&e.camera?null:t.mode==="custom"?L.pickCamera:L.pickWidget;return{...e,missing:i}}_single(){return!0}};je("iob-agent-dvr-live",le);
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://raw.githubusercontent.com/ioBroker/web-components/main/schemas/manifest.json",
|
|
3
|
+
"manifestVersion": 1,
|
|
4
|
+
"tag": "iob-agent-dvr-live",
|
|
5
|
+
"name": {
|
|
6
|
+
"en": "Agent DVR live camera",
|
|
7
|
+
"de": "Agent DVR Live-Kamera"
|
|
8
|
+
},
|
|
9
|
+
"description": {
|
|
10
|
+
"en": "Live tile of a camera, opens the live stream: from the adapter settings or set up here",
|
|
11
|
+
"de": "Live-Kachel einer Kamera, öffnet den Livestream: aus den Adapter-Einstellungen oder hier eingestellt"
|
|
12
|
+
},
|
|
13
|
+
"icon": "../agent-dvr.png",
|
|
14
|
+
"module": "agent-dvr-live.js",
|
|
15
|
+
"size": {
|
|
16
|
+
"width": 400,
|
|
17
|
+
"height": 260
|
|
18
|
+
},
|
|
19
|
+
"settings": {
|
|
20
|
+
"type": "panel",
|
|
21
|
+
"items": {
|
|
22
|
+
"mode": {
|
|
23
|
+
"type": "select",
|
|
24
|
+
"label": {
|
|
25
|
+
"en": "Source",
|
|
26
|
+
"de": "Quelle"
|
|
27
|
+
},
|
|
28
|
+
"default": "adapter",
|
|
29
|
+
"options": [
|
|
30
|
+
{
|
|
31
|
+
"value": "adapter",
|
|
32
|
+
"label": {
|
|
33
|
+
"en": "Widget from the adapter settings",
|
|
34
|
+
"de": "Widget aus den Adapter-Einstellungen"
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"value": "custom",
|
|
39
|
+
"label": {
|
|
40
|
+
"en": "Own settings here",
|
|
41
|
+
"de": "Eigene Einstellungen hier"
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
]
|
|
45
|
+
},
|
|
46
|
+
"widget": {
|
|
47
|
+
"type": "objectId",
|
|
48
|
+
"types": "state",
|
|
49
|
+
"root": "agent-dvr",
|
|
50
|
+
"label": {
|
|
51
|
+
"en": "Widget",
|
|
52
|
+
"de": "Widget"
|
|
53
|
+
},
|
|
54
|
+
"help": {
|
|
55
|
+
"en": "The live widget of a camera, e.g. agent-dvr.0.cam_8_Garden.widget_live",
|
|
56
|
+
"de": "Live-Widget einer Kamera, z. B. agent-dvr.0.cam_8_Garten.widget_live"
|
|
57
|
+
},
|
|
58
|
+
"hidden": "data.mode === 'custom'"
|
|
59
|
+
},
|
|
60
|
+
"camera": {
|
|
61
|
+
"type": "objectId",
|
|
62
|
+
"types": "device",
|
|
63
|
+
"root": "agent-dvr",
|
|
64
|
+
"label": {
|
|
65
|
+
"en": "Camera",
|
|
66
|
+
"de": "Kamera"
|
|
67
|
+
},
|
|
68
|
+
"help": {
|
|
69
|
+
"en": "Choose the camera, e.g. agent-dvr.0.cam_8_Garden",
|
|
70
|
+
"de": "Kamera wählen, z. B. agent-dvr.0.cam_8_Garten"
|
|
71
|
+
},
|
|
72
|
+
"hidden": "data.mode !== 'custom'"
|
|
73
|
+
},
|
|
74
|
+
"follow": {
|
|
75
|
+
"type": "checkbox",
|
|
76
|
+
"label": {
|
|
77
|
+
"en": "Use the colors of the visualization",
|
|
78
|
+
"de": "Farben der Visualisierung übernehmen"
|
|
79
|
+
},
|
|
80
|
+
"default": false,
|
|
81
|
+
"help": {
|
|
82
|
+
"en": "Tiles, badges, player and accent in the colors of the theme instead of the widget colors",
|
|
83
|
+
"de": "Kacheln, Badges, Player und Akzent in den Farben des Themes statt der Widget-Farben"
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
"hLive": {
|
|
87
|
+
"type": "header",
|
|
88
|
+
"text": {
|
|
89
|
+
"en": "Live Widget",
|
|
90
|
+
"de": "Live-Widget"
|
|
91
|
+
},
|
|
92
|
+
"size": 5,
|
|
93
|
+
"hidden": "data.mode !== 'custom'"
|
|
94
|
+
},
|
|
95
|
+
"liveAspect": {
|
|
96
|
+
"type": "text",
|
|
97
|
+
"label": {
|
|
98
|
+
"en": "Live tile aspect ratio (e.g. 16/9)",
|
|
99
|
+
"de": "Seitenverhältnis Live-Kachel (z. B. 16/9)"
|
|
100
|
+
},
|
|
101
|
+
"default": "",
|
|
102
|
+
"hidden": "data.mode !== 'custom'",
|
|
103
|
+
"help": {
|
|
104
|
+
"en": "Used when the adapter could not detect the resolution of the camera. Empty = automatic",
|
|
105
|
+
"de": "Gilt, wenn der Adapter die Auflösung der Kamera nicht erkennen konnte. Leer = automatisch"
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
"liveRefreshSec": {
|
|
109
|
+
"type": "number",
|
|
110
|
+
"label": {
|
|
111
|
+
"en": "Snapshot refresh interval (s, 0 = never)",
|
|
112
|
+
"de": "Aktualisierung Vorschaubild (s, 0 = nie)"
|
|
113
|
+
},
|
|
114
|
+
"min": 0,
|
|
115
|
+
"max": 3600,
|
|
116
|
+
"default": 0,
|
|
117
|
+
"hidden": "data.mode !== 'custom'",
|
|
118
|
+
"help": {
|
|
119
|
+
"en": "Only the image is refreshed in the browser – an open player never closes",
|
|
120
|
+
"de": "Nur das Bild wird im Browser erneuert – ein offener Player schließt sich nie"
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
"compact": {
|
|
124
|
+
"type": "checkbox",
|
|
125
|
+
"label": {
|
|
126
|
+
"en": "Compact layout",
|
|
127
|
+
"de": "Kompaktes Layout"
|
|
128
|
+
},
|
|
129
|
+
"default": false,
|
|
130
|
+
"hidden": "data.mode !== 'custom'",
|
|
131
|
+
"help": {
|
|
132
|
+
"en": "Smaller spacing and font – more entries at a glance",
|
|
133
|
+
"de": "Kleinere Abstände und Schrift – mehr Einträge auf einen Blick"
|
|
134
|
+
}
|
|
135
|
+
},
|
|
136
|
+
"maxModalWidth": {
|
|
137
|
+
"type": "number",
|
|
138
|
+
"label": {
|
|
139
|
+
"en": "Max. player width (px)",
|
|
140
|
+
"de": "Max. Player-Breite (px)"
|
|
141
|
+
},
|
|
142
|
+
"min": 300,
|
|
143
|
+
"max": 2000,
|
|
144
|
+
"default": 900,
|
|
145
|
+
"hidden": "data.mode !== 'custom'"
|
|
146
|
+
},
|
|
147
|
+
"hColors": {
|
|
148
|
+
"type": "header",
|
|
149
|
+
"text": {
|
|
150
|
+
"en": "Colors & Design",
|
|
151
|
+
"de": "Farben & Design"
|
|
152
|
+
},
|
|
153
|
+
"size": 5,
|
|
154
|
+
"hidden": "data.mode !== 'custom'"
|
|
155
|
+
},
|
|
156
|
+
"colorCardBg": {
|
|
157
|
+
"type": "color",
|
|
158
|
+
"label": {
|
|
159
|
+
"en": "Tile background",
|
|
160
|
+
"de": "Kachel-Hintergrund"
|
|
161
|
+
},
|
|
162
|
+
"default": "rgba(127,127,127,0.15)",
|
|
163
|
+
"hidden": "data.mode !== 'custom' || data.follow"
|
|
164
|
+
},
|
|
165
|
+
"colorTagBg": {
|
|
166
|
+
"type": "color",
|
|
167
|
+
"label": {
|
|
168
|
+
"en": "Tag badge background",
|
|
169
|
+
"de": "Tag-Badge-Hintergrund"
|
|
170
|
+
},
|
|
171
|
+
"default": "rgba(0,0,0,0.55)",
|
|
172
|
+
"hidden": "data.mode !== 'custom' || data.follow"
|
|
173
|
+
},
|
|
174
|
+
"colorTagText": {
|
|
175
|
+
"type": "color",
|
|
176
|
+
"label": {
|
|
177
|
+
"en": "Tag badge text color",
|
|
178
|
+
"de": "Tag-Badge-Textfarbe"
|
|
179
|
+
},
|
|
180
|
+
"default": "#ffffff",
|
|
181
|
+
"hidden": "data.mode !== 'custom' || data.follow"
|
|
182
|
+
},
|
|
183
|
+
"colorModalBg": {
|
|
184
|
+
"type": "color",
|
|
185
|
+
"label": {
|
|
186
|
+
"en": "Modal background",
|
|
187
|
+
"de": "Modal-Hintergrund"
|
|
188
|
+
},
|
|
189
|
+
"default": "#1c1c1e",
|
|
190
|
+
"hidden": "data.mode !== 'custom' || data.follow"
|
|
191
|
+
},
|
|
192
|
+
"borderRadius": {
|
|
193
|
+
"type": "number",
|
|
194
|
+
"label": {
|
|
195
|
+
"en": "Border radius (px)",
|
|
196
|
+
"de": "Eckenradius (px)"
|
|
197
|
+
},
|
|
198
|
+
"min": 0,
|
|
199
|
+
"max": 32,
|
|
200
|
+
"default": 8,
|
|
201
|
+
"hidden": "data.mode !== 'custom'",
|
|
202
|
+
"help": {
|
|
203
|
+
"en": "Corner radius of the tiles (0 = square)",
|
|
204
|
+
"de": "Abrundungsradius der Kacheln (0 = eckig)"
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
var De=Object.defineProperty;var he=n=>{throw TypeError(n)};var Be=(n,t,e)=>t in n?De(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e;var te=(n,t,e)=>Be(n,typeof t!="symbol"?t+"":t,e),ne=(n,t,e)=>t.has(n)||he("Cannot "+e);var a=(n,t,e)=>(ne(n,t,"read from private field"),e?e.call(n):t.get(n)),y=(n,t,e)=>t.has(n)?he("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(n):t.set(n,e),v=(n,t,e,i)=>(ne(n,t,"write to private field"),i?i.call(n,e):t.set(n,e),e),f=(n,t,e)=>(ne(n,t,"access private method"),e);var me="iob-dialog-close";var ge="iob-change";function K(n){return!!n.form}var be=["header","staticText","divider"];function w(n,t){return n==null?"":typeof n=="object"?n[t]||n.en||Object.values(n).find(e=>!!e)||"":String(n)}function X(n){let t={};for(let[e,i]of Object.entries(n.items||{}))i&&!be.includes(i.type)&&(t[e]=i.type);return t}function xe(n){return typeof n=="string"?n:typeof n=="number"||typeof n=="boolean"?n.toString():JSON.stringify(n)}function Pe(n,t){if(t!=null)switch(n){case"number":case"slider":{if(typeof t=="number")return Number.isFinite(t)?t:void 0;let e=xe(t).trim().replace(",",".");if(!e)return;let i=Number(e);return Number.isFinite(i)?i:void 0}case"checkbox":return t===!0||t==="true"||t===1||t==="1";default:return xe(t)}}function J(n,t){let e={};for(let[i,r]of Object.entries(n)){let o=Pe(r,t[i]);o!==void 0&&(e[i]=o)}return e}var we='"Roboto", "Helvetica", "Arial", sans-serif',Ve=Object.freeze({type:"light",primary:"#3399CC",primaryContrast:"#FFFFFF",secondary:"#164477",secondaryContrast:"#FFFFFF",background:"#FFFFFF",paper:"#FFFFFF",text:"rgba(0, 0, 0, 0.87)",textSecondary:"rgba(0, 0, 0, 0.6)",divider:"rgba(0, 0, 0, 0.12)",error:"#D32F2F",warning:"#ED6C02",info:"#0288D1",success:"#2E7D32",fontFamily:we,fontSize:14,borderRadius:4}),He=Object.freeze({type:"dark",primary:"#4DABF5",primaryContrast:"rgba(0, 0, 0, 0.87)",secondary:"#436A93",secondaryContrast:"#FFFFFF",background:"#121212",paper:"#121212",text:"#FFFFFF",textSecondary:"rgba(255, 255, 255, 0.7)",divider:"rgba(255, 255, 255, 0.12)",error:"#F44336",warning:"#FFA726",info:"#29B6F6",success:"#66BB6A",fontFamily:we,fontSize:14,borderRadius:4}),ie=["primary","primaryContrast","secondary","secondaryContrast","background","paper","text","textSecondary","divider","error","warning","info","success","fontFamily"],re=["fontSize","borderRadius"];function ye(n){return{...n==="dark"?He:Ve}}function P(n){if(!n||typeof n!="object")return ye(typeof n=="string"?n:"light");let t=n,e=ye(typeof t.type=="string"?t.type:"light");for(let i of ie){let r=t[i];typeof r=="string"&&r.trim()&&(e[i]=r.trim())}for(let i of re){let r=t[i],o=typeof r=="string"?parseFloat(r):r;typeof o=="number"&&Number.isFinite(o)&&o>=0&&(e[i]=o)}return e}function Se(n,t){return n.type===t.type&&ie.every(e=>n[e]===t[e])&&re.every(e=>n[e]===t[e])}function ve(n){return`--iob-${n.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}`}function Y(n){let t={};for(let e of ie)t[ve(e)]=n[e];for(let e of re)t[ve(e)]=`${n[e]}px`;return t["color-scheme"]=n.type,t}var Ee={ok:{en:"OK","zh-cn":"\u786E\u5B9A"},cancel:{en:"Cancel",de:"Abbrechen",ru:"\u041E\u0442\u043C\u0435\u043D\u0430",pt:"Cancelar",nl:"Annuleren",fr:"Annuler",it:"Annulla",es:"Cancelar",pl:"Anuluj",uk:"\u0421\u043A\u0430\u0441\u0443\u0432\u0430\u0442\u0438","zh-cn":"\u53D6\u6D88"},close:{en:"Close",de:"Schlie\xDFen",ru:"\u0417\u0430\u043A\u0440\u044B\u0442\u044C",pt:"Fechar",nl:"Sluiten",fr:"Fermer",it:"Chiudi",es:"Cerrar",pl:"Zamknij",uk:"\u0417\u0430\u043A\u0440\u0438\u0442\u0438","zh-cn":"\u5173\u95ED"}},We=`
|
|
2
|
+
dialog {
|
|
3
|
+
box-sizing: border-box;
|
|
4
|
+
width: 480px;
|
|
5
|
+
max-width: calc(100vw - 32px);
|
|
6
|
+
max-height: calc(100vh - 32px);
|
|
7
|
+
padding: 0;
|
|
8
|
+
border: 0;
|
|
9
|
+
border-radius: calc(var(--iob-border-radius) * 2);
|
|
10
|
+
background: var(--iob-paper);
|
|
11
|
+
color: var(--iob-text);
|
|
12
|
+
font-family: var(--iob-font-family);
|
|
13
|
+
font-size: var(--iob-font-size);
|
|
14
|
+
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
|
|
15
|
+
}
|
|
16
|
+
/* as the dialogs of MUI: a dark paper gets lighter the higher it lies */
|
|
17
|
+
dialog.dark { background-image: linear-gradient(rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.16)); }
|
|
18
|
+
dialog::backdrop { background: rgba(0, 0, 0, 0.5); }
|
|
19
|
+
dialog:focus { outline: none; }
|
|
20
|
+
form { display: flex; flex-direction: column; height: 100%; max-height: inherit; margin: 0; }
|
|
21
|
+
header { display: flex; align-items: center; gap: 8px; padding: 12px 8px 12px 16px; font-size: 1.15em; font-weight: 500; }
|
|
22
|
+
header span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
23
|
+
.body { flex: 1; min-height: 0; padding: 0 16px 16px; overflow: auto; display: flex; flex-direction: column; gap: 12px; }
|
|
24
|
+
footer { display: flex; justify-content: flex-end; gap: 8px; padding: 0 16px 16px; }
|
|
25
|
+
button { font: inherit; padding: 6px 16px; border-radius: var(--iob-border-radius); border: 1px solid var(--iob-primary); background: transparent; color: var(--iob-primary); cursor: pointer; }
|
|
26
|
+
button.primary { background: var(--iob-primary); color: var(--iob-primary-contrast); }
|
|
27
|
+
button.close { border: 0; padding: 2px 8px; font-size: 1.4em; line-height: 1; color: var(--iob-text-secondary); }
|
|
28
|
+
label { display: flex; flex-direction: column; gap: 4px; }
|
|
29
|
+
label.check { flex-direction: row; align-items: center; gap: 8px; }
|
|
30
|
+
input, select, textarea { font: inherit; accent-color: var(--iob-primary); }
|
|
31
|
+
.help { color: var(--iob-text-secondary); font-size: 0.85em; }
|
|
32
|
+
h3 { margin: 4px 0 0; font-size: 1em; }
|
|
33
|
+
p { margin: 0; }
|
|
34
|
+
hr { width: 100%; border: 0; border-top: 1px solid var(--iob-divider); margin: 0; }
|
|
35
|
+
[hidden] { display: none !important; }
|
|
36
|
+
`;function Ce(n){if(!n)return null;try{let t=new Function("data",`return (${n});`);return e=>{try{return!!t(e)}catch{return!1}}}catch{return null}}function oe(n){return typeof n=="string"?n:typeof n=="number"||typeof n=="boolean"?String(n):""}function Ge(n){let{input:t,setting:e}=n;if(t)return t instanceof HTMLInputElement&&t.type==="checkbox"?t.checked:t instanceof HTMLSelectElement?e.options?.[t.selectedIndex]?.value:t.value}function Ue(n,t,e,i,r){let o={name:t,setting:e,box:n.createElement("div"),hidden:Ce(e.hidden),disabled:Ce(e.disabled)},m=w(e.label,r);switch(e.type){case"header":return o.box=n.createElement("h3"),o.box.textContent=w(e.text,r)||m,o;case"staticText":return o.box=n.createElement("p"),o.box.textContent=w(e.text,r)||m,o;case"divider":return o.box=n.createElement("hr"),o;default:break}let u=n.createElement("label");o.box=u;let l=n.createElement("span");if(l.textContent=m||t,e.type==="checkbox"){let s=n.createElement("input");s.type="checkbox",s.checked=i===!0||i==="true",u.className="check",u.append(s,l),o.input=s}else if(e.type==="select"){let s=n.createElement("select");for(let d of e.options||[]){let p=n.createElement("option");p.textContent=w(d.label,r),s.append(p)}let h=(e.options||[]).findIndex(d=>String(d.value)===oe(i));s.selectedIndex=h===-1?0:h,u.append(l,s),o.input=s}else if(e.type==="text"&&(e.minRows||1)>1){let s=n.createElement("textarea");s.rows=e.minRows||2,s.value=oe(i),u.append(l,s),o.input=s}else{let s=n.createElement("input"),h=oe(i);switch(e.type){case"number":case"slider":s.type=e.type==="slider"?"range":"number",e.min!==void 0&&(s.min=String(e.min)),e.max!==void 0&&(s.max=String(e.max)),s.step=e.step!==void 0?String(e.step):"any";break;case"password":s.type="password";break;case"color":s.type=!h||/^#[0-9a-f]{6}$/i.test(h)?"color":"text";break;default:s.type="text";break}if(s.value=h,s.type==="range"){let d=n.createElement("output");d.textContent=s.value,s.addEventListener("input",()=>d.textContent=s.value),l.append(": ",d)}u.append(l,s),o.input=s}if(e.help){let s=n.createElement("span");s.className="help",s.textContent=w(e.help,r),u.append(s)}return o}function ke(n,t={}){let e=t.lang||"en",i=document,r=C=>Ee[C][e]||Ee[C].en||C,o=i.createElement("div");o.setAttribute("data-iob-dialog","");let m=o.attachShadow({mode:"open"}),u=i.createElement("style");u.textContent=We;let l=i.createElement("dialog"),s=P(t.theme);l.className=s.type==="dark"?"dark":"";for(let[C,L]of Object.entries(Y(s)))l.style.setProperty(C,L);n.width&&(l.style.width=`${n.width}px`),n.height&&(l.style.height=`${n.height}px`);let h=i.createElement("form"),d=i.createElement("header"),p=i.createElement("span");p.textContent=w(n.title,e);let b=i.createElement("button");b.type="button",b.className="close",b.title=r("close"),b.setAttribute("aria-label",r("close")),b.textContent="\xD7",d.append(p,b);let S=i.createElement("div");return S.className="body",h.append(d,S),l.append(h),m.append(u,l),new Promise(C=>{let L=!1,B=_=>{L||(L=!0,l.open&&l.close(),o.remove(),C(_))};if(b.addEventListener("click",()=>B(null)),l.addEventListener("close",()=>B(null)),h.addEventListener("submit",_=>_.preventDefault()),K(n)){let _={},W=[];for(let[x,E]of Object.entries(n.form.items||{})){let Ie=n.data?.[x]??E.default,ue=Ue(i,x,E,Ie,e);W.push(ue),S.append(ue.box)}let de=()=>{for(let x of W)x.input&&(_[x.name]=Ge(x));return _},ee=()=>{let x=de();for(let E of W)E.box.hidden=E.hidden?E.hidden(x):!1,E.input&&(E.input.disabled=E.disabled?E.disabled(x):!1)};h.addEventListener("input",ee),h.addEventListener("change",ee),ee();let pe=W.find(x=>x.input&&!x.box.hidden&&!x.input.disabled);pe?.input&&(pe.input.autofocus=!0);let fe=i.createElement("footer"),G=i.createElement("button");G.type="button",G.textContent=w(n.cancel,e)||r("cancel"),G.addEventListener("click",()=>B(null));let U=i.createElement("button");U.type="submit",U.className="primary",U.textContent=w(n.ok,e)||r("ok"),fe.append(G,U),h.append(fe),h.addEventListener("submit",()=>B(J(X(n.form),de())))}else S.append(n.element),l.addEventListener(me,_=>B(_.detail??null));i.body.append(o),l.showModal(),(!m.activeElement||m.activeElement===b)&&(l.tabIndex=-1,l.focus())})}function Te(n){return[...new Set(n.filter(t=>typeof t=="string"&&!!t))]}var Ke=["socket","dialogs","theme","editMode","settings","value"],k,O,$,T,A,M,g,I,D,H,c,se,R,V,Fe,_e,ae,ce,j,Z=class extends HTMLElement{constructor(){super(...arguments);y(this,c);te(this,"states",{});te(this,"objects",{});y(this,k,null);y(this,O,{});y(this,$,P("light"));y(this,T,!1);y(this,A,null);y(this,M);y(this,g,null);y(this,I,!1);y(this,D,(e,i)=>{a(this,g)?.states.includes(e)&&(this.states[e]=i||null,f(this,c,j).call(this))});y(this,H,(e,i)=>{a(this,g)?.objects.includes(e)&&(this.objects[e]=i||null,f(this,c,R).call(this))})}get socket(){return a(this,k)}set socket(e){v(this,k,e||null),f(this,c,R).call(this)}get settings(){return a(this,O)}set settings(e){v(this,O,e||{}),f(this,c,R).call(this)}get theme(){return a(this,$)}set theme(e){let i=P(e);Se(i,a(this,$))||(v(this,$,i),f(this,c,se).call(this),f(this,c,j).call(this))}get editMode(){return a(this,T)}set editMode(e){let i=!!e;i!==a(this,T)&&(v(this,T,i),f(this,c,j).call(this))}get dialogs(){return a(this,A)}set dialogs(e){v(this,A,e||null)}get value(){return a(this,M)}set value(e){e!==a(this,M)&&(v(this,M,e),f(this,c,j).call(this))}connectedCallback(){for(let e of Ke)if(Object.prototype.hasOwnProperty.call(this,e)){let i=this[e];delete this[e],this[e]=i}f(this,c,se).call(this),f(this,c,R).call(this)}disconnectedCallback(){f(this,c,ce).call(this)}getStateIds(e){return[]}getObjectIds(e){return[]}get systemLang(){return a(this,k)?.systemLang||"en"}text(e){return w(e,this.systemLang)}setState(e,i){return a(this,k)&&!a(this,T)?a(this,k).setState(e,i):Promise.resolve()}changeValue(e){return a(this,T)||this.emit(ge,e)?!1:(this.value=e,!0)}emit(e,i){return this.dispatchEvent(new CustomEvent(e,{detail:i,bubbles:!0,composed:!0,cancelable:!0}))}async openDialog(e){if(a(this,T))return null;let i=a(this,A)?await a(this,A).open(e):await ke(e,{lang:this.systemLang,theme:a(this,$)});return K(e)?i&&typeof i=="object"?J(X(e.form),i):null:i??null}};k=new WeakMap,O=new WeakMap,$=new WeakMap,T=new WeakMap,A=new WeakMap,M=new WeakMap,g=new WeakMap,I=new WeakMap,D=new WeakMap,H=new WeakMap,c=new WeakSet,se=function(){for(let[e,i]of Object.entries(Y(a(this,$))))this.style.setProperty(e,i)},R=function(){if(!this.isConnected)return;let e=a(this,k),i=e?Te(this.getStateIds(a(this,O))):[],r=e?Te(this.getObjectIds(a(this,O))):[];a(this,g)&&a(this,g).socket!==e&&f(this,c,ce).call(this);let o=a(this,g)?.states||[],m=a(this,g)?.objects||[],u=o.filter(d=>!i.includes(d)),l=m.filter(d=>!r.includes(d)),s=i.filter(d=>!o.includes(d)),h=r.filter(d=>!m.includes(d));e&&u.length&&e.unsubscribeState(u,a(this,D)),e&&l.length&&f(this,c,ae).call(this,e,l);for(let d of u)delete this.states[d];for(let d of[...u,...l])!i.includes(d)&&!r.includes(d)&&delete this.objects[d];v(this,g,e&&(i.length||r.length)?{socket:e,states:i,objects:r}:null),e&&s.length&&f(this,c,Fe).call(this,e,s),e&&h.length&&f(this,c,_e).call(this,e,h),f(this,c,j).call(this)},V=function(e,i,r){return a(this,g)?.socket===e&&a(this,g)[i].includes(r)},Fe=function(e,i){e.subscribeState(i,a(this,D)).catch(r=>console.warn(`<${this.localName}>: cannot subscribe ${i.join(", ")}: ${r}`));for(let r of i)e.getState(r).then(o=>{f(this,c,V).call(this,e,"states",r)&&this.states[r]===void 0&&(this.states[r]=o||null,f(this,c,j).call(this))}).catch(()=>{}),e.getObject(r).then(o=>{f(this,c,V).call(this,e,"states",r)&&!f(this,c,V).call(this,e,"objects",r)&&(this.objects[r]=o||null,f(this,c,j).call(this))}).catch(()=>{})},_e=function(e,i){e.subscribeObject(i,a(this,H)).catch(r=>console.warn(`<${this.localName}>: cannot subscribe the objects ${i.join(", ")}: ${r}`));for(let r of i)e.getObject(r).then(o=>{f(this,c,V).call(this,e,"objects",r)&&(this.objects[r]=o||null,f(this,c,R).call(this))}).catch(()=>{})},ae=function(e,i){e.unsubscribeObject(i,a(this,H)).catch(()=>{})},ce=function(){if(a(this,g)){let{socket:e,states:i,objects:r}=a(this,g);i.length&&e.unsubscribeState(i,a(this,D)),r.length&&f(this,c,ae).call(this,e,r),v(this,g,null)}this.states={},this.objects={}},j=function(){a(this,I)||(v(this,I,!0),queueMicrotask(()=>{v(this,I,!1),this.isConnected&&this.render()}))};function je(n,t){let e=typeof n=="string"?n:n.tag;customElements.get(e)||customElements.define(e,t)}var z={widgetMode:"nojs",count:50,thumbSize:"medium",minCol:150,maxModalWidth:900,showTags:!0,tagPosition:"bottom-left",sortNewest:!0,showSearch:!0,defaultTag:"",compact:!1,playerUrl:"",liveAspect:"",liveRefreshSec:0,colorCardBg:"rgba(127,127,127,0.15)",colorTagBg:"rgba(0,0,0,0.55)",colorTagText:"#ffffff",colorAccent:"#8ab4f8",colorModalBg:"#1c1c1e",borderRadius:8},Xe={small:120,medium:180,large:240},N={pickWidget:{en:"Please choose a widget in the settings.",de:"Bitte in den Einstellungen ein Widget ausw\xE4hlen."},pickCamera:{en:"Please choose a camera in the settings.",de:"Bitte in den Einstellungen eine Kamera ausw\xE4hlen."},pickInstance:{en:"Please choose an agent-dvr instance in the settings.",de:"Bitte in den Einstellungen eine agent-dvr-Instanz ausw\xE4hlen."},waiting:{en:"Waiting for data of the adapter \u2026",de:"Warte auf Daten des Adapters \u2026"},noCamera:{en:"Camera not found",de:"Kamera nicht gefunden"},noCameras:{en:"No cameras",de:"Keine Kameras"}},$e={en:{noRecordings:"No recordings",search:"Search \u2026",all:"All",download:"Download",live:"LIVE"},de:{noRecordings:"Keine Aufnahmen",search:"Suche \u2026",all:"Alle",download:"Herunterladen",live:"LIVE"}};function F(n){return String(n??"").replace(/[&<>"]/g,t=>({"&":"&","<":"<",">":">",'"':"""})[t])}function Le(n){let t=String(n||"").replace(/^system\.adapter\./,"");return/^\d+$/.test(t)?`agent-dvr.${t}`:/^[^.]+\.\d+$/.test(t)?t:""}function Oe(n){let t=n&&n.val;if(typeof t!="string"||!t)return null;try{return JSON.parse(t)}catch{return null}}function Ae(n,t){if(n.mode==="custom"){let e={...z};for(let[i,r]of Object.entries(n))r!=null&&(e[i]=r);return e.minCol=Xe[e.thumbSize]||Number(e.minCol)||150,e}return!t||!t.settings?null:{...z,...t.settings}}function ze(n,t){return{...$e[t]||$e.en,...n&&n.labels||{}}}function Ne(n,t,e){let i=n.compact?6:12,r=`${Math.max(0,Number(n.borderRadius)||0)}px`,o=t?{card:"color-mix(in srgb, var(--iob-text, currentColor) 10%, transparent)",tagBg:"var(--iob-primary)",tagText:"var(--iob-primary-contrast)",accent:"var(--iob-primary)",modal:"var(--iob-paper)",info:"var(--iob-text)"}:{card:n.colorCardBg||z.colorCardBg,tagBg:n.colorTagBg||z.colorTagBg,tagText:n.colorTagText||z.colorTagText,accent:n.colorAccent||z.colorAccent,modal:n.colorModalBg||z.colorModalBg,info:"#fff"};return`:host{display:block;width:100%;height:100%;overflow:hidden;color:inherit;font:inherit}.root{--adv-card-bg:${o.card};--adv-tag-bg:${o.tagBg};--adv-tag-color:${o.tagText};--adv-accent:${o.accent};--adv-radius:${r};width:100%;height:100%;box-sizing:border-box;overflow:auto;${e?"pointer-events:none;":""}}.bar{display:flex;flex-wrap:wrap;gap:8px;align-items:center;margin-bottom:10px}.search{flex:1 1 160px;min-width:120px;padding:6px 10px;border-radius:8px;border:1px solid rgba(127,127,127,.4);background:rgba(127,127,127,.08);color:inherit;font:inherit}.tags{display:flex;flex-wrap:wrap;gap:6px}.tagbtn{padding:4px 10px;border-radius:999px;border:1px solid rgba(127,127,127,.4);background:transparent;color:inherit;cursor:pointer;font:inherit;font-size:.8rem}.tagbtn.on{background:var(--adv-accent);color:${t?"var(--iob-primary-contrast)":"#fff"};border-color:var(--adv-accent)}.grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(${Number(n.minCol)||150}px,1fr));gap:${i}px}.fitted{overflow:hidden;display:flex;align-items:center;justify-content:center}.fitted .grid{justify-content:center;align-content:center}.cell{display:flex;flex-direction:column;cursor:pointer;min-width:0}.img{position:relative;display:block;border-radius:var(--adv-radius);overflow:hidden;background:var(--adv-card-bg)}.img img{width:100%;height:auto;display:block}.img.fix img{height:100%;object-fit:cover}.tag{position:absolute;background:var(--adv-tag-bg);color:var(--adv-tag-color);font-size:.6rem;padding:2px 4px;border-radius:3px;line-height:1;max-width:85%;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.play{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;opacity:0;transition:opacity .15s;background:rgba(0,0,0,.2)}.play::before{content:"";border-style:solid;border-width:11px 0 11px 18px;border-color:transparent transparent transparent #fff;filter:drop-shadow(0 1px 2px rgba(0,0,0,.6))}.cell:hover .play{opacity:1}.cap{font-size:${n.compact?".65rem":".72rem"};margin-top:${n.compact?2:4}px;line-height:1.25;opacity:.85;overflow:hidden;text-overflow:ellipsis}.empty,.msg{padding:24px;text-align:center;opacity:.7}.single{height:100%;display:flex;flex-direction:column}.single .cell{flex:1 1 auto;min-height:0}.single .img{flex:1 1 auto;min-height:0}.single .img img{width:100%;height:100%;object-fit:contain}dialog{border:0;padding:12px;border-radius:14px;background:${o.modal};max-width:min(92vw,${Number(n.maxModalWidth)||900}px);width:min(92vw,${Number(n.maxModalWidth)||900}px);box-sizing:border-box;box-shadow:0 16px 48px rgba(0,0,0,.55),0 0 0 1px rgba(255,255,255,.08);overflow:visible}dialog::backdrop{background:rgba(0,0,0,.35)}.box{position:relative;display:flex;flex-direction:column;gap:8px}video{width:100%;max-height:80vh;border-radius:8px;background:#000;display:block;object-fit:contain}.close{position:absolute;top:6px;right:6px;width:32px;height:32px;border-radius:50%;background:rgba(0,0,0,.65);color:#fff;display:flex;align-items:center;justify-content:center;cursor:pointer;font-size:15px;z-index:2;border:2px solid rgba(255,255,255,.35)}.info{color:${o.info};font-size:.8rem;text-align:center}.info a{color:var(--adv-accent)}`}function Re(n){let t=document.createElement("dialog");t.innerHTML='<div class="box"><span class="close" role="button" aria-label="close">✕</span><video controls preload="none" playsinline></video><div class="info"></div></div>';let e=t.querySelector("video"),i=t.querySelector(".info"),r=()=>t.open&&t.close();return t.querySelector(".close").addEventListener("click",r),t.addEventListener("click",o=>o.target===t&&r()),t.addEventListener("close",()=>{try{e.pause()}catch{}e.removeAttribute("src"),e.removeAttribute("style");try{e.load()}catch{}}),n.appendChild(t),{el:t,open(o,m,u){u&&(e.style.aspectRatio=u.replace("/"," / "),e.style.objectFit="fill"),e.setAttribute("src",o),i.innerHTML=m,t.open||t.showModal(),e.play&&e.play().catch(()=>{})}}}function Me(n,t,e){let i=n.aspect||t.liveAspect||"",r=i?String(i).replace("/"," / "):"";return`<div class="cell" data-cam="${F(n.id)}"><span class="img${r?" fix":""}"${r?` style="aspect-ratio:${F(r)}"`:""}><img class="snap" alt="" src="${F(`${n.snapshot}&ts=${Date.now()}`)}" data-base="${F(n.snapshot)}"><span class="tag" style="top:5px;left:5px">● ${F(e.live)}</span><span class="play"></span></span><span class="cap">${F(n.name)}</span></div>`}var Q=class{constructor(t){this.root=t,this.timer=null,this.sec=0}set(t){t=Math.max(0,Number(t)||0),!(t===this.sec&&(this.timer||!t))&&(this.stop(),this.sec=t,t>0&&(this.timer=setInterval(()=>{for(let e of this.root.querySelectorAll("img.snap")){let i=e.getAttribute("data-base");i&&(e.src=`${i}&ts=${Date.now()}`)}},t*1e3)))}stop(){clearInterval(this.timer),this.timer=null,this.sec=0}};var q=class extends Z{constructor(){super(),this.attachShadow({mode:"open"}),this.shadowRoot.innerHTML='<style></style><div class="root"></div>',this._player=Re(this.shadowRoot),this._timer=new Q(this.shadowRoot),this._key="",this._cams=[],this._cfg=null}_target(t){return{instance:"",camera:"",missing:N.pickInstance}}_single(){return!1}getStateIds(t){let e=this._target(t);return e.instance?[`${e.instance}.widget_config`]:[]}render(){let t=this.settings||{},e=this._target(t),i=this.shadowRoot.querySelector(".root"),r=e.instance?Oe(this.states[`${e.instance}.widget_config`]):null,o=Ae(t,r),m=this.shadowRoot.querySelector("style"),u=Ne(o||{},!!t.follow,this.editMode);if(m.textContent!==u&&(m.textContent=u),e.missing)return this._msg(i,this.text(e.missing));if(!o||!r||!Array.isArray(r.cameras))return this._msg(i,this.text(N.waiting));let l=e.camera?r.cameras.filter(p=>p.id===e.camera):r.cameras,s=JSON.stringify([o,l,r.labels,this.systemLang]);if(this._timer.set(o.liveRefreshSec),s===this._key)return;if(this._key=s,this._cfg=o,this._cams=l,!l.length)return this._msg(i,this.text(e.camera?N.noCamera:N.noCameras));let h=ze(r,this.systemLang),d=l.map(p=>Me(p,o,h)).join("");if(i.innerHTML=this._single()?`<div class="single">${d}</div>`:`<div class="grid">${d}</div>`,this._single()){let p=i.querySelector(".img");p&&p.removeAttribute("style"),p&&p.classList.remove("fix")}for(let p of i.querySelectorAll(".cell"))p.addEventListener("click",()=>this._open(p.getAttribute("data-cam")));this._fit()}_fits(){return!this._single()&&(this.settings||{}).fit!==!1}_fit(){let t=this.shadowRoot.querySelector(".root"),e=t&&t.querySelector(".grid");if(!this._fits()||!e){t&&t.classList.remove("fitted");return}!this._ro&&typeof ResizeObserver<"u"&&(this._ro=new ResizeObserver(()=>this._fit()),this._ro.observe(t));let i=getComputedStyle(t),r=t.clientWidth-parseFloat(i.paddingLeft)-parseFloat(i.paddingRight),o=t.clientHeight-parseFloat(i.paddingTop)-parseFloat(i.paddingBottom),m=e.children.length;if(!m||r<=0||o<=0)return;let u=parseFloat(getComputedStyle(e).rowGap)||8,l=e.querySelector(".cap"),s=l?l.getBoundingClientRect().height+(parseFloat(getComputedStyle(l).marginTop)||0):0,h=0;for(let p of this._cams){let b=String(p.aspect||this._cfg.liveAspect||"16/9").split(/[/:x]/),S=Number(b[1])/Number(b[0]);h=Math.max(h,S>0&&isFinite(S)?S:9/16)}let d={cols:1,w:0};for(let p=1;p<=m;p++){let b=Math.ceil(m/p),S=(r-(p-1)*u)/p,C=((o-(b-1)*u)/b-s)/h,L=Math.floor(Math.min(S,C));L>d.w&&(d={cols:p,w:L})}if(d.w<40){t.classList.remove("fitted"),e.style.gridTemplateColumns="";return}t.classList.add("fitted"),e.style.gridTemplateColumns=`repeat(${d.cols}, ${d.w}px)`}_msg(t,e){this._key="",this._timer.stop(),t.innerHTML=`<div class="msg">${F(e)}</div>`}_open(t){let e=this._cams.find(i=>i.id===t);!e||this.editMode||this._player.open(e.live,`${F(e.name)} · Live`,e.aspect||this._cfg.liveAspect||"")}connectedCallback(){super.connectedCallback&&super.connectedCallback(),this._key=""}disconnectedCallback(){super.disconnectedCallback&&super.disconnectedCallback(),this._timer.stop(),this._player.el.open&&this._player.el.close(),this._ro&&this._ro.disconnect(),this._ro=null}};var le=class extends q{_target(t){let e=Le(t.instance);return{instance:e,camera:"",missing:e?null:N.pickInstance}}};je("iob-agent-dvr-overview",le);
|