diff --git a/README.md b/README.md index 883ffe6..07629f0 100644 --- a/README.md +++ b/README.md @@ -1,88 +1,182 @@ -# Dawnline +
-[![CI](https://github.com/tickcount/luci-app-dawnline/actions/workflows/ci.yml/badge.svg)](https://github.com/tickcount/luci-app-dawnline/actions/workflows/ci.yml) -[![Build packages](https://github.com/tickcount/luci-app-dawnline/actions/workflows/build.yml/badge.svg)](https://github.com/tickcount/luci-app-dawnline/actions/workflows/build.yml) + + + Dawnline + -Your OpenWrt router as a private VPN for the people you choose. +

Dawnline

-Dawnline runs an [AmneziaWG](https://docs.amnezia.org/) server on the router -and gives every person a personal link. They open it, add their own devices -(up to the limit you set) and connect with AmneziaVPN or AmneziaWG. You decide -what each person may reach: the home network, the internet, or both. +**Your OpenWrt router as a private VPN for the people you choose.** -Dawnline is the successor of [Liminal](https://github.com/tickcount/openwrt-liminal): -the same idea rebuilt around people instead of peers, with a personal portal, -limits, live traffic and a LuCI admin that follows a modern design. +Latest release +CI +Downloads +License +
+OpenWrt 24.10 +OpenWrt 25.12 +AmneziaWG 2.0 and 3.1 -![Overview](docs/screenshots/overview.png) +[**Quick start**](#-quick-start)  ·  [Features](#-features)  ·  [How it works](#-how-it-works)  ·  [Screenshots](#-a-closer-look)  ·  [FAQ](#-faq)  ·  [Development](#-development) -| People | A person | +
+ +
+ +Dawnline runs an [AmneziaWG] server on your OpenWrt router and gives every +person you invite **a personal link**. They open it, **add their own phones and +computers** and connect with AmneziaVPN, AmneziaWG or WireGuard. You decide +**what each of them may reach** (the home network, the internet, or both) and +**for how long, how much and when**. + +

+ The personal portal: devices and access, and adding a phone in three steps +
+ A person's own page: their devices and access. Adding a phone takes three steps, and the page sees it connect. +

+ +## 💡 Why Dawnline? + +Sharing a home VPN usually means making a config file by hand, sending it over +a messenger and hoping nobody shares it further. Dawnline turns that around: + +| | A VPN by hand | With Dawnline | +|---|---|---| +| **Setting up a device** | You make a config and send it | They add it themselves from their link | +| **Who can do what** | Everyone gets the same | Home, internet or both, per person | +| **Ending access** | Find and delete their peers | A date, a data limit, or one click | +| **Knowing what goes on** | Read `wg show` | Who is online, traffic, places, a log | +| **When something breaks** | You find out from them | A watchdog notices and repairs it | + +It is the successor of [Liminal]: the same idea rebuilt around people instead +of peers, with a personal portal, limits, live traffic and a LuCI admin that +follows a modern design. + +## 🚀 Quick start + +1. **Install** on the router (it asks before it changes anything): + + ```sh + sh -c "$(wget -qO- https://raw.githubusercontent.com/tickcount/luci-app-dawnline/main/install.sh)" + ``` + +2. **Set up** in LuCI: Network › Dawnline, and follow the + wizard. It suggests the port, the public address and the networks. +3. **Invite** someone: Add person, then send them the link or the + invite card with its QR code. They do the rest. + +> [!TIP] +> Behind Cloudflare, give the portal a port Cloudflare proxies: 2053, 2083, +> 2087, 2096 or 8443. + +## ✨ Features + + + + + + + + + + + + + + + + + + + + + + +
+

🔗 A link, not an account

+

Three words, like vpn.example.com/kamiro-telosu-bavine. The link is the key: no sign-up, no password, and a new link locks the old one out at once.

+
+

📱 Their own devices

+

People add, rename and remove devices up to their limit. Adding one walks them through it: the right app, then a QR code, a link, a key or a file.

+
+

👥 People, not peers

+

One card per person with their devices, who is online, traffic, end date and data limit. Filter by who needs attention or is paused.

+
+

🧭 Who reaches what

+

The home network, the internet or both; only some networks or devices at home (a NAS, Home Assistant). Family sees family, guests see guests.

+
+

⏳ Limits

+

End dates, monthly or total data limits, allowed hours, a pause button. Changes apply at once, without dropping anyone else's connection.

+
+

🕶️ Disguise

+

Presets that make the VPN traffic harder to spot and block, with what each one needs from the apps.

+
+

🏠 Internet like a home device

+

People's devices go online the way the devices at home do, so your proxies, ad and DNS filters cover them too.

+
+

🗺️ Overview and places

+

Who is online with what, speed now, the last 30 days, and a map of where people connect from, at city level.

+
+

🩺 Repairs itself

+

Health checks with one-click fixes, and a watchdog that checks the tunnels, access rules and portal every minute and mends them.

+
+

📦 Updates and backups

+

Dawnline and AmneziaWG built for your firmware in one place; nightly backups, and export and import to move to another router.

+
+ +## 🧩 How it works + +```mermaid +flowchart LR + you(["🛠️ You, in LuCI"]) -- "add a person" --> link["🔗 Their link"] + link -- "they open it" --> portal["📱 Their portal"] + portal -- "add a device" --> app["App and connection"] + app == "AmneziaWG tunnel" ==> router["🌅 Dawnline
on your router"] + router -- "if allowed" --> home["🏠 Home network"] + router -- "if allowed" --> net["🌍 Internet"] +``` + +1. **You add a person** in LuCI and choose what they may reach, their device + limit, an end date or a data limit. +2. **They open their link** on any device. The portal is theirs alone: it shows + their devices and their access; access and limits stay yours to change. +3. **They add a device.** The portal points them to the app for that system and + hands over the connection; the router gives each device its own keys. +4. **The device connects** through the router's AmneziaWG server, and Dawnline + lets through what that person may reach, counts their traffic and keeps to + their limits. + +## 📸 A closer look + +

+ Overview: who is online, speed, the last 30 days and where people connect from +
+ Overview: who is online, speed now, the last 30 days and a map of where people connect from. +

+ + + + + + +
+ People: everyone on the server, with their devices, data and state +

People: online, ending soon, over the limit, outside their hours, paused.

+
+ A person: their devices, traffic, places and limits +

A person: their devices, traffic, places and limits.

+
+ +## 📋 Requirements + +| | What Dawnline needs | |---|---| -| ![People](docs/screenshots/people.png) | ![Person](docs/screenshots/person.png) | +| **OpenWrt** | 24.10 (opkg, `.ipk`) or 25.12 (apk, `.apk`) | +| **AmneziaWG** | `kmod-amneziawg`, `amneziawg-tools`, `luci-proto-amneziawg`: the installer adds a build made for your firmware when they are missing | +| **Free flash** | about 2 MB | -| Personal portal | Home network access | -|---|---| -| ![Personal portal](docs/screenshots/portal.png) | ![Access](docs/screenshots/access.png) | - -## Features - -- **People, not peers.** One card per person with device chips, live status, - traffic, end date and data limit. Add a person, send them the link or the - invite card (QR code), and they do the rest. -- **Personal portal.** Every person gets a link made of three words - (`https://vpn.example.com/kamiro-telosu-bavine`). The link is the key: no - accounts, no sessions, and a new link locks the old one out at once. People - add, rename and remove their devices and get each one as a QR code, - "Open in AmneziaVPN" (`vpn://`), a key or a `.conf` file. They cannot change - access or limits. Links work on the portal's own port with a Let's Encrypt - certificate (via ACME), several addresses at once (a Cloudflare-proxied name, - a plain IP), the same link at home, and wrong links can redirect to your - website. Behind Cloudflare, pick a port it proxies (2053, 2083, 2087, 2096 or - 8443). -- **Access per person**, enforced in an `inet dawnline` nftables table on the - tunnel interface: home network only, internet only, or both, and optionally - only some home networks or home services (picked from the devices the router - sees over DHCP). Devices of different people reach each other never, always, - or within circles (family sees family, guests see guests). "Who reaches what" - sums up the rules and "Check access" walks them step by step for a device - and an address. -- **Limits.** End dates (pause, keep, or remove devices when they pass), monthly - or total data limits, allowed hours, pause anyone. Devices - drop off the tunnel at once (`awg syncconf`, no interface restart). -- **Disguise presets** for AmneziaWG obfuscation (junk packets, - header and padding parameters), with what each preset needs from the apps. -- **Internet like a home device.** Tunnel clients' internet traffic enters the - router from the LAN, through a small network namespace on the LAN bridge - (needs `kmod-veth`). Whatever handles LAN traffic on the router (proxies, DPI - bypass, DNS filters, the `lan` zone) handles VPN clients too, with no - per-tool integration. -- **Overview.** Who is online with what, speed now, today and the last 30 days, - and a map of where people connect from (city level). -- **Diagnostics.** Health checks with one-click fixes, including the ones that - matter for reaching the portal from outside (DNS, port forwards, reply - routing behind proxies such as SSClash/Mihomo, certificate coverage). A - watchdog checks the tunnels, access rules, portal, resolver and LuCI link - every minute and repairs them on its own (a cron job looks after the agent - itself). One log holds people's activity and the service log: tunnel starts - and stops with netifd's reasons, repairs and errors (`dawnline log` on the - router). -- **Updates.** Dawnline itself, AmneziaWG builds for your firmware (choose - between [Slava-Shchipunov](https://github.com/Slava-Shchipunov/awg-openwrt) - and [2Grey](https://github.com/2Grey/awg-openwrt), AmneziaWG 2.0 or 3.1), and - the few OpenWrt packages Dawnline adds. -- **Backups** nightly and before risky operations, JSON export/import to move - to another router. - -## Requirements - -- OpenWrt **24.10** (opkg, `.ipk`) or **25.12** (apk, `.apk`) -- AmneziaWG (`kmod-amneziawg`, `amneziawg-tools`, `luci-proto-amneziawg`): - the installer adds a build made for your firmware when it is missing -- About 2 MB of free flash - -## Install - -On the router: +## 📥 Install ```sh sh -c "$(wget -qO- https://raw.githubusercontent.com/tickcount/luci-app-dawnline/main/install.sh)" @@ -90,17 +184,21 @@ sh -c "$(wget -qO- https://raw.githubusercontent.com/tickcount/luci-app-dawnline The installer checks the firmware, the clock, free space and DNS, lets you pick a release (the latest is the default), shows the plan and asks before it -changes anything. It downloads the Dawnline package for your package manager, -checks it against `sha256sums.txt`, installs AmneziaWG built for your firmware -if it is missing, then installs Dawnline with its dependencies and checks that -LuCI can reach it. Then open **LuCI → Network → Dawnline** and run the setup -wizard. +changes anything. It downloads the package for your package manager, checks it +against `sha256sums.txt`, installs AmneziaWG built for your firmware if it is +missing, then installs Dawnline and checks that LuCI can reach it. -Before changing anything it saves `/etc/config/{dawnline,network,firewall,dhcp,uhttpd}` -and the service state to `/etc/dawnline/installer-backups/` (the newest three -are kept); if a step fails, it puts them back. Packages are not rolled back: to -return to an older release, run the installer with `--tag`. Everything it does -is logged to `/tmp/dawnline-install.log`. +> [!NOTE] +> Before changing anything it saves `/etc/config/{dawnline,network,firewall,dhcp,uhttpd}` +> and the service state to `/etc/dawnline/installer-backups/` (the newest three +> are kept), and puts them back if a step fails. Packages are not rolled back: +> to return to an older release, run the installer with `--tag`. Everything it +> does is logged to `/tmp/dawnline-install.log`. + +
+Installer options + +
With options, download it first: @@ -117,39 +215,64 @@ sh /tmp/dawnline-install.sh --awg grey # AmneziaWG from 2Grey | `-n`, `--dry-run` | Check the system, resolve, download and verify the release; change nothing | | `-v`, `--verbose` / `-q`, `--quiet` | More detail / only warnings and errors | | `--tag X.Y.Z` | A given release (`sh install.sh 0.3.1` works too) | -| `--awg auto\|slava\|grey\|skip` | Where AmneziaWG comes from when it is missing: [Slava-Shchipunov](https://github.com/Slava-Shchipunov/awg-openwrt), then [2Grey](https://github.com/2Grey/awg-openwrt) (`auto`, the default), only one of them, or not at all (install it later from **Dawnline → Updates**). `DAWNLINE_AWG` does the same | +| `--awg auto\|slava\|grey\|skip` | Where AmneziaWG comes from when it is missing: [Slava-Shchipunov], then [2Grey] (`auto`, the default), only one of them, or not at all (install it later from **Dawnline → Updates**). `DAWNLINE_AWG` does the same | | `--no-awg` | Same as `--awg skip` | -When GitHub is slow or blocked, the installer retries downloads through -`ghfast.top` and `gh-proxy.com` on its own. To fetch the installer itself -through a mirror: +
+ +
+When GitHub is slow or blocked + +
+ +The installer retries downloads through `ghfast.top` and `gh-proxy.com` on its +own. To fetch the installer itself through a mirror: ```sh sh -c "$(wget -qO- https://cdn.jsdelivr.net/gh/tickcount/luci-app-dawnline@main/install.sh)" sh -c "$(wget -qO- https://ghfast.top/https://raw.githubusercontent.com/tickcount/luci-app-dawnline/main/install.sh)" ``` -By hand, from a [release](https://github.com/tickcount/luci-app-dawnline/releases): +
+ +
+Installing by hand + +
+ +From a [release](https://github.com/tickcount/luci-app-dawnline/releases): ```sh opkg update && opkg install ./luci-app-dawnline-0.1.0.ipk # OpenWrt 24.10 apk update && apk add --allow-untrusted ./luci-app-dawnline-0.1.0.apk # OpenWrt 25.12 ``` -**Upgrade** from **Dawnline → Updates**, or run the installer again. Settings, -keys and history are kept, and a backup is made first. +
-**Remove** on the router: +**Upgrade** from Dawnline › Updates, or run the installer +again. Settings, keys and history are kept, and a backup is made first. + +### Remove ```sh sh -c "$(wget -qO- https://raw.githubusercontent.com/tickcount/luci-app-dawnline/main/uninstall.sh)" ``` It backs up the configuration to `/etc/dawnline/backups`, runs Dawnline's own -removal (the same as **Settings → Remove Dawnline from this router**), removes -the package and cleans up what is left. AmneziaWG stays installed, since other -tunnels may use it. After installing Dawnline again, restore the backup in -**Settings → Backups**. With options, download it first: +removal (the same as Settings › Remove Dawnline from this router), +removes the package and cleans up what is left. After installing Dawnline +again, restore the backup in Settings › Backups. + +> [!IMPORTANT] +> AmneziaWG stays installed, since other tunnels may use it. Add `--remove-awg` +> to take it away too. + +
+Uninstaller options + +
+ +With options, download it first: ```sh wget -O /tmp/dawnline-uninstall.sh https://raw.githubusercontent.com/tickcount/luci-app-dawnline/main/uninstall.sh @@ -163,25 +286,83 @@ sh /tmp/dawnline-uninstall.sh --dry-run | `--remove-awg` | Also remove AmneziaWG, unless another interface still uses it (`--keep-awg`, the default, keeps it) | | `-n`, `--dry-run` | Show what would be removed; change nothing | -By hand: **Settings → Remove Dawnline from this router** (keeps a backup), then -`opkg remove luci-app-dawnline` or `apk del luci-app-dawnline`. +By hand: Settings › Remove Dawnline from this router +(keeps a backup), then `opkg remove luci-app-dawnline` or +`apk del luci-app-dawnline`. -## What Dawnline changes on the router +
+ +## ❓ FAQ + +
+Which apps do people use? + +
+ +AmneziaVPN or AmneziaWG on phones and computers, and plain WireGuard when the +disguise is off. The portal shows each person the app for their system and how +to add the connection in it. + +
+ +
+What happens when someone loses their link? + +
+ +Make a new one on their page. The old link stops working at once; their devices +keep working, unless you tick the ones to remove with it. + +
+ +
+Does it touch the rest of my router? + +
+ +Only what it created, and `dawnline teardown` removes all of it. The full list +is under [What Dawnline changes on the router](#-what-dawnline-changes-on-the-router). + +
+ +
+How do I move to another router? + +
+ +Export JSON in Settings › Backups on the old +one, install Dawnline on the new one and import the file there. + +
+ +
+Where do the places on the map come from? + +
+ +From the address a device connects from, looked up at city level and cached on +the router. It can be turned off in Settings. + +
+ +## 🧾 What Dawnline changes on the router Only objects it created: network interfaces tagged `_dawnline`, firewall sections named `dawnline_*`, the `inet dawnline` nft table, `/tmp/hosts/dawnline`, the `dawnline` network namespace with its two veth links (`dlx0`, `dll0`, the -latter a port of the LAN bridge), policy rules for the tunnel interfaces with -one routing table, a second dnsmasq instance on port 5354 -(`/var/etc/dawnline-dns.conf`), a cron line for the agent's heartbeat check -and, while the portal is on, a uhttpd instance for it. `dawnline teardown` -removes all of them. +latter a port of the LAN bridge, which needs `kmod-veth`), policy rules for the +tunnel interfaces with one routing table, a second dnsmasq instance on port +5354 (`/var/etc/dawnline-dns.conf`), a cron line for the agent's heartbeat +check and, while the portal is on, a uhttpd instance for it. +`dawnline teardown` removes all of them. Data lives in `/etc/config/dawnline` (mode 0600, contains private keys) and `/etc/dawnline/` (usage, events, issued configurations, backups). Live counters -are kept in `/var/run/dawnline` and flushed to flash at most hourly. +are kept in `/var/run/dawnline` and flushed to flash at most hourly. Access +changes reach the tunnel with `awg syncconf`, without restarting the interface; +`dawnline log` on the router shows the service log. -## Development +## 🛠️ Development ``` package/luci-app-dawnline/ @@ -203,18 +384,25 @@ npm ci npm run format # Prettier npm run ci # format check, types, tests, minified bundles -scripts/lint-ucode.py # static ucode checks -scripts/check-ucode.sh root@router # compile every ucode file on a router -scripts/deploy.sh root@router # install the working tree (backs up configs first) -scripts/build-packages.sh all # .ipk and .apk with the OpenWrt SDK in Docker -scripts/capture-screenshots.mjs # capture docs/screenshots/raw/*.png from a router -scripts/frame-screenshots.py # frame them for this README +scripts/lint-ucode.py # static ucode checks +scripts/check-ucode.sh root@router # compile every ucode file on a router +scripts/deploy.sh root@router # install the working tree (backs up configs first) +scripts/build-packages.sh all # .ipk and .apk with the OpenWrt SDK in Docker +scripts/capture-screenshots.mjs --demo # README screenshots from a router, a demo cast in place of its people +scripts/frame-screenshots.py # frame them for this README ``` The web bundles are committed: CI fails when they are out of date. Pushing a tag `vX.Y.Z` (matching `PKG_VERSION`) builds both packages with the OpenWrt SDK and publishes a release with `sha256sums.txt`. -## License +--- -[MIT](LICENSE) +
+Made for OpenWrt · MIT license · Back to top ↑ +
+ +[AmneziaWG]: https://docs.amnezia.org/ +[Liminal]: https://github.com/tickcount/openwrt-liminal +[Slava-Shchipunov]: https://github.com/Slava-Shchipunov/awg-openwrt +[2Grey]: https://github.com/2Grey/awg-openwrt diff --git a/docs/assets/logo-dark.svg b/docs/assets/logo-dark.svg new file mode 100644 index 0000000..c15b1af --- /dev/null +++ b/docs/assets/logo-dark.svg @@ -0,0 +1 @@ + diff --git a/docs/assets/logo-light.svg b/docs/assets/logo-light.svg new file mode 100644 index 0000000..d7ca324 --- /dev/null +++ b/docs/assets/logo-light.svg @@ -0,0 +1 @@ + diff --git a/docs/screenshots/access.png b/docs/screenshots/access.png deleted file mode 100644 index 45e9614..0000000 Binary files a/docs/screenshots/access.png and /dev/null differ diff --git a/docs/screenshots/overview.png b/docs/screenshots/overview.png index 9ec0014..e48cacd 100644 Binary files a/docs/screenshots/overview.png and b/docs/screenshots/overview.png differ diff --git a/docs/screenshots/people.png b/docs/screenshots/people.png index 0012cfa..abe2ba6 100644 Binary files a/docs/screenshots/people.png and b/docs/screenshots/people.png differ diff --git a/docs/screenshots/person.png b/docs/screenshots/person.png index f487547..c08e7ac 100644 Binary files a/docs/screenshots/person.png and b/docs/screenshots/person.png differ diff --git a/docs/screenshots/portal.png b/docs/screenshots/portal.png index 209e146..a9faeed 100644 Binary files a/docs/screenshots/portal.png and b/docs/screenshots/portal.png differ diff --git a/docs/screenshots/raw/access.png b/docs/screenshots/raw/access.png deleted file mode 100644 index 9646ea7..0000000 Binary files a/docs/screenshots/raw/access.png and /dev/null differ diff --git a/docs/screenshots/raw/overview.png b/docs/screenshots/raw/overview.png index 94f509b..9ca7646 100644 Binary files a/docs/screenshots/raw/overview.png and b/docs/screenshots/raw/overview.png differ diff --git a/docs/screenshots/raw/people.png b/docs/screenshots/raw/people.png index 0473fe6..ff13c11 100644 Binary files a/docs/screenshots/raw/people.png and b/docs/screenshots/raw/people.png differ diff --git a/docs/screenshots/raw/person.png b/docs/screenshots/raw/person.png index e96ea2b..b7fdbeb 100644 Binary files a/docs/screenshots/raw/person.png and b/docs/screenshots/raw/person.png differ diff --git a/docs/screenshots/raw/portal-add-1.png b/docs/screenshots/raw/portal-add-1.png new file mode 100644 index 0000000..ecad8f3 Binary files /dev/null and b/docs/screenshots/raw/portal-add-1.png differ diff --git a/docs/screenshots/raw/portal-add-2.png b/docs/screenshots/raw/portal-add-2.png new file mode 100644 index 0000000..06cb0e8 Binary files /dev/null and b/docs/screenshots/raw/portal-add-2.png differ diff --git a/docs/screenshots/raw/portal-add-3.png b/docs/screenshots/raw/portal-add-3.png new file mode 100644 index 0000000..faf8e06 Binary files /dev/null and b/docs/screenshots/raw/portal-add-3.png differ diff --git a/docs/screenshots/raw/portal.png b/docs/screenshots/raw/portal.png index f3f1913..8983d93 100644 Binary files a/docs/screenshots/raw/portal.png and b/docs/screenshots/raw/portal.png differ diff --git a/package/luci-app-dawnline/Makefile b/package/luci-app-dawnline/Makefile index 7577be2..46c1377 100644 --- a/package/luci-app-dawnline/Makefile +++ b/package/luci-app-dawnline/Makefile @@ -6,7 +6,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=luci-app-dawnline -PKG_VERSION:=0.9.0 +PKG_VERSION:=0.10.0 PKG_RELEASE:=1 PKG_LICENSE:=MIT diff --git a/package/luci-app-dawnline/htdocs/luci-static/resources/dawnline/app.js b/package/luci-app-dawnline/htdocs/luci-static/resources/dawnline/app.js index 090ff43..a343a53 100644 --- a/package/luci-app-dawnline/htdocs/luci-static/resources/dawnline/app.js +++ b/package/luci-app-dawnline/htdocs/luci-static/resources/dawnline/app.js @@ -5,25 +5,25 @@ 'require poll'; 'require rpc'; 'require ui'; -var bi=Object.create;var Po=Object.defineProperty;var xi=Object.getOwnPropertyDescriptor;var wi=Object.getOwnPropertyNames;var yi=Object.getPrototypeOf,ki=Object.prototype.hasOwnProperty;var $i=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports);var Ci=(n,e,r,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of wi(e))!ki.call(n,a)&&a!==r&&Po(n,a,{get:()=>e[a],enumerable:!(o=xi(e,a))||o.enumerable});return n};var Ei=(n,e,r)=>(r=n!=null?bi(yi(n)):{},Ci(e||!n||!n.__esModule?Po(r,"default",{value:n,enumerable:!0}):r,n));var rr=$i((nr,or)=>{"use strict";var tr=(function(){var n=function(w,v){var y=236,E=17,k=w,z=r[v],f=null,g=0,S=null,T=[],N={},W=function(P,D){g=k*4+17,f=(function(_){for(var I=new Array(_),M=0;M<_;M+=1){I[M]=new Array(_);for(var j=0;j<_;j+=1)I[M][j]=null}return I})(g),q(0,0),q(g-7,0),q(0,g-7),K(),R(),de(P,D),k>=7&&Z(P),S==null&&(S=ge(k,z,T)),Q(S,D)},q=function(P,D){for(var _=-1;_<=7;_+=1)if(!(P+_<=-1||g<=P+_))for(var I=-1;I<=7;I+=1)D+I<=-1||g<=D+I||(0<=_&&_<=6&&(I==0||I==6)||0<=I&&I<=6&&(_==0||_==6)||2<=_&&_<=4&&2<=I&&I<=4?f[P+_][D+I]=!0:f[P+_][D+I]=!1)},Y=function(){for(var P=0,D=0,_=0;_<8;_+=1){W(!0,_);var I=a.getLostPoint(N);(_==0||P>I)&&(P=I,D=_)}return D},R=function(){for(var P=8;P>_&1)==1;f[Math.floor(_/3)][_%3+g-8-3]=I}for(var _=0;_<18;_+=1){var I=!P&&(D>>_&1)==1;f[_%3+g-8-3][Math.floor(_/3)]=I}},de=function(P,D){for(var _=z<<3|D,I=a.getBCHTypeInfo(_),M=0;M<15;M+=1){var j=!P&&(I>>M&1)==1;M<6?f[M][8]=j:M<8?f[M+1][8]=j:f[g-15+M][8]=j}for(var M=0;M<15;M+=1){var j=!P&&(I>>M&1)==1;M<8?f[8][g-M-1]=j:M<9?f[8][15-M-1+1]=j:f[8][15-M-1]=j}f[g-8][8]=!P},Q=function(P,D){for(var _=-1,I=g-1,M=7,j=0,J=a.getMaskFunction(D),V=g-1;V>0;V-=2)for(V==6&&(V-=1);;){for(var pe=0;pe<2;pe+=1)if(f[I][V-pe]==null){var xe=!1;j>>M&1)==1);var ne=J(I,V-pe);ne&&(xe=!xe),f[I][V-pe]=xe,M-=1,M==-1&&(j+=1,M=7)}if(I+=_,I<0||g<=I){I-=_,_=-_;break}}},te=function(P,D){for(var _=0,I=0,M=0,j=new Array(D.length),J=new Array(D.length),V=0;V=0?So.getAt(To):0}}for(var _o=0,ne=0;neV*8)throw"code length overflow. ("+M.getLengthInBits()+">"+V*8+")";for(M.getLengthInBits()+4<=V*8&&M.put(0,4);M.getLengthInBits()%8!=0;)M.putBit(!1);for(;!(M.getLengthInBits()>=V*8||(M.put(y,8),M.getLengthInBits()>=V*8));)M.put(E,8);return te(M,I)};N.addData=function(P,D){D=D||"Byte";var _=null;switch(D){case"Numeric":_=c(P);break;case"Alphanumeric":_=p(P);break;case"Byte":_=u(P);break;case"Kanji":_=x(P);break;default:throw"mode:"+D}T.push(_),S=null},N.isDark=function(P,D){if(P<0||g<=P||D<0||g<=D)throw P+","+D;return f[P][D]},N.getModuleCount=function(){return g},N.make=function(){if(k<1){for(var P=1;P<40;P++){for(var D=l.getRSBlocks(P,z),_=d(),I=0;I"u"?P*4:D;var _="";_+='";for(var M=0;M';_+=""}return _+="",_+="
",_},N.createSvgTag=function(P,D,_,I){var M={};typeof arguments[0]=="object"&&(M=arguments[0],P=M.cellSize,D=M.margin,_=M.alt,I=M.title),P=P||2,D=typeof D>"u"?P*4:D,_=typeof _=="string"?{text:_}:_||{},_.text=_.text||null,_.id=_.text?_.id||"qrcode-description":null,I=typeof I=="string"?{text:I}:I||{},I.text=I.text||null,I.id=I.text?I.id||"qrcode-title":null;var j=N.getModuleCount()*P+D*2,J,V,pe,xe,ne="",De;for(De="l"+P+",0 0,"+P+" -"+P+",0 0,-"+P+"z ",ne+=''+O(I.text)+"":"",ne+=_.text?''+O(_.text)+"":"",ne+='',ne+='"u"?P*4:D;var _=N.getModuleCount()*P+D*2,I=D,M=_-D;return B(_,_,function(j,J){if(I<=j&&j"u"?P*4:D;var I=N.getModuleCount()*P+D*2,M="";return M+="",M};var O=function(P){for(var D="",_=0;_":D+=">";break;case"&":D+="&";break;case'"':D+=""";break;default:D+=I;break}}return D},X=function(P){var D=1;P=typeof P>"u"?D*2:P;var _=N.getModuleCount()*D+P*2,I=P,M=_-P,j,J,V,pe,xe,ne={"██":"█","█ ":"▀"," █":"▄"," ":" "},De={"██":"▀","█ ":"▀"," █":" "," ":" "},Ae="";for(j=0;j<_;j+=2){for(V=Math.floor((j-I)/D),pe=Math.floor((j+1-I)/D),J=0;J<_;J+=1)xe="█",I<=J&&J=M?De[xe]:ne[xe];Ae+=` -`}return _%2&&P>0?Ae.substring(0,Ae.length-_-1)+Array(_+1).join("▀"):Ae.substring(0,Ae.length-1)};return N.createASCII=function(P,D){if(P=P||1,P<2)return X(D);P-=1,D=typeof D>"u"?P*2:D;var _=N.getModuleCount()*P+D*2,I=D,M=_-D,j,J,V,pe,xe=Array(P+1).join("██"),ne=Array(P+1).join(" "),De="",Ae="";for(j=0;j<_;j+=1){for(V=Math.floor((j-I)/P),Ae="",J=0;J<_;J+=1)pe=1,I<=J&&J>>8),z.push(S&255)):z.push(E)}}return z}};var e={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8},r={L:1,M:0,Q:3,H:2},o={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7},a=(function(){var w=[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],v=1335,y=7973,E=21522,k={},z=function(f){for(var g=0;f!=0;)g+=1,f>>>=1;return g};return k.getBCHTypeInfo=function(f){for(var g=f<<10;z(g)-z(v)>=0;)g^=v<=0;)g^=y<5&&(S+=3+W-5)}for(var T=0;T=256;)k-=255;return w[k]},E})();function s(w,v){if(typeof w.length>"u")throw w.length+"/"+v;var y=(function(){for(var k=0;k"u")throw"bad rs block @ typeNumber:"+k+"/errorCorrectionLevel:"+z;for(var g=f.length/3,S=[],T=0;T>>7-E%8&1)==1},y.put=function(E,k){for(var z=0;z>>k-z-1&1)==1)},y.getLengthInBits=function(){return v},y.putBit=function(E){var k=Math.floor(v/8);w.length<=k&&w.push(0),E&&(w[k]|=128>>>v%8),v+=1},y},c=function(w){var v=e.MODE_NUMBER,y=w,E={};E.getMode=function(){return v},E.getLength=function(f){return y.length},E.write=function(f){for(var g=y,S=0;S+2>>8&255)*192+(T&255),f.put(T,13),S+=2}if(S>>8)},v.writeBytes=function(y,E,k){E=E||0,k=k||y.length;for(var z=0;z0&&(y+=","),y+=w[E];return y+="]",y},v},h=function(){var w=0,v=0,y=0,E="",k={},z=function(g){E+=String.fromCharCode(f(g&63))},f=function(g){if(!(g<0)){if(g<26)return 65+g;if(g<52)return 97+(g-26);if(g<62)return 48+(g-52);if(g==62)return 43;if(g==63)return 47}throw"n:"+g};return k.writeByte=function(g){for(w=w<<8|g&255,v+=8,y+=1;v>=6;)z(w>>>v-6),v-=6},k.flush=function(){if(v>0&&(z(w<<6-v),w=0,v=0),y%3!=0)for(var g=3-y%3,S=0;S=v.length){if(k==0)return-1;throw"unexpected end of file./"+k}var g=v.charAt(y);if(y+=1,g=="=")return k=0,-1;if(g.match(/^\s$/))continue;E=E<<6|f(g.charCodeAt(0)),k+=6}var S=E>>>k-8&255;return k-=8,S};var f=function(g){if(65<=g&&g<=90)return g-65;if(97<=g&&g<=122)return g-97+26;if(48<=g&&g<=57)return g-48+52;if(g==43)return 62;if(g==47)return 63;throw"c:"+g};return z},C=function(w,v){var y=w,E=v,k=new Array(w*v),z={};z.setPixel=function(T,N,W){k[N*y+T]=W},z.write=function(T){T.writeString("GIF87a"),T.writeShort(y),T.writeShort(E),T.writeByte(128),T.writeByte(0),T.writeByte(0),T.writeByte(0),T.writeByte(0),T.writeByte(0),T.writeByte(255),T.writeByte(255),T.writeByte(255),T.writeString(","),T.writeShort(0),T.writeShort(0),T.writeShort(y),T.writeShort(E),T.writeByte(0);var N=2,W=g(N);T.writeByte(N);for(var q=0;W.length-q>255;)T.writeByte(255),T.writeBytes(W,q,255),q+=255;T.writeByte(W.length-q),T.writeBytes(W,q,W.length-q),T.writeByte(0),T.writeString(";")};var f=function(T){var N=T,W=0,q=0,Y={};return Y.write=function(R,K){if(R>>>K)throw"length over";for(;W+K>=8;)N.writeByte(255&(R<>>=8-W,q=0,W=0;q=R<0&&N.writeByte(q)},Y},g=function(T){for(var N=1<>6,128|i&63):i<55296||i>=57344?o.push(224|i>>12,128|i>>6&63,128|i&63):(a++,i=65536+((i&1023)<<10|r.charCodeAt(a)&1023),o.push(240|i>>18,128|i>>12&63,128|i>>6&63,128|i&63))}return o}return e(n)}})();(function(n){typeof define=="function"&&define.amd?define([],n):typeof nr=="object"&&(or.exports=n())})(function(){return tr})});function Gn(n,e){return n==null||n===!1||n===""||(Array.isArray(n)?n.forEach(r=>Gn(r,e)):e.push(n instanceof Node?n:String(n))),e}function t(n,e,r){let o=window.E,a=e!=null&&typeof e=="object"&&!Array.isArray(e)&&!(e instanceof Node);return!a&&r===void 0?o(n,{},Gn(e,[])):o(n,a?e:{},Gn(r,[]))}var Do={phone:'',computer:'',tablet:'',router:'',server:'',other:'',ethernet:'',bridge:'',wifi:'',tunnel:'',plus:'',chart:'',reset:'',package:'',code:'',plug:'',sunrise:'',refresh:'',archive:'',qr:'',copy:'',download:'',link:'',amnezia:'',amneziawg:'',wireguard:'',appstore:'',googleplay:'',github:'',openwrt:'',apple:'',windows:'',linux:'',eye:'',share:'',arrow:'',trash:'',edit:'',pause:'',play:'',key:'',out:'',admin:'',shield:'',shieldplus:'',lock:'',zap:'',check:'',alert:'',x:'',globe:'',home:'',open:'',file:'',network:'',moon:'',chevron:'',clock:'',calendar:'',minus:'',more:'',pin:'',activity:''};function ft(n,e="dl-icon"){let r=Do[n]??Do.phone;return``}function b(n,e="dl-icon"){let r=document.createElement("span");return r.className="dl-icon-wrap",r.innerHTML=ft(n,e),r}function U(n,e="info",r=0){let o=document.querySelector(".dl-toasts");o||(o=t("div",{class:"dl-toasts dl-root",role:"status","aria-live":"polite"}),document.body.appendChild(o));let a=e==="error"?"x":e==="warning"?"alert":e==="success"?"check":null,i=()=>{s.classList.remove("show"),setTimeout(()=>s.remove(),200)},s=t("div",{class:`dl-toast ${e}`},[a?b(a):"",t("span",{},n),e==="error"?t("button",{type:"button","aria-label":"Close",click:i},b("x")):""]);o.appendChild(s),requestAnimationFrame(()=>s.classList.add("show")),setTimeout(i,r||(e==="error"?8e3:e==="warning"?5e3:2600))}function be(n){return n instanceof Error?n.message:String(n)}async function G(n,e){try{let r=await n();return e&&U(e,"success",3500),r}catch(r){U(be(r),"error",1e4);return}}function Ao(n){try{let e=n();e&&typeof e.then=="function"&&e.catch(r=>U(be(r),"error"))}catch(e){U(be(e),"error")}}function Ho(n){if(n&&typeof n=="object"){if(typeof n.error=="string")throw new Error(n.error);typeof n.warning=="string"&&n.warning&&U(n.warning,"warning",12e3)}return n}function F(n,e=[]){let r=rpc.declare({object:"luci.dawnline",method:n,params:e});return async(...o)=>Ho(await r(...o))}var Li=F("logs_clear",["person","device","category","older_days"]),Mi=(n={})=>Li(n.person??"",n.device??"",n.category??"",n.older_days??""),Si=rpc.declare({object:"luci.dawnline",method:"person_update",params:["id","name","access","device_limit","expires","expire_action","expire_warn","quota_gb","quota_period","bonus_gb","hours","note","dns_mode","paused","services","circle","home_nets","server"]});async function Ti(n,e){let o=[n,...["name","access","device_limit","expires","expire_action","expire_warn","quota_gb","quota_period","bonus_gb","hours","note","dns_mode"].map(a=>e[a]),e.paused,e.services,e.circle,e.home_nets,e.server];return Ho(await Si(...o))}var _i=F("status",["days"]),A={rev:F("rev"),personUpdate:Ti,settingsGet:F("settings_get"),portalInfo:F("portal_info"),settingsUpdate:F("settings_update",["values"]),serviceSet:F("service_set",["id","name","address","ports"]),serviceDelete:F("service_delete",["id"]),geoClear:F("geo_clear"),events:F("events",["limit","person","since"]),logsClear:Mi,interfaces:F("interfaces",["id"]),serverInterfaces:F("server_interfaces",["id","auto_wan","wan_device","auto_lan","lan_devices","lan_like","device_mesh","mesh"]),circleSet:F("circle_set",["id","server","name","color","members"]),circleDelete:F("circle_delete",["id"]),accessCheck:F("access_check",["from","to"]),homeHosts:F("home_hosts",["id"]),usageClear:F("usage_clear",["scope","id"]),uninstall:F("uninstall",["confirm"]),status:_i,setupDefaults:F("setup_defaults"),serverCreate:F("server_create",["id","name","ifname","port","subnet","endpoint","mtu","preset","lan_zone","wan_zone","lan_like","portal_enabled","portal_port"]),serverObfuscation:F("server_obfuscation",["id","preset"]),serverUpdate:F("server_update",["id","values"]),serverPorts:F("server_ports",["id"]),endpointProbe:F("endpoint_probe",["host","id","port"]),serverDelete:F("server_delete",["id"]),personLinks:F("person_links",["id"]),personCreate:F("person_create",["name","slug","server","access","device_limit","expires","quota_gb","quota_period"]),personPause:F("person_pause",["id","paused"]),personRegen:F("person_regen",["id","remove"]),personDelete:F("person_delete",["id"]),personUsage:F("person_usage",["id","days"]),deviceCreate:F("device_create",["person","name","kind"]),deviceConfig:F("device_config",["id"]),deviceUpdate:F("device_update",["id","name","disabled"]),deviceDelete:F("device_delete",["id"]),deviceRotate:F("device_rotate",["id"]),apply:F("apply"),health:F("health"),healthFix:F("health_fix",["id"]),serviceLog:F("service_log"),serviceLogClear:F("service_log_clear",["older_days"]),backupList:F("backup_list"),backupCreate:F("backup_create"),backupRestore:F("backup_restore",["name"]),backupDelete:F("backup_delete",["name"]),backupRead:F("backup_read",["name"]),backupUpload:F("backup_upload",["data"]),exportJson:F("export"),importJson:F("import",["data"]),updatesStatus:F("updates_status"),updatesRun:F("updates_run",["what"]),updatesReleases:F("updates_releases",["page"]),updatesNotes:F("updates_notes",["component","tag","build"]),updatesChanges:F("updates_changes",["from","to"])};function H(n,e,r="neutral",o={}){let{disabled:a,...i}=o,s=t("button",{class:`cbi-button cbi-button-${r}`,type:"button",...i,click:async l=>{if(l.preventDefault(),l.stopPropagation(),!s.disabled){s.disabled=!0,s.classList.add("spinning");try{await e(l)}catch(d){U(be(d),"error")}finally{s.disabled=!1,s.classList.remove("spinning")}}}},n);return s.disabled=!!a,s}function Le(n,e,r,o="neutral",a=""){return H([b(n),t("span",{class:"dl-btn-label"},e)],r,o,{title:e,class:`cbi-button cbi-button-${o} dl-icon-btn ${a}`.trim()})}function $e(n){return document.addEventListener("luci-navigate",n),()=>document.removeEventListener("luci-navigate",n)}var gt=null;function Wn(n=!1){let e=gt;gt=null,e?.(n)}function oe(n,e,r,o=""){Wn();let a=t("div",{class:`dl-modal ${o}`},e),i=t("div",{class:"button-row"},r);a.addEventListener("keydown",s=>{if(s.key==="Escape"){s.preventDefault(),s.stopPropagation(),ae();return}if(s.key!=="Enter"||s.shiftKey||s.ctrlKey||s.metaKey||s.altKey)return;let l=s.target;if(!l||["TEXTAREA","BUTTON","SELECT","A"].includes(l.tagName))return;let d=i.querySelector(".cbi-button-positive");!d||d.disabled||(s.preventDefault(),d.click())}),ui.showModal(n,[a,i])}function ae(){Wn(),ui.hideModal()}function ie(n="Cancel",e=!1){return t("button",{class:`cbi-button ${e?"cbi-button-negative":"cbi-button-neutral"}`,type:"button",click:ae},n)}function le(n,e,r="Confirm",o=!1){return new Promise(a=>{oe(n,e,[ie()," ",t("button",{class:`cbi-button ${o?"cbi-button-negative":"cbi-button-positive"}`,type:"button",click:()=>{let i=gt;gt=null,ui.hideModal(),i?.(!0)}},r)]),gt=a})}$e(()=>{gt&&(Wn(),ui.hideModal())});async function ue(n,e="Copied to clipboard",r=!1){try{if(navigator.clipboard&&window.isSecureContext)await navigator.clipboard.writeText(n);else{let o=t("textarea",{style:"position:fixed;opacity:0"},n);document.body.appendChild(o),o.select();let a=document.execCommand("copy");if(o.remove(),!a)throw new Error("Copying is blocked here. Select the text and copy it by hand.")}return U(e,"success",2500),!0}catch(o){return r||U(be(o),"error"),!1}}function Te(n,e,r="text/plain"){let o=globalThis,a=typeof e=="string"?new o.Blob([e],{type:r}):e,i=URL.createObjectURL(a),s=t("a",{href:i,download:n,style:"display:none"});document.body.appendChild(s),s.click(),setTimeout(()=>{URL.revokeObjectURL(i),s.remove()},1e3)}function Fn(n,e){return new Promise(r=>{let o=t("input",{type:"file",accept:n,style:"display:none"});o.addEventListener("cancel",()=>{o.remove(),r(null)}),o.addEventListener("change",()=>{let a=o.files?.[0];if(o.remove(),!a)return r(null);let i=new FileReader;i.onload=()=>{let s=String(i.result??"");r({name:a.name,data:e==="base64"?s.replace(/^data:[^,]*,/,""):s})},i.onerror=()=>r(null),e==="base64"?i.readAsDataURL(a):i.readAsText(a)}),document.body.appendChild(o),o.click()})}function Ce(n,e){let r=document.querySelector(".dl-dd");if(r&&(r.dlClose?r.dlClose():r.remove(),r.dlAnchor===n))return;let o=t("div",{class:"dl-dd dl-root",role:"menu"},e.map(u=>u?t("button",{type:"button",role:"menuitem",class:u.danger?"danger":u.warn?"warn":"",click:()=>{p(),Ao(u.run)}},[u.icon??"",t("span",{},u.label)]):t("hr")));document.body.appendChild(o);let a=n.getBoundingClientRect(),i=o.offsetWidth,s=o.offsetHeight;o.style.top=`${a.bottom+6+s>window.innerHeight-8&&a.top-6-s>8?a.top-6-s:a.bottom+6}px`,o.style.left=`${Math.max(8,Math.min(a.right-i,window.innerWidth-i-8))}px`;let l=u=>{!o.contains(u.target)&&!n.contains(u.target)&&p()},d=u=>{if(u.key==="Escape"||u.key==="Tab")return p();let x=[...o.querySelectorAll("button:not([disabled])")];if(!x.length||!["ArrowDown","ArrowUp","Home","End"].includes(u.key))return;u.preventDefault();let $=x.indexOf(document.activeElement),h=u.key==="Home"?0:u.key==="End"?x.length-1:u.key==="ArrowDown"?($+1)%x.length:($-1+x.length)%x.length;x[h].focus({preventScroll:!0})},c=$e(p);o.dlAnchor=n,o.dlClose=p;function p(){o.remove(),c(),document.removeEventListener("mousedown",l,!0),document.removeEventListener("keydown",d,!0),window.removeEventListener("scroll",p,!0)}setTimeout(()=>{document.addEventListener("mousedown",l,!0),document.addEventListener("keydown",d,!0),window.addEventListener("scroll",p,!0)}),o.querySelector("button")?.focus({preventScroll:!0})}var dt=null,Je=null,qn=0;function vt(){dt&&(dt.style.display="none"),Je=null,clearInterval(qn),qn=0}function me(n,e){let r=o=>{dt??(dt=document.body.appendChild(t("div",{class:"dl-tip dl-tip-float dl-root"}))),dt.replaceChildren(...e().map(a=>typeof a=="string"?document.createTextNode(a):a)),dt.style.display="",dt.style.left=`${o.clientX}px`,dt.style.top=`${o.clientY-10}px`,Je=n,qn||(qn=window.setInterval(()=>{(!Je?.isConnected||!Je.getClientRects().length)&&vt()},400))};n.addEventListener("mouseenter",r),n.addEventListener("mousemove",r),n.addEventListener("mouseleave",vt),n.addEventListener("pointerup",o=>{o.pointerType!=="mouse"&&(Je===n?vt():r(o))})}$e(vt);window.addEventListener("scroll",()=>Je&&vt(),{capture:!0,passive:!0});document.addEventListener("pointerdown",n=>{Je&&!Je.contains(n.target)&&vt()},!0);function ee(n){if(!n||n<0)return"0 B";let e=["B","KB","MB","GB","TB"],r=0,o=n;for(;o>=1024&&r=100||r===0?Math.round(o):o.toFixed(1)} ${e[r]}`}function Oe(n){let e=n*8;return e<1e3?`${Math.round(e)} bit/s`:e<1e6?`${(e/1e3).toFixed(e<1e4?1:0)} kbit/s`:e<1e9?`${(e/1e6).toFixed(e<1e7?1:0)} Mbit/s`:`${(e/1e9).toFixed(1)} Gbit/s`}function re(n,e=Date.now()/1e3){if(!n)return"never";let r=Math.max(0,Math.round(e-n));return r<60?"just now":r<3600?`${Math.floor(r/60)} min ago`:r<86400?`${Math.floor(r/3600)} h ago`:r<86400*30?`${Math.floor(r/86400)} d ago`:new Date(n*1e3).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"})}function xt(n){if(!n||n<0)return"—";let e=Math.floor(n/86400),r=Math.floor(n%86400/3600),o=Math.floor(n%3600/60);return e?`${e}d ${r}h`:r?`${r}h ${o}m`:`${o}m`}function zt(n){let e=new Date(n*1e3),r=new Date,o=e.toDateString()===r.toDateString(),a=e.toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit"});return o?a:`${e.toLocaleDateString("en-GB",{day:"numeric",month:"short"})} ${a}`}function je(n){return`${n.getFullYear()}-${String(n.getMonth()+1).padStart(2,"0")}-${String(n.getDate()).padStart(2,"0")}`}function wt(n){let[e,r,o]=n.split("-").map(Number);return new Date(e,(r||1)-1,o||1,12)}function Ue(n){return(typeof n=="string"?/^\d{4}-\d{2}-\d{2}$/.test(n)?wt(n):new Date(n):n).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"})}function Me(n){return n?Ue(n):""}function Kn(n,e){let r=o=>{let[a,i,s]=o.split("-").map(Number);return Date.UTC(a,i-1,s)};return Math.round((r(n)-r(e))/864e5)}function Ht(n,e){let r=wt(n);return r.setDate(r.getDate()+e),je(r)}function bt(n,e){let[r,o,a]=n.split("-").map(Number),i=new Date(r,o-1+e,1,12),s=new Date(i.getFullYear(),i.getMonth()+1,0).getDate();return i.setDate(Math.min(a,s)),je(i)}function Ie(n){return n?.length?n[n.length-1].day:je(new Date)}function zo(n,e,r,o,a=30){let i=n||o;return e==="day"?Ht(i,r):e==="week"?Ht(i,7*r):e==="month"?bt(i,r):e==="year"?bt(i,12*r):Ht(i,a*r)}function Ye(n,e=Date.now()){if(!n)return null;let r=typeof e=="number"?je(new Date(e)):e,o=Kn(n,r);return o>=0?o+1:o}function Ze(n,e){return e!=null&&e>0&&n.expire_warn>0&&e<=n.expire_warn}function en(n){return n<=1?"ends today":n===2?"ends tomorrow":`ends in ${n} days`}function tn(n,e,r=`${e}s`){return`${n.toLocaleString("en-GB")} ${n===1?e:r}`}function Nt(n){return n<1024?`${n} B`:n<1048576?`${(n/1024).toFixed(n<10240?1:0)} KB`:`${(n/1048576).toFixed(1)} MB`}var ct={lan:"Home network",internet:"Internet",both:"Home network + Internet"};var No=["computer","phone","tablet","router","other"],Qe={computer:"PC",phone:"Phone",tablet:"Tablet",router:"Router",other:"Other"},Ro={active:"Active",paused:"Paused",expired:"Expired",quota:"Data limit reached",hours:"Outside allowed hours",no_server:"No server",server_off:"Server is turned off"};function He(n){let e=n.trim().split(/\s+/).filter(Boolean);if(!e.length)return"?";let r=e[0][0]??"",o=e.length>1?e[e.length-1][0]??"":e[0][1]??"";return(r+o).toUpperCase()}function nn(n){let e=r=>r.disabled?3:r.online?0:r.handshake?1:2;return n.map((r,o)=>[r,o]).sort((r,o)=>e(r[0])-e(o[0])||r[1]-o[1]).map(([r])=>r)}function Ee(n,e,r){return t("span",{class:`dl-pill ${n}`,title:r??null},e)}function Pi(n){return n.state==="active"?"ok":n.state==="quota"||n.state==="expired"?"bad":"warn"}function Di(n){return n.state==="server_off"&&n.paused?"paused":n.state}function Io(n){let e=Di(n);return e==="active"||e==="server_off"?"":Ee(Pi({...n,state:e}),Ro[e])}function Bo(n){let e=n.access==="both"?["lan","inet"]:n.access==="lan"?["lan"]:["inet"],r=t("span",{class:"dl-access","aria-label":ct[n.access]},e.map(o=>t("span",{class:`dl-ibadge ${o}`},b(o==="lan"?"home":"globe"))));return me(r,()=>[t("div",{class:"dl-tip-title"},ct[n.access]),n.access==="lan"&&n.services?.length?t("div",{class:"dl-muted"},`${n.services.length} home service${n.services.length===1?"":"s"} only`):""]),r}var Ai={paused:"Paused",expired:"Access ended",quota:"Data limit",hours:"Outside hours",server_off:"Server off",no_server:"No server"};function on(n,e,r="Not set up yet",o){let a=n.handshake?`Last seen ${re(n.handshake,e)} · ${new Date(n.handshake*1e3).toLocaleString()}`:"";if(n.disabled)return t("span",{class:"dl-dstat",title:a},"Disabled");if(n.online)return t("span",{class:"dl-dstat ok"},"Connected");let i=o&&Ai[o.state];return i?t("span",{class:"dl-dstat warn",title:a||"Not connected yet"},i):n.handshake?t("span",{class:"dl-dstat",title:new Date(n.handshake*1e3).toLocaleString()},`Last seen ${re(n.handshake,e)}`):t("span",{class:"dl-dstat warn",title:"Waiting for the first connection"},r)}var rn=null;function Oo(n,e,r,o){rn?.close();let a=t("aside",{class:"dl-drawer",role:"dialog","aria-modal":"true"},[t("div",{class:"dl-drawer-head"},[n,t("button",{type:"button",class:"dl-drawer-x","aria-label":"Close",click:()=>c()},b("x"))]),t("div",{class:"dl-drawer-body"},e),r?t("div",{class:"dl-drawer-foot"},r):""]),i=t("div",{class:"dl-drawer-overlay dl-root",click:u=>{u.target===i&&c()}},a),s=u=>{u.key==="Escape"&&!document.body.classList.contains("modal-overlay-active")&&c()},l=!1,d=$e(()=>c());function c(){l||(l=!0,d(),document.removeEventListener("keydown",s),i.classList.remove("open"),setTimeout(()=>i.remove(),220),rn===p&&(rn=null),o())}let p={close:c,panel:a};return document.addEventListener("keydown",s),document.body.appendChild(i),requestAnimationFrame(()=>i.classList.add("open")),rn=p,p}function ce(n,e,r){return t("div",{class:"dl-setrow"},[t("div",{class:"dl-stack"},[t("span",{class:"dl-setrow-label"},n),r?t("span",{class:"dl-sub"},r):""]),t("div",{class:"dl-setrow-ctl"},e)])}function he(n,e,r,o=e){let a=ce(n,o," "),i=a.querySelector(".dl-sub"),s=()=>{let l=r();i.textContent=l.text,i.classList.toggle("bad",l.bad),e.classList.toggle("cbi-input-invalid",l.bad)};return e.addEventListener("input",s),a.refresh=s,a.help=r,s(),a}function ye(n,e,r,o=e){let a=t("div",{class:"dl-sub"}),i=t("div",{class:"cbi-value dl-live"},[t("div",{class:"cbi-value-title"},[t("label",{},n),a]),t("div",{class:"cbi-value-field"},o)]),s=()=>{let l=r();a.textContent=l.text,a.classList.toggle("bad",l.bad),e.classList.toggle("cbi-input-invalid",l.bad)};return e.addEventListener("input",s),e.addEventListener("change",s),i.refresh=s,i.help=r,s(),i}function ze(n,e=[]){for(let r of n){let o=r.help?.();if(o?.bad)return o.text}for(let r of e){let o=r();if(o.bad)return o.text}return null}function Rt(n,e,r,o=""){return t("section",{class:`dl-setsec ${o}`},[t("div",{class:"dl-setsec-body"},[n?t("h3",{},n):"",...e]),r.length?t("div",{class:"dl-setsec-foot"},r):""])}function fe(n,e,r,o){return t("div",{class:"dl-group"},[t("div",{class:"dl-group-head"},[t("span",{class:"dl-group-ic"},b(n)),t("span",{class:"dl-stack"},[t("b",{},e),r?t("span",{class:"dl-sub"},r):""])]),t("div",{class:"dl-group-body"},o.filter(a=>a!==""))])}function Xe(n,e,r,o,a){return t("div",{class:`dl-row dl-need-row ${e}`},[e?t("span",{class:"dl-need-ic"},b(n)):b(n),t("span",{class:"dl-row-main dl-stack"},[t("b",{},r),t("span",{class:"dl-sub"},o)]),a])}function pt(n,e){let r={ok:"success",warn:"warning",error:"error",info:"notice"}[n];return t("div",{class:`alert-message ${r}`},e)}function et(n,e=""){let r=t("div",{class:e});return r.innerHTML=n,r}function Vn(n){let e=/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\/(\d{1,2})$/.exec(n.trim());if(!e)return null;let[r,o,a,i]=e.slice(1,5).map(Number),s=Number(e[5]);if([r,o,a,i].some(c=>c>255)||s<8||s>30)return null;let l=r*2**24+o*2**16+a*2**8+i,d=2**(32-s);return{net:l-l%d,size:d}}var Hi=(n,e)=>n.netVn(n));function $t(n){return n.split("/")[0].split(".").slice(0,3).join(".")}function an(n){return`${n.trim()}.0/24`}function Yn(n,e,r){let o=n.trim(),a=/^\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(o)?Vn(an(o)):null;if(!a)return{text:"Three numbers, like 10.77.0.",bad:!0};if(!zi.some(s=>a.net>=s.net&&a.net+a.size<=s.net+s.size))return{text:"Use a private range: 10.x.x, 172.16–31.x or 192.168.x.",bad:!0};let i=e.find(s=>{let l=Vn(s.cidr);return l!=null&&Hi(a,l)});if(i){let s=i.cidr.endsWith("/24")?`${$t(i.cidr)}.x`:i.cidr,l=r&&r!==o?` Try ${r}.`:"";return{text:`${i.name} already uses ${s}.${l}`,bad:!0}}return{text:`Devices get ${o}.2 – ${o}.254, the router ${o}.1.`,bad:!1}}var Uo=(n,e)=>e.find(r=>r.from<=n&&n<=r.to)?.who??null,Ni=n=>Number.isInteger(n)&&n>=1&&n<=65535;function It(n,e,r){if(!Ni(n))return{text:"Use a port from 1 to 65535.",bad:!0};let o=Uo(n,e);return o?{text:`Used by ${o}. Choose another port.`,bad:!0}:{text:r,bad:!1}}function sn(n,e,r){let o=r?`HTTPS here, plain HTTP for links on IP addresses on ${n+1}.`:"HTTPS on this port, opened on WAN.",a=It(n,e,o);if(a.bad||!r)return a;if(n===65535)return{text:"Links on IP addresses also need the next port: choose a lower one.",bad:!0};let i=Uo(n+1,e);return i?{text:`Links on IP addresses also need ${n+1}, used by ${i}. Choose another port.`,bad:!0}:a}var yt=n=>Array.from(n).length,jo=48,Ri=/[<>"\\\u0000-\u001f\u007f]/;function _e(n,e=[],r=""){let o=n.trim();return o?yt(n)>jo?{text:`Up to ${jo} characters (${yt(n)} now).`,bad:!0}:Ri.test(n)?{text:'Names can’t contain < > " or \\.',bad:!0}:e.some(a=>a.toLowerCase()===o.toLowerCase())?{text:`“${o}” already exists — pick another name.`,bad:!0}:{text:r,bad:!1}:{text:"Enter a name.",bad:!0}}function Go(n,e=[]){return yt(n)>32?{text:`Up to 32 characters (${yt(n)} now).`,bad:!0}:_e(n,e,"Shown on the person cards.")}var Ii=/^[A-Za-z0-9]([A-Za-z0-9-]{0,61}[A-Za-z0-9])?(\.[A-Za-z0-9]([A-Za-z0-9-]{0,61}[A-Za-z0-9])?)*$/,Bi=/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/;function Ct(n){let e=Bi.exec(n);return!!e&&e.slice(1).every(r=>Number(r)<=255)}function Jn(n){return/^([0-9a-fA-F]{0,4}:){2,7}[0-9a-fA-F]{0,4}$/.test(n)&&!/:::/.test(n)}function kt(n,e,r=null){let o=n.trim();if(!o)return r!=null?{text:r,bad:!1}:{text:"Enter a hostname or IP address.",bad:!0};if(/^[a-z]+:\/\//i.test(o))return{text:"Leave out https:// — just the name.",bad:!0};if(/\/.*/.test(o))return{text:"Just the name, without a path.",bad:!0};if(/^[^:\[]+:\d+$/.test(o))return{text:"Just the name, without a port (the port is on AmneziaWG).",bad:!0};if(/\s/.test(o))return{text:"A hostname has no spaces.",bad:!0};if(o.length>253||!(Ii.test(o)||Ct(o)||Jn(o)))return{text:"Use a hostname or an IP address.",bad:!0};let a=Jn(o)?`[${o}]`:o;return{text:e?`Devices connect to ${a}:${e}.`:`Links use ${a}.`,bad:!1}}function Wo(n,e){let r=n.split(/[ ,]+/).filter(Boolean);if(!r.length)return{text:`This router (${e}): queries go where your home network sends them, and home names work.`,bad:!1};let o=r.find(a=>!Ct(a)&&!Jn(a));return o?{text:`“${o}” is not an IP address. Separate several with commas.`,bad:!0}:{text:`Devices use ${r.join(" and ")} — home names and your LAN’s DNS filters no longer apply to them.`,bad:!1}}function Fo(n,e){let r=n.trim();if(!r)return{text:`Automatic by device type and disguise: ${e.computer} for computers and routers, ${e.phone} for phones and tablets.`,bad:!1};if(!/^\d{1,4}$/.test(r)||Number(r)<1280||Number(r)>1500)return{text:"MTU must be 1280–1500, or empty for automatic.",bad:!0};let o=Number(r);return{text:`Computers and routers get ${o}, phones and tablets ${Math.min(o,1280)}.`,bad:!1}}function qo(n){let e=n.trim();return e?!/^\d{1,3}$/.test(e)||Number(e)>600?{text:"Use 0–600 seconds.",bad:!0}:Number(e)===0?{text:"Off: NAT may close the tunnel when idle, and “Connected” lags.",bad:!1}:{text:`Devices send a packet every ${e} s to keep NAT open (a little battery on phones).`,bad:!1}:{text:"Default: a packet every 25 s keeps NAT open and “Connected” accurate.",bad:!1}}function ln(n,e=0){let r=n.trim();if(!/^\d{1,2}$/.test(r)||Number(r)<1||Number(r)>32)return{text:"Use 1–32.",bad:!0};let o=Number(r);return e>o?{text:`Already has ${e} devices: remove ${e-o===1?"one":`${e-o}`} first, or allow more.`,bad:!0}:{text:`They can add ${o} device${o===1?"":"s"} themselves.`,bad:!1}}function dn(n,e=!0){let r=n.trim();if(!r)return{text:"Optional. No data limit.",bad:!1};let o=Number(r);return!/^\d+(\.\d+)?$/.test(r)||o<0||o>1e5?{text:"A number of GB, up to 100000.",bad:!0}:o===0?{text:"Optional. No data limit.",bad:!1}:{text:e?`Paused after ${r} GB this month, resumed on the 1st.`:`Paused after ${r} GB in total.`,bad:!1}}function Ko(n,e,r,o){let a=n.trim();if(!a)return{text:"Optional. No end date.",bad:!1};let i=r(a,e);return i==null?{text:"Use a date.",bad:!0}:i<0?{text:"That date has passed: access would end at once.",bad:!0}:{text:i===1?`Access ends today (${o(a)}).`:`Access ends in ${i} days (${o(a)}).`,bad:!1}}function Vo(n,e=null){let r=n.trim();return r?Ct(r)?e&&!e(r)?{text:`${r} is not in any home network of this server: nobody would reach it.`,bad:!1}:{text:"",bad:!1}:{text:"Use an IPv4 address, like 192.168.1.10.",bad:!0}:{text:"The device’s address at home.",bad:!0}}function Jo(n){let e=n.split(/[ ,]+/).filter(Boolean);if(!e.length)return{text:"All ports.",bad:!1};let r=e.find(o=>!/^\d{1,5}$/.test(o)||Number(o)<1||Number(o)>65535);return r?{text:`“${r}” is not a port (1–65535).`,bad:!0}:{text:`Port${e.length===1?"":"s"} ${e.join(", ")}.`,bad:!1}}function Yo(n){let e=n.trim();return e?/^https?:\/\//i.test(e)?e.length>300||!/^https?:\/\/[A-Za-z0-9.-]+(:[0-9]+)?(\/[^\s"'<>]*)?$/.test(e)?{text:"Not a usable address (no spaces or quotes).",bad:!0}:{text:"Wrong links are sent there instead of a “Not found”.",bad:!1}:{text:"Must start with http:// or https://.",bad:!0}:{text:"Wrong links get a bare “Not found”.",bad:!1}}function Zo(n){return yt(n)>64?{text:`Up to 64 characters (${yt(n)} now).`,bad:!0}:/[\u0000-\u001f\u007f]/.test(n)?{text:"One line, please.",bad:!0}:{text:"Shown in the browser tab and at the top of the portal.",bad:!1}}function Qo(n,e="phone.myata"){let r=n.trim();return r?/^[a-z0-9-]{1,32}(\.[a-z0-9-]{1,32})*$/.test(r)?{text:`Devices get names like ${e}.${r}.`,bad:!1}:{text:/[A-Z]/.test(r)?"Lowercase only.":"Lowercase letters, digits, dashes and dots.",bad:!0}:{text:`The default, lan: devices get names like ${e}.lan.`,bad:!1}}function Xo(n){let e=n.trim();return e?Ct(e)?{text:`${e} takes over when the tunnel is down.`,bad:!1}:{text:"Use an IPv4 address, or leave it empty.",bad:!0}:{text:"None: without the tunnel those devices have no DNS.",bad:!1}}function er(n){let e=n.trim();return/^([01]?[0-9]|2[0-3]):[0-5][0-9]$/.test(e)?{text:`Runs within an hour after ${e} (router time).`,bad:!1}:{text:"Use HH:MM, 00:00–23:59.",bad:!0}}function Zn(n,e,r,o={}){let a=0,i="",s=null;return{help:()=>{let{host:c,port:p}=n(),u=kt(c,p,o.empty??null);if(u.bad||!c.trim())return u;if(s&&s.host===c.trim())return{text:s.text,bad:s.bad};let x=o.idle?.();return{text:x?`${x} Checking where it points…`:`${u.text} Checking where it points…`,bad:!1}},schedule:()=>{let{host:c}=n(),p=kt(c,n().port,o.empty??null);p.bad||!c.trim()||c.trim()===s?.host||(clearTimeout(a),a=window.setTimeout(async()=>{let u=c.trim();i=u;try{let{id:x,port:$}=n(),h=await e(u,x,$);if(i!==u)return;s={host:u,text:h.text,bad:h.status==="error"}}catch{if(i!==u)return;s={host:u,text:p.text,bad:!1}}r()},700))}}}var ir=Ei(rr(),1),Oi=n=>``,ar="#0a0a0a",Qn="#f2f2f2",ji=n=>n.length>300,Et=n=>+n.toFixed(2);function Xn(n,e,r,o,a){return`M${Et(n+a)} ${Et(e)}h${Et(r-2*a)}a${a} ${a} 0 0 1 ${a} ${a}v${Et(o-2*a)}a${a} ${a} 0 0 1 -${a} ${a}h-${Et(r-2*a)}a${a} ${a} 0 0 1 -${a} -${a}v-${Et(o-2*a)}a${a} ${a} 0 0 1 ${a} -${a}z`}function Lt(n,e=3,r=!0,o="plain"){let a=ji(n),i=o==="night",s=(0,ir.default)(0,a?"L":"H");s.addData(n,"Byte"),s.make();let l=s.getModuleCount(),d=l+e*2,c=r&&!a?Math.round(l*.22):0;c&&(l-c)%2&&c++;let p=(l-c)/2,u=p+c,x=(w,v)=>c>0&&w>=p&&w=p&&vi&&(v<7&&w<7||v<7&&w>=l-7||v>=l-7&&w<7),h="";if(i){let w=a?.48:.42;for(let v=0;v${Oi(i?ar:"#fff")}`}let B=``;return i?`${B}${C}`:`${B}${C}`}var Ui={connect:"connections",disconnect:"connections",roam:"connections",device_added:"people",device_removed:"people",devices_removed:"people",device_changed:"people",device_keys:"people",link_changed:"people",person_added:"people",person_removed:"people",person_changed:"people",paused:"people",resumed:"people",expiring:"people",expired_kept:"people",portal_blocked:"problems"},Mt=["connections","people","problems"],ut={connections:"Connections",people:"People",problems:"Problems"},sr={connections:"Connects, disconnects and IP changes",people:"People and their devices added, changed, paused, removed",problems:"Blocked portal sign-ins (tunnels and services are in the service log)"},Bt=n=>Ui[n]??"problems",Ot={awg:"AmneziaWG",dawnline:"Dawnline",portal:"Portal"},Gi=["person_added","person_removed","person_changed"];function Ne(n){return n.by?n.by:Gi.includes(n.type)||n.detail==="by admin"||n.detail?.endsWith(" (admin)")?"admin":n.detail?.endsWith(" (portal)")?"portal":null}function lr(n){return(n.detail??"").replace(/ \((admin|portal)\)$/,"").replace(/^by admin$/,"")}var cn=n=>n.sys?["error","repair","down"].includes(n.sys.level):Bt(n.ev.type)==="problems";function pn(n){let e=n.keep_days>0?`${n.keep_days} day${n.keep_days===1?"":"s"}`:"no age limit",r=n.persist==="off"?"kept in memory only (lost on reboot)":`saved to flash ${n.persist==="10min"?"every 10 minutes":"hourly"}`;return`Kept for ${e}, up to ${n.max.toLocaleString("en-GB")} events, ${r}.`}function dr(n,e=120,r=26,o=je(new Date)){let a=Math.max(1,...n),i=t("div",{class:"dl-spark"});return i.style.width=`${e}px`,i.style.height=`${r}px`,n.forEach((s,l)=>{let d=t("i");d.style.height=`${Math.max(6,s/a*100)}%`,s||d.classList.add("zero");let c=n.length-1-l;me(d,()=>[t("div",{class:"dl-tip-title"},c===0?"Today":c===1?"Yesterday":wt(Ht(o,-c)).toLocaleDateString("en-GB",{weekday:"short",day:"numeric",month:"short"})),t("div",{class:"dl-muted"},ee(s))]),i.appendChild(d)}),i}function Wi(n){let e=n==null?"":String(n);return/^[=+\-@\t\r]/.test(e)&&(e=`'${e}`),/[",\r\n]/.test(e)?`"${e.replace(/"/g,'""')}"`:e}function cr(n,e){return[n.join(","),...e.map(r=>n.map(o=>Wi(r[o])).join(","))].join(` -`)}function Fi(n){let e=new Map(n.people.map(o=>[o.id,o.name])),r=new Map(n.people.flatMap(o=>o.devices.map(a=>[a.id,a.name])));return{people:e,devices:r}}function Fe(n,e,r,o="",a=[]){let i=Fi(n),s=[...e.map(p=>({ts:p.ts,category:Bt(p.type),type:p.type,person:p.person?i.people.get(p.person)??p.pname??p.person:"",device:p.device?i.devices.get(p.device)??p.dname??p.device:"",detail:p.detail??"",where:p.where??"",by:Ne(p)??""})),...a.map(p=>({ts:p.ts,category:"system",type:`${p.src}.${p.level}`,person:"",device:"",detail:`${p.who?`${p.who} `:""}${p.msg}${p.detail?` -${p.detail}`:""}`,where:Ot[p.src]??p.src,by:""}))].sort((p,u)=>p.ts-u.ts).map(({ts:p,...u})=>({time:new Date(p*1e3).toISOString(),...u})),l=new Date().toISOString().slice(0,10),d=`dawnline-activity${o?`-${o}`:""}-${l}.${r}`;if(r==="json"){Te(d,JSON.stringify(s,null,2),"application/json");return}Te(d,cr(["time","category","type","person","device","detail","where","by"],s),"text/csv")}var qi=[["","Everything"],["7","Older than 7 days"],["30","Older than 30 days"],["90","Older than 90 days"]],pr=n=>n?`${n} event${n===1?"":"s"} removed`:"Nothing matched";function tt(n,e,r,o,a,i=!1){let s=t("select",{class:"cbi-input-select"},[t("option",{value:""},"All categories"),...Mt.map(d=>t("option",{value:d,selected:d===a?"selected":null},ut[d])),i?t("option",{value:"system",selected:a==="system"?"selected":null},"System"):""]),l=t("select",{class:"cbi-input-select"},qi.map(([d,c])=>t("option",{value:d},c)));oe(n,[t("p",{class:"dl-muted"},`${e} This cannot be undone; export first if you want a copy.`),t("label",{class:"dl-fld"},[t("span",{class:"dl-fld-label"},"Category"),s]),t("label",{class:"dl-fld"},[t("span",{class:"dl-fld-label"},"Which events"),l])],[ie()," ",H("Clear",async()=>{let d=0;if(s.value!=="system")try{d+=(await A.logsClear({...r,category:s.value,older_days:l.value})).removed}catch(c){U(be(c),"error",1e4);return}if(i&&(s.value==="system"||s.value===""))try{d+=(await A.serviceLogClear(l.value)).removed}catch(c){ae(),U(`${s.value==="system"?"":`Activity: ${pr(d).toLowerCase()}. `}The service log was not cleared: ${be(c)}`,"error",1e4),o();return}ae(),U(pr(d),"success",3e3),o()},"negative")])}function St(n,e,r,o){let a=n==="device"?`Clears ${r}'s daily and monthly traffic history. Their person's totals and data limit are not changed.`:n==="person"?`Clears ${r}'s traffic history and that of their devices. Their data limit starts again from zero.`:"Clears traffic history for everyone. Data limits start again from zero.";oe(n==="all"?"Reset all traffic history?":`Reset traffic history for ${r}?`,[t("p",{class:"dl-muted"},a)],[ie()," ",H("Reset",async()=>{await G(()=>A.usageClear(n,e),"Traffic history reset")&&(ae(),o())},"negative")])}function ve(n,e,r){let o=t("button",{type:"button",role:"switch",class:`dl-switch${n?" on":""}`,"aria-checked":n?"true":"false","aria-label":e,click:()=>{let a=!o.classList.contains("on");eo(o,a),r?.(a)}},t("i"));return o}function eo(n,e){n.classList.toggle("on",e),n.setAttribute("aria-checked",e?"true":"false")}var Pe=n=>n.classList.contains("on");function we(n,e,r={}){n.some(([i])=>i===e)||(n=[...n,[e,e]]);let o=t("div",{class:`dl-seg${r.cls?` ${r.cls}`:""}`,role:"radiogroup","aria-label":r.label??null,"data-value":e}),a=()=>o.querySelectorAll(":scope > button").forEach(i=>{let s=i.dataset.v===o.dataset.value;i.classList.toggle("on",s),i.setAttribute("aria-checked",s?"true":"false")});for(let[i,s]of n)o.appendChild(t("button",{type:"button",role:"radio","data-v":i,click:()=>{i!==o.dataset.value&&(r.optimistic!==!1&&(o.dataset.value=i,a()),r.onChange?.(i))}},s));return a(),o}function qe(n,e,r,o={}){return t("button",{type:"button",...o,class:`dl-chipbtn${e?" on":""}${o.class?` ${o.class}`:""}`,"aria-pressed":e?"true":"false",click:r},n)}function un(n,e){n.classList.toggle("on",e),n.setAttribute("aria-pressed",e?"true":"false")}function se(n,e={}){return t("input",{type:"text",class:"cbi-input-text",value:n,...e})}var Ki={jc:"0",jmin:"0",jmax:"0",s1:"0",s2:"0",s3:"0",s4:"0",h1:"1",h2:"2",h3:"3",h4:"4",i1:"",i2:"",i3:"",i4:"",i5:""},Vi={header_protection_key:"HeaderProtectionKey",content_padding_addition:"ContentPaddingAddition",rekey_after_time:"RekeyAfterTime",rekey_timeout:"RekeyTimeout",reject_after_time:"RejectAfterTime",keepalive_timeout:"KeepaliveTimeout",max_handshake_attempts:"MaxHandshakeAttempts",random_trailers:"RandomTrailers",disable_cookies:"DisableCookies"};function Ji(n){let e={};for(let[r,o]of Object.entries(Vi))n[r]!=null&&n[r]!==""&&(e[o]=String(n[r]));return e}function Yi(n,e){let r=n.amnezia,o=r.obfuscation??{},a=d=>o[d]!=null&&o[d]!==""?String(o[d]):Ki[d],i=r.host.replace(/^\[(.*)\]$/,"$1"),s={H1:a("h1"),H2:a("h2"),H3:a("h3"),H4:a("h4"),I1:a("i1"),I2:a("i2"),I3:a("i3"),I4:a("i4"),I5:a("i5"),Jc:a("jc"),Jmin:a("jmin"),Jmax:a("jmax"),S1:a("s1"),S2:a("s2"),S3:a("s3"),S4:a("s4"),...Ji(o),allowed_ips:r.allowed_ips,client_ip:r.client_ip,client_priv_key:r.client_priv_key,client_pub_key:r.client_pub_key,config:n.conf.replace(/\r?\n/g,`\r -`),hostName:i,mtu:r.mtu,persistent_keep_alive:r.persistent_keep_alive,port:Number(r.port),psk_key:r.psk_key,server_pub_key:r.server_pub_key},l={containers:[{container:"amnezia-awg",awg:{isThirdPartyConfig:!0,last_config:JSON.stringify(s),port:String(r.port),protocol_version:o.header_protection_key?"3.1":"2",transport_proto:"udp"}}],defaultContainer:"amnezia-awg",description:e,hostName:i};return r.dns[0]&&(l.dns1=r.dns[0]),r.dns[1]&&(l.dns2=r.dns[1]),l}function Zi(n){let e="";for(let r=0;r"u")return null;try{let r=new e.Blob([n]).stream().pipeThrough(new e.CompressionStream("deflate")),o=new Uint8Array(await new e.Response(r).arrayBuffer()),a=new Uint8Array(4+o.length);return new DataView(a.buffer).setUint32(0,n.length,!1),a.set(o,4),a}catch{return null}}async function to(n,e,r=!0){let o=new TextEncoder().encode(JSON.stringify(Yi(n,e))),a=r?await Qi(o):null;return`vpn://${Zi(a??o)}`}var mr=[{id:"off",title:"Off",ic:"zap",stealth:0,speed:4,text:"Plain WireGuard-compatible traffic. Fastest, but easy to recognise and block.",apps:"Any WireGuard app",short:"Any WireGuard app"},{id:"balanced",title:"Balanced",ic:"shield",stealth:3,speed:4,needs:"v2",text:"AmneziaWG 2.0: junk packets, padded packets and a first packet that looks like DNS. For networks that learned to spot 1.0-style junk.",apps:"AmneziaVPN 4.8.12 or newer, AmneziaWG 2.0+ apps",short:"AmneziaWG 2.0+ apps"},{id:"max",title:"Maximum",ic:"lock",stealth:4,speed:3,needs:"v3",text:"AmneziaWG 3.1: encrypted packet headers, random tails and sizes, jittered timing, and a first packet that looks like DNS.",apps:"Apps with AmneziaWG 3.1 (current AmneziaVPN)",short:"AmneziaWG 3.1 apps"}],jt=n=>mr.find(e=>e.id===n),mn=n=>n.v3?"max":n.v2?"balanced":"off",Ut=n=>n==="standard"?"Standard (old)":n==="strong"?"Strong (old)":null,Xi={v2:"Needs AmneziaWG 2.0 or newer on the router (kmod-amneziawg and amneziawg-tools from July 2025 on).",v3:"Needs AmneziaWG 3.1 on the router (kmod-amneziawg and amneziawg-tools 3.1)."},es={v2:"Needs AmneziaWG on the router.",v3:"Needs AmneziaWG 3.1 on the router: install it first."};function ur(n,e){return t("span",{class:"dl-dots",title:`${e}: ${n} of 4`},[t("span",{class:"dl-dots-label"},e),t("span",{class:"dl-dots-row"},[0,1,2,3].map(r=>t("i",{class:rdom.content(i,mr.map(l=>{let d=!l.needs||n[l.needs],c=l.id===e;return t("button",{type:"button",role:"radio","aria-checked":c?"true":"false","aria-disabled":d?null:"true",class:`dl-method${c?" on":""}${d?"":" off"}`,click:()=>{!d||c||(e=l.id,s(),r(l.id))}},[t("div",{class:"dl-method-head"},[t("span",{class:"dl-method-ic"},b(l.ic)),t("b",{},l.title),l.id===o?t("span",{class:"dl-pill ok"},"Current"):""]),t("p",{},l.text),t("div",{class:"dl-method-meters"},[ur(l.stealth,"Stealth"),ur(l.speed,"Speed")]),t("div",{class:"dl-method-foot"},d?[b(l.id==="off"?"wireguard":"amneziawg"),t("span",{},l.apps)]:[b("alert"),t("span",{},(a?Xi:es)[l.needs])])])}));return s(),i}function hr(n,e){return t("div",{class:"dl-corehead"},[t("h3",{},n),e?t("span",{class:"dl-sub"},e):""])}var fr=[["jc","Jc"],["jmin","Jmin"],["jmax","Jmax"],["s1","S1"],["s2","S2"],["s3","S3"],["s4","S4"],["h1","H1"],["h2","H2"],["h3","H3"],["h4","H4"],["i1","I1"],["i2","I2"],["i3","I3"],["i4","I4"],["i5","I5"],["header_protection_key","HeaderProtectionKey"],["content_padding_addition","ContentPaddingAddition"],["rekey_after_time","RekeyAfterTime"],["rekey_timeout","RekeyTimeout"],["reject_after_time","RejectAfterTime"],["keepalive_timeout","KeepaliveTimeout"],["max_handshake_attempts","MaxHandshakeAttempts"],["random_trailers","RandomTrailers"],["disable_cookies","DisableCookies"]];function ts(n){let e=c=>n[c]!=null&&n[c]!=="",r=fr.filter(([c])=>e(c));if(!r.length)return null;let o=(c,p)=>t("span",{class:"dl-pv"},[t("i",{},p),t("b",{},c==="header_protection_key"?`${n[c].slice(0,6)}••••`:n[c])]),a=(c,p,u,x)=>{let $=fr.filter(([h])=>x.includes(h)&&e(h));return $.length?t("div",{class:"dl-pgroup"},[t("div",{class:"dl-pgroup-head"},[b(p),t("b",{},c)]),t("p",{},u),t("div",{class:"dl-pvals"},$.map(([h,m])=>o(h,m)))]):""},i=Number(n.jc||0),s=(n.i1??"").includes("0x8580")?"A first packet shaped like a DNS answer.":"Extra packets sent before the handshake.",l=r.map(([c,p])=>`${p} = ${n[c]}`).join(` -`),d=t("div",{class:"dl-pgrid"},[a("Junk packets","zap",i?`${i} random packet${i===1?"":"s"} of ${n.jmin}–${n.jmax} bytes before each handshake.`:"No junk packets.",["jc","jmin","jmax"]),a("Padding","archive","Random bytes in front of handshake, cookie and data packets, so their sizes do not match WireGuard.",["s1","s2","s3","s4"]),a("Packet types","key","The values that replace WireGuard’s recognisable message types.",["h1","h2","h3","h4"]),a("Signatures","globe",s,["i1","i2","i3","i4","i5"]),a("Protection","lock","AmneziaWG 3.1: encrypted headers, random tails and extra padding on data packets.",["header_protection_key","content_padding_addition","random_trailers","disable_cookies"]),a("Timing","clock","Handshake and key timers vary within these ranges instead of WireGuard’s fixed values.",["rekey_after_time","rekey_timeout","reject_after_time","keepalive_timeout","max_handshake_attempts"])]);return t("details",{class:"dl-params"},[t("summary",{},[b("chevron"),t("span",{},"Current parameters"),t("span",{class:"dl-pcount"},String(r.length)),t("span",{class:"dl-spacer"}),t("button",{type:"button",class:"dl-linkbtn",click:c=>{c.preventDefault(),ue(l,"Parameters copied")}},"Copy as config")]),d])}function gr(n,e){if(/^\s*\[.+\]\s*$/.test(n))return t("span",{class:"dl-conf-sec"},n);let r=/^(\s*[A-Za-z0-9]+\s*=)\s*(.*)$/.exec(n);if(!r)return document.createTextNode(n);let o=/^(\s*)(PrivateKey|PresharedKey)\b/.test(n);return t("span",{},[t("span",{class:"dl-conf-k"},r[1])," ",o&&!e?t("span",{class:"dl-conf-mask"},"••••••••••••••••"):r[2]])}function ns(n){let e=!1,r=t("pre",{class:"dl-conf"}),o=()=>dom.content(r,n.conf.split(` +var vi=Object.create;var Po=Object.defineProperty;var bi=Object.getOwnPropertyDescriptor;var xi=Object.getOwnPropertyNames;var wi=Object.getPrototypeOf,yi=Object.prototype.hasOwnProperty;var ki=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports);var $i=(n,e,r,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of xi(e))!yi.call(n,a)&&a!==r&&Po(n,a,{get:()=>e[a],enumerable:!(o=bi(e,a))||o.enumerable});return n};var Ci=(n,e,r)=>(r=n!=null?vi(wi(n)):{},$i(e||!n||!n.__esModule?Po(r,"default",{value:n,enumerable:!0}):r,n));var Wo=ki((Uo,Go)=>{"use strict";var jo=(function(){var n=function(C,k){var y=236,w=17,b=C,H=r[k],f=null,g=0,M=null,T=[],z={},W=function(A,N){g=b*4+17,f=(function(S){for(var O=new Array(S),_=0;_=7&&Q(A),M==null&&(M=F(b,H,T)),ee(M,N)},q=function(A,N){for(var S=-1;S<=7;S+=1)if(!(A+S<=-1||g<=A+S))for(var O=-1;O<=7;O+=1)N+O<=-1||g<=N+O||(0<=S&&S<=6&&(O==0||O==6)||0<=O&&O<=6&&(S==0||S==6)||2<=S&&S<=4&&2<=O&&O<=4?f[A+S][N+O]=!0:f[A+S][N+O]=!1)},Z=function(){for(var A=0,N=0,S=0;S<8;S+=1){W(!0,S);var O=a.getLostPoint(z);(S==0||A>O)&&(A=O,N=S)}return N},I=function(){for(var A=8;A>S&1)==1;f[Math.floor(S/3)][S%3+g-8-3]=O}for(var S=0;S<18;S+=1){var O=!A&&(N>>S&1)==1;f[S%3+g-8-3][Math.floor(S/3)]=O}},de=function(A,N){for(var S=H<<3|N,O=a.getBCHTypeInfo(S),_=0;_<15;_+=1){var j=!A&&(O>>_&1)==1;_<6?f[_][8]=j:_<8?f[_+1][8]=j:f[g-15+_][8]=j}for(var _=0;_<15;_+=1){var j=!A&&(O>>_&1)==1;_<8?f[8][g-_-1]=j:_<9?f[8][15-_-1+1]=j:f[8][15-_-1]=j}f[g-8][8]=!A},ee=function(A,N){for(var S=-1,O=g-1,_=7,j=0,Y=a.getMaskFunction(N),J=g-1;J>0;J-=2)for(J==6&&(J-=1);;){for(var ue=0;ue<2;ue+=1)if(f[O][J-ue]==null){var xe=!1;j>>_&1)==1);var te=Y(O,J-ue);te&&(xe=!xe),f[O][J-ue]=xe,_-=1,_==-1&&(j+=1,_=7)}if(O+=S,O<0||g<=O){O-=S,S=-S;break}}},B=function(A,N){for(var S=0,O=0,_=0,j=new Array(N.length),Y=new Array(N.length),J=0;J=0?So.getAt(To):0}}for(var _o=0,te=0;teJ*8)throw"code length overflow. ("+_.getLengthInBits()+">"+J*8+")";for(_.getLengthInBits()+4<=J*8&&_.put(0,4);_.getLengthInBits()%8!=0;)_.putBit(!1);for(;!(_.getLengthInBits()>=J*8||(_.put(y,8),_.getLengthInBits()>=J*8));)_.put(w,8);return B(_,O)};z.addData=function(A,N){N=N||"Byte";var S=null;switch(N){case"Numeric":S=c(A);break;case"Alphanumeric":S=p(A);break;case"Byte":S=u(A);break;case"Kanji":S=x(A);break;default:throw"mode:"+N}T.push(S),M=null},z.isDark=function(A,N){if(A<0||g<=A||N<0||g<=N)throw A+","+N;return f[A][N]},z.getModuleCount=function(){return g},z.make=function(){if(b<1){for(var A=1;A<40;A++){for(var N=l.getRSBlocks(A,H),S=d(),O=0;O"u"?A*4:N;var S="";S+='";for(var _=0;_';S+=""}return S+="",S+="
",S},z.createSvgTag=function(A,N,S,O){var _={};typeof arguments[0]=="object"&&(_=arguments[0],A=_.cellSize,N=_.margin,S=_.alt,O=_.title),A=A||2,N=typeof N>"u"?A*4:N,S=typeof S=="string"?{text:S}:S||{},S.text=S.text||null,S.id=S.text?S.id||"qrcode-description":null,O=typeof O=="string"?{text:O}:O||{},O.text=O.text||null,O.id=O.text?O.id||"qrcode-title":null;var j=z.getModuleCount()*A+N*2,Y,J,ue,xe,te="",De;for(De="l"+A+",0 0,"+A+" -"+A+",0 0,-"+A+"z ",te+=''+ne(O.text)+"":"",te+=S.text?''+ne(S.text)+"":"",te+='',te+='"u"?A*4:N;var S=z.getModuleCount()*A+N*2,O=N,_=S-N;return R(S,S,function(j,Y){if(O<=j&&j<_&&O<=Y&&Y<_){var J=Math.floor((j-O)/A),ue=Math.floor((Y-O)/A);return z.isDark(ue,J)?0:1}else return 1})},z.createImgTag=function(A,N,S){A=A||2,N=typeof N>"u"?A*4:N;var O=z.getModuleCount()*A+N*2,_="";return _+="",_};var ne=function(A){for(var N="",S=0;S":N+=">";break;case"&":N+="&";break;case'"':N+=""";break;default:N+=O;break}}return N},pe=function(A){var N=1;A=typeof A>"u"?N*2:A;var S=z.getModuleCount()*N+A*2,O=A,_=S-A,j,Y,J,ue,xe,te={"██":"█","█ ":"▀"," █":"▄"," ":" "},De={"██":"▀","█ ":"▀"," █":" "," ":" "},Ae="";for(j=0;j=_?De[xe]:te[xe];Ae+=` +`}return S%2&&A>0?Ae.substring(0,Ae.length-S-1)+Array(S+1).join("▀"):Ae.substring(0,Ae.length-1)};return z.createASCII=function(A,N){if(A=A||1,A<2)return pe(N);A-=1,N=typeof N>"u"?A*2:N;var S=z.getModuleCount()*A+N*2,O=N,_=S-N,j,Y,J,ue,xe=Array(A+1).join("██"),te=Array(A+1).join(" "),De="",Ae="";for(j=0;j>>8),H.push(M&255)):H.push(w)}}return H}};var e={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8},r={L:1,M:0,Q:3,H:2},o={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7},a=(function(){var C=[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],k=1335,y=7973,w=21522,b={},H=function(f){for(var g=0;f!=0;)g+=1,f>>>=1;return g};return b.getBCHTypeInfo=function(f){for(var g=f<<10;H(g)-H(k)>=0;)g^=k<=0;)g^=y<5&&(M+=3+W-5)}for(var T=0;T=256;)b-=255;return C[b]},w})();function s(C,k){if(typeof C.length>"u")throw C.length+"/"+k;var y=(function(){for(var b=0;b"u")throw"bad rs block @ typeNumber:"+b+"/errorCorrectionLevel:"+H;for(var g=f.length/3,M=[],T=0;T>>7-w%8&1)==1},y.put=function(w,b){for(var H=0;H>>b-H-1&1)==1)},y.getLengthInBits=function(){return k},y.putBit=function(w){var b=Math.floor(k/8);C.length<=b&&C.push(0),w&&(C[b]|=128>>>k%8),k+=1},y},c=function(C){var k=e.MODE_NUMBER,y=C,w={};w.getMode=function(){return k},w.getLength=function(f){return y.length},w.write=function(f){for(var g=y,M=0;M+2>>8&255)*192+(T&255),f.put(T,13),M+=2}if(M>>8)},k.writeBytes=function(y,w,b){w=w||0,b=b||y.length;for(var H=0;H0&&(y+=","),y+=C[w];return y+="]",y},k},h=function(){var C=0,k=0,y=0,w="",b={},H=function(g){w+=String.fromCharCode(f(g&63))},f=function(g){if(!(g<0)){if(g<26)return 65+g;if(g<52)return 97+(g-26);if(g<62)return 48+(g-52);if(g==62)return 43;if(g==63)return 47}throw"n:"+g};return b.writeByte=function(g){for(C=C<<8|g&255,k+=8,y+=1;k>=6;)H(C>>>k-6),k-=6},b.flush=function(){if(k>0&&(H(C<<6-k),C=0,k=0),y%3!=0)for(var g=3-y%3,M=0;M=k.length){if(b==0)return-1;throw"unexpected end of file./"+b}var g=k.charAt(y);if(y+=1,g=="=")return b=0,-1;if(g.match(/^\s$/))continue;w=w<<6|f(g.charCodeAt(0)),b+=6}var M=w>>>b-8&255;return b-=8,M};var f=function(g){if(65<=g&&g<=90)return g-65;if(97<=g&&g<=122)return g-97+26;if(48<=g&&g<=57)return g-48+52;if(g==43)return 62;if(g==47)return 63;throw"c:"+g};return H},E=function(C,k){var y=C,w=k,b=new Array(C*k),H={};H.setPixel=function(T,z,W){b[z*y+T]=W},H.write=function(T){T.writeString("GIF87a"),T.writeShort(y),T.writeShort(w),T.writeByte(128),T.writeByte(0),T.writeByte(0),T.writeByte(0),T.writeByte(0),T.writeByte(0),T.writeByte(255),T.writeByte(255),T.writeByte(255),T.writeString(","),T.writeShort(0),T.writeShort(0),T.writeShort(y),T.writeShort(w),T.writeByte(0);var z=2,W=g(z);T.writeByte(z);for(var q=0;W.length-q>255;)T.writeByte(255),T.writeBytes(W,q,255),q+=255;T.writeByte(W.length-q),T.writeBytes(W,q,W.length-q),T.writeByte(0),T.writeString(";")};var f=function(T){var z=T,W=0,q=0,Z={};return Z.write=function(I,V){if(I>>>V)throw"length over";for(;W+V>=8;)z.writeByte(255&(I<>>=8-W,q=0,W=0;q=I<0&&z.writeByte(q)},Z},g=function(T){for(var z=1<>6,128|i&63):i<55296||i>=57344?o.push(224|i>>12,128|i>>6&63,128|i&63):(a++,i=65536+((i&1023)<<10|r.charCodeAt(a)&1023),o.push(240|i>>18,128|i>>12&63,128|i>>6&63,128|i&63))}return o}return e(n)}})();(function(n){typeof define=="function"&&define.amd?define([],n):typeof Uo=="object"&&(Go.exports=n())})(function(){return jo})});function Wn(n,e){return n==null||n===!1||n===""||(Array.isArray(n)?n.forEach(r=>Wn(r,e)):e.push(n instanceof Node?n:String(n))),e}function t(n,e,r){let o=window.E,a=e!=null&&typeof e=="object"&&!Array.isArray(e)&&!(e instanceof Node);return!a&&r===void 0?o(n,{},Wn(e,[])):o(n,a?e:{},Wn(r,[]))}var Do={phone:'',computer:'',tablet:'',router:'',server:'',other:'',ethernet:'',bridge:'',wifi:'',tunnel:'',plus:'',chart:'',reset:'',package:'',code:'',plug:'',sunrise:'',refresh:'',archive:'',qr:'',copy:'',download:'',link:'',amnezia:'',amneziawg:'',wireguard:'',appstore:'',googleplay:'',github:'',openwrt:'',apple:'',windows:'',linux:'',eye:'',share:'',arrow:'',trash:'',edit:'',pause:'',play:'',key:'',out:'',admin:'',shield:'',shieldplus:'',lock:'',zap:'',check:'',alert:'',x:'',globe:'',home:'',open:'',file:'',network:'',moon:'',chevron:'',clock:'',calendar:'',minus:'',more:'',pin:'',activity:''};function ft(n,e="dl-icon"){let r=Do[n]??Do.phone;return``}function v(n,e="dl-icon"){let r=document.createElement("span");return r.className="dl-icon-wrap",r.innerHTML=ft(n,e),r}function U(n,e="info",r=0){let o=document.querySelector(".dl-toasts");o||(o=t("div",{class:"dl-toasts dl-root",role:"status","aria-live":"polite"}),document.body.appendChild(o));let a=e==="error"?"x":e==="warning"?"alert":e==="success"?"check":null,i=()=>{s.classList.remove("show"),setTimeout(()=>s.remove(),200)},s=t("div",{class:`dl-toast ${e}`},[a?v(a):"",t("span",{},n),e==="error"?t("button",{type:"button","aria-label":"Close",click:i},v("x")):""]);o.appendChild(s),requestAnimationFrame(()=>s.classList.add("show")),setTimeout(i,r||(e==="error"?8e3:e==="warning"?5e3:2600))}function be(n){return n instanceof Error?n.message:String(n)}async function G(n,e){try{let r=await n();return e&&U(e,"success",3500),r}catch(r){U(be(r),"error",1e4);return}}function Ao(n){try{let e=n();e&&typeof e.then=="function"&&e.catch(r=>U(be(r),"error"))}catch(e){U(be(e),"error")}}function Ho(n){if(n&&typeof n=="object"){if(typeof n.error=="string")throw new Error(n.error);typeof n.warning=="string"&&n.warning&&U(n.warning,"warning",12e3)}return n}function K(n,e=[]){let r=rpc.declare({object:"luci.dawnline",method:n,params:e});return async(...o)=>Ho(await r(...o))}var Ei=K("logs_clear",["person","device","category","older_days"]),Li=(n={})=>Ei(n.person??"",n.device??"",n.category??"",n.older_days??""),Mi=rpc.declare({object:"luci.dawnline",method:"person_update",params:["id","name","access","device_limit","expires","expire_action","expire_warn","quota_gb","quota_period","bonus_gb","hours","note","dns_mode","paused","services","circle","home_nets","server"]});async function Si(n,e){let o=[n,...["name","access","device_limit","expires","expire_action","expire_warn","quota_gb","quota_period","bonus_gb","hours","note","dns_mode"].map(a=>e[a]),e.paused,e.services,e.circle,e.home_nets,e.server];return Ho(await Mi(...o))}var Ti=K("status",["days"]),P={rev:K("rev"),personUpdate:Si,settingsGet:K("settings_get"),portalInfo:K("portal_info"),settingsUpdate:K("settings_update",["values"]),serviceSet:K("service_set",["id","name","address","ports"]),serviceDelete:K("service_delete",["id"]),geoClear:K("geo_clear"),events:K("events",["limit","person","since"]),logsClear:Li,interfaces:K("interfaces",["id"]),serverInterfaces:K("server_interfaces",["id","auto_wan","wan_device","auto_lan","lan_devices","lan_like","device_mesh","mesh"]),circleSet:K("circle_set",["id","server","name","color","members"]),circleDelete:K("circle_delete",["id"]),accessCheck:K("access_check",["from","to"]),homeHosts:K("home_hosts",["id"]),usageClear:K("usage_clear",["scope","id"]),uninstall:K("uninstall",["confirm"]),status:Ti,setupDefaults:K("setup_defaults"),serverCreate:K("server_create",["id","name","ifname","port","subnet","endpoint","mtu","preset","lan_zone","wan_zone","lan_like","portal_enabled","portal_port"]),serverObfuscation:K("server_obfuscation",["id","preset"]),serverUpdate:K("server_update",["id","values"]),serverPorts:K("server_ports",["id"]),endpointProbe:K("endpoint_probe",["host","id","port"]),serverDelete:K("server_delete",["id"]),personLinks:K("person_links",["id"]),personCreate:K("person_create",["name","slug","server","access","device_limit","expires","quota_gb","quota_period"]),personPause:K("person_pause",["id","paused"]),personRegen:K("person_regen",["id","remove"]),personDelete:K("person_delete",["id"]),personUsage:K("person_usage",["id","days"]),deviceCreate:K("device_create",["person","name","kind"]),deviceConfig:K("device_config",["id"]),deviceUpdate:K("device_update",["id","name","disabled"]),deviceDelete:K("device_delete",["id"]),deviceRotate:K("device_rotate",["id"]),apply:K("apply"),health:K("health"),healthFix:K("health_fix",["id"]),serviceLog:K("service_log"),serviceLogClear:K("service_log_clear",["older_days"]),backupList:K("backup_list"),backupCreate:K("backup_create"),backupRestore:K("backup_restore",["name"]),backupDelete:K("backup_delete",["name"]),backupRead:K("backup_read",["name"]),backupUpload:K("backup_upload",["data"]),exportJson:K("export"),importJson:K("import",["data"]),updatesStatus:K("updates_status"),updatesRun:K("updates_run",["what"]),updatesReleases:K("updates_releases",["page"]),updatesNotes:K("updates_notes",["component","tag","build"]),updatesChanges:K("updates_changes",["from","to"])};function D(n,e,r="neutral",o={}){let{disabled:a,...i}=o,s=t("button",{class:`cbi-button cbi-button-${r}`,type:"button",...i,click:async l=>{if(l.preventDefault(),l.stopPropagation(),!s.disabled){s.disabled=!0,s.classList.add("spinning");try{await e(l)}catch(d){U(be(d),"error")}finally{s.disabled=!1,s.classList.remove("spinning")}}}},n);return s.disabled=!!a,s}function Le(n,e,r,o="neutral",a=""){return D([v(n),t("span",{class:"dl-btn-label"},e)],r,o,{title:e,class:`cbi-button cbi-button-${o} dl-icon-btn ${a}`.trim()})}function $e(n){return document.addEventListener("luci-navigate",n),()=>document.removeEventListener("luci-navigate",n)}var gt=null;function Fn(n=!1){let e=gt;gt=null,e?.(n)}function oe(n,e,r,o=""){Fn();let a=t("div",{class:`dl-modal ${o}`},e),i=t("div",{class:"button-row"},r);a.addEventListener("keydown",s=>{if(s.key==="Escape"){s.preventDefault(),s.stopPropagation(),ae();return}if(s.key!=="Enter"||s.shiftKey||s.ctrlKey||s.metaKey||s.altKey)return;let l=s.target;if(!l||["TEXTAREA","BUTTON","SELECT","A"].includes(l.tagName))return;let d=i.querySelector(".cbi-button-positive");!d||d.disabled||(s.preventDefault(),d.click())}),ui.showModal(n,[a,i])}function ae(){Fn(),ui.hideModal()}function ie(n="Cancel",e=!1){return t("button",{class:`cbi-button ${e?"cbi-button-negative":"cbi-button-neutral"}`,type:"button",click:ae},n)}function se(n,e,r="Confirm",o=!1){return new Promise(a=>{oe(n,e,[ie()," ",t("button",{class:`cbi-button ${o?"cbi-button-negative":"cbi-button-positive"}`,type:"button",click:()=>{let i=gt;gt=null,ui.hideModal(),i?.(!0)}},r)]),gt=a})}$e(()=>{gt&&(Fn(),ui.hideModal())});async function me(n,e="Copied to clipboard",r=!1){try{if(navigator.clipboard&&window.isSecureContext)await navigator.clipboard.writeText(n);else{let o=t("textarea",{style:"position:fixed;opacity:0"},n);document.body.appendChild(o),o.select();let a=document.execCommand("copy");if(o.remove(),!a)throw new Error("Copying is blocked here. Select the text and copy it by hand.")}return U(e,"success",2500),!0}catch(o){return r||U(be(o),"error"),!1}}function Te(n,e,r="text/plain"){let o=globalThis,a=typeof e=="string"?new o.Blob([e],{type:r}):e,i=URL.createObjectURL(a),s=t("a",{href:i,download:n,style:"display:none"});document.body.appendChild(s),s.click(),setTimeout(()=>{URL.revokeObjectURL(i),s.remove()},1e3)}function qn(n,e){return new Promise(r=>{let o=t("input",{type:"file",accept:n,style:"display:none"});o.addEventListener("cancel",()=>{o.remove(),r(null)}),o.addEventListener("change",()=>{let a=o.files?.[0];if(o.remove(),!a)return r(null);let i=new FileReader;i.onload=()=>{let s=String(i.result??"");r({name:a.name,data:e==="base64"?s.replace(/^data:[^,]*,/,""):s})},i.onerror=()=>r(null),e==="base64"?i.readAsDataURL(a):i.readAsText(a)}),document.body.appendChild(o),o.click()})}function Ce(n,e){let r=document.querySelector(".dl-dd");if(r&&(r.dlClose?r.dlClose():r.remove(),r.dlAnchor===n))return;let o=t("div",{class:"dl-dd dl-root",role:"menu"},e.map(u=>u?t("button",{type:"button",role:"menuitem",class:u.danger?"danger":u.warn?"warn":"",click:()=>{p(),Ao(u.run)}},[u.icon??"",t("span",{},u.label)]):t("hr")));document.body.appendChild(o);let a=n.getBoundingClientRect(),i=o.offsetWidth,s=o.offsetHeight;o.style.top=`${a.bottom+6+s>window.innerHeight-8&&a.top-6-s>8?a.top-6-s:a.bottom+6}px`,o.style.left=`${Math.max(8,Math.min(a.right-i,window.innerWidth-i-8))}px`;let l=u=>{!o.contains(u.target)&&!n.contains(u.target)&&p()},d=u=>{if(u.key==="Escape"||u.key==="Tab")return p();let x=[...o.querySelectorAll("button:not([disabled])")];if(!x.length||!["ArrowDown","ArrowUp","Home","End"].includes(u.key))return;u.preventDefault();let $=x.indexOf(document.activeElement),h=u.key==="Home"?0:u.key==="End"?x.length-1:u.key==="ArrowDown"?($+1)%x.length:($-1+x.length)%x.length;x[h].focus({preventScroll:!0})},c=$e(p);o.dlAnchor=n,o.dlClose=p;function p(){o.remove(),c(),document.removeEventListener("mousedown",l,!0),document.removeEventListener("keydown",d,!0),window.removeEventListener("scroll",p,!0)}setTimeout(()=>{document.addEventListener("mousedown",l,!0),document.addEventListener("keydown",d,!0),window.addEventListener("scroll",p,!0)}),o.querySelector("button")?.focus({preventScroll:!0})}var lt=null,Je=null,Kn=0;function vt(){lt&&(lt.style.display="none"),Je=null,clearInterval(Kn),Kn=0}function he(n,e){let r=o=>{lt??(lt=document.body.appendChild(t("div",{class:"dl-tip dl-tip-float dl-root"}))),lt.replaceChildren(...e().map(a=>typeof a=="string"?document.createTextNode(a):a)),lt.style.display="",lt.style.left=`${o.clientX}px`,lt.style.top=`${o.clientY-10}px`,Je=n,Kn||(Kn=window.setInterval(()=>{(!Je?.isConnected||!Je.getClientRects().length)&&vt()},400))};n.addEventListener("mouseenter",r),n.addEventListener("mousemove",r),n.addEventListener("mouseleave",vt),n.addEventListener("pointerup",o=>{o.pointerType!=="mouse"&&(Je===n?vt():r(o))})}$e(vt);window.addEventListener("scroll",()=>Je&&vt(),{capture:!0,passive:!0});document.addEventListener("pointerdown",n=>{Je&&!Je.contains(n.target)&&vt()},!0);function X(n){if(!n||n<0)return"0 B";let e=["B","KB","MB","GB","TB"],r=0,o=n;for(;o>=1024&&r=100||r===0?Math.round(o):o.toFixed(1)} ${e[r]}`}function Oe(n){let e=n*8;return e<1e3?`${Math.round(e)} bit/s`:e<1e6?`${(e/1e3).toFixed(e<1e4?1:0)} kbit/s`:e<1e9?`${(e/1e6).toFixed(e<1e7?1:0)} Mbit/s`:`${(e/1e9).toFixed(1)} Gbit/s`}function re(n,e=Date.now()/1e3){if(!n)return"never";let r=Math.max(0,Math.round(e-n));return r<60?"just now":r<3600?`${Math.floor(r/60)} min ago`:r<86400?`${Math.floor(r/3600)} h ago`:r<86400*30?`${Math.floor(r/86400)} d ago`:new Date(n*1e3).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"})}function xt(n){if(!n||n<0)return"—";let e=Math.floor(n/86400),r=Math.floor(n%86400/3600),o=Math.floor(n%3600/60);return e?`${e}d ${r}h`:r?`${r}h ${o}m`:`${o}m`}function Ht(n){let e=new Date(n*1e3),r=new Date,o=e.toDateString()===r.toDateString(),a=e.toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit"});return o?a:`${e.toLocaleDateString("en-GB",{day:"numeric",month:"short"})} ${a}`}function je(n){return`${n.getFullYear()}-${String(n.getMonth()+1).padStart(2,"0")}-${String(n.getDate()).padStart(2,"0")}`}function wt(n){let[e,r,o]=n.split("-").map(Number);return new Date(e,(r||1)-1,o||1,12)}function Ue(n){return(typeof n=="string"?/^\d{4}-\d{2}-\d{2}$/.test(n)?wt(n):new Date(n):n).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"})}function Me(n){return n?Ue(n):""}function Vn(n,e){let r=o=>{let[a,i,s]=o.split("-").map(Number);return Date.UTC(a,i-1,s)};return Math.round((r(n)-r(e))/864e5)}function At(n,e){let r=wt(n);return r.setDate(r.getDate()+e),je(r)}function bt(n,e){let[r,o,a]=n.split("-").map(Number),i=new Date(r,o-1+e,1,12),s=new Date(i.getFullYear(),i.getMonth()+1,0).getDate();return i.setDate(Math.min(a,s)),je(i)}function Ie(n){return n?.length?n[n.length-1].day:je(new Date)}function zo(n,e,r,o,a=30){let i=n||o;return e==="day"?At(i,r):e==="week"?At(i,7*r):e==="month"?bt(i,r):e==="year"?bt(i,12*r):At(i,a*r)}function Ye(n,e=Date.now()){if(!n)return null;let r=typeof e=="number"?je(new Date(e)):e,o=Vn(n,r);return o>=0?o+1:o}function Ze(n,e){return e!=null&&e>0&&n.expire_warn>0&&e<=n.expire_warn}function Xt(n){return n<=1?"ends today":n===2?"ends tomorrow":`ends in ${n} days`}function en(n,e,r=`${e}s`){return`${n.toLocaleString("en-GB")} ${n===1?e:r}`}function zt(n){return n<1024?`${n} B`:n<1048576?`${(n/1024).toFixed(n<10240?1:0)} KB`:`${(n/1048576).toFixed(1)} MB`}var dt={lan:"Home network",internet:"Internet",both:"Home network + Internet"};var No=["computer","phone","tablet","router","other"],Qe={computer:"PC",phone:"Phone",tablet:"Tablet",router:"Router",other:"Other"},Ro={active:"Active",paused:"Paused",expired:"Expired",quota:"Data limit reached",hours:"Outside allowed hours",no_server:"No server",server_off:"Server is turned off"};function He(n){let e=n.trim().split(/\s+/).filter(Boolean);if(!e.length)return"?";let r=e[0][0]??"",o=e.length>1?e[e.length-1][0]??"":e[0][1]??"";return(r+o).toUpperCase()}function tn(n){let e=r=>r.disabled?3:r.online?0:r.handshake?1:2;return n.map((r,o)=>[r,o]).sort((r,o)=>e(r[0])-e(o[0])||r[1]-o[1]).map(([r])=>r)}function Ee(n,e,r){return t("span",{class:`dl-pill ${n}`,title:r??null},e)}function _i(n){return n.state==="active"?"ok":n.state==="quota"||n.state==="expired"?"bad":"warn"}function Pi(n){return n.state==="server_off"&&n.paused?"paused":n.state}function Io(n){let e=Pi(n);return e==="active"||e==="server_off"?"":Ee(_i({...n,state:e}),Ro[e])}function Bo(n){let e=n.access==="both"?["lan","inet"]:n.access==="lan"?["lan"]:["inet"],r=t("span",{class:"dl-access","aria-label":dt[n.access]},e.map(o=>t("span",{class:`dl-ibadge ${o}`},v(o==="lan"?"home":"globe"))));return he(r,()=>[t("div",{class:"dl-tip-title"},dt[n.access]),n.access==="lan"&&n.services?.length?t("div",{class:"dl-muted"},`${n.services.length} home service${n.services.length===1?"":"s"} only`):""]),r}var Di={paused:"Paused",expired:"Access ended",quota:"Data limit",hours:"Outside hours",server_off:"Server off",no_server:"No server"};function nn(n,e,r="Not set up yet",o){let a=n.handshake?`Last seen ${re(n.handshake,e)} · ${new Date(n.handshake*1e3).toLocaleString()}`:"";if(n.disabled)return t("span",{class:"dl-dstat",title:a},"Disabled");if(n.online)return t("span",{class:"dl-dstat ok"},"Connected");let i=o&&Di[o.state];return i?t("span",{class:"dl-dstat warn",title:a||"Not connected yet"},i):n.handshake?t("span",{class:"dl-dstat",title:new Date(n.handshake*1e3).toLocaleString()},`Last seen ${re(n.handshake,e)}`):t("span",{class:"dl-dstat warn",title:"Waiting for the first connection"},r)}var on=null;function Oo(n,e,r,o){on?.close();let a=t("aside",{class:"dl-drawer",role:"dialog","aria-modal":"true"},[t("div",{class:"dl-drawer-head"},[n,t("button",{type:"button",class:"dl-drawer-x","aria-label":"Close",click:()=>c()},v("x"))]),t("div",{class:"dl-drawer-body"},e),r?t("div",{class:"dl-drawer-foot"},r):""]),i=t("div",{class:"dl-drawer-overlay dl-root",click:u=>{u.target===i&&c()}},a),s=u=>{u.key==="Escape"&&!document.body.classList.contains("modal-overlay-active")&&c()},l=!1,d=$e(()=>c());function c(){l||(l=!0,d(),document.removeEventListener("keydown",s),i.classList.remove("open"),setTimeout(()=>i.remove(),220),on===p&&(on=null),o())}let p={close:c,panel:a};return document.addEventListener("keydown",s),document.body.appendChild(i),requestAnimationFrame(()=>i.classList.add("open")),on=p,p}function ce(n,e,r){return t("div",{class:"dl-setrow"},[t("div",{class:"dl-stack"},[t("span",{class:"dl-setrow-label"},n),r?t("span",{class:"dl-sub"},r):""]),t("div",{class:"dl-setrow-ctl"},e)])}function ge(n,e,r,o=e){let a=ce(n,o," "),i=a.querySelector(".dl-sub"),s=()=>{let l=r();i.textContent=l.text,i.classList.toggle("bad",l.bad),e.classList.toggle("cbi-input-invalid",l.bad)};return e.addEventListener("input",s),a.refresh=s,a.help=r,s(),a}function ye(n,e,r,o=e){let a=t("div",{class:"dl-sub"}),i=t("div",{class:"cbi-value dl-live"},[t("div",{class:"cbi-value-title"},[t("label",{},n),a]),t("div",{class:"cbi-value-field"},o)]),s=()=>{let l=r();a.textContent=l.text,a.classList.toggle("bad",l.bad),e.classList.toggle("cbi-input-invalid",l.bad)};return e.addEventListener("input",s),e.addEventListener("change",s),i.refresh=s,i.help=r,s(),i}function ze(n,e=[]){for(let r of n){let o=r.help?.();if(o?.bad)return o.text}for(let r of e){let o=r();if(o.bad)return o.text}return null}function Nt(n,e,r,o=""){return t("section",{class:`dl-setsec ${o}`},[t("div",{class:"dl-setsec-body"},[n?t("h3",{},n):"",...e]),r.length?t("div",{class:"dl-setsec-foot"},r):""])}function fe(n,e,r,o){return t("div",{class:"dl-group"},[t("div",{class:"dl-group-head"},[t("span",{class:"dl-group-ic"},v(n)),t("span",{class:"dl-stack"},[t("b",{},e),r?t("span",{class:"dl-sub"},r):""])]),t("div",{class:"dl-group-body"},o.filter(a=>a!==""))])}function Xe(n,e,r,o,a){return t("div",{class:`dl-row dl-need-row ${e}`},[e?t("span",{class:"dl-need-ic"},v(n)):v(n),t("span",{class:"dl-row-main dl-stack"},[t("b",{},r),t("span",{class:"dl-sub"},o)]),a])}function ct(n,e){let r={ok:"success",warn:"warning",error:"error",info:"notice"}[n];return t("div",{class:`alert-message ${r}`},e)}function yt(n,e=""){let r=t("div",{class:e});return r.innerHTML=n,r}var qo=Ci(Wo(),1),Ai=n=>``,Fo="#0a0a0a",Hi="#f2f2f2",zi={night:[Fo,Hi],day:["#ffffff",Fo]},Ni=n=>n.length>300,kt=n=>+n.toFixed(2);function Jn(n,e,r,o,a){return`M${kt(n+a)} ${kt(e)}h${kt(r-2*a)}a${a} ${a} 0 0 1 ${a} ${a}v${kt(o-2*a)}a${a} ${a} 0 0 1 -${a} ${a}h-${kt(r-2*a)}a${a} ${a} 0 0 1 -${a} -${a}v-${kt(o-2*a)}a${a} ${a} 0 0 1 ${a} -${a}z`}function rn(n,e=3,r=!0,o="plain"){let a=Ni(n),i=o!=="plain",[s,l]=i?zi[o]:["#fff","#000"],d=(0,qo.default)(0,a?"L":"H");d.addData(n,"Byte"),d.make();let c=d.getModuleCount(),p=c+e*2,u=r&&!a?Math.round(c*.22):0;u&&(c-u)%2&&u++;let x=(c-u)/2,$=x+u,h=(y,w)=>u>0&&y>=x&&y<$&&w>=x&&w<$,m=(y,w)=>i&&(w<7&&y<7||w<7&&y>=c-7||w>=c-7&&y<7),E="";if(i){let y=a?.48:.42;for(let w=0;w${Ai(i?s:"#fff")}`}let k=``;return i?`${k}${C}`:`${k}${C}`}function pt(){let n=document.documentElement.getAttribute("data-darkmode");return n!=null?n==="true":window.matchMedia?.("(prefers-color-scheme: dark)").matches??!1}function an(n){let e=pt();return yt(rn(n,3,!0,e?"night":"day"),`dl-qr${e?"":" light"}`)}function Yn(n){let e=/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\/(\d{1,2})$/.exec(n.trim());if(!e)return null;let[r,o,a,i]=e.slice(1,5).map(Number),s=Number(e[5]);if([r,o,a,i].some(c=>c>255)||s<8||s>30)return null;let l=r*2**24+o*2**16+a*2**8+i,d=2**(32-s);return{net:l-l%d,size:d}}var Ri=(n,e)=>n.netYn(n));function Ct(n){return n.split("/")[0].split(".").slice(0,3).join(".")}function ln(n){return`${n.trim()}.0/24`}function Qn(n,e,r){let o=n.trim(),a=/^\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(o)?Yn(ln(o)):null;if(!a)return{text:"Three numbers, like 10.77.0.",bad:!0};if(!Ii.some(s=>a.net>=s.net&&a.net+a.size<=s.net+s.size))return{text:"Use a private range: 10.x.x, 172.16–31.x or 192.168.x.",bad:!0};let i=e.find(s=>{let l=Yn(s.cidr);return l!=null&&Ri(a,l)});if(i){let s=i.cidr.endsWith("/24")?`${Ct(i.cidr)}.x`:i.cidr,l=r&&r!==o?` Try ${r}.`:"";return{text:`${i.name} already uses ${s}.${l}`,bad:!0}}return{text:`Devices get ${o}.2 – ${o}.254, the router ${o}.1.`,bad:!1}}var Vo=(n,e)=>e.find(r=>r.from<=n&&n<=r.to)?.who??null,Bi=n=>Number.isInteger(n)&&n>=1&&n<=65535;function Rt(n,e,r){if(!Bi(n))return{text:"Use a port from 1 to 65535.",bad:!0};let o=Vo(n,e);return o?{text:`Used by ${o}. Choose another port.`,bad:!0}:{text:r,bad:!1}}function dn(n,e,r){let o=r?`HTTPS here, plain HTTP for links on IP addresses on ${n+1}.`:"HTTPS on this port, opened on WAN.",a=Rt(n,e,o);if(a.bad||!r)return a;if(n===65535)return{text:"Links on IP addresses also need the next port: choose a lower one.",bad:!0};let i=Vo(n+1,e);return i?{text:`Links on IP addresses also need ${n+1}, used by ${i}. Choose another port.`,bad:!0}:a}var sn=n=>Array.from(n).length,Ko=48,Oi=/[<>"\\\u0000-\u001f\u007f]/;function _e(n,e=[],r=""){let o=n.trim();return o?sn(n)>Ko?{text:`Up to ${Ko} characters (${sn(n)} now).`,bad:!0}:Oi.test(n)?{text:'Names can’t contain < > " or \\.',bad:!0}:e.some(a=>a.toLowerCase()===o.toLowerCase())?{text:`“${o}” already exists — pick another name.`,bad:!0}:{text:r,bad:!1}:{text:"Enter a name.",bad:!0}}function Jo(n,e=[]){return sn(n)>32?{text:`Up to 32 characters (${sn(n)} now).`,bad:!0}:_e(n,e,"Shown on the person cards.")}var ji=/^[A-Za-z0-9]([A-Za-z0-9-]{0,61}[A-Za-z0-9])?(\.[A-Za-z0-9]([A-Za-z0-9-]{0,61}[A-Za-z0-9])?)*$/,Ui=/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/;function Et(n){let e=Ui.exec(n);return!!e&&e.slice(1).every(r=>Number(r)<=255)}function Zn(n){return/^([0-9a-fA-F]{0,4}:){2,7}[0-9a-fA-F]{0,4}$/.test(n)&&!/:::/.test(n)}function $t(n,e,r=null){let o=n.trim();if(!o)return r!=null?{text:r,bad:!1}:{text:"Enter a hostname or IP address.",bad:!0};if(/^[a-z]+:\/\//i.test(o))return{text:"Leave out https:// — just the name.",bad:!0};if(/\/.*/.test(o))return{text:"Just the name, without a path.",bad:!0};if(/^[^:\[]+:\d+$/.test(o))return{text:"Just the name, without a port (the port is on AmneziaWG).",bad:!0};if(/\s/.test(o))return{text:"A hostname has no spaces.",bad:!0};if(o.length>253||!(ji.test(o)||Et(o)||Zn(o)))return{text:"Use a hostname or an IP address.",bad:!0};let a=Zn(o)?`[${o}]`:o;return{text:e?`Devices connect to ${a}:${e}.`:`Links use ${a}.`,bad:!1}}function Yo(n,e){let r=n.split(/[ ,]+/).filter(Boolean);if(!r.length)return{text:`This router (${e}): queries go where your home network sends them, and home names work.`,bad:!1};let o=r.find(a=>!Et(a)&&!Zn(a));return o?{text:`“${o}” is not an IP address. Separate several with commas.`,bad:!0}:{text:`Devices use ${r.join(" and ")} — home names and your LAN’s DNS filters no longer apply to them.`,bad:!1}}function Zo(n,e){let r=n.trim();if(!r)return{text:`Automatic by device type and disguise: ${e.computer} for computers and routers, ${e.phone} for phones and tablets.`,bad:!1};if(!/^\d{1,4}$/.test(r)||Number(r)<1280||Number(r)>1500)return{text:"MTU must be 1280–1500, or empty for automatic.",bad:!0};let o=Number(r);return{text:`Computers and routers get ${o}, phones and tablets ${Math.min(o,1280)}.`,bad:!1}}function Qo(n){let e=n.trim();return e?!/^\d{1,3}$/.test(e)||Number(e)>600?{text:"Use 0–600 seconds.",bad:!0}:Number(e)===0?{text:"Off: NAT may close the tunnel when idle, and “Connected” lags.",bad:!1}:{text:`Devices send a packet every ${e} s to keep NAT open (a little battery on phones).`,bad:!1}:{text:"Default: a packet every 25 s keeps NAT open and “Connected” accurate.",bad:!1}}function cn(n,e=0){let r=n.trim();if(!/^\d{1,2}$/.test(r)||Number(r)<1||Number(r)>32)return{text:"Use 1–32.",bad:!0};let o=Number(r);return e>o?{text:`Already has ${e} devices: remove ${e-o===1?"one":`${e-o}`} first, or allow more.`,bad:!0}:{text:`They can add ${o} device${o===1?"":"s"} themselves.`,bad:!1}}function pn(n,e=!0){let r=n.trim();if(!r)return{text:"Optional. No data limit.",bad:!1};let o=Number(r);return!/^\d+(\.\d+)?$/.test(r)||o<0||o>1e5?{text:"A number of GB, up to 100000.",bad:!0}:o===0?{text:"Optional. No data limit.",bad:!1}:{text:e?`Paused after ${r} GB this month, resumed on the 1st.`:`Paused after ${r} GB in total.`,bad:!1}}function Xo(n,e,r,o){let a=n.trim();if(!a)return{text:"Optional. No end date.",bad:!1};let i=r(a,e);return i==null?{text:"Use a date.",bad:!0}:i<0?{text:"That date has passed: access would end at once.",bad:!0}:{text:i===1?`Access ends today (${o(a)}).`:`Access ends in ${i} days (${o(a)}).`,bad:!1}}function er(n,e=null){let r=n.trim();return r?Et(r)?e&&!e(r)?{text:`${r} is not in any home network of this server: nobody would reach it.`,bad:!1}:{text:"",bad:!1}:{text:"Use an IPv4 address, like 192.168.1.10.",bad:!0}:{text:"The device’s address at home.",bad:!0}}function tr(n){let e=n.split(/[ ,]+/).filter(Boolean);if(!e.length)return{text:"All ports.",bad:!1};let r=e.find(o=>!/^\d{1,5}$/.test(o)||Number(o)<1||Number(o)>65535);return r?{text:`“${r}” is not a port (1–65535).`,bad:!0}:{text:`Port${e.length===1?"":"s"} ${e.join(", ")}.`,bad:!1}}function nr(n){let e=n.trim();return e?/^https?:\/\//i.test(e)?e.length>300||!/^https?:\/\/[A-Za-z0-9.-]+(:[0-9]+)?(\/[^\s"'<>]*)?$/.test(e)?{text:"Not a usable address (no spaces or quotes).",bad:!0}:{text:"Wrong links are sent there instead of a “Not found”.",bad:!1}:{text:"Must start with http:// or https://.",bad:!0}:{text:"Wrong links get a bare “Not found”.",bad:!1}}function or(n,e="phone.myata"){let r=n.trim();return r?/^[a-z0-9-]{1,32}(\.[a-z0-9-]{1,32})*$/.test(r)?{text:`Devices get names like ${e}.${r}.`,bad:!1}:{text:/[A-Z]/.test(r)?"Lowercase only.":"Lowercase letters, digits, dashes and dots.",bad:!0}:{text:`The default, lan: devices get names like ${e}.lan.`,bad:!1}}function rr(n){let e=n.trim();return e?Et(e)?{text:`${e} takes over when the tunnel is down.`,bad:!1}:{text:"Use an IPv4 address, or leave it empty.",bad:!0}:{text:"None: without the tunnel those devices have no DNS.",bad:!1}}function ar(n){let e=n.trim();return/^([01]?[0-9]|2[0-3]):[0-5][0-9]$/.test(e)?{text:`Runs within an hour after ${e} (router time).`,bad:!1}:{text:"Use HH:MM, 00:00–23:59.",bad:!0}}function Xn(n,e,r,o={}){let a=0,i="",s=null;return{help:()=>{let{host:c,port:p}=n(),u=$t(c,p,o.empty??null);if(u.bad||!c.trim())return u;if(s&&s.host===c.trim())return{text:s.text,bad:s.bad};let x=o.idle?.();return{text:x?`${x} Checking where it points…`:`${u.text} Checking where it points…`,bad:!1}},schedule:()=>{let{host:c}=n(),p=$t(c,n().port,o.empty??null);p.bad||!c.trim()||c.trim()===s?.host||(clearTimeout(a),a=window.setTimeout(async()=>{let u=c.trim();i=u;try{let{id:x,port:$}=n(),h=await e(u,x,$);if(i!==u)return;s={host:u,text:h.text,bad:h.status==="error"}}catch{if(i!==u)return;s={host:u,text:p.text,bad:!1}}r()},700))}}}var Gi={connect:"connections",disconnect:"connections",roam:"connections",device_added:"people",device_removed:"people",devices_removed:"people",device_changed:"people",device_keys:"people",link_changed:"people",person_added:"people",person_removed:"people",person_changed:"people",paused:"people",resumed:"people",expiring:"people",expired_kept:"people",portal_blocked:"problems"},Lt=["connections","people","problems"],ut={connections:"Connections",people:"People",problems:"Problems"},ir={connections:"Connects, disconnects and IP changes",people:"People and their devices added, changed, paused, removed",problems:"Blocked portal sign-ins (tunnels and services are in the service log)"},It=n=>Gi[n]??"problems",Bt={awg:"AmneziaWG",dawnline:"Dawnline",portal:"Portal"},Wi=["person_added","person_removed","person_changed"];function Ne(n){return n.by?n.by:Wi.includes(n.type)||n.detail==="by admin"||n.detail?.endsWith(" (admin)")?"admin":n.detail?.endsWith(" (portal)")?"portal":null}function sr(n){return(n.detail??"").replace(/ \((admin|portal)\)$/,"").replace(/^by admin$/,"")}var un=n=>n.sys?["error","repair","down"].includes(n.sys.level):It(n.ev.type)==="problems";function mn(n){let e=n.keep_days>0?`${n.keep_days} day${n.keep_days===1?"":"s"}`:"no age limit",r=n.persist==="off"?"kept in memory only (lost on reboot)":`saved to flash ${n.persist==="10min"?"every 10 minutes":"hourly"}`;return`Kept for ${e}, up to ${n.max.toLocaleString("en-GB")} events, ${r}.`}function lr(n,e=120,r=26,o=je(new Date)){let a=Math.max(1,...n),i=t("div",{class:"dl-spark"});return i.style.width=`${e}px`,i.style.height=`${r}px`,n.forEach((s,l)=>{let d=t("i");d.style.height=`${Math.max(6,s/a*100)}%`,s||d.classList.add("zero");let c=n.length-1-l;he(d,()=>[t("div",{class:"dl-tip-title"},c===0?"Today":c===1?"Yesterday":wt(At(o,-c)).toLocaleDateString("en-GB",{weekday:"short",day:"numeric",month:"short"})),t("div",{class:"dl-muted"},X(s))]),i.appendChild(d)}),i}function Fi(n){let e=n==null?"":String(n);return/^[=+\-@\t\r]/.test(e)&&(e=`'${e}`),/[",\r\n]/.test(e)?`"${e.replace(/"/g,'""')}"`:e}function dr(n,e){return[n.join(","),...e.map(r=>n.map(o=>Fi(r[o])).join(","))].join(` +`)}function qi(n){let e=new Map(n.people.map(o=>[o.id,o.name])),r=new Map(n.people.flatMap(o=>o.devices.map(a=>[a.id,a.name])));return{people:e,devices:r}}function Fe(n,e,r,o="",a=[]){let i=qi(n),s=[...e.map(p=>({ts:p.ts,category:It(p.type),type:p.type,person:p.person?i.people.get(p.person)??p.pname??p.person:"",device:p.device?i.devices.get(p.device)??p.dname??p.device:"",detail:p.detail??"",where:p.where??"",by:Ne(p)??""})),...a.map(p=>({ts:p.ts,category:"system",type:`${p.src}.${p.level}`,person:"",device:"",detail:`${p.who?`${p.who} `:""}${p.msg}${p.detail?` +${p.detail}`:""}`,where:Bt[p.src]??p.src,by:""}))].sort((p,u)=>p.ts-u.ts).map(({ts:p,...u})=>({time:new Date(p*1e3).toISOString(),...u})),l=new Date().toISOString().slice(0,10),d=`dawnline-activity${o?`-${o}`:""}-${l}.${r}`;if(r==="json"){Te(d,JSON.stringify(s,null,2),"application/json");return}Te(d,dr(["time","category","type","person","device","detail","where","by"],s),"text/csv")}var Ki=[["","Everything"],["7","Older than 7 days"],["30","Older than 30 days"],["90","Older than 90 days"]],cr=n=>n?`${n} event${n===1?"":"s"} removed`:"Nothing matched";function et(n,e,r,o,a,i=!1){let s=t("select",{class:"cbi-input-select"},[t("option",{value:""},"All categories"),...Lt.map(d=>t("option",{value:d,selected:d===a?"selected":null},ut[d])),i?t("option",{value:"system",selected:a==="system"?"selected":null},"System"):""]),l=t("select",{class:"cbi-input-select"},Ki.map(([d,c])=>t("option",{value:d},c)));oe(n,[t("p",{class:"dl-muted"},`${e} This cannot be undone; export first if you want a copy.`),t("label",{class:"dl-fld"},[t("span",{class:"dl-fld-label"},"Category"),s]),t("label",{class:"dl-fld"},[t("span",{class:"dl-fld-label"},"Which events"),l])],[ie()," ",D("Clear",async()=>{let d=0;if(s.value!=="system")try{d+=(await P.logsClear({...r,category:s.value,older_days:l.value})).removed}catch(c){U(be(c),"error",1e4);return}if(i&&(s.value==="system"||s.value===""))try{d+=(await P.serviceLogClear(l.value)).removed}catch(c){ae(),U(`${s.value==="system"?"":`Activity: ${cr(d).toLowerCase()}. `}The service log was not cleared: ${be(c)}`,"error",1e4),o();return}ae(),U(cr(d),"success",3e3),o()},"negative")])}function Mt(n,e,r,o){let a=n==="device"?`Clears ${r}'s daily and monthly traffic history. Their person's totals and data limit are not changed.`:n==="person"?`Clears ${r}'s traffic history and that of their devices. Their data limit starts again from zero.`:"Clears traffic history for everyone. Data limits start again from zero.";oe(n==="all"?"Reset all traffic history?":`Reset traffic history for ${r}?`,[t("p",{class:"dl-muted"},a)],[ie()," ",D("Reset",async()=>{await G(()=>P.usageClear(n,e),"Traffic history reset")&&(ae(),o())},"negative")])}function ve(n,e,r){let o=t("button",{type:"button",role:"switch",class:`dl-switch${n?" on":""}`,"aria-checked":n?"true":"false","aria-label":e,click:()=>{let a=!o.classList.contains("on");eo(o,a),r?.(a)}},t("i"));return o}function eo(n,e){n.classList.toggle("on",e),n.setAttribute("aria-checked",e?"true":"false")}var Pe=n=>n.classList.contains("on");function we(n,e,r={}){n.some(([i])=>i===e)||(n=[...n,[e,e]]);let o=t("div",{class:`dl-seg${r.cls?` ${r.cls}`:""}`,role:"radiogroup","aria-label":r.label??null,"data-value":e}),a=()=>o.querySelectorAll(":scope > button").forEach(i=>{let s=i.dataset.v===o.dataset.value;i.classList.toggle("on",s),i.setAttribute("aria-checked",s?"true":"false")});for(let[i,s]of n)o.appendChild(t("button",{type:"button",role:"radio","data-v":i,click:()=>{i!==o.dataset.value&&(r.optimistic!==!1&&(o.dataset.value=i,a()),r.onChange?.(i))}},s));return a(),o}function qe(n,e,r,o={}){return t("button",{type:"button",...o,class:`dl-chipbtn${e?" on":""}${o.class?` ${o.class}`:""}`,"aria-pressed":e?"true":"false",click:r},n)}function hn(n,e){n.classList.toggle("on",e),n.setAttribute("aria-pressed",e?"true":"false")}function le(n,e={}){return t("input",{type:"text",class:"cbi-input-text",value:n,...e})}var Vi={jc:"0",jmin:"0",jmax:"0",s1:"0",s2:"0",s3:"0",s4:"0",h1:"1",h2:"2",h3:"3",h4:"4",i1:"",i2:"",i3:"",i4:"",i5:""},Ji={header_protection_key:"HeaderProtectionKey",content_padding_addition:"ContentPaddingAddition",rekey_after_time:"RekeyAfterTime",rekey_timeout:"RekeyTimeout",reject_after_time:"RejectAfterTime",keepalive_timeout:"KeepaliveTimeout",max_handshake_attempts:"MaxHandshakeAttempts",random_trailers:"RandomTrailers",disable_cookies:"DisableCookies"};function Yi(n){let e={};for(let[r,o]of Object.entries(Ji))n[r]!=null&&n[r]!==""&&(e[o]=String(n[r]));return e}function Zi(n,e){let r=n.amnezia,o=r.obfuscation??{},a=d=>o[d]!=null&&o[d]!==""?String(o[d]):Vi[d],i=r.host.replace(/^\[(.*)\]$/,"$1"),s={H1:a("h1"),H2:a("h2"),H3:a("h3"),H4:a("h4"),I1:a("i1"),I2:a("i2"),I3:a("i3"),I4:a("i4"),I5:a("i5"),Jc:a("jc"),Jmin:a("jmin"),Jmax:a("jmax"),S1:a("s1"),S2:a("s2"),S3:a("s3"),S4:a("s4"),...Yi(o),allowed_ips:r.allowed_ips,client_ip:r.client_ip,client_priv_key:r.client_priv_key,client_pub_key:r.client_pub_key,config:n.conf.replace(/\r?\n/g,`\r +`),hostName:i,mtu:r.mtu,persistent_keep_alive:r.persistent_keep_alive,port:Number(r.port),psk_key:r.psk_key,server_pub_key:r.server_pub_key},l={containers:[{container:"amnezia-awg",awg:{isThirdPartyConfig:!0,last_config:JSON.stringify(s),port:String(r.port),protocol_version:o.header_protection_key?"3.1":"2",transport_proto:"udp"}}],defaultContainer:"amnezia-awg",description:e,hostName:i};return r.dns[0]&&(l.dns1=r.dns[0]),r.dns[1]&&(l.dns2=r.dns[1]),l}function Qi(n){let e="";for(let r=0;r"u")return null;try{let r=new e.Blob([n]).stream().pipeThrough(new e.CompressionStream("deflate")),o=new Uint8Array(await new e.Response(r).arrayBuffer()),a=new Uint8Array(4+o.length);return new DataView(a.buffer).setUint32(0,n.length,!1),a.set(o,4),a}catch{return null}}async function to(n,e,r=!0){let o=new TextEncoder().encode(JSON.stringify(Zi(n,e))),a=r?await Xi(o):null;return`vpn://${Qi(a??o)}`}var ur=[{id:"off",title:"Off",ic:"zap",stealth:0,speed:4,text:"Plain WireGuard-compatible traffic. Fastest, but easy to recognise and block.",apps:"Any WireGuard app",short:"Any WireGuard app"},{id:"balanced",title:"Balanced",ic:"shield",stealth:3,speed:4,needs:"v2",text:"AmneziaWG 2.0: junk packets, padded packets and a first packet that looks like DNS. For networks that learned to spot 1.0-style junk.",apps:"AmneziaVPN 4.8.12 or newer, AmneziaWG 2.0+ apps",short:"AmneziaWG 2.0+ apps"},{id:"max",title:"Maximum",ic:"lock",stealth:4,speed:3,needs:"v3",text:"AmneziaWG 3.1: encrypted packet headers, random tails and sizes, jittered timing, and a first packet that looks like DNS.",apps:"Apps with AmneziaWG 3.1 (current AmneziaVPN)",short:"AmneziaWG 3.1 apps"}],Ot=n=>ur.find(e=>e.id===n),fn=n=>n.v3?"max":n.v2?"balanced":"off",jt=n=>n==="standard"?"Standard (old)":n==="strong"?"Strong (old)":null,es={v2:"Needs AmneziaWG 2.0 or newer on the router (kmod-amneziawg and amneziawg-tools from July 2025 on).",v3:"Needs AmneziaWG 3.1 on the router (kmod-amneziawg and amneziawg-tools 3.1)."},ts={v2:"Needs AmneziaWG on the router.",v3:"Needs AmneziaWG 3.1 on the router: install it first."};function pr(n,e){return t("span",{class:"dl-dots",title:`${e}: ${n} of 4`},[t("span",{class:"dl-dots-label"},e),t("span",{class:"dl-dots-row"},[0,1,2,3].map(r=>t("i",{class:rdom.content(i,ur.map(l=>{let d=!l.needs||n[l.needs],c=l.id===e;return t("button",{type:"button",role:"radio","aria-checked":c?"true":"false","aria-disabled":d?null:"true",class:`dl-method${c?" on":""}${d?"":" off"}`,click:()=>{!d||c||(e=l.id,s(),r(l.id))}},[t("div",{class:"dl-method-head"},[t("span",{class:"dl-method-ic"},v(l.ic)),t("b",{},l.title),l.id===o?t("span",{class:"dl-pill ok"},"Current"):""]),t("p",{},l.text),t("div",{class:"dl-method-meters"},[pr(l.stealth,"Stealth"),pr(l.speed,"Speed")]),t("div",{class:"dl-method-foot"},d?[v(l.id==="off"?"wireguard":"amneziawg"),t("span",{},l.apps)]:[v("alert"),t("span",{},(a?es:ts)[l.needs])])])}));return s(),i}function mr(n,e){return t("div",{class:"dl-corehead"},[t("h3",{},n),e?t("span",{class:"dl-sub"},e):""])}var hr=[["jc","Jc"],["jmin","Jmin"],["jmax","Jmax"],["s1","S1"],["s2","S2"],["s3","S3"],["s4","S4"],["h1","H1"],["h2","H2"],["h3","H3"],["h4","H4"],["i1","I1"],["i2","I2"],["i3","I3"],["i4","I4"],["i5","I5"],["header_protection_key","HeaderProtectionKey"],["content_padding_addition","ContentPaddingAddition"],["rekey_after_time","RekeyAfterTime"],["rekey_timeout","RekeyTimeout"],["reject_after_time","RejectAfterTime"],["keepalive_timeout","KeepaliveTimeout"],["max_handshake_attempts","MaxHandshakeAttempts"],["random_trailers","RandomTrailers"],["disable_cookies","DisableCookies"]];function ns(n){let e=c=>n[c]!=null&&n[c]!=="",r=hr.filter(([c])=>e(c));if(!r.length)return null;let o=(c,p)=>t("span",{class:"dl-pv"},[t("i",{},p),t("b",{},c==="header_protection_key"?`${n[c].slice(0,6)}••••`:n[c])]),a=(c,p,u,x)=>{let $=hr.filter(([h])=>x.includes(h)&&e(h));return $.length?t("div",{class:"dl-pgroup"},[t("div",{class:"dl-pgroup-head"},[v(p),t("b",{},c)]),t("p",{},u),t("div",{class:"dl-pvals"},$.map(([h,m])=>o(h,m)))]):""},i=Number(n.jc||0),s=(n.i1??"").includes("0x8580")?"A first packet shaped like a DNS answer.":"Extra packets sent before the handshake.",l=r.map(([c,p])=>`${p} = ${n[c]}`).join(` +`),d=t("div",{class:"dl-pgrid"},[a("Junk packets","zap",i?`${i} random packet${i===1?"":"s"} of ${n.jmin}–${n.jmax} bytes before each handshake.`:"No junk packets.",["jc","jmin","jmax"]),a("Padding","archive","Random bytes in front of handshake, cookie and data packets, so their sizes do not match WireGuard.",["s1","s2","s3","s4"]),a("Packet types","key","The values that replace WireGuard’s recognisable message types.",["h1","h2","h3","h4"]),a("Signatures","globe",s,["i1","i2","i3","i4","i5"]),a("Protection","lock","AmneziaWG 3.1: encrypted headers, random tails and extra padding on data packets.",["header_protection_key","content_padding_addition","random_trailers","disable_cookies"]),a("Timing","clock","Handshake and key timers vary within these ranges instead of WireGuard’s fixed values.",["rekey_after_time","rekey_timeout","reject_after_time","keepalive_timeout","max_handshake_attempts"])]);return t("details",{class:"dl-params"},[t("summary",{},[v("chevron"),t("span",{},"Current parameters"),t("span",{class:"dl-pcount"},String(r.length)),t("span",{class:"dl-spacer"}),t("button",{type:"button",class:"dl-linkbtn",click:c=>{c.preventDefault(),me(l,"Parameters copied")}},"Copy as config")]),d])}function fr(n,e){if(/^\s*\[.+\]\s*$/.test(n))return t("span",{class:"dl-conf-sec"},n);let r=/^(\s*[A-Za-z0-9]+\s*=)\s*(.*)$/.exec(n);if(!r)return document.createTextNode(n);let o=/^(\s*)(PrivateKey|PresharedKey)\b/.test(n);return t("span",{},[t("span",{class:"dl-conf-k"},r[1])," ",o&&!e?t("span",{class:"dl-conf-mask"},"••••••••••••••••"):r[2]])}function os(n){let e=!1,r=t("pre",{class:"dl-conf"}),o=()=>dom.content(r,n.conf.split(` `).flatMap((s,l)=>l?[` -`,gr(s,e)]:[gr(s,e)])),a=t("button",{type:"button",class:"dl-chipbtn",click:s=>{s.preventDefault(),e=!e,dom.content(a,[b(e?"x":"key"),e?"Hide key":"Show key"]),o()}},[b("key"),"Show key"]);o();let i=new Blob([n.conf]).size;return t("div",{class:"dl-stack gap8"},[t("div",{class:"dl-filecard"},[t("span",{class:"dl-filecard-ic"},".conf"),t("span",{class:"dl-stack"},[t("span",{class:"dl-mono dl-ellipsis"},n.filename),t("span",{class:"dl-sub"},`AmneziaWG · ${i} bytes · import it in the app`)]),H([b("download")," Download"],()=>Te(n.filename,n.conf,"application/octet-stream"),"positive")]),t("details",{class:"dl-params"},[t("summary",{},[b("chevron"),t("span",{},"Configuration"),t("span",{class:"dl-spacer"}),a,t("button",{type:"button",class:"dl-chipbtn",click:s=>{s.preventDefault(),ue(n.conf,"Configuration copied")}},[b("copy"),"Copy"])]),r])])}function no(n){let e=n.amnezia.obfuscation??{},r={h1:"1",h2:"2",h3:"3",h4:"4"};return Object.entries(e).every(([o,a])=>a==null||a===""||a===(r[o]??"0"))}async function os(n,e="file"){if(!n.has_private_key)return t("div",{class:"dl-hint"},"This device generated its own keys in the browser, so its full configuration only exists on that device.");let r=await to(n,n.server),o={qr:()=>t("div",{class:"dl-qr-pane"},[et(Lt(n.conf),"dl-qr"),t("span",{class:"dl-sub"},no(n)?"Scan with AmneziaVPN or any WireGuard app on the device.":"Scan with AmneziaVPN or AmneziaWG on the device.")]),key:()=>t("div",{class:"dl-stack gap8"},[t("div",{class:"dl-linkbox"},[t("span",{class:"dl-mono"},r),H("Copy",()=>ue(r,"Key copied"))]),t("span",{class:"dl-sub"},"AmneziaVPN → Add server → Insert key. Keep it private.")]),file:()=>ns(n)},a=t("div",{class:"dl-connect-body"}),i=t("div",{class:"dl-seg"}),s=l=>{i.querySelectorAll("button").forEach(d=>d.classList.toggle("on",d.dataset.id===l)),dom.content(a,o[l]())};for(let[l,d]of[["file","File"],["key","Key"],["qr","QR code"]])i.appendChild(t("button",{type:"button","data-id":l,click:()=>s(l)},d));return s(e),t("div",{class:"dl-stack gap12"},[i,a])}async function rs(n,e,r,o){let a=jt(r),s=n.st.people.filter(d=>d.server===e.id).reduce((d,c)=>d+c.devices.length,0);await le(o?"Generate new disguise values?":`Switch to ${a.title}?`,`${s} AmneziaWG device${s===1?" stops":"s stop"} connecting until ${s===1?"it imports its":"they import their"} configuration again (from their personal link or from you).${r==="max"?" They need an app with AmneziaWG 3.1.":r==="balanced"?" They need an app with AmneziaWG 2.0 or newer.":""}${n.st.servers.length===1&&s?" To keep the old disguise for some people, add a second server and move them there.":""}`,o?"Generate and apply":"Switch and apply",!0)&&await G(()=>A.serverObfuscation(e.id,r),o?"New values applied":`${a.title} applied`)&&(U("Devices are marked “Update config” until they import again.","info",6e3),await n.refresh())}function as(n,e){let r=n.st,o=se(String(e.port),{inputmode:"numeric",class:"cbi-input-text dl-w-port dl-mono"}),a=se(e.mtu?String(e.mtu):"",{placeholder:"Auto",inputmode:"numeric",class:"cbi-input-text dl-w-port dl-mono"}),i=se(String(e.keepalive??""),{placeholder:"25",inputmode:"numeric",class:"cbi-input-text dl-w-port dl-mono"}),s=jt(e.preset)?e.preset:void 0,l=s??mn(r.awg),d=H("",()=>rs(n,e,l,l===s),"neutral"),c=()=>dom.content(d,l===s?[b("reset")," Generate new values"]:[`Switch to ${jt(l).title}`]);c();let p=r.awg_state?.tools!==!1,u=[],x=he("UDP port",o,()=>It(Number(o.value),u,`Opened on the WAN firewall automatically.${Number(o.value)===4500?" 4500 is IPsec’s port: most networks let it through.":""}`));A.serverPorts(e.id).then(m=>{u=m.udp_taken??[],x.refresh()}).catch(()=>{});let $=he("MTU",a,()=>Fo(a.value,e.mtus)),h=he("Keep-alive",i,()=>qo(i.value));return Rt("",[hr("AmneziaWG",e.ifname),fe("globe","Listening","Where devices reach this core from the internet",[x]),fe("file","In every device configuration","Changing these marks devices “Update config” until they import again",[$,h]),fe("shield","Disguise","So networks that block VPNs do not recognise the tunnel. Off = plain WireGuard",[Ut(e.preset)?pt("warn",[t("b",{},Ut(e.preset))," is AmneziaWG 1.0 junk only, which networks learned to spot; it is not offered any more. Switch to ",t("b",{},"Balanced")," or ",t("b",{},"Maximum"),": devices import their configuration again."]):"",hn(r.awg,l,m=>{l=m,c()},s,p),p&&!r.awg.v3?pt("info",["This router runs an older AmneziaWG. ",t("b",{},"Maximum")," becomes available with kmod-amneziawg and amneziawg-tools 3.1."]):"",ts(e.obf??{})??"",t("div",{class:"dl-row-end"},[t("span",{class:"dl-sub"},"Applies at once: every AmneziaWG device imports its configuration again."),d])]),t("details",{class:"dl-params"},[t("summary",{},[b("chevron"),t("span",{},"Tunnel"),t("span",{class:"dl-pcount"},"3")]),t("div",{class:"dl-params-body"},[ce("Interface",t("span",{class:"dl-mono"},`${e.ifname} · router ${e.address}`)),ce("Tunnel subnet",t("span",{class:"dl-mono"},e.subnet),"Device addresses come from it."),ce("Server public key",t("span",{class:"dl-keyrow"},[t("code",{class:"dl-mono"},e.public_key),H([b("copy")],()=>ue(e.public_key,"Public key copied"),"neutral",{title:"Copy",class:"cbi-button cbi-button-neutral dl-icon-only sm"})]))])])],[t("span",{class:"dl-sub"},"Port, MTU and keep-alive apply at once."),H("Save",()=>{let m=ze([x,$,h]);if(m){U(m,"warning");return}return n.save({port:o.value,mtu:a.value,keepalive:i.value},"AmneziaWG saved")},"positive")])}function is(n){let e=jt(n.preset),r=n.obf??{},o=(s,l)=>t("span",{class:`dl-segs ${l}`},[0,1,2,3].map(d=>t("i",{class:d+r[s]).map(s=>`${s.toUpperCase()} ${r[s]}`);return i.length&&a.push(i.slice(0,2).join(" · ")+(i.length>2?` +${i.length-2}`:"")),["h1","h2","h3","h4"].some(s=>r[s]&&r[s]!==String(["h1","h2","h3","h4"].indexOf(s)+1))&&a.push("H1–H4 random"),r.i1&&a.push(/0x(8580|0100)0001/.test(r.i1)?"DNS-like first packets":"Signature packets"),r.header_protection_key&&a.push("Encrypted headers"),a.length||a.push(e?.id==="off"?"Plain WireGuard":"No values yet"),t("div",{class:"dl-bento-tile dl-disg"},[t("div",{class:"dl-bento-head"},[t("span",{class:"dl-metric-label"},"Disguise"),t("a",{href:`${L.url("admin/network/dawnline/server")}?server=${encodeURIComponent(n.id)}§ion=awg`},"Change")]),t("div",{class:"dl-disg-id"},[t("span",{class:`dl-disg-ic${e?.id==="off"?" off":""}`},b(e?.ic??"shield")),t("span",{class:"dl-stack"},[t("b",{},e?e.title:Ut(n.preset)??"Custom"),t("span",{class:"dl-sub"},e?e.short:Ut(n.preset)?"Switch to Balanced or Maximum":"Set by hand")])]),e?t("div",{class:"dl-disg-meters"},[t("span",{},"Stealth"),o(e.stealth,"acc"),t("span",{},"Speed"),o(e.speed,"ok")]):"",t("div",{class:"dl-disg-chips"},a.map(s=>t("span",{},s)))])}var oo={id:"awg",label:"AmneziaWG",settingsCard:as,overviewTile:is,connectBlock:os,qrText:n=>n.conf,appKey:{label:"Copy AmneziaVPN key",make:n=>to(n,n.server)},file:{label:"Download .conf",make:n=>({name:n.filename,text:n.conf})}};var ss={awg:oo};function Be(n){return ss[n?.core||"awg"]??oo}function Tt(n,e){return Be(n.find(r=>r.id===e))}var ls=2,Gt=new Set,ro=null,fn=null;async function vr(){if(document.visibilityState!=="visible"||!Gt.size)return;let n=await A.rev().catch(()=>null);if(!n)return;let e=ro!=null&&n.rev!==ro;ro=n.rev,n.version&&(fn&&n.version!==fn?(U(`Dawnline was updated to ${n.version}: reload the page.`,"warning",15e3),fn=null):fn??(fn=n.version)),e&&Gt.forEach(r=>r())}function gn(n){return Gt.add(n),poll.add(vr,ls),()=>{Gt.delete(n),Gt.size||poll.remove(vr)}}function wr(n,e,r,o,a=0){let i=[],s=null,l=p=>{s&&p>s.from&&i.push({...s,to:p}),s=null},d=n.filter(p=>p.device===e).sort((p,u)=>p.ts-u.ts);for(let p of d)if(p.type==="connect")l(p.ts),p.detail&&(s={ip:p.detail,from:p.ts,to:p.ts,live:!1});else if(p.type==="roam"){let u=p.detail?.split("→")[1]?.trim();l(p.ts),u&&(s={ip:u,from:p.ts,to:p.ts,live:!1})}else p.type==="disconnect"&&l(p.ts);let c=s;return c&&o?i.push({...c,to:Math.max(r,c.from),live:!0}):l(Math.min(r,a)),i}function Ke(n){return`${n.city||`${n.lat.toFixed(1)},${n.lon.toFixed(1)}`}|${n.cc}`}function yr(n,e,r,o){let a=new Map;for(let s of e)(s.device===r||!a.has(s.ip))&&a.set(s.ip,s);let i=[];for(let s of n){let l=a.get(s.ip);!l||s.to<=o||i.push({key:Ke(l),point:l,from:Math.max(s.from,o),to:s.to,live:s.live})}return i}function kr(n){let e=new Map,r=0;for(let o of n)e.set(o.key,(e.get(o.key)??0)+(o.to-o.from)),r+=o.to-o.from;return new Map([...e].map(([o,a])=>[o,r?a/r:0]))}function br(n,e=2700){let r=[];for(let o of n){let a=r[r.length-1];if(a&&o.key!==a.key&&!o.live&&o.to-o.from{i&&(r.push({kind:"move",k:i,start:o,ms:e}),o+=e);let s=Math.min(1100,Math.max(350,(a.to-a.from)/3600*45));r.push({kind:"stay",k:i,start:o,ms:s}),o+=s}),{steps:r,total:o}}function Lr(n,e,r){let o=e.findIndex(l=>r>=l.start&&rr>=s.from&&rs.kind==="stay"&&s.k===o),i=n[o];return a.start+a.ms*Math.min(.999,Math.max(0,(r-i.from)/Math.max(1,i.to-i.from)))}var ds=n=>n<=0?0:n>=1?1:n<.5?2*n*n:1-(-2*n+2)**2/2;function Sr(n){return-ao/2+(1+ao)*ds((n-xr)/(1-xr))}var Tr=n=>n+Cr>=1;function _r(n){return["interpolate",["linear"],["abs",["-",["get","pos"],n]],0,1,Cr,1,ao/2,0]}function Pr(n,e){let r=n==="24h"?86400:n==="7d"?604800:2592e3,o=e-r,a=[],i=(l,d)=>{let c=(l-o)/r;c>.02&&c<.98&&a.push([c,d])},s=new Date(o*1e3);if(n==="24h")for(s.setMinutes(0,0,0);s.getTime()/1e3<=e;)s.getHours()%6===0&&i(s.getTime()/1e3,`${String(s.getHours()).padStart(2,"0")}:00`),s.setHours(s.getHours()+1);else if(n==="7d")for(s.setHours(12,0,0,0);s.getTime()/1e3<=e;s.setDate(s.getDate()+1))i(s.getTime()/1e3,s.toLocaleDateString("en-GB",{weekday:"short"}));else{let l=new Date(e*1e3);l.setHours(0,0,0,0);for(let d=0;d<5;d++){let c=new Date(l);c.setDate(l.getDate()-7*d),i(c.getTime()/1e3,c.toLocaleDateString("en-GB",{day:"numeric",month:"short"}))}a.reverse()}return a}var vn=n=>new Date(n*1e3).toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit"});function Dr(n,e){let r=o=>new Date(o*1e3).toDateString();return r(n)===r(e)?"Today":r(n)===r(e-86400)?"Yesterday":new Date(n*1e3).toLocaleDateString("en-GB",{weekday:"short",day:"numeric",month:"short"})}var so="https://unpkg.com/maplibre-gl@6.14.0/dist",Ar={module:"sha384-q26X6R1yFeg0QR9SHHn6U3Nb0ddRRTtwxsahubv5R89/v5nijKpk9KviUp9ZLySk",css:"sha384-1TZtfVz7qtwR5vD7cMwjGT+9uiK4lqE3pbUOPwYO6OCpb+TYP0S9vLIhG02JCU04"},Hr="https://basemaps.cartocdn.com/gl/dark-matter-gl-style/style.json",zr="https://basemaps.cartocdn.com/gl/positron-gl-style/style.json",cs={online:0,"24h":86400,"7d":7*86400,"30d":30*86400},Wt=null;function ps(n){if(n.appendChild(t("link",{rel:"stylesheet",href:`${so}/maplibre-gl.css`,integrity:Ar.css,crossorigin:"anonymous"})),Wt)return Wt;let e=`${so}/maplibre-gl.mjs`;return Wt=new Promise((o,a)=>{let i=t("link",{rel:"modulepreload",href:e,integrity:Ar.module,crossorigin:"anonymous"});i.addEventListener("load",()=>o()),i.addEventListener("error",()=>a(new Error("integrity"))),document.head.appendChild(i)}).then(()=>import(e)).then(o=>(o.getWorkerUrl()||o.setWorkerUrl(`${so}/maplibre-gl-worker.mjs`),o),o=>{throw Wt=null,new Error(o?.message==="integrity"?"The map library from the CDN is not the expected file: not loading it.":"Could not load the map library (no internet access from this browser?)")}),Wt}function bn(){let n=document.documentElement.getAttribute("data-darkmode");return n!=null?n==="true":window.matchMedia?.("(prefers-color-scheme: dark)").matches??!1}var us=10,Nr=30,ms=62,hs=4,Rr=4.5,fs=7,xn="#3b82f6",lo="#8a8a8a";function Ir(n,e,r=.2,o=64){let[a,i]=n,[s,l]=e,d=s-a,c=d>180?s-360:d<-180?s+360:s,p=c-a,u=l-i,x=Math.hypot(p,u);if(x===0||r===0)return[n,[c,l]];let $=-u/x,h=p/x,m=x*r,C=(a+c)/2+$*m,B=(i+l)/2+h*m,w=[],v=Math.max(2,Math.floor(o));for(let y=0;y<=v;y+=1){let E=y/v,k=1-E;w.push([k*k*a+2*k*E*C+E*E*c,k*k*i+2*k*E*B+E*E*l])}return w}function co(n,e){let r=new Map;for(let o of n.geo.points){if(n.person&&o.person!==n.person||n.device&&o.device!==n.device||(e==="online"?!o.online:n.now-o.ts>cs[e]))continue;let a=n.device?Ke(o):n.person?`${o.device}|${o.city}|${o.cc}`:o.device,i=r.get(a);(!i||o.online&&!i.online||o.online===i.online&&o.ts>i.ts)&&r.set(a,o)}return[...r.values()]}function po(n,e){let r=0;return co(n,e).sort((o,a)=>Number(a.online)-Number(o.online)||a.ts-o.ts).map(o=>({...o,n:o.online?0:++r}))}var nt=class{constructor(e,r="online",o=380){this.cb=e;this.map=null;this.gl=null;this.markers=[];this.popup=null;this.theme=null;this.resize=null;this.fitBlind=!1;this.data=null;this.fitted=!1;this.fitKey=null;this.people=[];this.slots=[];this.merged=[];this.piles=new Map;this.dock=null;this.dockKey="";this.dockQuiet=!1;this.piledKeys=new Set;this.foldedKeys=new Set;this.targetZoom=null;this.before=null;this.hiddenKey="";this.focused=null;this.dead=!1;this.places=new Map;this.replaying=null;this.bandDots=[];this.range=r,this.status=t("div",{class:"dl-map-status"}),this.card=t("div",{class:"dl-map-card","aria-live":"polite"}),this.el=t("div",{class:"dl-geomap",style:`height:${o}px`},[this.status,this.card])}async mount(e){this.data=e;try{this.gl=await ps(this.el)}catch(o){this.status.textContent=o.message;return}if(this.dead)return;this.map=new this.gl.Map({container:this.el,style:bn()?Hr:zr,center:[e.geo.home?.lon??20,e.geo.home?.lat??50],zoom:1,renderWorldCopies:!1,attributionControl:{compact:!0},minZoom:1}),this.map.on("style.load",()=>this.layers()),this.map.on("move",()=>this.declutter()),this.map.once("idle",()=>{let o=this.el.querySelector(".maplibregl-ctrl-attrib");o?.classList.remove("maplibregl-compact-show"),o?.removeAttribute("open")}),this.resize=new ResizeObserver(()=>{!this.map||!this.el.clientWidth||!this.el.clientHeight||(this.map.resize(),this.fitBlind&&(this.fitKey=null,this.draw()))}),this.resize.observe(this.el);let r=bn();this.theme=new MutationObserver(()=>{!this.map||bn()===r||(r=bn(),this.map.setStyle(r?Hr:zr))}),this.theme.observe(document.documentElement,{attributes:!0,attributeFilter:["data-darkmode"]})}layers(){if(this.map){this.hiddenKey="",this.map.setProjection({type:"globe"}),this.map.addSource("dl-areas",{type:"geojson",data:{type:"FeatureCollection",features:[]}}),this.map.addLayer({id:"dl-area",type:"circle",source:"dl-areas",paint:{"circle-radius":["interpolate",["exponential",2],["zoom"],2,6,6,26,9,140,12,900],"circle-color":["case",["get","online"],xn,lo],"circle-opacity":["case",["get","online"],.12,.06],"circle-stroke-width":1,"circle-stroke-color":["case",["get","online"],xn,lo],"circle-stroke-opacity":["case",["get","online"],.35,.15]}}),this.map.addSource("dl-band",{type:"geojson",data:{type:"FeatureCollection",features:this.bandDots}}),this.map.addLayer({id:"dl-band",type:"circle",source:"dl-band",paint:{"circle-radius":1.4,"circle-color":xn,"circle-opacity":0}}),this.map.addSource("dl-arcs",{type:"geojson",data:{type:"FeatureCollection",features:[]}});for(let e of[!1,!0])this.map.addLayer({id:e?"dl-arc-live":"dl-arc-recent",type:"line",source:"dl-arcs",filter:["==",["get","online"],e],layout:{"line-join":"round","line-cap":"round"},paint:{"line-color":e?xn:lo,"line-width":2,"line-opacity":.85,"line-dasharray":[2,2]}});this.draw()}}setRange(e){this.range=e,this.fitKey=null,this.draw()}update(e){this.data=e,this.draw()}destroy(){this.dead=!0,this.dropCard();for(let e of this.piles.values())e.marker.remove();this.piles.clear(),this.theme?.disconnect(),this.resize?.disconnect(),this.map?.remove(),this.map=null}groups(e){let r=new Map;for(let o of e){let a=`${o.person}|${Ke(o)}`,i=r.get(a);i||(i={key:a,person:o.person,lat:o.lat,lon:o.lon,city:o.city,country:o.country,cc:o.cc,asn:o.asn,org:o.org,online:!1,ts:0,points:[]},r.set(a,i)),i.points.push(o),i.online||(i.online=o.online),i.ts=Math.max(i.ts,o.ts)}return[...r.values()]}draw(){if(!this.map||!this.data||!this.map.getSource("dl-arcs"))return;let e=this.data,r=this.groups(co(e,this.range)),o=e.person||e.device?null:e.geo.home;for(let d of this.markers)d.remove();this.markers=[];let a=e.person||e.device?null:vs(r,o),i=r.map(d=>({g:d,at:a?.get(d.key)??[d.lon,d.lat]}));if(this.slots=[],this.map.getSource("dl-areas").setData({type:"FeatureCollection",features:i.map(({g:d})=>({type:"Feature",properties:{online:d.online,key:d.key},geometry:{type:"Point",coordinates:[d.lon,d.lat]}}))}),this.map.getSource("dl-arcs").setData({type:"FeatureCollection",features:o?i.map(({g:d,at:c})=>({type:"Feature",properties:{online:d.online,person:d.person,key:d.key},geometry:{type:"LineString",coordinates:Ir([o.lon,o.lat],c)}})):[]}),o){let d=t("span",{class:"dl-mk-host"});d.innerHTML=`${ft("server","dl-mk-host-ic")}`,this.dock=d.appendChild(t("span",{class:"dl-mk-dock"})),this.dockQuiet=this.dockKey!=="",this.dockKey="";let c=t("div",{class:"dl-mk-hub",title:`Home router${o.city?` · ${o.city}`:""}${o.org?` · ${o.org}`:""}`},[d,t("span",{class:"dl-mk-label chip"},o.city||"Home")]);c.addEventListener("mouseenter",()=>this.showMerged(o.city||"the server")),c.addEventListener("mouseleave",()=>this.focus(this.focused)),c.addEventListener("click",()=>this.zoomToMerged()),this.add(c,[o.lon,o.lat],!0)}let s=new Map(e.device?po(e,this.range).map(d=>[Ke(d),d.n]):[]);this.people=[],this.places.clear();for(let{g:d,at:c}of i){let p=d.points.length,u=e.people.find(m=>m.id===d.person);if(e.person){let m=e.device?this.deviceMarker(d,c,u,s.get(Ke(d))??0):this.placeMarker(d,c,u);this.add(m,c);continue}let x=d.points.map(m=>u?.devices.find(C=>C.id===m.device)?.kind??"other"),$=t("span",{class:"dl-mk-badge"});$.innerHTML=p<=2?x.map(m=>ft(m,"dl-mk-badge-ic")).join(""):String(p);let h=t("button",{type:"button",class:`dl-mk${d.online?" online":""}`,"aria-label":`${u?.name??"Someone"}: ${p} device${p===1?"":"s"} in ${d.city||"an unknown city"}`},[t("span",{class:"dl-mk-av"},[He(u?.name??"?"),$]),t("span",{class:"dl-mk-label below"},d.city||d.cc||"?")]);h.addEventListener("mouseenter",()=>this.focus(d.person)),h.addEventListener("mouseleave",()=>this.focus(null)),this.people.push({el:h,person:d.person}),h.addEventListener("click",m=>{m.stopPropagation(),this.openPopup(d,c,h)}),this.add(h,c,!1,u?.name??"Someone",`${d.city||d.cc||"?"} · ${d.online?"now":re(d.ts,e.now)}`,d.key,d)}this.declutter();let l=i.map(d=>d.g.key).sort().join(";");if(l!==this.fitKey&&!this.popup){let d=this.fitted&&!this.fitBlind;if(this.fitBlind=!this.el.clientWidth||!this.el.clientHeight,this.fitKey=l,this.fitted=!0,o&&!i.length){let c={center:[o.lon,o.lat],zoom:12};d?this.glide(12,()=>this.map.flyTo({...c,duration:1200})):this.map.jumpTo(c)}else{let c=i.map(p=>p.at);o&&(c.length===0||this.range!=="online"||i.some(p=>p.g.online))&&c.push([o.lon,o.lat]),this.fit(c,d)}}this.status.textContent=i.length||o?"":"No locations yet",this.status.style.display=this.status.textContent?"":"none",this.focus(this.focused&&this.people.some(d=>d.person===this.focused)?this.focused:null)}add(e,r,o=!1,a,i,s,l){s&&this.foldedKeys.has(s)&&e.classList.add("merged"),s&&this.piledKeys.has(s)&&e.classList.add("piled"),e.dataset.key=s??"",e.classList.add("dl-mk-new"),requestAnimationFrame(()=>requestAnimationFrame(()=>e.classList.remove("dl-mk-new")));let d=new this.gl.Marker({element:e}).setLngLat(r).addTo(this.map);this.markers.push(d),this.slots.push({marker:d,el:e,at:r,fixed:o,who:a,where:i,g:l})}declutter(){if(!this.map)return;let e=this.map.getZoom();this.el.classList.toggle("dl-lod-far",e=Rr&&e{let l=this.map.project(s.at),d=s.el.querySelector(":scope > .dl-mk-host, :scope > .dl-mk-av, :scope > .dl-mk-tile");return{x:l.x,y:l.y,r:(d?.offsetWidth||24)/2+3,fixed:s.fixed}}),o=r.filter(s=>s.fixed);this.merged=[],this.foldedKeys.clear();let a=this.targetZoom==null?1:Math.min(1,2**(this.targetZoom-this.map.getZoom()));r.forEach((s,l)=>{if(s.fixed)return;let d=this.slots[l],c=d.el.classList.contains("merged")?12:6,p=o.find(u=>Math.hypot(u.x-s.x,u.y-s.y)*a{let c=this.slots[d];!c||c.fixed||(r[d].fixed&&([s,l]=[0,0]),c.marker.setOffset([s,l]),xs(c.el,s,l))})}closePopup(e=!1){let r=this.popup;if(!r||r.card.classList.contains("leaving"))return;r.card.classList.add("leaving"),setTimeout(()=>{this.popup===r&&this.dropCard()},140);let o=this.before;if(this.before=null,!o)return;let a=()=>this.map?.flyTo({...o,duration:800});if(!e)return a();let i=!1,s=()=>{i||(i=!0,window.removeEventListener("pointerup",s,!0),window.removeEventListener("pointercancel",s,!0),setTimeout(a,0))};window.addEventListener("pointerup",s,!0),window.addEventListener("pointercancel",s,!0),setTimeout(s,1500)}dropCard(){this.popup?.off(),this.popup?.card.remove(),this.popup=null}showMerged(e){this.merged.length&&(dom.content(this.card,[t("div",{class:"dl-map-card-head"},[t("b",{},`Near ${e}`)," · click to zoom in"]),...this.merged.map(r=>t("div",{class:"dl-map-card-row"},[t("span",{},r.who),t("span",{class:"dl-faint"},r.where)]))]),this.card.classList.add("on"))}paintDock(){let e=this.dock;if(!e)return;let r=this.merged.map(a=>`${a.key}:${a.online?1:0}`).join("|");if(r===this.dockKey)return;this.dockKey=r,e.parentElement?.classList.toggle("docked",this.merged.length>0);let o=this.slots.find(a=>a.fixed).at;this.merged.length&&Or(e,this.merged,this.faceActions(()=>[o]),this.dockQuiet),this.dockQuiet=!1}faceActions(e){return{click:(r,o)=>this.openFace(r,o,e()),hover:r=>this.focus(r?.g?.person??null)}}pileUp(e){let r=new Set;if(!this.data?.person&&!this.data?.device){let o=e.flatMap((l,d)=>!l.fixed&&this.slots[d].el.querySelector(":scope > .dl-mk-av")?[d]:[]),a=new Map(o.map(l=>[l,l])),i=l=>a.get(l)===l?l:i(a.get(l));for(let l of o)for(let d of o){if(d<=l)continue;let c=this.slots[l].el.classList.contains("piled")&&this.slots[d].el.classList.contains("piled");Math.hypot(e[l].x-e[d].x,e[l].y-e[d].y)this.slots[m]),c=d.map(Br),p=c.map(m=>m.key).sort().join(",");r.add(p);let u=[d.reduce((m,C)=>m+C.at[0],0)/d.length,d.reduce((m,C)=>m+C.at[1],0)/d.length],x=this.piles.get(p);if(!x){let m=t("span",{class:"dl-mk-pile-box"}),C=[...new Set(d.map(v=>v.g?.city||v.g?.cc||"?"))],B=t("div",{class:"dl-mk-pile"},[m,t("span",{class:"dl-mk-label below"},C.length===1?C[0]:`${d.length} people`)]);x={marker:new this.gl.Marker({element:B}).setLngLat(u).addTo(this.map),el:B,box:m,faces:c},B.addEventListener("mouseleave",()=>this.focus(this.focused));let w=x;B.addEventListener("click",v=>{v.stopPropagation(),this.zoomInTo(w.faces.map(y=>y.at),!1)}),this.piles.set(p,x)}x.faces=c;let $=x;Or(x.box,c,this.faceActions(()=>$.faces.map(m=>m.at)));for(let m of l)this.slots[m].el.classList.add("piled"),Object.assign(e[m],{r:0,fixed:!0});let h=this.map.project(u);e.push({x:h.x,y:h.y,r:(x.el.offsetWidth||60)/2+3,fixed:!0})}}this.piledKeys=new Set(this.slots.filter(o=>o.el.classList.contains("piled")).map(o=>o.el.dataset.key??"")),this.slots.forEach((o,a)=>{(!e[a].fixed||o.fixed||o.el.classList.contains("merged"))&&o.el.classList.remove("piled")});for(let[o,a]of this.piles)r.has(o)||(this.piles.delete(o),a.el.classList.add("out"),setTimeout(()=>a.marker.remove(),200))}zoomToMerged(){!this.map||!this.merged.length||this.zoomInTo([this.slots.find(e=>e.fixed).at,...this.merged.map(e=>e.at)],!1)}openFace(e,r,o){if(!e.g)return;if(o.every(i=>wn(i,e.at)<1))return this.openPopup(e.g,e.at,r);let a=()=>{let i=this.slots.find(s=>s.el.dataset.key===e.key);i?.g&&!i.el.classList.contains("merged")&&!i.el.classList.contains("piled")&&this.openPopup(i.g,i.at,i.el)};this.zoomInTo(this.nearby(e.at),!0)?this.map.once("moveend",a):a()}nearby(e){return[e,...this.slots.filter(r=>!r.fixed&&r.at!==e&&wn(r.at,e)<=Nr).map(r=>r.at)]}zoomInTo(e,r){let o=new this.gl.LngLatBounds;for(let p of e)o.extend(p);let a=e.some(p=>e.some(u=>wn(p,u)>Nr)),i=this.map.cameraForBounds(o,{padding:50,maxZoom:a?12:us}),s=this.map.getZoom(),l=e.map(p=>this.map.project(p)),d=0;l.forEach((p,u)=>l.slice(u+1).forEach(x=>{let $=Math.hypot(p.x-x.x,p.y-x.y),h=s+Math.log2(ms/Math.max($,1e-6));h<=12&&(d=Math.max(d,h))}));let c=Math.min(12,Math.max(i?.zoom??0,d));return c<=s+.05?!1:(r&&!this.before&&(this.before={center:this.map.getCenter().toArray(),zoom:s}),this.map.flyTo({center:i?.center??o.getCenter(),zoom:c,duration:800}),!0)}placeMarker(e,r,o){let a=this.data.now,i=[...e.points].sort((u,x)=>Number(x.online)-Number(u.online)||x.ts-u.ts)[0],s=o?.devices.find(u=>u.id===i.device)?.kind??"other",l=e.points.length,d=t("span",{class:"dl-mk-tile"});d.innerHTML=ft(s,"dl-mk-tile-ic")+(l>1?`${l}`:"");let c=e.online?"now":re(e.ts,a),p=t("button",{type:"button",class:`dl-mk place${e.online?" online":""}`,style:e.online?null:`--dl-mk-fade:${Math.max(.4,1-.6*(a-e.ts)/(30*86400)).toFixed(2)}`,"aria-label":`${l} device${l===1?"":"s"} in ${e.city||"an unknown city"}, ${c}`},[d,t("span",{class:"dl-mk-label below"},[e.city||e.cc||"?",t("span",{class:"dl-mk-when"},c)])]);return p.addEventListener("click",u=>{u.stopPropagation(),this.openPopup(e,r,p)}),p}deviceMarker(e,r,o,a){let i=o?.devices.find(p=>p.id===e.points[0].device)?.kind??"other",s=t("span",{class:"dl-mk-tile"}),l=t("span",{class:"dl-mk-label below"}),d=t("button",{type:"button",class:"dl-mk place step"},[s,l]);d.addEventListener("click",p=>{p.stopPropagation(),this.openPopup(e,r,d)});let c=Ke(e);return this.places.set(c,{el:d,tile:s,label:l,when:null,g:e,n:a,kind:i}),this.paintPlace(c,!1),d}paintPlace(e,r){let o=this.places.get(e);if(!o)return;let a=this.replaying,i=a?a.active===e:o.g.online,s=o.el.classList.contains("online"),l=o.g.city||o.g.cc||"?";o.el.classList.toggle("online",i),o.el.classList.toggle("faded",!!a&&!i),o.tile.classList.toggle("sm",!i),i||!o.n?o.tile.innerHTML=ft(o.kind,"dl-mk-tile-ic"):o.tile.textContent=String(o.n),o.when=null,i?(o.when=t("span",{class:`dl-mk-when${a?" inline":""}`},a?a.when:"now"),o.label.replaceChildren(l,a?" · ":"",o.when)):o.label.replaceChildren(`${l} · ${o.g.online?"now":re(o.g.ts,this.data.now)}`);let d=i?a?a.when:"now":o.g.online?"now":re(o.g.ts,this.data.now);o.el.setAttribute("aria-label",`${o.n?`${o.n}: `:""}${o.g.city||"an unknown city"}, ${d}`),r&&i&&!s&&(o.el.classList.remove("arrive"),o.el.offsetWidth,o.el.classList.add("arrive"),setTimeout(()=>o.el.classList.remove("arrive"),500))}replay(e,r=!0){let o=this.replaying;if(this.replaying=e,o&&e&&o.active===e.active){let a=e.active?this.places.get(e.active):null;a?.when&&(a.when.textContent=e.when);return}for(let a of this.places.keys())a!==e?.active&&this.paintPlace(a,r);e?.active&&this.paintPlace(e.active,r),this.declutter(),setTimeout(()=>this.declutter(),320)}hoverPlace(e){for(let[r,o]of this.places)o.el.classList.toggle("hl",r===e)}band(e,r){if(this.bandDots=[],this.map&&e&&r){let o=Ir(e,r),a=o.map(c=>this.map.project(c)),i=[0];for(let c=1;ci[d]?(p-i[d])/(i[d+1]-i[d]):0,x=[o[d][0]+(o[d+1][0]-o[d][0])*u,o[d][1]+(o[d+1][1]-o[d][1])*u];this.bandDots.push({type:"Feature",properties:{pos:c/l},geometry:{type:"Point",coordinates:x}})}}this.map?.getLayer("dl-band")&&(this.map.setPaintProperty("dl-band","circle-opacity",0),this.map.getSource("dl-band").setData({type:"FeatureCollection",features:this.bandDots}))}bandAt(e){this.map?.getLayer("dl-band")&&this.map.setPaintProperty("dl-band","circle-opacity",_r(e))}focus(e){this.focused=e;for(let s of this.people)s.el.classList.toggle("dim",!!e&&s.person!==e),s.el.classList.toggle("hl",s.person===e);let r=e?["case",["==",["get","person"],e],.85,.15]:.85;for(let s of["dl-arc-live","dl-arc-recent"])this.map?.getLayer(s)&&this.map.setPaintProperty(s,"line-opacity",r);if(this.card.classList.toggle("on",!!e),!e||!this.data)return;let o=this.data,a=o.people.find(s=>s.id===e),i=co(o,this.range).filter(s=>s.person===e).sort((s,l)=>Number(l.online)-Number(s.online)||l.ts-s.ts);dom.content(this.card,[t("div",{class:"dl-map-card-head"},[t("b",{},a?.name??e),` · ${i.length} device${i.length===1?"":"s"}`]),...i.map(s=>t("div",{class:"dl-map-card-row"},[t("span",{},a?.devices.find(l=>l.id===s.device)?.name??"Device"),t("span",{class:"dl-faint"},`${s.city||s.cc||"?"} · ${s.online?"now":re(s.ts,o.now)}`)]))])}fit(e,r=!1){if(!e.length)return;let o=(p,u)=>{let x=Math.PI/180,$=(u[1]-p[1])*x,h=(u[0]-p[0])*x,m=Math.sin($/2)**2+Math.cos(p[1]*x)*Math.cos(u[1]*x)*Math.sin(h/2)**2;return 12742*Math.asin(Math.sqrt(m))},a=[e.reduce((p,u)=>p+u[0],0)/e.length,e.reduce((p,u)=>p+u[1],0)/e.length],i=e;if(e.length>=5){let p=[...e].sort((u,x)=>o(a,u)-o(a,x));i=p.slice(0,Math.ceil(p.length*.9))}let s=new this.gl.LngLatBounds(i[0],i[0]);i.forEach(p=>s.extend(p));let l=this.el.clientHeight||380,d=!!this.data?.person,c={padding:{top:this.data?.device?Math.min(56,l/4):Math.min(60,l/5),bottom:d?Math.min(52,l/4):Math.min(40,l/8),left:48,right:48},maxZoom:this.data?.person?11:12};r?this.glide(this.map.cameraForBounds(s,c)?.zoom??null,()=>this.map.fitBounds(s,{...c,duration:1200})):this.map.fitBounds(s,{...c,duration:0})}glide(e,r){this.targetZoom=e,this.declutter(),this.map.once("moveend",()=>{this.targetZoom=null,this.declutter()}),r()}openPopup(e,r,o){let a=this.data,i=[e.city,e.cc||e.country].filter(Boolean).join(", "),s=[...new Set(e.points.map(v=>v.person))],l=e.points.sort((v,y)=>Number(y.online)-Number(v.online)||y.ts-v.ts).map(v=>{let y=a.people.find(k=>k.id===v.person),E=y?.devices.find(k=>k.id===v.device);return t("button",{type:"button",class:"dl-pop-row",click:()=>this.cb.openDevice(v.person,v.device)},[t("span",{class:`dl-pop-dot${v.online?" on":""}`}),t("span",{class:"dl-pop-name"},[t("b",{},y?.name??v.person),` · ${E?.name??"device"}`]),t("span",{class:"dl-faint dl-nowrap"},v.online?"now":re(v.ts,a.now))])}),d=t("div",{class:"dl-pop"},[t("div",{class:"dl-pop-head"},[t("span",{class:"dl-pop-net"},b("globe")),t("div",{class:"dl-stack"},[t("strong",{},e.org||"Unknown network"),t("span",{class:"dl-faint"},[e.asn?`AS${e.asn} · `:"",i?`${i} · approximate`:"approximate location"])])]),t("div",{class:"dl-pop-list"},l),s.length===1?t("div",{class:"dl-pop-actions"},[t("button",{type:"button",class:"cbi-button cbi-button-positive important",click:()=>this.cb.openPerson(s[0])},`Open ${a.people.find(v=>v.id===s[0])?.name??"person"}`)]):""]);this.zoomInTo(this.nearby(r),!0),this.dropCard();let c=t("div",{class:"dl-root dl-popcard",role:"dialog"},[t("span",{class:"dl-popcard-tip"}),d]);document.body.appendChild(c);let p=this.el,u=o?.querySelector(".dl-mk-av, .dl-mk-tile")??o??null,x=()=>{if(!u)return;let v=u.getBoundingClientRect(),y=p.getBoundingClientRect(),E=v.left+v.width/2,k=v.top+v.height/2;c.classList.toggle("away",Ey.right||ky.bottom);let z=c.offsetWidth,f=c.offsetHeight,g=v.top-f-12>=8||v.top>window.innerHeight-v.bottom,S=Math.min(Math.max(8,E-z/2),window.innerWidth-z-8);c.classList.toggle("above",g),c.classList.toggle("below",!g),c.style.left=`${S}px`,c.style.top=`${g?v.top-f-12:v.bottom+12}px`,c.style.setProperty("--tip-x",`${E-S}px`)},$=v=>{v.target?.closest(".dl-popcard, .maplibregl-marker")||this.closePopup(!0)},h=v=>{v.key==="Escape"&&this.closePopup()},m=v=>{v.target instanceof Element&&v.target.closest(".dl-popcard")||this.closePopup()},C=()=>this.closePopup();this.map.on("move",x),window.addEventListener("scroll",m,{capture:!0,passive:!0}),window.addEventListener("resize",x),document.addEventListener("pointerdown",$,!0),document.addEventListener("keydown",h);let B=$e(C);window.addEventListener("pagehide",C),this.popup={card:c,off:()=>{this.map?.off("move",x),window.removeEventListener("scroll",m,!0),window.removeEventListener("resize",x),document.removeEventListener("pointerdown",$,!0),document.removeEventListener("keydown",h),B(),window.removeEventListener("pagehide",C)}};let w=window.setInterval(()=>{if(this.popup?.card!==c)return clearInterval(w);(!p.isConnected||!p.getClientRects().length)&&this.dropCard()},400);x()}};function gs(n,e=6){let r=n.map(o=>({x:o.x,y:o.y}));for(let o=0;o<16;o++){let a=!1;for(let i=0;i[o.x-n[a].x,o.y-n[a].y])}function vs(n,e){let r=new Map,o=e?[[e.lon,e.lat]]:[],a=i=>o.some(s=>wn(i,s)<1.3);for(let i of[...n].sort((s,l)=>s.key>>12)/1048575),d=(s&4095)/4096*2*Math.PI,c=[i.lon,i.lat];for(let p=0;p<24;p++){let u=d+p*2.39996,x=Math.min(8,l+p*.25);if(c=[i.lon+x*Math.sin(u)/(111.32*Math.cos(i.lat*Math.PI/180)),i.lat+x*Math.cos(u)/111.32],!a(c))break}o.push(c),r.set(i.key,c)}return r}function bs(n){let e=2166136261;for(let r=0;r>>0}function Br(n){return{key:n.el.dataset.key??"",who:n.who??"Someone",where:n.where??"",online:!!n.g?.online,at:n.at,badge:n.el.querySelector(".dl-mk-badge")?.innerHTML??"",g:n.g}}function Or(n,e,r,o=!1){let a=e.length>3,i=()=>[...n.children].filter(h=>!h.classList.contains("out")),s=new Map(i().map(h=>[h,h.getBoundingClientRect().left])),l=n.getBoundingClientRect().width,d=new Map;n.querySelectorAll(".dl-mk-face:not(.out)").forEach(h=>d.set(h.dataset.key??"",h));let c=n.querySelector(".dl-mk-more:not(.out)"),p=h=>{Object.assign(h.style,{position:"absolute",left:`${h.offsetLeft}px`,top:`${h.offsetTop}px`,transform:""}),h.classList.add("out"),setTimeout(()=>h.remove(),200)},u=[];for(let h of e.slice(0,a?2:3)){let m=d.get(h.key);if(d.delete(h.key),!m){let w=t("button",{type:"button",class:`dl-mk-face${o?"":" in"}`,"data-key":h.key},[t("span",{class:"dl-mk-av"},He(h.who)),t("span",{class:"dl-mk-badge"})]);w.addEventListener("animationend",()=>w.classList.remove("in"),{once:!0}),m=w}let C=m,B=C.querySelector(".dl-mk-badge");B.innerHTML!==h.badge&&(B.innerHTML=h.badge),C.title=`${h.who} · ${h.where}`,C.setAttribute("aria-label",`${h.who}, ${h.where}`),C.classList.toggle("on",h.online),C.onclick=w=>{w.stopPropagation(),r.click(h,C)},C.onmouseenter=()=>r.hover(h),C.onmouseleave=()=>r.hover(null),u.push(C)}for(let h of d.values())p(h);if(a){if(!c){c=t("span",{class:`dl-mk-more${o?"":" in"}`});let h=c;h.addEventListener("animationend",()=>h.classList.remove("in"),{once:!0})}c.textContent=`+${e.length-2}`,u.push(c)}else c&&p(c);let x=null;for(let h of u)(x?x.nextElementSibling:n.firstElementChild)!==h&&(x?x.after(h):n.prepend(h)),x=h;for(let h of u){let m=s.get(h);if(m==null)continue;let C=m-h.getBoundingClientRect().left;Math.abs(C)<.5||(h.style.transition="none",h.style.transform=`translateX(${C}px)`,h.offsetWidth,h.style.transition="",h.style.transform="")}n.style.width="";let $=n.getBoundingClientRect().width;if(l&&Math.abs($-l)>.5){n.style.width=`${l}px`,n.offsetWidth,n.style.width=`${$}px`;let h=()=>{n.style.width="",n.removeEventListener("transitionend",h)};n.addEventListener("transitionend",h),setTimeout(h,400)}}function wn(n,e){let r=Math.PI/180,o=Math.sin((e[1]-n[1])*r/2)**2+Math.cos(n[1]*r)*Math.cos(e[1]*r)*Math.sin((e[0]-n[0])*r/2)**2;return 12742*Math.asin(Math.min(1,Math.sqrt(o)))}function xs(n,e,r){let o=n.querySelector(":scope > .dl-mk-ptr"),a=Math.hypot(e,r);if(a<1){o?.remove();return}o||(o=t("span",{class:"dl-mk-ptr"},[t("i",{class:"line"}),t("i",{class:"spot"})]),n.prepend(o));let i=o.firstElementChild,s=o.lastElementChild;i.style.width=`${a}px`,i.style.transform=`rotate(${Math.atan2(-r,-e)}rad)`,s.style.transform=`translate(${-e}px, ${-r}px)`}function _t(n,e,r=!0){let o=[["online","Online now"],["24h","24h"],["7d","7 days"],["30d","30 days"]],a=t("div",{class:"dl-seg",role:"tablist"});for(let[i,s]of o)i==="online"&&!r||a.appendChild(t("button",{type:"button",role:"tab",class:i===n?"on":"","data-v":i,click:()=>{a.querySelectorAll("button").forEach(l=>l.classList.toggle("on",l.dataset.v===i)),e(i)}},s));return a}var jr={"24h":86400,"7d":7*86400,"30d":30*86400},uo=(n,e)=>`${(n/e*100).toFixed(3)}%`,yn=class{constructor(e,r,o){this.map=e;this.range=r;this.el=t("div",{class:"dl-dplaces"});this.controls=t("div",{class:"dl-map-replay"});this.pending=null;this.rows=new Map;this.st=[];this.steps=[];this.total=0;this.ms=0;this.stepI=-1;this.on=!1;this.playing=!1;this.raf=0;this.last=0;this.endTimer=0;this.play=t("button",{type:"button",class:"dl-map-btn"});this.chip=t("span",{class:"dl-map-chip"});this.stop=t("button",{type:"button",class:"dl-map-btn",title:"Back to now","aria-label":"Back to now"},b("x"));this.reduced=window.matchMedia?.("(prefers-reduced-motion: reduce)").matches??!1;this.data=o,this.play.addEventListener("click",()=>this.toggle()),this.stop.addEventListener("click",()=>this.end()),this.paint()}mapData(){let e=this.data;return{geo:e.geo,people:[e.person],now:e.now,person:e.person.id,device:e.device.id}}update(e){let r={...this.pending??this.data,...e};if(this.on){this.pending=r;return}this.data=r,this.map.update(this.mapData()),this.paint()}setRange(e){this.end(),this.range=e,this.map.setRange(e),this.paint()}destroy(){cancelAnimationFrame(this.raf),clearTimeout(this.endTimer)}paint(){let e=this.data,r=jr[this.range],o=e.now-r,a=yr(wr(e.events??[],e.device.id,e.now,e.device.online,e.device.handshake),e.geo.points,e.device.id,o),i=kr(a);this.st=$r(a);let s=po(this.mapData(),this.range),l=a.length>0;this.el.classList.toggle("strips",l),this.el.classList.toggle("can-replay",this.st.length>1),this.rows.clear(),dom.content(this.el,s.length?[...s.map(d=>{let c=Ke(d),p=i.get(c),u=l?t("div",{class:`dl-dplace-strip${d.online?" live":""}`},a.filter($=>$.key===c).map($=>t("i",{style:`left:${uo($.from-o,r)};width:${uo($.to-$.from,r)}`}))):"",x=t("div",{class:"dl-dplace-row"},[t("span",{class:`dl-dplace-n${d.online?" live":""}`},d.online?b(e.device.kind):String(d.n)),t("span",{class:"dl-row-main dl-stack"},[t("span",{},[d.city||d.cc||"Unknown city",d.org?t("span",{class:"dl-muted"},` · ${d.org}`):""]),t("span",{class:"dl-faint"},[t("span",{class:"dl-mono"},d.ip),p!=null?` · ${p>0&&p<.005?"<1":Math.round(p*100)}% of the time`:""])]),t("span",{class:d.online?"dl-dplace-now":"dl-faint dl-nowrap"},d.online?"now":re(d.ts,e.now)),u]);if(x.addEventListener("mouseenter",()=>this.map.hoverPlace(c)),x.addEventListener("mouseleave",()=>this.map.hoverPlace(null)),u){let $=h=>{let m=u.getBoundingClientRect();this.seek(o+r*Math.min(1,Math.max(0,(h.clientX-m.left)/m.width)))};u.addEventListener("pointerdown",h=>{u.setPointerCapture(h.pointerId),$(h)}),u.addEventListener("pointermove",h=>h.buttons&&$(h))}return this.rows.set(c,x),x}),l?t("div",{class:"dl-dplace-axis"},Pr(this.range,e.now).map(([d,c])=>t("span",{style:`left:${(d*100).toFixed(2)}%`},c))):""]:t("div",{class:"dl-sub"},"No locations in this period.")),this.paintControls()}paintControls(){dom.content(this.play,b(this.playing?"pause":"play")),this.play.title=this.playing?"Pause":"Replay this period",this.play.setAttribute("aria-label",this.play.title),dom.content(this.controls,this.on?[this.play,this.chip,this.stop]:this.st.length>1?[this.play]:[])}begin(){this.on=!0,{steps:this.steps,total:this.total}=Er(this.st,this.reduced?400:io),this.ms=0,this.stepI=-1,this.map.replay({active:null,when:""},!0)}toggle(){if(this.playing){this.playing=!1,cancelAnimationFrame(this.raf),this.paintControls();return}clearTimeout(this.endTimer),(!this.on||this.ms>=this.total)&&this.begin(),this.playing=!0,this.last=performance.now(),this.paintControls(),this.raf=requestAnimationFrame(e=>this.frame(e))}frame(e){if(this.playing){if(this.ms=Math.min(this.total,this.ms+(e-this.last)),this.last=e,this.show(!0),this.msthis.frame(r));return}this.playing=!1,this.paintControls(),this.endTimer=window.setTimeout(()=>this.end(),1500)}}seek(e){this.st.length<2||(clearTimeout(this.endTimer),this.on||this.begin(),this.ms=Mr(this.st,this.steps,e),this.stepI=-1,this.show(!1),this.paintControls())}show(e){let r=Lr(this.st,this.steps,this.ms),o=this.st[r.step.k];if(r.step.kind==="move"){let s=this.st[r.step.k-1];r.i!==this.stepI&&(this.map.replay({active:null,when:""},e),this.map.band([s.point.lon,s.point.lat],[o.point.lon,o.point.lat]));let l=Sr(r.q);this.reduced||this.map.bandAt(l),(this.reduced?r.q>=.5:Tr(l))&&this.map.replay({active:o.key,when:vn(r.t)},e)}else r.i!==this.stepI&&this.map.band(),this.map.replay({active:o.key,when:vn(r.t)},e);this.stepI=r.i;let a=this.data,i=a.now-jr[this.range];this.el.classList.add("replay"),this.el.style.setProperty("--at",uo(r.t-i,a.now-i));for(let[s,l]of this.rows)l.classList.toggle("cur",s===o.key);this.chip.textContent=`${Dr(r.t,a.now)}, ${vn(r.t)} · ${o.point.city||o.point.cc||"?"}`}end(){if(cancelAnimationFrame(this.raf),clearTimeout(this.endTimer),!!this.on){this.on=!1,this.playing=!1,this.ms=0,this.stepI=-1,this.map.band(),this.map.replay(null,!1),this.el.classList.remove("replay");for(let e of this.rows.values())e.classList.remove("cur");this.pending?(this.data=this.pending,this.pending=null,this.map.update(this.mapData()),this.paint()):this.paintControls()}}};function Pt(n){return`${L.url("admin/network/dawnline/server")}?${n?`server=${encodeURIComponent(n)}&`:""}section=people`}function ke(n,e){return`${L.url("admin/network/dawnline/person")}?id=${encodeURIComponent(n)}${e?`&device=${encodeURIComponent(e)}`:""}`}function ws(n){return n?new Date(n*1e3).toLocaleString("en-GB",{day:"numeric",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit"}):"—"}function mo(n,e,r=!1){return t("div",{class:"dl-kvrow"},[t("span",{class:"dl-kvrow-k"},n),t("button",{type:"button",class:`dl-kvrow-v copy${r?" dl-mono":""}`,title:"Copy",click:()=>ue(e,`${n} copied`)},[t("span",{},e),b("copy")])])}function kn(n,e){return t("div",{class:"dl-kvrow"},[t("span",{class:"dl-kvrow-k"},n),t("span",{class:"dl-kvrow-v"},e)])}var Ur={connect:["ok","Connected","plug"],disconnect:["","Went offline","plug"],roam:["","Changed network","network"],device_added:["ok","Added","plus"],device_removed:["","Removed","trash"],device_keys:["","New keys","reset"]};function ys(n,e,r){let o=n.filter(a=>a.device===e&&Ur[a.type]).reverse().slice(0,12);return o.length?t("div",{class:"dl-dev-log"},o.map(a=>{let[i,s,l]=Ur[a.type],d=a.type==="connect"?[a.detail?t("span",{class:"dl-muted"},` from ${a.detail}`):"",a.where?t("span",{class:"dl-muted"},` · ${a.where}`):""]:a.type==="roam"?[t("span",{class:"dl-muted"},` · ${a.detail??""}`)]:a.type==="device_added"||a.type==="device_removed"||a.type==="device_keys"?[t("span",{class:"dl-muted"},Ne(a)==="portal"?" on the portal":Ne(a)==="admin"?" by you":"")]:[],c=new Date(a.ts*1e3);return t("div",{class:`dl-dev-log-row${Ne(a)==="admin"?" dl-ev-by-admin":""}`},[Ne(a)==="admin"?t("span",{class:"dl-ev-tile",title:"Done by you in LuCI"},b("admin")):t("span",{class:`dl-ev-tile ev ${i}`},b(l)),t("span",{class:"dl-row-main"},[t("span",{},s),...d]),t("span",{class:"dl-faint dl-nowrap",title:c.toLocaleString()},re(a.ts,r))])})):t("div",{class:"dl-sub"},"No activity yet.")}async function Gr(n,e,r){let o=await A.status(1).catch(()=>null),a=o?.people.find(s=>s.id===n),i=a?.devices.find(s=>s.id===e);o&&a&&i&&Ge(a,i,{...r,geo:o.geo,now:o.now,today:Ie(o.series),core:Tt(o.servers,a.server)})}async function Ge(n,e,r){let o=await G(()=>A.deviceConfig(e.id));if(!o)return;let a=r.core??Be(null),i=e,s=n,l=r.geo,d=r.now,c=r.today??je(new Date),p=await a.connectBlock(o,e.kind==="phone"||e.kind==="tablet"?"qr":"file"),u=t("div",{class:"dl-drawer-title"}),x=t("div",{}),$=t("div",{}),h=t("div",{},t("div",{class:"dl-sub"},"Loading…")),m=[],C=Q=>{m=Q.filter(te=>te.device===i.id),dom.content(h,ys(Q,i.id,d)),y?.update({events:Q})},B=async(Q=!1)=>{let te=r.events?.();if(te&&!Q)return C(te);let ge=await A.events(2e3,n.id).catch(()=>null);ge&&C(ge.events)},w="30d",v=null,y=null,E=()=>{dom.content(u,[t("span",{class:`dl-dcard-ic${i.online?" on":""}`},b(i.kind)),t("div",{class:"dl-stack"},[t("div",{class:"dl-title-row"},[t("h3",{},i.name),H([b("edit")],()=>f(),"neutral",{title:"Rename",class:"cbi-button cbi-button-neutral dl-icon-only sm"})]),t("span",{class:"dl-sub"},`${s.name} · ${Qe[i.kind]}`)])]);let Q=i.spark.reduce((te,ge)=>te+ge,0);dom.content(x,t("div",{class:"dl-dstats"},[t("div",{class:"dl-dstats-cell wide"},[t("span",{class:"dl-metric-label"},"Status"),on(i,d,"Waiting for the first connection",s)]),t("div",{class:"dl-dstats-cell"},[t("span",{class:"dl-metric-label"},"This month"),t("b",{},ee(i.month[0]+i.month[1])),t("span",{class:"dl-sub dl-mono"},`↓ ${ee(i.month[1])} ↑ ${ee(i.month[0])}`)]),t("div",{class:"dl-dstats-cell"},[t("span",{class:"dl-metric-label"},"Last 7 days"),t("b",{},ee(Q)),dr(i.spark,120,22,c)])])),dom.content($,t("div",{class:"dl-kv2"},[mo("Tunnel address",i.address),i.hostname&&s.access!=="internet"?mo("Local address",i.hostname):"",i.endpoint&&!l?.points.some(te=>te.device===i.id&&te.ip===i.endpoint)?kn("Client IP",i.endpoint):"",kn("Total",t("span",{class:"dl-kv-act"},[`↓ ${ee(i.total[1])} · ↑ ${ee(i.total[0])}`,t("button",{type:"button",class:"dl-linkbtn danger",click:()=>St("device",i.id,i.name,()=>setTimeout(z,300))},"Reset")])),kn("Added",`${ws(i.created)} · ${i.created_by==="portal"?"from the portal":"by you"}`),o.amnezia.client_pub_key?mo("Public key",o.amnezia.client_pub_key):kn("Public key","—")])),dom.content(g,[H([b(i.disabled?"play":"pause"),i.disabled?" Enable":" Disable"],async()=>{await G(()=>A.deviceUpdate(i.id,void 0,!i.disabled),i.disabled?"Device enabled":"Device disabled")&&await z()},"neutral",i.disabled?{}:{class:"cbi-button cbi-button-neutral dl-btn-warn"}),H([b("key")," New keys"],async()=>{if(!await le("Generate new keys?","The current configuration on this device stops working until it is imported again.","Generate",!0))return;await G(()=>A.deviceRotate(i.id),"New keys generated")&&(r.refresh(),de.close(),await Gr(s.id,i.id,r))}),t("span",{class:"dl-spacer"}),H([b("trash")," Remove"],async()=>{await le(`Remove ${i.name}?`,"The device is disconnected immediately and its configuration stops working.","Remove",!0)&&await G(()=>A.deviceDelete(i.id),"Device removed")&&(de.close(),r.refresh())},"negative")])},k=async()=>{let Q=await A.status(1).catch(()=>null),te=Q?.people.find(O=>O.id===s.id),ge=te?.devices.find(O=>O.id===i.id);!Q||!te||!ge||(s=te,i=ge,l=Q.geo,d=Q.now,c=Ie(Q.series),E(),y?.update({geo:Q.geo,now:Q.now,person:s,device:i}))},z=async()=>{await k(),r.refresh()},f=()=>{let Q=t("input",{type:"text",class:"cbi-input-text",value:i.name,maxlength:48}),te=s.devices.filter(O=>O.id!==i.id).map(O=>O.name),ge=ye("Name",Q,()=>_e(Q.value,te,"Shown in the portal and in the app."));oe(`Rename ${i.name}`,[ge],[ie()," ",H("Save",async()=>{let O=ge.help();if(O.bad){U(O.text,"warning");return}await G(()=>A.deviceUpdate(i.id,Q.value,void 0),"Renamed")&&(ae(),await z())},"positive")]),setTimeout(()=>Q.select(),50)},g=t("div",{class:"dl-drawer-actions"}),S=t("section",{class:"dl-dsec"},[t("div",{class:"dl-dsec-head"},[t("h4",{},"Connect")]),i.config_stale?t("div",{class:"dl-note warn"},[b("alert"),t("span",{},"This device has an older configuration: networks or DNS changed since it was set up. Import it again with the QR code, key or file below.")]):"",p]),T=t("section",{class:"dl-dsec"},[t("div",{class:"dl-dsec-head"},[t("h4",{},"Activity"),t("div",{class:"dl-dsec-actions"},[t("button",{type:"button",class:"dl-linkbtn",click:()=>Fe({people:[s]},m,"csv",i.id)},"Export"),t("button",{type:"button",class:"dl-linkbtn danger",click:()=>tt(`Clear ${i.name}'s activity`,`Removes events about ${i.name}.`,{device:i.id},()=>{B(!0),r.refresh()})},"Clear"),t("a",{href:`${L.url("admin/network/dawnline/diagnostics")}?tab=log`},"All activity")])]),h]),N=t("section",{class:"dl-dsec"},[t("div",{class:"dl-dsec-head"},t("h4",{},"Details")),$]),W="";if(l?.enabled){v=new nt({openPerson:te=>location.href=ke(te),openDevice:(te,ge)=>location.href=ke(te,ge)},w,220);let Q=y=new yn(v,w,{geo:l,now:d??Date.now()/1e3,person:s,device:i,events:r.events?.()??null});W=t("section",{class:"dl-dsec"},[t("div",{class:"dl-dsec-head"},[t("h4",{},"Locations"),_t(w,te=>{w=te,Q.setRange(te)},!1)]),t("div",{class:"dl-dmap"},[v.el,Q.controls]),Q.el])}let q=!i.handshake||i.config_stale,Y=t("div",{class:"dl-stack gap16"},q?[x,S,N,W,T]:[x,N,W,T,S]);B();let R=()=>{k(),B()},K=gn(R),Z=window.setInterval(R,3e4),de=Oo(u,Y,g,()=>{clearInterval(Z),K(),y?.destroy(),v?.destroy()});E(),v&&y&&requestAnimationFrame(()=>y&&v?.mount(y.mapData()))}function Wr(n,e,r,o){let a=o.core??Be(null),i=()=>G(()=>A.deviceConfig(r.id)),s=[{label:"Show QR code",icon:b("qr"),run:async()=>{let l=await i();l&&oe(`${r.name} · QR code`,t("div",{class:"dl-qr-pane"},[et(Lt(a.qrText(l)),"dl-qr"),t("span",{class:"dl-sub"},no(l)?"Scan with AmneziaVPN or any WireGuard app on the device.":"Scan with AmneziaVPN or AmneziaWG on the device.")]),ie("Close"))}},{label:a.file.label,icon:b("download"),run:async()=>{let l=await i();if(!l)return;let d=a.file.make(l);Te(d.name,d.text,"application/octet-stream")}},a.appKey?{label:a.appKey.label,icon:b("copy"),run:async()=>{let l=await i();l&&ue(await a.appKey.make(l),"Key copied")}}:null,null,{label:"Rename",icon:b("edit"),run:()=>Ge(e,r,o)},{label:"New keys",icon:b("key"),run:async()=>{await le("Generate new keys?","The current configuration on this device stops working until it is imported again.","Generate",!0)&&await G(()=>A.deviceRotate(r.id),"New keys generated")&&o.refresh()}},{label:r.disabled?"Enable":"Disable",icon:b(r.disabled?"play":"pause"),warn:!r.disabled,run:async()=>{await G(()=>A.deviceUpdate(r.id,void 0,!r.disabled),r.disabled?"Device enabled":"Device disabled")&&o.refresh()}},{label:"Delete",icon:b("trash"),danger:!0,run:async()=>{await le(`Remove ${r.name}?`,"The device is disconnected immediately and its configuration stops working.","Remove",!0)&&await G(()=>A.deviceDelete(r.id),"Device removed")&&o.refresh()}}];Ce(n,s)}function ot(n,e){let r=n.devices.map(c=>c.name),o=c=>{let p=Qe[c],u=1,x=p;for(;r.some($=>$.toLowerCase()===x.toLowerCase());)x=`${p} ${++u}`;return x},a="phone",i=t("input",{type:"text",class:"cbi-input-text",placeholder:o(a),maxlength:48}),s=ye("Name",i,()=>i.value.trim()?_e(i.value,r,"Shown in the portal and in the app."):{text:`Named after its type: ${o(a)}.`,bad:!1}),l=t("div",{class:"dl-kinds",role:"radiogroup","aria-label":"Type"},No.map(c=>t("button",{type:"button",role:"radio",class:c===a?"on":"","aria-checked":c===a?"true":"false","data-kind":c,click:()=>{a=c,l.querySelectorAll("button").forEach(p=>{let u=p.dataset.kind===c;p.classList.toggle("on",u),p.setAttribute("aria-checked",u?"true":"false")}),i.placeholder=o(c),s.refresh()}},[b(c),t("span",{},Qe[c])]))),d=n.devices.length>=n.device_limit;oe(`Add a device for ${n.name}`,[d?t("p",{class:"dl-hint"},`${n.name} already has ${n.devices.length} of ${n.device_limit} devices. As admin you can still add one.`):"",t("div",{class:"dl-fld"},[t("span",{class:"dl-fld-label"},"Type"),l]),s],[ie()," ",H("Add device",async()=>{let c=s.help();if(c.bad){U(c.text,"warning");return}let p=i.value.trim()||o(a),u=await G(()=>A.deviceCreate(n.id,p,a));u&&(ae(),U(`${p} added`,"success",3e3),e.refresh(),await Gr(n.id,u.id,e))},"positive")]),setTimeout(()=>i.focus(),50)}var Ve=1080,qt=1512,We=96,ks="-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif",$s="ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",Ft=n=>n.replace(/[&<>"']/g,e=>({"&":"&","<":"<",">":">",'"':""","'":"'"})[e]);function Cs(n,e,r){let o=new URL(r),a=o.pathname.slice(1),i=Math.min(92,Math.floor((Ve-2*We)/(.58*(4+n.name.length)))),s=Ve-2*We,l=392,d=40,c=Lt(r,2).replace("`${m}`;return``+p(We+82,We+42,36,"#a3a3a3",Ft(e))+p(We,276,i,"#ffffff",`Hi, ${Ft(n.name)}`,'font-weight="600"')+p(We,340,40,"#8a8a8a",`Scan to connect to ${Ft(e)}`)+``+c+`${Ft(a)}`+p(Ve/2,l+s+156,34,"#737373",Ft(o.host),'text-anchor="middle"')+""}async function Es(n){let e=new Image;e.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(n)}`,await e.decode();let r=document.createElement("canvas");return r.width=Ve,r.height=qt,r.getContext("2d").drawImage(e,0,0,Ve,qt),new Promise((o,a)=>r.toBlob(i=>i?o(i):a(new Error("Could not draw the card")),"image/png"))}async function Fr(n){let e=await G(()=>A.personLinks(n));return e?e.link?{link:e.link,links:e.links??[]}:(U("The personal portal is off. Turn it on in Settings.","warning"),null):null}async function $n(n){let e=await Fr(n);e&&await ue(e.link,"Personal link copied")}async function Kt(n,e,r={}){let o=n.link,a=n.links;if(o===void 0){let m=await Fr(n.id);if(!m)return;o=m.link,a=m.links}if(!o){U("The personal portal is off. Turn it on in Settings.","warning");return}let i=o,s=await G(()=>Es(Cs(n,e,i)));if(!s)return;let l=new File([s],`${n.id}-invite.png`,{type:"image/png"}),d=URL.createObjectURL(s),c=navigator,p=!!c.canShare?.({files:[l]}),u=!p&&typeof c.share=="function"&&(c.canShare?.({url:i})??!0),x=()=>{URL.revokeObjectURL(d),ae()},$=async m=>{try{await c.share(m)}catch{}},h=p?H([b("link")," Share card"],()=>$({files:[l],title:`Invite ${n.name}`}),"positive"):u?H([b("link")," Share link"],()=>$({url:i,title:`Invite ${n.name}`,text:"Your personal VPN link"}),"positive"):H([b("download")," Download card"],()=>Te(l.name,s),"positive");oe(r.title??`Invite ${n.name}`,t("div",{class:"dl-invite"},[t("img",{src:d,alt:`Invite card for ${n.name}`}),t("div",{class:"dl-invite-side"},[t("p",{class:"dl-muted"},r.lead??`Send ${n.name} the card or the link. They open it, add their devices and connect — no account needed.`),t("button",{type:"button",class:"dl-invite-link",title:"Copy link",click:()=>ue(i,"Personal link copied")},[t("span",{},i.replace(/^https:\/\//,"")),b("copy")]),...(a??[]).filter(m=>m!==i).map(m=>t("button",{type:"button",class:"dl-invite-link alt",title:"Copy this link",click:()=>ue(m,"Link copied")},[t("span",{},m.replace(/^https?:\/\//,"")),t("span",{class:`dl-pill ${m.startsWith("http:")?"warn":""}`},m.startsWith("http:")?"HTTP":"Also"),b("copy")])),t("ol",{class:"dl-invite-steps"},[t("li",{},["Install ",t("b",{},"AmneziaVPN")," on the device"]),t("li",{},"Open the link or scan the code"),t("li",{},"Add the device and connect")]),t("div",{class:"dl-invite-actions"},[h,H([b("copy")," Copy link"],()=>ue(i,"Personal link copied"))])])]),[t("button",{class:"cbi-button cbi-button-neutral",click:x},"Done")],"wide")}function Vt(n,e){let r=n.servers.find(d=>d.id===e)??n.servers[0],o=n.people.filter(d=>d.server===r.id),a=new Set(o.map(d=>d.id)),i=o.flatMap(d=>d.devices),s=d=>o.reduce((c,p)=>{let u=d(p);return[c[0]+u[0],c[1]+u[1]]},[0,0]),l=r.series?.[r.series.length-1];return{...n,servers:[r],people:o,series:r.series??n.series,events:n.events.filter(d=>d.person?a.has(d.person):!0),geo:{...n.geo,points:n.geo.points.filter(d=>a.has(d.person))},totals:{people:o.length,devices:i.length,online:i.filter(d=>d.online).length,active:o.filter(d=>d.state==="active").length,today:l?[l.rx,l.tx]:[0,0],month:s(d=>d.month)}}}var qr=3,ho=class{constructor(){this.n=0;this.shown=0}next(){return++this.n}take(e){return e{let x=e.next(),$=null;try{$=await n.fetch(u),r>=qr&&U("The router answers again.","success",3e3),r=0}catch{return++r===qr&&U("The router is not answering: what you see may be out of date.","warning",8e3),null}return $==null||!e.take(x)?null:(n.apply($,p),$)},a=(p=!1)=>o(p,!1),i=()=>document.visibilityState==="visible",s=()=>i()&&(n.active?.()??!0)?o(!0,!1):Promise.resolve(null);poll.add(s,n.every);let l=n.live?gn(()=>void(i()&&(n.active?.()??!0)&&o(!0,!0))):null,d=()=>{poll.remove(s),l?.(),c()},c=$e(d);return{refresh:a,claim:()=>e.claim(),stop:d}}function Dt(n){let e=document.activeElement;return!!n&&!!e&&e!==document.body&&n.contains(e)}function Se(n,e,r=!1){return r&&Dt(n)?!1:(dom.content(n,e),!0)}function Kr(n,e){let r=n,a=t("div",{class:"dl-choices"},[{v:"internet",ic:"globe",text:"Browse the internet through your router. No access to devices at home."},{v:"lan",ic:"home",text:"Reach devices at home (NAS, printer, cameras). Internet stays on their own connection."},{v:"both",ic:"shield",text:"Home devices and the internet, all through your router."}].map(i=>t("button",{type:"button",class:`dl-choice${i.v===r?" selected":""}`,"data-v":i.v,click:()=>{r=i.v,a.querySelectorAll(".dl-choice").forEach(s=>s.classList.toggle("selected",s.dataset.v===i.v)),e?.(i.v)}},[t("span",{class:"dl-choice-title"},[b(i.ic),ct[i.v]]),t("span",{class:"dl-choice-text"},i.text)])));return{el:a,get:()=>r}}function fo(n){try{return localStorage.getItem(n)}catch{return null}}function go(n,e){try{localStorage.setItem(n,e)}catch{}}function Ls(n){let e=n.devices.length,r=Math.max(1,n.device_limit,e),o=Math.min(160,r*22+(r-1)*3);return t("div",{class:"dl-slotbar",title:`${e} of ${n.device_limit} devices`},[t("span",{class:"dl-slotbar-segs",style:`width: ${o}px`},Array.from({length:r},(a,i)=>t("i",{class:i>=n.device_limit?"over":in.state==="server_off"?n.paused:!["active","quota","expired"].includes(n.state),vo=n=>n.state==="server_off"?n.paused:n.state!=="active",Jr=n=>vo(n)?n.state==="server_off"?"paused":n.state:null;function Ms(n,e){let r=Ye(n.expires,e);return n.state==="quota"||n.state==="expired"||Ze(n,r)||!!n.quota_limit&&n.quota_used>=n.quota_limit*.9}function Yr(n,e){return bt(n&&Kn(n,e)>=0?n:e,1)}var Zr=n=>n.people.map(e=>e.id).sort().join(" "),Qr=!1,mt=class{constructor(){this.list=t("div",{class:"dl-plist",role:"list"});this.filter=["all","online","attention","paused"].find(e=>e===(new URLSearchParams(location.search).get("filter")??fo("dl.people.filter")))??"all";this.sort=["seen","name","usage"].find(e=>e===fo("dl.people.sort"))??"seen";this.query="";this.noFooter=!0;this.serverId=null;this.el=null}async load(){return A.status(30)}scope(e){return this.serverId?Vt(e,this.serverId):e}embed(e,r){return this.serverId=r,this.render(e)}person(e){return this.st.people.find(r=>r.id===e)}get today(){return Ie(this.st.series)}deviceOpts(e){return{refresh:()=>this.refresh(),geo:this.st.geo,now:this.st.now,today:this.today,core:Tt(this.st.servers,e.server)}}take(e,r){let o=this.scope(e),a=Zr(o)!==Zr(this.st);this.st=o,a?this.rebuild():(this.paintCards(r),this.decorate(r))}async update(){await this.poller?.refresh()}async refresh(){this.poller?.claim();let e=await A.status(30).catch(()=>null);e&&(this.st=this.scope(e),this.rebuild())}rebuild(){let e=new Map;for(let o of Array.from(this.list.children))o.dataset.sid&&e.set(o.dataset.sid,o);let r=this.st.people.map(o=>{let a=e.get(o.id)??t("div",{class:"dl-card",role:"listitem","data-sid":o.id});return this.renderCard(a,o.id)});dom.content(this.list,r.length?r:t("div",{class:"dl-plist-none"},this.st.servers.length?"No people yet. Add someone and send them their personal link.":"Set up the server first, then add people.")),this.decorate()}paintCards(e=!1){for(let r of this.st.people){let o=this.card(r.id);o&&!(e&&Dt(o))&&this.renderCard(o,r.id)}}card(e){return this.list.querySelector(`[data-sid="${CSS.escape(e)}"]`)}render(e){let r=this.scope(e);this.st=r;let o=this,a=t("select",{class:"dl-select","aria-label":"Sort",change:d=>{o.sort=d.target.value,go("dl.people.sort",o.sort),o.decorate()}},[t("option",{value:"seen",selected:o.sort==="seen"?"selected":null},"Last seen"),t("option",{value:"name",selected:o.sort==="name"?"selected":null},"Name"),t("option",{value:"usage",selected:o.sort==="usage"?"selected":null},"Usage")]),i=t("input",{type:"search",class:"cbi-input-text dl-people-find",placeholder:"Find…","aria-label":"Find a person or device",hidden:r.people.length>8?null:"hidden",input:d=>{o.query=d.target.value.trim().toLowerCase(),o.decorate()}}),s=d=>{let c=d.target;d.key==="/"&&!i.hidden&&!["INPUT","TEXTAREA","SELECT"].includes(c?.tagName)&&!c?.isContentEditable&&(d.preventDefault(),i.focus())};document.addEventListener("keydown",s),$e(()=>document.removeEventListener("keydown",s));let l=t("div",{class:"dl-root"},[o.serverId?"":t("div",{class:"dl-pagehead"},[t("div",{class:"dl-stack"},[t("h2",{class:"dl-h1"},"People"),t("span",{class:"dl-muted dl-people-count"},this.countText())]),r.servers.length?H([b("plus")," Add person"],()=>o.openCreate(),"add"):""]),r.servers.length?"":t("div",{class:"alert-message warning"},["No server yet. ",t("a",{href:L.url("admin/network/dawnline/server")},"Run the setup wizard")," before adding people."]),t("div",{class:"dl-toolbar"},[t("div",{class:"dl-seg dl-people-tabs",role:"tablist"}),t("div",{class:"dl-toolbar-end"},[i,a,o.serverId?H([b("plus")," Add person"],()=>o.openCreate(),"add"):""])]),this.list]);return this.el=l,this.rebuild(),this.poller??(this.poller=rt({fetch:()=>A.status(30),every:30,live:!0,active:()=>!!o.el?.isConnected,apply:(d,c)=>o.take(d,c)})),!Qr&&new URLSearchParams(location.search).get("add")&&(Qr=!0,setTimeout(()=>o.openCreate(),100)),Promise.resolve(l)}countText(){let e=this.st.totals;return`${e.people} ${e.people===1?"person":"people"} · ${e.devices} device${e.devices===1?"":"s"} · ${e.online} online`}decorate(e=!1){let r=this.el?.querySelector(".dl-people-count");r&&(r.textContent=this.countText());let o=this.st.people,a=this.today,i=m=>Ms(m,a),s={all:o.length,online:o.filter(m=>m.online>0).length,attention:o.filter(i).length,paused:o.filter(m=>Vr(m)).length},l=this.el?.querySelector(".dl-people-tabs");if(l&&!(e&&Dt(l))){let m={all:"All",online:"Online",attention:"Needs attention",paused:"Paused"};dom.content(l,Object.keys(m).map(C=>t("button",{type:"button",role:"tab",class:C===this.filter?"on":"",click:()=>{this.filter=C,go("dl.people.filter",C),this.decorate()}},[m[C],t("b",{class:C==="attention"&&s[C]?"warn":""},String(s[C]))])))}let d=this.query,c=m=>[m.name,m.note??"",...m.devices.flatMap(C=>[C.name,C.address,C.hostname,C.endpoint])].join(" ").toLowerCase(),p=m=>!(this.filter==="online"&&!m.online||this.filter==="attention"&&!i(m)||this.filter==="paused"&&!Vr(m)||d&&!c(m).includes(d)),u=m=>Jr(m)==="paused"?2:vo(m)?1:0,x=[...o].sort((m,C)=>u(m)-u(C)||(this.sort==="name"?m.name.localeCompare(C.name):this.sort==="usage"?C.month[0]+C.month[1]-(m.month[0]+m.month[1]):C.online-m.online||C.last_seen-m.last_seen)),$=0;for(let m of x){let C=this.card(m.id);if(!C)continue;this.list.appendChild(C),C.classList.toggle("dl-off",vo(m));let B=p(m);C.classList.toggle("dl-filtered",!B),B&&$++}let h=this.el?.querySelector(".dl-people-none")??null;o.length&&!$?(h??(h=t("div",{class:"dl-empty dl-people-none"},t("p",{},"No one here right now."))),h.previousElementSibling!==this.list&&this.list.after(h)):h?.remove()}async quick(e,r,o){await G(()=>A.personUpdate(e.id,r),o)&&await this.update()}renderCard(e,r){let o=this.person(r);if(!o)return dom.content(e,t("em",{},"This person was just removed.")),e;let a=this.today,i=Ye(o.expires,a),s=Math.max(0,o.device_limit-o.devices.length),l=o.has_link??this.st.settings.portal_enabled,d=[],c=Jr(o);if(o.expires&&c!=="expired"){let h=Ze(o,i),m=i!=null&&i<0;d.push(t("span",{class:`dl-pill-ic${m?" bad":h?" warn":""}`,title:`Access ends ${Me(o.expires)}`},[b("calendar"),m?`ended ${Me(o.expires)}`:h?en(i):`until ${Me(o.expires)}`]))}o.hours&&c!=="hours"&&d.push(t("span",{class:"dl-pill-ic",title:"Allowed hours"},[b("clock"),o.hours.replace("-","–")]));let p=nn(o.devices).map(h=>t("button",{type:"button",class:`dl-chip${h.disabled?" disabled":""}${h.online?" live":""}`,title:`${Qe[h.kind]} · ${h.address}${h.online?` · online from ${h.endpoint}`:h.handshake?` · seen ${re(h.handshake,this.st.now)}`:""}`,click:m=>{m.preventDefault(),Ge(o,h,this.deviceOpts(o))}},[b(h.kind),t("span",{class:"dl-chip-name"},h.name),!h.handshake&&!h.disabled?t("span",{class:"dl-chip-tag"},"not set up"):""]));p.push(t("button",{type:"button",class:"dl-chip add",title:s>0?"Add device":"Over the limit: admins can still add",click:h=>{h.preventDefault(),ot(o,this.deviceOpts(o))}},[b("plus"),"Add device"]));let u=[];o.expires&&Ze(o,i)&&c!=="expired"&&u.push(t("button",{type:"button",class:"dl-fix",click:()=>this.quick(o,{expires:Yr(o.expires,a)},"Extended by 1 month")},"Extend 1 month"));let x=Le("more","More",h=>Ce(h.currentTarget,[{label:"Open",icon:b("open"),run:()=>{location.href=ke(o.id)}},l?{label:"Invite card",icon:b("qr"),run:()=>Kt(o,this.st.servers.find(m=>m.id===o.server)?.name??"Home")}:null,s>0?{label:"Add device",icon:b("plus"),run:()=>ot(o,this.deviceOpts(o))}:null,null,{label:o.paused?"Resume":"Pause",icon:b(o.paused?"play":"pause"),warn:!o.paused,run:()=>this.togglePause(o)},{label:"Delete",icon:b("trash"),danger:!0,run:()=>this.remove(o.id)}].filter((m,C,B)=>m||C>0&&B[C-1])),"neutral","dl-icon-only"),$=t("div",{class:"dl-pcard-actions"},[l?Le("link","Copy link",()=>$n(o.id),"neutral","dl-icon-only"):"",x]);return dom.content(e,t("div",{class:"dl-pcard"},[t("div",{class:"dl-pcard-main"},[t("div",{class:"dl-pcard-top"},[t("span",{class:`dl-avatar${o.online?" online":""}`},He(o.name)),t("div",{class:"dl-pcard-who"},[t("div",{class:"dl-card-head"},[t("a",{class:"dl-card-name",href:ke(o.id)},o.name),Bo(o),...d]),Ls(o)])]),t("div",{class:"dl-chips"},p),u.length?t("div",{class:"dl-fixes"},u):""]),this.usageSide(o,$),c?this.stopStrip(o,c):""])),e}stopStrip(e,r){let o=this.today,a=bt(`${o.slice(0,8)}01`,1),i=()=>this.quick(e,{bonus_gb:String((e.bonus_gb||0)+10)},"+10 GB this month"),s={paused:["pause","warn","Paused","Devices can’t connect until you resume",["play","Resume",()=>this.togglePause(e)]],quota:e.quota_period==="month"?["chart","bad","Data limit reached",`Paused until it resets on ${Me(a)}`,["plus","+10 GB this month",i]]:["chart","bad","Data limit reached","Paused until the limit is raised",["edit","Change limit",()=>location.href=ke(e.id)]],expired:["calendar","bad",`Access ended ${Me(e.expires)}`,"Devices can’t connect",["calendar","Extend 1 month",()=>this.quick(e,{expires:Yr(e.expires,o)},"Extended by 1 month")]],hours:["clock","warn","Outside allowed hours",`Access ${e.hours.replace("-","–")} (router time)`,null],no_server:["alert","warn","No server","Choose a server on their page",null]},[l,d,c,p,u]=s[r];return t("div",{class:`dl-pstrip ${d}`},[t("span",{class:`dl-need-ic ${d}`},b(l)),t("span",{class:"dl-pstrip-text"},[t("b",{},c),t("span",{class:"dl-faint"},p)]),u?H([b(u[0]),` ${u[1]}`],u[2]):""])}usageSide(e,r){let o=e.quota_used||e.month[0]+e.month[1],a=e.quota_limit?Math.min(100,e.quota_used/e.quota_limit*100):0,i=e.devices.reduce((p,u)=>p+(u.spark[u.spark.length-1]??0),0),s=e.rate?.[e.rate.length-1],l=e.online&&s&&this.st.now-s[0]<180,d=t("div",{class:`dl-usebar${a>=100?" bad":a>=90?" warn":""}`});if(e.quota_limit){let p=t("i",{class:"fill"});p.style.width=`${a}%`,d.appendChild(p),me(d,()=>[t("div",{class:"dl-tip-title"},`${a.toFixed(1)}% used`),t("div",{class:"dl-muted"},`${ee(e.quota_used)} of ${ee(e.quota_limit)} · ${ee(Math.max(0,e.quota_limit-e.quota_used))} left`),t("div",{class:"dl-faint"},e.quota_period==="total"?"In total":`This month${e.bonus_gb?` · includes +${e.bonus_gb} GB extra`:""}`)])}else{let p=e.devices.map(u=>({d:u,v:u.month[0]+u.month[1]})).filter(u=>u.v>0).sort((u,x)=>x.v-u.v);p.forEach((u,x)=>{let $=t("i",{class:`c${Math.min(x,4)}`});$.style.flexGrow=String(u.v),d.appendChild($)}),p.length&&me(d,()=>[t("div",{class:"dl-tip-title"},"This month by device"),...p.map((u,x)=>t("div",{class:"dl-tip-row"},[t("span",{class:`dl-swatch c${Math.min(x,4)}`}),t("span",{},u.d.name),t("b",{},ee(u.v))]))])}let c=e.quota_limit?`${ee(Math.max(0,e.quota_limit-e.quota_used))} left`:"no limit";return t("div",{class:"dl-pside"},[t("div",{class:"dl-pside-top"},[l?t("span",{class:"dl-pside-state live"},"Online"):t("span",{class:"dl-pside-state"},e.online?"Online":e.last_seen?"Offline":"Never connected"),r]),t("div",{class:"dl-use-num"},[t("b",{class:o?"":"dl-faint"},ee(o)),t("span",{class:"dl-faint"},e.quota_limit?`of ${ee(e.quota_limit)}`:e.quota_period==="total"&&e.quota_gb?"in total":"this month")]),d,l?t("div",{class:"dl-use-live",title:"Right now"},[`↓ ${Oe(s[2])}`,t("span",{class:"dl-faint"},`↑ ${Oe(s[1])}`)]):t("div",{class:"dl-faint dl-pside-foot"},i?`today ${ee(i)} · ${c}`:c)])}async togglePause(e){await G(()=>A.personPause(e.id,!e.paused),e.paused?`${e.name} resumed`:`${e.name} paused`)&&await this.refresh()}async remove(e){let r=this.person(e);await le(`Remove ${r?.name??e}?`,`All ${r?.devices.length??0} devices are disconnected immediately and the personal link stops working. Usage history is kept in backups.`,"Remove",!0)&&await G(()=>A.personDelete(e),"Person removed")&&await this.refresh()}openCreate(){let e=this.st;if(!e.servers.length){U("Set up the server first.","warning");return}let r=t("input",{type:"text",class:"cbi-input-text",placeholder:"e.g. Myata",maxlength:48}),o=(()=>{try{return JSON.parse(fo("dl.person.last")??"{}")}catch{return{}}})(),a=Kr(o.access??"internet"),i=t("input",{type:"number",class:"cbi-input-text",min:1,max:32,value:e.settings.default_device_limit}),s=t("input",{type:"date",class:"cbi-input-text"}),l=t("input",{type:"number",class:"cbi-input-text",min:0,step:"any",placeholder:"Unlimited",value:o.quota??""}),d=(w,v)=>t("button",{type:"button",class:"cbi-button cbi-button-neutral",click:()=>{s.value=v?bt(Ie(e.series),v):"",s.dispatchEvent(new Event("change"))}},w),c=e.servers[0],p=!this.serverId&&e.servers.length>1?t("select",{class:"cbi-input-select"},e.servers.map(w=>t("option",{value:w.id},w.name))):null,u=(w,v,y)=>t("div",{class:"cbi-value"},[t("label",{class:"cbi-value-title"},w),t("div",{class:"cbi-value-field"},[v,y?t("div",{class:"cbi-value-description"},y):""])]),x=Ie(e.series),$=ye("Name",r,()=>_e(r.value,[],"Shown in their portal and apps.")),h=ye("Devices",i,()=>ln(i.value)),m=ye("End date",s,()=>Ko(s.value,x,Ye,Me),t("div",{class:"dl-actions"},[s,d("1 month",1),d("3 months",3),d("1 year",12),d("None",0)])),C=ye("Monthly data (GB)",l,()=>dn(l.value));s.addEventListener("change",()=>m.refresh());let B=e.settings.portal_enabled;oe("Add person",[$,p?u("Server",p):"",t("div",{class:"cbi-value dl-block"},[t("label",{class:"cbi-value-title"},"Access"),t("div",{class:"cbi-value-field"},a.el)]),h,m,C],[ie()," ",H(B?"Create and copy link":"Create",async()=>{let w=ze([$,h,m,C]);if(w){U(w,"warning");return}let v=await G(()=>A.personCreate(r.value.trim(),"",p?.value??c.id,a.get(),i.value.trim(),s.value,l.value.trim(),"month"));v&&(go("dl.person.last",JSON.stringify({access:a.get(),quota:l.value.trim()})),v.link&&await ue(v.link,"Personal link copied",!0),this.showCreated(v.id,r.value.trim(),v.link,e.servers.find(y=>y.id===(p?.value??c.id))?.name??c.name),await this.refresh())},"positive")]),setTimeout(()=>r.focus(),50)}showCreated(e,r,o,a){if(o){Kt({id:e,name:r,link:o},a,{title:`${r} is ready`,lead:`Send ${r} the card or the link. They open it, add their devices and connect — no account needed.`});return}let i=this.person(e);oe(`${r} is ready`,[t("p",{},"Created. Turn on the personal portal in Settings to get a link, or add devices for them here.")],[t("button",{class:"cbi-button cbi-button-neutral",click:ae},"Done")," ",t("a",{class:"cbi-button cbi-button-neutral",href:`${L.url("admin/network/dawnline/settings")}?section=portal`},"Open Settings")," ",i?H("Add device",()=>{ae(),ot(i,this.deviceOpts(i))},"positive"):""])}};var Cn=["#3a83f7","#a78bfa","#f472b6","#f59e0b","#10b981","#22d3ee","#ef4444","#84cc16"],bo=n=>t("i",{class:"dl-circle-dot",style:`background:${Cn[n?.color??0]??Cn[0]}`}),at=n=>n.access==="both"||n.access==="lan"&&!n.services?.length;function Xr(n,e,r){let o=se(n?.name??e.name??"",{placeholder:"NAS"}),a=se(n?.address??e.address??"",{placeholder:"192.168.1.10",class:"cbi-input-text dl-mono"}),i=se((n?.ports??e.ports??[]).join(", "),{placeholder:"All ports, or e.g. 445, 5000",class:"cbi-input-text dl-mono"}),s=ye("Name",o,()=>_e(o.value,[],"Shown to people who may reach it.")),l=ye("Address",a,()=>Vo(a.value)),d=ye("Ports",i,()=>Jo(i.value));oe(n?`Edit ${n.name}`:"Add service",[s,l,d],[ie()," ",H("Save",async()=>{let c=ze([s,l,d]);if(c){U(c,"warning");return}let p=i.value.split(/[ ,]+/).filter(Boolean);await G(()=>A.serviceSet(n?.id??"",o.value,a.value,p),"Saved")&&(ae(),r())},"positive")])}var Ss={_smb:"SMB",_afpovertcp:"AFP",_http:"Web",_https:"Web",_ssh:"SSH",_sftp:"SFTP","_sftp-ssh":"SFTP",_ipp:"Printer",_ipps:"Printer",_printer:"Printer","_pdl-datastream":"Printer",_airplay:"AirPlay",_raop:"AirPlay",_rfb:"Screen sharing",_googlecast:"Cast",_hap:"HomeKit",_rdp:"Remote desktop",_ftp:"FTP"},Ts=[["Web",["80","443"]],["SMB",["445"]],["SSH",["22"]]];function _s(n){let e=new Map;for(let r of n.services){let o=Ss[r.type.split(".")[0]];!o||!r.port||(e.get(o)??e.set(o,new Set).get(o)).add(String(r.port))}return e.size?[...e].map(([r,o])=>[r,[...o].sort((a,i)=>+a-+i)]):Ts}function ea(n,e,r){let o=n,a=null,i=!1,s=null,l=new Set,d=t("div",{class:"dl-list"}),c=t("div",{class:"dl-stack gap8"},t("span",{class:"dl-sub"},"Looking for devices at home…")),p=()=>{let m=o.services;dom.content(d,m.length?m.map(C=>t("div",{class:"dl-row"},[b("home"),t("span",{class:"dl-row-main dl-stack"},[t("b",{},C.name),t("span",{class:"dl-mono dl-faint"},`${C.address}${C.ports.length?` · ports ${C.ports.join(", ")}`:" · all ports"}`)]),H("Edit",()=>Xr(C,{},r)),H([b("trash")],async()=>{await le(`Remove ${C.name}?`,"People limited to this service lose access to it.","Remove",!0)&&await G(()=>A.serviceDelete(C.id),"Removed")&&await r()},"neutral",{title:"Remove","aria-label":`Remove ${C.name}`})])):[t("div",{class:"dl-row dl-muted"},"No services yet: pick ports of a device below.")])};async function u(m,C){if(!l.has(m.address)){l.add(m.address),$();try{let B=o.services.find(v=>v.address===m.address);(C===null?B&&await G(()=>A.serviceDelete(B.id),`${B.name} removed`):await G(()=>A.serviceSet(B?.id??"",B?.name??(m.name||m.address),m.address,C),B?`${B.name} updated`:`${m.name||m.address} added`))&&await r()}finally{l.delete(m.address),$()}}}function x(m){let C=o.services.find(E=>E.address===m.address),B=!!C&&!C.ports.length,w=new Set(C?.ports??[]),v=l.has(m.address),y=(E,k,z)=>qe(E,k,z,{disabled:v?"disabled":null,"aria-busy":v?"true":null});return t("div",{class:"dl-row"},[b(m.services.some(E=>E.type.startsWith("_ipp")||E.type.startsWith("_printer"))?"file":"computer"),t("span",{class:"dl-row-main dl-stack"},[t("b",{},m.name||m.address),t("span",{class:"dl-mono dl-faint"},m.address)]),t("div",{class:"dl-chips-row dl-host-ports"},[y("All ports",B,()=>u(m,B?null:[])),..._s(m).map(([E,k])=>{let z=!B&&k.every(f=>w.has(f));return y(`${E} ${k.join(", ")}`,z,()=>{let f=new Set(B?[]:w);for(let g of k)z?f.delete(g):f.add(g);u(m,f.size?[...f]:null)})})])])}function $(){if(i)return dom.content(c,t("span",{class:"dl-sub"},"Couldn't read the devices at home."));if(!a)return;let m=a;if(!m.hosts.length)return dom.content(c,t("span",{class:"dl-sub"},"No devices found in the home network right now."));let C=t("details",{class:"dl-params",open:s??!o.services.length?"":null},[t("summary",{},[b("chevron"),t("span",{},"Add from devices at home"),t("span",{class:"dl-pcount"},String(m.hosts.length))]),t("div",{class:"dl-params-body"},[t("span",{class:"dl-sub"},m.mdns?"Ports they announce over Bonjour. Pick what to open, or all ports.":"Devices that got an address from this router. Pick the ports to open, or all ports."),t("div",{class:"dl-list"},m.hosts.map(x))])]);C.addEventListener("toggle",()=>s=C.open),dom.content(c,C)}return A.homeHosts(e).then(m=>{a=m,$()}).catch(()=>{i=!0,$()}),p(),{el:t("div",{class:"dl-stack gap8"},[t("div",{class:"dl-iflead"},[t("div",{class:"dl-iflead-row"},[t("b",{},"Home services"),H([b("plus")," Add service"],()=>Xr(null,{},r))]),t("span",{class:"dl-sub"},"Home-only people can be limited to these instead of whole networks (chosen on their page). Shared by all servers.")]),d,c]),update(m){o=m,p(),$()}}}function En(n,e,r,o){let a=new Set(n.circles.filter(m=>m.server===e).map(m=>m.color)),i=r?.color??Cn.findIndex((m,C)=>!a.has(C));i<0&&(i=0);let s=se(r?.name??"",{placeholder:"Family"}),l=n.people.filter(m=>m.server===e).sort((m,C)=>m.name.localeCompare(C.name)),d=new Set(l.filter(m=>r&&m.circle===r.id).map(m=>m.id)),c=t("div",{class:"dl-swatches",role:"radiogroup","aria-label":"Colour"}),p=()=>dom.content(c,Cn.map((m,C)=>t("button",{type:"button",role:"radio",class:`dl-swatch${C===i?" on":""}`,style:`--sw:${m}`,"aria-checked":C===i?"true":"false","aria-label":`Colour ${C+1}`,click:()=>{i=C,p()}})));p();let u=t("div",{class:"dl-chips-row"},l.map(m=>{let C=m.circle&&m.circle!==r?.id?n.circles.find(B=>B.id===m.circle):void 0;return t("button",{type:"button",class:`dl-chipbtn${d.has(m.id)?" on":""}`,title:at(m)?C?`Now in ${C.name}`:"":`${m.name} has no home access: their devices aren't reachable anyway`,click:B=>{d.delete(m.id)||d.add(m.id),B.currentTarget.classList.toggle("on",d.has(m.id))}},[m.name,at(m)?C?t("b",{},C.name):"":t("b",{},"internet")])})),x=(m,C)=>t("div",{class:"cbi-value"},[t("label",{class:"cbi-value-title"},m),t("div",{class:"cbi-value-field"},C)]),$=n.circles.filter(m=>m.server===e&&m.id!==r?.id).map(m=>m.name),h=ye("Name",s,()=>Go(s.value,$));oe(r?`Edit ${r.name}`:"New circle",[h,x("Colour",c),x("People",u),t("p",{class:"dl-sub"},"Devices of people in one circle reach each other. A person is in one circle at a time.")],[r?H("Delete",async()=>{await G(()=>A.circleDelete(r.id),`${r.name} deleted`)&&(ae(),o())},"negative"):"",t("span",{class:"dl-spacer"}),ie()," ",H("Save",async()=>{let m=h.help();if(m.bad){U(m.text,"warning");return}await G(()=>A.circleSet(r?.id??"",e,s.value,i,[...d]),"Saved")&&(ae(),o())},"positive")],"dl-circle-modal")}function ta(n,e,r){let o=n.circles.filter(a=>a.server===e);return t("div",{class:"dl-chips-row dl-circles"},[...o.map(a=>{let i=n.people.filter(s=>s.circle===a.id).map(s=>s.name);return t("button",{type:"button",class:"dl-chip",title:`Edit ${a.name}`,click:()=>En(n,e,a,r)},[bo(a),t("b",{},a.name),t("span",{class:"dl-faint"},i.length?i.join(", "):"nobody yet")])}),t("button",{type:"button",class:"dl-chip add",title:"New circle","aria-label":"New circle",click:()=>En(n,e,null,r)},b("plus"))])}function xo(n,e){let r=n.people.filter(p=>p.server===e.id),o=(p="")=>t("span",{class:"dl-yes"},[b("check"),p]),a=()=>t("span",{class:"dl-faint"},"—"),i=p=>{let u=new Set(p.map(x=>x.access==="lan"&&x.services?.length?"services":x.home_nets?.length?"some":"all"));return u.size||u.add("all"),o([...u].map(x=>({all:"all networks",some:"their networks",services:"services"})[x]).join(" / "))},s=()=>e.mesh==="off"?a():e.mesh==="circles"?o("circle"):o(),l=e.lan_like?"like home":"direct",d=(p,u,x)=>t("tr",{},[t("td",{},[t("b",{},p),t("div",{class:"dl-sub"},`${u.length} ${u.length===1?"person":"people"}`)]),...x.map($=>t("td",{},$))]),c=p=>r.filter(u=>u.access===p);return t("section",{class:"dl-setsec"},[t("div",{class:"dl-setsec-body"},[t("div",{class:"dl-panel-head"},[t("h3",{},"Who reaches what"),t("span",{class:"dl-spacer"}),t("span",{class:"dl-sub"},"From the rules on this server")]),t("div",{class:"dl-reach-wrap"},t("table",{class:"dl-table dl-reach"},[t("tr",{},["","Internet","Home","This router","Each other"].map(p=>t("th",{},p))),d("Internet",c("internet"),[o(l),a(),t("span",{class:"dl-faint"},"DNS"),a()]),d("Home",c("lan"),[t("span",{class:"dl-faint"},"their own"),i(c("lan")),o(),s()]),d("Both",c("both"),[o(l),i(c("both")),o(),s()])])),t("p",{class:"dl-sub"},"Home devices reach the devices of people with home access, on the networks those people reach. Paused, ended and over-the-limit people reach nothing.")])])}function na(n,e){let r=n.people.filter(c=>c.server===e.id).flatMap(c=>c.devices.map(p=>({id:p.id,label:`${c.name} · ${p.name}`}))).sort((c,p)=>c.label.localeCompare(p.label)),o="@addr",a=(c,p)=>{let u=t("select",{class:"cbi-input-select","aria-label":c},[...r.map(m=>t("option",{value:m.id,selected:m.id===p?"selected":null},m.label)),t("option",{value:o,selected:p===o?"selected":null},"Address")]),x=se("",{placeholder:c,class:"cbi-input-text dl-mono"}),$=t("div",{class:"dl-check-end"},[u,x]),h=()=>x.hidden=u.value!==o;return u.addEventListener("change",h),h(),{el:$,value:()=>u.value===o?x.value.trim():u.value}},i=a("10.0.1.11",r[0]?.id??o),s=a("10.0.1.20:445",o),l=t("div",{class:"dl-stack gap8"}),d=async()=>{let c=await G(()=>A.accessCheck(i.value(),s.value()));if(!c)return;let p=c.steps.findIndex(u=>!u.ok);dom.content(l,[t("div",{class:`dl-verdict ${c.ok?"ok":"bad"}`},[t("b",{},c.ok?"Allowed":"Blocked"),t("span",{class:"dl-sub"},c.ok?"Every step lets it through":`Stops at step ${p+1} of ${c.steps.length}`)]),t("ul",{class:"dl-checks"},c.steps.map(u=>t("li",{},[t("span",{class:`dl-check-icon ${u.ok?"ok":"error"}`},b(u.ok?"check":"x")),t("div",{class:"dl-check-body"},[t("div",{class:"dl-check-title"},u.title),u.detail?t("div",{class:"dl-check-detail"},u.detail):""])])))])};return t("section",{class:"dl-setsec"},[t("div",{class:"dl-setsec-body"},[t("div",{class:"dl-panel-head"},[t("h3",{},"Check access"),t("span",{class:"dl-spacer"}),t("span",{class:"dl-sub"},"Why something does or does not connect")]),t("div",{class:"dl-check-form"},[i.el,t("span",{class:"dl-faint"},"→"),s.el,H("Check",d)]),l])])}var Ln={app:"Dawnline",amneziawg:"AmneziaWG",packages:"System packages",pkgs:"System packages"};function it(n){return(n.startsWith("check")?n.slice(6)||"all":n).split(/[:@ ]/)[0]}function Mn(n){return it(n.action==="check"?`check:${n.component??""}`:n.component??"")}function oa(n){return n=Math.max(0,Math.floor(n)),`${Math.floor(n/60)}:${String(n%60).padStart(2,"0")}`}function ra(n,e){return!n?.from&&!n?.to?e:n.from&&n.to&&n.from!==n.to?`${n.from} → ${n.to}`:n.to??n.from??e}function aa(n,e){let r=n.check?.components??{},o=e==="all"?["app","amneziawg","packages"]:[e],a=[],i;for(let l of o){let d=r[l];if(d){if(d.error)return{tone:"warn",text:d.error};l==="packages"&&d.updates?a.push(`${d.updates} system package${d.updates===1?"":"s"}`):l!=="packages"&&d.update&&d.installed&&d.latest&&(a.push(`${Ln[l]} ${d.latest}`),e!=="all"&&(i=d.latest))}}if(a.length)return{tone:"acc",text:`Update available: ${a.join(", ")}`,update:i};let s=o.length===1?r[o[0]]:null;return s?.status==="dev"?{tone:"acc",text:`Installed version is newer than the release (${s.latest})`}:s?.note?{tone:"warn",text:s.note}:{tone:"ok",text:o.length>1?"Everything is up to date":"Latest version is installed"}}function ia(n,e,r,o){return e?n.id===e:r&&n.id===r?!1:n.state==="running"||o>0&&n.started>=o}var sa=n=>new Promise(e=>setTimeout(e,n));async function Jt(n,e,r){let o=r?Mn(r):it(n),a=r?r.action==="check":n.startsWith("check"),i=Date.now(),s=t("b",{},Ln[o]??(o==="all"?"All components":"Dawnline")),l=t("span",{class:"dl-pill dl-mono"},e.version??""),d=t("span",{class:"dl-pill info",hidden:!0}),c=t("span",{},"0:00"),p=t("pre",{class:"dl-log"},"Operation started. Waiting for log output…"),u=t("div",{}),x=t("div",{class:"dl-op-actions"}),$=[],h=f=>dom.content(x,f),m=(f=!1)=>ie("Close",f);oe(e.title,t("div",{class:"dl-op"},[t("div",{class:"dl-op-head"},[s,e.version?l:"",d,t("span",{class:"dl-spacer"}),t("span",{class:"dl-faint dl-op-timer"},[b("clock"),c])]),t("div",{class:"dl-op-loghead"},[t("b",{},"Operation log"),Le("copy","Copy log",()=>ue($.join(` -`),"Log copied"))]),p,u]),[x],"wide"),h([t("button",{class:"cbi-button cbi-button-neutral spinning",type:"button",disabled:"disabled"},a?"Checking…":"Working…")]);let C=r??null,B=r?.id,w,v=0,y=f=>{B!==f.id&&(B=f.id,e.onJob?.(f))};if(r)e.onJob?.(r);else try{let f=await A.updatesStatus().catch(()=>null);w=f?.job?.id,v=f?.now??0;let g=await A.updatesRun(n);g.job&&g.job.state==="running"&&g.job.id!==w&&(C=g.job,y(g.job))}catch(f){return $=[be(f)],p.textContent=$[0],dom.content(u,t("div",{class:"dl-comp-status warn"},[b("alert"),t("span",{},be(f))])),h([m(!0)]),U(be(f),"error"),null}let E=null,k=0;for(;;){if(await sa(1e3),E=await A.updatesStatus().catch(()=>null),!E){if(++k>60)break;continue}k=0;let f=E.job;if(!f||!ia(f,B,w,v)){if(Date.now()-i>15e3)break;continue}if(y(f),C=f,f.log.length){$=f.log;let g=p.scrollTop+p.clientHeight>=p.scrollHeight-8;p.textContent=$.join(` -`),g&&(p.scrollTop=p.scrollHeight)}if(l.textContent=ra(f,e.version??""),!l.isConnected&&l.textContent&&s.after(l),c.textContent=oa((f.finished??E.now)-f.started),f.state==="running"){d.hidden=!f.phase,d.textContent=f.phase;continue}break}if(p.scrollTop=p.scrollHeight,d.hidden=!1,!C||C.state==="running")return d.className="dl-pill warn",d.textContent="No answer",dom.content(u,t("div",{class:"dl-comp-status warn"},[b("alert"),t("span",{},"The router stopped answering. The job may still finish: reopen Components in a minute.")])),h([m()]),e.onDone?.(E),C;if(C.state==="failed")return d.className="dl-pill bad",d.textContent="Failed",dom.content(u,t("div",{class:"dl-comp-status bad"},[b("x"),t("span",{},[t("b",{},C.error??"Operation failed"),a?"":". Nothing else was changed."])])),h([H("Copy log",()=>ue($.join(` -`),"Log copied")),m(!0)]),U(`${Ln[o]??"Update"}: ${C.error??"failed"}`,"error"),e.onDone?.(E),C;if(d.className="dl-pill ok",d.textContent="Finished",a&&E){let f=aa(E,o);if(dom.content(u,t("div",{class:`dl-comp-status ${f.tone}`},[b(f.tone==="ok"?"check":f.tone==="warn"?"alert":"download"),t("span",{},f.text)])),U(f.text,f.tone==="warn"?"warning":"success"),e.onDone?.(E),f.update&&e.onUpdate){let g=E;h([m(),H(`Update to ${f.update}`,()=>e.onUpdate(g),"positive")])}else h([m()]),f.tone==="ok"&&setTimeout(()=>u.isConnected&&ae(),1200);return C}if(o==="app"&&C.to){let f=C.to,g=t("span",{},"Waiting for the router to restart its services…");dom.content(u,t("div",{class:"dl-comp-status ok"},[b("check"),t("span",{},[t("b",{},`Dawnline ${f} is installed. `),g])]));let S=()=>{ui.menu?.flushCache(),location.reload()};h([m(),H("Reload now",S,"positive")]),U(`Dawnline updated to ${f}`,"success",6e3);for(let T=1;T<=30;T++)if(g.textContent=`Waiting for the router to restart its services (${T} of 30)…`,await sa(1500),(await A.updatesStatus().catch(()=>null))?.version===f)return g.textContent="Services are back. Reloading…",setTimeout(S,800),C;return g.textContent="Services restarted. Reload the page to use the new version.",C}let z=o==="pkgs"?`Updated ${[...C.result?.pkgs?.updated??[],...C.result?.pkgs?.installed??[]].join(", ")||"system packages"}`:o==="amneziawg"?`AmneziaWG${C.to?` ${C.to}`:""} is installed`:"Operation completed";return dom.content(u,t("div",{class:"dl-comp-status ok"},[b("check"),t("span",{},z)])),h([m()]),U(z,"success"),e.onDone?.(E),C}var Ps={https:"HTTPS for the portal",acme:"ACME certificates",home:"the home-like link",awg:"AmneziaWG"};async function la(n,e,r,o){return!await le(`Install ${e}?`,r,"Install")||(await Jt(n,{title:`Installing ${e}`}))?.state!=="done"?!1:(setTimeout(()=>o?.(),4e3),!0)}function Sn(n){return la("amneziawg:auto","AmneziaWG","Dawnline installs the AmneziaWG build made for this firmware and loads it. If the network service has to restart to learn it, connections drop for a few seconds.",n)}async function Yt(n,e,r){return n==="awg"?Sn(r):e.length?la(`pkgs:${e.join(",")}`,Ps[n],`${e.join(", ")} from the OpenWrt feeds. Dawnline sets the rest up when they arrive.`,r):!0}async function da(n,e){if(n==="awg")return Sn(e);let r=await G(()=>A.updatesStatus());return r?Yt(n,r.needs?.[n]??[],e):!1}var Ds=[["wan","WAN"],["ethernet","Ethernet"],["wifi","Wi-Fi"],["vpn","VPN & tunnels"],["other","Other"]],As={wan:"globe",ethernet:"ethernet",bridge:"bridge",wifi:"wifi",vpn:"tunnel",other:"link"};function ca(n,e,r){let o=n.id,a=e,i=t("div",{class:"dl-stack gap16"},t("section",{class:"dl-setsec"},t("div",{class:"dl-setsec-body"},t("p",{class:"dl-muted"},"Loading interfaces…")))),s,l=!0,d="",c=!0,p=!0,u="all",x=!1,$=ea(a,o,r),h=new Set,m="",C=()=>JSON.stringify([p,l,l?"":d,c,[...h].sort()]),B=()=>s.detected.lan||s.saved.lan||"",w=()=>(l?s.detected.wan||s.saved.wan:d)||"",v=()=>new Map(s.devices.map(R=>[R.name,R])),y=()=>{let R=v();return[...c&&B()?[B()]:[],...[...h].filter(Z=>Z!==B())].filter(Z=>Z!==w()).map(Z=>R.get(Z)??{name:Z,nets:[],missing:!0})},E=(R,K)=>{s=R,K&&(l=R.config.auto_wan,d=R.config.wan_device||R.detected.wan||R.saved.wan||"",c=R.config.auto_lan,p=R.config.lan_like,u=R.config.mesh??(R.config.device_mesh?"all":"off"),h=new Set(R.config.lan_devices),m=C()),q()},k=async R=>{let K=await A.interfaces(o).catch(Z=>(U(Z.message,"error"),null));K&&E(K,R)};function z(R){let K=c&&R.name===B(),Z=!!R.own||!!R.master||R.name===w()||K;return K||h.has(R.name)||!Z&&(R.nets.length>0||!!R.missing)}function f(R){let K=c&&R.name===B(),Z=R.name===w(),de=!K&&h.has(R.name),te=!(!!R.own||!!R.master||Z||K)&&(R.nets.length>0||de||!!R.missing),ge=(de||K)&&!R.zone&&!R.missing,O=R.missing?"Not present right now":R.own?"This server":R.master?`Port of ${R.master}`:Z?`Internet${R.zone?` · zone ${R.zone}`:""}`:R.nets.length?R.nets.join(", "):"No IPv4 network",X=t("button",{type:"button",class:`dl-if${de?" sel":""}${K?" auto":""}${!te&&!de&&!K?" off":""}${ge?" warn":""}`,"aria-pressed":de||K?"true":"false","aria-disabled":te?null:"true",click:()=>{te&&(h.has(R.name)?h.delete(R.name):h.add(R.name),q())}},[t("span",{class:"dl-if-ic"},b(As[R.kind]??"link")),t("span",{class:"dl-if-main"},[t("span",{class:"dl-if-name"},R.name),t("span",{class:"dl-if-sub"},O)]),K?t("span",{class:"dl-if-badge ok"},"Auto"):de?t("span",{class:"dl-if-check"},b("check")):""]);return me(X,()=>[t("div",{class:"dl-tip-title"},R.name),t("div",{class:"dl-muted"},[R.logical?`Interface ${R.logical}`:"No netifd interface",R.zone?` · zone ${R.zone}`:" · no firewall zone"]),R.members.length?t("div",{class:"dl-muted"},`Ports: ${R.members.join(", ")}`):"",R.nets.length?t("div",{class:"dl-mono"},R.nets.join(", ")):"",ge?t("div",{class:"dl-warn"},"Not in a firewall zone: the firewall rejects this traffic."):"",R.master?t("div",{class:"dl-muted"},`Choose ${R.master} to include it.`):""]),X}function g(){let R=s.like_home;return!p||!s.config.lan_like||!n.enabled?"":!s.needs?.length&&R.active&&R.bridged?"ok":"warn"}function S(){let R=s.like_home;return p?s.needs?.length?[t("span",{class:"dl-warn"},`Needs ${s.needs.join(" and ")}.`)," Until they are installed, internet traffic goes straight to the WAN."]:s.config.lan_like?n.enabled?R.active&&R.bridged?["Internet traffic enters ",t("span",{class:"dl-mono"},R.dev??"")," as ",t("span",{class:"dl-mono"},R.address??""),", so whatever handles home traffic (proxies, filters, DNS) handles it too."]:[t("span",{class:"dl-warn"},`Not working: ${R.error??"the link is down"}`)," Internet traffic goes straight to the WAN for now."]:["Internet traffic enters the router from your LAN, so whatever handles home traffic (proxies, filters, DNS) handles it too."]:["Internet traffic will enter the router from your LAN, so it is handled like any home device. Save to turn on."]:["Off: internet traffic goes straight to the WAN, past whatever handles home traffic on this router."]}let T={off:"Devices of different people never reach each other; a person's own devices don't either.",all:"Devices of people with home access reach each other, like home devices do. Internet-only people never.",circles:"Within a circle: family sees family, guests see guests. Everyone reaches their own devices. Internet-only people never."};function N(R,K,Z,de,Q="",te){return t("div",{class:te?"dl-setrow head":"dl-setrow"},[t("div",{class:"dl-lh-main"},[t("span",{class:`dl-need-ic ${Q}`},b(R)),t("div",{class:"dl-stack"},[t("span",{class:"dl-setrow-label"},K),t("span",{class:"dl-sub"},Z),te??""])]),t("div",{class:"dl-setrow-ctl"},de)])}let W=(R,K)=>{let Z=de=>t("span",{class:"dl-mono"},de);return R?t("span",{},[" Now: ",Z(R),...K&&K!==R?[", was ",Z(K)]:[],"."]):t("span",{},K?[" Not found now: using ",Z(K),"."]:[" Not found."])};function q(){let R=t("select",{class:"cbi-input-select","aria-label":"Internet interface",change:M=>{d=M.target.value,q()}},s.devices.filter(M=>!M.own&&!M.master&&M.zone&&!M.missing).map(M=>t("option",{value:M.name,selected:M.name===d?"selected":null},`${M.name} · zone ${M.zone}`))),Z=y().flatMap(M=>M.nets.map(j=>[j,M.name])),de=JSON.parse(C()),Q=JSON.parse(m),te=(...M)=>M.some(j=>JSON.stringify(de[j])!==JSON.stringify(Q[j])),ge=te(0,1,2),O=te(3,4),X=M=>H("Save",async()=>{let j=await G(()=>A.serverInterfaces(o,l,l?"":d,c,[...h],p,u!=="off",u),"Access saved");j&&(E(j,!0),j.nets_changed&&j.lan_only&&U(`${j.lan_only} ${j.lan_only===1?"person has":"people have"} Home-only access: their devices need the configuration again to reach the new networks.`,"warning",1e4))},"positive",{disabled:!M}),P=t("section",{class:"dl-setsec dl-ifcard"},[t("div",{class:"dl-setsec-body"},[t("div",{class:"dl-panel-head"},[t("h3",{},"Internet"),t("span",{class:"dl-spacer"}),t("span",{class:"dl-sub"},"People with Internet or Both")]),N("home","Internet like a home device",S(),[p&&s.needs?.length?H("Install",()=>Yt("home",s.needs,()=>k(!1)),"positive"):"",ve(p,"Internet like a home device",M=>{p=M,q()})],g()),N("globe","Auto-detect WAN",["The interface with the default route: the server port opens there and Internet access leaves through it.",W(s.detected.wan,s.saved.wan)],[l?"":R,ve(l,"Auto-detect WAN",M=>{l=M,q()})])]),t("div",{class:"dl-setsec-foot"},[t("span",{class:"dl-sub"},p?["Internet like a home device",w()?[" · leaves through ",t("span",{class:"dl-mono"},w())]:""]:w()?["Internet straight to ",t("span",{class:"dl-mono"},w())]:"No WAN found"),X(ge)])]),D=we([["off","Off"],["all","Everyone"],["circles","Circles"]],u,{label:"Devices reach each other",cls:"sm",optimistic:!1,onChange:async M=>{let j={off:"Off",all:"Everyone",circles:"Circles"}[M];await G(()=>A.serverUpdate(o,{mesh:M}),`Devices reach each other: ${j}`)&&(u=M,s.config.mesh=M,q(),await r())}}),_=t("section",{class:"dl-setsec dl-ifcard"},[t("div",{class:"dl-setsec-body"},[t("div",{class:"dl-panel-head"},[t("h3",{},"Home network"),t("span",{class:"dl-spacer"}),t("span",{class:"dl-sub"},"People with Home or Both"),H([b("reset")," Rescan"],()=>k(!1),"neutral",{title:"Read the interfaces again"})]),N("network","Networks","Everyone with home access reaches these, unless their page leaves one out; their devices can be reached from here too. Click one to add or remove it.","","",Y()),N("link","Devices reach each other",T[u],D,"",u==="circles"?ta(a,o,r):void 0),$.el]),t("div",{class:"dl-setsec-foot"},[t("span",{class:"dl-sub dl-if-summary"},Z.length?["Home access reaches ",...Z.flatMap(([M,j],J)=>[J?", ":"",t("span",{class:"dl-mono"},M),` (${j})`])]:"No home network: Home access reaches nothing but this router."),X(O)])]),I=window.scrollY;i.style.minHeight=`${i.offsetHeight}px`,dom.content(i,[P,_]),i.style.minHeight="",window.scrollTo({top:I})}function Y(){let R=s.devices.filter(z),K=s.devices.filter(Z=>!z(Z));return t("div",{class:"dl-stack gap8 dl-netpick"},[R.length?t("div",{class:"dl-ifgrid"},R.map(f)):t("span",{class:"dl-warn"},"No home network: Home access reaches nothing but this router."),t("label",{class:"dl-boxrow"},[t("span",{class:"dl-stack"},[t("span",{},"Auto-detect LAN"),t("span",{class:"dl-sub"},["Adds the LAN this router uses.",W(s.detected.lan,s.saved.lan)])]),ve(c,"Auto-detect LAN",Z=>{c=Z,q()})]),K.length?t("details",{class:"dl-params",open:x?"":null,toggle:Z=>x=Z.currentTarget.open},[t("summary",{},[b("chevron"),t("span",{},"Other interfaces"),t("span",{class:"dl-pcount"},String(K.length))]),t("div",{class:"dl-params-body"},[t("span",{class:"dl-sub"},"The WAN, this server, ports and Wi-Fi of a bridge (they come with it) and interfaces without an IPv4 network."),...Ds.map(([Z,de])=>{let Q=K.filter(te=>te.category===Z);return Q.length?t("div",{class:"dl-ifgroup"},[t("h4",{},de),t("div",{class:"dl-ifgrid"},Q.map(f))]):""})])]):""])}return k(!0),{el:i,update(R){a=R,$.update(R),s&&q()}}}var Hs={connect:"ok",disconnect:"",roam:"",device_added:"ok",device_removed:"",person_added:"",person_removed:"",paused:"warn",resumed:"ok",expiring:"warn",expired_kept:"",portal_blocked:"bad",person_changed:"",devices_removed:"warn"},zs={devices_removed:"trash",link_changed:"link",person_added:"plus",person_removed:"trash",person_changed:"edit",paused:"pause",resumed:"play",expiring:"calendar",expired_kept:"calendar"};function Ns(n,e){return e.device?n.people.flatMap(o=>o.devices).find(o=>o.id===e.device)?.kind??e.dkind??"other":zs[e.type]??"activity"}function wo(n,e){let r=n.people.find(h=>h.id===e.person),o=r?.name??e.pname??e.person??"",a=r?.devices.find(h=>h.id===e.device)?.name??e.dname??"",i=h=>t("b",{},h),s=h=>t("span",{class:"dl-muted"},h),l=h=>t("span",{class:"dl-mono"},h),d=h=>e.hosts?.[h]?[t("span",{class:"dl-ev-host"},[t("b",{},e.hosts[h]),t("span",{class:"dl-faint"},` (${h})`)])]:[l(h)],c=h=>t("span",{class:"dl-ev-kind"},`${h} `),p=a?`${o} · ${a}`:o,u=lr(e),x=u||a||"a device",$=h=>[t("span",{class:"dl-you"},"You"),s(` ${h} `)];if(Ne(e)==="admin")switch(e.type){case"device_added":return[...$("added"),c("device"),i(x),s(" for "),i(o)];case"device_removed":return[...$("removed"),c("device"),i(x),s(" from "),i(o)];case"paused":return[...$("paused"),c("person"),i(o)];case"resumed":return[...$("resumed"),c("person"),i(o)];case"device_changed":{let h=u.startsWith("renamed from ");return[...$(h?"renamed":u),c("device"),i(a||"a device"),s(" of "),i(o),...h?[s(` · was ${u.slice(13)}`)]:[]]}case"device_keys":return[...$("issued new keys for"),c("device"),i(x),s(" of "),i(o),s(" · it needs its new configuration")];case"link_changed":return[...$("issued a new link for"),c("person"),i(o),s(" · the old link stopped working")]}switch(e.type){case"connect":return[c("Device"),i(p),s(" connected"),...e.detail?[s(" from "),...d(e.detail)]:[],...e.where?[s(` · ${e.where}`)]:[]];case"disconnect":return[c("Device"),i(p),s(" went offline")];case"roam":return[c("Device"),i(p),s(" changed network "),...(e.detail??"").split(" → ").flatMap((h,m)=>m?[s(" → "),...d(h)]:d(h))];case"device_added":return[c("Person"),i(o),s(" added "),c("device"),i(x),...Ne(e)==="portal"?[s(" on their portal")]:[]];case"device_removed":return[c("Person"),i(o),s(" removed "),c("device"),i(x),...Ne(e)==="portal"?[s(" on their portal")]:[]];case"device_keys":return[c("Person"),i(o),s(" issued new keys for "),c("device"),i(x),s(" on their portal")];case"person_added":return[...$("added"),c("person"),i(e.detail??o)];case"person_removed":return[...$("removed"),c("person"),i(e.detail??o)];case"person_changed":return[...$("changed"),c("person"),i(o),...u?[s(` · ${u.replace(/_/g," ")}`)]:[]];case"expiring":return[c("Person"),i(o),s(`’s access ends in ${e.detail??"a few days"}`)];case"expired_kept":return[c("Person"),i(o),s(`’s end date passed (${e.detail??""}) · access kept`)];case"paused":return[c("Person"),i(o),s(` paused — ${e.detail??""}`)];case"resumed":return[c("Person"),i(o),s(" resumed"),...e.detail&&e.detail!=="active"?[s(` — ${e.detail}`)]:[]];case"portal_blocked":return[t("b",{class:"dl-sys-src"},"Personal portal"),s(" blocked "),l(e.detail??""),s(" for 15 min after too many wrong codes")];case"devices_removed":return[c("Person"),i(o),s(" — all devices removed, end date reached")];default:return[s(`${e.type}${e.detail?`: ${e.detail}`:""}`)]}}var Rs={portal_blocked:["globe","bad"]};function Is(n,e){if(n.servers.length<2||!e.person)return"";let r=n.people.find(a=>a.id===e.person),o=r&&n.servers.find(a=>a.id===r.server);return o?t("span",{class:"dl-ev-srv",title:"Server"},o.name):""}function st(n,e,r={}){let o=Rs[e.type],a=Ne(e);return t("div",{class:`dl-row${a==="admin"?" dl-ev-by-admin":o?` dl-ev-by-system ${o[1]}`:""}`},[a==="admin"?t("span",{class:"dl-ev-tile",title:"Done by you in LuCI"},b("admin")):o?t("span",{class:"dl-ev-tile sys"},b(o[0])):t("span",{class:`dl-ev-tile ev ${Hs[e.type]??""}`},b(Ns(n,e))),t("span",{class:"dl-row-main"},wo(n,e)),r.server===!1?"":Is(n,e),t("span",{class:"dl-faint dl-nowrap",title:new Date(e.ts*1e3).toLocaleString()},r.time??re(e.ts,n.now))])}var Bs={info:"",up:"ok",down:"warn",repair:"warn",error:"bad"},Os={awg:"tunnel",dawnline:"sunrise",portal:"globe"};function Tn(n,e,r,o){let a=n.by==="admin",i=t("div",{class:`dl-row dl-slog-row ${a?"dl-ev-by-admin":`dl-ev-by-system ${Bs[n.level]??""}`}${n.detail?" has-detail":""}`},[a?t("span",{class:"dl-ev-tile",title:"Done by you in LuCI"},b("admin")):t("span",{class:"dl-ev-tile sys",title:n.level},b(Os[n.src]??"zap")),t("span",{class:"dl-row-main"},a?[t("span",{class:"dl-you"},"You"),t("span",{class:"dl-muted"},` ${n.msg} `),n.kind?t("span",{class:"dl-ev-kind"},`${n.kind} `):"",n.who?t("b",{},n.who):"",n.note?t("span",{class:"dl-muted"},` · ${n.note}`):"",n.detail?t("span",{class:`dl-slog-more${e?" open":""}`},b("chevron")):"",n.detail&&e?t("pre",{class:"dl-slog-detail"},n.detail):""]:[n.src==="awg"&&n.who&&n.who!=="AmneziaWG"?t("span",{class:"dl-ev-kind"},"Server "):"",t("b",{class:"dl-sys-src",title:Ot[n.src]??n.src},n.who??Ot[n.src]??n.src)," ",t("span",{class:"dl-muted"},n.msg),n.detail?t("span",{class:`dl-slog-more${e?" open":""}`},b("chevron")):"",n.detail&&e?t("pre",{class:"dl-slog-detail"},n.detail):""]),t("span",{class:"dl-faint dl-nowrap",title:new Date(n.ts*1e3).toLocaleString()},o)]);return n.detail&&i.addEventListener("click",s=>{s.target.closest("pre")||r()}),i}function pa(n){let e=new Date(n*1e3),r=new Date,o=new Date;return o.setDate(r.getDate()-1),e.toDateString()===r.toDateString()?"Today":e.toDateString()===o.toDateString()?"Yesterday":e.toLocaleDateString("en-GB",{weekday:"long",day:"numeric",month:"long"})}var At=n=>wt(n).toLocaleDateString("en-GB",{day:"numeric",month:"short"});function _n(n,e,r,o=!1){let a=n.slice(-15),i=a[a.length-1],s=i&&e-i[0]<180,l=s?i[2]:0,d=s?i[1]:0,[c,p]=r,u=200,x=40,$=Math.max(1,...a.map(v=>Math.max(v[1],v[2]))),h=v=>a.map((y,E)=>`${a.length>1?E/(a.length-1)*u:u},${x-2-y[v]/$*(x-6)}`),m=h(2),C=h(1),B=a.length>1&&!o?et(``):t("div",{class:"dl-speed-wait"},[t("i"),o?"":t("span",{},"Collecting… 1 point a minute")]),w=(v,y,E,k)=>t("div",{class:"dl-speed-col"},[t("span",{class:"dl-sub"},[t("span",{class:E},y),` ${v}`]),o?t("span",{class:"dl-speed-val off"},"—"):t("span",{class:"dl-speed-val"},Oe(k))]);return a.length>1&&!o&&me(B,()=>{let v=a[a.length-1];return[t("div",{class:"dl-tip-title"},new Date(v[0]*1e3).toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit"})),t("div",{},`↓ ${Oe(v[2])} · ↑ ${Oe(v[1])}`)]}),t("div",{class:"dl-bento-tile"},[t("div",{class:"dl-bento-head"},[t("span",{class:"dl-metric-label"},"Speed now"),o?"":t("span",{class:"dl-sub"},"last 15 min")]),t("div",{class:"dl-speed-cols"},[w("Download","↓","dl-dn",l),w("Upload","↑","dl-up",d)]),B,t("div",{class:"dl-speed-today"},[t("span",{},["Today ",t("b",{},ee(c+p))]),t("span",{},[t("span",{class:"dl-dn"},"↓"),` ${ee(p)} `,t("span",{class:"dl-up"},"↑"),` ${ee(c)}`])])])}function Pn(n,e){let r=n.slice(-30),o=r.map(d=>d.rx+d.tx),a=Math.max(1,...o),i=o.reduce((d,c)=>d+c,0),s=o.reduce((d,c,p)=>c>o[d]?p:d,0),l=t("div",{class:"dl-bento-bars"},r.map((d,c)=>{let p=o[c],u=t("i",{class:c===r.length-1?"hi":"",style:`height:${Math.max(4,p/a*100)}%`});return me(u,()=>[t("div",{class:"dl-tip-title"},c===r.length-1?`Today · ${At(d.day)}`:At(d.day)),t("div",{},ee(p)),t("div",{class:"dl-muted dl-mono"},`↓ ${ee(d.tx)} ↑ ${ee(d.rx)}`)]),u}));return t("div",{class:"dl-bento-tile month"},[t("div",{class:"dl-bento-head"},[t("span",{},[t("span",{class:"dl-metric-label"},"Last 30 days"),t("b",{class:"dl-bento-total"},ee(i))]),o[s]>0?t("span",{class:"dl-sub"},`peak ${ee(o[s])} · ${At(r[s].day)}`):""]),r.length?l:t("p",{class:"dl-muted"},"No traffic yet."),t("div",{class:"dl-bento-head"},[t("span",{class:"dl-sub"},r.length?At(r[0].day):""),t("span",{class:"dl-sub"},e),t("span",{class:"dl-sub"},"today")])])}function ua(n){let e=n.slice(-30),r=e.map(a=>a.rx+a.tx),o=Math.max(1,...r);return t("div",{class:"dl-dbars"},e.map((a,i)=>{let s=t("i",{class:`${r[i]?"":"zero"}${i===e.length-1?" hi":""}`});return s.style.height=`${Math.max(8,r[i]/o*100)}%`,me(s,()=>[t("div",{class:"dl-tip-title"},i===e.length-1?`Today · ${At(a.day)}`:At(a.day)),t("div",{},ee(r[i]))]),s}))}var ma={apply:"Repair",sync:"Reload devices",restart:"Restart service",netrestart:"Restart network",updates:"Open Components"};async function Dn(n){return n==="netrestart"&&!await le("Restart the network?","Every interface restarts. Connections drop for a few seconds.","Restart network")?null:await G(()=>A.healthFix(n),"Done")??null}function yo(n,e,r,o="action"){let a=n.fix;return a?a.startsWith("install:")?H("Install",()=>da(a.slice(8),r),o):a==="updates"?t("a",{class:`cbi-button cbi-button-${o}`,href:L.url("admin/network/dawnline/updates")},ma.updates):H(ma[a]??"Fix",()=>e(a),o):""}function js(n){return/^(awg|up_|peers_|fw_|reply_|port_|subnet_)/.test(n)?"shield":/^(portal|cert)/.test(n)?"link":/^(ep_|home_|resolver)/.test(n)?"globe":n==="clock"?"clock":n==="agent"?"activity":n==="flash"?"download":n==="nft"?"lock":n==="data"?"users":"alert"}function ha(n,e,r,o=3){let a=n.filter(s=>s.status==="error"||s.status==="warn").sort((s,l)=>s.status===l.status?0:s.status==="error"?-1:1);if(!a.length)return"";let i=a.length-o;return t("div",{class:"dl-list dl-notices"},[...a.slice(0,o).map(s=>Xe(js(s.id),s.status==="error"?"bad":"warn",s.problem??s.title,s.detail,yo(s,e,r,s.status==="error"?"positive":"neutral"))),i>0?t("a",{class:"dl-row dl-notices-more",href:L.url("admin/network/dawnline/diagnostics")},[`${i} more in Diagnostics`,t("span",{class:"dl-spacer"}),"→"]):""])}function Us(n){let e=[],r=(s,l)=>t("a",{href:s},l),o=Ie(n.series),a=!!n.awg_state&&!n.awg_state.ok;for(let s of n.servers)s.enabled&&s.blocked?e.push({tone:"bad",text:[`${s.name} ${s.blocked}. `,r(L.url("admin/network/dawnline/diagnostics"),"Open Diagnostics")]}):s.enabled&&!s.up&&!a&&e.push({tone:"bad",text:[`Tunnel ${s.ifname} is down. `,r(L.url("admin/network/dawnline/diagnostics"),"Open Diagnostics")]});for(let s of n.people)if(s.state==="quota")e.push({tone:"warn",text:[r(ke(s.id),s.name)," reached the data limit."]});else if(s.state==="expired")e.push({tone:"warn",text:[r(ke(s.id),s.name),"’s access has ended."]});else{let l=Ye(s.expires,o);Ze(s,l)?e.push({tone:"",text:[r(ke(s.id),s.name),`’s access ${en(l)}.`]}):l!=null&&l<0&&s.expire_action==="notify"&&e.push({tone:"",text:[r(ke(s.id),s.name),`’s end date passed (${Me(s.expires)}) · access kept.`]}),s.quota_limit&&s.quota_used>=s.quota_limit*.9&&e.push({tone:"",text:[r(ke(s.id),s.name)," has used 90% of the data limit."]})}let i=n.people.flatMap(s=>s.devices.filter(l=>l.config_stale).map(l=>[s,l]));i.length&&e.push({tone:"warn",text:i.length===1?[r(ke(i[0][0].id,i[0][1].id),`${i[0][0].name} · ${i[0][1].name}`)," needs its configuration again."]:[`${i.length} devices need their configuration again (networks or DNS changed).`]});for(let s of n.servers)n.wan&&Ct(s.endpoint)&&s.endpoint!==n.wan&&e.push({tone:"warn",text:[`Public address changed: ${s.name} still gives devices ${s.endpoint}, the router is ${n.wan} now. `,t("button",{type:"button",class:"dl-fix",click:async l=>{let d=l.currentTarget;d.disabled=!0,await G(()=>A.serverUpdate(s.id,{endpoint:n.wan}),`${s.name} uses ${n.wan} now — devices need their configuration again`),d.disabled=!1}},"Use the new address")," A DDNS name would follow it by itself."]});return n.servers.some(s=>s.lan_like)&&n.like_home.error&&e.push({tone:"warn",text:[`Internet through the LAN is off: ${n.like_home.error} `,r(L.url("admin/network/dawnline/diagnostics"),"Details")]}),!n.settings.portal_enabled&&!n.people.length&&e.push({tone:"",text:["The personal portal is off. ",r(L.url("admin/network/dawnline/settings"),"Turn on")]}),e}var An=class{constructor(e,r){this.srvId=e;this.go=r;this.el=t("div",{class:"dl-srvov"});this.map=null;this.mapOn=null;this.range="online";this.parts={};this.healthAt=0}mount(e){this.st=Vt(e,this.srvId);for(let r of["health","bento","map","side","activity"])this.parts[r]=t("div",{});return dom.content(this.el,[this.parts.health,this.parts.bento,this.parts.map,t("div",{class:"dl-grid2"},[this.parts.activity,this.parts.side])]),this.paint(),this.loadHealth(),this.el}update(e,r=!1){this.st=Vt(e,this.srvId),this.paint(r),Date.now()-this.healthAt>6e4&&this.loadHealth()}async loadHealth(){this.healthAt=Date.now();let e=await A.health().catch(()=>null);if(!e)return;let r=()=>void this.loadHealth(),o=async a=>{await Dn(a)&&(r(),a==="netrestart"&&setTimeout(r,5e3))};Se(this.parts.health,ha(e.checks,a=>void o(a),r),!0)}mapData(){return{geo:this.st.geo,people:this.st.people,now:this.st.now}}paintMap(){let e=this.st.geo.enabled;if(e===this.mapOn&&(!e||this.map)){this.map?.update(this.mapData());return}this.mapOn=e,dom.content(this.parts.map,this.mapCard())}mapCard(){let e=this.st,r=t("div",{class:"dl-panel-head pad"},[t("div",{class:"dl-stack"},[t("h3",{},"Where people connect from"),t("span",{class:"dl-sub"},"City-level, from the client IP · locations cached on the router")]),t("span",{class:"dl-spacer"}),_t(this.range,l=>{this.range=l,this.map?.setRange(l)})]);if(this.map?.destroy(),this.map=null,!e.geo.enabled)return t("div",{class:"dl-panel flush"},[r,t("div",{class:"dl-map-off"},["Locations are off. ",t("a",{href:L.url("admin/network/dawnline/settings")},"Turn them on in Settings"),"."])]);let o=this.map=new nt({openPerson:l=>location.href=ke(l),openDevice:(l,d)=>location.href=ke(l,d)},this.range),a=$e(()=>{a(),o.destroy(),this.map===o&&(this.map=null)}),i=t("div",{class:"dl-map-legend"},[t("span",{},[t("i",{class:"line live"}),"Live tunnel"]),t("span",{},[t("i",{class:"line"}),"Seen recently"])]),s=t("div",{class:"dl-map-wrap"},[o.el,i]);return requestAnimationFrame(()=>o.mount(this.mapData())),t("div",{class:"dl-panel flush"},[r,s])}paint(e=!1){let r=this.st,o=r.servers[0];this.paintMap(),Se(this.parts.bento,t("div",{class:"dl-bento"},[this.onlineTile(),this.speedTile(),Be(o).overviewTile(o),this.monthTile()]),e);let a=Us(r);Se(this.parts.side,t("div",{class:"dl-panel flush"},[t("div",{class:"dl-panel-head pad"},[t("h3",{},"Needs attention"),t("span",{class:"dl-spacer"}),t("a",{href:L.url("admin/network/dawnline/diagnostics")},"Health")]),a.length?a.slice(0,8).map(s=>t("div",{class:"dl-attn-item dl-row"},[t("span",{class:`dl-ev-dot ${s.tone}`}),t("span",{},s.text),s.action??""])):t("div",{class:"dl-row dl-muted"},[b("check"),"All good. Nothing needs you right now."])]),e);let i=[...r.events].reverse().slice(0,8);Se(this.parts.activity,t("div",{class:"dl-panel flush"},[t("div",{class:"dl-panel-head pad"},[t("h3",{},"Activity"),t("span",{class:"dl-spacer"}),t("a",{href:`${L.url("admin/network/dawnline/diagnostics")}?tab=log`},"View all")]),i.length?i.map(s=>st(r,s)):t("div",{class:"dl-row dl-muted"},"Nothing yet. Connections, new devices and pauses appear here.")]),e)}onlineTile(){let e=this.st,r=e.servers[0]?!e.servers[0].enabled:!1,o=12,a=B=>B.spark[B.spark.length-1]??0,i=B=>e.geo.points.find(w=>w.device===B.id&&w.city)?.city,s=B=>/^(10\.|192\.168\.|172\.(1[6-9]|2\d|3[01])\.)/.test(B.endpoint??""),l=(B,w=!1)=>s(B)?w&&B.endpoint?`LAN · ${B.endpoint}`:"LAN":i(B)??"",d=B=>[...e.events].reverse().find(w=>w.type==="connect"&&w.device===B.id)?.ts??0,c=e.people.map(B=>({p:B,devs:B.devices.filter(w=>w.online).sort((w,v)=>a(v)-a(w))})).filter(B=>B.devs.length).sort((B,w)=>w.devs.reduce((v,y)=>v+a(y),0)-B.devs.reduce((v,y)=>v+a(y),0)),p=c.length<=2,u=({p:B,devs:w})=>{let v=w.map(d).filter(Boolean),y=v.length?Math.min(...v):0,E=(B.rate??[]).slice(-15),k=E[E.length-1],z=k&&e.now-k[0]<180?k:null,f=200,g=30,S=Math.max(1,...E.map(Y=>Math.max(Y[1],Y[2]))),T=Y=>E.map((R,K)=>`${E.length>1?K/(E.length-1)*f:f},${g-2-R[Y]/S*(g-6)}`),N=E.length>1?et(``):"",W=!z||z[1]<64&&z[2]<64,q=B.access==="both"?["home","globe"]:B.access==="lan"?["home"]:["globe"];return[t("div",{class:"dl-hc"},[t("div",{class:"dl-hc-head"},[t("span",{class:"dl-onl-av sm"},He(B.name)),t("span",{class:"dl-stack"},[t("b",{},B.name),t("span",{class:"dl-hc-since"},y?`online for ${re(y,e.now).replace(" ago","")}`:"online")]),t("span",{class:"dl-hc-reach"},q.map(Y=>t("span",{class:`dl-ibadge ${Y==="home"?"lan":"inet"}`},b(Y))))]),t("div",{class:"dl-hc-speed"},[t("div",{class:"dl-hc-speed-row"},W?[t("span",{class:"dl-faint"},"Idle right now")]:[t("span",{},[t("span",{class:"dl-dn"},"↓"),` ${Oe(z[2])}`]),t("span",{},[t("span",{class:"dl-up"},"↑"),` ${Oe(z[1])}`]),t("span",{class:"dl-spacer"}),t("span",{class:"dl-faint"},"15 min")]),N]),t("div",{class:"dl-hc-devs"},w.map(Y=>t("span",{class:"dl-hc-dev"},[b(Y.kind),Y.name,l(Y)?[" · ",l(Y,!0)]:""]))),t("div",{class:"dl-hc-foot"},[t("span",{class:"dl-faint"},`${ee(w.reduce((Y,R)=>Y+a(R),0))} today · ${ee(B.month[0]+B.month[1])} this month`)])])]},x=B=>{let{p:w,devs:v}=B,y=t("span",{class:"dl-onl-dev"},v.length>1?String(v.length):b(v[0].kind)),E=t("a",{class:`dl-onl-p${p?"":" sm"}`,href:ke(w.id),"aria-label":`${w.name}, online`},[t("span",{class:"dl-onl-av"},[He(w.name),y]),p?t("span",{class:"dl-onl-name"},w.name):"",p?t("span",{class:"dl-onl-meta"},[...v.slice(0,3).map(k=>b(k.kind)),v.length>3?`+${v.length-3}`:"",l(v[0])?t("span",{},[" · ",l(v[0])]):""]):""]);return me(E,()=>u(B)),E},$=t("b",{class:`dl-onl-count${c.length?"":" none"}`},String(c.length)),h=c.reduce((B,w)=>B+w.devs.length,0);c.length&&me($,()=>[`${c.length} ${c.length===1?"person":"people"} · ${h} device${h===1?"":"s"}`]);let m=c.length>o?c.slice(0,o-1):c,C=e.people.flatMap(B=>B.devices.map(w=>({p:B,d:w}))).filter(B=>B.d.handshake).sort((B,w)=>w.d.handshake-B.d.handshake)[0];return t("div",{class:"dl-bento-tile online"},[t("div",{class:"dl-bento-head"},[t("span",{class:"dl-metric-label"},"Online"),$]),c.length?t("div",{class:`dl-onl-row${p?"":" grid"}`},[...m.map(x),c.length>o?t("a",{class:"dl-onl-p sm more",href:`${L.url("admin/network/dawnline/server")}?server=${encodeURIComponent(this.srvId)}§ion=people&filter=online`,title:"Everyone online",click:B=>{this.go&&(B.preventDefault(),this.go("people","online"))}},[t("span",{class:"dl-onl-av"},`+${c.length-m.length}`)]):""]):t("div",{class:"dl-onl-empty"},[t("span",{},r?"The server is turned off":"Nobody is connected"),C?t("span",{class:"dl-sub"},`Last: ${C.p.name}, ${re(C.d.handshake,e.now)}`):t("span",{class:"dl-sub"},r?"Devices connect once it is on":"No device has connected yet")])])}speedTile(){let e=this.st.servers[0];return _n(e?.rate??[],this.st.now,this.st.totals.today,e?!e.enabled:!1)}monthTile(){let e=[...this.st.people].map(r=>[r,r.month[0]+r.month[1]]).filter(([,r])=>r>0).sort((r,o)=>o[1]-r[1]).slice(0,2);return Pn(this.st.series,e.length?`Most: ${e.map(([r,o])=>`${r.name} ${ee(o)}`).join(" · ")}`:"")}};var fa=[["overview","Overview"],["people","People"],["connection","Connection"],["access","Access"],["awg",""]],Gs={general:"connection",network:"connection",interfaces:"access",advanced:"awg",disguise:"awg",tunnel:"awg",core:"awg"},ko=(n,e)=>{let r=new URLSearchParams;n&&r.set("server",n),e&&e!=="overview"&&r.set("section",e);let o=r.toString();return`${L.url("admin/network/dawnline/server")}${o?`?${o}`:""}`},Zt=class{constructor(){this.noFooter=!0;this.root=t("div",{class:"dl-root"});this.section="overview";this.srvId="";this.ov={};this.pp={};this.tabsEl=t("div",{});this.headEl=t("div",{});this.secEl=t("div",{});this.bodyEl=t("div",{class:"dl-srvbody"})}async load(){let e=await A.status(31),r=e.servers.length?null:await A.setupDefaults();return[e,r]}render([e,r]){if(this.st=e,!e.servers.length&&r)return this.wizard(r);let o=new URLSearchParams(location.search),a=o.get("section")??"",i=Gs[a]??a;return fa.some(([s])=>s===i)&&(this.section=i),this.srvId=(e.servers.find(s=>s.id===o.get("server"))??e.servers[0]).id,dom.content(this.root,[this.tabsEl,this.headEl,this.secEl,this.bodyEl]),this.paint(),this.poller?.stop(),this.poller=rt({fetch:()=>A.status(31),every:30,live:!0,active:()=>this.section==="overview"&&this.root.isConnected,apply:(s,l)=>{s.servers.length&&(this.st=s,this.paintHead(l),this.ov[this.current().id]?.update(s,l))}}),this.root}paintHead(e=!1){Se(this.headEl,this.head(this.current()),e),(!e||!Dt(this.tabsEl))&&this.paintTabs()}async refreshStatus(){let e=await A.status(31).catch(()=>null);return e?.servers.length?(this.st=e,this.paintHead(),e):null}current(){return this.st.servers.find(e=>e.id===this.srvId)??this.st.servers[0]}async refresh(){let e=await A.status(31).catch(()=>null);e&&(this.st=e,e.servers.length?this.paint():location.href=ko())}paint(){this.paintTabs(),dom.content(this.headEl,this.head(this.current())),this.paintSections(),this.showSection(this.section)}paintTabs(){let e=this.current();dom.content(this.tabsEl,t("div",{class:"dl-srvtabs",role:"tablist","aria-label":"Servers"},[...this.st.servers.map(r=>t("button",{type:"button",role:"tab",class:`dl-srvtab${r.id===e.id?" on":""}`,"aria-selected":r.id===e.id?"true":"false",click:()=>{r.id!==this.srvId&&(this.srvId=r.id,this.paint())}},[t("i",{class:`dot ${r.enabled?r.up?"ok":"bad":"warn"}`}),t("b",{},r.name)])),t("button",{type:"button",class:"dl-srvtab add",click:()=>this.addServer()},[b("plus"),"Add server"])]))}paintSections(){let e=Be(this.current());dom.content(this.secEl,t("div",{class:"dl-seg dl-srvsections",role:"tablist","aria-label":"Server"},fa.map(([r,o])=>t("button",{type:"button",role:"tab","data-section":r,class:r===this.section?"on":"","aria-selected":r===this.section?"true":"false",click:()=>this.showSection(r)},r==="awg"?e.label:o))))}go(e,r){let o=this.pp[this.current().id];if(r&&o)o.filter=r,o.el&&o.decorate();else if(r){let a=this.pp[this.current().id]=new mt;a.filter=r}this.showSection(e),window.scrollTo({top:0,behavior:"smooth"})}detachKept(){let e=[...Object.values(this.ov).map(r=>r.el),...Object.values(this.pp).map(r=>r.el)];for(let r of e)r&&this.bodyEl.contains(r)&&r.remove()}showSection(e){this.section=e,this.secEl.querySelectorAll("[data-section]").forEach(s=>{let l=s.dataset.section===e;s.classList.toggle("on",l),s.setAttribute("aria-selected",l?"true":"false")});let r=this.st,o=this.current(),i={overview:()=>{let s=this.ov[o.id];return s?(s.update(r),s.el):(this.ov[o.id]=new An(o.id,(l,d)=>this.go(l,d))).mount(r)},people:()=>{var c,p;let s=this.pp[o.id];if(s?.el)return s.update(),s.el;let l=t("div",{},t("p",{class:"dl-muted"},"Loading people…"));return((c=this.pp)[p=o.id]??(c[p]=new mt)).embed(r,o.id).then(u=>{l.isConnected?dom.content(l,u):l.replaceChildren(u)}).catch(u=>{delete this.pp[o.id],dom.content(l,t("p",{class:"dl-muted"},`Couldn't show people: ${be(u)}`))}),l},connection:()=>this.connection(o),access:()=>this.access(o),awg:()=>this.awg(o)}[e]();this.detachKept(),dom.content(this.bodyEl,i)}head(e){let r=(i,s)=>t("span",{class:"dl-addrbar-seg"},[b(i),...s]),o=e.endpoint||"—",a=t("div",{class:"dl-actions"},[e.enabled?"":H([b("play")," Turn on"],()=>this.save(e,{enabled:"1"},"Server turned on"),"add")]);return t("div",{class:"dl-srvpagehead"},[t("div",{class:"dl-title-row"},[t("h2",{class:"dl-h1"},e.name),t("span",{class:`dl-pill ${e.enabled?e.up?"ok":"bad":"warn"}`},e.enabled?e.up?"Running":e.blocked?"Can’t start":"Not running":"Turned off"),t("span",{class:"dl-spacer"}),a]),t("div",{class:"dl-addrbar"},[t("button",{type:"button",class:"dl-addrbar-seg main",title:"Copy address",click:()=>ue(o,"Address copied")},[b("globe"),t("span",{class:"dl-mono"},o),b("copy")]),r(Be(e).id==="awg"?"amneziawg":"tunnel",[t("span",{class:"dl-mono"},`${Be(e).label} :${e.port}`)]),e.up?r("clock",[`up ${xt(e.uptime)}`]):""]),e.blocked?t("div",{class:"dl-note warn"},[b("alert"),t("span",{},`${e.name} ${e.blocked}.`)]):""])}async save(e,r,o="Saved"){await G(()=>A.serverUpdate(e.id,r),o)&&await this.refresh()}connection(e){let r=se(e.name,{placeholder:"Home"}),o=se(e.endpoint,{placeholder:"vpn.example.com",class:"cbi-input-text dl-mono"}),a=se(e.dns.join(", "),{placeholder:"This router (recommended)",class:"cbi-input-text dl-mono"}),i=this.st.people.filter($=>$.server===e.id).length,s=H([b(e.enabled?"pause":"play"),e.enabled?" Turn off":" Turn on"],async()=>{e.enabled&&!await le(`Turn off ${e.name}?`,`The tunnel stops and ${i} ${i===1?"person is":"people are"} disconnected until you turn it back on. Nothing is deleted.`,"Turn off",!0)||await this.save(e,{enabled:e.enabled?"0":"1"},e.enabled?"Server turned off":"Server turned on")},e.enabled?"negative":"positive"),l=this.st.settings.portal_host,d=he("Name",r,()=>_e(r.value,[],"Shown to people in their portal and apps.")),c=Zn(()=>({host:o.value,port:e.port,id:e.id}),($,h,m)=>A.endpointProbe($,h,m),()=>p.refresh(),{empty:l?`Empty = the portal’s address (${l}).`:"Empty = the portal’s address."}),p=he("Public address",o,c.help);o.addEventListener("input",c.schedule),c.schedule();let u=e.reached?`Reached from the internet ${re(e.reached,this.st.now)}.`:"Never reached from the internet yet — test with a phone on mobile data.",x=he("DNS for devices",a,()=>Wo(a.value,e.address));return t("div",{class:"dl-stack gap16"},[Rt("Connection",[t("p",{class:"dl-muted"},"The name people see, where devices find the router, and DNS. The port is on AmneziaWG."),fe("router","Server","What people see",[d]),fe("globe","Devices connect to","A DDNS name keeps links working when your IP changes; not through Cloudflare (use a DNS-only name or an IP)",[p,t("div",{class:`dl-sub ${e.reached?"ok":"warn"}`},u)]),fe("file","For every device","Changing it marks devices “Update config” until they import again",[x])],[t("span"),H("Save",()=>{let $=ze([d,p,x]);if($){U($,"warning");return}return this.save(e,{name:r.value,endpoint:o.value,dns:a.value})},"positive")]),Rt("Danger zone",[t("div",{class:"dl-setrow"},[t("div",{class:"dl-stack"},[t("span",{class:"dl-setrow-label"},e.enabled?"Turn off this server":"This server is off"),t("span",{class:"dl-sub"},e.enabled?"Stops the tunnel and disconnects everyone on it. Settings and people are kept.":"Nobody can connect. Turn it on to bring the tunnel back.")]),t("div",{class:"dl-setrow-ctl"},s)]),t("div",{class:"dl-setrow"},[t("div",{class:"dl-stack"},[t("span",{class:"dl-setrow-label"},"Change the tunnel network"),t("span",{class:"dl-sub"},`Devices have ${$t(e.subnet)}.x addresses now. A new range when it clashes with a network you connect to; every device then needs its configuration again.`)]),t("div",{class:"dl-setrow-ctl"},H([b("edit")," Change"],()=>this.changeSubnet(e),"negative"))]),t("div",{class:"dl-setrow"},[t("div",{class:"dl-stack"},[t("span",{class:"dl-setrow-label"},"Remove server"),t("span",{class:"dl-sub"},`Removes the tunnel, its firewall rules and ${i} ${i===1?"person":"people"} with all their devices. A backup is made first.`)]),t("div",{class:"dl-setrow-ctl"},H([b("trash")," Remove"],()=>this.remove(e),"negative"))])],[],"danger")])}access(e){let r=xo(this.st,e),o=ca(e,this.st,async()=>{let a=await this.refreshStatus();if(!a)return;let i=a.servers.find(l=>l.id===e.id)??e;o.update(a);let s=xo(a,i);r.replaceWith(s),r=s});return t("div",{class:"dl-stack gap16"},[o.el,t("div",{class:"dl-health-cols"},[r,na(this.st,e)])])}awg(e){let r={st:this.st,save:(o,a)=>this.save(e,o,a),refresh:()=>this.refresh()};return t("div",{class:"dl-stack gap16"},[Be(e).settingsCard(r,e)])}async addServer(){let e=await G(()=>A.setupDefaults());e&&dom.content(this.root,this.wizard(e,!0,()=>{dom.content(this.root,[this.tabsEl,this.headEl,this.secEl,this.bodyEl]),this.paint()}))}async changeSubnet(e){let r=await G(()=>A.serverPorts(e.id));if(!r)return;let o=r.networks??[],a=this.st.people.filter(l=>l.server===e.id).reduce((l,d)=>l+d.devices.length,0),i=se($t(e.subnet),{class:"cbi-input-text dl-mono dl-w-range"}),s=he("Address range",i,()=>Yn(i.value,o,""));oe("Change the tunnel network",[s,t("p",{class:"dl-muted"},a?`${a} device${a===1?" gets a new address and stops":"s get new addresses and stop"} connecting until ${a===1?"it imports its":"they import their"} configuration again (from their personal link or from you).`:"No devices on this server yet: nothing else changes.")],[ie()," ",H("Change",async()=>{let l=s.help();if(l.bad){U(l.text,"warning");return}let d=an(i.value);if(d===e.subnet){ae();return}await G(()=>A.serverUpdate(e.id,{subnet:d}),"Tunnel network changed")&&(ae(),a&&U("Devices are marked “Update config” until they import again.","info",6e3),await this.refresh())},"negative")]),setTimeout(()=>i.select(),50)}async remove(e){let r=this.st.people.filter(o=>o.server===e.id);oe(`Remove ${e.name}?`,[t("p",{},`This removes the tunnel, its firewall rules and ${r.length} ${r.length===1?"person":"people"} with all their devices. A backup is made first.`)],[ie()," ",H("Remove",async()=>{ae(),await G(()=>A.serverDelete(e.id),"Server removed")&&setTimeout(()=>{location.href=ko()},800)},"negative")])}wizard(e,r=!1,o){let a={id:e.id,name:e.name,endpoint:e.endpoint,port:e.port,range:$t(e.subnet),preset:mn(e.awg),portal:!1,portal_port:e.portal_port||8443,lan_like:!0,lan_zone:e.lan_zone,wan_zone:e.wan_zone},i=0,s=!r&&a.portal_port===a.port,l=()=>/^\d{1,3}(\.\d{1,3}){3}$/.test(a.endpoint),d=()=>It(a.port,e.udp_taken??[],`Opened on the WAN firewall automatically.${a.port===4500?" 4500 is IPsec’s port: most networks let it through.":""}`),c={ddns:"From your DDNS name.",cert:"From your Let’s Encrypt certificate.",wan:"Your WAN address now — it may change; a DDNS name is better.",portal:"The portal’s address."},p=Zn(()=>({host:a.endpoint,port:a.port}),(S,T,N)=>A.endpointProbe(S,"",N),()=>u?.refresh(),{idle:()=>a.endpoint===e.endpoint&&e.endpoint_from?c[e.endpoint_from]??"":""}),u=null,x=e.wan_kind==="cgnat"||e.wan_kind==="private"?Xe("alert","warn",e.wan_kind==="cgnat"?"Your router has no public address (CGNAT)":`Your router is behind another router (WAN ${e.wan_ip})`,e.wan_kind==="cgnat"?"The ISP shares one address: devices can only connect if the ISP gives you a public address or IPv6. Ask them, or use a DDNS name that points at an IPv6 address.":"Forward the UDP port on the upstream router to this one and use a DDNS name or that router’s public address here.",""):"",$=e.awg_state?.tools&&e.awg_state.handler===!1?t("div",{class:"dl-note warn"},[b("alert"),t("span",{},"Creating the server restarts the network for a few seconds: AmneziaWG was installed after the network started.")]):"",h=()=>Yn(a.range,e.networks??[],$t(e.subnet)),m=()=>sn(a.portal_port,e.tcp_taken??[],l()),C=t("div",{class:"dl-wizard"}),B=(S,T={})=>{let N=se(String(a[S]),T);return N.addEventListener("input",()=>{S==="port"||S==="portal_port"?a[S]=N.value.trim()===""?0:Number(N.value):a[S]=N.value.trim(),S==="port"&&s&&(a.portal_port=a.port),S==="portal_port"&&(s=a.portal_port===a.port)}),N},w={id:"server",title:"Server",render:()=>t("div",{class:"dl-wizard-groups"},[t("p",{class:"dl-muted"},r?"One more server: another port or disguise for networks where the first does not get through, or its own home access rules. People are moved between servers from their page.":"Where devices connect to. A hostname that always points at your router (DDNS) keeps links working when your IP changes."),fe("router","Server","What people see",[he("Name",B("name"),()=>_e(a.name,[],"Shown to people in their portal and apps."))]),fe("globe","Devices connect to","A hostname or IP address of your router on the internet; not through Cloudflare (use a DNS-only name or an IP). IPv6 works too, and is the way out of CGNAT",[(()=>{let S=B("endpoint",{placeholder:"vpn.example.com",class:"cbi-input-text dl-mono"});return u=he("Public address",S,p.help),S.addEventListener("input",p.schedule),p.schedule(),u})()]),x,$]),check:()=>{let S=_e(a.name);if(S.bad)return`Name: ${S.text}`;let T=kt(a.endpoint,a.port);return T.bad?`Public address: ${T.text}`:null}},v={id:"awg",title:"AmneziaWG",render:()=>t("div",{class:"dl-wizard-groups"},[fe("globe","Listening","Where devices reach AmneziaWG from the internet",[he("UDP port",B("port",{inputmode:"numeric",class:"cbi-input-text dl-w-port dl-mono"}),d)]),fe("network","Tunnel network","Addresses devices get inside the tunnel",[(()=>{let S=B("range",{class:"cbi-input-text dl-w-range dl-mono","aria-label":"First three numbers of the device addresses"});return he("Device addresses",S,h,t("span",{class:"dl-suffixed"},[S,t("span",{class:"dl-mono"},".x")]))})()]),fe("shield","Disguise","So networks that block VPNs do not recognise the tunnel. Off = plain WireGuard",[hn(e.awg,a.preset,S=>a.preset=S,void 0,e.awg_state?.tools!==!1)])]),check:()=>{let S=d();if(S.bad)return`UDP port: ${S.text}`;let T=h();return T.bad?`Device addresses: ${T.text}`:null}},y={id:"portal",title:"Portal",render:()=>{let S=B("portal_port",{inputmode:"numeric",class:"cbi-input-text dl-w-port dl-mono"}),T=he("Listening port",S,m);T.hidden=!a.portal;let N=we([["off","Off"],["on","On"]],a.portal?"on":"off",{label:"Personal portal",onChange:W=>{a.portal=W==="on",T.hidden=!a.portal}});return t("div",{class:"dl-wizard-groups"},[fe("home","Internet like a home device","How devices reach the internet",[ce("Through the home network",ve(a.lan_like,"Internet like a home device",W=>a.lan_like=W),"Whatever handles home traffic on this router (proxies, filters, DNS) handles theirs too. Change it later under Servers → Access.")]),fe("link","Personal portal","A page where each person adds their own devices with their personal link",[ce("Portal",N,"Off: only you add devices, from LuCI. On: people manage their devices within the limits you set."),T])])},check:()=>{if(!a.portal)return null;let S=m();return S.bad?`Portal port: ${S.text}`:null}},E=()=>[w,v,r?null:y].filter(S=>S!=null),k=e.awg_state,z=k?.missing??[],f=z.length?t("div",{class:"dl-list dl-notices"},[Xe("shield","bad","AmneziaWG isn’t installed",`The tunnel needs ${z.join(" and ")}. Install the build made for this firmware, then create the server.`,H("Install",()=>Sn(()=>location.reload()),"positive"))]):k&&!k.loaded?t("div",{class:"dl-list dl-notices"},[Xe("shield","warn","AmneziaWG’s kernel module doesn’t load on this firmware","Try another build in Components, or update OpenWrt. The server can’t start until it loads.",t("a",{class:"cbi-button cbi-button-neutral",href:L.url("admin/network/dawnline/updates")},"Open Components"))]):"",g=()=>{let S=E();i>=S.length&&(i=S.length-1),dom.content(C,[t("h2",{},r?"Add a server":"Set up Dawnline"),f,t("div",{class:"dl-steps"},S.map((T,N)=>t("span",{class:`dl-step${N===i?" current":N0?H("Back",()=>{i--,g()}):o?H("Cancel",o):"",t("span",{class:"dl-spacer"}),i{let T=S[i].check?.();if(T){U(T,"warning");return}i++,g()},"positive"):H("Create server",async()=>{for(let N of S){let W=N.check?.();if(W){U(W,"warning");return}}let T=await G(()=>A.serverCreate(a.id,a.name,e.ifname,a.port,an(a.range),a.endpoint,e.mtu,a.preset,a.lan_zone,a.wan_zone,a.lan_like,r?void 0:a.portal,r?void 0:a.portal_port),"Server created");T&&(T.network_restart&&U("Restarting the network so it knows AmneziaWG: back in a few seconds"),setTimeout(()=>{location.href=ko(T.id)},T.network_restart?1e4:1500))},"positive",{disabled:z.length>0,title:z.length?"Install AmneziaWG first":null})])])};return g(),C}};function lt(n){let e={el:n(),refresh(){let r=n();e.el.replaceWith(r),e.el=r}};return e}function Re(n,e,r,o,a="",i=[]){return t("section",{class:`dl-setsec ${a}`,id:`dl-set-${n}`},[t("div",{class:"dl-setsec-body"},[i.length?t("div",{class:"dl-setsec-head"},[t("h3",{},e),t("span",{class:"dl-spacer"}),...i]):t("h3",{},e),...r]),o.length?t("div",{class:"dl-setsec-foot"},o):""])}function ga(n){let e=n.filter(a=>a.status!=="skip"),r=e.filter(a=>a.status==="error"||a.status==="warn"),o=e.some(a=>a.status==="error")?"error":r.length?"warn":"ok";return{bad:r,worst:o}}function va(n){let e=n.d.settings,r=n.d.effective,o=n.d.cert,a=ve(r.portal_enabled,"Enable portal"),i=se(e.portal_port,{placeholder:"8443",inputmode:"numeric",class:"cbi-input-text dl-w-port"}),s=se(e.portal_title,{placeholder:"Dawnline"}),l=se(e.portal_redirect,{placeholder:"Show “Not found”",class:"cbi-input-text dl-mono"}),d=se("",{placeholder:"vpn.example.com or an IP","aria-label":"Other address"}),c=O=>/^\d{1,3}(\.\d{1,3}){3}$/.test(O),p=[r.portal_host,...r.portal_alt??[]].filter((O,X,P)=>O&&P.indexOf(O)===X),u=!!n.portal,x=[],$=O=>{O&&!x.some(X=>X.host===O)&&x.push({host:O,kind:c(O)?"ip":"name",ips:[],here:!1,cloudflare:!1,cert:!1})},h=O=>{x=[...O,...x.filter(X=>!O.some(P=>P.host===X.host))],!p.length&&O[0]&&(p=[O[0].host])};n.portal&&h(n.portal.candidates),p.forEach($);let m=O=>O.kind==="ip"?t("span",{class:"dl-addr-warn"},[b("alert"),"Plain HTTP: the link and VPN keys travel unencrypted"]):t("span",{class:"dl-sub"},O.cloudflare?"Behind Cloudflare · often stalls in Russia":O.ips.length?O.here?`Points at this router${O.cert?" · Let’s Encrypt certificate":" · no certificate yet"}`:`Points at ${O.ips.join(", ")}, not this router`:u?"Your address":"Checking where it points…"),C=t("div",{class:"dl-addr-opts",role:"group","aria-label":"Portal addresses"}),B=O=>{p.includes(O)?p.length>1&&(p=p.filter(X=>X!==O)):p=[...p,O],w(),E()},w=()=>dom.content(C,[...x.map(O=>{let X=p.includes(O.host),P=p[0]===O.host;return t("div",{class:`dl-addr-opt${X?" on":""}`,role:"checkbox","aria-checked":X?"true":"false",tabindex:"0",click:()=>B(O.host),keydown:D=>{(D.key===" "||D.key==="Enter")&&(D.preventDefault(),B(O.host))}},[t("i",{class:"dl-addr-check"},X?b("check"):""),t("span",{class:"dl-stack"},[t("span",{class:"dl-mono"},O.host),m(O)]),P?t("span",{class:"dl-pill info"},"Main"):X?t("button",{type:"button",class:"dl-linkbtn",click:D=>{D.stopPropagation(),p=[O.host,...p.filter(_=>_!==O.host)],w(),E()}},"Make main"):O.cloudflare?t("span",{class:"dl-pill warn"},"Cloudflare"):O.kind==="ip"?t("span",{class:"dl-pill"},"IP"):O.here&&O.cert?t("span",{class:"dl-pill ok"},"Recommended"):""])}),t("div",{class:"dl-addr-opt other"},[t("i",{class:"dl-addr-check"},b("plus")),d,H("Add",()=>{let O=d.value.trim().toLowerCase();if(!O)return;let X=kt(O);if(X.bad){U(X.text,"warning");return}$(O),p.includes(O)||(p=[...p,O]),d.value="",w(),E()})])]);d.addEventListener("keydown",O=>{O.key==="Enter"&&(O.preventDefault(),d.nextElementSibling?.click())});let v=t("div",{class:"dl-links"}),y=()=>{},E=()=>{y();let O=Number(i.value)||r.portal_port;dom.content(v,p.map((X,P)=>{let D=c(X),_=D?O+1:O,I=`${D?"http":"https"}://${X}${_===(D?80:443)?"":`:${_}`}/`;return t("div",{class:"dl-link-row"},[t("span",{class:`dl-link-ic ${D?"warn":"ok"}`},b(D?"alert":"lock")),t("span",{class:"dl-mono dl-link-url"},[I,t("b",{},"kamiro-telosu-bavine")]),P===0?t("span",{class:"dl-pill info"},"Main"):D?t("span",{class:"dl-pill warn"},"HTTP"):""])}))};w(),E(),i.addEventListener("input",()=>E());let k={portal:"Portal running",portal_dns:"Points here",portal_reply:"Answers reach visitors",portal_http:"Plain HTTP",cert:"Certificate"},z=n.d.needs??{https:[],acme:[],home:[]},f=O=>{if(!r.portal_enabled)return t("div",{hidden:!0});if(!O)return fe("check","Ready to share","The portal’s checks from Health",[t("p",{class:"dl-muted dl-loading"},"Running checks…")]);let X=O.filter(M=>M.status!=="skip");if(!X.length)return t("div",{hidden:!0});let{bad:P,worst:D}=ga(O),_=t("div",{class:"dl-ready-details",hidden:!0},X.map(M=>t("div",{class:`dl-ready-item ${M.status}`},[b(M.status==="ok"?"check":"alert"),t("span",{class:"dl-stack"},[t("span",{},M.title),t("span",{class:"dl-sub"},M.detail)])]))),I=t("div",{class:"dl-stack gap8"},[t("div",{class:`dl-ready-sum ${D}`},[b(D==="ok"?"check":"alert"),t("span",{class:"dl-stack"},[t("b",{},D==="ok"?`All ${X.length} checks passed`:`${X.length-P.length} of ${X.length} checks passed`),P.length?t("span",{class:"dl-sub"},P.map(M=>M.detail).join(" ")):t("span",{class:"dl-sub"},"Links will open for the people you send them to.")]),t("button",{type:"button",class:"dl-linkbtn",click:M=>{_.hidden=!_.hidden,M.currentTarget.textContent=_.hidden?"Details":"Hide"}},"Details")]),t("div",{class:"dl-chips-row"},X.map(M=>t("span",{class:`dl-check-chip ${M.status}`,title:M.detail},[b(M.status==="ok"?"check":"alert"),k[M.id]??M.title]))),_]);return fe("check","Ready to share","The portal’s checks from Health",[I])},g=O=>{if(!r.portal_enabled||!O&&!z.https.length)return t("span",{hidden:!0});if(z.https.length)return t("span",{class:"dl-pill bad"},"Can’t start");let{worst:X}=ga(O);return t("span",{class:`dl-pill ${X==="ok"?"ok":X==="error"?"bad":"warn"}`},X==="error"?"Needs attention":"Ready")},S=f(n.portal?.checks??null),T=g(n.portal?.checks??null);n.portalFill=O=>{u=!0,h(O.candidates),w(),E();let X=f(O.checks);S.replaceWith(X),S=X;let P=g(O.checks);T.replaceWith(P),T=P};let N=o&&!o.self_signed&&o.expires?Ue(o.expires):"",W=he("Listening port",i,()=>sn(i.value.trim()===""?r.portal_port:Number(i.value),n.d.tcp_taken??[],p.some(c)));y=W.refresh;let q=he("Title",s,()=>Zo(s.value)),Y=he("Unknown links",l,()=>Yo(l.value)),R=!!(e.portal_cert&&e.portal_key),K=o?R?"Your files":o.self_signed?"Self-signed":"Let’s Encrypt":"Portal is off",Z=()=>{let O=se(e.portal_cert,{placeholder:"/etc/ssl/…/fullchain.crt"}),X=se(e.portal_key,{placeholder:"/etc/ssl/…/key"});oe("Use your own certificate",[t("p",{class:"dl-muted"},"Paths on the router. Leave both empty to pick a certificate automatically."),ce("Certificate file",O),ce("Key file",X)],[ie()," ",H("Save",()=>{ae(),n.save({portal_cert:O.value.trim(),portal_key:X.value.trim()},"Certificate saved","portal")},"positive")])},de=(O,X,P,D,_,I)=>Xe(O,X,P,D,H(I,()=>Yt(_,z[_],()=>n.reload("portal")),"positive")),Q=z.https.length?de("lock","bad","HTTPS isn’t available on this router",`The portal needs ${z.https.join(" and ")}. It can’t start without them.`,"https","Install"):"",te=z.acme.length&&(!o||o.self_signed)?de("lock","","Free certificate from Let’s Encrypt",`ACME isn’t installed. With it the router gets a certificate${e.portal_host?` for ${e.portal_host}`:""} and browsers stop warning.`,"acme","Install ACME"):"",ge=[t("div",{class:"dl-row"},[b("lock"),t("span",{class:"dl-row-main dl-stack"},[t("b",{},[K,N?t("span",{class:"dl-faint"},` · until ${N}`):""]),t("span",{class:"dl-sub dl-ellipsis",title:o?.path??""},o?o.self_signed?"Made by the router: browsers warn until a certificate covers the address.":`${R?"Your files":"Found automatically"} · ${o.path}`:"Turn the portal on to see its certificate.")])]),t("div",{class:"dl-row"},[b("file"),t("span",{class:"dl-row-main dl-stack"},[t("b",{},"Your own files"),t("span",{class:"dl-sub"},R?`${e.portal_cert} · ${e.portal_key}`:"Not set: the certificate is picked automatically.")]),R?H("Reset",()=>n.save({portal_cert:"",portal_key:""},"Automatic certificate","portal"),"negative"):"",H(R?"Change":"Use files",Z)]),te];return Re("portal","Personal portal",[t("span",{class:"dl-muted"},"A page where each person adds and manages their devices with their personal link."),Q?t("div",{class:"dl-list"},[Q]):"",fe("network","Port","How the portal listens (80 and 443 stay free)",[W]),fe("edit","Appearance","What people see",[q,Y]),fe("link","Addresses","Pick one or more; the first is the main link",[C,t("div",{class:"dl-stack gap8"},[v,t("span",{class:"dl-sub"},"Example code; each person gets their own three words.")])]),fe("lock","Certificate","Used for HTTPS links",ge),S],[t("span"),H("Save",()=>{let O=ze([W,q,Y]);if(O){U(O,"warning");return}return n.save({portal_enabled:Pe(a)?"1":"0",portal_host:p[0]??"",portal_alt:p.slice(1),portal_port:i.value,portal_title:s.value,portal_redirect:l.value.trim()},"Saved","portal")},"positive")],"",[T,a])}function ba(n){let e=n.d.settings,r=n.d.effective,o=se(e.default_device_limit,{placeholder:"3",inputmode:"numeric",class:"cbi-input-text dl-w-port"}),a=ve(r.hostnames,"Device hostnames"),i=se(e.domain,{placeholder:"lan",class:"cbi-input-text dl-w-port"}),s=se(e.home_dns_fallback==="none"?"":e.home_dns_fallback||r.home_dns_fallback||"",{placeholder:"None",inputmode:"decimal",class:"cbi-input-text dl-w-ip dl-mono"}),l=he("Devices per person",o,()=>{if(!o.value.trim())return{text:"The default, 3. Pre-filled when you add someone.",bad:!1};let p=ln(o.value);return p.bad?p:{text:"Pre-filled when you add someone.",bad:!1}}),d=he("Device hostnames",i,()=>Qo(i.value),t("div",{class:"dl-hostport"},[a,t("span",{class:"dl-faint dl-mono"},"phone.myata."),i])),c=he("Fallback DNS",s,()=>{let p=Xo(s.value);return p.bad?p:{text:`For Home-only devices using home names: ${p.text}`,bad:!1}});return Re("defaults","New people",[l,d,c],[t("span"),H("Save",()=>{let p=ze([l,d,c]);if(p){U(p,"warning");return}return n.save({default_device_limit:o.value,hostnames:Pe(a)?"1":"0",domain:i.value,home_dns_fallback:s.value},"Saved","defaults")},"positive")])}function xa(n){let e=n.d.effective,r=ve(e.geo_enabled,"Locations"),o=t("select",{class:"cbi-input-select"},[t("option",{value:"ipwho.is",selected:e.geo_provider!=="ipapi.co"?"selected":null},"ipwho.is (fallback: ipapi.co)"),t("option",{value:"ipapi.co",selected:e.geo_provider==="ipapi.co"?"selected":null},"ipapi.co (fallback: ipwho.is)")]);return Re("map","Map & locations",[t("div",{class:"dl-setrow head"},[t("span",{class:"dl-muted"},"Show where people connect from on the Overview and person pages, at city level."),r]),ce("Provider",o)],[t("span",{class:"dl-sub"},"The router sends each new client IP to the provider once and caches the city. Map tiles load in your browser from CARTO; people never see the map."),H("Save",()=>n.save({geo_enabled:Pe(r)?"1":"0",geo_provider:o.value},"Saved","map"),"positive")])}var Ws=[["app","Dawnline"],["amneziawg","AmneziaWG"],["packages","System packages"]];function wa(n){let e=n.d.effective.updates,r=ve(e.check,"Check automatically",h=>$(h,Pe(a))),o=we([["6h","Every 6 h"],["12h","Every 12 h"],["1d","Daily"],["7d","Weekly"]],e.interval,{label:"How often",cls:"sm"}),a=ve(e.auto,"Install automatically",h=>$(Pe(r),h)),i=se(e.time,{placeholder:"04:00",inputmode:"numeric",class:"cbi-input-text dl-w-port dl-mono","aria-label":"Time"}),s=we([["scheduled","At a set time"],["immediate","As soon as found"]],e.mode,{label:"When",cls:"sm",onChange:h=>i.hidden=h!=="scheduled"});i.hidden=e.mode!=="scheduled";let l=new Set(e.targets),d=t("div",{class:"dl-chips-row"},Ws.map(([h,m])=>{let C=qe(m,l.has(h),()=>{l.delete(h)||l.add(h),un(C,l.has(h))});return C})),c=ve(e.keep,"Keep the previous version"),p=ve(e.mirrors,"GitHub mirrors"),u=ce("How often",o),x=[ce("When",t("div",{class:"dl-hostport"},[s,i]),"A set time keeps tunnel restarts out of the evening; the run happens within an hour of it."),ce("Components",d,"AmneziaWG is off by default: a new kernel module restarts every tunnel.")],$=(h,m)=>{u.hidden=!h;for(let C of x)C.hidden=!m};return $(e.check,e.auto),Re("updates","Updates",[t("span",{class:"dl-muted"},"How Dawnline keeps its components current. Every Dawnline update makes a backup of the settings first."),ce("Check automatically",r,"Looks for new versions in the background; Components shows what it found and the service log names it."),u,ce("Install automatically",a,"Downloads and installs new versions of the components below."),...x,ce("Keep the previous version",c,"Saves the replaced Dawnline or AmneziaWG package on flash, so Roll back works without internet. Under 1 MB."),ce("GitHub mirrors",p,"When GitHub is unreachable, download through mirrors. Checksums are still verified.")],[t("span",{class:"dl-sub"},"Run a check or an update by hand in Components."),H("Save",()=>{if(s.dataset.value==="scheduled"){let h=er(i.value);if(h.bad){U(`Time: ${h.text}`,"warning");return}}return n.save({update_check:Pe(r)?"1":"0",update_interval:o.dataset.value,update_auto:Pe(a)?"1":"0",update_mode:s.dataset.value,update_time:i.value.trim(),update_targets:[...l],update_keep:Pe(c)?"1":"0",update_mirrors:Pe(p)?"1":"0"},"Saved","updates")},"positive")])}function ya(n){let e=n.d.logs,r=e.policy,o=we([["7","7 days"],["30","30 days"],["90","90 days"],["365","1 year"],["0","No limit"]],String(r.keep_days),{label:"Keep activity",cls:"sm"}),a=we([["500","500"],["2000","2,000"],["5000","5,000"],["20000","20,000"]],String(r.max),{label:"Maximum events",cls:"sm"}),i=we([["10min","Every 10 min"],["hourly","Hourly"],["off","Memory only"]],r.persist,{label:"Save to flash",cls:"sm"}),s=we([["31","1 month"],["62","2 months"],["180","6 months"],["365","1 year"],["730","2 years"]],String(r.usage_days),{label:"Daily traffic",cls:"sm"}),l=we([["12","1 year"],["24","2 years"],["60","5 years"],["120","10 years"]],String(r.usage_months),{label:"Monthly traffic",cls:"sm"}),d=new Set(r.categories),c=t("div",{class:"dl-chips-row"},Mt.map($=>{let h=qe([ut[$],t("b",{},String(e.by_category[$]??0))],d.has($),()=>{d.delete($)||d.add($),un(h,d.has($))},{title:sr[$]});return h})),p=e.oldest?Ue(new Date(e.oldest*1e3)):"",u=($,h,m,C)=>t("div",{class:"dl-row"},[b($),t("span",{class:"dl-row-main dl-stack"},[t("b",{},h),t("span",{class:"dl-sub"},m)]),...C]),x=$=>H($.toUpperCase(),async()=>{let[h,m]=await Promise.all([A.status(1),A.events(2e4)]);Fe(h,m.events,$)},"neutral",{title:`Download the log as ${$.toUpperCase()}`});return Re("logs","Logs & history",[t("p",{class:"dl-muted"},pn(r)),ce("Keep activity",o,"Older events are removed automatically."),ce("Maximum size",a,"Newest events are kept when the log is full."),ce("Record",c,"Switched-off categories are not logged from now on."),ce("Save to flash",i,"The log lives in memory and is copied to flash. Memory only saves flash writes but is lost on reboot."),ce("Daily traffic",s,"Per-day history behind the charts."),ce("Monthly traffic",l,"Per-month totals; data limits use the current month."),t("h4",{class:"dl-setsub"},"Stored data"),t("div",{class:"dl-list"},[u("activity","Activity log",e.events?`${tn(e.events,"event")} since ${p} · ${Nt(e.log_ram)} in memory${r.persist==="off"?"":`, ${Nt(e.log_flash)} on flash`}`:"Empty",[x("csv"),x("json"),H("Clear",()=>tt("Clear activity","Removes events from the log on the router.",{},()=>n.reload("logs")),"negative")]),u("chart","Traffic history",e.usage_days?`${tn(e.usage_days,"day")} since ${Ue(e.usage_since)} · ${Nt(e.usage_flash)} on flash`:"Empty",[H("Reset",()=>St("all","","",()=>setTimeout(()=>n.reload("logs"),300)),"negative")]),u("pin","Location cache",`${tn(n.d.geo_cached,"address","addresses")} · ${Nt(e.geo_flash)} on flash`,[H("Clear",async()=>{await G(()=>A.geoClear(),"Location cache cleared")&&await n.reload("logs")},"negative")])])],[t("span",{class:"dl-sub"},"Clear one person or device from their own page."),H("Save",()=>n.save({log_keep_days:o.dataset.value,log_max:a.dataset.value,log_persist:i.dataset.value,usage_keep_days:s.dataset.value,usage_keep_months:l.dataset.value,log_category:[...d]},"Saved","logs"),"positive")])}var Fs={manual:"Manual",auto:"Nightly","pre-restore":"Before restore","pre-import":"Before import","pre-delete":"Before removing a server","pre-update":"Before update"},ka=3;function $o(n){let e=new Date(n*1e3),r=e.toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit"}),o=Math.round((new Date(new Date().toDateString()).getTime()-new Date(e.toDateString()).getTime())/864e5);return`${o===0?"Today":o===1?"Yesterday":e.toLocaleDateString("en-GB",{day:"numeric",month:"short"})}, ${r}`}async function qs(n){let e=await G(()=>A.backupRead(n.name));if(!e)return;let r=atob(e.data),o=new Uint8Array(r.length);for(let i=0;iqs(n),"neutral","dl-icon-only"),Le("more","More",r=>Ce(r.currentTarget,[{label:"Restore",icon:b("reset"),run:async()=>{await le("Restore this backup?",`Everything returns to ${$o(n.created)}. The current state is backed up first.`,"Restore",!0)&&await G(()=>A.backupRestore(n.name),"Restored")&&e(!0)}},{label:"Delete",icon:b("trash"),danger:!0,run:async()=>{await le("Delete this backup?",`The backup from ${$o(n.created)} is removed from the router.`,"Delete",!0)&&await G(()=>A.backupDelete(n.name),"Backup deleted")&&e()}}]),"neutral","dl-icon-only")])])}function Ca(n,e){let r=n.slice(0,ka).map(d=>$a(d,e)),o=n.slice(ka),a=n.length?t("div",{class:"dl-list"},[...r,o.length?t("details",{class:"dl-bk-older"},[t("summary",{},[b("chevron"),`${o.length} older backup${o.length===1?"":"s"}`]),...o.map(d=>$a(d,e))]):""]):t("div",{class:"dl-list"},[t("div",{class:"dl-row dl-muted"},"No backups yet.")]),i=H("Restore from file",async()=>{let d=await Fn(".tar.gz,.tgz,application/gzip","base64");if(!d)return;await le("Restore from file?",`Replace the current Dawnline configuration with ${d.name}? The current state is backed up first.`,"Restore",!0)&&await G(()=>A.backupUpload(d.data),"Restored")&&e(!0)}),s=H("Export JSON",async()=>{let d=await G(()=>A.exportJson());d&&Te(`dawnline-export-${new Date().toISOString().slice(0,10)}.json`,JSON.stringify(d,null,2),"application/json")}),l=H("Import JSON",async()=>{let d=await Fn(".json,application/json","text");if(!d)return;let c;try{c=JSON.parse(d.data)}catch{U("Not a JSON file.","error");return}await le("Import?","This replaces the whole Dawnline configuration on this router. The current state is backed up first.","Import",!0)&&await G(()=>A.importJson(c),"Imported")&&e(!0)});return t("section",{class:"dl-setsec",id:"dl-set-backups"},[t("div",{class:"dl-setsec-body"},[t("div",{class:"dl-setsec-head"},[t("div",{class:"dl-stack"},[t("h3",{},"Backups"),t("span",{class:"dl-sub"},"Nightly when something changed, and before every restore, import or update. The last 10 are kept.")]),t("span",{class:"dl-spacer"}),H([b("plus")," Back up now"],async()=>{await G(()=>A.backupCreate(),"Backup created")&&e()},"positive")]),a]),t("div",{class:"dl-setsec-foot"},[t("span",{class:"dl-sub"},"Backups contain private keys: keep downloads safe. JSON moves everything except usage history to another router."),t("span",{class:"dl-row-actions dl-bk-actions"},[i,s,l])])])}function Ks(){let n=se("",{placeholder:"remove"}),e=H("Remove Dawnline",async()=>{await G(()=>A.uninstall(n.value.trim()),"Dawnline removed")&&(ae(),setTimeout(()=>location.reload(),800))},"negative",{disabled:!0});n.addEventListener("input",()=>{e.disabled=n.value.trim()!=="remove"}),oe("Remove Dawnline?",[t("p",{},"Everyone is disconnected and the tunnel, firewall rules and portal are removed. A backup is made first. Type “remove” to confirm."),n],[ie()," ",e])}function Ea(){return Re("danger","Remove Dawnline from this router",[t("p",{class:"dl-muted"},"Deletes the tunnel, firewall rules, access table and hostnames Dawnline created, and stops the service. People and keys are kept in a backup.")],[t("span"),H("Remove",()=>Ks(),"negative")],"danger")}var Hn=class{constructor(){this.root=t("div",{class:"dl-settings-main"});this.backups=[];this.portal=null;this.portalSeq=0;this.cards={}}load(){return A.settingsGet()}render(e){this.d=e,this.cards={portal:lt(()=>va(this)),defaults:lt(()=>ba(this)),map:lt(()=>xa(this)),updates:lt(()=>wa(this)),logs:lt(()=>ya(this)),backups:lt(()=>Ca(this.backups,a=>this.loadBackups(a))),danger:lt(()=>Ea())};let r=["portal","defaults","map","updates","logs","backups","danger"];dom.content(this.root,r.map(a=>this.cards[a].el)),this.loadBackups().then(()=>{new URLSearchParams(location.search).get("section")==="backups"&&document.getElementById("dl-set-backups")?.scrollIntoView({block:"start"})}),this.loadPortal();let o=new URLSearchParams(location.search).get("section");return o&&o!=="backups"&&requestAnimationFrame(()=>document.getElementById(`dl-set-${o}`)?.scrollIntoView({block:"start"})),t("div",{},[t("div",{class:"dl-pagehead"},[t("h2",{class:"dl-h1"},"Settings")]),this.root])}async save(e,r,o){let a=await G(()=>A.settingsUpdate(e),r);a&&(this.d=a,this.cards[o].refresh(),o==="portal"&&this.loadPortal())}async loadPortal(){let e=++this.portalSeq,r=await A.portalInfo().catch(()=>null);e===this.portalSeq&&(this.portal=r??this.portal??{candidates:[],checks:[]},this.portalFill?.(this.portal))}async loadBackups(e=!1){e&&await this.reload();let r=await A.backupList().catch(()=>null);r&&(this.backups=r.backups,this.cards.backups?.refresh())}async reload(e){let r=await A.settingsGet().catch(()=>null);if(r){if(this.d=r,e)this.cards[e].refresh();else for(let o of Object.values(this.cards))o.refresh();(!e||e==="portal")&&this.loadPortal()}}};function La(n,e=!1){return n&&(e?/^https?:\/\//i:/^https:\/\//i).test(n)?n:null}function Ma(n){let e=[],r=l=>{let d=[],c=/(`[^`]+`)|(\*\*[^*]+\*\*)|(\[[^\]]+\]\((https?:\/\/[^)\s]+)\))|(https?:\/\/[^\s<>()]+[^\s<>().,;:!?])/g,p=0;for(let u;u=c.exec(l);)u.index>p&&d.push(l.slice(p,u.index)),u[1]?d.push(t("code",{},u[1].slice(1,-1))):u[2]?d.push(t("b",{},u[2].slice(2,-2))):u[3]?d.push(t("a",{href:u[4],target:"_blank",rel:"noopener"},u[3].replace(/^\[|\]\(.*$/g,""))):u[5]&&d.push(t("a",{href:u[5],target:"_blank",rel:"noopener"},u[5].replace(/^https?:\/\/(github\.com\/)?/,""))),p=u.index+u[0].length;return p{a.length&&e.push(t("p",{},r(a.join(" ")))),a=[],o=null};for(let l of n.replace(/\r/g,"").split(` +`,fr(s,e)]:[fr(s,e)])),a=t("button",{type:"button",class:"dl-chipbtn",click:s=>{s.preventDefault(),e=!e,dom.content(a,[v(e?"x":"key"),e?"Hide key":"Show key"]),o()}},[v("key"),"Show key"]);o();let i=new Blob([n.conf]).size;return t("div",{class:"dl-stack gap8"},[t("div",{class:"dl-filecard"},[t("span",{class:"dl-filecard-ic"},".conf"),t("span",{class:"dl-stack"},[t("span",{class:"dl-mono dl-ellipsis"},n.filename),t("span",{class:"dl-sub"},`AmneziaWG · ${i} bytes`)]),D([v("download")," Download"],()=>Te(n.filename,n.conf,"application/octet-stream"),"positive")]),t("details",{class:"dl-params"},[t("summary",{},[v("chevron"),t("span",{},"Configuration"),t("span",{class:"dl-spacer"}),a,t("button",{type:"button",class:"dl-chipbtn",click:s=>{s.preventDefault(),me(n.conf,"Configuration copied")}},[v("copy"),"Copy"])]),r])])}function no(n){let e=n.amnezia.obfuscation??{},r={h1:"1",h2:"2",h3:"3",h4:"4"};return Object.entries(e).every(([o,a])=>a==null||a===""||a===(r[o]??"0"))}async function rs(n,e="file"){if(!n.has_private_key)return t("div",{class:"dl-hint"},"This device generated its own keys in the browser, so its full configuration only exists on that device.");let r=await to(n,n.server),o={qr:()=>t("div",{class:"dl-qr-pane"},[an(n.conf),t("span",{class:"dl-sub"},no(n)?"Scan with AmneziaVPN or any WireGuard app on the device.":"Scan with AmneziaVPN or AmneziaWG on the device.")]),key:()=>t("div",{class:"dl-stack gap8"},[t("div",{class:"dl-linkbox"},[t("span",{class:"dl-mono"},r),D("Copy",()=>me(r,"Key copied"))]),t("span",{class:"dl-sub"},"AmneziaVPN → Add server → Insert key. Keep it private.")]),file:()=>os(n)},a=t("div",{class:"dl-connect-body"}),i=t("div",{class:"dl-seg"}),s=l=>{i.querySelectorAll("button").forEach(d=>d.classList.toggle("on",d.dataset.id===l)),dom.content(a,o[l]())};for(let[l,d]of[["file","File"],["key","Key"],["qr","QR code"]])i.appendChild(t("button",{type:"button","data-id":l,click:()=>s(l)},d));return s(e),t("div",{class:"dl-stack gap12"},[i,a])}async function as(n,e,r,o){let a=Ot(r),s=n.st.people.filter(d=>d.server===e.id).reduce((d,c)=>d+c.devices.length,0);await se(o?"Generate new disguise values?":`Switch to ${a.title}?`,`${s} AmneziaWG device${s===1?" stops":"s stop"} connecting until ${s===1?"it imports its":"they import their"} configuration again (from their personal link or from you).${r==="max"?" They need an app with AmneziaWG 3.1.":r==="balanced"?" They need an app with AmneziaWG 2.0 or newer.":""}${n.st.servers.length===1&&s?" To keep the old disguise for some people, add a second server and move them there.":""}`,o?"Generate and apply":"Switch and apply",!0)&&await G(()=>P.serverObfuscation(e.id,r),o?"New values applied":`${a.title} applied`)&&(U("Devices are marked “Update config” until they import again.","info",6e3),await n.refresh())}function is(n,e){let r=n.st,o=le(String(e.port),{inputmode:"numeric",class:"cbi-input-text dl-w-port dl-mono"}),a=le(e.mtu?String(e.mtu):"",{placeholder:"Auto",inputmode:"numeric",class:"cbi-input-text dl-w-port dl-mono"}),i=le(String(e.keepalive??""),{placeholder:"25",inputmode:"numeric",class:"cbi-input-text dl-w-port dl-mono"}),s=Ot(e.preset)?e.preset:void 0,l=s??fn(r.awg),d=D("",()=>as(n,e,l,l===s),"neutral"),c=()=>dom.content(d,l===s?[v("reset")," Generate new values"]:[`Switch to ${Ot(l).title}`]);c();let p=r.awg_state?.tools!==!1,u=[],x=ge("UDP port",o,()=>Rt(Number(o.value),u,`Opened on the WAN firewall automatically.${Number(o.value)===4500?" 4500 is IPsec’s port: most networks let it through.":""}`));P.serverPorts(e.id).then(m=>{u=m.udp_taken??[],x.refresh()}).catch(()=>{});let $=ge("MTU",a,()=>Zo(a.value,e.mtus)),h=ge("Keep-alive",i,()=>Qo(i.value));return Nt("",[mr("AmneziaWG",e.ifname),fe("globe","Listening","Where devices reach this core from the internet",[x]),fe("file","In every device configuration","Changing these marks devices “Update config” until they import again",[$,h]),fe("shield","Disguise","So networks that block VPNs do not recognise the tunnel. Off = plain WireGuard",[jt(e.preset)?ct("warn",[t("b",{},jt(e.preset))," is AmneziaWG 1.0 junk only, which networks learned to spot; it is not offered any more. Switch to ",t("b",{},"Balanced")," or ",t("b",{},"Maximum"),": devices import their configuration again."]):"",gn(r.awg,l,m=>{l=m,c()},s,p),p&&!r.awg.v3?ct("info",["This router runs an older AmneziaWG. ",t("b",{},"Maximum")," becomes available with kmod-amneziawg and amneziawg-tools 3.1."]):"",ns(e.obf??{})??"",t("div",{class:"dl-row-end"},[t("span",{class:"dl-sub"},"Applies at once: every AmneziaWG device imports its configuration again."),d])]),t("details",{class:"dl-params"},[t("summary",{},[v("chevron"),t("span",{},"Tunnel"),t("span",{class:"dl-pcount"},"3")]),t("div",{class:"dl-params-body"},[ce("Interface",t("span",{class:"dl-mono"},`${e.ifname} · router ${e.address}`)),ce("Tunnel subnet",t("span",{class:"dl-mono"},e.subnet),"Device addresses come from it."),ce("Server public key",t("span",{class:"dl-keyrow"},[t("code",{class:"dl-mono"},e.public_key),D([v("copy")],()=>me(e.public_key,"Public key copied"),"neutral",{title:"Copy",class:"cbi-button cbi-button-neutral dl-icon-only sm"})]))])])],[t("span",{class:"dl-sub"},"Port, MTU and keep-alive apply at once."),D("Save",()=>{let m=ze([x,$,h]);if(m){U(m,"warning");return}return n.save({port:o.value,mtu:a.value,keepalive:i.value},"AmneziaWG saved")},"positive")])}function ss(n){let e=Ot(n.preset),r=n.obf??{},o=(s,l)=>t("span",{class:`dl-segs ${l}`},[0,1,2,3].map(d=>t("i",{class:d+r[s]).map(s=>`${s.toUpperCase()} ${r[s]}`);return i.length&&a.push(i.slice(0,2).join(" · ")+(i.length>2?` +${i.length-2}`:"")),["h1","h2","h3","h4"].some(s=>r[s]&&r[s]!==String(["h1","h2","h3","h4"].indexOf(s)+1))&&a.push("H1–H4 random"),r.i1&&a.push(/0x(8580|0100)0001/.test(r.i1)?"DNS-like first packets":"Signature packets"),r.header_protection_key&&a.push("Encrypted headers"),a.length||a.push(e?.id==="off"?"Plain WireGuard":"No values yet"),t("div",{class:"dl-bento-tile dl-disg"},[t("div",{class:"dl-bento-head"},[t("span",{class:"dl-metric-label"},"Disguise"),t("a",{href:`${L.url("admin/network/dawnline/server")}?server=${encodeURIComponent(n.id)}§ion=awg`},"Change")]),t("div",{class:"dl-disg-id"},[t("span",{class:`dl-disg-ic${e?.id==="off"?" off":""}`},v(e?.ic??"shield")),t("span",{class:"dl-stack"},[t("b",{},e?e.title:jt(n.preset)??"Custom"),t("span",{class:"dl-sub"},e?e.short:jt(n.preset)?"Switch to Balanced or Maximum":"Set by hand")])]),e?t("div",{class:"dl-disg-meters"},[t("span",{},"Stealth"),o(e.stealth,"acc"),t("span",{},"Speed"),o(e.speed,"ok")]):"",t("div",{class:"dl-disg-chips"},a.map(s=>t("span",{},s)))])}var oo={id:"awg",label:"AmneziaWG",settingsCard:is,overviewTile:ss,connectBlock:rs,qrText:n=>n.conf,appKey:{label:"Copy AmneziaVPN config",make:n=>to(n,n.server)},file:{label:"Download AmneziaWG config",make:n=>({name:n.filename,text:n.conf})}};var ls={awg:oo};function Be(n){return ls[n?.core||"awg"]??oo}function St(n,e){return Be(n.find(r=>r.id===e))}var ds=2,Ut=new Set,ro=null,vn=null;async function gr(){if(document.visibilityState!=="visible"||!Ut.size)return;let n=await P.rev().catch(()=>null);if(!n)return;let e=ro!=null&&n.rev!==ro;ro=n.rev,n.version&&(vn&&n.version!==vn?(U(`Dawnline was updated to ${n.version}: reload the page.`,"warning",15e3),vn=null):vn??(vn=n.version)),e&&Ut.forEach(r=>r())}function bn(n){return Ut.add(n),poll.add(gr,ds),()=>{Ut.delete(n),Ut.size||poll.remove(gr)}}function xr(n,e,r,o,a=0){let i=[],s=null,l=p=>{s&&p>s.from&&i.push({...s,to:p}),s=null},d=n.filter(p=>p.device===e).sort((p,u)=>p.ts-u.ts);for(let p of d)if(p.type==="connect")l(p.ts),p.detail&&(s={ip:p.detail,from:p.ts,to:p.ts,live:!1});else if(p.type==="roam"){let u=p.detail?.split("→")[1]?.trim();l(p.ts),u&&(s={ip:u,from:p.ts,to:p.ts,live:!1})}else p.type==="disconnect"&&l(p.ts);let c=s;return c&&o?i.push({...c,to:Math.max(r,c.from),live:!0}):l(Math.min(r,a)),i}function Ke(n){return`${n.city||`${n.lat.toFixed(1)},${n.lon.toFixed(1)}`}|${n.cc}`}function wr(n,e,r,o){let a=new Map;for(let s of e)(s.device===r||!a.has(s.ip))&&a.set(s.ip,s);let i=[];for(let s of n){let l=a.get(s.ip);!l||s.to<=o||i.push({key:Ke(l),point:l,from:Math.max(s.from,o),to:s.to,live:s.live})}return i}function yr(n){let e=new Map,r=0;for(let o of n)e.set(o.key,(e.get(o.key)??0)+(o.to-o.from)),r+=o.to-o.from;return new Map([...e].map(([o,a])=>[o,r?a/r:0]))}function vr(n,e=2700){let r=[];for(let o of n){let a=r[r.length-1];if(a&&o.key!==a.key&&!o.live&&o.to-o.from{i&&(r.push({kind:"move",k:i,start:o,ms:e}),o+=e);let s=Math.min(1100,Math.max(350,(a.to-a.from)/3600*45));r.push({kind:"stay",k:i,start:o,ms:s}),o+=s}),{steps:r,total:o}}function Er(n,e,r){let o=e.findIndex(l=>r>=l.start&&rr>=s.from&&rs.kind==="stay"&&s.k===o),i=n[o];return a.start+a.ms*Math.min(.999,Math.max(0,(r-i.from)/Math.max(1,i.to-i.from)))}var cs=n=>n<=0?0:n>=1?1:n<.5?2*n*n:1-(-2*n+2)**2/2;function Mr(n){return-ao/2+(1+ao)*cs((n-br)/(1-br))}var Sr=n=>n+$r>=1;function Tr(n){return["interpolate",["linear"],["abs",["-",["get","pos"],n]],0,1,$r,1,ao/2,0]}function _r(n,e){let r=n==="24h"?86400:n==="7d"?604800:2592e3,o=e-r,a=[],i=(l,d)=>{let c=(l-o)/r;c>.02&&c<.98&&a.push([c,d])},s=new Date(o*1e3);if(n==="24h")for(s.setMinutes(0,0,0);s.getTime()/1e3<=e;)s.getHours()%6===0&&i(s.getTime()/1e3,`${String(s.getHours()).padStart(2,"0")}:00`),s.setHours(s.getHours()+1);else if(n==="7d")for(s.setHours(12,0,0,0);s.getTime()/1e3<=e;s.setDate(s.getDate()+1))i(s.getTime()/1e3,s.toLocaleDateString("en-GB",{weekday:"short"}));else{let l=new Date(e*1e3);l.setHours(0,0,0,0);for(let d=0;d<5;d++){let c=new Date(l);c.setDate(l.getDate()-7*d),i(c.getTime()/1e3,c.toLocaleDateString("en-GB",{day:"numeric",month:"short"}))}a.reverse()}return a}var xn=n=>new Date(n*1e3).toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit"});function Pr(n,e){let r=o=>new Date(o*1e3).toDateString();return r(n)===r(e)?"Today":r(n)===r(e-86400)?"Yesterday":new Date(n*1e3).toLocaleDateString("en-GB",{weekday:"short",day:"numeric",month:"short"})}var so="https://unpkg.com/maplibre-gl@6.14.0/dist",Dr={module:"sha384-q26X6R1yFeg0QR9SHHn6U3Nb0ddRRTtwxsahubv5R89/v5nijKpk9KviUp9ZLySk",css:"sha384-1TZtfVz7qtwR5vD7cMwjGT+9uiK4lqE3pbUOPwYO6OCpb+TYP0S9vLIhG02JCU04"},Ar="https://basemaps.cartocdn.com/gl/dark-matter-gl-style/style.json",Hr="https://basemaps.cartocdn.com/gl/positron-gl-style/style.json",ps={online:0,"24h":86400,"7d":7*86400,"30d":30*86400},Gt=null;function us(n){if(n.appendChild(t("link",{rel:"stylesheet",href:`${so}/maplibre-gl.css`,integrity:Dr.css,crossorigin:"anonymous"})),Gt)return Gt;let e=`${so}/maplibre-gl.mjs`;return Gt=new Promise((o,a)=>{let i=t("link",{rel:"modulepreload",href:e,integrity:Dr.module,crossorigin:"anonymous"});i.addEventListener("load",()=>o()),i.addEventListener("error",()=>a(new Error("integrity"))),document.head.appendChild(i)}).then(()=>import(e)).then(o=>(o.getWorkerUrl()||o.setWorkerUrl(`${so}/maplibre-gl-worker.mjs`),o),o=>{throw Gt=null,new Error(o?.message==="integrity"?"The map library from the CDN is not the expected file: not loading it.":"Could not load the map library (no internet access from this browser?)")}),Gt}var ms=10,zr=30,hs=62,fs=4,Nr=4.5,gs=7,wn="#3b82f6",lo="#8a8a8a";function Rr(n,e,r=.2,o=64){let[a,i]=n,[s,l]=e,d=s-a,c=d>180?s-360:d<-180?s+360:s,p=c-a,u=l-i,x=Math.hypot(p,u);if(x===0||r===0)return[n,[c,l]];let $=-u/x,h=p/x,m=x*r,E=(a+c)/2+$*m,R=(i+l)/2+h*m,C=[],k=Math.max(2,Math.floor(o));for(let y=0;y<=k;y+=1){let w=y/k,b=1-w;C.push([b*b*a+2*b*w*E+w*w*c,b*b*i+2*b*w*R+w*w*l])}return C}function co(n,e){let r=new Map;for(let o of n.geo.points){if(n.person&&o.person!==n.person||n.device&&o.device!==n.device||(e==="online"?!o.online:n.now-o.ts>ps[e]))continue;let a=n.device?Ke(o):n.person?`${o.device}|${o.city}|${o.cc}`:o.device,i=r.get(a);(!i||o.online&&!i.online||o.online===i.online&&o.ts>i.ts)&&r.set(a,o)}return[...r.values()]}function po(n,e){let r=0;return co(n,e).sort((o,a)=>Number(a.online)-Number(o.online)||a.ts-o.ts).map(o=>({...o,n:o.online?0:++r}))}var tt=class{constructor(e,r="online",o=380){this.cb=e;this.map=null;this.gl=null;this.markers=[];this.popup=null;this.theme=null;this.resize=null;this.fitBlind=!1;this.data=null;this.fitted=!1;this.fitKey=null;this.people=[];this.slots=[];this.merged=[];this.piles=new Map;this.dock=null;this.dockKey="";this.dockQuiet=!1;this.piledKeys=new Set;this.foldedKeys=new Set;this.targetZoom=null;this.before=null;this.hiddenKey="";this.focused=null;this.dead=!1;this.places=new Map;this.replaying=null;this.bandDots=[];this.range=r,this.status=t("div",{class:"dl-map-status"}),this.card=t("div",{class:"dl-map-card","aria-live":"polite"}),this.el=t("div",{class:"dl-geomap",style:`height:${o}px`},[this.status,this.card])}async mount(e){this.data=e;try{this.gl=await us(this.el)}catch(o){this.status.textContent=o.message;return}if(this.dead)return;this.map=new this.gl.Map({container:this.el,style:pt()?Ar:Hr,center:[e.geo.home?.lon??20,e.geo.home?.lat??50],zoom:1,renderWorldCopies:!1,attributionControl:{compact:!0},minZoom:1}),this.map.on("style.load",()=>this.layers()),this.map.on("move",()=>this.declutter()),this.map.once("idle",()=>{let o=this.el.querySelector(".maplibregl-ctrl-attrib");o?.classList.remove("maplibregl-compact-show"),o?.removeAttribute("open")}),this.resize=new ResizeObserver(()=>{!this.map||!this.el.clientWidth||!this.el.clientHeight||(this.map.resize(),this.fitBlind&&(this.fitKey=null,this.draw()))}),this.resize.observe(this.el);let r=pt();this.theme=new MutationObserver(()=>{!this.map||pt()===r||(r=pt(),this.map.setStyle(r?Ar:Hr))}),this.theme.observe(document.documentElement,{attributes:!0,attributeFilter:["data-darkmode"]})}layers(){if(this.map){this.hiddenKey="",this.map.setProjection({type:"globe"}),this.map.addSource("dl-areas",{type:"geojson",data:{type:"FeatureCollection",features:[]}}),this.map.addLayer({id:"dl-area",type:"circle",source:"dl-areas",paint:{"circle-radius":["interpolate",["exponential",2],["zoom"],2,6,6,26,9,140,12,900],"circle-color":["case",["get","online"],wn,lo],"circle-opacity":["case",["get","online"],.12,.06],"circle-stroke-width":1,"circle-stroke-color":["case",["get","online"],wn,lo],"circle-stroke-opacity":["case",["get","online"],.35,.15]}}),this.map.addSource("dl-band",{type:"geojson",data:{type:"FeatureCollection",features:this.bandDots}}),this.map.addLayer({id:"dl-band",type:"circle",source:"dl-band",paint:{"circle-radius":1.4,"circle-color":wn,"circle-opacity":0}}),this.map.addSource("dl-arcs",{type:"geojson",data:{type:"FeatureCollection",features:[]}});for(let e of[!1,!0])this.map.addLayer({id:e?"dl-arc-live":"dl-arc-recent",type:"line",source:"dl-arcs",filter:["==",["get","online"],e],layout:{"line-join":"round","line-cap":"round"},paint:{"line-color":e?wn:lo,"line-width":2,"line-opacity":.85,"line-dasharray":[2,2]}});this.draw()}}setRange(e){this.range=e,this.fitKey=null,this.draw()}update(e){this.data=e,this.draw()}destroy(){this.dead=!0,this.dropCard();for(let e of this.piles.values())e.marker.remove();this.piles.clear(),this.theme?.disconnect(),this.resize?.disconnect(),this.map?.remove(),this.map=null}groups(e){let r=new Map;for(let o of e){let a=`${o.person}|${Ke(o)}`,i=r.get(a);i||(i={key:a,person:o.person,lat:o.lat,lon:o.lon,city:o.city,country:o.country,cc:o.cc,asn:o.asn,org:o.org,online:!1,ts:0,points:[]},r.set(a,i)),i.points.push(o),i.online||(i.online=o.online),i.ts=Math.max(i.ts,o.ts)}return[...r.values()]}draw(){if(!this.map||!this.data||!this.map.getSource("dl-arcs"))return;let e=this.data,r=this.groups(co(e,this.range)),o=e.person||e.device?null:e.geo.home;for(let d of this.markers)d.remove();this.markers=[];let a=e.person||e.device?null:bs(r,o),i=r.map(d=>({g:d,at:a?.get(d.key)??[d.lon,d.lat]}));if(this.slots=[],this.map.getSource("dl-areas").setData({type:"FeatureCollection",features:i.map(({g:d})=>({type:"Feature",properties:{online:d.online,key:d.key},geometry:{type:"Point",coordinates:[d.lon,d.lat]}}))}),this.map.getSource("dl-arcs").setData({type:"FeatureCollection",features:o?i.map(({g:d,at:c})=>({type:"Feature",properties:{online:d.online,person:d.person,key:d.key},geometry:{type:"LineString",coordinates:Rr([o.lon,o.lat],c)}})):[]}),o){let d=t("span",{class:"dl-mk-host"});d.innerHTML=`${ft("server","dl-mk-host-ic")}`,this.dock=d.appendChild(t("span",{class:"dl-mk-dock"})),this.dockQuiet=this.dockKey!=="",this.dockKey="";let c=t("div",{class:"dl-mk-hub",title:`Home router${o.city?` · ${o.city}`:""}${o.org?` · ${o.org}`:""}`},[d,t("span",{class:"dl-mk-label chip"},o.city||"Home")]);c.addEventListener("mouseenter",()=>this.showMerged(o.city||"the server")),c.addEventListener("mouseleave",()=>this.focus(this.focused)),c.addEventListener("click",()=>this.zoomToMerged()),this.add(c,[o.lon,o.lat],!0)}let s=new Map(e.device?po(e,this.range).map(d=>[Ke(d),d.n]):[]);this.people=[],this.places.clear();for(let{g:d,at:c}of i){let p=d.points.length,u=e.people.find(m=>m.id===d.person);if(e.person){let m=e.device?this.deviceMarker(d,c,u,s.get(Ke(d))??0):this.placeMarker(d,c,u);this.add(m,c);continue}let x=d.points.map(m=>u?.devices.find(E=>E.id===m.device)?.kind??"other"),$=t("span",{class:"dl-mk-badge"});$.innerHTML=p<=2?x.map(m=>ft(m,"dl-mk-badge-ic")).join(""):String(p);let h=t("button",{type:"button",class:`dl-mk${d.online?" online":""}`,"aria-label":`${u?.name??"Someone"}: ${p} device${p===1?"":"s"} in ${d.city||"an unknown city"}`},[t("span",{class:"dl-mk-av"},[He(u?.name??"?"),$]),t("span",{class:"dl-mk-label below"},d.city||d.cc||"?")]);h.addEventListener("mouseenter",()=>this.focus(d.person)),h.addEventListener("mouseleave",()=>this.focus(null)),this.people.push({el:h,person:d.person}),h.addEventListener("click",m=>{m.stopPropagation(),this.openPopup(d,c,h)}),this.add(h,c,!1,u?.name??"Someone",`${d.city||d.cc||"?"} · ${d.online?"now":re(d.ts,e.now)}`,d.key,d)}this.declutter();let l=i.map(d=>d.g.key).sort().join(";");if(l!==this.fitKey&&!this.popup){let d=this.fitted&&!this.fitBlind;if(this.fitBlind=!this.el.clientWidth||!this.el.clientHeight,this.fitKey=l,this.fitted=!0,o&&!i.length){let c={center:[o.lon,o.lat],zoom:12};d?this.glide(12,()=>this.map.flyTo({...c,duration:1200})):this.map.jumpTo(c)}else{let c=i.map(p=>p.at);o&&(c.length===0||this.range!=="online"||i.some(p=>p.g.online))&&c.push([o.lon,o.lat]),this.fit(c,d)}}this.status.textContent=i.length||o?"":"No locations yet",this.status.style.display=this.status.textContent?"":"none",this.focus(this.focused&&this.people.some(d=>d.person===this.focused)?this.focused:null)}add(e,r,o=!1,a,i,s,l){s&&this.foldedKeys.has(s)&&e.classList.add("merged"),s&&this.piledKeys.has(s)&&e.classList.add("piled"),e.dataset.key=s??"",e.classList.add("dl-mk-new"),requestAnimationFrame(()=>requestAnimationFrame(()=>e.classList.remove("dl-mk-new")));let d=new this.gl.Marker({element:e}).setLngLat(r).addTo(this.map);this.markers.push(d),this.slots.push({marker:d,el:e,at:r,fixed:o,who:a,where:i,g:l})}declutter(){if(!this.map)return;let e=this.map.getZoom();this.el.classList.toggle("dl-lod-far",e=Nr&&e{let l=this.map.project(s.at),d=s.el.querySelector(":scope > .dl-mk-host, :scope > .dl-mk-av, :scope > .dl-mk-tile");return{x:l.x,y:l.y,r:(d?.offsetWidth||24)/2+3,fixed:s.fixed}}),o=r.filter(s=>s.fixed);this.merged=[],this.foldedKeys.clear();let a=this.targetZoom==null?1:Math.min(1,2**(this.targetZoom-this.map.getZoom()));r.forEach((s,l)=>{if(s.fixed)return;let d=this.slots[l],c=d.el.classList.contains("merged")?12:6,p=o.find(u=>Math.hypot(u.x-s.x,u.y-s.y)*a{let c=this.slots[d];!c||c.fixed||(r[d].fixed&&([s,l]=[0,0]),c.marker.setOffset([s,l]),ws(c.el,s,l))})}closePopup(e=!1){let r=this.popup;if(!r||r.card.classList.contains("leaving"))return;r.card.classList.add("leaving"),setTimeout(()=>{this.popup===r&&this.dropCard()},140);let o=this.before;if(this.before=null,!o)return;let a=()=>this.map?.flyTo({...o,duration:800});if(!e)return a();let i=!1,s=()=>{i||(i=!0,window.removeEventListener("pointerup",s,!0),window.removeEventListener("pointercancel",s,!0),setTimeout(a,0))};window.addEventListener("pointerup",s,!0),window.addEventListener("pointercancel",s,!0),setTimeout(s,1500)}dropCard(){this.popup?.off(),this.popup?.card.remove(),this.popup=null}showMerged(e){this.merged.length&&(dom.content(this.card,[t("div",{class:"dl-map-card-head"},[t("b",{},`Near ${e}`)," · click to zoom in"]),...this.merged.map(r=>t("div",{class:"dl-map-card-row"},[t("span",{},r.who),t("span",{class:"dl-faint"},r.where)]))]),this.card.classList.add("on"))}paintDock(){let e=this.dock;if(!e)return;let r=this.merged.map(a=>`${a.key}:${a.online?1:0}`).join("|");if(r===this.dockKey)return;this.dockKey=r,e.parentElement?.classList.toggle("docked",this.merged.length>0);let o=this.slots.find(a=>a.fixed).at;this.merged.length&&Br(e,this.merged,this.faceActions(()=>[o]),this.dockQuiet),this.dockQuiet=!1}faceActions(e){return{click:(r,o)=>this.openFace(r,o,e()),hover:r=>this.focus(r?.g?.person??null)}}pileUp(e){let r=new Set;if(!this.data?.person&&!this.data?.device){let o=e.flatMap((l,d)=>!l.fixed&&this.slots[d].el.querySelector(":scope > .dl-mk-av")?[d]:[]),a=new Map(o.map(l=>[l,l])),i=l=>a.get(l)===l?l:i(a.get(l));for(let l of o)for(let d of o){if(d<=l)continue;let c=this.slots[l].el.classList.contains("piled")&&this.slots[d].el.classList.contains("piled");Math.hypot(e[l].x-e[d].x,e[l].y-e[d].y)this.slots[m]),c=d.map(Ir),p=c.map(m=>m.key).sort().join(",");r.add(p);let u=[d.reduce((m,E)=>m+E.at[0],0)/d.length,d.reduce((m,E)=>m+E.at[1],0)/d.length],x=this.piles.get(p);if(!x){let m=t("span",{class:"dl-mk-pile-box"}),E=[...new Set(d.map(k=>k.g?.city||k.g?.cc||"?"))],R=t("div",{class:"dl-mk-pile"},[m,t("span",{class:"dl-mk-label below"},E.length===1?E[0]:`${d.length} people`)]);x={marker:new this.gl.Marker({element:R}).setLngLat(u).addTo(this.map),el:R,box:m,faces:c},R.addEventListener("mouseleave",()=>this.focus(this.focused));let C=x;R.addEventListener("click",k=>{k.stopPropagation(),this.zoomInTo(C.faces.map(y=>y.at),!1)}),this.piles.set(p,x)}x.faces=c;let $=x;Br(x.box,c,this.faceActions(()=>$.faces.map(m=>m.at)));for(let m of l)this.slots[m].el.classList.add("piled"),Object.assign(e[m],{r:0,fixed:!0});let h=this.map.project(u);e.push({x:h.x,y:h.y,r:(x.el.offsetWidth||60)/2+3,fixed:!0})}}this.piledKeys=new Set(this.slots.filter(o=>o.el.classList.contains("piled")).map(o=>o.el.dataset.key??"")),this.slots.forEach((o,a)=>{(!e[a].fixed||o.fixed||o.el.classList.contains("merged"))&&o.el.classList.remove("piled")});for(let[o,a]of this.piles)r.has(o)||(this.piles.delete(o),a.el.classList.add("out"),setTimeout(()=>a.marker.remove(),200))}zoomToMerged(){!this.map||!this.merged.length||this.zoomInTo([this.slots.find(e=>e.fixed).at,...this.merged.map(e=>e.at)],!1)}openFace(e,r,o){if(!e.g)return;if(o.every(i=>yn(i,e.at)<1))return this.openPopup(e.g,e.at,r);let a=()=>{let i=this.slots.find(s=>s.el.dataset.key===e.key);i?.g&&!i.el.classList.contains("merged")&&!i.el.classList.contains("piled")&&this.openPopup(i.g,i.at,i.el)};this.zoomInTo(this.nearby(e.at),!0)?this.map.once("moveend",a):a()}nearby(e){return[e,...this.slots.filter(r=>!r.fixed&&r.at!==e&&yn(r.at,e)<=zr).map(r=>r.at)]}zoomInTo(e,r){let o=new this.gl.LngLatBounds;for(let p of e)o.extend(p);let a=e.some(p=>e.some(u=>yn(p,u)>zr)),i=this.map.cameraForBounds(o,{padding:50,maxZoom:a?12:ms}),s=this.map.getZoom(),l=e.map(p=>this.map.project(p)),d=0;l.forEach((p,u)=>l.slice(u+1).forEach(x=>{let $=Math.hypot(p.x-x.x,p.y-x.y),h=s+Math.log2(hs/Math.max($,1e-6));h<=12&&(d=Math.max(d,h))}));let c=Math.min(12,Math.max(i?.zoom??0,d));return c<=s+.05?!1:(r&&!this.before&&(this.before={center:this.map.getCenter().toArray(),zoom:s}),this.map.flyTo({center:i?.center??o.getCenter(),zoom:c,duration:800}),!0)}placeMarker(e,r,o){let a=this.data.now,i=[...e.points].sort((u,x)=>Number(x.online)-Number(u.online)||x.ts-u.ts)[0],s=o?.devices.find(u=>u.id===i.device)?.kind??"other",l=e.points.length,d=t("span",{class:"dl-mk-tile"});d.innerHTML=ft(s,"dl-mk-tile-ic")+(l>1?`${l}`:"");let c=e.online?"now":re(e.ts,a),p=t("button",{type:"button",class:`dl-mk place${e.online?" online":""}`,style:e.online?null:`--dl-mk-fade:${Math.max(.4,1-.6*(a-e.ts)/(30*86400)).toFixed(2)}`,"aria-label":`${l} device${l===1?"":"s"} in ${e.city||"an unknown city"}, ${c}`},[d,t("span",{class:"dl-mk-label below"},[e.city||e.cc||"?",t("span",{class:"dl-mk-when"},c)])]);return p.addEventListener("click",u=>{u.stopPropagation(),this.openPopup(e,r,p)}),p}deviceMarker(e,r,o,a){let i=o?.devices.find(p=>p.id===e.points[0].device)?.kind??"other",s=t("span",{class:"dl-mk-tile"}),l=t("span",{class:"dl-mk-label below"}),d=t("button",{type:"button",class:"dl-mk place step"},[s,l]);d.addEventListener("click",p=>{p.stopPropagation(),this.openPopup(e,r,d)});let c=Ke(e);return this.places.set(c,{el:d,tile:s,label:l,when:null,g:e,n:a,kind:i}),this.paintPlace(c,!1),d}paintPlace(e,r){let o=this.places.get(e);if(!o)return;let a=this.replaying,i=a?a.active===e:o.g.online,s=o.el.classList.contains("online"),l=o.g.city||o.g.cc||"?";o.el.classList.toggle("online",i),o.el.classList.toggle("faded",!!a&&!i),o.tile.classList.toggle("sm",!i),i||!o.n?o.tile.innerHTML=ft(o.kind,"dl-mk-tile-ic"):o.tile.textContent=String(o.n),o.when=null,i?(o.when=t("span",{class:`dl-mk-when${a?" inline":""}`},a?a.when:"now"),o.label.replaceChildren(l,a?" · ":"",o.when)):o.label.replaceChildren(`${l} · ${o.g.online?"now":re(o.g.ts,this.data.now)}`);let d=i?a?a.when:"now":o.g.online?"now":re(o.g.ts,this.data.now);o.el.setAttribute("aria-label",`${o.n?`${o.n}: `:""}${o.g.city||"an unknown city"}, ${d}`),r&&i&&!s&&(o.el.classList.remove("arrive"),o.el.offsetWidth,o.el.classList.add("arrive"),setTimeout(()=>o.el.classList.remove("arrive"),500))}replay(e,r=!0){let o=this.replaying;if(this.replaying=e,o&&e&&o.active===e.active){let a=e.active?this.places.get(e.active):null;a?.when&&(a.when.textContent=e.when);return}for(let a of this.places.keys())a!==e?.active&&this.paintPlace(a,r);e?.active&&this.paintPlace(e.active,r),this.declutter(),setTimeout(()=>this.declutter(),320)}hoverPlace(e){for(let[r,o]of this.places)o.el.classList.toggle("hl",r===e)}band(e,r){if(this.bandDots=[],this.map&&e&&r){let o=Rr(e,r),a=o.map(c=>this.map.project(c)),i=[0];for(let c=1;ci[d]?(p-i[d])/(i[d+1]-i[d]):0,x=[o[d][0]+(o[d+1][0]-o[d][0])*u,o[d][1]+(o[d+1][1]-o[d][1])*u];this.bandDots.push({type:"Feature",properties:{pos:c/l},geometry:{type:"Point",coordinates:x}})}}this.map?.getLayer("dl-band")&&(this.map.setPaintProperty("dl-band","circle-opacity",0),this.map.getSource("dl-band").setData({type:"FeatureCollection",features:this.bandDots}))}bandAt(e){this.map?.getLayer("dl-band")&&this.map.setPaintProperty("dl-band","circle-opacity",Tr(e))}focus(e){this.focused=e;for(let s of this.people)s.el.classList.toggle("dim",!!e&&s.person!==e),s.el.classList.toggle("hl",s.person===e);let r=e?["case",["==",["get","person"],e],.85,.15]:.85;for(let s of["dl-arc-live","dl-arc-recent"])this.map?.getLayer(s)&&this.map.setPaintProperty(s,"line-opacity",r);if(this.card.classList.toggle("on",!!e),!e||!this.data)return;let o=this.data,a=o.people.find(s=>s.id===e),i=co(o,this.range).filter(s=>s.person===e).sort((s,l)=>Number(l.online)-Number(s.online)||l.ts-s.ts);dom.content(this.card,[t("div",{class:"dl-map-card-head"},[t("b",{},a?.name??e),` · ${i.length} device${i.length===1?"":"s"}`]),...i.map(s=>t("div",{class:"dl-map-card-row"},[t("span",{},a?.devices.find(l=>l.id===s.device)?.name??"Device"),t("span",{class:"dl-faint"},`${s.city||s.cc||"?"} · ${s.online?"now":re(s.ts,o.now)}`)]))])}fit(e,r=!1){if(!e.length)return;let o=(p,u)=>{let x=Math.PI/180,$=(u[1]-p[1])*x,h=(u[0]-p[0])*x,m=Math.sin($/2)**2+Math.cos(p[1]*x)*Math.cos(u[1]*x)*Math.sin(h/2)**2;return 12742*Math.asin(Math.sqrt(m))},a=[e.reduce((p,u)=>p+u[0],0)/e.length,e.reduce((p,u)=>p+u[1],0)/e.length],i=e;if(e.length>=5){let p=[...e].sort((u,x)=>o(a,u)-o(a,x));i=p.slice(0,Math.ceil(p.length*.9))}let s=new this.gl.LngLatBounds(i[0],i[0]);i.forEach(p=>s.extend(p));let l=this.el.clientHeight||380,d=!!this.data?.person,c={padding:{top:this.data?.device?Math.min(56,l/4):Math.min(60,l/5),bottom:d?Math.min(52,l/4):Math.min(40,l/8),left:48,right:48},maxZoom:this.data?.person?11:12};r?this.glide(this.map.cameraForBounds(s,c)?.zoom??null,()=>this.map.fitBounds(s,{...c,duration:1200})):this.map.fitBounds(s,{...c,duration:0})}glide(e,r){this.targetZoom=e,this.declutter(),this.map.once("moveend",()=>{this.targetZoom=null,this.declutter()}),r()}openPopup(e,r,o){let a=this.data,i=[e.city,e.cc||e.country].filter(Boolean).join(", "),s=[...new Set(e.points.map(k=>k.person))],l=e.points.sort((k,y)=>Number(y.online)-Number(k.online)||y.ts-k.ts).map(k=>{let y=a.people.find(b=>b.id===k.person),w=y?.devices.find(b=>b.id===k.device);return t("button",{type:"button",class:"dl-pop-row",click:()=>this.cb.openDevice(k.person,k.device)},[t("span",{class:`dl-pop-dot${k.online?" on":""}`}),t("span",{class:"dl-pop-name"},[t("b",{},y?.name??k.person),` · ${w?.name??"device"}`]),t("span",{class:"dl-faint dl-nowrap"},k.online?"now":re(k.ts,a.now))])}),d=t("div",{class:"dl-pop"},[t("div",{class:"dl-pop-head"},[t("span",{class:"dl-pop-net"},v("globe")),t("div",{class:"dl-stack"},[t("strong",{},e.org||"Unknown network"),t("span",{class:"dl-faint"},[e.asn?`AS${e.asn} · `:"",i?`${i} · approximate`:"approximate location"])])]),t("div",{class:"dl-pop-list"},l),s.length===1?t("div",{class:"dl-pop-actions"},[t("button",{type:"button",class:"cbi-button cbi-button-positive important",click:()=>this.cb.openPerson(s[0])},`Open ${a.people.find(k=>k.id===s[0])?.name??"person"}`)]):""]);this.zoomInTo(this.nearby(r),!0),this.dropCard();let c=t("div",{class:"dl-root dl-popcard",role:"dialog"},[t("span",{class:"dl-popcard-tip"}),d]);document.body.appendChild(c);let p=this.el,u=o?.querySelector(".dl-mk-av, .dl-mk-tile")??o??null,x=()=>{if(!u)return;let k=u.getBoundingClientRect(),y=p.getBoundingClientRect(),w=k.left+k.width/2,b=k.top+k.height/2;c.classList.toggle("away",wy.right||by.bottom);let H=c.offsetWidth,f=c.offsetHeight,g=k.top-f-12>=8||k.top>window.innerHeight-k.bottom,M=Math.min(Math.max(8,w-H/2),window.innerWidth-H-8);c.classList.toggle("above",g),c.classList.toggle("below",!g),c.style.left=`${M}px`,c.style.top=`${g?k.top-f-12:k.bottom+12}px`,c.style.setProperty("--tip-x",`${w-M}px`)},$=k=>{k.target?.closest(".dl-popcard, .maplibregl-marker")||this.closePopup(!0)},h=k=>{k.key==="Escape"&&this.closePopup()},m=k=>{k.target instanceof Element&&k.target.closest(".dl-popcard")||this.closePopup()},E=()=>this.closePopup();this.map.on("move",x),window.addEventListener("scroll",m,{capture:!0,passive:!0}),window.addEventListener("resize",x),document.addEventListener("pointerdown",$,!0),document.addEventListener("keydown",h);let R=$e(E);window.addEventListener("pagehide",E),this.popup={card:c,off:()=>{this.map?.off("move",x),window.removeEventListener("scroll",m,!0),window.removeEventListener("resize",x),document.removeEventListener("pointerdown",$,!0),document.removeEventListener("keydown",h),R(),window.removeEventListener("pagehide",E)}};let C=window.setInterval(()=>{if(this.popup?.card!==c)return clearInterval(C);(!p.isConnected||!p.getClientRects().length)&&this.dropCard()},400);x()}};function vs(n,e=6){let r=n.map(o=>({x:o.x,y:o.y}));for(let o=0;o<16;o++){let a=!1;for(let i=0;i[o.x-n[a].x,o.y-n[a].y])}function bs(n,e){let r=new Map,o=e?[[e.lon,e.lat]]:[],a=i=>o.some(s=>yn(i,s)<1.3);for(let i of[...n].sort((s,l)=>s.key>>12)/1048575),d=(s&4095)/4096*2*Math.PI,c=[i.lon,i.lat];for(let p=0;p<24;p++){let u=d+p*2.39996,x=Math.min(8,l+p*.25);if(c=[i.lon+x*Math.sin(u)/(111.32*Math.cos(i.lat*Math.PI/180)),i.lat+x*Math.cos(u)/111.32],!a(c))break}o.push(c),r.set(i.key,c)}return r}function xs(n){let e=2166136261;for(let r=0;r>>0}function Ir(n){return{key:n.el.dataset.key??"",who:n.who??"Someone",where:n.where??"",online:!!n.g?.online,at:n.at,badge:n.el.querySelector(".dl-mk-badge")?.innerHTML??"",g:n.g}}function Br(n,e,r,o=!1){let a=e.length>3,i=()=>[...n.children].filter(h=>!h.classList.contains("out")),s=new Map(i().map(h=>[h,h.getBoundingClientRect().left])),l=n.getBoundingClientRect().width,d=new Map;n.querySelectorAll(".dl-mk-face:not(.out)").forEach(h=>d.set(h.dataset.key??"",h));let c=n.querySelector(".dl-mk-more:not(.out)"),p=h=>{Object.assign(h.style,{position:"absolute",left:`${h.offsetLeft}px`,top:`${h.offsetTop}px`,transform:""}),h.classList.add("out"),setTimeout(()=>h.remove(),200)},u=[];for(let h of e.slice(0,a?2:3)){let m=d.get(h.key);if(d.delete(h.key),!m){let C=t("button",{type:"button",class:`dl-mk-face${o?"":" in"}`,"data-key":h.key},[t("span",{class:"dl-mk-av"},He(h.who)),t("span",{class:"dl-mk-badge"})]);C.addEventListener("animationend",()=>C.classList.remove("in"),{once:!0}),m=C}let E=m,R=E.querySelector(".dl-mk-badge");R.innerHTML!==h.badge&&(R.innerHTML=h.badge),E.title=`${h.who} · ${h.where}`,E.setAttribute("aria-label",`${h.who}, ${h.where}`),E.classList.toggle("on",h.online),E.onclick=C=>{C.stopPropagation(),r.click(h,E)},E.onmouseenter=()=>r.hover(h),E.onmouseleave=()=>r.hover(null),u.push(E)}for(let h of d.values())p(h);if(a){if(!c){c=t("span",{class:`dl-mk-more${o?"":" in"}`});let h=c;h.addEventListener("animationend",()=>h.classList.remove("in"),{once:!0})}c.textContent=`+${e.length-2}`,u.push(c)}else c&&p(c);let x=null;for(let h of u)(x?x.nextElementSibling:n.firstElementChild)!==h&&(x?x.after(h):n.prepend(h)),x=h;for(let h of u){let m=s.get(h);if(m==null)continue;let E=m-h.getBoundingClientRect().left;Math.abs(E)<.5||(h.style.transition="none",h.style.transform=`translateX(${E}px)`,h.offsetWidth,h.style.transition="",h.style.transform="")}n.style.width="";let $=n.getBoundingClientRect().width;if(l&&Math.abs($-l)>.5){n.style.width=`${l}px`,n.offsetWidth,n.style.width=`${$}px`;let h=()=>{n.style.width="",n.removeEventListener("transitionend",h)};n.addEventListener("transitionend",h),setTimeout(h,400)}}function yn(n,e){let r=Math.PI/180,o=Math.sin((e[1]-n[1])*r/2)**2+Math.cos(n[1]*r)*Math.cos(e[1]*r)*Math.sin((e[0]-n[0])*r/2)**2;return 12742*Math.asin(Math.min(1,Math.sqrt(o)))}function ws(n,e,r){let o=n.querySelector(":scope > .dl-mk-ptr"),a=Math.hypot(e,r);if(a<1){o?.remove();return}o||(o=t("span",{class:"dl-mk-ptr"},[t("i",{class:"line"}),t("i",{class:"spot"})]),n.prepend(o));let i=o.firstElementChild,s=o.lastElementChild;i.style.width=`${a}px`,i.style.transform=`rotate(${Math.atan2(-r,-e)}rad)`,s.style.transform=`translate(${-e}px, ${-r}px)`}function Tt(n,e,r=!0){let o=[["online","Online now"],["24h","24h"],["7d","7 days"],["30d","30 days"]],a=t("div",{class:"dl-seg",role:"tablist"});for(let[i,s]of o)i==="online"&&!r||a.appendChild(t("button",{type:"button",role:"tab",class:i===n?"on":"","data-v":i,click:()=>{a.querySelectorAll("button").forEach(l=>l.classList.toggle("on",l.dataset.v===i)),e(i)}},s));return a}var Or={"24h":86400,"7d":7*86400,"30d":30*86400},uo=(n,e)=>`${(n/e*100).toFixed(3)}%`,kn=class{constructor(e,r,o){this.map=e;this.range=r;this.el=t("div",{class:"dl-dplaces"});this.controls=t("div",{class:"dl-map-replay"});this.pending=null;this.rows=new Map;this.st=[];this.steps=[];this.total=0;this.ms=0;this.stepI=-1;this.on=!1;this.playing=!1;this.raf=0;this.last=0;this.endTimer=0;this.play=t("button",{type:"button",class:"dl-map-btn"});this.chip=t("span",{class:"dl-map-chip"});this.stop=t("button",{type:"button",class:"dl-map-btn",title:"Back to now","aria-label":"Back to now"},v("x"));this.reduced=window.matchMedia?.("(prefers-reduced-motion: reduce)").matches??!1;this.data=o,this.play.addEventListener("click",()=>this.toggle()),this.stop.addEventListener("click",()=>this.end()),this.paint()}mapData(){let e=this.data;return{geo:e.geo,people:[e.person],now:e.now,person:e.person.id,device:e.device.id}}update(e){let r={...this.pending??this.data,...e};if(this.on){this.pending=r;return}this.data=r,this.map.update(this.mapData()),this.paint()}setRange(e){this.end(),this.range=e,this.map.setRange(e),this.paint()}destroy(){cancelAnimationFrame(this.raf),clearTimeout(this.endTimer)}paint(){let e=this.data,r=Or[this.range],o=e.now-r,a=wr(xr(e.events??[],e.device.id,e.now,e.device.online,e.device.handshake),e.geo.points,e.device.id,o),i=yr(a);this.st=kr(a);let s=po(this.mapData(),this.range),l=a.length>0;this.el.classList.toggle("strips",l),this.el.classList.toggle("can-replay",this.st.length>1),this.rows.clear(),dom.content(this.el,s.length?[...s.map(d=>{let c=Ke(d),p=i.get(c),u=l?t("div",{class:`dl-dplace-strip${d.online?" live":""}`},a.filter($=>$.key===c).map($=>t("i",{style:`left:${uo($.from-o,r)};width:${uo($.to-$.from,r)}`}))):"",x=t("div",{class:"dl-dplace-row"},[t("span",{class:`dl-dplace-n${d.online?" live":""}`},d.online?v(e.device.kind):String(d.n)),t("span",{class:"dl-row-main dl-stack"},[t("span",{},[d.city||d.cc||"Unknown city",d.org?t("span",{class:"dl-muted"},` · ${d.org}`):""]),t("span",{class:"dl-faint"},[t("span",{class:"dl-mono"},d.ip),p!=null?` · ${p>0&&p<.005?"<1":Math.round(p*100)}% of the time`:""])]),t("span",{class:d.online?"dl-dplace-now":"dl-faint dl-nowrap"},d.online?"now":re(d.ts,e.now)),u]);if(x.addEventListener("mouseenter",()=>this.map.hoverPlace(c)),x.addEventListener("mouseleave",()=>this.map.hoverPlace(null)),u){let $=h=>{let m=u.getBoundingClientRect();this.seek(o+r*Math.min(1,Math.max(0,(h.clientX-m.left)/m.width)))};u.addEventListener("pointerdown",h=>{u.setPointerCapture(h.pointerId),$(h)}),u.addEventListener("pointermove",h=>h.buttons&&$(h))}return this.rows.set(c,x),x}),l?t("div",{class:"dl-dplace-axis"},_r(this.range,e.now).map(([d,c])=>t("span",{style:`left:${(d*100).toFixed(2)}%`},c))):""]:t("div",{class:"dl-sub"},"No locations in this period.")),this.paintControls()}paintControls(){dom.content(this.play,v(this.playing?"pause":"play")),this.play.title=this.playing?"Pause":"Replay this period",this.play.setAttribute("aria-label",this.play.title),dom.content(this.controls,this.on?[this.play,this.chip,this.stop]:this.st.length>1?[this.play]:[])}begin(){this.on=!0,{steps:this.steps,total:this.total}=Cr(this.st,this.reduced?400:io),this.ms=0,this.stepI=-1,this.map.replay({active:null,when:""},!0)}toggle(){if(this.playing){this.playing=!1,cancelAnimationFrame(this.raf),this.paintControls();return}clearTimeout(this.endTimer),(!this.on||this.ms>=this.total)&&this.begin(),this.playing=!0,this.last=performance.now(),this.paintControls(),this.raf=requestAnimationFrame(e=>this.frame(e))}frame(e){if(this.playing){if(this.ms=Math.min(this.total,this.ms+(e-this.last)),this.last=e,this.show(!0),this.msthis.frame(r));return}this.playing=!1,this.paintControls(),this.endTimer=window.setTimeout(()=>this.end(),1500)}}seek(e){this.st.length<2||(clearTimeout(this.endTimer),this.on||this.begin(),this.ms=Lr(this.st,this.steps,e),this.stepI=-1,this.show(!1),this.paintControls())}show(e){let r=Er(this.st,this.steps,this.ms),o=this.st[r.step.k];if(r.step.kind==="move"){let s=this.st[r.step.k-1];r.i!==this.stepI&&(this.map.replay({active:null,when:""},e),this.map.band([s.point.lon,s.point.lat],[o.point.lon,o.point.lat]));let l=Mr(r.q);this.reduced||this.map.bandAt(l),(this.reduced?r.q>=.5:Sr(l))&&this.map.replay({active:o.key,when:xn(r.t)},e)}else r.i!==this.stepI&&this.map.band(),this.map.replay({active:o.key,when:xn(r.t)},e);this.stepI=r.i;let a=this.data,i=a.now-Or[this.range];this.el.classList.add("replay"),this.el.style.setProperty("--at",uo(r.t-i,a.now-i));for(let[s,l]of this.rows)l.classList.toggle("cur",s===o.key);this.chip.textContent=`${Pr(r.t,a.now)}, ${xn(r.t)} · ${o.point.city||o.point.cc||"?"}`}end(){if(cancelAnimationFrame(this.raf),clearTimeout(this.endTimer),!!this.on){this.on=!1,this.playing=!1,this.ms=0,this.stepI=-1,this.map.band(),this.map.replay(null,!1),this.el.classList.remove("replay");for(let e of this.rows.values())e.classList.remove("cur");this.pending?(this.data=this.pending,this.pending=null,this.map.update(this.mapData()),this.paint()):this.paintControls()}}};function _t(n){return`${L.url("admin/network/dawnline/server")}?${n?`server=${encodeURIComponent(n)}&`:""}section=people`}function ke(n,e){return`${L.url("admin/network/dawnline/person")}?id=${encodeURIComponent(n)}${e?`&device=${encodeURIComponent(e)}`:""}`}function ys(n){return n?new Date(n*1e3).toLocaleString("en-GB",{day:"numeric",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit"}):"—"}function mo(n,e,r=!1){return t("div",{class:"dl-kvrow"},[t("span",{class:"dl-kvrow-k"},n),t("button",{type:"button",class:`dl-kvrow-v copy${r?" dl-mono":""}`,title:"Copy",click:()=>me(e,`${n} copied`)},[t("span",{},e),v("copy")])])}function $n(n,e){return t("div",{class:"dl-kvrow"},[t("span",{class:"dl-kvrow-k"},n),t("span",{class:"dl-kvrow-v"},e)])}var jr={connect:["ok","Connected","plug"],disconnect:["","Went offline","plug"],roam:["","Changed network","network"],device_added:["ok","Added","plus"],device_removed:["","Removed","trash"],device_keys:["","New keys","reset"]};function ks(n,e,r){let o=n.filter(a=>a.device===e&&jr[a.type]).reverse().slice(0,12);return o.length?t("div",{class:"dl-dev-log"},o.map(a=>{let[i,s,l]=jr[a.type],d=a.type==="connect"?[a.detail?t("span",{class:"dl-muted"},` from ${a.detail}`):"",a.where?t("span",{class:"dl-muted"},` · ${a.where}`):""]:a.type==="roam"?[t("span",{class:"dl-muted"},` · ${a.detail??""}`)]:a.type==="device_added"||a.type==="device_removed"||a.type==="device_keys"?[t("span",{class:"dl-muted"},Ne(a)==="portal"?" on the portal":Ne(a)==="admin"?" by you":"")]:[],c=new Date(a.ts*1e3);return t("div",{class:`dl-dev-log-row${Ne(a)==="admin"?" dl-ev-by-admin":""}`},[Ne(a)==="admin"?t("span",{class:"dl-ev-tile",title:"Done by you in LuCI"},v("admin")):t("span",{class:`dl-ev-tile ev ${i}`},v(l)),t("span",{class:"dl-row-main"},[t("span",{},s),...d]),t("span",{class:"dl-faint dl-nowrap",title:c.toLocaleString()},re(a.ts,r))])})):t("div",{class:"dl-sub"},"No activity yet.")}async function Ur(n,e,r){let o=await P.status(1).catch(()=>null),a=o?.people.find(s=>s.id===n),i=a?.devices.find(s=>s.id===e);o&&a&&i&&Ge(a,i,{...r,geo:o.geo,now:o.now,today:Ie(o.series),core:St(o.servers,a.server)})}async function Ge(n,e,r){let o=await G(()=>P.deviceConfig(e.id));if(!o)return;let a=r.core??Be(null),i=e,s=n,l=r.geo,d=r.now,c=r.today??je(new Date),p=await a.connectBlock(o,e.kind==="phone"||e.kind==="tablet"?"qr":"file"),u=t("div",{class:"dl-drawer-title"}),x=t("div",{}),$=t("div",{}),h=t("div",{},t("div",{class:"dl-sub"},"Loading…")),m=[],E=ee=>{m=ee.filter(B=>B.device===i.id),dom.content(h,ks(ee,i.id,d)),y?.update({events:ee})},R=async(ee=!1)=>{let B=r.events?.();if(B&&!ee)return E(B);let F=await P.events(2e3,n.id).catch(()=>null);F&&E(F.events)},C="30d",k=null,y=null,w=()=>{dom.content(u,[t("span",{class:`dl-dcard-ic${i.online?" on":""}`},v(i.kind)),t("div",{class:"dl-stack"},[t("div",{class:"dl-title-row"},[t("h3",{},i.name),D([v("edit")],()=>f(),"neutral",{title:"Rename",class:"cbi-button cbi-button-neutral dl-icon-only sm"})]),t("span",{class:"dl-sub"},`${s.name} · ${Qe[i.kind]}`)])]);let ee=i.spark.reduce((B,F)=>B+F,0);dom.content(x,t("div",{class:"dl-dstats"},[t("div",{class:"dl-dstats-cell wide"},[t("span",{class:"dl-metric-label"},"Status"),nn(i,d,"Waiting for the first connection",s)]),t("div",{class:"dl-dstats-cell"},[t("span",{class:"dl-metric-label"},"This month"),t("b",{},X(i.month[0]+i.month[1])),t("span",{class:"dl-sub dl-mono"},`↓ ${X(i.month[1])} ↑ ${X(i.month[0])}`)]),t("div",{class:"dl-dstats-cell"},[t("span",{class:"dl-metric-label"},"Last 7 days"),t("b",{},X(ee)),lr(i.spark,120,22,c)])])),dom.content($,t("div",{class:"dl-kv2"},[mo("Tunnel address",i.address),i.hostname&&s.access!=="internet"?mo("Local address",i.hostname):"",i.endpoint&&!l?.points.some(B=>B.device===i.id&&B.ip===i.endpoint)?$n("Client IP",i.endpoint):"",$n("Total",t("span",{class:"dl-kv-act"},[`↓ ${X(i.total[1])} · ↑ ${X(i.total[0])}`,t("button",{type:"button",class:"dl-linkbtn danger",click:()=>Mt("device",i.id,i.name,()=>setTimeout(H,300))},"Reset")])),$n("Added",`${ys(i.created)} · ${i.created_by==="portal"?"from the portal":"by you"}`),o.amnezia.client_pub_key?mo("Public key",o.amnezia.client_pub_key):$n("Public key","—")])),dom.content(g,[D([v(i.disabled?"play":"pause"),i.disabled?" Enable":" Disable"],async()=>{await G(()=>P.deviceUpdate(i.id,void 0,!i.disabled),i.disabled?"Device enabled":"Device disabled")&&await H()},"neutral",i.disabled?{}:{class:"cbi-button cbi-button-neutral dl-btn-warn"}),D([v("key")," New keys"],async()=>{if(!await se("Generate new keys?","The current configuration on this device stops working until it is imported again.","Generate",!0))return;await G(()=>P.deviceRotate(i.id),"New keys generated")&&(r.refresh(),de.close(),await Ur(s.id,i.id,r))}),t("span",{class:"dl-spacer"}),D([v("trash")," Remove"],async()=>{await se(`Remove ${i.name}?`,"The device is disconnected immediately and its configuration stops working.","Remove",!0)&&await G(()=>P.deviceDelete(i.id),"Device removed")&&(de.close(),r.refresh())},"negative")])},b=async()=>{let ee=await P.status(1).catch(()=>null),B=ee?.people.find(ne=>ne.id===s.id),F=B?.devices.find(ne=>ne.id===i.id);!ee||!B||!F||(s=B,i=F,l=ee.geo,d=ee.now,c=Ie(ee.series),w(),y?.update({geo:ee.geo,now:ee.now,person:s,device:i}))},H=async()=>{await b(),r.refresh()},f=()=>{let ee=t("input",{type:"text",class:"cbi-input-text",value:i.name,maxlength:48}),B=s.devices.filter(ne=>ne.id!==i.id).map(ne=>ne.name),F=ye("Name",ee,()=>_e(ee.value,B,"Shown in the portal and in the app."));oe(`Rename ${i.name}`,[F],[ie()," ",D("Save",async()=>{let ne=F.help();if(ne.bad){U(ne.text,"warning");return}await G(()=>P.deviceUpdate(i.id,ee.value,void 0),"Renamed")&&(ae(),await H())},"positive")]),setTimeout(()=>ee.select(),50)},g=t("div",{class:"dl-drawer-actions"}),M=t("section",{class:"dl-dsec"},[t("div",{class:"dl-dsec-head"},[t("h4",{},"Connect")]),i.config_stale?t("div",{class:"dl-note warn"},[v("alert"),t("span",{},"This device has an older configuration: networks or DNS changed since it was set up. Import it again with the QR code, key or file below.")]):"",p]),T=t("section",{class:"dl-dsec"},[t("div",{class:"dl-dsec-head"},[t("h4",{},"Activity"),t("div",{class:"dl-dsec-actions"},[t("button",{type:"button",class:"dl-linkbtn",click:()=>Fe({people:[s]},m,"csv",i.id)},"Export"),t("button",{type:"button",class:"dl-linkbtn danger",click:()=>et(`Clear ${i.name}'s activity`,`Removes events about ${i.name}.`,{device:i.id},()=>{R(!0),r.refresh()})},"Clear"),t("a",{href:`${L.url("admin/network/dawnline/diagnostics")}?tab=log`},"All activity")])]),h]),z=t("section",{class:"dl-dsec"},[t("div",{class:"dl-dsec-head"},t("h4",{},"Details")),$]),W="";if(l?.enabled){k=new tt({openPerson:B=>location.href=ke(B),openDevice:(B,F)=>location.href=ke(B,F)},C,220);let ee=y=new kn(k,C,{geo:l,now:d??Date.now()/1e3,person:s,device:i,events:r.events?.()??null});W=t("section",{class:"dl-dsec"},[t("div",{class:"dl-dsec-head"},[t("h4",{},"Locations"),Tt(C,B=>{C=B,ee.setRange(B)},!1)]),t("div",{class:"dl-dmap"},[k.el,ee.controls]),ee.el])}let q=!i.handshake||i.config_stale,Z=t("div",{class:"dl-stack gap16"},q?[x,M,z,W,T]:[x,z,W,T,M]);R();let I=()=>{b(),R()},V=bn(I),Q=window.setInterval(I,3e4),de=Oo(u,Z,g,()=>{clearInterval(Q),V(),y?.destroy(),k?.destroy()});w(),k&&y&&requestAnimationFrame(()=>y&&k?.mount(y.mapData()))}function Gr(n,e,r,o){let a=o.core??Be(null),i=()=>G(()=>P.deviceConfig(r.id)),s=[{label:"Show QR code",icon:v("qr"),run:async()=>{let l=await i();l&&oe(`${r.name} · QR code`,t("div",{class:"dl-qr-pane"},[an(a.qrText(l)),t("span",{class:"dl-sub"},no(l)?"Scan with AmneziaVPN or any WireGuard app on the device.":"Scan with AmneziaVPN or AmneziaWG on the device.")]),ie("Close"))}},{label:a.file.label,icon:v("download"),run:async()=>{let l=await i();if(!l)return;let d=a.file.make(l);Te(d.name,d.text,"application/octet-stream")}},a.appKey?{label:a.appKey.label,icon:v("copy"),run:async()=>{let l=await i();l&&me(await a.appKey.make(l),"Key copied")}}:null,null,{label:"Rename",icon:v("edit"),run:()=>Ge(e,r,o)},{label:"New keys",icon:v("key"),run:async()=>{await se("Generate new keys?","The current configuration on this device stops working until it is imported again.","Generate",!0)&&await G(()=>P.deviceRotate(r.id),"New keys generated")&&o.refresh()}},{label:r.disabled?"Enable":"Disable",icon:v(r.disabled?"play":"pause"),warn:!r.disabled,run:async()=>{await G(()=>P.deviceUpdate(r.id,void 0,!r.disabled),r.disabled?"Device enabled":"Device disabled")&&o.refresh()}},{label:"Delete",icon:v("trash"),danger:!0,run:async()=>{await se(`Remove ${r.name}?`,"The device is disconnected immediately and its configuration stops working.","Remove",!0)&&await G(()=>P.deviceDelete(r.id),"Device removed")&&o.refresh()}}];Ce(n,s)}function nt(n,e){let r=n.devices.map(c=>c.name),o=c=>{let p=Qe[c],u=1,x=p;for(;r.some($=>$.toLowerCase()===x.toLowerCase());)x=`${p} ${++u}`;return x},a="phone",i=t("input",{type:"text",class:"cbi-input-text",placeholder:o(a),maxlength:48}),s=ye("Name",i,()=>i.value.trim()?_e(i.value,r,"Shown in the portal and in the app."):{text:`Named after its type: ${o(a)}.`,bad:!1}),l=t("div",{class:"dl-kinds",role:"radiogroup","aria-label":"Type"},No.map(c=>t("button",{type:"button",role:"radio",class:c===a?"on":"","aria-checked":c===a?"true":"false","data-kind":c,click:()=>{a=c,l.querySelectorAll("button").forEach(p=>{let u=p.dataset.kind===c;p.classList.toggle("on",u),p.setAttribute("aria-checked",u?"true":"false")}),i.placeholder=o(c),s.refresh()}},[v(c),t("span",{},Qe[c])]))),d=n.devices.length>=n.device_limit;oe(`Add a device for ${n.name}`,[d?t("p",{class:"dl-hint"},`${n.name} already has ${n.devices.length} of ${n.device_limit} devices. As admin you can still add one.`):"",t("div",{class:"dl-fld"},[t("span",{class:"dl-fld-label"},"Type"),l]),s],[ie()," ",D("Add device",async()=>{let c=s.help();if(c.bad){U(c.text,"warning");return}let p=i.value.trim()||o(a),u=await G(()=>P.deviceCreate(n.id,p,a));u&&(ae(),U(`${p} added`,"success",3e3),e.refresh(),await Ur(n.id,u.id,e))},"positive")]),setTimeout(()=>i.focus(),50)}var Ve=1080,Ft=1512,We=96,$s="-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif",Cs="ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",Wt=n=>n.replace(/[&<>"']/g,e=>({"&":"&","<":"<",">":">",'"':""","'":"'"})[e]);function Es(n,e,r){let o=new URL(r),a=o.pathname.slice(1),i=Math.min(92,Math.floor((Ve-2*We)/(.58*(4+n.name.length)))),s=Ve-2*We,l=392,d=40,c=rn(r,2).replace("`${m}`;return``+p(We+82,We+42,36,"#a3a3a3",Wt(e))+p(We,276,i,"#ffffff",`Hi, ${Wt(n.name)}`,'font-weight="600"')+p(We,340,40,"#8a8a8a",`Scan to connect to ${Wt(e)}`)+``+c+`${Wt(a)}`+p(Ve/2,l+s+156,34,"#737373",Wt(o.host),'text-anchor="middle"')+""}async function Ls(n){let e=new Image;e.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(n)}`,await e.decode();let r=document.createElement("canvas");return r.width=Ve,r.height=Ft,r.getContext("2d").drawImage(e,0,0,Ve,Ft),new Promise((o,a)=>r.toBlob(i=>i?o(i):a(new Error("Could not draw the card")),"image/png"))}async function Wr(n){let e=await G(()=>P.personLinks(n));return e?e.link?{link:e.link,links:e.links??[]}:(U("The personal portal is off. Turn it on in Settings.","warning"),null):null}async function Cn(n){let e=await Wr(n);e&&await me(e.link,"Personal link copied")}async function qt(n,e,r={}){let o=n.link,a=n.links;if(o===void 0){let m=await Wr(n.id);if(!m)return;o=m.link,a=m.links}if(!o){U("The personal portal is off. Turn it on in Settings.","warning");return}let i=o,s=await G(()=>Ls(Es(n,e,i)));if(!s)return;let l=new File([s],`${n.id}-invite.png`,{type:"image/png"}),d=URL.createObjectURL(s),c=navigator,p=!!c.canShare?.({files:[l]}),u=!p&&typeof c.share=="function"&&(c.canShare?.({url:i})??!0),x=()=>{URL.revokeObjectURL(d),ae()},$=async m=>{try{await c.share(m)}catch{}},h=p?D([v("link")," Share card"],()=>$({files:[l],title:`Invite ${n.name}`}),"positive"):u?D([v("link")," Share link"],()=>$({url:i,title:`Invite ${n.name}`,text:"Your personal VPN link"}),"positive"):D([v("download")," Download card"],()=>Te(l.name,s),"positive");oe(r.title??`Invite ${n.name}`,t("div",{class:"dl-invite"},[t("img",{src:d,alt:`Invite card for ${n.name}`}),t("div",{class:"dl-invite-side"},[t("p",{class:"dl-muted"},r.lead??`Send ${n.name} the card or the link. They open it, add their devices and connect — no account needed.`),t("button",{type:"button",class:"dl-invite-link",title:"Copy link",click:()=>me(i,"Personal link copied")},[t("span",{},i.replace(/^https:\/\//,"")),v("copy")]),...(a??[]).filter(m=>m!==i).map(m=>t("button",{type:"button",class:"dl-invite-link alt",title:"Copy this link",click:()=>me(m,"Link copied")},[t("span",{},m.replace(/^https?:\/\//,"")),t("span",{class:`dl-pill ${m.startsWith("http:")?"warn":""}`},m.startsWith("http:")?"HTTP":"Also"),v("copy")])),t("ol",{class:"dl-invite-steps"},[t("li",{},["Install ",t("b",{},"AmneziaVPN")," on the device"]),t("li",{},"Open the link or scan the code"),t("li",{},"Add the device and connect")]),t("div",{class:"dl-invite-actions"},[h,D([v("copy")," Copy link"],()=>me(i,"Personal link copied"))])])]),[t("button",{class:"cbi-button cbi-button-neutral",click:x},"Done")],"wide")}function Kt(n,e){let r=n.servers.find(d=>d.id===e)??n.servers[0],o=n.people.filter(d=>d.server===r.id),a=new Set(o.map(d=>d.id)),i=o.flatMap(d=>d.devices),s=d=>o.reduce((c,p)=>{let u=d(p);return[c[0]+u[0],c[1]+u[1]]},[0,0]),l=r.series?.[r.series.length-1];return{...n,servers:[r],people:o,series:r.series??n.series,events:n.events.filter(d=>d.person?a.has(d.person):!0),geo:{...n.geo,points:n.geo.points.filter(d=>a.has(d.person))},totals:{people:o.length,devices:i.length,online:i.filter(d=>d.online).length,active:o.filter(d=>d.state==="active").length,today:l?[l.rx,l.tx]:[0,0],month:s(d=>d.month)}}}var Fr=3,ho=class{constructor(){this.n=0;this.shown=0}next(){return++this.n}take(e){return e{let x=e.next(),$=null;try{$=await n.fetch(u),r>=Fr&&U("The router answers again.","success",3e3),r=0}catch{return++r===Fr&&U("The router is not answering: what you see may be out of date.","warning",8e3),null}return $==null||!e.take(x)?null:(n.apply($,p),$)},a=(p=!1)=>o(p,!1),i=()=>document.visibilityState==="visible",s=()=>i()&&(n.active?.()??!0)?o(!0,!1):Promise.resolve(null);poll.add(s,n.every);let l=n.live?bn(()=>void(i()&&(n.active?.()??!0)&&o(!0,!0))):null,d=()=>{poll.remove(s),l?.(),c()},c=$e(d);return{refresh:a,claim:()=>e.claim(),stop:d}}function Pt(n){let e=document.activeElement;return!!n&&!!e&&e!==document.body&&n.contains(e)}function Se(n,e,r=!1){return r&&Pt(n)?!1:(dom.content(n,e),!0)}function qr(n,e){let r=n,a=t("div",{class:"dl-choices"},[{v:"internet",ic:"globe",text:"Browse the internet through your router. No access to devices at home."},{v:"lan",ic:"home",text:"Reach devices at home (NAS, printer, cameras). Internet stays on their own connection."},{v:"both",ic:"shield",text:"Home devices and the internet, all through your router."}].map(i=>t("button",{type:"button",class:`dl-choice${i.v===r?" selected":""}`,"data-v":i.v,click:()=>{r=i.v,a.querySelectorAll(".dl-choice").forEach(s=>s.classList.toggle("selected",s.dataset.v===i.v)),e?.(i.v)}},[t("span",{class:"dl-choice-title"},[v(i.ic),dt[i.v]]),t("span",{class:"dl-choice-text"},i.text)])));return{el:a,get:()=>r}}function fo(n){try{return localStorage.getItem(n)}catch{return null}}function go(n,e){try{localStorage.setItem(n,e)}catch{}}function Ms(n){let e=n.devices.length,r=Math.max(1,n.device_limit,e),o=Math.min(160,r*22+(r-1)*3);return t("div",{class:"dl-slotbar",title:`${e} of ${n.device_limit} devices`},[t("span",{class:"dl-slotbar-segs",style:`width: ${o}px`},Array.from({length:r},(a,i)=>t("i",{class:i>=n.device_limit?"over":in.state==="server_off"?n.paused:!["active","quota","expired"].includes(n.state),vo=n=>n.state==="server_off"?n.paused:n.state!=="active",Vr=n=>vo(n)?n.state==="server_off"?"paused":n.state:null;function Ss(n,e){let r=Ye(n.expires,e);return n.state==="quota"||n.state==="expired"||Ze(n,r)||!!n.quota_limit&&n.quota_used>=n.quota_limit*.9}function Jr(n,e){return bt(n&&Vn(n,e)>=0?n:e,1)}var Yr=n=>n.people.map(e=>e.id).sort().join(" "),Zr=!1,mt=class{constructor(){this.list=t("div",{class:"dl-plist",role:"list"});this.filter=["all","online","attention","paused"].find(e=>e===(new URLSearchParams(location.search).get("filter")??fo("dl.people.filter")))??"all";this.sort=["seen","name","usage"].find(e=>e===fo("dl.people.sort"))??"seen";this.query="";this.noFooter=!0;this.serverId=null;this.el=null}async load(){return P.status(30)}scope(e){return this.serverId?Kt(e,this.serverId):e}embed(e,r){return this.serverId=r,this.render(e)}person(e){return this.st.people.find(r=>r.id===e)}get today(){return Ie(this.st.series)}deviceOpts(e){return{refresh:()=>this.refresh(),geo:this.st.geo,now:this.st.now,today:this.today,core:St(this.st.servers,e.server)}}take(e,r){let o=this.scope(e),a=Yr(o)!==Yr(this.st);this.st=o,a?this.rebuild():(this.paintCards(r),this.decorate(r))}async update(){await this.poller?.refresh()}async refresh(){this.poller?.claim();let e=await P.status(30).catch(()=>null);e&&(this.st=this.scope(e),this.rebuild())}rebuild(){let e=new Map;for(let o of Array.from(this.list.children))o.dataset.sid&&e.set(o.dataset.sid,o);let r=this.st.people.map(o=>{let a=e.get(o.id)??t("div",{class:"dl-card",role:"listitem","data-sid":o.id});return this.renderCard(a,o.id)});dom.content(this.list,r.length?r:t("div",{class:"dl-plist-none"},this.st.servers.length?"No people yet. Add someone and send them their personal link.":"Set up the server first, then add people.")),this.decorate()}paintCards(e=!1){for(let r of this.st.people){let o=this.card(r.id);o&&!(e&&Pt(o))&&this.renderCard(o,r.id)}}card(e){return this.list.querySelector(`[data-sid="${CSS.escape(e)}"]`)}render(e){let r=this.scope(e);this.st=r;let o=this,a=t("select",{class:"dl-select","aria-label":"Sort",change:d=>{o.sort=d.target.value,go("dl.people.sort",o.sort),o.decorate()}},[t("option",{value:"seen",selected:o.sort==="seen"?"selected":null},"Last seen"),t("option",{value:"name",selected:o.sort==="name"?"selected":null},"Name"),t("option",{value:"usage",selected:o.sort==="usage"?"selected":null},"Usage")]),i=t("input",{type:"search",class:"cbi-input-text dl-people-find",placeholder:"Find…","aria-label":"Find a person or device",hidden:r.people.length>8?null:"hidden",input:d=>{o.query=d.target.value.trim().toLowerCase(),o.decorate()}}),s=d=>{let c=d.target;d.key==="/"&&!i.hidden&&!["INPUT","TEXTAREA","SELECT"].includes(c?.tagName)&&!c?.isContentEditable&&(d.preventDefault(),i.focus())};document.addEventListener("keydown",s),$e(()=>document.removeEventListener("keydown",s));let l=t("div",{class:"dl-root"},[o.serverId?"":t("div",{class:"dl-pagehead"},[t("div",{class:"dl-stack"},[t("h2",{class:"dl-h1"},"People"),t("span",{class:"dl-muted dl-people-count"},this.countText())]),r.servers.length?D([v("plus")," Add person"],()=>o.openCreate(),"add"):""]),r.servers.length?"":t("div",{class:"alert-message warning"},["No server yet. ",t("a",{href:L.url("admin/network/dawnline/server")},"Run the setup wizard")," before adding people."]),t("div",{class:"dl-toolbar"},[t("div",{class:"dl-seg dl-people-tabs",role:"tablist"}),t("div",{class:"dl-toolbar-end"},[i,a,o.serverId?D([v("plus")," Add person"],()=>o.openCreate(),"add"):""])]),this.list]);return this.el=l,this.rebuild(),this.poller??(this.poller=ot({fetch:()=>P.status(30),every:30,live:!0,active:()=>!!o.el?.isConnected,apply:(d,c)=>o.take(d,c)})),!Zr&&new URLSearchParams(location.search).get("add")&&(Zr=!0,setTimeout(()=>o.openCreate(),100)),Promise.resolve(l)}countText(){let e=this.st.totals;return`${e.people} ${e.people===1?"person":"people"} · ${e.devices} device${e.devices===1?"":"s"} · ${e.online} online`}decorate(e=!1){let r=this.el?.querySelector(".dl-people-count");r&&(r.textContent=this.countText());let o=this.st.people,a=this.today,i=m=>Ss(m,a),s={all:o.length,online:o.filter(m=>m.online>0).length,attention:o.filter(i).length,paused:o.filter(m=>Kr(m)).length},l=this.el?.querySelector(".dl-people-tabs");if(l&&!(e&&Pt(l))){let m={all:"All",online:"Online",attention:"Needs attention",paused:"Paused"};dom.content(l,Object.keys(m).map(E=>t("button",{type:"button",role:"tab",class:E===this.filter?"on":"",click:()=>{this.filter=E,go("dl.people.filter",E),this.decorate()}},[m[E],t("b",{class:E==="attention"&&s[E]?"warn":""},String(s[E]))])))}let d=this.query,c=m=>[m.name,m.note??"",...m.devices.flatMap(E=>[E.name,E.address,E.hostname,E.endpoint])].join(" ").toLowerCase(),p=m=>!(this.filter==="online"&&!m.online||this.filter==="attention"&&!i(m)||this.filter==="paused"&&!Kr(m)||d&&!c(m).includes(d)),u=m=>Vr(m)==="paused"?2:vo(m)?1:0,x=[...o].sort((m,E)=>u(m)-u(E)||(this.sort==="name"?m.name.localeCompare(E.name):this.sort==="usage"?E.month[0]+E.month[1]-(m.month[0]+m.month[1]):E.online-m.online||E.last_seen-m.last_seen)),$=0;for(let m of x){let E=this.card(m.id);if(!E)continue;this.list.appendChild(E),E.classList.toggle("dl-off",vo(m));let R=p(m);E.classList.toggle("dl-filtered",!R),R&&$++}let h=this.el?.querySelector(".dl-people-none")??null;o.length&&!$?(h??(h=t("div",{class:"dl-empty dl-people-none"},t("p",{},"No one here right now."))),h.previousElementSibling!==this.list&&this.list.after(h)):h?.remove()}async quick(e,r,o){await G(()=>P.personUpdate(e.id,r),o)&&await this.update()}renderCard(e,r){let o=this.person(r);if(!o)return dom.content(e,t("em",{},"This person was just removed.")),e;let a=this.today,i=Ye(o.expires,a),s=Math.max(0,o.device_limit-o.devices.length),l=o.has_link??this.st.settings.portal_enabled,d=[],c=Vr(o);if(o.expires&&c!=="expired"){let h=Ze(o,i),m=i!=null&&i<0;d.push(t("span",{class:`dl-pill-ic${m?" bad":h?" warn":""}`,title:`Access ends ${Me(o.expires)}`},[v("calendar"),m?`ended ${Me(o.expires)}`:h?Xt(i):`until ${Me(o.expires)}`]))}o.hours&&c!=="hours"&&d.push(t("span",{class:"dl-pill-ic",title:"Allowed hours"},[v("clock"),o.hours.replace("-","–")]));let p=tn(o.devices).map(h=>t("button",{type:"button",class:`dl-chip${h.disabled?" disabled":""}${h.online?" live":""}`,title:`${Qe[h.kind]} · ${h.address}${h.online?` · online from ${h.endpoint}`:h.handshake?` · seen ${re(h.handshake,this.st.now)}`:""}`,click:m=>{m.preventDefault(),Ge(o,h,this.deviceOpts(o))}},[v(h.kind),t("span",{class:"dl-chip-name"},h.name),!h.handshake&&!h.disabled?t("span",{class:"dl-chip-tag"},"not set up"):""]));p.push(t("button",{type:"button",class:"dl-chip add",title:s>0?"Add device":"Over the limit: admins can still add",click:h=>{h.preventDefault(),nt(o,this.deviceOpts(o))}},[v("plus"),"Add device"]));let u=[];o.expires&&Ze(o,i)&&c!=="expired"&&u.push(t("button",{type:"button",class:"dl-fix",click:()=>this.quick(o,{expires:Jr(o.expires,a)},"Extended by 1 month")},"Extend 1 month"));let x=Le("more","More",h=>Ce(h.currentTarget,[{label:"Open",icon:v("open"),run:()=>{location.href=ke(o.id)}},l?{label:"Invite card",icon:v("qr"),run:()=>qt(o,this.st.servers.find(m=>m.id===o.server)?.name??"Home")}:null,s>0?{label:"Add device",icon:v("plus"),run:()=>nt(o,this.deviceOpts(o))}:null,null,{label:o.paused?"Resume":"Pause",icon:v(o.paused?"play":"pause"),warn:!o.paused,run:()=>this.togglePause(o)},{label:"Delete",icon:v("trash"),danger:!0,run:()=>this.remove(o.id)}].filter((m,E,R)=>m||E>0&&R[E-1])),"neutral","dl-icon-only"),$=t("div",{class:"dl-pcard-actions"},[l?Le("link","Copy link",()=>Cn(o.id),"neutral","dl-icon-only"):"",x]);return dom.content(e,t("div",{class:"dl-pcard"},[t("div",{class:"dl-pcard-main"},[t("div",{class:"dl-pcard-top"},[t("span",{class:`dl-avatar${o.online?" online":""}`},He(o.name)),t("div",{class:"dl-pcard-who"},[t("div",{class:"dl-card-head"},[t("a",{class:"dl-card-name",href:ke(o.id)},o.name),Bo(o),...d]),Ms(o)])]),t("div",{class:"dl-chips"},p),u.length?t("div",{class:"dl-fixes"},u):""]),this.usageSide(o,$),c?this.stopStrip(o,c):""])),e}stopStrip(e,r){let o=this.today,a=bt(`${o.slice(0,8)}01`,1),i=()=>this.quick(e,{bonus_gb:String((e.bonus_gb||0)+10)},"+10 GB this month"),s={paused:["pause","warn","Paused","Devices can’t connect until you resume",["play","Resume",()=>this.togglePause(e)]],quota:e.quota_period==="month"?["chart","bad","Data limit reached",`Paused until it resets on ${Me(a)}`,["plus","+10 GB this month",i]]:["chart","bad","Data limit reached","Paused until the limit is raised",["edit","Change limit",()=>location.href=ke(e.id)]],expired:["calendar","bad",`Access ended ${Me(e.expires)}`,"Devices can’t connect",["calendar","Extend 1 month",()=>this.quick(e,{expires:Jr(e.expires,o)},"Extended by 1 month")]],hours:["clock","warn","Outside allowed hours",`Access ${e.hours.replace("-","–")} (router time)`,null],no_server:["alert","warn","No server","Choose a server on their page",null]},[l,d,c,p,u]=s[r];return t("div",{class:`dl-pstrip ${d}`},[t("span",{class:`dl-need-ic ${d}`},v(l)),t("span",{class:"dl-pstrip-text"},[t("b",{},c),t("span",{class:"dl-faint"},p)]),u?D([v(u[0]),` ${u[1]}`],u[2]):""])}usageSide(e,r){let o=e.quota_used||e.month[0]+e.month[1],a=e.quota_limit?Math.min(100,e.quota_used/e.quota_limit*100):0,i=e.devices.reduce((p,u)=>p+(u.spark[u.spark.length-1]??0),0),s=e.rate?.[e.rate.length-1],l=e.online&&s&&this.st.now-s[0]<180,d=t("div",{class:`dl-usebar${a>=100?" bad":a>=90?" warn":""}`});if(e.quota_limit){let p=t("i",{class:"fill"});p.style.width=`${a}%`,d.appendChild(p),he(d,()=>[t("div",{class:"dl-tip-title"},`${a.toFixed(1)}% used`),t("div",{class:"dl-muted"},`${X(e.quota_used)} of ${X(e.quota_limit)} · ${X(Math.max(0,e.quota_limit-e.quota_used))} left`),t("div",{class:"dl-faint"},e.quota_period==="total"?"In total":`This month${e.bonus_gb?` · includes +${e.bonus_gb} GB extra`:""}`)])}else{let p=e.devices.map(u=>({d:u,v:u.month[0]+u.month[1]})).filter(u=>u.v>0).sort((u,x)=>x.v-u.v);p.forEach((u,x)=>{let $=t("i",{class:`c${Math.min(x,4)}`});$.style.flexGrow=String(u.v),d.appendChild($)}),p.length&&he(d,()=>[t("div",{class:"dl-tip-title"},"This month by device"),...p.map((u,x)=>t("div",{class:"dl-tip-row"},[t("span",{class:`dl-swatch c${Math.min(x,4)}`}),t("span",{},u.d.name),t("b",{},X(u.v))]))])}let c=e.quota_limit?`${X(Math.max(0,e.quota_limit-e.quota_used))} left`:"no limit";return t("div",{class:"dl-pside"},[t("div",{class:"dl-pside-top"},[l?t("span",{class:"dl-pside-state live"},"Online"):t("span",{class:"dl-pside-state"},e.online?"Online":e.last_seen?"Offline":"Never connected"),r]),t("div",{class:"dl-use-num"},[t("b",{class:o?"":"dl-faint"},X(o)),t("span",{class:"dl-faint"},e.quota_limit?`of ${X(e.quota_limit)}`:e.quota_period==="total"&&e.quota_gb?"in total":"this month")]),d,l?t("div",{class:"dl-use-live",title:"Right now"},[`↓ ${Oe(s[2])}`,t("span",{class:"dl-faint"},`↑ ${Oe(s[1])}`)]):t("div",{class:"dl-faint dl-pside-foot"},i?`today ${X(i)} · ${c}`:c)])}async togglePause(e){await G(()=>P.personPause(e.id,!e.paused),e.paused?`${e.name} resumed`:`${e.name} paused`)&&await this.refresh()}async remove(e){let r=this.person(e);await se(`Remove ${r?.name??e}?`,`All ${r?.devices.length??0} devices are disconnected immediately and the personal link stops working. Usage history is kept in backups.`,"Remove",!0)&&await G(()=>P.personDelete(e),"Person removed")&&await this.refresh()}openCreate(){let e=this.st;if(!e.servers.length){U("Set up the server first.","warning");return}let r=t("input",{type:"text",class:"cbi-input-text",placeholder:"e.g. Myata",maxlength:48}),o=(()=>{try{return JSON.parse(fo("dl.person.last")??"{}")}catch{return{}}})(),a=qr(o.access??"internet"),i=t("input",{type:"number",class:"cbi-input-text",min:1,max:32,value:e.settings.default_device_limit}),s=t("input",{type:"date",class:"cbi-input-text"}),l=t("input",{type:"number",class:"cbi-input-text",min:0,step:"any",placeholder:"Unlimited",value:o.quota??""}),d=(C,k)=>t("button",{type:"button",class:"cbi-button cbi-button-neutral",click:()=>{s.value=k?bt(Ie(e.series),k):"",s.dispatchEvent(new Event("change"))}},C),c=e.servers[0],p=!this.serverId&&e.servers.length>1?t("select",{class:"cbi-input-select"},e.servers.map(C=>t("option",{value:C.id},C.name))):null,u=(C,k,y)=>t("div",{class:"cbi-value"},[t("label",{class:"cbi-value-title"},C),t("div",{class:"cbi-value-field"},[k,y?t("div",{class:"cbi-value-description"},y):""])]),x=Ie(e.series),$=ye("Name",r,()=>_e(r.value,[],"Shown in their portal and apps.")),h=ye("Devices",i,()=>cn(i.value)),m=ye("End date",s,()=>Xo(s.value,x,Ye,Me),t("div",{class:"dl-actions"},[s,d("1 month",1),d("3 months",3),d("1 year",12),d("None",0)])),E=ye("Monthly data (GB)",l,()=>pn(l.value));s.addEventListener("change",()=>m.refresh());let R=e.settings.portal_enabled;oe("Add person",[$,p?u("Server",p):"",t("div",{class:"cbi-value dl-block"},[t("label",{class:"cbi-value-title"},"Access"),t("div",{class:"cbi-value-field"},a.el)]),h,m,E],[ie()," ",D(R?"Create and copy link":"Create",async()=>{let C=ze([$,h,m,E]);if(C){U(C,"warning");return}let k=await G(()=>P.personCreate(r.value.trim(),"",p?.value??c.id,a.get(),i.value.trim(),s.value,l.value.trim(),"month"));k&&(go("dl.person.last",JSON.stringify({access:a.get(),quota:l.value.trim()})),k.link&&await me(k.link,"Personal link copied",!0),this.showCreated(k.id,r.value.trim(),k.link,e.servers.find(y=>y.id===(p?.value??c.id))?.name??c.name),await this.refresh())},"positive")]),setTimeout(()=>r.focus(),50)}showCreated(e,r,o,a){if(o){qt({id:e,name:r,link:o},a,{title:`${r} is ready`,lead:`Send ${r} the card or the link. They open it, add their devices and connect — no account needed.`});return}let i=this.person(e);oe(`${r} is ready`,[t("p",{},"Created. Turn on the personal portal in Settings to get a link, or add devices for them here.")],[t("button",{class:"cbi-button cbi-button-neutral",click:ae},"Done")," ",t("a",{class:"cbi-button cbi-button-neutral",href:`${L.url("admin/network/dawnline/settings")}?section=portal`},"Open Settings")," ",i?D("Add device",()=>{ae(),nt(i,this.deviceOpts(i))},"positive"):""])}};var En=["#3a83f7","#a78bfa","#f472b6","#f59e0b","#10b981","#22d3ee","#ef4444","#84cc16"],bo=n=>t("i",{class:"dl-circle-dot",style:`background:${En[n?.color??0]??En[0]}`}),rt=n=>n.access==="both"||n.access==="lan"&&!n.services?.length;function Qr(n,e,r){let o=le(n?.name??e.name??"",{placeholder:"NAS"}),a=le(n?.address??e.address??"",{placeholder:"192.168.1.10",class:"cbi-input-text dl-mono"}),i=le((n?.ports??e.ports??[]).join(", "),{placeholder:"All ports, or e.g. 445, 5000",class:"cbi-input-text dl-mono"}),s=ye("Name",o,()=>_e(o.value,[],"Shown to people who may reach it.")),l=ye("Address",a,()=>er(a.value)),d=ye("Ports",i,()=>tr(i.value));oe(n?`Edit ${n.name}`:"Add service",[s,l,d],[ie()," ",D("Save",async()=>{let c=ze([s,l,d]);if(c){U(c,"warning");return}let p=i.value.split(/[ ,]+/).filter(Boolean);await G(()=>P.serviceSet(n?.id??"",o.value,a.value,p),"Saved")&&(ae(),r())},"positive")])}var Ts={_smb:"SMB",_afpovertcp:"AFP",_http:"Web",_https:"Web",_ssh:"SSH",_sftp:"SFTP","_sftp-ssh":"SFTP",_ipp:"Printer",_ipps:"Printer",_printer:"Printer","_pdl-datastream":"Printer",_airplay:"AirPlay",_raop:"AirPlay",_rfb:"Screen sharing",_googlecast:"Cast",_hap:"HomeKit",_rdp:"Remote desktop",_ftp:"FTP"},_s=[["Web",["80","443"]],["SMB",["445"]],["SSH",["22"]]];function Ps(n){let e=new Map;for(let r of n.services){let o=Ts[r.type.split(".")[0]];!o||!r.port||(e.get(o)??e.set(o,new Set).get(o)).add(String(r.port))}return e.size?[...e].map(([r,o])=>[r,[...o].sort((a,i)=>+a-+i)]):_s}function Xr(n,e,r){let o=n,a=null,i=!1,s=null,l=new Set,d=t("div",{class:"dl-list"}),c=t("div",{class:"dl-stack gap8"},t("span",{class:"dl-sub"},"Looking for devices at home…")),p=()=>{let m=o.services;dom.content(d,m.length?m.map(E=>t("div",{class:"dl-row"},[v("home"),t("span",{class:"dl-row-main dl-stack"},[t("b",{},E.name),t("span",{class:"dl-mono dl-faint"},`${E.address}${E.ports.length?` · ports ${E.ports.join(", ")}`:" · all ports"}`)]),D("Edit",()=>Qr(E,{},r)),D([v("trash")],async()=>{await se(`Remove ${E.name}?`,"People limited to this service lose access to it.","Remove",!0)&&await G(()=>P.serviceDelete(E.id),"Removed")&&await r()},"neutral",{title:"Remove","aria-label":`Remove ${E.name}`})])):[t("div",{class:"dl-row dl-muted"},"No services yet: pick ports of a device below.")])};async function u(m,E){if(!l.has(m.address)){l.add(m.address),$();try{let R=o.services.find(k=>k.address===m.address);(E===null?R&&await G(()=>P.serviceDelete(R.id),`${R.name} removed`):await G(()=>P.serviceSet(R?.id??"",R?.name??(m.name||m.address),m.address,E),R?`${R.name} updated`:`${m.name||m.address} added`))&&await r()}finally{l.delete(m.address),$()}}}function x(m){let E=o.services.find(w=>w.address===m.address),R=!!E&&!E.ports.length,C=new Set(E?.ports??[]),k=l.has(m.address),y=(w,b,H)=>qe(w,b,H,{disabled:k?"disabled":null,"aria-busy":k?"true":null});return t("div",{class:"dl-row"},[v(m.services.some(w=>w.type.startsWith("_ipp")||w.type.startsWith("_printer"))?"file":"computer"),t("span",{class:"dl-row-main dl-stack"},[t("b",{},m.name||m.address),t("span",{class:"dl-mono dl-faint"},m.address)]),t("div",{class:"dl-chips-row dl-host-ports"},[y("All ports",R,()=>u(m,R?null:[])),...Ps(m).map(([w,b])=>{let H=!R&&b.every(f=>C.has(f));return y(`${w} ${b.join(", ")}`,H,()=>{let f=new Set(R?[]:C);for(let g of b)H?f.delete(g):f.add(g);u(m,f.size?[...f]:null)})})])])}function $(){if(i)return dom.content(c,t("span",{class:"dl-sub"},"Couldn't read the devices at home."));if(!a)return;let m=a;if(!m.hosts.length)return dom.content(c,t("span",{class:"dl-sub"},"No devices found in the home network right now."));let E=t("details",{class:"dl-params",open:s??!o.services.length?"":null},[t("summary",{},[v("chevron"),t("span",{},"Add from devices at home"),t("span",{class:"dl-pcount"},String(m.hosts.length))]),t("div",{class:"dl-params-body"},[t("span",{class:"dl-sub"},m.mdns?"Ports they announce over Bonjour. Pick what to open, or all ports.":"Devices that got an address from this router. Pick the ports to open, or all ports."),t("div",{class:"dl-list"},m.hosts.map(x))])]);E.addEventListener("toggle",()=>s=E.open),dom.content(c,E)}return P.homeHosts(e).then(m=>{a=m,$()}).catch(()=>{i=!0,$()}),p(),{el:t("div",{class:"dl-stack gap8"},[t("div",{class:"dl-iflead"},[t("div",{class:"dl-iflead-row"},[t("b",{},"Home services"),D([v("plus")," Add service"],()=>Qr(null,{},r))]),t("span",{class:"dl-sub"},"Home-only people can be limited to these instead of whole networks (chosen on their page). Shared by all servers.")]),d,c]),update(m){o=m,p(),$()}}}function Ln(n,e,r,o){let a=new Set(n.circles.filter(m=>m.server===e).map(m=>m.color)),i=r?.color??En.findIndex((m,E)=>!a.has(E));i<0&&(i=0);let s=le(r?.name??"",{placeholder:"Family"}),l=n.people.filter(m=>m.server===e).sort((m,E)=>m.name.localeCompare(E.name)),d=new Set(l.filter(m=>r&&m.circle===r.id).map(m=>m.id)),c=t("div",{class:"dl-swatches",role:"radiogroup","aria-label":"Colour"}),p=()=>dom.content(c,En.map((m,E)=>t("button",{type:"button",role:"radio",class:`dl-swatch${E===i?" on":""}`,style:`--sw:${m}`,"aria-checked":E===i?"true":"false","aria-label":`Colour ${E+1}`,click:()=>{i=E,p()}})));p();let u=t("div",{class:"dl-chips-row"},l.map(m=>{let E=m.circle&&m.circle!==r?.id?n.circles.find(R=>R.id===m.circle):void 0;return t("button",{type:"button",class:`dl-chipbtn${d.has(m.id)?" on":""}`,title:rt(m)?E?`Now in ${E.name}`:"":`${m.name} has no home access: their devices aren't reachable anyway`,click:R=>{d.delete(m.id)||d.add(m.id),R.currentTarget.classList.toggle("on",d.has(m.id))}},[m.name,rt(m)?E?t("b",{},E.name):"":t("b",{},"internet")])})),x=(m,E)=>t("div",{class:"cbi-value"},[t("label",{class:"cbi-value-title"},m),t("div",{class:"cbi-value-field"},E)]),$=n.circles.filter(m=>m.server===e&&m.id!==r?.id).map(m=>m.name),h=ye("Name",s,()=>Jo(s.value,$));oe(r?`Edit ${r.name}`:"New circle",[h,x("Colour",c),x("People",u),t("p",{class:"dl-sub"},"Devices of people in one circle reach each other. A person is in one circle at a time.")],[r?D("Delete",async()=>{await G(()=>P.circleDelete(r.id),`${r.name} deleted`)&&(ae(),o())},"negative"):"",t("span",{class:"dl-spacer"}),ie()," ",D("Save",async()=>{let m=h.help();if(m.bad){U(m.text,"warning");return}await G(()=>P.circleSet(r?.id??"",e,s.value,i,[...d]),"Saved")&&(ae(),o())},"positive")],"dl-circle-modal")}function ea(n,e,r){let o=n.circles.filter(a=>a.server===e);return t("div",{class:"dl-chips-row dl-circles"},[...o.map(a=>{let i=n.people.filter(s=>s.circle===a.id).map(s=>s.name);return t("button",{type:"button",class:"dl-chip",title:`Edit ${a.name}`,click:()=>Ln(n,e,a,r)},[bo(a),t("b",{},a.name),t("span",{class:"dl-faint"},i.length?i.join(", "):"nobody yet")])}),t("button",{type:"button",class:"dl-chip add",title:"New circle","aria-label":"New circle",click:()=>Ln(n,e,null,r)},v("plus"))])}function xo(n,e){let r=n.people.filter(p=>p.server===e.id),o=(p="")=>t("span",{class:"dl-yes"},[v("check"),p]),a=()=>t("span",{class:"dl-faint"},"—"),i=p=>{let u=new Set(p.map(x=>x.access==="lan"&&x.services?.length?"services":x.home_nets?.length?"some":"all"));return u.size||u.add("all"),o([...u].map(x=>({all:"all networks",some:"their networks",services:"services"})[x]).join(" / "))},s=()=>e.mesh==="off"?a():e.mesh==="circles"?o("circle"):o(),l=e.lan_like?"like home":"direct",d=(p,u,x)=>t("tr",{},[t("td",{},[t("b",{},p),t("div",{class:"dl-sub"},`${u.length} ${u.length===1?"person":"people"}`)]),...x.map($=>t("td",{},$))]),c=p=>r.filter(u=>u.access===p);return t("section",{class:"dl-setsec"},[t("div",{class:"dl-setsec-body"},[t("div",{class:"dl-panel-head"},[t("h3",{},"Who reaches what"),t("span",{class:"dl-spacer"}),t("span",{class:"dl-sub"},"From the rules on this server")]),t("div",{class:"dl-reach-wrap"},t("table",{class:"dl-table dl-reach"},[t("tr",{},["","Internet","Home","This router","Each other"].map(p=>t("th",{},p))),d("Internet",c("internet"),[o(l),a(),t("span",{class:"dl-faint"},"DNS"),a()]),d("Home",c("lan"),[t("span",{class:"dl-faint"},"their own"),i(c("lan")),o(),s()]),d("Both",c("both"),[o(l),i(c("both")),o(),s()])])),t("p",{class:"dl-sub"},"Home devices reach the devices of people with home access, on the networks those people reach. Paused, ended and over-the-limit people reach nothing.")])])}function ta(n,e){let r=n.people.filter(c=>c.server===e.id).flatMap(c=>c.devices.map(p=>({id:p.id,label:`${c.name} · ${p.name}`}))).sort((c,p)=>c.label.localeCompare(p.label)),o="@addr",a=(c,p)=>{let u=t("select",{class:"cbi-input-select","aria-label":c},[...r.map(m=>t("option",{value:m.id,selected:m.id===p?"selected":null},m.label)),t("option",{value:o,selected:p===o?"selected":null},"Address")]),x=le("",{placeholder:c,class:"cbi-input-text dl-mono"}),$=t("div",{class:"dl-check-end"},[u,x]),h=()=>x.hidden=u.value!==o;return u.addEventListener("change",h),h(),{el:$,value:()=>u.value===o?x.value.trim():u.value}},i=a("10.0.1.11",r[0]?.id??o),s=a("10.0.1.20:445",o),l=t("div",{class:"dl-stack gap8"}),d=async()=>{let c=await G(()=>P.accessCheck(i.value(),s.value()));if(!c)return;let p=c.steps.findIndex(u=>!u.ok);dom.content(l,[t("div",{class:`dl-verdict ${c.ok?"ok":"bad"}`},[t("b",{},c.ok?"Allowed":"Blocked"),t("span",{class:"dl-sub"},c.ok?"Every step lets it through":`Stops at step ${p+1} of ${c.steps.length}`)]),t("ul",{class:"dl-checks"},c.steps.map(u=>t("li",{},[t("span",{class:`dl-check-icon ${u.ok?"ok":"error"}`},v(u.ok?"check":"x")),t("div",{class:"dl-check-body"},[t("div",{class:"dl-check-title"},u.title),u.detail?t("div",{class:"dl-check-detail"},u.detail):""])])))])};return t("section",{class:"dl-setsec"},[t("div",{class:"dl-setsec-body"},[t("div",{class:"dl-panel-head"},[t("h3",{},"Check access"),t("span",{class:"dl-spacer"}),t("span",{class:"dl-sub"},"Why something does or does not connect")]),t("div",{class:"dl-check-form"},[i.el,t("span",{class:"dl-faint"},"→"),s.el,D("Check",d)]),l])])}var Mn={app:"Dawnline",amneziawg:"AmneziaWG",packages:"System packages",pkgs:"System packages"};function at(n){return(n.startsWith("check")?n.slice(6)||"all":n).split(/[:@ ]/)[0]}function Sn(n){return at(n.action==="check"?`check:${n.component??""}`:n.component??"")}function na(n){return n=Math.max(0,Math.floor(n)),`${Math.floor(n/60)}:${String(n%60).padStart(2,"0")}`}function oa(n,e){return!n?.from&&!n?.to?e:n.from&&n.to&&n.from!==n.to?`${n.from} → ${n.to}`:n.to??n.from??e}function ra(n,e){let r=n.check?.components??{},o=e==="all"?["app","amneziawg","packages"]:[e],a=[],i;for(let l of o){let d=r[l];if(d){if(d.error)return{tone:"warn",text:d.error};l==="packages"&&d.updates?a.push(`${d.updates} system package${d.updates===1?"":"s"}`):l!=="packages"&&d.update&&d.installed&&d.latest&&(a.push(`${Mn[l]} ${d.latest}`),e!=="all"&&(i=d.latest))}}if(a.length)return{tone:"acc",text:`Update available: ${a.join(", ")}`,update:i};let s=o.length===1?r[o[0]]:null;return s?.status==="dev"?{tone:"acc",text:`Installed version is newer than the release (${s.latest})`}:s?.note?{tone:"warn",text:s.note}:{tone:"ok",text:o.length>1?"Everything is up to date":"Latest version is installed"}}function aa(n,e,r,o){return e?n.id===e:r&&n.id===r?!1:n.state==="running"||o>0&&n.started>=o}var ia=n=>new Promise(e=>setTimeout(e,n));async function Vt(n,e,r){let o=r?Sn(r):at(n),a=r?r.action==="check":n.startsWith("check"),i=Date.now(),s=t("b",{},Mn[o]??(o==="all"?"All components":"Dawnline")),l=t("span",{class:"dl-pill dl-mono"},e.version??""),d=t("span",{class:"dl-pill info",hidden:!0}),c=t("span",{},"0:00"),p=t("pre",{class:"dl-log"},"Operation started. Waiting for log output…"),u=t("div",{}),x=t("div",{class:"dl-op-actions"}),$=[],h=f=>dom.content(x,f),m=(f=!1)=>ie("Close",f);oe(e.title,t("div",{class:"dl-op"},[t("div",{class:"dl-op-head"},[s,e.version?l:"",d,t("span",{class:"dl-spacer"}),t("span",{class:"dl-faint dl-op-timer"},[v("clock"),c])]),t("div",{class:"dl-op-loghead"},[t("b",{},"Operation log"),Le("copy","Copy log",()=>me($.join(` +`),"Log copied"))]),p,u]),[x],"wide"),h([t("button",{class:"cbi-button cbi-button-neutral spinning",type:"button",disabled:"disabled"},a?"Checking…":"Working…")]);let E=r??null,R=r?.id,C,k=0,y=f=>{R!==f.id&&(R=f.id,e.onJob?.(f))};if(r)e.onJob?.(r);else try{let f=await P.updatesStatus().catch(()=>null);C=f?.job?.id,k=f?.now??0;let g=await P.updatesRun(n);g.job&&g.job.state==="running"&&g.job.id!==C&&(E=g.job,y(g.job))}catch(f){return $=[be(f)],p.textContent=$[0],dom.content(u,t("div",{class:"dl-comp-status warn"},[v("alert"),t("span",{},be(f))])),h([m(!0)]),U(be(f),"error"),null}let w=null,b=0;for(;;){if(await ia(1e3),w=await P.updatesStatus().catch(()=>null),!w){if(++b>60)break;continue}b=0;let f=w.job;if(!f||!aa(f,R,C,k)){if(Date.now()-i>15e3)break;continue}if(y(f),E=f,f.log.length){$=f.log;let g=p.scrollTop+p.clientHeight>=p.scrollHeight-8;p.textContent=$.join(` +`),g&&(p.scrollTop=p.scrollHeight)}if(l.textContent=oa(f,e.version??""),!l.isConnected&&l.textContent&&s.after(l),c.textContent=na((f.finished??w.now)-f.started),f.state==="running"){d.hidden=!f.phase,d.textContent=f.phase;continue}break}if(p.scrollTop=p.scrollHeight,d.hidden=!1,!E||E.state==="running")return d.className="dl-pill warn",d.textContent="No answer",dom.content(u,t("div",{class:"dl-comp-status warn"},[v("alert"),t("span",{},"The router stopped answering. The job may still finish: reopen Components in a minute.")])),h([m()]),e.onDone?.(w),E;if(E.state==="failed")return d.className="dl-pill bad",d.textContent="Failed",dom.content(u,t("div",{class:"dl-comp-status bad"},[v("x"),t("span",{},[t("b",{},E.error??"Operation failed"),a?"":". Nothing else was changed."])])),h([D("Copy log",()=>me($.join(` +`),"Log copied")),m(!0)]),U(`${Mn[o]??"Update"}: ${E.error??"failed"}`,"error"),e.onDone?.(w),E;if(d.className="dl-pill ok",d.textContent="Finished",a&&w){let f=ra(w,o);if(dom.content(u,t("div",{class:`dl-comp-status ${f.tone}`},[v(f.tone==="ok"?"check":f.tone==="warn"?"alert":"download"),t("span",{},f.text)])),U(f.text,f.tone==="warn"?"warning":"success"),e.onDone?.(w),f.update&&e.onUpdate){let g=w;h([m(),D(`Update to ${f.update}`,()=>e.onUpdate(g),"positive")])}else h([m()]),f.tone==="ok"&&setTimeout(()=>u.isConnected&&ae(),1200);return E}if(o==="app"&&E.to){let f=E.to,g=t("span",{},"Waiting for the router to restart its services…");dom.content(u,t("div",{class:"dl-comp-status ok"},[v("check"),t("span",{},[t("b",{},`Dawnline ${f} is installed. `),g])]));let M=()=>{ui.menu?.flushCache(),location.reload()};h([m(),D("Reload now",M,"positive")]),U(`Dawnline updated to ${f}`,"success",6e3);for(let T=1;T<=30;T++)if(g.textContent=`Waiting for the router to restart its services (${T} of 30)…`,await ia(1500),(await P.updatesStatus().catch(()=>null))?.version===f)return g.textContent="Services are back. Reloading…",setTimeout(M,800),E;return g.textContent="Services restarted. Reload the page to use the new version.",E}let H=o==="pkgs"?`Updated ${[...E.result?.pkgs?.updated??[],...E.result?.pkgs?.installed??[]].join(", ")||"system packages"}`:o==="amneziawg"?`AmneziaWG${E.to?` ${E.to}`:""} is installed`:"Operation completed";return dom.content(u,t("div",{class:"dl-comp-status ok"},[v("check"),t("span",{},H)])),h([m()]),U(H,"success"),e.onDone?.(w),E}var Ds={https:"HTTPS for the portal",acme:"ACME certificates",home:"the home-like link",awg:"AmneziaWG"};async function sa(n,e,r,o){return!await se(`Install ${e}?`,r,"Install")||(await Vt(n,{title:`Installing ${e}`}))?.state!=="done"?!1:(setTimeout(()=>o?.(),4e3),!0)}function Tn(n){return sa("amneziawg:auto","AmneziaWG","Dawnline installs the AmneziaWG build made for this firmware and loads it. If the network service has to restart to learn it, connections drop for a few seconds.",n)}async function Jt(n,e,r){return n==="awg"?Tn(r):e.length?sa(`pkgs:${e.join(",")}`,Ds[n],`${e.join(", ")} from the OpenWrt feeds. Dawnline sets the rest up when they arrive.`,r):!0}async function la(n,e){if(n==="awg")return Tn(e);let r=await G(()=>P.updatesStatus());return r?Jt(n,r.needs?.[n]??[],e):!1}var As=[["wan","WAN"],["ethernet","Ethernet"],["wifi","Wi-Fi"],["vpn","VPN & tunnels"],["other","Other"]],Hs={wan:"globe",ethernet:"ethernet",bridge:"bridge",wifi:"wifi",vpn:"tunnel",other:"link"};function da(n,e,r){let o=n.id,a=e,i=t("div",{class:"dl-stack gap16"},t("section",{class:"dl-setsec"},t("div",{class:"dl-setsec-body"},t("p",{class:"dl-muted"},"Loading interfaces…")))),s,l=!0,d="",c=!0,p=!0,u="all",x=!1,$=Xr(a,o,r),h=new Set,m="",E=()=>JSON.stringify([p,l,l?"":d,c,[...h].sort()]),R=()=>s.detected.lan||s.saved.lan||"",C=()=>(l?s.detected.wan||s.saved.wan:d)||"",k=()=>new Map(s.devices.map(I=>[I.name,I])),y=()=>{let I=k();return[...c&&R()?[R()]:[],...[...h].filter(Q=>Q!==R())].filter(Q=>Q!==C()).map(Q=>I.get(Q)??{name:Q,nets:[],missing:!0})},w=(I,V)=>{s=I,V&&(l=I.config.auto_wan,d=I.config.wan_device||I.detected.wan||I.saved.wan||"",c=I.config.auto_lan,p=I.config.lan_like,u=I.config.mesh??(I.config.device_mesh?"all":"off"),h=new Set(I.config.lan_devices),m=E()),q()},b=async I=>{let V=await P.interfaces(o).catch(Q=>(U(Q.message,"error"),null));V&&w(V,I)};function H(I){let V=c&&I.name===R(),Q=!!I.own||!!I.master||I.name===C()||V;return V||h.has(I.name)||!Q&&(I.nets.length>0||!!I.missing)}function f(I){let V=c&&I.name===R(),Q=I.name===C(),de=!V&&h.has(I.name),B=!(!!I.own||!!I.master||Q||V)&&(I.nets.length>0||de||!!I.missing),F=(de||V)&&!I.zone&&!I.missing,ne=I.missing?"Not present right now":I.own?"This server":I.master?`Port of ${I.master}`:Q?`Internet${I.zone?` · zone ${I.zone}`:""}`:I.nets.length?I.nets.join(", "):"No IPv4 network",pe=t("button",{type:"button",class:`dl-if${de?" sel":""}${V?" auto":""}${!B&&!de&&!V?" off":""}${F?" warn":""}`,"aria-pressed":de||V?"true":"false","aria-disabled":B?null:"true",click:()=>{B&&(h.has(I.name)?h.delete(I.name):h.add(I.name),q())}},[t("span",{class:"dl-if-ic"},v(Hs[I.kind]??"link")),t("span",{class:"dl-if-main"},[t("span",{class:"dl-if-name"},I.name),t("span",{class:"dl-if-sub"},ne)]),V?t("span",{class:"dl-if-badge ok"},"Auto"):de?t("span",{class:"dl-if-check"},v("check")):""]);return he(pe,()=>[t("div",{class:"dl-tip-title"},I.name),t("div",{class:"dl-muted"},[I.logical?`Interface ${I.logical}`:"No netifd interface",I.zone?` · zone ${I.zone}`:" · no firewall zone"]),I.members.length?t("div",{class:"dl-muted"},`Ports: ${I.members.join(", ")}`):"",I.nets.length?t("div",{class:"dl-mono"},I.nets.join(", ")):"",F?t("div",{class:"dl-warn"},"Not in a firewall zone: the firewall rejects this traffic."):"",I.master?t("div",{class:"dl-muted"},`Choose ${I.master} to include it.`):""]),pe}function g(){let I=s.like_home;return!p||!s.config.lan_like||!n.enabled?"":!s.needs?.length&&I.active&&I.bridged?"ok":"warn"}function M(){let I=s.like_home;return p?s.needs?.length?[t("span",{class:"dl-warn"},`Needs ${s.needs.join(" and ")}.`)," Until they are installed, internet traffic goes straight to the WAN."]:s.config.lan_like?n.enabled?I.active&&I.bridged?["Internet traffic enters ",t("span",{class:"dl-mono"},I.dev??"")," as ",t("span",{class:"dl-mono"},I.address??""),", so whatever handles home traffic (proxies, filters, DNS) handles it too."]:[t("span",{class:"dl-warn"},`Not working: ${I.error??"the link is down"}`)," Internet traffic goes straight to the WAN for now."]:["Internet traffic enters the router from your LAN, so whatever handles home traffic (proxies, filters, DNS) handles it too."]:["Internet traffic will enter the router from your LAN, so it is handled like any home device. Save to turn on."]:["Off: internet traffic goes straight to the WAN, past whatever handles home traffic on this router."]}let T={off:"Devices of different people never reach each other; a person's own devices don't either.",all:"Devices of people with home access reach each other, like home devices do. Internet-only people never.",circles:"Within a circle: family sees family, guests see guests. Everyone reaches their own devices. Internet-only people never."};function z(I,V,Q,de,ee="",B){return t("div",{class:B?"dl-setrow head":"dl-setrow"},[t("div",{class:"dl-lh-main"},[t("span",{class:`dl-need-ic ${ee}`},v(I)),t("div",{class:"dl-stack"},[t("span",{class:"dl-setrow-label"},V),t("span",{class:"dl-sub"},Q),B??""])]),t("div",{class:"dl-setrow-ctl"},de)])}let W=(I,V)=>{let Q=de=>t("span",{class:"dl-mono"},de);return I?t("span",{},[" Now: ",Q(I),...V&&V!==I?[", was ",Q(V)]:[],"."]):t("span",{},V?[" Not found now: using ",Q(V),"."]:[" Not found."])};function q(){let I=t("select",{class:"cbi-input-select","aria-label":"Internet interface",change:_=>{d=_.target.value,q()}},s.devices.filter(_=>!_.own&&!_.master&&_.zone&&!_.missing).map(_=>t("option",{value:_.name,selected:_.name===d?"selected":null},`${_.name} · zone ${_.zone}`))),Q=y().flatMap(_=>_.nets.map(j=>[j,_.name])),de=JSON.parse(E()),ee=JSON.parse(m),B=(..._)=>_.some(j=>JSON.stringify(de[j])!==JSON.stringify(ee[j])),F=B(0,1,2),ne=B(3,4),pe=_=>D("Save",async()=>{let j=await G(()=>P.serverInterfaces(o,l,l?"":d,c,[...h],p,u!=="off",u),"Access saved");j&&(w(j,!0),j.nets_changed&&j.lan_only&&U(`${j.lan_only} ${j.lan_only===1?"person has":"people have"} Home-only access: their devices need the configuration again to reach the new networks.`,"warning",1e4))},"positive",{disabled:!_}),A=t("section",{class:"dl-setsec dl-ifcard"},[t("div",{class:"dl-setsec-body"},[t("div",{class:"dl-panel-head"},[t("h3",{},"Internet"),t("span",{class:"dl-spacer"}),t("span",{class:"dl-sub"},"People with Internet or Both")]),z("home","Internet like a home device",M(),[p&&s.needs?.length?D("Install",()=>Jt("home",s.needs,()=>b(!1)),"positive"):"",ve(p,"Internet like a home device",_=>{p=_,q()})],g()),z("globe","Auto-detect WAN",["The interface with the default route: the server port opens there and Internet access leaves through it.",W(s.detected.wan,s.saved.wan)],[l?"":I,ve(l,"Auto-detect WAN",_=>{l=_,q()})])]),t("div",{class:"dl-setsec-foot"},[t("span",{class:"dl-sub"},p?["Internet like a home device",C()?[" · leaves through ",t("span",{class:"dl-mono"},C())]:""]:C()?["Internet straight to ",t("span",{class:"dl-mono"},C())]:"No WAN found"),pe(F)])]),N=we([["off","Off"],["all","Everyone"],["circles","Circles"]],u,{label:"Devices reach each other",cls:"sm",optimistic:!1,onChange:async _=>{let j={off:"Off",all:"Everyone",circles:"Circles"}[_];await G(()=>P.serverUpdate(o,{mesh:_}),`Devices reach each other: ${j}`)&&(u=_,s.config.mesh=_,q(),await r())}}),S=t("section",{class:"dl-setsec dl-ifcard"},[t("div",{class:"dl-setsec-body"},[t("div",{class:"dl-panel-head"},[t("h3",{},"Home network"),t("span",{class:"dl-spacer"}),t("span",{class:"dl-sub"},"People with Home or Both"),D([v("reset")," Rescan"],()=>b(!1),"neutral",{title:"Read the interfaces again"})]),z("network","Networks","Everyone with home access reaches these, unless their page leaves one out; their devices can be reached from here too. Click one to add or remove it.","","",Z()),z("link","Devices reach each other",T[u],N,"",u==="circles"?ea(a,o,r):void 0),$.el]),t("div",{class:"dl-setsec-foot"},[t("span",{class:"dl-sub dl-if-summary"},Q.length?["Home access reaches ",...Q.flatMap(([_,j],Y)=>[Y?", ":"",t("span",{class:"dl-mono"},_),` (${j})`])]:"No home network: Home access reaches nothing but this router."),pe(ne)])]),O=window.scrollY;i.style.minHeight=`${i.offsetHeight}px`,dom.content(i,[A,S]),i.style.minHeight="",window.scrollTo({top:O})}function Z(){let I=s.devices.filter(H),V=s.devices.filter(Q=>!H(Q));return t("div",{class:"dl-stack gap8 dl-netpick"},[I.length?t("div",{class:"dl-ifgrid"},I.map(f)):t("span",{class:"dl-warn"},"No home network: Home access reaches nothing but this router."),t("label",{class:"dl-boxrow"},[t("span",{class:"dl-stack"},[t("span",{},"Auto-detect LAN"),t("span",{class:"dl-sub"},["Adds the LAN this router uses.",W(s.detected.lan,s.saved.lan)])]),ve(c,"Auto-detect LAN",Q=>{c=Q,q()})]),V.length?t("details",{class:"dl-params",open:x?"":null,toggle:Q=>x=Q.currentTarget.open},[t("summary",{},[v("chevron"),t("span",{},"Other interfaces"),t("span",{class:"dl-pcount"},String(V.length))]),t("div",{class:"dl-params-body"},[t("span",{class:"dl-sub"},"The WAN, this server, ports and Wi-Fi of a bridge (they come with it) and interfaces without an IPv4 network."),...As.map(([Q,de])=>{let ee=V.filter(B=>B.category===Q);return ee.length?t("div",{class:"dl-ifgroup"},[t("h4",{},de),t("div",{class:"dl-ifgrid"},ee.map(f))]):""})])]):""])}return b(!0),{el:i,update(I){a=I,$.update(I),s&&q()}}}var zs={connect:"ok",disconnect:"",roam:"",device_added:"ok",device_removed:"",person_added:"",person_removed:"",paused:"warn",resumed:"ok",expiring:"warn",expired_kept:"",portal_blocked:"bad",person_changed:"",devices_removed:"warn"},Ns={devices_removed:"trash",link_changed:"link",person_added:"plus",person_removed:"trash",person_changed:"edit",paused:"pause",resumed:"play",expiring:"calendar",expired_kept:"calendar"};function Rs(n,e){return e.device?n.people.flatMap(o=>o.devices).find(o=>o.id===e.device)?.kind??e.dkind??"other":Ns[e.type]??"activity"}function wo(n,e){let r=n.people.find(h=>h.id===e.person),o=r?.name??e.pname??e.person??"",a=r?.devices.find(h=>h.id===e.device)?.name??e.dname??"",i=h=>t("b",{},h),s=h=>t("span",{class:"dl-muted"},h),l=h=>t("span",{class:"dl-mono"},h),d=h=>e.hosts?.[h]?[t("span",{class:"dl-ev-host"},[t("b",{},e.hosts[h]),t("span",{class:"dl-faint"},` (${h})`)])]:[l(h)],c=h=>t("span",{class:"dl-ev-kind"},`${h} `),p=a?`${o} · ${a}`:o,u=sr(e),x=u||a||"a device",$=h=>[t("span",{class:"dl-you"},"You"),s(` ${h} `)];if(Ne(e)==="admin")switch(e.type){case"device_added":return[...$("added"),c("device"),i(x),s(" for "),i(o)];case"device_removed":return[...$("removed"),c("device"),i(x),s(" from "),i(o)];case"paused":return[...$("paused"),c("person"),i(o)];case"resumed":return[...$("resumed"),c("person"),i(o)];case"device_changed":{let h=u.startsWith("renamed from ");return[...$(h?"renamed":u),c("device"),i(a||"a device"),s(" of "),i(o),...h?[s(` · was ${u.slice(13)}`)]:[]]}case"device_keys":return[...$("issued new keys for"),c("device"),i(x),s(" of "),i(o),s(" · it needs its new configuration")];case"link_changed":return[...$("issued a new link for"),c("person"),i(o),s(" · the old link stopped working")]}switch(e.type){case"connect":return[c("Device"),i(p),s(" connected"),...e.detail?[s(" from "),...d(e.detail)]:[],...e.where?[s(` · ${e.where}`)]:[]];case"disconnect":return[c("Device"),i(p),s(" went offline")];case"roam":return[c("Device"),i(p),s(" changed network "),...(e.detail??"").split(" → ").flatMap((h,m)=>m?[s(" → "),...d(h)]:d(h))];case"device_added":return[c("Person"),i(o),s(" added "),c("device"),i(x),...Ne(e)==="portal"?[s(" on their portal")]:[]];case"device_removed":return[c("Person"),i(o),s(" removed "),c("device"),i(x),...Ne(e)==="portal"?[s(" on their portal")]:[]];case"device_keys":return[c("Person"),i(o),s(" issued new keys for "),c("device"),i(x),s(" on their portal")];case"person_added":return[...$("added"),c("person"),i(e.detail??o)];case"person_removed":return[...$("removed"),c("person"),i(e.detail??o)];case"person_changed":return[...$("changed"),c("person"),i(o),...u?[s(` · ${u.replace(/_/g," ")}`)]:[]];case"expiring":return[c("Person"),i(o),s(`’s access ends in ${e.detail??"a few days"}`)];case"expired_kept":return[c("Person"),i(o),s(`’s end date passed (${e.detail??""}) · access kept`)];case"paused":return[c("Person"),i(o),s(` paused — ${e.detail??""}`)];case"resumed":return[c("Person"),i(o),s(" resumed"),...e.detail&&e.detail!=="active"?[s(` — ${e.detail}`)]:[]];case"portal_blocked":return[t("b",{class:"dl-sys-src"},"Personal portal"),s(" blocked "),l(e.detail??""),s(" for 15 min after too many wrong codes")];case"devices_removed":return[c("Person"),i(o),s(" — all devices removed, end date reached")];default:return[s(`${e.type}${e.detail?`: ${e.detail}`:""}`)]}}var Is={portal_blocked:["globe","bad"]};function Bs(n,e){if(n.servers.length<2||!e.person)return"";let r=n.people.find(a=>a.id===e.person),o=r&&n.servers.find(a=>a.id===r.server);return o?t("span",{class:"dl-ev-srv",title:"Server"},o.name):""}function it(n,e,r={}){let o=Is[e.type],a=Ne(e);return t("div",{class:`dl-row${a==="admin"?" dl-ev-by-admin":o?` dl-ev-by-system ${o[1]}`:""}`},[a==="admin"?t("span",{class:"dl-ev-tile",title:"Done by you in LuCI"},v("admin")):o?t("span",{class:"dl-ev-tile sys"},v(o[0])):t("span",{class:`dl-ev-tile ev ${zs[e.type]??""}`},v(Rs(n,e))),t("span",{class:"dl-row-main"},wo(n,e)),r.server===!1?"":Bs(n,e),t("span",{class:"dl-faint dl-nowrap",title:new Date(e.ts*1e3).toLocaleString()},r.time??re(e.ts,n.now))])}var Os={info:"",up:"ok",down:"warn",repair:"warn",error:"bad"},js={awg:"tunnel",dawnline:"sunrise",portal:"globe"};function _n(n,e,r,o){let a=n.by==="admin",i=t("div",{class:`dl-row dl-slog-row ${a?"dl-ev-by-admin":`dl-ev-by-system ${Os[n.level]??""}`}${n.detail?" has-detail":""}`},[a?t("span",{class:"dl-ev-tile",title:"Done by you in LuCI"},v("admin")):t("span",{class:"dl-ev-tile sys",title:n.level},v(js[n.src]??"zap")),t("span",{class:"dl-row-main"},a?[t("span",{class:"dl-you"},"You"),t("span",{class:"dl-muted"},` ${n.msg} `),n.kind?t("span",{class:"dl-ev-kind"},`${n.kind} `):"",n.who?t("b",{},n.who):"",n.note?t("span",{class:"dl-muted"},` · ${n.note}`):"",n.detail?t("span",{class:`dl-slog-more${e?" open":""}`},v("chevron")):"",n.detail&&e?t("pre",{class:"dl-slog-detail"},n.detail):""]:[n.src==="awg"&&n.who&&n.who!=="AmneziaWG"?t("span",{class:"dl-ev-kind"},"Server "):"",t("b",{class:"dl-sys-src",title:Bt[n.src]??n.src},n.who??Bt[n.src]??n.src)," ",t("span",{class:"dl-muted"},n.msg),n.detail?t("span",{class:`dl-slog-more${e?" open":""}`},v("chevron")):"",n.detail&&e?t("pre",{class:"dl-slog-detail"},n.detail):""]),t("span",{class:"dl-faint dl-nowrap",title:new Date(n.ts*1e3).toLocaleString()},o)]);return n.detail&&i.addEventListener("click",s=>{s.target.closest("pre")||r()}),i}function ca(n){let e=new Date(n*1e3),r=new Date,o=new Date;return o.setDate(r.getDate()-1),e.toDateString()===r.toDateString()?"Today":e.toDateString()===o.toDateString()?"Yesterday":e.toLocaleDateString("en-GB",{weekday:"long",day:"numeric",month:"long"})}var Dt=n=>wt(n).toLocaleDateString("en-GB",{day:"numeric",month:"short"});function Pn(n,e,r,o=!1){let a=n.slice(-15),i=a[a.length-1],s=i&&e-i[0]<180,l=s?i[2]:0,d=s?i[1]:0,[c,p]=r,u=200,x=40,$=Math.max(1,...a.map(k=>Math.max(k[1],k[2]))),h=k=>a.map((y,w)=>`${a.length>1?w/(a.length-1)*u:u},${x-2-y[k]/$*(x-6)}`),m=h(2),E=h(1),R=a.length>1&&!o?yt(``):t("div",{class:"dl-speed-wait"},[t("i"),o?"":t("span",{},"Collecting… 1 point a minute")]),C=(k,y,w,b)=>t("div",{class:"dl-speed-col"},[t("span",{class:"dl-sub"},[t("span",{class:w},y),` ${k}`]),o?t("span",{class:"dl-speed-val off"},"—"):t("span",{class:"dl-speed-val"},Oe(b))]);return a.length>1&&!o&&he(R,()=>{let k=a[a.length-1];return[t("div",{class:"dl-tip-title"},new Date(k[0]*1e3).toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit"})),t("div",{},`↓ ${Oe(k[2])} · ↑ ${Oe(k[1])}`)]}),t("div",{class:"dl-bento-tile"},[t("div",{class:"dl-bento-head"},[t("span",{class:"dl-metric-label"},"Speed now"),o?"":t("span",{class:"dl-sub"},"last 15 min")]),t("div",{class:"dl-speed-cols"},[C("Download","↓","dl-dn",l),C("Upload","↑","dl-up",d)]),R,t("div",{class:"dl-speed-today"},[t("span",{},["Today ",t("b",{},X(c+p))]),t("span",{},[t("span",{class:"dl-dn"},"↓"),` ${X(p)} `,t("span",{class:"dl-up"},"↑"),` ${X(c)}`])])])}function Dn(n,e){let r=n.slice(-30),o=r.map(d=>d.rx+d.tx),a=Math.max(1,...o),i=o.reduce((d,c)=>d+c,0),s=o.reduce((d,c,p)=>c>o[d]?p:d,0),l=t("div",{class:"dl-bento-bars"},r.map((d,c)=>{let p=o[c],u=t("i",{class:c===r.length-1?"hi":"",style:`height:${Math.max(4,p/a*100)}%`});return he(u,()=>[t("div",{class:"dl-tip-title"},c===r.length-1?`Today · ${Dt(d.day)}`:Dt(d.day)),t("div",{},X(p)),t("div",{class:"dl-muted dl-mono"},`↓ ${X(d.tx)} ↑ ${X(d.rx)}`)]),u}));return t("div",{class:"dl-bento-tile month"},[t("div",{class:"dl-bento-head"},[t("span",{},[t("span",{class:"dl-metric-label"},"Last 30 days"),t("b",{class:"dl-bento-total"},X(i))]),o[s]>0?t("span",{class:"dl-sub"},`peak ${X(o[s])} · ${Dt(r[s].day)}`):""]),r.length?l:t("p",{class:"dl-muted"},"No traffic yet."),t("div",{class:"dl-bento-head"},[t("span",{class:"dl-sub"},r.length?Dt(r[0].day):""),t("span",{class:"dl-sub"},e),t("span",{class:"dl-sub"},"today")])])}function pa(n){let e=n.slice(-30),r=e.map(a=>a.rx+a.tx),o=Math.max(1,...r);return t("div",{class:"dl-dbars"},e.map((a,i)=>{let s=t("i",{class:`${r[i]?"":"zero"}${i===e.length-1?" hi":""}`});return s.style.height=`${Math.max(8,r[i]/o*100)}%`,he(s,()=>[t("div",{class:"dl-tip-title"},i===e.length-1?`Today · ${Dt(a.day)}`:Dt(a.day)),t("div",{},X(r[i]))]),s}))}var ua={apply:"Repair",sync:"Reload devices",restart:"Restart service",netrestart:"Restart network",updates:"Open Components"};async function An(n){return n==="netrestart"&&!await se("Restart the network?","Every interface restarts. Connections drop for a few seconds.","Restart network")?null:await G(()=>P.healthFix(n),"Done")??null}function yo(n,e,r,o="action"){let a=n.fix;return a?a.startsWith("install:")?D("Install",()=>la(a.slice(8),r),o):a==="updates"?t("a",{class:`cbi-button cbi-button-${o}`,href:L.url("admin/network/dawnline/updates")},ua.updates):D(ua[a]??"Fix",()=>e(a),o):""}function Us(n){return/^(awg|up_|peers_|fw_|reply_|port_|subnet_)/.test(n)?"shield":/^(portal|cert)/.test(n)?"link":/^(ep_|home_|resolver)/.test(n)?"globe":n==="clock"?"clock":n==="agent"?"activity":n==="flash"?"download":n==="nft"?"lock":n==="data"?"users":"alert"}function ma(n,e,r,o=3){let a=n.filter(s=>s.status==="error"||s.status==="warn").sort((s,l)=>s.status===l.status?0:s.status==="error"?-1:1);if(!a.length)return"";let i=a.length-o;return t("div",{class:"dl-list dl-notices"},[...a.slice(0,o).map(s=>Xe(Us(s.id),s.status==="error"?"bad":"warn",s.problem??s.title,s.detail,yo(s,e,r,s.status==="error"?"positive":"neutral"))),i>0?t("a",{class:"dl-row dl-notices-more",href:L.url("admin/network/dawnline/diagnostics")},[`${i} more in Diagnostics`,t("span",{class:"dl-spacer"}),"→"]):""])}function Gs(n){let e=[],r=(s,l)=>t("a",{href:s},l),o=Ie(n.series),a=!!n.awg_state&&!n.awg_state.ok;for(let s of n.servers)s.enabled&&s.blocked?e.push({tone:"bad",text:[`${s.name} ${s.blocked}. `,r(L.url("admin/network/dawnline/diagnostics"),"Open Diagnostics")]}):s.enabled&&!s.up&&!a&&e.push({tone:"bad",text:[`Tunnel ${s.ifname} is down. `,r(L.url("admin/network/dawnline/diagnostics"),"Open Diagnostics")]});for(let s of n.people)if(s.state==="quota")e.push({tone:"warn",text:[r(ke(s.id),s.name)," reached the data limit."]});else if(s.state==="expired")e.push({tone:"warn",text:[r(ke(s.id),s.name),"’s access has ended."]});else{let l=Ye(s.expires,o);Ze(s,l)?e.push({tone:"",text:[r(ke(s.id),s.name),`’s access ${Xt(l)}.`]}):l!=null&&l<0&&s.expire_action==="notify"&&e.push({tone:"",text:[r(ke(s.id),s.name),`’s end date passed (${Me(s.expires)}) · access kept.`]}),s.quota_limit&&s.quota_used>=s.quota_limit*.9&&e.push({tone:"",text:[r(ke(s.id),s.name)," has used 90% of the data limit."]})}let i=n.people.flatMap(s=>s.devices.filter(l=>l.config_stale).map(l=>[s,l]));i.length&&e.push({tone:"warn",text:i.length===1?[r(ke(i[0][0].id,i[0][1].id),`${i[0][0].name} · ${i[0][1].name}`)," needs its configuration again."]:[`${i.length} devices need their configuration again (networks or DNS changed).`]});for(let s of n.servers)n.wan&&Et(s.endpoint)&&s.endpoint!==n.wan&&e.push({tone:"warn",text:[`Public address changed: ${s.name} still gives devices ${s.endpoint}, the router is ${n.wan} now. `,t("button",{type:"button",class:"dl-fix",click:async l=>{let d=l.currentTarget;d.disabled=!0,await G(()=>P.serverUpdate(s.id,{endpoint:n.wan}),`${s.name} uses ${n.wan} now — devices need their configuration again`),d.disabled=!1}},"Use the new address")," A DDNS name would follow it by itself."]});return n.servers.some(s=>s.lan_like)&&n.like_home.error&&e.push({tone:"warn",text:[`Internet through the LAN is off: ${n.like_home.error} `,r(L.url("admin/network/dawnline/diagnostics"),"Details")]}),!n.settings.portal_enabled&&!n.people.length&&e.push({tone:"",text:["The personal portal is off. ",r(L.url("admin/network/dawnline/settings"),"Turn on")]}),e}var Hn=class{constructor(e,r){this.srvId=e;this.go=r;this.el=t("div",{class:"dl-srvov"});this.map=null;this.mapOn=null;this.range="online";this.parts={};this.healthAt=0}mount(e){this.st=Kt(e,this.srvId);for(let r of["health","bento","map","side","activity"])this.parts[r]=t("div",{});return dom.content(this.el,[this.parts.health,this.parts.bento,this.parts.map,t("div",{class:"dl-grid2"},[this.parts.activity,this.parts.side])]),this.paint(),this.loadHealth(),this.el}update(e,r=!1){this.st=Kt(e,this.srvId),this.paint(r),Date.now()-this.healthAt>6e4&&this.loadHealth()}async loadHealth(){this.healthAt=Date.now();let e=await P.health().catch(()=>null);if(!e)return;let r=()=>void this.loadHealth(),o=async a=>{await An(a)&&(r(),a==="netrestart"&&setTimeout(r,5e3))};Se(this.parts.health,ma(e.checks,a=>void o(a),r),!0)}mapData(){return{geo:this.st.geo,people:this.st.people,now:this.st.now}}paintMap(){let e=this.st.geo.enabled;if(e===this.mapOn&&(!e||this.map)){this.map?.update(this.mapData());return}this.mapOn=e,dom.content(this.parts.map,this.mapCard())}mapCard(){let e=this.st,r=t("div",{class:"dl-panel-head pad"},[t("div",{class:"dl-stack"},[t("h3",{},"Where people connect from"),t("span",{class:"dl-sub"},"City-level, from the client IP · locations cached on the router")]),t("span",{class:"dl-spacer"}),Tt(this.range,l=>{this.range=l,this.map?.setRange(l)})]);if(this.map?.destroy(),this.map=null,!e.geo.enabled)return t("div",{class:"dl-panel flush"},[r,t("div",{class:"dl-map-off"},["Locations are off. ",t("a",{href:L.url("admin/network/dawnline/settings")},"Turn them on in Settings"),"."])]);let o=this.map=new tt({openPerson:l=>location.href=ke(l),openDevice:(l,d)=>location.href=ke(l,d)},this.range),a=$e(()=>{a(),o.destroy(),this.map===o&&(this.map=null)}),i=t("div",{class:"dl-map-legend"},[t("span",{},[t("i",{class:"line live"}),"Live tunnel"]),t("span",{},[t("i",{class:"line"}),"Seen recently"])]),s=t("div",{class:"dl-map-wrap"},[o.el,i]);return requestAnimationFrame(()=>o.mount(this.mapData())),t("div",{class:"dl-panel flush"},[r,s])}paint(e=!1){let r=this.st,o=r.servers[0];this.paintMap(),Se(this.parts.bento,t("div",{class:"dl-bento"},[this.onlineTile(),this.speedTile(),Be(o).overviewTile(o),this.monthTile()]),e);let a=Gs(r);Se(this.parts.side,t("div",{class:"dl-panel flush"},[t("div",{class:"dl-panel-head pad"},[t("h3",{},"Needs attention"),t("span",{class:"dl-spacer"}),t("a",{href:L.url("admin/network/dawnline/diagnostics")},"Health")]),a.length?a.slice(0,8).map(s=>t("div",{class:"dl-attn-item dl-row"},[t("span",{class:`dl-ev-dot ${s.tone}`}),t("span",{},s.text),s.action??""])):t("div",{class:"dl-row dl-muted"},[v("check"),"All good. Nothing needs you right now."])]),e);let i=[...r.events].reverse().slice(0,8);Se(this.parts.activity,t("div",{class:"dl-panel flush"},[t("div",{class:"dl-panel-head pad"},[t("h3",{},"Activity"),t("span",{class:"dl-spacer"}),t("a",{href:`${L.url("admin/network/dawnline/diagnostics")}?tab=log`},"View all")]),i.length?i.map(s=>it(r,s)):t("div",{class:"dl-row dl-muted"},"Nothing yet. Connections, new devices and pauses appear here.")]),e)}onlineTile(){let e=this.st,r=e.servers[0]?!e.servers[0].enabled:!1,o=12,a=R=>R.spark[R.spark.length-1]??0,i=R=>e.geo.points.find(C=>C.device===R.id&&C.city)?.city,s=R=>/^(10\.|192\.168\.|172\.(1[6-9]|2\d|3[01])\.)/.test(R.endpoint??""),l=(R,C=!1)=>s(R)?C&&R.endpoint?`LAN · ${R.endpoint}`:"LAN":i(R)??"",d=R=>[...e.events].reverse().find(C=>C.type==="connect"&&C.device===R.id)?.ts??0,c=e.people.map(R=>({p:R,devs:R.devices.filter(C=>C.online).sort((C,k)=>a(k)-a(C))})).filter(R=>R.devs.length).sort((R,C)=>C.devs.reduce((k,y)=>k+a(y),0)-R.devs.reduce((k,y)=>k+a(y),0)),p=c.length<=2,u=({p:R,devs:C})=>{let k=C.map(d).filter(Boolean),y=k.length?Math.min(...k):0,w=(R.rate??[]).slice(-15),b=w[w.length-1],H=b&&e.now-b[0]<180?b:null,f=200,g=30,M=Math.max(1,...w.map(Z=>Math.max(Z[1],Z[2]))),T=Z=>w.map((I,V)=>`${w.length>1?V/(w.length-1)*f:f},${g-2-I[Z]/M*(g-6)}`),z=w.length>1?yt(``):"",W=!H||H[1]<64&&H[2]<64,q=R.access==="both"?["home","globe"]:R.access==="lan"?["home"]:["globe"];return[t("div",{class:"dl-hc"},[t("div",{class:"dl-hc-head"},[t("span",{class:"dl-onl-av sm"},He(R.name)),t("span",{class:"dl-stack"},[t("b",{},R.name),t("span",{class:"dl-hc-since"},y?`online for ${re(y,e.now).replace(" ago","")}`:"online")]),t("span",{class:"dl-hc-reach"},q.map(Z=>t("span",{class:`dl-ibadge ${Z==="home"?"lan":"inet"}`},v(Z))))]),t("div",{class:"dl-hc-speed"},[t("div",{class:"dl-hc-speed-row"},W?[t("span",{class:"dl-faint"},"Idle right now")]:[t("span",{},[t("span",{class:"dl-dn"},"↓"),` ${Oe(H[2])}`]),t("span",{},[t("span",{class:"dl-up"},"↑"),` ${Oe(H[1])}`]),t("span",{class:"dl-spacer"}),t("span",{class:"dl-faint"},"15 min")]),z]),t("div",{class:"dl-hc-devs"},C.map(Z=>t("span",{class:"dl-hc-dev"},[v(Z.kind),Z.name,l(Z)?[" · ",l(Z,!0)]:""]))),t("div",{class:"dl-hc-foot"},[t("span",{class:"dl-faint"},`${X(C.reduce((Z,I)=>Z+a(I),0))} today · ${X(R.month[0]+R.month[1])} this month`)])])]},x=R=>{let{p:C,devs:k}=R,y=t("span",{class:"dl-onl-dev"},k.length>1?String(k.length):v(k[0].kind)),w=t("a",{class:`dl-onl-p${p?"":" sm"}`,href:ke(C.id),"aria-label":`${C.name}, online`},[t("span",{class:"dl-onl-av"},[He(C.name),y]),p?t("span",{class:"dl-onl-name"},C.name):"",p?t("span",{class:"dl-onl-meta"},[...k.slice(0,3).map(b=>v(b.kind)),k.length>3?`+${k.length-3}`:"",l(k[0])?t("span",{},[" · ",l(k[0])]):""]):""]);return he(w,()=>u(R)),w},$=t("b",{class:`dl-onl-count${c.length?"":" none"}`},String(c.length)),h=c.reduce((R,C)=>R+C.devs.length,0);c.length&&he($,()=>[`${c.length} ${c.length===1?"person":"people"} · ${h} device${h===1?"":"s"}`]);let m=c.length>o?c.slice(0,o-1):c,E=e.people.flatMap(R=>R.devices.map(C=>({p:R,d:C}))).filter(R=>R.d.handshake).sort((R,C)=>C.d.handshake-R.d.handshake)[0];return t("div",{class:"dl-bento-tile online"},[t("div",{class:"dl-bento-head"},[t("span",{class:"dl-metric-label"},"Online"),$]),c.length?t("div",{class:`dl-onl-row${p?"":" grid"}`},[...m.map(x),c.length>o?t("a",{class:"dl-onl-p sm more",href:`${L.url("admin/network/dawnline/server")}?server=${encodeURIComponent(this.srvId)}§ion=people&filter=online`,title:"Everyone online",click:R=>{this.go&&(R.preventDefault(),this.go("people","online"))}},[t("span",{class:"dl-onl-av"},`+${c.length-m.length}`)]):""]):t("div",{class:"dl-onl-empty"},[t("span",{},r?"The server is turned off":"Nobody is connected"),E?t("span",{class:"dl-sub"},`Last: ${E.p.name}, ${re(E.d.handshake,e.now)}`):t("span",{class:"dl-sub"},r?"Devices connect once it is on":"No device has connected yet")])])}speedTile(){let e=this.st.servers[0];return Pn(e?.rate??[],this.st.now,this.st.totals.today,e?!e.enabled:!1)}monthTile(){let e=[...this.st.people].map(r=>[r,r.month[0]+r.month[1]]).filter(([,r])=>r>0).sort((r,o)=>o[1]-r[1]).slice(0,2);return Dn(this.st.series,e.length?`Most: ${e.map(([r,o])=>`${r.name} ${X(o)}`).join(" · ")}`:"")}};var ha=[["overview","Overview"],["people","People"],["connection","Connection"],["access","Access"],["awg",""]],Ws={general:"connection",network:"connection",interfaces:"access",advanced:"awg",disguise:"awg",tunnel:"awg",core:"awg"},ko=(n,e)=>{let r=new URLSearchParams;n&&r.set("server",n),e&&e!=="overview"&&r.set("section",e);let o=r.toString();return`${L.url("admin/network/dawnline/server")}${o?`?${o}`:""}`},Yt=class{constructor(){this.noFooter=!0;this.root=t("div",{class:"dl-root"});this.section="overview";this.srvId="";this.ov={};this.pp={};this.tabsEl=t("div",{});this.headEl=t("div",{});this.secEl=t("div",{});this.bodyEl=t("div",{class:"dl-srvbody"})}async load(){let e=await P.status(31),r=e.servers.length?null:await P.setupDefaults();return[e,r]}render([e,r]){if(this.st=e,!e.servers.length&&r)return this.wizard(r);let o=new URLSearchParams(location.search),a=o.get("section")??"",i=Ws[a]??a;return ha.some(([s])=>s===i)&&(this.section=i),this.srvId=(e.servers.find(s=>s.id===o.get("server"))??e.servers[0]).id,dom.content(this.root,[this.tabsEl,this.headEl,this.secEl,this.bodyEl]),this.paint(),this.poller?.stop(),this.poller=ot({fetch:()=>P.status(31),every:30,live:!0,active:()=>this.section==="overview"&&this.root.isConnected,apply:(s,l)=>{s.servers.length&&(this.st=s,this.paintHead(l),this.ov[this.current().id]?.update(s,l))}}),this.root}paintHead(e=!1){Se(this.headEl,this.head(this.current()),e),(!e||!Pt(this.tabsEl))&&this.paintTabs()}async refreshStatus(){let e=await P.status(31).catch(()=>null);return e?.servers.length?(this.st=e,this.paintHead(),e):null}current(){return this.st.servers.find(e=>e.id===this.srvId)??this.st.servers[0]}async refresh(){let e=await P.status(31).catch(()=>null);e&&(this.st=e,e.servers.length?this.paint():location.href=ko())}paint(){this.paintTabs(),dom.content(this.headEl,this.head(this.current())),this.paintSections(),this.showSection(this.section)}paintTabs(){let e=this.current();dom.content(this.tabsEl,t("div",{class:"dl-srvtabs",role:"tablist","aria-label":"Servers"},[...this.st.servers.map(r=>t("button",{type:"button",role:"tab",class:`dl-srvtab${r.id===e.id?" on":""}`,"aria-selected":r.id===e.id?"true":"false",click:()=>{r.id!==this.srvId&&(this.srvId=r.id,this.paint())}},[t("i",{class:`dot ${r.enabled?r.up?"ok":"bad":"warn"}`}),t("b",{},r.name)])),t("button",{type:"button",class:"dl-srvtab add",click:()=>this.addServer()},[v("plus"),"Add server"])]))}paintSections(){let e=Be(this.current());dom.content(this.secEl,t("div",{class:"dl-seg dl-srvsections",role:"tablist","aria-label":"Server"},ha.map(([r,o])=>t("button",{type:"button",role:"tab","data-section":r,class:r===this.section?"on":"","aria-selected":r===this.section?"true":"false",click:()=>this.showSection(r)},r==="awg"?e.label:o))))}go(e,r){let o=this.pp[this.current().id];if(r&&o)o.filter=r,o.el&&o.decorate();else if(r){let a=this.pp[this.current().id]=new mt;a.filter=r}this.showSection(e),window.scrollTo({top:0,behavior:"smooth"})}detachKept(){let e=[...Object.values(this.ov).map(r=>r.el),...Object.values(this.pp).map(r=>r.el)];for(let r of e)r&&this.bodyEl.contains(r)&&r.remove()}showSection(e){this.section=e,this.secEl.querySelectorAll("[data-section]").forEach(s=>{let l=s.dataset.section===e;s.classList.toggle("on",l),s.setAttribute("aria-selected",l?"true":"false")});let r=this.st,o=this.current(),i={overview:()=>{let s=this.ov[o.id];return s?(s.update(r),s.el):(this.ov[o.id]=new Hn(o.id,(l,d)=>this.go(l,d))).mount(r)},people:()=>{var c,p;let s=this.pp[o.id];if(s?.el)return s.update(),s.el;let l=t("div",{},t("p",{class:"dl-muted"},"Loading people…"));return((c=this.pp)[p=o.id]??(c[p]=new mt)).embed(r,o.id).then(u=>{l.isConnected?dom.content(l,u):l.replaceChildren(u)}).catch(u=>{delete this.pp[o.id],dom.content(l,t("p",{class:"dl-muted"},`Couldn't show people: ${be(u)}`))}),l},connection:()=>this.connection(o),access:()=>this.access(o),awg:()=>this.awg(o)}[e]();this.detachKept(),dom.content(this.bodyEl,i)}head(e){let r=(i,s)=>t("span",{class:"dl-addrbar-seg"},[v(i),...s]),o=e.endpoint||"—",a=t("div",{class:"dl-actions"},[e.enabled?"":D([v("play")," Turn on"],()=>this.save(e,{enabled:"1"},"Server turned on"),"add")]);return t("div",{class:"dl-srvpagehead"},[t("div",{class:"dl-title-row"},[t("h2",{class:"dl-h1"},e.name),t("span",{class:`dl-pill ${e.enabled?e.up?"ok":"bad":"warn"}`},e.enabled?e.up?"Running":e.blocked?"Can’t start":"Not running":"Turned off"),t("span",{class:"dl-spacer"}),a]),t("div",{class:"dl-addrbar"},[t("button",{type:"button",class:"dl-addrbar-seg main",title:"Copy address",click:()=>me(o,"Address copied")},[v("globe"),t("span",{class:"dl-mono"},o),v("copy")]),r(Be(e).id==="awg"?"amneziawg":"tunnel",[t("span",{class:"dl-mono"},`${Be(e).label} :${e.port}`)]),e.up?r("clock",[`up ${xt(e.uptime)}`]):""]),e.blocked?t("div",{class:"dl-note warn"},[v("alert"),t("span",{},`${e.name} ${e.blocked}.`)]):""])}async save(e,r,o="Saved"){await G(()=>P.serverUpdate(e.id,r),o)&&await this.refresh()}connection(e){let r=le(e.name,{placeholder:"Home"}),o=le(e.endpoint,{placeholder:"vpn.example.com",class:"cbi-input-text dl-mono"}),a=le(e.dns.join(", "),{placeholder:"This router (recommended)",class:"cbi-input-text dl-mono"}),i=this.st.people.filter($=>$.server===e.id).length,s=D([v(e.enabled?"pause":"play"),e.enabled?" Turn off":" Turn on"],async()=>{e.enabled&&!await se(`Turn off ${e.name}?`,`The tunnel stops and ${i} ${i===1?"person is":"people are"} disconnected until you turn it back on. Nothing is deleted.`,"Turn off",!0)||await this.save(e,{enabled:e.enabled?"0":"1"},e.enabled?"Server turned off":"Server turned on")},e.enabled?"negative":"positive"),l=this.st.settings.portal_host,d=ge("Name",r,()=>_e(r.value,[],"Shown to people in their portal and apps.")),c=Xn(()=>({host:o.value,port:e.port,id:e.id}),($,h,m)=>P.endpointProbe($,h,m),()=>p.refresh(),{empty:l?`Empty = the portal’s address (${l}).`:"Empty = the portal’s address."}),p=ge("Public address",o,c.help);o.addEventListener("input",c.schedule),c.schedule();let u=e.reached?`Reached from the internet ${re(e.reached,this.st.now)}.`:"Never reached from the internet yet — test with a phone on mobile data.",x=ge("DNS for devices",a,()=>Yo(a.value,e.address));return t("div",{class:"dl-stack gap16"},[Nt("Connection",[t("p",{class:"dl-muted"},"The name people see, where devices find the router, and DNS. The port is on AmneziaWG."),fe("router","Server","What people see",[d]),fe("globe","Devices connect to","A DDNS name keeps links working when your IP changes; not through Cloudflare (use a DNS-only name or an IP)",[p,t("div",{class:`dl-sub ${e.reached?"ok":"warn"}`},u)]),fe("file","For every device","Changing it marks devices “Update config” until they import again",[x])],[t("span"),D("Save",()=>{let $=ze([d,p,x]);if($){U($,"warning");return}return this.save(e,{name:r.value,endpoint:o.value,dns:a.value})},"positive")]),Nt("Danger zone",[t("div",{class:"dl-setrow"},[t("div",{class:"dl-stack"},[t("span",{class:"dl-setrow-label"},e.enabled?"Turn off this server":"This server is off"),t("span",{class:"dl-sub"},e.enabled?"Stops the tunnel and disconnects everyone on it. Settings and people are kept.":"Nobody can connect. Turn it on to bring the tunnel back.")]),t("div",{class:"dl-setrow-ctl"},s)]),t("div",{class:"dl-setrow"},[t("div",{class:"dl-stack"},[t("span",{class:"dl-setrow-label"},"Change the tunnel network"),t("span",{class:"dl-sub"},`Devices have ${Ct(e.subnet)}.x addresses now. A new range when it clashes with a network you connect to; every device then needs its configuration again.`)]),t("div",{class:"dl-setrow-ctl"},D([v("edit")," Change"],()=>this.changeSubnet(e),"negative"))]),t("div",{class:"dl-setrow"},[t("div",{class:"dl-stack"},[t("span",{class:"dl-setrow-label"},"Remove server"),t("span",{class:"dl-sub"},`Removes the tunnel, its firewall rules and ${i} ${i===1?"person":"people"} with all their devices. A backup is made first.`)]),t("div",{class:"dl-setrow-ctl"},D([v("trash")," Remove"],()=>this.remove(e),"negative"))])],[],"danger")])}access(e){let r=xo(this.st,e),o=da(e,this.st,async()=>{let a=await this.refreshStatus();if(!a)return;let i=a.servers.find(l=>l.id===e.id)??e;o.update(a);let s=xo(a,i);r.replaceWith(s),r=s});return t("div",{class:"dl-stack gap16"},[o.el,t("div",{class:"dl-health-cols"},[r,ta(this.st,e)])])}awg(e){let r={st:this.st,save:(o,a)=>this.save(e,o,a),refresh:()=>this.refresh()};return t("div",{class:"dl-stack gap16"},[Be(e).settingsCard(r,e)])}async addServer(){let e=await G(()=>P.setupDefaults());e&&dom.content(this.root,this.wizard(e,!0,()=>{dom.content(this.root,[this.tabsEl,this.headEl,this.secEl,this.bodyEl]),this.paint()}))}async changeSubnet(e){let r=await G(()=>P.serverPorts(e.id));if(!r)return;let o=r.networks??[],a=this.st.people.filter(l=>l.server===e.id).reduce((l,d)=>l+d.devices.length,0),i=le(Ct(e.subnet),{class:"cbi-input-text dl-mono dl-w-range"}),s=ge("Address range",i,()=>Qn(i.value,o,""));oe("Change the tunnel network",[s,t("p",{class:"dl-muted"},a?`${a} device${a===1?" gets a new address and stops":"s get new addresses and stop"} connecting until ${a===1?"it imports its":"they import their"} configuration again (from their personal link or from you).`:"No devices on this server yet: nothing else changes.")],[ie()," ",D("Change",async()=>{let l=s.help();if(l.bad){U(l.text,"warning");return}let d=ln(i.value);if(d===e.subnet){ae();return}await G(()=>P.serverUpdate(e.id,{subnet:d}),"Tunnel network changed")&&(ae(),a&&U("Devices are marked “Update config” until they import again.","info",6e3),await this.refresh())},"negative")]),setTimeout(()=>i.select(),50)}async remove(e){let r=this.st.people.filter(o=>o.server===e.id);oe(`Remove ${e.name}?`,[t("p",{},`This removes the tunnel, its firewall rules and ${r.length} ${r.length===1?"person":"people"} with all their devices. A backup is made first.`)],[ie()," ",D("Remove",async()=>{ae(),await G(()=>P.serverDelete(e.id),"Server removed")&&setTimeout(()=>{location.href=ko()},800)},"negative")])}wizard(e,r=!1,o){let a={id:e.id,name:e.name,endpoint:e.endpoint,port:e.port,range:Ct(e.subnet),preset:fn(e.awg),portal:!1,portal_port:e.portal_port||8443,lan_like:!0,lan_zone:e.lan_zone,wan_zone:e.wan_zone},i=0,s=!r&&a.portal_port===a.port,l=()=>/^\d{1,3}(\.\d{1,3}){3}$/.test(a.endpoint),d=()=>Rt(a.port,e.udp_taken??[],`Opened on the WAN firewall automatically.${a.port===4500?" 4500 is IPsec’s port: most networks let it through.":""}`),c={ddns:"From your DDNS name.",cert:"From your Let’s Encrypt certificate.",wan:"Your WAN address now — it may change; a DDNS name is better.",portal:"The portal’s address."},p=Xn(()=>({host:a.endpoint,port:a.port}),(M,T,z)=>P.endpointProbe(M,"",z),()=>u?.refresh(),{idle:()=>a.endpoint===e.endpoint&&e.endpoint_from?c[e.endpoint_from]??"":""}),u=null,x=e.wan_kind==="cgnat"||e.wan_kind==="private"?Xe("alert","warn",e.wan_kind==="cgnat"?"Your router has no public address (CGNAT)":`Your router is behind another router (WAN ${e.wan_ip})`,e.wan_kind==="cgnat"?"The ISP shares one address: devices can only connect if the ISP gives you a public address or IPv6. Ask them, or use a DDNS name that points at an IPv6 address.":"Forward the UDP port on the upstream router to this one and use a DDNS name or that router’s public address here.",""):"",$=e.awg_state?.tools&&e.awg_state.handler===!1?t("div",{class:"dl-note warn"},[v("alert"),t("span",{},"Creating the server restarts the network for a few seconds: AmneziaWG was installed after the network started.")]):"",h=()=>Qn(a.range,e.networks??[],Ct(e.subnet)),m=()=>dn(a.portal_port,e.tcp_taken??[],l()),E=t("div",{class:"dl-wizard"}),R=(M,T={})=>{let z=le(String(a[M]),T);return z.addEventListener("input",()=>{M==="port"||M==="portal_port"?a[M]=z.value.trim()===""?0:Number(z.value):a[M]=z.value.trim(),M==="port"&&s&&(a.portal_port=a.port),M==="portal_port"&&(s=a.portal_port===a.port)}),z},C={id:"server",title:"Server",render:()=>t("div",{class:"dl-wizard-groups"},[t("p",{class:"dl-muted"},r?"One more server: another port or disguise for networks where the first does not get through, or its own home access rules. People are moved between servers from their page.":"Where devices connect to. A hostname that always points at your router (DDNS) keeps links working when your IP changes."),fe("router","Server","What people see",[ge("Name",R("name"),()=>_e(a.name,[],"Shown to people in their portal and apps."))]),fe("globe","Devices connect to","A hostname or IP address of your router on the internet; not through Cloudflare (use a DNS-only name or an IP). IPv6 works too, and is the way out of CGNAT",[(()=>{let M=R("endpoint",{placeholder:"vpn.example.com",class:"cbi-input-text dl-mono"});return u=ge("Public address",M,p.help),M.addEventListener("input",p.schedule),p.schedule(),u})()]),x,$]),check:()=>{let M=_e(a.name);if(M.bad)return`Name: ${M.text}`;let T=$t(a.endpoint,a.port);return T.bad?`Public address: ${T.text}`:null}},k={id:"awg",title:"AmneziaWG",render:()=>t("div",{class:"dl-wizard-groups"},[fe("globe","Listening","Where devices reach AmneziaWG from the internet",[ge("UDP port",R("port",{inputmode:"numeric",class:"cbi-input-text dl-w-port dl-mono"}),d)]),fe("network","Tunnel network","Addresses devices get inside the tunnel",[(()=>{let M=R("range",{class:"cbi-input-text dl-w-range dl-mono","aria-label":"First three numbers of the device addresses"});return ge("Device addresses",M,h,t("span",{class:"dl-suffixed"},[M,t("span",{class:"dl-mono"},".x")]))})()]),fe("shield","Disguise","So networks that block VPNs do not recognise the tunnel. Off = plain WireGuard",[gn(e.awg,a.preset,M=>a.preset=M,void 0,e.awg_state?.tools!==!1)])]),check:()=>{let M=d();if(M.bad)return`UDP port: ${M.text}`;let T=h();return T.bad?`Device addresses: ${T.text}`:null}},y={id:"portal",title:"Portal",render:()=>{let M=R("portal_port",{inputmode:"numeric",class:"cbi-input-text dl-w-port dl-mono"}),T=ge("Listening port",M,m);T.hidden=!a.portal;let z=we([["off","Off"],["on","On"]],a.portal?"on":"off",{label:"Personal portal",onChange:W=>{a.portal=W==="on",T.hidden=!a.portal}});return t("div",{class:"dl-wizard-groups"},[fe("home","Internet like a home device","How devices reach the internet",[ce("Through the home network",ve(a.lan_like,"Internet like a home device",W=>a.lan_like=W),"Whatever handles home traffic on this router (proxies, filters, DNS) handles theirs too. Change it later under Servers → Access.")]),fe("link","Personal portal","A page where each person adds their own devices with their personal link",[ce("Portal",z,"Off: only you add devices, from LuCI. On: people manage their devices within the limits you set."),T])])},check:()=>{if(!a.portal)return null;let M=m();return M.bad?`Portal port: ${M.text}`:null}},w=()=>[C,k,r?null:y].filter(M=>M!=null),b=e.awg_state,H=b?.missing??[],f=H.length?t("div",{class:"dl-list dl-notices"},[Xe("shield","bad","AmneziaWG isn’t installed",`The tunnel needs ${H.join(" and ")}. Install the build made for this firmware, then create the server.`,D("Install",()=>Tn(()=>location.reload()),"positive"))]):b&&!b.loaded?t("div",{class:"dl-list dl-notices"},[Xe("shield","warn","AmneziaWG’s kernel module doesn’t load on this firmware","Try another build in Components, or update OpenWrt. The server can’t start until it loads.",t("a",{class:"cbi-button cbi-button-neutral",href:L.url("admin/network/dawnline/updates")},"Open Components"))]):"",g=()=>{let M=w();i>=M.length&&(i=M.length-1),dom.content(E,[t("h2",{},r?"Add a server":"Set up Dawnline"),f,t("div",{class:"dl-steps"},M.map((T,z)=>t("span",{class:`dl-step${z===i?" current":z0?D("Back",()=>{i--,g()}):o?D("Cancel",o):"",t("span",{class:"dl-spacer"}),i{let T=M[i].check?.();if(T){U(T,"warning");return}i++,g()},"positive"):D("Create server",async()=>{for(let z of M){let W=z.check?.();if(W){U(W,"warning");return}}let T=await G(()=>P.serverCreate(a.id,a.name,e.ifname,a.port,ln(a.range),a.endpoint,e.mtu,a.preset,a.lan_zone,a.wan_zone,a.lan_like,r?void 0:a.portal,r?void 0:a.portal_port),"Server created");T&&(T.network_restart&&U("Restarting the network so it knows AmneziaWG: back in a few seconds"),setTimeout(()=>{location.href=ko(T.id)},T.network_restart?1e4:1500))},"positive",{disabled:H.length>0,title:H.length?"Install AmneziaWG first":null})])])};return g(),E}};function st(n){let e={el:n(),refresh(){let r=n();e.el.replaceWith(r),e.el=r}};return e}function Re(n,e,r,o,a="",i=[]){return t("section",{class:`dl-setsec ${a}`,id:`dl-set-${n}`},[t("div",{class:"dl-setsec-body"},[i.length?t("div",{class:"dl-setsec-head"},[t("h3",{},e),t("span",{class:"dl-spacer"}),...i]):t("h3",{},e),...r]),o.length?t("div",{class:"dl-setsec-foot"},o):""])}function fa(n){let e=n.filter(a=>a.status!=="skip"),r=e.filter(a=>a.status==="error"||a.status==="warn"),o=e.some(a=>a.status==="error")?"error":r.length?"warn":"ok";return{bad:r,worst:o}}function ga(n){let e=n.d.settings,r=n.d.effective,o=n.d.cert,a=ve(r.portal_enabled,"Enable portal"),i=le(e.portal_port,{placeholder:"8443",inputmode:"numeric",class:"cbi-input-text dl-w-port"}),s=le(e.portal_redirect,{placeholder:"Show “Not found”",class:"cbi-input-text dl-mono"}),l=le("",{placeholder:"vpn.example.com or an IP","aria-label":"Other address"}),d=B=>/^\d{1,3}(\.\d{1,3}){3}$/.test(B),c=[r.portal_host,...r.portal_alt??[]].filter((B,F,ne)=>B&&ne.indexOf(B)===F),p=!!n.portal,u=[],x=B=>{B&&!u.some(F=>F.host===B)&&u.push({host:B,kind:d(B)?"ip":"name",ips:[],here:!1,cloudflare:!1,cert:!1})},$=B=>{u=[...B,...u.filter(F=>!B.some(ne=>ne.host===F.host))],!c.length&&B[0]&&(c=[B[0].host])};n.portal&&$(n.portal.candidates),c.forEach(x);let h=B=>B.kind==="ip"?t("span",{class:"dl-addr-warn"},[v("alert"),"Plain HTTP: the link and VPN keys travel unencrypted"]):t("span",{class:"dl-sub"},B.cloudflare?"Behind Cloudflare · often stalls in Russia":B.ips.length?B.here?`Points at this router${B.cert?" · Let’s Encrypt certificate":" · no certificate yet"}`:`Points at ${B.ips.join(", ")}, not this router`:p?"Your address":"Checking where it points…"),m=t("div",{class:"dl-addr-opts",role:"group","aria-label":"Portal addresses"}),E=B=>{c.includes(B)?c.length>1&&(c=c.filter(F=>F!==B)):c=[...c,B],R(),y()},R=()=>dom.content(m,[...u.map(B=>{let F=c.includes(B.host),ne=c[0]===B.host;return t("div",{class:`dl-addr-opt${F?" on":""}`,role:"checkbox","aria-checked":F?"true":"false",tabindex:"0",click:()=>E(B.host),keydown:pe=>{(pe.key===" "||pe.key==="Enter")&&(pe.preventDefault(),E(B.host))}},[t("i",{class:"dl-addr-check"},F?v("check"):""),t("span",{class:"dl-stack"},[t("span",{class:"dl-mono"},B.host),h(B)]),ne?t("span",{class:"dl-pill info"},"Main"):F?t("button",{type:"button",class:"dl-linkbtn",click:pe=>{pe.stopPropagation(),c=[B.host,...c.filter(A=>A!==B.host)],R(),y()}},"Make main"):B.cloudflare?t("span",{class:"dl-pill warn"},"Cloudflare"):B.kind==="ip"?t("span",{class:"dl-pill"},"IP"):B.here&&B.cert?t("span",{class:"dl-pill ok"},"Recommended"):""])}),t("div",{class:"dl-addr-opt other"},[t("i",{class:"dl-addr-check"},v("plus")),l,D("Add",()=>{let B=l.value.trim().toLowerCase();if(!B)return;let F=$t(B);if(F.bad){U(F.text,"warning");return}x(B),c.includes(B)||(c=[...c,B]),l.value="",R(),y()})])]);l.addEventListener("keydown",B=>{B.key==="Enter"&&(B.preventDefault(),l.nextElementSibling?.click())});let C=t("div",{class:"dl-links"}),k=()=>{},y=()=>{k();let B=Number(i.value)||r.portal_port;dom.content(C,c.map((F,ne)=>{let pe=d(F),A=pe?B+1:B,N=`${pe?"http":"https"}://${F}${A===(pe?80:443)?"":`:${A}`}/`;return t("div",{class:"dl-link-row"},[t("span",{class:`dl-link-ic ${pe?"warn":"ok"}`},v(pe?"alert":"lock")),t("span",{class:"dl-mono dl-link-url"},[N,t("b",{},"kamiro-telosu-bavine")]),ne===0?t("span",{class:"dl-pill info"},"Main"):pe?t("span",{class:"dl-pill warn"},"HTTP"):""])}))};R(),y(),i.addEventListener("input",()=>y());let w={portal:"Portal running",portal_dns:"Points here",portal_reply:"Answers reach visitors",portal_http:"Plain HTTP",cert:"Certificate"},b=n.d.needs??{https:[],acme:[],home:[]},H=B=>{if(!r.portal_enabled)return t("div",{hidden:!0});if(!B)return fe("check","Ready to share","The portal’s checks from Health",[t("p",{class:"dl-muted dl-loading"},"Running checks…")]);let F=B.filter(S=>S.status!=="skip");if(!F.length)return t("div",{hidden:!0});let{bad:ne,worst:pe}=fa(B),A=t("div",{class:"dl-ready-details",hidden:!0},F.map(S=>t("div",{class:`dl-ready-item ${S.status}`},[v(S.status==="ok"?"check":"alert"),t("span",{class:"dl-stack"},[t("span",{},S.title),t("span",{class:"dl-sub"},S.detail)])]))),N=t("div",{class:"dl-stack gap8"},[t("div",{class:`dl-ready-sum ${pe}`},[v(pe==="ok"?"check":"alert"),t("span",{class:"dl-stack"},[t("b",{},pe==="ok"?`All ${F.length} checks passed`:`${F.length-ne.length} of ${F.length} checks passed`),ne.length?t("span",{class:"dl-sub"},ne.map(S=>S.detail).join(" ")):t("span",{class:"dl-sub"},"Links will open for the people you send them to.")]),t("button",{type:"button",class:"dl-linkbtn",click:S=>{A.hidden=!A.hidden,S.currentTarget.textContent=A.hidden?"Details":"Hide"}},"Details")]),t("div",{class:"dl-chips-row"},F.map(S=>t("span",{class:`dl-check-chip ${S.status}`,title:S.detail},[v(S.status==="ok"?"check":"alert"),w[S.id]??S.title]))),A]);return fe("check","Ready to share","The portal’s checks from Health",[N])},f=B=>{if(!r.portal_enabled||!B&&!b.https.length)return t("span",{hidden:!0});if(b.https.length)return t("span",{class:"dl-pill bad"},"Can’t start");let{worst:F}=fa(B);return t("span",{class:`dl-pill ${F==="ok"?"ok":F==="error"?"bad":"warn"}`},F==="error"?"Needs attention":"Ready")},g=H(n.portal?.checks??null),M=f(n.portal?.checks??null);n.portalFill=B=>{p=!0,$(B.candidates),R(),y();let F=H(B.checks);g.replaceWith(F),g=F;let ne=f(B.checks);M.replaceWith(ne),M=ne};let T=o&&!o.self_signed&&o.expires?Ue(o.expires):"",z=ge("Listening port",i,()=>dn(i.value.trim()===""?r.portal_port:Number(i.value),n.d.tcp_taken??[],c.some(d)));k=z.refresh;let W=ge("Unknown links",s,()=>nr(s.value)),q=!!(e.portal_cert&&e.portal_key),Z=o?q?"Your files":o.self_signed?"Self-signed":"Let’s Encrypt":"Portal is off",I=()=>{let B=le(e.portal_cert,{placeholder:"/etc/ssl/…/fullchain.crt"}),F=le(e.portal_key,{placeholder:"/etc/ssl/…/key"});oe("Use your own certificate",[t("p",{class:"dl-muted"},"Paths on the router. Leave both empty to pick a certificate automatically."),ce("Certificate file",B),ce("Key file",F)],[ie()," ",D("Save",()=>{ae(),n.save({portal_cert:B.value.trim(),portal_key:F.value.trim()},"Certificate saved","portal")},"positive")])},V=(B,F,ne,pe,A,N)=>Xe(B,F,ne,pe,D(N,()=>Jt(A,b[A],()=>n.reload("portal")),"positive")),Q=b.https.length?V("lock","bad","HTTPS isn’t available on this router",`The portal needs ${b.https.join(" and ")}. It can’t start without them.`,"https","Install"):"",de=b.acme.length&&(!o||o.self_signed)?V("lock","","Free certificate from Let’s Encrypt",`ACME isn’t installed. With it the router gets a certificate${e.portal_host?` for ${e.portal_host}`:""} and browsers stop warning.`,"acme","Install ACME"):"",ee=[t("div",{class:"dl-row"},[v("lock"),t("span",{class:"dl-row-main dl-stack"},[t("b",{},[Z,T?t("span",{class:"dl-faint"},` · until ${T}`):""]),t("span",{class:"dl-sub dl-ellipsis",title:o?.path??""},o?o.self_signed?"Made by the router: browsers warn until a certificate covers the address.":`${q?"Your files":"Found automatically"} · ${o.path}`:"Turn the portal on to see its certificate.")])]),t("div",{class:"dl-row"},[v("file"),t("span",{class:"dl-row-main dl-stack"},[t("b",{},"Your own files"),t("span",{class:"dl-sub"},q?`${e.portal_cert} · ${e.portal_key}`:"Not set: the certificate is picked automatically.")]),q?D("Reset",()=>n.save({portal_cert:"",portal_key:""},"Automatic certificate","portal"),"negative"):"",D(q?"Change":"Use files",I)]),de];return Re("portal","Personal portal",[t("span",{class:"dl-muted"},"A page where each person adds and manages their devices with their personal link."),Q?t("div",{class:"dl-list"},[Q]):"",fe("network","Port","How the portal listens (80 and 443 stay free)",[z]),fe("edit","Appearance","What people see",[W]),fe("link","Addresses","Pick one or more; the first is the main link",[m,t("div",{class:"dl-stack gap8"},[C,t("span",{class:"dl-sub"},"Example code; each person gets their own three words.")])]),fe("lock","Certificate","Used for HTTPS links",ee),g],[t("span"),D("Save",()=>{let B=ze([z,W]);if(B){U(B,"warning");return}return n.save({portal_enabled:Pe(a)?"1":"0",portal_host:c[0]??"",portal_alt:c.slice(1),portal_port:i.value,portal_redirect:s.value.trim()},"Saved","portal")},"positive")],"",[M,a])}function va(n){let e=n.d.settings,r=n.d.effective,o=le(e.default_device_limit,{placeholder:"3",inputmode:"numeric",class:"cbi-input-text dl-w-port"}),a=ve(r.hostnames,"Device hostnames"),i=le(e.domain,{placeholder:"lan",class:"cbi-input-text dl-w-port"}),s=le(e.home_dns_fallback==="none"?"":e.home_dns_fallback||r.home_dns_fallback||"",{placeholder:"None",inputmode:"decimal",class:"cbi-input-text dl-w-ip dl-mono"}),l=ge("Devices per person",o,()=>{if(!o.value.trim())return{text:"The default, 3. Pre-filled when you add someone.",bad:!1};let p=cn(o.value);return p.bad?p:{text:"Pre-filled when you add someone.",bad:!1}}),d=ge("Device hostnames",i,()=>or(i.value),t("div",{class:"dl-hostport"},[a,t("span",{class:"dl-faint dl-mono"},"phone.myata."),i])),c=ge("Fallback DNS",s,()=>{let p=rr(s.value);return p.bad?p:{text:`For Home-only devices using home names: ${p.text}`,bad:!1}});return Re("defaults","New people",[l,d,c],[t("span"),D("Save",()=>{let p=ze([l,d,c]);if(p){U(p,"warning");return}return n.save({default_device_limit:o.value,hostnames:Pe(a)?"1":"0",domain:i.value,home_dns_fallback:s.value},"Saved","defaults")},"positive")])}function ba(n){let e=n.d.effective,r=ve(e.geo_enabled,"Locations"),o=t("select",{class:"cbi-input-select"},[t("option",{value:"ipwho.is",selected:e.geo_provider!=="ipapi.co"?"selected":null},"ipwho.is (fallback: ipapi.co)"),t("option",{value:"ipapi.co",selected:e.geo_provider==="ipapi.co"?"selected":null},"ipapi.co (fallback: ipwho.is)")]);return Re("map","Map & locations",[t("div",{class:"dl-setrow head"},[t("span",{class:"dl-muted"},"Show where people connect from on the Overview and person pages, at city level."),r]),ce("Provider",o)],[t("span",{class:"dl-sub"},"The router sends each new client IP to the provider once and caches the city. Map tiles load in your browser from CARTO; people never see the map."),D("Save",()=>n.save({geo_enabled:Pe(r)?"1":"0",geo_provider:o.value},"Saved","map"),"positive")])}var Fs=[["app","Dawnline"],["amneziawg","AmneziaWG"],["packages","System packages"]];function xa(n){let e=n.d.effective.updates,r=ve(e.check,"Check automatically",h=>$(h,Pe(a))),o=we([["6h","Every 6 h"],["12h","Every 12 h"],["1d","Daily"],["7d","Weekly"]],e.interval,{label:"How often",cls:"sm"}),a=ve(e.auto,"Install automatically",h=>$(Pe(r),h)),i=le(e.time,{placeholder:"04:00",inputmode:"numeric",class:"cbi-input-text dl-w-port dl-mono","aria-label":"Time"}),s=we([["scheduled","At a set time"],["immediate","As soon as found"]],e.mode,{label:"When",cls:"sm",onChange:h=>i.hidden=h!=="scheduled"});i.hidden=e.mode!=="scheduled";let l=new Set(e.targets),d=t("div",{class:"dl-chips-row"},Fs.map(([h,m])=>{let E=qe(m,l.has(h),()=>{l.delete(h)||l.add(h),hn(E,l.has(h))});return E})),c=ve(e.keep,"Keep the previous version"),p=ve(e.mirrors,"GitHub mirrors"),u=ce("How often",o),x=[ce("When",t("div",{class:"dl-hostport"},[s,i]),"A set time keeps tunnel restarts out of the evening; the run happens within an hour of it."),ce("Components",d,"AmneziaWG is off by default: a new kernel module restarts every tunnel.")],$=(h,m)=>{u.hidden=!h;for(let E of x)E.hidden=!m};return $(e.check,e.auto),Re("updates","Updates",[t("span",{class:"dl-muted"},"How Dawnline keeps its components current. Every Dawnline update makes a backup of the settings first."),ce("Check automatically",r,"Looks for new versions in the background; Components shows what it found and the service log names it."),u,ce("Install automatically",a,"Downloads and installs new versions of the components below."),...x,ce("Keep the previous version",c,"Saves the replaced Dawnline or AmneziaWG package on flash, so Roll back works without internet. Under 1 MB."),ce("GitHub mirrors",p,"When GitHub is unreachable, download through mirrors. Checksums are still verified.")],[t("span",{class:"dl-sub"},"Run a check or an update by hand in Components."),D("Save",()=>{if(s.dataset.value==="scheduled"){let h=ar(i.value);if(h.bad){U(`Time: ${h.text}`,"warning");return}}return n.save({update_check:Pe(r)?"1":"0",update_interval:o.dataset.value,update_auto:Pe(a)?"1":"0",update_mode:s.dataset.value,update_time:i.value.trim(),update_targets:[...l],update_keep:Pe(c)?"1":"0",update_mirrors:Pe(p)?"1":"0"},"Saved","updates")},"positive")])}function wa(n){let e=n.d.logs,r=e.policy,o=we([["7","7 days"],["30","30 days"],["90","90 days"],["365","1 year"],["0","No limit"]],String(r.keep_days),{label:"Keep activity",cls:"sm"}),a=we([["500","500"],["2000","2,000"],["5000","5,000"],["20000","20,000"]],String(r.max),{label:"Maximum events",cls:"sm"}),i=we([["10min","Every 10 min"],["hourly","Hourly"],["off","Memory only"]],r.persist,{label:"Save to flash",cls:"sm"}),s=we([["31","1 month"],["62","2 months"],["180","6 months"],["365","1 year"],["730","2 years"]],String(r.usage_days),{label:"Daily traffic",cls:"sm"}),l=we([["12","1 year"],["24","2 years"],["60","5 years"],["120","10 years"]],String(r.usage_months),{label:"Monthly traffic",cls:"sm"}),d=new Set(r.categories),c=t("div",{class:"dl-chips-row"},Lt.map($=>{let h=qe([ut[$],t("b",{},String(e.by_category[$]??0))],d.has($),()=>{d.delete($)||d.add($),hn(h,d.has($))},{title:ir[$]});return h})),p=e.oldest?Ue(new Date(e.oldest*1e3)):"",u=($,h,m,E)=>t("div",{class:"dl-row"},[v($),t("span",{class:"dl-row-main dl-stack"},[t("b",{},h),t("span",{class:"dl-sub"},m)]),...E]),x=$=>D($.toUpperCase(),async()=>{let[h,m]=await Promise.all([P.status(1),P.events(2e4)]);Fe(h,m.events,$)},"neutral",{title:`Download the log as ${$.toUpperCase()}`});return Re("logs","Logs & history",[t("p",{class:"dl-muted"},mn(r)),ce("Keep activity",o,"Older events are removed automatically."),ce("Maximum size",a,"Newest events are kept when the log is full."),ce("Record",c,"Switched-off categories are not logged from now on."),ce("Save to flash",i,"The log lives in memory and is copied to flash. Memory only saves flash writes but is lost on reboot."),ce("Daily traffic",s,"Per-day history behind the charts."),ce("Monthly traffic",l,"Per-month totals; data limits use the current month."),t("h4",{class:"dl-setsub"},"Stored data"),t("div",{class:"dl-list"},[u("activity","Activity log",e.events?`${en(e.events,"event")} since ${p} · ${zt(e.log_ram)} in memory${r.persist==="off"?"":`, ${zt(e.log_flash)} on flash`}`:"Empty",[x("csv"),x("json"),D("Clear",()=>et("Clear activity","Removes events from the log on the router.",{},()=>n.reload("logs")),"negative")]),u("chart","Traffic history",e.usage_days?`${en(e.usage_days,"day")} since ${Ue(e.usage_since)} · ${zt(e.usage_flash)} on flash`:"Empty",[D("Reset",()=>Mt("all","","",()=>setTimeout(()=>n.reload("logs"),300)),"negative")]),u("pin","Location cache",`${en(n.d.geo_cached,"address","addresses")} · ${zt(e.geo_flash)} on flash`,[D("Clear",async()=>{await G(()=>P.geoClear(),"Location cache cleared")&&await n.reload("logs")},"negative")])])],[t("span",{class:"dl-sub"},"Clear one person or device from their own page."),D("Save",()=>n.save({log_keep_days:o.dataset.value,log_max:a.dataset.value,log_persist:i.dataset.value,usage_keep_days:s.dataset.value,usage_keep_months:l.dataset.value,log_category:[...d]},"Saved","logs"),"positive")])}var qs={manual:"Manual",auto:"Nightly","pre-restore":"Before restore","pre-import":"Before import","pre-delete":"Before removing a server","pre-update":"Before update"},ya=3;function $o(n){let e=new Date(n*1e3),r=e.toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit"}),o=Math.round((new Date(new Date().toDateString()).getTime()-new Date(e.toDateString()).getTime())/864e5);return`${o===0?"Today":o===1?"Yesterday":e.toLocaleDateString("en-GB",{day:"numeric",month:"short"})}, ${r}`}async function Ks(n){let e=await G(()=>P.backupRead(n.name));if(!e)return;let r=atob(e.data),o=new Uint8Array(r.length);for(let i=0;iKs(n),"neutral","dl-icon-only"),Le("more","More",r=>Ce(r.currentTarget,[{label:"Restore",icon:v("reset"),run:async()=>{await se("Restore this backup?",`Everything returns to ${$o(n.created)}. The current state is backed up first.`,"Restore",!0)&&await G(()=>P.backupRestore(n.name),"Restored")&&e(!0)}},{label:"Delete",icon:v("trash"),danger:!0,run:async()=>{await se("Delete this backup?",`The backup from ${$o(n.created)} is removed from the router.`,"Delete",!0)&&await G(()=>P.backupDelete(n.name),"Backup deleted")&&e()}}]),"neutral","dl-icon-only")])])}function $a(n,e){let r=n.slice(0,ya).map(d=>ka(d,e)),o=n.slice(ya),a=n.length?t("div",{class:"dl-list"},[...r,o.length?t("details",{class:"dl-bk-older"},[t("summary",{},[v("chevron"),`${o.length} older backup${o.length===1?"":"s"}`]),...o.map(d=>ka(d,e))]):""]):t("div",{class:"dl-list"},[t("div",{class:"dl-row dl-muted"},"No backups yet.")]),i=D("Restore from file",async()=>{let d=await qn(".tar.gz,.tgz,application/gzip","base64");if(!d)return;await se("Restore from file?",`Replace the current Dawnline configuration with ${d.name}? The current state is backed up first.`,"Restore",!0)&&await G(()=>P.backupUpload(d.data),"Restored")&&e(!0)}),s=D("Export JSON",async()=>{let d=await G(()=>P.exportJson());d&&Te(`dawnline-export-${new Date().toISOString().slice(0,10)}.json`,JSON.stringify(d,null,2),"application/json")}),l=D("Import JSON",async()=>{let d=await qn(".json,application/json","text");if(!d)return;let c;try{c=JSON.parse(d.data)}catch{U("Not a JSON file.","error");return}await se("Import?","This replaces the whole Dawnline configuration on this router. The current state is backed up first.","Import",!0)&&await G(()=>P.importJson(c),"Imported")&&e(!0)});return t("section",{class:"dl-setsec",id:"dl-set-backups"},[t("div",{class:"dl-setsec-body"},[t("div",{class:"dl-setsec-head"},[t("div",{class:"dl-stack"},[t("h3",{},"Backups"),t("span",{class:"dl-sub"},"Nightly when something changed, and before every restore, import or update. The last 10 are kept.")]),t("span",{class:"dl-spacer"}),D([v("plus")," Back up now"],async()=>{await G(()=>P.backupCreate(),"Backup created")&&e()},"positive")]),a]),t("div",{class:"dl-setsec-foot"},[t("span",{class:"dl-sub"},"Backups contain private keys: keep downloads safe. JSON moves everything except usage history to another router."),t("span",{class:"dl-row-actions dl-bk-actions"},[i,s,l])])])}function Vs(){let n=le("",{placeholder:"remove"}),e=D("Remove Dawnline",async()=>{await G(()=>P.uninstall(n.value.trim()),"Dawnline removed")&&(ae(),setTimeout(()=>location.reload(),800))},"negative",{disabled:!0});n.addEventListener("input",()=>{e.disabled=n.value.trim()!=="remove"}),oe("Remove Dawnline?",[t("p",{},"Everyone is disconnected and the tunnel, firewall rules and portal are removed. A backup is made first. Type “remove” to confirm."),n],[ie()," ",e])}function Ca(){return Re("danger","Remove Dawnline from this router",[t("p",{class:"dl-muted"},"Deletes the tunnel, firewall rules, access table and hostnames Dawnline created, and stops the service. People and keys are kept in a backup.")],[t("span"),D("Remove",()=>Vs(),"negative")],"danger")}var zn=class{constructor(){this.root=t("div",{class:"dl-settings-main"});this.backups=[];this.portal=null;this.portalSeq=0;this.cards={}}load(){return P.settingsGet()}render(e){this.d=e,this.cards={portal:st(()=>ga(this)),defaults:st(()=>va(this)),map:st(()=>ba(this)),updates:st(()=>xa(this)),logs:st(()=>wa(this)),backups:st(()=>$a(this.backups,a=>this.loadBackups(a))),danger:st(()=>Ca())};let r=["portal","defaults","map","updates","logs","backups","danger"];dom.content(this.root,r.map(a=>this.cards[a].el)),this.loadBackups().then(()=>{new URLSearchParams(location.search).get("section")==="backups"&&document.getElementById("dl-set-backups")?.scrollIntoView({block:"start"})}),this.loadPortal();let o=new URLSearchParams(location.search).get("section");return o&&o!=="backups"&&requestAnimationFrame(()=>document.getElementById(`dl-set-${o}`)?.scrollIntoView({block:"start"})),t("div",{},[t("div",{class:"dl-pagehead"},[t("h2",{class:"dl-h1"},"Settings")]),this.root])}async save(e,r,o){let a=await G(()=>P.settingsUpdate(e),r);a&&(this.d=a,this.cards[o].refresh(),o==="portal"&&this.loadPortal())}async loadPortal(){let e=++this.portalSeq,r=await P.portalInfo().catch(()=>null);e===this.portalSeq&&(this.portal=r??this.portal??{candidates:[],checks:[]},this.portalFill?.(this.portal))}async loadBackups(e=!1){e&&await this.reload();let r=await P.backupList().catch(()=>null);r&&(this.backups=r.backups,this.cards.backups?.refresh())}async reload(e){let r=await P.settingsGet().catch(()=>null);if(r){if(this.d=r,e)this.cards[e].refresh();else for(let o of Object.values(this.cards))o.refresh();(!e||e==="portal")&&this.loadPortal()}}};function Ea(n,e=!1){return n&&(e?/^https?:\/\//i:/^https:\/\//i).test(n)?n:null}function La(n){let e=[],r=l=>{let d=[],c=/(`[^`]+`)|(\*\*[^*]+\*\*)|(\[[^\]]+\]\((https?:\/\/[^)\s]+)\))|(https?:\/\/[^\s<>()]+[^\s<>().,;:!?])/g,p=0;for(let u;u=c.exec(l);)u.index>p&&d.push(l.slice(p,u.index)),u[1]?d.push(t("code",{},u[1].slice(1,-1))):u[2]?d.push(t("b",{},u[2].slice(2,-2))):u[3]?d.push(t("a",{href:u[4],target:"_blank",rel:"noopener"},u[3].replace(/^\[|\]\(.*$/g,""))):u[5]&&d.push(t("a",{href:u[5],target:"_blank",rel:"noopener"},u[5].replace(/^https?:\/\/(github\.com\/)?/,""))),p=u.index+u[0].length;return p{a.length&&e.push(t("p",{},r(a.join(" ")))),a=[],o=null};for(let l of n.replace(/\r/g,"").split(` `)){let d=l.trimEnd();if(i){/^```/.test(d.trim())?(e.push(t("pre",{},i.join(` `))),i=null):i.push(l);continue}if(/^```/.test(d.trim())){s(),i=[];continue}let c=/^(#{1,6})\s+(.*)$/.exec(d),p=/^\s*[-*+]\s+(.*)$/.exec(d)??/^\s*\d+[.)]\s+(.*)$/.exec(d);c?(s(),e.push(t("h5",{},r(c[2])))):p?(a.length&&s(),o||(o=t("ul",{}),e.push(o)),o.appendChild(t("li",{},r(p[1])))):d.trim()?(o&&(o=null),a.push(d.trim())):s()}return i&&e.push(t("pre",{},i.join(` -`))),s(),e}function Sa(n){let e=[],r=!1;for(let o of n.replace(/\r/g,"").split(` +`))),s(),e}function Ma(n){let e=[],r=!1;for(let o of n.replace(/\r/g,"").split(` `)){let a=/^#{1,6}\s+(.*)$/.exec(o);if(a){if(r=/^install\b/i.test(a[1].trim()),/^what.s new$/i.test(a[1].trim()))continue}else/^\*\*Full Changelog\*\*/.test(o)&&(r=!1);r||e.push(o)}return e.join(` `).replace(/\n{3,}/g,` -`).trim()}async function Qt(n,e,r,o){let a=t("div",{class:"dl-notes"},t("p",{class:"dl-muted dl-loading"},"Loading release notes…")),i=t("div",{class:"dl-op-head"}),s="";oe(r,[i,a],[H([b("copy")," Copy"],()=>ue(s,"Release notes copied"))," ",ie("Close")],"wide");try{let l=await A.updatesNotes(n,e,o??"");s=Sa(l.body||"");let d=La(l.url);dom.content(i,[l.published?t("span",{class:"dl-pill"},Ue(l.published)):"",l.prerelease?t("span",{class:"dl-pill warn"},"Pre-release"):"",t("span",{class:"dl-spacer"}),d?t("a",{href:d,target:"_blank",rel:"noopener",class:"dl-linkbtn"},["On GitHub ",b("open")]):""]),dom.content(a,s.trim()?Ma(s):t("p",{class:"dl-muted"},"This release has no notes."))}catch(l){dom.content(a,t("p",{class:"dl-muted"},be(l)))}}var Ta={"6h":"every 6 h","12h":"every 12 h","1d":"daily","7d":"weekly"},Co=n=>n?Ue(n):"";function Vs(n){let e=/^(.{20,}?)(?:;\s|:\s)/.exec(n)?.[1];return e||(n.length<=90?n:`${n.slice(0,90).replace(/[\s,;:]+\S*$/,"")}…`)}function Pa(n,e){let r=n.st,o=r.policy,a=r.kept?.app,i=e?.update&&e.tag?e.tag:r.version,s=x=>()=>Qt("app",x,`What’s new in Dawnline ${x.replace(/^v/,"")}`),l=e?.tag&&(e.update||e.status==="latest")?Js(n,e.tag,e.update?r.version:""):null,d=e?.tag??i,c=o.check&&r.auto?.check?r.auto.check+({"6h":6,"12h":12,"1d":24,"7d":168}[o.interval]??24)*3600:0,p=(x,$)=>t("div",{class:"dl-stack gap4"},[t("span",{class:"dl-metric-label"},x),t("span",{class:"dl-comp-side-v"},$)]),u=[{label:"What’s new",ic:"file",run:s(i)},{label:"Open on GitHub",ic:"globe",run:()=>window.open(`https://github.com/${r.repo}`,"_blank","noopener")},null,{label:`Reinstall ${r.version}`,ic:"reset",warn:!0,run:()=>n.op("app:reinstall","Reinstalling Dawnline",r.version)},a?{label:`Roll back to ${a.version}`,ic:"archive",warn:!0,run:async()=>{await le(`Roll back to Dawnline ${a.version}?`,`The copy kept on the router replaces ${r.version}. A backup of the settings is made first.`,"Roll back")&&n.op("app:rollback","Rolling back Dawnline",r.version)}}:null];return t("section",{class:"dl-panel flush dl-comp-hero"},[t("div",{class:"dl-comp-hero-main"},[t("div",{class:"dl-comp-hero-head"},[t("span",{class:"dl-group-ic"},b("sunrise")),t("b",{class:"dl-comp-name"},"Dawnline"),n.state("app",e,e?.latest??""),t("span",{class:"dl-spacer"}),n.round(()=>n.op("check:app","Checking Dawnline",r.version),u,!0)]),t("div",{class:"dl-comp-verrow"},[t("div",{class:"dl-stack"},[t("div",{class:"dl-comp-big"},[r.version,e?.update?t("small",{},`→ ${e.latest}`):e?.status==="dev"&&e.latest?t("small",{class:"dl-faint"},`release ${e.latest}`):""]),t("span",{class:"dl-faint dl-comp-meta"},e?.error?"":e?.update?e.published?`released ${Co(e.published)}`:"":e?.status==="dev"?"ahead of the latest release":e?`latest release${e.published?` · released ${Co(e.published)}`:""}`:"not checked yet")])]),l?.items.length?t("div",{class:"dl-stack gap4"},[t("ul",{class:"dl-comp-bullets"},l.items.map(x=>t("li",{},x))),l.total>l.items.length?t("button",{type:"button",class:"dl-linkbtn dl-comp-more",click:s(d)},`+${l.total-l.items.length} more in What’s new`):""]):"",e?.error?t("p",{class:"dl-sub dl-comp-lead dl-upd-bad"},e.error):"",e?.update?t("div",{class:"dl-comp-btns"},[H("Update now",()=>n.op("app","Updating Dawnline",r.version),"positive",{disabled:n.busy}),H("What’s new",s(i))]):"",Ys(n)]),t("div",{class:"dl-comp-hero-side"},[p("Source",[b("globe"),t("a",{href:`https://github.com/${r.repo}`,target:"_blank",rel:"noopener"},r.repo)]),p("Auto-update",[o.auto?Ee("ok","On"):Ee("","Off"),t("span",{class:"dl-muted"},o.auto?o.mode==="immediate"?"as soon as found":`${Ta[o.interval]==="weekly"?"weekly":"daily"} at ${o.time}`:o.check?`checks ${Ta[o.interval]}`:"checks off")]),p("Last check",r.check?[re(r.check.time,r.now),c>r.now?t("span",{class:"dl-faint"},`· next in ${xt(c-r.now)}`):""]:["Never"]),p("Rollback",a?[t("span",{class:"dl-mono"},a.version),t("span",{class:"dl-faint"},"kept on flash")]:[t("span",{class:"dl-muted"},o.keep?"Kept after the next update":"Off")])])])}function Js(n,e,r){if(n.notes.has(e))return n.notes.get(e)??null;n.notes.set(e,null);let o=a=>a.replace(/\*\*|`|\[([^\]]+)\]\([^)]*\)/g,(i,s)=>s??"").trim();return(async()=>{let i=((await A.updatesNotes("app",e,"").catch(()=>null))?.body??"").split(` -`).map(l=>/^\s*[-*+]\s+(.*)$/.exec(l)?.[1]).filter(l=>!!l);i.length||(i=(await A.updatesChanges(r,e).catch(()=>null))?.items??[]);let s={items:i.slice(0,3).map(l=>Vs(o(l))),total:i.length};n.notes.set(e,s),s.items.length&&n.root.isConnected&&n.paint()})(),null}function Ys(n){let e=t("div",{class:"dl-params-body"}),r=t("details",{class:"dl-params dl-comp-vers",open:n.versOpen?"open":null},[t("summary",{},[b("chevron"),t("span",{},"Versions"),t("span",{class:"dl-sub"},"install any release")]),e]);return r.addEventListener("toggle",()=>{n.versOpen=r.open,n.versOpen&&zn(n,e)}),n.versOpen&&zn(n,e),r}async function zn(n,e){let r=se("",{placeholder:"Tag, e.g. 0.3.1",class:"cbi-input-text dl-mono","aria-label":"Release tag"}),o=p=>{if(p=p.trim(),!/^v?[0-9][0-9A-Za-z.+~-]{0,40}$/.test(p))return U("Enter a release tag like 0.3.1","warning");_a(n,p)};r.addEventListener("keydown",p=>{p.key==="Enter"&&(p.preventDefault(),o(r.value))});let a=t("div",{class:"dl-comp-tag"},[r,H("Install",()=>o(r.value),"neutral",{disabled:n.busy})]),i=n.versPage,s=p=>{n.versPage=Math.max(1,n.versPage+p),zn(n,e)},l=p=>t("div",{class:"dl-comp-pager"},[t("button",{type:"button",class:"dl-linkbtn",disabled:i<=1?"disabled":null,click:()=>s(-1)},"← Newer"),t("span",{class:"dl-faint"},`Page ${i}`),t("button",{type:"button",class:"dl-linkbtn",disabled:p?null:"disabled",click:()=>s(1)},"Older →")]),d=n.versCache.get(i);if(!d){dom.content(e,[a,t("p",{class:"dl-muted dl-loading"},"Loading versions…")]);try{d=(await A.updatesReleases(i)).releases}catch(p){if(i!==n.versPage||!e.isConnected)return;dom.content(e,[a,t("div",{class:"dl-row-actions"},[t("span",{class:"dl-muted"},`Failed to load versions: ${be(p)}`),H("Try again",()=>zn(n,e))]),l(!1)]);return}if(n.versCache.set(i,d),i!==n.versPage||!e.isConnected)return}if(!d.length)return dom.content(e,[a,t("p",{class:"dl-muted"},i>1?"No more versions.":"No versions found."),l(!1)]);let c=n.st.version;dom.content(e,[a,...d.map(p=>{let u=p.tag.replace(/^v/,"");return t("div",{class:"dl-comp-ver"},[t("span",{class:"dl-mono"},u),t("span",{class:"dl-sub"},Co(p.published)),p.prerelease?Ee("warn","Pre-release"):"",t("span",{class:"dl-comp-ic"},Le("file","What’s new",()=>Qt("app",p.tag,`What’s new in Dawnline ${u}`))),u===c?Ee("ok","Installed"):H("Install",()=>_a(n,p.tag),"neutral",{disabled:n.busy})])}),l(d.length>=5)])}async function _a(n,e){let r=e.replace(/^v/,"");r.localeCompare(n.st.version,void 0,{numeric:!0})<0&&!await le(`Install Dawnline ${r}?`,`It is older than ${n.st.version}. A backup of the settings is made first; restore it from Settings if something looks wrong.`,"Install")||n.op(`app@${e}`,`Installing Dawnline ${r}`,n.st.version)}function Da(n,e){let r=n.st,o=r.kept?.amneziawg,a=e?.sources??{},i=Object.keys(a),s=e?.current??null,l=s?a[s]:void 0,d=!!e?.ru,c=r.needs?.awg??[],p=c.length?null:e?.installed??null,u=[];s&&p&&u.push({label:"Reinstall this build",warn:!0,ic:"reset",run:()=>n.op(`amneziawg:${s}${d?":ru":""}`,"Reinstalling AmneziaWG",p)}),o&&u.push({label:`Roll back to ${o.version}`,ic:"archive",warn:!0,run:async()=>{await le(`Roll back AmneziaWG to ${o.version}?`,"The build kept on the router is installed again. Every AmneziaWG tunnel restarts for a few seconds.","Roll back")&&n.op("amneziawg:rollback","Rolling back AmneziaWG",p??void 0)}});let x=[e?.release?{label:"What’s new",ic:"file",run:()=>Qt("amneziawg",e.release,`What’s new in the ${l?.label??"AmneziaWG"} build`,s??"slava")}:null,{label:"Open on GitHub",ic:"globe",run:()=>window.open(`https://github.com/${l?.repo??"Slava-Shchipunov/awg-openwrt"}`,"_blank","noopener")},...u.length?[null,...u]:[]].filter((f,g,S)=>f!==null||g>0&&S[g-1]!==null),$=r.tunnels??[],h=$.length?`Switching restarts ${$.length===1?"the tunnel":`${$.length} tunnels`} for a few seconds: ${$.join(", ")}. Devices keep their configurations.`:"Switching takes a few seconds. Devices keep their configurations.",m=$.length>1?`${$.slice(0,-1).join(", ")} and ${$[$.length-1]}`:$[0],C=$.length?`Switching restarts ${m} for a few seconds.`:"Switching takes a few seconds.",B=async f=>{let g=a[f];await le(p?`Switch to AmneziaWG ${g.gen}?`:`Install AmneziaWG ${g.gen}?`,`The ${g.label} build, ${g.version}. ${h}${g.gen==="3.1"?" Devices need AmneziaVPN 3.1 or newer.":""}`,p?"Switch":"Install")&&n.op(`amneziawg:${f}${d?":ru":""}`,p?`Switching to AmneziaWG ${g.gen}`:"Installing AmneziaWG",p??void 0)},w=f=>{let g=a[f],S=s===f&&!!p;return t("div",{class:"dl-row"},[t("span",{class:"dl-row-main dl-stack"},[t("b",{},g.gen?`AmneziaWG ${g.gen}`:"AmneziaWG"),t("span",{class:"dl-sub"},`${g.label} · ${g.gen==="3.1"?"AmneziaVPN 3.1+":"every app"}`)]),t("span",{class:"dl-mono dl-faint dl-comp-bver"},g.version??"none yet"),t("span",{class:"dl-comp-bact"},S?Ee("ok","Active"):g.version?H(p?"Switch":"Install",()=>B(f),p?"neutral":"positive",{disabled:n.busy}):Ee("","No build"))])},v=i.map(f=>a[f]?.newer?`${a[f].label} moves to ${a[f].newer.gen} with OpenWrt ${a[f].newer.tag.replace(/^v/,"")}.`:"").filter(Boolean),y=ve(d,"Russian translation",f=>{s&&n.op(`amneziawg:${s}${f?":ru":""}`,f?"Adding the Russian translation":"Removing the Russian translation",p??void 0)});y.disabled=!s||!p||n.busy;let E=n.awgOpen??!p,k=t("details",{class:"dl-params dl-comp-fold",open:E?"open":null},[t("summary",{},[b("chevron"),t("span",{},"Build and translation")]),t("div",{class:"dl-params-body"},[t("div",{class:"dl-list"},[...i.length?i.map(w):[t("div",{class:"dl-row"},t("span",{class:"dl-sub"},"Check for updates to see the builds for this router."))],t("div",{class:"dl-row"},[t("span",{class:"dl-row-main dl-stack"},[t("b",{},"Russian translation"),t("span",{class:"dl-sub"},"LuCI pages for AmneziaWG")]),t("span",{class:"dl-comp-bact"},y)])]),p&&i.length||v.length?t("div",{class:`dl-comp-status ${p&&i.length?"warn":"acc"}`},[b(p&&i.length?"alert":"download"),t("span",{},[p&&i.length?t("b",{},C):"",...v.map(f=>` ${f}`)])]):""])]);k.addEventListener("toggle",()=>n.awgOpen=k.open);let z=[];return e?.update&&p&&s?z.push(H(`Update to ${e.latest}`,()=>n.op(`amneziawg:${s}${d?":ru":""}`,"Updating AmneziaWG",p),"neutral",{disabled:n.busy})):z.push((e||c.length)&&!p?Ee("warn","Not installed"):n.state("amneziawg",e,e?.latest??"")),z.push(n.round(()=>n.op("check:amneziawg","Checking AmneziaWG",p??void 0),x)),[n.row("shield","AmneziaWG",[p?`${p}${e?.release?` · ${e.release} build`:""}`:c.length?`missing ${c.join(", ")}`:e?"not installed":"version not checked"],z),t("div",{class:"dl-comp-foldwrap"},k)]}var Zs=[{title:"Home-like link",sub:"Policy routing and the veth pair",pkgs:["ip-full","kmod-veth"],feature:"home"},{title:"HTTPS for the portal",sub:"OpenSSL for uhttpd",pkgs:["libustream-openssl","openssl-util"],feature:"https"},{title:"Certificates (ACME)",sub:"Let’s Encrypt certificate for the portal",pkgs:["acme","acme-acmesh-dnsapi"],feature:"acme",optional:!0}],Eo={home:"network",https:"lock",acme:"file"};function Aa(n,e){let r=n.st,o=e?.pkgs??{},a=Zs.filter(c=>c.feature==="home"?r.home:r.portal),i=async(c,p,u=c)=>{await le(`Update ${p}?`,`${u.join(", ")} from the OpenWrt feeds. Services that use them restart for a moment.`,"Update")&&n.op(`pkgs:${c.join(",")}`,`Updating ${p}`)},s=[{label:"Check system packages",ic:"refresh",run:()=>n.op("check:packages","Checking system packages")},{label:"Open the OpenWrt package list",ic:"globe",run:()=>window.open("https://openwrt.org/packages/start","_blank","noopener")}],l=0;return{rows:a.map(c=>{let p=c.pkgs.filter(m=>o[m]?.installed),u=[...new Set(p.flatMap(m=>[...o[m]?.latest?[m]:[],...o[m]?.with??[]]))],x=r.needs?.[c.feature]??c.pkgs.filter(m=>!o[m]?.installed),$=p.find(m=>o[m]?.latest),h=p.map(m=>`${m} ${o[m]?.installed??""}`).join(", ");return x.length?n.row(Eo[c.feature],c.title,[`${c.optional?"not installed":`missing ${x.join(", ")}`}`],[H("Install",()=>n.op(`pkgs:${x.join(",")}`,`Installing ${c.title}`),c.optional?"neutral":"positive",{disabled:n.busy}),t("span",{class:"dl-comp-ic"},n.more(s))]):e&&u.length?(l++,n.row(Eo[c.feature],c.title,$?[`${o[$].installed} → ${o[$].latest}`,u.length>1?` · +${u.length-1}`:""]:[u.join(", ")],[H("Update",()=>i(p.filter(m=>o[m]?.latest||o[m]?.with?.length),c.title,u),"neutral",{disabled:n.busy}),t("span",{class:"dl-comp-ic"},n.more(s))])):n.row(Eo[c.feature],c.title,[h||c.sub],[n.state("pkgs",e,""),t("span",{class:"dl-comp-ic"},n.more(s))])}),updates:l,total:a.length}}var Qs={app:"Dawnline",amneziawg:"AmneziaWG",pkgs:"System packages",all:"Components"};function Ha(n){let e=n.st,r=a=>{let i=it(a.component??"app"),s=Qs[i]??"Components",l=a.auto?"automatically":"by you",d="ok",c="check",p;if(a.kind==="found")d="accent",c="download",p=[t("b",{},(a.items??[]).join(", ")),` found by ${a.auto?"the automatic check":"a check"}`];else if(a.state==="failed")d="bad",c="x",p=[t("b",{},s),` ${a.kind==="install"?"update":"check"} failed${a.error?` · ${a.error}`:""}`];else{let u=a.from&&a.to&&a.from!==a.to?` ${a.from} → ${a.to}`:a.to?` ${a.to}`:"";p=[t("b",{},s),`${u} ${u?"":"updated "}${l}${a.took?` · ${xt(a.took)}`:""}`.replace(/\s+/g," ")]}return t("div",{class:"dl-row"},[t("span",{class:`dl-ev-tile ev ${d}`},b(c)),t("span",{class:"dl-row-main"},p),t("span",{class:"dl-faint dl-nowrap",title:new Date(a.ts*1e3).toLocaleString()},re(a.ts,e.now))])},o=e.history??[];return t("section",{class:"dl-panel flush"},[t("div",{class:"dl-panel-head pad"},[t("h3",{},"Activity"),t("span",{class:"dl-spacer"}),t("a",{href:`${L.url("admin/network/dawnline/diagnostics")}?tab=log`},"All in Log →")]),o.length?t("div",{},o.slice(0,8).map(r)):t("p",{class:"dl-sub dl-comp-empty"},"Updates, and checks that found something, show up here.")])}var Nn=class{constructor(){this.root=t("div",{class:"dl-upd"});this.following=null;this.versOpen=!1;this.versPage=1;this.versCache=new Map;this.notes=new Map;this.awgOpen=null}load(){return A.updatesStatus()}render(e){return this.st=e,this.paint(),e.job?.state==="running"&&this.follow(e.job),poll.add(async()=>{if(!this.root.isConnected)return;let r=await A.updatesStatus().catch(()=>null);if(!r)return;let o=this.st;this.st=r,r.job?.state==="running"&&this.following!=="starting"&&r.job.id!==this.following&&this.follow(r.job),(r.job?.id!==o.job?.id||r.job?.state!==o.job?.state||r.job?.phase!==o.job?.phase||r.check?.time!==o.check?.time)&&this.paint()},5),this.root}get busy(){return this.st.job?.state==="running"}async refresh(e){this.st=e??await A.updatesStatus().catch(()=>null)??this.st,this.paint()}async op(e,r,o){if(this.busy||this.following==="starting"){U("Another component action is already running","warning");return}this.following="starting",this.paint();let a=it(e),i=await Jt(e,{title:r,version:o,onJob:s=>this.following=s.id,onDone:s=>this.refresh(s),onUpdate:s=>{let l=s.check?.components??{};a==="amneziawg"&&l.amneziawg?.current?this.op(`amneziawg:${l.amneziawg.current}${l.amneziawg.ru?":ru":""}`,"Updating AmneziaWG",l.amneziawg.installed??void 0):this.op("app","Updating Dawnline",this.st.version)}});this.following==="starting"&&(this.following=i?.id??null),this.refresh()}async follow(e){this.following=e.id;let r=Mn(e),o={app:"Dawnline",amneziawg:"AmneziaWG",pkgs:"system packages",all:"components"}[r]??"components";await Jt(null,{title:`${e.action==="check"?"Checking":e.auto?"Automatic update:":"Updating"} ${o}`,onDone:a=>this.refresh(a)},e)}paint(){let e=this.st,r=e.check?.components??{},o=e.firmware,a=Aa(this,r.packages),i=(e.needs?.awg??[]).length>0,l=(!i&&r.amneziawg?.update&&r.amneziawg.installed?1:0)+a.updates;dom.content(this.root,[t("div",{class:"dl-pagehead"},[t("div",{class:"dl-stack"},[t("h2",{class:"dl-h1"},"Components"),t("span",{class:"dl-faint"},[o?.version?`OpenWrt ${o.version} · ${o.target}`:"",e.check?`checked ${re(e.check.time,e.now)}`:"not checked yet"].filter(Boolean).join(" · "))]),t("div",{class:"dl-row-actions"},[t("a",{class:"cbi-button cbi-button-neutral dl-icon-btn",href:`${L.url("admin/network/dawnline/settings")}?section=updates`},[b("edit")," Settings"]),H([b("refresh")," Check all"],()=>this.op("check","Checking all components"),"neutral",{disabled:this.busy})])]),Pa(this,r.app),t("div",{class:"dl-comp-cols"},[t("section",{class:"dl-panel flush"},[t("div",{class:"dl-panel-head pad"},[t("h3",{},"Components"),t("span",{class:"dl-spacer"}),t("span",{class:"dl-faint dl-comp-count"},i?l?`AmneziaWG not installed · ${l} update${l===1?"":"s"}`:"AmneziaWG not installed":!r.amneziawg&&!r.packages?"":l?`${l} of ${1+a.total} need${l===1?"s":""} an update`:"Everything is up to date")]),t("div",{},[...Da(this,r.amneziawg),...a.rows])]),Ha(this)])])}state(e,r,o){let a=this.st.job;if(a?.state==="running"){let i=l=>l==="packages"?"pkgs":l,s=a.action==="check"?[i(a.component||"all")]:(a.component??"").split(" ").map(l=>i(it(l)));if(s.includes(e)||s.includes("all"))return t("button",{type:"button",class:"dl-pill info dl-comp-run",title:"Show progress",click:()=>this.follow(a)},[a.action==="check"?"Checking":"Updating","…"])}return r?r.error?Ee("warn","Check failed",r.error):r.update?Ee("info","Update available"):r.status==="dev"?Ee("info","Newer than release",`The latest release is ${o}`):Ee("ok","Up to date"):Ee("","Not checked")}more(e){let r=H([b("more")],()=>Ce(r,e.filter((o,a,i)=>o!==null||a>0&&ao?{label:o.label,icon:b(o.ic),warn:o.warn,run:o.run}:null)),"neutral",{title:"More","aria-label":"More"});return r}round(e,r,o=!1){let a=this.busy?" is-busy":"",i;return o?i=H([b("refresh")," Check"],e,"neutral",{class:`cbi-button cbi-button-neutral dl-comp-check${a}`,"aria-label":"Check for updates"}):(i=Le("refresh","Check for updates",e,"neutral",a.trim()),i.removeAttribute("title"),i.setAttribute("aria-label","Check for updates"),me(i,()=>["Check for updates"])),t("span",{class:"dl-comp-ic"},[i,this.more(r)])}row(e,r,o,a){return t("div",{class:"dl-row"},[t("span",{class:"dl-group-ic"},b(e)),t("span",{class:"dl-row-main dl-stack"},[t("b",{},r),t("span",{class:"dl-mono dl-faint dl-comp-sub"},o)]),...a])}};var za=(n,e)=>t("div",{class:"cbi-value"},[t("label",{class:"cbi-value-title"},n),t("div",{class:"cbi-value-field"},e)]);function Na(n){let e=n.st.servers.find(r=>r.id===n.p.server)?.name??"Home";Kt(n.p,e)}async function Ra(n){let e=n.p,r=e.code_set??0,o=e.devices.filter(l=>l.created_by==="portal"&&l.created>=r),a=o.map(l=>t("input",{type:"checkbox",id:`dl-rm-${l.id}`,checked:"checked","data-id":l.id})),i=[t("p",{},"The old link stops working right away.")];o.length&&i.push(t("p",{},"Devices added through the old link keep working until they are removed. Remove them too:"),t("div",{class:"dl-checklist"},o.map((l,d)=>t("label",{for:`dl-rm-${l.id}`},[a[d],` ${l.name}`]))));let s=async()=>{let l=a.filter(c=>c.checked).map(c=>c.dataset.id),d=await G(()=>A.personRegen(e.id,l),l.length?`New link created, ${l.length} device${l.length===1?"":"s"} removed`:"New link created");d&&(ae(),l.length&&await n.refresh(),d.link&&await ue(d.link,"New link copied"))};oe("Create a new link?",i,[ie()," ",H("Create new link",s,"negative")])}function Lo(n){let e=t("textarea",{class:"cbi-input-textarea dl-note-input",rows:3,maxlength:500,placeholder:"Only you see this"},n.p.note??"");oe("Note",[e],[ie()," ",H("Save",async()=>{ae(),await n.patch({note:e.value.trim()},e.value.trim()?"Note saved":"Note removed")},"positive")]),setTimeout(()=>e.focus(),50)}function Ia(n){let e=n.p,r=t("select",{class:"cbi-input-select"},[t("option",{value:"pause",selected:e.expire_action==="pause"?"selected":null},"Pause access"),t("option",{value:"notify",selected:e.expire_action==="notify"?"selected":null},"Keep access"),t("option",{value:"remove",selected:e.expire_action==="remove"?"selected":null},"Remove their devices")]),o=t("select",{class:"cbi-input-select"},[0,1,3,7,14].map(a=>t("option",{value:a,selected:e.expire_warn===a?"selected":null},a?`${a} day${a===1?"":"s"} before`:"Don’t warn")));oe("When access ends",[za("Then",r),t("div",{class:"cbi-value"},[t("label",{class:"cbi-value-title"},"Warn"),t("div",{class:"cbi-value-field"},[o,t("div",{class:"cbi-value-description"},"Shown in their portal and on the Overview.")])])],[ie()," ",H("Save",async()=>{ae(),await n.patch({expire_action:r.value,expire_warn:o.value},"Saved")},"positive")])}function Ba(n){let e=t("input",{type:"text",class:"cbi-input-text",value:n.p.name,maxlength:48}),r=ye("Name",e,()=>_e(e.value,[],"Shown in their portal and apps."));oe("Rename",[r],[ie()," ",H("Save",async()=>{let o=r.help();if(o.bad){U(o.text,"warning");return}await n.patch({name:e.value.trim()},"Renamed")&&ae()},"positive")]),setTimeout(()=>e.select(),50)}function Oa(n){let e=n.p,r=n.st.servers.filter(i=>i.id!==e.server),o=t("select",{class:"cbi-input-select"},r.map(i=>t("option",{value:i.id},`${i.name} · ${i.endpoint||"no address"}:${i.port}`))),a=e.devices.length;oe(`Move ${e.name} to another server`,[za("Server",o),t("p",{class:"dl-muted"},a?`${a} device${a===1?" gets a new address and stops":"s get new addresses and stop"} connecting until ${a===1?"it imports its":"they import their"} configuration again (from the personal link or from you). Circles and home networks of the old server are left behind.`:"They have no devices yet: nothing else changes.")],[ie()," ",H("Move",async()=>{await n.patch({server:o.value},`Moved to ${r.find(i=>i.id===o.value)?.name??"the server"}`)&&(ae(),a&&U("Devices are marked “Update config” until they import again.","info",6e3))},"positive")])}async function ja(n){let e=n.p;await le(`Delete ${e.name}?`,`All ${e.devices.length} devices are disconnected immediately and the personal link stops working.`,"Delete",!0)&&await G(()=>A.personDelete(e.id),"Deleted")&&(location.href=Pt(e.server))}function Ua(n){let e=n.p,r=n.st,o=e.online?"online now":e.last_seen?`last seen ${re(e.last_seen,r.now)}`:"never connected",a=e.created?`Added ${Me(je(new Date(e.created*1e3)))}`:"",i=e.has_link??r.settings.portal_enabled,s=[{label:"Rename",icon:b("edit"),run:()=>Ba(n)},{label:e.note?"Edit note":"Add note",icon:b("file"),run:()=>Lo(n)},...r.servers.length>1?[{label:"Move to server…",icon:b("server"),run:()=>Oa(n)}]:[],...i?[null,{label:"Invite card",icon:b("qr"),run:()=>Na(n)},{label:"New link",icon:b("key"),run:()=>Ra(n)}]:[],null,...e.paused?[]:[{label:"Pause",icon:b("pause"),warn:!0,run:()=>n.patch({paused:!0},"Paused")}],{label:"Delete",icon:b("trash"),danger:!0,run:()=>ja(n)}];return t("div",{class:"dl-person-head"},[t("div",{class:"dl-pagehead"},[t("div",{class:"dl-person-id"},[t("span",{class:`dl-avatar lg${e.online?" online":""}`},He(e.name)),t("div",{class:"dl-stack"},[t("div",{class:"dl-title-row"},[t("h2",{class:"dl-h1"},e.name),Io(e)]),t("span",{class:"dl-faint",title:a},`${e.devices.length} of ${e.device_limit} devices · ${o}`)])]),t("div",{class:"dl-pcard-actions"},[e.paused?H([b("play")," Resume"],()=>n.patch({paused:!1},"Resumed"),"add"):"",i?Le("link","Copy link",()=>$n(e.id),"neutral","dl-icon-only"):"",Le("more","More",l=>Ce(l.currentTarget,s),"neutral","dl-icon-only")])]),e.note?t("button",{type:"button",class:"dl-pnote",title:"Edit note",click:()=>Lo(n)},[b("file"),t("span",{},e.note)]):""])}function Ga(n){let e=n.p,r=n.series[n.series.length-1];return t("div",{class:`dl-person-live${e.online?"":" solo"}`},[e.online?_n(e.rate??[],n.st.now,r?[r.rx,r.tx]:[0,0]):"",Pn(n.series,`${ee(e.month[0]+e.month[1])} this month`)])}async function Xs(n,e){let r=await G(()=>A.deviceConfig(e.id));r&&oe(`Set up ${e.name}`,[await n.core.connectBlock(r,"qr")],[ie("Close")])}async function el(n,e){let r=await G(()=>A.deviceConfig(e.id));if(!r)return;if(!r.has_private_key){U("This device made its own keys in the browser; its configuration only exists there.","warning");return}let o=n.core.file.make(r);Te(o.name,o.text,"application/octet-stream")}function Wa(n){let e=n.p,r=n.st.now,o=d=>Ge(e,d,n.deviceOpts()),a=d=>c=>{c.target.closest("button:not(.dl-dcard-title), a")||o(d)},i=d=>H([b("more")],c=>Wr(c.currentTarget,e,d,n.deviceOpts()),"neutral",{title:"QR, file, key, rename, new keys, remove",class:"cbi-button cbi-button-neutral dl-icon-only"}),s=nn(e.devices).map(d=>{let c=t("div",{class:"dl-dcard-head"},[t("span",{class:"dl-dcard-ic"},b(d.kind)),t("button",{type:"button",class:"dl-dcard-title",click:()=>o(d)},[t("b",{},d.name),on(d,r,void 0,e),d.config_stale?t("span",{class:"dl-pill warn dl-stale"},"Update config"):""]),i(d)]),p=t("div",{class:"dl-dcard-trend"},[t("div",{class:"dl-stack"},[t("b",{},ee(d.month[0]+d.month[1])),t("span",{class:"dl-sub"},"this month")]),ua(n.devSeries[d.id]??[])]);return t("article",{class:`dl-dcard clickable${d.online?" online":""}${d.disabled?" off":""}`,click:a(d)},[c,d.handshake?p:d.disabled?t("div",{class:"dl-sub"},`${Qe[d.kind]} · created ${re(d.created,r)} ${d.created_by==="portal"?"in the portal":"by you"}.`):t("div",{class:"dl-chips-row"},[t("button",{type:"button",class:"dl-chipbtn",click:()=>Xs(n,d)},[b("qr"),"Show QR"]),t("button",{type:"button",class:"dl-chipbtn",click:()=>el(n,d)},[b("download"),"Config"])])])}),l=e.devices.length>=e.device_limit;return s.push(t("button",{type:"button",class:"dl-dslot add",click:()=>ot(e,n.deviceOpts())},[t("span",{class:"dl-dslot-ic"},b("plus")),t("span",{class:"dl-stack"},[t("b",{},"Add device"),t("span",{class:"dl-sub"},l?`Over the limit · ${e.devices.length} of ${e.device_limit}`:`${e.devices.length} of ${e.device_limit}`)])])),t("section",{class:"dl-devsec"},[t("div",{class:"dl-panel-head"},[t("h3",{},"Devices"),t("span",{class:"dl-sub"},`${e.online} online`)]),t("div",{class:"dl-dgrid"},s)])}function Fa(n){let e=n.p,r=we([["device","Device’s own DNS"],["home","Home names"]],e.dns_mode,{label:"DNS",cls:"sm",optimistic:!1,onChange:a=>n.patch({dns_mode:a},a==="home"?"Home names on — devices need their configuration again":"Device DNS — devices need their configuration again")}),o=n.st.settings.home_dns_fallback;return t("div",{class:"dl-stack gap4 dl-dnspick"},[t("div",{class:"dl-row-actions"},[t("span",{class:"dl-sub"},"DNS"),r]),t("span",{class:"dl-sub"},e.dns_mode==="home"?["Names like ",t("span",{class:"dl-mono"},`nas.${n.st.settings.domain}`)," work. Internet names are resolved at home, so they depend on the tunnel",o?[" (",t("span",{class:"dl-mono"},o)," takes over when it is down)."]:" — with no fallback set, they stop when it is down."]:"Internet keeps working exactly as without the VPN. Reach home devices by IP address.")])}function qa(n){let e=n.p,o=n.st.servers.find(i=>i.id===e.server)?.home??[];if(o.length<2)return"";let a=new Set(e.home_nets?.length?e.home_nets:o.map(i=>i.dev));return t("div",{class:"dl-stack gap4"},[t("div",{class:"dl-chips-row"},o.map(i=>qe(i.dev,a.has(i.dev),()=>{let s=new Set(a);if(s.delete(i.dev)||s.add(i.dev),!s.size)return U("Keep at least one network, or choose Internet only.","warning",5e3);let l=s.size===o.length?[]:[...s];n.patch({home_nets:l},l.length?`${e.name} reaches ${l.join(", ")}`:`${e.name} reaches every home network`)},{title:i.nets.join(", ")}))),t("span",{class:"dl-sub"},e.home_nets?.length?`Home networks ${e.name} reaches. Networks added to the server later stay out.`:`Home networks ${e.name} reaches: all of them. Untick one to keep ${e.name} out of it.`)])}function Ka(n){let e=new Set(n.p.services??[]);return t("div",{class:"dl-stack gap4"},[t("div",{class:"dl-chips-row"},n.st.services.map(r=>qe(r.name,e.has(r.id),()=>{let o=new Set(e);o.delete(r.id)||o.add(r.id),n.patch({services:[...o]},o.size?"Home services updated":"Whole home network")},{title:`${r.address}${r.ports.length?` · ${r.ports.join(", ")}`:""}`}))),t("span",{class:"dl-sub"},e.size?"Only the selected services at home.":"Whole home network. Pick services to narrow it down.")])}function Va(n){let e=n.p,r=n.st;if(r.servers.find(c=>c.id===e.server)?.mesh!=="circles"||!at(e))return"";let a=r.circles.filter(c=>c.server===e.server),i=a.find(c=>c.id===e.circle),s=i?r.people.filter(c=>c.id!==e.id&&c.circle===i.id&&at(c)).map(c=>c.name):[],l=t("button",{type:"button",class:"dl-chipbtn",click:()=>Ce(l,[...a.map(c=>({label:c.name,icon:bo(c),run:()=>c.id!==e.circle&&n.patch({circle:c.id},`${e.name} is in ${c.name}`)})),e.circle?{label:"No circle",icon:b("x"),run:()=>n.patch({circle:""},`${e.name} is in no circle`)}:null,{label:"New circle",icon:b("plus"),run:()=>En(r,e.server,null,()=>n.refresh())}])},"Change"),d=i?r.people.filter(c=>c.circle===i.id&&at(c)):[e];return t("div",{class:"dl-tile2"},[t("div",{class:"dl-tile2-label"},[t("span",{},"Devices see each other"),l]),t("div",{class:"dl-tile2-row"},[t("span",{class:"dl-tile2-value"},i?i.name:"No circle"),t("span",{class:"dl-avstack",title:d.map(c=>c.name).join(", ")},d.slice(0,5).map(c=>t("span",{class:"dl-avatar sm"},He(c.name))))]),t("span",{class:"dl-sub"},i?s.length?[e.name,...s].join(", "):`Nobody else in ${i.name} yet`:`Only ${e.name}'s own devices`)])}function Ja(n){let e=n.p,r=n.st.now,o=t("div",{class:"dl-slots"});for(let s=0;s=e.device_limit,c=t("i",{class:d?"over":l?"used":""});me(c,()=>[t("div",{class:"dl-tip-title"},l?`${l.name}${d?" · over the limit":""}`:"Free slot"),t("div",{class:"dl-muted"},l?l.online?"Connected":l.handshake?`Last seen ${re(l.handshake,r)}`:"Not set up yet":"They can add a device here")]),o.appendChild(c)}let a=Math.max(1,e.devices.length),i=t("button",{type:"button","aria-label":"Allow fewer devices",disabled:e.device_limit<=a?"disabled":null,click:()=>n.patch({device_limit:String(e.device_limit-1)})},"−");return e.device_limit<=a&&e.devices.length>1&&me(i,()=>[t("div",{class:"dl-tip-title"},`${e.devices.length} devices in use`),t("div",{class:"dl-muted"},"Remove a device first to lower the limit")]),t("div",{class:"dl-tile2"},[t("div",{class:"dl-tile2-label"},"Devices"),t("div",{class:"dl-tile2-row"},[t("span",{class:"dl-tile2-value"},[String(e.devices.length),t("span",{class:"dl-faint"},` / ${e.device_limit}`)]),t("div",{class:"dl-stepper"},[i,t("button",{type:"button","aria-label":"Allow more devices",disabled:e.device_limit>=32?"disabled":null,click:()=>n.patch({device_limit:String(e.device_limit+1)})},"+")])]),o])}var tl={internet:"Browse the internet through your router. No access to devices at home, and home cannot reach theirs.",lan:"Reach devices at home, and home reaches theirs. Internet stays on their own connection.",both:"Home devices and the internet, all through your router. Home reaches their devices too."},Ya=/^([01]\d|2[0-3]):[0-5]\d$/;function nl(n){let e=n.p,r=n.today,o=Ye(e.expires,r),a=t("input",{type:"date",class:"dl-date-hidden",value:e.expires,tabindex:"-1","aria-hidden":"true"});a.addEventListener("change",()=>a.value&&n.patch({expires:a.value},`Access until ${Me(a.value)}`));let i=(c,p)=>{let u=zo(e.expires&&(o??-1)>=0?e.expires:"",c,p,r);n.patch({expires:u},`Access until ${Me(u)}`)},s=[["week",1,"+1 week"],["month",1,"+1 month"],["month",3,"+3 months"],["year",1,"+1 year"]].map(([c,p,u])=>t("button",{type:"button",class:"dl-chipbtn",click:()=>i(c,p)},u)),l=t("span",{class:"dl-datechip"},[t("button",{type:"button",class:"dl-chipbtn",click:()=>{a.focus({preventScroll:!0});try{a.showPicker()}catch{}}},[b("calendar"),e.expires?Me(e.expires):"Date"]),a]),d={pause:"pause access",notify:"keep access",remove:"remove their devices"}[e.expire_action];return t("div",{class:"dl-tile2"},[t("div",{class:"dl-tile2-label"},[t("span",{},"Access ends"),e.expires?t("span",{class:o!=null&&o<0?"dl-bad":Ze(e,o)?"dl-warn":"dl-ok"},o!=null&&o<0?"ended":`${o} day${o===1?"":"s"} left`):t("span",{class:"dl-faint"},"no end date")]),t("div",{class:"dl-chips-row"},[...s,l,e.expires?t("button",{type:"button",class:"dl-chipbtn",click:()=>n.patch({expires:""},"No end date")},"No end"):""]),t("div",{class:"dl-tile2-foot"},[t("span",{class:"dl-muted"},`When it ends: ${d}${e.expire_warn?`, warn ${e.expire_warn} day${e.expire_warn===1?"":"s"} before`:""}`),t("a",{href:"#",click:c=>{c.preventDefault(),Ia(n)}},"Change")])])}function ol(n){let e=n.p,r=e.quota_used||e.month[0]+e.month[1],o=e.quota_limit?Math.min(100,e.quota_used/e.quota_limit*100):0,a=t("div",{class:`dl-meter${o>=100?" bad":o>=90?" warn":""}`},[t("i"),e.quota_limit?t("span",{class:"mark",title:"Alert at 90%"}):""]);a.firstChild.style.width=`${o}%`,e.quota_limit&&me(a,()=>[t("div",{class:"dl-tip-title"},`${o.toFixed(1)}% used`),t("div",{class:"dl-muted"},`${ee(e.quota_used)} of ${ee(e.quota_limit)} · ${ee(Math.max(0,e.quota_limit-e.quota_used))} left`),t("div",{class:"dl-faint"},"Alert at 90%")]);let i=we([["month","Monthly"],["total","Total"]],e.quota_period,{label:"Data limit period",cls:"sm",optimistic:!1,onChange:l=>n.patch({quota_period:l})}),s=[10,50,100].map(l=>t("button",{type:"button",class:`dl-chipbtn${e.quota_gb===l?" on":""}`,click:()=>n.patch({quota_gb:String(l)},`Data limit ${l} GB`)},`${l} GB`));return s.push(t("button",{type:"button",class:`dl-chipbtn${e.quota_gb?"":" on"}`,click:()=>n.patch({quota_gb:""},"No data limit")},"Unlimited")),s.push(t("button",{type:"button",class:"dl-chipbtn",click:()=>{let l=t("input",{type:"number",class:"cbi-input-text dl-w-port",min:0,step:"any",value:e.quota_gb?String(e.quota_gb):""}),d=ye("Data limit (GB)",l,()=>dn(l.value,e.quota_period==="month"));oe("Data limit",[d],[ie()," ",H("Save",async()=>{let c=d.help();if(c.bad){U(c.text,"warning");return}let p=l.value.trim();await n.patch({quota_gb:p},p&&Number(p)>0?`Data limit ${p} GB`:"No data limit")&&ae()},"positive")]),setTimeout(()=>l.select(),50)}},"Custom")),t("div",{class:"dl-tile2"},[t("div",{class:"dl-tile2-label"},[t("span",{},"Data"),i]),t("div",{class:"dl-tile2-row"},[t("span",{class:"dl-tile2-value"},[ee(r),e.quota_limit?t("span",{class:"dl-faint"},` of ${ee(e.quota_limit)}`):t("span",{class:"dl-faint"}," · no limit")]),e.quota_period==="month"?t("span",{class:"dl-sub"},"resets on the 1st"):""]),e.quota_limit?a:"",t("div",{class:"dl-chips-row"},s),e.quota_gb&&e.quota_period==="month"?t("div",{class:"dl-tile2-foot"},[t("span",{class:"dl-muted"},e.bonus_gb?`Includes +${e.bonus_gb} GB extra this month`:"Need a little more this month?"),t("a",{href:"#",click:l=>{l.preventDefault(),n.patch({bonus_gb:String((e.bonus_gb||0)+10)},"+10 GB this month")}},"+10 GB this month")]):"",t("div",{class:"dl-tile2-foot"},[t("span",{class:"dl-muted"},`${ee(e.total[0]+e.total[1])} in total`),t("button",{type:"button",class:"dl-linkbtn danger",click:()=>St("person",e.id,e.name,()=>setTimeout(()=>n.refresh(),300))},"Reset usage")])])}function rl(n){let e=n.p,r=!!e.hours,[o,a]=(e.hours||"07:00-23:00").split("-"),i=t("input",{type:"time",class:"cbi-input-text",value:o,"aria-label":"From"}),s=t("input",{type:"time",class:"cbi-input-text",value:a,"aria-label":"To"}),l=t("div",{class:"dl-tile2-row"},[i,t("span",{class:"dl-faint"},"to"),s]),d=()=>{let x=`${i.value}-${s.value}`;if(x!==e.hours){if(!Ya.test(i.value)||!Ya.test(s.value))return U("Enter both times, like 07:00 and 23:00.","warning");if(i.value===s.value)return U("The start and the end must differ.","warning");n.patch({hours:x},`Allowed ${i.value}–${s.value}`)}};l.addEventListener("focusout",x=>{l.contains(x.relatedTarget)||d()});for(let x of[i,s])x.addEventListener("keydown",$=>{$.key==="Enter"&&($.preventDefault(),d())});let c=t("button",{type:"button",role:"switch","aria-checked":r?"true":"false",class:`dl-switch${r?" on":""}`,"aria-label":"Limit hours",click:()=>{if(r)return n.patch({hours:""},"Any time");c.classList.add("on"),c.setAttribute("aria-checked","true"),p.textContent="Set the hours, then press Enter",u.appendChild(l),i.focus()}},t("i")),p=t("span",{},r?`${o} – ${a} (router time)`:"Any time"),u=t("div",{class:"dl-tile2"},[t("div",{class:"dl-tile2-row"},[t("div",{class:"dl-stack"},[t("span",{class:"dl-tile2-label"},"Allowed hours"),p]),c]),r?l:""]);return u}function Za(n){let e=n.p,r=we(["internet","lan","both"].map(o=>[o,[b(o==="internet"?"globe":o==="lan"?"home":"shield"),o==="internet"?"Internet":o==="lan"?"Home":"Both"]]),e.access,{label:"Access",cls:"wide",optimistic:!1,onChange:o=>n.patch({access:o},`Access: ${ct[o]}`)});return t("section",{class:"dl-devsec","aria-label":"Access and limits"},[t("div",{class:"dl-panel-head"},[t("h3",{},"Access & limits")]),t("div",{class:"dl-panel"},[t("div",{class:"dl-stack gap8"},[t("span",{class:"dl-tile2-label"},"Can reach"),r,t("span",{class:"dl-sub"},tl[e.access]),e.access==="lan"&&n.st.services.length?Ka(n):"",at(e)?qa(n):"",e.access==="lan"?Fa(n):""]),t("div",{class:"dl-tiles2"},[Ja(n),Va(n),nl(n),ol(n),rl(n)])])])}function al(n){let e=n.st,r=t("div",{class:"dl-panel-head pad"},[t("h3",{},"Locations"),t("span",{class:"dl-spacer"}),e.geo.enabled?_t("30d",a=>n.map?.setRange(a),!1):"",H("Hide",()=>{n.mapOpen=!1,n.map?.destroy(),n.map=null,n.paintPlaces()},"neutral")]);if(!e.geo.enabled)return t("div",{class:"dl-panel flush"},[r,t("div",{class:"dl-map-off"},["Locations are off. ",t("a",{href:L.url("admin/network/dawnline/settings")},"Turn them on in Settings"),"."])]);let o=new nt({openPerson:()=>{},openDevice:(a,i)=>{let s=n.p.devices.find(l=>l.id===i);s&&Ge(n.p,s,n.deviceOpts())}},"30d",280);return n.map=o,requestAnimationFrame(()=>o.mount(n.mapData())),t("div",{class:"dl-panel flush"},[r,o.el])}function Qa(n){let e=n.st;if(!e.geo.enabled)return t("div",{class:"dl-places"},[b("pin"),t("div",{class:"dl-stack"},[t("span",{},"Locations are off"),t("span",{class:"dl-sub"},"City-level, from the client IP")]),t("span",{class:"dl-spacer"}),t("a",{class:"cbi-button cbi-button-neutral",href:L.url("admin/network/dawnline/settings")},"Turn on")]);if(n.mapOpen)return n.map&&n.parts.places.contains(n.map.el)?null:al(n);let r=e.now-30*86400,o=e.geo.points.filter(s=>s.person===n.p.id&&s.ts>=r).sort((s,l)=>l.ts-s.ts),a=[...new Set(o.map(s=>s.city||s.country).filter(Boolean))],i=o[0];return t("div",{class:"dl-places"},[b("pin"),t("div",{class:"dl-stack"},[t("span",{},i?i.city||i.country:"No locations yet"),t("span",{class:"dl-sub"},i?`${a.length} place${a.length===1?"":"s"} in 30 days${i.org?` · ${i.org}`:""}`:"Shown after a device connects")]),t("span",{class:"dl-spacer"}),o.length?H("Show map",()=>{n.mapOpen=!0,n.paintPlaces()},"neutral"):""])}function Xa(n){let e=n.p,r=n.st,o=n.events.filter(l=>l.person===e.id),a=[],i=[...o].reverse();for(let l=0;l1){let u=p.querySelector(".dl-row-main");dom.content(u,[...wo(r,d).slice(0,3),t("span",{class:"dl-muted"},`${c} times`)]),u.title=i.slice(l,l+c).map(x=>x.detail??"").join(` -`)}a.push(p),l+=c-1}let s=H([b("more")],()=>Ce(s,[{label:"Export CSV",icon:b("download"),run:()=>Fe(r,o,"csv",e.id)},{label:"Export JSON",icon:b("download"),run:()=>Fe(r,o,"json",e.id)},null,{label:`Clear ${e.name}'s activity`,icon:b("trash"),danger:!0,run:()=>tt(`Clear ${e.name}'s activity`,`Removes events about ${e.name} and their devices.`,{person:e.id},()=>n.refresh())}]),"neutral",{title:"Export or clear",class:"cbi-button cbi-button-neutral dl-icon-only"});return t("div",{class:"dl-panel flush"},[t("div",{class:"dl-panel-head pad"},[t("h3",{},"Activity"),t("span",{class:"dl-sub"},o.length>10?`latest 10 of ${o.length}`:""),t("span",{class:"dl-spacer"}),s]),a.length?a:t("div",{class:"dl-row dl-muted"},"Nothing yet.")])}var Rn=class{constructor(){this.id="";this.events=[];this.mapOpen=!1;this.map=null;this.parts={};this.series=[];this.devSeries={};this.ticks=0;this.fullNext=!1}async fetch(e){let[r,o,a]=await Promise.all([A.status(30),e?A.events(2e3,this.id).catch(()=>null):Promise.resolve(null),e?A.personUsage(this.id,30).catch(()=>null):Promise.resolve(null)]);return{st:r,ev:o?.events??null,use:a}}async load(){return this.id=new URLSearchParams(location.search).get("id")??"",this.fetch(!0)}render(e){this.take(e);let r=this.st.people.find(s=>s.id===this.id);if(!r)return t("div",{class:"dl-empty"},[t("h3",{},"Person not found"),t("p",{},"They may have been removed."),t("a",{class:"cbi-button",href:L.url("admin/network/dawnline/server")},"Back to Servers")]);this.p=r;for(let s of["crumbs","head","devices","traffic","places","activity","limits"])this.parts[s]=t("div",{});this.parts.devices.className="dl-person-devices";let o=t("div",{},[this.parts.crumbs,this.parts.head,t("div",{class:"dl-grid-person"},[t("div",{class:"dl-col"},[this.parts.devices,this.parts.traffic,this.parts.places,this.parts.activity]),t("div",{class:"dl-col"},[this.parts.limits])])]);this.paint();let a=new URLSearchParams(location.search),i=a.get("device")&&r.devices.find(s=>s.id===a.get("device"));return i?setTimeout(()=>Ge(this.p,i,this.deviceOpts()),50):a.get("add")&&setTimeout(()=>ot(this.p,this.deviceOpts()),50),this.poller=rt({fetch:s=>{let l=s||this.fullNext||++this.ticks%4===0;return this.fullNext=!1,this.fetch(l)},every:15,live:!0,active:()=>o.isConnected,apply:(s,l)=>this.apply(s,l)}),o}take(e){this.st=e.st,e.ev&&(this.events=e.ev),e.use&&(this.series=e.use.person,this.devSeries=e.use.devices)}apply(e,r){this.take(e);let o=this.st.people.find(a=>a.id===this.id);if(!o){r||(location.href=Pt(this.p?.server));return}this.p=o,this.paint(r),this.map?.update(this.mapData())}async refresh(){this.fullNext=!0,await this.poller?.refresh()}async patch(e,r){var i;this.poller?.claim();let o=await G(()=>A.personUpdate(this.p.id,e),r);if(!o)return!1;this.poller?.claim();let a=this.st.people.findIndex(s=>s.id===this.p.id);return(i=o.person).rate??(i.rate=this.p.rate),a>=0&&(this.st.people[a]=o.person),this.p=o.person,this.paint(),!0}get today(){return Ie(this.series.length?this.series:this.st.series)}get core(){return Tt(this.st.servers,this.p.server)}deviceOpts(){return{refresh:()=>this.refresh(),geo:this.st.geo,now:this.st.now,today:this.today,core:this.core,events:()=>this.events}}mapData(){return{geo:this.st.geo,people:this.st.people,now:this.st.now,person:this.p.id}}crumbs(){let e=this.p;return t("nav",{class:"dl-crumbs","aria-label":"Breadcrumb"},[t("a",{href:Pt(e.server)},this.st.servers.find(r=>r.id===e.server)?.name??"Servers"),t("span",{},"/"),t("a",{href:Pt(e.server)},"People"),t("span",{},"/"),t("span",{},e.name)])}paint(e=!1){Se(this.parts.crumbs,this.crumbs(),e),Se(this.parts.head,Ua(this),e),Se(this.parts.traffic,Ga(this),e),Se(this.parts.devices,Wa(this),e),Se(this.parts.limits,Za(this),e),this.paintPlaces(e),Se(this.parts.activity,Xa(this),e)}paintPlaces(e=!1){let r=Qa(this);r&&Se(this.parts.places,r,e&&!this.mapOpen)}};var il={ok:"check",warn:"alert",error:"x",skip:"pause"},In=class{constructor(e,r,o,a){this.el=t("div",{});this.wdEl=t("div",{});this.checksEl=t("div",{class:"dl-panel"});this.recentEl=t("div",{class:"dl-panel flush dl-recent"});this.checks=null;this.summary=t("div",{});this.open=new Set;this.st=e,this.sl=r,this.events=o,this.toLog=a,dom.content(this.el,[this.summary,this.wdEl,t("div",{class:"dl-health-cols"},[this.checksEl,this.recentEl])]),this.paintChecks(),this.paintLive(r,o)}async run(e){let r=e?await Dn(e):await A.health().catch(()=>null);r&&(this.take(r),e==="netrestart"&&setTimeout(()=>this.el.isConnected&&void this.run(),5e3))}take(e){this.checks=e.checks,this.paintChecks(),this.paintLive(e,this.events)}paintChecks(){let e=this.checks;if(!e){dom.content(this.summary,""),dom.content(this.checksEl,[t("div",{class:"dl-panel-head"},[t("h3",{},"Checks")]),t("p",{class:"dl-muted dl-loading"},"Running checks…")]);return}let r=e.filter(s=>s.status==="error").length,o=e.filter(s=>s.status==="warn").length;dom.content(this.summary,r?pt("error",`${r} problem${r>1?"s":""} need attention.`):o?pt("warn",`${o} warning${o>1?"s":""}.`):pt("ok","All checks passed."));let a=new Map;for(let s of this.sl.watchdog.repairs)a.set(s.id,Math.max(a.get(s.id)??0,s.ts));let i=()=>this.run();dom.content(this.checksEl,[t("div",{class:"dl-panel-head"},[t("h3",{},"Checks"),t("span",{class:"dl-spacer"}),H("Run again",i)]),t("ul",{class:"dl-checks"},e.map(s=>t("li",{},[t("span",{class:`dl-check-icon ${s.status}`},b(il[s.status])),t("div",{class:"dl-check-body"},[t("div",{class:"dl-check-title"},s.title),t("div",{class:"dl-check-detail"},s.detail),a.has(s.id)?t("div",{class:"dl-check-repaired"},`Repaired by the watchdog at ${zt(a.get(s.id))}`):""]),yo(s,l=>void this.run(l),i)])))])}paintLive(e,r){this.sl=e,this.events=r;let o=e.watchdog,a=o.beat!=null&&o.now-o.beat>180,i=o.repairs.filter(d=>o.now-d.ts<86400),s=i[i.length-1],l=ve(o.enabled,"Watchdog repairs",async d=>{await G(()=>A.settingsUpdate({watchdog:d?"1":"0"}),d?"Watchdog on":"Watchdog off")||eo(l,!d);let p=await A.serviceLog().catch(()=>null);p&&this.paintLive(p,this.events)});dom.content(this.wdEl,t("div",{class:"dl-panel dl-wd"},[t("div",{class:"dl-wd-head"},[t("span",{class:`dl-wd-tile${o.enabled?"":" off"}`},b("shield")),t("div",{class:"dl-stack"},[t("span",{class:"dl-wd-title"},"Watchdog"),t("span",{class:"dl-sub"},o.enabled?"Every minute it checks the tunnels and services and repairs what it can on its own.":"Off: problems are only written to the log. Nothing is repaired on its own.")]),t("span",{class:"dl-spacer"}),l]),t("div",{class:"dl-wd-foot"},[t("div",{class:"dl-wd-chips"},o.targets.map(d=>t("span",{class:`dl-check-chip${d.ok?"":" error"}`,title:d.ok?"OK":`Not working${d.tries?` · ${d.tries} repair${d.tries>1?"s":""}`:""}`},[b(d.ok?"check":"x"),d.name]))),t("span",{class:`dl-sub${a?" dl-warn-text":""}`},a?`The agent has not checked in for ${Math.round((o.now-o.beat)/60)} min; cron restarts it after 5.`:[o.last?`Looked ${re(o.last,o.now)}`:"Starts within a minute"," · ",i.length?`${i.length} repair${i.length>1?"s":""} today, last ${s.name} at ${zt(s.ts)}`:"no repairs today"])])])),this.paintRecent()}paintRecent(){let e=(this.sl.watchdog.now||Date.now()/1e3)-604800,r=[...this.events.map(a=>({ts:a.ts,ev:a})),...this.sl.log.map(a=>({ts:a.ts,sys:a}))].filter(a=>a.ts>=e&&cn(a)).sort((a,i)=>i.ts-a.ts),o=t("div",{class:"dl-panel-head pad"},[t("h3",{},"Recent problems"),t("span",{class:"dl-spacer"}),r.length?t("a",{href:"#",click:a=>(a.preventDefault(),this.toLog())},"All in Log →"):""]);if(!r.length){dom.content(this.recentEl,[o,t("div",{class:"dl-recent-empty"},[t("span",{class:"dl-check-icon ok"},b("check")),"No problems in the last 7 days."])]);return}dom.content(this.recentEl,[o,...r.slice(0,8).map(a=>{if(a.sys){let i=a.sys,s=`${i.ts}|${i.msg}`;return Tn(i,this.open.has(s),()=>{this.open.delete(s)||this.open.add(s),this.paintRecent()},zt(i.ts))}return st(this.st,a.ev,{time:zt(a.ts)})})])}};var Bn=300,sl=["all","connections","people","system","problems"],On=class{constructor(e,r,o){this.events=[];this.system=[];this.kind="all";this.shown=Bn;this.open=new Set;this.list=t("div",{});this.sub="";this.tabs=t("div",{class:"dl-seg",role:"tablist"});this.st=e,this.take(r),this.system=o,this.el=t("div",{},[t("div",{class:"dl-toolbar"},[this.tabs]),this.list]),this.paint()}actions(){let e=()=>this.kind==="all"?"":this.kind,r=i=>()=>{let s=this.filtered().reverse();Fe(this.st,s.filter(l=>l.ev).map(l=>l.ev),i,e(),s.filter(l=>l.sys).map(l=>l.sys))},o=H([b("download")," Export"],()=>Ce(o,[{label:"CSV (spreadsheet)",icon:b("download"),run:r("csv")},{label:"JSON",icon:b("download"),run:r("json")}])),a=H([b("trash")," Clear"],()=>tt("Clear the log","Removes events from the log on the router.",{},()=>this.reload(),this.kind==="all"?void 0:this.kind,!0));return[o,a]}take(e){this.events=e.events,this.policy=e.policy;let r=Mt.filter(o=>!e.policy.categories.includes(o));this.sub=`${pn(e.policy)}${r.length?` Not recorded: ${r.map(o=>ut[o].toLowerCase()).join(", ")}.`:""}`}async reload(){let[e,r]=await Promise.all([A.events(2e4).catch(()=>null),A.serviceLog().catch(()=>null)]);e&&this.take(e),r&&(this.system=r.log),this.paint()}items(){return[...this.events.map(e=>({ts:e.ts,ev:e})),...this.system.map(e=>({ts:e.ts,sys:e}))].sort((e,r)=>r.ts-e.ts)}matches(e,r){return r==="all"?!0:r==="problems"?cn(e):r==="system"?!!e.sys:!!e.ev&&Bt(e.ev.type)===r}filtered(){return this.items().filter(e=>this.matches(e,this.kind))}paintTabs(e){dom.content(this.tabs,sl.map(r=>t("button",{type:"button",role:"tab",class:r===this.kind?"on":"","aria-selected":r===this.kind?"true":"false",click:()=>this.show(r)},[r==="all"?"All":r==="system"?"System":ut[r],t("b",{},String(e.filter(o=>this.matches(o,r)).length))])))}show(e){this.kind=e,this.shown=Bn,this.paint()}paint(){this.paintTabs(this.items());let e=this.filtered();if(!e.length){dom.content(this.list,t("div",{class:"dl-empty"},[t("p",{},this.events.length||this.system.length?"No events match.":"The log is empty.")]));return}let r=[],o="",a=null;for(let i of e.slice(0,this.shown)){let s=pa(i.ts);s!==o&&(o=s,a=t("div",{class:"dl-panel flush"},t("div",{class:"dl-panel-head pad"},t("h3",{},s))),r.push(a));let l=new Date(i.ts*1e3).toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit"});if(i.sys){let d=`${i.sys.ts}|${i.sys.msg}`;a.appendChild(Tn(i.sys,this.open.has(d),()=>{this.open.delete(d)||this.open.add(d),this.paint()},l))}else a.appendChild(st(this.st,i.ev,{time:l}))}e.length>this.shown&&r.push(t("div",{class:"dl-more-row"},H(`Show ${Math.min(Bn,e.length-this.shown)} more of ${e.length-this.shown}`,()=>{this.shown+=Bn,this.paint()}))),dom.content(this.list,r)}};var ll=[["health","Health"],["log","Log"]],Mo=2e4,jn=class{constructor(){this.tab=new URLSearchParams(location.search).get("tab")==="log"?"log":"health";this.segEl=t("div",{class:"dl-seg dl-srvsections dl-diag-tabs",role:"tablist","aria-label":"Diagnostics"});this.subEl=t("span",{class:"dl-muted"});this.actionsEl=t("div",{class:"dl-row-actions"});this.bodyEl=t("div",{});this.eventsAt=0}load(){return this.eventsAt=Date.now(),Promise.all([A.status(1),A.events(Mo),A.serviceLog()])}render([e,r,o]){return this.log=new On(e,r,o.log),this.health=new In(e,o,r.events,()=>{this.show("log"),this.log.show("problems")}),this.show(this.tab),rt({fetch:async()=>{let a=this.tab==="log",[i,s]=await Promise.all([A.serviceLog().catch(()=>null),a?A.events(Mo).catch(()=>null):Promise.resolve(null)]);return i||s?{n:i,e:s}:null},every:10,active:()=>this.bodyEl.isConnected,apply:({n:a,e:i})=>this.take(a,i)}),t("div",{},[t("div",{class:"dl-pagehead"},[t("div",{class:"dl-stack"},[t("h2",{class:"dl-h1"},"Diagnostics"),this.subEl]),this.actionsEl]),this.segEl,this.bodyEl])}take(e,r){r&&(this.log.take(r),this.eventsAt=Date.now()),e&&(this.log.system=e.log),e&&this.health.paintLive(e,r?.events??this.health.events),this.tab==="log"&&this.log.paint()}show(e){this.tab=e,dom.content(this.segEl,ll.map(([r,o])=>t("button",{type:"button",role:"tab",class:r===e?"on":"","aria-selected":r===e?"true":"false",click:()=>r!==this.tab&&this.show(r)},o))),this.bodyEl.replaceChildren(e==="log"?this.log.el:this.health.el),this.subEl.textContent=e==="log"?this.log.sub:"Everything Dawnline depends on, checked live. The watchdog repairs what it can on its own.",dom.content(this.actionsEl,e==="log"?this.log.actions():""),e==="log"?(this.log.paint(),Date.now()-this.eventsAt>1e4&&A.events(Mo).then(r=>this.take(null,r)).catch(()=>null)):this.health.checks||this.health.run()}};var ei=":root{--dl-card: var(--panel-bg, var(--background-color-high, transparent));--dl-elevated: var(--elevated, var(--background-color-high, Canvas));--dl-line: var(--border, var(--border-color-medium, color-mix(in srgb, currentColor 14%, transparent)));--dl-soft: var(--muted, color-mix(in srgb, currentColor 5%, transparent));--dl-soft-hover: var(--soft-hover, color-mix(in srgb, currentColor 10%, transparent));--dl-fg: var(--foreground, var(--text-color-highest, inherit));--dl-fg-muted: var(--muted-foreground, color-mix(in srgb, currentColor 65%, transparent));--dl-fg-faint: var(--text-tertiary, color-mix(in srgb, currentColor 50%, transparent));--dl-accent: var(--accent, #3a83f7);--dl-ok: var(--success, #00a240);--dl-warn: var(--warning, #e25507);--dl-bad: var(--danger, #e02e2a);--dl-ok-wash: var(--success-a15, color-mix(in srgb, #00a240 15%, transparent));--dl-warn-wash: var(--warning-a15, color-mix(in srgb, #e25507 15%, transparent));--dl-bad-wash: var(--destructive-a15, color-mix(in srgb, #e02e2a 15%, transparent));--dl-info-wash: var(--info-a15, color-mix(in srgb, #3a83f7 15%, transparent));--dl-info: var(--info, #2c67c5);--dl-track: var(--foreground-a10, color-mix(in srgb, currentColor 10%, transparent));--dl-chart-1: var(--chart-blue, #3a83f7);--dl-chart-2: var(--chart-green, #00a240);--dl-ring: var(--ring, #3a83f7);--dl-primary: var(--primary, #0d0d0d);--dl-primary-fg: var(--primary-foreground, #fff);--dl-mono: var(--font-mono, ui-monospace, Menlo, Consolas, monospace);--dl-shadow: var(--shadow-sm, none);--dl-radius: 16px}.dl-root,.dl-modal{cursor:default}:is(.dl-root,.dl-modal) :is(input:not([type=checkbox],[type=radio],[type=range],[type=button],[type=submit]),textarea,[contenteditable=true]){cursor:text}.dl-icon-wrap{display:inline-flex;align-items:center;justify-content:center;line-height:0}.dl-icon{width:16px;height:16px}.dl-icon-btn{display:inline-flex!important;align-items:center;gap:6px}.dl-muted{color:var(--dl-fg-muted)}.dl-faint,.dl-sep{color:var(--dl-fg-faint)}.dl-nowrap{white-space:nowrap}.dl-mono{font-family:var(--dl-mono);font-size:13px}.dl-spacer{flex:1}.dl-pill{display:inline-flex;align-items:center;gap:4px;height:20px;padding:0 8px;border-radius:999px;font-size:12px;line-height:20px;font-weight:500;white-space:nowrap;background:var(--dl-soft);color:var(--dl-fg-muted)}.dl-pill.ok{background:var(--dl-ok-wash);color:var(--dl-ok)}.dl-pill.warn{background:var(--dl-warn-wash);color:var(--dl-warn)}.dl-pill.bad{background:var(--dl-bad-wash);color:var(--dl-bad)}.dl-pill.accent{background:var(--dl-info-wash);color:var(--dl-info)}.dl-pill.off{opacity:.75}.dl-panel{background:var(--dl-card);border:1px solid var(--dl-line);border-radius:var(--dl-radius);padding:16px;margin:0 0 16px;min-width:0;box-shadow:var(--dl-shadow)}.dl-panel-head{display:flex;align-items:center;flex-wrap:wrap;gap:8px 12px;margin:0 0 12px}.dl-panel-head h3{margin:0!important;padding:0;font-size:16px;line-height:24px;font-weight:500;border:0;background:none}.dl-tiles{display:grid;grid-template-columns:repeat(auto-fit,minmax(170px,1fr));gap:12px;margin:0 0 16px}.dl-tile{background:var(--dl-card);border:1px solid var(--dl-line);border-radius:var(--dl-radius);padding:14px 16px;min-width:0;box-shadow:var(--dl-shadow)}.dl-tile-label{font-size:12px;line-height:16px;font-weight:500;color:var(--dl-fg-faint)}.dl-tile-value{font-size:24px;line-height:32px;font-weight:500;margin-top:4px;font-variant-numeric:tabular-nums;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;letter-spacing:-.01em}.dl-tile-sub{font-size:12px;line-height:16px;color:var(--dl-fg-muted);margin-top:2px;font-variant-numeric:tabular-nums}.dl-grid2{display:grid;grid-template-columns:minmax(0,1.45fr) minmax(0,1fr);gap:0 16px}@media(max-width:960px){.dl-grid2{grid-template-columns:minmax(0,1fr)}}.dl-chart{display:block;width:100%;height:120px}.dl-bar-down{fill:var(--dl-chart-1)}.dl-bar-up{fill:var(--dl-chart-2);opacity:.8}.dl-legend{display:flex;gap:16px;font-size:12px;color:var(--dl-fg-muted);margin-top:8px}.dl-legend i{display:inline-block;width:8px;height:8px;border-radius:999px;margin-right:6px;vertical-align:0}.dl-legend .down{background:var(--dl-chart-1)}.dl-legend .up{background:var(--dl-chart-2)}.dl-events{list-style:none;margin:0;padding:0}.dl-events li{display:flex;gap:12px;align-items:baseline;padding:8px 0;border-top:1px solid var(--dl-line);font-size:14px;line-height:20px;min-width:0}.dl-events li:first-child{border-top:0;padding-top:0}.dl-ev-time{flex:0 0 88px;color:var(--dl-fg-faint);font-variant-numeric:tabular-nums;white-space:nowrap;font-size:13px}.dl-ev-dot{flex:0 0 auto;width:6px;height:6px;border-radius:50%;background:var(--dl-fg-faint);transform:translateY(-2px)}.dl-ev-dot.ok{background:var(--dl-ok)}.dl-ev-dot.warn{background:var(--dl-warn)}.dl-ev-dot.bad{background:var(--dl-bad)}.dl-ev-dot.accent{background:var(--dl-accent)}.dl-row>.dl-ev-dot,.dl-dev-log-row>.dl-ev-dot{margin:0 4px}.dl-ev-tile{flex:none;display:inline-flex;align-items:center;justify-content:center;width:22px;height:22px;margin:-2px -4px;border-radius:7px;background:color-mix(in srgb,var(--dl-accent) 16%,transparent);color:var(--dl-accent);align-self:center}.dl-ev-tile .dl-icon-wrap{display:inline-flex}.dl-ev-tile .dl-icon{width:14px;height:14px}.dl-row.dl-ev-by-admin{background:color-mix(in srgb,var(--dl-accent) 6%,transparent)}.dl-you{color:var(--dl-accent);font-weight:500}.dl-ev-kind{color:var(--dl-fg-faint)}.dl-slotbar{display:flex;align-items:center;gap:8px;margin:8px 0 0 44px}.dl-slotbar-segs{display:flex;gap:3px;flex:none;max-width:100%}.dl-slotbar-segs i{flex:1;min-width:2px;display:block;height:4px;border-radius:2px;background:var(--dl-soft-hover)}.dl-slotbar-segs i.used{background:var(--dl-fg-muted)}.dl-slotbar-text{font-size:12px;color:var(--dl-fg-faint);font-variant-numeric:tabular-nums}.dl-slotbar-segs i.over{background:color-mix(in srgb,var(--dl-warn) 80%,transparent)}.dl-ev-srv{flex:none;font-size:11px;line-height:18px;padding:0 8px;border-radius:999px;background:var(--dl-soft);color:var(--dl-fg-muted);white-space:nowrap}.dl-ev-by-system{--sys: var(--dl-fg-muted)}.dl-ev-by-system.ok{--sys: var(--dl-ok)}.dl-ev-by-system.warn{--sys: var(--dl-warn)}.dl-ev-by-system.bad{--sys: var(--dl-bad)}.dl-ev-tile.ev{background:var(--dl-soft);color:var(--dl-fg-muted)}.dl-ev-tile.ev.ok{background:var(--dl-ok-wash);color:var(--dl-ok)}.dl-ev-tile.ev.warn{background:var(--dl-warn-wash);color:var(--dl-warn)}.dl-ev-tile.ev.bad{background:var(--dl-bad-wash);color:var(--dl-bad)}.dl-ev-tile.ev.accent{background:color-mix(in srgb,var(--dl-accent) 16%,transparent);color:var(--dl-accent)}.dl-ev-tile.sys{background:color-mix(in srgb,var(--sys) 16%,transparent);color:var(--sys)}.dl-row.dl-ev-by-system{background:color-mix(in srgb,var(--sys) 6%,transparent)}.dl-sys-src{color:var(--sys)}.dl-ev-by-system:not(.ok):not(.warn):not(.bad) .dl-sys-src{color:var(--dl-fg)}.dl-ev-text{min-width:0;overflow-wrap:anywhere}.dl-server{display:flex;flex-wrap:wrap;align-items:center;gap:8px 10px}.dl-server-name{font-size:16px;line-height:24px;font-weight:500}.dl-kv{display:grid;grid-template-columns:max-content minmax(0,1fr);gap:6px 24px;margin:12px 0 0;font-size:14px;line-height:20px}.dl-kv dt{color:var(--dl-fg-muted);font-weight:400;margin:0}.dl-kv dd{margin:0;overflow-wrap:anywhere;font-variant-numeric:tabular-nums}";var ti='.dl-plist{display:block}.dl-plist>.dl-card{display:block;margin:0 0 12px;padding:16px;min-width:0;background:var(--dl-card);border:1px solid var(--dl-line);border-radius:var(--dl-radius);box-shadow:var(--dl-shadow)}.dl-plist>.dl-card.dl-filtered{display:none}.dl-plist>.dl-card.dl-off :is(.dl-card-name,.dl-avatar,.dl-access,.dl-slotbar,.dl-chips,.dl-pill-ic,.dl-use-num,.dl-pside-foot,.dl-pside-state){opacity:.45}.dl-plist>.dl-card.dl-off .dl-usebar i{background:var(--dl-fg-faint)}.dl-plist>.dl-card.dl-off .dl-chip-tag{background:var(--dl-soft);color:var(--dl-fg-muted)}.dl-pcard:has(>.dl-pstrip){row-gap:14px}.dl-pstrip{grid-column:1 / -1;display:flex;align-items:center;flex-wrap:wrap;gap:8px 12px;margin:0 -16px -16px;padding:10px 16px;border-top:1px solid var(--dl-line);border-radius:0 0 var(--dl-radius) var(--dl-radius);font-size:14px;line-height:20px}.dl-pstrip.warn{background:color-mix(in srgb,var(--dl-warn) 7%,transparent)}.dl-pstrip.bad{background:color-mix(in srgb,var(--dl-bad) 7%,transparent)}.dl-pstrip-text{flex:1;min-width:0;display:flex;flex-wrap:wrap;align-items:baseline;gap:0 8px}.dl-pstrip-text b{font-weight:500}.dl-pstrip>.cbi-button{flex:none;height:32px!important}.dl-plist-none{color:var(--dl-fg-muted);text-align:center;padding:28px 16px;background:var(--dl-card);border:1px solid var(--dl-line);border-radius:var(--dl-radius)}.dl-card-head{display:flex;align-items:center;flex-wrap:wrap;gap:6px 8px}.dl-avatar{flex:0 0 auto;width:32px;height:32px;border-radius:50%;display:inline-flex;align-items:center;justify-content:center;font-size:12px;font-weight:600;color:var(--dl-fg);background:var(--dl-soft);position:relative;margin-right:4px;letter-spacing:.02em}.dl-avatar.online:after{content:"";position:absolute;right:-1px;bottom:-1px;width:9px;height:9px;border-radius:50%;background:var(--dl-ok);box-shadow:0 0 0 2px var(--dl-card)}.dl-card-name{font-size:16px;line-height:24px;font-weight:500}.dl-card-slug{font-size:13px;color:var(--dl-fg-faint);font-family:var(--dl-mono)}.dl-quota{margin:8px 0 0 44px;max-width:320px;height:6px;border-radius:999px;background:var(--dl-track);overflow:hidden}.dl-quota>i{display:block;height:100%;background:var(--dl-accent);border-radius:999px}.dl-quota.warn>i{background:var(--dl-warn)}.dl-quota.bad>i{background:var(--dl-bad)}.dl-chips{display:flex;flex-wrap:wrap;gap:6px;margin:12px 0 0 44px}.dl-chip{all:unset;box-sizing:border-box;cursor:pointer;display:inline-flex;align-items:center;gap:6px;max-width:240px;height:28px;padding:0 12px 0 10px;border-radius:999px;font-size:13px;background:var(--dl-soft);color:var(--dl-fg);transition:background .15s}.dl-chip:hover{background:var(--dl-soft-hover)}.dl-chip:focus-visible{outline:2px solid var(--dl-ring);outline-offset:2px}.dl-chip .dl-icon{width:14px;height:14px;color:var(--dl-fg-muted)}.dl-chip.add{background:transparent;border:1px dashed color-mix(in srgb,var(--dl-fg) 28%,transparent);color:var(--dl-fg-muted)}.dl-chip.add:hover{background:var(--dl-soft);color:var(--dl-fg);border-color:color-mix(in srgb,var(--dl-fg) 45%,transparent)}.dl-chip.add:hover .dl-icon{color:var(--dl-fg)}.dl-chip.disabled .dl-chip-name{text-decoration:line-through;color:var(--dl-fg-faint)}.dl-chip-name{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-dot{flex:0 0 auto;width:6px;height:6px;border-radius:50%;background:var(--dl-fg-faint);opacity:.6}.dl-dot.online{background:var(--dl-ok);opacity:1;box-shadow:0 0 0 3px var(--dl-ok-wash)}.dl-empty{text-align:center;padding:40px 16px;background:var(--dl-card);border:1px solid var(--dl-line);border-radius:var(--dl-radius)}.dl-empty .dl-icon-wrap{width:40px;height:40px;border-radius:12px;background:var(--dl-soft);margin-bottom:12px}.dl-empty .dl-icon{width:20px;height:20px}.dl-empty h3{margin:0 0 4px!important;font-size:16px;font-weight:500}.dl-empty p{margin:0 0 16px;color:var(--dl-fg-muted);font-size:14px}.dl-toolbar{display:flex;flex-wrap:wrap;align-items:center;gap:8px 12px;margin:0 0 16px}.dl-toolbar .dl-muted{font-size:13px}@media(max-width:640px){.dl-slotbar,.dl-chips,.dl-quota{margin-left:0}.dl-btn-label{display:none}}.cbi-value.dl-block{display:block!important}.cbi-value.dl-block>.cbi-value-title{display:block;width:auto;float:none;text-align:left;padding:0 0 8px}.cbi-value.dl-block>.cbi-value-field{display:block;width:100%;margin:0}.dl-people-find{width:160px;min-width:0}.dl-people-find[hidden]{display:none}';var ni="#modal_overlay{z-index:1100!important}.dl-dd{position:fixed;z-index:1200;min-width:200px;padding:4px;border-radius:12px;background:var(--dl-elevated);border:1px solid var(--dl-line);box-shadow:0 12px 32px #0000004d;display:flex;flex-direction:column}.dl-dd button{all:unset;cursor:pointer;display:flex;align-items:center;gap:10px;padding:7px 10px;border-radius:8px;font-size:13px;color:var(--dl-fg)}.dl-dd button .dl-icon{width:15px;height:15px;color:var(--dl-fg-muted)}.dl-dd button:hover,.dl-dd button:focus-visible{background:var(--dl-soft)}.dl-dd button.danger,.dl-dd button.danger .dl-icon{color:var(--dl-bad, #e5484d)}.dl-dd button.warn,.dl-dd button.warn .dl-icon{color:var(--dl-warn)}.dl-dd hr{border:0;border-top:1px solid var(--dl-line);margin:4px 0}.dl-chipbtn b{font-weight:500;font-size:11px;margin-left:6px;opacity:.6}.dl-setsub{margin:20px 0 8px!important;font-size:13px;font-weight:500;color:var(--dl-fg)}.dl-row-actions{display:flex;flex-wrap:wrap;gap:8px;align-items:center}.dl-more-row{display:flex;justify-content:center;padding:8px 0 16px}.dl-dsec-actions{display:flex;align-items:center;gap:12px}.dl-kv-act{display:inline-flex;align-items:center;gap:12px;flex-wrap:wrap}.dl-linkbtn,.dl-bento-head a,.dl-bento-foot a,.dl-panel-head a,.dl-dsec-head a,.dl-tile2-foot a{all:unset;box-sizing:border-box;cursor:pointer;display:inline-flex;align-items:center;gap:4px;height:26px;padding:0 9px;margin:-4px -6px;border-radius:8px;font-size:12px;font-weight:500;color:var(--dl-fg-muted);text-decoration:none!important;white-space:nowrap;transition:background .12s,color .12s}.dl-bento-head a,.dl-bento-foot a,.dl-panel-head a,.dl-dsec-head a,.dl-tile2-foot a{color:var(--dl-accent)}.dl-linkbtn:hover,.dl-bento-head a:hover,.dl-bento-foot a:hover,.dl-panel-head a:hover,.dl-dsec-head a:hover,.dl-tile2-foot a:hover{background:var(--dl-soft);color:var(--dl-fg);text-decoration:none!important}.dl-bento-head a:hover,.dl-bento-foot a:hover,.dl-panel-head a:hover,.dl-dsec-head a:hover,.dl-tile2-foot a:hover{background:color-mix(in srgb,var(--dl-accent) 12%,transparent);color:var(--dl-accent)}.dl-linkbtn:focus-visible,.dl-bento-head a:focus-visible,.dl-bento-foot a:focus-visible,.dl-panel-head a:focus-visible{outline:2px solid var(--dl-ring);outline-offset:1px}.dl-linkbtn.danger:hover{color:var(--dl-bad);background:var(--dl-bad-wash)}.dl-ifcards{display:flex;flex-direction:column;gap:20px;margin:24px 0}.dl-ifcard .dl-setsec-body{gap:14px}.dl-iflead{display:flex;flex-direction:column;gap:2px;padding-top:14px;border-top:1px solid var(--dl-line)}.dl-iflead b{font-size:14px;font-weight:500}.dl-ifgroup h4{margin:0 0 8px!important;padding:0!important;font-size:11px!important;font-weight:500!important;letter-spacing:.06em;text-transform:uppercase;color:var(--dl-fg-muted);border:0!important;background:none!important}.dl-ifgrid{display:grid;grid-template-columns:repeat(auto-fill,minmax(210px,1fr));gap:8px}.dl-if{all:unset;box-sizing:border-box;cursor:pointer;display:flex;align-items:center;gap:10px;min-height:52px;padding:8px 12px 8px 10px;min-width:0;border:1px solid var(--dl-line);border-radius:10px;background:var(--dl-card);transition:background .15s,border-color .15s}.dl-if:hover{background:var(--dl-soft)}.dl-if:focus-visible{outline:2px solid var(--dl-ring);outline-offset:2px}.dl-if-ic{width:30px;height:30px;border-radius:8px;background:var(--dl-soft);display:inline-flex;align-items:center;justify-content:center;flex:0 0 auto;color:var(--dl-fg-muted)}.dl-if-ic .dl-icon{width:16px;height:16px}.dl-if-main{display:flex;flex-direction:column;min-width:0;flex:1}.dl-if-name{font-size:13.5px;font-weight:500;color:var(--dl-fg);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.dl-if-sub{font:11px/16px var(--dl-mono);color:var(--dl-fg-muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.dl-if.sel{border-color:var(--dl-accent);background:color-mix(in srgb,var(--dl-accent) 9%,transparent)}.dl-if.sel .dl-if-ic{background:color-mix(in srgb,var(--dl-accent) 18%,transparent);color:var(--dl-accent)}.dl-if-check{color:var(--dl-accent);display:inline-flex}.dl-if-check .dl-icon{width:16px;height:16px}.dl-if.auto{border-color:color-mix(in srgb,var(--dl-ok) 55%,transparent);background:var(--dl-ok-wash);cursor:default}.dl-if.auto .dl-if-ic{background:color-mix(in srgb,var(--dl-ok) 18%,transparent);color:var(--dl-ok)}.dl-if-badge{display:inline-flex;align-items:center;gap:5px;font-size:10.5px;font-weight:600;letter-spacing:.05em;text-transform:uppercase;flex:0 0 auto}.dl-if-badge.ok{color:var(--dl-ok)}.dl-if.off{cursor:default;opacity:.5}.dl-if.off:hover{background:var(--dl-card)}.dl-if.warn{border-color:color-mix(in srgb,var(--dl-warn) 60%,transparent)}.dl-if-wanctl{gap:10px;align-items:center}.dl-if-wanctl select{max-width:240px}.dl-if-summary{min-width:0;line-height:18px}.dl-warn{color:var(--dl-warn)}.dl-w-ip{width:160px}.dl-dnspick{padding-top:8px;border-top:1px solid var(--dl-line)}.dl-dnspick .dl-row-actions{gap:10px}.dl-note{display:flex;gap:8px;align-items:flex-start;padding:10px 12px;border-radius:10px;font-size:12.5px;line-height:18px;margin:0 0 10px;background:var(--dl-soft)}.dl-note.warn{background:var(--dl-warn-wash, color-mix(in srgb, var(--dl-warn) 14%, transparent))}.dl-note .dl-icon{width:15px;height:15px;flex:0 0 auto;margin-top:1px;color:var(--dl-warn)}.dl-stale{align-self:flex-start;margin-top:4px;font-size:10.5px}.dl-root .cbi-button.dl-btn-warn,.dl-btn-warn.cbi-button{background:var(--dl-warn-wash)!important;color:var(--dl-warn)!important;border-color:color-mix(in srgb,var(--dl-warn) 35%,transparent)!important}.dl-root .cbi-button.dl-btn-warn:hover,.dl-btn-warn.cbi-button:hover{background:color-mix(in srgb,var(--dl-warn) 24%,transparent)!important}.dl-btn-warn .dl-icon{color:var(--dl-warn)}.dl-srvtabs{display:flex;flex-wrap:wrap;gap:6px;padding:4px;margin:0 0 20px;border-radius:12px;background:var(--dl-soft);width:fit-content;max-width:100%}.dl-srvtab{all:unset;box-sizing:border-box;cursor:pointer;display:inline-flex;align-items:center;gap:8px;height:34px;padding:0 14px;border-radius:9px;font-size:13px;color:var(--dl-fg-muted);text-decoration:none!important;white-space:nowrap}.dl-srvtab b{font-weight:500}.dl-srvtab i.dot{width:7px;height:7px;border-radius:50%;background:var(--dl-fg-faint);flex:0 0 auto}.dl-srvtab i.dot.ok{background:var(--dl-ok);animation:dl-srv-pulse 2s ease-out infinite}.dl-srvtab i.dot.bad{background:var(--dl-bad)}.dl-srvtab i.dot.warn{background:var(--dl-warn)}@keyframes dl-srv-pulse{0%{box-shadow:0 0 color-mix(in srgb,var(--dl-ok) 55%,transparent)}70%,to{box-shadow:0 0 0 6px transparent}}@media(prefers-reduced-motion:reduce){.dl-srvtab i.dot.ok{animation:none}}.dl-srvtab:hover{color:var(--dl-fg);background:var(--dl-soft-hover)}.dl-srvtab.on{background:var(--dl-card);color:var(--dl-fg);box-shadow:0 1px 2px #0000002e,inset 0 0 0 1px var(--dl-line)}.dl-srvtab:focus-visible{outline:2px solid var(--dl-ring);outline-offset:1px}.dl-srvtab.add{color:var(--dl-fg-muted)}.dl-srvtab.add .dl-icon{width:14px;height:14px}.dl-srvhead{display:flex;flex-direction:column;gap:14px;margin:0 0 20px}.dl-srvhead .dl-title-row{display:flex;align-items:center;gap:10px}.dl-srvhead .dl-h1{margin:0!important}.dl-metrics.compact .dl-metric{padding:14px 18px}.dl-metrics.compact .dl-metric-value{display:flex;align-items:center;gap:6px;font-size:18px;line-height:26px;min-width:0}.dl-metrics.compact .dl-metric-value>span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0}.dl-metrics.compact .dl-metric-value .dl-mono{font-size:15px}.dl-metrics.compact .cbi-button{flex:0 0 auto}.dl-srvsections{margin:0 0 16px}.dl-srvbody>.dl-setsec,.dl-srvbody>.dl-ifcards{margin:0}.dl-srvbody .dl-ifcards{margin:0}.dl-metric-ic{display:inline-flex;align-items:center;gap:8px;font-size:16px}.dl-metric-ic .dl-icon{width:18px;height:18px;color:var(--dl-accent)}.dl-keyrow{display:inline-flex;align-items:center;gap:8px;min-width:0}.dl-keyrow code{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:12px;background:none;padding:0}.dl-params{border:1px solid var(--dl-line);border-radius:12px;background:var(--dl-card)}.dl-params>summary{list-style:none;cursor:pointer;display:flex;align-items:center;gap:8px;padding:10px 14px;font-size:13px;color:var(--dl-fg);user-select:none}.dl-params>summary::-webkit-details-marker{display:none}.dl-params>summary>.dl-icon-wrap{display:inline-flex;color:var(--dl-fg-muted);transition:transform .15s}.dl-params>summary>.dl-icon-wrap .dl-icon{width:15px;height:15px}.dl-params[open]>summary>.dl-icon-wrap{transform:rotate(90deg)}.dl-params>summary:focus{outline:none}.dl-params>summary:focus-visible{outline:2px solid var(--dl-ring);outline-offset:-2px;border-radius:12px}.dl-params>summary:hover{background:var(--dl-soft);border-radius:12px}.dl-pcount{font-size:11px;padding:0 6px;border-radius:999px;background:var(--dl-soft);color:var(--dl-fg-muted)}.dl-pgrid{display:grid;grid-template-columns:repeat(auto-fill,minmax(260px,1fr));gap:10px;padding:4px 14px 14px}.dl-pgroup{display:flex;flex-direction:column;gap:6px;padding:12px;border-radius:10px;background:var(--dl-soft);min-width:0}.dl-pgroup-head{display:flex;align-items:center;gap:8px;font-size:13px}.dl-pgroup-head b{font-weight:500}.dl-pgroup-head .dl-icon{width:14px;height:14px;color:var(--dl-fg-muted)}.dl-pgroup p{margin:0!important;font-size:12px;line-height:17px;color:var(--dl-fg-muted)}.dl-pvals{display:flex;flex-wrap:wrap;gap:4px;margin-top:2px}.dl-pv{display:inline-flex;align-items:stretch;max-width:100%;border-radius:6px;overflow:hidden;font:500 11.5px/22px var(--dl-mono);box-shadow:inset 0 0 0 1px var(--dl-line)}.dl-pv i{font-style:normal;padding:0 6px;background:var(--dl-card);color:var(--dl-fg-faint)}.dl-pv b{font-weight:500;padding:0 7px;color:var(--dl-fg);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0}";var oi=".dl-methods{display:grid;grid-template-columns:repeat(auto-fit,minmax(210px,1fr));gap:10px}.dl-method{all:unset;box-sizing:border-box;cursor:pointer;display:flex;flex-direction:column;gap:10px;padding:14px;border-radius:12px;border:1px solid var(--dl-line);background:var(--dl-card);transition:border-color .15s,background .15s;min-width:0}.dl-method:hover{background:var(--dl-soft)}.dl-method:focus-visible{outline:2px solid var(--dl-ring);outline-offset:2px}.dl-method.on{border-color:var(--dl-accent);background:color-mix(in srgb,var(--dl-accent) 8%,transparent);box-shadow:inset 0 0 0 1px var(--dl-accent)}.dl-method.off{cursor:not-allowed;opacity:.55}.dl-method.off:hover{background:var(--dl-card)}.dl-method-head{display:flex;flex-wrap:wrap;align-items:center;gap:8px 10px}.dl-method-head .dl-pill{flex:none}.dl-method-head b{font-weight:500;font-size:14.5px;flex:1}.dl-method-ic{width:32px;height:32px;border-radius:9px;background:var(--dl-soft);display:inline-flex;align-items:center;justify-content:center;color:var(--dl-fg-muted);flex:0 0 auto}.dl-method-ic .dl-icon{width:17px;height:17px}.dl-method.on .dl-method-ic{background:color-mix(in srgb,var(--dl-accent) 18%,transparent);color:var(--dl-accent)}.dl-method p{margin:0!important;font-size:12.5px;line-height:18px;color:var(--dl-fg-muted);flex:1}.dl-method-meters{display:flex;gap:16px}.dl-dots{display:inline-flex;align-items:center;gap:6px;font-size:11px;color:var(--dl-fg-faint)}.dl-dots-row{display:inline-flex;gap:3px}.dl-dots-row i{width:6px;height:6px;border-radius:50%;background:var(--dl-line)}.dl-dots-row i.on{background:var(--dl-fg-muted)}.dl-method.on .dl-dots-row i.on{background:var(--dl-accent)}.dl-method-foot{display:flex;align-items:center;gap:6px;font-size:11.5px;color:var(--dl-fg-faint);padding-top:8px;border-top:1px solid var(--dl-line)}.dl-method-foot .dl-icon{width:13px;height:13px;flex:0 0 auto}.dl-method.off .dl-method-foot{color:var(--dl-warn)}.dl-ibadge{display:inline-flex;align-items:center;gap:3px;height:22px;padding:0 6px;border-radius:999px;background:var(--dl-soft);color:var(--dl-fg-muted);flex:0 0 auto}.dl-ibadge .dl-icon{width:13px;height:13px}.dl-ibadge.warn{background:var(--dl-warn-wash);color:var(--dl-warn)}.dl-ibadge.bad{background:var(--dl-bad-wash);color:var(--dl-bad)}.dl-access{display:inline-flex;gap:4px;flex:0 0 auto}.dl-ibadge.lan{background:color-mix(in srgb,var(--dl-accent) 16%,transparent);color:var(--dl-accent)}.dl-ibadge.inet{background:var(--dl-ok-wash);color:var(--dl-ok)}";var ri=".dl-addrbar{display:inline-flex;align-items:stretch;flex-wrap:nowrap;max-width:100%;margin-top:4px;border:1px solid var(--dl-line);border-radius:10px;background:var(--dl-card);overflow:hidden}.dl-addrbar-seg{all:unset;box-sizing:border-box;display:inline-flex;align-items:center;gap:7px;padding:6px 12px;font-size:13px;color:var(--dl-fg-muted);border-left:1px solid var(--dl-line);white-space:nowrap;min-width:0}.dl-addrbar-seg:first-child{border-left:0}.dl-addrbar-seg .dl-icon{width:14px;height:14px;color:var(--dl-fg-faint);flex:0 0 auto}.dl-addrbar-seg .dl-mono{font-size:12.5px}.dl-addrbar-seg.main{cursor:pointer;color:var(--dl-fg)}.dl-addrbar-seg.main:hover{background:var(--dl-soft)}.dl-addrbar-seg.main:focus-visible{outline:2px solid var(--dl-ring);outline-offset:-2px}.dl-addrbar-seg.main>.dl-icon-wrap:last-child .dl-icon{opacity:.7}.dl-bento{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));grid-template-rows:auto auto;gap:10px;margin:0 0 20px}.dl-person-devices{margin-bottom:16px}.dl-person-head{display:flex;flex-direction:column;margin:0 0 20px}.dl-person-head>.dl-pagehead{margin-bottom:0;align-items:flex-start}.dl-pnote{all:unset;box-sizing:border-box;cursor:pointer;align-self:flex-start;display:inline-flex;align-items:flex-start;gap:6px;margin:10px 0 0 62px;max-width:60ch;padding:6px 12px 6px 10px;border-radius:10px;font-size:13px;line-height:18px;white-space:pre-line;background:var(--dl-soft);color:var(--dl-fg);box-shadow:inset 0 0 0 1px var(--dl-line)}.dl-pnote:hover{background:var(--dl-soft-hover)}.dl-pnote .dl-icon{width:14px;height:14px;flex:none;margin-top:2px;color:var(--dl-fg-muted)}.dl-note-input{width:100%;box-sizing:border-box;min-height:80px;resize:vertical}.dl-dcard-trend{display:flex;align-items:flex-end;gap:12px;min-width:0}.dl-dcard-trend>.dl-stack{flex:none}.dl-dcard-trend b{font-size:16px;font-weight:500;font-variant-numeric:tabular-nums}.dl-dbars{flex:1;min-width:0;height:32px;display:flex;align-items:flex-end;gap:2px}.dl-dbars i{flex:1;min-width:0;border-radius:2px;background:var(--dl-chart-1);opacity:.55}.dl-dbars i.zero{background:var(--dl-track);opacity:1}.dl-dbars i.hi{opacity:1}.dl-dbars i:hover{opacity:1;filter:brightness(1.2)}.dl-datechip{position:relative;display:inline-flex}.dl-date-hidden{position:absolute!important;left:0;bottom:0;width:1px!important;min-width:0!important;height:1px!important;opacity:0;pointer-events:none;border:0!important;padding:0!important;margin:0!important}.dl-chipbtn .dl-icon{width:13px;height:13px}.dl-chipbtn:has(.dl-icon){display:inline-flex;align-items:center;gap:5px}.dl-places{display:flex;align-items:center;gap:12px;padding:12px 16px;border:1px solid var(--dl-line);border-radius:var(--dl-radius);background:var(--dl-card);font-size:14px}.dl-places>.dl-icon{width:18px;height:18px;color:var(--dl-fg-muted);flex:none}.dl-person-live{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:10px}.dl-person-live .dl-bento-head{flex-wrap:nowrap;white-space:nowrap;min-width:0}.dl-person-live .dl-bento-head>*{min-width:0;overflow:hidden;text-overflow:ellipsis}.dl-person-live .dl-bento-head>:first-child{flex:none}.dl-person-live.solo{grid-template-columns:minmax(0,1fr)}.dl-person-live:not(.solo) .dl-bento-tile.month>.dl-bento-head:first-child{flex-wrap:wrap;row-gap:2px}.dl-person-live:not(.solo) .dl-bento-tile.month>.dl-bento-head:first-child>.dl-sub{flex-basis:100%}.dl-person-live>.dl-bento-tile,.dl-person-live>.dl-bento-tile.month{grid-column:auto;grid-row:auto}@media(max-width:760px){.dl-person-live{grid-template-columns:minmax(0,1fr)}}.dl-bento-tile{background:var(--dl-card);border:1px solid var(--dl-line);border-radius:var(--dl-radius);padding:14px 16px;display:flex;flex-direction:column;gap:10px;min-width:0;box-shadow:var(--dl-shadow)}.dl-bento-tile.month{grid-column:1 / -1}.dl-onl-count{font-size:13px;line-height:22px;min-width:22px;padding:0 8px;border-radius:999px;background:var(--dl-soft);text-align:center;font-weight:500;font-variant-numeric:tabular-nums}.dl-onl-count.none{color:var(--dl-fg-faint)}.dl-onl-row{flex:1;display:flex;align-items:center;justify-content:center;gap:12px;min-width:0}.dl-onl-p{display:flex;flex-direction:column;align-items:center;gap:5px;width:104px;min-width:0;padding:6px 2px;border-radius:12px;color:var(--dl-fg)!important;text-decoration:none!important}.dl-onl-p:hover{background:var(--dl-soft)}.dl-onl-av{position:relative;width:42px;height:42px;border-radius:50%;background:var(--dl-soft);display:inline-flex;align-items:center;justify-content:center;font-size:13px;font-weight:500;box-shadow:0 0 0 2px var(--dl-ok)}.dl-onl-p.more .dl-onl-av{box-shadow:0 0 0 1px var(--dl-line);color:var(--dl-fg-muted)}.dl-onl-dev{position:absolute;right:-6.5px;bottom:-6.5px;width:20px;height:20px;border-radius:8.5px;border:1.5px solid transparent;background:var(--dl-card);display:inline-flex;align-items:center;justify-content:center;font-size:10px;color:var(--dl-fg-muted)}.dl-onl-dev .dl-icon-wrap{display:inline-flex}.dl-onl-dev .dl-icon{width:12px;height:12px}.dl-onl-name{font-size:12.5px;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-onl-p .dl-sub{font-size:11px;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-onl-row.grid{flex-wrap:wrap;align-content:center;gap:10px 8px;max-height:108px;overflow:hidden}.dl-onl-p.sm{width:auto;padding:4px}.dl-onl-p:hover .dl-onl-dev{background:linear-gradient(var(--dl-soft),var(--dl-soft)),var(--dl-card)}.dl-onl-p.sm:hover{background:none}.dl-onl-p.sm:hover .dl-onl-dev{background:var(--dl-card)}.dl-onl-p.sm .dl-onl-av{transition:box-shadow .15s ease}.dl-onl-p.sm:hover .dl-onl-av{box-shadow:0 0 0 2px var(--dl-ok),0 0 0 6px var(--dl-soft)}.dl-onl-p.sm.more:hover .dl-onl-av{box-shadow:0 0 0 1px var(--dl-line),0 0 0 6px var(--dl-soft)}.dl-onl-p.sm .dl-onl-av{width:36px;height:36px;font-size:11.5px}.dl-onl-meta{display:inline-flex;align-items:center;gap:3px;font-size:11px;color:var(--dl-fg-faint);max-width:100%;white-space:nowrap;overflow:hidden}.dl-onl-meta .dl-icon-wrap{display:inline-flex}.dl-onl-meta .dl-icon{width:12px;height:12px}.dl-onl-av.sm{width:34px;height:34px;font-size:11.5px}.dl-tip-float:has(.dl-hc){padding:0;white-space:normal;border-radius:16px}.dl-hc{width:280px;padding:14px;display:flex;flex-direction:column;gap:10px}.dl-hc-head{display:flex;align-items:center;gap:10px}.dl-hc-head .dl-stack{flex:1;min-width:0}.dl-hc-head b{font-size:14px;font-weight:500}.dl-hc-since{font-size:11.5px;color:var(--dl-ok)}.dl-hc-reach{display:inline-flex;gap:4px}.dl-hc-speed{border-radius:12px;background:var(--dl-soft);padding:10px 12px;display:flex;flex-direction:column;gap:6px}.dl-hc-speed-row{display:flex;align-items:baseline;gap:12px;font-size:13px;font-variant-numeric:tabular-nums}.dl-hc-chart{display:block;width:100%;height:30px}.dl-hc-chart .area{fill:color-mix(in srgb,var(--dl-chart-1) 16%,transparent)}.dl-hc-chart .dn{fill:none;stroke:var(--dl-chart-1);stroke-width:1.5;vector-effect:non-scaling-stroke}.dl-hc-chart .up{fill:none;stroke:var(--dl-ok);stroke-width:1.2;vector-effect:non-scaling-stroke}.dl-hc-devs{display:flex;flex-wrap:wrap;gap:6px}.dl-hc-dev{display:inline-flex;align-items:center;gap:5px;height:24px;padding:0 9px;border-radius:999px;background:var(--dl-soft);font-size:11.5px}.dl-hc-dev .dl-icon-wrap{display:inline-flex}.dl-hc-dev .dl-icon{width:12px;height:12px;color:var(--dl-fg-muted)}.dl-hc-foot{display:flex;align-items:center;gap:8px;font-size:11.5px}.dl-disg-id{display:flex;align-items:center;gap:10px}.dl-disg-id b{font-size:16px;font-weight:500}.dl-disg-ic{width:36px;height:36px;border-radius:11px;background:color-mix(in srgb,var(--dl-accent) 14%,transparent);color:var(--dl-accent);display:inline-flex;align-items:center;justify-content:center;flex:none}.dl-disg-ic .dl-icon-wrap{display:inline-flex}.dl-disg-ic .dl-icon{width:18px;height:18px}.dl-disg-ic.off{background:var(--dl-soft);color:var(--dl-fg-muted)}.dl-disg-meters{display:grid;grid-template-columns:auto 1fr;gap:6px 10px;align-items:center;font-size:12px;color:var(--dl-fg-muted)}.dl-segs{display:inline-flex;gap:3px}.dl-segs i{width:18px;height:5px;border-radius:3px;background:var(--dl-track)}.dl-segs.acc i.on{background:var(--dl-accent)}.dl-segs.ok i.on{background:var(--dl-ok)}.dl-disg-chips{margin-top:auto;display:flex;flex-wrap:wrap;gap:5px}.dl-disg-chips span{font:11px/20px var(--dl-mono);padding:0 8px;border-radius:999px;background:var(--dl-soft);color:var(--dl-fg-muted);white-space:nowrap}.dl-onl-empty{flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:4px;font-size:13px;text-align:center}.dl-bento-head{display:flex;align-items:center;justify-content:space-between;gap:10px;min-width:0}.dl-bento-head.start{justify-content:flex-start}.dl-bento-big{font-family:inherit;font-size:28px;line-height:34px;font-weight:500;letter-spacing:-.01em;font-variant-numeric:tabular-nums;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.dl-bento-big small{font-size:13px;font-weight:400;color:var(--dl-fg-faint);letter-spacing:0}.dl-avstack{display:inline-flex}.dl-avstack .dl-avatar{margin-left:-7px;box-shadow:0 0 0 2px var(--dl-card)}.dl-avstack .dl-avatar:first-child{margin-left:0}.dl-avatar.more{background:var(--dl-soft);color:var(--dl-fg-muted)}.dl-bento-list{display:flex;flex-direction:column;gap:2px}.dl-bento-row{display:flex;align-items:center;gap:10px;padding:8px;margin:0 -8px;border-radius:10px;color:var(--dl-fg)!important;text-decoration:none!important;min-width:0;transition:background .12s}.dl-bento-row:hover{background:var(--dl-soft)}.dl-bento-row:hover b{text-decoration:none}.dl-bento-row:focus-visible{outline:2px solid var(--dl-ring);outline-offset:-2px}.dl-bento-row-main{display:flex;flex-direction:column;gap:1px;flex:1;min-width:0}.dl-bento-row-main b{font-weight:500;font-size:13.5px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-bento-row-main .dl-sub{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-bento-row.off b{color:var(--dl-fg-muted);font-weight:400}.dl-bento-row-val{display:flex;flex-direction:column;align-items:flex-end;font-size:13px;font-variant-numeric:tabular-nums;white-space:nowrap}.dl-bento-row-val small{font-size:11px;color:var(--dl-fg-faint)}.dl-bento-sep{font-size:11px;color:var(--dl-fg-faint);padding:12px 0 4px}.dl-bento-devs{display:inline-flex;gap:3px;color:var(--dl-fg-faint)}.dl-bento-devs .dl-icon{width:13px;height:13px}.dl-bento-devs .on{color:var(--dl-ok)}.dl-bento-foot{display:flex;align-items:center;gap:10px;margin-top:auto;padding-top:10px;border-top:1px solid var(--dl-line);color:var(--dl-fg)!important;text-decoration:none!important}.dl-bento-foot.split,.dl-bento-foot.end{justify-content:space-between}.dl-bento-foot.end>a:only-child{margin-left:auto}.dl-bento-empty{display:flex;align-items:center;gap:10px;padding:14px 0;font-size:13.5px;color:var(--dl-fg-muted)}.dl-bento-empty .dl-icon{width:18px;height:18px}.dl-split{display:flex;height:6px;border-radius:3px;overflow:hidden;background:var(--dl-soft)}.dl-split i{display:block;height:100%}.dl-split i.dn{background:var(--dl-accent)}.dl-split i.up{background:var(--dl-ok)}.dl-dn{color:var(--dl-accent)}.dl-up{color:var(--dl-ok)}.dl-bento-method{display:flex;align-items:center;gap:8px;font-size:18px;font-weight:500}.dl-bento-method .dl-icon{width:20px;height:20px;color:var(--dl-accent)}.dl-meter{display:inline-flex;gap:3px}.dl-meter i{width:16px;height:4px;border-radius:2px;background:var(--dl-line)}.dl-meter i.on{background:var(--dl-accent)}.dl-bento-total{font-size:16px;font-weight:500;margin-left:8px}.dl-bento-bars{display:flex;align-items:flex-end;gap:3px;height:54px}.dl-bento-bars i{flex:1;min-width:0;border-radius:3px 3px 0 0;background:var(--dl-soft-hover);transition:background .15s}.dl-bento-bars i.future{height:4px;background:var(--dl-soft)}.dl-bento-bars i:hover{background:var(--dl-fg-faint)}.dl-bento-bars i.hi{background:var(--dl-accent)}@media(max-width:700px){.dl-addrbar{flex-wrap:wrap}}@media(max-width:900px){.dl-bento{grid-template-columns:minmax(0,1fr) minmax(0,1fr)}.dl-bento-tile.online{grid-column:span 2}}@media(max-width:560px){.dl-bento{grid-template-columns:minmax(0,1fr)}.dl-bento-tile.online,.dl-bento-tile.month{grid-column:auto}}.dl-srvpagehead{display:flex;flex-direction:column;align-items:flex-start;gap:10px;margin:0 0 20px}.dl-srvpagehead>.dl-title-row{display:flex;align-items:center;gap:10px;width:100%;flex-wrap:wrap}.dl-srvpagehead .dl-actions{margin:0;flex-wrap:wrap}.dl-toolbar-end{display:flex;align-items:center;gap:8px;margin-left:auto;flex-wrap:nowrap;min-width:0}@media(max-width:640px){.dl-toolbar-end{flex-wrap:wrap;width:100%}}.dl-notices{margin:0 0 16px}.dl-notices .dl-need-row .dl-sub{overflow-wrap:anywhere}.dl-notices-more{font-size:13px;color:var(--dl-fg-muted);text-decoration:none}.dl-notices-more:hover{background:var(--dl-soft);color:var(--dl-fg)}.dl-speed-cols{display:grid;grid-template-columns:1fr 1fr;gap:12px}.dl-speed-col{display:flex;flex-direction:column;gap:2px;min-width:0}.dl-speed-val{font-size:20px;line-height:26px;font-weight:500;font-variant-numeric:tabular-nums;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.dl-speed-today{display:flex;justify-content:space-between;gap:10px;font-size:12px;color:var(--dl-fg-muted);white-space:nowrap;font-variant-numeric:tabular-nums}.dl-speed-today b{font-weight:500;color:var(--dl-fg)}.dl-speed-chart{display:block;width:100%;height:44px}.dl-speed-chart .area{fill:color-mix(in srgb,var(--dl-accent) 16%,transparent)}.dl-speed-chart .line{fill:none;stroke:var(--dl-accent);stroke-width:1.5;vector-effect:non-scaling-stroke}.dl-speed-chart .line.up{stroke:var(--dl-ok);stroke-width:1.2;opacity:.85}.dl-speed-wait{height:44px;display:flex;flex-direction:column;justify-content:flex-end;gap:6px;font-size:11px;color:var(--dl-fg-faint)}.dl-speed-wait i{display:block;height:1px;background:var(--dl-line);order:2}.dl-speed-val.off{color:var(--dl-fg-faint)}.dl-fld{display:flex;flex-direction:column;gap:8px;margin:0 0 16px}.dl-fld-label{font-size:13px;font-weight:500;color:var(--dl-fg)}.dl-fld .cbi-input-text{width:100%;box-sizing:border-box}.dl-kinds{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:6px}.dl-kinds button{all:unset;box-sizing:border-box;cursor:pointer;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:6px;height:68px;border-radius:10px;border:1px solid var(--dl-line);color:var(--dl-fg-muted);font-size:12px;font-weight:500;text-align:center;min-width:0}.dl-kinds button .dl-icon{width:20px;height:20px}.dl-kinds button:hover{background:var(--dl-soft);color:var(--dl-fg)}.dl-kinds button:focus-visible{outline:2px solid var(--dl-ring);outline-offset:2px}.dl-kinds button.on{border-color:var(--dl-accent);color:var(--dl-fg);background:color-mix(in srgb,var(--dl-accent) 10%,transparent);box-shadow:inset 0 0 0 1px var(--dl-accent)}.dl-kinds button.on .dl-icon{color:var(--dl-accent)}.dl-choices{display:grid;grid-template-columns:repeat(auto-fit,minmax(170px,1fr));gap:8px}.dl-choice{all:unset;box-sizing:border-box;cursor:pointer;display:flex;flex-direction:column;gap:4px;padding:12px 14px;border-radius:12px;background:var(--dl-card);box-shadow:inset 0 0 0 1px var(--dl-line);transition:background .15s,box-shadow .15s}.dl-choice:hover{background:var(--dl-soft)}.dl-choice:focus-visible{outline:2px solid var(--dl-ring);outline-offset:2px}.dl-choice.selected{box-shadow:inset 0 0 0 2px var(--dl-accent);background:var(--accent-a10, color-mix(in srgb, var(--dl-accent) 8%, transparent))}.dl-choice-title{display:flex;align-items:center;gap:8px;font-size:14px;font-weight:500;color:var(--dl-fg)}.dl-choice-text{font-size:12px;line-height:16px;color:var(--dl-fg-muted)}.dl-attn-item>.cbi-button{margin-left:auto;flex:none;align-self:center}";var ai='.dl-steps{display:flex;align-items:center;gap:8px;margin:0 0 16px;flex-wrap:wrap}.dl-step{display:flex;align-items:center;gap:8px;font-size:14px;font-weight:500;color:var(--dl-fg-faint)}.dl-step b{display:inline-flex;width:24px;height:24px;align-items:center;justify-content:center;border-radius:50%;background:var(--dl-soft);font-size:12px;font-weight:600}.dl-step.current{color:var(--dl-fg)}.dl-step.current b{background:var(--dl-primary);color:var(--dl-primary-fg)}.dl-step.done{color:var(--dl-fg-muted)}.dl-step.done b{background:var(--dl-ok-wash);color:var(--dl-ok)}.dl-step+.dl-step:before{content:"";width:24px;height:1px;background:var(--dl-line)}.dl-wizard .dl-panel>div{display:flex;flex-direction:column;gap:16px}.dl-wizard .dl-panel>div>p{margin:0!important;color:var(--dl-fg-muted)}.dl-wizard .dl-panel>div>.cbi-value{margin:0}.dl-wizard h4{font-size:14px;font-weight:500;margin:8px 0 -6px!important}.dl-wizard h4:first-child{margin-top:0!important}.dl-modal .cbi-tabmenu{margin-bottom:16px}.dl-modal .cbi-value.dl-live>.cbi-value-title{display:flex;flex-direction:column;gap:2px;text-align:left}.dl-modal .cbi-value.dl-live>.cbi-value-title>.dl-sub{white-space:normal}.dl-checklist{display:flex;flex-direction:column;gap:6px;margin:4px 0 8px}.dl-checklist label{display:flex;align-items:center;gap:8px;font-size:14px;cursor:pointer}.dl-checklist input{margin:0}.dl-invite{display:grid;grid-template-columns:250px minmax(0,1fr);gap:22px;align-items:start}.dl-invite img{display:block;width:100%;border-radius:18px;box-shadow:0 0 0 1px var(--dl-line)}.dl-invite-side{display:flex;flex-direction:column;gap:14px;min-width:0}.dl-invite-side>p{margin:0!important}.dl-invite-link{all:unset;box-sizing:border-box;cursor:pointer;display:flex;align-items:center;gap:10px;min-width:0;padding:11px 14px;border-radius:12px;background:var(--dl-soft);font:13px/18px var(--dl-mono);color:var(--dl-fg)}.dl-invite-link>span:first-child{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-invite-link>.dl-icon-wrap{flex:none;display:inline-flex}.dl-invite-link .dl-icon{width:15px;height:15px;color:var(--dl-fg-muted);flex:none}.dl-invite-link:hover{background:var(--dl-soft-hover)}.dl-invite-link.alt{padding:8px 14px;font-size:12px;color:var(--dl-fg-muted)}.dl-invite-link>.dl-pill{flex:none}.dl-invite-steps{margin:0;padding-left:20px;list-style:decimal!important;font-size:13px;line-height:24px;color:var(--dl-fg-muted)}.dl-invite-steps b{color:var(--dl-fg);font-weight:500}.dl-invite-steps li{display:list-item!important;list-style:inherit!important;padding-left:4px}.dl-invite-actions{display:flex;gap:8px;flex-wrap:wrap}.modal:has(.dl-modal.wide){max-width:min(760px,94vw)!important;width:100%!important}@media(max-width:640px){.dl-invite{grid-template-columns:minmax(0,1fr)}.dl-invite img{max-width:260px;margin:0 auto}}.dl-toasts{position:fixed;left:50%;bottom:max(24px,env(safe-area-inset-bottom));transform:translate(-50%);z-index:100000;display:flex;flex-direction:column;align-items:center;gap:8px;pointer-events:none}.dl-toast{pointer-events:auto;display:inline-flex;align-items:center;gap:8px;max-width:min(520px,92vw);padding:10px 16px;border-radius:999px;background:var(--dl-fg);color:var(--dl-card);font-size:13px;line-height:18px;box-shadow:0 10px 30px #0000004d;opacity:0;transform:translateY(12px);transition:opacity .18s,transform .18s}.dl-toast.show{opacity:1;transform:none}.dl-toast .dl-icon-wrap{display:inline-flex}.dl-toast .dl-icon{width:15px;height:15px}.dl-toast.success .dl-icon{color:var(--dl-ok)}.dl-toast.error{background:var(--dl-bad);color:#fff}.dl-toast.error .dl-icon{color:#fff}.dl-toast.warning{background:var(--dl-warn);color:#111}.dl-toast.warning .dl-icon{color:#111}.dl-toast button{all:unset;cursor:pointer;display:inline-flex;margin-left:4px;opacity:.8}.dl-toast button:hover{opacity:1}';var ii=".dl-setblock{display:flex;flex-direction:column;gap:8px;margin:0}.dl-addr-opts{display:flex;flex-direction:column;gap:6px}.dl-addr-opt{all:unset;box-sizing:border-box;cursor:pointer;display:grid;grid-template-columns:16px minmax(0,1fr) auto;gap:12px;align-items:center;padding:10px 14px;border-radius:12px;box-shadow:inset 0 0 0 1px var(--dl-line);min-width:0}.dl-addr-opt:hover{background:var(--dl-soft)}.dl-addr-opt.on{box-shadow:inset 0 0 0 1.5px var(--dl-accent);background:color-mix(in srgb,var(--dl-accent) 7%,transparent)}.dl-addr-opt .dl-mono{font-size:13px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-addr-opt .dl-stack{min-width:0}.dl-addr-opt input{width:100%}.dl-addr-opt.other{cursor:default}.dl-addr-opt.other:hover{background:none}.dl-addr-opt.other input{width:100%}.dl-addr-check{width:16px;height:16px;border-radius:5px;box-shadow:inset 0 0 0 1.5px var(--dl-fg-faint);display:inline-flex;align-items:center;justify-content:center}.dl-addr-check .dl-icon-wrap{display:inline-flex}.dl-addr-check .dl-icon{width:12px;height:12px}.dl-addr-opt.on .dl-addr-check{background:var(--dl-accent);box-shadow:none;color:#fff}.dl-addr-opt.other .dl-addr-check{box-shadow:none;color:var(--dl-fg-muted)}.dl-addr-warn{display:inline-flex;align-items:center;gap:5px;font-size:12px;line-height:17px;color:var(--dl-warn)}.dl-addr-warn .dl-icon-wrap{display:inline-flex}.dl-addr-warn .dl-icon{width:13px;height:13px}.dl-pill.info{background:color-mix(in srgb,var(--dl-accent) 14%,transparent);color:var(--dl-accent)}.dl-links{border-radius:12px;background:var(--dl-soft);overflow:hidden}.dl-link-row{display:grid;grid-template-columns:18px minmax(0,1fr) auto;gap:10px;align-items:center;padding:11px 14px}.dl-link-row+.dl-link-row{border-top:1px solid var(--dl-line)}.dl-link-ic{display:inline-flex}.dl-link-ic .dl-icon{width:15px;height:15px}.dl-link-ic.ok .dl-icon{color:var(--dl-ok)}.dl-link-ic.warn .dl-icon{color:var(--dl-warn)}.dl-link-url{font-size:13px;color:var(--dl-fg-muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-link-url b{font-weight:500;color:var(--dl-accent)}@media(max-width:640px){.dl-link-url,.dl-addr-opt .dl-mono,.dl-filecard .dl-ellipsis,.dl-invite-link>span:first-child{white-space:normal;overflow-wrap:anywhere}}.dl-ready-sum{display:flex;align-items:center;gap:12px;padding:12px 14px;border-radius:12px}.dl-ready-sum>.dl-icon-wrap{display:inline-flex}.dl-ready-sum>.dl-icon-wrap .dl-icon{width:18px;height:18px}.dl-ready-sum .dl-stack{flex:1;min-width:0}.dl-ready-sum b{font-weight:500;font-size:13px}.dl-ready-sum.ok{background:var(--dl-ok-wash)}.dl-ready-sum.ok b,.dl-ready-sum.ok .dl-icon{color:var(--dl-ok)}.dl-ready-sum.warn{background:var(--dl-warn-wash)}.dl-ready-sum.warn b,.dl-ready-sum.warn .dl-icon{color:var(--dl-warn)}.dl-ready-sum.error{background:var(--dl-bad-wash)}.dl-ready-sum.error b,.dl-ready-sum.error .dl-icon{color:var(--dl-bad)}.dl-check-chip{display:inline-flex;align-items:center;gap:5px;height:26px;padding:0 10px;border-radius:999px;background:var(--dl-soft);font-size:12px;color:var(--dl-fg-muted)}.dl-check-chip .dl-icon-wrap{display:inline-flex}.dl-check-chip .dl-icon{width:13px;height:13px;color:var(--dl-ok)}.dl-check-chip.warn{background:var(--dl-warn-wash);color:var(--dl-warn)}.dl-check-chip.warn .dl-icon{color:var(--dl-warn)}.dl-check-chip.error{background:var(--dl-bad-wash);color:var(--dl-bad)}.dl-check-chip.error .dl-icon{color:var(--dl-bad)}.dl-ready-details{display:flex;flex-direction:column;gap:8px;padding:4px 2px}.dl-ready-details[hidden]{display:none}.dl-ready-item{display:flex;align-items:flex-start;gap:8px;font-size:13px;line-height:18px;min-width:0}.dl-ready-item .dl-icon-wrap{display:inline-flex;margin-top:1px}.dl-ready-item .dl-icon{width:15px;height:15px}.dl-ready-item.ok .dl-icon{color:var(--dl-ok)}.dl-ready-item.warn .dl-icon{color:var(--dl-warn)}.dl-ready-item.error .dl-icon{color:var(--dl-bad)}.dl-params-body{display:flex;flex-direction:column;gap:14px;padding:6px 14px 14px}.dl-params-body>.dl-setrow{margin:0;padding:0}.dl-pgrid.flush{padding:0;grid-template-columns:repeat(2,minmax(0,1fr))}@media(max-width:640px){.dl-pgrid.flush{grid-template-columns:minmax(0,1fr)}}.dl-qr-pane{display:flex;flex-direction:column;align-items:center;gap:8px;text-align:center}.dl-qr{width:min(280px,72vw);aspect-ratio:1;background:#fff;padding:8px;border-radius:12px;box-shadow:inset 0 0 0 1px var(--dl-line)}.dl-qr svg{display:block;width:100%;height:100%}.dl-filecard{display:flex;align-items:center;gap:12px;padding:12px;border-radius:14px;background:var(--dl-soft);min-width:0}.dl-filecard>.dl-stack{flex:1;min-width:0}.dl-filecard-ic{width:40px;height:46px;border-radius:8px;flex:none;display:inline-flex;align-items:center;justify-content:center;font:10px var(--dl-mono);color:var(--dl-fg-muted);background:var(--dl-card);box-shadow:inset 0 0 0 1px var(--dl-line)}.dl-params>.dl-conf{margin:0;border-top:1px solid var(--dl-line);border-radius:0 0 12px 12px;background:none}.dl-conf-sec{color:var(--dl-accent)}.dl-conf-k{color:var(--dl-fg-faint)}.dl-conf-mask{padding:0 6px;border-radius:4px;background:var(--dl-soft);color:var(--dl-fg-muted)}.dl-params>summary .dl-chipbtn{height:26px;font-size:12px}.dl-conf{white-space:pre-wrap;word-break:break-all;max-height:22em;overflow:auto;font-family:var(--dl-mono);font-size:12px;line-height:18px;margin:0;padding:12px;border-radius:12px;background:var(--dl-soft)}.dl-key{width:100%;box-sizing:border-box;font-family:var(--dl-mono);font-size:12px;word-break:break-all;min-height:7em}.dl-actions{display:flex;align-items:center;gap:6px;flex-wrap:wrap;margin:12px 0 0}.dl-link-box{display:flex;gap:6px;align-items:center;flex-wrap:wrap}.dl-link-box input{flex:1 1 18em;min-width:0;font-family:var(--dl-mono);font-size:12px}.dl-hint{font-size:12px;line-height:16px;color:var(--dl-fg-muted);margin:8px 0}.dl-divider{border:0;border-top:1px solid var(--dl-line);margin:16px 0}";var si=".dl-checks{list-style:none;margin:0;padding:0}.dl-checks li{display:flex;align-items:center;gap:12px;padding:12px 0;border-top:1px solid var(--dl-line)}.dl-checks li:first-child{border-top:0;padding-top:0}.dl-checks li:last-child{padding-bottom:0}.dl-check-icon{flex:0 0 auto;width:28px;height:28px;border-radius:50%;display:inline-flex;align-items:center;justify-content:center}.dl-check-icon .dl-icon{width:14px;height:14px}.dl-check-icon.ok{background:var(--dl-ok-wash);color:var(--dl-ok)}.dl-check-icon.warn{background:var(--dl-warn-wash);color:var(--dl-warn)}.dl-check-icon.error{background:var(--dl-bad-wash);color:var(--dl-bad)}.dl-check-icon.skip{background:var(--dl-soft);color:var(--dl-fg-faint)}.dl-check-body{flex:1;min-width:0}.dl-check-title{font-size:14px;line-height:20px;font-weight:500}.dl-check-detail{font-size:12px;line-height:16px;color:var(--dl-fg-muted);overflow-wrap:anywhere}.dl-check-repaired{margin-top:2px;font-size:12px;line-height:16px;color:var(--dl-warn)}.dl-wd{margin:0 0 16px;display:flex;flex-direction:column;gap:14px}.dl-wd-head{display:flex;align-items:center;gap:12px;min-width:0}.dl-wd-head>.dl-stack{min-width:0}.dl-wd-title{font-size:16px;line-height:24px;font-weight:500}.dl-wd-tile{flex:none;width:36px;height:36px;border-radius:10px;display:inline-flex;align-items:center;justify-content:center;background:var(--dl-ok-wash);color:var(--dl-ok)}.dl-wd-tile.off{background:var(--dl-soft);color:var(--dl-fg-faint)}.dl-wd-tile .dl-icon{width:18px;height:18px}.dl-wd-foot{display:flex;align-items:center;flex-wrap:wrap;gap:8px 16px;padding-top:14px;border-top:1px solid var(--dl-line)}.dl-wd-chips{display:flex;flex-wrap:wrap;gap:6px;flex:1 1 auto;min-width:0}.dl-wd-chips .dl-check-chip.error .dl-icon{color:var(--dl-bad)}.dl-warn-text{color:var(--dl-warn)!important}.dl-health-cols{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(440px,100%),1fr));gap:16px;align-items:start}.dl-health-cols>.dl-panel{margin:0;min-width:0}.dl-recent{display:flex;flex-direction:column}.dl-recent .dl-panel-head a{font-size:13px}.dl-recent-empty{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:10px;padding:32px 16px;color:var(--dl-fg-muted);font-size:13px;border-top:1px solid var(--dl-line)}.dl-loading{margin:0;font-size:13px}.dl-diag-tabs{margin:0 0 16px}.dl-row.dl-slog-row{align-items:baseline}.dl-slog-row .dl-ev-tile{align-self:flex-start;margin-top:-1px}.dl-slog-row.has-detail{cursor:pointer}.dl-row.dl-slog-row.has-detail:hover{background:color-mix(in srgb,var(--sys) 11%,transparent)}.dl-slog-more{display:inline-flex;vertical-align:-2px;margin-left:6px;color:var(--dl-fg-faint);transform:rotate(90deg);transition:transform .15s}.dl-slog-more .dl-icon{width:14px;height:14px}.dl-slog-more.open{transform:rotate(-90deg)}.dl-slog-detail{margin:8px 0 2px;padding:8px 10px;border-radius:8px;background:var(--dl-soft);font-family:var(--dl-mono);font-size:12px;line-height:17px;white-space:pre-wrap;overflow-wrap:anywhere;color:var(--dl-fg-muted);cursor:text}.dl-table{width:100%;border-collapse:collapse;font-size:14px;line-height:20px}.dl-table th{text-align:left;font-weight:500;color:var(--dl-fg-faint);padding:0 8px 8px;border-bottom:1px solid var(--dl-line)}.dl-table td{padding:10px 8px;border-bottom:1px solid var(--dl-line);vertical-align:middle}.dl-table th:first-child,.dl-table td:first-child{padding-left:0}.dl-table th:last-child,.dl-table td:last-child{padding-right:0}.dl-table tr:last-child td{border-bottom:0}.dl-table .dl-right{text-align:right;white-space:nowrap}.dl-log{max-height:18em;overflow:auto;font-family:var(--dl-mono);font-size:12px;line-height:18px;margin:8px 0 0;padding:12px;white-space:pre-wrap;border-radius:12px;background:var(--dl-soft)}";var li=".dl-pagehead{display:flex;align-items:flex-end;justify-content:space-between;gap:16px;flex-wrap:wrap;margin:0 0 20px}.dl-h1{margin:0!important;padding:0!important;font-size:24px!important;line-height:32px!important;font-weight:500!important;border:0!important}.dl-title-row{display:flex;align-items:center;gap:10px;flex-wrap:wrap}.dl-stack{display:flex;flex-direction:column;gap:2px;min-width:0}.dl-stack.gap4{gap:4px}.dl-stack.gap8{gap:8px}.dl-sub{font-size:12px;line-height:16px;color:var(--dl-fg-muted)}.dl-ok{color:var(--dl-ok)}.dl-warn{color:var(--dl-warn)}.dl-bad{color:var(--dl-bad)}.dl-icon-only{width:auto!important;min-width:0!important;aspect-ratio:1 / 1;padding:0!important;justify-content:center;display:inline-flex!important;align-items:center;border-radius:999px!important}.dl-panel.flush{padding:0;overflow:hidden}.dl-panel-head.pad{padding:16px 16px 12px;margin:0}.dl-col{display:flex;flex-direction:column;gap:16px;min-width:0}.dl-col>.dl-panel,.dl-col>section.dl-panel{margin:0}.dl-crumbs{display:flex;gap:8px;align-items:center;font-size:14px;margin:0 0 16px;color:var(--dl-fg-faint)}.dl-crumbs a{color:var(--dl-fg-faint)}.dl-crumbs a:hover{color:var(--dl-fg)}.dl-crumbs span:last-child{color:var(--dl-fg)}.dl-metrics{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));background:var(--dl-card);border:1px solid var(--dl-line);border-radius:var(--dl-radius);margin:0 0 16px;box-shadow:var(--dl-shadow)}.dl-metric{display:flex;flex-direction:column;gap:4px;padding:16px 20px;min-width:0}.dl-metric+.dl-metric{border-left:1px solid var(--dl-line)}.dl-metric-label{font-size:12px;font-weight:500;color:var(--dl-fg-faint)}.dl-metric-value{font-size:28px;line-height:36px;font-weight:500;letter-spacing:-.01em;font-variant-numeric:tabular-nums;white-space:nowrap}.dl-metric-value .dl-faint{font-size:16px}.dl-metric-sub{font-size:12px;color:var(--dl-fg-muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}@media(max-width:900px){.dl-metrics{grid-template-columns:repeat(2,minmax(0,1fr))}.dl-metric:nth-child(3){border-left:0}.dl-metric:nth-child(n+3){border-top:1px solid var(--dl-line)}}.dl-seg{display:inline-flex;gap:2px;padding:3px;border-radius:999px;background:var(--dl-soft);flex-wrap:wrap}.dl-seg button{all:unset;cursor:pointer;display:inline-flex;align-items:center;gap:6px;padding:4px 12px;border-radius:999px;font-size:13px;font-weight:500;color:var(--dl-fg-muted);white-space:nowrap}.dl-seg button:hover{color:var(--dl-fg)}.dl-seg button.on{background:var(--dl-soft-hover);color:var(--dl-fg)}.dl-seg.dl-srvsections{flex-wrap:nowrap;max-width:100%;overflow-x:auto;scrollbar-width:none}.dl-seg.dl-srvsections::-webkit-scrollbar{display:none}.dl-seg.dl-srvsections button{flex:none;white-space:nowrap}.dl-seg button:focus-visible{outline:2px solid var(--dl-ring)}.dl-seg button b{font-weight:500;font-size:11px;padding:0 6px;border-radius:999px;background:var(--dl-soft)}.dl-seg button b.warn{background:var(--dl-warn-wash);color:var(--dl-warn)}.dl-seg.sm button{padding:2px 9px;font-size:11px}.dl-seg.wide{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));border-radius:12px;padding:4px}.dl-seg.wide button{flex-direction:column;justify-content:center;padding:8px 6px;border-radius:9px;gap:3px}.dl-seg.wide button.on{background:var(--dl-primary);color:var(--dl-primary-fg)}";var di=`.dl-geomap{position:relative;border-top:1px solid var(--dl-line);background:transparent}.dl-map-status{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;color:var(--dl-fg-muted);font-size:13px;z-index:1;pointer-events:none}.dl-map-wrap{position:relative}.dl-map-legend{position:absolute;left:12px;bottom:12px;display:flex;gap:12px;align-items:center;padding:6px 12px;border-radius:999px;font-size:12px;background:color-mix(in srgb,var(--dl-card) 88%,transparent);border:1px solid var(--dl-line);backdrop-filter:blur(6px);z-index:2}.dl-map-legend span{display:inline-flex;align-items:center;gap:6px;color:var(--dl-fg-muted)}.dl-map-legend i.line{width:14px;height:0;border-top:2px dashed #8a8a8a}.dl-map-legend i.line.live{border-top-color:#3b82f6}.dl-map-off{padding:32px 16px;text-align:center;color:var(--dl-fg-muted);border-top:1px solid var(--dl-line)}.dl-mk{all:unset;cursor:pointer;position:relative;display:flex;align-items:center;justify-content:center;transition:opacity .2s}.dl-mk-hub{position:relative;display:flex;align-items:center;justify-content:center}.dl-mk-host{box-sizing:border-box;width:40px;height:40px;border-radius:11px;display:flex;align-items:center;justify-content:center;background:color-mix(in srgb,var(--dl-elevated) 60%,transparent);border:1px solid var(--dl-line);backdrop-filter:blur(6px);box-shadow:0 6px 16px #00000059}.dl-mk-host-tile{width:26px;height:26px;border-radius:7px;display:flex;align-items:center;justify-content:center;background:var(--dl-fg);color:var(--background, var(--dl-elevated))}.dl-mk-host-ic{width:14px;height:14px}.dl-mk-av{position:relative;box-sizing:border-box;width:28px;height:28px;border-radius:50%;display:flex;align-items:center;justify-content:center;font-size:10px;font-weight:500;line-height:1;border:2px solid #8a8a8a;background:var(--dl-elevated);color:var(--dl-fg-muted);transition:box-shadow .2s}.dl-mk.online .dl-mk-av{border-color:#3b82f6;background:color-mix(in srgb,#3b82f6 22%,var(--dl-elevated));color:var(--dl-fg)}.dl-mk-badge{position:absolute;left:16px;bottom:-6px;height:16px;min-width:16px;padding:0 3px;border-radius:8px;border:2px solid var(--dl-elevated);background:#6b6b6b;color:#fff;display:flex;align-items:center;justify-content:center;gap:1px;font-size:9px;font-weight:600;white-space:nowrap;box-sizing:content-box}.dl-mk.online .dl-mk-badge{background:#3b82f6}.dl-mk-badge-ic{width:10px;height:10px;stroke-width:2.2}.dl-mk-badge:has(>svg:only-child){width:16px;min-width:0;padding:0}.dl-mk-tile{position:relative;width:26px;height:26px;border-radius:7px;display:flex;align-items:center;justify-content:center;background:color-mix(in srgb,var(--dl-fg) 18%,var(--dl-elevated));color:var(--dl-fg)}.dl-mk.place.online .dl-mk-tile{background:#3b82f6;color:#fff;box-shadow:0 2px 8px #3b82f659}.dl-mk-tile-ic{width:14px;height:14px}.dl-mk-tile-n{position:absolute;right:-5px;top:-5px;min-width:14px;height:14px;padding:0 3px;box-sizing:border-box;border-radius:7px;background:var(--dl-fg);color:var(--dl-elevated);font-size:9px;font-weight:600;line-height:14px;text-align:center}.dl-mk-when{display:block;text-align:center;color:var(--dl-fg-faint);font-weight:400}.dl-mk.place.online .dl-mk-when{color:#3b82f6}.dl-mk-tile.sm{width:18px;height:18px;border-radius:5px;font-size:9px;font-weight:600}.dl-dmap{border:1px solid var(--dl-line);border-radius:12px;overflow:hidden}.dl-dmap .dl-geomap{border-top:0}.dl-dplaces{display:flex;flex-direction:column;margin-top:4px}.dl-dplace-row{display:flex;align-items:center;gap:10px;padding:9px 2px;border-top:1px solid var(--dl-line);font-size:13px}.dl-dplace-row:first-child{border-top:0}.dl-dplace-n{flex:0 0 auto;width:20px;height:20px;border-radius:5px;display:flex;align-items:center;justify-content:center;font-size:10px;font-weight:600;background:color-mix(in srgb,var(--dl-fg) 18%,var(--dl-elevated));color:var(--dl-fg)}.dl-dplace-n.live{background:#3b82f6;color:#fff}.dl-dplace-n .dl-icon{width:12px;height:12px}.dl-dplace-now{color:#3b82f6}.dl-dplaces.strips .dl-dplace-row{position:relative;display:grid;grid-template-columns:20px minmax(0,1fr) auto;column-gap:10px;row-gap:9px;margin:0 -10px;padding:11px 10px;border-top:0;border-radius:10px;transition:background .15s}.dl-dplaces.strips .dl-dplace-row+.dl-dplace-row:before{content:"";position:absolute;left:10px;right:10px;top:0;height:1px;background:var(--dl-line)}.dl-dplaces.strips .dl-dplace-row:is(:hover,.cur){background:var(--dl-soft)}.dl-dplaces.strips .dl-dplace-row:is(:hover,.cur):before,.dl-dplaces.strips .dl-dplace-row:is(:hover,.cur)+.dl-dplace-row:before{opacity:0}.dl-dplace-strip{grid-column:2 / 4;position:relative;height:6px;border-radius:3px;background:var(--dl-track)}.dl-dplaces.can-replay .dl-dplace-strip{cursor:ew-resize;touch-action:none}.dl-dplace-strip i{position:absolute;top:0;bottom:0;min-width:2px;border-radius:2px;background:#8a8a8a}.dl-dplace-strip.live i{background:#3b82f6}.dl-dplaces.replay .dl-dplace-strip:after{content:"";position:absolute;left:var(--at);top:-4px;bottom:-4px;width:2px;margin-left:-1px;border-radius:1px;background:var(--dl-fg);box-shadow:0 0 0 2px var(--dialog-bg, var(--dl-elevated));pointer-events:none}.dl-dplace-axis{position:relative;height:16px;margin:4px 0 0 30px;font-size:11px;line-height:16px;color:var(--dl-fg-faint)}.dl-dplace-axis span{position:absolute;top:0;transform:translate(-50%);white-space:nowrap}.dl-dmap{position:relative}.dl-map-replay{position:absolute;left:10px;top:10px;z-index:3;display:flex;align-items:center;gap:6px}.dl-map-btn{all:unset;box-sizing:border-box;cursor:pointer;width:28px;height:28px;border-radius:8px;display:inline-flex;align-items:center;justify-content:center;background:var(--dl-elevated);border:1px solid var(--dl-line);color:var(--dl-fg)}.dl-map-btn:hover{background:color-mix(in srgb,var(--dl-fg) 8%,var(--dl-elevated))}.dl-map-btn:focus-visible{outline:2px solid var(--dl-ring)}.dl-map-btn .dl-icon{width:13px;height:13px}.dl-map-chip{display:inline-flex;align-items:center;height:28px;box-sizing:border-box;padding:0 10px;border-radius:8px;font-size:11.5px;white-space:nowrap;background:var(--dl-elevated);border:1px solid var(--dl-line);color:var(--dl-fg);font-variant-numeric:tabular-nums}.dl-mk.step .dl-mk-tile{transition:width .3s cubic-bezier(.2,.8,.2,1),height .3s cubic-bezier(.2,.8,.2,1),border-radius .3s,background-color .3s,color .3s,box-shadow .3s,transform .24s}.dl-mk.step .dl-mk-tile.sm .dl-mk-tile-ic{width:11px;height:11px}.dl-mk.step.faded>*{opacity:.5}.dl-mk.step:is(.online,.hl){z-index:2}.dl-mk.step.hl .dl-mk-tile{box-shadow:0 0 0 3px color-mix(in srgb,#3b82f6 55%,transparent)}.dl-mk.step.arrive .dl-mk-tile{animation:dl-mk-arrive .45s cubic-bezier(.2,.8,.2,1)}@keyframes dl-mk-arrive{0%{transform:scale(.8)}55%{transform:scale(1.12)}to{transform:scale(1)}}.dl-mk-when.inline{display:inline}.dl-mk>*{transition:opacity .15s;opacity:var(--dl-mk-fade, 1)}.dl-mk.merged,.dl-mk.piled{pointer-events:none}.dl-mk.dl-mk-new>*{transition:none}.dl-mk.merged>*,.dl-mk.piled>*{opacity:0}.dl-mk-hub{cursor:default}.dl-mk-host{position:relative}.dl-mk-host{transition:border-radius .22s ease,border-right-color .22s ease}.dl-mk-host.docked{border-top-right-radius:0;border-bottom-right-radius:0;border-right-color:transparent}.dl-mk-dock{position:absolute;left:100%;top:-1px;height:40px;box-sizing:border-box;display:flex;align-items:center;gap:6px;padding:0 10px 0 2px;border:1px solid var(--dl-line);border-left:0;border-radius:0 11px 11px 0;background:color-mix(in srgb,var(--dl-elevated) 60%,transparent);backdrop-filter:blur(6px);box-shadow:0 6px 16px #00000059;pointer-events:none;opacity:0;clip-path:inset(-24px 100% -24px 0);transition:clip-path .28s cubic-bezier(.2,.8,.2,1),opacity .2s ease}.dl-mk-host.docked .dl-mk-dock{pointer-events:auto;opacity:1;clip-path:inset(-24px -24px -24px 0)}.dl-mk-new .dl-mk-host,.dl-mk-new .dl-mk-dock{transition:none}.dl-mk-pile{position:relative;display:flex;justify-content:center}.dl-mk-pile-box{box-sizing:border-box;height:40px;display:flex;align-items:center;gap:6px;padding:0 10px 0 6px;border-radius:20px;cursor:zoom-in;background:color-mix(in srgb,var(--dl-elevated) 60%,transparent);border:1px solid var(--dl-line);backdrop-filter:blur(6px);box-shadow:0 6px 16px #00000059;animation:dl-plate-in .26s cubic-bezier(.2,.8,.2,1) both;transition:opacity .18s ease,transform .18s ease}.dl-mk-pile.out{pointer-events:none}.dl-mk-pile.out>*{opacity:0;transform:scale(.85);transition:opacity .18s ease,transform .18s ease}@keyframes dl-plate-in{0%{opacity:0;transform:scale(.85)}}.dl-mk-face{all:unset;position:relative;display:flex;cursor:pointer;transition:transform .18s ease,opacity .18s ease}.dl-mk-face>.dl-mk-badge{position:relative;left:auto;bottom:-8px;margin-left:-12px;align-self:center}.dl-mk-face.on .dl-mk-av{border-color:#3b82f6;background:color-mix(in srgb,#3b82f6 22%,var(--dl-elevated));color:var(--dl-fg)}.dl-mk-face.on .dl-mk-badge{background:#3b82f6}.dl-mk-face:hover .dl-mk-av{box-shadow:0 0 0 4px #3b82f640}.dl-mk-face.in{animation:dl-dock-in .24s cubic-bezier(.2,.8,.2,1) both}.dl-mk-face.out{transform:scale(.4);opacity:0;pointer-events:none}@keyframes dl-dock-in{0%{transform:scale(.4);opacity:0}}.dl-mk-more{font-size:11px;font-weight:600;color:var(--dl-fg-muted)}.dl-mk-av,.dl-mk-tile{transition:box-shadow .2s,transform .24s cubic-bezier(.2,.8,.2,1)}.dl-mk.merged .dl-mk-av,.dl-mk.merged .dl-mk-tile,.dl-mk.piled .dl-mk-av{transform:scale(.5)}.dl-mk-host,.dl-mk-dock,.dl-mk-pile-box{transition-property:border-radius,border-right-color,clip-path,opacity,height,width,padding,gap}.dl-mk-dock,.dl-mk-pile-box{transition-duration:.22s;transition-timing-function:cubic-bezier(.2,.8,.2,1)}.dl-mk-pile-box{position:relative}.dl-mk-more{transition:transform .22s cubic-bezier(.2,.8,.2,1),opacity .18s ease}.dl-mk-more.in{animation:dl-dock-in .24s ease both}.dl-mk-more.out{transform:scale(.4);opacity:0}.dl-mk-face .dl-mk-av{transition:box-shadow .2s,transform .24s cubic-bezier(.2,.8,.2,1),width .2s ease,height .2s ease,font-size .2s ease}.dl-mk-face{transition:transform .22s cubic-bezier(.2,.8,.2,1),opacity .18s ease,margin .2s ease}.dl-mk-face>.dl-mk-badge{max-width:48px;overflow:hidden;transition:opacity .2s ease,transform .2s ease,max-width .22s ease,margin .22s ease,padding .22s ease,border-width .22s ease,height .22s ease,min-width .22s ease,width .22s ease,bottom .22s ease}.dl-lod-far .dl-mk-host{width:32px;height:32px;border-radius:9px}.dl-lod-far .dl-mk-host.docked{border-radius:9px 0 0 9px}.dl-lod-far .dl-mk-host-tile{width:20px;height:20px;border-radius:6px}.dl-lod-far .dl-mk-host-ic{width:11px;height:11px}.dl-lod-far .dl-mk-dock{height:32px;gap:0;padding:0 4px 0 0;border-radius:0 9px 9px 0}.dl-lod-far .dl-mk-pile-box{height:32px;gap:0;padding:0 4px;border-radius:16px}.dl-lod-far .dl-mk-face+.dl-mk-face{margin-left:-6px}.dl-lod-far .dl-mk-face .dl-mk-av{width:22px;height:22px;font-size:8px;box-shadow:0 0 0 2px var(--dl-elevated)}.dl-lod-far .dl-mk-face>.dl-mk-badge{max-width:0;min-width:0;padding:0;margin-left:0;border-width:0;opacity:0;transform:scale(.5);pointer-events:none}.dl-lod-far .dl-mk-more{margin-left:4px;font-size:10px}.dl-mk-label{transition:opacity .2s ease}.dl-lod-far .dl-mk:not(.step) .dl-mk-label{opacity:0}.dl-lod-mid .dl-mk-host{width:36px;height:36px}.dl-lod-mid .dl-mk-dock,.dl-lod-mid .dl-mk-pile-box{height:36px}.dl-lod-mid .dl-mk-face .dl-mk-av{width:24px;height:24px;font-size:9px}.dl-lod-mid .dl-mk-face>.dl-mk-badge{height:12px;min-width:12px;margin-left:-10px;bottom:-7px}.dl-lod-mid .dl-mk-face>.dl-mk-badge:has(>svg:only-child){width:12px}.dl-lod-mid .dl-mk-face>.dl-mk-badge .dl-mk-badge-ic{width:8px;height:8px}@media(prefers-reduced-motion:reduce){.dl-mk-dock,.dl-mk-pile-box,.dl-mk-face,.dl-mk-av,.dl-mk-tile,.dl-mk.step .dl-mk-tile,.dl-mk-host,.dl-mk-face>.dl-mk-badge{transition:none;animation:none}}.dl-mk-hub:has(.dl-mk-host.docked) .dl-mk-host{cursor:zoom-in}.dl-mk-ptr{position:absolute;left:50%;top:50%;width:0;height:0;z-index:-1;pointer-events:none}.dl-mk-ptr .line{position:absolute;left:0;top:-.5px;height:1px;background:var(--dl-fg-faint);transform-origin:0 50%}.dl-mk-ptr .spot{position:absolute;left:-3.5px;top:-3.5px;width:7px;height:7px;border-radius:50%;box-sizing:border-box;border:1.5px solid #fff;background:#8a8a8a}.dl-mk.online .dl-mk-ptr .spot,.dl-mk.place.online .dl-mk-ptr .spot{background:#3b82f6}.dl-mk.dim>*{opacity:.18}.dl-mk.hl .dl-mk-av{box-shadow:0 0 0 4px #3b82f640}.dl-mk-label{position:absolute;left:50%;bottom:100%;margin-bottom:4px;transform:translate(-50%);white-space:nowrap;pointer-events:none;font-size:10px;line-height:14px;font-weight:500;color:var(--dl-fg)}.dl-mk-label.below{bottom:auto;top:100%;margin:4px 0 0}.dl-mk-label.chip{padding:2px 6px;border-radius:4px;font-size:11px;line-height:16px;font-weight:600;background:color-mix(in srgb,var(--background, var(--dl-card)) 80%,transparent);backdrop-filter:blur(8px)}.dl-geomap .maplibregl-ctrl-bottom-right .maplibregl-ctrl-attrib.maplibregl-compact{margin:0 10px 10px 0;min-height:28px;padding:0;border-radius:8px;background:var(--dl-elevated);border:1px solid var(--dl-line);color:var(--dl-fg-muted);box-shadow:none;font-size:11px;line-height:26px}.dl-geomap .maplibregl-ctrl-bottom-right .maplibregl-ctrl-attrib.maplibregl-compact:not(.maplibregl-compact-show){width:28px;height:28px;box-sizing:border-box}.dl-geomap .maplibregl-ctrl-bottom-right .maplibregl-ctrl-attrib.maplibregl-compact.maplibregl-compact-show{padding:0 32px 0 10px}.dl-geomap .maplibregl-ctrl-attrib a{color:var(--dl-fg-muted)}.dl-geomap .maplibregl-ctrl-attrib-button{top:0;right:0;width:26px;height:26px;margin:0;border-radius:8px;background:none}.dl-geomap .maplibregl-ctrl-attrib-button:after{content:"";position:absolute;inset:5px;background:var(--dl-fg);-webkit-mask:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill-rule='evenodd' d='M12 2a10 10 0 1 1 0 20 10 10 0 0 1 0-20Zm-1.2 8.2h2.4V17h-2.4v-6.8ZM12 6a1.4 1.4 0 1 0 0 2.8A1.4 1.4 0 0 0 12 6Z'/%3E%3C/svg%3E") center / contain no-repeat;mask:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill-rule='evenodd' d='M12 2a10 10 0 1 1 0 20 10 10 0 0 1 0-20Zm-1.2 8.2h2.4V17h-2.4v-6.8ZM12 6a1.4 1.4 0 1 0 0 2.8A1.4 1.4 0 0 0 12 6Z'/%3E%3C/svg%3E") center / contain no-repeat}.dl-geomap .maplibregl-ctrl-attrib-button:focus{outline:none;box-shadow:none}.dl-geomap .maplibregl-ctrl-attrib-button:focus-visible{outline:2px solid var(--dl-ring)}.dl-map-card{position:absolute;right:12px;top:12px;z-index:3;min-width:200px;max-width:260px;padding:10px 12px;border-radius:10px;font-size:12px;line-height:20px;background:var(--dl-elevated);color:var(--dl-fg);border:1px solid var(--dl-line);box-shadow:var(--shadow-xl, 0 8px 16px -4px rgba(0,0,0,.4));opacity:0;transition:opacity .2s;pointer-events:none}.dl-map-card.on{opacity:1}.dl-map-card-head b{font-weight:500}.dl-map-card-row{display:flex;justify-content:space-between;gap:12px;white-space:nowrap}.dl-popcard{position:fixed;z-index:2100;width:max-content;max-width:300px;padding:12px;border-radius:12px;box-sizing:border-box;background:var(--dl-elevated);color:var(--dl-fg);border:1px solid var(--dl-line);box-shadow:var(--shadow-xl, 0 8px 16px -4px rgba(0,0,0,.4))}.dl-popcard.away{visibility:hidden}.dl-popcard.leaving{pointer-events:none}.dl-popcard-tip{position:absolute;left:var(--tip-x, 50%);width:10px;height:10px;margin-left:-6px;box-sizing:border-box;background:var(--dl-elevated);border:solid var(--dl-line);transform:rotate(45deg)}.dl-popcard.above .dl-popcard-tip{bottom:-6px;border-width:0 1px 1px 0}.dl-popcard.below .dl-popcard-tip{top:-6px;border-width:1px 0 0 1px}.dl-popcard.above{transform-origin:var(--tip-x, 50%) 100%}.dl-popcard.below{transform-origin:var(--tip-x, 50%) 0}@media(prefers-reduced-motion:no-preference){.dl-popcard{animation:dl-pop-in .16s ease-out}.dl-popcard.leaving{animation:dl-pop-out .14s ease-in forwards}}@keyframes dl-pop-in{0%{opacity:0;transform:scale(.94)}to{opacity:1;transform:none}}@keyframes dl-pop-out{0%{opacity:1;transform:none}to{opacity:0;transform:scale(.94)}}.dl-pop{display:flex;flex-direction:column;gap:4px;font-size:12px;line-height:18px;min-width:210px}.dl-pop-head{display:flex;align-items:center;gap:8px;font-size:13px;margin-bottom:2px}.dl-pop-net{width:30px;height:30px;border-radius:9px;background:var(--dl-soft);display:inline-flex;align-items:center;justify-content:center;flex:0 0 auto;color:var(--dl-fg-muted)}.dl-pop-list{display:flex;flex-direction:column;margin:6px 0 0;max-height:116px;overflow-y:auto}.dl-pop-row{all:unset;cursor:pointer;display:flex;align-items:center;gap:8px;padding:6px 8px;border-radius:8px}.dl-pop-row:hover{background:var(--dl-soft)}.dl-pop-row:focus{outline:none}.dl-pop-row:focus-visible{outline:2px solid var(--dl-ring)}.dl-pop-name{flex:1;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.dl-pop-name b{font-weight:500}.dl-pop-dot{width:6px;height:6px;border-radius:50%;background:var(--dl-fg-faint);flex:0 0 auto}.dl-pop-dot.on{background:var(--dl-ok);box-shadow:0 0 0 3px var(--dl-ok-wash)}.dl-pop-actions{display:flex;gap:6px;margin-top:8px;padding-top:8px;border-top:1px solid var(--dl-line)}.dl-pop-actions .cbi-button{flex:1;height:28px!important;font-size:12px!important;justify-content:center}.dl-chartbox{position:relative}.dl-bars{display:flex;align-items:flex-end;gap:4px;border-bottom:1px solid var(--dl-line)}.dl-bar{flex:1;height:100%;display:flex;flex-direction:column-reverse;gap:1px;cursor:default;min-width:3px}.dl-bar i{display:block;border-radius:3px 3px 0 0}.dl-bar i.down{background:var(--dl-chart-1)}.dl-bar i.up{background:var(--dl-chart-2);opacity:.75;border-radius:3px 3px 0 0}.dl-bar:hover i{filter:brightness(1.25)}.dl-bar.empty{background:linear-gradient(to top,var(--dl-line) 2px,transparent 2px)}.dl-tip{position:absolute;top:-8px;transform:translate(-50%,-100%);padding:8px 10px;border-radius:10px;font-size:12px;line-height:18px;white-space:nowrap;background:var(--dl-elevated);border:1px solid var(--dl-line);box-shadow:var(--shadow-xl, 0 8px 16px -4px rgba(0,0,0,.4));pointer-events:none;z-index:3}.dl-tip-title{font-weight:500}.dl-tip-float{position:fixed;z-index:2000;color:var(--dl-fg)}.dl-spark i:hover{opacity:1;filter:brightness(1.25)}.dl-meter,.dl-slots{cursor:default}.dl-axis{display:flex;justify-content:space-between;font-size:12px;color:var(--dl-fg-faint);margin-top:6px}.dl-legend i.down{background:var(--dl-chart-1)}.dl-legend i.up{background:var(--dl-chart-2)}.dl-spark{display:flex;align-items:flex-end;gap:2px;flex:0 0 auto}.dl-spark i{flex:1;display:block;border-radius:2px 2px 0 0;background:var(--dl-chart-1);opacity:.85}.dl-spark i.zero{opacity:.22}`;var ci=`.dl-row{display:flex;align-items:center;gap:12px;padding:12px 16px;border-top:1px solid var(--dl-line);font-size:14px;line-height:20px;min-width:0}.dl-row.link{color:inherit;text-decoration:none}.dl-row.link:hover{background:var(--dl-soft)}.dl-row-main{flex:1;min-width:0;overflow-wrap:anywhere}.dl-row-main b{font-weight:500}.dl-attn{display:flex;flex-direction:column;gap:10px;padding:16px;border-top:1px solid var(--dl-line)}.dl-attn-item{display:flex;gap:10px;align-items:baseline;font-size:13px;color:var(--dl-fg-muted)}.dl-avatar.sm{width:26px;height:26px;font-size:10px;margin:0}.dl-avatar.lg{width:48px;height:48px;font-size:15px;margin:0}.dl-avatar.lg.online:after{width:12px;height:12px}.dl-list{border:1px solid var(--dl-line);border-radius:12px;overflow:hidden}.dl-list>.dl-row:first-child{border-top:0}.dl-ellipsis{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0}.dl-row-main.dl-stack{min-width:0}.dl-person-id{display:flex;align-items:center;gap:14px;min-width:0}.dl-grid-person{display:grid;grid-template-columns:minmax(0,1.7fr) minmax(0,1fr);gap:16px;align-items:start}@media(max-width:1000px){.dl-grid-person{grid-template-columns:minmax(0,1fr)}}.dl-devsec{display:flex;flex-direction:column;gap:12px}.dl-devsec .dl-panel-head{margin:0}.dl-dgrid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}.dl-dcard>.dl-dcard-head+*{margin-top:auto}@media(max-width:700px){.dl-dgrid{grid-template-columns:minmax(0,1fr)}}.dl-dgrid>.dl-dslot.add:only-child{grid-column:1 / -1}.dl-dcard{background:var(--dl-card);border:1px solid var(--dl-line);border-radius:14px;padding:14px;display:flex;flex-direction:column;gap:12px;min-width:0;box-shadow:var(--dl-shadow)}.dl-dcard.online{border-color:color-mix(in srgb,var(--dl-ok) 35%,transparent)}.dl-dcard.off{opacity:.7}.dl-dcard-head{display:flex;align-items:center;gap:12px}.dl-dcard-ic{width:40px;height:40px;border-radius:12px;background:var(--dl-soft);display:inline-flex;align-items:center;justify-content:center;flex:0 0 auto;color:var(--dl-fg-muted)}.dl-dcard-ic .dl-icon{width:20px;height:20px}.dl-dcard.online .dl-dcard-ic{background:var(--dl-ok-wash);color:var(--dl-ok)}.dl-dcard-title{all:unset;cursor:pointer;flex:1;min-width:0;display:flex;flex-direction:column}.dl-dcard-title b{font-weight:500;font-size:15px}.dl-dstat{display:inline-flex;align-items:center;gap:6px;font-size:12px;color:var(--dl-fg-muted);white-space:nowrap;min-width:0}.dl-dstat i.dot{flex:none}.dl-dstat.ok{color:var(--dl-ok)}.dl-dstat.warn{color:var(--dl-warn)}.dl-dstat i.dot,.dl-savebar i.dot{width:6px;height:6px;border-radius:50%;background:var(--dl-fg-faint)}.dl-dstat i.dot.ok{background:var(--dl-ok);box-shadow:0 0 0 3px var(--dl-ok-wash)}.dl-dstat i.dot.warn{background:var(--dl-warn)}.dl-dcard-use{display:flex;align-items:flex-end;justify-content:space-between;gap:12px}.dl-dcard-foot{padding-top:10px;border-top:1px solid var(--dl-line);font-size:11px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.dl-dslot.add{all:unset;box-sizing:border-box;cursor:pointer;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:10px;padding:14px;min-height:0;border:1px dashed color-mix(in srgb,currentColor 18%,transparent);border-radius:14px;text-align:center;color:var(--dl-fg-muted);transition:background .15s,border-color .15s,color .15s}.dl-dslot.add .dl-stack{align-items:center}.dl-dslot.add:hover{border-color:color-mix(in srgb,currentColor 35%,transparent);color:var(--dl-fg)}.dl-dslot.add:focus-visible{outline:2px solid var(--dl-ring);outline-offset:2px}.dl-dslot.add b{font-weight:500}.dl-dslot.add:hover{background:var(--dl-soft)}.dl-dslot-ic{width:36px;height:36px;border-radius:999px;background:var(--dl-soft);display:inline-flex;align-items:center;justify-content:center;flex:0 0 auto;color:var(--dl-fg-muted)}.dl-dslot.add:hover .dl-dslot-ic{background:var(--dl-primary);color:var(--dl-primary-fg)}.dl-tiles2{display:grid;gap:10px;margin-top:16px}.dl-tile2{border:1px solid var(--dl-line);border-radius:14px;padding:14px;display:flex;flex-direction:column;gap:10px;min-width:0}.dl-tile2-label{display:flex;align-items:center;justify-content:space-between;gap:8px;font-size:12px;font-weight:500;color:var(--dl-fg-faint)}.dl-tile2-row{display:flex;align-items:center;justify-content:space-between;gap:10px;flex-wrap:wrap}.dl-tile2-value{font-size:20px;line-height:28px;font-weight:500;letter-spacing:-.01em;font-variant-numeric:tabular-nums}.dl-tile2-value .dl-faint{font-size:14px;font-weight:400}.dl-tile2-foot{display:flex;align-items:center;justify-content:space-between;gap:12px;padding-top:10px;border-top:1px solid var(--dl-line);font-size:12px}.dl-stepper{display:inline-flex;align-items:stretch;height:32px;border:1px solid var(--input, var(--dl-line));border-radius:8px;overflow:hidden}.dl-stepper button{all:unset;cursor:pointer;width:32px;display:inline-flex;align-items:center;justify-content:center;font-size:16px;color:var(--dl-fg)}.dl-stepper button:hover{background:var(--dl-soft)}.dl-stepper button[disabled]{opacity:.35;cursor:not-allowed}.dl-stepper+.dl-stepper{margin-left:4px}.dl-step-select{border:0!important;border-left:1px solid var(--input, var(--dl-line))!important;border-right:1px solid var(--input, var(--dl-line))!important;border-radius:0!important;background:transparent!important;color:inherit;font:500 13px inherit;padding:0 10px!important;height:100%!important;min-width:0!important}.dl-slots{display:grid;grid-auto-flow:column;grid-auto-columns:minmax(0,1fr);gap:3px}.dl-slots i{height:4px;border-radius:999px;background:var(--dl-track);display:block}.dl-slots i.used{background:var(--dl-fg)}.dl-slots i.over{background:color-mix(in srgb,var(--dl-warn) 80%,transparent)}.dl-date{display:flex;align-items:center;gap:8px;flex:1 1 150px;min-width:0;box-sizing:border-box;height:34px;padding:0 10px;border:1px solid var(--input, var(--dl-line));border-radius:8px;color:var(--dl-fg-faint)}.dl-date input{border:0!important;background:transparent!important;box-shadow:none!important;padding:0!important;height:32px!important;color:var(--dl-fg);flex:1;min-width:0!important;width:100%!important}.dl-meter{position:relative;height:6px;border-radius:999px;background:var(--dl-track)}.dl-meter>i{display:block;height:100%;border-radius:999px;background:var(--dl-accent)}.dl-meter.warn>i{background:var(--dl-warn)}.dl-meter.bad>i{background:var(--dl-bad)}.dl-meter .mark{position:absolute;left:90%;top:-3px;width:1px;height:12px;background:var(--dl-warn)}.dl-meter.sm{height:4px}.dl-chips-row{display:flex;flex-wrap:wrap;gap:4px}.dl-chipbtn{all:unset;cursor:pointer;height:26px;padding:0 10px;border-radius:999px;background:var(--dl-soft);font-size:12px;font-weight:500;display:inline-flex;align-items:center}.dl-chipbtn:hover{background:var(--dl-soft-hover)}.dl-chipbtn.on{background:var(--dl-primary);color:var(--dl-primary-fg)}.dl-switch{all:unset;cursor:pointer;position:relative;width:32px;height:20px;border-radius:999px;background:var(--switch-off, var(--dl-track));flex:0 0 auto;transition:background .15s}.dl-switch i{position:absolute;left:2px;top:2px;width:16px;height:16px;border-radius:50%;background:#fff;transition:left .15s;box-shadow:0 1px 2px #0000004d}.dl-switch.on{background:var(--dl-accent)}.dl-switch.on i{left:14px}.dl-switch:focus-visible{outline:2px solid var(--dl-ring);outline-offset:2px}.dl-linkbox{display:flex;align-items:center;gap:8px;height:36px;padding:0 4px 0 12px;border:1px solid var(--input, var(--dl-line));border-radius:8px;background:var(--input-bg, transparent)}.dl-linkbox .dl-mono{flex:1;min-width:0;font-size:12px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;color:var(--dl-fg-muted)}.dl-linkbox .cbi-button{height:28px!important}.dl-pcard{display:grid;grid-template-columns:minmax(0,1fr) 260px;gap:20px;align-items:stretch;min-width:0}.dl-pcard-main{min-width:0}.dl-pcard-top{display:flex;align-items:center;gap:12px;min-width:0}.dl-pcard-top .dl-avatar{margin-right:0}.dl-pcard-who{flex:1;min-width:0}.dl-pcard-who .dl-slotbar{margin:3px 0 0}.dl-pside{display:flex;flex-direction:column;justify-content:space-between;gap:8px;padding-left:20px;border-left:1px solid var(--dl-line);min-width:0}.dl-pside-top{display:flex;align-items:center;justify-content:space-between;gap:8px}.dl-pside-state{display:inline-flex;align-items:center;gap:6px;font-size:13px;color:var(--dl-fg-muted)}.dl-pside-state.live{color:var(--dl-ok)}.dl-pside-foot{font-size:12px}.dl-pside .dl-use-num b{font-size:20px}.dl-none{display:none!important}.dl-pcard-actions{display:flex;gap:6px;flex:0 0 auto}.dl-pcard-actions .cbi-button{height:32px!important}.dl-icon-only .dl-btn-label{display:none}.dl-pill-ic{display:inline-flex;align-items:center;gap:4px;height:22px;padding:0 8px;border-radius:999px;font-size:12px;white-space:nowrap;background:var(--dl-soft);color:var(--dl-fg-muted)}.dl-pill-ic .dl-icon{width:12px;height:12px}.dl-pill-ic.warn{background:var(--dl-warn-wash);color:var(--dl-warn)}.dl-pill-ic.bad{background:var(--dl-bad-wash);color:var(--dl-bad)}.dl-use-num{display:flex;align-items:baseline;gap:6px;white-space:nowrap}.dl-use-num b{font-size:15px;font-weight:500}.dl-use-live{display:flex;align-items:center;gap:8px;font-size:12px;font-variant-numeric:tabular-nums}.dl-usebar{display:flex;gap:2px;height:6px;border-radius:999px;overflow:hidden;background:var(--dl-track)}.dl-usebar i{display:block;height:100%;min-width:3px;flex:0 1 0}.dl-usebar i.fill{flex:none;min-width:0;border-radius:999px;background:var(--dl-accent)}.dl-usebar.warn i.fill{background:var(--dl-warn)}.dl-usebar.bad i.fill{background:var(--dl-bad)}.dl-usebar .c0,.dl-swatch.c0{background:var(--dl-chart-1)}.dl-usebar .c1,.dl-swatch.c1{background:#8b7cf6}.dl-usebar .c2,.dl-swatch.c2{background:#2fb889}.dl-usebar .c3,.dl-swatch.c3{background:#d9a03f}.dl-usebar .c4,.dl-swatch.c4{background:var(--dl-fg-faint)}.dl-tip-row{display:flex;align-items:center;gap:8px;min-width:160px}.dl-tip-row b{margin-left:auto;font-weight:500}.dl-swatch{width:8px;height:8px;border-radius:2px;flex:none}.dl-card-name{color:var(--dl-fg)!important;text-decoration:none}.dl-card-name:hover{text-decoration:underline}.dl-chip-tag{font-size:11px;line-height:18px;padding:0 6px;border-radius:999px;background:var(--dl-warn-wash);color:var(--dl-warn)}.dl-chip.live{background:var(--dl-ok-wash);color:color-mix(in srgb,var(--dl-ok) 35%,var(--dl-fg))}.dl-chip.live:hover{background:color-mix(in srgb,var(--dl-ok) 22%,transparent)}.dl-chip.live .dl-icon{color:var(--dl-ok)}.dl-fixes{display:flex;gap:6px;flex-wrap:wrap;margin:10px 0 0 44px}.dl-fix{all:unset;cursor:pointer;height:26px;padding:0 10px;border-radius:999px;background:var(--dl-info-wash);color:var(--dl-info);font-size:12px;font-weight:500;display:inline-flex;align-items:center}.dl-fix:hover{filter:brightness(1.15)}@media(max-width:760px){.dl-pcard{grid-template-columns:1fr}.dl-pside{padding:12px 0 0;border-left:0;border-top:1px solid var(--dl-line)}.dl-fixes{margin-left:0}}.dl-select{height:34px!important;border-radius:999px!important;min-width:136px!important;width:auto!important;padding:0 34px 0 14px!important;appearance:none!important;-webkit-appearance:none!important;background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238b8f98' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E")!important;background-repeat:no-repeat!important;background-position:right 12px center!important;background-size:14px!important}.dl-savebar{position:fixed;left:50%;bottom:24px;transform:translate(-50%,160%);opacity:0;transition:transform .25s cubic-bezier(.2,.8,.2,1),opacity .2s;display:flex;align-items:center;gap:10px;padding:8px 8px 8px 18px;border-radius:999px;background:var(--dl-elevated);border:1px solid var(--dl-line);box-shadow:var(--shadow-2xl, 0 16px 32px -8px rgba(0,0,0,.5));z-index:60;pointer-events:none}.dl-savebar.show{transform:translate(-50%);opacity:1;pointer-events:auto}.dl-savebar-text{display:inline-flex;align-items:center;gap:8px;font-size:13px;font-weight:500}`;var pi=".dl-toast strong{display:block;font-weight:500}.dl-toast div{opacity:.8;font-size:13px}.dl-drawer-overlay{position:fixed;inset:0;z-index:900;display:flex;justify-content:flex-end;background:transparent;transition:background .2s}.dl-drawer-overlay.open{background:var(--scrim, rgba(0,0,0,.45))}.dl-drawer{width:min(520px,100%);height:100%;display:flex;flex-direction:column;background:var(--dialog-bg, var(--dl-elevated));color:var(--dl-fg);border-left:1px solid var(--dl-line);box-shadow:var(--shadow-2xl, -16px 0 32px -8px rgba(0,0,0,.5));transform:translate(100%);transition:transform .22s cubic-bezier(.2,.8,.2,1)}.dl-drawer-overlay.open .dl-drawer{transform:none}.dl-drawer-head{display:flex;align-items:center;gap:12px;padding:16px 20px;border-bottom:1px solid var(--dl-line)}.dl-drawer-title{flex:1;min-width:0;display:flex;align-items:center;gap:12px}.dl-drawer-title h3{margin:0!important;padding:0!important;border:0!important;font-size:18px!important;line-height:26px;font-weight:500!important}.dl-drawer-x{all:unset;cursor:pointer;width:32px;height:32px;border-radius:50%;display:inline-flex;align-items:center;justify-content:center;color:var(--dl-fg-muted)}.dl-drawer-x:hover{background:var(--dl-soft);color:var(--dl-fg)}.dl-drawer-body{flex:1;overflow:auto;padding:20px}.dl-drawer-foot{padding:12px 20px;border-top:1px solid var(--dl-line)}.dl-drawer-actions{display:flex;align-items:center;gap:8px}.dl-dcard-ic.on{background:var(--dl-ok-wash);color:var(--dl-ok)}.dl-icon-only.sm{width:28px;height:28px!important}.dl-stack.gap12{gap:12px}.dl-stack.gap16{gap:16px}.dl-dstats{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));border:1px solid var(--dl-line);border-radius:14px;overflow:hidden}.dl-dstats-cell{display:flex;flex-direction:column;gap:4px;padding:12px 14px;min-width:0}.dl-dstats-cell.wide{grid-column:span 2;border-bottom:1px solid var(--dl-line)}.dl-dstats-cell+.dl-dstats-cell:not(.wide):last-child{border-left:1px solid var(--dl-line)}.dl-dstats-cell b{font-size:16px;font-weight:500;font-variant-numeric:tabular-nums}.dl-dstats-cell .dl-dstat{font-size:14px}.dl-dsec{border:1px solid var(--dl-line);border-radius:14px;padding:16px;display:flex;flex-direction:column;gap:12px}.dl-dsec-head{display:flex;align-items:center;justify-content:space-between;gap:12px}.dl-dsec-head h4{margin:0!important;padding:0!important;font-size:14px!important;font-weight:500!important;border:0!important}.dl-dstat i.dot{width:6px;height:6px;border-radius:50%;background:var(--dl-fg-faint);display:inline-block}.dl-connect-body{min-height:60px}.dl-connect-body .dl-qr{width:min(240px,70vw)}.dl-kv2{display:flex;flex-direction:column}.dl-kvrow{display:flex;align-items:center;justify-content:space-between;gap:16px;padding:9px 0;border-top:1px solid var(--dl-line);font-size:13px;min-width:0}.dl-kvrow:first-child{border-top:0;padding-top:0}.dl-kvrow-k{color:var(--dl-fg-muted);flex:0 0 auto}.dl-kvrow-v{min-width:0;text-align:right;overflow-wrap:anywhere}.dl-kvrow-v.copy{all:unset;cursor:pointer;display:inline-flex;align-items:center;gap:6px;min-width:0;color:var(--dl-fg)}.dl-kvrow-v.copy span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-kvrow-v.copy .dl-icon{width:13px;height:13px;color:var(--dl-fg-faint)}.dl-kvrow-v.copy:hover .dl-icon{color:var(--dl-fg)}@media(max-width:560px){.dl-drawer{width:100%}.dl-dstats{grid-template-columns:minmax(0,1fr)}.dl-dstats-cell.wide{grid-column:auto}.dl-dstats-cell+.dl-dstats-cell:not(.wide):last-child{border-left:0;border-top:1px solid var(--dl-line)}}.dl-dev-log{display:flex;flex-direction:column}.dl-dev-log-row{display:flex;align-items:center;gap:10px;padding:8px 0;border-top:1px solid var(--dl-line);font-size:13px;line-height:20px;min-width:0}.dl-dev-log-row:first-child{border-top:0;padding-top:0}.dl-dev-log-row .dl-row-main{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}";var mi=".dl-settings-main{min-width:0;display:flex;flex-direction:column;gap:20px}.dl-setsec{background:var(--dl-card);border:1px solid var(--dl-line);border-radius:var(--dl-radius);overflow:hidden;scroll-margin-top:88px;box-shadow:var(--dl-shadow)}.dl-setsec-body{padding:20px;display:flex;flex-direction:column;gap:14px}.dl-setsec-body h3{margin:0!important;padding:0!important;font-size:18px!important;line-height:26px;font-weight:500!important;border:0!important}.dl-setsec-body p{margin:0}.dl-setsec-head{display:flex;align-items:center;gap:10px}.dl-group{border:1px solid var(--dl-line);border-radius:14px;padding:2px 16px}.dl-group-head{display:flex;align-items:center;gap:12px;padding:14px 0 10px}.dl-group-head b{font-size:15px;font-weight:500}.dl-group-ic{width:32px;height:32px;border-radius:10px;background:var(--dl-soft);color:var(--dl-fg-muted);display:inline-flex;align-items:center;justify-content:center;flex:none}.dl-group-ic .dl-icon-wrap{display:inline-flex}.dl-group-ic .dl-icon{width:16px;height:16px}.dl-group-body>*{padding:12px 0;margin:0!important}.dl-group-body>*+*:not(.alert-message):not(.dl-params){border-top:1px solid var(--dl-line)}.dl-group-body>.alert-message,.dl-group-body>.dl-params{margin:12px 0!important}.dl-group-body>.alert-message{padding:10px 14px}.dl-group-body>.dl-params{padding:0}.dl-group-body>.alert-message+*,.dl-group-body>.dl-params+*{border-top:0}.dl-group-body>.dl-row{border-left:0;border-right:0;border-bottom:0;padding-left:0;padding-right:0;background:none}.dl-group-body>.dl-row:first-child{border-top:0}.dl-setsec-foot{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:10px 16px;padding:12px 20px;border-top:1px solid var(--dl-line);background:var(--dl-soft)}.dl-setsec.danger{border-color:color-mix(in srgb,var(--dl-bad) 40%,transparent)}.dl-setsec.danger .dl-setsec-foot{background:color-mix(in srgb,var(--dl-bad) 6%,transparent)}.dl-setrow{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,420px);align-items:center;gap:8px 24px}.dl-setrow.head{display:flex;justify-content:space-between;gap:16px}.dl-setrow-label{font-size:14px;font-weight:500}.dl-setrow-ctl{display:flex;justify-content:flex-end;min-width:0}.dl-setrow-ctl .dl-chips-row{justify-content:flex-end}.dl-setrow-ctl>input{width:100%}.dl-hostport{display:flex;align-items:center;gap:8px;flex:1;min-width:0;justify-content:flex-end}.dl-hostport input{flex:1;min-width:0}.dl-root input.dl-w-port,.dl-hostport input.dl-w-port{flex:0 0 90px;width:90px}.dl-root input.dl-w-range{flex:0 0 130px;width:130px}.dl-setrow .dl-sub.bad{color:var(--dl-bad)}.dl-suffixed{display:inline-flex;align-items:center;gap:6px}.dl-suffixed>span{color:var(--dl-fg-muted)}.dl-more summary{cursor:pointer;color:var(--dl-fg-muted);font-size:13px;margin-bottom:10px}.dl-more .dl-setrow+.dl-setrow{margin-top:10px}@media(max-width:760px){.dl-setrow:not(.head){grid-template-columns:minmax(0,1fr)}.dl-setrow-ctl,.dl-setrow-ctl .dl-chips-row{justify-content:flex-start}}.dl-need-ic{width:30px;height:30px;border-radius:9px;background:var(--dl-soft);color:var(--dl-fg-muted);display:inline-flex;align-items:center;justify-content:center;flex:none}.dl-need-ic .dl-icon-wrap{display:inline-flex}.dl-need-ic .dl-icon{width:15px;height:15px}.dl-need-row.bad .dl-need-ic,.dl-need-ic.bad{background:var(--dl-bad-wash);color:var(--dl-bad)}.dl-need-row.warn .dl-need-ic,.dl-need-ic.warn{background:var(--dl-warn-wash);color:var(--dl-warn)}.dl-need-ic.ok{background:var(--dl-ok-wash);color:var(--dl-ok)}.dl-lh-main{display:flex;align-items:flex-start;gap:12px;min-width:0}.dl-lh-main>.dl-need-ic{margin-top:1px}.dl-sub .dl-mono{font-size:.92em}.dl-need-row>.cbi-button{flex:none}.dl-bk-row .dl-group-ic{width:30px;height:30px}.dl-bk-older>summary{list-style:none;cursor:pointer;display:flex;align-items:center;gap:8px;padding:11px 16px;border-top:1px solid var(--dl-line);font-size:13px;color:var(--dl-fg-muted);user-select:none}.dl-bk-older>summary::-webkit-details-marker{display:none}.dl-bk-older>summary:hover{background:var(--dl-soft);color:var(--dl-fg)}.dl-bk-older>summary .dl-icon-wrap{display:inline-flex;transition:transform .15s}.dl-bk-older>summary .dl-icon{width:14px;height:14px}.dl-bk-older[open]>summary .dl-icon-wrap{transform:rotate(90deg)}#dl-set-backups .dl-setsec-head h3+.dl-sub{margin-top:2px}#dl-set-backups .dl-setsec-foot>.dl-sub{flex:1 1 260px}.dl-bk-actions{flex:0 1 auto;justify-content:flex-end}@media(max-width:640px){#dl-set-backups .dl-setsec-foot>.dl-sub{flex-basis:100%}.dl-bk-actions{justify-content:flex-start}}.dl-upd{display:flex;flex-direction:column;gap:16px}.dl-upd>.dl-pagehead{margin:0 0 4px}.dl-upd-bad{color:var(--dl-bad)}";var hi=".dl-comp-hero{display:grid;grid-template-columns:minmax(0,1.5fr) minmax(0,1fr)}.dl-comp-hero-main{padding:20px;display:flex;flex-direction:column;gap:12px;min-width:0}.dl-comp-hero-side{padding:20px;border-left:1px solid var(--dl-line);display:flex;flex-direction:column;gap:14px;min-width:0}.dl-comp-name{font-size:16px;font-weight:500}.dl-comp-hero-head{display:flex;align-items:center;gap:10px;flex-wrap:wrap;min-width:0}.dl-comp-hero-head .dl-spacer{flex:1}.dl-comp-big{font-family:var(--dl-mono);font-size:26px;line-height:34px;letter-spacing:-.02em;display:flex;align-items:baseline;gap:10px}.dl-comp-big small{font-size:14px;color:var(--dl-accent)}.dl-comp-big small.dl-faint{color:var(--dl-fg-faint)}.dl-comp-verrow{display:flex;align-items:center;gap:4px 12px;flex-wrap:wrap;min-width:0}.dl-comp-verrow .dl-spacer{flex:1}.dl-comp-meta{font-size:13px}.dl-comp-bullets{margin:0;padding-left:18px;display:flex;flex-direction:column;gap:4px;color:var(--dl-fg-muted);font-size:13px}.dl-comp-bullets li{list-style:disc}.dl-comp-lead{margin:0}.dl-comp-more{align-self:flex-start;font-size:12px;color:var(--dl-fg-faint);margin-left:18px;padding:0!important}.dl-comp-more:hover{color:var(--dl-accent);background:none!important;text-decoration:underline;text-underline-offset:2px}.dl-comp-hero-main>.dl-comp-vers{margin-top:auto}.dl-comp-btns{display:flex;gap:8px;flex-wrap:nowrap;align-items:center;flex:none}.dl-comp-side-v{display:flex;align-items:center;gap:8px;font-size:14px;min-width:0;flex-wrap:wrap}.dl-comp-side-v .dl-icon{width:15px;height:15px;color:var(--dl-fg-muted)}.dl-comp-side-v a{color:inherit;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-comp-side-v a:hover{color:var(--dl-accent)}.dl-comp-cols{display:grid;grid-template-columns:minmax(0,1.5fr) minmax(0,1fr);gap:16px;align-items:start}.dl-comp-cols>.dl-panel>div>.dl-row:first-child{border-top:1px solid var(--dl-line)}.dl-comp-count{font-size:13px}.dl-comp-sub{font-size:11px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-comp-ic{display:inline-flex;gap:4px;flex:none}.dl-comp-ic .cbi-button{width:30px;height:30px;padding:0!important;justify-content:center;border-radius:999px!important}.dl-comp-ic .dl-btn-label{display:none}.dl-comp-ic .dl-icon{width:14px;height:14px}.dl-comp-ic .is-busy{pointer-events:none;opacity:.5}.dl-comp-ic .cbi-button.dl-comp-check{width:auto;padding:0 12px 0 10px!important;gap:6px;display:inline-flex;align-items:center;font-size:13px}.dl-row>.dl-pill,.dl-row>.cbi-button,.dl-row>.dl-comp-ic{flex:none}button.dl-pill.dl-comp-run{all:unset;display:inline-flex;align-items:center;height:20px;padding:0 8px;border-radius:999px;font-size:12px;cursor:pointer;background:color-mix(in srgb,var(--dl-accent) 14%,transparent);color:var(--dl-accent)}.dl-comp-foldwrap{padding:0 16px 14px 60px}.dl-comp-fold .dl-params-body{gap:12px}.dl-comp-fold .dl-list>.dl-row{padding:10px 14px}.dl-comp-bver{font-size:12px;width:130px;text-align:right;flex:none;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-comp-bact{width:84px;flex:none;display:flex;justify-content:flex-end}.dl-comp-warn{display:flex;align-items:flex-start;gap:8px;font-size:12px;line-height:18px;color:var(--dl-fg-muted)}.dl-comp-warn .dl-icon-wrap{display:inline-flex;flex:none;margin-top:2px}.dl-comp-warn .dl-icon{width:14px;height:14px;color:var(--dl-warn)}.dl-comp-empty{margin:0;padding:4px 16px 16px}@media(max-width:760px){.dl-comp-hero,.dl-comp-cols{grid-template-columns:minmax(0,1fr)}.dl-comp-hero-side{border-left:0;border-top:1px solid var(--dl-line)}.dl-comp-foldwrap{padding-left:16px}.dl-comp-bver{display:none}}.dl-comp-status{display:flex;align-items:center;gap:8px;font-size:13px;padding:9px 12px;border-radius:10px;background:var(--dl-soft);min-width:0}.dl-comp-status>.dl-icon-wrap{display:inline-flex;flex:none}.dl-comp-status .dl-icon{width:15px;height:15px}.dl-comp-status.ok{background:var(--dl-ok-wash);color:var(--dl-ok)}.dl-comp-status.acc{background:color-mix(in srgb,var(--dl-accent) 12%,transparent);color:var(--dl-accent)}.dl-comp-status.warn{background:var(--dl-warn-wash);color:var(--dl-warn)}.dl-comp-status.bad{background:var(--dl-bad-wash);color:var(--dl-bad)}.dl-comp-status b{font-weight:600}.dl-comp-vers .dl-params-body{gap:0;padding:4px 14px 12px}.dl-comp-tag{display:flex;gap:6px;padding:6px 0 10px}.dl-comp-tag input{flex:1;min-width:0}.dl-comp-ver{display:flex;align-items:center;gap:8px;padding:7px 0;border-top:1px solid var(--dl-line);font-size:13px}.dl-comp-ver .dl-mono{min-width:52px}.dl-comp-ver .dl-sub{flex:1}.dl-comp-ver .cbi-button:not(.dl-icon-btn){height:26px!important;font-size:12px!important}.dl-comp-pager{display:flex;align-items:center;justify-content:space-between;padding-top:10px;border-top:1px solid var(--dl-line);font-size:12px}.dl-comp-pager .dl-linkbtn[disabled]{opacity:.4;cursor:default}.dl-comp-vers .dl-loading,.dl-comp-vers .dl-params-body>p{padding:6px 0 10px}.dl-op-head{display:flex;align-items:center;gap:8px;flex-wrap:wrap;margin-bottom:14px}.dl-op-head .dl-spacer{flex:1}.dl-op-timer{display:inline-flex;align-items:center;gap:5px;font-variant-numeric:tabular-nums}.dl-op-timer .dl-icon,.dl-op-head .dl-linkbtn .dl-icon{width:14px;height:14px}.dl-op-loghead{display:flex;align-items:center;justify-content:space-between}.dl-op-loghead b{font-weight:500;font-size:13px}.dl-op .dl-log{max-height:16em;min-height:12em;margin-top:8px}.dl-op .dl-comp-status{margin:14px 0 0}.dl-op-actions{display:flex;gap:8px;justify-content:flex-end;flex-wrap:wrap;width:100%}.dl-notes{max-height:55vh;overflow:auto;border-radius:12px;background:var(--dl-soft);padding:14px 16px;font-size:13px;line-height:20px;overflow-wrap:anywhere}.dl-notes h5{margin:10px 0 6px;font-size:14px;font-weight:500}.dl-notes h5:first-child{margin-top:0}.dl-notes p{margin:0 0 8px}.dl-notes ul{margin:0 0 10px;padding-left:18px}.dl-notes li{list-style:disc}.dl-notes code{font-family:var(--dl-mono);font-size:12px;padding:1px 5px;border-radius:6px;background:var(--dl-soft-hover)}.dl-notes pre{font-family:var(--dl-mono);font-size:12px;padding:10px;border-radius:8px;background:var(--dl-soft-hover);white-space:pre-wrap;margin:0 0 10px}.dl-notes a{color:var(--dl-accent)}";var fi=".dl-chip.static{cursor:default}.dl-chip.static:hover{background:var(--dl-soft)}.dl-chip.static .dl-chip-name{font-weight:500}.dl-setrow.head .dl-chips-row{margin-top:8px}.dl-setrow.head>.dl-lh-main,.dl-setrow.head>.dl-lh-main>.dl-stack{flex:1 1 auto;min-width:0}.dl-setrow.head>.dl-setrow-ctl:empty{display:none}.dl-setrow.head:has(>.dl-lh-main){align-items:flex-start}.dl-setrow.head>.dl-setrow-ctl{align-items:center;min-height:30px}.dl-netpick{margin-top:10px}.dl-boxrow{display:flex;align-items:center;justify-content:space-between;gap:16px;margin:0;padding:10px 14px;border:1px solid var(--dl-line);border-radius:12px;font-size:13px;cursor:pointer}.dl-boxrow>.dl-switch{flex:none}.dl-ifpick{display:flex;flex-direction:column;gap:12px;padding:14px;border:1px solid var(--dl-line);border-radius:14px}.dl-iflead-row{display:flex;align-items:center;justify-content:space-between;gap:12px}.dl-host-ports{justify-content:flex-end}@media(max-width:760px){.dl-host-ports{justify-content:flex-start}}.dl-circle-dot{display:inline-block;width:8px;height:8px;border-radius:50%;flex:none}.dl-circles .dl-chip b{font-weight:500}.dl-circle-name{display:inline-flex;align-items:center;gap:8px;font-size:14px;font-weight:500}.dl-w400{font-weight:400}.dl-swatches{display:flex;flex-wrap:wrap;gap:8px}.dl-swatch{all:unset;cursor:pointer;width:22px;height:22px;border-radius:50%;background:var(--sw);box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--dl-fg) 12%,transparent)}.dl-swatch.on{box-shadow:0 0 0 2px var(--dl-card),0 0 0 4px var(--sw)}.dl-swatch:focus-visible{outline:2px solid var(--dl-ring);outline-offset:3px}.dl-circle-modal .dl-chipbtn b{margin-left:6px;font-weight:500;font-size:11px;opacity:.6}.dl-reach td:first-child b{font-weight:500}.dl-ev-host{white-space:nowrap}.dl-ev-host b{font-weight:500;color:var(--dl-fg)}.dl-reach{font-size:13px}.dl-reach th,.dl-reach td{white-space:nowrap;padding-left:6px;padding-right:6px}.dl-reach-wrap{overflow-x:auto}.dl-yes{display:inline-flex;align-items:center;gap:4px;color:var(--dl-ok)}.dl-yes .dl-icon-wrap{display:inline-flex}.dl-yes .dl-icon{width:14px;height:14px}.dl-check-form{display:grid;grid-template-columns:minmax(0,1fr) auto minmax(0,1fr) auto;align-items:start;gap:8px}.dl-check-form>.dl-faint{line-height:36px}.dl-check-end{display:flex;flex-direction:column;gap:6px;min-width:0}.dl-check-end>*{width:100%!important;min-width:0}@media(max-width:560px){.dl-check-form{grid-template-columns:minmax(0,1fr)}.dl-check-form>.dl-faint{display:none}}.dl-verdict{display:flex;align-items:baseline;gap:10px;padding:10px 12px;border-radius:12px}.dl-verdict b{font-weight:500}.dl-verdict.ok{background:var(--dl-ok-wash)}.dl-verdict.ok b{color:var(--dl-ok)}.dl-verdict.bad{background:var(--dl-bad-wash)}.dl-verdict.bad b{color:var(--dl-bad)}.dl-corehead{display:flex;align-items:center;gap:10px;flex-wrap:wrap;margin:0 0 4px}.dl-corehead h3{margin:0!important}.dl-row-end{display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap}.dl-dcard.clickable{cursor:pointer}.dl-dcard.clickable:hover{border-color:color-mix(in srgb,var(--dl-fg) 22%,transparent)}";var Cl=[ei,ti,ni,oi,ri,ai,ii,si,li,di,ci,pi,mi,hi,fi].join(` -`);function gi(){let n=document.createElement("style");return n.dataset.dawnline="1",n.textContent=Cl,n}function ht(n){return()=>{let e=new n;return Object.assign({load:()=>e.load(),render:async o=>{let a=await e.render(o),i=document.createElement("div");return i.className="dl-root",i.append(gi(),a),i},addFooter(){return e.noFooter?document.createElement("div"):this.super("addFooter",[])}},{handleSave:null,handleSaveApply:null,handleReset:null})}}var v1=ht(Zt),b1=ht(mt),x1=ht(Zt),w1=ht(Hn),y1=ht(Rn),k1=ht(jn),$1=ht(Nn);function vi(n){return()=>({load:()=>(ui.menu?.flushCache(),location.replace(`${L.url("admin/network/dawnline/diagnostics")}${n?`?tab=${n}`:""}`),new Promise(()=>{})),render:()=>document.createElement("div"),handleSave:null,handleSaveApply:null,handleReset:null})}var C1=vi(""),E1=vi("log");return baseclass.extend({ activity: E1, diagnostics: k1, health: C1, overview: v1, people: b1, person: y1, server: x1, settings: w1, updates: $1 }); +`).trim()}async function Zt(n,e,r,o){let a=t("div",{class:"dl-notes"},t("p",{class:"dl-muted dl-loading"},"Loading release notes…")),i=t("div",{class:"dl-op-head"}),s="";oe(r,[i,a],[D([v("copy")," Copy"],()=>me(s,"Release notes copied"))," ",ie("Close")],"wide");try{let l=await P.updatesNotes(n,e,o??"");s=Ma(l.body||"");let d=Ea(l.url);dom.content(i,[l.published?t("span",{class:"dl-pill"},Ue(l.published)):"",l.prerelease?t("span",{class:"dl-pill warn"},"Pre-release"):"",t("span",{class:"dl-spacer"}),d?t("a",{href:d,target:"_blank",rel:"noopener",class:"dl-linkbtn"},["On GitHub ",v("open")]):""]),dom.content(a,s.trim()?La(s):t("p",{class:"dl-muted"},"This release has no notes."))}catch(l){dom.content(a,t("p",{class:"dl-muted"},be(l)))}}var Sa={"6h":"every 6 h","12h":"every 12 h","1d":"daily","7d":"weekly"},Co=n=>n?Ue(n):"";function Js(n){let e=/^(.{20,}?)(?:;\s|:\s)/.exec(n)?.[1];return e||(n.length<=90?n:`${n.slice(0,90).replace(/[\s,;:]+\S*$/,"")}…`)}function _a(n,e){let r=n.st,o=r.policy,a=r.kept?.app,i=e?.update&&e.tag?e.tag:r.version,s=x=>()=>Zt("app",x,`What’s new in Dawnline ${x.replace(/^v/,"")}`),l=e?.tag&&(e.update||e.status==="latest")?Ys(n,e.tag,e.update?r.version:""):null,d=e?.tag??i,c=o.check&&r.auto?.check?r.auto.check+({"6h":6,"12h":12,"1d":24,"7d":168}[o.interval]??24)*3600:0,p=(x,$)=>t("div",{class:"dl-stack gap4"},[t("span",{class:"dl-metric-label"},x),t("span",{class:"dl-comp-side-v"},$)]),u=[{label:"What’s new",ic:"file",run:s(i)},{label:"Open on GitHub",ic:"globe",run:()=>window.open(`https://github.com/${r.repo}`,"_blank","noopener")},null,{label:`Reinstall ${r.version}`,ic:"reset",warn:!0,run:()=>n.op("app:reinstall","Reinstalling Dawnline",r.version)},a?{label:`Roll back to ${a.version}`,ic:"archive",warn:!0,run:async()=>{await se(`Roll back to Dawnline ${a.version}?`,`The copy kept on the router replaces ${r.version}. A backup of the settings is made first.`,"Roll back")&&n.op("app:rollback","Rolling back Dawnline",r.version)}}:null];return t("section",{class:"dl-panel flush dl-comp-hero"},[t("div",{class:"dl-comp-hero-main"},[t("div",{class:"dl-comp-hero-head"},[t("span",{class:"dl-group-ic"},v("sunrise")),t("b",{class:"dl-comp-name"},"Dawnline"),n.state("app",e,e?.latest??""),t("span",{class:"dl-spacer"}),n.round(()=>n.op("check:app","Checking Dawnline",r.version),u,!0)]),t("div",{class:"dl-comp-verrow"},[t("div",{class:"dl-stack"},[t("div",{class:"dl-comp-big"},[r.version,e?.update?t("small",{},`→ ${e.latest}`):e?.status==="dev"&&e.latest?t("small",{class:"dl-faint"},`release ${e.latest}`):""]),t("span",{class:"dl-faint dl-comp-meta"},e?.error?"":e?.update?e.published?`released ${Co(e.published)}`:"":e?.status==="dev"?"ahead of the latest release":e?`latest release${e.published?` · released ${Co(e.published)}`:""}`:"not checked yet")])]),l?.items.length?t("div",{class:"dl-stack gap4"},[t("ul",{class:"dl-comp-bullets"},l.items.map(x=>t("li",{},x))),l.total>l.items.length?t("button",{type:"button",class:"dl-linkbtn dl-comp-more",click:s(d)},`+${l.total-l.items.length} more in What’s new`):""]):"",e?.error?t("p",{class:"dl-sub dl-comp-lead dl-upd-bad"},e.error):"",e?.update?t("div",{class:"dl-comp-btns"},[D("Update now",()=>n.op("app","Updating Dawnline",r.version),"positive",{disabled:n.busy}),D("What’s new",s(i))]):"",Zs(n)]),t("div",{class:"dl-comp-hero-side"},[p("Source",[v("globe"),t("a",{href:`https://github.com/${r.repo}`,target:"_blank",rel:"noopener"},r.repo)]),p("Auto-update",[o.auto?Ee("ok","On"):Ee("","Off"),t("span",{class:"dl-muted"},o.auto?o.mode==="immediate"?"as soon as found":`${Sa[o.interval]==="weekly"?"weekly":"daily"} at ${o.time}`:o.check?`checks ${Sa[o.interval]}`:"checks off")]),p("Last check",r.check?[re(r.check.time,r.now),c>r.now?t("span",{class:"dl-faint"},`· next in ${xt(c-r.now)}`):""]:["Never"]),p("Rollback",a?[t("span",{class:"dl-mono"},a.version),t("span",{class:"dl-faint"},"kept on flash")]:[t("span",{class:"dl-muted"},o.keep?"Kept after the next update":"Off")])])])}function Ys(n,e,r){if(n.notes.has(e))return n.notes.get(e)??null;n.notes.set(e,null);let o=a=>a.replace(/\*\*|`|\[([^\]]+)\]\([^)]*\)/g,(i,s)=>s??"").trim();return(async()=>{let i=((await P.updatesNotes("app",e,"").catch(()=>null))?.body??"").split(` +`).map(l=>/^\s*[-*+]\s+(.*)$/.exec(l)?.[1]).filter(l=>!!l);i.length||(i=(await P.updatesChanges(r,e).catch(()=>null))?.items??[]);let s={items:i.slice(0,3).map(l=>Js(o(l))),total:i.length};n.notes.set(e,s),s.items.length&&n.root.isConnected&&n.paint()})(),null}function Zs(n){let e=t("div",{class:"dl-params-body"}),r=t("details",{class:"dl-params dl-comp-vers",open:n.versOpen?"open":null},[t("summary",{},[v("chevron"),t("span",{},"Versions"),t("span",{class:"dl-sub"},"install any release")]),e]);return r.addEventListener("toggle",()=>{n.versOpen=r.open,n.versOpen&&Nn(n,e)}),n.versOpen&&Nn(n,e),r}async function Nn(n,e){let r=le("",{placeholder:"Tag, e.g. 0.3.1",class:"cbi-input-text dl-mono","aria-label":"Release tag"}),o=p=>{if(p=p.trim(),!/^v?[0-9][0-9A-Za-z.+~-]{0,40}$/.test(p))return U("Enter a release tag like 0.3.1","warning");Ta(n,p)};r.addEventListener("keydown",p=>{p.key==="Enter"&&(p.preventDefault(),o(r.value))});let a=t("div",{class:"dl-comp-tag"},[r,D("Install",()=>o(r.value),"neutral",{disabled:n.busy})]),i=n.versPage,s=p=>{n.versPage=Math.max(1,n.versPage+p),Nn(n,e)},l=p=>t("div",{class:"dl-comp-pager"},[t("button",{type:"button",class:"dl-linkbtn",disabled:i<=1?"disabled":null,click:()=>s(-1)},"← Newer"),t("span",{class:"dl-faint"},`Page ${i}`),t("button",{type:"button",class:"dl-linkbtn",disabled:p?null:"disabled",click:()=>s(1)},"Older →")]),d=n.versCache.get(i);if(!d){dom.content(e,[a,t("p",{class:"dl-muted dl-loading"},"Loading versions…")]);try{d=(await P.updatesReleases(i)).releases}catch(p){if(i!==n.versPage||!e.isConnected)return;dom.content(e,[a,t("div",{class:"dl-row-actions"},[t("span",{class:"dl-muted"},`Failed to load versions: ${be(p)}`),D("Try again",()=>Nn(n,e))]),l(!1)]);return}if(n.versCache.set(i,d),i!==n.versPage||!e.isConnected)return}if(!d.length)return dom.content(e,[a,t("p",{class:"dl-muted"},i>1?"No more versions.":"No versions found."),l(!1)]);let c=n.st.version;dom.content(e,[a,...d.map(p=>{let u=p.tag.replace(/^v/,"");return t("div",{class:"dl-comp-ver"},[t("span",{class:"dl-mono"},u),t("span",{class:"dl-sub"},Co(p.published)),p.prerelease?Ee("warn","Pre-release"):"",t("span",{class:"dl-comp-ic"},Le("file","What’s new",()=>Zt("app",p.tag,`What’s new in Dawnline ${u}`))),u===c?Ee("ok","Installed"):D("Install",()=>Ta(n,p.tag),"neutral",{disabled:n.busy})])}),l(d.length>=5)])}async function Ta(n,e){let r=e.replace(/^v/,"");r.localeCompare(n.st.version,void 0,{numeric:!0})<0&&!await se(`Install Dawnline ${r}?`,`It is older than ${n.st.version}. A backup of the settings is made first; restore it from Settings if something looks wrong.`,"Install")||n.op(`app@${e}`,`Installing Dawnline ${r}`,n.st.version)}function Pa(n,e){let r=n.st,o=r.kept?.amneziawg,a=e?.sources??{},i=Object.keys(a),s=e?.current??null,l=s?a[s]:void 0,d=!!e?.ru,c=r.needs?.awg??[],p=c.length?null:e?.installed??null,u=[];s&&p&&u.push({label:"Reinstall this build",warn:!0,ic:"reset",run:()=>n.op(`amneziawg:${s}${d?":ru":""}`,"Reinstalling AmneziaWG",p)}),o&&u.push({label:`Roll back to ${o.version}`,ic:"archive",warn:!0,run:async()=>{await se(`Roll back AmneziaWG to ${o.version}?`,"The build kept on the router is installed again. Every AmneziaWG tunnel restarts for a few seconds.","Roll back")&&n.op("amneziawg:rollback","Rolling back AmneziaWG",p??void 0)}});let x=[e?.release?{label:"What’s new",ic:"file",run:()=>Zt("amneziawg",e.release,`What’s new in the ${l?.label??"AmneziaWG"} build`,s??"slava")}:null,{label:"Open on GitHub",ic:"globe",run:()=>window.open(`https://github.com/${l?.repo??"Slava-Shchipunov/awg-openwrt"}`,"_blank","noopener")},...u.length?[null,...u]:[]].filter((f,g,M)=>f!==null||g>0&&M[g-1]!==null),$=r.tunnels??[],h=$.length?`Switching restarts ${$.length===1?"the tunnel":`${$.length} tunnels`} for a few seconds: ${$.join(", ")}. Devices keep their configurations.`:"Switching takes a few seconds. Devices keep their configurations.",m=$.length>1?`${$.slice(0,-1).join(", ")} and ${$[$.length-1]}`:$[0],E=$.length?`Switching restarts ${m} for a few seconds.`:"Switching takes a few seconds.",R=async f=>{let g=a[f];await se(p?`Switch to AmneziaWG ${g.gen}?`:`Install AmneziaWG ${g.gen}?`,`The ${g.label} build, ${g.version}. ${h}${g.gen==="3.1"?" Devices need AmneziaVPN 3.1 or newer.":""}`,p?"Switch":"Install")&&n.op(`amneziawg:${f}${d?":ru":""}`,p?`Switching to AmneziaWG ${g.gen}`:"Installing AmneziaWG",p??void 0)},C=f=>{let g=a[f],M=s===f&&!!p;return t("div",{class:"dl-row"},[t("span",{class:"dl-row-main dl-stack"},[t("b",{},g.gen?`AmneziaWG ${g.gen}`:"AmneziaWG"),t("span",{class:"dl-sub"},`${g.label} · ${g.gen==="3.1"?"AmneziaVPN 3.1+":"every app"}`)]),t("span",{class:"dl-mono dl-faint dl-comp-bver"},g.version??"none yet"),t("span",{class:"dl-comp-bact"},M?Ee("ok","Active"):g.version?D(p?"Switch":"Install",()=>R(f),p?"neutral":"positive",{disabled:n.busy}):Ee("","No build"))])},k=i.map(f=>a[f]?.newer?`${a[f].label} moves to ${a[f].newer.gen} with OpenWrt ${a[f].newer.tag.replace(/^v/,"")}.`:"").filter(Boolean),y=ve(d,"Russian translation",f=>{s&&n.op(`amneziawg:${s}${f?":ru":""}`,f?"Adding the Russian translation":"Removing the Russian translation",p??void 0)});y.disabled=!s||!p||n.busy;let w=n.awgOpen??!p,b=t("details",{class:"dl-params dl-comp-fold",open:w?"open":null},[t("summary",{},[v("chevron"),t("span",{},"Build and translation")]),t("div",{class:"dl-params-body"},[t("div",{class:"dl-list"},[...i.length?i.map(C):[t("div",{class:"dl-row"},t("span",{class:"dl-sub"},"Check for updates to see the builds for this router."))],t("div",{class:"dl-row"},[t("span",{class:"dl-row-main dl-stack"},[t("b",{},"Russian translation"),t("span",{class:"dl-sub"},"LuCI pages for AmneziaWG")]),t("span",{class:"dl-comp-bact"},y)])]),p&&i.length||k.length?t("div",{class:`dl-comp-status ${p&&i.length?"warn":"acc"}`},[v(p&&i.length?"alert":"download"),t("span",{},[p&&i.length?t("b",{},E):"",...k.map(f=>` ${f}`)])]):""])]);b.addEventListener("toggle",()=>n.awgOpen=b.open);let H=[];return e?.update&&p&&s?H.push(D(`Update to ${e.latest}`,()=>n.op(`amneziawg:${s}${d?":ru":""}`,"Updating AmneziaWG",p),"neutral",{disabled:n.busy})):H.push((e||c.length)&&!p?Ee("warn","Not installed"):n.state("amneziawg",e,e?.latest??"")),H.push(n.round(()=>n.op("check:amneziawg","Checking AmneziaWG",p??void 0),x)),[n.row("shield","AmneziaWG",[p?`${p}${e?.release?` · ${e.release} build`:""}`:c.length?`missing ${c.join(", ")}`:e?"not installed":"version not checked"],H),t("div",{class:"dl-comp-foldwrap"},b)]}var Qs=[{title:"Home-like link",sub:"Policy routing and the veth pair",pkgs:["ip-full","kmod-veth"],feature:"home"},{title:"HTTPS for the portal",sub:"OpenSSL for uhttpd",pkgs:["libustream-openssl","openssl-util"],feature:"https"},{title:"Certificates (ACME)",sub:"Let’s Encrypt certificate for the portal",pkgs:["acme","acme-acmesh-dnsapi"],feature:"acme",optional:!0}],Eo={home:"network",https:"lock",acme:"file"};function Da(n,e){let r=n.st,o=e?.pkgs??{},a=Qs.filter(c=>c.feature==="home"?r.home:r.portal),i=async(c,p,u=c)=>{await se(`Update ${p}?`,`${u.join(", ")} from the OpenWrt feeds. Services that use them restart for a moment.`,"Update")&&n.op(`pkgs:${c.join(",")}`,`Updating ${p}`)},s=[{label:"Check system packages",ic:"refresh",run:()=>n.op("check:packages","Checking system packages")},{label:"Open the OpenWrt package list",ic:"globe",run:()=>window.open("https://openwrt.org/packages/start","_blank","noopener")}],l=0;return{rows:a.map(c=>{let p=c.pkgs.filter(m=>o[m]?.installed),u=[...new Set(p.flatMap(m=>[...o[m]?.latest?[m]:[],...o[m]?.with??[]]))],x=r.needs?.[c.feature]??c.pkgs.filter(m=>!o[m]?.installed),$=p.find(m=>o[m]?.latest),h=p.map(m=>`${m} ${o[m]?.installed??""}`).join(", ");return x.length?n.row(Eo[c.feature],c.title,[`${c.optional?"not installed":`missing ${x.join(", ")}`}`],[D("Install",()=>n.op(`pkgs:${x.join(",")}`,`Installing ${c.title}`),c.optional?"neutral":"positive",{disabled:n.busy}),t("span",{class:"dl-comp-ic"},n.more(s))]):e&&u.length?(l++,n.row(Eo[c.feature],c.title,$?[`${o[$].installed} → ${o[$].latest}`,u.length>1?` · +${u.length-1}`:""]:[u.join(", ")],[D("Update",()=>i(p.filter(m=>o[m]?.latest||o[m]?.with?.length),c.title,u),"neutral",{disabled:n.busy}),t("span",{class:"dl-comp-ic"},n.more(s))])):n.row(Eo[c.feature],c.title,[h||c.sub],[n.state("pkgs",e,""),t("span",{class:"dl-comp-ic"},n.more(s))])}),updates:l,total:a.length}}var Xs={app:"Dawnline",amneziawg:"AmneziaWG",pkgs:"System packages",all:"Components"};function Aa(n){let e=n.st,r=a=>{let i=at(a.component??"app"),s=Xs[i]??"Components",l=a.auto?"automatically":"by you",d="ok",c="check",p;if(a.kind==="found")d="accent",c="download",p=[t("b",{},(a.items??[]).join(", ")),` found by ${a.auto?"the automatic check":"a check"}`];else if(a.state==="failed")d="bad",c="x",p=[t("b",{},s),` ${a.kind==="install"?"update":"check"} failed${a.error?` · ${a.error}`:""}`];else{let u=a.from&&a.to&&a.from!==a.to?` ${a.from} → ${a.to}`:a.to?` ${a.to}`:"";p=[t("b",{},s),`${u} ${u?"":"updated "}${l}${a.took?` · ${xt(a.took)}`:""}`.replace(/\s+/g," ")]}return t("div",{class:"dl-row"},[t("span",{class:`dl-ev-tile ev ${d}`},v(c)),t("span",{class:"dl-row-main"},p),t("span",{class:"dl-faint dl-nowrap",title:new Date(a.ts*1e3).toLocaleString()},re(a.ts,e.now))])},o=e.history??[];return t("section",{class:"dl-panel flush"},[t("div",{class:"dl-panel-head pad"},[t("h3",{},"Activity"),t("span",{class:"dl-spacer"}),t("a",{href:`${L.url("admin/network/dawnline/diagnostics")}?tab=log`},"All in Log →")]),o.length?t("div",{},o.slice(0,8).map(r)):t("p",{class:"dl-sub dl-comp-empty"},"Updates, and checks that found something, show up here.")])}var Rn=class{constructor(){this.root=t("div",{class:"dl-upd"});this.following=null;this.versOpen=!1;this.versPage=1;this.versCache=new Map;this.notes=new Map;this.awgOpen=null}load(){return P.updatesStatus()}render(e){return this.st=e,this.paint(),e.job?.state==="running"&&this.follow(e.job),poll.add(async()=>{if(!this.root.isConnected)return;let r=await P.updatesStatus().catch(()=>null);if(!r)return;let o=this.st;this.st=r,r.job?.state==="running"&&this.following!=="starting"&&r.job.id!==this.following&&this.follow(r.job),(r.job?.id!==o.job?.id||r.job?.state!==o.job?.state||r.job?.phase!==o.job?.phase||r.check?.time!==o.check?.time)&&this.paint()},5),this.root}get busy(){return this.st.job?.state==="running"}async refresh(e){this.st=e??await P.updatesStatus().catch(()=>null)??this.st,this.paint()}async op(e,r,o){if(this.busy||this.following==="starting"){U("Another component action is already running","warning");return}this.following="starting",this.paint();let a=at(e),i=await Vt(e,{title:r,version:o,onJob:s=>this.following=s.id,onDone:s=>this.refresh(s),onUpdate:s=>{let l=s.check?.components??{};a==="amneziawg"&&l.amneziawg?.current?this.op(`amneziawg:${l.amneziawg.current}${l.amneziawg.ru?":ru":""}`,"Updating AmneziaWG",l.amneziawg.installed??void 0):this.op("app","Updating Dawnline",this.st.version)}});this.following==="starting"&&(this.following=i?.id??null),this.refresh()}async follow(e){this.following=e.id;let r=Sn(e),o={app:"Dawnline",amneziawg:"AmneziaWG",pkgs:"system packages",all:"components"}[r]??"components";await Vt(null,{title:`${e.action==="check"?"Checking":e.auto?"Automatic update:":"Updating"} ${o}`,onDone:a=>this.refresh(a)},e)}paint(){let e=this.st,r=e.check?.components??{},o=e.firmware,a=Da(this,r.packages),i=(e.needs?.awg??[]).length>0,l=(!i&&r.amneziawg?.update&&r.amneziawg.installed?1:0)+a.updates;dom.content(this.root,[t("div",{class:"dl-pagehead"},[t("div",{class:"dl-stack"},[t("h2",{class:"dl-h1"},"Components"),t("span",{class:"dl-faint"},[o?.version?`OpenWrt ${o.version} · ${o.target}`:"",e.check?`checked ${re(e.check.time,e.now)}`:"not checked yet"].filter(Boolean).join(" · "))]),t("div",{class:"dl-row-actions"},[t("a",{class:"cbi-button cbi-button-neutral dl-icon-btn",href:`${L.url("admin/network/dawnline/settings")}?section=updates`},[v("edit")," Settings"]),D([v("refresh")," Check all"],()=>this.op("check","Checking all components"),"neutral",{disabled:this.busy})])]),_a(this,r.app),t("div",{class:"dl-comp-cols"},[t("section",{class:"dl-panel flush"},[t("div",{class:"dl-panel-head pad"},[t("h3",{},"Components"),t("span",{class:"dl-spacer"}),t("span",{class:"dl-faint dl-comp-count"},i?l?`AmneziaWG not installed · ${l} update${l===1?"":"s"}`:"AmneziaWG not installed":!r.amneziawg&&!r.packages?"":l?`${l} of ${1+a.total} need${l===1?"s":""} an update`:"Everything is up to date")]),t("div",{},[...Pa(this,r.amneziawg),...a.rows])]),Aa(this)])])}state(e,r,o){let a=this.st.job;if(a?.state==="running"){let i=l=>l==="packages"?"pkgs":l,s=a.action==="check"?[i(a.component||"all")]:(a.component??"").split(" ").map(l=>i(at(l)));if(s.includes(e)||s.includes("all"))return t("button",{type:"button",class:"dl-pill info dl-comp-run",title:"Show progress",click:()=>this.follow(a)},[a.action==="check"?"Checking":"Updating","…"])}return r?r.error?Ee("warn","Check failed",r.error):r.update?Ee("info","Update available"):r.status==="dev"?Ee("info","Newer than release",`The latest release is ${o}`):Ee("ok","Up to date"):Ee("","Not checked")}more(e){let r=D([v("more")],()=>Ce(r,e.filter((o,a,i)=>o!==null||a>0&&ao?{label:o.label,icon:v(o.ic),warn:o.warn,run:o.run}:null)),"neutral",{title:"More","aria-label":"More"});return r}round(e,r,o=!1){let a=this.busy?" is-busy":"",i;return o?i=D([v("refresh")," Check"],e,"neutral",{class:`cbi-button cbi-button-neutral dl-comp-check${a}`,"aria-label":"Check for updates"}):(i=Le("refresh","Check for updates",e,"neutral",a.trim()),i.removeAttribute("title"),i.setAttribute("aria-label","Check for updates"),he(i,()=>["Check for updates"])),t("span",{class:"dl-comp-ic"},[i,this.more(r)])}row(e,r,o,a){return t("div",{class:"dl-row"},[t("span",{class:"dl-group-ic"},v(e)),t("span",{class:"dl-row-main dl-stack"},[t("b",{},r),t("span",{class:"dl-mono dl-faint dl-comp-sub"},o)]),...a])}};var Ha=(n,e)=>t("div",{class:"cbi-value"},[t("label",{class:"cbi-value-title"},n),t("div",{class:"cbi-value-field"},e)]);function za(n){let e=n.st.servers.find(r=>r.id===n.p.server)?.name??"Home";qt(n.p,e)}async function Na(n){let e=n.p,r=e.code_set??0,o=e.devices.filter(l=>l.created_by==="portal"&&l.created>=r),a=o.map(l=>t("input",{type:"checkbox",id:`dl-rm-${l.id}`,checked:"checked","data-id":l.id})),i=[t("p",{},"The old link stops working right away.")];o.length&&i.push(t("p",{},"Devices added through the old link keep working until they are removed. Remove them too:"),t("div",{class:"dl-checklist"},o.map((l,d)=>t("label",{for:`dl-rm-${l.id}`},[a[d],` ${l.name}`]))));let s=async()=>{let l=a.filter(c=>c.checked).map(c=>c.dataset.id),d=await G(()=>P.personRegen(e.id,l),l.length?`New link created, ${l.length} device${l.length===1?"":"s"} removed`:"New link created");d&&(ae(),l.length&&await n.refresh(),d.link&&await me(d.link,"New link copied"))};oe("Create a new link?",i,[ie()," ",D("Create new link",s,"negative")])}function Lo(n){let e=t("textarea",{class:"cbi-input-textarea dl-note-input",rows:3,maxlength:500,placeholder:"Only you see this"},n.p.note??"");oe("Note",[e],[ie()," ",D("Save",async()=>{ae(),await n.patch({note:e.value.trim()},e.value.trim()?"Note saved":"Note removed")},"positive")]),setTimeout(()=>e.focus(),50)}function Ra(n){let e=n.p,r=t("select",{class:"cbi-input-select"},[t("option",{value:"pause",selected:e.expire_action==="pause"?"selected":null},"Pause access"),t("option",{value:"notify",selected:e.expire_action==="notify"?"selected":null},"Keep access"),t("option",{value:"remove",selected:e.expire_action==="remove"?"selected":null},"Remove their devices")]),o=t("select",{class:"cbi-input-select"},[0,1,3,7,14].map(a=>t("option",{value:a,selected:e.expire_warn===a?"selected":null},a?`${a} day${a===1?"":"s"} before`:"Don’t warn")));oe("When access ends",[Ha("Then",r),t("div",{class:"cbi-value"},[t("label",{class:"cbi-value-title"},"Warn"),t("div",{class:"cbi-value-field"},[o,t("div",{class:"cbi-value-description"},"Shown in their portal and on the Overview.")])])],[ie()," ",D("Save",async()=>{ae(),await n.patch({expire_action:r.value,expire_warn:o.value},"Saved")},"positive")])}function Ia(n){let e=t("input",{type:"text",class:"cbi-input-text",value:n.p.name,maxlength:48}),r=ye("Name",e,()=>_e(e.value,[],"Shown in their portal and apps."));oe("Rename",[r],[ie()," ",D("Save",async()=>{let o=r.help();if(o.bad){U(o.text,"warning");return}await n.patch({name:e.value.trim()},"Renamed")&&ae()},"positive")]),setTimeout(()=>e.select(),50)}function Ba(n){let e=n.p,r=n.st.servers.filter(i=>i.id!==e.server),o=t("select",{class:"cbi-input-select"},r.map(i=>t("option",{value:i.id},`${i.name} · ${i.endpoint||"no address"}:${i.port}`))),a=e.devices.length;oe(`Move ${e.name} to another server`,[Ha("Server",o),t("p",{class:"dl-muted"},a?`${a} device${a===1?" gets a new address and stops":"s get new addresses and stop"} connecting until ${a===1?"it imports its":"they import their"} configuration again (from the personal link or from you). Circles and home networks of the old server are left behind.`:"They have no devices yet: nothing else changes.")],[ie()," ",D("Move",async()=>{await n.patch({server:o.value},`Moved to ${r.find(i=>i.id===o.value)?.name??"the server"}`)&&(ae(),a&&U("Devices are marked “Update config” until they import again.","info",6e3))},"positive")])}async function Oa(n){let e=n.p;await se(`Delete ${e.name}?`,`All ${e.devices.length} devices are disconnected immediately and the personal link stops working.`,"Delete",!0)&&await G(()=>P.personDelete(e.id),"Deleted")&&(location.href=_t(e.server))}function ja(n){let e=n.p,r=n.st,o=e.online?"online now":e.last_seen?`last seen ${re(e.last_seen,r.now)}`:"never connected",a=e.created?`Added ${Me(je(new Date(e.created*1e3)))}`:"",i=e.has_link??r.settings.portal_enabled,s=[{label:"Rename",icon:v("edit"),run:()=>Ia(n)},{label:e.note?"Edit note":"Add note",icon:v("file"),run:()=>Lo(n)},...r.servers.length>1?[{label:"Move to server…",icon:v("server"),run:()=>Ba(n)}]:[],...i?[null,{label:"Invite card",icon:v("qr"),run:()=>za(n)},{label:"New link",icon:v("key"),run:()=>Na(n)}]:[],null,...e.paused?[]:[{label:"Pause",icon:v("pause"),warn:!0,run:()=>n.patch({paused:!0},"Paused")}],{label:"Delete",icon:v("trash"),danger:!0,run:()=>Oa(n)}];return t("div",{class:"dl-person-head"},[t("div",{class:"dl-pagehead"},[t("div",{class:"dl-person-id"},[t("span",{class:`dl-avatar lg${e.online?" online":""}`},He(e.name)),t("div",{class:"dl-stack"},[t("div",{class:"dl-title-row"},[t("h2",{class:"dl-h1"},e.name),Io(e)]),t("span",{class:"dl-faint",title:a},`${e.devices.length} of ${e.device_limit} devices · ${o}`)])]),t("div",{class:"dl-pcard-actions"},[e.paused?D([v("play")," Resume"],()=>n.patch({paused:!1},"Resumed"),"add"):"",i?Le("link","Copy link",()=>Cn(e.id),"neutral","dl-icon-only"):"",Le("more","More",l=>Ce(l.currentTarget,s),"neutral","dl-icon-only")])]),e.note?t("button",{type:"button",class:"dl-pnote",title:"Edit note",click:()=>Lo(n)},[v("file"),t("span",{},e.note)]):""])}function Ua(n){let e=n.p,r=n.series[n.series.length-1];return t("div",{class:`dl-person-live${e.online?"":" solo"}`},[e.online?Pn(e.rate??[],n.st.now,r?[r.rx,r.tx]:[0,0]):"",Dn(n.series,`${X(e.month[0]+e.month[1])} this month`)])}async function el(n,e){let r=await G(()=>P.deviceConfig(e.id));r&&oe(`Set up ${e.name}`,[await n.core.connectBlock(r,"qr")],[ie("Close")])}async function tl(n,e){let r=await G(()=>P.deviceConfig(e.id));if(!r)return;if(!r.has_private_key){U("This device made its own keys in the browser; its configuration only exists there.","warning");return}let o=n.core.file.make(r);Te(o.name,o.text,"application/octet-stream")}function Ga(n){let e=n.p,r=n.st.now,o=d=>Ge(e,d,n.deviceOpts()),a=d=>c=>{c.target.closest("button:not(.dl-dcard-title), a")||o(d)},i=d=>D([v("more")],c=>Gr(c.currentTarget,e,d,n.deviceOpts()),"neutral",{title:"QR, file, key, rename, new keys, remove",class:"cbi-button cbi-button-neutral dl-icon-only"}),s=tn(e.devices).map(d=>{let c=t("div",{class:"dl-dcard-head"},[t("span",{class:"dl-dcard-ic"},v(d.kind)),t("button",{type:"button",class:"dl-dcard-title",click:()=>o(d)},[t("b",{},d.name),nn(d,r,void 0,e),d.config_stale?t("span",{class:"dl-pill warn dl-stale"},"Update config"):""]),i(d)]),p=t("div",{class:"dl-dcard-trend"},[t("div",{class:"dl-stack"},[t("b",{},X(d.month[0]+d.month[1])),t("span",{class:"dl-sub"},"this month")]),pa(n.devSeries[d.id]??[])]);return t("article",{class:`dl-dcard clickable${d.online?" online":""}${d.disabled?" off":""}`,click:a(d)},[c,d.handshake?p:d.disabled?t("div",{class:"dl-sub"},`${Qe[d.kind]} · created ${re(d.created,r)} ${d.created_by==="portal"?"in the portal":"by you"}.`):t("div",{class:"dl-chips-row"},[t("button",{type:"button",class:"dl-chipbtn",click:()=>el(n,d)},[v("qr"),"Show QR"]),t("button",{type:"button",class:"dl-chipbtn",click:()=>tl(n,d)},[v("download"),"Config"])])])}),l=e.devices.length>=e.device_limit;return s.push(t("button",{type:"button",class:"dl-dslot add",click:()=>nt(e,n.deviceOpts())},[t("span",{class:"dl-dslot-ic"},v("plus")),t("span",{class:"dl-stack"},[t("b",{},"Add device"),t("span",{class:"dl-sub"},l?`Over the limit · ${e.devices.length} of ${e.device_limit}`:`${e.devices.length} of ${e.device_limit}`)])])),t("section",{class:"dl-devsec"},[t("div",{class:"dl-panel-head"},[t("h3",{},"Devices"),t("span",{class:"dl-sub"},`${e.online} online`)]),t("div",{class:"dl-dgrid"},s)])}function Wa(n){let e=n.p,r=we([["device","Device’s own DNS"],["home","Home names"]],e.dns_mode,{label:"DNS",cls:"sm",optimistic:!1,onChange:a=>n.patch({dns_mode:a},a==="home"?"Home names on — devices need their configuration again":"Device DNS — devices need their configuration again")}),o=n.st.settings.home_dns_fallback;return t("div",{class:"dl-stack gap4 dl-dnspick"},[t("div",{class:"dl-row-actions"},[t("span",{class:"dl-sub"},"DNS"),r]),t("span",{class:"dl-sub"},e.dns_mode==="home"?["Names like ",t("span",{class:"dl-mono"},`nas.${n.st.settings.domain}`)," work. Internet names are resolved at home, so they depend on the tunnel",o?[" (",t("span",{class:"dl-mono"},o)," takes over when it is down)."]:" — with no fallback set, they stop when it is down."]:"Internet keeps working exactly as without the VPN. Reach home devices by IP address.")])}function Fa(n){let e=n.p,o=n.st.servers.find(i=>i.id===e.server)?.home??[];if(o.length<2)return"";let a=new Set(e.home_nets?.length?e.home_nets:o.map(i=>i.dev));return t("div",{class:"dl-stack gap4"},[t("div",{class:"dl-chips-row"},o.map(i=>qe(i.dev,a.has(i.dev),()=>{let s=new Set(a);if(s.delete(i.dev)||s.add(i.dev),!s.size)return U("Keep at least one network, or choose Internet only.","warning",5e3);let l=s.size===o.length?[]:[...s];n.patch({home_nets:l},l.length?`${e.name} reaches ${l.join(", ")}`:`${e.name} reaches every home network`)},{title:i.nets.join(", ")}))),t("span",{class:"dl-sub"},e.home_nets?.length?`Home networks ${e.name} reaches. Networks added to the server later stay out.`:`Home networks ${e.name} reaches: all of them. Untick one to keep ${e.name} out of it.`)])}function qa(n){let e=new Set(n.p.services??[]);return t("div",{class:"dl-stack gap4"},[t("div",{class:"dl-chips-row"},n.st.services.map(r=>qe(r.name,e.has(r.id),()=>{let o=new Set(e);o.delete(r.id)||o.add(r.id),n.patch({services:[...o]},o.size?"Home services updated":"Whole home network")},{title:`${r.address}${r.ports.length?` · ${r.ports.join(", ")}`:""}`}))),t("span",{class:"dl-sub"},e.size?"Only the selected services at home.":"Whole home network. Pick services to narrow it down.")])}function Ka(n){let e=n.p,r=n.st;if(r.servers.find(c=>c.id===e.server)?.mesh!=="circles"||!rt(e))return"";let a=r.circles.filter(c=>c.server===e.server),i=a.find(c=>c.id===e.circle),s=i?r.people.filter(c=>c.id!==e.id&&c.circle===i.id&&rt(c)).map(c=>c.name):[],l=t("button",{type:"button",class:"dl-chipbtn",click:()=>Ce(l,[...a.map(c=>({label:c.name,icon:bo(c),run:()=>c.id!==e.circle&&n.patch({circle:c.id},`${e.name} is in ${c.name}`)})),e.circle?{label:"No circle",icon:v("x"),run:()=>n.patch({circle:""},`${e.name} is in no circle`)}:null,{label:"New circle",icon:v("plus"),run:()=>Ln(r,e.server,null,()=>n.refresh())}])},"Change"),d=i?r.people.filter(c=>c.circle===i.id&&rt(c)):[e];return t("div",{class:"dl-tile2"},[t("div",{class:"dl-tile2-label"},[t("span",{},"Devices see each other"),l]),t("div",{class:"dl-tile2-row"},[t("span",{class:"dl-tile2-value"},i?i.name:"No circle"),t("span",{class:"dl-avstack",title:d.map(c=>c.name).join(", ")},d.slice(0,5).map(c=>t("span",{class:"dl-avatar sm"},He(c.name))))]),t("span",{class:"dl-sub"},i?s.length?[e.name,...s].join(", "):`Nobody else in ${i.name} yet`:`Only ${e.name}'s own devices`)])}function Va(n){let e=n.p,r=n.st.now,o=t("div",{class:"dl-slots"});for(let s=0;s=e.device_limit,c=t("i",{class:d?"over":l?"used":""});he(c,()=>[t("div",{class:"dl-tip-title"},l?`${l.name}${d?" · over the limit":""}`:"Free slot"),t("div",{class:"dl-muted"},l?l.online?"Connected":l.handshake?`Last seen ${re(l.handshake,r)}`:"Not set up yet":"They can add a device here")]),o.appendChild(c)}let a=Math.max(1,e.devices.length),i=t("button",{type:"button","aria-label":"Allow fewer devices",disabled:e.device_limit<=a?"disabled":null,click:()=>n.patch({device_limit:String(e.device_limit-1)})},"−");return e.device_limit<=a&&e.devices.length>1&&he(i,()=>[t("div",{class:"dl-tip-title"},`${e.devices.length} devices in use`),t("div",{class:"dl-muted"},"Remove a device first to lower the limit")]),t("div",{class:"dl-tile2"},[t("div",{class:"dl-tile2-label"},"Devices"),t("div",{class:"dl-tile2-row"},[t("span",{class:"dl-tile2-value"},[String(e.devices.length),t("span",{class:"dl-faint"},` / ${e.device_limit}`)]),t("div",{class:"dl-stepper"},[i,t("button",{type:"button","aria-label":"Allow more devices",disabled:e.device_limit>=32?"disabled":null,click:()=>n.patch({device_limit:String(e.device_limit+1)})},"+")])]),o])}var nl={internet:"Browse the internet through your router. No access to devices at home, and home cannot reach theirs.",lan:"Reach devices at home, and home reaches theirs. Internet stays on their own connection.",both:"Home devices and the internet, all through your router. Home reaches their devices too."},Ja=/^([01]\d|2[0-3]):[0-5]\d$/;function ol(n){let e=n.p,r=n.today,o=Ye(e.expires,r),a=t("input",{type:"date",class:"dl-date-hidden",value:e.expires,tabindex:"-1","aria-hidden":"true"});a.addEventListener("change",()=>a.value&&n.patch({expires:a.value},`Access until ${Me(a.value)}`));let i=(c,p)=>{let u=zo(e.expires&&(o??-1)>=0?e.expires:"",c,p,r);n.patch({expires:u},`Access until ${Me(u)}`)},s=[["week",1,"+1 week"],["month",1,"+1 month"],["month",3,"+3 months"],["year",1,"+1 year"]].map(([c,p,u])=>t("button",{type:"button",class:"dl-chipbtn",click:()=>i(c,p)},u)),l=t("span",{class:"dl-datechip"},[t("button",{type:"button",class:"dl-chipbtn",click:()=>{a.focus({preventScroll:!0});try{a.showPicker()}catch{}}},[v("calendar"),e.expires?Me(e.expires):"Date"]),a]),d={pause:"pause access",notify:"keep access",remove:"remove their devices"}[e.expire_action];return t("div",{class:"dl-tile2"},[t("div",{class:"dl-tile2-label"},[t("span",{},"Access ends"),e.expires?t("span",{class:o!=null&&o<0?"dl-bad":Ze(e,o)?"dl-warn":"dl-ok"},o!=null&&o<0?"ended":`${o} day${o===1?"":"s"} left`):t("span",{class:"dl-faint"},"no end date")]),t("div",{class:"dl-chips-row"},[...s,l,e.expires?t("button",{type:"button",class:"dl-chipbtn",click:()=>n.patch({expires:""},"No end date")},"No end"):""]),t("div",{class:"dl-tile2-foot"},[t("span",{class:"dl-muted"},`When it ends: ${d}${e.expire_warn?`, warn ${e.expire_warn} day${e.expire_warn===1?"":"s"} before`:""}`),t("a",{href:"#",click:c=>{c.preventDefault(),Ra(n)}},"Change")])])}function rl(n){let e=n.p,r=e.quota_used||e.month[0]+e.month[1],o=e.quota_limit?Math.min(100,e.quota_used/e.quota_limit*100):0,a=t("div",{class:`dl-meter${o>=100?" bad":o>=90?" warn":""}`},[t("i"),e.quota_limit?t("span",{class:"mark",title:"Alert at 90%"}):""]);a.firstChild.style.width=`${o}%`,e.quota_limit&&he(a,()=>[t("div",{class:"dl-tip-title"},`${o.toFixed(1)}% used`),t("div",{class:"dl-muted"},`${X(e.quota_used)} of ${X(e.quota_limit)} · ${X(Math.max(0,e.quota_limit-e.quota_used))} left`),t("div",{class:"dl-faint"},"Alert at 90%")]);let i=we([["month","Monthly"],["total","Total"]],e.quota_period,{label:"Data limit period",cls:"sm",optimistic:!1,onChange:l=>n.patch({quota_period:l})}),s=[10,50,100].map(l=>t("button",{type:"button",class:`dl-chipbtn${e.quota_gb===l?" on":""}`,click:()=>n.patch({quota_gb:String(l)},`Data limit ${l} GB`)},`${l} GB`));return s.push(t("button",{type:"button",class:`dl-chipbtn${e.quota_gb?"":" on"}`,click:()=>n.patch({quota_gb:""},"No data limit")},"Unlimited")),s.push(t("button",{type:"button",class:"dl-chipbtn",click:()=>{let l=t("input",{type:"number",class:"cbi-input-text dl-w-port",min:0,step:"any",value:e.quota_gb?String(e.quota_gb):""}),d=ye("Data limit (GB)",l,()=>pn(l.value,e.quota_period==="month"));oe("Data limit",[d],[ie()," ",D("Save",async()=>{let c=d.help();if(c.bad){U(c.text,"warning");return}let p=l.value.trim();await n.patch({quota_gb:p},p&&Number(p)>0?`Data limit ${p} GB`:"No data limit")&&ae()},"positive")]),setTimeout(()=>l.select(),50)}},"Custom")),t("div",{class:"dl-tile2"},[t("div",{class:"dl-tile2-label"},[t("span",{},"Data"),i]),t("div",{class:"dl-tile2-row"},[t("span",{class:"dl-tile2-value"},[X(r),e.quota_limit?t("span",{class:"dl-faint"},` of ${X(e.quota_limit)}`):t("span",{class:"dl-faint"}," · no limit")]),e.quota_period==="month"?t("span",{class:"dl-sub"},"resets on the 1st"):""]),e.quota_limit?a:"",t("div",{class:"dl-chips-row"},s),e.quota_gb&&e.quota_period==="month"?t("div",{class:"dl-tile2-foot"},[t("span",{class:"dl-muted"},e.bonus_gb?`Includes +${e.bonus_gb} GB extra this month`:"Need a little more this month?"),t("a",{href:"#",click:l=>{l.preventDefault(),n.patch({bonus_gb:String((e.bonus_gb||0)+10)},"+10 GB this month")}},"+10 GB this month")]):"",t("div",{class:"dl-tile2-foot"},[t("span",{class:"dl-muted"},`${X(e.total[0]+e.total[1])} in total`),t("button",{type:"button",class:"dl-linkbtn danger",click:()=>Mt("person",e.id,e.name,()=>setTimeout(()=>n.refresh(),300))},"Reset usage")])])}function al(n){let e=n.p,r=!!e.hours,[o,a]=(e.hours||"07:00-23:00").split("-"),i=t("input",{type:"time",class:"cbi-input-text",value:o,"aria-label":"From"}),s=t("input",{type:"time",class:"cbi-input-text",value:a,"aria-label":"To"}),l=t("div",{class:"dl-tile2-row"},[i,t("span",{class:"dl-faint"},"to"),s]),d=()=>{let x=`${i.value}-${s.value}`;if(x!==e.hours){if(!Ja.test(i.value)||!Ja.test(s.value))return U("Enter both times, like 07:00 and 23:00.","warning");if(i.value===s.value)return U("The start and the end must differ.","warning");n.patch({hours:x},`Allowed ${i.value}–${s.value}`)}};l.addEventListener("focusout",x=>{l.contains(x.relatedTarget)||d()});for(let x of[i,s])x.addEventListener("keydown",$=>{$.key==="Enter"&&($.preventDefault(),d())});let c=t("button",{type:"button",role:"switch","aria-checked":r?"true":"false",class:`dl-switch${r?" on":""}`,"aria-label":"Limit hours",click:()=>{if(r)return n.patch({hours:""},"Any time");c.classList.add("on"),c.setAttribute("aria-checked","true"),p.textContent="Set the hours, then press Enter",u.appendChild(l),i.focus()}},t("i")),p=t("span",{},r?`${o} – ${a} (router time)`:"Any time"),u=t("div",{class:"dl-tile2"},[t("div",{class:"dl-tile2-row"},[t("div",{class:"dl-stack"},[t("span",{class:"dl-tile2-label"},"Allowed hours"),p]),c]),r?l:""]);return u}function Ya(n){let e=n.p,r=we(["internet","lan","both"].map(o=>[o,[v(o==="internet"?"globe":o==="lan"?"home":"shield"),o==="internet"?"Internet":o==="lan"?"Home":"Both"]]),e.access,{label:"Access",cls:"wide",optimistic:!1,onChange:o=>n.patch({access:o},`Access: ${dt[o]}`)});return t("section",{class:"dl-devsec","aria-label":"Access and limits"},[t("div",{class:"dl-panel-head"},[t("h3",{},"Access & limits")]),t("div",{class:"dl-panel"},[t("div",{class:"dl-stack gap8"},[t("span",{class:"dl-tile2-label"},"Can reach"),r,t("span",{class:"dl-sub"},nl[e.access]),e.access==="lan"&&n.st.services.length?qa(n):"",rt(e)?Fa(n):"",e.access==="lan"?Wa(n):""]),t("div",{class:"dl-tiles2"},[Va(n),Ka(n),ol(n),rl(n),al(n)])])])}function il(n){let e=n.st,r=t("div",{class:"dl-panel-head pad"},[t("h3",{},"Locations"),t("span",{class:"dl-spacer"}),e.geo.enabled?Tt("30d",a=>n.map?.setRange(a),!1):"",D("Hide",()=>{n.mapOpen=!1,n.map?.destroy(),n.map=null,n.paintPlaces()},"neutral")]);if(!e.geo.enabled)return t("div",{class:"dl-panel flush"},[r,t("div",{class:"dl-map-off"},["Locations are off. ",t("a",{href:L.url("admin/network/dawnline/settings")},"Turn them on in Settings"),"."])]);let o=new tt({openPerson:()=>{},openDevice:(a,i)=>{let s=n.p.devices.find(l=>l.id===i);s&&Ge(n.p,s,n.deviceOpts())}},"30d",280);return n.map=o,requestAnimationFrame(()=>o.mount(n.mapData())),t("div",{class:"dl-panel flush"},[r,o.el])}function Za(n){let e=n.st;if(!e.geo.enabled)return t("div",{class:"dl-places"},[v("pin"),t("div",{class:"dl-stack"},[t("span",{},"Locations are off"),t("span",{class:"dl-sub"},"City-level, from the client IP")]),t("span",{class:"dl-spacer"}),t("a",{class:"cbi-button cbi-button-neutral",href:L.url("admin/network/dawnline/settings")},"Turn on")]);if(n.mapOpen)return n.map&&n.parts.places.contains(n.map.el)?null:il(n);let r=e.now-30*86400,o=e.geo.points.filter(s=>s.person===n.p.id&&s.ts>=r).sort((s,l)=>l.ts-s.ts),a=[...new Set(o.map(s=>s.city||s.country).filter(Boolean))],i=o[0];return t("div",{class:"dl-places"},[v("pin"),t("div",{class:"dl-stack"},[t("span",{},i?i.city||i.country:"No locations yet"),t("span",{class:"dl-sub"},i?`${a.length} place${a.length===1?"":"s"} in 30 days${i.org?` · ${i.org}`:""}`:"Shown after a device connects")]),t("span",{class:"dl-spacer"}),o.length?D("Show map",()=>{n.mapOpen=!0,n.paintPlaces()},"neutral"):""])}function Qa(n){let e=n.p,r=n.st,o=n.events.filter(l=>l.person===e.id),a=[],i=[...o].reverse();for(let l=0;l1){let u=p.querySelector(".dl-row-main");dom.content(u,[...wo(r,d).slice(0,3),t("span",{class:"dl-muted"},`${c} times`)]),u.title=i.slice(l,l+c).map(x=>x.detail??"").join(` +`)}a.push(p),l+=c-1}let s=D([v("more")],()=>Ce(s,[{label:"Export CSV",icon:v("download"),run:()=>Fe(r,o,"csv",e.id)},{label:"Export JSON",icon:v("download"),run:()=>Fe(r,o,"json",e.id)},null,{label:`Clear ${e.name}'s activity`,icon:v("trash"),danger:!0,run:()=>et(`Clear ${e.name}'s activity`,`Removes events about ${e.name} and their devices.`,{person:e.id},()=>n.refresh())}]),"neutral",{title:"Export or clear",class:"cbi-button cbi-button-neutral dl-icon-only"});return t("div",{class:"dl-panel flush"},[t("div",{class:"dl-panel-head pad"},[t("h3",{},"Activity"),t("span",{class:"dl-sub"},o.length>10?`latest 10 of ${o.length}`:""),t("span",{class:"dl-spacer"}),s]),a.length?a:t("div",{class:"dl-row dl-muted"},"Nothing yet.")])}var In=class{constructor(){this.id="";this.events=[];this.mapOpen=!1;this.map=null;this.parts={};this.series=[];this.devSeries={};this.ticks=0;this.fullNext=!1}async fetch(e){let[r,o,a]=await Promise.all([P.status(30),e?P.events(2e3,this.id).catch(()=>null):Promise.resolve(null),e?P.personUsage(this.id,30).catch(()=>null):Promise.resolve(null)]);return{st:r,ev:o?.events??null,use:a}}async load(){return this.id=new URLSearchParams(location.search).get("id")??"",this.fetch(!0)}render(e){this.take(e);let r=this.st.people.find(s=>s.id===this.id);if(!r)return t("div",{class:"dl-empty"},[t("h3",{},"Person not found"),t("p",{},"They may have been removed."),t("a",{class:"cbi-button",href:L.url("admin/network/dawnline/server")},"Back to Servers")]);this.p=r;for(let s of["crumbs","head","devices","traffic","places","activity","limits"])this.parts[s]=t("div",{});this.parts.devices.className="dl-person-devices";let o=t("div",{},[this.parts.crumbs,this.parts.head,t("div",{class:"dl-grid-person"},[t("div",{class:"dl-col"},[this.parts.devices,this.parts.traffic,this.parts.places,this.parts.activity]),t("div",{class:"dl-col"},[this.parts.limits])])]);this.paint();let a=new URLSearchParams(location.search),i=a.get("device")&&r.devices.find(s=>s.id===a.get("device"));return i?setTimeout(()=>Ge(this.p,i,this.deviceOpts()),50):a.get("add")&&setTimeout(()=>nt(this.p,this.deviceOpts()),50),this.poller=ot({fetch:s=>{let l=s||this.fullNext||++this.ticks%4===0;return this.fullNext=!1,this.fetch(l)},every:15,live:!0,active:()=>o.isConnected,apply:(s,l)=>this.apply(s,l)}),o}take(e){this.st=e.st,e.ev&&(this.events=e.ev),e.use&&(this.series=e.use.person,this.devSeries=e.use.devices)}apply(e,r){this.take(e);let o=this.st.people.find(a=>a.id===this.id);if(!o){r||(location.href=_t(this.p?.server));return}this.p=o,this.paint(r),this.map?.update(this.mapData())}async refresh(){this.fullNext=!0,await this.poller?.refresh()}async patch(e,r){var i;this.poller?.claim();let o=await G(()=>P.personUpdate(this.p.id,e),r);if(!o)return!1;this.poller?.claim();let a=this.st.people.findIndex(s=>s.id===this.p.id);return(i=o.person).rate??(i.rate=this.p.rate),a>=0&&(this.st.people[a]=o.person),this.p=o.person,this.paint(),!0}get today(){return Ie(this.series.length?this.series:this.st.series)}get core(){return St(this.st.servers,this.p.server)}deviceOpts(){return{refresh:()=>this.refresh(),geo:this.st.geo,now:this.st.now,today:this.today,core:this.core,events:()=>this.events}}mapData(){return{geo:this.st.geo,people:this.st.people,now:this.st.now,person:this.p.id}}crumbs(){let e=this.p;return t("nav",{class:"dl-crumbs","aria-label":"Breadcrumb"},[t("a",{href:_t(e.server)},this.st.servers.find(r=>r.id===e.server)?.name??"Servers"),t("span",{},"/"),t("a",{href:_t(e.server)},"People"),t("span",{},"/"),t("span",{},e.name)])}paint(e=!1){Se(this.parts.crumbs,this.crumbs(),e),Se(this.parts.head,ja(this),e),Se(this.parts.traffic,Ua(this),e),Se(this.parts.devices,Ga(this),e),Se(this.parts.limits,Ya(this),e),this.paintPlaces(e),Se(this.parts.activity,Qa(this),e)}paintPlaces(e=!1){let r=Za(this);r&&Se(this.parts.places,r,e&&!this.mapOpen)}};var sl={ok:"check",warn:"alert",error:"x",skip:"pause"},Bn=class{constructor(e,r,o,a){this.el=t("div",{});this.wdEl=t("div",{});this.checksEl=t("div",{class:"dl-panel"});this.recentEl=t("div",{class:"dl-panel flush dl-recent"});this.checks=null;this.summary=t("div",{});this.open=new Set;this.st=e,this.sl=r,this.events=o,this.toLog=a,dom.content(this.el,[this.summary,this.wdEl,t("div",{class:"dl-health-cols"},[this.checksEl,this.recentEl])]),this.paintChecks(),this.paintLive(r,o)}async run(e){let r=e?await An(e):await P.health().catch(()=>null);r&&(this.take(r),e==="netrestart"&&setTimeout(()=>this.el.isConnected&&void this.run(),5e3))}take(e){this.checks=e.checks,this.paintChecks(),this.paintLive(e,this.events)}paintChecks(){let e=this.checks;if(!e){dom.content(this.summary,""),dom.content(this.checksEl,[t("div",{class:"dl-panel-head"},[t("h3",{},"Checks")]),t("p",{class:"dl-muted dl-loading"},"Running checks…")]);return}let r=e.filter(s=>s.status==="error").length,o=e.filter(s=>s.status==="warn").length;dom.content(this.summary,r?ct("error",`${r} problem${r>1?"s":""} need attention.`):o?ct("warn",`${o} warning${o>1?"s":""}.`):ct("ok","All checks passed."));let a=new Map;for(let s of this.sl.watchdog.repairs)a.set(s.id,Math.max(a.get(s.id)??0,s.ts));let i=()=>this.run();dom.content(this.checksEl,[t("div",{class:"dl-panel-head"},[t("h3",{},"Checks"),t("span",{class:"dl-spacer"}),D("Run again",i)]),t("ul",{class:"dl-checks"},e.map(s=>t("li",{},[t("span",{class:`dl-check-icon ${s.status}`},v(sl[s.status])),t("div",{class:"dl-check-body"},[t("div",{class:"dl-check-title"},s.title),t("div",{class:"dl-check-detail"},s.detail),a.has(s.id)?t("div",{class:"dl-check-repaired"},`Repaired by the watchdog at ${Ht(a.get(s.id))}`):""]),yo(s,l=>void this.run(l),i)])))])}paintLive(e,r){this.sl=e,this.events=r;let o=e.watchdog,a=o.beat!=null&&o.now-o.beat>180,i=o.repairs.filter(d=>o.now-d.ts<86400),s=i[i.length-1],l=ve(o.enabled,"Watchdog repairs",async d=>{await G(()=>P.settingsUpdate({watchdog:d?"1":"0"}),d?"Watchdog on":"Watchdog off")||eo(l,!d);let p=await P.serviceLog().catch(()=>null);p&&this.paintLive(p,this.events)});dom.content(this.wdEl,t("div",{class:"dl-panel dl-wd"},[t("div",{class:"dl-wd-head"},[t("span",{class:`dl-wd-tile${o.enabled?"":" off"}`},v("shield")),t("div",{class:"dl-stack"},[t("span",{class:"dl-wd-title"},"Watchdog"),t("span",{class:"dl-sub"},o.enabled?"Every minute it checks the tunnels and services and repairs what it can on its own.":"Off: problems are only written to the log. Nothing is repaired on its own.")]),t("span",{class:"dl-spacer"}),l]),t("div",{class:"dl-wd-foot"},[t("div",{class:"dl-wd-chips"},o.targets.map(d=>t("span",{class:`dl-check-chip${d.ok?"":" error"}`,title:d.ok?"OK":`Not working${d.tries?` · ${d.tries} repair${d.tries>1?"s":""}`:""}`},[v(d.ok?"check":"x"),d.name]))),t("span",{class:`dl-sub${a?" dl-warn-text":""}`},a?`The agent has not checked in for ${Math.round((o.now-o.beat)/60)} min; cron restarts it after 5.`:[o.last?`Looked ${re(o.last,o.now)}`:"Starts within a minute"," · ",i.length?`${i.length} repair${i.length>1?"s":""} today, last ${s.name} at ${Ht(s.ts)}`:"no repairs today"])])])),this.paintRecent()}paintRecent(){let e=(this.sl.watchdog.now||Date.now()/1e3)-604800,r=[...this.events.map(a=>({ts:a.ts,ev:a})),...this.sl.log.map(a=>({ts:a.ts,sys:a}))].filter(a=>a.ts>=e&&un(a)).sort((a,i)=>i.ts-a.ts),o=t("div",{class:"dl-panel-head pad"},[t("h3",{},"Recent problems"),t("span",{class:"dl-spacer"}),r.length?t("a",{href:"#",click:a=>(a.preventDefault(),this.toLog())},"All in Log →"):""]);if(!r.length){dom.content(this.recentEl,[o,t("div",{class:"dl-recent-empty"},[t("span",{class:"dl-check-icon ok"},v("check")),"No problems in the last 7 days."])]);return}dom.content(this.recentEl,[o,...r.slice(0,8).map(a=>{if(a.sys){let i=a.sys,s=`${i.ts}|${i.msg}`;return _n(i,this.open.has(s),()=>{this.open.delete(s)||this.open.add(s),this.paintRecent()},Ht(i.ts))}return it(this.st,a.ev,{time:Ht(a.ts)})})])}};var On=300,ll=["all","connections","people","system","problems"],jn=class{constructor(e,r,o){this.events=[];this.system=[];this.kind="all";this.shown=On;this.open=new Set;this.list=t("div",{});this.sub="";this.tabs=t("div",{class:"dl-seg",role:"tablist"});this.st=e,this.take(r),this.system=o,this.el=t("div",{},[t("div",{class:"dl-toolbar"},[this.tabs]),this.list]),this.paint()}actions(){let e=()=>this.kind==="all"?"":this.kind,r=i=>()=>{let s=this.filtered().reverse();Fe(this.st,s.filter(l=>l.ev).map(l=>l.ev),i,e(),s.filter(l=>l.sys).map(l=>l.sys))},o=D([v("download")," Export"],()=>Ce(o,[{label:"CSV (spreadsheet)",icon:v("download"),run:r("csv")},{label:"JSON",icon:v("download"),run:r("json")}])),a=D([v("trash")," Clear"],()=>et("Clear the log","Removes events from the log on the router.",{},()=>this.reload(),this.kind==="all"?void 0:this.kind,!0));return[o,a]}take(e){this.events=e.events,this.policy=e.policy;let r=Lt.filter(o=>!e.policy.categories.includes(o));this.sub=`${mn(e.policy)}${r.length?` Not recorded: ${r.map(o=>ut[o].toLowerCase()).join(", ")}.`:""}`}async reload(){let[e,r]=await Promise.all([P.events(2e4).catch(()=>null),P.serviceLog().catch(()=>null)]);e&&this.take(e),r&&(this.system=r.log),this.paint()}items(){return[...this.events.map(e=>({ts:e.ts,ev:e})),...this.system.map(e=>({ts:e.ts,sys:e}))].sort((e,r)=>r.ts-e.ts)}matches(e,r){return r==="all"?!0:r==="problems"?un(e):r==="system"?!!e.sys:!!e.ev&&It(e.ev.type)===r}filtered(){return this.items().filter(e=>this.matches(e,this.kind))}paintTabs(e){dom.content(this.tabs,ll.map(r=>t("button",{type:"button",role:"tab",class:r===this.kind?"on":"","aria-selected":r===this.kind?"true":"false",click:()=>this.show(r)},[r==="all"?"All":r==="system"?"System":ut[r],t("b",{},String(e.filter(o=>this.matches(o,r)).length))])))}show(e){this.kind=e,this.shown=On,this.paint()}paint(){this.paintTabs(this.items());let e=this.filtered();if(!e.length){dom.content(this.list,t("div",{class:"dl-empty"},[t("p",{},this.events.length||this.system.length?"No events match.":"The log is empty.")]));return}let r=[],o="",a=null;for(let i of e.slice(0,this.shown)){let s=ca(i.ts);s!==o&&(o=s,a=t("div",{class:"dl-panel flush"},t("div",{class:"dl-panel-head pad"},t("h3",{},s))),r.push(a));let l=new Date(i.ts*1e3).toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit"});if(i.sys){let d=`${i.sys.ts}|${i.sys.msg}`;a.appendChild(_n(i.sys,this.open.has(d),()=>{this.open.delete(d)||this.open.add(d),this.paint()},l))}else a.appendChild(it(this.st,i.ev,{time:l}))}e.length>this.shown&&r.push(t("div",{class:"dl-more-row"},D(`Show ${Math.min(On,e.length-this.shown)} more of ${e.length-this.shown}`,()=>{this.shown+=On,this.paint()}))),dom.content(this.list,r)}};var dl=[["health","Health"],["log","Log"]],Mo=2e4,Un=class{constructor(){this.tab=new URLSearchParams(location.search).get("tab")==="log"?"log":"health";this.segEl=t("div",{class:"dl-seg dl-srvsections dl-diag-tabs",role:"tablist","aria-label":"Diagnostics"});this.subEl=t("span",{class:"dl-muted"});this.actionsEl=t("div",{class:"dl-row-actions"});this.bodyEl=t("div",{});this.eventsAt=0}load(){return this.eventsAt=Date.now(),Promise.all([P.status(1),P.events(Mo),P.serviceLog()])}render([e,r,o]){return this.log=new jn(e,r,o.log),this.health=new Bn(e,o,r.events,()=>{this.show("log"),this.log.show("problems")}),this.show(this.tab),ot({fetch:async()=>{let a=this.tab==="log",[i,s]=await Promise.all([P.serviceLog().catch(()=>null),a?P.events(Mo).catch(()=>null):Promise.resolve(null)]);return i||s?{n:i,e:s}:null},every:10,active:()=>this.bodyEl.isConnected,apply:({n:a,e:i})=>this.take(a,i)}),t("div",{},[t("div",{class:"dl-pagehead"},[t("div",{class:"dl-stack"},[t("h2",{class:"dl-h1"},"Diagnostics"),this.subEl]),this.actionsEl]),this.segEl,this.bodyEl])}take(e,r){r&&(this.log.take(r),this.eventsAt=Date.now()),e&&(this.log.system=e.log),e&&this.health.paintLive(e,r?.events??this.health.events),this.tab==="log"&&this.log.paint()}show(e){this.tab=e,dom.content(this.segEl,dl.map(([r,o])=>t("button",{type:"button",role:"tab",class:r===e?"on":"","aria-selected":r===e?"true":"false",click:()=>r!==this.tab&&this.show(r)},o))),this.bodyEl.replaceChildren(e==="log"?this.log.el:this.health.el),this.subEl.textContent=e==="log"?this.log.sub:"Everything Dawnline depends on, checked live. The watchdog repairs what it can on its own.",dom.content(this.actionsEl,e==="log"?this.log.actions():""),e==="log"?(this.log.paint(),Date.now()-this.eventsAt>1e4&&P.events(Mo).then(r=>this.take(null,r)).catch(()=>null)):this.health.checks||this.health.run()}};var Xa=":root{--dl-card: var(--panel-bg, var(--background-color-high, transparent));--dl-elevated: var(--elevated, var(--background-color-high, Canvas));--dl-line: var(--border, var(--border-color-medium, color-mix(in srgb, currentColor 14%, transparent)));--dl-soft: var(--muted, color-mix(in srgb, currentColor 5%, transparent));--dl-soft-hover: var(--soft-hover, color-mix(in srgb, currentColor 10%, transparent));--dl-fg: var(--foreground, var(--text-color-highest, inherit));--dl-fg-muted: var(--muted-foreground, color-mix(in srgb, currentColor 65%, transparent));--dl-fg-faint: var(--text-tertiary, color-mix(in srgb, currentColor 50%, transparent));--dl-accent: var(--accent, #3a83f7);--dl-ok: var(--success, #00a240);--dl-warn: var(--warning, #e25507);--dl-bad: var(--danger, #e02e2a);--dl-ok-wash: var(--success-a15, color-mix(in srgb, #00a240 15%, transparent));--dl-warn-wash: var(--warning-a15, color-mix(in srgb, #e25507 15%, transparent));--dl-bad-wash: var(--destructive-a15, color-mix(in srgb, #e02e2a 15%, transparent));--dl-info-wash: var(--info-a15, color-mix(in srgb, #3a83f7 15%, transparent));--dl-info: var(--info, #2c67c5);--dl-track: var(--foreground-a10, color-mix(in srgb, currentColor 10%, transparent));--dl-chart-1: var(--chart-blue, #3a83f7);--dl-chart-2: var(--chart-green, #00a240);--dl-ring: var(--ring, #3a83f7);--dl-primary: var(--primary, #0d0d0d);--dl-primary-fg: var(--primary-foreground, #fff);--dl-mono: var(--font-mono, ui-monospace, Menlo, Consolas, monospace);--dl-shadow: var(--shadow-sm, none);--dl-radius: 16px}.dl-root,.dl-modal{cursor:default}:is(.dl-root,.dl-modal) :is(input:not([type=checkbox],[type=radio],[type=range],[type=button],[type=submit]),textarea,[contenteditable=true]){cursor:text}.dl-icon-wrap{display:inline-flex;align-items:center;justify-content:center;line-height:0}.dl-icon{width:16px;height:16px}.dl-icon-btn{display:inline-flex!important;align-items:center;gap:6px}.dl-muted{color:var(--dl-fg-muted)}.dl-faint,.dl-sep{color:var(--dl-fg-faint)}.dl-nowrap{white-space:nowrap}.dl-mono{font-family:var(--dl-mono);font-size:13px}.dl-spacer{flex:1}.dl-pill{display:inline-flex;align-items:center;gap:4px;height:20px;padding:0 8px;border-radius:999px;font-size:12px;line-height:20px;font-weight:500;white-space:nowrap;background:var(--dl-soft);color:var(--dl-fg-muted)}.dl-pill.ok{background:var(--dl-ok-wash);color:var(--dl-ok)}.dl-pill.warn{background:var(--dl-warn-wash);color:var(--dl-warn)}.dl-pill.bad{background:var(--dl-bad-wash);color:var(--dl-bad)}.dl-pill.accent{background:var(--dl-info-wash);color:var(--dl-info)}.dl-pill.off{opacity:.75}.dl-panel{background:var(--dl-card);border:1px solid var(--dl-line);border-radius:var(--dl-radius);padding:16px;margin:0 0 16px;min-width:0;box-shadow:var(--dl-shadow)}.dl-panel-head{display:flex;align-items:center;flex-wrap:wrap;gap:8px 12px;margin:0 0 12px}.dl-panel-head h3{margin:0!important;padding:0;font-size:16px;line-height:24px;font-weight:500;border:0;background:none}.dl-tiles{display:grid;grid-template-columns:repeat(auto-fit,minmax(170px,1fr));gap:12px;margin:0 0 16px}.dl-tile{background:var(--dl-card);border:1px solid var(--dl-line);border-radius:var(--dl-radius);padding:14px 16px;min-width:0;box-shadow:var(--dl-shadow)}.dl-tile-label{font-size:12px;line-height:16px;font-weight:500;color:var(--dl-fg-faint)}.dl-tile-value{font-size:24px;line-height:32px;font-weight:500;margin-top:4px;font-variant-numeric:tabular-nums;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;letter-spacing:-.01em}.dl-tile-sub{font-size:12px;line-height:16px;color:var(--dl-fg-muted);margin-top:2px;font-variant-numeric:tabular-nums}.dl-grid2{display:grid;grid-template-columns:minmax(0,1.45fr) minmax(0,1fr);gap:0 16px}@media(max-width:960px){.dl-grid2{grid-template-columns:minmax(0,1fr)}}.dl-chart{display:block;width:100%;height:120px}.dl-bar-down{fill:var(--dl-chart-1)}.dl-bar-up{fill:var(--dl-chart-2);opacity:.8}.dl-legend{display:flex;gap:16px;font-size:12px;color:var(--dl-fg-muted);margin-top:8px}.dl-legend i{display:inline-block;width:8px;height:8px;border-radius:999px;margin-right:6px;vertical-align:0}.dl-legend .down{background:var(--dl-chart-1)}.dl-legend .up{background:var(--dl-chart-2)}.dl-events{list-style:none;margin:0;padding:0}.dl-events li{display:flex;gap:12px;align-items:baseline;padding:8px 0;border-top:1px solid var(--dl-line);font-size:14px;line-height:20px;min-width:0}.dl-events li:first-child{border-top:0;padding-top:0}.dl-ev-time{flex:0 0 88px;color:var(--dl-fg-faint);font-variant-numeric:tabular-nums;white-space:nowrap;font-size:13px}.dl-ev-dot{flex:0 0 auto;width:6px;height:6px;border-radius:50%;background:var(--dl-fg-faint);transform:translateY(-2px)}.dl-ev-dot.ok{background:var(--dl-ok)}.dl-ev-dot.warn{background:var(--dl-warn)}.dl-ev-dot.bad{background:var(--dl-bad)}.dl-ev-dot.accent{background:var(--dl-accent)}.dl-row>.dl-ev-dot,.dl-dev-log-row>.dl-ev-dot{margin:0 4px}.dl-ev-tile{flex:none;display:inline-flex;align-items:center;justify-content:center;width:22px;height:22px;margin:-2px -4px;border-radius:7px;background:color-mix(in srgb,var(--dl-accent) 16%,transparent);color:var(--dl-accent);align-self:center}.dl-ev-tile .dl-icon-wrap{display:inline-flex}.dl-ev-tile .dl-icon{width:14px;height:14px}.dl-row.dl-ev-by-admin{background:color-mix(in srgb,var(--dl-accent) 6%,transparent)}.dl-you{color:var(--dl-accent);font-weight:500}.dl-ev-kind{color:var(--dl-fg-faint)}.dl-slotbar{display:flex;align-items:center;gap:8px;margin:8px 0 0 44px}.dl-slotbar-segs{display:flex;gap:3px;flex:none;max-width:100%}.dl-slotbar-segs i{flex:1;min-width:2px;display:block;height:4px;border-radius:2px;background:var(--dl-soft-hover)}.dl-slotbar-segs i.used{background:var(--dl-fg-muted)}.dl-slotbar-text{font-size:12px;color:var(--dl-fg-faint);font-variant-numeric:tabular-nums}.dl-slotbar-segs i.over{background:color-mix(in srgb,var(--dl-warn) 80%,transparent)}.dl-ev-srv{flex:none;font-size:11px;line-height:18px;padding:0 8px;border-radius:999px;background:var(--dl-soft);color:var(--dl-fg-muted);white-space:nowrap}.dl-ev-by-system{--sys: var(--dl-fg-muted)}.dl-ev-by-system.ok{--sys: var(--dl-ok)}.dl-ev-by-system.warn{--sys: var(--dl-warn)}.dl-ev-by-system.bad{--sys: var(--dl-bad)}.dl-ev-tile.ev{background:var(--dl-soft);color:var(--dl-fg-muted)}.dl-ev-tile.ev.ok{background:var(--dl-ok-wash);color:var(--dl-ok)}.dl-ev-tile.ev.warn{background:var(--dl-warn-wash);color:var(--dl-warn)}.dl-ev-tile.ev.bad{background:var(--dl-bad-wash);color:var(--dl-bad)}.dl-ev-tile.ev.accent{background:color-mix(in srgb,var(--dl-accent) 16%,transparent);color:var(--dl-accent)}.dl-ev-tile.sys{background:color-mix(in srgb,var(--sys) 16%,transparent);color:var(--sys)}.dl-row.dl-ev-by-system{background:color-mix(in srgb,var(--sys) 6%,transparent)}.dl-sys-src{color:var(--sys)}.dl-ev-by-system:not(.ok):not(.warn):not(.bad) .dl-sys-src{color:var(--dl-fg)}.dl-ev-text{min-width:0;overflow-wrap:anywhere}.dl-server{display:flex;flex-wrap:wrap;align-items:center;gap:8px 10px}.dl-server-name{font-size:16px;line-height:24px;font-weight:500}.dl-kv{display:grid;grid-template-columns:max-content minmax(0,1fr);gap:6px 24px;margin:12px 0 0;font-size:14px;line-height:20px}.dl-kv dt{color:var(--dl-fg-muted);font-weight:400;margin:0}.dl-kv dd{margin:0;overflow-wrap:anywhere;font-variant-numeric:tabular-nums}";var ei='.dl-plist{display:block}.dl-plist>.dl-card{display:block;margin:0 0 12px;padding:16px;min-width:0;background:var(--dl-card);border:1px solid var(--dl-line);border-radius:var(--dl-radius);box-shadow:var(--dl-shadow)}.dl-plist>.dl-card.dl-filtered{display:none}.dl-plist>.dl-card.dl-off :is(.dl-card-name,.dl-avatar,.dl-access,.dl-slotbar,.dl-chips,.dl-pill-ic,.dl-use-num,.dl-pside-foot,.dl-pside-state){opacity:.45}.dl-plist>.dl-card.dl-off .dl-usebar i{background:var(--dl-fg-faint)}.dl-plist>.dl-card.dl-off .dl-chip-tag{background:var(--dl-soft);color:var(--dl-fg-muted)}.dl-pcard:has(>.dl-pstrip){row-gap:14px}.dl-pstrip{grid-column:1 / -1;display:flex;align-items:center;flex-wrap:wrap;gap:8px 12px;margin:0 -16px -16px;padding:10px 16px;border-top:1px solid var(--dl-line);border-radius:0 0 var(--dl-radius) var(--dl-radius);font-size:14px;line-height:20px}.dl-pstrip.warn{background:color-mix(in srgb,var(--dl-warn) 7%,transparent)}.dl-pstrip.bad{background:color-mix(in srgb,var(--dl-bad) 7%,transparent)}.dl-pstrip-text{flex:1;min-width:0;display:flex;flex-wrap:wrap;align-items:baseline;gap:0 8px}.dl-pstrip-text b{font-weight:500}.dl-pstrip>.cbi-button{flex:none;height:32px!important}.dl-plist-none{color:var(--dl-fg-muted);text-align:center;padding:28px 16px;background:var(--dl-card);border:1px solid var(--dl-line);border-radius:var(--dl-radius)}.dl-card-head{display:flex;align-items:center;flex-wrap:wrap;gap:6px 8px}.dl-avatar{flex:0 0 auto;width:32px;height:32px;border-radius:50%;display:inline-flex;align-items:center;justify-content:center;font-size:12px;font-weight:600;color:var(--dl-fg);background:var(--dl-soft);position:relative;margin-right:4px;letter-spacing:.02em}.dl-avatar.online:after{content:"";position:absolute;right:-1px;bottom:-1px;width:9px;height:9px;border-radius:50%;background:var(--dl-ok);box-shadow:0 0 0 2px var(--dl-card)}.dl-card-name{font-size:16px;line-height:24px;font-weight:500}.dl-card-slug{font-size:13px;color:var(--dl-fg-faint);font-family:var(--dl-mono)}.dl-quota{margin:8px 0 0 44px;max-width:320px;height:6px;border-radius:999px;background:var(--dl-track);overflow:hidden}.dl-quota>i{display:block;height:100%;background:var(--dl-accent);border-radius:999px}.dl-quota.warn>i{background:var(--dl-warn)}.dl-quota.bad>i{background:var(--dl-bad)}.dl-chips{display:flex;flex-wrap:wrap;gap:6px;margin:12px 0 0 44px}.dl-chip{all:unset;box-sizing:border-box;cursor:pointer;display:inline-flex;align-items:center;gap:6px;max-width:240px;height:28px;padding:0 12px 0 10px;border-radius:999px;font-size:13px;background:var(--dl-soft);color:var(--dl-fg);transition:background .15s}.dl-chip:hover{background:var(--dl-soft-hover)}.dl-chip:focus-visible{outline:2px solid var(--dl-ring);outline-offset:2px}.dl-chip .dl-icon{width:14px;height:14px;color:var(--dl-fg-muted)}.dl-chip.add{background:transparent;border:1px dashed color-mix(in srgb,var(--dl-fg) 28%,transparent);color:var(--dl-fg-muted)}.dl-chip.add:hover{background:var(--dl-soft);color:var(--dl-fg);border-color:color-mix(in srgb,var(--dl-fg) 45%,transparent)}.dl-chip.add:hover .dl-icon{color:var(--dl-fg)}.dl-chip.disabled .dl-chip-name{text-decoration:line-through;color:var(--dl-fg-faint)}.dl-chip-name{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-dot{flex:0 0 auto;width:6px;height:6px;border-radius:50%;background:var(--dl-fg-faint);opacity:.6}.dl-dot.online{background:var(--dl-ok);opacity:1;box-shadow:0 0 0 3px var(--dl-ok-wash)}.dl-empty{text-align:center;padding:40px 16px;background:var(--dl-card);border:1px solid var(--dl-line);border-radius:var(--dl-radius)}.dl-empty .dl-icon-wrap{width:40px;height:40px;border-radius:12px;background:var(--dl-soft);margin-bottom:12px}.dl-empty .dl-icon{width:20px;height:20px}.dl-empty h3{margin:0 0 4px!important;font-size:16px;font-weight:500}.dl-empty p{margin:0 0 16px;color:var(--dl-fg-muted);font-size:14px}.dl-toolbar{display:flex;flex-wrap:wrap;align-items:center;gap:8px 12px;margin:0 0 16px}.dl-toolbar .dl-muted{font-size:13px}@media(max-width:640px){.dl-slotbar,.dl-chips,.dl-quota{margin-left:0}.dl-btn-label{display:none}}.cbi-value.dl-block{display:block!important}.cbi-value.dl-block>.cbi-value-title{display:block;width:auto;float:none;text-align:left;padding:0 0 8px}.cbi-value.dl-block>.cbi-value-field{display:block;width:100%;margin:0}.dl-people-find{width:160px;min-width:0}.dl-people-find[hidden]{display:none}';var ti="#modal_overlay{z-index:1100!important}.dl-dd{position:fixed;z-index:1200;min-width:200px;padding:4px;border-radius:12px;background:var(--dl-elevated);border:1px solid var(--dl-line);box-shadow:0 12px 32px #0000004d;display:flex;flex-direction:column}.dl-dd button{all:unset;cursor:pointer;display:flex;align-items:center;gap:10px;padding:7px 10px;border-radius:8px;font-size:13px;color:var(--dl-fg)}.dl-dd button .dl-icon{width:15px;height:15px;color:var(--dl-fg-muted)}.dl-dd button:hover,.dl-dd button:focus-visible{background:var(--dl-soft)}.dl-dd button.danger,.dl-dd button.danger .dl-icon{color:var(--dl-bad, #e5484d)}.dl-dd button.warn,.dl-dd button.warn .dl-icon{color:var(--dl-warn)}.dl-dd hr{border:0;border-top:1px solid var(--dl-line);margin:4px 0}.dl-chipbtn b{font-weight:500;font-size:11px;margin-left:6px;opacity:.6}.dl-setsub{margin:20px 0 8px!important;font-size:13px;font-weight:500;color:var(--dl-fg)}.dl-row-actions{display:flex;flex-wrap:wrap;gap:8px;align-items:center}.dl-more-row{display:flex;justify-content:center;padding:8px 0 16px}.dl-dsec-actions{display:flex;align-items:center;gap:12px}.dl-kv-act{display:inline-flex;align-items:center;gap:12px;flex-wrap:wrap}.dl-linkbtn,.dl-bento-head a,.dl-bento-foot a,.dl-panel-head a,.dl-dsec-head a,.dl-tile2-foot a{all:unset;box-sizing:border-box;cursor:pointer;display:inline-flex;align-items:center;gap:4px;height:26px;padding:0 9px;margin:-4px -6px;border-radius:8px;font-size:12px;font-weight:500;color:var(--dl-fg-muted);text-decoration:none!important;white-space:nowrap;transition:background .12s,color .12s}.dl-bento-head a,.dl-bento-foot a,.dl-panel-head a,.dl-dsec-head a,.dl-tile2-foot a{color:var(--dl-accent)}.dl-linkbtn:hover,.dl-bento-head a:hover,.dl-bento-foot a:hover,.dl-panel-head a:hover,.dl-dsec-head a:hover,.dl-tile2-foot a:hover{background:var(--dl-soft);color:var(--dl-fg);text-decoration:none!important}.dl-bento-head a:hover,.dl-bento-foot a:hover,.dl-panel-head a:hover,.dl-dsec-head a:hover,.dl-tile2-foot a:hover{background:color-mix(in srgb,var(--dl-accent) 12%,transparent);color:var(--dl-accent)}.dl-linkbtn:focus-visible,.dl-bento-head a:focus-visible,.dl-bento-foot a:focus-visible,.dl-panel-head a:focus-visible{outline:2px solid var(--dl-ring);outline-offset:1px}.dl-linkbtn.danger:hover{color:var(--dl-bad);background:var(--dl-bad-wash)}.dl-ifcards{display:flex;flex-direction:column;gap:20px;margin:24px 0}.dl-ifcard .dl-setsec-body{gap:14px}.dl-iflead{display:flex;flex-direction:column;gap:2px;padding-top:14px;border-top:1px solid var(--dl-line)}.dl-iflead b{font-size:14px;font-weight:500}.dl-ifgroup h4{margin:0 0 8px!important;padding:0!important;font-size:11px!important;font-weight:500!important;letter-spacing:.06em;text-transform:uppercase;color:var(--dl-fg-muted);border:0!important;background:none!important}.dl-ifgrid{display:grid;grid-template-columns:repeat(auto-fill,minmax(210px,1fr));gap:8px}.dl-if{all:unset;box-sizing:border-box;cursor:pointer;display:flex;align-items:center;gap:10px;min-height:52px;padding:8px 12px 8px 10px;min-width:0;border:1px solid var(--dl-line);border-radius:10px;background:var(--dl-card);transition:background .15s,border-color .15s}.dl-if:hover{background:var(--dl-soft)}.dl-if:focus-visible{outline:2px solid var(--dl-ring);outline-offset:2px}.dl-if-ic{width:30px;height:30px;border-radius:8px;background:var(--dl-soft);display:inline-flex;align-items:center;justify-content:center;flex:0 0 auto;color:var(--dl-fg-muted)}.dl-if-ic .dl-icon{width:16px;height:16px}.dl-if-main{display:flex;flex-direction:column;min-width:0;flex:1}.dl-if-name{font-size:13.5px;font-weight:500;color:var(--dl-fg);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.dl-if-sub{font:11px/16px var(--dl-mono);color:var(--dl-fg-muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.dl-if.sel{border-color:var(--dl-accent);background:color-mix(in srgb,var(--dl-accent) 9%,transparent)}.dl-if.sel .dl-if-ic{background:color-mix(in srgb,var(--dl-accent) 18%,transparent);color:var(--dl-accent)}.dl-if-check{color:var(--dl-accent);display:inline-flex}.dl-if-check .dl-icon{width:16px;height:16px}.dl-if.auto{border-color:color-mix(in srgb,var(--dl-ok) 55%,transparent);background:var(--dl-ok-wash);cursor:default}.dl-if.auto .dl-if-ic{background:color-mix(in srgb,var(--dl-ok) 18%,transparent);color:var(--dl-ok)}.dl-if-badge{display:inline-flex;align-items:center;gap:5px;font-size:10.5px;font-weight:600;letter-spacing:.05em;text-transform:uppercase;flex:0 0 auto}.dl-if-badge.ok{color:var(--dl-ok)}.dl-if.off{cursor:default;opacity:.5}.dl-if.off:hover{background:var(--dl-card)}.dl-if.warn{border-color:color-mix(in srgb,var(--dl-warn) 60%,transparent)}.dl-if-wanctl{gap:10px;align-items:center}.dl-if-wanctl select{max-width:240px}.dl-if-summary{min-width:0;line-height:18px}.dl-warn{color:var(--dl-warn)}.dl-w-ip{width:160px}.dl-dnspick{padding-top:8px;border-top:1px solid var(--dl-line)}.dl-dnspick .dl-row-actions{gap:10px}.dl-note{display:flex;gap:8px;align-items:flex-start;padding:10px 12px;border-radius:10px;font-size:12.5px;line-height:18px;margin:0 0 10px;background:var(--dl-soft)}.dl-note.warn{background:var(--dl-warn-wash, color-mix(in srgb, var(--dl-warn) 14%, transparent))}.dl-note .dl-icon{width:15px;height:15px;flex:0 0 auto;margin-top:1px;color:var(--dl-warn)}.dl-stale{align-self:flex-start;margin-top:4px;font-size:10.5px}.dl-root .cbi-button.dl-btn-warn,.dl-btn-warn.cbi-button{background:var(--dl-warn-wash)!important;color:var(--dl-warn)!important;border-color:color-mix(in srgb,var(--dl-warn) 35%,transparent)!important}.dl-root .cbi-button.dl-btn-warn:hover,.dl-btn-warn.cbi-button:hover{background:color-mix(in srgb,var(--dl-warn) 24%,transparent)!important}.dl-btn-warn .dl-icon{color:var(--dl-warn)}.dl-srvtabs{display:flex;flex-wrap:wrap;gap:6px;padding:4px;margin:0 0 20px;border-radius:12px;background:var(--dl-soft);width:fit-content;max-width:100%}.dl-srvtab{all:unset;box-sizing:border-box;cursor:pointer;display:inline-flex;align-items:center;gap:8px;height:34px;padding:0 14px;border-radius:9px;font-size:13px;color:var(--dl-fg-muted);text-decoration:none!important;white-space:nowrap}.dl-srvtab b{font-weight:500}.dl-srvtab i.dot{width:7px;height:7px;border-radius:50%;background:var(--dl-fg-faint);flex:0 0 auto}.dl-srvtab i.dot.ok{background:var(--dl-ok);animation:dl-srv-pulse 2s ease-out infinite}.dl-srvtab i.dot.bad{background:var(--dl-bad)}.dl-srvtab i.dot.warn{background:var(--dl-warn)}@keyframes dl-srv-pulse{0%{box-shadow:0 0 color-mix(in srgb,var(--dl-ok) 55%,transparent)}70%,to{box-shadow:0 0 0 6px transparent}}@media(prefers-reduced-motion:reduce){.dl-srvtab i.dot.ok{animation:none}}.dl-srvtab:hover{color:var(--dl-fg);background:var(--dl-soft-hover)}.dl-srvtab.on{background:var(--dl-card);color:var(--dl-fg);box-shadow:0 1px 2px #0000002e,inset 0 0 0 1px var(--dl-line)}.dl-srvtab:focus-visible{outline:2px solid var(--dl-ring);outline-offset:1px}.dl-srvtab.add{color:var(--dl-fg-muted)}.dl-srvtab.add .dl-icon{width:14px;height:14px}.dl-srvhead{display:flex;flex-direction:column;gap:14px;margin:0 0 20px}.dl-srvhead .dl-title-row{display:flex;align-items:center;gap:10px}.dl-srvhead .dl-h1{margin:0!important}.dl-metrics.compact .dl-metric{padding:14px 18px}.dl-metrics.compact .dl-metric-value{display:flex;align-items:center;gap:6px;font-size:18px;line-height:26px;min-width:0}.dl-metrics.compact .dl-metric-value>span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0}.dl-metrics.compact .dl-metric-value .dl-mono{font-size:15px}.dl-metrics.compact .cbi-button{flex:0 0 auto}.dl-srvsections{margin:0 0 16px}.dl-srvbody>.dl-setsec,.dl-srvbody>.dl-ifcards{margin:0}.dl-srvbody .dl-ifcards{margin:0}.dl-metric-ic{display:inline-flex;align-items:center;gap:8px;font-size:16px}.dl-metric-ic .dl-icon{width:18px;height:18px;color:var(--dl-accent)}.dl-keyrow{display:inline-flex;align-items:center;gap:8px;min-width:0}.dl-keyrow code{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:12px;background:none;padding:0}.dl-params{border:1px solid var(--dl-line);border-radius:12px;background:var(--dl-card)}.dl-params>summary{list-style:none;cursor:pointer;display:flex;align-items:center;gap:8px;padding:10px 14px;font-size:13px;color:var(--dl-fg);user-select:none}.dl-params>summary::-webkit-details-marker{display:none}.dl-params>summary>.dl-icon-wrap{display:inline-flex;color:var(--dl-fg-muted);transition:transform .15s}.dl-params>summary>.dl-icon-wrap .dl-icon{width:15px;height:15px}.dl-params[open]>summary>.dl-icon-wrap{transform:rotate(90deg)}.dl-params>summary:focus{outline:none}.dl-params>summary:focus-visible{outline:2px solid var(--dl-ring);outline-offset:-2px;border-radius:12px}.dl-params>summary:hover{background:var(--dl-soft);border-radius:12px}.dl-pcount{font-size:11px;padding:0 6px;border-radius:999px;background:var(--dl-soft);color:var(--dl-fg-muted)}.dl-pgrid{display:grid;grid-template-columns:repeat(auto-fill,minmax(260px,1fr));gap:10px;padding:4px 14px 14px}.dl-pgroup{display:flex;flex-direction:column;gap:6px;padding:12px;border-radius:10px;background:var(--dl-soft);min-width:0}.dl-pgroup-head{display:flex;align-items:center;gap:8px;font-size:13px}.dl-pgroup-head b{font-weight:500}.dl-pgroup-head .dl-icon{width:14px;height:14px;color:var(--dl-fg-muted)}.dl-pgroup p{margin:0!important;font-size:12px;line-height:17px;color:var(--dl-fg-muted)}.dl-pvals{display:flex;flex-wrap:wrap;gap:4px;margin-top:2px}.dl-pv{display:inline-flex;align-items:stretch;max-width:100%;border-radius:6px;overflow:hidden;font:500 11.5px/22px var(--dl-mono);box-shadow:inset 0 0 0 1px var(--dl-line)}.dl-pv i{font-style:normal;padding:0 6px;background:var(--dl-card);color:var(--dl-fg-faint)}.dl-pv b{font-weight:500;padding:0 7px;color:var(--dl-fg);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0}";var ni=".dl-methods{display:grid;grid-template-columns:repeat(auto-fit,minmax(210px,1fr));gap:10px}.dl-method{all:unset;box-sizing:border-box;cursor:pointer;display:flex;flex-direction:column;gap:10px;padding:14px;border-radius:12px;border:1px solid var(--dl-line);background:var(--dl-card);transition:border-color .15s,background .15s;min-width:0}.dl-method:hover{background:var(--dl-soft)}.dl-method:focus-visible{outline:2px solid var(--dl-ring);outline-offset:2px}.dl-method.on{border-color:var(--dl-accent);background:color-mix(in srgb,var(--dl-accent) 8%,transparent);box-shadow:inset 0 0 0 1px var(--dl-accent)}.dl-method.off{cursor:not-allowed;opacity:.55}.dl-method.off:hover{background:var(--dl-card)}.dl-method-head{display:flex;flex-wrap:wrap;align-items:center;gap:8px 10px}.dl-method-head .dl-pill{flex:none}.dl-method-head b{font-weight:500;font-size:14.5px;flex:1}.dl-method-ic{width:32px;height:32px;border-radius:9px;background:var(--dl-soft);display:inline-flex;align-items:center;justify-content:center;color:var(--dl-fg-muted);flex:0 0 auto}.dl-method-ic .dl-icon{width:17px;height:17px}.dl-method.on .dl-method-ic{background:color-mix(in srgb,var(--dl-accent) 18%,transparent);color:var(--dl-accent)}.dl-method p{margin:0!important;font-size:12.5px;line-height:18px;color:var(--dl-fg-muted);flex:1}.dl-method-meters{display:flex;gap:16px}.dl-dots{display:inline-flex;align-items:center;gap:6px;font-size:11px;color:var(--dl-fg-faint)}.dl-dots-row{display:inline-flex;gap:3px}.dl-dots-row i{width:6px;height:6px;border-radius:50%;background:var(--dl-line)}.dl-dots-row i.on{background:var(--dl-fg-muted)}.dl-method.on .dl-dots-row i.on{background:var(--dl-accent)}.dl-method-foot{display:flex;align-items:center;gap:6px;font-size:11.5px;color:var(--dl-fg-faint);padding-top:8px;border-top:1px solid var(--dl-line)}.dl-method-foot .dl-icon{width:13px;height:13px;flex:0 0 auto}.dl-method.off .dl-method-foot{color:var(--dl-warn)}.dl-ibadge{display:inline-flex;align-items:center;gap:3px;height:22px;padding:0 6px;border-radius:999px;background:var(--dl-soft);color:var(--dl-fg-muted);flex:0 0 auto}.dl-ibadge .dl-icon{width:13px;height:13px}.dl-ibadge.warn{background:var(--dl-warn-wash);color:var(--dl-warn)}.dl-ibadge.bad{background:var(--dl-bad-wash);color:var(--dl-bad)}.dl-access{display:inline-flex;gap:4px;flex:0 0 auto}.dl-ibadge.lan{background:color-mix(in srgb,var(--dl-accent) 16%,transparent);color:var(--dl-accent)}.dl-ibadge.inet{background:var(--dl-ok-wash);color:var(--dl-ok)}";var oi=".dl-addrbar{display:inline-flex;align-items:stretch;flex-wrap:nowrap;max-width:100%;margin-top:4px;border:1px solid var(--dl-line);border-radius:10px;background:var(--dl-card);overflow:hidden}.dl-addrbar-seg{all:unset;box-sizing:border-box;display:inline-flex;align-items:center;gap:7px;padding:6px 12px;font-size:13px;color:var(--dl-fg-muted);border-left:1px solid var(--dl-line);white-space:nowrap;min-width:0}.dl-addrbar-seg:first-child{border-left:0}.dl-addrbar-seg .dl-icon{width:14px;height:14px;color:var(--dl-fg-faint);flex:0 0 auto}.dl-addrbar-seg .dl-mono{font-size:12.5px}.dl-addrbar-seg.main{cursor:pointer;color:var(--dl-fg)}.dl-addrbar-seg.main:hover{background:var(--dl-soft)}.dl-addrbar-seg.main:focus-visible{outline:2px solid var(--dl-ring);outline-offset:-2px}.dl-addrbar-seg.main>.dl-icon-wrap:last-child .dl-icon{opacity:.7}.dl-bento{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));grid-template-rows:auto auto;gap:10px;margin:0 0 20px}.dl-person-devices{margin-bottom:16px}.dl-person-head{display:flex;flex-direction:column;margin:0 0 20px}.dl-person-head>.dl-pagehead{margin-bottom:0;align-items:flex-start}.dl-pnote{all:unset;box-sizing:border-box;cursor:pointer;align-self:flex-start;display:inline-flex;align-items:flex-start;gap:6px;margin:10px 0 0 62px;max-width:60ch;padding:6px 12px 6px 10px;border-radius:10px;font-size:13px;line-height:18px;white-space:pre-line;background:var(--dl-soft);color:var(--dl-fg);box-shadow:inset 0 0 0 1px var(--dl-line)}.dl-pnote:hover{background:var(--dl-soft-hover)}.dl-pnote .dl-icon{width:14px;height:14px;flex:none;margin-top:2px;color:var(--dl-fg-muted)}.dl-note-input{width:100%;box-sizing:border-box;min-height:80px;resize:vertical}.dl-dcard-trend{display:flex;align-items:flex-end;gap:12px;min-width:0}.dl-dcard-trend>.dl-stack{flex:none}.dl-dcard-trend b{font-size:16px;font-weight:500;font-variant-numeric:tabular-nums}.dl-dbars{flex:1;min-width:0;height:32px;display:flex;align-items:flex-end;gap:2px}.dl-dbars i{flex:1;min-width:0;border-radius:2px;background:var(--dl-chart-1);opacity:.55}.dl-dbars i.zero{background:var(--dl-track);opacity:1}.dl-dbars i.hi{opacity:1}.dl-dbars i:hover{opacity:1;filter:brightness(1.2)}.dl-datechip{position:relative;display:inline-flex}.dl-date-hidden{position:absolute!important;left:0;bottom:0;width:1px!important;min-width:0!important;height:1px!important;opacity:0;pointer-events:none;border:0!important;padding:0!important;margin:0!important}.dl-chipbtn .dl-icon{width:13px;height:13px}.dl-chipbtn:has(.dl-icon){display:inline-flex;align-items:center;gap:5px}.dl-places{display:flex;align-items:center;gap:12px;padding:12px 16px;border:1px solid var(--dl-line);border-radius:var(--dl-radius);background:var(--dl-card);font-size:14px}.dl-places>.dl-icon{width:18px;height:18px;color:var(--dl-fg-muted);flex:none}.dl-person-live{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:10px}.dl-person-live .dl-bento-head{flex-wrap:nowrap;white-space:nowrap;min-width:0}.dl-person-live .dl-bento-head>*{min-width:0;overflow:hidden;text-overflow:ellipsis}.dl-person-live .dl-bento-head>:first-child{flex:none}.dl-person-live.solo{grid-template-columns:minmax(0,1fr)}.dl-person-live:not(.solo) .dl-bento-tile.month>.dl-bento-head:first-child{flex-wrap:wrap;row-gap:2px}.dl-person-live:not(.solo) .dl-bento-tile.month>.dl-bento-head:first-child>.dl-sub{flex-basis:100%}.dl-person-live>.dl-bento-tile,.dl-person-live>.dl-bento-tile.month{grid-column:auto;grid-row:auto}@media(max-width:760px){.dl-person-live{grid-template-columns:minmax(0,1fr)}}.dl-bento-tile{background:var(--dl-card);border:1px solid var(--dl-line);border-radius:var(--dl-radius);padding:14px 16px;display:flex;flex-direction:column;gap:10px;min-width:0;box-shadow:var(--dl-shadow)}.dl-bento-tile.month{grid-column:1 / -1}.dl-onl-count{font-size:13px;line-height:22px;min-width:22px;padding:0 8px;border-radius:999px;background:var(--dl-soft);text-align:center;font-weight:500;font-variant-numeric:tabular-nums}.dl-onl-count.none{color:var(--dl-fg-faint)}.dl-onl-row{flex:1;display:flex;align-items:center;justify-content:center;gap:12px;min-width:0}.dl-onl-p{display:flex;flex-direction:column;align-items:center;gap:5px;width:104px;min-width:0;padding:6px 2px;border-radius:12px;color:var(--dl-fg)!important;text-decoration:none!important}.dl-onl-p:hover{background:var(--dl-soft)}.dl-onl-av{position:relative;width:42px;height:42px;border-radius:50%;background:var(--dl-soft);display:inline-flex;align-items:center;justify-content:center;font-size:13px;font-weight:500;box-shadow:0 0 0 2px var(--dl-ok)}.dl-onl-p.more .dl-onl-av{box-shadow:0 0 0 1px var(--dl-line);color:var(--dl-fg-muted)}.dl-onl-dev{position:absolute;right:-6.5px;bottom:-6.5px;width:20px;height:20px;border-radius:8.5px;border:1.5px solid transparent;background:var(--dl-card);display:inline-flex;align-items:center;justify-content:center;font-size:10px;color:var(--dl-fg-muted)}.dl-onl-dev .dl-icon-wrap{display:inline-flex}.dl-onl-dev .dl-icon{width:12px;height:12px}.dl-onl-name{font-size:12.5px;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-onl-p .dl-sub{font-size:11px;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-onl-row.grid{flex-wrap:wrap;align-content:center;gap:10px 8px;max-height:108px;overflow:hidden}.dl-onl-p.sm{width:auto;padding:4px}.dl-onl-p:hover .dl-onl-dev{background:linear-gradient(var(--dl-soft),var(--dl-soft)),var(--dl-card)}.dl-onl-p.sm:hover{background:none}.dl-onl-p.sm:hover .dl-onl-dev{background:var(--dl-card)}.dl-onl-p.sm .dl-onl-av{transition:box-shadow .15s ease}.dl-onl-p.sm:hover .dl-onl-av{box-shadow:0 0 0 2px var(--dl-ok),0 0 0 6px var(--dl-soft)}.dl-onl-p.sm.more:hover .dl-onl-av{box-shadow:0 0 0 1px var(--dl-line),0 0 0 6px var(--dl-soft)}.dl-onl-p.sm .dl-onl-av{width:36px;height:36px;font-size:11.5px}.dl-onl-meta{display:inline-flex;align-items:center;gap:3px;font-size:11px;color:var(--dl-fg-faint);max-width:100%;white-space:nowrap;overflow:hidden}.dl-onl-meta .dl-icon-wrap{display:inline-flex}.dl-onl-meta .dl-icon{width:12px;height:12px}.dl-onl-av.sm{width:34px;height:34px;font-size:11.5px}.dl-tip-float:has(.dl-hc){padding:0;white-space:normal;border-radius:16px}.dl-hc{width:280px;padding:14px;display:flex;flex-direction:column;gap:10px}.dl-hc-head{display:flex;align-items:center;gap:10px}.dl-hc-head .dl-stack{flex:1;min-width:0}.dl-hc-head b{font-size:14px;font-weight:500}.dl-hc-since{font-size:11.5px;color:var(--dl-ok)}.dl-hc-reach{display:inline-flex;gap:4px}.dl-hc-speed{border-radius:12px;background:var(--dl-soft);padding:10px 12px;display:flex;flex-direction:column;gap:6px}.dl-hc-speed-row{display:flex;align-items:baseline;gap:12px;font-size:13px;font-variant-numeric:tabular-nums}.dl-hc-chart{display:block;width:100%;height:30px}.dl-hc-chart .area{fill:color-mix(in srgb,var(--dl-chart-1) 16%,transparent)}.dl-hc-chart .dn{fill:none;stroke:var(--dl-chart-1);stroke-width:1.5;vector-effect:non-scaling-stroke}.dl-hc-chart .up{fill:none;stroke:var(--dl-ok);stroke-width:1.2;vector-effect:non-scaling-stroke}.dl-hc-devs{display:flex;flex-wrap:wrap;gap:6px}.dl-hc-dev{display:inline-flex;align-items:center;gap:5px;height:24px;padding:0 9px;border-radius:999px;background:var(--dl-soft);font-size:11.5px}.dl-hc-dev .dl-icon-wrap{display:inline-flex}.dl-hc-dev .dl-icon{width:12px;height:12px;color:var(--dl-fg-muted)}.dl-hc-foot{display:flex;align-items:center;gap:8px;font-size:11.5px}.dl-disg-id{display:flex;align-items:center;gap:10px}.dl-disg-id b{font-size:16px;font-weight:500}.dl-disg-ic{width:36px;height:36px;border-radius:11px;background:color-mix(in srgb,var(--dl-accent) 14%,transparent);color:var(--dl-accent);display:inline-flex;align-items:center;justify-content:center;flex:none}.dl-disg-ic .dl-icon-wrap{display:inline-flex}.dl-disg-ic .dl-icon{width:18px;height:18px}.dl-disg-ic.off{background:var(--dl-soft);color:var(--dl-fg-muted)}.dl-disg-meters{display:grid;grid-template-columns:auto 1fr;gap:6px 10px;align-items:center;font-size:12px;color:var(--dl-fg-muted)}.dl-segs{display:inline-flex;gap:3px}.dl-segs i{width:18px;height:5px;border-radius:3px;background:var(--dl-track)}.dl-segs.acc i.on{background:var(--dl-accent)}.dl-segs.ok i.on{background:var(--dl-ok)}.dl-disg-chips{margin-top:auto;display:flex;flex-wrap:wrap;gap:5px}.dl-disg-chips span{font:11px/20px var(--dl-mono);padding:0 8px;border-radius:999px;background:var(--dl-soft);color:var(--dl-fg-muted);white-space:nowrap}.dl-onl-empty{flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:4px;font-size:13px;text-align:center}.dl-bento-head{display:flex;align-items:center;justify-content:space-between;gap:10px;min-width:0}.dl-bento-head.start{justify-content:flex-start}.dl-bento-big{font-family:inherit;font-size:28px;line-height:34px;font-weight:500;letter-spacing:-.01em;font-variant-numeric:tabular-nums;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.dl-bento-big small{font-size:13px;font-weight:400;color:var(--dl-fg-faint);letter-spacing:0}.dl-avstack{display:inline-flex}.dl-avstack .dl-avatar{margin-left:-7px;box-shadow:0 0 0 2px var(--dl-card)}.dl-avstack .dl-avatar:first-child{margin-left:0}.dl-avatar.more{background:var(--dl-soft);color:var(--dl-fg-muted)}.dl-bento-list{display:flex;flex-direction:column;gap:2px}.dl-bento-row{display:flex;align-items:center;gap:10px;padding:8px;margin:0 -8px;border-radius:10px;color:var(--dl-fg)!important;text-decoration:none!important;min-width:0;transition:background .12s}.dl-bento-row:hover{background:var(--dl-soft)}.dl-bento-row:hover b{text-decoration:none}.dl-bento-row:focus-visible{outline:2px solid var(--dl-ring);outline-offset:-2px}.dl-bento-row-main{display:flex;flex-direction:column;gap:1px;flex:1;min-width:0}.dl-bento-row-main b{font-weight:500;font-size:13.5px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-bento-row-main .dl-sub{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-bento-row.off b{color:var(--dl-fg-muted);font-weight:400}.dl-bento-row-val{display:flex;flex-direction:column;align-items:flex-end;font-size:13px;font-variant-numeric:tabular-nums;white-space:nowrap}.dl-bento-row-val small{font-size:11px;color:var(--dl-fg-faint)}.dl-bento-sep{font-size:11px;color:var(--dl-fg-faint);padding:12px 0 4px}.dl-bento-devs{display:inline-flex;gap:3px;color:var(--dl-fg-faint)}.dl-bento-devs .dl-icon{width:13px;height:13px}.dl-bento-devs .on{color:var(--dl-ok)}.dl-bento-foot{display:flex;align-items:center;gap:10px;margin-top:auto;padding-top:10px;border-top:1px solid var(--dl-line);color:var(--dl-fg)!important;text-decoration:none!important}.dl-bento-foot.split,.dl-bento-foot.end{justify-content:space-between}.dl-bento-foot.end>a:only-child{margin-left:auto}.dl-bento-empty{display:flex;align-items:center;gap:10px;padding:14px 0;font-size:13.5px;color:var(--dl-fg-muted)}.dl-bento-empty .dl-icon{width:18px;height:18px}.dl-split{display:flex;height:6px;border-radius:3px;overflow:hidden;background:var(--dl-soft)}.dl-split i{display:block;height:100%}.dl-split i.dn{background:var(--dl-accent)}.dl-split i.up{background:var(--dl-ok)}.dl-dn{color:var(--dl-accent)}.dl-up{color:var(--dl-ok)}.dl-bento-method{display:flex;align-items:center;gap:8px;font-size:18px;font-weight:500}.dl-bento-method .dl-icon{width:20px;height:20px;color:var(--dl-accent)}.dl-meter{display:inline-flex;gap:3px}.dl-meter i{width:16px;height:4px;border-radius:2px;background:var(--dl-line)}.dl-meter i.on{background:var(--dl-accent)}.dl-bento-total{font-size:16px;font-weight:500;margin-left:8px}.dl-bento-bars{display:flex;align-items:flex-end;gap:3px;height:54px}.dl-bento-bars i{flex:1;min-width:0;border-radius:3px 3px 0 0;background:var(--dl-soft-hover);transition:background .15s}.dl-bento-bars i.future{height:4px;background:var(--dl-soft)}.dl-bento-bars i:hover{background:var(--dl-fg-faint)}.dl-bento-bars i.hi{background:var(--dl-accent)}@media(max-width:700px){.dl-addrbar{flex-wrap:wrap}}@media(max-width:900px){.dl-bento{grid-template-columns:minmax(0,1fr) minmax(0,1fr)}.dl-bento-tile.online{grid-column:span 2}}@media(max-width:560px){.dl-bento{grid-template-columns:minmax(0,1fr)}.dl-bento-tile.online,.dl-bento-tile.month{grid-column:auto}}.dl-srvpagehead{display:flex;flex-direction:column;align-items:flex-start;gap:10px;margin:0 0 20px}.dl-srvpagehead>.dl-title-row{display:flex;align-items:center;gap:10px;width:100%;flex-wrap:wrap}.dl-srvpagehead .dl-actions{margin:0;flex-wrap:wrap}.dl-toolbar-end{display:flex;align-items:center;gap:8px;margin-left:auto;flex-wrap:nowrap;min-width:0}@media(max-width:640px){.dl-toolbar-end{flex-wrap:wrap;width:100%}}.dl-notices{margin:0 0 16px}.dl-notices .dl-need-row .dl-sub{overflow-wrap:anywhere}.dl-notices-more{font-size:13px;color:var(--dl-fg-muted);text-decoration:none}.dl-notices-more:hover{background:var(--dl-soft);color:var(--dl-fg)}.dl-speed-cols{display:grid;grid-template-columns:1fr 1fr;gap:12px}.dl-speed-col{display:flex;flex-direction:column;gap:2px;min-width:0}.dl-speed-val{font-size:20px;line-height:26px;font-weight:500;font-variant-numeric:tabular-nums;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.dl-speed-today{display:flex;justify-content:space-between;gap:10px;font-size:12px;color:var(--dl-fg-muted);white-space:nowrap;font-variant-numeric:tabular-nums}.dl-speed-today b{font-weight:500;color:var(--dl-fg)}.dl-speed-chart{display:block;width:100%;height:44px}.dl-speed-chart .area{fill:color-mix(in srgb,var(--dl-accent) 16%,transparent)}.dl-speed-chart .line{fill:none;stroke:var(--dl-accent);stroke-width:1.5;vector-effect:non-scaling-stroke}.dl-speed-chart .line.up{stroke:var(--dl-ok);stroke-width:1.2;opacity:.85}.dl-speed-wait{height:44px;display:flex;flex-direction:column;justify-content:flex-end;gap:6px;font-size:11px;color:var(--dl-fg-faint)}.dl-speed-wait i{display:block;height:1px;background:var(--dl-line);order:2}.dl-speed-val.off{color:var(--dl-fg-faint)}.dl-fld{display:flex;flex-direction:column;gap:8px;margin:0 0 16px}.dl-fld-label{font-size:13px;font-weight:500;color:var(--dl-fg)}.dl-fld .cbi-input-text{width:100%;box-sizing:border-box}.dl-kinds{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:6px}.dl-kinds button{all:unset;box-sizing:border-box;cursor:pointer;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:6px;height:68px;border-radius:10px;border:1px solid var(--dl-line);color:var(--dl-fg-muted);font-size:12px;font-weight:500;text-align:center;min-width:0}.dl-kinds button .dl-icon{width:20px;height:20px}.dl-kinds button:hover{background:var(--dl-soft);color:var(--dl-fg)}.dl-kinds button:focus-visible{outline:2px solid var(--dl-ring);outline-offset:2px}.dl-kinds button.on{border-color:var(--dl-accent);color:var(--dl-fg);background:color-mix(in srgb,var(--dl-accent) 10%,transparent);box-shadow:inset 0 0 0 1px var(--dl-accent)}.dl-kinds button.on .dl-icon{color:var(--dl-accent)}.dl-choices{display:grid;grid-template-columns:repeat(auto-fit,minmax(170px,1fr));gap:8px}.dl-choice{all:unset;box-sizing:border-box;cursor:pointer;display:flex;flex-direction:column;gap:4px;padding:12px 14px;border-radius:12px;background:var(--dl-card);box-shadow:inset 0 0 0 1px var(--dl-line);transition:background .15s,box-shadow .15s}.dl-choice:hover{background:var(--dl-soft)}.dl-choice:focus-visible{outline:2px solid var(--dl-ring);outline-offset:2px}.dl-choice.selected{box-shadow:inset 0 0 0 2px var(--dl-accent);background:var(--accent-a10, color-mix(in srgb, var(--dl-accent) 8%, transparent))}.dl-choice-title{display:flex;align-items:center;gap:8px;font-size:14px;font-weight:500;color:var(--dl-fg)}.dl-choice-text{font-size:12px;line-height:16px;color:var(--dl-fg-muted)}.dl-attn-item>.cbi-button{margin-left:auto;flex:none;align-self:center}";var ri='.dl-steps{display:flex;align-items:center;gap:8px;margin:0 0 16px;flex-wrap:wrap}.dl-step{display:flex;align-items:center;gap:8px;font-size:14px;font-weight:500;color:var(--dl-fg-faint)}.dl-step b{display:inline-flex;width:24px;height:24px;align-items:center;justify-content:center;border-radius:50%;background:var(--dl-soft);font-size:12px;font-weight:600}.dl-step.current{color:var(--dl-fg)}.dl-step.current b{background:var(--dl-primary);color:var(--dl-primary-fg)}.dl-step.done{color:var(--dl-fg-muted)}.dl-step.done b{background:var(--dl-ok-wash);color:var(--dl-ok)}.dl-step+.dl-step:before{content:"";width:24px;height:1px;background:var(--dl-line)}.dl-wizard .dl-panel>div{display:flex;flex-direction:column;gap:16px}.dl-wizard .dl-panel>div>p{margin:0!important;color:var(--dl-fg-muted)}.dl-wizard .dl-panel>div>.cbi-value{margin:0}.dl-wizard h4{font-size:14px;font-weight:500;margin:8px 0 -6px!important}.dl-wizard h4:first-child{margin-top:0!important}.dl-modal .cbi-tabmenu{margin-bottom:16px}.dl-modal .cbi-value.dl-live>.cbi-value-title{display:flex;flex-direction:column;gap:2px;text-align:left}.dl-modal .cbi-value.dl-live>.cbi-value-title>.dl-sub{white-space:normal}.dl-checklist{display:flex;flex-direction:column;gap:6px;margin:4px 0 8px}.dl-checklist label{display:flex;align-items:center;gap:8px;font-size:14px;cursor:pointer}.dl-checklist input{margin:0}.dl-invite{display:grid;grid-template-columns:250px minmax(0,1fr);gap:22px;align-items:start}.dl-invite img{display:block;width:100%;border-radius:18px;box-shadow:0 0 0 1px var(--dl-line)}.dl-invite-side{display:flex;flex-direction:column;gap:14px;min-width:0}.dl-invite-side>p{margin:0!important}.dl-invite-link{all:unset;box-sizing:border-box;cursor:pointer;display:flex;align-items:center;gap:10px;min-width:0;padding:11px 14px;border-radius:12px;background:var(--dl-soft);font:13px/18px var(--dl-mono);color:var(--dl-fg)}.dl-invite-link>span:first-child{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-invite-link>.dl-icon-wrap{flex:none;display:inline-flex}.dl-invite-link .dl-icon{width:15px;height:15px;color:var(--dl-fg-muted);flex:none}.dl-invite-link:hover{background:var(--dl-soft-hover)}.dl-invite-link.alt{padding:8px 14px;font-size:12px;color:var(--dl-fg-muted)}.dl-invite-link>.dl-pill{flex:none}.dl-invite-steps{margin:0;padding-left:20px;list-style:decimal!important;font-size:13px;line-height:24px;color:var(--dl-fg-muted)}.dl-invite-steps b{color:var(--dl-fg);font-weight:500}.dl-invite-steps li{display:list-item!important;list-style:inherit!important;padding-left:4px}.dl-invite-actions{display:flex;gap:8px;flex-wrap:wrap}.modal:has(.dl-modal.wide){max-width:min(760px,94vw)!important;width:100%!important}@media(max-width:640px){.dl-invite{grid-template-columns:minmax(0,1fr)}.dl-invite img{max-width:260px;margin:0 auto}}.dl-toasts{position:fixed;left:50%;bottom:max(24px,env(safe-area-inset-bottom));transform:translate(-50%);z-index:100000;display:flex;flex-direction:column;align-items:center;gap:8px;pointer-events:none}.dl-toast{pointer-events:auto;display:inline-flex;align-items:center;gap:8px;max-width:min(520px,92vw);padding:10px 16px;border-radius:999px;background:var(--dl-fg);color:var(--dl-card);font-size:13px;line-height:18px;box-shadow:0 10px 30px #0000004d;opacity:0;transform:translateY(12px);transition:opacity .18s,transform .18s}.dl-toast.show{opacity:1;transform:none}.dl-toast .dl-icon-wrap{display:inline-flex}.dl-toast .dl-icon{width:15px;height:15px}.dl-toast.success .dl-icon{color:var(--dl-ok)}.dl-toast.error{background:var(--dl-bad);color:#fff}.dl-toast.error .dl-icon{color:#fff}.dl-toast.warning{background:var(--dl-warn);color:#111}.dl-toast.warning .dl-icon{color:#111}.dl-toast button{all:unset;cursor:pointer;display:inline-flex;margin-left:4px;opacity:.8}.dl-toast button:hover{opacity:1}';var ai=".dl-setblock{display:flex;flex-direction:column;gap:8px;margin:0}.dl-addr-opts{display:flex;flex-direction:column;gap:6px}.dl-addr-opt{all:unset;box-sizing:border-box;cursor:pointer;display:grid;grid-template-columns:16px minmax(0,1fr) auto;gap:12px;align-items:center;padding:10px 14px;border-radius:12px;box-shadow:inset 0 0 0 1px var(--dl-line);min-width:0}.dl-addr-opt:hover{background:var(--dl-soft)}.dl-addr-opt.on{box-shadow:inset 0 0 0 1.5px var(--dl-accent);background:color-mix(in srgb,var(--dl-accent) 7%,transparent)}.dl-addr-opt .dl-mono{font-size:13px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-addr-opt .dl-stack{min-width:0}.dl-addr-opt input{width:100%}.dl-addr-opt.other{cursor:default}.dl-addr-opt.other:hover{background:none}.dl-addr-opt.other input{width:100%}.dl-addr-check{width:16px;height:16px;border-radius:5px;box-shadow:inset 0 0 0 1.5px var(--dl-fg-faint);display:inline-flex;align-items:center;justify-content:center}.dl-addr-check .dl-icon-wrap{display:inline-flex}.dl-addr-check .dl-icon{width:12px;height:12px}.dl-addr-opt.on .dl-addr-check{background:var(--dl-accent);box-shadow:none;color:#fff}.dl-addr-opt.other .dl-addr-check{box-shadow:none;color:var(--dl-fg-muted)}.dl-addr-warn{display:inline-flex;align-items:center;gap:5px;font-size:12px;line-height:17px;color:var(--dl-warn)}.dl-addr-warn .dl-icon-wrap{display:inline-flex}.dl-addr-warn .dl-icon{width:13px;height:13px}.dl-pill.info{background:color-mix(in srgb,var(--dl-accent) 14%,transparent);color:var(--dl-accent)}.dl-links{border-radius:12px;background:var(--dl-soft);overflow:hidden}.dl-link-row{display:grid;grid-template-columns:18px minmax(0,1fr) auto;gap:10px;align-items:center;padding:11px 14px}.dl-link-row+.dl-link-row{border-top:1px solid var(--dl-line)}.dl-link-ic{display:inline-flex}.dl-link-ic .dl-icon{width:15px;height:15px}.dl-link-ic.ok .dl-icon{color:var(--dl-ok)}.dl-link-ic.warn .dl-icon{color:var(--dl-warn)}.dl-link-url{font-size:13px;color:var(--dl-fg-muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-link-url b{font-weight:500;color:var(--dl-accent)}@media(max-width:640px){.dl-link-url,.dl-addr-opt .dl-mono,.dl-filecard .dl-ellipsis,.dl-invite-link>span:first-child{white-space:normal;overflow-wrap:anywhere}}.dl-ready-sum{display:flex;align-items:center;gap:12px;padding:12px 14px;border-radius:12px}.dl-ready-sum>.dl-icon-wrap{display:inline-flex}.dl-ready-sum>.dl-icon-wrap .dl-icon{width:18px;height:18px}.dl-ready-sum .dl-stack{flex:1;min-width:0}.dl-ready-sum b{font-weight:500;font-size:13px}.dl-ready-sum.ok{background:var(--dl-ok-wash)}.dl-ready-sum.ok b,.dl-ready-sum.ok .dl-icon{color:var(--dl-ok)}.dl-ready-sum.warn{background:var(--dl-warn-wash)}.dl-ready-sum.warn b,.dl-ready-sum.warn .dl-icon{color:var(--dl-warn)}.dl-ready-sum.error{background:var(--dl-bad-wash)}.dl-ready-sum.error b,.dl-ready-sum.error .dl-icon{color:var(--dl-bad)}.dl-check-chip{display:inline-flex;align-items:center;gap:5px;height:26px;padding:0 10px;border-radius:999px;background:var(--dl-soft);font-size:12px;color:var(--dl-fg-muted)}.dl-check-chip .dl-icon-wrap{display:inline-flex}.dl-check-chip .dl-icon{width:13px;height:13px;color:var(--dl-ok)}.dl-check-chip.warn{background:var(--dl-warn-wash);color:var(--dl-warn)}.dl-check-chip.warn .dl-icon{color:var(--dl-warn)}.dl-check-chip.error{background:var(--dl-bad-wash);color:var(--dl-bad)}.dl-check-chip.error .dl-icon{color:var(--dl-bad)}.dl-ready-details{display:flex;flex-direction:column;gap:8px;padding:4px 2px}.dl-ready-details[hidden]{display:none}.dl-ready-item{display:flex;align-items:flex-start;gap:8px;font-size:13px;line-height:18px;min-width:0}.dl-ready-item .dl-icon-wrap{display:inline-flex;margin-top:1px}.dl-ready-item .dl-icon{width:15px;height:15px}.dl-ready-item.ok .dl-icon{color:var(--dl-ok)}.dl-ready-item.warn .dl-icon{color:var(--dl-warn)}.dl-ready-item.error .dl-icon{color:var(--dl-bad)}.dl-params-body{display:flex;flex-direction:column;gap:14px;padding:6px 14px 14px}.dl-params-body>.dl-setrow{margin:0;padding:0}.dl-pgrid.flush{padding:0;grid-template-columns:repeat(2,minmax(0,1fr))}@media(max-width:640px){.dl-pgrid.flush{grid-template-columns:minmax(0,1fr)}}.dl-qr-pane{display:flex;flex-direction:column;align-items:center;gap:8px;text-align:center}.dl-qr{width:min(280px,72vw);aspect-ratio:1;background:#0a0a0a;border-radius:18px;overflow:hidden}.dl-qr.light{background:#fff;box-shadow:inset 0 0 0 1px var(--dl-line)}.dl-qr svg{display:block;width:100%;height:100%}.dl-filecard{display:flex;align-items:center;gap:12px;padding:12px;border-radius:14px;background:var(--dl-soft);min-width:0}.dl-filecard>.dl-stack{flex:1;min-width:0}.dl-filecard-ic{width:40px;height:46px;border-radius:8px;flex:none;display:inline-flex;align-items:center;justify-content:center;font:10px var(--dl-mono);color:var(--dl-fg-muted);background:var(--dl-card);box-shadow:inset 0 0 0 1px var(--dl-line)}.dl-params>.dl-conf{margin:0;border-top:1px solid var(--dl-line);border-radius:0 0 12px 12px;background:none}.dl-conf-sec{color:var(--dl-accent)}.dl-conf-k{color:var(--dl-fg-faint)}.dl-conf-mask{padding:0 6px;border-radius:4px;background:var(--dl-soft);color:var(--dl-fg-muted)}.dl-params>summary .dl-chipbtn{height:26px;font-size:12px}.dl-conf{white-space:pre-wrap;word-break:break-all;max-height:22em;overflow:auto;font-family:var(--dl-mono);font-size:12px;line-height:18px;margin:0;padding:12px;border-radius:12px;background:var(--dl-soft)}.dl-key{width:100%;box-sizing:border-box;font-family:var(--dl-mono);font-size:12px;word-break:break-all;min-height:7em}.dl-actions{display:flex;align-items:center;gap:6px;flex-wrap:wrap;margin:12px 0 0}.dl-link-box{display:flex;gap:6px;align-items:center;flex-wrap:wrap}.dl-link-box input{flex:1 1 18em;min-width:0;font-family:var(--dl-mono);font-size:12px}.dl-hint{font-size:12px;line-height:16px;color:var(--dl-fg-muted);margin:8px 0}.dl-divider{border:0;border-top:1px solid var(--dl-line);margin:16px 0}";var ii=".dl-checks{list-style:none;margin:0;padding:0}.dl-checks li{display:flex;align-items:center;gap:12px;padding:12px 0;border-top:1px solid var(--dl-line)}.dl-checks li:first-child{border-top:0;padding-top:0}.dl-checks li:last-child{padding-bottom:0}.dl-check-icon{flex:0 0 auto;width:28px;height:28px;border-radius:50%;display:inline-flex;align-items:center;justify-content:center}.dl-check-icon .dl-icon{width:14px;height:14px}.dl-check-icon.ok{background:var(--dl-ok-wash);color:var(--dl-ok)}.dl-check-icon.warn{background:var(--dl-warn-wash);color:var(--dl-warn)}.dl-check-icon.error{background:var(--dl-bad-wash);color:var(--dl-bad)}.dl-check-icon.skip{background:var(--dl-soft);color:var(--dl-fg-faint)}.dl-check-body{flex:1;min-width:0}.dl-check-title{font-size:14px;line-height:20px;font-weight:500}.dl-check-detail{font-size:12px;line-height:16px;color:var(--dl-fg-muted);overflow-wrap:anywhere}.dl-check-repaired{margin-top:2px;font-size:12px;line-height:16px;color:var(--dl-warn)}.dl-wd{margin:0 0 16px;display:flex;flex-direction:column;gap:14px}.dl-wd-head{display:flex;align-items:center;gap:12px;min-width:0}.dl-wd-head>.dl-stack{min-width:0}.dl-wd-title{font-size:16px;line-height:24px;font-weight:500}.dl-wd-tile{flex:none;width:36px;height:36px;border-radius:10px;display:inline-flex;align-items:center;justify-content:center;background:var(--dl-ok-wash);color:var(--dl-ok)}.dl-wd-tile.off{background:var(--dl-soft);color:var(--dl-fg-faint)}.dl-wd-tile .dl-icon{width:18px;height:18px}.dl-wd-foot{display:flex;align-items:center;flex-wrap:wrap;gap:8px 16px;padding-top:14px;border-top:1px solid var(--dl-line)}.dl-wd-chips{display:flex;flex-wrap:wrap;gap:6px;flex:1 1 auto;min-width:0}.dl-wd-chips .dl-check-chip.error .dl-icon{color:var(--dl-bad)}.dl-warn-text{color:var(--dl-warn)!important}.dl-health-cols{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(440px,100%),1fr));gap:16px;align-items:start}.dl-health-cols>.dl-panel{margin:0;min-width:0}.dl-recent{display:flex;flex-direction:column}.dl-recent .dl-panel-head a{font-size:13px}.dl-recent-empty{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:10px;padding:32px 16px;color:var(--dl-fg-muted);font-size:13px;border-top:1px solid var(--dl-line)}.dl-loading{margin:0;font-size:13px}.dl-diag-tabs{margin:0 0 16px}.dl-row.dl-slog-row{align-items:baseline}.dl-slog-row .dl-ev-tile{align-self:flex-start;margin-top:-1px}.dl-slog-row.has-detail{cursor:pointer}.dl-row.dl-slog-row.has-detail:hover{background:color-mix(in srgb,var(--sys) 11%,transparent)}.dl-slog-more{display:inline-flex;vertical-align:-2px;margin-left:6px;color:var(--dl-fg-faint);transform:rotate(90deg);transition:transform .15s}.dl-slog-more .dl-icon{width:14px;height:14px}.dl-slog-more.open{transform:rotate(-90deg)}.dl-slog-detail{margin:8px 0 2px;padding:8px 10px;border-radius:8px;background:var(--dl-soft);font-family:var(--dl-mono);font-size:12px;line-height:17px;white-space:pre-wrap;overflow-wrap:anywhere;color:var(--dl-fg-muted);cursor:text}.dl-table{width:100%;border-collapse:collapse;font-size:14px;line-height:20px}.dl-table th{text-align:left;font-weight:500;color:var(--dl-fg-faint);padding:0 8px 8px;border-bottom:1px solid var(--dl-line)}.dl-table td{padding:10px 8px;border-bottom:1px solid var(--dl-line);vertical-align:middle}.dl-table th:first-child,.dl-table td:first-child{padding-left:0}.dl-table th:last-child,.dl-table td:last-child{padding-right:0}.dl-table tr:last-child td{border-bottom:0}.dl-table .dl-right{text-align:right;white-space:nowrap}.dl-log{max-height:18em;overflow:auto;font-family:var(--dl-mono);font-size:12px;line-height:18px;margin:8px 0 0;padding:12px;white-space:pre-wrap;border-radius:12px;background:var(--dl-soft)}";var si=".dl-pagehead{display:flex;align-items:flex-end;justify-content:space-between;gap:16px;flex-wrap:wrap;margin:0 0 20px}.dl-h1{margin:0!important;padding:0!important;font-size:24px!important;line-height:32px!important;font-weight:500!important;border:0!important}.dl-title-row{display:flex;align-items:center;gap:10px;flex-wrap:wrap}.dl-stack{display:flex;flex-direction:column;gap:2px;min-width:0}.dl-stack.gap4{gap:4px}.dl-stack.gap8{gap:8px}.dl-sub{font-size:12px;line-height:16px;color:var(--dl-fg-muted)}.dl-ok{color:var(--dl-ok)}.dl-warn{color:var(--dl-warn)}.dl-bad{color:var(--dl-bad)}.dl-icon-only{width:auto!important;min-width:0!important;aspect-ratio:1 / 1;padding:0!important;justify-content:center;display:inline-flex!important;align-items:center;border-radius:999px!important}.dl-panel.flush{padding:0;overflow:hidden}.dl-panel-head.pad{padding:16px 16px 12px;margin:0}.dl-col{display:flex;flex-direction:column;gap:16px;min-width:0}.dl-col>.dl-panel,.dl-col>section.dl-panel{margin:0}.dl-crumbs{display:flex;gap:8px;align-items:center;font-size:14px;margin:0 0 16px;color:var(--dl-fg-faint)}.dl-crumbs a{color:var(--dl-fg-faint)}.dl-crumbs a:hover{color:var(--dl-fg)}.dl-crumbs span:last-child{color:var(--dl-fg)}.dl-metrics{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));background:var(--dl-card);border:1px solid var(--dl-line);border-radius:var(--dl-radius);margin:0 0 16px;box-shadow:var(--dl-shadow)}.dl-metric{display:flex;flex-direction:column;gap:4px;padding:16px 20px;min-width:0}.dl-metric+.dl-metric{border-left:1px solid var(--dl-line)}.dl-metric-label{font-size:12px;font-weight:500;color:var(--dl-fg-faint)}.dl-metric-value{font-size:28px;line-height:36px;font-weight:500;letter-spacing:-.01em;font-variant-numeric:tabular-nums;white-space:nowrap}.dl-metric-value .dl-faint{font-size:16px}.dl-metric-sub{font-size:12px;color:var(--dl-fg-muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}@media(max-width:900px){.dl-metrics{grid-template-columns:repeat(2,minmax(0,1fr))}.dl-metric:nth-child(3){border-left:0}.dl-metric:nth-child(n+3){border-top:1px solid var(--dl-line)}}.dl-seg{display:inline-flex;gap:2px;padding:3px;border-radius:999px;background:var(--dl-soft);flex-wrap:wrap}.dl-seg button{all:unset;cursor:pointer;display:inline-flex;align-items:center;gap:6px;padding:4px 12px;border-radius:999px;font-size:13px;font-weight:500;color:var(--dl-fg-muted);white-space:nowrap}.dl-seg button:hover{color:var(--dl-fg)}.dl-seg button.on{background:var(--dl-soft-hover);color:var(--dl-fg)}.dl-seg.dl-srvsections{flex-wrap:nowrap;max-width:100%;overflow-x:auto;scrollbar-width:none}.dl-seg.dl-srvsections::-webkit-scrollbar{display:none}.dl-seg.dl-srvsections button{flex:none;white-space:nowrap}.dl-seg button:focus-visible{outline:2px solid var(--dl-ring)}.dl-seg button b{font-weight:500;font-size:11px;padding:0 6px;border-radius:999px;background:var(--dl-soft)}.dl-seg button b.warn{background:var(--dl-warn-wash);color:var(--dl-warn)}.dl-seg.sm button{padding:2px 9px;font-size:11px}.dl-seg.wide{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));border-radius:12px;padding:4px}.dl-seg.wide button{flex-direction:column;justify-content:center;padding:8px 6px;border-radius:9px;gap:3px}.dl-seg.wide button.on{background:var(--dl-primary);color:var(--dl-primary-fg)}";var li=`.dl-geomap{position:relative;border-top:1px solid var(--dl-line);background:transparent}.dl-map-status{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;color:var(--dl-fg-muted);font-size:13px;z-index:1;pointer-events:none}.dl-map-wrap{position:relative}.dl-map-legend{position:absolute;left:12px;bottom:12px;display:flex;gap:12px;align-items:center;padding:6px 12px;border-radius:999px;font-size:12px;background:color-mix(in srgb,var(--dl-card) 88%,transparent);border:1px solid var(--dl-line);backdrop-filter:blur(6px);z-index:2}.dl-map-legend span{display:inline-flex;align-items:center;gap:6px;color:var(--dl-fg-muted)}.dl-map-legend i.line{width:14px;height:0;border-top:2px dashed #8a8a8a}.dl-map-legend i.line.live{border-top-color:#3b82f6}.dl-map-off{padding:32px 16px;text-align:center;color:var(--dl-fg-muted);border-top:1px solid var(--dl-line)}.dl-mk{all:unset;cursor:pointer;position:relative;display:flex;align-items:center;justify-content:center;transition:opacity .2s}.dl-mk-hub{position:relative;display:flex;align-items:center;justify-content:center}.dl-mk-host{box-sizing:border-box;width:40px;height:40px;border-radius:11px;display:flex;align-items:center;justify-content:center;background:color-mix(in srgb,var(--dl-elevated) 60%,transparent);border:1px solid var(--dl-line);backdrop-filter:blur(6px);box-shadow:0 6px 16px #00000059}.dl-mk-host-tile{width:26px;height:26px;border-radius:7px;display:flex;align-items:center;justify-content:center;background:var(--dl-fg);color:var(--background, var(--dl-elevated))}.dl-mk-host-ic{width:14px;height:14px}.dl-mk-av{position:relative;box-sizing:border-box;width:28px;height:28px;border-radius:50%;display:flex;align-items:center;justify-content:center;font-size:10px;font-weight:500;line-height:1;border:2px solid #8a8a8a;background:var(--dl-elevated);color:var(--dl-fg-muted);transition:box-shadow .2s}.dl-mk.online .dl-mk-av{border-color:#3b82f6;background:color-mix(in srgb,#3b82f6 22%,var(--dl-elevated));color:var(--dl-fg)}.dl-mk-badge{position:absolute;left:16px;bottom:-6px;height:16px;min-width:16px;padding:0 3px;border-radius:8px;border:2px solid var(--dl-elevated);background:#6b6b6b;color:#fff;display:flex;align-items:center;justify-content:center;gap:1px;font-size:9px;font-weight:600;white-space:nowrap;box-sizing:content-box}.dl-mk.online .dl-mk-badge{background:#3b82f6}.dl-mk-badge-ic{width:10px;height:10px;stroke-width:2.2}.dl-mk-badge:has(>svg:only-child){width:16px;min-width:0;padding:0}.dl-mk-tile{position:relative;width:26px;height:26px;border-radius:7px;display:flex;align-items:center;justify-content:center;background:color-mix(in srgb,var(--dl-fg) 18%,var(--dl-elevated));color:var(--dl-fg)}.dl-mk.place.online .dl-mk-tile{background:#3b82f6;color:#fff;box-shadow:0 2px 8px #3b82f659}.dl-mk-tile-ic{width:14px;height:14px}.dl-mk-tile-n{position:absolute;right:-5px;top:-5px;min-width:14px;height:14px;padding:0 3px;box-sizing:border-box;border-radius:7px;background:var(--dl-fg);color:var(--dl-elevated);font-size:9px;font-weight:600;line-height:14px;text-align:center}.dl-mk-when{display:block;text-align:center;color:var(--dl-fg-faint);font-weight:400}.dl-mk.place.online .dl-mk-when{color:#3b82f6}.dl-mk-tile.sm{width:18px;height:18px;border-radius:5px;font-size:9px;font-weight:600}.dl-dmap{border:1px solid var(--dl-line);border-radius:12px;overflow:hidden}.dl-dmap .dl-geomap{border-top:0}.dl-dplaces{display:flex;flex-direction:column;margin-top:4px}.dl-dplace-row{display:flex;align-items:center;gap:10px;padding:9px 2px;border-top:1px solid var(--dl-line);font-size:13px}.dl-dplace-row:first-child{border-top:0}.dl-dplace-n{flex:0 0 auto;width:20px;height:20px;border-radius:5px;display:flex;align-items:center;justify-content:center;font-size:10px;font-weight:600;background:color-mix(in srgb,var(--dl-fg) 18%,var(--dl-elevated));color:var(--dl-fg)}.dl-dplace-n.live{background:#3b82f6;color:#fff}.dl-dplace-n .dl-icon{width:12px;height:12px}.dl-dplace-now{color:#3b82f6}.dl-dplaces.strips .dl-dplace-row{position:relative;display:grid;grid-template-columns:20px minmax(0,1fr) auto;column-gap:10px;row-gap:9px;margin:0 -10px;padding:11px 10px;border-top:0;border-radius:10px;transition:background .15s}.dl-dplaces.strips .dl-dplace-row+.dl-dplace-row:before{content:"";position:absolute;left:10px;right:10px;top:0;height:1px;background:var(--dl-line)}.dl-dplaces.strips .dl-dplace-row:is(:hover,.cur){background:var(--dl-soft)}.dl-dplaces.strips .dl-dplace-row:is(:hover,.cur):before,.dl-dplaces.strips .dl-dplace-row:is(:hover,.cur)+.dl-dplace-row:before{opacity:0}.dl-dplace-strip{grid-column:2 / 4;position:relative;height:6px;border-radius:3px;background:var(--dl-track)}.dl-dplaces.can-replay .dl-dplace-strip{cursor:ew-resize;touch-action:none}.dl-dplace-strip i{position:absolute;top:0;bottom:0;min-width:2px;border-radius:2px;background:#8a8a8a}.dl-dplace-strip.live i{background:#3b82f6}.dl-dplaces.replay .dl-dplace-strip:after{content:"";position:absolute;left:var(--at);top:-4px;bottom:-4px;width:2px;margin-left:-1px;border-radius:1px;background:var(--dl-fg);box-shadow:0 0 0 2px var(--dialog-bg, var(--dl-elevated));pointer-events:none}.dl-dplace-axis{position:relative;height:16px;margin:4px 0 0 30px;font-size:11px;line-height:16px;color:var(--dl-fg-faint)}.dl-dplace-axis span{position:absolute;top:0;transform:translate(-50%);white-space:nowrap}.dl-dmap{position:relative}.dl-map-replay{position:absolute;left:10px;top:10px;z-index:3;display:flex;align-items:center;gap:6px}.dl-map-btn{all:unset;box-sizing:border-box;cursor:pointer;width:28px;height:28px;border-radius:8px;display:inline-flex;align-items:center;justify-content:center;background:var(--dl-elevated);border:1px solid var(--dl-line);color:var(--dl-fg)}.dl-map-btn:hover{background:color-mix(in srgb,var(--dl-fg) 8%,var(--dl-elevated))}.dl-map-btn:focus-visible{outline:2px solid var(--dl-ring)}.dl-map-btn .dl-icon{width:13px;height:13px}.dl-map-chip{display:inline-flex;align-items:center;height:28px;box-sizing:border-box;padding:0 10px;border-radius:8px;font-size:11.5px;white-space:nowrap;background:var(--dl-elevated);border:1px solid var(--dl-line);color:var(--dl-fg);font-variant-numeric:tabular-nums}.dl-mk.step .dl-mk-tile{transition:width .3s cubic-bezier(.2,.8,.2,1),height .3s cubic-bezier(.2,.8,.2,1),border-radius .3s,background-color .3s,color .3s,box-shadow .3s,transform .24s}.dl-mk.step .dl-mk-tile.sm .dl-mk-tile-ic{width:11px;height:11px}.dl-mk.step.faded>*{opacity:.5}.dl-mk.step:is(.online,.hl){z-index:2}.dl-mk.step.hl .dl-mk-tile{box-shadow:0 0 0 3px color-mix(in srgb,#3b82f6 55%,transparent)}.dl-mk.step.arrive .dl-mk-tile{animation:dl-mk-arrive .45s cubic-bezier(.2,.8,.2,1)}@keyframes dl-mk-arrive{0%{transform:scale(.8)}55%{transform:scale(1.12)}to{transform:scale(1)}}.dl-mk-when.inline{display:inline}.dl-mk>*{transition:opacity .15s;opacity:var(--dl-mk-fade, 1)}.dl-mk.merged,.dl-mk.piled{pointer-events:none}.dl-mk.dl-mk-new>*{transition:none}.dl-mk.merged>*,.dl-mk.piled>*{opacity:0}.dl-mk-hub{cursor:default}.dl-mk-host{position:relative}.dl-mk-host{transition:border-radius .22s ease,border-right-color .22s ease}.dl-mk-host.docked{border-top-right-radius:0;border-bottom-right-radius:0;border-right-color:transparent}.dl-mk-dock{position:absolute;left:100%;top:-1px;height:40px;box-sizing:border-box;display:flex;align-items:center;gap:6px;padding:0 10px 0 2px;border:1px solid var(--dl-line);border-left:0;border-radius:0 11px 11px 0;background:color-mix(in srgb,var(--dl-elevated) 60%,transparent);backdrop-filter:blur(6px);box-shadow:0 6px 16px #00000059;pointer-events:none;opacity:0;clip-path:inset(-24px 100% -24px 0);transition:clip-path .28s cubic-bezier(.2,.8,.2,1),opacity .2s ease}.dl-mk-host.docked .dl-mk-dock{pointer-events:auto;opacity:1;clip-path:inset(-24px -24px -24px 0)}.dl-mk-new .dl-mk-host,.dl-mk-new .dl-mk-dock{transition:none}.dl-mk-pile{position:relative;display:flex;justify-content:center}.dl-mk-pile-box{box-sizing:border-box;height:40px;display:flex;align-items:center;gap:6px;padding:0 10px 0 6px;border-radius:20px;cursor:zoom-in;background:color-mix(in srgb,var(--dl-elevated) 60%,transparent);border:1px solid var(--dl-line);backdrop-filter:blur(6px);box-shadow:0 6px 16px #00000059;animation:dl-plate-in .26s cubic-bezier(.2,.8,.2,1) both;transition:opacity .18s ease,transform .18s ease}.dl-mk-pile.out{pointer-events:none}.dl-mk-pile.out>*{opacity:0;transform:scale(.85);transition:opacity .18s ease,transform .18s ease}@keyframes dl-plate-in{0%{opacity:0;transform:scale(.85)}}.dl-mk-face{all:unset;position:relative;display:flex;cursor:pointer;transition:transform .18s ease,opacity .18s ease}.dl-mk-face>.dl-mk-badge{position:relative;left:auto;bottom:-8px;margin-left:-12px;align-self:center}.dl-mk-face.on .dl-mk-av{border-color:#3b82f6;background:color-mix(in srgb,#3b82f6 22%,var(--dl-elevated));color:var(--dl-fg)}.dl-mk-face.on .dl-mk-badge{background:#3b82f6}.dl-mk-face:hover .dl-mk-av{box-shadow:0 0 0 4px #3b82f640}.dl-mk-face.in{animation:dl-dock-in .24s cubic-bezier(.2,.8,.2,1) both}.dl-mk-face.out{transform:scale(.4);opacity:0;pointer-events:none}@keyframes dl-dock-in{0%{transform:scale(.4);opacity:0}}.dl-mk-more{font-size:11px;font-weight:600;color:var(--dl-fg-muted)}.dl-mk-av,.dl-mk-tile{transition:box-shadow .2s,transform .24s cubic-bezier(.2,.8,.2,1)}.dl-mk.merged .dl-mk-av,.dl-mk.merged .dl-mk-tile,.dl-mk.piled .dl-mk-av{transform:scale(.5)}.dl-mk-host,.dl-mk-dock,.dl-mk-pile-box{transition-property:border-radius,border-right-color,clip-path,opacity,height,width,padding,gap}.dl-mk-dock,.dl-mk-pile-box{transition-duration:.22s;transition-timing-function:cubic-bezier(.2,.8,.2,1)}.dl-mk-pile-box{position:relative}.dl-mk-more{transition:transform .22s cubic-bezier(.2,.8,.2,1),opacity .18s ease}.dl-mk-more.in{animation:dl-dock-in .24s ease both}.dl-mk-more.out{transform:scale(.4);opacity:0}.dl-mk-face .dl-mk-av{transition:box-shadow .2s,transform .24s cubic-bezier(.2,.8,.2,1),width .2s ease,height .2s ease,font-size .2s ease}.dl-mk-face{transition:transform .22s cubic-bezier(.2,.8,.2,1),opacity .18s ease,margin .2s ease}.dl-mk-face>.dl-mk-badge{max-width:48px;overflow:hidden;transition:opacity .2s ease,transform .2s ease,max-width .22s ease,margin .22s ease,padding .22s ease,border-width .22s ease,height .22s ease,min-width .22s ease,width .22s ease,bottom .22s ease}.dl-lod-far .dl-mk-host{width:32px;height:32px;border-radius:9px}.dl-lod-far .dl-mk-host.docked{border-radius:9px 0 0 9px}.dl-lod-far .dl-mk-host-tile{width:20px;height:20px;border-radius:6px}.dl-lod-far .dl-mk-host-ic{width:11px;height:11px}.dl-lod-far .dl-mk-dock{height:32px;gap:0;padding:0 4px 0 0;border-radius:0 9px 9px 0}.dl-lod-far .dl-mk-pile-box{height:32px;gap:0;padding:0 4px;border-radius:16px}.dl-lod-far .dl-mk-face+.dl-mk-face{margin-left:-6px}.dl-lod-far .dl-mk-face .dl-mk-av{width:22px;height:22px;font-size:8px;box-shadow:0 0 0 2px var(--dl-elevated)}.dl-lod-far .dl-mk-face>.dl-mk-badge{max-width:0;min-width:0;padding:0;margin-left:0;border-width:0;opacity:0;transform:scale(.5);pointer-events:none}.dl-lod-far .dl-mk-more{margin-left:4px;font-size:10px}.dl-mk-label{transition:opacity .2s ease}.dl-lod-far .dl-mk:not(.step) .dl-mk-label{opacity:0}.dl-lod-mid .dl-mk-host{width:36px;height:36px}.dl-lod-mid .dl-mk-dock,.dl-lod-mid .dl-mk-pile-box{height:36px}.dl-lod-mid .dl-mk-face .dl-mk-av{width:24px;height:24px;font-size:9px}.dl-lod-mid .dl-mk-face>.dl-mk-badge{height:12px;min-width:12px;margin-left:-10px;bottom:-7px}.dl-lod-mid .dl-mk-face>.dl-mk-badge:has(>svg:only-child){width:12px}.dl-lod-mid .dl-mk-face>.dl-mk-badge .dl-mk-badge-ic{width:8px;height:8px}@media(prefers-reduced-motion:reduce){.dl-mk-dock,.dl-mk-pile-box,.dl-mk-face,.dl-mk-av,.dl-mk-tile,.dl-mk.step .dl-mk-tile,.dl-mk-host,.dl-mk-face>.dl-mk-badge{transition:none;animation:none}}.dl-mk-hub:has(.dl-mk-host.docked) .dl-mk-host{cursor:zoom-in}.dl-mk-ptr{position:absolute;left:50%;top:50%;width:0;height:0;z-index:-1;pointer-events:none}.dl-mk-ptr .line{position:absolute;left:0;top:-.5px;height:1px;background:var(--dl-fg-faint);transform-origin:0 50%}.dl-mk-ptr .spot{position:absolute;left:-3.5px;top:-3.5px;width:7px;height:7px;border-radius:50%;box-sizing:border-box;border:1.5px solid #fff;background:#8a8a8a}.dl-mk.online .dl-mk-ptr .spot,.dl-mk.place.online .dl-mk-ptr .spot{background:#3b82f6}.dl-mk.dim>*{opacity:.18}.dl-mk.hl .dl-mk-av{box-shadow:0 0 0 4px #3b82f640}.dl-mk-label{position:absolute;left:50%;bottom:100%;margin-bottom:4px;transform:translate(-50%);white-space:nowrap;pointer-events:none;font-size:10px;line-height:14px;font-weight:500;color:var(--dl-fg)}.dl-mk-label.below{bottom:auto;top:100%;margin:4px 0 0}.dl-mk-label.chip{padding:2px 6px;border-radius:4px;font-size:11px;line-height:16px;font-weight:600;background:color-mix(in srgb,var(--background, var(--dl-card)) 80%,transparent);backdrop-filter:blur(8px)}.dl-geomap .maplibregl-ctrl-bottom-right .maplibregl-ctrl-attrib.maplibregl-compact{margin:0 10px 10px 0;min-height:28px;padding:0;border-radius:8px;background:var(--dl-elevated);border:1px solid var(--dl-line);color:var(--dl-fg-muted);box-shadow:none;font-size:11px;line-height:26px}.dl-geomap .maplibregl-ctrl-bottom-right .maplibregl-ctrl-attrib.maplibregl-compact:not(.maplibregl-compact-show){width:28px;height:28px;box-sizing:border-box}.dl-geomap .maplibregl-ctrl-bottom-right .maplibregl-ctrl-attrib.maplibregl-compact.maplibregl-compact-show{padding:0 32px 0 10px}.dl-geomap .maplibregl-ctrl-attrib a{color:var(--dl-fg-muted)}.dl-geomap .maplibregl-ctrl-attrib-button{top:0;right:0;width:26px;height:26px;margin:0;border-radius:8px;background:none}.dl-geomap .maplibregl-ctrl-attrib-button:after{content:"";position:absolute;inset:5px;background:var(--dl-fg);-webkit-mask:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill-rule='evenodd' d='M12 2a10 10 0 1 1 0 20 10 10 0 0 1 0-20Zm-1.2 8.2h2.4V17h-2.4v-6.8ZM12 6a1.4 1.4 0 1 0 0 2.8A1.4 1.4 0 0 0 12 6Z'/%3E%3C/svg%3E") center / contain no-repeat;mask:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill-rule='evenodd' d='M12 2a10 10 0 1 1 0 20 10 10 0 0 1 0-20Zm-1.2 8.2h2.4V17h-2.4v-6.8ZM12 6a1.4 1.4 0 1 0 0 2.8A1.4 1.4 0 0 0 12 6Z'/%3E%3C/svg%3E") center / contain no-repeat}.dl-geomap .maplibregl-ctrl-attrib-button:focus{outline:none;box-shadow:none}.dl-geomap .maplibregl-ctrl-attrib-button:focus-visible{outline:2px solid var(--dl-ring)}.dl-map-card{position:absolute;right:12px;top:12px;z-index:3;min-width:200px;max-width:260px;padding:10px 12px;border-radius:10px;font-size:12px;line-height:20px;background:var(--dl-elevated);color:var(--dl-fg);border:1px solid var(--dl-line);box-shadow:var(--shadow-xl, 0 8px 16px -4px rgba(0,0,0,.4));opacity:0;transition:opacity .2s;pointer-events:none}.dl-map-card.on{opacity:1}.dl-map-card-head b{font-weight:500}.dl-map-card-row{display:flex;justify-content:space-between;gap:12px;white-space:nowrap}.dl-popcard{position:fixed;z-index:2100;width:max-content;max-width:300px;padding:12px;border-radius:12px;box-sizing:border-box;background:var(--dl-elevated);color:var(--dl-fg);border:1px solid var(--dl-line);box-shadow:var(--shadow-xl, 0 8px 16px -4px rgba(0,0,0,.4))}.dl-popcard.away{visibility:hidden}.dl-popcard.leaving{pointer-events:none}.dl-popcard-tip{position:absolute;left:var(--tip-x, 50%);width:10px;height:10px;margin-left:-6px;box-sizing:border-box;background:var(--dl-elevated);border:solid var(--dl-line);transform:rotate(45deg)}.dl-popcard.above .dl-popcard-tip{bottom:-6px;border-width:0 1px 1px 0}.dl-popcard.below .dl-popcard-tip{top:-6px;border-width:1px 0 0 1px}.dl-popcard.above{transform-origin:var(--tip-x, 50%) 100%}.dl-popcard.below{transform-origin:var(--tip-x, 50%) 0}@media(prefers-reduced-motion:no-preference){.dl-popcard{animation:dl-pop-in .16s ease-out}.dl-popcard.leaving{animation:dl-pop-out .14s ease-in forwards}}@keyframes dl-pop-in{0%{opacity:0;transform:scale(.94)}to{opacity:1;transform:none}}@keyframes dl-pop-out{0%{opacity:1;transform:none}to{opacity:0;transform:scale(.94)}}.dl-pop{display:flex;flex-direction:column;gap:4px;font-size:12px;line-height:18px;min-width:210px}.dl-pop-head{display:flex;align-items:center;gap:8px;font-size:13px;margin-bottom:2px}.dl-pop-net{width:30px;height:30px;border-radius:9px;background:var(--dl-soft);display:inline-flex;align-items:center;justify-content:center;flex:0 0 auto;color:var(--dl-fg-muted)}.dl-pop-list{display:flex;flex-direction:column;margin:6px 0 0;max-height:116px;overflow-y:auto}.dl-pop-row{all:unset;cursor:pointer;display:flex;align-items:center;gap:8px;padding:6px 8px;border-radius:8px}.dl-pop-row:hover{background:var(--dl-soft)}.dl-pop-row:focus{outline:none}.dl-pop-row:focus-visible{outline:2px solid var(--dl-ring)}.dl-pop-name{flex:1;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.dl-pop-name b{font-weight:500}.dl-pop-dot{width:6px;height:6px;border-radius:50%;background:var(--dl-fg-faint);flex:0 0 auto}.dl-pop-dot.on{background:var(--dl-ok);box-shadow:0 0 0 3px var(--dl-ok-wash)}.dl-pop-actions{display:flex;gap:6px;margin-top:8px;padding-top:8px;border-top:1px solid var(--dl-line)}.dl-pop-actions .cbi-button{flex:1;height:28px!important;font-size:12px!important;justify-content:center}.dl-chartbox{position:relative}.dl-bars{display:flex;align-items:flex-end;gap:4px;border-bottom:1px solid var(--dl-line)}.dl-bar{flex:1;height:100%;display:flex;flex-direction:column-reverse;gap:1px;cursor:default;min-width:3px}.dl-bar i{display:block;border-radius:3px 3px 0 0}.dl-bar i.down{background:var(--dl-chart-1)}.dl-bar i.up{background:var(--dl-chart-2);opacity:.75;border-radius:3px 3px 0 0}.dl-bar:hover i{filter:brightness(1.25)}.dl-bar.empty{background:linear-gradient(to top,var(--dl-line) 2px,transparent 2px)}.dl-tip{position:absolute;top:-8px;transform:translate(-50%,-100%);padding:8px 10px;border-radius:10px;font-size:12px;line-height:18px;white-space:nowrap;background:var(--dl-elevated);border:1px solid var(--dl-line);box-shadow:var(--shadow-xl, 0 8px 16px -4px rgba(0,0,0,.4));pointer-events:none;z-index:3}.dl-tip-title{font-weight:500}.dl-tip-float{position:fixed;z-index:2000;color:var(--dl-fg)}.dl-spark i:hover{opacity:1;filter:brightness(1.25)}.dl-meter,.dl-slots{cursor:default}.dl-axis{display:flex;justify-content:space-between;font-size:12px;color:var(--dl-fg-faint);margin-top:6px}.dl-legend i.down{background:var(--dl-chart-1)}.dl-legend i.up{background:var(--dl-chart-2)}.dl-spark{display:flex;align-items:flex-end;gap:2px;flex:0 0 auto}.dl-spark i{flex:1;display:block;border-radius:2px 2px 0 0;background:var(--dl-chart-1);opacity:.85}.dl-spark i.zero{opacity:.22}`;var di=`.dl-row{display:flex;align-items:center;gap:12px;padding:12px 16px;border-top:1px solid var(--dl-line);font-size:14px;line-height:20px;min-width:0}.dl-row.link{color:inherit;text-decoration:none}.dl-row.link:hover{background:var(--dl-soft)}.dl-row-main{flex:1;min-width:0;overflow-wrap:anywhere}.dl-row-main b{font-weight:500}.dl-attn{display:flex;flex-direction:column;gap:10px;padding:16px;border-top:1px solid var(--dl-line)}.dl-attn-item{display:flex;gap:10px;align-items:baseline;font-size:13px;color:var(--dl-fg-muted)}.dl-avatar.sm{width:26px;height:26px;font-size:10px;margin:0}.dl-avatar.lg{width:48px;height:48px;font-size:15px;margin:0}.dl-avatar.lg.online:after{width:12px;height:12px}.dl-list{border:1px solid var(--dl-line);border-radius:12px;overflow:hidden}.dl-list>.dl-row:first-child{border-top:0}.dl-ellipsis{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0}.dl-row-main.dl-stack{min-width:0}.dl-person-id{display:flex;align-items:center;gap:14px;min-width:0}.dl-grid-person{display:grid;grid-template-columns:minmax(0,1.7fr) minmax(0,1fr);gap:16px;align-items:start}@media(max-width:1000px){.dl-grid-person{grid-template-columns:minmax(0,1fr)}}.dl-devsec{display:flex;flex-direction:column;gap:12px}.dl-devsec .dl-panel-head{margin:0}.dl-dgrid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}.dl-dcard>.dl-dcard-head+*{margin-top:auto}@media(max-width:700px){.dl-dgrid{grid-template-columns:minmax(0,1fr)}}.dl-dgrid>.dl-dslot.add:only-child{grid-column:1 / -1}.dl-dcard{background:var(--dl-card);border:1px solid var(--dl-line);border-radius:14px;padding:14px;display:flex;flex-direction:column;gap:12px;min-width:0;box-shadow:var(--dl-shadow)}.dl-dcard.online{border-color:color-mix(in srgb,var(--dl-ok) 35%,transparent)}.dl-dcard.off{opacity:.7}.dl-dcard-head{display:flex;align-items:center;gap:12px}.dl-dcard-ic{width:40px;height:40px;border-radius:12px;background:var(--dl-soft);display:inline-flex;align-items:center;justify-content:center;flex:0 0 auto;color:var(--dl-fg-muted)}.dl-dcard-ic .dl-icon{width:20px;height:20px}.dl-dcard.online .dl-dcard-ic{background:var(--dl-ok-wash);color:var(--dl-ok)}.dl-dcard-title{all:unset;cursor:pointer;flex:1;min-width:0;display:flex;flex-direction:column}.dl-dcard-title b{font-weight:500;font-size:15px}.dl-dstat{display:inline-flex;align-items:center;gap:6px;font-size:12px;color:var(--dl-fg-muted);white-space:nowrap;min-width:0}.dl-dstat i.dot{flex:none}.dl-dstat.ok{color:var(--dl-ok)}.dl-dstat.warn{color:var(--dl-warn)}.dl-dstat i.dot,.dl-savebar i.dot{width:6px;height:6px;border-radius:50%;background:var(--dl-fg-faint)}.dl-dstat i.dot.ok{background:var(--dl-ok);box-shadow:0 0 0 3px var(--dl-ok-wash)}.dl-dstat i.dot.warn{background:var(--dl-warn)}.dl-dcard-use{display:flex;align-items:flex-end;justify-content:space-between;gap:12px}.dl-dcard-foot{padding-top:10px;border-top:1px solid var(--dl-line);font-size:11px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.dl-dslot.add{all:unset;box-sizing:border-box;cursor:pointer;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:10px;padding:14px;min-height:0;border:1px dashed color-mix(in srgb,currentColor 18%,transparent);border-radius:14px;text-align:center;color:var(--dl-fg-muted);transition:background .15s,border-color .15s,color .15s}.dl-dslot.add .dl-stack{align-items:center}.dl-dslot.add:hover{border-color:color-mix(in srgb,currentColor 35%,transparent);color:var(--dl-fg)}.dl-dslot.add:focus-visible{outline:2px solid var(--dl-ring);outline-offset:2px}.dl-dslot.add b{font-weight:500}.dl-dslot.add:hover{background:var(--dl-soft)}.dl-dslot-ic{width:36px;height:36px;border-radius:999px;background:var(--dl-soft);display:inline-flex;align-items:center;justify-content:center;flex:0 0 auto;color:var(--dl-fg-muted)}.dl-dslot.add:hover .dl-dslot-ic{background:var(--dl-primary);color:var(--dl-primary-fg)}.dl-tiles2{display:grid;gap:10px;margin-top:16px}.dl-tile2{border:1px solid var(--dl-line);border-radius:14px;padding:14px;display:flex;flex-direction:column;gap:10px;min-width:0}.dl-tile2-label{display:flex;align-items:center;justify-content:space-between;gap:8px;font-size:12px;font-weight:500;color:var(--dl-fg-faint)}.dl-tile2-row{display:flex;align-items:center;justify-content:space-between;gap:10px;flex-wrap:wrap}.dl-tile2-value{font-size:20px;line-height:28px;font-weight:500;letter-spacing:-.01em;font-variant-numeric:tabular-nums}.dl-tile2-value .dl-faint{font-size:14px;font-weight:400}.dl-tile2-foot{display:flex;align-items:center;justify-content:space-between;gap:12px;padding-top:10px;border-top:1px solid var(--dl-line);font-size:12px}.dl-stepper{display:inline-flex;align-items:stretch;height:32px;border:1px solid var(--input, var(--dl-line));border-radius:8px;overflow:hidden}.dl-stepper button{all:unset;cursor:pointer;width:32px;display:inline-flex;align-items:center;justify-content:center;font-size:16px;color:var(--dl-fg)}.dl-stepper button:hover{background:var(--dl-soft)}.dl-stepper button[disabled]{opacity:.35;cursor:not-allowed}.dl-stepper+.dl-stepper{margin-left:4px}.dl-step-select{border:0!important;border-left:1px solid var(--input, var(--dl-line))!important;border-right:1px solid var(--input, var(--dl-line))!important;border-radius:0!important;background:transparent!important;color:inherit;font:500 13px inherit;padding:0 10px!important;height:100%!important;min-width:0!important}.dl-slots{display:grid;grid-auto-flow:column;grid-auto-columns:minmax(0,1fr);gap:3px}.dl-slots i{height:4px;border-radius:999px;background:var(--dl-track);display:block}.dl-slots i.used{background:var(--dl-fg)}.dl-slots i.over{background:color-mix(in srgb,var(--dl-warn) 80%,transparent)}.dl-date{display:flex;align-items:center;gap:8px;flex:1 1 150px;min-width:0;box-sizing:border-box;height:34px;padding:0 10px;border:1px solid var(--input, var(--dl-line));border-radius:8px;color:var(--dl-fg-faint)}.dl-date input{border:0!important;background:transparent!important;box-shadow:none!important;padding:0!important;height:32px!important;color:var(--dl-fg);flex:1;min-width:0!important;width:100%!important}.dl-meter{position:relative;height:6px;border-radius:999px;background:var(--dl-track)}.dl-meter>i{display:block;height:100%;border-radius:999px;background:var(--dl-accent)}.dl-meter.warn>i{background:var(--dl-warn)}.dl-meter.bad>i{background:var(--dl-bad)}.dl-meter .mark{position:absolute;left:90%;top:-3px;width:1px;height:12px;background:var(--dl-warn)}.dl-meter.sm{height:4px}.dl-chips-row{display:flex;flex-wrap:wrap;gap:4px}.dl-chipbtn{all:unset;cursor:pointer;height:26px;padding:0 10px;border-radius:999px;background:var(--dl-soft);font-size:12px;font-weight:500;display:inline-flex;align-items:center}.dl-chipbtn:hover{background:var(--dl-soft-hover)}.dl-chipbtn.on{background:var(--dl-primary);color:var(--dl-primary-fg)}.dl-switch{all:unset;cursor:pointer;position:relative;width:32px;height:20px;border-radius:999px;background:var(--switch-off, var(--dl-track));flex:0 0 auto;transition:background .15s}.dl-switch i{position:absolute;left:2px;top:2px;width:16px;height:16px;border-radius:50%;background:#fff;transition:left .15s;box-shadow:0 1px 2px #0000004d}.dl-switch.on{background:var(--dl-accent)}.dl-switch.on i{left:14px}.dl-switch:focus-visible{outline:2px solid var(--dl-ring);outline-offset:2px}.dl-linkbox{display:flex;align-items:center;gap:8px;height:36px;padding:0 4px 0 12px;border:1px solid var(--input, var(--dl-line));border-radius:8px;background:var(--input-bg, transparent)}.dl-linkbox .dl-mono{flex:1;min-width:0;font-size:12px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;color:var(--dl-fg-muted)}.dl-linkbox .cbi-button{height:28px!important}.dl-pcard{display:grid;grid-template-columns:minmax(0,1fr) 260px;gap:20px;align-items:stretch;min-width:0}.dl-pcard-main{min-width:0}.dl-pcard-top{display:flex;align-items:center;gap:12px;min-width:0}.dl-pcard-top .dl-avatar{margin-right:0}.dl-pcard-who{flex:1;min-width:0}.dl-pcard-who .dl-slotbar{margin:3px 0 0}.dl-pside{display:flex;flex-direction:column;justify-content:space-between;gap:8px;padding-left:20px;border-left:1px solid var(--dl-line);min-width:0}.dl-pside-top{display:flex;align-items:center;justify-content:space-between;gap:8px}.dl-pside-state{display:inline-flex;align-items:center;gap:6px;font-size:13px;color:var(--dl-fg-muted)}.dl-pside-state.live{color:var(--dl-ok)}.dl-pside-foot{font-size:12px}.dl-pside .dl-use-num b{font-size:20px}.dl-none{display:none!important}.dl-pcard-actions{display:flex;gap:6px;flex:0 0 auto}.dl-pcard-actions .cbi-button{height:32px!important}.dl-icon-only .dl-btn-label{display:none}.dl-pill-ic{display:inline-flex;align-items:center;gap:4px;height:22px;padding:0 8px;border-radius:999px;font-size:12px;white-space:nowrap;background:var(--dl-soft);color:var(--dl-fg-muted)}.dl-pill-ic .dl-icon{width:12px;height:12px}.dl-pill-ic.warn{background:var(--dl-warn-wash);color:var(--dl-warn)}.dl-pill-ic.bad{background:var(--dl-bad-wash);color:var(--dl-bad)}.dl-use-num{display:flex;align-items:baseline;gap:6px;white-space:nowrap}.dl-use-num b{font-size:15px;font-weight:500}.dl-use-live{display:flex;align-items:center;gap:8px;font-size:12px;font-variant-numeric:tabular-nums}.dl-usebar{display:flex;gap:2px;height:6px;border-radius:999px;overflow:hidden;background:var(--dl-track)}.dl-usebar i{display:block;height:100%;min-width:3px;flex:0 1 0}.dl-usebar i.fill{flex:none;min-width:0;border-radius:999px;background:var(--dl-accent)}.dl-usebar.warn i.fill{background:var(--dl-warn)}.dl-usebar.bad i.fill{background:var(--dl-bad)}.dl-usebar .c0,.dl-swatch.c0{background:var(--dl-chart-1)}.dl-usebar .c1,.dl-swatch.c1{background:#8b7cf6}.dl-usebar .c2,.dl-swatch.c2{background:#2fb889}.dl-usebar .c3,.dl-swatch.c3{background:#d9a03f}.dl-usebar .c4,.dl-swatch.c4{background:var(--dl-fg-faint)}.dl-tip-row{display:flex;align-items:center;gap:8px;min-width:160px}.dl-tip-row b{margin-left:auto;font-weight:500}.dl-swatch{width:8px;height:8px;border-radius:2px;flex:none}.dl-card-name{color:var(--dl-fg)!important;text-decoration:none}.dl-card-name:hover{text-decoration:underline}.dl-chip-tag{font-size:11px;line-height:18px;padding:0 6px;border-radius:999px;background:var(--dl-warn-wash);color:var(--dl-warn)}.dl-chip.live{background:var(--dl-ok-wash);color:color-mix(in srgb,var(--dl-ok) 35%,var(--dl-fg))}.dl-chip.live:hover{background:color-mix(in srgb,var(--dl-ok) 22%,transparent)}.dl-chip.live .dl-icon{color:var(--dl-ok)}.dl-fixes{display:flex;gap:6px;flex-wrap:wrap;margin:10px 0 0 44px}.dl-fix{all:unset;cursor:pointer;height:26px;padding:0 10px;border-radius:999px;background:var(--dl-info-wash);color:var(--dl-info);font-size:12px;font-weight:500;display:inline-flex;align-items:center}.dl-fix:hover{filter:brightness(1.15)}@media(max-width:760px){.dl-pcard{grid-template-columns:1fr}.dl-pside{padding:12px 0 0;border-left:0;border-top:1px solid var(--dl-line)}.dl-fixes{margin-left:0}}.dl-select{height:34px!important;border-radius:999px!important;min-width:136px!important;width:auto!important;padding:0 34px 0 14px!important;appearance:none!important;-webkit-appearance:none!important;background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238b8f98' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E")!important;background-repeat:no-repeat!important;background-position:right 12px center!important;background-size:14px!important}.dl-savebar{position:fixed;left:50%;bottom:24px;transform:translate(-50%,160%);opacity:0;transition:transform .25s cubic-bezier(.2,.8,.2,1),opacity .2s;display:flex;align-items:center;gap:10px;padding:8px 8px 8px 18px;border-radius:999px;background:var(--dl-elevated);border:1px solid var(--dl-line);box-shadow:var(--shadow-2xl, 0 16px 32px -8px rgba(0,0,0,.5));z-index:60;pointer-events:none}.dl-savebar.show{transform:translate(-50%);opacity:1;pointer-events:auto}.dl-savebar-text{display:inline-flex;align-items:center;gap:8px;font-size:13px;font-weight:500}`;var ci=".dl-toast strong{display:block;font-weight:500}.dl-toast div{opacity:.8;font-size:13px}.dl-drawer-overlay{position:fixed;inset:0;z-index:900;display:flex;justify-content:flex-end;background:transparent;transition:background .2s}.dl-drawer-overlay.open{background:var(--scrim, rgba(0,0,0,.45))}.dl-drawer{width:min(520px,100%);height:100%;display:flex;flex-direction:column;background:var(--dialog-bg, var(--dl-elevated));color:var(--dl-fg);border-left:1px solid var(--dl-line);box-shadow:var(--shadow-2xl, -16px 0 32px -8px rgba(0,0,0,.5));transform:translate(100%);transition:transform .22s cubic-bezier(.2,.8,.2,1)}.dl-drawer-overlay.open .dl-drawer{transform:none}.dl-drawer-head{display:flex;align-items:center;gap:12px;padding:16px 20px;border-bottom:1px solid var(--dl-line)}.dl-drawer-title{flex:1;min-width:0;display:flex;align-items:center;gap:12px}.dl-drawer-title h3{margin:0!important;padding:0!important;border:0!important;font-size:18px!important;line-height:26px;font-weight:500!important}.dl-drawer-x{all:unset;cursor:pointer;width:32px;height:32px;border-radius:50%;display:inline-flex;align-items:center;justify-content:center;color:var(--dl-fg-muted)}.dl-drawer-x:hover{background:var(--dl-soft);color:var(--dl-fg)}.dl-drawer-body{flex:1;overflow:auto;padding:20px}.dl-drawer-foot{padding:12px 20px;border-top:1px solid var(--dl-line)}.dl-drawer-actions{display:flex;align-items:center;gap:8px}.dl-dcard-ic.on{background:var(--dl-ok-wash);color:var(--dl-ok)}.dl-icon-only.sm{width:28px;height:28px!important}.dl-stack.gap12{gap:12px}.dl-stack.gap16{gap:16px}.dl-dstats{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));border:1px solid var(--dl-line);border-radius:14px;overflow:hidden}.dl-dstats-cell{display:flex;flex-direction:column;gap:4px;padding:12px 14px;min-width:0}.dl-dstats-cell.wide{grid-column:span 2;border-bottom:1px solid var(--dl-line)}.dl-dstats-cell+.dl-dstats-cell:not(.wide):last-child{border-left:1px solid var(--dl-line)}.dl-dstats-cell b{font-size:16px;font-weight:500;font-variant-numeric:tabular-nums}.dl-dstats-cell .dl-dstat{font-size:14px}.dl-dsec{border:1px solid var(--dl-line);border-radius:14px;padding:16px;display:flex;flex-direction:column;gap:12px}.dl-dsec-head{display:flex;align-items:center;justify-content:space-between;gap:12px}.dl-dsec-head h4{margin:0!important;padding:0!important;font-size:14px!important;font-weight:500!important;border:0!important}.dl-dstat i.dot{width:6px;height:6px;border-radius:50%;background:var(--dl-fg-faint);display:inline-block}.dl-connect-body{min-height:60px}.dl-connect-body .dl-qr{width:min(240px,70vw)}.dl-kv2{display:flex;flex-direction:column}.dl-kvrow{display:flex;align-items:center;justify-content:space-between;gap:16px;padding:9px 0;border-top:1px solid var(--dl-line);font-size:13px;min-width:0}.dl-kvrow:first-child{border-top:0;padding-top:0}.dl-kvrow-k{color:var(--dl-fg-muted);flex:0 0 auto}.dl-kvrow-v{min-width:0;text-align:right;overflow-wrap:anywhere}.dl-kvrow-v.copy{all:unset;cursor:pointer;display:inline-flex;align-items:center;gap:6px;min-width:0;color:var(--dl-fg)}.dl-kvrow-v.copy span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-kvrow-v.copy .dl-icon{width:13px;height:13px;color:var(--dl-fg-faint)}.dl-kvrow-v.copy:hover .dl-icon{color:var(--dl-fg)}@media(max-width:560px){.dl-drawer{width:100%}.dl-dstats{grid-template-columns:minmax(0,1fr)}.dl-dstats-cell.wide{grid-column:auto}.dl-dstats-cell+.dl-dstats-cell:not(.wide):last-child{border-left:0;border-top:1px solid var(--dl-line)}}.dl-dev-log{display:flex;flex-direction:column}.dl-dev-log-row{display:flex;align-items:center;gap:10px;padding:8px 0;border-top:1px solid var(--dl-line);font-size:13px;line-height:20px;min-width:0}.dl-dev-log-row:first-child{border-top:0;padding-top:0}.dl-dev-log-row .dl-row-main{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}";var pi=".dl-settings-main{min-width:0;display:flex;flex-direction:column;gap:20px}.dl-setsec{background:var(--dl-card);border:1px solid var(--dl-line);border-radius:var(--dl-radius);overflow:hidden;scroll-margin-top:88px;box-shadow:var(--dl-shadow)}.dl-setsec-body{padding:20px;display:flex;flex-direction:column;gap:14px}.dl-setsec-body h3{margin:0!important;padding:0!important;font-size:18px!important;line-height:26px;font-weight:500!important;border:0!important}.dl-setsec-body p{margin:0}.dl-setsec-head{display:flex;align-items:center;gap:10px}.dl-group{border:1px solid var(--dl-line);border-radius:14px;padding:2px 16px}.dl-group-head{display:flex;align-items:center;gap:12px;padding:14px 0 10px}.dl-group-head b{font-size:15px;font-weight:500}.dl-group-ic{width:32px;height:32px;border-radius:10px;background:var(--dl-soft);color:var(--dl-fg-muted);display:inline-flex;align-items:center;justify-content:center;flex:none}.dl-group-ic .dl-icon-wrap{display:inline-flex}.dl-group-ic .dl-icon{width:16px;height:16px}.dl-group-body>*{padding:12px 0;margin:0!important}.dl-group-body>*+*:not(.alert-message):not(.dl-params){border-top:1px solid var(--dl-line)}.dl-group-body>.alert-message,.dl-group-body>.dl-params{margin:12px 0!important}.dl-group-body>.alert-message{padding:10px 14px}.dl-group-body>.dl-params{padding:0}.dl-group-body>.alert-message+*,.dl-group-body>.dl-params+*{border-top:0}.dl-group-body>.dl-row{border-left:0;border-right:0;border-bottom:0;padding-left:0;padding-right:0;background:none}.dl-group-body>.dl-row:first-child{border-top:0}.dl-setsec-foot{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:10px 16px;padding:12px 20px;border-top:1px solid var(--dl-line);background:var(--dl-soft)}.dl-setsec.danger{border-color:color-mix(in srgb,var(--dl-bad) 40%,transparent)}.dl-setsec.danger .dl-setsec-foot{background:color-mix(in srgb,var(--dl-bad) 6%,transparent)}.dl-setrow{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,420px);align-items:center;gap:8px 24px}.dl-setrow.head{display:flex;justify-content:space-between;gap:16px}.dl-setrow-label{font-size:14px;font-weight:500}.dl-setrow-ctl{display:flex;justify-content:flex-end;min-width:0}.dl-setrow-ctl .dl-chips-row{justify-content:flex-end}.dl-setrow-ctl>input{width:100%}.dl-hostport{display:flex;align-items:center;gap:8px;flex:1;min-width:0;justify-content:flex-end}.dl-hostport input{flex:1;min-width:0}.dl-root input.dl-w-port,.dl-hostport input.dl-w-port{flex:0 0 90px;width:90px}.dl-root input.dl-w-range{flex:0 0 130px;width:130px}.dl-setrow .dl-sub.bad{color:var(--dl-bad)}.dl-suffixed{display:inline-flex;align-items:center;gap:6px}.dl-suffixed>span{color:var(--dl-fg-muted)}.dl-more summary{cursor:pointer;color:var(--dl-fg-muted);font-size:13px;margin-bottom:10px}.dl-more .dl-setrow+.dl-setrow{margin-top:10px}@media(max-width:760px){.dl-setrow:not(.head){grid-template-columns:minmax(0,1fr)}.dl-setrow-ctl,.dl-setrow-ctl .dl-chips-row{justify-content:flex-start}}.dl-need-ic{width:30px;height:30px;border-radius:9px;background:var(--dl-soft);color:var(--dl-fg-muted);display:inline-flex;align-items:center;justify-content:center;flex:none}.dl-need-ic .dl-icon-wrap{display:inline-flex}.dl-need-ic .dl-icon{width:15px;height:15px}.dl-need-row.bad .dl-need-ic,.dl-need-ic.bad{background:var(--dl-bad-wash);color:var(--dl-bad)}.dl-need-row.warn .dl-need-ic,.dl-need-ic.warn{background:var(--dl-warn-wash);color:var(--dl-warn)}.dl-need-ic.ok{background:var(--dl-ok-wash);color:var(--dl-ok)}.dl-lh-main{display:flex;align-items:flex-start;gap:12px;min-width:0}.dl-lh-main>.dl-need-ic{margin-top:1px}.dl-sub .dl-mono{font-size:.92em}.dl-need-row>.cbi-button{flex:none}.dl-bk-row .dl-group-ic{width:30px;height:30px}.dl-bk-older>summary{list-style:none;cursor:pointer;display:flex;align-items:center;gap:8px;padding:11px 16px;border-top:1px solid var(--dl-line);font-size:13px;color:var(--dl-fg-muted);user-select:none}.dl-bk-older>summary::-webkit-details-marker{display:none}.dl-bk-older>summary:hover{background:var(--dl-soft);color:var(--dl-fg)}.dl-bk-older>summary .dl-icon-wrap{display:inline-flex;transition:transform .15s}.dl-bk-older>summary .dl-icon{width:14px;height:14px}.dl-bk-older[open]>summary .dl-icon-wrap{transform:rotate(90deg)}#dl-set-backups .dl-setsec-head h3+.dl-sub{margin-top:2px}#dl-set-backups .dl-setsec-foot>.dl-sub{flex:1 1 260px}.dl-bk-actions{flex:0 1 auto;justify-content:flex-end}@media(max-width:640px){#dl-set-backups .dl-setsec-foot>.dl-sub{flex-basis:100%}.dl-bk-actions{justify-content:flex-start}}.dl-upd{display:flex;flex-direction:column;gap:16px}.dl-upd>.dl-pagehead{margin:0 0 4px}.dl-upd-bad{color:var(--dl-bad)}";var mi=".dl-comp-hero{display:grid;grid-template-columns:minmax(0,1.5fr) minmax(0,1fr)}.dl-comp-hero-main{padding:20px;display:flex;flex-direction:column;gap:12px;min-width:0}.dl-comp-hero-side{padding:20px;border-left:1px solid var(--dl-line);display:flex;flex-direction:column;gap:14px;min-width:0}.dl-comp-name{font-size:16px;font-weight:500}.dl-comp-hero-head{display:flex;align-items:center;gap:10px;flex-wrap:wrap;min-width:0}.dl-comp-hero-head .dl-spacer{flex:1}.dl-comp-big{font-family:var(--dl-mono);font-size:26px;line-height:34px;letter-spacing:-.02em;display:flex;align-items:baseline;gap:10px}.dl-comp-big small{font-size:14px;color:var(--dl-accent)}.dl-comp-big small.dl-faint{color:var(--dl-fg-faint)}.dl-comp-verrow{display:flex;align-items:center;gap:4px 12px;flex-wrap:wrap;min-width:0}.dl-comp-verrow .dl-spacer{flex:1}.dl-comp-meta{font-size:13px}.dl-comp-bullets{margin:0;padding-left:18px;display:flex;flex-direction:column;gap:4px;color:var(--dl-fg-muted);font-size:13px}.dl-comp-bullets li{list-style:disc}.dl-comp-lead{margin:0}.dl-comp-more{align-self:flex-start;font-size:12px;color:var(--dl-fg-faint);margin-left:18px;padding:0!important}.dl-comp-more:hover{color:var(--dl-accent);background:none!important;text-decoration:underline;text-underline-offset:2px}.dl-comp-hero-main>.dl-comp-vers{margin-top:auto}.dl-comp-btns{display:flex;gap:8px;flex-wrap:nowrap;align-items:center;flex:none}.dl-comp-side-v{display:flex;align-items:center;gap:8px;font-size:14px;min-width:0;flex-wrap:wrap}.dl-comp-side-v .dl-icon{width:15px;height:15px;color:var(--dl-fg-muted)}.dl-comp-side-v a{color:inherit;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-comp-side-v a:hover{color:var(--dl-accent)}.dl-comp-cols{display:grid;grid-template-columns:minmax(0,1.5fr) minmax(0,1fr);gap:16px;align-items:start}.dl-comp-cols>.dl-panel>div>.dl-row:first-child{border-top:1px solid var(--dl-line)}.dl-comp-count{font-size:13px}.dl-comp-sub{font-size:11px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-comp-ic{display:inline-flex;gap:4px;flex:none}.dl-comp-ic .cbi-button{width:30px;height:30px;padding:0!important;justify-content:center;border-radius:999px!important}.dl-comp-ic .dl-btn-label{display:none}.dl-comp-ic .dl-icon{width:14px;height:14px}.dl-comp-ic .is-busy{pointer-events:none;opacity:.5}.dl-comp-ic .cbi-button.dl-comp-check{width:auto;padding:0 12px 0 10px!important;gap:6px;display:inline-flex;align-items:center;font-size:13px}.dl-row>.dl-pill,.dl-row>.cbi-button,.dl-row>.dl-comp-ic{flex:none}button.dl-pill.dl-comp-run{all:unset;display:inline-flex;align-items:center;height:20px;padding:0 8px;border-radius:999px;font-size:12px;cursor:pointer;background:color-mix(in srgb,var(--dl-accent) 14%,transparent);color:var(--dl-accent)}.dl-comp-foldwrap{padding:0 16px 14px 60px}.dl-comp-fold .dl-params-body{gap:12px}.dl-comp-fold .dl-list>.dl-row{padding:10px 14px}.dl-comp-bver{font-size:12px;width:130px;text-align:right;flex:none;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-comp-bact{width:84px;flex:none;display:flex;justify-content:flex-end}.dl-comp-warn{display:flex;align-items:flex-start;gap:8px;font-size:12px;line-height:18px;color:var(--dl-fg-muted)}.dl-comp-warn .dl-icon-wrap{display:inline-flex;flex:none;margin-top:2px}.dl-comp-warn .dl-icon{width:14px;height:14px;color:var(--dl-warn)}.dl-comp-empty{margin:0;padding:4px 16px 16px}@media(max-width:760px){.dl-comp-hero,.dl-comp-cols{grid-template-columns:minmax(0,1fr)}.dl-comp-hero-side{border-left:0;border-top:1px solid var(--dl-line)}.dl-comp-foldwrap{padding-left:16px}.dl-comp-bver{display:none}}.dl-comp-status{display:flex;align-items:center;gap:8px;font-size:13px;padding:9px 12px;border-radius:10px;background:var(--dl-soft);min-width:0}.dl-comp-status>.dl-icon-wrap{display:inline-flex;flex:none}.dl-comp-status .dl-icon{width:15px;height:15px}.dl-comp-status.ok{background:var(--dl-ok-wash);color:var(--dl-ok)}.dl-comp-status.acc{background:color-mix(in srgb,var(--dl-accent) 12%,transparent);color:var(--dl-accent)}.dl-comp-status.warn{background:var(--dl-warn-wash);color:var(--dl-warn)}.dl-comp-status.bad{background:var(--dl-bad-wash);color:var(--dl-bad)}.dl-comp-status b{font-weight:600}.dl-comp-vers .dl-params-body{gap:0;padding:4px 14px 12px}.dl-comp-tag{display:flex;gap:6px;padding:6px 0 10px}.dl-comp-tag input{flex:1;min-width:0}.dl-comp-ver{display:flex;align-items:center;gap:8px;padding:7px 0;border-top:1px solid var(--dl-line);font-size:13px}.dl-comp-ver .dl-mono{min-width:52px}.dl-comp-ver .dl-sub{flex:1}.dl-comp-ver .cbi-button:not(.dl-icon-btn){height:26px!important;font-size:12px!important}.dl-comp-pager{display:flex;align-items:center;justify-content:space-between;padding-top:10px;border-top:1px solid var(--dl-line);font-size:12px}.dl-comp-pager .dl-linkbtn[disabled]{opacity:.4;cursor:default}.dl-comp-vers .dl-loading,.dl-comp-vers .dl-params-body>p{padding:6px 0 10px}.dl-op-head{display:flex;align-items:center;gap:8px;flex-wrap:wrap;margin-bottom:14px}.dl-op-head .dl-spacer{flex:1}.dl-op-timer{display:inline-flex;align-items:center;gap:5px;font-variant-numeric:tabular-nums}.dl-op-timer .dl-icon,.dl-op-head .dl-linkbtn .dl-icon{width:14px;height:14px}.dl-op-loghead{display:flex;align-items:center;justify-content:space-between}.dl-op-loghead b{font-weight:500;font-size:13px}.dl-op .dl-log{max-height:16em;min-height:12em;margin-top:8px}.dl-op .dl-comp-status{margin:14px 0 0}.dl-op-actions{display:flex;gap:8px;justify-content:flex-end;flex-wrap:wrap;width:100%}.dl-notes{max-height:55vh;overflow:auto;border-radius:12px;background:var(--dl-soft);padding:14px 16px;font-size:13px;line-height:20px;overflow-wrap:anywhere}.dl-notes h5{margin:10px 0 6px;font-size:14px;font-weight:500}.dl-notes h5:first-child{margin-top:0}.dl-notes p{margin:0 0 8px}.dl-notes ul{margin:0 0 10px;padding-left:18px}.dl-notes li{list-style:disc}.dl-notes code{font-family:var(--dl-mono);font-size:12px;padding:1px 5px;border-radius:6px;background:var(--dl-soft-hover)}.dl-notes pre{font-family:var(--dl-mono);font-size:12px;padding:10px;border-radius:8px;background:var(--dl-soft-hover);white-space:pre-wrap;margin:0 0 10px}.dl-notes a{color:var(--dl-accent)}";var hi=".dl-chip.static{cursor:default}.dl-chip.static:hover{background:var(--dl-soft)}.dl-chip.static .dl-chip-name{font-weight:500}.dl-setrow.head .dl-chips-row{margin-top:8px}.dl-setrow.head>.dl-lh-main,.dl-setrow.head>.dl-lh-main>.dl-stack{flex:1 1 auto;min-width:0}.dl-setrow.head>.dl-setrow-ctl:empty{display:none}.dl-setrow.head:has(>.dl-lh-main){align-items:flex-start}.dl-setrow.head>.dl-setrow-ctl{align-items:center;min-height:30px}.dl-netpick{margin-top:10px}.dl-boxrow{display:flex;align-items:center;justify-content:space-between;gap:16px;margin:0;padding:10px 14px;border:1px solid var(--dl-line);border-radius:12px;font-size:13px;cursor:pointer}.dl-boxrow>.dl-switch{flex:none}.dl-ifpick{display:flex;flex-direction:column;gap:12px;padding:14px;border:1px solid var(--dl-line);border-radius:14px}.dl-iflead-row{display:flex;align-items:center;justify-content:space-between;gap:12px}.dl-host-ports{justify-content:flex-end}@media(max-width:760px){.dl-host-ports{justify-content:flex-start}}.dl-circle-dot{display:inline-block;width:8px;height:8px;border-radius:50%;flex:none}.dl-circles .dl-chip b{font-weight:500}.dl-circle-name{display:inline-flex;align-items:center;gap:8px;font-size:14px;font-weight:500}.dl-w400{font-weight:400}.dl-swatches{display:flex;flex-wrap:wrap;gap:8px}.dl-swatch{all:unset;cursor:pointer;width:22px;height:22px;border-radius:50%;background:var(--sw);box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--dl-fg) 12%,transparent)}.dl-swatch.on{box-shadow:0 0 0 2px var(--dl-card),0 0 0 4px var(--sw)}.dl-swatch:focus-visible{outline:2px solid var(--dl-ring);outline-offset:3px}.dl-circle-modal .dl-chipbtn b{margin-left:6px;font-weight:500;font-size:11px;opacity:.6}.dl-reach td:first-child b{font-weight:500}.dl-ev-host{white-space:nowrap}.dl-ev-host b{font-weight:500;color:var(--dl-fg)}.dl-reach{font-size:13px}.dl-reach th,.dl-reach td{white-space:nowrap;padding-left:6px;padding-right:6px}.dl-reach-wrap{overflow-x:auto}.dl-yes{display:inline-flex;align-items:center;gap:4px;color:var(--dl-ok)}.dl-yes .dl-icon-wrap{display:inline-flex}.dl-yes .dl-icon{width:14px;height:14px}.dl-check-form{display:grid;grid-template-columns:minmax(0,1fr) auto minmax(0,1fr) auto;align-items:start;gap:8px}.dl-check-form>.dl-faint{line-height:36px}.dl-check-end{display:flex;flex-direction:column;gap:6px;min-width:0}.dl-check-end>*{width:100%!important;min-width:0}@media(max-width:560px){.dl-check-form{grid-template-columns:minmax(0,1fr)}.dl-check-form>.dl-faint{display:none}}.dl-verdict{display:flex;align-items:baseline;gap:10px;padding:10px 12px;border-radius:12px}.dl-verdict b{font-weight:500}.dl-verdict.ok{background:var(--dl-ok-wash)}.dl-verdict.ok b{color:var(--dl-ok)}.dl-verdict.bad{background:var(--dl-bad-wash)}.dl-verdict.bad b{color:var(--dl-bad)}.dl-corehead{display:flex;align-items:center;gap:10px;flex-wrap:wrap;margin:0 0 4px}.dl-corehead h3{margin:0!important}.dl-row-end{display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap}.dl-dcard.clickable{cursor:pointer}.dl-dcard.clickable:hover{border-color:color-mix(in srgb,var(--dl-fg) 22%,transparent)}";var El=[Xa,ei,ti,ni,oi,ri,ai,ii,si,li,di,ci,pi,mi,hi].join(` +`);function fi(){let n=document.createElement("style");return n.dataset.dawnline="1",n.textContent=El,n}function ht(n){return()=>{let e=new n;return Object.assign({load:()=>e.load(),render:async o=>{let a=await e.render(o),i=document.createElement("div");return i.className="dl-root",i.append(fi(),a),i},addFooter(){return e.noFooter?document.createElement("div"):this.super("addFooter",[])}},{handleSave:null,handleSaveApply:null,handleReset:null})}}var C1=ht(Yt),E1=ht(mt),L1=ht(Yt),M1=ht(zn),S1=ht(In),T1=ht(Un),_1=ht(Rn);function gi(n){return()=>({load:()=>(ui.menu?.flushCache(),location.replace(`${L.url("admin/network/dawnline/diagnostics")}${n?`?tab=${n}`:""}`),new Promise(()=>{})),render:()=>document.createElement("div"),handleSave:null,handleSaveApply:null,handleReset:null})}var P1=gi(""),D1=gi("log");return baseclass.extend({ activity: D1, diagnostics: T1, health: P1, overview: C1, people: E1, person: S1, server: L1, settings: M1, updates: _1 }); diff --git a/package/luci-app-dawnline/root/usr/share/dawnline/portal/assets/portal.css b/package/luci-app-dawnline/root/usr/share/dawnline/portal/assets/portal.css index 2aeb34c..bd7c462 100644 --- a/package/luci-app-dawnline/root/usr/share/dawnline/portal/assets/portal.css +++ b/package/luci-app-dawnline/root/usr/share/dawnline/portal/assets/portal.css @@ -1 +1 @@ -@font-face{font-family:Geist;src:url(geist-latin-wght-normal.woff2) format("woff2");font-weight:100 900;font-display:swap;unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+2000-206F,U+20AC,U+2122,U+2190-21FF,U+2212,U+2215}@font-face{font-family:Geist;src:url(geist-cyrillic-wght-normal.woff2) format("woff2");font-weight:100 900;font-display:swap;unicode-range:U+0301,U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116}@font-face{font-family:Geist Mono;src:url(geist-mono-latin-wght-normal.woff2) format("woff2");font-weight:100 900;font-display:swap}:root{--ease-out: cubic-bezier(.23, 1, .32, 1);--ease-in: cubic-bezier(.55, 0, 1, .45);--ease-drawer: cubic-bezier(.32, .72, 0, 1);--spring: linear( 0, .022, .079, .158, .249, .344, .438, .527, .61, .684, .749, .805, .852, .891, .923, .949, .969, .984, .996, 1.004, 1.009, 1.013, 1.014, 1.015, 1.015, 1.014, 1.013, 1.012, 1.01, 1.009, 1.008, 1.006, 1.005, 1.004, 1.003, 1.002, 1.002, 1.001, 1.001, 1.001, 1 );--spring-pop: linear( 0, .034, .122, .244, .383, .526, .662, .785, .889, .974, 1.038, 1.083, 1.111, 1.124, 1.126, 1.119, 1.106, 1.09, 1.072, 1.054, 1.038, 1.023, 1.01, 1, .993, .988, .985, .984, .984, .985, .987, .989, .992, .994, .996, .998, .999, 1, 1.001, 1.002, 1 );--dur-press: .12s;--dur-hover: .15s;--dur-pop: .18s;--dur-swap: .26s;--dur-enter: .44s;--dur-sheet: .44s;--dur-exit: .16s;--bg: #fcfcfc;--card: #ffffff;--elevated: #ffffff;--text: #0d0d0d;--muted: #5d5d5d;--faint: #8f8f8f;--line: #0000001a;--input: #00000026;--soft: #0d0d0d0d;--soft-hover: #0d0d0d1a;--primary: #0d0d0d;--primary-fg: #ffffff;--accent: #3a83f7;--info: #2c67c5;--ok: #00a240;--ok-wash: #00a24026;--warn: #e25507;--warn-wash: #e2550726;--bad: #e02e2a;--bad-wash: #e02e2a1f;--chart: #3a83f7;--track: #0d0d0d1a;--scrim: #00000040;--shadow: 0 1px 2px -1px #00000014;--shadow-xl: 0 8px 16px -4px #0000001f;--radius: 16px;--mono: "Geist Mono", ui-monospace, Menlo, monospace;color-scheme:light dark}@media(prefers-color-scheme:dark){:root{--bg: #000000;--card: #0a0a0a;--elevated: #131313;--text: #ededed;--muted: #edededa6;--faint: #ededed78;--line: #ededed13;--input: #ededed24;--soft: #ededed0d;--soft-hover: #ededed1a;--primary: #ededed;--primary-fg: #131313;--accent: #006efe;--info: #5ba2fe;--ok: #40c977;--ok-wash: #40c97726;--warn: #ff8549;--warn-wash: #ff854926;--bad: #ff6764;--bad-wash: #ff676422;--chart: #3a83f7;--track: #ededed1a;--scrim: #00000099;--shadow: none;--shadow-xl: 0 8px 16px -4px #00000080}}*{box-sizing:border-box}html,body{margin:0}html{scrollbar-gutter:stable}body{background:var(--bg);color:var(--text);font:400 15px/22px Geist,-apple-system,system-ui,Segoe UI,sans-serif;-webkit-font-smoothing:antialiased;min-height:100vh;min-height:100dvh;cursor:default}input,textarea,.linkrow .mono,.conf{cursor:text}body.locked{overflow:hidden}a{color:var(--info);text-decoration:none}a:hover{text-decoration:underline}a.btn:hover,a.badge:hover{text-decoration:none}h1,h2{margin:0;font-weight:500;letter-spacing:-.01em}h1{font-size:24px;line-height:32px}h2{font-size:16px;line-height:24px}.muted{color:var(--muted)}.faint{color:var(--faint)}.s{font-size:13px;line-height:18px}.ok{color:var(--ok)}.warn{color:var(--warn)}.strong{font-weight:500}.center{text-align:center}.mono{font-family:var(--mono);font-size:12px}.stack{display:flex;flex-direction:column;gap:2px;min-width:0}.stack.gap{gap:10px}.grow{flex:1}.row{display:flex;align-items:center;gap:8px;flex-wrap:wrap}.row.gap{gap:8px;flex-wrap:nowrap}.row-baseline{display:flex;align-items:baseline;gap:10px;flex-wrap:wrap}.offscreen{position:fixed;left:-9999px;opacity:0}.top{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:max(12px,env(safe-area-inset-top)) 16px 12px;border-bottom:1px solid var(--line);position:sticky;top:0;background:color-mix(in srgb,var(--bg) 85%,transparent);backdrop-filter:saturate(180%) blur(12px);z-index:5}.brand{display:flex;align-items:center;gap:8px;font-weight:500;min-width:0}.brand .faint{font-weight:400}.logo{display:inline-flex;width:22px;height:22px;color:var(--text)}.logo svg{width:100%;height:100%}.wrap{width:100%;max-width:1048px;margin:0 auto;padding:20px 16px max(32px,env(safe-area-inset-bottom));display:flex;flex-direction:column;gap:20px}.hello{display:flex;align-items:center;gap:12px}.avatar{width:44px;height:44px;border-radius:50%;background:var(--soft-hover);display:inline-flex;align-items:center;justify-content:center;font-size:14px;font-weight:600;position:relative;flex:0 0 auto}.avatar.online:after{content:"";position:absolute;right:0;bottom:0;width:10px;height:10px;border-radius:50%;background:var(--ok);box-shadow:0 0 0 3px var(--bg)}.notice{display:flex;gap:10px;align-items:flex-start;padding:12px 14px;border-radius:12px;background:var(--warn-wash);font-size:14px}.notice.bad{background:var(--bad-wash)}.notice .ic{color:var(--warn)}.notice.bad .ic{color:var(--bad)}.alert{display:flex;gap:12px;align-items:center;padding:12px 16px;border:1px solid var(--line);border-radius:12px;background:var(--card);font-size:14px;line-height:20px}.alert-ic{width:30px;height:30px;border-radius:9px;display:inline-flex;align-items:center;justify-content:center;flex:none;background:var(--warn-wash);color:var(--warn)}.alert-ic.bad{background:var(--bad-wash);color:var(--bad)}.alert-ic .ic-svg{width:15px;height:15px}.layout{display:grid;grid-template-columns:minmax(0,1fr);gap:20px;grid-template-areas:"access" "devices"}.access{grid-area:access}.devices{grid-area:devices;display:flex;flex-direction:column;gap:12px;min-width:0}.desktop-only{display:none!important}@media(min-width:960px){.top{padding-left:max(16px,calc((100vw - 1048px)/2 + 16px));padding-right:max(16px,calc((100vw - 1048px)/2 + 16px))}.layout{grid-template-columns:minmax(0,1.7fr) minmax(0,1fr);grid-template-areas:"devices access";align-items:start;gap:16px}.desktop-only{display:inline-flex!important}.wrap{padding-top:28px}}.card{background:var(--card);border:1px solid var(--line);border-radius:var(--radius);padding:16px;box-shadow:var(--shadow);min-width:0}.card-head{display:flex;align-items:center;justify-content:space-between;gap:12px}.access{display:flex;flex-direction:column;gap:12px;min-width:0}.access-card{display:flex;flex-direction:column;gap:12px}.reach{display:flex;align-items:center;gap:12px;padding:12px;border-radius:12px;background:var(--soft)}.reach-ic{width:36px;height:36px;border-radius:10px;display:inline-flex;align-items:center;justify-content:center;flex:0 0 auto;background:color-mix(in srgb,var(--info) 14%,transparent);color:var(--info)}.tile{border:1px solid var(--line);border-radius:14px;padding:14px;display:flex;flex-direction:column;gap:8px;min-width:0}.tiles2{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}.tile-label{display:flex;justify-content:space-between;gap:8px;font-size:12px;font-weight:500;color:var(--faint)}.tile-value{font-size:20px;line-height:28px;font-weight:500;letter-spacing:-.01em;font-variant-numeric:tabular-nums}.tile-value.sm{font-size:16px}.tile-value .faint{font-size:14px;font-weight:400}.meter{position:relative;height:6px;border-radius:999px;background:var(--track);cursor:default}.meter i{display:block;height:100%;border-radius:999px;background:var(--accent)}.meter.warn i{background:var(--warn)}.meter.bad i{background:var(--bad)}.slots{display:grid;grid-auto-flow:column;grid-auto-columns:minmax(0,1fr);gap:3px}.slots i{display:block;height:4px;border-radius:999px;background:var(--track)}.slots i.used{background:var(--text)}.slots i.over{background:color-mix(in srgb,var(--warn) 80%,transparent)}.dgrid{display:grid;grid-template-columns:minmax(0,1fr);gap:10px}@media(min-width:640px){.dgrid{grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}}.dgrid>.slot.add:only-child{grid-column:1 / -1}.dcard{background:var(--card);border:1px solid var(--line);border-radius:var(--radius);padding:14px;display:flex;flex-direction:column;gap:12px;min-width:0;box-shadow:var(--shadow)}.dcard.online{border-color:color-mix(in srgb,var(--ok) 35%,transparent)}.dcard.off{opacity:.7}.dhead{display:flex;align-items:center;gap:12px}.dic{width:40px;height:40px;border-radius:12px;background:var(--soft);display:inline-flex;align-items:center;justify-content:center;flex:0 0 auto;color:var(--muted)}.dic .ic-svg{width:20px;height:20px}.dcard.online .dic{background:var(--ok-wash);color:var(--ok)}.dcard.here{border:1.5px dotted color-mix(in srgb,var(--accent) 80%,transparent)}.dcard.here .dic{background:color-mix(in srgb,var(--accent) 16%,transparent);color:var(--info)}.dstat.here{color:var(--info)}.dname{font-weight:500;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.dstat{display:inline-flex;align-items:center;gap:6px;font-size:13px;color:var(--muted)}.dstat.ok{color:var(--ok)}.dstat.warn{color:var(--warn)}.duse{display:flex;align-items:flex-end;justify-content:space-between;gap:12px}.spark{display:flex;align-items:flex-end;gap:3px;height:26px;width:128px}.spark i{flex:1;display:block;border-radius:2px 2px 0 0;background:var(--chart);opacity:.85;cursor:default}.spark i.zero{opacity:.22}.spark i:hover{opacity:1;filter:brightness(1.2)}.names{display:flex;flex-direction:column;gap:10px;padding:12px;border-radius:12px;border:1px solid var(--line)}.names-head{display:flex;gap:10px;align-items:flex-start}.names-ic{width:28px;height:28px;border-radius:8px;display:inline-flex;align-items:center;justify-content:center;flex:none;background:color-mix(in srgb,var(--info) 14%,transparent);color:var(--info)}.names-ic .ic-svg{width:15px;height:15px}.names-list{display:flex;flex-wrap:wrap;gap:6px}.name-chip{all:unset;box-sizing:border-box;cursor:pointer;display:inline-flex;align-items:center;gap:6px;height:28px;max-width:100%;padding:0 9px 0 10px;border-radius:999px;background:var(--soft)}.name-chip:hover{background:var(--soft-hover)}.name-chip:focus-visible{outline:2px solid var(--accent);outline-offset:2px}.name-chip .mono{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0}.name-chip .ic-svg{width:13px;height:13px;color:var(--faint)}.slot.add{all:unset;box-sizing:border-box;cursor:pointer;display:flex;align-items:center;gap:14px;padding:16px;min-height:72px;border:1px dashed var(--input);border-radius:var(--radius);color:var(--text);text-align:left}.slot.add:hover{background:var(--soft);border-color:color-mix(in srgb,var(--text) 30%,transparent)}.slot-ic{width:40px;height:40px;border-radius:12px;background:var(--soft);display:inline-flex;align-items:center;justify-content:center;flex:0 0 auto;color:var(--muted)}.slot.add:hover .slot-ic{background:var(--primary);color:var(--primary-fg)}.slot.add:focus-visible{outline:2px solid var(--accent);outline-offset:2px}@media(min-width:960px){.slot.add{flex-direction:column;justify-content:center;gap:10px;min-height:140px;text-align:center;color:var(--muted)}.slot.add .stack{align-items:center}.slot.add .strong{color:var(--text)}.slot.add .slot-ic{border-radius:999px;width:36px;height:36px}}.ic{display:inline-flex;line-height:0}.ic-svg{width:16px;height:16px}.btn{all:unset;box-sizing:border-box;cursor:pointer;display:inline-flex;align-items:center;justify-content:center;gap:8px;height:40px;padding:0 16px;border-radius:999px;font-size:14px;font-weight:500;background:var(--soft);color:var(--text);-webkit-tap-highlight-color:transparent;white-space:nowrap}.btn:hover{background:var(--soft-hover)}.btn.primary{background:var(--primary);color:var(--primary-fg)}.btn.primary:hover{opacity:.9}.btn.danger-solid{background:var(--bad);color:#fff}.btn.small{height:32px;padding:0 12px;font-size:13px}.btn.big{height:48px;font-size:15px}.btn.block{display:flex;width:100%}.btn[disabled]{opacity:.45;cursor:not-allowed}.btn:focus-visible,.kind:focus-visible,.icon-btn:focus-visible,.slot:focus-visible{outline:2px solid var(--accent);outline-offset:2px}.icon-btn{all:unset;cursor:pointer;width:36px;height:36px;display:inline-flex;align-items:center;justify-content:center;border-radius:50%;color:var(--muted);flex:0 0 auto}.icon-btn:hover{background:var(--soft);color:var(--text)}.icon-btn.soft{background:var(--soft)}@media(pointer:coarse){.icon-btn{width:40px;height:40px}}input[type=text]{width:100%;font:inherit;color:var(--text);background:var(--card);border:1px solid var(--input);border-radius:10px;padding:0 12px;height:44px}input[type=text]:focus{outline:none;border-color:transparent;box-shadow:0 0 0 2px color-mix(in srgb,var(--accent) 60%,transparent)}.lbl{display:block;font-size:13px;font-weight:500;color:var(--muted);margin:14px 2px 6px}.err{color:var(--bad);min-height:1.2em;margin:8px 2px;font-size:14px}.kinds{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:6px}.kind{all:unset;box-sizing:border-box;cursor:pointer;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:6px;height:63px;min-width:0;border-radius:12px;box-shadow:inset 0 0 0 1px var(--line);color:var(--muted);font-size:12.5px;line-height:15px;font-weight:500;text-align:center}.kind .ic{display:inline-flex;line-height:0}.kind .ic-svg{width:20px;height:20px}.kind:hover{color:var(--text);background:color-mix(in srgb,var(--text) 4%,transparent)}.kind.on{box-shadow:inset 0 0 0 1.5px var(--accent);color:var(--text);background:color-mix(in srgb,var(--accent) 10%,transparent)}.kind.on .ic{color:var(--accent)}.signin{text-align:center;max-width:420px;margin:8vh auto 0;width:100%;padding:28px 20px;display:flex;flex-direction:column;gap:10px}.hero-ic{width:52px;height:52px;margin:0 auto 6px;border-radius:16px;display:grid;place-items:center;background:var(--primary);color:var(--primary-fg)}.hero-ic .ic-svg{width:24px;height:24px}.signin input{text-align:center;margin-top:8px}.menu{position:absolute;z-index:30;width:230px;padding:4px;border-radius:14px;background:var(--elevated);border:1px solid var(--line);box-shadow:var(--shadow-xl)}.menu-item{all:unset;box-sizing:border-box;cursor:pointer;display:flex;align-items:center;gap:10px;width:100%;height:40px;padding:0 12px;border-radius:10px;font-size:14px}.menu-item:hover,.menu-item:focus-visible{background:var(--soft-hover)}.menu-item .ic{color:var(--muted)}.menu-item.danger,.menu-item.danger .ic{color:var(--bad)}.menu-item.warn,.menu-item.warn .ic{color:var(--warn)}.menu-sep{height:1px;background:var(--line);margin:4px 8px}@media(pointer:coarse){.menu-item{height:44px}}.sheet{position:fixed;inset:0;z-index:20;display:flex;align-items:flex-end;justify-content:center}.scrim{position:absolute;inset:0;background:var(--scrim)}.sheet-panel{position:relative;width:100%;max-width:520px;max-height:92vh;max-height:92dvh;overflow:auto;background:var(--elevated);border-radius:20px 20px 0 0;border:1px solid var(--line);border-bottom:0;padding:6px 16px max(20px,env(safe-area-inset-bottom))}.grab{width:36px;height:4px;border-radius:999px;background:var(--input);margin:4px auto 8px}.sheet-head{display:flex;align-items:flex-start;justify-content:space-between;gap:8px;padding:4px 0 12px}.sheet-head h2{font-size:20px;line-height:28px;font-weight:600}.sheet-body{display:flex;flex-direction:column;gap:14px}@media(min-width:640px){.sheet{align-items:center}.sheet-panel{border-radius:16px;border-bottom:1px solid var(--line);padding:20px;max-width:480px}.grab{display:none}}.ask{display:flex;flex-direction:column;align-items:center;text-align:center;gap:8px;padding-top:6px}.ask h2{font-size:18px;line-height:24px;font-weight:600}.ask p{margin:0;font-size:14px;line-height:20px}.ask-ic{width:52px;height:52px;border-radius:16px;display:grid;place-items:center;margin-bottom:6px}.ask-ic .ic-svg{width:24px;height:24px}.ask-ic.bad{background:var(--bad-wash);color:var(--bad)}.ask-ic.warn{background:var(--warn-wash);color:var(--warn)}.ask-actions{width:100%;margin-top:10px}@media(min-width:640px){.sheet-panel.asks{max-width:360px;padding:24px 20px 20px}.ask{padding-top:0}}.pane{display:flex;flex-direction:column;gap:10px}.qr{width:min(240px,70vw);aspect-ratio:1;background:#0a0a0a;border-radius:22px;padding:12px;box-shadow:inset 0 0 0 1px #ffffff2e}.qr.light{background:#fff;border-radius:12px;padding:10px;box-shadow:inset 0 0 0 1px var(--line)}.qr svg{display:block;width:100%;height:100%}.filecard{display:flex;align-items:center;gap:12px;padding:12px;border-radius:14px;background:var(--soft);min-width:0}.filecard>.stack{flex:1;min-width:0}.filecard-ic{width:40px;height:46px;border-radius:8px;flex:none;display:inline-flex;align-items:center;justify-content:center;font:10px var(--mono);color:var(--muted);background:var(--card);box-shadow:inset 0 0 0 1px var(--line)}.ellipsis{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0}@media(max-width:480px){.filecard .ellipsis{white-space:normal;overflow-wrap:anywhere}}.confbox{border:1px solid var(--line);border-radius:12px}.confbox>summary{list-style:none;display:flex;align-items:center;gap:8px;padding:8px 10px 8px 12px;color:var(--text)}.confbox>summary::-webkit-details-marker{display:none}.confbox>summary>.ic:first-child{transition:transform .2s var(--ease-out);color:var(--muted)}.confbox[open]>summary>.ic:first-child{transform:rotate(90deg)}.confbox .grow{flex:1}.confbox>.conf{margin:0;border-top:1px solid var(--line);border-radius:0 0 12px 12px;background:none}.conf-sec{color:var(--accent, var(--info))}.conf-k{color:var(--faint)}.conf-mask{padding:0 6px;border-radius:4px;background:var(--soft);color:var(--muted)}.conf{white-space:pre-wrap;word-break:break-all;font:12px/18px var(--mono);background:var(--soft);border-radius:10px;padding:12px;max-height:16rem;overflow:auto}details>summary{cursor:pointer;color:var(--muted);font-size:13px;font-weight:500}.tip{position:fixed;z-index:50;translate:-50% -100%;padding:6px 10px;border-radius:10px;font-size:12px;line-height:17px;white-space:nowrap;background:var(--elevated);border:1px solid var(--line);box-shadow:var(--shadow-xl);pointer-events:none}.tip-title{font-weight:500}.toast{position:fixed;left:50%;bottom:max(20px,env(safe-area-inset-bottom));translate:-50% 0;z-index:60;background:var(--primary);color:var(--primary-fg);padding:10px 16px;border-radius:999px;font-weight:500;font-size:14px;max-width:90vw}.toast.bad{background:var(--bad);color:#fff}.firststeps{grid-column:1 / -1;display:flex;flex-direction:column;gap:12px}.firststeps p{margin:0;font-size:14px}.firststeps h2{margin:0;font-size:17px}.setup{display:flex;flex-direction:column;gap:12px}.step{border:1px solid var(--line);border-radius:16px;background:var(--card);padding:14px 16px 16px;display:flex;flex-direction:column;gap:12px;min-width:0}.step-head{display:flex;align-items:center;gap:10px}.step-n{width:22px;height:22px;border-radius:50%;background:var(--soft);display:inline-flex;align-items:center;justify-content:center;font-size:12px;font-weight:600;flex:none}.step-n:empty{display:none}.step-ic{width:28px;height:28px;border-radius:8px;background:var(--soft);display:inline-flex;align-items:center;justify-content:center;flex:none}.step-title{font-weight:600;font-size:16px;display:flex;align-items:center;gap:10px;min-width:0;flex:1}.chip{font-size:11px;padding:2px 7px;border-radius:999px;background:#3a83f729;color:var(--accent);white-space:nowrap}.fold-link{all:unset;cursor:pointer;font-size:13px;color:var(--muted);padding:4px 0}.fold-link:hover{color:var(--text)}.badge{all:unset;box-sizing:border-box;cursor:pointer;display:flex;align-items:center;gap:12px;padding:8px 12px 8px 8px;border-radius:12px;min-height:56px;background:var(--soft);color:var(--text);min-width:0}.badge:hover{background:var(--soft-hover)}.badge.primary{background:var(--primary);color:var(--primary-fg)}.badge-ic{width:36px;height:36px;border-radius:10px;flex:none;display:inline-flex;align-items:center;justify-content:center;background:#7f7f7f2e}.badge-ic .ic-svg{width:20px;height:20px}.badge-txt{display:flex;flex-direction:column;line-height:1.2;min-width:0;flex:1}.badge-top{font-size:11px;opacity:.7}.badge-main{font-size:15px;font-weight:600;letter-spacing:-.01em;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.badge-chev{opacity:.5;display:inline-flex;flex:none}.badges2{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}.badges2 .badge-chev{display:none}.pills{display:flex;flex-wrap:wrap;gap:6px}.pill{all:unset;box-sizing:border-box;cursor:pointer;display:inline-flex;align-items:center;gap:6px;font-size:13px;padding:7px 10px 7px 9px;border-radius:999px;border:1px solid var(--line);color:var(--muted);white-space:nowrap}.pill .ic-svg{width:14px;height:14px}.pill.on{border-color:var(--accent);background:#3a83f71f;color:var(--text)}.howto{margin:0;padding:0 4px 0 22px;font-size:13px;color:var(--muted);display:flex;flex-direction:column;gap:4px}.howto b{font-weight:500;color:var(--text)}.linkrow{display:flex;align-items:center;gap:8px;padding:6px 6px 6px 12px;border-radius:12px;background:var(--soft);min-width:0}.linkrow .mono{flex:1;min-width:0;font-size:12px;color:var(--muted)}.qr.small{width:148px;flex:none}.code-row{display:flex;flex-direction:column;align-items:center;gap:12px}.code-row>.stack{align-self:stretch}.qr.big{width:100%}.pill-link{all:unset;box-sizing:border-box;cursor:pointer;display:inline-flex;align-items:center;gap:4px;font-size:12px;font-weight:500;padding:5px 8px 5px 10px;border-radius:999px;border:1px solid var(--line);color:var(--muted);white-space:nowrap}.pill-link:hover{color:var(--text);background:var(--soft)}.pill-link .ic-svg{width:13px;height:13px;transform:rotate(90deg)}.step-sub{margin-top:-8px}.step-head.fold{all:unset;box-sizing:border-box;cursor:pointer;display:flex;align-items:center;gap:10px;width:100%;color:inherit}.fold-chev{display:inline-flex;color:var(--muted)}.fold-chev .ic-svg{width:16px;height:16px}.step.folded{padding-bottom:14px}.way{display:flex;flex-direction:column;gap:10px;padding:12px 14px;border-radius:14px;background:var(--soft)}.way-row{display:flex;align-items:center;gap:10px}.way-end{width:36px;height:36px;border-radius:10px;flex:none;display:inline-flex;align-items:center;justify-content:center;background:var(--soft-hover);color:var(--muted)}.way-end .ic-svg{width:18px;height:18px}.way-end.home{color:var(--info);background:color-mix(in srgb,var(--info) 14%,transparent)}.way-track{position:relative;flex:1;height:8px}.way-track:before,.way-glow,.way-fill{position:absolute;inset:0;-webkit-mask:radial-gradient(circle,#000 1.4px,transparent 1.9px) 0 50% / 9px 8px repeat-x;mask:radial-gradient(circle,#000 1.4px,transparent 1.9px) 0 50% / 9px 8px repeat-x}.way-track:before{content:"";background:var(--faint);opacity:.55}.way-glow{overflow:hidden}.way-glow i{position:absolute;inset:0;background:linear-gradient(90deg,transparent 32%,var(--info) 50%,transparent 68%);transform:translate(-70%)}.way-fill{background:var(--ok);clip-path:inset(0 100% 0 0)}.way-text{display:flex;flex-direction:column;align-items:center;text-align:center;gap:2px}.way-text>:empty{display:none}.way.done .way-end{background:var(--ok-wash);color:var(--ok)}.way.done .way-fill{clip-path:inset(0)}.way.done .way-glow,.way.stopped .way-glow{opacity:0}.btn,.badge,.pill,.kind,.icon-btn,.slot.add,.slot-ic,.name-chip,.fold-link,.pill-link,.menu-item{transition:transform var(--dur-press) var(--ease-out),background-color var(--dur-hover) var(--ease-out),border-color var(--dur-hover) var(--ease-out),box-shadow var(--dur-hover) var(--ease-out),color var(--dur-hover) var(--ease-out),opacity var(--dur-hover) var(--ease-out)}.btn:active,.pill:active,.kind:active,.icon-btn:active,.fold-link:active,.pill-link:active{transform:scale(.97)}.badge:active,.slot.add:active{transform:scale(.985)}.name-chip:active{transform:scale(.96)}.btn[disabled]:active{transform:none}.icon-btn[aria-expanded=true]{background:var(--soft-hover);color:var(--text)}.kind .ic,.menu-item .ic{transition:color var(--dur-hover) var(--ease-out)}.spark i{transition:opacity .12s var(--ease-out),filter .12s var(--ease-out)}input,textarea{transition:border-color var(--dur-hover) var(--ease-out),box-shadow var(--dur-hover) var(--ease-out)}.intro,.slot.add.intro{animation:rise-in var(--dur-enter) var(--ease-out) backwards;animation-delay:calc(40ms + var(--i, 0) * 45ms)}.top.first .sun{animation:sunrise .9s var(--ease-out) .12s backwards}.wrap.first .meter i{animation:fill-x .8s var(--ease-out) .3s backwards}.wrap.first .slots i.used,.wrap.first .slots i.over{animation:fill-x .48s var(--ease-out) backwards;animation-delay:calc(.32s + var(--i, 0) * 50ms)}.wrap.first .spark i{transform-origin:bottom;animation:grow-y .56s var(--ease-out) backwards;animation-delay:calc(.32s + var(--i, 0) * 30ms)}.wrap.first .avatar.online:after{animation:pop-in .48s var(--spring-pop) .42s backwards}.wrap.first .hero-ic{animation:pop-in .52s var(--spring-pop) .16s backwards}.enter,.slot.add.enter{animation:rise-in .36s var(--ease-out) backwards}.unfold{animation:rise-in .32s var(--ease-out) backwards;animation-delay:calc(30ms + var(--i, 0) * 40ms)}.swap{animation:focus-in var(--dur-swap) var(--ease-out) backwards}.swap-ic{animation:icon-in .28s var(--spring) backwards}.copied>.ic,.copied .badge-ic .ic{color:var(--ok)}.badge.primary.copied .badge-ic .ic{color:inherit}.menu{opacity:0;transform:translateY(-4px) scale(.96);transform-origin:top right;filter:blur(2px);transition:opacity var(--dur-pop) var(--ease-out),transform .22s var(--ease-out),filter var(--dur-pop) var(--ease-out)}.menu.up{transform:translateY(4px) scale(.96);transform-origin:bottom right}.menu.show{opacity:1;transform:none;filter:none}.menu.gone{opacity:0;transform:scale(.98);filter:none;pointer-events:none;transition-duration:.12s;transition-timing-function:var(--ease-in)}.tip{opacity:0;transform:translateY(4px) scale(.96);transform-origin:50% 100%;transition:opacity .12s var(--ease-out),transform var(--dur-pop) var(--ease-out)}.tip.show{opacity:1;transform:none}.toast{opacity:0;transform:translateY(12px) scale(.96);filter:blur(4px);transition:transform .38s var(--ease-out),opacity .24s var(--ease-out),filter .24s var(--ease-out)}.toast.show{opacity:1;transform:none;filter:none}.toast.gone{opacity:0;transform:translateY(4px) scale(.98);filter:blur(2px);transition-duration:var(--dur-exit);transition-timing-function:var(--ease-in)}.scrim{opacity:0;transition:opacity .3s var(--ease-out)}.sheet.open .scrim{opacity:1}.sheet.closing .scrim{transition-duration:.26s}.sheet-panel{transform:translateY(100%);transition:transform var(--dur-sheet) var(--ease-drawer)}.sheet.open .sheet-panel{transform:none}.sheet.closing .sheet-panel{transition-duration:.3s}.sheet-panel.dragging{transition:none}.sheet-panel.morphing{overflow:hidden}.sheet-panel.morphing-w{max-width:none}@media(max-width:639px){.grab,.sheet-head,.ask{touch-action:none}.grab{cursor:grab}}@media(min-width:640px){.sheet-panel{opacity:0;transform:translateY(8px) scale(.96);filter:blur(4px);transition:opacity .22s var(--ease-out),transform .32s var(--ease-out),filter .22s var(--ease-out)}.sheet.open .sheet-panel{opacity:1;transform:none;filter:none}.sheet.closing .sheet-panel{opacity:0;transform:scale(.98);filter:blur(2px);transition-duration:var(--dur-exit);transition-timing-function:var(--ease-in)}.sheet.closing .scrim{transition-duration:.18s}.sheet.fresh .sheet-inner>.sheet-head,.sheet.fresh .sheet-body>:not(.setup),.sheet.fresh .setup>*{animation:settle-in .28s var(--ease-out) backwards;animation-delay:calc(20ms + var(--i, 0) * 25ms)}}.sheet.fresh .ask-ic{animation:pop-in .52s var(--spring-pop) 80ms backwards}.sheet-inner,.setup{position:relative;isolation:isolate}.ghost{position:absolute;z-index:-1;pointer-events:none}.fold.to-off .fold-chev{animation:icon-in .28s var(--spring) backwards}.pill.to-on{animation:pill-on var(--dur-pop) var(--ease-out)}.pill.to-off{animation:pill-off var(--dur-pop) var(--ease-out)}.pill.to-on .ic,.kind.on .ic{animation:pop-sm .34s var(--spring-pop)}.qr.swap{animation:qr-in .36s var(--ease-out) backwards}.conf-v.unmask{animation:unmask .42s var(--ease-out) backwards}.conf-mask.unmask{animation:focus-in .2s var(--ease-out) backwards}.confbox[open]>.conf{animation:rise-in .26s var(--ease-out) backwards}.way-glow i{animation:way-run 2s cubic-bezier(.45,0,.55,1) infinite}.way-glow{transition:opacity .2s var(--ease-out)}.way-fill{transition:clip-path .7s var(--ease-out) 80ms}.way-end{transition:background-color .3s var(--ease-out),color .3s var(--ease-out)}.way.done .way-end.home{transition-delay:.6s}.way.done .way-end.home .ic{animation:pop-sm .42s var(--spring-pop) .6s}.btn{--spin: var(--text)}.btn.primary{--spin: var(--primary-fg)}.btn.danger-solid{--spin: #fff}.btn.busy{position:relative;color:transparent!important;cursor:progress}.btn.busy[disabled]{opacity:1}.btn.busy:after{content:"";position:absolute;inset:0;margin:auto;width:16px;height:16px;border-radius:50%;border:2px solid color-mix(in srgb,var(--spin) 28%,transparent);border-top-color:var(--spin);animation:spin .7s linear infinite,focus-in var(--dur-hover) var(--ease-out)}.btn[disabled]{transition:opacity var(--dur-hover) var(--ease-out)}@keyframes rise-in{0%{opacity:0;transform:translateY(8px);filter:blur(4px)}}@keyframes settle-in{0%{opacity:0;transform:translateY(4px)}}@keyframes focus-in{0%{opacity:0;filter:blur(4px)}}@keyframes fade{0%{opacity:0}}@keyframes icon-in{0%{opacity:0;transform:scale(.7);filter:blur(3px)}}@keyframes pop-in{0%{opacity:0;transform:scale(.7);filter:blur(4px)}}@keyframes pop-sm{0%{transform:scale(.82)}}@keyframes sunrise{0%{transform:translateY(10px)}}@keyframes fill-x{0%{clip-path:inset(0 100% 0 0 round 999px)}to{clip-path:inset(0 0 0 0 round 999px)}}@keyframes grow-y{0%{transform:scaleY(0)}}@keyframes pill-on{0%{border-color:var(--line);background-color:transparent;color:var(--muted)}}@keyframes pill-off{0%{border-color:var(--accent);background-color:#3a83f71f;color:var(--text)}}@keyframes qr-in{0%{opacity:0;transform:scale(.98);filter:blur(6px)}}@keyframes unmask{0%{opacity:.25;filter:blur(5px)}}@keyframes way-run{0%{transform:translate(-70%)}72%,to{transform:translate(70%)}}@keyframes spin{to{transform:rotate(360deg)}}@media(prefers-reduced-motion:reduce){.intro,.slot.add.intro,.enter,.slot.add.enter,.unfold,.swap,.swap-ic,.qr.swap,.conf-v.unmask,.confbox[open]>.conf,.wrap.first .hero-ic,.wrap.first .avatar.online:after,.sheet.fresh .sheet-inner>.sheet-head,.sheet.fresh .sheet-body>:not(.setup),.sheet.fresh .setup>*,.sheet.fresh .ask-ic{animation-name:fade;animation-duration:.2s}.top.first .sun,.wrap.first .meter i,.wrap.first .slots i.used,.wrap.first .slots i.over,.wrap.first .spark i,.fold.to-off .fold-chev,.pill.to-on .ic,.kind.on .ic,.way.done .way-end.home .ic{animation:none}.way-glow{display:none}.way-fill{transition:none}.sheet-panel,.sheet.open .sheet-panel,.sheet.closing .sheet-panel,.menu,.menu.up,.menu.gone,.tip,.toast,.toast.gone{transform:none;filter:none}.sheet-panel{opacity:0;transition:opacity .2s var(--ease-out)}.sheet.open .sheet-panel{opacity:1}.confbox>summary>.ic:first-child{transition:none}.btn:active,.badge:active,.pill:active,.kind:active,.icon-btn:active,.slot.add:active,.name-chip:active,.fold-link:active,.pill-link:active{transform:none}} +@font-face{font-family:Geist;src:url(geist-latin-wght-normal.woff2) format("woff2");font-weight:100 900;font-display:swap;unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+2000-206F,U+20AC,U+2122,U+2190-21FF,U+2212,U+2215}@font-face{font-family:Geist;src:url(geist-cyrillic-wght-normal.woff2) format("woff2");font-weight:100 900;font-display:swap;unicode-range:U+0301,U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116}@font-face{font-family:Geist Mono;src:url(geist-mono-latin-wght-normal.woff2) format("woff2");font-weight:100 900;font-display:swap}:root{color-scheme:dark;--bg: #080808;--raised: #121212;--field: #161616;--knob: #232323;--seg: rgba(237, 237, 237, .05);--seg-shadow: none;--line: rgba(255, 255, 255, .06);--text: #ededed;--text-2: #8c8c8a;--text-3: #4f4f4e;--accent: #4eafff;--accent-ink: #ffffff;--accent-soft: rgba(78, 175, 255, .13);--ok: #57d64b;--ok-soft: rgba(87, 214, 75, .14);--warn: #ff8a3d;--bad: #ff5c5c;--bad-soft: rgba(255, 92, 92, .13);--sel-bg: rgba(131, 209, 255, .25);--sel-fg: #64c6ff;--scrim: rgba(8, 8, 8, .8);--line-glass: rgba(255, 255, 255, .07);--pop-shadow: 0 18px 48px -14px rgba(0, 0, 0, .75);--sheet-shadow: 0 24px 64px -16px rgba(0, 0, 0, .6);--bar: rgba(237, 237, 237, .13);--toast: #232323;--toast-fg: #ededed;--qr-bg: #0a0a0a;--gi-a: rgba(255, 255, 255, .58);--gi-b: rgba(255, 255, 255, .14);--gi-rim: rgba(255, 255, 255, .5);--gi-edge: rgba(0, 0, 0, 0);--gi-detail: #ffffff;--t-grey-a: #cfcfcd;--t-grey-b: #5a5a59;--t-blue-a: #a6d9ff;--t-blue-b: #1d84e6;--t-green-a: #a8f29c;--t-green-b: #3aa32c;--t-red-a: #ffadad;--t-red-b: #dc3a3a;--t-orange-a: #ffc08f;--t-orange-b: #ec6a12;--font: Geist, -apple-system, system-ui, "Segoe UI", sans-serif;--mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;--r-sheet: 36px;--r-card: 28px;--r-row: 20px;--r-field: 16px;--r-tile: 12px;--ease-out: cubic-bezier(.23, 1, .32, 1);--gutter-l: max(16px, env(safe-area-inset-left, 0px));--gutter-r: max(16px, env(safe-area-inset-right, 0px))}@media(prefers-color-scheme:light){:root{color-scheme:light;--bg: #f2f2f1;--raised: #ffffff;--field: #f3f3f2;--knob: #e8e8e7;--seg: #ffffff;--seg-shadow: 0 1px 2px rgba(0, 0, 0, .08), 0 0 0 .5px rgba(0, 0, 0, .05);--line: rgba(0, 0, 0, .07);--text: #0b0b0b;--text-2: #6d6d6b;--text-3: #a6a6a4;--accent: #2b9dff;--accent-soft: rgba(43, 157, 255, .12);--ok: #33a328;--ok-soft: rgba(51, 163, 40, .12);--warn: #ee6a12;--bad: #e5484d;--bad-soft: rgba(229, 72, 77, .1);--sel-bg: rgba(78, 175, 255, .22);--sel-fg: #0a76cf;--scrim: rgba(236, 236, 235, .62);--line-glass: rgba(0, 0, 0, .07);--pop-shadow: 0 18px 44px -14px rgba(0, 0, 0, .2);--sheet-shadow: 0 24px 64px -18px rgba(0, 0, 0, .22);--bar: rgba(11, 11, 11, .11);--toast: #0b0b0b;--toast-fg: #f2f2f1;--qr-bg: #ffffff;--gi-a: rgba(250, 250, 249, .72);--gi-b: rgba(206, 206, 204, .5);--gi-rim: rgba(255, 255, 255, .9);--gi-edge: rgba(0, 0, 0, .11);--gi-detail: rgba(28, 28, 28, .72);--t-grey-a: #a9a9a7;--t-grey-b: #3d3d3c;--t-blue-a: #7cc4ff;--t-blue-b: #0a6fd6;--t-green-a: #82e070;--t-green-b: #2e8a22;--t-red-a: #ff9090;--t-red-b: #c92a2a}}*{box-sizing:border-box}html{-webkit-text-size-adjust:100%;scrollbar-gutter:stable}body{margin:0;background:var(--bg);color:var(--text);font:400 15px/22px var(--font);letter-spacing:-.011em;-webkit-font-smoothing:antialiased;min-height:100vh;min-height:100dvh;cursor:default}body.locked{overflow:hidden}input,textarea,.linkrow .mono,.conf{cursor:text}::selection{background:var(--sel-bg);color:var(--sel-fg)}button{font:inherit;color:inherit;letter-spacing:inherit;background:none;border:0;padding:0;margin:0;cursor:pointer;-webkit-tap-highlight-color:transparent}button:disabled{cursor:default}a{color:inherit;text-decoration:none}:focus{outline:none}:focus-visible{outline:2px solid color-mix(in srgb,var(--accent) 65%,transparent);outline-offset:2px}[hidden]{display:none!important}.offscreen{position:fixed;left:-9999px;top:0;opacity:0}.mono{font-family:var(--mono);letter-spacing:0}.num{font-variant-numeric:tabular-nums}.ok-t{color:var(--ok)}.warn-t{color:var(--warn)}.bad-t{color:var(--bad)}.here-t{color:var(--accent)}.i{width:18px;height:18px;flex:none}.gi{width:24px;height:24px;flex:none;overflow:visible;--ta: var(--t-grey-a);--tb: var(--t-grey-b)}.gi.t-blue{--ta: var(--t-blue-a);--tb: var(--t-blue-b)}.gi.t-green{--ta: var(--t-green-a);--tb: var(--t-green-b)}.gi.t-red{--ta: var(--t-red-a);--tb: var(--t-red-b)}.gi.t-orange{--ta: var(--t-orange-a);--tb: var(--t-orange-b)}.gi .ta{stop-color:var(--ta)}.gi .tb{stop-color:var(--tb)}.gi .fa{stop-color:var(--gi-a)}.gi .fb{stop-color:var(--gi-b)}.gi .fc{stop-color:var(--ta);stop-opacity:.28}.gi .ge{stroke:var(--gi-edge)}.gi .gr{stroke:var(--gi-rim)}.gi .gd{stroke:var(--gi-detail)}.gi .gdf{color:var(--gi-detail)}.knob{width:32px;height:32px;border-radius:50%;background:var(--knob);color:var(--text);display:grid;place-items:center;flex:none;transition:transform .15s var(--ease-out),background-color .15s}.knob:hover{background:color-mix(in srgb,var(--knob),var(--text) 6%)}.knob:active{transform:scale(.8)}.knob .i{width:16px;height:16px}.knob.back .i{transform:rotate(180deg)}.knob[aria-expanded=true]{background:color-mix(in srgb,var(--knob),var(--text) 10%)}.btn{height:48px;border-radius:999px;display:inline-flex;align-items:center;justify-content:center;gap:8px;padding:0 20px;font-size:16px;font-weight:500;letter-spacing:-.015em;user-select:none;-webkit-user-select:none;transition:transform .2s var(--ease-out),background-color .2s var(--ease-out),color .2s var(--ease-out)}.btn:active{transform:scale(.95)}.btn.block{width:100%}.btn.sm{height:40px;font-size:15px;padding:0 16px}.btn.accent{background:var(--accent);color:var(--accent-ink);font-weight:600}.btn.accent:hover{background:color-mix(in srgb,var(--accent) 82%,transparent)}.btn.tint{background:var(--accent-soft);color:var(--accent);font-weight:600}.btn.tint:hover{background:color-mix(in srgb,var(--accent) 20%,transparent)}.btn.tint:active{background:color-mix(in srgb,var(--accent) 24%,transparent)}.btn.soft{background:var(--knob);color:var(--text)}.btn.soft:hover{background:color-mix(in srgb,var(--knob),var(--text) 6%)}.btn.red{background:var(--bad);color:#fff;font-weight:600}.busy{position:relative}.orb{position:absolute;inset:0;margin:auto;width:28px;height:28px;overflow:hidden;contain:strict;pointer-events:none}.orb i{position:absolute;left:50%;top:50%;width:7px;height:7px;margin:-3.5px 0 0 -3.5px;border-radius:50%;background:currentColor;animation:orb-converge 1.8s linear infinite both}.orb i:nth-child(2){animation:orb-breathe 1.8s ease-in-out infinite both}@keyframes orb-converge{0%{transform:translateY(-5px) scale(1);filter:blur(0);animation-timing-function:linear}10%{transform:translateY(-5px) scale(1);filter:blur(0);animation-timing-function:cubic-bezier(.55,0,1,.45)}22%{transform:translate(2.15px,-1.25px) scale(.72);filter:blur(.8px);animation-timing-function:cubic-bezier(.33,1,.68,1)}33%{transform:translate(4.3px,2.5px) scale(1);filter:blur(0);animation-timing-function:linear}43%{transform:translate(4.3px,2.5px) scale(1);filter:blur(0);animation-timing-function:cubic-bezier(.55,0,1,.45)}55%{transform:translateY(2.5px) scale(.72);filter:blur(.8px);animation-timing-function:cubic-bezier(.33,1,.68,1)}66%{transform:translate(-4.3px,2.5px) scale(1);filter:blur(0);animation-timing-function:linear}77%{transform:translate(-4.3px,2.5px) scale(1);filter:blur(0);animation-timing-function:cubic-bezier(.55,0,1,.45)}88%{transform:translate(-2.15px,-1.25px) scale(.72);filter:blur(.8px);animation-timing-function:cubic-bezier(.33,1,.68,1)}to{transform:translateY(-5px) scale(1);filter:blur(0)}}@keyframes orb-breathe{0%,to{opacity:.16;filter:blur(2.4px);transform:scale(1.2)}50%{opacity:.32;filter:blur(1.6px);transform:scale(.98)}}.field{height:48px;border-radius:var(--r-field);background:var(--field);display:flex;align-items:center;gap:12px;padding:0 4px 0 16px;overflow:hidden;transition:box-shadow .2s var(--ease-out)}.field:focus-within{box-shadow:inset 0 0 0 1.5px color-mix(in srgb,var(--text) 16%,transparent)}.field input{flex:1;min-width:0;border:0;outline:0;background:transparent;padding:0;font:500 16px/24px var(--font);color:var(--text);letter-spacing:-.012em}.field input::placeholder{color:var(--text-3)}.go{width:48px;height:40px;border-radius:12px;background:var(--knob);color:var(--text-3);display:grid;place-items:center;flex:none;transition:background-color .2s var(--ease-out),color .2s var(--ease-out),transform .2s var(--ease-out)}.go .i{width:20px;height:20px}.go.ready{background:var(--accent);color:var(--accent-ink)}.go.ready:active{transform:scale(.9)}.go:not(.ready){cursor:not-allowed}.seg{position:relative;display:flex;align-items:center;height:48px;padding:0 4px;border-radius:var(--r-field);background:var(--field)}.seg-pill{position:absolute;left:0;top:4px;height:40px;border-radius:12px;background:var(--seg);box-shadow:var(--seg-shadow);pointer-events:none}.seg-b{position:relative;z-index:1;height:40px;font-size:16px;font-weight:500;color:var(--text-3);white-space:nowrap;transition:color .2s var(--ease-out)}.seg-b.on{color:var(--text)}.seg-b:not(.on):hover{color:var(--text-2)}.appseg .seg-b{flex:0 0 56px;display:flex;align-items:center;justify-content:center;justify-content:safe center;gap:8px;padding:0 18px;overflow:hidden}.appseg .seg-b.on{flex:1 1 56px}.appseg .seg-b .i{width:20px;height:20px}.appseg .seg-l{max-width:0;opacity:0;margin-left:-8px;overflow:hidden;white-space:nowrap}.appseg .seg-b.on .seg-l{max-width:180px;opacity:1;margin-left:0}.appseg{container-type:inline-size}@container (max-width: 300px){.appseg .seg-b{flex-basis:44px;padding:0 12px}}.kinds{display:grid;grid-template-columns:repeat(var(--n, 4),minmax(0,1fr));gap:8px;position:relative;container-type:inline-size}.kind{position:relative;z-index:1;display:flex;flex-direction:column;align-items:center;gap:8px;min-width:0;color:var(--text-3);font-size:12px;line-height:16px;font-weight:500;transition:color .2s var(--ease-out)}.kind-tile{width:100%;height:56px;border-radius:14px;background:var(--field);display:grid;place-items:center;transition:background-color .2s var(--ease-out),transform .2s var(--ease-out),box-shadow .22s var(--ease-out)}.kind.on .kind-tile{box-shadow:inset 0 0 0 1.5px var(--accent)}.kind-lbl{white-space:nowrap}.kind:hover .kind-tile,.kind:focus-visible .kind-tile{background:var(--knob)}.kind:active .kind-tile{transform:scale(.94)}.kind:focus-visible{outline:none}.kind:focus-visible .kind-lbl,.kind.on{color:var(--text)}.kind .gi{width:26px;height:26px;filter:grayscale(1);opacity:.55;transition:filter .26s var(--ease-out),opacity .26s var(--ease-out)}.kind.on .gi{filter:none;opacity:1}@container (max-width: 330px){.kind-tile{height:50px}.kind{font-size:11.5px}}.or{display:flex;align-items:center;gap:12px;margin:22px 0;color:var(--text-3);font-size:12px;font-weight:500;letter-spacing:.06em}.or:before,.or:after{content:"";flex:1;height:1px;background:var(--line)}.badge{width:100%;text-align:left;display:flex;align-items:center;gap:12px;height:60px;padding:0 14px 0 12px;border-radius:18px;background:var(--field);transition:background-color .2s,transform .2s var(--ease-out)}.badge:hover{background:var(--knob)}.badge:active{transform:scale(.98)}.badge .b-ic{width:36px;height:36px;border-radius:10px;background:var(--text);color:var(--raised);display:grid;place-items:center;flex:none}.badge .b-ic .i{width:20px;height:20px}.badge .b-t{flex:1;min-width:0;display:flex;flex-direction:column}.badge .b-top{font-size:12px;line-height:16px;color:var(--text-2)}.badge .b-main{font-size:15px;line-height:20px;font-weight:500}.badge>.i{color:var(--text-3);width:16px;height:16px}.badge.primary .b-ic{background:var(--accent-soft);color:var(--accent)}.badges2{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}.badges2 .badge{padding:0 10px;gap:10px}.badges2 .badge>.i{display:none}.badges2 .b-ic{width:32px;height:32px}.hint{margin:0;font-size:13px;line-height:18px;color:var(--text-2)}.hint a,.hint button{color:var(--accent);font-weight:500}.howto{margin:0;padding:0;list-style:none;display:flex;flex-wrap:wrap;align-items:center;gap:6px;font-size:13px;color:var(--text-2)}.howto li{display:inline-flex;align-items:center;gap:6px}.howto li+li:before{content:"\203a";color:var(--text-3)}.howto b{color:var(--text);font-weight:500}.linkrow{display:flex;align-items:center;gap:8px;height:44px;padding:0 4px 0 14px;border-radius:14px;background:color-mix(in srgb,var(--knob) 72%,var(--field))}.view>.linkrow{background:var(--field)}.linkrow .mono{flex:1;min-width:0;font-size:13px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;user-select:all}.linkrow .knob{width:36px;height:36px;border-radius:10px;background:transparent}.linkrow .knob:hover{background:var(--knob)}.qrbox{position:relative;width:148px;height:148px;flex:none;border-radius:18px;overflow:hidden;background:var(--qr-bg)}.qrbox.light{box-shadow:inset 0 0 0 1px var(--line)}.qrbox.big{width:208px;height:208px;border-radius:24px;align-self:center}.qrbox.big+.linkrow{margin-top:16px}.qrbox.dense{width:100%;max-width:none;height:auto;aspect-ratio:1;align-self:stretch;border-radius:22px}.qrbox svg{display:block;width:100%;height:100%}.qrbox>svg.old{position:absolute;inset:0}.coderow{display:flex;gap:14px;align-items:flex-start}.coderow.stacked{flex-direction:column;align-items:stretch}.coderow .side{position:relative;display:flex;flex-direction:column;gap:8px;min-width:0;font-size:14px;line-height:20px;color:var(--text-2)}.coderow .side b{color:var(--text);font-weight:500}.side .words{display:flex;flex-direction:column;gap:8px}.side .words.old{position:absolute;left:0;right:0;top:0;pointer-events:none}.side .arr{color:var(--text-2);font-weight:400;margin:0 6px}@media(max-width:380px){.coderow{flex-direction:column}}@media(prefers-reduced-motion:reduce){.orb i{animation:none;opacity:.3;filter:blur(1.4px)}.orb i:first-child{opacity:1;filter:none}}.mt{position:relative}.mt-ib{display:inline-block;white-space:nowrap}.mt-new{white-space:nowrap}.mt-old{position:absolute;white-space:nowrap;pointer-events:none}.mt-new.w,.mt-old.w{white-space:inherit}.mt-new i,.mt-old i{font-style:normal;display:inline-block;white-space:pre}.acc{display:flex;flex-direction:column}.acc-row{background:var(--raised);overflow:hidden;border-radius:0;padding:0 8px;transition:background-color .15s}.acc-row.rt{border-top-left-radius:var(--r-row);border-top-right-radius:var(--r-row)}.acc-row.rb{border-bottom-left-radius:var(--r-row);border-bottom-right-radius:var(--r-row)}.acc-row.open{margin-block:10px}.acc-row.open:first-child{margin-top:0}.acc-row.open:last-child{margin-bottom:0}.acc-row:not(.open):not(.still):hover{background:color-mix(in srgb,var(--raised),var(--knob) 40%)}.acc-head{width:100%;display:flex;align-items:center;gap:10px;height:52px;padding:0 6px 0 8px;text-align:left}.acc-row.still .acc-head{cursor:default;padding-right:10px}.acc-head .gi{width:22px;height:22px}.acc-title{flex:1;min-width:0;font-size:15px;font-weight:500;letter-spacing:-.02em;display:flex;align-items:center;gap:8px}.acc-title .t{min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.acc-val{display:flex;align-items:center;gap:8px;color:var(--text-2);font-size:14px;white-space:nowrap;transition:opacity .2s var(--ease-out),filter .2s var(--ease-out),transform .26s var(--ease-out)}.acc-val>span{display:inline-flex;align-items:center;gap:8px}.acc-row.open .acc-val.hide-open{opacity:0;filter:blur(4px);transform:translate(8px);pointer-events:none}.acc-chev{width:16px;height:16px;color:var(--text-2);transform:rotate(90deg);transition:transform var(--spring-soft-dur, .47s) var(--spring-soft, ease)}.acc-row.open .acc-chev{transform:rotate(-90deg)}.acc-body{display:none;padding:0 8px 16px 40px}.acc-row.open .acc-body,.acc-row.closing .acc-body{display:flex;flex-direction:column;gap:12px}.acc .desc{margin:0;font-size:14px;line-height:20px;opacity:.6}.acc.inset .acc-row{background:var(--field)}.acc.inset .acc-row:not(.open):not(.still):hover{background:color-mix(in srgb,var(--field),var(--knob) 50%)}.acc.inset .acc-body{padding-left:8px}.acc.inset .seg{background:color-mix(in srgb,var(--knob) 65%,var(--field))}@media(prefers-reduced-motion:reduce){.acc-chev{transition:none}}.edge-fade{position:fixed;left:0;right:0;z-index:30;pointer-events:none}.edge-fade.top{top:0;height:calc(80px + env(safe-area-inset-top,0px));opacity:0;transition:opacity .2s;background:linear-gradient(var(--bg) 0%,color-mix(in srgb,var(--bg) 75%,transparent) 50%,transparent 100%);-webkit-backdrop-filter:blur(12px);backdrop-filter:blur(12px);-webkit-mask-image:linear-gradient(#000 0%,rgba(0,0,0,.88) 44%,transparent 100%);mask-image:linear-gradient(#000 0%,rgba(0,0,0,.88) 44%,transparent 100%)}body.scrolled .edge-fade.top{opacity:1}.edge-fade.bot{bottom:0;height:calc(96px + env(safe-area-inset-bottom,0px));background:linear-gradient(to top in oklab,var(--bg) 0%,transparent 100%)}.crumbs{display:flex;align-items:center;gap:10px;height:32px;margin:0 0 32px}.cr-mark{width:32px;height:32px;display:grid;place-items:center;flex:none}.logo{width:24px;height:24px;flex:none;overflow:hidden}.logo .sun,.logo .bar{fill:var(--text)}.cr-path{flex:1;min-width:0;display:flex;align-items:center;gap:6px;font-size:15px;line-height:22px;letter-spacing:-.15px;color:var(--text-2)}.cr-path span{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.cr-path .cur{color:var(--text);font-weight:500}.cr-path .i{width:14px;height:14px}.page{max-width:1072px;margin:0 auto;padding-left:var(--gutter-l);padding-right:var(--gutter-r);padding-block:calc(40px + env(safe-area-inset-top,0px)) 112px}.cols{display:grid;gap:40px}.cols>.access{order:-1}@media(min-width:960px){.cols{grid-template-columns:minmax(0,1fr) 384px;gap:36px;align-items:start}.cols>.access{order:0;position:sticky;top:calc(84px + env(safe-area-inset-top,0px))}}.sec-head{display:flex;align-items:baseline;gap:8px;padding:0 4px 12px}.sec-head h2{margin:0;font-size:20px;line-height:28px;font-weight:500;letter-spacing:-.025em}.sec-head .aside{color:var(--text-3);font-size:14px;font-weight:500}.sec-head .aside.warn-t{color:var(--warn)}.note-s{margin:12px 4px 0;color:var(--text-3);font-size:13px;line-height:18px}.notice{display:flex;align-items:center;gap:14px;padding:14px 18px 14px 14px;border-radius:24px;background:var(--raised);margin:0 0 22px}.notice .gi{width:36px;height:36px}.notice .t{display:flex;flex-direction:column;min-width:0}.notice b{font-weight:500;font-size:15px;line-height:22px;letter-spacing:-.02em}.notice span{color:var(--text-2);font-size:14px;line-height:20px}.notice.warn{background:color-mix(in srgb,var(--warn) 10%,var(--raised));box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--warn) 22%,transparent)}.notice.bad{background:color-mix(in srgb,var(--bad) 10%,var(--raised));box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--bad) 22%,transparent)}.page.single{min-height:100vh;min-height:100dvh;display:flex;flex-direction:column;align-items:center;justify-content:center;padding-block:calc(24px + env(safe-area-inset-top,0px)) calc(24px + env(safe-area-inset-bottom,0px))}.page.single .crumbs{position:relative;left:12px;max-width:calc(100% - 84px);margin:0 0 16px}.page.single .cr-mark{position:absolute;right:calc(100% + 10px);top:0}.page.single .page-body{width:100%;max-width:400px}.page.single .gone{margin:0}.gone{max-width:400px;margin:12vh auto 0;padding:32px 24px 28px;border-radius:var(--r-sheet);background:var(--raised);text-align:center;display:flex;flex-direction:column;align-items:center}.gone .gi{width:56px;height:56px;margin-bottom:16px}.gone h1{margin:0;font-size:22px;line-height:28px;font-weight:500;letter-spacing:-.03em}.gone p{margin:6px 0 0;color:var(--text-2);text-wrap:balance}.dgrid{display:grid;gap:10px;grid-template-columns:minmax(0,1fr)}@media(min-width:560px){.dgrid{grid-template-columns:repeat(2,minmax(0,1fr))}}.dev{background:var(--raised);border-radius:var(--r-card);padding:8px;display:flex;flex-direction:column;gap:8px;min-width:0}.dev.is-here{box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--accent) 32%,transparent)}.dev.off{opacity:.5}.dev-top{display:flex;align-items:center;gap:12px;padding:8px 6px 6px 10px}.dev-top .gi{width:32px;height:32px}.dev-id{flex:1;min-width:0;display:flex;flex-direction:column}.dev-name{font-size:16px;line-height:22px;font-weight:500;letter-spacing:-.02em;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.dev-stat{font-size:13px;line-height:18px;color:var(--text-2);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.dev-stat.ok-t{color:var(--ok)}.dev-stat.warn-t{color:var(--warn)}.dev-stat.here-t{color:var(--accent)}.dev-use{margin-top:auto;background:var(--field);border-radius:var(--r-row);padding:12px 14px 12px 16px;display:flex;align-items:flex-end;justify-content:space-between;gap:12px;min-height:66px}.use-txt{display:flex;flex-direction:column;min-width:0}.use-lbl{font-size:13px;line-height:18px;color:var(--text-2);white-space:nowrap}.use-val{font-size:17px;line-height:24px;font-weight:500;letter-spacing:-.02em}.spark{display:flex;align-items:flex-end;gap:4px;height:34px}.spark i{width:6px;border-radius:3px;background:var(--bar);transition:background-color .15s}.spark i.today{background:var(--accent)}.spark i:hover{background:var(--text-2)}.spark i.today:hover{background:color-mix(in srgb,var(--accent) 75%,var(--text))}.dev .setup-btn{margin-top:auto}.upd-pill{display:inline-flex;align-items:center;align-self:center;gap:6px;height:32px;padding:0 12px 0 10px;border-radius:999px;flex:none;background:color-mix(in srgb,var(--warn) 14%,transparent);color:var(--warn);font-size:13px;font-weight:600;transition:background-color .15s,transform .15s var(--ease-out)}.upd-pill:hover{background:color-mix(in srgb,var(--warn) 22%,transparent)}.upd-pill:active{transform:scale(.94)}.upd-pill .i{width:14px;height:14px}.dev.add{align-items:center;justify-content:center;min-height:144px;gap:10px;color:var(--text-2);font-weight:500;transition:background-color .2s var(--ease-out),transform .2s var(--ease-out)}.dev.add:hover{background:color-mix(in srgb,var(--raised),var(--knob) 45%)}.dev.add:active{transform:scale(.98)}.dev.add .gi{width:36px;height:36px}.dev.first{grid-column:1 / -1;align-items:center;text-align:center;padding:28px 24px 24px;gap:6px}.dev.first .gi{width:44px;height:44px;margin-bottom:8px}.dev.first b{font-size:18px;line-height:24px;font-weight:500;letter-spacing:-.02em}.dev.first p{margin:0 0 14px;color:var(--text-2);font-size:14px;line-height:20px;max-width:34ch;text-wrap:balance}.dev.first .btn{max-width:320px}.reach2{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}.reach-tile{position:relative;display:flex;flex-direction:column;gap:1px;padding:12px 12px 12px 14px;border-radius:16px;background:var(--field);min-width:0}.reach-tile .rt-ic{width:28px;height:28px;margin-bottom:10px}.reach-tile b{font-size:14px;line-height:20px;font-weight:500;letter-spacing:-.015em}.reach-tile .rt-sub{font-size:12px;line-height:16px;color:var(--text-2)}.reach-tile .rt-mark{position:absolute;top:12px;right:12px;width:20px;height:20px;border-radius:50%;display:grid;place-items:center;background:var(--ok-soft);color:var(--ok)}.reach-tile .rt-mark .i{width:12px;height:12px;stroke-width:2.4}.reach-tile.off b{color:var(--text-2)}.reach-tile.off .rt-sub{color:var(--text-3)}.reach-tile.off .rt-ic{opacity:.45}.reach-tile.off .rt-mark{background:var(--knob);color:var(--text-3)}.lbl-s{font-size:12px;font-weight:500;color:var(--text-2)}.names{display:flex;flex-wrap:wrap;gap:6px}.namechip{display:inline-flex;align-items:center;gap:8px;height:32px;padding:0 10px 0 12px;border-radius:10px;background:var(--field);font-family:var(--mono);font-size:13px;letter-spacing:0;transition:background-color .15s,transform .15s var(--ease-out)}.namechip:hover{background:var(--knob)}.namechip:active{transform:scale(.96)}.namechip .faint{color:var(--text-3)}.namechip .i{width:14px;height:14px;color:var(--text-2)}.ring{width:16px;height:16px;transform:rotate(-90deg)}.ring .trk{stroke:var(--bar)}.ring .arc{stroke:var(--accent)}.ring .arc.warn{stroke:var(--warn)}.ring .arc.bad{stroke:var(--bad)}.month{display:flex;flex-direction:column;gap:8px}.mbars{display:flex;align-items:flex-end;gap:3px;height:64px}.mbars i{flex:1;border-radius:2.5px;background:var(--bar);min-height:3px;transition:background-color .12s}.mbars i.future{background:color-mix(in srgb,var(--bar) 45%,transparent)}.mbars i.today{background:var(--accent)}.mbars i:not(.future):hover{background:var(--text-2)}.month-axis{position:relative;display:flex;justify-content:space-between;font-size:11px;color:var(--text-3);font-weight:500}.month-axis .td{position:absolute;transform:translate(-50%);color:var(--accent)}.month-axis .hide{visibility:hidden}.month-read{display:flex;justify-content:space-between;align-items:baseline;margin-top:10px;font-size:13px;color:var(--text-2)}.month-read b{color:var(--text);font-weight:500;font-size:15px;letter-spacing:-.02em}.meter{height:6px;border-radius:3px;background:var(--bar);overflow:hidden}.meter>i{display:block;height:100%;border-radius:3px;background:var(--accent)}.meter>i.warn{background:var(--warn)}.meter>i.bad{background:var(--bad)}.until{display:flex;align-items:center;justify-content:space-between;gap:16px;padding:14px 16px;border-radius:16px;background:var(--field)}.until-num{display:flex;flex-direction:column;min-width:0}.until-num b{font-size:36px;line-height:40px;font-weight:600;letter-spacing:-.045em}.until-num span{font-size:13px;line-height:18px;color:var(--text-2)}.until-num .until-sub{margin-top:8px;font-size:12px;color:var(--text-3)}.until.soon .until-num b{color:var(--warn)}.cal{display:flex;flex-direction:column;gap:6px;flex:none}.cal-h,.cal-g{display:grid;grid-template-columns:repeat(7,10px);gap:5px}.cal-h span{font-size:9px;line-height:10px;font-weight:600;color:var(--text-3);text-align:center}.cal-g i{width:10px;height:10px;border-radius:3px;background:color-mix(in srgb,var(--text) 16%,transparent)}.cal-g i.past{background:color-mix(in srgb,var(--text) 5%,transparent)}.cal-g i.today{background:var(--accent)}.cal-g i.end{background:transparent;box-shadow:inset 0 0 0 1.5px var(--accent)}.cal-g i.after{background:transparent}.until.soon .cal-g i.today{background:var(--warn)}.until.soon .cal-g i.end{box-shadow:inset 0 0 0 1.5px var(--warn)}.acc-row.open .cal-g i{animation:cal-in .36s var(--ease-out) backwards;animation-delay:calc(var(--i) * 7ms)}@keyframes cal-in{0%{opacity:0;transform:scale(.4)}}.hours{display:flex;flex-direction:column;gap:8px;padding:14px 16px;border-radius:16px;background:var(--field)}.hours-top{display:flex;justify-content:space-between;align-items:baseline;font-size:13px;color:var(--text-2)}.hours-top b{color:var(--text);font-weight:500;font-size:15px;letter-spacing:-.02em}.hours-bar{position:relative;height:8px;border-radius:4px;background:color-mix(in srgb,var(--text) 8%,transparent)}.hours-bar i{position:absolute;top:0;bottom:0;border-radius:4px;background:color-mix(in srgb,var(--ok) 70%,transparent)}.hours-now{position:absolute;top:-4px;width:2px;height:16px;margin-left:-1px;border-radius:1px;background:var(--text);box-shadow:0 0 0 2px var(--field)}.hours-now.out{background:var(--warn)}.hours-axis{display:flex;justify-content:space-between;font-size:10px;color:var(--text-3);font-weight:500}@media(prefers-reduced-motion:reduce){.acc-row.open .cal-g i{animation:none}}.sheet-root{position:fixed;inset:0;z-index:50;display:none}.sheet-root.open{display:block}.scrim{position:absolute;inset:0;background:var(--scrim);-webkit-backdrop-filter:blur(8px);backdrop-filter:blur(8px)}.sheet{position:absolute;left:var(--gutter-l);right:var(--gutter-r);bottom:calc(16px + env(safe-area-inset-bottom,0px));margin:0 auto;max-width:400px;max-height:calc(100% - 32px - env(safe-area-inset-top,0px) - env(safe-area-inset-bottom,0px));background:var(--raised);border-radius:var(--r-sheet);box-shadow:var(--sheet-shadow);overflow:hidden;display:flex;flex-direction:column}@media(min-width:760px){.sheet-root.open{display:flex;align-items:center;justify-content:center}.sheet{position:relative;left:auto;right:auto;bottom:auto;margin:0;width:calc(100% - var(--gutter-l) - var(--gutter-r))}}.sheet .x{position:absolute;z-index:3;right:22px;top:22px}.vp{position:relative;overflow:hidden;flex:none}.sheet-scroll{flex:1 1 auto;min-height:0;overflow-y:auto;overscroll-behavior:contain}.view{padding:0 24px 24px;display:flex;flex-direction:column}.vhead{display:flex;align-items:center;gap:12px;height:76px;padding-right:44px;flex:none;cursor:grab;touch-action:none}.vhead h2{flex:1;margin:0;font-size:20px;line-height:28px;font-weight:500;letter-spacing:-.5px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.vhead.center h2{text-align:center}.vhead.with-acts{padding-right:126px}.vsub{margin:-16px 0 18px;color:var(--text-2);font-size:14px;line-height:20px}.vhead.center+.vsub{text-align:center;margin:-6px auto 24px;max-width:32ch;text-wrap:balance}.kinds-note{margin:14px 2px 16px}.view>.hint.bad-t{margin-top:8px}.secure-note{margin-top:12px;text-align:center}.sheet-acts{position:absolute;z-index:3;top:22px;right:58px}.hpill{position:relative;display:flex;gap:2px}.hp-b{display:grid;place-items:center;width:38px;height:32px;background:var(--knob);color:var(--text);transition:background-color .15s,transform .15s var(--ease-out)}.hp-b:first-of-type{border-radius:16px 6px 6px 16px}.hp-b:last-of-type{border-radius:6px 16px 16px 6px}.hp-b .i{width:16px;height:16px}.hp-b:hover{background:color-mix(in srgb,var(--knob),var(--text) 6%)}.hp-b:active{transform:scale(.94)}.hp-b.done{color:var(--ok)}.hp-tip{position:absolute;z-index:4;left:0;top:calc(100% + 8px);height:26px;padding:0 10px;display:flex;align-items:center;border-radius:999px;background:var(--toast);color:var(--toast-fg);font:500 12px/1 var(--font);letter-spacing:-.1px;white-space:nowrap;box-shadow:0 0 0 1px var(--line-glass),var(--pop-shadow);opacity:0;pointer-events:none;overflow:hidden;transform-origin:50% 0}.hp-tip.on{opacity:1}.hp-tip .tt{position:relative;display:inline-flex;justify-content:center;white-space:nowrap}.hp-tip .tt-m{position:absolute;left:0;top:0;visibility:hidden;white-space:nowrap}.sheet .x,.sheet-acts{transition:transform .15s var(--ease-out),background-color .15s,opacity .24s var(--ease-out),filter .24s var(--ease-out),scale .24s var(--ease-out)}.sheet.arrived .x,.sheet.arrived .sheet-acts{opacity:0;filter:blur(3px);scale:.9;pointer-events:none}.center-col{display:flex;flex-direction:column;align-items:center;text-align:center}.center-col.ask{padding-top:28px}.center-col.secure{padding-top:4px}.center-col .gi.xl{width:64px;height:64px;margin:8px 0 16px}.center-col h3{margin:0;font-size:20px;line-height:28px;font-weight:500;letter-spacing:-.5px}.center-col p{margin:6px 0 22px;color:var(--text-2);font-size:15px;line-height:21px;max-width:30ch;text-wrap:balance}.center-col.secure p{margin-top:0}.btnrow{display:flex;gap:8px;width:100%}.btnrow .btn{flex:1}.btnrow2{display:grid;gap:8px}.btnrow2 .btn{width:100%}.setup{display:flex;flex-direction:column}.setup .notice{margin:0 0 16px}.steps-gap{height:22px}.step{display:flex;gap:12px}.step+.step{margin-top:20px}.step-n{width:24px;height:24px;border-radius:50%;background:var(--knob);font-size:13px;font-weight:600;display:grid;place-items:center;flex:none}.step-b{flex:1;min-width:0;display:flex;flex-direction:column;gap:10px}.step-t{font-size:16px;line-height:24px;font-weight:500;letter-spacing:-.02em}.step-box{display:flex;flex-direction:column;gap:10px}.way{display:flex;flex-direction:column;padding:12px 14px;border-radius:20px;background:var(--field);margin-bottom:18px}.way-row{display:flex;align-items:center;gap:10px}.way-end{width:34px;height:34px;border-radius:11px;background:var(--knob);display:grid;place-items:center;flex:none;color:var(--text-2);transition:background-color .4s var(--ease-out),color .4s var(--ease-out)}.way-end .i{width:17px;height:17px}.way-end.home{color:var(--accent);background:color-mix(in srgb,var(--accent) 14%,transparent)}.way-track{position:relative;flex:1;height:8px}.way-track:before,.way-glow,.way-fill{content:"";position:absolute;inset:0;-webkit-mask:radial-gradient(circle,#000 1.4px,transparent 1.9px) 0 50% / 9px 8px repeat-x;mask:radial-gradient(circle,#000 1.4px,transparent 1.9px) 0 50% / 9px 8px repeat-x}.way-track:before{background:var(--text-3);opacity:.8}.way-glow{overflow:hidden;transition:opacity .2s var(--ease-out)}.way-glow i{position:absolute;inset:0;background:linear-gradient(90deg,transparent 32%,var(--accent) 50%,transparent 68%);transform:translate(-70%);animation:way-run 2s cubic-bezier(.45,0,.55,1) infinite}@keyframes way-run{0%{transform:translate(-70%)}72%,to{transform:translate(70%)}}.way-fill{background:var(--ok);clip-path:inset(0 100% 0 0);transition:clip-path .7s var(--ease-out) 80ms}.way.done .way-fill{clip-path:inset(0)}.way.done .way-glow,.way.stopped .way-glow{opacity:0}.way.done .way-end{color:var(--ok);background:var(--ok-soft)}.way.done .way-end.home{transition-delay:.6s}.way.done .way-end.home .i{animation:way-pop .42s var(--spring-bouncy, ease) .6s backwards}@keyframes way-pop{0%{transform:scale(.6)}to{transform:none}}.way-text{display:flex;flex-direction:column;align-items:center;justify-content:center;min-height:30px;margin-top:10px;text-align:center}.way-text .t{display:flex;flex-direction:column;align-items:center;min-width:0}.way-text b{position:relative;display:inline-flex;justify-content:center;white-space:nowrap;font-weight:500;font-size:14px;line-height:20px;transition:color .3s var(--ease-out)}.way-text .ws{color:var(--text-2);font-size:13px;line-height:18px}.way.done .way-text b{color:var(--ok)}.filecard{display:flex;flex-direction:column;gap:10px;padding:12px;border-radius:18px;background:var(--field)}.fc-row{display:flex;align-items:center;gap:12px;min-width:0}.filecard-ic{width:38px;height:46px;border-radius:9px;background:var(--knob);font:600 10px/1 var(--mono);display:grid;place-items:center;color:var(--text-2);flex:none}.filecard .t{flex:1;min-width:0;display:flex;flex-direction:column}.filecard .t .mono{font-size:13px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.filecard .t span:last-child{font-size:12px;color:var(--text-2);line-height:16px}.confbar{display:flex;gap:8px}.conf{margin:0;padding:12px 14px;border-radius:14px;background:var(--field);font:12px/18px var(--mono);max-height:16rem;overflow:auto;white-space:pre;color:var(--text-2)}.conf .k{color:var(--text)}.conf .sec{color:var(--accent)}.conf .mask{color:var(--text-3);letter-spacing:1px}.osm{white-space:normal}.osm-ic{display:inline-grid;width:1.05em;height:1.05em;margin-right:.25em;vertical-align:-.16em}.osm-ic>svg{grid-area:1 / 1;width:100%;height:100%}.osm-ic .eye{fill:var(--field)}.osm-p{display:inline-block;white-space:pre}.scanline{display:flex;flex-wrap:wrap;align-items:baseline;column-gap:.3em}.scanline .osm{white-space:nowrap}@media(max-width:440px){.scanline{flex-direction:column;align-items:flex-start}}.way-text b .mt-old{color:var(--text-2)}@media(prefers-reduced-motion:reduce){.way-glow{display:none}.way-fill{transition:none}.way.done .way-end.home .i{animation:none}}.menu{position:fixed;z-index:60;min-width:224px;padding:6px;border-radius:20px;background:var(--field);box-shadow:var(--pop-shadow),inset 0 0 0 1px var(--line)}.menu-hl{position:absolute;left:6px;right:6px;top:6px;height:40px;border-radius:14px;background:var(--knob);opacity:0;transition:opacity .15s var(--ease-out);pointer-events:none}.menu-hl.moving{transition:opacity .15s var(--ease-out),transform var(--spring-quick-dur, .3s) var(--spring-quick, ease-out),background-color .15s}.menu-hl.bad{background:var(--bad-soft)}.menu-hl.warn{background:color-mix(in srgb,var(--warn) 13%,transparent)}.mi{position:relative;z-index:1;display:flex;align-items:center;gap:12px;width:100%;height:40px;padding:0 12px;border-radius:14px;font-size:14px;font-weight:500;text-align:left}.mi .i{width:16px;height:16px;color:var(--text-2)}.mi.warn,.mi.warn .i{color:var(--warn)}.mi.bad,.mi.bad .i{color:var(--bad)}.menu-sep{height:1px;margin:6px 12px;background:var(--line)}.toasts{position:fixed;left:0;right:0;height:42px;bottom:calc(24px + env(safe-area-inset-bottom,0px));z-index:70;display:flex;justify-content:center;align-items:flex-end;pointer-events:none;padding-left:var(--gutter-l);padding-right:var(--gutter-r)}.toast{position:absolute;display:flex;align-items:center;gap:8px;height:42px;padding:0 18px 0 13px;border-radius:999px;background:var(--toast);color:var(--toast-fg);font-size:14px;font-weight:500;box-shadow:var(--pop-shadow);white-space:nowrap}.toast .i{width:18px;height:18px;color:var(--ok)}.toast.bad .i{color:var(--bad)} diff --git a/package/luci-app-dawnline/root/usr/share/dawnline/portal/assets/portal.js b/package/luci-app-dawnline/root/usr/share/dawnline/portal/assets/portal.js index 7ff6adc..a890724 100644 --- a/package/luci-app-dawnline/root/usr/share/dawnline/portal/assets/portal.js +++ b/package/luci-app-dawnline/root/usr/share/dawnline/portal/assets/portal.js @@ -1,6 +1,6 @@ -"use strict";(()=>{var _n=Object.create;var dt=Object.defineProperty;var Sn=Object.getOwnPropertyDescriptor;var Pn=Object.getOwnPropertyNames;var Dn=Object.getPrototypeOf,Hn=Object.prototype.hasOwnProperty;var Bn=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var Nn=(e,t,n,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Pn(t))!Hn.call(e,s)&&s!==n&&dt(e,s,{get:()=>t[s],enumerable:!(a=Sn(t,s))||a.enumerable});return e};var Rn=(e,t,n)=>(n=e!=null?_n(Dn(e)):{},Nn(t||!e||!e.__esModule?dt(n,"default",{value:e,enumerable:!0}):n,e));var xt=Bn((wt,bt)=>{"use strict";var yt=(function(){var e=function(v,y){var g=236,k=17,d=v,M=n[y],l=null,o=0,C=null,f=[],x={},B=function(u,p){o=d*4+17,l=(function(c){for(var h=new Array(c),w=0;w=7&&Z(u),C==null&&(C=$e(d,M,f)),Y(C,p)},N=function(u,p){for(var c=-1;c<=7;c+=1)if(!(u+c<=-1||o<=u+c))for(var h=-1;h<=7;h+=1)p+h<=-1||o<=p+h||(0<=c&&c<=6&&(h==0||h==6)||0<=h&&h<=6&&(c==0||c==6)||2<=c&&c<=4&&2<=h&&h<=4?l[u+c][p+h]=!0:l[u+c][p+h]=!1)},I=function(){for(var u=0,p=0,c=0;c<8;c+=1){B(!0,c);var h=s.getLostPoint(x);(c==0||u>h)&&(u=h,p=c)}return p},F=function(){for(var u=8;u>c&1)==1;l[Math.floor(c/3)][c%3+o-8-3]=h}for(var c=0;c<18;c+=1){var h=!u&&(p>>c&1)==1;l[c%3+o-8-3][Math.floor(c/3)]=h}},ne=function(u,p){for(var c=M<<3|p,h=s.getBCHTypeInfo(c),w=0;w<15;w+=1){var A=!u&&(h>>w&1)==1;w<6?l[w][8]=A:w<8?l[w+1][8]=A:l[o-15+w][8]=A}for(var w=0;w<15;w+=1){var A=!u&&(h>>w&1)==1;w<8?l[8][o-w-1]=A:w<9?l[8][15-w-1+1]=A:l[8][15-w-1]=A}l[o-8][8]=!u},Y=function(u,p){for(var c=-1,h=o-1,w=7,A=0,D=s.getMaskFunction(p),_=o-1;_>0;_-=2)for(_==6&&(_-=1);;){for(var G=0;G<2;G+=1)if(l[h][_-G]==null){var W=!1;A>>w&1)==1);var H=D(h,_-G);H&&(W=!W),l[h][_-G]=W,w-=1,w==-1&&(A+=1,w=7)}if(h+=c,h<0||o<=h){h-=c,c=-c;break}}},de=function(u,p){for(var c=0,h=0,w=0,A=new Array(p.length),D=new Array(p.length),_=0;_=0?lt.getAt(ct):0}}for(var ut=0,H=0;H_*8)throw"code length overflow. ("+w.getLengthInBits()+">"+_*8+")";for(w.getLengthInBits()+4<=_*8&&w.put(0,4);w.getLengthInBits()%8!=0;)w.putBit(!1);for(;!(w.getLengthInBits()>=_*8||(w.put(g,8),w.getLengthInBits()>=_*8));)w.put(k,8);return de(w,h)};x.addData=function(u,p){p=p||"Byte";var c=null;switch(p){case"Numeric":c=T(u);break;case"Alphanumeric":c=E(u);break;case"Byte":c=P(u);break;case"Kanji":c=K(u);break;default:throw"mode:"+p}f.push(c),C=null},x.isDark=function(u,p){if(u<0||o<=u||p<0||o<=p)throw u+","+p;return l[u][p]},x.getModuleCount=function(){return o},x.make=function(){if(d<1){for(var u=1;u<40;u++){for(var p=m.getRSBlocks(u,M),c=L(),h=0;h";for(var w=0;w';c+=""}return c+="",c+="",c},x.createSvgTag=function(u,p,c,h){var w={};typeof arguments[0]=="object"&&(w=arguments[0],u=w.cellSize,p=w.margin,c=w.alt,h=w.title),u=u||2,p=typeof p=="undefined"?u*4:p,c=typeof c=="string"?{text:c}:c||{},c.text=c.text||null,c.id=c.text?c.id||"qrcode-description":null,h=typeof h=="string"?{text:h}:h||{},h.text=h.text||null,h.id=h.text?h.id||"qrcode-title":null;var A=x.getModuleCount()*u+p*2,D,_,G,W,H="",X;for(X="l"+u+",0 0,"+u+" -"+u+",0 0,-"+u+"z ",H+=''+$(h.text)+"":"",H+=c.text?''+$(c.text)+"":"",H+='',H+='":p+=">";break;case"&":p+="&";break;case'"':p+=""";break;default:p+=h;break}}return p},q=function(u){var p=1;u=typeof u=="undefined"?p*2:u;var c=x.getModuleCount()*p+u*2,h=u,w=c-u,A,D,_,G,W,H={"██":"█","█ ":"▀"," █":"▄"," ":" "},X={"██":"▀","█ ":"▀"," █":" "," ":" "},ee="";for(A=0;A=w?X[W]:H[W];ee+=` -`}return c%2&&u>0?ee.substring(0,ee.length-c-1)+Array(c+1).join("▀"):ee.substring(0,ee.length-1)};return x.createASCII=function(u,p){if(u=u||1,u<2)return q(p);u-=1,p=typeof p=="undefined"?u*2:p;var c=x.getModuleCount()*u+p*2,h=p,w=c-p,A,D,_,G,W=Array(u+1).join("██"),H=Array(u+1).join(" "),X="",ee="";for(A=0;A>>8),M.push(C&255)):M.push(k)}}return M}};var t={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8},n={L:1,M:0,Q:3,H:2},a={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7},s=(function(){var v=[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],y=1335,g=7973,k=21522,d={},M=function(l){for(var o=0;l!=0;)o+=1,l>>>=1;return o};return d.getBCHTypeInfo=function(l){for(var o=l<<10;M(o)-M(y)>=0;)o^=y<=0;)o^=g<5&&(C+=3+B-5)}for(var f=0;f=256;)d-=255;return v[d]},k})();function b(v,y){if(typeof v.length=="undefined")throw v.length+"/"+y;var g=(function(){for(var d=0;d>>7-k%8&1)==1},g.put=function(k,d){for(var M=0;M>>d-M-1&1)==1)},g.getLengthInBits=function(){return y},g.putBit=function(k){var d=Math.floor(y/8);v.length<=d&&v.push(0),k&&(v[d]|=128>>>y%8),y+=1},g},T=function(v){var y=t.MODE_NUMBER,g=v,k={};k.getMode=function(){return y},k.getLength=function(l){return g.length},k.write=function(l){for(var o=g,C=0;C+2>>8&255)*192+(f&255),l.put(f,13),C+=2}if(C>>8)},y.writeBytes=function(g,k,d){k=k||0,d=d||g.length;for(var M=0;M0&&(g+=","),g+=v[k];return g+="]",g},y},U=function(){var v=0,y=0,g=0,k="",d={},M=function(o){k+=String.fromCharCode(l(o&63))},l=function(o){if(!(o<0)){if(o<26)return 65+o;if(o<52)return 97+(o-26);if(o<62)return 48+(o-52);if(o==62)return 43;if(o==63)return 47}throw"n:"+o};return d.writeByte=function(o){for(v=v<<8|o&255,y+=8,g+=1;y>=6;)M(v>>>y-6),y-=6},d.flush=function(){if(y>0&&(M(v<<6-y),v=0,y=0),g%3!=0)for(var o=3-g%3,C=0;C=y.length){if(d==0)return-1;throw"unexpected end of file./"+d}var o=y.charAt(g);if(g+=1,o=="=")return d=0,-1;if(o.match(/^\s$/))continue;k=k<<6|l(o.charCodeAt(0)),d+=6}var C=k>>>d-8&255;return d-=8,C};var l=function(o){if(65<=o&&o<=90)return o-65;if(97<=o&&o<=122)return o-97+26;if(48<=o&&o<=57)return o-48+52;if(o==43)return 62;if(o==47)return 63;throw"c:"+o};return M},j=function(v,y){var g=v,k=y,d=new Array(v*y),M={};M.setPixel=function(f,x,B){d[x*g+f]=B},M.write=function(f){f.writeString("GIF87a"),f.writeShort(g),f.writeShort(k),f.writeByte(128),f.writeByte(0),f.writeByte(0),f.writeByte(0),f.writeByte(0),f.writeByte(0),f.writeByte(255),f.writeByte(255),f.writeByte(255),f.writeString(","),f.writeShort(0),f.writeShort(0),f.writeShort(g),f.writeShort(k),f.writeByte(0);var x=2,B=o(x);f.writeByte(x);for(var N=0;B.length-N>255;)f.writeByte(255),f.writeBytes(B,N,255),N+=255;f.writeByte(B.length-N),f.writeBytes(B,N,B.length-N),f.writeByte(0),f.writeString(";")};var l=function(f){var x=f,B=0,N=0,I={};return I.write=function(F,z){if(F>>>z)throw"length over";for(;B+z>=8;)x.writeByte(255&(F<>>=8-B,N=0,B=0;N=F<0&&x.writeByte(N)},I},o=function(f){for(var x=1<>6,128|i&63):i<55296||i>=57344?a.push(224|i>>12,128|i>>6&63,128|i&63):(s++,i=65536+((i&1023)<<10|n.charCodeAt(s)&1023),a.push(240|i>>18,128|i>>12&63,128|i>>6&63,128|i&63))}return a}return t(e)}})();(function(e){typeof define=="function"&&define.amd?define([],e):typeof wt=="object"&&(bt.exports=e())})(function(){return yt})});function ve(e){if(!e||e<0)return"0 B";let t=["B","KB","MB","GB","TB"],n=0,a=e;for(;a>=1024&&n=100||n===0?Math.round(a):a.toFixed(1)} ${t[n]}`}function pt(e,t=Date.now()/1e3){if(!e)return"never";let n=Math.max(0,Math.round(t-e));return n<60?"just now":n<3600?`${Math.floor(n/60)} min ago`:n<86400?`${Math.floor(n/3600)} h ago`:n<86400*30?`${Math.floor(n/86400)} d ago`:new Date(e*1e3).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"})}function Se(e){return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")}`}function Pe(e){let[t,n,a]=e.split("-").map(Number);return new Date(t,(n||1)-1,a||1,12)}function In(e){return(typeof e=="string"?/^\d{4}-\d{2}-\d{2}$/.test(e)?Pe(e):new Date(e):e).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"})}function Fe(e){return e?In(e):""}function On(e,t){let n=a=>{let[s,i,b]=a.split("-").map(Number);return Date.UTC(s,i-1,b)};return Math.round((n(e)-n(t))/864e5)}function ft(e,t){let n=Pe(e);return n.setDate(n.getDate()+t),Se(n)}function qe(e,t=Date.now()){if(!e)return null;let n=typeof t=="number"?Se(new Date(t)):t,a=On(e,n);return a>=0?a+1:a}function ze(e,t){return t!=null&&t>0&&e.expire_warn>0&&t<=e.expire_warn}function ht(e){return e<=1?"ends today":e===2?"ends tomorrow":`ends in ${e} days`}var gt={lan:"Home network",internet:"Internet",both:"Home network + Internet"};var De={computer:"PC",phone:"Phone",tablet:"Tablet",router:"Router",other:"Other"};function mt(e){var s,i,b;let t=e.trim().split(/\s+/).filter(Boolean);if(!t.length)return"?";let n=(s=t[0][0])!=null?s:"",a=t.length>1?(i=t[t.length-1][0])!=null?i:"":(b=t[0][1])!=null?b:"";return(n+a).toUpperCase()}function Ue(e){let t=n=>n.disabled?3:n.online?0:n.handshake?1:2;return e.map((n,a)=>[n,a]).sort((n,a)=>t(n[0])-t(a[0])||n[1]-a[1]).map(([n])=>n)}var vt={phone:'',computer:'',tablet:'',router:'',server:'',other:'',ethernet:'',bridge:'',wifi:'',tunnel:'',plus:'',chart:'',reset:'',package:'',code:'',plug:'',sunrise:'',refresh:'',archive:'',qr:'',copy:'',download:'',link:'',amnezia:'',amneziawg:'',wireguard:'',appstore:'',googleplay:'',github:'',openwrt:'',apple:'',windows:'',linux:'',eye:'',share:'',arrow:'',trash:'',edit:'',pause:'',play:'',key:'',out:'',admin:'',shield:'',shieldplus:'',lock:'',zap:'',check:'',alert:'',x:'',globe:'',home:'',open:'',file:'',network:'',moon:'',chevron:'',clock:'',calendar:'',minus:'',more:'',pin:'',activity:''};function He(e,t="dl-icon"){var a;let n=(a=vt[e])!=null?a:vt.phone;return``}var Ct=Rn(xt(),1),Kn=e=>``,Mt="#0a0a0a",We="#f2f2f2",Ve=e=>e.length>300,ye=e=>+e.toFixed(2);function Ye(e,t,n,a,s){return`M${ye(e+s)} ${ye(t)}h${ye(n-2*s)}a${s} ${s} 0 0 1 ${s} ${s}v${ye(a-2*s)}a${s} ${s} 0 0 1 -${s} ${s}h-${ye(n-2*s)}a${s} ${s} 0 0 1 -${s} -${s}v-${ye(a-2*s)}a${s} ${s} 0 0 1 ${s} -${s}z`}function kt(e,t=3,n=!0,a="plain"){let s=Ve(e),i=a==="night",b=(0,Ct.default)(0,s?"L":"H");b.addData(e,"Byte"),b.make();let m=b.getModuleCount(),L=m+t*2,T=n&&!s?Math.round(m*.22):0;T&&(m-T)%2&&T++;let E=(m-T)/2,P=E+T,K=(v,y)=>T>0&&v>=E&&v=E&&yi&&(y<7&&v<7||y<7&&v>=m-7||y>=m-7&&v<7),U="";if(i){let v=s?.48:.42;for(let y=0;y${Kn(i?Mt:"#fff")}`}let Q=``;return i?`${Q}${j}`:`${Q}${j}`}var Gn={jc:"0",jmin:"0",jmax:"0",s1:"0",s2:"0",s3:"0",s4:"0",h1:"1",h2:"2",h3:"3",h4:"4",i1:"",i2:"",i3:"",i4:"",i5:""},Fn={header_protection_key:"HeaderProtectionKey",content_padding_addition:"ContentPaddingAddition",rekey_after_time:"RekeyAfterTime",rekey_timeout:"RekeyTimeout",reject_after_time:"RejectAfterTime",keepalive_timeout:"KeepaliveTimeout",max_handshake_attempts:"MaxHandshakeAttempts",random_trailers:"RandomTrailers",disable_cookies:"DisableCookies"};function qn(e){let t={};for(let[n,a]of Object.entries(Fn))e[n]!=null&&e[n]!==""&&(t[a]=String(e[n]));return t}function zn(e,t){var L;let n=e.amnezia,a=(L=n.obfuscation)!=null?L:{},s=T=>a[T]!=null&&a[T]!==""?String(a[T]):Gn[T],i=n.host.replace(/^\[(.*)\]$/,"$1"),b={H1:s("h1"),H2:s("h2"),H3:s("h3"),H4:s("h4"),I1:s("i1"),I2:s("i2"),I3:s("i3"),I4:s("i4"),I5:s("i5"),Jc:s("jc"),Jmin:s("jmin"),Jmax:s("jmax"),S1:s("s1"),S2:s("s2"),S3:s("s3"),S4:s("s4"),...qn(a),allowed_ips:n.allowed_ips,client_ip:n.client_ip,client_priv_key:n.client_priv_key,client_pub_key:n.client_pub_key,config:e.conf.replace(/\r?\n/g,`\r -`),hostName:i,mtu:n.mtu,persistent_keep_alive:n.persistent_keep_alive,port:Number(n.port),psk_key:n.psk_key,server_pub_key:n.server_pub_key},m={containers:[{container:"amnezia-awg",awg:{isThirdPartyConfig:!0,last_config:JSON.stringify(b),port:String(n.port),protocol_version:a.header_protection_key?"3.1":"2",transport_proto:"udp"}}],defaultContainer:"amnezia-awg",description:t,hostName:i};return n.dns[0]&&(m.dns1=n.dns[0]),n.dns[1]&&(m.dns2=n.dns[1]),m}function Un(e){let t="";for(let n=0;ne.replace(/^vpn:\/\//,"");function r(e,t={},...n){let a=document.createElement(e);for(let[i,b]of Object.entries(t))b==null||b===!1||(i.startsWith("on")&&typeof b=="function"?a.addEventListener(i.slice(2),b):i==="class"?a.className=String(b):b===!0?a.setAttribute(i,""):a.setAttribute(i,String(b)));let s=i=>{i==null||i===!1||(Array.isArray(i)?i.forEach(s):a.appendChild(typeof i=="string"?document.createTextNode(i):i))};return n.forEach(s),a}function R(e){let t=r("span",{class:"ic"});return t.innerHTML=He(e,"ic-svg"),t}var se=()=>typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches,re={out:"cubic-bezier(0.23, 1, 0.32, 1)",in:"cubic-bezier(0.55, 0, 1, 0.45)",drawer:"cubic-bezier(0.32, 0.72, 0, 1)"};function At(e){var n;let t=e.closest(".sheet-panel");return t?(t.dataset.hold=String(+((n=t.dataset.hold)!=null?n:0)+1),()=>{var s;let a=+((s=t.dataset.hold)!=null?s:1)-1;a>0?t.dataset.hold=String(a):delete t.dataset.hold}):()=>{}}function Yn(e,t){return e<=0||t<=0?0:(1-1/(e*.55/t+1))*t}function Vn(e,t,n){return e<=0||t<-.1?!1:t>.4||e>n/3}var Et=e=>Math.round(Math.min(380,Math.max(220,200+e*.35)));function ae(e,t){e.classList.remove(t),e.offsetWidth,e.classList.add(t)}function $t(e,t){let n=0,a=0,s=!1,i=null,b=new ResizeObserver(()=>{if(e.dataset.hold){i==null||i.cancel(),e.classList.remove("morphing","morphing-w"),n=e.offsetHeight,a=e.offsetWidth;return}let m=getComputedStyle(e),L=i?parseFloat(m.height):n,T=i?parseFloat(m.width):a;i==null||i.cancel(),e.classList.remove("morphing","morphing-w");let E=e.offsetHeight,P=e.offsetWidth,K=e.dataset.morph==="width"||s;delete e.dataset.morph;let O=a!==0&&P!==a;if(n=E,a=P,!L||se()||O&&!K)return;let U=Math.abs(E-L),V=K?Math.abs(P-T):0;if(U<2&&V<2)return;s=V>=2,e.classList.add("morphing"),e.classList.toggle("morphing-w",s);let j=e.animate(s?[{height:`${L}px`,width:`${T}px`},{height:`${E}px`,width:`${P}px`}]:[{height:`${L}px`},{height:`${E}px`}],{duration:Et(Math.max(U,V)),easing:re.out});i=j;let Q=()=>{i===j&&(i=null,s=!1,e.classList.remove("morphing","morphing-w"))};j.onfinish=Q,j.oncancel=Q});return b.observe(t),()=>b.disconnect()}function _t(e,t,n=0){let a=[...e.childNodes];if(!a.length||!e.isConnected){e.replaceChildren(...t);return}let s=getComputedStyle(e),i=document.createElement("div");i.className="ghost",i.setAttribute("aria-hidden","true"),i.inert=!0,Object.assign(i.style,{display:s.display==="flex"?"flex":"block",flexDirection:s.flexDirection,alignItems:s.alignItems,gap:s.gap,top:s.paddingTop,left:s.paddingLeft,right:s.paddingRight}),i.append(...a),e.replaceChildren(i,...t);let b=se(),m=i.animate([{opacity:1,transform:"none"},{opacity:0,transform:b?"none":`translateX(${-n*8}px)`}],{duration:120,easing:re.out,fill:"forwards"}),L=()=>i.remove();m.onfinish=L,m.oncancel=L;for(let T of t)T instanceof HTMLElement&&T.animate(b?[{opacity:0},{opacity:1}]:[{opacity:0,transform:`translate(${n*12}px, ${n?0:6}px)`,filter:"blur(4px)"},{opacity:1,transform:"none",filter:"blur(0)"}],{duration:b?160:280,delay:50,easing:re.out,fill:"backwards"})}function St(e){return!e||!e.isConnected?Promise.resolve():e.animate(se()?[{opacity:1},{opacity:0}]:[{opacity:1,transform:"none",filter:"blur(0)"},{opacity:0,transform:"scale(0.96)",filter:"blur(4px)"}],{duration:200,easing:re.in,fill:"forwards"}).finished.then(()=>{},()=>{})}var Pt=e=>new Promise(t=>setTimeout(t,se()?0:e)),Ce={ms:520,contentMs:300,blur:4,drift:6,scale:.98};async function Dt(e){if(!e.isConnected)return;let t=At(e),n=parseFloat(getComputedStyle(e.parentElement).rowGap)||0,a=e.offsetHeight;e.style.overflow="hidden",e.style.transformOrigin="50% 0",e.inert=!0;let s=()=>{};se()?await e.animate([{opacity:1},{opacity:0}],{duration:160,easing:re.out,fill:"forwards"}).finished.then(s,s):(e.animate([{opacity:1,filter:"blur(0px)",transform:"none"},{opacity:0,filter:`blur(${Ce.blur}px)`,transform:`translateY(${-Ce.drift}px) scale(${Ce.scale})`}],{duration:Ce.contentMs,easing:re.out,fill:"forwards"}),await e.animate([{height:`${a}px`,marginTop:"0px"},{height:"0px",marginTop:`${-n}px`}],{duration:Ce.ms,easing:re.drawer,fill:"forwards"}).finished.then(s,s)),e.remove(),t()}function Ht(e){if(!e.isConnected||se())return ae(e,"swap");let t=At(e),n=parseFloat(getComputedStyle(e.parentElement).rowGap)||0,a=e.offsetHeight;e.style.overflow="hidden";let s=e.animate([{height:"0px",marginTop:`${-n}px`,opacity:0,filter:"blur(4px)"},{height:`${a}px`,marginTop:"0px",opacity:1,filter:"blur(0px)"}],{duration:380,easing:re.drawer}),i=()=>{e.style.overflow="",t()};s.onfinish=i,s.oncancel=i}function Bt(e,t){let n=[...e.querySelectorAll(t)].map(a=>({el:a,r:a.getBoundingClientRect()}));n.sort((a,s)=>Math.round(a.r.top-s.r.top)||a.r.left-s.r.left),n.forEach(({el:a},s)=>{a.style.setProperty("--i",String(Math.min(s,8))),a.classList.add("intro")})}function Nt(e){let t=new Map,n=new Map;return e.querySelectorAll("[data-key]").forEach(a=>{let s=a.getBoundingClientRect();t.set(a.dataset.key,{x:s.left+scrollX,y:s.top+scrollY})}),e.querySelectorAll("[data-v]").forEach(a=>{var s;return n.set(a.dataset.v,(s=a.textContent)!=null?s:"")}),{at:t,text:n}}function Rt(e,t){let n=se();e.querySelectorAll("[data-key]").forEach(a=>{let s=t.at.get(a.dataset.key);if(!s){a.classList.add("enter");return}if(n)return;let i=a.getBoundingClientRect(),b=s.x-(i.left+scrollX),m=s.y-(i.top+scrollY);Math.abs(b)<1&&Math.abs(m)<1||a.animate([{transform:`translate(${b}px, ${m}px)`},{transform:"none"}],{duration:Et(Math.hypot(b,m)),easing:re.out})}),e.querySelectorAll("[data-v]").forEach(a=>{let s=t.text.get(a.dataset.v);s!=null&&s!==a.textContent&&a.classList.add("swap")})}function It(e,t){let n=m=>m.classList.contains("on")||m.classList.contains("open"),a=m=>{var L,T;return(T=(L=m.dataset.sig)!=null?L:m.textContent)!=null?T:""},s=m=>{let L=m.getBoundingClientRect(),T=m.parentElement.getBoundingClientRect();return{x:L.left-T.left,y:L.top-T.top}},i=new Map;e.querySelectorAll("[data-m]").forEach(m=>i.set(m.dataset.m,{on:n(m),says:a(m)}));let b=new Map;e.querySelectorAll("[data-glide]").forEach(m=>b.set(m.dataset.glide,s(m))),t(),se()||e.querySelectorAll("[data-glide]").forEach(m=>{let L=b.get(m.dataset.glide);if(!L)return;let T=s(m),E=L.x-T.x,P=L.y-T.y;(Math.abs(E)>=1||Math.abs(P)>=1)&&m.animate([{transform:`translate(${E}px, ${P}px)`},{transform:"none"}],{duration:280,easing:re.out})}),e.querySelectorAll("[data-m]").forEach(m=>{let L=i.get(m.dataset.m);L&&(L.on!==n(m)?m.classList.add(n(m)?"to-on":"to-off"):L.says!==a(m)&&m.classList.add("swap"))})}var Qe=new WeakMap;function Ot(e,t){var m,L,T,E,P,K;if(!e)return;let n=e.querySelector(".ic"),a=(L=(m=e.querySelector(".badge-main"))!=null?m:e.querySelector(":scope > span:not(.ic)"))!=null?L:e.children.length?null:e,s=(P=Qe.get(e))!=null?P:{timer:0,icon:(T=n==null?void 0:n.innerHTML)!=null?T:null,label:(E=a==null?void 0:a.textContent)!=null?E:null};clearTimeout(s.timer);let i=!!a&&(a.classList.contains("badge-main")||/^copy$/i.test((K=s.label)!=null?K:"")),b=(O,U)=>{n&&O!=null&&n.innerHTML!==O&&(n.innerHTML=O,ae(n,"swap-ic")),a&&i&&U!=null&&a.textContent!==U&&(a.textContent=U,ae(a,"swap"))};b(t,"Copied"),e.classList.add("copied"),s.timer=window.setTimeout(()=>{Qe.delete(e),e.classList.remove("copied"),b(s.icon,s.label)},1600),Qe.set(e,s)}function je(e){let t=window.setTimeout(()=>e.classList.add("busy"),250);return()=>{clearTimeout(t),e.classList.remove("busy")}}function Kt(e,t,n,a){e.addEventListener("pointerdown",s=>{let i=s.target;if(!a()||s.button!==0||!i.closest(".grab, .sheet-head, .ask")||i.closest("button, a, input"))return;let b=s.clientY,m=e.offsetHeight,L=0,T=[{t:s.timeStamp,y:s.clientY}];try{e.setPointerCapture(s.pointerId)}catch{}e.classList.add("dragging");let E=K=>{let O=K.clientY-b;for(L=O<0?-Yn(-O,m):O,e.style.transform=`translateY(${L}px)`,t.style.opacity=String(1-Math.max(0,L)/m),T.push({t:K.timeStamp,y:K.clientY});T.length>2&&K.timeStamp-T[0].t>100;)T.shift()},P=K=>{e.removeEventListener("pointermove",E),e.removeEventListener("pointerup",P),e.removeEventListener("pointercancel",P);let O=T[0],U=T[T.length-1],V=U.t>O.t?(U.y-O.y)/(U.t-O.t):0;e.classList.remove("dragging"),e.style.transform="",t.style.opacity="",K.type==="pointerup"&&Vn(L,V,m)&&n()};e.addEventListener("pointermove",E),e.addEventListener("pointerup",P),e.addEventListener("pointercancel",P)})}function Gt(e){let t=r("span",{class:"strong s"},"Waiting for the connection"),n=r("span",{class:"faint s"}),a=r("span",{class:"way-end home"},R("server")),s=r("div",{class:"way",role:"status","aria-live":"polite"},r("div",{class:"way-row"},r("span",{class:"way-end"},R(e)),r("span",{class:"way-track"},r("span",{class:"way-glow"},r("i")),r("span",{class:"way-fill"})),a),r("div",{class:"way-text"},t,n)),i=(b,m)=>{if(t.textContent!==b&&(t.textContent=b,ae(t,"swap")),n.textContent===m)return;let L=!n.textContent;n.textContent=m,L?Ht(n):ae(n,"swap")};return{el:s,connected:()=>{s.classList.add("done"),i("Connected","You’re all set.")},gaveUp:()=>{s.classList.add("stopped"),i("No connection yet","Close this and open it again to keep checking.")}}}var oe={vpn:"AmneziaVPN",awg:"AmneziaWG",wg:"WireGuard"};function qt(e,t=0){return/iPhone|iPad|iPod/.test(e)||/Macintosh/.test(e)&&t>1?"ios":/Android/.test(e)?"android":/Windows/.test(e)?"windows":/Mac OS X|Macintosh/.test(e)?"mac":/CrOS/.test(e)?"unknown":/Linux|X11/.test(e)?"linux":"unknown"}var zt=e=>/Telegram|FBAN|FBAV|Instagram|VKClient|Line\//i.test(e);function Ut(e,t){return e==="router"||t==="unknown"?!1:e==="phone"||e==="tablet"?t==="ios"||t==="android":e==="computer"?t==="windows"||t==="mac"||t==="linux":!0}var Wt=e=>e==="computer"?["windows","mac","linux"]:e==="other"?["ios","android","windows","mac","linux"]:[];function Yt(e){let t={off:{vpn:"",awg:""},balanced:{vpn:"4.8.12",awg:"2.0"},max:{vpn:"current",awg:"3.1"},legacy:{vpn:"",awg:""}}[e],n=[{id:"vpn",name:oe.vpn,need:t.vpn,sub:"Connects from a link, no files"},{id:"awg",name:oe.awg,need:t.awg,sub:"The light client: a file or a QR code"}];return e==="off"&&n.push({id:"wg",name:oe.wg,need:"",sub:"Any WireGuard app: this server has no disguise"}),n}function ke(e){return e.need?`This server needs ${e.need==="current"?`the current version of ${e.name}`:`${e.name} ${e.need} or newer`}. Installed a while ago? Update it in the store.`:""}var Be="https://github.com/amnezia-vpn/amnezia-client/releases/latest",Ft={href:Be,top:"APK file on",main:"GitHub",mark:"github",why:"The APK is for phones without Google Play, or where the store hides the app."};function Vt(e,t){var a;return(a={vpn:{ios:{href:"https://apps.apple.com/app/amneziavpn/id1600529900",top:"Download on the",main:"App Store",mark:"appstore"},android:{href:"https://play.google.com/store/apps/details?id=org.amnezia.vpn",top:"Get it on",main:"Google Play",mark:"googleplay",alt:Ft},windows:{href:Be,top:"Official release on GitHub",main:"Download for Windows",mark:"windows"},mac:{href:Be,top:"Official release on GitHub",main:"Download for Mac",mark:"apple"},linux:{href:Be,top:"Official release on GitHub",main:"Download for Linux",mark:"linux"}},awg:{ios:{href:"https://apps.apple.com/us/app/amneziawg/id6478942365",top:"Download on the",main:"App Store",mark:"appstore"},android:{href:"https://play.google.com/store/apps/details?id=org.amnezia.awg",top:"Get it on",main:"Google Play",mark:"googleplay",alt:{...Ft,href:"https://github.com/amnezia-vpn/amneziawg-android/releases"}},windows:{href:"https://github.com/amnezia-vpn/amneziawg-windows-client/releases",top:"Official release on GitHub",main:"Download for Windows",mark:"windows"},mac:{href:"https://apps.apple.com/us/app/amneziawg/id6478942365",top:"Download on the",main:"Mac App Store",mark:"appstore"},linux:{href:"https://github.com/amnezia-vpn/amneziawg-tools",top:"On GitHub",main:"amneziawg-tools",mark:"linux"}},wg:{ios:{href:"https://apps.apple.com/app/wireguard/id1441195209",top:"Download on the",main:"App Store",mark:"appstore"},android:{href:"https://play.google.com/store/apps/details?id=com.wireguard.android",top:"Get it on",main:"Google Play",mark:"googleplay"},windows:{href:"https://www.wireguard.com/install/",top:"Download from",main:"wireguard.com",mark:"windows"},mac:{href:"https://apps.apple.com/app/wireguard/id1451685025",top:"Download on the",main:"Mac App Store",mark:"appstore"},linux:{href:"https://www.wireguard.com/install/",top:"Install from",main:"wireguard.com",mark:"linux"}}}[e][t])!=null?a:null}var Je=e=>e==="wg"?{href:"https://openwrt.org/docs/guide-user/services/vpn/wireguard/start",top:"OpenWrt packages",main:"wireguard-tools",mark:"openwrt"}:{href:"https://openwrt.org/packages/start",top:"OpenWrt packages",main:"amneziawg-tools + kmod",mark:"openwrt"},Ze=e=>e==="android",Qt=e=>`${e.replace(/\.conf$/i,"")}.vpn`,Ne={ios:{file:"+ → Create from file or archive",qr:"+ → Create from QR code"},android:{file:"+ → Import from file or archive",qr:"+ → Scan from QR code"},mac:{file:"+ → Import tunnel(s) from file"},windows:{file:"Add Tunnel → Import tunnel(s) from file"}};function jt(e,t="unknown"){var a;if(e==="vpn")return"Add server → Scan QR";let n=(a=Ne[t])==null?void 0:a.qr;return n!=null?n:`${Ne.ios.qr} (Android: ${Ne.android.qr.replace(/^.* → /,"")})`}function Qn(e,t="unknown"){var n,a;return e==="vpn"?"Add server → Insert key":(a=(n=Ne[t])==null?void 0:n.file)!=null?a:"Add tunnel → Import from file"}function Jt(e,t,n,a){if(t==="linux")return[["Open a terminal in the folder with the file",""],["Run ",`sudo ${e==="wg"?"wg-quick":"awg-quick"} up ./${n}`]];let s=Qn(e,t);return[[`Open ${oe[e]}`,""],[s.replace(/ → [^→]*$/," → "),s.replace(/^.* → /,"")],[a?"Confirm the import and connect":"Pick the file and connect",""]]}var Xe={ios:"iPhone / iPad",android:"Android",windows:"Windows",mac:"Mac",linux:"Linux",unknown:"this device"},Zt=(e,t)=>`${e}#setup=${t}`;function Xt(e){var t,n;return(n=(t=/^#setup=(d_[0-9a-f]{8})$/.exec(e))==null?void 0:t[1])!=null?n:null}var en=e=>({phone:"phone",tablet:"tablet",computer:"computer",router:"router",other:"device"})[e],tn=e=>({ios:"This iPhone",android:"This phone",windows:"This PC",mac:"This Mac",linux:"This PC",unknown:"This device"})[e];var at=()=>{var e;return(e=S==null?void 0:S.today)!=null?e:Se(new Date)},pn=()=>{var e;return(e=S==null?void 0:S.now)!=null?e:Date.now()/1e3},xe=document.getElementById("app"),dn,Re=(dn=xe.dataset.base)!=null?dn:"",jn=xe.dataset.title||"Dawnline",Jn=()=>window.matchMedia("(max-width: 959px)").matches||/Android|iPhone|iPad/.test(navigator.userAgent),S=null,Zn=/^\/[a-z]{6}-[a-z]{6}-[a-z]{6}$/.test(Re)?Re.slice(1):"",nt=class extends Error{constructor(n,a,s){super(a);this.status=n;this.httpsUrl=s}};async function fe(e,t){var s;let n=await fetch(`${Re}/api/${e}`,{method:t===void 0?"GET":"POST",credentials:"omit",headers:t===void 0?{}:{"Content-Type":"application/json"},body:t===void 0?void 0:JSON.stringify(t),cache:"no-store"}),a=null;try{a=await n.json()}catch{}if(!n.ok)throw new nt(n.status,(s=a==null?void 0:a.error)!=null?s:`Request failed (${n.status})`,(a==null?void 0:a.https_url)||void 0);return a}var Le=null;function nn(e){Le===e&&(Le=null),e.classList.remove("show"),e.classList.add("gone"),setTimeout(()=>e.remove(),200)}function pe(e,t=!1){Le&&nn(Le);let n=r("div",{class:`toast${t?" bad":""}`,role:"status"},e);document.body.appendChild(n),n.offsetWidth,n.classList.add("show"),Le=n,setTimeout(()=>nn(n),2600)}async function ge(e,t="Copied",n){try{await navigator.clipboard.writeText(e)}catch{let a=r("textarea",{class:"offscreen"},e);document.body.appendChild(a),a.select();let s=document.execCommand("copy");if(a.remove(),!s)return pe("Copying is blocked here. Select the text and copy it by hand.",!0)}Ot(n instanceof HTMLElement?n:null,He("check","ic-svg")),pe(t)}function Ie(e,t){var s;let n=navigator;if(bn()!=="ios"||typeof n.share!="function"||typeof File=="undefined")return null;let a=new File([t],e,{type:"application/octet-stream"});return(s=n.canShare)!=null&&s.call(n,{files:[a]})?async()=>{try{await n.share({files:[a]})}catch(i){(i==null?void 0:i.name)!=="AbortError"&&st(e,t)}}:null}function st(e,t){let n=URL.createObjectURL(new Blob([t],{type:"application/octet-stream"})),a=r("a",{href:n,download:e,class:"offscreen"});document.body.appendChild(a),a.click(),setTimeout(()=>{URL.revokeObjectURL(n),a.remove()},1e3)}var ie=null;function fn(e,t){let n=a=>{ie!=null||(ie=document.body.appendChild(r("div",{class:"tip",role:"tooltip"}))),ie.replaceChildren(...t().map((s,i)=>r("div",{class:i?"muted":"tip-title"},s))),ie.style.left=`${a.clientX}px`,ie.style.top=`${a.clientY-10}px`,ie.classList.add("show")};e.addEventListener("mouseenter",n),e.addEventListener("mousemove",n),e.addEventListener("mouseleave",()=>ie==null?void 0:ie.classList.remove("show"))}function Xn(e){let t=Math.max(1,...e),n=r("div",{class:"spark"});return e.forEach((a,s)=>{let i=r("i",{class:a?"":"zero"});i.style.height=`${Math.max(8,a/t*100)}%`,i.style.setProperty("--i",String(s));let b=e.length-1-s;fn(i,()=>[b===0?"Today":b===1?"Yesterday":Pe(ft(at(),-b)).toLocaleDateString("en-GB",{weekday:"short",day:"numeric",month:"short"}),ve(a)]),n.appendChild(i)}),n}async function hn(e,t){if(e.disabled)return;e.disabled=!0;let n=je(e);try{await t()}finally{n(),e.disabled=!1}}var te=null,ce=null,gn=()=>window.matchMedia("(max-width: 639px)").matches,Ae=!1;window.addEventListener("popstate",()=>{te&&(Ae=!1,ue())});function ue(e=!1){if(!te)return;let t=te;if(te=null,Ae&&(Ae=!1,history.back()),document.body.classList.remove("locked"),ce==null||ce(),ce=null,e){t.remove();return}t.classList.remove("open"),t.classList.add("closing"),setTimeout(()=>t.remove(),gn()?320:180)}function mn(e,t,n=!1){if(te){ce==null||ce(),ce=null;let m=te.querySelector(".sheet-panel");m.setAttribute("aria-label",e),m.setAttribute("role",n?"alertdialog":"dialog"),m.classList.contains("asks")!==n&&(m.dataset.morph="width",m.classList.toggle("asks",n)),m.scrollTop=0,_t(m.querySelector(".sheet-inner"),t);return}let a=r("div",{class:"sheet-inner"},...t),s=r("div",{class:`sheet-panel${n?" asks":""}`,role:n?"alertdialog":"dialog","aria-modal":"true","aria-label":e},r("div",{class:"grab"}),a),i=r("div",{class:"scrim",onclick:()=>ue()}),b=r("div",{class:"sheet fresh"},i,s);if(a.querySelectorAll(":scope > .sheet-head, .sheet-body > :not(.setup), .setup > *").forEach((m,L)=>m.style.setProperty("--i",String(Math.min(L,6)))),document.body.appendChild(b),document.body.classList.add("locked"),!Ae)try{history.pushState({sheet:!0},""),Ae=!0}catch{}$t(s,a),Kt(s,i,()=>ue(),gn),b.offsetWidth,b.classList.add("open"),setTimeout(()=>b.classList.remove("fresh"),700),te=b}function Oe(e,t,...n){mn(e,[r("div",{class:"sheet-head"},r("div",{class:"stack"},r("h2",{},e),t?r("span",{class:"muted s"},t):null),r("button",{class:"icon-btn","aria-label":"Close",onclick:()=>ue()},R("x"))),r("div",{class:"sheet-body"},...n)])}function vn(e){mn(e.title,[r("div",{class:"ask"},r("span",{class:`ask-ic ${e.tone}`},R(e.icon)),r("h2",{},e.title),r("p",{class:"muted"},e.text),r("div",{class:"row gap ask-actions"},r("button",{type:"button",class:"btn block",onclick:()=>ue()},"Cancel"),r("button",{type:"button",class:`btn ${e.actionClass} block`,onclick:t=>hn(t.currentTarget,e.run)},e.action)))],!0)}document.addEventListener("keydown",e=>{e.key==="Escape"&&(Te(!0),ue(!0))});var me=null,be=null;function Te(e=!1){let t=me;if(t){if(me=null,be==null||be.setAttribute("aria-expanded","false"),be=null,e){t.remove();return}t.classList.remove("show"),t.classList.add("gone"),setTimeout(()=>t.remove(),150)}}document.addEventListener("click",e=>{me&&!me.contains(e.target)&&Te()});function er(e,t){if(be===e)return Te();Te();let n=t.filter((L,T)=>L||T>0&&t[T-1]&&t.slice(T+1).some(Boolean)),a=r("div",{class:"menu",role:"menu"},n.map(L=>L?r("button",{type:"button",role:"menuitem",class:`menu-item${L.danger?" danger":L.warn?" warn":""}`,onclick:()=>{Te(),L.run()}},R(L.icon),r("span",{},L.label)):r("div",{class:"menu-sep"})));document.body.appendChild(a);let s=e.getBoundingClientRect(),i=230,b=a.offsetHeight,m=s.bottom+6+b>window.innerHeight-8&&s.top-6-b>8;a.classList.toggle("up",m),a.style.left=`${Math.max(8,Math.min(window.innerWidth-i-8,s.right-i))}px`,a.style.top=`${(m?s.top-6-b:s.bottom+6)+window.scrollY}px`,a.offsetWidth,a.classList.add("show"),e.setAttribute("aria-expanded","true"),me=a,be=e}var tr='',nr=".alert, .hello, .card-head, .access-card, .dcard, .slot.add, .firststeps, .devices > .faint, .signin, .wrap > .card",et=!1;function ot(...e){let t=et?Nt(xe):null,n=et?"":" first",a=r("main",{class:`wrap${n}`},...e);xe.replaceChildren(r("header",{class:`top${n}`},r("div",{class:"brand"},(()=>{let s=r("span",{class:"logo"});return s.innerHTML=tr,s})(),r("span",{},(S==null?void 0:S.server.name)||jn),r("span",{class:"faint"},"· Dawnline"))),a),t?Rt(xe,t):Bt(a,nr),et=!0}function yn(){ot(r("div",{class:"card signin","data-key":"gone"},r("div",{class:"hero-ic"},R("key")),r("h1",{},"This link no longer works"),r("p",{class:"muted"},"Ask for a new personal link.")))}function rr(e){switch(e.state){case"server_off":return["server","The server is turned off","Your devices can’t connect until the admin turns it on again."];case"no_server":return["server","No server yet","Ask the admin to add you to a server."];case"quota":return["chart","You have used all your data","Your devices stay connected but nothing gets through until it resets."];case"expired":return["calendar","Your access has ended","Ask the admin to extend it."];case"hours":return["clock","Outside your hours",`Access is available ${e.hours.replace("-","–")} (router time); until then nothing gets through.`];default:return["pause","Your access is paused by the admin","Your devices can’t connect until the admin resumes it."]}}function rn(e,t,n,a){return r("div",{class:"alert","data-key":"notice"},r("span",{class:`alert-ic ${e}`},R(t)),r("div",{class:"stack"},r("span",{class:"strong"},n),r("span",{class:"muted s"},a)))}function ar(e){return e.state==="active"?"ok":e.state==="quota"||e.state==="expired"?"bad":"warn"}var sr={internet:"The internet, through the router",lan:"Devices at home",both:"Devices at home and the internet, through the router"};function or(e){let t=e.person,n=t.quota_limit?Math.min(100,t.quota_used/t.quota_limit*100):0,a=r("div",{class:`meter${n>=100?" bad":n>=90?" warn":""}`},r("i"));a.firstChild.style.width=`${n}%`,t.quota_limit&&fn(a,()=>[`${n.toFixed(1)}% used`,`${ve(Math.max(0,t.quota_limit-t.quota_used))} left`]);let s=qe(t.expires,at()),i=r("div",{class:"slots"});for(let L=0;L=t.device_limit?"over":L=0?`${s} day${s===1?"":"s"} left`:"ended"):null)),r("span",{class:"faint s"},t.hours?`Available ${t.hours.replace("-","–")} (router time). Need a change? Ask the admin.`:"Need a change? Ask the admin.")))}function ir(e,t){return e.disabled?r("span",{class:"dstat"},"Disabled by the admin"):e.config_stale&&e.handshake?r("span",{class:"dstat warn"},"Settings changed, update needed"):e.online&&t.state==="quota"?r("span",{class:"dstat warn"},"Connected, no data left"):e.online&&t.state==="hours"?r("span",{class:"dstat warn"},"Connected, outside your hours"):e.online?r("span",{class:"dstat ok"},"Connected"):e.handshake?r("span",{class:"dstat",title:new Date(e.handshake*1e3).toLocaleString()},`Last connected ${pt(e.handshake,pn())}`):r("span",{class:"dstat warn"},"Not set up yet")}function wn(e,t){return e.access!=="internet"&&e.state==="active"&&!t.disabled}function lr(e,t){let n=Ue(e.devices).filter(i=>i.hostname&&wn(e,i));if(!n.length)return null;let a=n[0].hostname,s=a.slice(a.indexOf("."));return r("div",{class:"names"},r("div",{class:"names-head"},r("span",{class:"names-ic"},R("home")),r("div",{class:"stack"},r("span",{class:"strong s"},"Names at home"),r("span",{class:"faint s"},t?"Devices at home and on this VPN reach yours as ":"Other devices at home reach yours as ",r("span",{class:"mono"},`name${s}`)))),r("div",{class:"names-list"},n.map(i=>{let b=i.hostname.indexOf(".");return r("button",{type:"button",class:"name-chip",title:i.name,"aria-label":`Copy ${i.hostname}`,onclick:m=>ge(i.hostname,"Address copied",m.currentTarget)},r("span",{class:"mono"},b>0?[i.hostname.slice(0,b),r("span",{class:"faint"},i.hostname.slice(b))]:i.hostname),R("copy"))})))}function cr(e,t){let n=r("button",{type:"button",class:"icon-btn soft","aria-label":`${e.name} options`,"aria-haspopup":"menu","aria-expanded":"false"},R("more")),a=[...wn(t.person,e)?[{label:"Copy IP address",icon:"copy",run:()=>ge(e.address,"IP address copied")},...e.hostname?[{label:"Copy local address",icon:"home",run:()=>ge(e.hostname,"Address copied")}]:[],null]:[],...e.disabled?[]:[{label:"Rename",icon:"edit",run:()=>br(e)},{label:"Reconnect",icon:"refresh",warn:!0,run:()=>cn(e,t)},{label:"Remove",icon:"trash",danger:!0,run:()=>xr(e)}]];n.addEventListener("click",T=>{T.stopPropagation(),er(n,a)});let s=e.spark.reduce((T,E)=>T+E,0),i=!e.handshake&&!e.disabled,b=!!t.locked,m=t.here===e.id,L=m?r("span",{class:"dstat here"},"This device"):ir(e,t.person);return L.dataset.v=`stat:${e.id}`,r("article",{class:`dcard${e.online?" online":""}${e.disabled?" off":""}${m?" here":""}`,"data-key":e.id},r("div",{class:"dhead"},r("span",{class:"dic"},R(e.kind)),r("div",{class:"stack grow"},r("span",{class:"dname","data-v":`name:${e.id}`},e.name),L),b||!a.length?null:n),i&&b?null:i?[r("button",{type:"button",class:"btn primary block",onclick:()=>Ke(e)},R("arrow"),r("span",{},`Set up ${e.name}`))]:r("div",{class:"duse"},r("div",{class:"stack"},r("span",{class:"faint s"},"Last 7 days"),r("span",{class:"mono","data-v":`week:${e.id}`},ve(s))),Xn(e.spark)),e.config_stale&&!i&&!b?r("button",{type:"button",class:"btn block",onclick:()=>cn(e,t)},R("refresh"),r("span",{},"Update the connection")):null)}function Me(e){let t=e.person,n=qe(t.expires,at()),a=t.state!=="active"?rn(ar(t),...rr(t)):ze(t,n)?rn("warn","calendar",`Your access ${ht(n)}`,`On ${Fe(t.expires)}. Ask the admin to extend it.`):null,i=Ue(t.devices).sort((L,T)=>+(T.id===e.here)-+(L.id===e.here)).map(L=>cr(L,e)),b=e.locked?0:Math.max(0,t.device_limit-t.devices.length);!t.devices.length&&b?i.push(r("div",{class:"card firststeps","data-key":"first"},r("h2",{},"Add your first device"),r("p",{class:"muted"},"Two steps, about a minute: get the app, then add the connection. The next screen shows both for the device you pick."),r("button",{type:"button",class:"btn primary block big",onclick:un},R("plus"),r("span",{},Jn()?"Add this phone":"Add this device")))):b&&i.push(r("button",{type:"button",class:"slot add",onclick:un,"data-key":"add"},r("span",{class:"slot-ic"},R("plus")),r("span",{class:"strong"},"Add device")));let m=r("section",{class:"devices","aria-label":"Your devices"},r("div",{class:"card-head","data-key":"devices-head"},r("div",{class:"row-baseline"},r("h2",{},"Your devices"))),r("div",{class:"dgrid"},i),e.locked?null:[e.can_add?null:r("span",{class:"faint s","data-key":"limit"},`You have reached your limit of ${t.device_limit} devices. Remove one or ask the admin for more.`)]);ot(a,r("div",{class:"hello","data-key":"hello"},r("span",{class:`avatar${t.online?" online":""}`},mt(t.name)),r("h1",{},`Hi, ${t.name}`)),r("div",{class:"layout"},or(e),m))}var bn=()=>qt(navigator.userAgent,navigator.maxTouchPoints),ur=()=>{var e;return(e=S==null?void 0:S.server.preset)!=null?e:xn()?"off":"max"},xn=()=>(S==null?void 0:S.server.awg_disguise)===!1,Mn="dl.qr.light",he=(()=>{try{return localStorage.getItem(Mn)==="1"}catch{return!1}})(),Cn=new WeakMap;function kn(e,t){Cn.set(e,t),e.className=`qr${Ve(t)?" big":""}${he?" light":""}`,e.innerHTML=kt(t,3,!0,he?"plain":"night")}function Ln(e){e.replaceChildren(he?"":"Not scanning? ",r("a",{href:"#",onclick:t=>{t.preventDefault(),dr()}},he?"Show the dark code":"Show a light code"))}function an(){let e=r("span",{class:"faint s qr-flip"});return Ln(e),e}function dr(){he=!he;try{localStorage.setItem(Mn,he?"1":"0")}catch{}document.querySelectorAll(".qr").forEach(e=>{let t=Cn.get(e);t&&(kn(e,t),ae(e,"swap"))}),document.querySelectorAll(".qr-flip").forEach(Ln)}function Ee(e){Oe("Open the link securely","Connection settings only travel encrypted",r("div",{class:"stack gap"},r("p",{class:"muted"},"This page is open without encryption. To add or set up a device, open the same link over HTTPS:"),r("a",{class:"btn primary block big",href:e},R("lock"),r("span",{},"Open securely")),r("p",{class:"faint s"},"The browser may warn that the certificate is not trusted: it is this router’s own. Choose to continue (“Advanced” → “Proceed”).")))}var it=()=>(S==null?void 0:S.https_url)||null;async function pr(e){let t=it();if(t)return Ee(t),null;try{return await fe(`devices/${e.id}/config`)}catch(n){let a=n;return a.httpsUrl?Ee(a.httpsUrl):pe(a.message,!0),null}}function sn(e,t){if(/^\s*\[.+\]\s*$/.test(e))return r("span",{class:"conf-sec"},e);let n=/^(\s*[A-Za-z0-9]+\s*=)\s*(.*)$/.exec(e);if(!n)return document.createTextNode(e);let a=/^(\s*)(PrivateKey|PresharedKey)\b/.test(e);return r("span",{},r("span",{class:"conf-k"},n[1])," ",a?t?r("span",{class:"conf-v"},n[2]):r("span",{class:"conf-mask"},"••••••••••••••••"):n[2])}function fr(e){let t=!1,n=r("pre",{class:"conf"}),a=(i=!1)=>{n.replaceChildren(...e.conf.split(` -`).flatMap((b,m)=>m?[` -`,sn(b,t)]:[sn(b,t)])),i&&n.querySelectorAll(".conf-v, .conf-mask").forEach(b=>b.classList.add("unmask"))},s=r("button",{class:"btn small",onclick:i=>{i.preventDefault(),t=!t,s.replaceChildren(R(t?"x":"key"),r("span",{},t?"Hide key":"Show key")),ae(s,"swap"),a(!0)}},R("key"),r("span",{},"Show key"));return a(),r("div",{class:"pane"},r("div",{class:"filecard"},r("span",{class:"filecard-ic"},".conf"),r("span",{class:"stack"},r("span",{class:"mono ellipsis"},e.filename),r("span",{class:"faint s"},xn()?"For computers and routers: import it in any WireGuard app":"For computers and routers: import it in AmneziaWG or AmneziaVPN")),Ie(e.filename,e.conf)?r("button",{class:"btn primary",onclick:()=>Ie(e.filename,e.conf)()},R("open"),r("span",{},"Share file")):r("button",{class:"btn primary",onclick:()=>st(e.filename,e.conf)},R("download"),r("span",{},"Download"))),r("details",{class:"confbox"},r("summary",{},R("chevron"),r("span",{},"Configuration"),r("span",{class:"grow"}),s,r("button",{class:"btn small",onclick:i=>{i.preventDefault(),ge(e.conf,"Configuration copied",i.currentTarget)}},R("copy"),r("span",{},"Copy"))),n))}async function hr(e,t){var n;e.connected(),(n=e.el.closest(".sheet-panel"))==null||n.scrollTo({top:0,behavior:se()?"auto":"smooth"}),await Pt(400),await Promise.all(t.map(a=>Dt(a))),await new Promise(a=>setTimeout(a,2e3)),te!=null&&te.contains(e.el)&&!e.el.closest(".ghost")&&ue()}function Tn(e,t=4){window.setTimeout(async()=>{var n;try{let a=await fe("state");S=a,!te&&!me&&Me(a),!((n=a.person.devices.find(s=>s.id===e))!=null&&n.online)&&t>1&&Tn(e,t-1)}catch{}},1500)}function gr(e,t,n){let a=pn(),s=0,i=0,b=!1,m=Date.now(),L=async()=>{if(s=0,!b){if(Date.now()-m>6e5){b=!0,n();return}if(document.hidden){T();return}try{let P=await fe("state");S=P;let K=P.person.devices.find(O=>O.id===e.id);if(K&&K.handshake>a){b=!0,t(),K.online||Tn(e.id);return}}catch(P){if(P.status===404||P.status===401){b=!0;return}}i++,T()}},T=()=>{!b&&!s&&(s=window.setTimeout(L,i<6?5e3:i<12?15e3:3e4))},E=()=>{!document.hidden&&!b&&!s&&L()};return document.addEventListener("visibilitychange",E),T(),()=>{b=!0,s&&clearTimeout(s),document.removeEventListener("visibilitychange",E)}}var An=e=>`dl.app.${e.id}`;function mr(e){try{let t=localStorage.getItem(An(e));return t==="vpn"||t==="awg"||t==="wg"?t:null}catch{return null}}function vr(e,t){try{localStorage.setItem(An(e),t)}catch{}}var on={vpn:"amnezia",awg:"amneziawg",wg:"wireguard"},yr={ios:"apple",android:"googleplay",windows:"windows",mac:"apple",linux:"linux",unknown:"other"};function le(e,t=!1,n){var i;let a=[r("span",{class:"badge-ic"},R(e.mark)),r("span",{class:"badge-txt"},r("span",{class:"badge-top"},e.top),r("span",{class:"badge-main"},e.main)),r("span",{class:"badge-chev"},R("chevron"))],s=`badge${t?" primary":""}`;return e.onclick?r("button",{type:"button",class:s,onclick:e.onclick,"data-m":n},a):r("a",{class:s,href:e.href,target:(i=e.href)!=null&&i.startsWith("vpn:")?null:"_blank",rel:"noopener noreferrer","data-m":n},a)}function ln(e,t){return r("div",{class:"pills"},t.map(n=>r("button",{type:"button",class:`pill${n.on?" on":""}`,onclick:n.pick,"data-m":`${e}:${n.id}`},n.icon?R(n.icon):null,r("span",{},n.label))))}var we=(e,t,...n)=>r("div",{class:"step"},r("div",{class:"step-head"},r("span",{class:"step-n"},e),r("span",{class:"step-title"},t)),...n);function wr(e){let t=typeof navigator.share=="function";return r("div",{class:"linkrow"},r("span",{class:"mono ellipsis"},e.replace(/^https?:\/\//,"")),r("button",{type:"button",class:"btn small",onclick:n=>ge(e,"Link copied",n.currentTarget)},"Copy"),t?r("button",{type:"button",class:"icon-btn soft","aria-label":"Share the link",onclick:()=>{var n;return navigator.share({url:e,title:(n=S==null?void 0:S.title)!=null?n:"Dawnline"}).catch(()=>{})}},R("share")):null)}async function Ke(e,t){var $e;let n=t!=null?t:await pr(e);if(!n)return;let a=await Lt(n,n.server),s=Yt(ur()),i=bn(),b=e.kind==="phone"||e.kind==="tablet",m=e.kind==="router",L=i==="ios"||i==="android",T=Wt(e.kind),E=($e=mr(e))!=null?$e:m?"awg":"vpn";s.some($=>$.id===E)||(E=m?"awg":"vpn");let P=T.length?T.includes(i)?i:"windows":i,K=Ut(e.kind,i),O=()=>T.length?P===i:K,U=()=>b||P==="ios"||P==="android",V=!1,j=!1,Q="app",v=null,y=r("div",{class:"setup"}),g=Gt(e.kind),k=en(e.kind),d=!1,M=$=>{var q;return(q=s.find(u=>u.id===$))!=null?q:s[0]},l=()=>ln("app",s.filter($=>!m||$.id!=="vpn").map($=>({id:$.id,label:$.name,icon:on[$.id],on:$.id===E,pick:()=>{E=$.id,vr(e,E),Y()}}))),o=()=>ln("os",T.map($=>({id:$,label:$===i?tn($):Xe[$],icon:yr[$],on:$===P,pick:()=>{P=$,Y()}}))),C=()=>{let $=m?Je(E):Vt(E,P);return $?[$.alt?[r("div",{class:"badges2"},le($,!1,"store"),le($.alt,!1,"store-alt")),r("span",{class:"faint s"},$.alt.why)]:le($,!1,"store"),ke(M(E))?r("span",{class:"faint s","data-m":"update"},ke(M(E))):null]:[r("span",{class:"muted s"},`Get ${oe[E]} on the ${Xe[P]} and come back here.`)]},f=()=>we("1",[r("span",{class:"grow","data-m":"get"},`Get ${oe[E]}`),s.length>1&&!V?r("button",{type:"button",class:"pill-link",onclick:()=>{V=!0,v="picker",Y()}},r("span",{},"Another app"),R("chevron")):null],V?r("div",{class:`stack gap${v==="picker"?" enter":""}`},l(),r("span",{class:"faint s","data-m":"app-sub"},M(E).sub)):null,T.length?o():null,...C()),x=()=>{let $=oe[E],q=O()&&L,u=E==="vpn"&&q&&!Ze(i)?Ie(Qt(n.filename),a):null;if(E==="vpn"&&q&&(Ze(i)||u))return we("2","Add the connection",le(u?{top:"Then come back here and tap",main:"Send to AmneziaVPN",mark:"amnezia",onclick:()=>void u()}:{href:a,top:"Then come back here and tap",main:"Open in AmneziaVPN",mark:"amnezia"},!0,"connect"),r("span",{class:"faint s"},u?"Pick AmneziaVPN in the share sheet. Not there? ":"Nothing opened? ",r("a",{href:"#",onclick:c=>(c.preventDefault(),ge(a,"Key copied",c.currentTarget))},"Copy the key")," and add it in the app."));if(E==="vpn")return we("2","Add the connection",le({top:"The connection as one key",main:"Copy the key",mark:"copy",onclick:c=>ge(a,"Key copied",c.currentTarget)},!0,"connect"),r("ol",{class:"howto","data-m":"howto"},r("li",{},"Open AmneziaVPN"),r("li",{},"Add server → ",r("b",{},"Insert key")),r("li",{},"Paste the key and connect")));let p=L?Ie(n.filename,n.conf):null;return we("2","Add the connection",le(p?{top:O()?`Straight into ${$}`:`Send it to the ${k}`,main:"Share the file",mark:"share",onclick:()=>p()}:{top:"Then import it in the app",main:"Download the file",mark:"download",onclick:()=>st(n.filename,n.conf)},!0,"connect"),r("ol",{class:"howto","data-m":"howto"},Jt(E,P,n.filename,!!p&&O()).map(([c,h])=>r("li",{},c,h?r("b",{},h):null))))},B=($,...q)=>Q===$?r("div",{class:"step-head open","data-m":`fold:${$}`},...q):r("button",{type:"button",class:"step-head fold","aria-expanded":"false","data-m":`fold:${$}`,onclick:()=>{Q=$,v=$,Y()}},...q,r("span",{class:"fold-chev"},R("chevron"))),N=($,q)=>{let u=r("div",{"data-m":$,"data-sig":`${q.length}:${q.slice(-24)}`});return kn(u,q),u},I=($,q)=>($&&q.filter(u=>!!u).forEach((u,p)=>{u.classList.add("unfold"),u.style.setProperty("--i",String(p))}),q),F=Zt(location.origin+location.pathname,e.id),z=({easiest:$=!1,fold:q=!1,or:u=!1}={})=>{let p=`${u?"Or open":"Open"} your link on the ${k}`;return r("div",{class:`step${q&&Q!=="link"?" folded":""}`},q?B("link",r("span",{class:"step-title grow"},p),$?r("span",{class:"chip","data-glide":"easiest"},"Easiest"):null):r("div",{class:"step-head"},r("span",{class:"step-title grow"},p),$?r("span",{class:"chip"},"Easiest"):null),...q&&Q!=="link"?[]:I(v==="link",[r("span",{class:"muted s step-sub"},"The same page there does both steps for that device."),U()?r("div",{class:"code-row"},N("link-qr",F),r("span",{class:"stack gap"},r("span",{class:"muted s"},"Point its camera at the code: the link opens there."),an())):null,wr(F)]))},Z=()=>j?(()=>{let $=z();return v==="away"&&$.classList.add("enter"),$})():r("div",{class:"center"},r("button",{type:"button",class:"fold-link",onclick:()=>{j=!0,v="away",Y()}},`Not on the ${k} right now?`)),ne=()=>r("div",{class:`step${Q!=="app"?" folded":""}`},B("app",r("span",{class:"step-ic"},R(on[E])),r("span",{class:"step-title grow"},"Already has the app")),...Q!=="app"?[]:I(v==="app",[s.length>1?r("div",{},l()):null,r("div",{class:"code-row"},N("app-qr",E==="vpn"?Tt(a):n.conf),r("span",{class:"stack"},r("span",{class:"muted s"},`In ${oe[E]}: `,r("b",{},jt(E)),". The connection is added at once."),ke(M(E))?r("span",{class:"faint s"},ke(M(E))):null,an()))])),Y=()=>{if(d)return;let $=[];zt(navigator.userAgent)&&$.push(r("div",{class:"notice"},R("alert"),r("span",{class:"grow"},"Open this page in Safari or Chrome: the store opens from here, but the app handoff does not."))),O()?$.push(f(),x(),Z()):m?$.push(we("1",[r("span",{class:"grow","data-m":"get"},`Get ${oe[E]} on the router`)],s.length>2?l():null,le(Je(E),!1,"store")),we("2","Import the configuration",fr(n))):b?$.push(z({easiest:!0,fold:!0}),ne()):$.push(r("span",{class:"muted s"},`The app goes on the ${k}.`),f(),x(),z({easiest:!0,or:!0})),It(y,()=>y.replaceChildren(...$.flat().filter(q=>q instanceof Node))),v=null};Y();let de=gr(e,()=>{d=!0,hr(g,[y])},g.gaveUp);Oe(`Set up ${e.name}`,O()?"Two steps, about a minute":m?"The packages and the file for OpenWrt":null,g.el,y),ce=()=>{de(),S&&Me(S)}}function br(e){let t=r("input",{type:"text",value:e.name,maxlength:48,"aria-label":"Device name"}),n=r("button",{class:"btn primary block",type:"submit"},"Save");Oe(`Rename ${e.name}`,null,r("form",{class:"stack gap",onsubmit:a=>{a.preventDefault(),hn(n,async()=>{try{S=(await fe(`devices/${e.id}`,{action:"rename",name:t.value})).state,ue(),Me(S),pe("Renamed")}catch(s){pe(s.message,!0)}})}},t,n)),setTimeout(()=>t.select(),50)}function cn(e,t){let n=it();if(n)return Ee(n);vn({icon:"refresh",tone:"warn",title:`Reconnect ${e.name}?`,text:t.here===e.id?"It gets new keys. This device is connected through its current settings: it disconnects a few seconds after you confirm. Add the new ones that open next.":"It gets new keys and its current settings stop working. Set it up again with the new ones that open next.",action:"Reconnect",actionClass:"primary",run:async()=>{var a;try{let s=await fe(`devices/${e.id}`,{action:"reconnect"});S=s.state,Me(S),await Ke((a=S.person.devices.find(i=>i.id===e.id))!=null?a:{...e,handshake:0},s.config)}catch(s){pe(s.message,!0)}}})}function xr(e){vn({icon:"trash",tone:"bad",title:`Remove ${e.name}?`,text:"Its connection stops working at once. You can add it again later.",action:"Remove",actionClass:"danger-solid",run:async()=>{try{S=(await fe(`devices/${e.id}`,{action:"delete"})).state,ue(),await St(xe.querySelector(`[data-key="${CSS.escape(e.id)}"]`)),Me(S),pe("Device removed")}catch(t){pe(t.message,!0)}}})}var J=navigator.userAgent,En=/iPad/.test(J)||/Macintosh/.test(J)&&navigator.maxTouchPoints>1;function tt(){return En||/Tablet/i.test(J)||/Android/.test(J)&&!/Mobile/.test(J)?"tablet":/Android|iPhone|Mobile/i.test(J)?"phone":"computer"}var Mr=[[/^SM-S93/,"Galaxy S25"],[/^SM-S92/,"Galaxy S24"],[/^SM-S91/,"Galaxy S23"],[/^SM-S90/,"Galaxy S22"],[/^SM-G99/,"Galaxy S21"],[/^SM-F9/,"Galaxy Z Fold"],[/^SM-F7/,"Galaxy Z Flip"],[/^SM-A5/,"Galaxy A5x"],[/^SM-A3/,"Galaxy A3x"],[/^SM-X/,"Galaxy Tab"]],rt="",Cr=(async()=>{var t;let e=navigator.userAgentData;if(!e||!/Android/.test(J))return"";try{let n=((t=(await e.getHighEntropyValues(["model"])).model)!=null?t:"").trim();if(!n||n==="K")return"";let a=Mr.find(([s])=>s.test(n));rt=a?`${a[1]} (${n})`:/^SM-/.test(n)?`Galaxy ${n}`:n}catch{}return rt})();function kr(e){return/iPhone/.test(J)?"iPhone":En?"iPad":/Android/.test(J)?rt||(e==="tablet"?"Android tablet":"Android phone"):/CrOS/.test(J)?"Chromebook":/Mac OS X/.test(J)?"Mac":/Windows/.test(J)?"Windows PC":/Linux/.test(J)?"Linux PC":De[e]}function un(){if(!S)return;let e=it();if(e){Ee(e);return}let t=tt(),n=new Set(S.person.devices.map(T=>T.name.toLowerCase())),a=T=>{let E=T===tt()?kr(T):De[T];if(!n.has(E.toLowerCase()))return E;for(let P=2;P<20;P++)if(!n.has(`${E} ${P}`.toLowerCase()))return`${E} ${P}`;return E},s=r("input",{type:"text",value:a(t),maxlength:48,"aria-label":"Device name",required:!0}),i=!1;s.addEventListener("input",()=>i=!0),Cr.then(()=>{!i&&t===tt()&&(s.value=a(t))});let b=r("div",{class:"kinds"},S.kinds.map(T=>r("button",{type:"button",class:`kind${T===t?" on":""}`,"data-k":T,onclick:()=>{t=T,b.querySelectorAll(".kind").forEach(E=>E.classList.toggle("on",E.dataset.k===T)),i||(s.value=a(T))}},R(T),r("span",{},De[T])))),m=r("p",{class:"err"}),L=r("button",{class:"btn primary block",type:"submit"},"Create connection");Oe("Add a device",`${S.person.device_limit-S.person.devices.length} of ${S.person.device_limit} slots free`,r("form",{class:"add",onsubmit:async T=>{T.preventDefault(),L.disabled=!0;let E=je(L);m.textContent="";try{let P=await fe("devices",{name:s.value.trim(),kind:t});S=P.state;let K=P.state.person.devices.find(O=>O.id===P.id);await Ke(K,P.config)}catch(P){if(P.httpsUrl){Ee(P.httpsUrl);return}m.textContent=P.message,ae(m,"enter"),L.disabled=!1}finally{E()}}},r("label",{class:"lbl"},"What is it?"),b,r("p",{class:"muted s"},"Phones and tablets get a smaller packet size that suits mobile networks."),r("label",{class:"lbl"},"Name"),s,m,L))}window.addEventListener("hashchange",()=>$n());function $n(){let e=Xt(location.hash);if(!e)return;history.replaceState(null,"",location.pathname+location.search);let t=S==null?void 0:S.person.devices.find(n=>n.id===e);t&&!t.handshake&&!t.disabled&&!(S!=null&&S.locked)&&Ke(t)}async function Lr(){try{S=await fe("state"),document.title=`${S.person.name} · ${S.title}`,!te&&!me&&Me(S),$n()}catch(e){let t=e;t.status===404||t.status===401?(S=null,yn()):S||ot(r("div",{class:"card"},r("p",{},t.message)))}}!Re||!Zn?yn():Lr();})(); +"use strict";(()=>{var Oo=Object.create;var On=Object.defineProperty;var Ro=Object.getOwnPropertyDescriptor;var No=Object.getOwnPropertyNames;var Io=Object.getPrototypeOf,Fo=Object.prototype.hasOwnProperty;var Ko=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var qo=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of No(e))!Fo.call(t,o)&&o!==n&&On(t,o,{get:()=>e[o],enumerable:!(r=Ro(e,o))||r.enumerable});return t};var Go=(t,e,n)=>(n=t!=null?Oo(Io(t)):{},qo(e||!t||!t.__esModule?On(n,"default",{value:t,enumerable:!0}):n,t));var gr=Ko((hr,mr)=>{"use strict";var fr=(function(){var t=function(d,m){var s=236,h=17,f=d,E=n[m],p=null,l=0,L=null,x=[],C={},R=function(w,k){l=f*4+17,p=(function(y){for(var T=new Array(y),S=0;S=7&&ot(w),L==null&&(L=$t(f,E,x)),G(L,k)},I=function(w,k){for(var y=-1;y<=7;y+=1)if(!(w+y<=-1||l<=w+y))for(var T=-1;T<=7;T+=1)k+T<=-1||l<=k+T||(0<=y&&y<=6&&(T==0||T==6)||0<=T&&T<=6&&(y==0||y==6)||2<=y&&y<=4&&2<=T&&T<=4?p[w+y][k+T]=!0:p[w+y][k+T]=!1)},z=function(){for(var w=0,k=0,y=0;y<8;y+=1){R(!0,y);var T=o.getLostPoint(C);(y==0||w>T)&&(w=T,k=y)}return k},Q=function(){for(var w=8;w>y&1)==1;p[Math.floor(y/3)][y%3+l-8-3]=T}for(var y=0;y<18;y+=1){var T=!w&&(k>>y&1)==1;p[y%3+l-8-3][Math.floor(y/3)]=T}},it=function(w,k){for(var y=E<<3|k,T=o.getBCHTypeInfo(y),S=0;S<15;S+=1){var D=!w&&(T>>S&1)==1;S<6?p[S][8]=D:S<8?p[S+1][8]=D:p[l-15+S][8]=D}for(var S=0;S<15;S+=1){var D=!w&&(T>>S&1)==1;S<8?p[8][l-S-1]=D:S<9?p[8][15-S-1+1]=D:p[8][15-S-1]=D}p[l-8][8]=!w},G=function(w,k){for(var y=-1,T=l-1,S=7,D=0,K=o.getMaskFunction(k),N=l-1;N>0;N-=2)for(N==6&&(N-=1);;){for(var X=0;X<2;X+=1)if(p[T][N-X]==null){var nt=!1;D>>S&1)==1);var q=K(T,N-X);q&&(nt=!nt),p[T][N-X]=nt,S-=1,S==-1&&(D+=1,S=7)}if(T+=y,T<0||l<=T){T-=y,y=-y;break}}},V=function(w,k){for(var y=0,T=0,S=0,D=new Array(k.length),K=new Array(k.length),N=0;N=0?Dn.getAt(Bn):0}}for(var Hn=0,q=0;qN*8)throw"code length overflow. ("+S.getLengthInBits()+">"+N*8+")";for(S.getLengthInBits()+4<=N*8&&S.put(0,4);S.getLengthInBits()%8!=0;)S.putBit(!1);for(;!(S.getLengthInBits()>=N*8||(S.put(s,8),S.getLengthInBits()>=N*8));)S.put(h,8);return V(S,T)};C.addData=function(w,k){k=k||"Byte";var y=null;switch(k){case"Numeric":y=u(w);break;case"Alphanumeric":y=M(w);break;case"Byte":y=b(w);break;case"Kanji":y=A(w);break;default:throw"mode:"+k}x.push(y),L=null},C.isDark=function(w,k){if(w<0||l<=w||k<0||l<=k)throw w+","+k;return p[w][k]},C.getModuleCount=function(){return l},C.make=function(){if(f<1){for(var w=1;w<40;w++){for(var k=g.getRSBlocks(w,E),y=v(),T=0;T";for(var S=0;S';y+=""}return y+="",y+="",y},C.createSvgTag=function(w,k,y,T){var S={};typeof arguments[0]=="object"&&(S=arguments[0],w=S.cellSize,k=S.margin,y=S.alt,T=S.title),w=w||2,k=typeof k=="undefined"?w*4:k,y=typeof y=="string"?{text:y}:y||{},y.text=y.text||null,y.id=y.text?y.id||"qrcode-description":null,T=typeof T=="string"?{text:T}:T||{},T.text=T.text||null,T.id=T.text?T.id||"qrcode-title":null;var D=C.getModuleCount()*w+k*2,K,N,X,nt,q="",gt;for(gt="l"+w+",0 0,"+w+" -"+w+",0 0,-"+w+"z ",q+=''+lt(T.text)+"":"",q+=y.text?''+lt(y.text)+"":"",q+='',q+='":k+=">";break;case"&":k+="&";break;case'"':k+=""";break;default:k+=T;break}}return k},rn=function(w){var k=1;w=typeof w=="undefined"?k*2:w;var y=C.getModuleCount()*k+w*2,T=w,S=y-w,D,K,N,X,nt,q={"██":"█","█ ":"▀"," █":"▄"," ":" "},gt={"██":"▀","█ ":"▀"," █":" "," ":" "},vt="";for(D=0;D=S?gt[nt]:q[nt];vt+=` +`}return y%2&&w>0?vt.substring(0,vt.length-y-1)+Array(y+1).join("▀"):vt.substring(0,vt.length-1)};return C.createASCII=function(w,k){if(w=w||1,w<2)return rn(k);w-=1,k=typeof k=="undefined"?w*2:k;var y=C.getModuleCount()*w+k*2,T=k,S=y-k,D,K,N,X,nt=Array(w+1).join("██"),q=Array(w+1).join(" "),gt="",vt="";for(D=0;D>>8),E.push(L&255)):E.push(h)}}return E}};var e={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8},n={L:1,M:0,Q:3,H:2},r={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7},o=(function(){var d=[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],m=1335,s=7973,h=21522,f={},E=function(p){for(var l=0;p!=0;)l+=1,p>>>=1;return l};return f.getBCHTypeInfo=function(p){for(var l=p<<10;E(l)-E(m)>=0;)l^=m<=0;)l^=s<5&&(L+=3+R-5)}for(var x=0;x=256;)f-=255;return d[f]},h})();function c(d,m){if(typeof d.length=="undefined")throw d.length+"/"+m;var s=(function(){for(var f=0;f>>7-h%8&1)==1},s.put=function(h,f){for(var E=0;E>>f-E-1&1)==1)},s.getLengthInBits=function(){return m},s.putBit=function(h){var f=Math.floor(m/8);d.length<=f&&d.push(0),h&&(d[f]|=128>>>m%8),m+=1},s},u=function(d){var m=e.MODE_NUMBER,s=d,h={};h.getMode=function(){return m},h.getLength=function(p){return s.length},h.write=function(p){for(var l=s,L=0;L+2>>8&255)*192+(x&255),p.put(x,13),L+=2}if(L>>8)},m.writeBytes=function(s,h,f){h=h||0,f=f||s.length;for(var E=0;E0&&(s+=","),s+=d[h];return s+="]",s},m},B=function(){var d=0,m=0,s=0,h="",f={},E=function(l){h+=String.fromCharCode(p(l&63))},p=function(l){if(!(l<0)){if(l<26)return 65+l;if(l<52)return 97+(l-26);if(l<62)return 48+(l-52);if(l==62)return 43;if(l==63)return 47}throw"n:"+l};return f.writeByte=function(l){for(d=d<<8|l&255,m+=8,s+=1;m>=6;)E(d>>>m-6),m-=6},f.flush=function(){if(m>0&&(E(d<<6-m),d=0,m=0),s%3!=0)for(var l=3-s%3,L=0;L=m.length){if(f==0)return-1;throw"unexpected end of file./"+f}var l=m.charAt(s);if(s+=1,l=="=")return f=0,-1;if(l.match(/^\s$/))continue;h=h<<6|p(l.charCodeAt(0)),f+=6}var L=h>>>f-8&255;return f-=8,L};var p=function(l){if(65<=l&&l<=90)return l-65;if(97<=l&&l<=122)return l-97+26;if(48<=l&&l<=57)return l-48+52;if(l==43)return 62;if(l==47)return 63;throw"c:"+l};return E},H=function(d,m){var s=d,h=m,f=new Array(d*m),E={};E.setPixel=function(x,C,R){f[C*s+x]=R},E.write=function(x){x.writeString("GIF87a"),x.writeShort(s),x.writeShort(h),x.writeByte(128),x.writeByte(0),x.writeByte(0),x.writeByte(0),x.writeByte(0),x.writeByte(0),x.writeByte(255),x.writeByte(255),x.writeByte(255),x.writeString(","),x.writeShort(0),x.writeShort(0),x.writeShort(s),x.writeShort(h),x.writeByte(0);var C=2,R=l(C);x.writeByte(C);for(var I=0;R.length-I>255;)x.writeByte(255),x.writeBytes(R,I,255),I+=255;x.writeByte(R.length-I),x.writeBytes(R,I,R.length-I),x.writeByte(0),x.writeString(";")};var p=function(x){var C=x,R=0,I=0,z={};return z.write=function(Q,et){if(Q>>>et)throw"length over";for(;R+et>=8;)C.writeByte(255&(Q<>>=8-R,I=0,R=0;I=Q<0&&C.writeByte(I)},z},l=function(x){for(var C=1<>6,128|a&63):a<55296||a>=57344?r.push(224|a>>12,128|a>>6&63,128|a&63):(o++,a=65536+((a&1023)<<10|n.charCodeAt(o)&1023),r.push(240|a>>18,128|a>>12&63,128|a>>6&63,128|a&63))}return r}return e(t)}})();(function(t){typeof define=="function"&&define.amd?define([],t):typeof hr=="object"&&(mr.exports=t())})(function(){return fr})});var Rn={phone:'',computer:'',tablet:'',router:'',server:'',other:'',ethernet:'',bridge:'',wifi:'',tunnel:'',plus:'',chart:'',reset:'',package:'',code:'',plug:'',sunrise:'',refresh:'',archive:'',qr:'',copy:'',download:'',link:'',amnezia:'',amneziawg:'',wireguard:'',appstore:'',googleplay:'',github:'',openwrt:'',apple:'',windows:'',linux:'',eye:'',share:'',arrow:'',trash:'',edit:'',pause:'',play:'',key:'',out:'',admin:'',shield:'',shieldplus:'',lock:'',zap:'',check:'',alert:'',x:'',globe:'',home:'',open:'',file:'',network:'',moon:'',chevron:'',clock:'',calendar:'',minus:'',more:'',pin:'',activity:''};function Se(t,e="dl-icon"){var r;let n=(r=Rn[t])!=null?r:Rn.phone;return``}function Nn(t,e){let n=r=>{r==null||r===!1||(Array.isArray(r)?r.forEach(n):t.appendChild(typeof r=="string"?document.createTextNode(r):r))};e.forEach(n)}function i(t,e={},...n){let r=document.createElement(t);for(let[o,a]of Object.entries(e))a==null||a===!1||(o.startsWith("on")&&typeof a=="function"?r.addEventListener(o.slice(2),a):o==="class"?r.className=String(a):a===!0?r.setAttribute(o,""):r.setAttribute(o,String(a)));return Nn(r,n),r}function Rt(t,...e){t.replaceChildren(),Nn(t,e)}function _t(t){let e=document.createElement("template");return e.innerHTML=t.trim(),e.content.firstElementChild}var F=(t,e="i")=>_t(Se(t,e));var Lt=()=>typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches;function Qt(t,e,n=1){let r=Math.sqrt(t/n),o=e/(2*Math.sqrt(t*n)),a=u=>{if(o<.999){let O=r*Math.sqrt(1-o*o);return 1-Math.exp(-o*r*u)*(Math.cos(O*u)+o*r/O*Math.sin(O*u))}if(o<=1.001)return 1-Math.exp(-r*u)*(1+r*u);let M=Math.sqrt(o*o-1),b=-r*(o-M),A=-r*(o+M);return 1-(A*Math.exp(b*u)-b*Math.exp(A*u))/(A-b)},c=0;for(let u=0;u<3;u+=.004)Math.abs(1-a(u))>.0015&&(c=u);c+=.004;let g=[];for(let u=0;u<=64;u++)g.push(+a(c*u/64).toFixed(4));g[64]=1;let v=Math.round(c*1e3);return{duration:v,easing:`linear(${g.join(", ")})`,at:u=>u>=v?1:a(u/1e3)}}var kt=Qt(300,20),U=Qt(300,35),yt=Qt(520,24),Fn=Qt(520,46),Et=Qt(380,28),In=Qt(900,60),Y="cubic-bezier(0.23, 1, 0.32, 1)",J="cubic-bezier(0.55, 0, 1, 0.45)",an="cubic-bezier(0.32, 0.72, 0, 1)";function Kn(t){t.style.setProperty("--spring-bouncy",kt.easing),t.style.setProperty("--spring-bouncy-dur",`${kt.duration}ms`),t.style.setProperty("--spring-smooth",U.easing),t.style.setProperty("--spring-smooth-dur",`${U.duration}ms`),t.style.setProperty("--spring-soft",Et.easing),t.style.setProperty("--spring-soft-dur",`${Et.duration}ms`),t.style.setProperty("--spring-quick",In.easing),t.style.setProperty("--spring-quick-dur",`${In.duration}ms`)}function _(t,e,n){var r;return Lt()?e.some(o=>"opacity"in o)?t.animate(e.map(o=>"opacity"in o?{opacity:o.opacity}:{}),{duration:Math.min(Number((r=n.duration)!=null?r:200),160),easing:"ease-out",fill:n.fill}):t.animate(e,{...n,duration:0,delay:0}):t.animate(e,n)}function qn(t,e){return t<=0||e<=0?0:(1-1/(t*.55/e+1))*e}function Gn(t,e,n){return t<=0||e<-.1?!1:e>.4||t>n/3}function ct(t){if(!t||t<0)return"0 B";let e=["B","KB","MB","GB","TB"],n=0,r=t;for(;r>=1024&&n=100||n===0?Math.round(r):r.toFixed(1)} ${e[n]}`}function Un(t,e=Date.now()/1e3){if(!t)return"never";let n=Math.max(0,Math.round(e-t));return n<60?"just now":n<3600?`${Math.floor(n/60)} min ago`:n<86400?`${Math.floor(n/3600)} h ago`:n<86400*30?`${Math.floor(n/86400)} d ago`:new Date(t*1e3).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"})}function $e(t){return`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}-${String(t.getDate()).padStart(2,"0")}`}function Tt(t){let[e,n,r]=t.split("-").map(Number);return new Date(e,(n||1)-1,r||1,12)}function Uo(t){return(typeof t=="string"?/^\d{4}-\d{2}-\d{2}$/.test(t)?Tt(t):new Date(t):t).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"})}function pe(t){return t?Uo(t):""}function Wo(t,e){let n=r=>{let[o,a,c]=r.split("-").map(Number);return Date.UTC(o,a-1,c)};return Math.round((n(t)-n(e))/864e5)}function Xt(t,e){let n=Tt(t);return n.setDate(n.getDate()+e),$e(n)}function _e(t,e=Date.now()){if(!t)return null;let n=typeof e=="number"?$e(new Date(e)):e,r=Wo(t,n);return r>=0?r+1:r}function fe(t,e){return e!=null&&e>0&&t.expire_warn>0&&e<=t.expire_warn}function Wn(t){return t<=1?"ends today":t===2?"ends tomorrow":`ends in ${t} days`}var zn={lan:"Home network",internet:"Internet",both:"Home network + Internet"};var sn={computer:"PC",phone:"Phone",tablet:"Tablet",router:"Router",other:"Other"};function Pe(t){let e=n=>n.disabled?3:n.online?0:n.handshake?1:2;return t.map((n,r)=>[n,r]).sort((n,r)=>e(n[0])-e(r[0])||n[1]-r[1]).map(([n])=>n)}var at={vpn:"AmneziaVPN",awg:"AmneziaWG",wg:"WireGuard"};function Yn(t,e=0){return/iPhone|iPad|iPod/.test(t)||/Macintosh/.test(t)&&e>1?"ios":/Android/.test(t)?"android":/Windows/.test(t)?"windows":/Mac OS X|Macintosh/.test(t)?"mac":/CrOS/.test(t)?"unknown":/Linux|X11/.test(t)?"linux":"unknown"}var jn=t=>/Telegram|FBAN|FBAV|Instagram|VKClient|Line\//i.test(t);function Qn(t,e){return t==="router"||e==="unknown"?!1:t==="phone"||t==="tablet"?e==="ios"||e==="android":t==="computer"?e==="windows"||e==="mac"||e==="linux":!0}function Xn(t){let e=[{id:"vpn",name:at.vpn},{id:"awg",name:at.awg}];return t==="off"&&e.push({id:"wg",name:at.wg}),e}var De="https://github.com/amnezia-vpn/amnezia-client/releases/latest",Vn={href:De,top:"APK file on",main:"GitHub",mark:"github",why:"The APK is for phones without Google Play, or where the store hides the app."};function Jn(t,e){var r;return(r={vpn:{ios:{href:"https://apps.apple.com/app/amneziavpn/id1600529900",top:"Download on the",main:"App Store",mark:"appstore"},android:{href:"https://play.google.com/store/apps/details?id=org.amnezia.vpn",top:"Get it on",main:"Google Play",mark:"googleplay",alt:Vn},windows:{href:De,top:"Official release on GitHub",main:"Download for Windows",mark:"windows"},mac:{href:De,top:"Official release on GitHub",main:"Download for Mac",mark:"apple"},linux:{href:De,top:"Official release on GitHub",main:"Download for Linux",mark:"linux"}},awg:{ios:{href:"https://apps.apple.com/us/app/amneziawg/id6478942365",top:"Download on the",main:"App Store",mark:"appstore"},android:{href:"https://play.google.com/store/apps/details?id=org.amnezia.awg",top:"Get it on",main:"Google Play",mark:"googleplay",alt:{...Vn,href:"https://github.com/amnezia-vpn/amneziawg-android/releases"}},windows:{href:"https://github.com/amnezia-vpn/amneziawg-windows-client/releases",top:"Official release on GitHub",main:"Download for Windows",mark:"windows"},mac:{href:"https://apps.apple.com/us/app/amneziawg/id6478942365",top:"Download on the",main:"Mac App Store",mark:"appstore"},linux:{href:"https://github.com/amnezia-vpn/amneziawg-tools",top:"On GitHub",main:"amneziawg-tools",mark:"linux"}},wg:{ios:{href:"https://apps.apple.com/app/wireguard/id1441195209",top:"Download on the",main:"App Store",mark:"appstore"},android:{href:"https://play.google.com/store/apps/details?id=com.wireguard.android",top:"Get it on",main:"Google Play",mark:"googleplay"},windows:{href:"https://www.wireguard.com/install/",top:"Download from",main:"wireguard.com",mark:"windows"},mac:{href:"https://apps.apple.com/app/wireguard/id1451685025",top:"Download on the",main:"Mac App Store",mark:"appstore"},linux:{href:"https://www.wireguard.com/install/",top:"Install from",main:"wireguard.com",mark:"linux"}}}[t][e])!=null?r:null}var Zn=t=>t==="wg"?{href:"https://openwrt.org/docs/guide-user/services/vpn/wireguard/start",top:"OpenWrt packages",main:"wireguard-tools",mark:"openwrt"}:{href:"https://openwrt.org/packages/start",top:"OpenWrt packages + kmod",main:"amneziawg-tools",mark:"openwrt"},ln=t=>t==="android",he=t=>`${t.replace(/\.conf$/i,"")}.vpn`,Be={ios:{file:"+ → Create from file or archive",qr:"+ → Create from QR code"},android:{file:"+ → Import from file or archive",qr:"+ → Scan from QR code"},mac:{file:"+ → Import tunnel(s) from file"},windows:{file:"Add Tunnel → Import tunnel(s) from file"}};function me(t,e="unknown"){var r;if(t==="vpn")return"Add server → Scan QR";let n=(r=Be[e])==null?void 0:r.qr;return n!=null?n:`${Be.ios.qr} (Android: ${Be.android.qr.replace(/^.* → /,"")})`}function zo(t,e="unknown"){var n,r;return t==="vpn"?"Add server → Insert key":(r=(n=Be[e])==null?void 0:n.file)!=null?r:"Add tunnel → Import from file"}function tr(t,e,n,r){if(e==="linux")return[["Open a terminal in the folder with the file",""],["Run ",`sudo ${t==="wg"?"wg-quick":"awg-quick"} up ./${n}`]];let o=zo(t,e);return[[`Open ${at[t]}`,""],[o.replace(/ → [^→]*$/," → "),o.replace(/^.* → /,"")],[r?"Confirm the import and connect":"Pick the file and connect",""]]}var er={ios:"iPhone / iPad",android:"Android",windows:"Windows",mac:"Mac",linux:"Linux",unknown:"this device"},nr=(t,e)=>`${t}#setup=${e}`;function rr(t){var e,n;return(n=(e=/^#setup=(d_[0-9a-f]{8})$/.exec(t))==null?void 0:e[1])!=null?n:null}var or=t=>`${t}#add`,ir=t=>t==="#add",ar=t=>({phone:"phone",tablet:"tablet",computer:"computer",router:"router",other:"device"})[t];var tt=null,dt=()=>tt;function xt(t){tt=t}var Vo=document.getElementById("app"),sr,Jt=(sr=Vo.dataset.base)!=null?sr:"",lr=/^\/[a-z]{6}-[a-z]{6}-[a-z]{6}$/.test(Jt)?Jt.slice(1):"",Zt=()=>location.origin+location.pathname,Pt=()=>{var t;return(t=tt==null?void 0:tt.today)!=null?t:$e(new Date)},te=()=>{var t;return(t=tt==null?void 0:tt.now)!=null?t:Date.now()/1e3},He=()=>Yn(navigator.userAgent,navigator.maxTouchPoints),Yo=()=>(tt==null?void 0:tt.server.awg_disguise)===!1,cr=()=>{var t;return(t=tt==null?void 0:tt.server.preset)!=null?t:Yo()?"off":"max"},dr=()=>(tt==null?void 0:tt.https_url)||null,Ut=()=>(tt==null?void 0:tt.server.name)||"Dawnline",ur=()=>{};function pr(t){ur=t}var Mt=(t={})=>ur(t);var Nt=class extends Error{constructor(n,r,o){super(r);this.status=n;this.httpsUrl=o}};async function ut(t,e){var o;let n=await fetch(`${Jt}/api/${t}`,{method:e===void 0?"GET":"POST",credentials:"omit",headers:e===void 0?{}:{"Content-Type":"application/json"},body:e===void 0?void 0:JSON.stringify(e),cache:"no-store"}),r=null;try{r=await n.json()}catch{}if(!n.ok)throw new Nt(n.status,(o=r==null?void 0:r.error)!=null?o:`Request failed (${n.status})`,(r==null?void 0:r.https_url)||void 0);return r}var Oe=t=>t instanceof Nt&&(t.status===404||t.status===401);var yr=Go(gr(),1),jo=t=>``,vr="#0a0a0a",Qo="#f2f2f2",Xo={night:[vr,Qo],day:["#ffffff",vr]},dn=t=>t.length>300,ee=t=>+t.toFixed(2);function cn(t,e,n,r,o){return`M${ee(t+o)} ${ee(e)}h${ee(n-2*o)}a${o} ${o} 0 0 1 ${o} ${o}v${ee(r-2*o)}a${o} ${o} 0 0 1 -${o} ${o}h-${ee(n-2*o)}a${o} ${o} 0 0 1 -${o} -${o}v-${ee(r-2*o)}a${o} ${o} 0 0 1 ${o} -${o}z`}function xr(t,e=3,n=!0,r="plain"){let o=dn(t),a=r!=="plain",[c,g]=a?Xo[r]:["#fff","#000"],v=(0,yr.default)(0,o?"L":"H");v.addData(t,"Byte"),v.make();let u=v.getModuleCount(),M=u+e*2,b=n&&!o?Math.round(u*.22):0;b&&(u-b)%2&&b++;let A=(u-b)/2,O=A+b,B=(s,h)=>b>0&&s>=A&&s=A&&ha&&(h<7&&s<7||h<7&&s>=u-7||h>=u-7&&s<7),H="";if(a){let s=o?.48:.42;for(let h=0;h${jo(a?c:"#fff")}`}let m=``;return a?`${m}${d}`:`${m}${d}`}var br={opacity:1,filter:"blur(0px)",transform:"none"},Jo={opacity:0,filter:"blur(5px)",transform:"scale(.86)"},wr={opacity:0,filter:"blur(5px)",transform:"scale(.6)"},Mr={duration:180,easing:J,fill:"forwards"},Re={duration:340,delay:70,easing:Y,fill:"backwards"},Cr=Re.delay+Re.duration,Ne=new WeakMap;function un(t){let e=getComputedStyle(t);return{opacity:e.opacity,filter:e.filter==="none"?"blur(0px)":e.filter,transform:e.transform}}function kr(t){var e;for(let n of[...t.childNodes])n.nodeType===Node.TEXT_NODE&&((e=n.textContent)!=null&&e.trim())&&n.replaceWith(i("span",{},n.textContent));return[...t.children].filter(n=>!n.classList.contains("orb"))}function Er(t,e){var r;let n=(r=Ne.get(t))!=null?r:[];Ne.set(t,e),n.forEach(o=>o.cancel())}function Lr(t){var o;(o=t.querySelector(":scope > .orb"))==null||o.remove();let e=kr(t),n=e.map(un),r=i("span",{class:"orb","aria-hidden":"true"},i("i"),i("i"));t.append(r),t.classList.add("busy"),t.setAttribute("aria-busy","true"),Er(t,[...e.map((a,c)=>_(a,[n[c],Jo],Mr)),_(r,[wr,br],Re)])}function Tr(t){let e=t.querySelector(":scope > .orb"),n=kr(t),r=[...e?[_(e,[un(e),wr],Mr)]:[],...n.map(o=>_(o,[un(o),br],Re))];Er(t,r),t.removeAttribute("aria-busy"),Promise.all(r.map(o=>o.finished)).then(()=>{Ne.get(t)===r&&(Ne.delete(t),r.forEach(o=>o.cancel()),e==null||e.remove(),t.classList.remove("busy"))},()=>{})}var Ar=t=>[...t].map(e=>i("i",{},e)),ne=new WeakMap,ge=t=>{var e,n,r;return(r=(n=(e=ne.get(t))==null?void 0:e.text)!=null?n:t.textContent)!=null?r:""};function hn(t){let e=document.createRange();return e.selectNodeContents(t),e.getBoundingClientRect()}function Sr(t){var a;let e=t.firstChild;if(!e||e.nodeType!==Node.TEXT_NODE)return[];let n=document.createRange(),r=[],o=0;for(let c of(a=e.textContent)!=null?a:"")n.setStart(e,o),n.setEnd(e,o+c.length),r.push(n.getBoundingClientRect().left),o+=c.length;return r.map(c=>c-r[0])}function $r(t,e){let n=[...t.children];if(!n.length)return;let r=n[0].getBoundingClientRect().left;n.forEach((o,a)=>{if(!a||e[a]===void 0)return;let c=r+e[a]-o.getBoundingClientRect().left;Math.abs(c)>.01&&(o.style.marginLeft=`${c}px`)})}function Zo(t,e){let n=0;for(;nnew Array(a.length+1).fill(0));for(let v=o.length-1;v>=0;v--)for(let u=a.length-1;u>=0;u--)c[v][u]=o[v]===a[u]?c[v+1][u+1]+1:Math.max(c[v+1][u],c[v][u+1]);let g=[];for(let v=0;v=c[v][u+1]?v++:u++;for(let v=r;v>0;v--)g.push([t.length-v,e.length-v]);return g}function Ie(t){let e=ne.get(t);e&&(clearTimeout(e.timer),ne.delete(t),t.getAnimations().forEach(n=>n.cancel()),t.classList.remove("mt","mt-ib"),t.textContent=e.text)}function bt(t,e){Ie(t),t.textContent=e}function Z(t,e,n=ge(t),r={}){var ot,it;let{whole:o=!1,at:a}=r,c=((ot=r.glide)!=null?ot:!0)&&!a,g=ne.has(t)?t.getBoundingClientRect().width:null;if(Ie(t),n===e||Lt()||!t.getClientRects().length){t.textContent=e;return}let v=getComputedStyle(t),u=o&&v.display==="inline";v.display==="inline"&&!o&&t.classList.add("mt-ib"),v.position==="static"&&t.classList.add("mt");let M=null,b=a!=null?a:null,A=[];b||(t.textContent=n,M=t.getBoundingClientRect(),b=hn(t),A=Sr(t)),t.textContent=e;let O=t.getBoundingClientRect(),B=Sr(t),P=(it=g!=null?g:M==null?void 0:M.width)!=null?it:O.width,H=c&&!u&&!!M&&Math.abs(O.width-P)>.5,$=!H||!M||Math.abs(O.left-M.left)<.5?"start":Math.abs(O.right-M.right)<.5?"end":"middle",d=i("span",{class:o?"mt-new w":"mt-new"},o?e:Ar(e)),m=i("span",{class:o?"mt-old w":"mt-old","aria-hidden":"true"},o?n:Ar(n));o&&(m.style.width=`${b.width+1}px`),t.replaceChildren(d,m),H&&_(t,[{width:`${P}px`},{width:`${O.width}px`}],{duration:U.duration,easing:U.easing,fill:"forwards"});let s=t.getBoundingClientRect(),h=(G,V)=>{m.style.top=`${V}px`,$==="end"?m.style.right=`${-G}px`:$==="middle"?(m.style.left="50%",m.style.translate=`calc(-50% + ${G}px) 0`):m.style.left=`${G}px`},f=$==="end"?b.right-s.right:$==="middle"?(b.left+b.right-s.left-s.right)/2:b.left-s.left;h(f,b.top-s.top);let E=hn(m);if(h(f+b.left-E.left,b.top-s.top+b.top-E.top),o){_(m,[{opacity:1,filter:"blur(0px)"},{opacity:0,filter:"blur(4px)"}],{duration:180,easing:J,fill:"forwards"}),_(d,[{opacity:0,filter:"blur(4px)"},{opacity:1,filter:"blur(0px)"}],{duration:280,delay:60,easing:Y,fill:"backwards"});let G=Math.max(340,H?U.duration:0)+40;ne.set(t,{text:e,timer:window.setTimeout(()=>Ie(t),G)});return}$r(d,B),$r(m,A);let p=[...m.children],l=[...d.children],L=Zo([...n],[...e]),x=new Set(L.map(([G])=>G)),C=new Set(L.map(([,G])=>G));L.forEach(([G,V])=>{let $t=p[G].getBoundingClientRect(),lt=l[V].getBoundingClientRect();p[G].style.visibility="hidden",(Math.abs($t.left-lt.left)>.5||Math.abs($t.top-lt.top)>.5)&&_(l[V],[{transform:`translate(${$t.left-lt.left}px, ${$t.top-lt.top}px)`},{transform:"none"}],{duration:U.duration,easing:U.easing})});let R=p.filter((G,V)=>!x.has(V)),I=l.filter((G,V)=>!C.has(V)),z=Math.min(12,160/Math.max(1,R.length)),Q=Math.min(22,260/Math.max(1,I.length));R.forEach((G,V)=>_(G,[{opacity:1,filter:"blur(0px)",transform:"none"},{opacity:0,filter:"blur(4px)",transform:"translateY(-0.45em)"}],{duration:220,delay:V*z,easing:J,fill:"forwards"})),I.forEach((G,V)=>_(G,[{opacity:0,filter:"blur(4px)",transform:"translateY(0.45em)"},{opacity:1,filter:"blur(0px)",transform:"none"}],{duration:380,delay:120+V*Q,easing:Y,fill:"backwards"}));let et=Math.max(220+R.length*z,I.length?120+I.length*Q+380:0,H||L.length?U.duration:0)+40;ne.set(t,{text:e,timer:window.setTimeout(()=>Ie(t),et)})}function Fe(t){return new Map([...t.querySelectorAll("[data-t]")].map(e=>[e.dataset.t,ge(e)]))}function Ke(t,e){t.querySelectorAll("[data-t]").forEach(n=>{var a;let r=e.get(n.dataset.t),o=(a=n.textContent)!=null?a:"";r!==void 0&&r!==o&&Z(n,o,r)})}var _r=t=>`${t.tagName}.${[...t.classList].filter(e=>e!=="mt"&&e!=="mt-ib").join(" ")}`,Pr=t=>t.outerHTML.replace(/\bgl\d+/g,"gl");function ti(t){let e=new Map,n=(r,o)=>r.childNodes.forEach((a,c)=>{var M,b;let g=`${o}/${c}`;if(a.nodeType===Node.TEXT_NODE){if((M=a.textContent)!=null&&M.trim()){let A=document.createRange();A.selectNodeContents(a);let O=A.getBoundingClientRect();e.set(g,{kind:"#text",text:a.textContent,svg:"",at:O,words:O,node:a})}return}if(!(a instanceof Element))return;let v=a instanceof SVGElement?Pr(a):"",u=a instanceof HTMLElement&&!v?hn((b=a.querySelector(":scope > .mt-new"))!=null?b:a):null;e.set(g,{kind:_r(a),text:a instanceof HTMLElement?ge(a):"",svg:v,at:a.getBoundingClientRect(),words:u,node:a}),v||n(a,g)});return n(t,""),e}var pn=t=>_(t,[{opacity:0,filter:"blur(4px)"},{opacity:1,filter:"blur(0px)"}],{duration:280,delay:60,easing:Y,fill:"backwards"});function qe(t,e){var O;let n=ti(t),r=t.getBoundingClientRect();if(Rt(t,e),!n.size||Lt())return;let o=t.getBoundingClientRect(),a=B=>B&&new DOMRect(B.left-r.left+o.left,B.top-r.top+o.top,B.width,B.height),c=[],g=[],v=new Set,u=(B,P,H)=>{var m;let $=B.parentElement,d=H?(m=n.get(H))==null?void 0:m.at:r;P!=null&&P.at&&P.node instanceof Element&&g.push($&&d?[P.node,P.at,$,d]:[P.node,P.at,t,r]),c.push(()=>pn(B))},M=(B,P,H)=>{let $=B.getBoundingClientRect(),d=P.left-r.left-($.left-o.left),m=P.top-r.top-($.top-o.top),s=d-H[0],h=m-H[1];return(Math.abs(s)>.5||Math.abs(h)>.5)&&_(B,[{transform:`translate(${s}px, ${h}px)`},{transform:"none"}],{duration:U.duration,easing:U.easing}),[d,m]},b=(B,P,H)=>[...B.childNodes].forEach(($,d)=>{var E,p;let m=`${P}/${d}`;v.add(m);let s=n.get(m);if($.nodeType===Node.TEXT_NODE){let l=(E=$.textContent)!=null?E:"";if(!l.trim()||(s==null?void 0:s.kind)==="#text"&&s.text===l)return;let L=i("span",{},l);$.replaceWith(L),s!=null&&s.at&&M(L,s.at,H),c.push(()=>{var x;return(s==null?void 0:s.kind)==="#text"&&l.length<=40&&s.text.length<=40?Z(L,l,s.text,{whole:!0,at:(x=a(s.words))!=null?x:void 0}):pn(L)});return}if(!($ instanceof Element))return;let h=$.getBoundingClientRect();if(!s||s.kind!==_r($)||s.at&&Math.abs(s.at.height-h.height)>1&&!($ instanceof SVGElement))return u($,s,P);let f=s.at?M($,s.at,H):H;if($ instanceof SVGElement){s.svg!==Pr($)&&c.push(()=>pn($));return}if(!$.children.length&&$ instanceof HTMLElement){let l=(p=$.textContent)!=null?p:"";l!==s.text&&c.push(()=>{var L;return l.length<=40&&s.text.length<=40?Z($,l,s.text,{whole:!0,at:(L=a(s.words))!=null?L:void 0}):u($,s,P)});return}b($,m,f)});b(t,"",[0,0]);for(let[B,P]of n)!v.has(B)&&B.lastIndexOf("/")===0&&P.at&&P.node instanceof Element&&g.push([P.node,P.at,t,r]);c.forEach(B=>B());let A=new Map;for(let[,,B]of g)!A.has(B)&&getComputedStyle(B).position==="static"&&B.classList.add("mt"),A.set(B,((O=A.get(B))!=null?O:0)+1);for(let[B,P,H,$]of g){let d=B;d.style.position="absolute",d.style.margin="0",d.style.left=`${P.left-$.left-H.clientLeft}px`,d.style.top=`${P.top-$.top-H.clientTop}px`,d.style.width=`${P.width}px`,d.style.pointerEvents="none",d.setAttribute("aria-hidden","true"),H.appendChild(d),_(d,[{opacity:1,filter:"blur(0px)"},{opacity:0,filter:"blur(4px)"}],{duration:180,easing:J,fill:"forwards"}).onfinish=()=>{d.remove();let m=A.get(H)-1;A.set(H,m),m||H.classList.remove("mt")}}}var ei='',fn=()=>[F("apple"),_t(ei)];function ni(t,e){if(t===e)return["",t,t,""];let n=t.split(" "),r=e.split(" "),o=0;for(;ov?d[2]:d[1],M=d=>i("span",{class:"osm-p"},d),b=()=>{c=o.findIndex(d=>d[1]!==d[2]),c<0&&(v=0),a=o.map(d=>({pre:M(d[0]),word:M(u(d)),suf:M(d[3])})),g=c>=0?i("span",{class:"osm-ic"},fn()[v]):null,n.replaceChildren(...a.flatMap((d,m)=>[m?i("span",{class:"arr"},"›"):null,d.pre,m===c?g:null,d.word,d.suf]).filter(d=>!!d))},A={width:"1.05em",marginRight:"0.25em"},O=d=>_(d,[{opacity:1,filter:"blur(0px)",...A},{opacity:0,filter:"blur(3px)",width:"0px",marginRight:"0px"}],{duration:220,easing:J,fill:"forwards"}).onfinish=()=>d.remove(),B=d=>_(d,[{opacity:0,filter:"blur(3px)",width:"0px",marginRight:"0px"},{opacity:1,filter:"blur(0px)",...A}],{duration:U.duration,easing:U.easing}),P=(d,m)=>{r.setAttribute("aria-label",(d===m?d:`${d} (Android: ${m.split(" → ").pop()})`).replace(/ → /g," › "));let s=d.split(" → "),h=m.split(" → "),f=s.map((p,l)=>{var L;return ni(p,(L=h[l])!=null?L:p)});if(!a.length||f.length!==o.length)return o=f,b();let E=c;o=f,c=o.findIndex(p=>p[1]!==p[2]),c<0&&(v=0),o.forEach((p,l)=>{Z(a[l].pre,p[0],void 0,{whole:!0}),Z(a[l].word,u(p),void 0,{whole:!0}),Z(a[l].suf,p[3],void 0,{whole:!0})}),c!==E&&(g&&O(g),g=c>=0?i("span",{class:"osm-ic"},fn()[v]):null,g&&(a[c].word.before(g),B(g)))};P(t,e);let H=()=>{if(!r.isConnected)return clearInterval($);if(c<0||!g||!r.offsetParent)return;v=1-v,Z(a[c].word,u(o[c]));let d=g.firstElementChild,m=fn()[v];if(Lt()){d.replaceWith(m);return}g.appendChild(m),_(d,[{opacity:1,filter:"blur(0px)",transform:"none"},{opacity:0,filter:"blur(3px)",transform:"scale(.5) rotate(-40deg)"}],{duration:200,easing:J,fill:"forwards"}).onfinish=()=>d.remove(),_(m,[{opacity:0,filter:"blur(3px)",transform:"scale(.5) rotate(40deg)"},{opacity:1,filter:"blur(0px)",transform:"none"}],{duration:yt.duration,delay:80,easing:yt.easing,fill:"backwards"})},$=window.setInterval(H,3e3);return{el:r,set:P}}var Ge=null,ve=null,Br=0,Hr=(t,e,n)=>_(t,e,{duration:n,easing:J,fill:"forwards"}).onfinish=()=>t.remove();function wt(t,e=!1){Ge!=null||(Ge=document.body.appendChild(i("div",{class:"toasts"}))),ve&&Hr(ve,[{opacity:1},{opacity:0,transform:"scale(.96)",filter:"blur(4px)"}],140);let n=i("div",{class:`toast${e?" bad":""}`,role:"status"},F(e?"alert":"check"),i("span",{},t));Ge.appendChild(n),ve=n,_(n,[{opacity:0,transform:"translateY(18px) scale(.9)",filter:"blur(6px)"},{opacity:1,transform:"none",filter:"none"}],{duration:kt.duration,easing:kt.easing}),clearTimeout(Br),Br=window.setTimeout(()=>{ve===n&&(ve=null,Hr(n,[{opacity:1},{opacity:0,transform:"translateY(6px) scale(.96)",filter:"blur(4px)"}],180))},2400)}function ri(t){var a;if(t.classList.contains("copied"))return;let e=t.querySelector("svg.i"),n=t.querySelector(".lbl, .b-main"),r=n?ge(n):"";t.classList.add("copied");let o=null;e&&(o=F("check",(a=e.getAttribute("class"))!=null?a:"i"),e.replaceWith(o),_(o,[{opacity:0,transform:"scale(.6)",filter:"blur(3px)"},{opacity:1,transform:"none",filter:"none"}],{duration:yt.duration,easing:yt.easing})),n&&/^Copy/.test(r)&&Z(n,"Copied"),setTimeout(()=>{o&&e&&o.replaceWith(e),n&&/^Copy/.test(r)&&Z(n,r),t.classList.remove("copied")},1600)}async function pt(t,e="Copied",n){try{await navigator.clipboard.writeText(t)}catch{let r=i("textarea",{class:"offscreen"},t);document.body.appendChild(r),r.select();let o=document.execCommand("copy");if(r.remove(),!o)return wt("Copying is blocked here. Select the text and copy it by hand.",!0)}n instanceof Element&&ri(n),wt(e)}function Wt(t,e){var o;let n=navigator;if(He()!=="ios"||typeof n.share!="function"||typeof File=="undefined")return null;let r=new File([e],t,{type:"application/octet-stream"});return(o=n.canShare)!=null&&o.call(n,{files:[r]})?async()=>{try{await n.share({files:[r]})}catch(a){(a==null?void 0:a.name)!=="AbortError"&&Ue(t,e)}}:null}function Ue(t,e){let n=URL.createObjectURL(new Blob([e],{type:"application/octet-stream"})),r=i("a",{href:n,download:t,class:"offscreen"});document.body.appendChild(r),r.click(),setTimeout(()=>{URL.revokeObjectURL(n),r.remove()},1e3)}function ye(t,e){let n=Wt(t,e);n?n():Ue(t,e)}async function zt(t,e){if(t.disabled)return;t.disabled=!0,Lr(t);let n=performance.now();try{await e()}finally{let r=Lt()?0:Cr-(performance.now()-n);r>0&&await new Promise(o=>setTimeout(o,r)),Tr(t),t.disabled=!1}}var mn=matchMedia("(prefers-color-scheme: light)"),oi=()=>mn.matches?"day":"night";function gn(t,e){var n,r;t.dataset.qr=e,t.classList.toggle("dense",dn(e)),t.classList.toggle("light",mn.matches),t.innerHTML=xr(e,3,!0,oi()),t.dataset.mods=String((r=(n=t.firstElementChild)==null?void 0:n.viewBox.baseVal.width)!=null?r:0)}function xe(t,e=!1){let n=i("div",{class:`qrbox${e?" big":""}`});return gn(n,t),n}mn.addEventListener("change",()=>document.querySelectorAll(".qrbox[data-qr]").forEach(t=>{var e;(e=t.querySelector("svg.old"))==null||e.remove(),gn(t,t.dataset.qr)}));function vn(t,e){let n=xe(t),r=i("div",{class:"words"},e),o=i("div",{class:"side"},r),a=i("div",{class:`coderow${n.classList.contains("dense")?" stacked":""}`},n,o);return{el:a,swap(c,g){let v=n.dataset.qr===c?null:n.querySelector("svg");if(v){gn(n,c),a.classList.toggle("stacked",n.classList.contains("dense"));let M=n.querySelector("svg");v.classList.add("old"),n.appendChild(v),_(M,[{opacity:0},{opacity:1}],{duration:200,easing:Y}),_(v,[{opacity:1},{opacity:0}],{duration:220,delay:110,easing:J,fill:"forwards"}).onfinish=()=>v.remove()}if(!g)return;let u=r;r=i("div",{class:"words"},g),o.appendChild(r),u.classList.add("old"),_(r,[{opacity:0,filter:"blur(3px)"},{opacity:1,filter:"blur(0px)"}],{duration:220,easing:Y}),_(u,[{opacity:1,filter:"blur(0px)"},{opacity:0,filter:"blur(3px)"}],{duration:200,delay:90,easing:J,fill:"forwards"}).onfinish=()=>u.remove()}}}function re(t){let e=typeof navigator.share=="function";return i("div",{class:"linkrow"},i("span",{class:"mono"},t.replace(/^https?:\/\//,"")),i("button",{type:"button",class:"knob","aria-label":"Copy the link",onclick:n=>pt(t,"Link copied",n.currentTarget)},F("copy")),e?i("button",{type:"button",class:"knob","aria-label":"Share the link",onclick:()=>navigator.share({url:t,title:Ut()}).catch(()=>{})},F("share")):null)}var Vt=null,Dt=null,be=()=>!!Vt;function Bt(t=!1){let e=Vt;if(e){if(Vt=null,Dt==null||Dt.setAttribute("aria-expanded","false"),Dt=null,t){e.remove();return}_(e,[{opacity:1},{opacity:0,transform:"scale(.96)",filter:"blur(3px)"}],{duration:120,easing:J,fill:"forwards"}).onfinish=()=>e.remove()}}function Or(t,e){var u;if(Dt===t&&Vt)return Bt();Bt(!0);let n=e.filter((M,b)=>M||b>0&&e[b-1]&&e.slice(b+1).some(Boolean)),r=i("span",{class:"menu-hl"}),o=i("div",{class:"menu",role:"menu"},r);for(let M of n){if(!M){o.appendChild(i("div",{class:"menu-sep"}));continue}let b=i("button",{type:"button",role:"menuitem",class:`mi ${(u=M.tone)!=null?u:""}`,onclick:()=>{Bt(),M.run()}},F(M.icon),i("span",{},M.label));b.addEventListener("pointerenter",()=>{var A;r.className=`menu-hl${r.style.opacity==="1"?" moving":""} ${(A=M.tone)!=null?A:""}`,r.style.transform=`translateY(${b.offsetTop-6}px)`,r.style.opacity="1"}),o.appendChild(b)}o.addEventListener("pointerleave",()=>r.style.opacity="0"),document.body.appendChild(o);let a=t.getBoundingClientRect(),c=o.offsetWidth,g=o.offsetHeight,v=a.bottom+8+g{let e=t.target;Vt&&!Vt.contains(e)&&!(Dt!=null&&Dt.contains(e))&&Bt()});addEventListener("scroll",()=>Bt(),{passive:!0});var st,At,W,Rr,ae,Ft,rt,It=[],We=null,yn=null,we=!1,oe=null,St=()=>!!(st!=null&&st.classList.contains("open")),se=400,Nr=80,ii=3.2,le=()=>matchMedia("(min-width: 760px)").matches,ie=se,xn=null;function ce(){var o;if(!st||!St())return null;if(!le())return W.style.maxWidth&&(W.style.maxWidth=""),ie=se,null;let t=[...rt.querySelectorAll(".qrbox.dense")].find(a=>{let c=a.closest(".acc-row");return a.offsetWidth&&(!c||c.classList.contains("open"))&&!a.closest(".leaving")}),e=se;if(t){let a=Math.min(innerWidth-32-Nr,innerHeight-120);e=Math.max(se,Math.round(Math.min(+((o=t.dataset.mods)!=null?o:0)*ii,a)+Nr))}let n=t&&t!==xn?t:null;if(xn=t!=null?t:null,Math.abs(e-ie)<8)return n?{from:e,want:e,reveal:n}:null;let r=parseFloat(getComputedStyle(W).maxWidth)||ie;return ie=e,W.getAnimations().filter(a=>{var c;return(c=a.effect)==null?void 0:c.getKeyframes().some(g=>"maxWidth"in g)}).forEach(a=>a.cancel()),W.style.maxWidth=`${e}px`,{from:r,want:e,reveal:n}}function de(t){if(!t)return;Math.abs(t.from-t.want)>1&&_(W,[{maxWidth:`${t.from}px`},{maxWidth:`${t.want}px`}],{duration:U.duration,easing:U.easing});let e=t.reveal;e&&setTimeout(()=>{if(!e.isConnected)return;let n=Ft.getBoundingClientRect(),r=e.getBoundingClientRect(),o=r.bottom>n.bottom-16?r.bottom-n.bottom+16:r.topft()},F("x")),ae=i("div",{class:"sheet-acts"}),rt=i("div",{class:"vp"}),Ft=i("div",{class:"sheet-scroll"},rt),W=i("div",{class:"sheet",role:"dialog","aria-modal":"true"},Rr,ae,Ft),At=i("div",{class:"scrim",onclick:()=>ft()}),st=i("div",{class:"sheet-root","aria-hidden":"true"},At,W),document.body.appendChild(st),new ResizeObserver(()=>de(ce())).observe(rt),li()}function Ir(t){W.setAttribute("aria-label",t.label),W.setAttribute("role",t.asks?"alertdialog":"dialog")}function ze(){let t=yn;yn=null,t==null||t()}function Fr(t){yn=t}function Yt(t){We=t}function ht(t){if(st||ai(),Bt(!0),ze(),St()){It=[t],bn(t());return}oe=document.activeElement instanceof HTMLElement?document.activeElement:null,It=[t],We=null,ie=se,xn=null,W.style.maxWidth="",W.classList.remove("arrived");let e=t();rt.replaceChildren(e.el),Kr(e,!1),Ir(e),st.classList.add("open"),st.setAttribute("aria-hidden","false"),document.body.classList.add("locked");let n=ce();if(n&&de({...n,from:n.want}),W.getAnimations().forEach(r=>r.cancel()),At.getAnimations().forEach(r=>r.cancel()),W.style.transform="",le()?_(W,[{opacity:0,transform:"scale(.9)",filter:"blur(4px)"},{opacity:1,transform:"none",filter:"none"}],{duration:Et.duration,easing:Et.easing}):_(W,[{transform:"translateY(calc(100% + 40px))"},{transform:"none"}],{duration:500,easing:an}),_(At,[{opacity:0},{opacity:1}],le()?{duration:Et.duration,easing:Et.easing}:{duration:420,easing:"ease-out"}),!we)try{history.pushState({sheet:!0},""),we=!0}catch{}}function ft(t=!1){if(!St()||st.dataset.closing)return;ze(),we&&(we=!1,history.back()),document.body.classList.remove("locked");let e=()=>{st.classList.remove("open"),st.setAttribute("aria-hidden","true"),delete st.dataset.closing,W.style.transform="",At.style.opacity="",W.getAnimations().forEach(a=>a.cancel()),At.getAnimations().forEach(a=>a.cancel()),rt.getAnimations().forEach(a=>a.cancel()),rt.replaceChildren(),ae.replaceChildren(),W.classList.remove("arrived"),W.style.maxWidth="",ie=se,It=[],oe!=null&&oe.isConnected&&oe.focus({preventScroll:!0}),oe=null;let o=We;We=null,o==null||o()};if(t)return e();st.dataset.closing="1";let n=getComputedStyle(W).transform;W.getAnimations().forEach(o=>o.cancel()),_(At,[{opacity:getComputedStyle(At).opacity},{opacity:0}],le()?{duration:120,easing:J,fill:"forwards"}:{duration:320,easing:"ease-out",fill:"forwards"});let r=n==="none"?"none":n;_(W,le()?[{opacity:1,transform:r,filter:"blur(0px)"},{opacity:0,transform:`${r==="none"?"":r} scale(.96)`.trim(),filter:"blur(3px)"}]:[{transform:r},{transform:"translateY(calc(100% + 40px))"}],le()?{duration:120,easing:J,fill:"forwards"}:{duration:420,easing:an,fill:"forwards"}).onfinish=e}addEventListener("popstate",()=>{St()&&(we=!1,ft())});function Kr(t,e=!0){var o;let n=(o=t.acts)!=null?o:null,r=ae.firstElementChild;if(n!==r){if(!e||r&&n&&r.dataset.key===n.dataset.key)return ae.replaceChildren(...n?[n]:[]);r&&(Object.assign(r.style,{position:"absolute",right:"0",top:"0",pointerEvents:"none"}),_(r,[{opacity:1,transform:"none",filter:"none"},{opacity:0,transform:"scale(.9)",filter:"blur(3px)"}],{duration:180,easing:"cubic-bezier(.2,0,0,1)",fill:"forwards"}).onfinish=()=>r.remove()),n&&(ae.appendChild(n),_(n,[{opacity:0,transform:"scale(.9)",filter:"blur(3px)"},{opacity:1,transform:"none",filter:"none"}],{duration:260,delay:110,easing:"cubic-bezier(.2,0,0,1)",fill:"backwards"}))}}function bn(t){Ir(t),Kr(t),W.classList.remove("arrived");let e=[...rt.children],n=rt.getBoundingClientRect().height;rt.getAnimations().forEach(a=>a.cancel()),e.forEach(a=>{a.classList.add("leaving"),Object.assign(a.style,{position:"absolute",left:"0",right:"0",top:"0",pointerEvents:"none"}),a.inert=!0}),rt.appendChild(t.el),t.el.style.pointerEvents="none",setTimeout(()=>t.el.style.pointerEvents="",320),Ft.scrollTop=0;let r=ce(),o=t.el.getBoundingClientRect().height;_(rt,[{height:`${n}px`},{height:`${o}px`}],{duration:360,easing:"cubic-bezier(.25,1,.5,1)"}),de(r),e.forEach(a=>_(a,[{opacity:1,transform:"none",filter:"none"},{opacity:0,transform:"scale(.96)",filter:"blur(2px)"}],{duration:200,easing:"cubic-bezier(.2,0,0,1)",fill:"forwards"}).onfinish=()=>a.remove()),_(t.el,[{opacity:0,transform:"scale(.96)",filter:"blur(4px)"},{opacity:1,transform:"none",filter:"none"}],{duration:280,delay:110,easing:"cubic-bezier(.2,0,0,1)",fill:"backwards"})}function Ve(t){if(!St())return ht(t);ze(),It.push(t),bn(t())}function si(){It.length<2||(ze(),It.pop(),bn(It[It.length-1]()))}function qr(t,e=[]){if(!St())return t();let n=rt.getBoundingClientRect().height;rt.getAnimations().forEach(v=>v.cancel());let r=rt.lastElementChild,o=new Map;r==null||r.querySelectorAll("*").forEach(v=>{(!(v instanceof SVGElement)||v instanceof SVGSVGElement)&&o.set(v,v.getBoundingClientRect())}),t();let a=ce(),c=rt.getBoundingClientRect().height;Math.abs(c-n)>1&&_(rt,[{height:`${n}px`},{height:`${c}px`}],{duration:U.duration,easing:U.easing}),de(a);let g=new Set;for(let[v,u]of o){if(!v.isConnected||!u.width||!u.height)continue;let M=v.getBoundingClientRect();if(!M.width||!M.height)continue;let b=u.left-M.left,A=u.top-M.top;if(Math.abs(b)<.5&&Math.abs(A)<.5)continue;g.add(v);let O=v.parentElement;for(;O&&O!==r&&!g.has(O);)O=O.parentElement;O&&O!==r||_(v,[{transform:`translate(${b}px, ${A}px)`},{transform:"none"}],{duration:U.duration,easing:U.easing})}for(let v of e)v&&_(v,[{opacity:0,filter:"blur(4px)"},{opacity:1,filter:"none"}],{duration:280,easing:Y})}function Gr(){W==null||W.classList.add("arrived")}var Ur=()=>Ft==null?void 0:Ft.scrollTo({top:0,behavior:"smooth"}),wn=t=>St()&&rt.contains(t)&&!t.closest(".leaving");function li(){let t=null;W.addEventListener("pointerdown",n=>{let r=n.target;!r.closest(".vhead")||r.closest("button, a, input")||(t={y:n.clientY,t:performance.now(),dy:0,v:0},W.setPointerCapture(n.pointerId))}),W.addEventListener("pointermove",n=>{if(!t)return;let r=n.clientY-t.y,o=performance.now(),a=r>0?r:-qn(-r,W.offsetHeight);t.v=(a-t.dy)/Math.max(1,o-t.t),t.dy=a,t.t=o,W.style.transform=`translateY(${a}px)`,At.style.opacity=String(Math.max(0,1-Math.max(0,a)/420))});let e=()=>{if(!t)return;let{dy:n,v:r}=t;if(t=null,Gn(n,r,W.offsetHeight))return ft();let o=W.style.transform;W.style.transform="",At.style.opacity="",n!==0&&_(W,[{transform:o},{transform:"none"}],{duration:U.duration,easing:U.easing})};W.addEventListener("pointerup",e),W.addEventListener("pointercancel",e)}function Ct(t,e={}){return i("div",{class:`vhead${e.back?" center":""}${e.acts?" with-acts":""}`},e.back?i("button",{type:"button",class:"knob back","aria-label":"Back",onclick:si},F("chevron")):null,i("h2",{},t))}var Ht=t=>i("p",{class:"vsub"},t),Kt=(...t)=>i("p",{class:"hint"},...t);function Wr(){ht(()=>{let t=Zt();return{el:i("div",{class:"view"},Ct("Open on another device"),Ht("Point its camera at the code: this page opens there."),xe(t,!0),re(t)),label:"Open on another device"}})}var ci='',je=null,Me=null,Ye=null;function Mn(t){if(Me)return Me;je=i("header",{class:"crumbs"}),Me=i("div",{class:"page-body"}),t.replaceChildren(i("div",{class:"edge-fade top","aria-hidden":"true"}),i("div",{class:"edge-fade bot","aria-hidden":"true"}),Ye=i("main",{class:"page"},je,Me));let e=()=>document.body.classList.toggle("scrolled",scrollY>2);return addEventListener("scroll",e,{passive:!0}),e(),Me}function Cn(t){Ye==null||Ye.classList.toggle("single",t)}function kn(t=!1,e=!1){var o;if(!je)return;let n=t?null:(o=dt())==null?void 0:o.person,r=i("span",{class:n?"":"cur","aria-current":n?null:"page"},Ut());je.replaceChildren(i("span",{class:"cr-mark"},_t(ci)),i("nav",{class:"cr-path","aria-label":"Breadcrumb"},r,n?[F("chevron"),i("span",{class:"cur","aria-current":"page"},n.name)]:null),...n&&!e?[i("button",{type:"button",class:"knob cr-qr","aria-label":"Open on another device",onclick:Wr},F("qr"))]:[])}function Vr(t,e,n=10){let r=g=>(Tt(g).getDay()+6)%7,o=Xt(t,-r(t)),a=Xt(e,6-r(e)),c=[];for(let g=o;g<=a;g=Xt(g,1))if(c.push({day:g,kind:gn*7)return null;return c}var di=/^([01]?\d|2[0-3]):([0-5]\d)$/;function zr(t){let e=di.exec(t.trim());return e?+e[1]*60+ +e[2]:null}var Ce=t=>(t%1440+1440)%1440,jt=t=>`${String(Math.floor(Ce(t)/60)).padStart(2,"0")}:${String(Ce(t)%60).padStart(2,"0")}`;function Qe(t,e,n){let[r,o]=t.split("-"),a=zr(r!=null?r:""),c=zr(o!=null?o:"");if(a==null||c==null)return null;let g=e==null?0:n-e;return{from:Ce(a+g),to:Ce(c+g),yours:e!=null}}var Yr=t=>t.fromCe(Math.floor(t/60)+e);function Qr(t){let e=Tt(t);return{days:new Date(e.getFullYear(),e.getMonth()+1,0).getDate(),day:e.getDate()}}var Xr={phone:{b:'',f:'',d:''},mobile:{b:'',f:'',d:''},tablet:{b:'',f:'',d:''},computer:{b:'',f:'',d:''},router:{b:'',f:'',d:''},other:{b:'',f:'',d:""},plus:{b:'',f:'',d:''},globe:{b:'',f:'',d:''},home:{b:'',f:'',d:''},shield:{b:'',f:'',d:''},chart:{b:'',f:'',d:''},calendar:{b:'',f:'',d:''},clock:{b:'',f:'',d:''},pause:{b:'',f:'',d:''},server:{b:'',f:'',d:''},link:{b:'',f:'',d:''},key:{b:'',f:'',d:''},lock:{b:'',f:'',d:''},check:{b:'',f:'',d:''},trash:{b:'',f:'',d:''},refresh:{b:'',f:'',d:''},app:{b:'',f:'',d:null},file:{b:'',f:'',d:''}},ui=()=>Se("amnezia","").replace(/^]*>/,"").replace(/<\/svg>$/,""),pi=0;function fi(t,e="grey",n="gi"){var c;let r=(c=Xr[t])!=null?c:Xr.other,o=`gl${++pi}`,a=r.d===null?`${ui()}`:`${r.d}`;return``}var j=(t,e="grey",n="gi")=>_t(fi(t,e,n));function Xe(t,e,n,r){return i("div",{class:`notice ${t}`},j(e,t==="bad"?"red":"orange"),i("div",{class:"t"},n?i("b",{},n):null,i("span",{},r)))}function hi(t){var n;let e=Qe(t,(n=dt())==null?void 0:n.tz_offset,-new Date().getTimezoneOffset());return e?`${jt(e.from)}–${jt(e.to)} ${e.yours?"your time":"(router time)"}`:`${t.replace("-","–")} (router time)`}function En(t){switch(t.state){case"server_off":return["server","Server is disabled","Your devices can’t connect until it’s enabled again."];case"no_server":return["server","No server yet","You haven’t been added to one."];case"quota":return["chart","Out of data","Nothing gets through until it resets."];case"expired":return["calendar","Access ended","Your devices can’t connect until it’s extended."];case"hours":return["clock","Outside your hours",`Open ${hi(t.hours)}.`];default:return["pause","Access paused","Your devices can’t connect until it’s resumed."]}}function Jr(t){if(t.state!=="active")return Xe(t.state==="quota"||t.state==="expired"?"bad":"warn",...En(t));let e=_e(t.expires,Pt());return fe(t,e)?Xe("warn","calendar",`Access ${Wn(e)}`,`On ${pe(t.expires)}.`):null}function mi(t){let e=i("div",{class:"view"},Ct("Open the link securely"),Ht("Connection settings only travel encrypted"),i("div",{class:"center-col secure"},j("lock","blue","gi xl"),i("p",{},"This page is open without encryption. To add or set up a device, open the same link over HTTPS:")),i("a",{class:"btn accent block",href:t},F("lock"),i("span",{},"Open securely")),Kt("The browser may warn that the certificate is not trusted: it is this router’s own. Choose to continue (“Advanced” → “Proceed”)."));return e.lastElementChild.classList.add("secure-note"),{el:e,label:"Open the link securely"}}var ke=t=>ht(()=>mi(t));function ue(){let t=dr();return t?(ke(t),!0):!1}var gi={jc:"0",jmin:"0",jmax:"0",s1:"0",s2:"0",s3:"0",s4:"0",h1:"1",h2:"2",h3:"3",h4:"4",i1:"",i2:"",i3:"",i4:"",i5:""},vi={header_protection_key:"HeaderProtectionKey",content_padding_addition:"ContentPaddingAddition",rekey_after_time:"RekeyAfterTime",rekey_timeout:"RekeyTimeout",reject_after_time:"RejectAfterTime",keepalive_timeout:"KeepaliveTimeout",max_handshake_attempts:"MaxHandshakeAttempts",random_trailers:"RandomTrailers",disable_cookies:"DisableCookies"};function yi(t){let e={};for(let[n,r]of Object.entries(vi))t[n]!=null&&t[n]!==""&&(e[r]=String(t[n]));return e}function xi(t,e){var v;let n=t.amnezia,r=(v=n.obfuscation)!=null?v:{},o=u=>r[u]!=null&&r[u]!==""?String(r[u]):gi[u],a=n.host.replace(/^\[(.*)\]$/,"$1"),c={H1:o("h1"),H2:o("h2"),H3:o("h3"),H4:o("h4"),I1:o("i1"),I2:o("i2"),I3:o("i3"),I4:o("i4"),I5:o("i5"),Jc:o("jc"),Jmin:o("jmin"),Jmax:o("jmax"),S1:o("s1"),S2:o("s2"),S3:o("s3"),S4:o("s4"),...yi(r),allowed_ips:n.allowed_ips,client_ip:n.client_ip,client_priv_key:n.client_priv_key,client_pub_key:n.client_pub_key,config:t.conf.replace(/\r?\n/g,`\r +`),hostName:a,mtu:n.mtu,persistent_keep_alive:n.persistent_keep_alive,port:Number(n.port),psk_key:n.psk_key,server_pub_key:n.server_pub_key},g={containers:[{container:"amnezia-awg",awg:{isThirdPartyConfig:!0,last_config:JSON.stringify(c),port:String(n.port),protocol_version:r.header_protection_key?"3.1":"2",transport_proto:"udp"}}],defaultContainer:"amnezia-awg",description:e,hostName:a};return n.dns[0]&&(g.dns1=n.dns[0]),n.dns[1]&&(g.dns2=n.dns[1]),g}function bi(t){let e="";for(let n=0;nt.replace(/^vpn:\/\//,"");var to=["height","marginTop","marginBottom","borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"];function qt(t,e={}){let n=i("div",{class:`acc${e.inset?" inset":""}`}),r=t.map((u,M)=>{var $;let b=u.body.filter(d=>!!d),A=!b.length,O=[u.icon,i("span",{class:"acc-title"},i("span",{class:"t"},u.title),($=u.tag)!=null?$:null),u.val?i("span",{class:`acc-val${u.valHide?" hide-open":""}`},u.val):null],B=M===e.open&&!A,P=A?i("div",{class:"acc-head"},...O):i("button",{type:"button",class:"acc-head","aria-expanded":String(B),onclick:()=>v(H)},...O,F("chevron","i acc-chev")),H=i("div",{class:`acc-row${A?" still":""}${B?" open":""}`},P,i("div",{class:"acc-body"},...b));return n.appendChild(H),H}),o=u=>u.querySelector(".acc-body"),a=()=>r.forEach((u,M)=>{let b=u.classList.contains("open");u.classList.toggle("rt",M===0||b||r[M-1].classList.contains("open")),u.classList.toggle("rb",M===r.length-1||b||r[M+1].classList.contains("open"))}),c=u=>{let M=getComputedStyle(u),b={};for(let A of to)b[A]=A==="height"?`${u.getBoundingClientRect().height}px`:M[A];return b},g=()=>r.forEach(u=>{var M;return(M=u.querySelector("button.acc-head"))==null?void 0:M.setAttribute("aria-expanded",String(u.classList.contains("open")))});function v(u){var B;let M=r.map(c);r.forEach(P=>P.getAnimations().forEach(H=>H.cancel())),r.forEach(P=>o(P).getAnimations().forEach(H=>H.cancel()));let b=!u.classList.contains("open"),A=r.filter(P=>P.classList.contains("open")&&(P===u||b));r.forEach(P=>{P.classList.remove("closing"),P!==u&&P.classList.remove("open")}),u.classList.toggle("open",b),a();let O=ce();r.forEach((P,H)=>{let $=c(P);to.some(d=>M[H][d]!==$[d])&&(A.includes(P)&&P.classList.add("closing"),_(P,[M[H],$],{duration:Et.duration,easing:Et.easing}).onfinish=()=>P.classList.remove("closing"))}),A.forEach(P=>_(o(P),[{opacity:1},{opacity:0,filter:"blur(2px)"}],{duration:160,easing:J,fill:"forwards"})),b&&_(o(u),[{opacity:0,filter:"blur(2px)"},{opacity:1,filter:"blur(0px)"}],{duration:300,easing:"cubic-bezier(0,0,.58,1)"}),de(O),g(),(B=e.onToggle)==null||B.call(e,r.indexOf(u),b,!1)}return a(),{el:n,openIndex:()=>r.findIndex(u=>u.classList.contains("open")),setOpen(u){r.forEach((M,b)=>M.classList.toggle("open",b===u&&!M.classList.contains("still"))),a(),g(),r.forEach((M,b)=>{var A;return(A=e.onToggle)==null?void 0:A.call(e,b,M.classList.contains("open"),!0)})}}}function eo(t,e,n){let r=i("span",{class:"seg-pill"}),o=i("div",{class:"seg appseg",role:"tablist"},r),a=t.map(A=>{let O=i("button",{type:"button",class:"seg-b",role:"tab","aria-label":A.label,title:A.label,onclick:()=>b(A.value)},F(A.icon),i("span",{class:"seg-l"},A.label));return O.dataset.v=A.value,o.appendChild(O),O}),c=A=>A.querySelector(".seg-l"),g=()=>a.forEach(A=>{let O=A.dataset.v===e;A.classList.toggle("on",O),A.setAttribute("aria-selected",String(O))}),v=()=>{let A=a.find(O=>O.dataset.v===e);return A&&A.offsetWidth?[A.offsetLeft,o.clientWidth-A.offsetLeft-A.offsetWidth]:null},u=()=>{let A=v();A&&(r.style.left=`${A[0]}px`,r.style.right=`${A[1]}px`)},M=0;function b(A){if(A===e)return;let O=a.findIndex(C=>C.dataset.v===e),B=a.findIndex(C=>C.dataset.v===A),P=getComputedStyle(r),H=parseFloat(P.left)||0,$=parseFloat(P.right)||0,d=a.map(C=>parseFloat(getComputedStyle(C).flexGrow)||0),m=c(a[O]),s=m.getBoundingClientRect().width;[...a,...a.map(c)].forEach(C=>C.getAnimations().forEach(R=>R.cancel())),e=A,g(),a.forEach((C,R)=>{let I=R===B?1:0;d[R]!==I&&_(C,[{flexGrow:d[R]},{flexGrow:I}],{duration:U.duration,easing:U.easing})}),_(m,[{opacity:1,maxWidth:`${s}px`,marginLeft:"0px"},{opacity:0,maxWidth:"0px",marginLeft:"-8px"}],{duration:220,easing:"ease-out"}),_(c(a[B]),[{opacity:0,filter:"blur(4px)"},{opacity:1,filter:"none"}],{duration:280,delay:70,easing:Y,fill:"backwards"});let h=B>O,f=Lt()?U:Fn,E=performance.now(),p=Math.max(U.duration,f.duration),l=h?U:f,L=h?f:U;cancelAnimationFrame(M);let x=()=>{let C=Lt()?p:performance.now()-E,R=v();if(!R){M=0;return}r.style.left=`${H+(R[0]-H)*l.at(C)}px`,r.style.right=`${$+(R[1]-$)*L.at(C)}px`,M=C{M||u()}).observe(o),{el:o,sync(A){A!==e&&(e=A,g(),u())}}}var oo={vpn:"amnezia",awg:"amneziawg",wg:"wireguard"},io=t=>`dl.app.${t.id}`;function ao(t){try{let e=localStorage.getItem(io(t));return e==="vpn"||e==="awg"||e==="wg"?e:null}catch{return null}}function so(t,e){try{localStorage.setItem(io(t),e)}catch{}}function Gt(t,e=!1){var a,c;let n=[i("span",{class:"b-ic"},F(t.mark)),i("span",{class:"b-t"},i("span",{class:"b-top"},t.top),i("span",{class:"b-main"},t.main)),F(t.onclick||(a=t.href)!=null&&a.startsWith("vpn:")?"chevron":"open")],r=`badge${e?" primary":""}`;if(t.onclick)return i("button",{type:"button",class:r,onclick:t.onclick},n);let o=(c=t.href)==null?void 0:c.startsWith("vpn:");return i("a",{class:r,href:t.href,target:o?null:"_blank",rel:"noopener noreferrer"},n)}function lo(t,e,n){let r=n?Zn(t):Jn(t,e);return r?r.alt?[i("div",{class:"badges2"},Gt(r),Gt(r.alt)),Kt(r.alt.why)]:[Gt(r)]:[Kt(`Get ${at[t]} on the ${er[e]} and come back here.`)]}var no=t=>i("ol",{class:"howto"},t.map(([e,n])=>i("li",{},e.replace(/ → $/," ›"),n?[" ",i("b",{},n)]:null))),Mi=(t,e)=>i("button",{type:"button",onclick:e},t);function co(t){let e=t.app(),n=at[e],r=t.pf==="ios"||t.pf==="android",o=t.same()&&r,a=v=>pt(t.key,"Key copied",v.currentTarget),c=e==="vpn"&&o&&!ln(t.pf)?Wt(he(t.cfg.filename),t.key):null;if(e==="vpn"&&o&&(ln(t.pf)||c))return[Gt(c?{top:"Then come back here and tap",main:"Send to AmneziaVPN",mark:"amnezia",onclick:()=>void c()}:{href:t.key,top:"Then come back here and tap",main:"Open in AmneziaVPN",mark:"amnezia"},!0),Kt(c?"Pick AmneziaVPN in the share sheet. Not there? ":"Nothing opened? ",Mi("Copy the key",a)," and add it in the app.")];if(e==="vpn")return[Gt({top:"The connection as one key",main:"Copy the key",mark:"copy",onclick:a},!0),no([["Open AmneziaVPN",""],["Add server › ","Insert key"],["Paste the key and connect",""]])];let g=r?Wt(t.cfg.filename,t.cfg.conf):null;return[Gt(g?{top:t.same()?`Straight into ${n}`:`Send it to the ${t.there}`,main:"Share the file",mark:"share",onclick:()=>void g()}:{top:"Then import it in the app",main:"Download the file",mark:"download",onclick:()=>Ue(t.cfg.filename,t.cfg.conf)},!0),no(tr(e,t.pf,t.cfg.filename,!!g&&t.same()))]}function uo(t){let e=t.app(),n=(o,a,c)=>i("button",{type:"button",class:"btn soft sm",onclick:c},F(o),i("span",{class:"lbl"},a));if(e==="vpn"){let o=he(t.cfg.filename),a=!!Wt(o,t.key);return[i("p",{class:"desc"},`Send it to the ${t.there} in a message or a note, then in AmneziaVPN: Add server › Insert key.`),i("div",{class:"btnrow2"},n("copy","Copy the key",c=>pt(t.key,"Key copied",c.currentTarget)),n(a?"share":"download",a?"Share as a file":"Download the key",()=>ye(o,t.key)))]}let r=!!Wt(t.cfg.filename,t.cfg.conf);return[i("p",{class:"desc"},`Send it to the ${t.there}, then import `,i("b",{},t.cfg.filename),` in ${at[e]}.`),i("div",{class:"btnrow2"},n(r?"share":"download",r?"Share the file":"Download the file",()=>ye(t.cfg.filename,t.cfg.conf)),n("copy","Copy the configuration",o=>pt(t.cfg.conf,"Configuration copied",o.currentTarget)))]}function ro(t,e){if(/^\s*\[.+\]\s*$/.test(t))return i("span",{class:"sec"},t);let n=/^(\s*[A-Za-z0-9]+\s*=)\s*(.*)$/.exec(t);if(!n)return document.createTextNode(t);let r=/^(\s*)(PrivateKey|PresharedKey)\b/.test(t);return i("span",{},i("span",{class:"k"},n[1])," ",r&&!e?i("span",{class:"mask"},"••••••••••••••••"):n[2])}function po(t){let e=!1,n=i("pre",{class:"conf"}),r=()=>n.replaceChildren(...t.conf.split(` +`).flatMap((u,M)=>M?[` +`,ro(u,e)]:[ro(u,e)]));r();let o=!!Wt(t.filename,t.conf),a=i("button",{type:"button",class:"btn soft sm",onclick:()=>{e=!e,a.replaceChildren(F(e?"x":"key"),i("span",{},e?"Hide key":"Show key")),r(),n.querySelectorAll(".mask, .k").forEach(u=>_(u,[{filter:"blur(4px)",opacity:.4},{filter:"none",opacity:1}],{duration:320,easing:Y}))}},F("key"),i("span",{},"Show key")),c=i("button",{type:"button",class:"btn soft sm",onclick:u=>pt(t.conf,"Configuration copied",u.currentTarget)},F("copy"),i("span",{class:"lbl"},"Copy")),g=i("div",{class:"filecard"},i("div",{class:"fc-row"},i("span",{class:"filecard-ic"},".conf"),i("span",{class:"t"},i("span",{class:"mono"},t.filename),i("span",{},"For computers and routers"))),i("button",{type:"button",class:"btn accent sm block",onclick:()=>ye(t.filename,t.conf)},F(o?"open":"download"),i("span",{},o?"Share file":"Download"))),v=qt([{icon:j("file"),title:"Configuration",body:[i("div",{class:"confbar"},a,c),n]}],{inset:!0});return i("div",{class:"step-box"},g,v.el)}function fo(t){let e=i("span",{class:"osm-p"},at[t]),n=Dr(me(t,"ios"),me(t,"android"));return{el:i("span",{class:"scanline"},i("span",{},"In ",e,":"),n.el),set(r){Z(e,at[r],void 0,{whole:!0}),n.set(me(r,"ios"),me(r,"android"))}}}function ho(t){let e=i("span",{class:"tt"}),n=i("span",{class:"tt-m"}),r=i("span",{class:"hp-tip","aria-hidden":"true"},e,n),o=i("button",{type:"button",class:"hp-b",onclick:()=>ye(t().file,t().text)},F("download")),a=i("button",{type:"button",class:"hp-b"},F("copy")),c=i("div",{class:"hpill",role:"group","aria-label":"The connection","data-key":"conn"},o,a,r),g=null,v=0,u=0,M=s=>{var h;return s===a&&a.classList.contains("done")?"Copied":(h=s.getAttribute("aria-label"))!=null?h:""},b=(s,h)=>{n.textContent=h;let f=n.offsetWidth+20;return Math.min(s.offsetLeft+s.offsetWidth/2,c.offsetWidth+46-f/2)},A=s=>`translateX(${s}px) translateX(-50%)`,O=s=>{let h=getComputedStyle(r).transform;r.getAnimations().forEach(f=>f.cancel()),r.style.transform=A(s),_(r,[{transform:h},{transform:A(s)}],{duration:U.duration,easing:U.easing})},B=s=>Z(e,s),P=s=>{if(clearTimeout(v),g===s&&r.classList.contains("on"))return;if(g=s,r.classList.contains("on")){let f=M(s);return O(b(s,f)),B(f)}let h=()=>{let f=M(s);bt(e,f);let E=b(s,f);r.getAnimations().forEach(p=>p.cancel()),r.style.transform=A(E),r.classList.add("on"),_(r,[{opacity:0,transform:`${A(E)} translateY(-3px) scale(.96)`,filter:"blur(3px)"},{opacity:1,transform:A(E),filter:"blur(0px)"}],{duration:220,easing:Y})};performance.now(){clearTimeout(v),g=null,r.classList.contains("on")&&(u=performance.now()+500,r.classList.remove("on"),_(r,[{opacity:1},{opacity:0}],{duration:120,easing:"ease-out"}))};for(let s of[o,a])s.addEventListener("pointerenter",h=>{h.pointerType==="mouse"&&P(s)}),s.addEventListener("focus",()=>{s.matches(":focus-visible")&&P(s)}),s.addEventListener("blur",H);c.addEventListener("pointerleave",H);let $=s=>{let h=F(s);a.querySelector("svg").replaceWith(h),_(h,[{opacity:0,transform:"scale(.6)",filter:"blur(3px)"},{opacity:1,transform:"none",filter:"none"}],{duration:yt.duration,easing:yt.easing})},d=()=>{if(g!==a||!r.classList.contains("on"))return;let s=M(a);O(b(a,s)),B(s)},m=0;return a.addEventListener("click",()=>{let s=t();pt(s.text,s.msg),clearTimeout(m),a.classList.contains("done")||(a.classList.add("done"),$("check"),d()),m=window.setTimeout(()=>{a.classList.remove("done"),$("copy"),d()},1600)}),{el:c,sync(){let s=t().app;o.setAttribute("aria-label",`Download ${s} config`),a.setAttribute("aria-label",`Copy ${s} config`)}}}function go(t){let e=i("b",{},"Waiting for the connection"),n=i("span",{class:"ws",hidden:!0}),r=i("div",{class:"way",role:"status","aria-live":"polite"},i("div",{class:"way-row"},i("span",{class:"way-end"},F(t.kind)),i("span",{class:"way-track"},i("span",{class:"way-glow"},i("i")),i("span",{class:"way-fill"})),i("span",{class:"way-end home"},F("server"))),i("div",{class:"way-text"},i("span",{class:"t"},e,n)));return{el:r,connected(){r.classList.add("done"),Z(e,`${t.name} connected`)},gaveUp(){r.classList.add("stopped"),Z(e,"No connection yet"),n.textContent="Close this and open it again to keep checking.",n.hidden=!1,_(e.parentElement,[{opacity:0,filter:"blur(4px)"},{opacity:1,filter:"none"}],{duration:280,easing:Y})}}}function vo(t,e=4){window.setTimeout(async()=>{var n;try{let r=await ut("state");xt(r),be()||Mt(),!((n=r.person.devices.find(o=>o.id===t))!=null&&n.online)&&e>1&&vo(t,e-1)}catch{}},1500)}function yo(t,e,n){let r=te(),o=0,a=0,c=!1,g=Date.now(),v=async()=>{if(o=0,!c){if(Date.now()-g>6e5){c=!0,n();return}if(document.hidden)return u();try{let b=await ut("state");xt(b);let A=b.person.devices.find(O=>O.id===t.id);if(A&&A.handshake>r){c=!0,e(),A.online||vo(t.id);return}}catch(b){if(Oe(b)){c=!0;return}}a++,u()}},u=()=>{!c&&!o&&(o=window.setTimeout(v,a<6?5e3:a<12?15e3:3e4))},M=()=>{!document.hidden&&!c&&!o&&v()};return document.addEventListener("visibilitychange",M),u(),()=>{c=!0,o&&clearTimeout(o),document.removeEventListener("visibilitychange",M)}}var mo=t=>new Promise(e=>setTimeout(e,t));async function xo(t,e,n){t.connected(),Gr(),Ur(),await mo(400),wn(t.el)&&(e.style.overflow="hidden",_(e,[{height:`${e.offsetHeight}px`,opacity:1,filter:"none"},{height:"0px",opacity:0,filter:"blur(4px)"}],{duration:520,easing:Y,fill:"forwards"}),_(t.el,[{marginBottom:"18px"},{marginBottom:"0px"}],{duration:520,easing:Y,fill:"forwards"}),await mo(2400),wn(t.el)&&(Yt(()=>Mt({flash:n.id})),ft()))}async function Ci(t){try{return await ut(`devices/${t.id}/config`)}catch(e){return e instanceof Nt&&e.httpsUrl?ke(e.httpsUrl):wt(e.message,!0),null}}async function Je(t,e){if(ue())return;let n=async()=>{let r=await Ci(t);if(!r)return;let o=await Ln(r,r.server);ht(()=>wo(t,r,o))};e instanceof HTMLButtonElement?await zt(e,n):await n()}async function Ze(t,e){let n=await Ln(e,e.server);Ve(()=>wo(t,e,n))}function bo(t,e,n){return i("div",{class:"step"},i("span",{class:"step-n"},t),i("div",{class:"step-b"},typeof e=="string"?i("span",{class:"step-t"},e):e,n))}function ki(t,e,n){let r=t.hidden?0:t.getBoundingClientRect().height;if(t.getAnimations().forEach(g=>g.cancel()),n){t.hidden=e;return}t.style.overflow="hidden",t.hidden=!1;let o=e?0:t.getBoundingClientRect().height,[a,c]=e?[1,0]:[0,1];_(t,[{height:`${r}px`,opacity:a,filter:`blur(${4-a*4}px)`},{height:`${o}px`,opacity:c,filter:`blur(${4-c*4}px)`}],{duration:U.duration,easing:U.easing}).onfinish=()=>{t.style.overflow="",t.hidden=e}}function wo(t,e,n){var ot,it;let r=He(),o=Xn(cr()),a=t.kind==="phone"||t.kind==="tablet",c=t.kind==="router",g=Qn(t.kind,r),v=g?"same":c?"router":a?"away":"pc-away",u=ar(t.kind),M=o.filter(G=>!c||G.id!=="vpn"),b=(ot=ao(t))!=null?ot:c?"awg":"vpn";M.some(G=>G.id===b)||(b=M[0].id);let A={d:t,cfg:e,key:n,pf:r,there:u,app:()=>b,same:()=>g},O=[],B=()=>{if(M.length<2)return null;let G=eo(M.map(V=>({value:V.id,label:V.name,icon:oo[V.id]})),b,V=>{b=V,so(t,V),O.forEach($t=>$t.sync(V)),qr(p)});return O.push(G),G.el},P=i("span",{class:"step-t"}),H=i("div",{class:"step-box"}),$=i("div",{class:"step-box"}),d=i("div",{class:"step-box"}),m=i("div",{class:"step-box"}),s=null,h=null,f=null,E=v==="away"?ho(()=>({...b==="vpn"?{text:n,msg:"Key copied",file:he(e.filename)}:{text:e.conf,msg:"Configuration copied",file:e.filename},app:at[b]})):null;function p(){Z(P,c?`Get ${at[b]} on the router`:`Get ${at[b]}`,void 0,{whole:!0}),qe(H,lo(b,r,c)),c?$.firstChild||Rt($,po(e)):qe($,co(A));let G=b==="vpn"?Zr(n):e.conf;s&&h&&s.el.isConnected?f!==b&&(s.swap(G),h.set(b)):(h=fo(b),s=vn(G,[h.el]),d.replaceChildren(s.el)),f=b,qe(m,uo(A)),E==null||E.sync()}p();let l=nr(Zt(),t.id),L=()=>[a?vn(l,[i("span",{},"Point its camera at the code: the link opens there.")]).el:i("p",{class:"desc"},`Open this link on the ${u} to set it up there.`),re(l)],x=()=>bo("1",P,[B(),H]),C=()=>bo("2",c?"Import the configuration":"Add the connection",[$]),R=i("div",{class:"setup"});if(jn(navigator.userAgent)&&R.appendChild(Xe("warn","shield",null,"Open this page in Safari or Chrome: the store opens from here, but the app handoff does not.")),v==="same"){let G=i("div",{class:"steps-wrap"},i("div",{class:"steps-gap"}),x(),C()),V=qt([{icon:j("link"),title:`Not on the ${u} right now?`,body:L()}],{inset:!0,onToggle:($t,lt,rn)=>ki(G,lt,rn)});R.append(V.el,G)}else v==="router"?R.append(x(),C()):v==="away"?R.appendChild(qt([{icon:j("link"),title:`Open your link on the ${u}`,body:L()},{icon:j("app"),title:"Already has the app",body:[B(),d]}],{inset:!0,open:1}).el):R.appendChild(qt([{icon:j("link"),title:`Open your link on the ${u}`,body:L()},{icon:j("key"),title:"Copy or save the connection",body:[B(),m]}],{inset:!0,open:0}).el);let I=go(t),z=!1;Fr(yo(t,()=>{z||(z=!0,xo(I,R,t))},I.gaveUp)),Yt(()=>Mt());let Q=v==="same"?"Two steps, about a minute":c?"The packages and the file for OpenWrt":`The app goes on the ${u}.`;return{el:i("div",{class:"view"},Ct(`Set up ${t.name}`,{acts:!!E}),Ht(Q),I.el,R),label:`Set up ${t.name}`,acts:(it=E==null?void 0:E.el)!=null?it:null}}var mt=navigator.userAgent,ko=/iPad/.test(mt)||/Macintosh/.test(mt)&&navigator.maxTouchPoints>1;function Le(){return ko||/Tablet/i.test(mt)||/Android/.test(mt)&&!/Mobile/.test(mt)?"tablet":/Android|iPhone|Mobile/i.test(mt)?"phone":"computer"}var Ei=[[/^SM-S93/,"Galaxy S25"],[/^SM-S92/,"Galaxy S24"],[/^SM-S91/,"Galaxy S23"],[/^SM-S90/,"Galaxy S22"],[/^SM-G99/,"Galaxy S21"],[/^SM-F9/,"Galaxy Z Fold"],[/^SM-F7/,"Galaxy Z Flip"],[/^SM-A5/,"Galaxy A5x"],[/^SM-A3/,"Galaxy A3x"],[/^SM-X/,"Galaxy Tab"]],Tn="",Li=(async()=>{var e;let t=navigator.userAgentData;if(!t||!/Android/.test(mt))return"";try{let n=((e=(await t.getHighEntropyValues(["model"])).model)!=null?e:"").trim();if(!n||n==="K")return"";let r=Ei.find(([o])=>o.test(n));Tn=r?`${r[1]} (${n})`:/^SM-/.test(n)?`Galaxy ${n}`:n}catch{}return Tn})();function Ti(t){return/iPhone/.test(mt)?"iPhone":ko?"iPad":/Android/.test(mt)?Tn||(t==="tablet"?"Android tablet":"Android phone"):/CrOS/.test(mt)?"Chromebook":/Mac OS X/.test(mt)?"Mac":/Windows/.test(mt)?"Windows PC":/Linux/.test(mt)?"Linux PC":sn[t]}var Mo={computer:"PC",mobile:"Mobile",router:"Router",other:"Other"},Ee=t=>t==="phone"||t==="tablet"?"mobile":t,Co=t=>t!=="mobile"?t:Le()==="tablet"?"tablet":"phone";function Te(){let t=dt();if(!(!t||t.locked)){if(!t.can_add)return wt(`You have reached your limit of ${t.person.device_limit} devices`,!0);ue()||ht(Ai)}}function Ai(){let t=dt(),e=t.person,n=["computer","mobile","router","other"].filter(d=>t.kinds.some(m=>Ee(m)===d)),r=n.includes(Ee(Le()))?Ee(Le()):n[0],o=!1,a=new Set(e.devices.map(d=>d.name.toLowerCase())),c=d=>{let m=d===Ee(Le())?Ti(Co(d)):d==="mobile"?"Phone":sn[d];if(!a.has(m.toLowerCase()))return m;for(let s=2;s<20;s++)if(!a.has(`${m} ${s}`.toLowerCase()))return`${m} ${s}`;return m},g=i("div",{class:"kinds",role:"radiogroup","aria-label":"What is it?"});g.style.setProperty("--n",String(n.length));let v=n.map(d=>{let m=i("button",{type:"button",class:"kind",role:"radio","aria-label":Mo[d],onclick:()=>O(d)},i("span",{class:"kind-tile"},j(d,"blue")),i("span",{class:"kind-lbl"},Mo[d]));return g.appendChild(m),m}),u=i("input",{type:"text",maxlength:48,required:!0,"aria-label":"Name",autocomplete:"off"}),M=i("button",{class:"go ready",type:"submit","aria-label":"Create connection"},F("arrow")),b=i("p",{class:"hint bad-t",hidden:!0}),A=d=>{if(!b.hidden)return Z(b,d);b.textContent=d,b.hidden=!1,_(b,[{opacity:0,transform:"translateY(-4px)"},{opacity:1,transform:"none"}],{duration:220,easing:Y})};u.value=c(r),u.addEventListener("input",()=>{o=!0,M.classList.toggle("ready",!!u.value.trim()),b.hidden=!0}),Li.then(()=>{!o&&r===Ee(Le())&&(u.value=c(r))});function O(d){r=d,v.forEach((m,s)=>{let h=n[s]===d;m.classList.toggle("on",h),m.setAttribute("aria-checked",String(h))}),o||(u.value=c(d),M.classList.add("ready"))}O(r);let B=i("form",{class:"field",autocomplete:"off"},u,M);B.addEventListener("submit",d=>{d.preventDefault();let m=u.value.trim();if(m){if(a.has(m.toLowerCase()))return A("You already have a device with this name.");zt(M,async()=>{try{let s=await ut("devices",{name:m,kind:Co(r)});xt(s.state),Mt({pop:s.id});let h=s.state.person.devices.find(f=>f.id===s.id);await Ze(h,s.config)}catch(s){if(s instanceof Nt&&s.httpsUrl)return ke(s.httpsUrl);A(s.message)}})}});let P=i("button",{type:"button",class:"btn soft block",onclick:()=>Ve(Si)},F("qr"),i("span",{},"Add it from the device")),H=e.device_limit-e.devices.length,$=i("div",{class:"view"},Ct("Add a device"),Ht(`${H} of ${e.device_limit} slots free`),g,Kt("Phones and tablets get a smaller packet size that suits mobile networks."),B,b,i("div",{class:"or"},"OR"),P);return $.querySelector(".hint").classList.add("kinds-note"),{el:$,label:"Add a device"}}function Si(){let t=or(Zt());return{el:i("div",{class:"view"},Ct("Open on the device",{back:!0}),Ht("Point its camera at the code: your page opens there with this device ready to add."),xe(t,!0),re(t)),label:"Open on the device"}}function Eo(t){let e=i("button",{type:"button",class:`btn ${t.cls}`,onclick:r=>zt(r.currentTarget,t.run)},i("span",{},t.action));return{el:i("div",{class:"view"},i("div",{class:"center-col ask"},j(t.icon,t.tone,"gi xl"),i("h3",{},t.title),i("p",{},t.text),i("div",{class:"btnrow"},i("button",{type:"button",class:"btn soft",onclick:()=>ft()},"Cancel"),e))),label:t.title,asks:!0}}function Lo(t){ht(()=>{let e=i("input",{type:"text",maxlength:48,"aria-label":"Device name",autocomplete:"off"});e.value=t.name;let n=i("button",{class:"go",type:"submit","aria-label":"Save"},F("check"));e.addEventListener("input",()=>n.classList.toggle("ready",!!e.value.trim()&&e.value.trim()!==t.name));let r=i("form",{class:"field",autocomplete:"off"},e,n);return r.addEventListener("submit",o=>{o.preventDefault();let a=e.value.trim();!a||a===t.name||zt(n,async()=>{try{let c=await ut(`devices/${t.id}`,{action:"rename",name:a});xt(c.state),Yt(()=>{Mt(),wt("Renamed")}),ft()}catch(c){wt(c.message,!0)}})}),setTimeout(()=>e.select(),60),{el:i("div",{class:"view"},Ct(`Rename ${t.name}`),r),label:`Rename ${t.name}`}})}function An(t){var n;if(ue())return;let e=((n=dt())==null?void 0:n.here)===t.id;ht(()=>Eo({icon:"refresh",tone:"orange",title:`Reconnect ${t.name}?`,text:e?"It gets new keys. This device is connected through its current settings: it disconnects a few seconds after you confirm. Add the new ones that open next.":"It gets new keys and its current settings stop working. Set it up again with the new ones that open next.",action:"Reconnect",cls:"accent",run:async()=>{var r;try{let o=await ut(`devices/${t.id}`,{action:"reconnect"});xt(o.state),Mt(),await Ze((r=o.state.person.devices.find(a=>a.id===t.id))!=null?r:{...t,handshake:0},o.config)}catch(o){wt(o.message,!0)}}}))}function To(t){ht(()=>Eo({icon:"trash",tone:"red",title:`Remove ${t.name}?`,text:"Its connection stops working at once. You can add it again later.",action:"Remove",cls:"red",run:async()=>{try{let e=await ut(`devices/${t.id}`,{action:"delete"});xt(e.state),Yt(()=>{let n=document.querySelector(`.dev[data-id="${CSS.escape(t.id)}"]`),r=()=>{Mt(),wt("Device removed")};if(!n)return r();_(n,[{opacity:1,transform:"none",filter:"none"},{opacity:0,transform:"scale(.9)",filter:"blur(6px)"}],{duration:220,easing:J,fill:"forwards"}).onfinish=r}),ft()}catch(e){wt(e.message,!0)}}}))}var Sn=(t,e)=>t.access!=="internet"&&t.state==="active"&&!e.disabled;function $i(t,e){return t.disabled?["","Disabled"]:t.config_stale&&t.handshake?["warn-t","Settings changed"]:t.online&&e.state==="quota"?["warn-t","Connected, no data left"]:t.online&&e.state==="hours"?["warn-t","Connected, outside your hours"]:t.online?["ok-t","Connected"]:t.handshake?["",`Last connected ${Un(t.handshake,te())}`]:["warn-t","Not set up yet"]}function _i(t,e){return[...Sn(e.person,t)?[{label:"Copy IP address",icon:"copy",run:()=>pt(t.address,"IP address copied")},...t.hostname?[{label:"Copy local address",icon:"home",run:()=>pt(t.hostname,"Address copied")}]:[],null]:[],...t.disabled?[]:[{label:"Rename",icon:"edit",run:()=>Lo(t)},{label:"Reconnect",icon:"refresh",tone:"warn",run:()=>An(t)},{label:"Remove",icon:"trash",tone:"bad",run:()=>To(t)}]]}function Pi(t){return t===0?"Today":t===1?"Yesterday":Tt(Xt(Pt(),-t)).toLocaleDateString("en-GB",{weekday:"short",day:"numeric",month:"short"})}function Di(t,e){let n=t.spark.reduce((c,g)=>c+g,0),r=i("span",{class:"use-lbl"},"Last 7 days"),o=i("span",{class:"use-val num","data-t":`${t.id}:use`},ct(n)),a;if(e)a=i("button",{type:"button",class:"upd-pill","aria-label":"Update the connection",title:"Its settings changed: update the connection",onclick:()=>An(t)},F("refresh"),i("span",{},"Update"));else{let c=Math.max(1,...t.spark);a=i("div",{class:"spark"}),t.spark.forEach((g,v)=>{let u=t.spark.length-1-v,M=i("i",{class:u===0?"today":""});M.style.height=`${Math.max(3,Math.round(g/c*34))}px`,M.addEventListener("pointerenter",()=>{bt(r,Pi(u)),bt(o,ct(g))}),M.addEventListener("pointerleave",()=>{bt(r,"Last 7 days"),bt(o,ct(n))}),a.appendChild(M)})}return i("div",{class:"dev-use"},i("div",{class:"use-txt"},r,o),a)}function Bi(t,e){let n=e.person,r=!!e.locked,o=e.here===t.id,[a,c]=o?["here-t","This device"]:$i(t,n),g=!t.handshake&&!t.disabled,v=t.config_stale&&!g&&!r&&!t.disabled,u=!o&&t.handshake&&!t.online&&!t.disabled&&!t.config_stale?new Date(t.handshake*1e3).toLocaleString("en-GB"):v?"Settings changed, update needed":c,M=_i(t,e),b=r||!M.length?null:i("button",{type:"button",class:"knob more","aria-label":`${t.name} options`,"aria-haspopup":"menu","aria-expanded":"false"},F("more"));return b==null||b.addEventListener("click",()=>Or(b,M)),i("article",{class:`dev${o?" is-here":""}${t.disabled?" off":""}`,"data-id":t.id},i("div",{class:"dev-top"},j(t.kind,o?"blue":"grey"),i("div",{class:"dev-id"},i("span",{class:"dev-name","data-t":`${t.id}:name`},t.name),i("span",{class:`dev-stat ${a}`,title:u,"data-t":`${t.id}:stat`},c)),b),g&&r?null:g?i("button",{type:"button",class:"btn tint block setup-btn","aria-label":`Set up ${t.name}`,onclick:A=>Je(t,A.currentTarget)},F("qr"),i("span",{},"Connect")):Di(t,v))}var Hi=t=>i("div",{class:"dev first","data-id":"first"},j("plus","blue"),i("b",{},"Add your first device"),i("p",{},"Two steps, about a minute: get the app, then add the connection."),i("button",{type:"button",class:"btn accent block",onclick:Te},F("plus"),i("span",{},t?"Add this phone":"Add this device"))),Oi=()=>i("button",{type:"button",class:"dev add","data-id":"add",onclick:Te},j("plus"),i("span",{},"Add device"));function Ao(){return i("section",{class:"devices",id:"devices","aria-label":"Your devices"},i("div",{class:"sec-head"},i("h2",{},"Your devices"),i("span",{class:"aside num"})),i("div",{class:"dgrid"}),i("p",{class:"note-s limit",hidden:!0}))}function So(t,e,n={}){let r=e.person,o=t.querySelector(".dgrid"),a=o.childElementCount>0,c=new Map([...o.querySelectorAll("[data-id]")].map($=>[$.dataset.id,$.getBoundingClientRect()])),g=Fe(o),u=Pe(r.devices).sort(($,d)=>+(d.id===e.here)-+($.id===e.here)).map($=>Bi($,e)),M=e.locked?0:Math.max(0,r.device_limit-r.devices.length),b=matchMedia("(max-width: 959px)").matches||/Android|iPhone|iPad/.test(navigator.userAgent);!r.devices.length&&M?u.push(Hi(b)):e.can_add&&!e.locked&&u.push(Oi()),o.classList.toggle("empty",!r.devices.length),o.replaceChildren(...u);for(let $ of u){let d=c.get($.dataset.id),m=$.getBoundingClientRect();$.dataset.id===n.pop?_($,[{opacity:0,transform:"scale(.9)",filter:"blur(6px)"},{opacity:1,transform:"none",filter:"none"}],{duration:kt.duration,easing:kt.easing}):d&&(d.left!==m.left||d.top!==m.top)?_($,[{transform:`translate(${d.left-m.left}px, ${d.top-m.top}px)`},{transform:"none"}],{duration:U.duration,easing:U.easing}):!d&&a&&_($,[{opacity:0,transform:"scale(.9)",filter:"blur(6px)"},{opacity:getComputedStyle($).opacity,transform:"none",filter:"none"}],{duration:U.duration,delay:60,easing:U.easing,fill:"backwards"}),$.dataset.id===n.flash&&$.animate([{boxShadow:"inset 0 0 0 1.5px var(--ok)"},{boxShadow:"inset 0 0 0 1.5px transparent"}],{duration:1800,easing:"ease-out"})}a&&Ke(o,g);let A=t.querySelector(".sec-head .aside"),O=`${r.devices.length} of ${r.device_limit}`;a?Z(A,O):A.textContent=O,A.classList.toggle("warn-t",r.devices.length>r.device_limit);let B=t.querySelector(".limit"),P=B.hidden,H=e.can_add||!!e.locked;if(B.textContent=`You have reached your limit of ${r.device_limit} devices. Remove one to add another.`,B.getAnimations().forEach($=>$.cancel()),a&&!P&&H){let $=_(B,[{opacity:1,filter:"none"},{opacity:0,filter:"blur(4px)"}],{duration:200,easing:J,fill:"forwards"});$.onfinish=()=>{B.hidden=!0,$.cancel()}}else B.hidden=H,a&&P&&!H&&_(B,[{opacity:0,transform:"translateY(6px)",filter:"blur(4px)"},{opacity:1,transform:"none",filter:"none"}],{duration:420,easing:Y})}var $n=t=>i("p",{class:"desc"},t),en=(t,e)=>`${(t/e*100).toFixed(2)}%`;function Ri(t){let e=(n,r,o,a)=>i("div",{class:`reach-tile${n?"":" off"}`},j(r,n?"blue":"grey","gi rt-ic"),i("b",{},o),i("span",{class:"rt-sub"},n?a:"Not included"),i("span",{class:"rt-mark","aria-label":n?"Included":"Not included"},F(n?"check":"minus")));return i("div",{class:"reach2"},e(t!=="internet","home","Home network","Devices at home"),e(t!=="lan","globe","Internet","Through the router"))}function Ni(t,e){let n=Pe(t.devices).filter(c=>c.hostname&&Sn(t,c));if(!n.length)return[];let r=n[0].hostname,o=r.indexOf("."),a=o>0?r.slice(o):"";return[i("span",{class:"lbl-s"},e?"Devices at home and on this VPN reach yours as ":"Other devices at home reach yours as ",i("span",{class:"mono"},`name${a}`)),i("div",{class:"names"},n.map(c=>{let g=c.hostname.indexOf(".");return i("button",{type:"button",class:"namechip",title:c.name,"aria-label":`Copy ${c.hostname}`,onclick:v=>pt(c.hostname,"Address copied",v.currentTarget)},i("span",{},g>0?[c.hostname.slice(0,g),i("span",{class:"faint"},c.hostname.slice(g))]:c.hostname),F("copy"))}))]}function Ii(t){let e=2*Math.PI*6,n=t>=100?" bad":t>=90?" warn":"";return _t(``)}function Fi(t){let e=i("i",{class:t>=100?"bad":t>=90?"warn":""});return e.style.width=`${t.toFixed(1)}%`,i("div",{class:"meter"},e)}function Ki(t,e,n){var B,P;let{days:r,day:o}=Qr(Pt()),a=(B=t.month_days)!=null?B:[],c=Math.max(1,...a),g=H=>Tt(`${Pt().slice(0,8)}${String(H).padStart(2,"0")}`).toLocaleDateString("en-GB",{day:"numeric",month:"short"}),v=i("b",{class:"num","data-t":"m-used"},ct(e)),u=i("span",{}," used"),M=i("span",{class:"mread"},v,u),b=i("div",{class:"mbars"});for(let H=0;H=o){b.appendChild(i("i",{class:"future"}));continue}let $=(P=a[H])!=null?P:0,d=i("i",{class:H===o-1?"today":""});d.style.height=`${Math.max(3,Math.round($/c*64))}px`,d.addEventListener("pointerenter",()=>{bt(v,ct($)),bt(u,` on ${g(H+1)}`)}),d.addEventListener("pointerleave",()=>{bt(v,ct(e)),bt(u," used")}),b.appendChild(d)}let A=i("span",{class:"td"},"Today");A.style.left=en(o-.5,r);let O=i("div",{class:"month-axis"},i("span",{class:o<=4?"hide":""},g(1)),A,i("span",{class:o>=r-3?"hide":""},g(r)));return i("div",{class:"month"},b,O,i("div",{class:"month-read"},M,i("span",{class:`num${t.state==="quota"?" bad-t":""}`,"data-t":"m-left"},t.quota_limit?`${ct(Math.max(0,t.quota_limit-e))} left`:"No limit")),t.quota_limit?Fi(n):null)}function qi(t,e){let n=a=>Tt(a).toLocaleDateString("en-GB",{weekday:"short",day:"numeric",month:"short"}),r=Vr(Pt(),t.expires),o=r?i("div",{class:"cal","aria-hidden":"true"},i("div",{class:"cal-h"},["M","T","W","T","F","S","S"].map(a=>i("span",{},a))),i("div",{class:"cal-g"},r.map((a,c)=>{let g=i("i",{class:a.kind,title:n(a.day)});return g.style.setProperty("--i",String(c)),g}))):null;return i("div",{class:`until${fe(t,e)?" soon":""}`},i("div",{class:"until-num"},i("b",{class:"num"},String(e)),i("span",{},`${e===1?"day":"days"} left`),i("span",{class:"until-sub"},`Ends ${n(t.expires)}`)),o)}function Gi(t,e){let n=-new Date().getTimezoneOffset(),r=Qe(t,e,n);if(!r)return null;let o=jr(te(),r.yours?n:e!=null?e:n),a=Yr(r),c=a.some(([u,M])=>o>=u&&oi("span",{},u))))}function Ui(t,e=1){let n=t.person,r=n.quota_used||n.month[0]+n.month[1],o=n.quota_limit?Math.min(100,r/n.quota_limit*100):0,a=n.quota_period==="total"&&!!n.quota_gb,c=_e(n.expires,Pt()),g=n.expires?i("span",{class:"until-val"},i("span",{class:"num","data-t":"until-date"},pe(n.expires).replace(/ \d{4}$/,"")),c!=null?i("span",{class:`num ${c<0?"bad-t":fe(n,c)?"warn-t":"ok-t"}`,"data-t":"until-left"},c>=0?`${c} day${c===1?"":"s"}`:"ended"):null):i("span",{},"No end date"),v=[n.expires?c!=null&&c<0?$n(`It ended on ${pe(n.expires)}.`):qi(n,c!=null?c:0):null,n.hours?Gi(n.hours,t.tz_offset):null];return qt([{icon:j(n.access==="internet"?"globe":n.access==="lan"?"home":"shield"),title:zn[n.access],body:[Ri(n.access),...Ni(n,!!t.server.device_mesh)]},{icon:j("chart"),title:a?"Data used":"Data this month",val:i("span",{class:"data-val"},n.quota_limit?Ii(o):null,i("span",{class:"num","data-t":"data-val"},`${ct(r)}${n.quota_limit?` / ${ct(n.quota_limit)}`:" · no limit"}`)),valHide:!0,body:[a?$n(`${ct(r)} of ${ct(n.quota_limit)} in total.`):Ki(n,r,o),$n(n.quota_limit?a?"A total for your whole access, it does not reset.":"Resets on the 1st.":"No data limit. The count starts again on the 1st.")]},{icon:j("calendar"),title:"Access until",val:g,valHide:!!n.expires&&(c!=null?c:0)>=0,body:v}],{open:e})}function $o(){return i("section",{class:"access",id:"access","aria-label":"Your access"},i("div",{class:"sec-head"},i("h2",{},"Your access")),i("div",{class:"acc-slot"}))}var tn=null;function _o(t,e){let n=Ui(e,tn?tn.openIndex():1),r=Fe(t);t.querySelector(".acc-slot").replaceChildren(n.el),tn&&Ke(t,r),tn=n}Kn(document.documentElement);var nn=document.getElementById("app"),Ot=null,_n=!1;function Po(){let t=[...nn.querySelectorAll(".crumbs, .notice, .sec-head, .dgrid > *, .note-s:not([hidden]), .acc-slot .acc-row, .gone")],e=t.map(n=>getComputedStyle(n).opacity);t.forEach((n,r)=>_(n,[{opacity:0,transform:"translateY(10px)",filter:"blur(4px)"},{opacity:e[r],transform:"none",filter:"none"}],{duration:520,delay:60+r*40,easing:Y,fill:"backwards"})),nn.querySelectorAll(".logo .sun").forEach(n=>_(n,[{transform:"translateY(7px)"},{transform:"none"}],{duration:900,delay:150,easing:Y,fill:"backwards"})),_n=!0}function Do(t={}){let e=dt();if(!e)return;if(e.person.state==="paused"){document.title=Ut();let[r,o,a]=En(e.person);return Pn(r,o,a,!1,"orange")}let n=Mn(nn);Cn(!1),kn(),document.title=Ut(),Ot||(Ot={notice:i("div",{class:"notice-slot"}),devices:Ao(),access:$o()},Rt(n,Ot.notice,i("div",{class:"cols"},Ot.devices,Ot.access))),Rt(Ot.notice,Jr(e.person)),So(Ot.devices,e,t),_o(Ot.access,e),_n||Po()}pr(Do);function Pn(t,e,n,r=!1,o="grey"){Ot=null;let a=Mn(nn);Cn(!0),kn(r,!0),Rt(a,i("div",{class:"gone"},j(t,o),i("h1",{},e),i("p",{},n))),_n||Po()}function Bo(){xt(null),ft(!0),Pn("key","This link no longer works","Ask for a new one.",!0)}function Ho(){let t=dt(),e=rr(location.hash),n=ir(location.hash);if(!t||!e&&!n)return;if(history.replaceState(null,"",location.pathname+location.search),n)return Te();let r=t.person.devices.find(o=>o.id===e);r&&!r.handshake&&!r.disabled&&!t.locked&&Je(r)}addEventListener("hashchange",Ho);async function Wi(){try{xt(await ut("state")),!St()&&!be()&&Do(),Ho()}catch(t){Oe(t)?Bo():dt()||Pn("server","The page could not load",t.message)}}document.addEventListener("keydown",t=>{t.key==="Escape"&&(be()?Bt(!0):St()&&ft(!0))});!Jt||!lr?Bo():Wi();})(); diff --git a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/awg.uc b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/awg.uc index ddacfef..7ca8097 100644 --- a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/awg.uc +++ b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/awg.uc @@ -6,7 +6,7 @@ import { readfile, stat, unlink } from 'fs'; import { - q, sh, sh_out, rand_int, rand_bytes, valid_key, ip2int, translit, ensure_dir, write_file, read_json, write_json, lock, unlock, + q, sh, sh_out, rand_int, rand_bytes, valid_key, ip2int, tunnel_name, ensure_dir, write_file, read_json, write_json, lock, unlock, slog, iface_status, DATA_DIR, RUN_DIR } from 'dawnline.util'; import * as core from 'dawnline.core'; @@ -336,25 +336,6 @@ export function obf_neutral(o) { return true; }; -/* - * The .conf file name doubles as the tunnel name in WireGuard apps (15 - * characters at most): the device first, so a person's devices stay apart, - * and a number when the cut would still make two of them alike. - */ -function conf_filename(m, p, dev) { - let label = (d) => trim(substr(trim(replace(lc(translit(d.name + '-' + p.id)), /[^a-z0-9]+/g, '-'), '-'), 0, 15), '-'); - let order = sort(map(p.devices, (id) => m.devices[id]), - (a, b) => (a.created - b.created) || (a.id < b.id ? -1 : a.id > b.id ? 1 : 0)); - let seen = {}; - for (let d in order) { - let l = label(d); - let n = seen[l] = (seen[l] ?? 0) + 1; - if (d.id == dev.id) - return (n > 1 ? trim(substr(l, 0, 15 - length(`-${n}`)), '-') + `-${n}` : l) + '.conf'; - } - return label(dev) + '.conf'; -} - /** * The junk a device sends is its own: within the preset's own ranges, the * count and sizes are shifted a little by the device (deterministic, so the @@ -423,7 +404,8 @@ export function client_config(m, dev) { name: dev.name, person: p.name, server: srv.name, - filename: conf_filename(m, p, dev), + // The file name is the tunnel's name in WireGuard apps: the server's, in the portal and the admin alike. + filename: `${tunnel_name(srv.name)}.conf`, conf: join('\n', lines) + '\n', has_private_key: dev.private_key != '', amnezia: { diff --git a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/core.uc b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/core.uc index f95b9a7..42a9889 100644 --- a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/core.uc +++ b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/core.uc @@ -81,7 +81,6 @@ export function load(c) { portal_alt: g('portal_alt'), portal_cert: g('portal_cert'), portal_key: g('portal_key'), - portal_title: g('portal_title'), // Where unknown portal links go instead of a bare 404 (empty = 404). portal_redirect: g('portal_redirect'), default_device_limit: g('default_device_limit'), diff --git a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/migrate.uc b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/migrate.uc index 270f1f6..d5016ac 100644 --- a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/migrate.uc +++ b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/migrate.uc @@ -57,6 +57,14 @@ export function uhttpd() { store.transact((w, m) => w.delete('dawnline', 'settings', 'portal_443')); }; +/** The portal names itself after the server now (the breadcrumb, the tab): its own title setting is gone. */ +function portal_title() { + let c = cursor(); + c.load('dawnline'); + if (c.get('dawnline', 'settings', 'portal_title') != null) + store.transact((w, m) => w.delete('dawnline', 'settings', 'portal_title')); +} + /* * Steps that cannot tell from the config whether they ran are recorded in * `settings.migrated` (a list), so they run exactly once. @@ -101,4 +109,5 @@ export function run() { word_codes(); uhttpd(); auto_mtu(); + portal_title(); }; diff --git a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/portal.uc b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/portal.uc index b036ae4..421bfdf 100644 --- a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/portal.uc +++ b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/portal.uc @@ -29,7 +29,7 @@ // that answers anything not shaped like a link (its not_found() twin). import { stat, readfile } from 'fs'; -import { read_json, write_json, ensure_dir, lock, unlock, cloudflare_ip, ip2int, today, tunnel_name, VERSION, RUN_DIR } from 'dawnline.util'; +import { read_json, write_json, ensure_dir, lock, unlock, cloudflare_ip, ip2int, today, VERSION, RUN_DIR } from 'dawnline.util'; import * as core from 'dawnline.core'; import * as awg from 'dawnline.awg'; import * as live from 'dawnline.live'; @@ -64,8 +64,8 @@ const NOT_READY = "Adding devices isn't available right now: the VPN server isn' // States the admin stopped the person in: the portal only shows, it changes nothing. const LOCKED = { - paused: 'Your access is paused by the admin.', - expired: 'Your access has ended. Ask the admin to extend it.', + paused: 'Your access is paused.', + expired: 'Your access has ended.', }; function html_escape(s) { @@ -241,11 +241,16 @@ function rate_action(r) { /* ---------- pages ---------- */ +/** What the page is called (the tab, the first crumb): the person's server, or Dawnline. */ +function place(r) { + return r.person ? r.m.servers[r.person.server]?.name || 'Dawnline' : 'Dawnline'; +} + /** The app shell; it reads the code from its own URL and sends it along. */ function shell(r) { // The build's time joins the version so every update busts the hour-long asset cache. let v = `?v=${VERSION}.${stat(`${ASSETS}/portal.js`)?.mtime ?? 0}`; - let base = r.base, title = r.title; + let base = r.base, title = place(r); headers(r, '200 OK', { 'Content-Type': 'text/html; charset=utf-8', 'Content-Security-Policy': "default-src 'none'; script-src 'self'; style-src 'self'; img-src 'self' data: blob:; font-src 'self'; " + @@ -338,17 +343,24 @@ function need_https(r) { send_json(r, '403 Forbidden', { error: 'Open this link over HTTPS to get the connection settings.', https_url: u }); } +/** The router's offset from UTC in minutes: the admin sets hours in its time, the page shows the visitor's. */ +function tz_offset() { + let t = time(); + return int((timegm(localtime(t)) - t) / 60); +} + /** Everything the page shows. */ function state(r) { let m = r.m, person = r.person; let usage = core.load_usage(); let v = view.person_view(m, person, usage, live.dump(m), view.states(m, usage)); v.state = person_state(m, person, usage); + // Day by day this month, for the page's chart (the admin's views have no use for it). + v.month_days = view.month_days(usage.people?.[person.id]); let srv = m.servers[person.server]; // The device this page was opened from, through the tunnel or beside it. let here = view.device_here(v.devices, r.peer); return { - title: r.title, person: v, here, server: { @@ -367,6 +379,8 @@ function state(r) { today: today(), // Its clock too: "last connected 3 min ago" is measured against it, not the phone's. now: time(), + // And its time zone: hours are set in the router's time, shown in the visitor's. + tz_offset: tz_offset(), version: VERSION, }; } @@ -383,15 +397,6 @@ function api_state(r) { send_json(r, '200 OK', state(r)); } -/** - * A configuration as the person gets it: the file, and so the tunnel the apps - * name after it, is the server's name. The admin's downloads keep the device - * in the name: one browser fetches many of them. - */ -function own_config(c) { - return c ? { ...c, filename: `${tunnel_name(c.server)}.conf` } : c; -} - function api_add(r) { need_open(r); need_https(r); @@ -401,7 +406,7 @@ function api_add(r) { rate_action(r); let res = guard(r, () => devices.add(r.person.id, b.name, b.kind, { by: 'portal', public_key: b.public_key })); reload(r); - send_json(r, '200 OK', { id: res.id, config: own_config(res.config), state: state(r) }); + send_json(r, '200 OK', { id: res.id, config: res.config, state: state(r) }); } function api_config(r, id) { @@ -409,7 +414,7 @@ function api_config(r, id) { need_open(r); need_https(r); awg.mark_issued(r.m, d.id); - send_json(r, '200 OK', own_config(awg.client_config(r.m, d))); + send_json(r, '200 OK', awg.client_config(r.m, d)); } /** POST /devices/ { action }: what each action does; the answer carries the new state. */ @@ -424,7 +429,7 @@ const ACTIONS = { if (!devices.ready()) fail(r, '503 Service Unavailable', NOT_READY); let config = guard(r, () => devices.reconnect(d.id, { by: 'portal', person: r.person.id, defer: d.address == r.peer })); - return { config: own_config(config) }; + return { config }; }, 'delete': (r, d, b) => { guard(r, () => devices.remove(d.id, { by: 'portal', person: r.person.id })); @@ -490,7 +495,6 @@ export function handle(io) { method: env.REQUEST_METHOD ?? 'GET', peer: env.REMOTE_ADDR ?? '', buckets: buckets(env), - title: m.settings.portal_title || 'Dawnline', // The port in the visitor's address bar ([v6]:port, name:port, or the default). hsts: https && (match(host, /:([0-9]+)$/)?.[1] ?? '443') == '443', person: null, diff --git a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/schema.uc b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/schema.uc index d7acdef..6709dbf 100644 --- a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/schema.uc +++ b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/schema.uc @@ -107,9 +107,9 @@ export function to_int(v, dflt, lo, hi) { /* ---------- the settings section ---------- */ /* - * type: bool | int | enum | host | hosts | url | file | domain | ipv4 | time | text | targets + * type: bool | int | enum | host | hosts | url | file | domain | ipv4 | time | targets * dflt: the parsed default; restart: the portal (uhttpd) must restart when it changes; - * min/max: ints and text length; values: enums; msg: the error for a bad value. + * min/max: ints; values: enums; msg: the error for a bad value. */ export const SETTINGS = { portal_enabled: { type: 'bool', dflt: false, restart: true }, @@ -117,7 +117,6 @@ export const SETTINGS = { portal_alt: { type: 'hosts', dflt: [], restart: true, msg: 'Other addresses must be hostnames or IP addresses.' }, portal_port: { type: 'int', dflt: 8443, min: 1, max: 65535, restart: true, msg: 'Choose a free port between 1 and 65535 (not 22, 53, 80 or 443).' }, - portal_title: { type: 'text', dflt: 'Dawnline', max: 64, msg: 'Portal title: up to 64 characters on one line.' }, portal_redirect: { type: 'url', dflt: '', msg: 'Redirect must be a full http:// or https:// address.' }, portal_cert: { type: 'file', dflt: '', restart: true }, portal_key: { type: 'file', dflt: '', restart: true }, @@ -226,10 +225,6 @@ export function validate(key, val) { if (!match(val, /^([01]?[0-9]|2[0-3]):[0-5][0-9]$/)) bad(spec, key); } - else if (t == 'text') { - if (ulength(val) > spec.max || match(val, /[[:cntrl:]]/)) - bad(spec, key); - } return val; }; diff --git a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/util.uc b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/util.uc index b51c63f..e5e2f55 100644 --- a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/util.uc +++ b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/util.uc @@ -4,7 +4,7 @@ import { open, readfile, writefile, rename, mkdir, stat, unlink, popen, lsdir } from 'fs'; -export const VERSION = '0.9.0'; +export const VERSION = '0.10.0'; /** GitHub repository with Dawnline releases (updates and the installer). */ export const REPO = 'tickcount/luci-app-dawnline'; export const RUN_DIR = '/var/run/dawnline'; diff --git a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/view.uc b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/view.uc index cf8e050..a697fa2 100644 --- a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/view.uc +++ b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/view.uc @@ -16,6 +16,11 @@ export function spark(rec, n) { return out; }; +/** Daily totals (rx+tx) from the 1st of this month to today, oldest first (the portal's month chart). */ +export function month_days(rec) { + return spark(rec, +substr(day_key_ago(0), 8, 2)); +}; + /** The device holds an older configuration than the one it would get now. */ function config_stale(m, d) { m._issued ??= awg.issued(); diff --git a/scripts/capture-screenshots.mjs b/scripts/capture-screenshots.mjs index 7fda3c1..a217797 100755 --- a/scripts/capture-screenshots.mjs +++ b/scripts/capture-screenshots.mjs @@ -10,11 +10,13 @@ // // scripts/capture-screenshots.mjs [--router https://router.lan] [--person id] // [--mask real=shown ...] [--name real=shown ...] -// [--only overview,people] +// [--only overview,people] [--demo] // // --mask replaces text on every page before the capture (a domain, a name); // --name does the same for a person's name in any case, and for their initials. // Public IPv4 addresses are always swapped for documentation ones (203.0.113.x). +// --demo shows a made-up cast instead of the router's people (scripts/screenshot-demo.mjs): +// the router's answers are rewritten in the headless browser on their way to the page. import { execFileSync, spawn } from 'node:child_process'; import { existsSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs'; @@ -22,12 +24,20 @@ import { tmpdir } from 'node:os'; import { dirname, join, resolve } from 'node:path'; import { fileURLToPath } from 'node:url'; import { createInterface } from 'node:readline'; +import { demoRpc } from './screenshot-demo.mjs'; const ROOT = resolve(dirname(fileURLToPath(import.meta.url)), '..'); const RAW = join(ROOT, 'docs', 'screenshots', 'raw'); const SCALE = 2; -const args = { router: 'https://outline.lan', person: '', mask: [], names: [], only: [] }; +const args = { + router: 'https://outline.lan', + person: '', + mask: [], + names: [], + only: [], + demo: false, +}; for (let i = 2; i < process.argv.length; i++) { const a = process.argv[i]; const v = () => process.argv[++i] ?? die(`${a} needs a value`); @@ -36,6 +46,7 @@ for (let i = 2; i < process.argv.length; i++) { else if (a === '--mask') args.mask.push(v().split('=', 2)); else if (a === '--name') args.names.push(v().split('=', 2)); else if (a === '--only') args.only = v().split(','); + else if (a === '--demo') args.demo = true; else die(`unknown argument ${a}`); } if ([...args.mask, ...args.names].some((m) => m.length !== 2 || !m[0])) die('--mask and --name take real=shown'); @@ -100,31 +111,26 @@ const SHOTS = [ url: (s) => `${LUCI}/person?id=${encodeURIComponent(s.person)}`, width: 1400, ready: '.dl-grid-person .dl-row', - // Down to the end of Access & limits; activity rows that would be cut are hidden. + // Where they connected from, on the map. + prep: `(() => { + const b = [...document.querySelectorAll('.dl-grid-person button')].find((x) => x.textContent.trim() === 'Show map'); + b?.click(); + })()`, + settle: 6000, + // Down to the end of Access & limits or of the map, whichever is lower; activity rows that would be cut are hidden. clip: `(() => { - const c = ${column}, cut = document.querySelector('.dl-grid-person > .dl-col:last-child').getBoundingClientRect().bottom + 40; + const c = ${column}, cols = document.querySelectorAll('.dl-grid-person > .dl-col'); + const places = cols[0].children[2]; + const cut = Math.max(cols[1].getBoundingClientRect().bottom, places ? places.getBoundingClientRect().bottom : 0) + 40; document.querySelectorAll('.dl-grid-person .dl-row').forEach((r) => { if (r.getBoundingClientRect().bottom > cut - 8) r.style.visibility = 'hidden'; }); + // Activity that would start right at the cut goes too, its heading with it. + const act = cols[0].children[3]; + if (act && act.getBoundingClientRect().top > cut - 120) act.style.visibility = 'hidden'; return { x: c.x, y: 0, width: c.w, height: cut }; })()`, }, - { - name: 'access', - url: () => `${LUCI}/server?section=access`, - width: 1400, - ready: 'section.dl-ifcard details', - // The home network card alone, its folded lists closed. - prep: `(() => { - const card = [...document.querySelectorAll('section.dl-ifcard')].find((s) => s.querySelector('details')); - card.querySelectorAll('details[open]').forEach((d) => (d.open = false)); - card.setAttribute('data-shot', ''); - })()`, - clip: `(() => { - const r = document.querySelector('[data-shot]').getBoundingClientRect(); - return { x: r.left - 12, y: r.top - 12, width: r.width + 24, height: r.height + 24 }; - })()`, - }, { name: 'portal', url: (s) => s.portal, @@ -156,7 +162,17 @@ const MASK = `((pairs, inits) => { if (!doc.has(m)) doc.set(m, '203.0.113.' + (24 + doc.size)); return doc.get(m); }; - const swap = (s) => pairs.reduce((t, [a, b]) => t.split(a).join(b), s).replace(/\\b\\d{1,3}(?:\\.\\d{1,3}){3}\\b/g, ip); + // IPv6 too, unless link-local or private (fe80::, fc00::/7). + const ip6 = (m) => { + if (/^(fe8|fe9|fea|feb|fc|fd)/i.test(m)) return m; + if (!doc.has(m)) doc.set(m, '2001:db8::' + (24 + doc.size)); + return doc.get(m); + }; + const swap = (s) => + pairs + .reduce((t, [a, b]) => t.split(a).join(b), s) + .replace(/\\b\\d{1,3}(?:\\.\\d{1,3}){3}\\b/g, ip) + .replace(/\\b(?:[0-9a-f]{1,4}:){3,7}[0-9a-f]{1,4}\\b/gi, ip6); const w = document.createTreeWalker(document.body, NodeFilter.SHOW_TEXT); for (let n; (n = w.nextNode()); ) { const ini = inits.find(([a]) => n.nodeValue.trim() === a); @@ -203,6 +219,7 @@ async function connect(wsUrl) { let id = 0; const pending = new Map(); const waiters = []; + const listeners = []; ws.onmessage = (m) => { const msg = JSON.parse(m.data); if (msg.id && pending.has(msg.id)) { @@ -210,6 +227,7 @@ async function connect(wsUrl) { pending.delete(msg.id); msg.error ? fail(new Error(msg.error.message)) : ok(msg.result); } else if (msg.method) { + for (const l of listeners.filter((x) => x.method === msg.method)) l.fn(msg.params); for (const w of waiters.filter((x) => x.method === msg.method)) { waiters.splice(waiters.indexOf(w), 1); w.ok(msg.params); @@ -222,7 +240,8 @@ async function connect(wsUrl) { ws.send(JSON.stringify({ id, method, params })); }); const waitFor = (method) => new Promise((ok) => waiters.push({ method, ok })); - return { send, waitFor, close: () => ws.close() }; + const on = (method, fn) => listeners.push({ method, fn }); + return { send, waitFor, on, close: () => ws.close() }; } const sleep = (ms) => new Promise((ok) => setTimeout(ok, ms)); @@ -255,10 +274,40 @@ async function main() { const pages = await (await fetch(`http://127.0.0.1:${port}/json/list`)).json(); const page = await connect(pages.find((p) => p.type === 'page').webSocketDebuggerUrl); await page.send('Page.enable'); - await page.send('Emulation.setEmulatedMedia', { features: [{ name: 'prefers-color-scheme', value: 'dark' }] }); + await page.send('Emulation.setEmulatedMedia', { + features: [{ name: 'prefers-color-scheme', value: 'dark' }], + }); + // The person shown on the Person page; known once People has loaded (or from --person). + const s = { person: args.person, portal: '' }; + if (args.demo) { + page.on('Fetch.requestPaused', async (e) => { + try { + const r = await page.send('Fetch.getResponseBody', { + requestId: e.requestId, + }); + const body = r.base64Encoded ? Buffer.from(r.body, 'base64').toString('utf8') : r.body; + const out = demoRpc(e.request.postData ?? '', body, s.person); + await page.send('Fetch.fulfillRequest', { + requestId: e.requestId, + responseCode: e.responseStatusCode ?? 200, + responseHeaders: e.responseHeaders ?? [], + body: Buffer.from(out, 'utf8').toString('base64'), + }); + } catch { + await page.send('Fetch.continueRequest', { requestId: e.requestId }).catch(() => {}); + } + }); + await page.send('Fetch.enable', { + patterns: [{ urlPattern: '*ubus*', requestStage: 'Response' }], + }); + } const evaluate = async (expression) => { - const r = await page.send('Runtime.evaluate', { expression, awaitPromise: true, returnByValue: true }); + const r = await page.send('Runtime.evaluate', { + expression, + awaitPromise: true, + returnByValue: true, + }); if (r.exceptionDetails) throw new Error(r.exceptionDetails.exception?.description ?? r.exceptionDetails.text); return r.result.value; }; @@ -276,7 +325,12 @@ async function main() { }; // A tall window: Outline scrolls #maincontent, not the page, so it must hold everything. const viewport = (width, height = 2600) => - page.send('Emulation.setDeviceMetricsOverride', { width, height, deviceScaleFactor: SCALE, mobile: false }); + page.send('Emulation.setDeviceMetricsOverride', { + width, + height, + deviceScaleFactor: SCALE, + mobile: false, + }); await viewport(1400); await go(`${args.router}/cgi-bin/luci/`); @@ -297,13 +351,10 @@ async function main() { } // The person to show (the first one on People unless --person) and their personal link. - const s = { person: args.person, portal: '' }; await go(`${LUCI}/server?section=people`); await waitSel('.dl-srvbody a[href*="dawnline/person"]'); if (!s.person) - s.person = await evaluate( - `new URL(document.querySelector('.dl-srvbody a[href*="dawnline/person"]').href).searchParams.get('id')`, - ); + s.person = await evaluate(`new URL(document.querySelector('.dl-srvbody a[href*="dawnline/person"]').href).searchParams.get('id')`); s.portal = await evaluate(`L.require('rpc').then((rpc) => rpc.declare({ object: 'luci.dawnline', method: 'person_links', params: ['id'] })(${JSON.stringify(s.person)})) .then((r) => r.link ?? r.links?.[0] ?? '')`); diff --git a/scripts/frame-screenshots.py b/scripts/frame-screenshots.py index eff3b32..eaeab92 100755 --- a/scripts/frame-screenshots.py +++ b/scripts/frame-screenshots.py @@ -1,12 +1,16 @@ #!/usr/bin/env python3 -"""Put the README screenshots into a browser window on a dawn gradient. +"""Frame the README screenshots the way the portal draws its own surfaces. Raw captures live in docs/screenshots/raw/.png at SCALE device pixels per CSS pixel (scripts/capture-screenshots.mjs takes them); the framed images -are written to docs/screenshots/.png at the same scale. Needs a +are written to docs/screenshots/.png at the same scale. Each page sits on +a panel like the portal's sheets (#121212, radius 36, 16px around it, the page +inside at radius 20) on the portal's own black. A shot in FLOWS gets its steps +in a row in front of the page's lower edge, numbered: sheets captured alone on +a transparent page (raw/.png, FLOW_MARGIN around each). Needs a Chromium-based browser for the headless render (BROWSER=/path/to/chrome, default: Brave or Chrome on macOS). -Run: scripts/frame-screenshots.py +Run: scripts/frame-screenshots.py [name ...] (all of them when no name is given) """ import os import shutil @@ -18,16 +22,18 @@ import tempfile ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) RAW = os.path.join(ROOT, 'docs', 'screenshots', 'raw') OUT = os.path.join(ROOT, 'docs', 'screenshots') +FONT = os.path.join(ROOT, 'package', 'luci-app-dawnline', 'root', 'usr', 'share', 'dawnline', 'portal', 'assets', + 'geist-latin-wght-normal.woff2') -# name -> what the address bar shows -SHOTS = { - 'overview': 'router.lan · Dawnline', - 'people': 'router.lan · Dawnline · People', - 'person': 'router.lan · Dawnline · Myata', - 'portal': 'vpn.example.com/kamiro-telosu-bavine', - 'access': 'router.lan · Dawnline · Home · Access', +SHOTS = ['overview', 'people', 'person', 'portal'] +# name -> the steps in front of its page, in order (raw captures). Taken with demo data, not on a router: +# adding a device there would add one. +FLOWS = { + 'portal': ['portal-add-1', 'portal-add-2', 'portal-add-3'], } -PAD_X, PAD_Y, BAR = 120, 96, 40 +PAD_X, PAD_Y, INSET = 96, 80, 16 # canvas around the panel; panel around the page +FLOW_MARGIN = (56, 40, 56, 72) # around a step's sheet in its capture: left, top, right, bottom +STEP_GAP, STEP_OVER, STEP_PAD = 28, 150, 120 # between steps; how far they reach over the page; canvas beside them SCALE = 2 CANDIDATES = [ @@ -39,26 +45,18 @@ CANDIDATES = [ ] TEMPLATE = """
- -{url} -
""" +body{{position:relative;background:#080808}} +.panel{{position:absolute;left:{px}px;top:{py}px;width:{pw}px;height:{ph}px; + border-radius:36px;background:#121212;box-shadow:inset 0 0 0 1px rgba(255,255,255,.05),0 30px 80px rgba(0,0,0,.5)}} +.page{{position:absolute;left:{x}px;top:{y}px;width:{iw}px;height:{ih}px;display:block;border-radius:20px; + box-shadow:0 0 0 1px rgba(255,255,255,.04)}} +.sheet{{position:absolute;display:block;filter:drop-shadow(0 24px 48px rgba(0,0,0,.6))}} +.n{{position:absolute;width:34px;height:34px;border-radius:50%;display:grid;place-items:center; + font:600 16px Geist,sans-serif;color:#ededed;background:#232323; + box-shadow:0 0 0 1px rgba(255,255,255,.12),0 6px 16px rgba(0,0,0,.5)}} +
{steps}""" def png_size(path): @@ -67,22 +65,53 @@ def png_size(path): return struct.unpack('>II', head[16:24]) +def layout(iw, ih, flow): + """Where the page goes and its steps in a row in front of its lower edge: (width, height, page x, page y, steps).""" + w, h = iw + 2 * (INSET + PAD_X), ih + 2 * (INSET + PAD_Y) + x, y = PAD_X + INSET, PAD_Y + INSET + if not flow: + return w, h, x, y, '' + ml, mt, mr, mb = FLOW_MARGIN + sizes = [tuple(v // SCALE for v in png_size(src)) for src in flow] + row = sum(pw - ml - mr for pw, _ in sizes) + STEP_GAP * (len(sizes) - 1) + w = max(w, row + 2 * STEP_PAD) + x = (w - iw) // 2 + top = y + ih - STEP_OVER + h = top + max(ph - mt - mb for _, ph in sizes) + PAD_Y + out, sx = [], (w - row) // 2 + for i, (src, (pw, ph)) in enumerate(zip(flow, sizes)): + out.append(f'') + out.append(f'{i + 1}') + sx += pw - ml - mr + STEP_GAP + return w, h, x, y, ''.join(out) + + def main(): browser = next((b for b in CANDIDATES if b and os.path.exists(b)), None) if not browser: sys.exit('No Chromium-based browser found; set BROWSER=/path/to/chrome') + only = sys.argv[1:] + unknown = [n for n in only if n not in SHOTS] + if unknown: + sys.exit(f'unknown screenshot {", ".join(unknown)} (one of {", ".join(SHOTS)})') tmp = tempfile.mkdtemp() - for name, url in SHOTS.items(): + for name in SHOTS: + if only and name not in only: + continue src = os.path.join(RAW, f'{name}.png') if not os.path.exists(src): print(f'skip {name}: no raw capture') continue iw, ih = (v // SCALE for v in png_size(src)) - w, h = iw + 2 * PAD_X, ih + BAR + 2 * PAD_Y + flow = [os.path.join(RAW, f'{step}.png') for step in FLOWS.get(name, [])] + if not all(os.path.exists(p) for p in flow): + print(f'{name}: a step is missing, the page alone') + flow = [] + w, h, x, y, steps = layout(iw, ih, flow) html = os.path.join(tmp, f'{name}.html') with open(html, 'w', encoding='utf-8') as f: - f.write(TEMPLATE.format(w=w, h=h, iw=iw, ih=ih, bar=BAR, url=url, src=src, - gw=int(w * .8), gh=int(h * .5), gw2=int(w * .6), gh2=int(h * .45))) + f.write(TEMPLATE.format(w=w, h=h, x=x, y=y, iw=iw, ih=ih, px=x - INSET, py=y - INSET, pw=iw + 2 * INSET, + ph=ih + 2 * INSET, src=src, font=FONT, steps=steps)) out = os.path.join(OUT, f'{name}.png') subprocess.run([browser, '--headless=new', '--disable-gpu', '--hide-scrollbars', '--allow-file-access-from-files', f'--force-device-scale-factor={SCALE}', f'--window-size={w},{h}', f'--screenshot={out}', f'file://{html}'], diff --git a/scripts/screenshot-demo.mjs b/scripts/screenshot-demo.mjs new file mode 100644 index 0000000..92a304e --- /dev/null +++ b/scripts/screenshot-demo.mjs @@ -0,0 +1,397 @@ +// Demo data for the README screenshots (scripts/capture-screenshots.mjs --demo): +// the router's own answers (luci.dawnline status, events) with a made-up cast in +// place of its people, devices, places and activity, in the states the +// screenshots should show (online, ending soon, over the limit, paused, ended, +// outside their hours). The router's ids stay, so every page keeps working; it +// is only ever read. + +// The admin counts in binary units: "100 GB" is 100 GiB. +const GB = 2 ** 30; +const MIN = 60; +const HOUR = 3600; +const DAY = 86400; + +/** Where the cast connects from: [lat, lon, country, cc, network]. */ +const CITIES = { + Lisbon: [38.7223, -9.1393, 'Portugal', 'PT', 'MEO'], + Porto: [41.1579, -8.6291, 'Portugal', 'PT', 'NOS'], + Sintra: [38.8029, -9.3817, 'Portugal', 'PT', 'Vodafone Portugal'], + Madrid: [40.4168, -3.7038, 'Spain', 'ES', 'Telefonica de Espana'], + Barcelona: [41.3874, 2.1686, 'Spain', 'ES', 'Orange Espagne'], + Berlin: [52.52, 13.405, 'Germany', 'DE', 'Deutsche Telekom'], + Milan: [45.4642, 9.19, 'Italy', 'IT', 'TIM'], + Amsterdam: [52.3676, 4.9041, 'Netherlands', 'NL', 'KPN'], + Paris: [48.8566, 2.3522, 'France', 'FR', 'Orange'], + London: [51.5072, -0.1276, 'United Kingdom', 'GB', 'BT'], + Stockholm: [59.3293, 18.0686, 'Sweden', 'SE', 'Telia'], +}; +/** The router's own place. */ +const HOME = 'Lisbon'; +/** Shared at home (Access): what a Home-only person can be limited to. */ +const SERVICES = [ + { id: 'demo-nas', name: 'NAS', address: '10.0.1.20', ports: ['445', '5000'] }, + { + id: 'demo-ha', + name: 'Home Assistant', + address: '10.0.1.30', + ports: ['8123'], + }, +]; +/** How busy each day of the week is, Monday first. */ +const WEEK = [0.9, 1.15, 0.8, 1.05, 1.3, 0.75, 1.1]; + +/** + * Who the screenshots show, the --person first (the Person page), each with + * their city. A device: [name, kind, when it was last seen, GB this month, + * earlier places as 'City:days ago']; when: 'online', 'mins:N', 'hours:N', + * 'days:N', 'never', 'stale' (settings changed since), 'disabled'. Its last + * place is the person's city unless `at` names another. + */ +export const CAST = [ + { + name: 'Lena Ortiz', + city: 'Lisbon', + limit: 4, + quota: 100, + used: 38.6, + note: 'Family', + devices: [ + ['iPhone 16', 'phone', 'online', 14.2, ['Sintra:3', 'Porto:9', 'Madrid:16']], + ['MacBook Pro', 'computer', 'hours:3', 21.9, ['Berlin:12']], + ['iPad Air', 'tablet', 'never', 0], + ], + added: [['iPad Air', 2, 'portal']], + }, + { + name: 'Marco Rossi', + city: 'Milan', + ends: 4, + devices: [ + ['Pixel 9', 'phone', 'online', 6.4, ['Barcelona:8']], + ['ThinkPad X1', 'computer', 'days:1', 12.8], + ], + }, + { + name: 'Yuki Tanaka', + city: 'Amsterdam', + state: 'quota', + quota: 20, + used: 20.4, + devices: [ + ['Galaxy S24', 'phone', 'hours:6', 14.1, ['Paris:5']], + ['Living room TV', 'other', 'stale', 6.3], + ], + }, + { + name: 'Sam Okafor', + city: 'London', + state: 'paused', + paused: 3, + devices: [ + ['Gaming PC', 'computer', 'days:9', 3.1], + ['Steam Deck', 'other', 'disabled', 0], + ], + }, + { + name: 'Nora Lindqvist', + city: 'Stockholm', + state: 'expired', + ends: -3, + devices: [['iPhone 13 mini', 'phone', 'days:4', 1.2]], + }, + { + name: 'Mia Ortiz', + city: 'Lisbon', + state: 'hours', + hours: '07:00-21:00', + limit: 1, + devices: [['Fire HD 10', 'tablet', 'hours:11', 2.6]], + }, +]; + +const slug = (s) => + s + .toLowerCase() + .replace(/[^a-z0-9]+/g, '-') + .replace(/^-|-$/g, ''); +const date = (t) => new Date(t * 1000).toISOString().slice(0, 10); +const seen = (when, now) => { + const [k, n] = when.split(':'); + const v = +n || 0; + return ( + { + online: now - 40, + mins: now - v * MIN, + hours: now - v * HOUR, + days: now - v * DAY, + stale: now - 2 * DAY, + disabled: now - 41 * DAY, + }[k] ?? 0 + ); +}; +/** A week of daily totals that adds up to about a quarter of the month, today last (nothing before it was first seen). */ +const week = (gb, last, now) => + [0.8, 1.3, 0.6, 1.1, 1.6, 0.9, 1].map((f, i) => (!gb || now - (6 - i) * DAY < last - DAY ? 0 : Math.round(((gb / 4) * f * GB) / 7))); +let ipN = 10; +/** A documentation address (the capture swaps public addresses for these anyway). */ +const ip = () => `203.0.113.${ipN++}`; +const where = (city) => `${city} · ${CITIES[city][4]}`; + +/** What the last status made of the router's ids, for the calls that come after it (events, usage). */ +const demo = { events: [], people: new Map(), days: [], now: 0 }; + +/** + * Daily traffic over `days` (oldest first) for `gb` this month: busier some days of the week, today + * only partly gone. Each day's [rx, tx] in bytes, rx (from the devices) about an eighth. + */ +function daily(days, gb, now) { + const month = days[days.length - 1].slice(0, 7); + const w = days.map((d, i) => { + const wd = (new Date(`${d}T12:00:00Z`).getUTCDay() + 6) % 7; + const today = i === days.length - 1 ? ((now % DAY) / DAY) * 0.9 + 0.1 : 1; + return WEEK[wd] * (0.85 + ((i * 37) % 11) / 30) * today; + }); + const inMonth = w.reduce((s, x, i) => s + (days[i].startsWith(month) ? x : 0), 0) || 1; + return w.map((x) => { + const b = (x / inMonth) * gb * GB; + return [Math.round(b * 0.12), Math.round(b * 0.88)]; + }); +} +const usage = (days, pairs) => days.map((day, i) => ({ day, rx: pairs[i][0], tx: pairs[i][1] })); + +/** The places a device was at, oldest first: [city, ts, ip]. */ +function trail(c, d, hs, now) { + if (!hs) return []; + const earlier = (d[4] ?? []).map((s) => { + const [city, ago] = s.split(':'); + return [city, now - +ago * DAY - 5 * HOUR, ip()]; + }); + return [...earlier.reverse(), [c.city, hs, ip()]]; +} + +function demoStatus(st, first) { + const now = st.now; + ipN = 10; + const real = [...st.people].sort((a, b) => (a.id === first ? -1 : b.id === first ? 1 : a.id < b.id ? -1 : 1)); + const spare = real.flatMap((p) => p.devices); + const points = []; + const events = []; + const people = CAST.map((c, i) => { + const base = real[i] ?? { + ...real[real.length - 1], + id: `demo-${i}`, + devices: [], + }; + const state = c.state ?? 'active'; + const devices = c.devices.map((cd, j) => { + const [name, kind, when, gb] = cd; + const tpl = base.devices[j] ?? { + ...spare[j % spare.length], + id: `${base.id}-demo-${j}`, + address: `10.8.0.${200 + i * 8 + j}`, + }; + const hs = when === 'never' ? 0 : seen(when, now); + const online = when === 'online' && !['paused', 'expired', 'hours'].includes(state); + const places = trail(c, cd, hs, now); + places.forEach(([city, ts, addr], k) => { + const [lat, lon, country, cc, org] = CITIES[city]; + const current = online && k === places.length - 1; + points.push({ + person: base.id, + device: tpl.id, + ip: addr, + ts, + online: current, + lat, + lon, + city, + country, + cc, + asn: 0, + org, + }); + const ev = { + person: base.id, + device: tpl.id, + pname: c.name, + dname: name, + dkind: kind, + }; + // Online now: connected a while ago (the handshake renews every few minutes); otherwise on for a couple of hours. + events.push({ + ...ev, + type: 'connect', + detail: addr, + where: where(city), + ts: current ? now - 95 * MIN - j * 13 * MIN : ts - 2 * HOUR, + }); + if (!current) events.push({ ...ev, type: 'disconnect', ts }); + }); + // A phone in hand switches between Wi-Fi and mobile data. + if (online && kind === 'phone') { + const [, , addr] = places[places.length - 1]; + events.push({ + person: base.id, + device: tpl.id, + pname: c.name, + dname: name, + dkind: kind, + type: 'roam', + detail: `${ip()} → ${addr}`, + ts: now - 25 * MIN, + }); + } + return { + ...tpl, + name, + kind, + online, + active: online, + handshake: hs, + endpoint: places.length ? places[places.length - 1][2] : '', + config_stale: when === 'stale', + disabled: when === 'disabled', + month: [Math.round(gb * 0.12 * GB), Math.round(gb * 0.88 * GB)], + total: [Math.round(gb * 0.3 * GB), Math.round(gb * 2.2 * GB)], + spark: week(gb, hs, now), + hostname: hs ? `${slug(name)}.${slug(c.name.split(' ')[0])}.lan` : '', + }; + }); + for (const [name, ago, by] of c.added ?? []) { + const d = devices.find((x) => x.name === name); + if (d) + events.push({ + person: base.id, + device: d.id, + pname: c.name, + dname: name, + dkind: d.kind, + type: 'device_added', + detail: name, + by, + ts: now - ago * DAY, + }); + } + if (c.paused) + events.push({ + person: base.id, + pname: c.name, + type: 'paused', + by: 'admin', + ts: now - c.paused * DAY, + }); + const month = devices.reduce((s, d) => [s[0] + d.month[0], s[1] + d.month[1]], [0, 0]); + const live = devices.some((d) => d.online); + demo.people.set(base.id, { + devices: devices.map((d, j) => [d.id, c.devices[j][3]]), + }); + return { + ...base, + name: c.name, + state, + paused: state === 'paused', + hours: c.hours ?? '', + note: c.note ?? '', + expires: c.ends !== undefined ? date(now + c.ends * DAY) : '', + device_limit: c.limit ?? Math.max(3, devices.length), + quota_gb: c.quota ?? 0, + quota_period: 'month', + quota_limit: (c.quota ?? 0) * GB, + quota_used: Math.round((c.used ?? (month[0] + month[1]) / GB) * GB), + bonus_gb: 0, + month, + total: [month[0] * 3, month[1] * 3], + online: devices.filter((d) => d.online).length, + last_seen: Math.max(0, ...devices.map((d) => d.handshake)), + rate: (base.rate ?? []).map(([t], k) => [t, live ? 12000 + ((k * 7919) % 9000) : 0, live ? 120000 + ((k * 104729) % 90000) : 0]), + devices, + }; + }); + const devices = people.flatMap((p) => p.devices); + const month = people.reduce((s, p) => [s[0] + p.month[0], s[1] + p.month[1]], [0, 0]); + events.sort((a, b) => a.ts - b.ts); + demo.events = events; + points.sort((a, b) => b.ts - a.ts); + demo.now = now; + demo.days = (st.series ?? []).map((x) => x.day); + if (!demo.days.length) for (let k = 29; k >= 0; k--) demo.days.push(date(now - k * DAY)); + const all = CAST.reduce((s, c) => s + c.devices.reduce((t, d) => t + d[3], 0), 0); + const series = usage(demo.days, daily(demo.days, all, now)); + const today = series[series.length - 1]; + const [lat, lon, country, cc, org] = CITIES[HOME]; + return { + ...st, + people, + totals: { + ...st.totals, + people: people.length, + devices: devices.length, + online: devices.filter((d) => d.online).length, + active: people.filter((p) => p.state === 'active').length, + today: [today.rx, today.tx], + month, + }, + series, + servers: st.servers.map((x) => ({ ...x, series })), + services: st.services?.length ? st.services : SERVICES, + geo: st.geo && { + ...st.geo, + home: { lat, lon, city: HOME, country, cc, asn: 0, org }, + points, + }, + events: events.slice(-60), + }; +} + +/** + * A ubus JSON-RPC exchange (LuCI batches calls into one request) with the + * luci.dawnline answers made into the demo; anything else as it came. + */ +export function demoRpc(request, response, first) { + let req; + let res; + try { + req = JSON.parse(request); + res = JSON.parse(response); + } catch { + return response; + } + const calls = new Map((Array.isArray(req) ? req : [req]).map((c) => [c.id, c.params ?? []])); + const fix = (r) => { + const [, object, method, args] = calls.get(r?.id) ?? []; + const data = r?.result?.[1]; + if (object !== 'luci.dawnline' || !data || typeof data !== 'object') return r; + if (method === 'status' && Array.isArray(data.people)) return { ...r, result: [r.result[0], demoStatus(data, first)] }; + if (method === 'person_usage' && demo.people.has(args?.id) && demo.days.length) { + const devs = demo.people.get(args.id).devices ?? []; + const per = Object.fromEntries(devs.map(([id, gb]) => [id, daily(demo.days, gb, demo.now)])); + const sum = demo.days.map((_, i) => devs.reduce((s, [id]) => [s[0] + per[id][i][0], s[1] + per[id][i][1]], [0, 0])); + const devices = Object.fromEntries(devs.map(([id]) => [id, usage(demo.days, per[id])])); + return { + ...r, + result: [r.result[0], { ...data, person: usage(demo.days, sum), devices }], + }; + } + // Every check passes: the screenshots show Dawnline, not this router's own setup. + if (method === 'health' && Array.isArray(data.checks)) + return { + ...r, + result: [ + r.result[0], + { + ...data, + checks: data.checks.map((c) => (c.status === 'warn' || c.status === 'error' ? { ...c, status: 'ok', problem: null } : c)), + }, + ], + }; + if (method === 'events' && Array.isArray(data.events)) { + const mine = demo.events.filter((e) => !args?.person || e.person === args.person); + return { + ...r, + result: [r.result[0], { ...data, events: mine, total: mine.length }], + }; + } + return r; + }; + return JSON.stringify(Array.isArray(res) ? res.map(fix) : fix(res)); +} diff --git a/tests/ucode/fixtures/config/dawnline b/tests/ucode/fixtures/config/dawnline index 80150ac..2e1b2de 100644 --- a/tests/ucode/fixtures/config/dawnline +++ b/tests/ucode/fixtures/config/dawnline @@ -1,11 +1,12 @@ # Test fixture: a small installation (one server, two people, one device). -# migrate.test.uc expects bob's random code, the server's stored MTU 1380 and -# uhttpd's error_page: the one-time steps remove them. +# migrate.test.uc expects bob's random code, the server's stored MTU 1380, +# the old portal title and uhttpd's error_page: the one-time steps remove them. config settings 'settings' option portal_enabled '1' option portal_port '8443' option portal_host 'vpn.example.com' + option portal_title 'My VPN' option log_connections '0' option update_interval '7d' list update_targets 'app' diff --git a/tests/ucode/migrate.test.uc b/tests/ucode/migrate.test.uc index 66a2cd0..5f2daa7 100644 --- a/tests/ucode/migrate.test.uc +++ b/tests/ucode/migrate.test.uc @@ -16,6 +16,7 @@ test('before: the fixture holds the old state', () => { let c = conf('dawnline'); eq(c.get('dawnline', 'bob', 'code'), 'XyZ12345', 'random code'); eq(c.get('dawnline', 'main', 'mtu'), '1380', 'stored MTU'); + eq(c.get('dawnline', 'settings', 'portal_title'), 'My VPN', 'a portal title'); eq(conf('uhttpd').get('uhttpd', 'main', 'error_page'), '/cgi-bin/dawnline-portal', 'portal as error page'); }); @@ -27,6 +28,7 @@ test('run: the steps change what they must', () => { eq(c.get('dawnline', 'main', 'mtu'), null, 'MTU is automatic'); eq(c.get('dawnline', 'main', 'subnet'), '10.9.0.0/29', 'the rest of the server stays'); eq(c.get('dawnline', 'settings', 'portal_443'), null, 'no portal_443'); + eq(c.get('dawnline', 'settings', 'portal_title'), null, 'no portal title'); eq(conf('uhttpd').get('uhttpd', 'main', 'error_page'), null, 'error page gone'); eq(conf('uhttpd').get('uhttpd', 'main', 'home'), '/www', 'the rest of uhttpd stays'); eq(stat('/etc/config/dawnline').perm, { setuid: false, setgid: false, sticky: false, diff --git a/tests/ucode/schema.test.uc b/tests/ucode/schema.test.uc index 6bf2252..f2af829 100644 --- a/tests/ucode/schema.test.uc +++ b/tests/ucode/schema.test.uc @@ -77,13 +77,6 @@ test('validate: time', () => { throws(() => schema.validate('update_time', '23:60'), /HH:MM/, 'minute 60'); }); -test('validate: text', () => { - eq(schema.validate('portal_title', 'My VPN'), 'My VPN', 'plain'); - eq(schema.validate('portal_title', replace(sprintf('%64s', ''), ' ', 'a')), replace(sprintf('%64s', ''), ' ', 'a'), '64 characters'); - throws(() => schema.validate('portal_title', replace(sprintf('%65s', ''), ' ', 'a')), /64 characters/, '65 characters'); - throws(() => schema.validate('portal_title', 'a\nb'), /64 characters/, 'control character'); -}); - test('validate: targets', () => { eq(schema.validate('update_targets', [ 'app', 'bogus', 'app', 'amneziawg' ]), [ 'app', 'amneziawg' ], 'known ones, once'); eq(schema.validate('update_targets', []), [ 'none' ], 'empty is a choice'); @@ -110,8 +103,6 @@ test('get', () => { eq(schema.get({ home_dns_fallback: 'none' }, 'home_dns_fallback'), '', 'none reads as empty'); eq(schema.get({}, 'home_dns_fallback'), '1.1.1.1', 'missing ipv4'); eq(schema.get({ home_dns_fallback: '300.1.1.1' }, 'home_dns_fallback'), '1.1.1.1', 'bad ipv4'); - eq(schema.get({}, 'portal_title'), 'Dawnline', 'missing text'); - eq(schema.get({ portal_title: '' }, 'portal_title'), 'Dawnline', 'empty text'); eq(schema.get({ portal_host: 'vpn.example.com' }, 'portal_host'), 'vpn.example.com', 'host passes through'); eq(schema.get({ other: 'raw' }, 'other'), 'raw', 'unknown key is the raw value'); eq(schema.get(null, 'portal_port'), 8443, 'no section'); diff --git a/tests/ucode/view.test.uc b/tests/ucode/view.test.uc index 0617b76..b868375 100644 --- a/tests/ucode/view.test.uc +++ b/tests/ucode/view.test.uc @@ -1,5 +1,6 @@ -// dawnline.view: which device a portal page was opened from. +// dawnline.view: which device a portal page was opened from, and the usage series it draws. import * as view from 'dawnline.view'; +import { day_key_ago } from 'dawnline.util'; const devs = [ { id: 'd_1', address: '10.0.0.2', online: true, endpoint: '203.0.113.7' }, @@ -18,3 +19,20 @@ test('device_here', () => { eq(view.device_here(devs, ''), null, 'no address'); eq(view.device_here([ { id: 'd_5', address: '10.0.0.6', online: true, endpoint: '' } ], ''), null, 'no address, no endpoint'); }); + +test('month_days', () => { + let n = +substr(day_key_ago(0), 8, 2); + let days = {}; + // On the 1st, today is the 1st: then only today's own value. + if (n > 1) + days[day_key_ago(n - 1)] = [ 1, 2 ]; + days[day_key_ago(0)] = [ 5, 7 ]; + // Last month's last day stays out of this month's chart. + days[day_key_ago(n)] = [ 100, 100 ]; + let s = view.month_days({ days }); + eq(length(s), n, 'one bar a day, from the 1st to today'); + eq(s[n - 1], 12, 'today last, received and sent together'); + eq(s[0], n > 1 ? 3 : 12, 'the 1st first'); + eq(length(view.month_days(null)), n, 'no usage yet: zeros'); + eq(view.month_days(null)[0], 0, 'a day without traffic is zero'); +}); diff --git a/web/package-lock.json b/web/package-lock.json index b1486af..b22464e 100644 --- a/web/package-lock.json +++ b/web/package-lock.json @@ -1,12 +1,12 @@ { "name": "dawnline-web", - "version": "0.9.0", + "version": "0.10.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "dawnline-web", - "version": "0.9.0", + "version": "0.10.0", "license": "MIT", "dependencies": { "qrcode-generator": "1.4.4" diff --git a/web/package.json b/web/package.json index 6975f97..32bdb3d 100644 --- a/web/package.json +++ b/web/package.json @@ -1,6 +1,6 @@ { "name": "dawnline-web", - "version": "0.9.0", + "version": "0.10.0", "private": true, "license": "MIT", "type": "module", diff --git a/web/src/admin/cores/awg.ts b/web/src/admin/cores/awg.ts index dea02f3..0cb21d6 100644 --- a/web/src/admin/cores/awg.ts +++ b/web/src/admin/cores/awg.ts @@ -10,9 +10,9 @@ import { confirmDialog } from '../ui/modal'; import { copyText, downloadFile } from '../ui/files'; import { attempt, notify } from '../ui/toast'; import { input } from '../ui/controls'; -import { callout, card, firstBad, group, liveRow, row, svg } from '../ui/layout'; +import { callout, card, firstBad, group, liveRow, row } from '../ui/layout'; +import { qrCode } from '../ui/qr'; import { keepaliveHelp, mtuHelp, portHelp, type PortHold } from '../netcheck'; -import { qrSvg } from '../../shared/qr'; import { vpnKey } from '../../shared/vpnkey'; import { icon } from '../../shared/icons'; import { methodInfo, methodPicker, type Method, defaultMethod, legacyTitle } from '../disguise'; @@ -171,7 +171,7 @@ function fileCard(cfg: AwgConfig): HTMLElement { E('span', { class: 'dl-filecard-ic' }, '.conf'), E('span', { class: 'dl-stack' }, [ E('span', { class: 'dl-mono dl-ellipsis' }, cfg.filename), - E('span', { class: 'dl-sub' }, `AmneziaWG · ${size} bytes · import it in the app`), + E('span', { class: 'dl-sub' }, `AmneziaWG · ${size} bytes`), ]), button([icon('download'), ' Download'], () => downloadFile(cfg.filename, cfg.conf, 'application/octet-stream'), 'positive'), ]), @@ -218,7 +218,7 @@ export async function connectBlock(cfg: AwgConfig, initial: 'file' | 'key' | 'qr const panes: Record Node> = { qr: () => E('div', { class: 'dl-qr-pane' }, [ - svg(qrSvg(cfg.conf), 'dl-qr'), + qrCode(cfg.conf), E( 'span', { class: 'dl-sub' }, @@ -437,6 +437,6 @@ export const awg: Core = { overviewTile, connectBlock, qrText: (cfg) => cfg.conf, - appKey: { label: 'Copy AmneziaVPN key', make: (cfg) => vpnKey(cfg, cfg.server) }, - file: { label: 'Download .conf', make: (cfg) => ({ name: cfg.filename, text: cfg.conf }) }, + appKey: { label: 'Copy AmneziaVPN config', make: (cfg) => vpnKey(cfg, cfg.server) }, + file: { label: 'Download AmneziaWG config', make: (cfg) => ({ name: cfg.filename, text: cfg.conf }) }, }; diff --git a/web/src/admin/device.ts b/web/src/admin/device.ts index 112dd0b..f1c916a 100644 --- a/web/src/admin/device.ts +++ b/web/src/admin/device.ts @@ -11,10 +11,10 @@ import { copyText, downloadFile } from './ui/files'; import { dropdown, type MenuItem } from './ui/menu'; import { drawer } from './ui/drawer'; import { attempt, notify } from './ui/toast'; -import { liveField, svg } from './ui/layout'; +import { liveField } from './ui/layout'; +import { qrCode } from './ui/qr'; import { nameHelp } from './netcheck'; import { deviceStatus } from './ui/badges'; -import { qrSvg } from '../shared/qr'; import { ago, bytes, isoDay, KIND_LABEL, KINDS, todayOf } from '../shared/format'; import { icon } from '../shared/icons'; import { eventBy } from './events/model'; @@ -420,7 +420,7 @@ export function quickMenu(anchor: HTMLElement, p: Person, d: Device, o: DeviceOp modal( `${d.name} · QR code`, E('div', { class: 'dl-qr-pane' }, [ - svg(qrSvg(core.qrText(c)), 'dl-qr'), + qrCode(core.qrText(c)), E( 'span', { class: 'dl-sub' }, diff --git a/web/src/admin/map.ts b/web/src/admin/map.ts index 9b22dcc..f7090ac 100644 --- a/web/src/admin/map.ts +++ b/web/src/admin/map.ts @@ -10,6 +10,7 @@ import { E } from './e'; import { ago, initials } from '../shared/format'; import { icon, iconSvg } from '../shared/icons'; import { onNavigate } from './ui/nav'; +import { isDark } from './ui/theme'; import { placeKey, shimmerOpacity } from './places/model'; // mapcn requires maplibre-gl ^6 (the globe projection came with 5): an ES module, its worker beside it. @@ -71,12 +72,6 @@ function loadMapLibre(host: HTMLElement): Promise { return loading; } -function isDark(): boolean { - const attr = document.documentElement.getAttribute('data-darkmode'); - if (attr != null) return attr === 'true'; - return window.matchMedia?.('(prefers-color-scheme: dark)').matches ?? false; -} - /** A click on a marker brings the map at least this close (a city). */ const CLICK_ZOOM = 10; /** Places closer than this are one city: a click shows them together at city level. */ diff --git a/web/src/admin/netcheck.ts b/web/src/admin/netcheck.ts index 3f7fc43..f53790d 100644 --- a/web/src/admin/netcheck.ts +++ b/web/src/admin/netcheck.ts @@ -244,13 +244,6 @@ export function urlHelp(s: string): Help { return { text: 'Wrong links are sent there instead of a “Not found”.', bad: false }; } -/** The portal's title: up to 64 characters on one line. */ -export function titleHelp(s: string): Help { - if (chars(s) > 64) return { text: `Up to 64 characters (${chars(s)} now).`, bad: true }; - if (/[\u0000-\u001f\u007f]/.test(s)) return { text: 'One line, please.', bad: true }; - return { text: 'Shown in the browser tab and at the top of the portal.', bad: false }; -} - /** The home domain for device hostnames (schema domain): lowercase letters, digits, dashes, dots. */ export function domainHelp(s: string, example = 'phone.myata'): Help { const t = s.trim(); diff --git a/web/src/admin/pages/settings/portal.ts b/web/src/admin/pages/settings/portal.ts index e63b43c..417ea3f 100644 --- a/web/src/admin/pages/settings/portal.ts +++ b/web/src/admin/pages/settings/portal.ts @@ -7,7 +7,7 @@ import { button } from '../../ui/button'; import { cancelButton, closeModal, modal } from '../../ui/modal'; import { input, isOn, sw } from '../../ui/controls'; import { firstBad, group, liveRow, needRow, row } from '../../ui/layout'; -import { hostHelp, portalPortHelp, titleHelp, urlHelp } from '../../netcheck'; +import { hostHelp, portalPortHelp, urlHelp } from '../../netcheck'; import { icon } from '../../../shared/icons'; import { fmtDay } from '../../../shared/format'; import { installMissing } from '../../pkgs'; @@ -29,7 +29,6 @@ export function portalCard(host: SettingsHost): HTMLElement { const c = host.d.cert; const pOn = sw(eff.portal_enabled, 'Enable portal'); const port = input(s.portal_port, { placeholder: '8443', inputmode: 'numeric', class: 'cbi-input-text dl-w-port' }); - const title = input(s.portal_title, { placeholder: 'Dawnline' }); const redirect = input(s.portal_redirect, { placeholder: 'Show “Not found”', class: 'cbi-input-text dl-mono' }); const other = input('', { placeholder: 'vpn.example.com or an IP', 'aria-label': 'Other address' }); const isIp = (h: string) => /^\d{1,3}(\.\d{1,3}){3}$/.test(h); @@ -279,7 +278,6 @@ export function portalCard(host: SettingsHost): HTMLElement { portalPortHelp(port.value.trim() === '' ? eff.portal_port : Number(port.value), host.d.tcp_taken ?? [], picked.some(isIp)), ); refreshPort = listenRow.refresh; - const titleRow = liveRow('Title', title, () => titleHelp(title.value)); const redirectRow = liveRow('Unknown links', redirect, () => urlHelp(redirect.value)); const custom = !!(s.portal_cert && s.portal_key); const kind = !c ? 'Portal is off' : custom ? 'Your files' : c.self_signed ? 'Self-signed' : 'Let’s Encrypt'; @@ -371,7 +369,7 @@ export function portalCard(host: SettingsHost): HTMLElement { E('span', { class: 'dl-muted' }, 'A page where each person adds and manages their devices with their personal link.'), httpsRow ? E('div', { class: 'dl-list' }, [httpsRow]) : '', group('network', 'Port', 'How the portal listens (80 and 443 stay free)', [listenRow]), - group('edit', 'Appearance', 'What people see', [titleRow, redirectRow]), + group('edit', 'Appearance', 'What people see', [redirectRow]), group('link', 'Addresses', 'Pick one or more; the first is the main link', [ opts, E('div', { class: 'dl-stack gap8' }, [ @@ -388,7 +386,7 @@ export function portalCard(host: SettingsHost): HTMLElement { 'Save', () => { // The help lines already say what is wrong: do not send it anyway. - const bad = firstBad([listenRow, titleRow, redirectRow]); + const bad = firstBad([listenRow, redirectRow]); if (bad) { notify(bad, 'warning'); return; @@ -399,7 +397,6 @@ export function portalCard(host: SettingsHost): HTMLElement { portal_host: picked[0] ?? '', portal_alt: picked.slice(1), portal_port: port.value, - portal_title: title.value, portal_redirect: redirect.value.trim(), }, 'Saved', diff --git a/web/src/admin/styles/portal-settings.css b/web/src/admin/styles/portal-settings.css index c2f47ba..a5df265 100644 --- a/web/src/admin/styles/portal-settings.css +++ b/web/src/admin/styles/portal-settings.css @@ -47,7 +47,9 @@ .dl-pgrid.flush { padding: 0; grid-template-columns: repeat(2, minmax(0, 1fr)); } @media (max-width: 640px) { .dl-pgrid.flush { grid-template-columns: minmax(0, 1fr); } } .dl-qr-pane { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; } -.dl-qr { width: min(280px, 72vw); aspect-ratio: 1; background: #fff; padding: 8px; border-radius: 12px; box-shadow: inset 0 0 0 1px var(--dl-line); } +.dl-qr { width: min(280px, 72vw); aspect-ratio: 1; background: #0a0a0a; border-radius: 18px; overflow: hidden; } +/* The portal's round look: its own card colour (black at night, white by day), the light one ringed. */ +.dl-qr.light { background: #fff; box-shadow: inset 0 0 0 1px var(--dl-line); } .dl-qr svg { display: block; width: 100%; height: 100%; } .dl-filecard { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 14px; background: var(--dl-soft); min-width: 0; } .dl-filecard > .dl-stack { flex: 1; min-width: 0; } diff --git a/web/src/admin/ui/qr.ts b/web/src/admin/ui/qr.ts new file mode 100644 index 0000000..c114140 --- /dev/null +++ b/web/src/admin/ui/qr.ts @@ -0,0 +1,11 @@ +// A device's QR code, in the portal's round look: light dots on black on the +// dark theme, the same dots dark on white on a light one (shared/qr.ts). + +import { qrSvg } from '../../shared/qr'; +import { svg } from './layout'; +import { isDark } from './theme'; + +export function qrCode(text: string): HTMLElement { + const dark = isDark(); + return svg(qrSvg(text, 3, true, dark ? 'night' : 'day'), `dl-qr${dark ? '' : ' light'}`); +} diff --git a/web/src/admin/ui/theme.ts b/web/src/admin/ui/theme.ts new file mode 100644 index 0000000..56828b9 --- /dev/null +++ b/web/src/admin/ui/theme.ts @@ -0,0 +1,9 @@ +// Which theme the admin shows: Outline switches light and dark in place with +// html[data-darkmode]; without it, the system's choice. Read where something +// is drawn in the theme's own colours (the map, QR codes). + +export function isDark(): boolean { + const attr = document.documentElement.getAttribute('data-darkmode'); + if (attr != null) return attr === 'true'; + return window.matchMedia?.('(prefers-color-scheme: dark)').matches ?? false; +} diff --git a/web/src/portal/api.ts b/web/src/portal/api.ts new file mode 100644 index 0000000..02ddd63 --- /dev/null +++ b/web/src/portal/api.ts @@ -0,0 +1,39 @@ +// The portal's API: one fetch per call to the router, under the personal link. +// No sessions and no cookies: the code in the path is the key. A refused call +// throws an ApiError carrying the status and, for a plain-HTTP visitor, the +// HTTPS twin of the link. + +import { base } from './state'; + +export class ApiError extends Error { + constructor( + public status: number, + message: string, + /** The HTTPS twin of this link, when the answer was "not over plain HTTP". */ + public httpsUrl?: string, + ) { + super(message); + } +} + +export async function call(path: string, body?: unknown): Promise { + const res = await fetch(`${base}/api/${path}`, { + method: body === undefined ? 'GET' : 'POST', + credentials: 'omit', + headers: body === undefined ? {} : { 'Content-Type': 'application/json' }, + body: body === undefined ? undefined : JSON.stringify(body), + cache: 'no-store', + }); + // Any shape: an error answer may be empty or not JSON at all. + let data: { error?: string; https_url?: string } | null = null; + try { + data = await res.json(); + } catch { + /* empty */ + } + if (!res.ok) throw new ApiError(res.status, data?.error ?? `Request failed (${res.status})`, data?.https_url || undefined); + return data as T; +} + +/** The link stopped working (code regenerated, person removed). */ +export const gone = (e: unknown) => e instanceof ApiError && (e.status === 404 || e.status === 401); diff --git a/web/src/portal/days.ts b/web/src/portal/days.ts new file mode 100644 index 0000000..df36020 --- /dev/null +++ b/web/src/portal/days.ts @@ -0,0 +1,78 @@ +// The days and hours the access section draws, as plain data: the weeks left +// as a calendar, the admin's hours moved into the visitor's time, the month as +// one bar a day. Pure (no DOM): page/access.ts draws it; dates are the +// router's (`today` from its state), never the browser's calendar. + +import { addDays, parseDay } from '../shared/format'; + +export type CellKind = 'past' | 'today' | 'left' | 'end' | 'after'; +export interface Cell { + day: string; + kind: CellKind; +} + +/** + * The weeks from this one to the one the access ends in, Monday first, one + * cell a day: gone, today, left, the last day, after it. Null when that would + * take more than `maxWeeks` (far ends: the number of days says it alone). + */ +export function calendar(today: string, end: string, maxWeeks = 10): Cell[] | null { + const dow = (d: string) => (parseDay(d).getDay() + 6) % 7; + const first = addDays(today, -dow(today)); + const last = addDays(end, 6 - dow(end)); + const cells: Cell[] = []; + for (let d = first; d <= last; d = addDays(d, 1)) { + cells.push({ day: d, kind: d < today ? 'past' : d === today ? 'today' : d < end ? 'left' : d === end ? 'end' : 'after' }); + if (cells.length > maxWeeks * 7) return null; + } + return cells; +} + +const HM = /^([01]?\d|2[0-3]):([0-5]\d)$/; +/** "08:30" → 510, or null for anything else. */ +export function minuteOf(t: string): number | null { + const m = HM.exec(t.trim()); + return m ? +m[1] * 60 + +m[2] : null; +} +const wrap = (m: number) => ((m % 1440) + 1440) % 1440; +export const clockOf = (m: number) => `${String(Math.floor(wrap(m) / 60)).padStart(2, '0')}:${String(wrap(m) % 60).padStart(2, '0')}`; + +export interface Hours { + /** Start and end, minutes after midnight in the visitor's time. */ + from: number; + to: number; + /** In the visitor's time (the router told its offset), or the router's own. */ + yours: boolean; +} + +/** + * The admin's hours ("08:00-22:00", router time) in the visitor's time. The + * offsets are minutes east of UTC; without the router's offset the hours stay + * in the router's time. Null when they cannot be read. + */ +export function hoursFor(hours: string, routerOffset: number | undefined, visitorOffset: number): Hours | null { + const [a, b] = hours.split('-'); + const from = minuteOf(a ?? ''); + const to = minuteOf(b ?? ''); + if (from == null || to == null) return null; + const shift = routerOffset == null ? 0 : visitorOffset - routerOffset; + return { from: wrap(from + shift), to: wrap(to + shift), yours: routerOffset != null }; +} + +/** The window as stretches of the day: one, or two when it runs past midnight. */ +export const stretches = (h: Hours): [number, number][] => + h.from < h.to + ? [[h.from, h.to]] + : [ + [h.from, 1440], + [0, h.to], + ]; + +/** The moment `nowSec` (epoch seconds) as minutes after midnight at `offset` minutes east of UTC. */ +export const minuteAt = (nowSec: number, offset: number) => wrap(Math.floor(nowSec / 60) + offset); + +/** The days of today's month: how many, and which one today is (1-based). */ +export function monthOf(today: string): { days: number; day: number } { + const d = parseDay(today); + return { days: new Date(d.getFullYear(), d.getMonth() + 1, 0).getDate(), day: d.getDate() }; +} diff --git a/web/src/portal/dom.ts b/web/src/portal/dom.ts index d86190b..c389103 100644 --- a/web/src/portal/dom.ts +++ b/web/src/portal/dom.ts @@ -1,12 +1,22 @@ -// The portal's two DOM builders: an element from a tag, attributes and -// children, and an icon. No framework; shared by the page (main.ts) and the -// pieces drawn outside it (waitpath.ts). +// The portal's DOM builders: an element from a tag, attributes and children; +// an icon; markup that is ours (icons, glass icons, QR codes) as an element. +// No framework. The page's CSP forbids inline styles, so nothing here writes a +// `style` attribute: styles set from script go through `el.style`. import { iconSvg } from '../shared/icons'; export type Attrs = Record; export type Kid = Node | string | null | undefined | false | Kid[]; +function append(el: Node, kids: Kid[]) { + const add = (c: Kid) => { + if (c == null || c === false) return; + if (Array.isArray(c)) c.forEach(add); + else el.appendChild(typeof c === 'string' ? document.createTextNode(c) : c); + }; + kids.forEach(add); +} + export function h(tag: string, attrs: Attrs = {}, ...kids: Kid[]): HTMLElement { const el = document.createElement(tag); for (const [k, v] of Object.entries(attrs)) { @@ -16,17 +26,22 @@ export function h(tag: string, attrs: Attrs = {}, ...kids: Kid[]): HTMLElement { else if (v === true) el.setAttribute(k, ''); else el.setAttribute(k, String(v)); } - const add = (c: Kid) => { - if (c == null || c === false) return; - if (Array.isArray(c)) c.forEach(add); - else el.appendChild(typeof c === 'string' ? document.createTextNode(c) : c); - }; - kids.forEach(add); + append(el, kids); return el; } -export function ic(name: string): HTMLElement { - const s = h('span', { class: 'ic' }); - s.innerHTML = iconSvg(name, 'ic-svg'); - return s; +/** Replace what `el` holds with `kids` (nested lists flattened, empty ones skipped). */ +export function put(el: HTMLElement, ...kids: Kid[]) { + el.replaceChildren(); + append(el, kids); } + +/** Our own markup (never anything a visitor or the router typed) as one element. */ +export function markup(html: string): Element { + const t = document.createElement('template'); + t.innerHTML = html.trim(); + return t.content.firstElementChild!; +} + +/** A line icon (`svg.i`, stroke = currentColor), sized by CSS. */ +export const ic = (name: string, cls = 'i'): Element => markup(iconSvg(name, cls)); diff --git a/web/src/portal/flows/add.ts b/web/src/portal/flows/add.ts new file mode 100644 index 0000000..8942931 --- /dev/null +++ b/web/src/portal/flows/add.ts @@ -0,0 +1,214 @@ +// Adding a device: what it is (four kinds; phones and tablets are one choice, +// the same apps and the same smaller packets) and its name, guessed from the +// browser when it is this device; then straight on to its set-up. Or the page +// opens on the device itself, from a code, ready to add it there. + +import type { ClientConfig, Kind } from '../../shared/types'; +import { KIND_LABEL } from '../../shared/format'; +import { ApiError, call } from '../api'; +import { h, ic } from '../dom'; +import { EASE_OUT, play } from '../motion'; +import { addLink } from '../setup'; +import { pageUrl, repaint, setState, state, type State } from '../state'; +import { linkRow, qrBox } from '../ui/codes'; +import { once, toast } from '../ui/feedback'; +import { glass } from '../ui/glass'; +import { morphText } from '../ui/morph'; +import { go, head, hint, openSheet, sub, type View } from '../ui/sheet'; +import { secureFirst, showSecure } from './secure'; +import { continueSetup } from './setup-view'; + +// Best guess at the device this page is open on (the browser never tells its real name). +const UA = navigator.userAgent; +const IPAD = /iPad/.test(UA) || (/Macintosh/.test(UA) && navigator.maxTouchPoints > 1); + +function guessKind(): Kind { + if (IPAD || /Tablet/i.test(UA) || (/Android/.test(UA) && !/Mobile/.test(UA))) return 'tablet'; + if (/Android|iPhone|Mobile/i.test(UA)) return 'phone'; + return 'computer'; +} + +/** Samsung model codes → names people know (S and A series; the code stays in brackets). */ +const GALAXY: [RegExp, string][] = [ + [/^SM-S93/, 'Galaxy S25'], + [/^SM-S92/, 'Galaxy S24'], + [/^SM-S91/, 'Galaxy S23'], + [/^SM-S90/, 'Galaxy S22'], + [/^SM-G99/, 'Galaxy S21'], + [/^SM-F9/, 'Galaxy Z Fold'], + [/^SM-F7/, 'Galaxy Z Flip'], + [/^SM-A5/, 'Galaxy A5x'], + [/^SM-A3/, 'Galaxy A3x'], + [/^SM-X/, 'Galaxy Tab'], +]; + +/** Android model from Client Hints (Chrome); filled in shortly after the page loads. */ +let MODEL = ''; +const modelReady: Promise = (async () => { + const uad = (navigator as Navigator & { userAgentData?: { getHighEntropyValues(h: string[]): Promise<{ model?: string }> } }) + .userAgentData; + if (!uad || !/Android/.test(UA)) return ''; + try { + const m = ((await uad.getHighEntropyValues(['model'])).model ?? '').trim(); + if (!m || m === 'K') return ''; + const g = GALAXY.find(([re]) => re.test(m)); + MODEL = g ? `${g[1]} (${m})` : /^SM-/.test(m) ? `Galaxy ${m}` : m; + } catch { + /* not offered */ + } + return MODEL; +})(); + +function guessName(kind: Kind): string { + if (/iPhone/.test(UA)) return 'iPhone'; + if (IPAD) return 'iPad'; + if (/Android/.test(UA)) return MODEL || (kind === 'tablet' ? 'Android tablet' : 'Android phone'); + if (/CrOS/.test(UA)) return 'Chromebook'; + if (/Mac OS X/.test(UA)) return 'Mac'; + if (/Windows/.test(UA)) return 'Windows PC'; + if (/Linux/.test(UA)) return 'Linux PC'; + return KIND_LABEL[kind]; +} + +/* + * Phones and tablets are one choice. The device is still kept as a phone or a + * tablet (the lines say "the tablet"): on the device itself the browser tells + * which; picked from elsewhere it is a phone. + */ +type Pick = 'computer' | 'mobile' | 'router' | 'other'; +const PICK_LABEL: Record = { computer: 'PC', mobile: 'Mobile', router: 'Router', other: 'Other' }; +const pickOf = (k: Kind): Pick => (k === 'phone' || k === 'tablet' ? 'mobile' : k); +const kindOf = (p: Pick): Kind => (p !== 'mobile' ? p : guessKind() === 'tablet' ? 'tablet' : 'phone'); + +export function startAdd() { + const st = state(); + if (!st || st.locked) return; + if (!st.can_add) return toast(`You have reached your limit of ${st.person.device_limit} devices`, true); + if (secureFirst()) return; + openSheet(vAdd); +} + +function vAdd(): View { + const st = state()!; + const p = st.person; + // The kinds this router takes, as the four choices. + const picks = (['computer', 'mobile', 'router', 'other'] as Pick[]).filter((k) => st.kinds.some((x) => pickOf(x) === k)); + let pick: Pick = picks.includes(pickOf(guessKind())) ? pickOf(guessKind()) : picks[0]; + let edited = false; + const taken = new Set(p.devices.map((d) => d.name.toLowerCase())); + const suggest = (k: Pick) => { + const n = k === pickOf(guessKind()) ? guessName(kindOf(k)) : k === 'mobile' ? 'Phone' : KIND_LABEL[k]; + if (!taken.has(n.toLowerCase())) return n; + for (let i = 2; i < 20; i++) if (!taken.has(`${n} ${i}`.toLowerCase())) return `${n} ${i}`; + return n; + }; + + const kinds = h('div', { class: 'kinds', role: 'radiogroup', 'aria-label': 'What is it?' }); + kinds.style.setProperty('--n', String(picks.length)); + const tiles = picks.map((k) => { + const t = h( + 'button', + { type: 'button', class: 'kind', role: 'radio', 'aria-label': PICK_LABEL[k], onclick: () => choose(k) }, + h('span', { class: 'kind-tile' }, glass(k, 'blue')), + h('span', { class: 'kind-lbl' }, PICK_LABEL[k]), + ); + kinds.appendChild(t); + return t; + }); + const input = h('input', { type: 'text', maxlength: 48, required: true, 'aria-label': 'Name', autocomplete: 'off' }) as HTMLInputElement; + const goBtn = h('button', { class: 'go ready', type: 'submit', 'aria-label': 'Create connection' }, ic('arrow')) as HTMLButtonElement; + const err = h('p', { class: 'hint bad-t', hidden: true }); + const say = (msg: string) => { + // Already showing: its words change in place. + if (!err.hidden) return morphText(err, msg); + err.textContent = msg; + err.hidden = false; + play( + err, + [ + { opacity: 0, transform: 'translateY(-4px)' }, + { opacity: 1, transform: 'none' }, + ], + { duration: 220, easing: EASE_OUT }, + ); + }; + input.value = suggest(pick); + input.addEventListener('input', () => { + edited = true; + goBtn.classList.toggle('ready', !!input.value.trim()); + err.hidden = true; + }); + // The Android model arrives a moment later: use it unless they started typing. + void modelReady.then(() => { + if (!edited && pick === pickOf(guessKind())) input.value = suggest(pick); + }); + // The picked tile rings itself where it stands (the ring does not travel between tiles). + function choose(k: Pick) { + pick = k; + tiles.forEach((t, i) => { + const on = picks[i] === k; + t.classList.toggle('on', on); + t.setAttribute('aria-checked', String(on)); + }); + if (!edited) { + input.value = suggest(k); + goBtn.classList.add('ready'); + } + } + choose(pick); + + const form = h('form', { class: 'field', autocomplete: 'off' }, input, goBtn); + form.addEventListener('submit', (e) => { + e.preventDefault(); + const name = input.value.trim(); + if (!name) return; + if (taken.has(name.toLowerCase())) return say('You already have a device with this name.'); + void once(goBtn, async () => { + try { + const r = await call<{ id: string; config: ClientConfig; state: State }>('devices', { name, kind: kindOf(pick) }); + setState(r.state); + repaint({ pop: r.id }); + const dev = r.state.person.devices.find((d) => d.id === r.id)!; + await continueSetup(dev, r.config); + } catch (er) { + if (er instanceof ApiError && er.httpsUrl) return showSecure(er.httpsUrl); + say((er as Error).message); + } + }); + }); + const viaLink = h( + 'button', + { type: 'button', class: 'btn soft block', onclick: () => go(vLink) }, + ic('qr'), + h('span', {}, 'Add it from the device'), + ); + const free = p.device_limit - p.devices.length; + const el = h( + 'div', + { class: 'view' }, + head('Add a device'), + sub(`${free} of ${p.device_limit} slots free`), + kinds, + hint('Phones and tablets get a smaller packet size that suits mobile networks.'), + form, + err, + h('div', { class: 'or' }, 'OR'), + viaLink, + ); + el.querySelector('.hint')!.classList.add('kinds-note'); + return { el, label: 'Add a device' }; +} + +/** The page on the device itself, ready to add it: the link as a code for its camera, and as text. */ +function vLink(): View { + const link = addLink(pageUrl()); + const el = h( + 'div', + { class: 'view' }, + head('Open on the device', { back: true }), + sub('Point its camera at the code: your page opens there with this device ready to add.'), + qrBox(link, true), + linkRow(link), + ); + return { el, label: 'Open on the device' }; +} diff --git a/web/src/portal/flows/device-actions.ts b/web/src/portal/flows/device-actions.ts new file mode 100644 index 0000000..4cc541a --- /dev/null +++ b/web/src/portal/flows/device-actions.ts @@ -0,0 +1,142 @@ +// A device's own actions from its ⋯ menu: Rename, Reconnect (new keys, then +// the set-up of the new ones) and Remove. A question comes before what cannot +// be undone; the action's button stays busy until the router answers. + +import type { ClientConfig, Device } from '../../shared/types'; +import { call } from '../api'; +import { h, ic } from '../dom'; +import { EASE_IN, play } from '../motion'; +import { repaint, setState, state, type State } from '../state'; +import { once, toast } from '../ui/feedback'; +import { glass, type Tone } from '../ui/glass'; +import { closeSheet, head, onClosed, openSheet, type View } from '../ui/sheet'; +import { secureFirst } from './secure'; +import { continueSetup } from './setup-view'; + +/** A question before something that cannot be undone: the action's icon in its colour, what happens, Cancel and the action. */ +function ask(o: { icon: string; tone: Tone; title: string; text: string; action: string; cls: string; run: () => Promise }): View { + const ok = h( + 'button', + { type: 'button', class: `btn ${o.cls}`, onclick: (ev: Event) => once(ev.currentTarget as HTMLButtonElement, o.run) }, + // In an element: a busy button blurs its content away for the orb (ui/busy.ts). + h('span', {}, o.action), + ) as HTMLButtonElement; + const el = h( + 'div', + { class: 'view' }, + h( + 'div', + { class: 'center-col ask' }, + glass(o.icon, o.tone, 'gi xl'), + h('h3', {}, o.title), + h('p', {}, o.text), + h('div', { class: 'btnrow' }, h('button', { type: 'button', class: 'btn soft', onclick: () => closeSheet() }, 'Cancel'), ok), + ), + ); + return { el, label: o.title, asks: true }; +} + +export function rename(d: Device) { + openSheet(() => { + const input = h('input', { type: 'text', maxlength: 48, 'aria-label': 'Device name', autocomplete: 'off' }) as HTMLInputElement; + input.value = d.name; + const save = h('button', { class: 'go', type: 'submit', 'aria-label': 'Save' }, ic('check')) as HTMLButtonElement; + input.addEventListener('input', () => save.classList.toggle('ready', !!input.value.trim() && input.value.trim() !== d.name)); + const form = h('form', { class: 'field', autocomplete: 'off' }, input, save); + form.addEventListener('submit', (e) => { + e.preventDefault(); + const name = input.value.trim(); + if (!name || name === d.name) return; + void once(save, async () => { + try { + const r = await call<{ state: State }>(`devices/${d.id}`, { action: 'rename', name }); + setState(r.state); + onClosed(() => { + repaint(); + toast('Renamed'); + }); + closeSheet(); + } catch (er) { + toast((er as Error).message, true); + } + }); + }); + setTimeout(() => input.select(), 60); + return { el: h('div', { class: 'view' }, head(`Rename ${d.name}`), form), label: `Rename ${d.name}` }; + }); +} + +/** + * Set a device up from scratch (a new phone, the app reinstalled, settings the + * admin changed): new keys, so what it holds stops working; it shows "Not set + * up yet" until it connects with the new configuration, which the sheet goes on to. + */ +export function reconnect(d: Device) { + if (secureFirst()) return; + const here = state()?.here === d.id; + openSheet(() => + ask({ + icon: 'refresh', + tone: 'orange', + title: `Reconnect ${d.name}?`, + text: here + ? 'It gets new keys. This device is connected through its current settings: it disconnects a few seconds after you confirm. Add the new ones that open next.' + : 'It gets new keys and its current settings stop working. Set it up again with the new ones that open next.', + action: 'Reconnect', + cls: 'accent', + run: async () => { + try { + const r = await call<{ config: ClientConfig; state: State }>(`devices/${d.id}`, { action: 'reconnect' }); + setState(r.state); + repaint(); + await continueSetup(r.state.person.devices.find((x) => x.id === d.id) ?? { ...d, handshake: 0 }, r.config); + } catch (er) { + toast((er as Error).message, true); + } + }, + }), + ); +} + +export function removeDevice(d: Device) { + openSheet(() => + ask({ + icon: 'trash', + tone: 'red', + title: `Remove ${d.name}?`, + text: 'Its connection stops working at once. You can add it again later.', + action: 'Remove', + cls: 'red', + run: async () => { + try { + const r = await call<{ state: State }>(`devices/${d.id}`, { action: 'delete' }); + setState(r.state); + // The card goes first; the rest then glide into its place. + onClosed(() => { + const card = document.querySelector(`.dev[data-id="${CSS.escape(d.id)}"]`); + const done = () => { + repaint(); + toast('Device removed'); + }; + if (!card) return done(); + play( + card, + [ + { opacity: 1, transform: 'none', filter: 'none' }, + { opacity: 0, transform: 'scale(.9)', filter: 'blur(6px)' }, + ], + { + duration: 220, + easing: EASE_IN, + fill: 'forwards', + }, + ).onfinish = done; + }); + closeSheet(); + } catch (er) { + toast((er as Error).message, true); + } + }, + }), + ); +} diff --git a/web/src/portal/flows/page-code.ts b/web/src/portal/flows/page-code.ts new file mode 100644 index 0000000..3cddd5a --- /dev/null +++ b/web/src/portal/flows/page-code.ts @@ -0,0 +1,22 @@ +// This page on another device: from the breadcrumb, its link as a code for a +// phone's camera, and the link itself to copy or share. + +import { h } from '../dom'; +import { pageUrl } from '../state'; +import { linkRow, qrBox } from '../ui/codes'; +import { head, openSheet, sub } from '../ui/sheet'; + +export function showPageCode() { + openSheet(() => { + const url = pageUrl(); + const el = h( + 'div', + { class: 'view' }, + head('Open on another device'), + sub('Point its camera at the code: this page opens there.'), + qrBox(url, true), + linkRow(url), + ); + return { el, label: 'Open on another device' }; + }); +} diff --git a/web/src/portal/flows/secure.ts b/web/src/portal/flows/secure.ts new file mode 100644 index 0000000..35bb8f1 --- /dev/null +++ b/web/src/portal/flows/secure.ts @@ -0,0 +1,39 @@ +// A plain-HTTP link (an IP address) shows the page, but keys only travel +// encrypted: adding or setting up a device sends the visitor to the HTTPS twin +// first. Its certificate is the router's own, so the browser warns once; say so. + +import { h, ic } from '../dom'; +import { httpsTwin } from '../state'; +import { glass } from '../ui/glass'; +import { head, hint, openSheet, sub, type View } from '../ui/sheet'; + +function vSecure(url: string): View { + const el = h( + 'div', + { class: 'view' }, + head('Open the link securely'), + sub('Connection settings only travel encrypted'), + h( + 'div', + { class: 'center-col secure' }, + glass('lock', 'blue', 'gi xl'), + h('p', {}, 'This page is open without encryption. To add or set up a device, open the same link over HTTPS:'), + ), + // The same tab: the HTTPS page replaces this one. + h('a', { class: 'btn accent block', href: url }, ic('lock'), h('span', {}, 'Open securely')), + hint('The browser may warn that the certificate is not trusted: it is this router’s own. Choose to continue (“Advanced” → “Proceed”).'), + ); + el.lastElementChild!.classList.add('secure-note'); + return { el, label: 'Open the link securely' }; +} + +/** The HTTPS twin's sheet (here, or the one the router named in a refusal). */ +export const showSecure = (url: string) => openSheet(() => vSecure(url)); + +/** Over plain HTTP: the twin's sheet instead, and true (the caller stops). */ +export function secureFirst(): boolean { + const twin = httpsTwin(); + if (!twin) return false; + showSecure(twin); + return true; +} diff --git a/web/src/portal/flows/setup-parts.ts b/web/src/portal/flows/setup-parts.ts new file mode 100644 index 0000000..b59167d --- /dev/null +++ b/web/src/portal/flows/setup-parts.ts @@ -0,0 +1,408 @@ +// The pieces the set-up sheet is made of: store badges, the step that adds the +// connection (a link, the share sheet, a key or a file, as the app and the +// device allow), the panel that sends the connection to another device, the +// .conf for a router, the Download / Copy keys beside × and the line saying +// where an app scans a code. The rules behind them are setup.ts. + +import type { ClientConfig, Device } from '../../shared/types'; +import { h, ic, type Kid } from '../dom'; +import { EASE_OUT, POP, SMOOTH, play } from '../motion'; +import { + APP_NAME, + PLATFORM_LABEL, + importSteps, + keyFileName, + opensKeyLinks, + routerStore, + scanPath, + storeFor, + type AppId, + type Platform, + type Store, +} from '../setup'; +import { accordion } from '../ui/accordion'; +import { copy, download, sendFile, shareFile } from '../ui/feedback'; +import { glass } from '../ui/glass'; +import { menuLine, morphText, setText } from '../ui/morph'; +import { hint } from '../ui/sheet'; + +export const APP_ICON: Record = { vpn: 'amnezia', awg: 'amneziawg', wg: 'wireguard' }; + +/** The app a device was set up with last time, so the sheet reopens on it. */ +const memo = (d: Device) => `dl.app.${d.id}`; +export function recallApp(d: Device): AppId | null { + try { + const v = localStorage.getItem(memo(d)); + return v === 'vpn' || v === 'awg' || v === 'wg' ? v : null; + } catch { + return null; + } +} +export function rememberApp(d: Device, app: AppId) { + try { + localStorage.setItem(memo(d), app); + } catch { + /* private mode */ + } +} + +/** What the steps work with: the device, its configuration, the key, and the choices made. */ +export interface SetupCtx { + d: Device; + cfg: ClientConfig; + key: string; + /** The platform this page is open on. */ + pf: Platform; + /** "the phone": the device in a sentence. */ + there: string; + app(): AppId; + /** The page is open on the device being set up. */ + same(): boolean; +} + +/** + * A badge: the mark in a tile, two lines, a chevron (an action) or the open + * mark (a store page, in a new tab). `primary`: the one thing to tap in step 2. + */ +export function badge( + st: { href?: string; top: string; main: string; mark: string; onclick?: (ev: Event) => void }, + primary = false, +): HTMLElement { + const inner = [ + h('span', { class: 'b-ic' }, ic(st.mark)), + h('span', { class: 'b-t' }, h('span', { class: 'b-top' }, st.top), h('span', { class: 'b-main' }, st.main)), + ic(st.onclick || st.href?.startsWith('vpn:') ? 'chevron' : 'open'), + ]; + const cls = `badge${primary ? ' primary' : ''}`; + if (st.onclick) return h('button', { type: 'button', class: cls, onclick: st.onclick }, inner); + // A vpn:// key opens the app in place: no new tab. + const app = st.href?.startsWith('vpn:'); + return h('a', { class: cls, href: st.href, target: app ? null : '_blank', rel: 'noopener noreferrer' }, inner); +} + +/** Where the app comes from: the store (and, on Android, the APK beside it), or a line to go and get it. */ +export function storeBlock(app: AppId, os: Platform, router: boolean): Kid[] { + const st: Store | null = router ? routerStore(app) : storeFor(app, os); + if (!st) return [hint(`Get ${APP_NAME[app]} on the ${PLATFORM_LABEL[os]} and come back here.`)]; + // Android: the store can fail (no Google Play, or it hides the app), so the APK sits beside it. + if (st.alt) return [h('div', { class: 'badges2' }, badge(st), badge(st.alt)), hint(st.alt.why)]; + return [badge(st)]; +} + +const howto = (steps: [string, string][]) => + h( + 'ol', + { class: 'howto' }, + steps.map(([text, bold]) => h('li', {}, text.replace(/ → $/, ' ›'), bold ? [' ', h('b', {}, bold)] : null)), + ); + +const linkBtn = (label: string, run: (ev: Event) => void) => h('button', { type: 'button', onclick: run }, label); + +/** Step 2: a link for AmneziaVPN, the file for the others, in the words of where they go. */ +export function connectKids(c: SetupCtx): Kid[] { + const app = c.app(); + const name = APP_NAME[app]; + const hereHandheld = c.pf === 'ios' || c.pf === 'android'; + // On the phone being set up, a link opens AmneziaVPN only on Android; an + // iPhone takes the key as a .vpn file from the share sheet. + const inHand = c.same() && hereHandheld; + const copyKey = (ev: Event) => copy(c.key, 'Key copied', ev.currentTarget); + const send = app === 'vpn' && inHand && !opensKeyLinks(c.pf) ? shareFile(keyFileName(c.cfg.filename), c.key) : null; + if (app === 'vpn' && inHand && (opensKeyLinks(c.pf) || send)) + return [ + send + ? badge({ top: 'Then come back here and tap', main: 'Send to AmneziaVPN', mark: 'amnezia', onclick: () => void send() }, true) + : badge({ href: c.key, top: 'Then come back here and tap', main: 'Open in AmneziaVPN', mark: 'amnezia' }, true), + hint( + send ? 'Pick AmneziaVPN in the share sheet. Not there? ' : 'Nothing opened? ', + linkBtn('Copy the key', copyKey), + ' and add it in the app.', + ), + ]; + if (app === 'vpn') + return [ + badge({ top: 'The connection as one key', main: 'Copy the key', mark: 'copy', onclick: copyKey }, true), + howto([ + ['Open AmneziaVPN', ''], + ['Add server › ', 'Insert key'], + ['Paste the key and connect', ''], + ]), + ]; + const share = hereHandheld ? shareFile(c.cfg.filename, c.cfg.conf) : null; + return [ + share + ? badge( + { + top: c.same() ? `Straight into ${name}` : `Send it to the ${c.there}`, + main: 'Share the file', + mark: 'share', + onclick: () => void share(), + }, + true, + ) + : badge( + { + top: 'Then import it in the app', + main: 'Download the file', + mark: 'download', + onclick: () => download(c.cfg.filename, c.cfg.conf), + }, + true, + ), + // In the words of the app where the file goes: the phone in hand, or the computer's system. + howto(importSteps(app, c.pf, c.cfg.filename, !!share && c.same())), + ]; +} + +/** A computer set up from elsewhere: the connection to send there, as the key or the file. */ +export function sendKids(c: SetupCtx): Kid[] { + const app = c.app(); + const btn = (icon: string, label: string, run: (ev: Event) => void) => + h('button', { type: 'button', class: 'btn soft sm', onclick: run }, ic(icon), h('span', { class: 'lbl' }, label)); + if (app === 'vpn') { + const file = keyFileName(c.cfg.filename); + const share = !!shareFile(file, c.key); + return [ + h('p', { class: 'desc' }, `Send it to the ${c.there} in a message or a note, then in AmneziaVPN: Add server › Insert key.`), + h( + 'div', + { class: 'btnrow2' }, + btn('copy', 'Copy the key', (ev) => copy(c.key, 'Key copied', ev.currentTarget)), + btn(share ? 'share' : 'download', share ? 'Share as a file' : 'Download the key', () => sendFile(file, c.key)), + ), + ]; + } + const share = !!shareFile(c.cfg.filename, c.cfg.conf); + return [ + h('p', { class: 'desc' }, `Send it to the ${c.there}, then import `, h('b', {}, c.cfg.filename), ` in ${APP_NAME[app]}.`), + h( + 'div', + { class: 'btnrow2' }, + btn(share ? 'share' : 'download', share ? 'Share the file' : 'Download the file', () => sendFile(c.cfg.filename, c.cfg.conf)), + btn('copy', 'Copy the configuration', (ev) => copy(c.cfg.conf, 'Configuration copied', ev.currentTarget)), + ), + ]; +} + +/** One configuration line, highlighted; private and preshared keys masked unless shown. */ +function confLine(line: string, reveal: boolean): Node { + if (/^\s*\[.+\]\s*$/.test(line)) return h('span', { class: 'sec' }, line); + const m = /^(\s*[A-Za-z0-9]+\s*=)\s*(.*)$/.exec(line); + if (!m) return document.createTextNode(line); + const secret = /^(\s*)(PrivateKey|PresharedKey)\b/.test(line); + return h('span', {}, h('span', { class: 'k' }, m[1]), ' ', secret && !reveal ? h('span', { class: 'mask' }, '••••••••••••••••') : m[2]); +} + +/** The .conf for a router: a file card to download (or share), and the configuration folded, its keys hidden. */ +export function filePane(cfg: ClientConfig): HTMLElement { + let reveal = false; + const pre = h('pre', { class: 'conf' }); + const paint = () => + pre.replaceChildren(...cfg.conf.split('\n').flatMap((l, i) => (i ? ['\n', confLine(l, reveal)] : [confLine(l, reveal)]))); + paint(); + const share = !!shareFile(cfg.filename, cfg.conf); + const eye = h( + 'button', + { + type: 'button', + class: 'btn soft sm', + onclick: () => { + reveal = !reveal; + eye.replaceChildren(ic(reveal ? 'x' : 'key'), h('span', {}, reveal ? 'Hide key' : 'Show key')); + paint(); + // A key shown comes into focus out of a blur; hidden again, the mask fades back. + pre.querySelectorAll('.mask, .k').forEach((x) => + play( + x, + [ + { filter: 'blur(4px)', opacity: 0.4 }, + { filter: 'none', opacity: 1 }, + ], + { duration: 320, easing: EASE_OUT }, + ), + ); + }, + }, + ic('key'), + h('span', {}, 'Show key'), + ); + const cp = h( + 'button', + { type: 'button', class: 'btn soft sm', onclick: (ev: Event) => copy(cfg.conf, 'Configuration copied', ev.currentTarget) }, + ic('copy'), + h('span', { class: 'lbl' }, 'Copy'), + ); + const card = h( + 'div', + { class: 'filecard' }, + h( + 'div', + { class: 'fc-row' }, + h('span', { class: 'filecard-ic' }, '.conf'), + h('span', { class: 't' }, h('span', { class: 'mono' }, cfg.filename), h('span', {}, 'For computers and routers')), + ), + h( + 'button', + { type: 'button', class: 'btn accent sm block', onclick: () => sendFile(cfg.filename, cfg.conf) }, + ic(share ? 'open' : 'download'), + h('span', {}, share ? 'Share file' : 'Download'), + ), + ); + const conf = accordion([{ icon: glass('file'), title: 'Configuration', body: [h('div', { class: 'confbar' }, eye, cp), pre] }], { + inset: true, + }); + return h('div', { class: 'step-box' }, card, conf.el); +} + +export interface ScanLine { + el: HTMLElement; + /** Another app picked: its name and its path morph in place. */ + set(app: AppId): void; +} + +/** "In AmneziaWG: + › Create from QR code", with both phone systems' wording where they differ. */ +export function scanLine(app: AppId): ScanLine { + const name = h('span', { class: 'osm-p' }, APP_NAME[app]); + const path = menuLine(scanPath(app, 'ios'), scanPath(app, 'android')); + return { + el: h('span', { class: 'scanline' }, h('span', {}, 'In ', name, ':'), path.el), + set(a) { + morphText(name, APP_NAME[a], undefined, { whole: true }); + path.set(scanPath(a, 'ios'), scanPath(a, 'android')); + }, + }; +} + +export interface ConnPill { + el: HTMLElement; + /** The labels follow the app picked. */ + sync(): void; +} + +/** + * Beside ×: the connection itself, to download or copy, where the sheet offers + * neither (a phone or a tablet set up from elsewhere). One tooltip for both + * keys, under them: the first waits a beat; once one is up the next comes at + * once and the tooltip glides across. Copied: a check, and the tooltip says so. + */ +export function connPill(get: () => { text: string; msg: string; file: string; app: string }): ConnPill { + const tt = h('span', { class: 'tt' }); + const tm = h('span', { class: 'tt-m' }); + const tip = h('span', { class: 'hp-tip', 'aria-hidden': 'true' }, tt, tm); + const dl = h('button', { type: 'button', class: 'hp-b', onclick: () => sendFile(get().file, get().text) }, ic('download')); + const cp = h('button', { type: 'button', class: 'hp-b' }, ic('copy')); + const el = h('div', { class: 'hpill', role: 'group', 'aria-label': 'The connection', 'data-key': 'conn' }, dl, cp, tip); + + let tipFor: HTMLElement | null = null; + let tipT = 0; + let warmUntil = 0; + const words = (b: HTMLElement) => (b === cp && cp.classList.contains('done') ? 'Copied' : (b.getAttribute('aria-label') ?? '')); + // Centred under its key, but never past the sheet's edge (× and its margin to the right). + const centre = (b: HTMLElement, t: string) => { + tm.textContent = t; + const w = tm.offsetWidth + 20; + return Math.min(b.offsetLeft + b.offsetWidth / 2, el.offsetWidth + 46 - w / 2); + }; + const at = (x: number) => `translateX(${x}px) translateX(-50%)`; + const glideTo = (x: number) => { + const from = getComputedStyle(tip).transform; + tip.getAnimations().forEach((a) => a.cancel()); + tip.style.transform = at(x); + play(tip, [{ transform: from }, { transform: at(x) }], { duration: SMOOTH.duration, easing: SMOOTH.easing }); + }; + // Another key's words, or "Copied": what the two share slides, the rest morphs; the pill glides with it. + const reword = (t: string) => morphText(tt, t); + const show = (b: HTMLElement) => { + clearTimeout(tipT); + if (tipFor === b && tip.classList.contains('on')) return; + tipFor = b; + if (tip.classList.contains('on')) { + const t = words(b); + glideTo(centre(b, t)); + return reword(t); + } + const up = () => { + const t = words(b); + setText(tt, t); + const x = centre(b, t); + tip.getAnimations().forEach((a) => a.cancel()); + tip.style.transform = at(x); + tip.classList.add('on'); + play( + tip, + [ + { opacity: 0, transform: `${at(x)} translateY(-3px) scale(.96)`, filter: 'blur(3px)' }, + { opacity: 1, transform: at(x), filter: 'blur(0px)' }, + ], + { + duration: 220, + easing: EASE_OUT, + }, + ); + }; + if (performance.now() < warmUntil) up(); + else tipT = window.setTimeout(up, 420); + }; + const hide = () => { + clearTimeout(tipT); + tipFor = null; + if (!tip.classList.contains('on')) return; + warmUntil = performance.now() + 500; + tip.classList.remove('on'); + play(tip, [{ opacity: 1 }, { opacity: 0 }], { duration: 120, easing: 'ease-out' }); + }; + for (const b of [dl, cp]) { + b.addEventListener('pointerenter', (e) => { + if (e.pointerType === 'mouse') show(b); + }); + b.addEventListener('focus', () => { + if (b.matches(':focus-visible')) show(b); + }); + b.addEventListener('blur', hide); + } + el.addEventListener('pointerleave', hide); + + const icon = (name: string) => { + const n = ic(name); + cp.querySelector('svg')!.replaceWith(n); + play( + n, + [ + { opacity: 0, transform: 'scale(.6)', filter: 'blur(3px)' }, + { opacity: 1, transform: 'none', filter: 'none' }, + ], + { duration: POP.duration, easing: POP.easing }, + ); + }; + // Copied: the key shows a check and the tooltip says so, then both go back. + const sayCopy = () => { + if (tipFor !== cp || !tip.classList.contains('on')) return; + const t = words(cp); + glideTo(centre(cp, t)); + reword(t); + }; + let back = 0; + cp.addEventListener('click', () => { + const c = get(); + void copy(c.text, c.msg); + clearTimeout(back); + if (!cp.classList.contains('done')) { + cp.classList.add('done'); + icon('check'); + sayCopy(); + } + back = window.setTimeout(() => { + cp.classList.remove('done'); + icon('copy'); + sayCopy(); + }, 1600); + }); + return { + el, + sync() { + const app = get().app; + dl.setAttribute('aria-label', `Download ${app} config`); + cp.setAttribute('aria-label', `Copy ${app} config`); + }, + }; +} diff --git a/web/src/portal/flows/setup-view.ts b/web/src/portal/flows/setup-view.ts new file mode 100644 index 0000000..a8fcc72 --- /dev/null +++ b/web/src/portal/flows/setup-view.ts @@ -0,0 +1,254 @@ +// Setting a device up: one sheet. Its layout follows where the page is open: +// on the device itself, two steps (get the app, add the connection) with a way +// round folded under the wait; a router, its packages and the file; a phone or +// a tablet set up from elsewhere, its link as a code or the connection as a +// code for an app it has; a computer set up from elsewhere, its link or the +// connection to send there. Which app and where it comes from follow the +// server's disguise and the platform (setup.ts). The wait for the first +// connection sits on top the whole time (wait.ts). + +import type { ClientConfig, Device } from '../../shared/types'; +import { vpnKey, vpnQrText } from '../../shared/vpnkey'; +import { ApiError, call } from '../api'; +import { h, put } from '../dom'; +import { SMOOTH, play } from '../motion'; +import { APP_NAME, appsFor, deviceNoun, inWebview, keyFileName, sameDevice, setupLink, type AppId } from '../setup'; +import { pageUrl, platform, preset, repaint } from '../state'; +import { accordion } from '../ui/accordion'; +import { codeRow, linkRow, type CodeRow } from '../ui/codes'; +import { once, toast } from '../ui/feedback'; +import { glass } from '../ui/glass'; +import { morphInto, morphText } from '../ui/morph'; +import { iconSeg, type IconSeg } from '../ui/seg'; +import { glide, go, head, onClosed, onLeave, openSheet, sub, type View } from '../ui/sheet'; +import { notice } from '../page/notices'; +import { secureFirst, showSecure } from './secure'; +import { + APP_ICON, + connPill, + connectKids, + filePane, + recallApp, + rememberApp, + scanLine, + type ScanLine, + sendKids, + storeBlock, + type SetupCtx, +} from './setup-parts'; +import { arrive, waitWay, watchFirstConnection } from './wait'; + +async function getConfig(d: Device): Promise { + try { + return await call(`devices/${d.id}/config`); + } catch (e) { + if (e instanceof ApiError && e.httpsUrl) showSecure(e.httpsUrl); + else toast((e as Error).message, true); + return null; + } +} + +/** Set up a device from its card: the configuration first (the button waits for it), then the sheet. */ +export async function openSetup(d: Device, from?: EventTarget | null) { + if (secureFirst()) return; + const run = async () => { + const cfg = await getConfig(d); + if (!cfg) return; + const key = await vpnKey(cfg, cfg.server); + openSheet(() => setupView(d, cfg, key)); + }; + if (from instanceof HTMLButtonElement) await once(from, run); + else await run(); +} + +/** Further in a flow (Add, Reconnect): the configuration the router just sent, in the open sheet. */ +export async function continueSetup(d: Device, cfg: ClientConfig) { + const key = await vpnKey(cfg, cfg.server); + go(() => setupView(d, cfg, key)); +} + +/** A numbered step: its number, a title, what to do. */ +function step(n: string, title: Node | string, kids: (Node | null)[]): HTMLElement { + return h( + 'div', + { class: 'step' }, + h('span', { class: 'step-n' }, n), + h('div', { class: 'step-b' }, typeof title === 'string' ? h('span', { class: 'step-t' }, title) : title, kids), + ); +} + +/** Fold a block away (height, then gone) or bring it back; `instant` without motion. */ +function foldBlock(el: HTMLElement, fold: boolean, instant: boolean) { + const cur = el.hidden ? 0 : el.getBoundingClientRect().height; + el.getAnimations().forEach((a) => a.cancel()); + if (instant) { + el.hidden = fold; + return; + } + el.style.overflow = 'hidden'; + el.hidden = false; + const to = fold ? 0 : el.getBoundingClientRect().height; + const [a, b] = fold ? [1, 0] : [0, 1]; + play( + el, + [ + { height: `${cur}px`, opacity: a, filter: `blur(${4 - a * 4}px)` }, + { height: `${to}px`, opacity: b, filter: `blur(${4 - b * 4}px)` }, + ], + { + duration: SMOOTH.duration, + easing: SMOOTH.easing, + }, + ).onfinish = () => { + el.style.overflow = ''; + el.hidden = fold; + }; +} + +type Layout = 'same' | 'router' | 'away' | 'pc-away'; + +export function setupView(d: Device, cfg: ClientConfig, key: string): View { + const pf = platform(); + const apps = appsFor(preset()); + const handheld = d.kind === 'phone' || d.kind === 'tablet'; + const router = d.kind === 'router'; + const same = sameDevice(d.kind, pf); + const layout: Layout = same ? 'same' : router ? 'router' : handheld ? 'away' : 'pc-away'; + const there = deviceNoun(d.kind); + // A router takes AmneziaWG (or WireGuard), never AmneziaVPN. + const choices = apps.filter((a) => !router || a.id !== 'vpn'); + let app: AppId = recallApp(d) ?? (router ? 'awg' : 'vpn'); + if (!choices.some((a) => a.id === app)) app = choices[0].id; + const c: SetupCtx = { d, cfg, key, pf, there, app: () => app, same: () => same }; + + // The pickers and the boxes a pick changes live across repaints: a pick only + // refills what it changes, so the pills glide and nothing else in the sheet moves. + const segs: IconSeg[] = []; + const picker = () => { + if (choices.length < 2) return null; + const s = iconSeg( + choices.map((a) => ({ value: a.id, label: a.name, icon: APP_ICON[a.id] })), + app, + (v) => { + app = v; + rememberApp(d, v); + segs.forEach((x) => x.sync(v)); + // The sheet glides to its new height; inside, what changed morphs (morphInto). + glide(fill); + }, + ); + segs.push(s); + return s.el; + }; + const title1 = h('span', { class: 'step-t' }); + const getBox = h('div', { class: 'step-box' }); + const addBox = h('div', { class: 'step-box' }); + const codeBox = h('div', { class: 'step-box' }); + const sendBox = h('div', { class: 'step-box' }); + let code: CodeRow | null = null; + let scan: ScanLine | null = null; + let codeApp: AppId | null = null; + const pill = + layout === 'away' + ? connPill(() => ({ + ...(app === 'vpn' + ? { text: key, msg: 'Key copied', file: keyFileName(cfg.filename) } + : { text: cfg.conf, msg: 'Configuration copied', file: cfg.filename }), + app: APP_NAME[app], + })) + : null; + + /** Everything a pick changes, refilled in place. */ + function fill() { + morphText(title1, router ? `Get ${APP_NAME[app]} on the router` : `Get ${APP_NAME[app]}`, undefined, { whole: true }); + morphInto(getBox, storeBlock(app, pf, router)); + // The router's file is the same for either app: it stays as it is (a folded configuration stays folded). + if (!router) morphInto(addBox, connectKids(c)); + else if (!addBox.firstChild) put(addBox, filePane(cfg)); + const text = app === 'vpn' ? vpnQrText(key) : cfg.conf; + // Another app: its words morph in place, the code changes only when it holds something else (codes.ts). + if (code && scan && code.el.isConnected) { + if (codeApp !== app) { + code.swap(text); + scan.set(app); + } + } else { + scan = scanLine(app); + code = codeRow(text, [scan.el]); + codeBox.replaceChildren(code.el); + } + codeApp = app; + morphInto(sendBox, sendKids(c)); + pill?.sync(); + } + fill(); + + // Not on the device: the link goes there (as a code for a phone's camera); the page there does the rest. + const linkThere = setupLink(pageUrl(), d.id); + const linkBody = () => [ + handheld + ? codeRow(linkThere, [h('span', {}, 'Point its camera at the code: the link opens there.')]).el + : h('p', { class: 'desc' }, `Open this link on the ${there} to set it up there.`), + linkRow(linkThere), + ]; + const step1 = () => step('1', title1, [picker(), getBox]); + const step2 = () => step('2', router ? 'Import the configuration' : 'Add the connection', [addBox]); + + const body = h('div', { class: 'setup' }); + if (inWebview(navigator.userAgent)) + body.appendChild( + notice('warn', 'shield', null, 'Open this page in Safari or Chrome: the store opens from here, but the app handoff does not.'), + ); + if (layout === 'same') { + // Opened, the way round folds the steps away: the device is not in hand. + const steps = h('div', { class: 'steps-wrap' }, h('div', { class: 'steps-gap' }), step1(), step2()); + const round = accordion([{ icon: glass('link'), title: `Not on the ${there} right now?`, body: linkBody() }], { + inset: true, + onToggle: (_i, open, instant) => foldBlock(steps, open, instant), + }); + body.append(round.el, steps); + } else if (layout === 'router') body.append(step1(), step2()); + // A phone or a tablet set up from here: its link as a code, or the connection as a code for an app it has. + else if (layout === 'away') + body.appendChild( + accordion( + [ + { icon: glass('link'), title: `Open your link on the ${there}`, body: linkBody() }, + { icon: glass('app'), title: 'Already has the app', body: [picker(), codeBox] }, + ], + { inset: true, open: 1 }, + ).el, + ); + // A computer set up from somewhere else: its system is not known here, so the link goes there and the page there does both steps. + else + body.appendChild( + accordion( + [ + { icon: glass('link'), title: `Open your link on the ${there}`, body: linkBody() }, + { icon: glass('key'), title: 'Copy or save the connection', body: [picker(), sendBox] }, + ], + { inset: true, open: 0 }, + ).el, + ); + + const way = waitWay(d); + let finished = false; + onLeave( + watchFirstConnection( + d, + () => { + if (finished) return; + finished = true; + void arrive(way, body, d); + }, + way.gaveUp, + ), + ); + // Closed before the device connected: the page shows what the polls brought. + onClosed(() => repaint()); + + const subline = + layout === 'same' ? 'Two steps, about a minute' : router ? 'The packages and the file for OpenWrt' : `The app goes on the ${there}.`; + const el = h('div', { class: 'view' }, head(`Set up ${d.name}`, { acts: !!pill }), sub(subline), way.el, body); + return { el, label: `Set up ${d.name}`, acts: pill?.el ?? null }; +} diff --git a/web/src/portal/flows/wait.ts b/web/src/portal/flows/wait.ts new file mode 100644 index 0000000..c548496 --- /dev/null +++ b/web/src/portal/flows/wait.ts @@ -0,0 +1,171 @@ +// Waiting for a new device's first connection: the way from the device to the +// server (a light runs along it while the page waits), the polling behind it, +// and what happens when it comes: the way fills green and its line morphs into +// " connected", the sheet's buttons step away, the steps fold shut, +// and the sheet closes by itself onto the page. + +import type { Device } from '../../shared/types'; +import { gone, call } from '../api'; +import { h, ic } from '../dom'; +import { EASE_OUT, play } from '../motion'; +import { now, repaint, setState, type State } from '../state'; +import { menuOpen } from '../ui/menu'; +import { morphText } from '../ui/morph'; +import { closeSheet, onClosed, scrollTop, settle, showing } from '../ui/sheet'; + +export interface Way { + el: HTMLElement; + connected(): void; + gaveUp(): void; +} + +export function waitWay(d: Device): Way { + const line = h('b', {}, 'Waiting for the connection'); + const more = h('span', { class: 'ws', hidden: true }); + const el = h( + 'div', + { class: 'way', role: 'status', 'aria-live': 'polite' }, + h( + 'div', + { class: 'way-row' }, + h('span', { class: 'way-end' }, ic(d.kind)), + h('span', { class: 'way-track' }, h('span', { class: 'way-glow' }, h('i')), h('span', { class: 'way-fill' })), + h('span', { class: 'way-end home' }, ic('server')), + ), + h('div', { class: 'way-text' }, h('span', { class: 't' }, line, more)), + ); + return { + el, + connected() { + el.classList.add('done'); + morphText(line, `${d.name} connected`); + }, + gaveUp() { + el.classList.add('stopped'); + morphText(line, 'No connection yet'); + more.textContent = 'Close this and open it again to keep checking.'; + more.hidden = false; + play( + line.parentElement!, + [ + { opacity: 0, filter: 'blur(4px)' }, + { opacity: 1, filter: 'none' }, + ], + { duration: 280, easing: EASE_OUT }, + ); + }, + }; +} + +/** + * The first connection was seen (a fresh handshake) before the agent's watcher + * marked the device online, a second at most: ask again shortly, a few times, + * and repaint the page with the answer, so the card goes on to "Connected" + * instead of staying on "Last connected just now". + */ +function catchUp(id: string, tries = 4) { + window.setTimeout(async () => { + try { + const st = await call('state'); + setState(st); + if (!menuOpen()) repaint(); + if (!st.person.devices.find((x) => x.id === id)?.online && tries > 1) catchUp(id, tries - 1); + } catch { + /* a hiccup: the page keeps the last answer, as on load */ + } + }, 1500); +} + +/** + * Poll for the first connection of a device that never connected: 5 s at + * first, then slower, for ten minutes at most (then `gaveUp`), not while the + * tab is hidden (every poll is a process on the router), and never again once + * the link stopped working. `arrived` runs once. Returns the stop function. + */ +export function watchFirstConnection(d: Device, arrived: () => void, gaveUp: () => void): () => void { + // The first connection is a handshake newer than this sheet (router clock), not `online`: + // that follows the agent's watcher, which can lag the handshake by a poll, and a device + // set up again with new keys still reports the last handshake of its old ones. + const opened = now(); + let timer = 0; + let polls = 0; + let done = false; + const started = Date.now(); + const poll = async () => { + timer = 0; + if (done) return; + if (Date.now() - started > 600_000) { + done = true; + gaveUp(); + return; + } + if (document.hidden) return schedule(); + try { + const st = await call('state'); + setState(st); + const dev = st.person.devices.find((x) => x.id === d.id); + if (dev && dev.handshake > opened) { + done = true; + arrived(); + if (!dev.online) catchUp(d.id); + return; + } + } catch (e) { + if (gone(e)) { + done = true; + return; + } + } + polls++; + schedule(); + }; + const schedule = () => { + if (!done && !timer) timer = window.setTimeout(poll, polls < 6 ? 5000 : polls < 12 ? 15000 : 30000); + }; + const onVisible = () => { + if (!document.hidden && !done && !timer) void poll(); + }; + document.addEventListener('visibilitychange', onVisible); + schedule(); + return () => { + done = true; + if (timer) clearTimeout(timer); + document.removeEventListener('visibilitychange', onVisible); + }; +} + +const beat = (ms: number) => new Promise((r) => setTimeout(r, ms)); + +/** + * The first connection arrived. The way fills green and says so (the sheet + * goes back up to it if it was scrolled), the buttons beside × step away; then + * everything under the way, which did its job, folds shut. Two seconds to read + * it, and the sheet closes by itself onto the page, the card ringing green. + */ +export async function arrive(way: Way, rest: HTMLElement, d: Device) { + way.connected(); + settle(); + scrollTop(); + await beat(400); + if (!showing(way.el)) return; + rest.style.overflow = 'hidden'; + play( + rest, + [ + { height: `${rest.offsetHeight}px`, opacity: 1, filter: 'none' }, + { height: '0px', opacity: 0, filter: 'blur(4px)' }, + ], + { + duration: 520, + easing: EASE_OUT, + fill: 'forwards', + }, + ); + play(way.el, [{ marginBottom: '18px' }, { marginBottom: '0px' }], { duration: 520, easing: EASE_OUT, fill: 'forwards' }); + // Reading time, not motion: the same with less motion. + await beat(2400); + // Only this sheet: not one the visitor went on to. + if (!showing(way.el)) return; + onClosed(() => repaint({ flash: d.id })); + closeSheet(); +} diff --git a/web/src/portal/main.ts b/web/src/portal/main.ts index a18f27c..c280de5 100644 --- a/web/src/portal/main.ts +++ b/web/src/portal/main.ts @@ -1,1962 +1,146 @@ -// Dawnline personal portal: one person's devices, served by the router on -// its own HTTPS port. No framework; strict CSP (no inline scripts/styles). +// Dawnline personal portal: one person's devices and access, served by the +// router on its own HTTPS port. No framework; strict CSP (no inline scripts or +// styles). This module boots the page, loads the state and draws it; the page's +// parts live in page/, what its buttons start in flows/, the moving parts in ui/. // -// Layout: phone = "Your access" on top, devices below; desktop (≥ 960px) = -// devices on the left, access on the right. +// Layout: no navbar, a breadcrumb on top. Phone: "Your access" first, devices +// under it; desktop (≥ 960px): devices left, access right and sticky. -import type { ClientConfig, Device, Kind, Person } from '../shared/types'; -import { - ACCESS_LABEL, - KIND_LABEL, - addDays, - ago, - byDeviceState, - bytes, - date, - daysLeft, - endsIn, - endsSoon, - initials, - isoDay, - parseDay, -} from '../shared/format'; -import { iconSvg } from '../shared/icons'; -import { denseQr, qrSvg } from '../shared/qr'; -import { vpnKey, vpnQrText } from '../shared/vpnkey'; -import { h, ic, type Kid } from './dom'; -import { waitPath, type Way } from './waitpath'; -import { beat, busy, calm, copied, fold, followHeight, intro, leave, pullToClose, replay, restyle, settle, snap, swap } from './motion'; -import { - APP_NAME, - appsFor, - hereLabel, - deviceNoun, - importSteps, - keyFileName, - opensKeyLinks, - setupFromHash, - setupLink, - inWebview, - osGroup, - PLATFORM_LABEL, - platformOf, - routerStore, - sameDevice, - scanPath, - storeFor, - updateLine, - type AppId, - type Platform, - type Preset, - type Store, -} from './setup'; - -interface State { - title: string; - person: Person; - /** device_mesh: devices with home access reach each other through the tunnel. */ - /** awg_disguise: false = plain WireGuard, any WireGuard app connects. */ - server: { name: string; endpoint: string; device_mesh?: boolean; awg_disguise?: boolean; preset?: Preset }; - /** The device this page was opened from (through the tunnel), if any. */ - here?: string | null; - can_add: boolean; - /** The admin stopped the person (paused, access ended): the page only shows. */ - locked?: boolean; - /** Over plain HTTP: the same link over HTTPS, where the connection settings are. */ - https_url?: string | null; - kinds: Kind[]; - version: string; - /** The router's day (YYYY-MM-DD) when it sends one; the browser's otherwise. */ - today?: string; - /** The router's clock (epoch seconds): relative times are measured against it, not the phone's. */ - now?: number; -} - -/** Today on the router, for days left and chart labels. */ -const today = () => state?.today ?? isoDay(new Date()); -/** Now on the router (seconds), for "last connected 3 min ago". */ -const now = () => state?.now ?? Date.now() / 1000; +import { put, h } from './dom'; +import { EASE_OUT, play, publishSprings } from './motion'; +import { gone, call } from './api'; +import { base, code, onRepaint, placeName, setState, state, type RepaintOpts, type State } from './state'; +import { setupFromHash, wantsAdd } from './setup'; +import { frame, crumbs, single } from './page/frame'; +import { pageNotice, stateNotice } from './page/notices'; +import { devicesSection, fillDevices } from './page/devices'; +import { accessSection, fillAccess } from './page/access'; +import { glass, type Tone } from './ui/glass'; +import { closeMenu, menuOpen } from './ui/menu'; +import { closeSheet, sheetOpen } from './ui/sheet'; +import { startAdd } from './flows/add'; +import { openSetup } from './flows/setup-view'; +publishSprings(document.documentElement); const app = document.getElementById('app')!; -const base = app.dataset.base ?? ''; -const pageTitle = app.dataset.title || 'Dawnline'; -const isMobile = () => window.matchMedia('(max-width: 959px)').matches || /Android|iPhone|iPad/.test(navigator.userAgent); -let state: State | null = null; -/** The personal link is the key: its path is the code (no sessions). */ -const code = /^\/[a-z]{6}-[a-z]{6}-[a-z]{6}$/.test(base) ? base.slice(1) : ''; -/* ---------- API ---------- */ - -class ApiError extends Error { - constructor( - public status: number, - message: string, - /** The HTTPS twin of this link, when the answer was "not over plain HTTP". */ - public httpsUrl?: string, - ) { - super(message); - } -} - -async function call(path: string, body?: unknown): Promise { - const res = await fetch(`${base}/api/${path}`, { - method: body === undefined ? 'GET' : 'POST', - credentials: 'omit', - headers: body === undefined ? {} : { 'Content-Type': 'application/json' }, - body: body === undefined ? undefined : JSON.stringify(body), - cache: 'no-store', - }); - let data: any = null; - try { - data = await res.json(); - } catch { - /* empty */ - } - if (!res.ok) throw new ApiError(res.status, data?.error ?? `Request failed (${res.status})`, data?.https_url || undefined); - return data as T; -} - -/* ---------- small UI pieces ---------- */ - -/** One toast at a time: a new one sends the last away first. */ -let toastEl: HTMLElement | null = null; -function dropToast(t: HTMLElement) { - if (toastEl === t) toastEl = null; - t.classList.remove('show'); - t.classList.add('gone'); - setTimeout(() => t.remove(), 200); -} - -function toast(msg: string, bad = false) { - if (toastEl) dropToast(toastEl); - const t = h('div', { class: `toast${bad ? ' bad' : ''}`, role: 'status' }, msg); - document.body.appendChild(t); - void t.offsetWidth; - t.classList.add('show'); - toastEl = t; - setTimeout(() => dropToast(t), 2600); -} - -/** `from`: the control that copied, which then shows a check for a moment. */ -async function copy(text: string, what = 'Copied', from?: EventTarget | null) { - try { - await navigator.clipboard.writeText(text); - } catch { - const ta = h('textarea', { class: 'offscreen' }, text) as HTMLTextAreaElement; - document.body.appendChild(ta); - ta.select(); - const ok = document.execCommand('copy'); - ta.remove(); - if (!ok) return toast('Copying is blocked here. Select the text and copy it by hand.', true); - } - copied(from instanceof HTMLElement ? from : null, iconSvg('check', 'ic-svg')); - toast(what); -} - -/** - * On phones a share sheet hands the file straight to the VPN app, where a - * download would land in Files. Returns the action, or null where files - * cannot be shared. - */ -function shareFile(name: string, text: string): (() => Promise) | null { - const nav = navigator as Navigator & { canShare?: (d: unknown) => boolean }; - // Only iOS: there AmneziaWG, WireGuard and AmneziaVPN take a file from the - // share sheet. On Android neither app is a share target (and Chrome does not - // share .conf files), so a download goes into the app's own file picker; - // desktop browsers claim they can share files and then do nothing. - if (platform() !== 'ios') return null; - if (typeof nav.share !== 'function' || typeof File === 'undefined') return null; - const file = new File([text], name, { type: 'application/octet-stream' }); - if (!nav.canShare?.({ files: [file] })) return null; - return async () => { - try { - // The file alone: with a title, "Save to Files" also writes the title as a .txt. - await nav.share({ files: [file] }); - } catch (e) { - // Cancelled: nothing to do. Refused by the browser: the file still has to get out. - if ((e as Error)?.name !== 'AbortError') download(name, text); - } - }; -} - -function download(name: string, text: string) { - // Not text/plain: Safari would save "name.conf.txt". - const url = URL.createObjectURL(new Blob([text], { type: 'application/octet-stream' })); - const a = h('a', { href: url, download: name, class: 'offscreen' }); - document.body.appendChild(a); - a.click(); - setTimeout(() => { - URL.revokeObjectURL(url); - a.remove(); - }, 1000); -} - -// One tooltip for the page: it fades in where the pointer is, then only follows it -// (moving from bar to bar never replays the entrance). -let tipEl: HTMLElement | null = null; -function tip(el: HTMLElement, lines: () => string[]) { - const show = (ev: MouseEvent) => { - tipEl ??= document.body.appendChild(h('div', { class: 'tip', role: 'tooltip' })); - tipEl.replaceChildren(...lines().map((l, i) => h('div', { class: i ? 'muted' : 'tip-title' }, l))); - tipEl.style.left = `${ev.clientX}px`; - tipEl.style.top = `${ev.clientY - 10}px`; - tipEl.classList.add('show'); - }; - el.addEventListener('mouseenter', show); - el.addEventListener('mousemove', show); - el.addEventListener('mouseleave', () => tipEl?.classList.remove('show')); -} - -function spark(values: number[]): HTMLElement { - const max = Math.max(1, ...values); - const el = h('div', { class: 'spark' }); - values.forEach((v, i) => { - const b = h('i', { class: v ? '' : 'zero' }); - b.style.height = `${Math.max(8, (v / max) * 100)}%`; - b.style.setProperty('--i', String(i)); - const back = values.length - 1 - i; - tip(b, () => [ - back === 0 - ? 'Today' - : back === 1 - ? 'Yesterday' - : parseDay(addDays(today(), -back)).toLocaleDateString('en-GB', { weekday: 'short', day: 'numeric', month: 'short' }), - bytes(v), - ]); - el.appendChild(b); - }); - return el; -} - -/** Run a confirmed action once: its button stays disabled until the router answers. */ -async function once(btn: HTMLButtonElement, fn: () => Promise) { - if (btn.disabled) return; - btn.disabled = true; - const idle = busy(btn); - try { - await fn(); - } finally { - idle(); - btn.disabled = false; - } -} - -/* ---------- sheets (bottom sheet on phones, dialog on desktop) ---------- */ - -let sheetEl: HTMLElement | null = null; -let sheetClosed: (() => void) | null = null; -/** The sheet sits at the bottom (phones): it slides up and can be pulled down. */ -const bottomSheet = () => window.matchMedia('(max-width: 639px)').matches; - -// A sheet is a history entry: the phone's back button closes it instead of leaving the page. -let sheetHistory = false; -window.addEventListener('popstate', () => { - if (sheetEl) { - sheetHistory = false; - closeSheet(); - } -}); - -/** `immediate`: gone at once (Escape: what the keyboard does never animates). */ -function closeSheet(immediate = false) { - if (!sheetEl) return; - const s = sheetEl; - sheetEl = null; - if (sheetHistory) { - sheetHistory = false; - history.back(); - } - document.body.classList.remove('locked'); - sheetClosed?.(); - sheetClosed = null; - if (immediate) { - s.remove(); - return; - } - s.classList.remove('open'); - s.classList.add('closing'); - setTimeout(() => s.remove(), bottomSheet() ? 320 : 180); -} - -/** - * Open a sheet with this content, or turn the open one into it: the panel then - * keeps its place (and its history entry) while the old content fades out, the - * new one comes in and the size follows, so a flow of sheets reads as one. - * `asks`: the narrow question look (ask), which the panel also morphs out of. - */ -function present(label: string, inner: Node[], asks = false) { - if (sheetEl) { - sheetClosed?.(); - sheetClosed = null; - const panel = sheetEl.querySelector('.sheet-panel') as HTMLElement; - panel.setAttribute('aria-label', label); - panel.setAttribute('role', asks ? 'alertdialog' : 'dialog'); - // A question that turns into a sheet (or back) changes width too: let the panel morph it. - if (panel.classList.contains('asks') !== asks) { - panel.dataset.morph = 'width'; - panel.classList.toggle('asks', asks); - } - panel.scrollTop = 0; - swap(panel.querySelector('.sheet-inner') as HTMLElement, inner); - return; - } - const box = h('div', { class: 'sheet-inner' }, ...inner); - const panel = h( - 'div', - { class: `sheet-panel${asks ? ' asks' : ''}`, role: asks ? 'alertdialog' : 'dialog', 'aria-modal': 'true', 'aria-label': label }, - h('div', { class: 'grab' }), - box, - ); - const scrim = h('div', { class: 'scrim', onclick: () => closeSheet() }); - const s = h('div', { class: 'sheet fresh' }, scrim, panel); - // On a dialog the content settles in just after it; on phones the slide is the motion. - box - .querySelectorAll(':scope > .sheet-head, .sheet-body > :not(.setup), .setup > *') - .forEach((el, i) => el.style.setProperty('--i', String(Math.min(i, 6)))); - document.body.appendChild(s); - document.body.classList.add('locked'); - if (!sheetHistory) { - try { - history.pushState({ sheet: true }, ''); - sheetHistory = true; - } catch { - /* no history */ - } - } - followHeight(panel, box); - pullToClose(panel, scrim, () => closeSheet(), bottomSheet); - void s.offsetWidth; - s.classList.add('open'); - setTimeout(() => s.classList.remove('fresh'), 700); - sheetEl = s; -} - -/** A sheet: a title (and a line under it), a close button, the content. */ -function sheet(title: string, sub: string | null, ...content: Kid[]) { - present(title, [ - h( - 'div', - { class: 'sheet-head' }, - h('div', { class: 'stack' }, h('h2', {}, title), sub ? h('span', { class: 'muted s' }, sub) : null), - h('button', { class: 'icon-btn', 'aria-label': 'Close', onclick: () => closeSheet() }, ic('x')), - ), - h('div', { class: 'sheet-body' }, ...content), - ]); -} - -/** - * A question before something that cannot be undone (Remove, Reconnect): narrow - * and centred, the action's icon in its colour, one line of what happens, Cancel - * and the action (no ×: Cancel says it). `run` holds the action's button busy. - */ -function ask(o: { - icon: string; - tone: 'bad' | 'warn'; - title: string; - text: string; - action: string; - actionClass: string; - run: () => Promise; -}) { - present( - o.title, - [ - h( - 'div', - { class: 'ask' }, - h('span', { class: `ask-ic ${o.tone}` }, ic(o.icon)), - h('h2', {}, o.title), - h('p', { class: 'muted' }, o.text), - h( - 'div', - { class: 'row gap ask-actions' }, - h('button', { type: 'button', class: 'btn block', onclick: () => closeSheet() }, 'Cancel'), - h( - 'button', - { - type: 'button', - class: `btn ${o.actionClass} block`, - onclick: (ev: Event) => once(ev.currentTarget as HTMLButtonElement, o.run), - }, - o.action, - ), - ), - ), - ], - true, - ); -} - -document.addEventListener('keydown', (e) => { - if (e.key === 'Escape') { - closeMenu(true); - closeSheet(true); - } -}); - -/* ---------- dropdown menu ---------- */ - -let menuEl: HTMLElement | null = null; -/** The button the open menu belongs to: pressing it again closes the menu. */ -let menuFor: HTMLElement | null = null; - -/** `immediate`: gone at once (Escape). */ -function closeMenu(immediate = false) { - const m = menuEl; - if (!m) return; - menuEl = null; - menuFor?.setAttribute('aria-expanded', 'false'); - menuFor = null; - if (immediate) { - m.remove(); - return; - } - m.classList.remove('show'); - m.classList.add('gone'); - setTimeout(() => m.remove(), 150); -} -document.addEventListener('click', (e) => { - if (menuEl && !menuEl.contains(e.target as Node)) closeMenu(); -}); - -function menu(anchor: HTMLElement, all: ({ label: string; icon: string; danger?: boolean; warn?: boolean; run: () => unknown } | null)[]) { - if (menuFor === anchor) return closeMenu(); - closeMenu(); - // Separators only between items. - const items = all.filter((it, i) => it || (i > 0 && all[i - 1] && all.slice(i + 1).some(Boolean))); - const m = h( - 'div', - { class: 'menu', role: 'menu' }, - items.map((it) => - it - ? h( - 'button', - { - type: 'button', - role: 'menuitem', - class: `menu-item${it.danger ? ' danger' : it.warn ? ' warn' : ''}`, - onclick: () => { - closeMenu(); - it.run(); - }, - }, - ic(it.icon), - h('span', {}, it.label), - ) - : h('div', { class: 'menu-sep' }), - ), - ); - document.body.appendChild(m); - const r = anchor.getBoundingClientRect(); - const w = 230, - mh = m.offsetHeight; - // Under the button, or over it where the screen ends: it grows out of the button either way. - const up = r.bottom + 6 + mh > window.innerHeight - 8 && r.top - 6 - mh > 8; - m.classList.toggle('up', up); - m.style.left = `${Math.max(8, Math.min(window.innerWidth - w - 8, r.right - w))}px`; - m.style.top = `${(up ? r.top - 6 - mh : r.bottom + 6) + window.scrollY}px`; - void m.offsetWidth; - m.classList.add('show'); - anchor.setAttribute('aria-expanded', 'true'); - menuEl = m; - menuFor = anchor; -} - -/* ---------- views ---------- */ - -// The sun rises from behind the horizon once, on the visit's first paint. -const LOGO = - ''; - -/** The blocks of a page that come in on the first paint, in reading order. */ -const INTRO = '.alert, .hello, .card-head, .access-card, .dcard, .slot.add, .firststeps, .devices > .faint, .signin, .wrap > .card'; +let parts: { notice: HTMLElement; devices: HTMLElement; access: HTMLElement } | null = null; let booted = false; -/** - * Draw the page. The visit's first paint comes in (blocks rise in, the meters - * fill, the sun rises); a repaint only moves what changed: keyed blocks glide - * to their new places, new ones rise in, changed values come into focus. - */ -function shell(...content: Kid[]) { - const before = booted ? snap(app) : null; - const first = !booted ? ' first' : ''; - const wrap = h('main', { class: `wrap${first}` }, ...content); - app.replaceChildren( - h( - 'header', - { class: `top${first}` }, - h( - 'div', - { class: 'brand' }, - (() => { - const l = h('span', { class: 'logo' }); - l.innerHTML = LOGO; - return l; - })(), - h('span', {}, state?.server.name || pageTitle), - h('span', { class: 'faint' }, '· Dawnline'), - ), +/** The first paint comes in: the blocks rise one after the other, the sun rises behind its line. */ +function intro() { + const els = [...app.querySelectorAll('.crumbs, .notice, .sec-head, .dgrid > *, .note-s:not([hidden]), .acc-slot .acc-row, .gone')]; + // Each block rises to its own opacity: a card the admin disabled is dimmed all the way, not at the end. + const own = els.map((el) => getComputedStyle(el).opacity); + els.forEach((el, i) => + play( + el, + [ + { opacity: 0, transform: 'translateY(10px)', filter: 'blur(4px)' }, + { opacity: own[i], transform: 'none', filter: 'none' }, + ], + { + duration: 520, + delay: 60 + i * 40, + easing: EASE_OUT, + fill: 'backwards', + }, ), - wrap, ); - if (before) settle(app, before); - else intro(wrap, INTRO); + app.querySelectorAll('.logo .sun').forEach((s) => + play(s, [{ transform: 'translateY(7px)' }, { transform: 'none' }], { + duration: 900, + delay: 150, + easing: EASE_OUT, + fill: 'backwards', + }), + ); booted = true; } -/** The link stopped working while the page was open (code regenerated, person removed). */ +/** + * Draw the page from the state. The parts stay; a repaint refills them: cards + * that stay glide to their new places, the open access row stays open. + */ +function render(o: RepaintOpts = {}) { + const st = state(); + if (!st) return; + // Paused by the admin: nothing on the page works until it is resumed, so the page is the one card that says so. + if (st.person.state === 'paused') { + document.title = placeName(); + const [icon, title, text] = stateNotice(st.person); + return only(icon, title, text, false, 'orange'); + } + const slot = frame(app); + single(false); + crumbs(); + document.title = placeName(); + if (!parts) { + parts = { notice: h('div', { class: 'notice-slot' }), devices: devicesSection(), access: accessSection() }; + put(slot, parts.notice, h('div', { class: 'cols' }, parts.devices, parts.access)); + } + // What stops the devices comes first. + put(parts.notice, pageNotice(st.person)); + fillDevices(parts.devices, st, o); + fillAccess(parts.access, st); + if (!booted) intro(); +} +onRepaint(render); + +/** A card in place of the page: the link stopped working, nothing could load, or the access is paused. */ +function only(icon: string, title: string, text: string, gone = false, tone: Tone = 'grey') { + parts = null; + const slot = frame(app); + single(true); + crumbs(gone, true); + put(slot, h('div', { class: 'gone' }, glass(icon, tone), h('h1', {}, title), h('p', {}, text))); + if (!booted) intro(); +} + +/** The link stopped working (code regenerated, person removed): nothing else is left. */ function linkGone() { - shell( - h( - 'div', - { class: 'card signin', 'data-key': 'gone' }, - h('div', { class: 'hero-ic' }, ic('key')), - h('h1', {}, 'This link no longer works'), - h('p', { class: 'muted' }, 'Ask for a new personal link.'), - ), - ); -} - -/** Why the person's devices can't connect: icon, title and what happens next. */ -function stateNotice(p: Person): [string, string, string] { - switch (p.state) { - case 'server_off': - return ['server', 'The server is turned off', 'Your devices can’t connect until the admin turns it on again.']; - case 'no_server': - return ['server', 'No server yet', 'Ask the admin to add you to a server.']; - case 'quota': - return ['chart', 'You have used all your data', 'Your devices stay connected but nothing gets through until it resets.']; - case 'expired': - return ['calendar', 'Your access has ended', 'Ask the admin to extend it.']; - case 'hours': - return [ - 'clock', - 'Outside your hours', - `Access is available ${p.hours.replace('-', '–')} (router time); until then nothing gets through.`, - ]; - default: - return ['pause', 'Your access is paused by the admin', 'Your devices can’t connect until the admin resumes it.']; - } -} - -/** A notice in the admin's Overview style: a tinted icon tile, a title and a line under it. */ -function alertRow(tone: string, icon: string, title: string, sub: string): HTMLElement { - return h( - 'div', - { class: 'alert', 'data-key': 'notice' }, - h('span', { class: `alert-ic ${tone}` }, ic(icon)), - h('div', { class: 'stack' }, h('span', { class: 'strong' }, title), h('span', { class: 'muted s' }, sub)), - ); -} - -function stateTone(p: Person) { - return p.state === 'active' ? 'ok' : p.state === 'quota' || p.state === 'expired' ? 'bad' : 'warn'; -} - -const ACCESS_TEXT: Record = { - internet: 'The internet, through the router', - lan: 'Devices at home', - both: 'Devices at home and the internet, through the router', -}; - -function accessCard(st: State): HTMLElement { - const p = st.person; - const pct = p.quota_limit ? Math.min(100, (p.quota_used / p.quota_limit) * 100) : 0; - const bar = h('div', { class: `meter${pct >= 100 ? ' bad' : pct >= 90 ? ' warn' : ''}` }, h('i')); - (bar.firstChild as HTMLElement).style.width = `${pct}%`; - if (p.quota_limit) tip(bar, () => [`${pct.toFixed(1)}% used`, `${bytes(Math.max(0, p.quota_limit - p.quota_used))} left`]); - const left = daysLeft(p.expires, today()); - const slots = h('div', { class: 'slots' }); - // Devices the admin added over the limit get their own orange slots after the allowed ones. - for (let i = 0; i < Math.max(p.device_limit, p.devices.length); i++) - slots - .appendChild(h('i', { class: i >= p.device_limit ? 'over' : i < p.devices.length ? 'used' : '' })) - .style.setProperty('--i', String(i)); - const used = p.quota_used || p.month[0] + p.month[1]; - const icon = p.access === 'internet' ? 'globe' : p.access === 'lan' ? 'home' : 'shield'; - // Heading outside the card, like "Your devices", so both columns line up. - return h( - 'section', - { class: 'access', 'aria-label': 'Your access', 'data-key': 'access' }, - h( - 'div', - { class: 'card-head' }, - h('div', { class: 'row-baseline' }, h('h2', {}, 'Your access'), h('span', { class: 'faint s' }, 'set by the admin')), - ), - h( - 'div', - { class: 'card access-card' }, - h( - 'div', - { class: 'reach' }, - h('span', { class: 'reach-ic' }, ic(icon)), - h( - 'div', - { class: 'stack' }, - h('span', { class: 'strong' }, ACCESS_LABEL[p.access]), - h('span', { class: 'muted s' }, ACCESS_TEXT[p.access]), - ), - ), - namesAtHome(p, !!st.server.device_mesh), - h( - 'div', - { class: 'tile' }, - h( - 'div', - { class: 'tile-label' }, - h('span', {}, p.quota_period === 'total' && p.quota_gb ? 'Data used' : 'Data this month'), - p.quota_period === 'month' ? h('span', {}, 'resets on the 1st') : null, - ), - h( - 'span', - { class: 'tile-value', 'data-v': 'used' }, - bytes(used), - h('span', { class: 'faint' }, p.quota_limit ? ` of ${bytes(p.quota_limit)}` : ' · no limit'), - ), - p.quota_limit ? bar : null, - ), - h( - 'div', - { class: 'tiles2' }, - h( - 'div', - { class: 'tile' }, - h('div', { class: 'tile-label' }, 'Devices'), - h( - 'span', - { class: 'tile-value', 'data-v': 'count' }, - String(p.devices.length), - h('span', { class: 'faint' }, ` / ${p.device_limit}`), - ), - slots, - ), - h( - 'div', - { class: 'tile' }, - h('div', { class: 'tile-label' }, 'Access until'), - h('span', { class: 'tile-value sm', 'data-v': 'until' }, p.expires ? date(p.expires) : 'No end date'), - left != null - ? h( - 'span', - { class: `s ${endsSoon(p, left) ? 'warn' : 'ok'}` }, - left >= 0 ? `${left} day${left === 1 ? '' : 's'} left` : 'ended', - ) - : null, - ), - ), - h( - 'span', - { class: 'faint s' }, - p.hours ? `Available ${p.hours.replace('-', '–')} (router time). Need a change? Ask the admin.` : 'Need a change? Ask the admin.', - ), - ), - ); -} - -function deviceStatus(d: Device, p: Person): HTMLElement { - // Status as coloured text, no dots (only the avatar carries one). - if (d.disabled) return h('span', { class: 'dstat' }, 'Disabled by the admin'); - // Settings the device carries changed: it keeps working on the old ones only until they stop matching. - if (d.config_stale && d.handshake) return h('span', { class: 'dstat warn' }, 'Settings changed, update needed'); - // Over the data limit or outside the hours the tunnel stays up but passes nothing: the app says - // "connected", so say here why nothing works. - if (d.online && p.state === 'quota') return h('span', { class: 'dstat warn' }, 'Connected, no data left'); - if (d.online && p.state === 'hours') return h('span', { class: 'dstat warn' }, 'Connected, outside your hours'); - if (d.online) return h('span', { class: 'dstat ok' }, 'Connected'); - if (!d.handshake) return h('span', { class: 'dstat warn' }, 'Not set up yet'); - return h('span', { class: 'dstat', title: new Date(d.handshake * 1000).toLocaleString() }, `Last connected ${ago(d.handshake, now())}`); + setState(null); + closeSheet(true); + only('key', 'This link no longer works', 'Ask for a new one.', true); } /** - * How other devices at home reach this person's devices: once, in the access card, - * instead of an address on every device card. Only with access to the home network. + * A link that names a device (`#setup=d_…`, the code a set-up sheet hands to + * that device) opens its set-up at once, if it still waits for one; `#add` + * opens "Add a device". On load, or when such a link opens in a tab already on + * this page. Once: the fragment comes off the address (a reload shows the page). */ -/** - * Whether the home network can open connections to this device: the router lets - * it through only for people with home access who are active, and devices on. - */ -function reachableFromHome(p: Person, d: Device): boolean { - return p.access !== 'internet' && p.state === 'active' && !d.disabled; -} - -function namesAtHome(p: Person, mesh: boolean): HTMLElement | null { - const named = byDeviceState(p.devices).filter((d) => d.hostname && reachableFromHome(p, d)); - if (!named.length) return null; - const first = named[0].hostname; - const domain = first.slice(first.indexOf('.')); - return h( - 'div', - { class: 'names' }, - h( - 'div', - { class: 'names-head' }, - h('span', { class: 'names-ic' }, ic('home')), - h( - 'div', - { class: 'stack' }, - h('span', { class: 'strong s' }, 'Names at home'), - h( - 'span', - { class: 'faint s' }, - mesh ? 'Devices at home and on this VPN reach yours as ' : 'Other devices at home reach yours as ', - h('span', { class: 'mono' }, `name${domain}`), - ), - ), - ), - h( - 'div', - { class: 'names-list' }, - named.map((d) => { - const dot = d.hostname.indexOf('.'); - return h( - 'button', - { - type: 'button', - class: 'name-chip', - title: d.name, - 'aria-label': `Copy ${d.hostname}`, - onclick: (ev: Event) => copy(d.hostname, 'Address copied', ev.currentTarget), - }, - h( - 'span', - { class: 'mono' }, - dot > 0 ? [d.hostname.slice(0, dot), h('span', { class: 'faint' }, d.hostname.slice(dot))] : d.hostname, - ), - ic('copy'), - ); - }), - ), - ); -} - -function deviceCard(d: Device, st: State): HTMLElement { - const more = h( - 'button', - { type: 'button', class: 'icon-btn soft', 'aria-label': `${d.name} options`, 'aria-haspopup': 'menu', 'aria-expanded': 'false' }, - ic('more'), - ); - // The connection itself comes from the set-up sheet (Reconnect), not from here. - const items = [ - // How devices at home reach it: only where the router actually lets them through. - ...(reachableFromHome(st.person, d) - ? [ - { label: 'Copy IP address', icon: 'copy', run: () => copy(d.address, 'IP address copied') }, - ...(d.hostname ? [{ label: 'Copy local address', icon: 'home', run: () => copy(d.hostname, 'Address copied') }] : []), - null, - ] - : []), - // A device the admin turned off can't be renamed, set up again or removed here (the router refuses). - ...(d.disabled - ? [] - : [ - { label: 'Rename', icon: 'edit', run: () => rename(d) }, - { label: 'Reconnect', icon: 'refresh', warn: true, run: () => reconnect(d, st) }, - { label: 'Remove', icon: 'trash', danger: true, run: () => removeDevice(d) }, - ]), - ]; - more.addEventListener('click', (ev) => { - ev.stopPropagation(); - menu(more, items); - }); - const week = d.spark.reduce((a, b) => a + b, 0); - const setUp = !d.handshake && !d.disabled; - // Stopped by the admin: no actions, and a device never set up has nothing to show. - const locked = !!st.locked; - // The device this page was opened from (through the tunnel): blue, and says so. - const here = st.here === d.id; - // Opened through the tunnel, so it is connected: say which one it is instead. - // The home name is in the access card; the tunnel address says nothing to them. - const status = here ? h('span', { class: 'dstat here' }, 'This device') : deviceStatus(d, st.person); - status.dataset.v = `stat:${d.id}`; - return h( - 'article', - { class: `dcard${d.online ? ' online' : ''}${d.disabled ? ' off' : ''}${here ? ' here' : ''}`, 'data-key': d.id }, - h( - 'div', - { class: 'dhead' }, - h('span', { class: 'dic' }, ic(d.kind)), - h('div', { class: 'stack grow' }, h('span', { class: 'dname', 'data-v': `name:${d.id}` }, d.name), status), - locked || !items.length ? null : more, - ), - setUp && locked - ? null - : setUp - ? [ - h( - 'button', - { type: 'button', class: 'btn primary block', onclick: () => setup(d) }, - ic('arrow'), - h('span', {}, `Set up ${d.name}`), - ), - ] - : h( - 'div', - { class: 'duse' }, - h( - 'div', - { class: 'stack' }, - h('span', { class: 'faint s' }, 'Last 7 days'), - h('span', { class: 'mono', 'data-v': `week:${d.id}` }, bytes(week)), - ), - spark(d.spark), - ), - // The admin changed something the configuration carries: the status line says so, one button fixes it. - d.config_stale && !setUp && !locked - ? h( - 'button', - { type: 'button', class: 'btn block', onclick: () => reconnect(d, st) }, - ic('refresh'), - h('span', {}, 'Update the connection'), - ) - : null, - ); -} - -function main(st: State) { - const p = st.person; - const left = daysLeft(p.expires, today()); - const notice = - p.state !== 'active' - ? alertRow(stateTone(p), ...stateNotice(p)) - : endsSoon(p, left) - ? alertRow('warn', 'calendar', `Your access ${endsIn(left as number)}`, `On ${date(p.expires)}. Ask the admin to extend it.`) - : null; - - // The device this page was opened from comes first. - const order = byDeviceState(p.devices).sort((a, b) => Number(b.id === st.here) - Number(a.id === st.here)); - const cards: HTMLElement[] = order.map((d) => deviceCard(d, st)); - const free = st.locked ? 0 : Math.max(0, p.device_limit - p.devices.length); - // Nothing yet: one card with the button; the set-up sheet behind it walks through the app and the connection. - if (!p.devices.length && free) { - cards.push( - h( - 'div', - { class: 'card firststeps', 'data-key': 'first' }, - h('h2', {}, 'Add your first device'), - h( - 'p', - { class: 'muted' }, - 'Two steps, about a minute: get the app, then add the connection. The next screen shows both for the device you pick.', - ), - h( - 'button', - { type: 'button', class: 'btn primary block big', onclick: addDevice }, - ic('plus'), - h('span', {}, isMobile() ? 'Add this phone' : 'Add this device'), - ), - ), - ); - } else if (free) - cards.push( - h( - 'button', - { type: 'button', class: 'slot add', onclick: addDevice, 'data-key': 'add' }, - h('span', { class: 'slot-ic' }, ic('plus')), - // How many are left is in "Your devices 3 of 10" and the Devices tile. - h('span', { class: 'strong' }, 'Add device'), - ), - ); - - const devices = h( - 'section', - { class: 'devices', 'aria-label': 'Your devices' }, - h( - 'div', - { class: 'card-head', 'data-key': 'devices-head' }, - h( - 'div', - { class: 'row-baseline' }, - // How many (the Devices tile) and which are online (the cards) are shown already. - h('h2', {}, 'Your devices'), - ), - ), - h('div', { class: 'dgrid' }, cards), - st.locked - ? null - : [ - !st.can_add - ? h( - 'span', - { class: 'faint s', 'data-key': 'limit' }, - `You have reached your limit of ${p.device_limit} devices. Remove one or ask the admin for more.`, - ) - : null, - ], - ); - - // What stops the devices comes before the greeting. - shell( - notice, - h( - 'div', - { class: 'hello', 'data-key': 'hello' }, - h('span', { class: `avatar${p.online ? ' online' : ''}` }, initials(p.name)), - // What is wrong is in the notice above, not a pill here. - h('h1', {}, `Hi, ${p.name}`), - ), - h('div', { class: 'layout' }, accessCard(st), devices), - ); -} - -/** The platform this page is open on (iPad on Safari says Mac; touch points tell). */ -const platform = (): Platform => platformOf(navigator.userAgent, navigator.maxTouchPoints); -/** The server's disguise generation, for which apps and versions connect. */ -const preset = (): Preset => state?.server.preset ?? (plainWg() ? 'off' : 'max'); - -/** The server's disguise is off: plain WireGuard, so any WireGuard app connects. */ -const plainWg = () => state?.server.awg_disguise === false; - -/* ---------- QR codes ---------- */ - -// The portal draws its codes in the night look (light dots on a black card). -// Some in-app scanners read only dark on light: one line under every code -// switches all of them to the plain look, and the choice is remembered here. -const QR_LIGHT = 'dl.qr.light'; -let lightQr = (() => { - try { - return localStorage.getItem(QR_LIGHT) === '1'; - } catch { - return false; - } -})(); -/** What each drawn code encodes, to draw it again in the other look. */ -const qrText = new WeakMap(); - -function paintQr(q: HTMLElement, text: string) { - qrText.set(q, text); - // A dense code is drawn as large as the sheet allows: a phone camera needs the modules. - q.className = `qr${denseQr(text) ? ' big' : ''}${lightQr ? ' light' : ''}`; - q.innerHTML = qrSvg(text, 3, true, lightQr ? 'plain' : 'night'); -} - -/** "Not scanning? Show a light code", or the way back. */ -function paintFlip(line: HTMLElement) { - line.replaceChildren( - lightQr ? '' : 'Not scanning? ', - h( - 'a', - { - href: '#', - onclick: (ev: Event) => { - ev.preventDefault(); - flipQr(); - }, - }, - lightQr ? 'Show the dark code' : 'Show a light code', - ), - ); -} -function qrFlip(): HTMLElement { - const line = h('span', { class: 'faint s qr-flip' }); - paintFlip(line); - return line; -} - -function flipQr() { - lightQr = !lightQr; - try { - localStorage.setItem(QR_LIGHT, lightQr ? '1' : '0'); - } catch { - /* private mode: for this page only */ - } - document.querySelectorAll('.qr').forEach((q) => { - const text = qrText.get(q); - if (!text) return; - paintQr(q, text); - replay(q, 'swap'); - }); - document.querySelectorAll('.qr-flip').forEach(paintFlip); -} - -/* ---------- device flows ---------- */ - -/** - * A plain-HTTP link (an IP address) shows the page, but keys only travel - * encrypted: the connection settings are on the HTTPS twin. Its certificate - * is the router's own, so the browser warns once; say so. - */ -function secureSheet(url: string) { - sheet( - 'Open the link securely', - 'Connection settings only travel encrypted', - h( - 'div', - { class: 'stack gap' }, - h('p', { class: 'muted' }, 'This page is open without encryption. To add or set up a device, open the same link over HTTPS:'), - h('a', { class: 'btn primary block big', href: url }, ic('lock'), h('span', {}, 'Open securely')), - h( - 'p', - { class: 'faint s' }, - 'The browser may warn that the certificate is not trusted: it is this router’s own. Choose to continue (“Advanced” → “Proceed”).', - ), - ), - ); -} - -/** The secure twin when this page is plain HTTP, else null. */ -const httpsTwin = () => state?.https_url || null; - -async function getConfig(d: Device): Promise { - const twin = httpsTwin(); - if (twin) { - secureSheet(twin); - return null; - } - try { - return await call(`devices/${d.id}/config`); - } catch (e) { - const er = e as ApiError; - if (er.httpsUrl) secureSheet(er.httpsUrl); - else toast(er.message, true); - return null; - } -} - -/** One configuration line, highlighted; private and preshared keys masked unless shown. */ -function confLine(line: string, reveal: boolean): Node { - if (/^\s*\[.+\]\s*$/.test(line)) return h('span', { class: 'conf-sec' }, line); - const m = /^(\s*[A-Za-z0-9]+\s*=)\s*(.*)$/.exec(line); - if (!m) return document.createTextNode(line); - const secret = /^(\s*)(PrivateKey|PresharedKey)\b/.test(line); - return h( - 'span', - {}, - h('span', { class: 'conf-k' }, m[1]), - ' ', - secret ? (reveal ? h('span', { class: 'conf-v' }, m[2]) : h('span', { class: 'conf-mask' }, '••••••••••••••••')) : m[2], - ); -} - -/** The .conf as a file card (download) and a folded, highlighted view with copy and a hidden key. */ -function filePane(cfg: ClientConfig): HTMLElement { - let reveal = false; - const pre = h('pre', { class: 'conf' }); - // A key shown comes into focus out of a blur; hidden again, the mask fades back. - const paint = (toggled = false) => { - pre.replaceChildren(...cfg.conf.split('\n').flatMap((l, i) => (i ? ['\n', confLine(l, reveal)] : [confLine(l, reveal)]))); - if (toggled) pre.querySelectorAll('.conf-v, .conf-mask').forEach((el) => el.classList.add('unmask')); - }; - const eye = h( - 'button', - { - class: 'btn small', - onclick: (ev: Event) => { - ev.preventDefault(); - reveal = !reveal; - eye.replaceChildren(ic(reveal ? 'x' : 'key'), h('span', {}, reveal ? 'Hide key' : 'Show key')); - replay(eye, 'swap'); - paint(true); - }, - }, - ic('key'), - h('span', {}, 'Show key'), - ); - paint(); - return h( - 'div', - { class: 'pane' }, - h( - 'div', - { class: 'filecard' }, - h('span', { class: 'filecard-ic' }, '.conf'), - h( - 'span', - { class: 'stack' }, - h('span', { class: 'mono ellipsis' }, cfg.filename), - h( - 'span', - { class: 'faint s' }, - plainWg() - ? 'For computers and routers: import it in any WireGuard app' - : 'For computers and routers: import it in AmneziaWG or AmneziaVPN', - ), - ), - shareFile(cfg.filename, cfg.conf) - ? h( - 'button', - { class: 'btn primary', onclick: () => shareFile(cfg.filename, cfg.conf)!() }, - ic('open'), - h('span', {}, 'Share file'), - ) - : h('button', { class: 'btn primary', onclick: () => download(cfg.filename, cfg.conf) }, ic('download'), h('span', {}, 'Download')), - ), - h( - 'details', - { class: 'confbox' }, - h( - 'summary', - {}, - ic('chevron'), - h('span', {}, 'Configuration'), - h('span', { class: 'grow' }), - eye, - h( - 'button', - { - class: 'btn small', - onclick: (ev: Event) => { - ev.preventDefault(); - copy(cfg.conf, 'Configuration copied', ev.currentTarget); - }, - }, - ic('copy'), - h('span', {}, 'Copy'), - ), - ), - pre, - ), - ); -} - -/** - * The first connection arrived. The way fills green (the sheet goes back up to - * it if it was scrolled) and says so; then everything under it, which did its - * job, folds shut like an accordion while the sheet's edge comes up with it. - * Two seconds to read the way, and the sheet closes by itself onto the page - * (repainted, see catchUp). - */ -async function arrive(way: Way, rest: HTMLElement[]) { - way.connected(); - way.el.closest('.sheet-panel')?.scrollTo({ top: 0, behavior: calm() ? 'auto' : 'smooth' }); - await beat(400); - await Promise.all(rest.map((el) => fold(el))); - // Reading time, not motion: the same with less motion. - await new Promise((r) => setTimeout(r, 2000)); - // Only this sheet: not one the visitor went on to (a swap leaves the way in a ghost). - if (sheetEl?.contains(way.el) && !way.el.closest('.ghost')) closeSheet(); -} - -/** - * The first connection was seen (a fresh handshake) before the agent's watcher - * marked the device online, a second at most: ask again shortly, a few times, - * and repaint the page with the answer (unless a sheet or menu is open; closing - * it repaints), so the card goes on to "Connected" instead of staying on - * "Last connected just now". - */ -function catchUp(id: string, tries = 4) { - window.setTimeout(async () => { - try { - const st = await call('state'); - state = st; - if (!sheetEl && !menuEl) main(st); - if (!st.person.devices.find((x) => x.id === id)?.online && tries > 1) catchUp(id, tries - 1); - } catch { - /* a hiccup: the page keeps the last answer, as on load */ - } - }, 1500); -} - -/** - * Poll for the first connection of a device that never connected: 5 s at - * first, then slower, for ten minutes at most (then `gaveUp`), not while the - * tab is hidden (every poll is a process on the router), and never again once - * the link stopped working. `arrived` runs once. Returns the stop function. - */ -function watchFirstConnection(d: Device, arrived: () => void, gaveUp: () => void): () => void { - // The first connection is a handshake newer than this sheet (router clock), not `online`: - // that follows the agent's watcher, which can lag the handshake by a poll, and a device - // set up again with new keys still reports the last handshake of its old ones. - const opened = now(); - let timer = 0, - polls = 0, - done = false; - const started = Date.now(); - const poll = async () => { - timer = 0; - if (done) return; - if (Date.now() - started > 600_000) { - done = true; - gaveUp(); - return; - } - if (document.hidden) { - schedule(); - return; - } - try { - const st = await call('state'); - state = st; - const dev = st.person.devices.find((x) => x.id === d.id); - if (dev && dev.handshake > opened) { - done = true; - arrived(); - if (!dev.online) catchUp(d.id); - return; - } - } catch (e) { - if ((e as ApiError).status === 404 || (e as ApiError).status === 401) { - done = true; - return; - } - } - polls++; - schedule(); - }; - const schedule = () => { - if (!done && !timer) timer = window.setTimeout(poll, polls < 6 ? 5000 : polls < 12 ? 15000 : 30000); - }; - const onVisible = () => { - if (!document.hidden && !done && !timer) void poll(); - }; - document.addEventListener('visibilitychange', onVisible); - schedule(); - return () => { - done = true; - if (timer) clearTimeout(timer); - document.removeEventListener('visibilitychange', onVisible); - }; -} - -/* ---------- setting up a device: get the app, add the connection ---------- */ - -/** The app a device was set up with last time, so the sheet reopens on it. */ -const APP_MEMO = (d: Device) => `dl.app.${d.id}`; -function recallApp(d: Device): AppId | null { - try { - const v = localStorage.getItem(APP_MEMO(d)); - return v === 'vpn' || v === 'awg' || v === 'wg' ? v : null; - } catch { - return null; - } -} -function rememberApp(d: Device, app: AppId) { - try { - localStorage.setItem(APP_MEMO(d), app); - } catch { - /* private mode */ - } -} - -const APP_ICON: Record = { vpn: 'amnezia', awg: 'amneziawg', wg: 'wireguard' }; -const OS_ICON: Record = { - ios: 'apple', - android: 'googleplay', - windows: 'windows', - mac: 'apple', - linux: 'linux', - unknown: 'other', -}; - -/** - * A store badge: the mark in a tile, two lines, a chevron. `primary` = the one thing to tap. - * `key` names it across repaints, so a badge that now says something else comes into focus. - */ -function badge( - st: { href?: string; top: string; main: string; mark: string; onclick?: (ev: Event) => void }, - primary = false, - key?: string, -): HTMLElement { - const inner = [ - h('span', { class: 'badge-ic' }, ic(st.mark)), - h('span', { class: 'badge-txt' }, h('span', { class: 'badge-top' }, st.top), h('span', { class: 'badge-main' }, st.main)), - h('span', { class: 'badge-chev' }, ic('chevron')), - ]; - const cls = `badge${primary ? ' primary' : ''}`; - return st.onclick - ? h('button', { type: 'button', class: cls, onclick: st.onclick, 'data-m': key }, inner) - : h( - 'a', - { class: cls, href: st.href, target: st.href?.startsWith('vpn:') ? null : '_blank', rel: 'noopener noreferrer', 'data-m': key }, - inner, - ); -} - -/** Choice pills: an icon and a label each, one on. `group` keys them across repaints. */ -function pills(group: string, items: { id: string; label: string; icon?: string; on: boolean; pick: () => void }[]): HTMLElement { - return h( - 'div', - { class: 'pills' }, - items.map((it) => - h( - 'button', - { type: 'button', class: `pill${it.on ? ' on' : ''}`, onclick: it.pick, 'data-m': `${group}:${it.id}` }, - it.icon ? ic(it.icon) : null, - h('span', {}, it.label), - ), - ), - ); -} - -/** The step card: a numbered head and its content. */ -const step = (n: string, title: Kid, ...content: Kid[]) => - h( - 'div', - { class: 'step' }, - h('div', { class: 'step-head' }, h('span', { class: 'step-n' }, n), h('span', { class: 'step-title' }, title)), - ...content, - ); - -/** A link as text with Copy and, where the browser has one, the share sheet. */ -function linkRow(url: string): HTMLElement { - const share = typeof navigator.share === 'function'; - return h( - 'div', - { class: 'linkrow' }, - h('span', { class: 'mono ellipsis' }, url.replace(/^https?:\/\//, '')), - h('button', { type: 'button', class: 'btn small', onclick: (ev: Event) => copy(url, 'Link copied', ev.currentTarget) }, 'Copy'), - share - ? h( - 'button', - { - type: 'button', - class: 'icon-btn soft', - 'aria-label': 'Share the link', - onclick: () => navigator.share({ url, title: state?.title ?? 'Dawnline' }).catch(() => undefined), - }, - ic('share'), - ) - : null, - ); -} - -/** - * Set up a device: one sheet, two numbered steps. Which app and where it comes - * from follow the server's disguise and the platform the page is open on; a - * device set up from another device gets its link (and code) to take there. - */ -async function setup(d: Device, cfgIn?: ClientConfig) { - const cfg = cfgIn ?? (await getConfig(d)); - if (!cfg) return; - const key = await vpnKey(cfg, cfg.server); - const apps = appsFor(preset()); - const pf = platform(); - const handheld = d.kind === 'phone' || d.kind === 'tablet'; - const router = d.kind === 'router'; - const hereHandheld = pf === 'ios' || pf === 'android'; - const osChoices = osGroup(d.kind); - let app: AppId = recallApp(d) ?? (router ? 'awg' : 'vpn'); - if (!apps.some((a) => a.id === app)) app = router ? 'awg' : 'vpn'; - // Which system a computer (or an "other" device) runs is the person's call; the browser's guess comes first. - let os: Platform = osChoices.length ? (osChoices.includes(pf) ? pf : 'windows') : pf; - // With a system to pick, the page is on the device being set up when the pick is this browser's own. - const sameKind = sameDevice(d.kind, pf); - const same = () => (osChoices.length ? os === pf : sameKind); - // The device being set up is a phone or a tablet: its link goes there as a code for the camera. - const mobileTarget = () => handheld || os === 'ios' || os === 'android'; - let picker = false, - away = false, - open: 'link' | 'app' = 'app', - entered: string | null = null; - const body = h('div', { class: 'setup' }); - const way = waitPath(d.kind); - // The title names the device; the lines under it say "the phone". - const there = deviceNoun(d.kind); - // The device connected: the instructions are leaving, no repaint brings them back. - let finished = false; - - const appOf = (id: AppId) => apps.find((a) => a.id === id) ?? apps[0]; - const appPills = () => - pills( - 'app', - apps - .filter((a) => !router || a.id !== 'vpn') - .map((a) => ({ - id: a.id, - label: a.name, - icon: APP_ICON[a.id], - on: a.id === app, - pick: () => { - app = a.id; - rememberApp(d, app); - paint(); - }, - })), - ); - const osPills = () => - pills( - 'os', - osChoices.map((o) => ({ - id: o, - label: o === pf ? hereLabel(o) : PLATFORM_LABEL[o], - icon: OS_ICON[o], - on: o === os, - pick: () => { - os = o; - paint(); - }, - })), - ); - const storeBlock = (): Kid[] => { - const st: Store | null = router ? routerStore(app) : storeFor(app, os); - if (!st) return [h('span', { class: 'muted s' }, `Get ${APP_NAME[app]} on the ${PLATFORM_LABEL[os]} and come back here.`)]; - return [ - st.alt - ? [ - h('div', { class: 'badges2' }, badge(st, false, 'store'), badge(st.alt, false, 'store-alt')), - h('span', { class: 'faint s' }, st.alt.why), - ] - : badge(st, false, 'store'), - updateLine(appOf(app)) ? h('span', { class: 'faint s', 'data-m': 'update' }, updateLine(appOf(app))) : null, - ]; - }; - const getStep = () => - step( - '1', - [ - h('span', { class: 'grow', 'data-m': 'get' }, `Get ${APP_NAME[app]}`), - apps.length > 1 && !picker - ? h( - 'button', - { - type: 'button', - class: 'pill-link', - onclick: () => { - picker = true; - entered = 'picker'; - paint(); - }, - }, - h('span', {}, 'Another app'), - ic('chevron'), - ) - : null, - ], - picker - ? h( - 'div', - { class: `stack gap${entered === 'picker' ? ' enter' : ''}` }, - appPills(), - h('span', { class: 'faint s', 'data-m': 'app-sub' }, appOf(app).sub), - ) - : null, - osChoices.length ? osPills() : null, - ...storeBlock(), - ); - - // Step 2 follows the app and the device: a link for AmneziaVPN, the file for the others. - const connectStep = () => { - const name = APP_NAME[app]; - // On the phone being set up, a link opens AmneziaVPN only on Android; an - // iPhone takes the key as a .vpn file from the share sheet. - const inHand = same() && hereHandheld; - const send = app === 'vpn' && inHand && !opensKeyLinks(pf) ? shareFile(keyFileName(cfg.filename), key) : null; - if (app === 'vpn' && inHand && (opensKeyLinks(pf) || send)) - return step( - '2', - 'Add the connection', - send - ? badge( - { top: 'Then come back here and tap', main: 'Send to AmneziaVPN', mark: 'amnezia', onclick: () => void send() }, - true, - 'connect', - ) - : badge({ href: key, top: 'Then come back here and tap', main: 'Open in AmneziaVPN', mark: 'amnezia' }, true, 'connect'), - h( - 'span', - { class: 'faint s' }, - send ? 'Pick AmneziaVPN in the share sheet. Not there? ' : 'Nothing opened? ', - h('a', { href: '#', onclick: (ev: Event) => (ev.preventDefault(), copy(key, 'Key copied', ev.currentTarget)) }, 'Copy the key'), - ' and add it in the app.', - ), - ); - if (app === 'vpn') - return step( - '2', - 'Add the connection', - badge( - { - top: 'The connection as one key', - main: 'Copy the key', - mark: 'copy', - onclick: (ev) => copy(key, 'Key copied', ev.currentTarget), - }, - true, - 'connect', - ), - h( - 'ol', - { class: 'howto', 'data-m': 'howto' }, - h('li', {}, 'Open AmneziaVPN'), - h('li', {}, 'Add server → ', h('b', {}, 'Insert key')), - h('li', {}, 'Paste the key and connect'), - ), - ); - const share = hereHandheld ? shareFile(cfg.filename, cfg.conf) : null; - return step( - '2', - 'Add the connection', - share - ? badge( - { - top: same() ? `Straight into ${name}` : `Send it to the ${there}`, - main: 'Share the file', - mark: 'share', - onclick: () => share(), - }, - true, - 'connect', - ) - : badge( - { - top: 'Then import it in the app', - main: 'Download the file', - mark: 'download', - onclick: () => download(cfg.filename, cfg.conf), - }, - true, - 'connect', - ), - h( - 'ol', - { class: 'howto', 'data-m': 'howto' }, - // In the words of the app where the file goes: the computer's system, or the phone in hand. - importSteps(app, os, cfg.filename, !!share && same()).map(([text, bold]) => h('li', {}, text, bold ? h('b', {}, bold) : null)), - ), - ); - }; - - /** - * Two cards that hold codes, one open at a time: a folded card's head is the - * button that opens it (and folds the other); the open card's head is just a head. - */ - const foldHead = (id: 'link' | 'app', ...title: Kid[]) => - open === id - ? h('div', { class: 'step-head open', 'data-m': `fold:${id}` }, ...title) - : h( - 'button', - { - type: 'button', - class: 'step-head fold', - 'aria-expanded': 'false', - 'data-m': `fold:${id}`, - onclick: () => { - open = id; - entered = id; - paint(); - }, - }, - ...title, - h('span', { class: 'fold-chev' }, ic('chevron')), - ); - // A code keyed by what it encodes: one that now holds something else comes into focus. - const qrOf = (mark: string, text: string) => { - const q = h('div', { 'data-m': mark, 'data-sig': `${text.length}:${text.slice(-24)}` }); - paintQr(q, text); - return q; - }; - - /** What a card just unfolded comes in one piece after the other. */ - const unfolded = (now: boolean, kids: (HTMLElement | null)[]) => { - if (now) - kids - .filter((k): k is HTMLElement => !!k) - .forEach((k, i) => { - k.classList.add('unfold'); - k.style.setProperty('--i', String(i)); - }); - return kids; - }; - - // Not on the device: the link goes there (as a code for a phone's camera), the rest happens there. - // It names the device, so the page there opens straight on its set-up. - const linkThere = setupLink(location.origin + location.pathname, d.id); - const awayCard = ({ easiest = false, fold = false, or = false } = {}) => { - const title = `${or ? 'Or open' : 'Open'} your link on the ${there}`; - return h( - 'div', - { class: `step${fold && open !== 'link' ? ' folded' : ''}` }, - fold - ? foldHead( - 'link', - h('span', { class: 'step-title grow' }, title), - easiest ? h('span', { class: 'chip', 'data-glide': 'easiest' }, 'Easiest') : null, - ) - : h( - 'div', - { class: 'step-head' }, - h('span', { class: 'step-title grow' }, title), - easiest ? h('span', { class: 'chip' }, 'Easiest') : null, - ), - ...(fold && open !== 'link' - ? [] - : unfolded(entered === 'link', [ - h('span', { class: 'muted s step-sub' }, 'The same page there does both steps for that device.'), - mobileTarget() - ? h( - 'div', - { class: 'code-row' }, - qrOf('link-qr', linkThere), - h( - 'span', - { class: 'stack gap' }, - h('span', { class: 'muted s' }, 'Point its camera at the code: the link opens there.'), - qrFlip(), - ), - ) - : null, - linkRow(linkThere), - ])), - ); - }; - const awayFold = () => - away - ? (() => { - const c = awayCard(); - if (entered === 'away') c.classList.add('enter'); - return c; - })() - : h( - 'div', - { class: 'center' }, - h( - 'button', - { - type: 'button', - class: 'fold-link', - onclick: () => { - away = true; - entered = 'away'; - paint(); - }, - }, - `Not on the ${there} right now?`, - ), - ); - - // A phone set up from a computer: the link as a code, or the connection as a code for a phone that has the app. - const appCodeCard = () => - h( - 'div', - { class: `step${open !== 'app' ? ' folded' : ''}` }, - foldHead('app', h('span', { class: 'step-ic' }, ic(APP_ICON[app])), h('span', { class: 'step-title grow' }, 'Already has the app')), - ...(open !== 'app' - ? [] - : unfolded(entered === 'app', [ - apps.length > 1 ? h('div', {}, appPills()) : null, - h( - 'div', - { class: 'code-row' }, - qrOf('app-qr', app === 'vpn' ? vpnQrText(key) : cfg.conf), - h( - 'span', - { class: 'stack' }, - h('span', { class: 'muted s' }, `In ${APP_NAME[app]}: `, h('b', {}, scanPath(app)), '. The connection is added at once.'), - updateLine(appOf(app)) ? h('span', { class: 'faint s' }, updateLine(appOf(app))) : null, - qrFlip(), - ), - ), - ])), - ); - - const paint = () => { - if (finished) return; - const parts: Kid[] = []; - if (inWebview(navigator.userAgent)) - parts.push( - h( - 'div', - { class: 'notice' }, - ic('alert'), - h('span', { class: 'grow' }, 'Open this page in Safari or Chrome: the store opens from here, but the app handoff does not.'), - ), - ); - if (same()) parts.push(getStep(), connectStep(), awayFold()); - else if (router) - parts.push( - step( - '1', - [h('span', { class: 'grow', 'data-m': 'get' }, `Get ${APP_NAME[app]} on the router`)], - apps.length > 2 ? appPills() : null, - badge(routerStore(app), false, 'store'), - ), - step('2', 'Import the configuration', filePane(cfg)), - ); - else if (handheld) parts.push(awayCard({ easiest: true, fold: true }), appCodeCard()); - // A computer set up from a phone: the same two steps for the app on the computer, then the link that does both there. - else - parts.push( - h('span', { class: 'muted s' }, `The app goes on the ${there}.`), - getStep(), - connectStep(), - awayCard({ easiest: true, or: true }), - ); - restyle(body, () => body.replaceChildren(...parts.flat().filter((x): x is Node => x instanceof Node))); - entered = null; - }; - paint(); - const stop = watchFirstConnection( - d, - () => { - finished = true; - void arrive(way, [body]); - }, - way.gaveUp, - ); - sheet(`Set up ${d.name}`, same() ? 'Two steps, about a minute' : router ? 'The packages and the file for OpenWrt' : null, way.el, body); - sheetClosed = () => { - stop(); - if (state) main(state); - }; -} - -function rename(d: Device) { - const name = h('input', { type: 'text', value: d.name, maxlength: 48, 'aria-label': 'Device name' }) as HTMLInputElement; - const save = h('button', { class: 'btn primary block', type: 'submit' }, 'Save') as HTMLButtonElement; - sheet( - `Rename ${d.name}`, - null, - h( - 'form', - { - class: 'stack gap', - onsubmit: (e: Event) => { - e.preventDefault(); - void once(save, async () => { - try { - const r = await call<{ state: State }>(`devices/${d.id}`, { action: 'rename', name: name.value }); - state = r.state; - closeSheet(); - main(state); - toast('Renamed'); - } catch (er) { - toast((er as Error).message, true); - } - }); - }, - }, - name, - save, - ), - ); - setTimeout(() => name.select(), 50); -} - -/** - * Set a device up from scratch (a new phone, the app reinstalled, settings the - * admin changed): new keys, so what it holds stops working; it shows "Not set - * up yet" until it connects with the new configuration, which the set-up sheet - * opens on. - */ -function reconnect(d: Device, st: State) { - const twin = httpsTwin(); - if (twin) return secureSheet(twin); - ask({ - icon: 'refresh', - tone: 'warn', - title: `Reconnect ${d.name}?`, - text: - st.here === d.id - ? 'It gets new keys. This device is connected through its current settings: it disconnects a few seconds after you confirm. Add the new ones that open next.' - : 'It gets new keys and its current settings stop working. Set it up again with the new ones that open next.', - action: 'Reconnect', - actionClass: 'primary', - run: async () => { - try { - const r = await call<{ config: ClientConfig; state: State }>(`devices/${d.id}`, { action: 'reconnect' }); - state = r.state; - main(state); - await setup(state.person.devices.find((x) => x.id === d.id) ?? { ...d, handshake: 0 }, r.config); - } catch (er) { - toast((er as Error).message, true); - } - }, - }); -} - -function removeDevice(d: Device) { - ask({ - icon: 'trash', - tone: 'bad', - title: `Remove ${d.name}?`, - text: 'Its connection stops working at once. You can add it again later.', - action: 'Remove', - actionClass: 'danger-solid', - run: async () => { - try { - const r = await call<{ state: State }>(`devices/${d.id}`, { action: 'delete' }); - state = r.state; - closeSheet(); - // The card goes first; the rest then glide into its place. - await leave(app.querySelector(`[data-key="${CSS.escape(d.id)}"]`)); - main(state); - toast('Device removed'); - } catch (er) { - toast((er as Error).message, true); - } - }, - }); -} - -// Best guess at the device this page is open on (the browser never tells its real name). -const UA = navigator.userAgent; -const IPAD = /iPad/.test(UA) || (/Macintosh/.test(UA) && navigator.maxTouchPoints > 1); - -function guessKind(): Kind { - if (IPAD || /Tablet/i.test(UA) || (/Android/.test(UA) && !/Mobile/.test(UA))) return 'tablet'; - if (/Android|iPhone|Mobile/i.test(UA)) return 'phone'; - return 'computer'; -} - -/** Samsung model codes → names people know (S and A series; the code stays in brackets). */ -const GALAXY: [RegExp, string][] = [ - [/^SM-S93/, 'Galaxy S25'], - [/^SM-S92/, 'Galaxy S24'], - [/^SM-S91/, 'Galaxy S23'], - [/^SM-S90/, 'Galaxy S22'], - [/^SM-G99/, 'Galaxy S21'], - [/^SM-F9/, 'Galaxy Z Fold'], - [/^SM-F7/, 'Galaxy Z Flip'], - [/^SM-A5/, 'Galaxy A5x'], - [/^SM-A3/, 'Galaxy A3x'], - [/^SM-X/, 'Galaxy Tab'], -]; - -/** Android model from Client Hints (Chrome); filled in shortly after the page loads. */ -let MODEL = ''; -const modelReady: Promise = (async () => { - const uad = (navigator as Navigator & { userAgentData?: { getHighEntropyValues(h: string[]): Promise<{ model?: string }> } }) - .userAgentData; - if (!uad || !/Android/.test(UA)) return ''; - try { - const m = ((await uad.getHighEntropyValues(['model'])).model ?? '').trim(); - if (!m || m === 'K') return ''; - const g = GALAXY.find(([re]) => re.test(m)); - MODEL = g ? `${g[1]} (${m})` : /^SM-/.test(m) ? `Galaxy ${m}` : m; - } catch { - /* not offered */ - } - return MODEL; -})(); - -function guessName(kind: Kind): string { - if (/iPhone/.test(UA)) return 'iPhone'; - if (IPAD) return 'iPad'; - if (/Android/.test(UA)) return MODEL || (kind === 'tablet' ? 'Android tablet' : 'Android phone'); - if (/CrOS/.test(UA)) return 'Chromebook'; - if (/Mac OS X/.test(UA)) return 'Mac'; - if (/Windows/.test(UA)) return 'Windows PC'; - if (/Linux/.test(UA)) return 'Linux PC'; - return KIND_LABEL[kind]; -} - -function addDevice() { - if (!state) return; - const twin = httpsTwin(); - if (twin) { - secureSheet(twin); - return; - } - let kind: Kind = guessKind(); - const taken = new Set(state.person.devices.map((d) => d.name.toLowerCase())); - const suggest = (k: Kind) => { - const n = k === guessKind() ? guessName(k) : KIND_LABEL[k]; - if (!taken.has(n.toLowerCase())) return n; - for (let i = 2; i < 20; i++) if (!taken.has(`${n} ${i}`.toLowerCase())) return `${n} ${i}`; - return n; - }; - const name = h('input', { - type: 'text', - value: suggest(kind), - maxlength: 48, - 'aria-label': 'Device name', - required: true, - }) as HTMLInputElement; - let edited = false; - name.addEventListener('input', () => (edited = true)); - // The Android model arrives a moment later: use it unless they started typing. - modelReady.then(() => { - if (!edited && kind === guessKind()) name.value = suggest(kind); - }); - const kinds = h( - 'div', - { class: 'kinds' }, - (state.kinds as Kind[]).map((k) => - h( - 'button', - { - type: 'button', - class: `kind${k === kind ? ' on' : ''}`, - 'data-k': k, - onclick: () => { - kind = k; - kinds.querySelectorAll('.kind').forEach((b) => b.classList.toggle('on', (b as HTMLElement).dataset.k === k)); - if (!edited) name.value = suggest(k); - }, - }, - ic(k), - h('span', {}, KIND_LABEL[k]), - ), - ), - ); - const err = h('p', { class: 'err' }); - const submit = h('button', { class: 'btn primary block', type: 'submit' }, 'Create connection') as HTMLButtonElement; - sheet( - 'Add a device', - `${state.person.device_limit - state.person.devices.length} of ${state.person.device_limit} slots free`, - h( - 'form', - { - class: 'add', - onsubmit: async (e: Event) => { - e.preventDefault(); - submit.disabled = true; - const idle = busy(submit); - err.textContent = ''; - try { - const r = await call<{ id: string; config: ClientConfig; state: State }>('devices', { name: name.value.trim(), kind }); - state = r.state; - const dev = r.state.person.devices.find((d) => d.id === r.id)!; - await setup(dev, r.config); - } catch (er) { - if ((er as ApiError).httpsUrl) { - secureSheet((er as ApiError).httpsUrl as string); - return; - } - err.textContent = (er as Error).message; - replay(err, 'enter'); - submit.disabled = false; - } finally { - idle(); - } - }, - }, - h('label', { class: 'lbl' }, 'What is it?'), - kinds, - h('p', { class: 'muted s' }, 'Phones and tablets get a smaller packet size that suits mobile networks.'), - h('label', { class: 'lbl' }, 'Name'), - name, - err, - submit, - ), - ); -} - -/* ---------- boot ---------- */ - -/** - * A link that names a device (`#setup=d_…`: the code and the link a set-up - * sheet hands to that device) opens its set-up at once, if it still waits for - * one: on load, or when the link is opened in a tab already on this page. - * Once: the fragment comes off the address (a reload shows the page). - */ -window.addEventListener('hashchange', () => openFromLink()); function openFromLink() { + const st = state(); const id = setupFromHash(location.hash); - if (!id) return; + const add = wantsAdd(location.hash); + if (!st || (!id && !add)) return; history.replaceState(null, '', location.pathname + location.search); - const d = state?.person.devices.find((x) => x.id === id); - if (d && !d.handshake && !d.disabled && !state?.locked) void setup(d); + if (add) return startAdd(); + const d = st.person.devices.find((x) => x.id === id); + if (d && !d.handshake && !d.disabled && !st.locked) void openSetup(d); } +addEventListener('hashchange', openFromLink); async function refresh() { try { - state = await call('state'); - document.title = `${state.person.name} · ${state.title}`; - if (!sheetEl && !menuEl) main(state); + setState(await call('state')); + if (!sheetOpen() && !menuOpen()) render(); openFromLink(); } catch (e) { - const er = e as ApiError; - if (er.status === 404 || er.status === 401) { - state = null; - linkGone(); - } + if (gone(e)) linkGone(); // A network hiccup: keep showing the last state (the page loads fresh data on reload). - else if (!state) shell(h('div', { class: 'card' }, h('p', {}, er.message))); + else if (!state()) only('server', 'The page could not load', (e as Error).message); } } +// What the keyboard does never animates. +document.addEventListener('keydown', (e) => { + if (e.key !== 'Escape') return; + if (menuOpen()) closeMenu(true); + else if (sheetOpen()) closeSheet(true); +}); + // No periodic refresh: every portal request runs a CGI process on the router. // The page reloads its data after the visitor's own changes and while it waits // for a new device's first connection. diff --git a/web/src/portal/motion.ts b/web/src/portal/motion.ts index 6cf7e99..5d4459d 100644 --- a/web/src/portal/motion.ts +++ b/web/src/portal/motion.ts @@ -1,36 +1,91 @@ -// Portal motion: the moves between two states the DOM alone would snap -// between — a sheet's height following its content, cards that changed place -// after a repaint, a pane swapped for another, a sheet pulled down, a copy -// button saying it worked. This module measures and starts them; the curves, -// durations and every one-shot keyframe live in portal.css ("Motion"). +// Portal motion: the springs and curves every animation runs on, the one way +// to start an animation from script, and the pure decisions behind a sheet +// pulled down. What moves and when lives with each piece (ui/, page/, flows/); +// one-shot CSS keyframes live in the stylesheets. // -// Everything checks `calm()` (prefers-reduced-motion) and then only fades. -// The pure decisions (rubber band, when a pull dismisses) are exported for tests. +// Springs are physical (stiffness, damping) and sampled into CSS `linear()`, so +// a transition in CSS and an animation from script follow the same curve: +// BOUNCY is the skiper103 accordion (about 11% overshoot), SMOOTH the skiper21 +// tab pill (critically damped). Reduced motion keeps fades and drops travel. /** The visitor asked for less motion: fades only, nothing travels. */ export const calm = (): boolean => typeof matchMedia === 'function' && matchMedia('(prefers-reduced-motion: reduce)').matches; -/** The curves of portal.css, for animations started from script. */ -const EASE = { - out: 'cubic-bezier(0.23, 1, 0.32, 1)', - in: 'cubic-bezier(0.55, 0, 1, 0.45)', - drawer: 'cubic-bezier(0.32, 0.72, 0, 1)', -}; +export interface Spring { + /** Until it settles within 0.15% of the end. */ + duration: number; + /** The curve as CSS `linear()`. */ + easing: string; + /** Progress at `ms` (overshoots past 1 on a bouncy spring). */ + at(ms: number): number; +} + +/** A spring of stiffness `k` and damping `c` (mass 1), sampled into 64 steps. */ +export function spring(k: number, c: number, m = 1): Spring { + const w0 = Math.sqrt(k / m); + const z = c / (2 * Math.sqrt(k * m)); + const x = (t: number): number => { + if (z < 0.999) { + const wd = w0 * Math.sqrt(1 - z * z); + return 1 - Math.exp(-z * w0 * t) * (Math.cos(wd * t) + ((z * w0) / wd) * Math.sin(wd * t)); + } + if (z <= 1.001) return 1 - Math.exp(-w0 * t) * (1 + w0 * t); + const r = Math.sqrt(z * z - 1); + const s1 = -w0 * (z - r); + const s2 = -w0 * (z + r); + return 1 - (s2 * Math.exp(s1 * t) - s1 * Math.exp(s2 * t)) / (s2 - s1); + }; + let end = 0; + for (let t = 0; t < 3; t += 0.004) if (Math.abs(1 - x(t)) > 0.0015) end = t; + end += 0.004; + const pts: number[] = []; + for (let i = 0; i <= 64; i++) pts.push(+x((end * i) / 64).toFixed(4)); + pts[64] = 1; + const duration = Math.round(end * 1000); + return { duration, easing: `linear(${pts.join(', ')})`, at: (ms) => (ms >= duration ? 1 : x(ms / 1000)) }; +} + +/** The accordion, the toast, a card that pops in. */ +export const BOUNCY = spring(300, 20); +/** Pills, widths and heights: no overshoot. */ +export const SMOOTH = spring(300, 35); +/** Small things that pop: a check, a menu. */ +export const POP = spring(520, 24); +/** The leading edge of a stretching pill: faster than SMOOTH, no overshoot. */ +export const LEAD = spring(520, 46); +/** A dialog on a computer and the accordions: the menu's pop made softer (about 4% over, 90% there at ~140 ms). */ +export const SOFT = spring(380, 28); +/** What follows the pointer (a menu's highlight): there in about 130 ms, no overshoot. */ +export const QUICK = spring(900, 60); + +export const EASE_OUT = 'cubic-bezier(0.23, 1, 0.32, 1)'; +export const EASE_IN = 'cubic-bezier(0.55, 0, 1, 0.45)'; +export const DRAWER = 'cubic-bezier(0.32, 0.72, 0, 1)'; + +/** The springs as CSS variables, for transitions written in the stylesheets. */ +export function publishSprings(root: HTMLElement) { + root.style.setProperty('--spring-bouncy', BOUNCY.easing); + root.style.setProperty('--spring-bouncy-dur', `${BOUNCY.duration}ms`); + root.style.setProperty('--spring-smooth', SMOOTH.easing); + root.style.setProperty('--spring-smooth-dur', `${SMOOTH.duration}ms`); + root.style.setProperty('--spring-soft', SOFT.easing); + root.style.setProperty('--spring-soft-dur', `${SOFT.duration}ms`); + root.style.setProperty('--spring-quick', QUICK.easing); + root.style.setProperty('--spring-quick-dur', `${QUICK.duration}ms`); +} /** - * A block inside a sheet animating its own height: the sheet's edge follows it - * frame by frame on its own, so followHeight holds off meanwhile (a count: - * several such blocks may move at once). + * Start an animation. With reduced motion, an animation that fades keeps only + * its fade (short); one that only moves or resizes jumps to its end. */ -function hold(el: Element): () => void { - const panel = el.closest('.sheet-panel'); - if (!panel) return () => undefined; - panel.dataset.hold = String(+(panel.dataset.hold ?? 0) + 1); - return () => { - const n = +(panel.dataset.hold ?? 1) - 1; - if (n > 0) panel.dataset.hold = String(n); - else delete panel.dataset.hold; - }; +export function play(el: Element, frames: Keyframe[], o: KeyframeAnimationOptions): Animation { + if (!calm()) return el.animate(frames, o); + if (frames.some((f) => 'opacity' in f)) + return el.animate( + frames.map((f) => ('opacity' in f ? { opacity: f.opacity } : {})), + { duration: Math.min(Number(o.duration ?? 200), 160), easing: 'ease-out', fill: o.fill }, + ); + return el.animate(frames, { ...o, duration: 0, delay: 0 }); } /** Distance past an edge → how far it actually goes: resistance grows with the pull. */ @@ -46,416 +101,3 @@ export function dismisses(dy: number, velocity: number, height: number): boolean if (dy <= 0 || velocity < -0.1) return false; return velocity > 0.4 || dy > height / 3; } - -/** A height change takes longer the further it goes, inside the house range. */ -export const morphMs = (dist: number): number => Math.round(Math.min(380, Math.max(220, 200 + dist * 0.35))); - -/** Restart a one-shot CSS animation class on an element that already had it. */ -export function replay(el: Element, cls: string) { - el.classList.remove(cls); - void (el as HTMLElement).offsetWidth; - el.classList.add(cls); -} - -/** - * Keep `panel`'s size following `content`: whatever changes inside (a tab, a - * fold, a whole new sheet), the panel eases from the height it shows to the new - * one instead of jumping. Interruptible: a change mid-way starts from where it - * is. A width change (a window resize) only records, unless the panel asked for - * it (`data-morph="width"`: a question turning into a sheet), and then width - * and height morph together. Returns the stop. - */ -export function followHeight(panel: HTMLElement, content: HTMLElement): () => void { - let lastH = 0, - lastW = 0, - widthToo = false; - let anim: Animation | null = null; - const ro = new ResizeObserver(() => { - // Something inside moves its own height (hold): only keep up with the size. - if (panel.dataset.hold) { - anim?.cancel(); - panel.classList.remove('morphing', 'morphing-w'); - lastH = panel.offsetHeight; - lastW = panel.offsetWidth; - return; - } - const cs = getComputedStyle(panel); - const shownH = anim ? parseFloat(cs.height) : lastH; - const shownW = anim ? parseFloat(cs.width) : lastW; - anim?.cancel(); - // Measure the natural size: without the uncapped width of a morph still under way. - panel.classList.remove('morphing', 'morphing-w'); - const h = panel.offsetHeight, - w = panel.offsetWidth; - // Asked now, or still on its way from an earlier ask. - const asked = panel.dataset.morph === 'width' || widthToo; - delete panel.dataset.morph; - const resized = lastW !== 0 && w !== lastW; - lastH = h; - lastW = w; - if (!shownH || calm() || (resized && !asked)) return; - const dh = Math.abs(h - shownH), - dw = asked ? Math.abs(w - shownW) : 0; - if (dh < 2 && dw < 2) return; - widthToo = dw >= 2; - panel.classList.add('morphing'); - panel.classList.toggle('morphing-w', widthToo); - const a = panel.animate( - widthToo - ? [ - { height: `${shownH}px`, width: `${shownW}px` }, - { height: `${h}px`, width: `${w}px` }, - ] - : [{ height: `${shownH}px` }, { height: `${h}px` }], - { duration: morphMs(Math.max(dh, dw)), easing: EASE.out }, - ); - anim = a; - const done = () => { - if (anim !== a) return; - anim = null; - widthToo = false; - panel.classList.remove('morphing', 'morphing-w'); - }; - a.onfinish = done; - a.oncancel = done; - }); - ro.observe(content); - return () => ro.disconnect(); -} - -/** - * Swap `box`'s content for `next`: the old content fades out where it was - * (lifted out of the flow, so the box already takes the new height) while the - * new one comes in. `dir` -1 / 1: the new content comes from the left / right. - */ -export function swap(box: HTMLElement, next: Node[], dir = 0) { - const old = [...box.childNodes]; - if (!old.length || !box.isConnected) { - box.replaceChildren(...next); - return; - } - // The ghost lays the old content out as the box did, over the box's padding edge. - const cs = getComputedStyle(box); - const ghost = document.createElement('div'); - ghost.className = 'ghost'; - ghost.setAttribute('aria-hidden', 'true'); - ghost.inert = true; - Object.assign(ghost.style, { - display: cs.display === 'flex' ? 'flex' : 'block', - flexDirection: cs.flexDirection, - alignItems: cs.alignItems, - gap: cs.gap, - top: cs.paddingTop, - left: cs.paddingLeft, - right: cs.paddingRight, - }); - ghost.append(...old); - box.replaceChildren(ghost, ...next); - // The old content drops away fast (it sits under the new one, see .ghost) so the two never read together. - const still = calm(); - const out = ghost.animate( - [ - { opacity: 1, transform: 'none' }, - { opacity: 0, transform: still ? 'none' : `translateX(${-dir * 8}px)` }, - ], - { duration: 120, easing: EASE.out, fill: 'forwards' }, - ); - const drop = () => ghost.remove(); - out.onfinish = drop; - out.oncancel = drop; - for (const n of next) - if (n instanceof HTMLElement) - n.animate( - still - ? [{ opacity: 0 }, { opacity: 1 }] - : [ - { opacity: 0, transform: `translate(${dir * 12}px, ${dir ? 0 : 6}px)`, filter: 'blur(4px)' }, - { opacity: 1, transform: 'none', filter: 'blur(0)' }, - ], - { duration: still ? 160 : 280, delay: 50, easing: EASE.out, fill: 'backwards' }, - ); -} - -/** Play an element's way out before it is removed (it keeps its place until then). */ -export function leave(el: Element | null | undefined): Promise { - if (!el || !el.isConnected) return Promise.resolve(); - const a = el.animate( - calm() - ? [{ opacity: 1 }, { opacity: 0 }] - : [ - { opacity: 1, transform: 'none', filter: 'blur(0)' }, - { opacity: 0, transform: 'scale(0.96)', filter: 'blur(4px)' }, - ], - { duration: 200, easing: EASE.in, fill: 'forwards' }, - ); - return a.finished.then( - () => undefined, - () => undefined, - ); -} - -/** A beat between the steps of a sequence; none when the visitor asked for less motion. */ -export const beat = (ms: number): Promise => new Promise((r) => setTimeout(r, calm() ? 0 : ms)); - -/** - * The accordion's look: the height closes on the drawer curve over `ms`; the - * content dissolves faster, from the start, as blocks leave elsewhere (blur, a - * small rise and shrink, on the strong ease-out over `contentMs`). - */ -const FOLD = { ms: 520, contentMs: 300, blur: 4, drift: 6, scale: 0.98 }; - -/** - * Fold a block shut like an accordion and take it out: its height closes from - * the bottom edge (the sheet's edge comes with it) while its content dissolves - * into a blur. Less motion: it fades. - */ -export async function fold(el: HTMLElement): Promise { - if (!el.isConnected) return; - const release = hold(el); - const gap = parseFloat(getComputedStyle(el.parentElement as HTMLElement).rowGap) || 0; - const h = el.offsetHeight; - el.style.overflow = 'hidden'; - el.style.transformOrigin = '50% 0'; - el.inert = true; - const done = () => undefined; - if (calm()) - await el.animate([{ opacity: 1 }, { opacity: 0 }], { duration: 160, easing: EASE.out, fill: 'forwards' }).finished.then(done, done); - else { - el.animate( - [ - { opacity: 1, filter: 'blur(0px)', transform: 'none' }, - { opacity: 0, filter: `blur(${FOLD.blur}px)`, transform: `translateY(${-FOLD.drift}px) scale(${FOLD.scale})` }, - ], - { duration: FOLD.contentMs, easing: EASE.out, fill: 'forwards' }, - ); - await el - .animate( - [ - { height: `${h}px`, marginTop: '0px' }, - { height: '0px', marginTop: `${-gap}px` }, - ], - { duration: FOLD.ms, easing: EASE.drawer, fill: 'forwards' }, - ) - .finished.then(done, done); - } - el.remove(); - release(); -} - -/** - * The opposite, for a line that just got something to say: it opens from no - * height to its own (the sheet's edge comes with it) and comes into focus. - */ -export function grow(el: HTMLElement) { - if (!el.isConnected || calm()) return replay(el, 'swap'); - const release = hold(el); - const gap = parseFloat(getComputedStyle(el.parentElement as HTMLElement).rowGap) || 0; - const h = el.offsetHeight; - el.style.overflow = 'hidden'; - const a = el.animate( - [ - { height: '0px', marginTop: `${-gap}px`, opacity: 0, filter: 'blur(4px)' }, - { height: `${h}px`, marginTop: '0px', opacity: 1, filter: 'blur(0px)' }, - ], - { duration: 380, easing: EASE.drawer }, - ); - const end = () => { - el.style.overflow = ''; - release(); - }; - a.onfinish = end; - a.oncancel = end; -} - -/** - * The page's first paint: the blocks matching `selector` rise in, in reading - * order (top to bottom, then left to right, whatever the layout), at most - * eight steps apart. portal.css draws `.intro`; `--i` is the step. - */ -export function intro(root: ParentNode, selector: string) { - const els = [...root.querySelectorAll(selector)].map((el) => ({ el, r: el.getBoundingClientRect() })); - els.sort((a, b) => Math.round(a.r.top - b.r.top) || a.r.left - b.r.left); - els.forEach(({ el }, i) => { - el.style.setProperty('--i', String(Math.min(i, 8))); - el.classList.add('intro'); - }); -} - -/** Where the keyed blocks of a page are and what its keyed values say, before a repaint. */ -export interface Snap { - at: Map; - text: Map; -} - -export function snap(root: ParentNode): Snap { - const at = new Map(); - const text = new Map(); - root.querySelectorAll('[data-key]').forEach((el) => { - const r = el.getBoundingClientRect(); - at.set(el.dataset.key as string, { x: r.left + scrollX, y: r.top + scrollY }); - }); - root.querySelectorAll('[data-v]').forEach((el) => text.set(el.dataset.v as string, el.textContent ?? '')); - return { at, text }; -} - -/** - * After a repaint: a keyed block that moved glides from where it was (FLIP), - * one that is new rises in, a keyed value that changed comes into focus. - * Keyed blocks are never nested, so no move is counted twice. - */ -export function settle(root: ParentNode, before: Snap) { - const still = calm(); - root.querySelectorAll('[data-key]').forEach((el) => { - const was = before.at.get(el.dataset.key as string); - if (!was) { - el.classList.add('enter'); - return; - } - if (still) return; - const r = el.getBoundingClientRect(); - const dx = was.x - (r.left + scrollX), - dy = was.y - (r.top + scrollY); - if (Math.abs(dx) < 1 && Math.abs(dy) < 1) return; - el.animate([{ transform: `translate(${dx}px, ${dy}px)` }, { transform: 'none' }], { - duration: morphMs(Math.hypot(dx, dy)), - easing: EASE.out, - }); - }); - root.querySelectorAll('[data-v]').forEach((el) => { - const was = before.text.get(el.dataset.v as string); - if (was != null && was !== el.textContent) el.classList.add('swap'); - }); -} - -/** - * A repaint of a sheet's content that keeps its motion: keyed controls - * (`data-m`) that flipped on or off get `to-on` / `to-off`, whose keyframes - * start from the other look; one whose text changed comes into focus (`swap`); - * one marked `data-glide` that moved within its parent (a chip beside a chevron - * that went) glides there. - */ -export function restyle(root: ParentNode, paint: () => void) { - const state = (el: Element) => el.classList.contains('on') || el.classList.contains('open'); - // What it says: its text, or `data-sig` where the text says nothing (a QR code). - const says = (el: HTMLElement) => el.dataset.sig ?? el.textContent ?? ''; - const inParent = (el: HTMLElement) => { - const r = el.getBoundingClientRect(), - p = (el.parentElement as HTMLElement).getBoundingClientRect(); - return { x: r.left - p.left, y: r.top - p.top }; - }; - const before = new Map(); - root.querySelectorAll('[data-m]').forEach((el) => before.set(el.dataset.m as string, { on: state(el), says: says(el) })); - const placed = new Map(); - root.querySelectorAll('[data-glide]').forEach((el) => placed.set(el.dataset.glide as string, inParent(el))); - paint(); - if (!calm()) - root.querySelectorAll('[data-glide]').forEach((el) => { - const was = placed.get(el.dataset.glide as string); - if (!was) return; - const now = inParent(el); - const dx = was.x - now.x, - dy = was.y - now.y; - if (Math.abs(dx) >= 1 || Math.abs(dy) >= 1) - el.animate([{ transform: `translate(${dx}px, ${dy}px)` }, { transform: 'none' }], { duration: 280, easing: EASE.out }); - }); - root.querySelectorAll('[data-m]').forEach((el) => { - const was = before.get(el.dataset.m as string); - if (!was) return; - if (was.on !== state(el)) el.classList.add(state(el) ? 'to-on' : 'to-off'); - else if (was.says !== says(el)) el.classList.add('swap'); - }); -} - -/** A copy button in its "Copied" moment: what to put back, and when. */ -const COPIED = new WeakMap(); - -/** - * A copy button says it worked where the finger is: its icon turns into a - * check and a "Copy" label into "Copied", for a moment. Other labels (a host - * name on a chip) stay. `check` is the check icon's markup. - */ -export function copied(btn: HTMLElement | null | undefined, check: string) { - if (!btn) return; - const icon = btn.querySelector('.ic'); - const label = - btn.querySelector('.badge-main') ?? - btn.querySelector(':scope > span:not(.ic)') ?? - (btn.children.length ? null : btn); - const was = COPIED.get(btn) ?? { timer: 0, icon: icon?.innerHTML ?? null, label: label?.textContent ?? null }; - clearTimeout(was.timer); - const says = !!label && (label.classList.contains('badge-main') || /^copy$/i.test(was.label ?? '')); - const show = (svg: string | null, text: string | null) => { - if (icon && svg != null && icon.innerHTML !== svg) { - icon.innerHTML = svg; - replay(icon, 'swap-ic'); - } - if (label && says && text != null && label.textContent !== text) { - label.textContent = text; - replay(label, 'swap'); - } - }; - show(check, 'Copied'); - btn.classList.add('copied'); - was.timer = window.setTimeout(() => { - COPIED.delete(btn); - btn.classList.remove('copied'); - show(was.icon, was.label); - }, 1600); - COPIED.set(btn, was); -} - -/** A button waiting for the router: after a beat (no flash on a quick answer) a spinner takes the label's place. */ -export function busy(btn: HTMLElement): () => void { - const t = window.setTimeout(() => btn.classList.add('busy'), 250); - return () => { - clearTimeout(t); - btn.classList.remove('busy'); - }; -} - -/** - * Let a bottom sheet be pulled down by its grab bar and head (a question: all of it): the panel - * follows the finger (with resistance upwards), the scrim fades with it, and - * on release it either goes (`close`) or springs back. Only while `bottom()` - * (the sheet sits at the bottom: phones). The release transitions start from - * the dragged spot because the inline transform and `.dragging` go together. - */ -export function pullToClose(panel: HTMLElement, scrim: HTMLElement, close: () => void, bottom: () => boolean) { - panel.addEventListener('pointerdown', (e) => { - const t = e.target as Element; - if (!bottom() || e.button !== 0 || !t.closest('.grab, .sheet-head, .ask') || t.closest('button, a, input')) return; - const y0 = e.clientY, - h = panel.offsetHeight; - let dy = 0; - const trail: { t: number; y: number }[] = [{ t: e.timeStamp, y: e.clientY }]; - try { - panel.setPointerCapture(e.pointerId); - } catch { - /* a pointer the browser no longer tracks: the pull still follows while it is over the panel */ - } - panel.classList.add('dragging'); - const move = (ev: PointerEvent) => { - const raw = ev.clientY - y0; - dy = raw < 0 ? -rubber(-raw, h) : raw; - panel.style.transform = `translateY(${dy}px)`; - scrim.style.opacity = String(1 - Math.max(0, dy) / h); - trail.push({ t: ev.timeStamp, y: ev.clientY }); - while (trail.length > 2 && ev.timeStamp - trail[0].t > 100) trail.shift(); - }; - const up = (ev: PointerEvent) => { - panel.removeEventListener('pointermove', move); - panel.removeEventListener('pointerup', up); - panel.removeEventListener('pointercancel', up); - const first = trail[0], - last = trail[trail.length - 1]; - const v = last.t > first.t ? (last.y - first.y) / (last.t - first.t) : 0; - panel.classList.remove('dragging'); - panel.style.transform = ''; - scrim.style.opacity = ''; - if (ev.type === 'pointerup' && dismisses(dy, v, h)) close(); - }; - panel.addEventListener('pointermove', move); - panel.addEventListener('pointerup', up); - panel.addEventListener('pointercancel', up); - }); -} diff --git a/web/src/portal/page/access.ts b/web/src/portal/page/access.ts new file mode 100644 index 0000000..5c31ca2 --- /dev/null +++ b/web/src/portal/page/access.ts @@ -0,0 +1,311 @@ +// "Your access", set by the admin: one accordion of three rows. What the +// access reaches (home and internet as two tiles, and the names devices at +// home reach this person's devices by); the data, as a ring in the head and +// the month day by day inside; and until when, as the days left over a +// calendar of the weeks, with the admin's hours as a bar of the day. + +import type { Person } from '../../shared/types'; +import { ACCESS_LABEL, byDeviceState, bytes, date, daysLeft, endsSoon, parseDay } from '../../shared/format'; +import { h, ic, markup } from '../dom'; +import { calendar, clockOf, hoursFor, minuteAt, monthOf, stretches } from '../days'; +import { now, today, type State } from '../state'; +import { accordion, type Accordion } from '../ui/accordion'; +import { copy } from '../ui/feedback'; +import { glass } from '../ui/glass'; +import { morphChanged, setText, textsOf } from '../ui/morph'; +import { reachableFromHome } from './devices'; + +const desc = (text: string) => h('p', { class: 'desc' }, text); +/** A share of a length, as a CSS percentage. */ +const pc = (part: number, whole: number) => `${((part / whole) * 100).toFixed(2)}%`; + +/** What the access reaches, as two tiles: the home network and the internet, each in or out. */ +function reachTiles(access: Person['access']): HTMLElement { + const tile = (on: boolean, icon: string, name: string, sub: string) => + h( + 'div', + { class: `reach-tile${on ? '' : ' off'}` }, + glass(icon, on ? 'blue' : 'grey', 'gi rt-ic'), + h('b', {}, name), + h('span', { class: 'rt-sub' }, on ? sub : 'Not included'), + h('span', { class: 'rt-mark', 'aria-label': on ? 'Included' : 'Not included' }, ic(on ? 'check' : 'minus')), + ); + return h( + 'div', + { class: 'reach2' }, + tile(access !== 'internet', 'home', 'Home network', 'Devices at home'), + tile(access !== 'lan', 'globe', 'Internet', 'Through the router'), + ); +} + +/** How other devices at home reach this person's devices: once, here, only where the router lets them through. */ +function namesAtHome(p: Person, mesh: boolean): Node[] { + const named = byDeviceState(p.devices).filter((d) => d.hostname && reachableFromHome(p, d)); + if (!named.length) return []; + const first = named[0].hostname; + const dot0 = first.indexOf('.'); + const domain = dot0 > 0 ? first.slice(dot0) : ''; + return [ + h( + 'span', + { class: 'lbl-s' }, + mesh ? 'Devices at home and on this VPN reach yours as ' : 'Other devices at home reach yours as ', + h('span', { class: 'mono' }, `name${domain}`), + ), + h( + 'div', + { class: 'names' }, + named.map((d) => { + const dot = d.hostname.indexOf('.'); + return h( + 'button', + { + type: 'button', + class: 'namechip', + title: d.name, + 'aria-label': `Copy ${d.hostname}`, + onclick: (ev: Event) => copy(d.hostname, 'Address copied', ev.currentTarget), + }, + h('span', {}, dot > 0 ? [d.hostname.slice(0, dot), h('span', { class: 'faint' }, d.hostname.slice(dot))] : d.hostname), + ic('copy'), + ); + }), + ), + ]; +} + +/** Used against the limit, as a small ring (its colour: fine, nearly full, full). */ +function ring(pct: number): Element { + const c = 2 * Math.PI * 6; + const tone = pct >= 100 ? ' bad' : pct >= 90 ? ' warn' : ''; + return markup( + ``, + ); +} + +function meter(pct: number): HTMLElement { + const i = h('i', { class: pct >= 100 ? 'bad' : pct >= 90 ? 'warn' : '' }); + i.style.width = `${pct.toFixed(1)}%`; + return h('div', { class: 'meter' }, i); +} + +/** The month as one bar a day (today in blue, days to come faint), and the total under it. */ +function month(p: Person, used: number, pct: number): HTMLElement { + const { days, day } = monthOf(today()); + const series = p.month_days ?? []; + const max = Math.max(1, ...series); + const short = (d: number) => + parseDay(`${today().slice(0, 8)}${String(d).padStart(2, '0')}`).toLocaleDateString('en-GB', { day: 'numeric', month: 'short' }); + // The total, and a bar under the pointer in its place, at once: no morph while the pointer moves. + const total = h('b', { class: 'num', 'data-t': 'm-used' }, bytes(used)); + const tail = h('span', {}, ' used'); + const read = h('span', { class: 'mread' }, total, tail); + const bars = h('div', { class: 'mbars' }); + for (let i = 0; i < days; i++) { + if (i >= day) { + bars.appendChild(h('i', { class: 'future' })); + continue; + } + const v = series[i] ?? 0; + const b = h('i', { class: i === day - 1 ? 'today' : '' }); + b.style.height = `${Math.max(3, Math.round((v / max) * 64))}px`; + b.addEventListener('pointerenter', () => { + setText(total, bytes(v)); + setText(tail, ` on ${short(i + 1)}`); + }); + b.addEventListener('pointerleave', () => { + setText(total, bytes(used)); + setText(tail, ' used'); + }); + bars.appendChild(b); + } + // "Today" under its bar; the month's ends step aside when it comes close. + const td = h('span', { class: 'td' }, 'Today'); + td.style.left = pc(day - 0.5, days); + const axis = h( + 'div', + { class: 'month-axis' }, + h('span', { class: day <= 4 ? 'hide' : '' }, short(1)), + td, + h('span', { class: day >= days - 3 ? 'hide' : '' }, short(days)), + ); + return h( + 'div', + { class: 'month' }, + bars, + axis, + h( + 'div', + { class: 'month-read' }, + read, + h( + 'span', + { class: `num${p.state === 'quota' ? ' bad-t' : ''}`, 'data-t': 'm-left' }, + p.quota_limit ? `${bytes(Math.max(0, p.quota_limit - used))} left` : 'No limit', + ), + ), + p.quota_limit ? meter(pct) : null, + ); +} + +/** The days left as a number over a calendar of the weeks to the end (the last day ringed). */ +function untilCal(p: Person, left: number): HTMLElement { + const day = (d: string) => parseDay(d).toLocaleDateString('en-GB', { weekday: 'short', day: 'numeric', month: 'short' }); + const cells = calendar(today(), p.expires); + const cal = cells + ? h( + 'div', + { class: 'cal', 'aria-hidden': 'true' }, + h( + 'div', + { class: 'cal-h' }, + ['M', 'T', 'W', 'T', 'F', 'S', 'S'].map((x) => h('span', {}, x)), + ), + h( + 'div', + { class: 'cal-g' }, + cells.map((c, i) => { + const el = h('i', { class: c.kind, title: day(c.day) }); + el.style.setProperty('--i', String(i)); + return el; + }), + ), + ) + : null; + return h( + 'div', + { class: `until${endsSoon(p, left) ? ' soon' : ''}` }, + h( + 'div', + { class: 'until-num' }, + h('b', { class: 'num' }, String(left)), + h('span', {}, `${left === 1 ? 'day' : 'days'} left`), + h('span', { class: 'until-sub' }, `Ends ${day(p.expires)}`), + ), + cal, + ); +} + +/** The day as 24 hours in the visitor's time: the admin's window filled, now marked. */ +function hoursBar(hours: string, tzOffset: number | undefined): HTMLElement | null { + const visitor = -new Date().getTimezoneOffset(); + const hw = hoursFor(hours, tzOffset, visitor); + if (!hw) return null; + // The router's clock, read in the visitor's zone (or the router's, without its offset). + const at = minuteAt(now(), hw.yours ? visitor : (tzOffset ?? visitor)); + const segs = stretches(hw); + const inside = segs.some(([a, b]) => at >= a && at < b); + const bar = h('div', { class: 'hours-bar' }); + for (const [a, b] of segs) { + const i = h('i'); + i.style.left = pc(a, 1440); + i.style.width = pc(b - a, 1440); + bar.appendChild(i); + } + const mark = h('span', { class: `hours-now${inside ? '' : ' out'}`, title: `Now, ${clockOf(at)}` }); + mark.style.left = pc(at, 1440); + bar.appendChild(mark); + return h( + 'div', + { class: 'hours' }, + h( + 'div', + { class: 'hours-top' }, + h('span', {}, hw.yours ? 'Hours, your time' : 'Hours, router time'), + h('b', { class: 'num' }, `${clockOf(hw.from)}–${clockOf(hw.to)}`), + ), + bar, + h( + 'div', + { class: 'hours-axis' }, + ['00', '06', '12', '18', '24'].map((x) => h('span', {}, x)), + ), + ); +} + +/** The access accordion for this state; `open`: the row to keep open (a repaint), else the data. */ +export function accessAccordion(st: State, open = 1): Accordion { + const p = st.person; + const used = p.quota_used || p.month[0] + p.month[1]; + const pct = p.quota_limit ? Math.min(100, (used / p.quota_limit) * 100) : 0; + // A total over the whole access only with a limit; otherwise it is this month's count. + const total = p.quota_period === 'total' && !!p.quota_gb; + const left = daysLeft(p.expires, today()); + const untilVal = p.expires + ? h( + 'span', + { class: 'until-val' }, + h('span', { class: 'num', 'data-t': 'until-date' }, date(p.expires).replace(/ \d{4}$/, '')), + left != null + ? h( + 'span', + { class: `num ${left < 0 ? 'bad-t' : endsSoon(p, left) ? 'warn-t' : 'ok-t'}`, 'data-t': 'until-left' }, + left >= 0 ? `${left} day${left === 1 ? '' : 's'}` : 'ended', + ) + : null, + ) + : h('span', {}, 'No end date'); + const untilBody = [ + !p.expires ? null : left != null && left < 0 ? desc(`It ended on ${date(p.expires)}.`) : untilCal(p, left ?? 0), + p.hours ? hoursBar(p.hours, st.tz_offset) : null, + ]; + return accordion( + [ + { + icon: glass(p.access === 'internet' ? 'globe' : p.access === 'lan' ? 'home' : 'shield'), + title: ACCESS_LABEL[p.access], + body: [reachTiles(p.access), ...namesAtHome(p, !!st.server.device_mesh)], + }, + { + icon: glass('chart'), + title: total ? 'Data used' : 'Data this month', + val: h( + 'span', + { class: 'data-val' }, + p.quota_limit ? ring(pct) : null, + h( + 'span', + { class: 'num', 'data-t': 'data-val' }, + `${bytes(used)}${p.quota_limit ? ` / ${bytes(p.quota_limit)}` : ' · no limit'}`, + ), + ), + valHide: true, + body: [ + total ? desc(`${bytes(used)} of ${bytes(p.quota_limit)} in total.`) : month(p, used, pct), + desc( + !p.quota_limit + ? 'No data limit. The count starts again on the 1st.' + : total + ? 'A total for your whole access, it does not reset.' + : 'Resets on the 1st.', + ), + ], + }, + // No end date and no hours: nothing to open, the row just says so. + { icon: glass('calendar'), title: 'Access until', val: untilVal, valHide: !!p.expires && (left ?? 0) >= 0, body: untilBody }, + ], + { open }, + ); +} + +/** The section, built once; `fillAccess` puts the accordion in. */ +export function accessSection(): HTMLElement { + return h( + 'section', + { class: 'access', id: 'access', 'aria-label': 'Your access' }, + h('div', { class: 'sec-head' }, h('h2', {}, 'Your access')), + h('div', { class: 'acc-slot' }), + ); +} + +let shown: Accordion | null = null; +/** The accordion for this state, the same row open as before. */ +export function fillAccess(section: HTMLElement, st: State) { + const acc = accessAccordion(st, shown ? shown.openIndex() : 1); + // The values it showed: what changed morphs from it. + const said = textsOf(section); + section.querySelector('.acc-slot')!.replaceChildren(acc.el); + if (shown) morphChanged(section, said); + shown = acc; +} diff --git a/web/src/portal/page/devices.ts b/web/src/portal/page/devices.ts new file mode 100644 index 0000000..4d70c37 --- /dev/null +++ b/web/src/portal/page/devices.ts @@ -0,0 +1,293 @@ +// "Your devices": a card per device (the one this page is open on first, then +// by state), the card to add one, and the count. A repaint keeps the grid: +// cards that stay glide to their new places, a new one pops in, one that just +// connected rings green for a moment. What a card's buttons start lives in +// flows/. + +import type { Device, Person } from '../../shared/types'; +import { addDays, ago, byDeviceState, bytes, parseDay } from '../../shared/format'; +import { h, ic } from '../dom'; +import { BOUNCY, EASE_IN, EASE_OUT, SMOOTH, play } from '../motion'; +import { now, today, type RepaintOpts, type State } from '../state'; +import { copy } from '../ui/feedback'; +import { glass } from '../ui/glass'; +import { openMenu, type MenuItem } from '../ui/menu'; +import { morphChanged, morphText, setText, textsOf } from '../ui/morph'; +import { startAdd } from '../flows/add'; +import { reconnect, removeDevice, rename } from '../flows/device-actions'; +import { openSetup } from '../flows/setup-view'; + +/** The home network can open connections to it: home access, active, and the device on. */ +export const reachableFromHome = (p: Person, d: Device) => p.access !== 'internet' && p.state === 'active' && !d.disabled; + +/** The status line: its class and words (short, on one line; the full wording shows on hover). */ +function statusOf(d: Device, p: Person): [string, string] { + if (d.disabled) return ['', 'Disabled']; + // The Update pill beside it says what to do. + if (d.config_stale && d.handshake) return ['warn-t', 'Settings changed']; + // Over the data limit or outside the hours the tunnel stays up but passes nothing: the app says + // "connected", so say here why nothing works. + if (d.online && p.state === 'quota') return ['warn-t', 'Connected, no data left']; + if (d.online && p.state === 'hours') return ['warn-t', 'Connected, outside your hours']; + if (d.online) return ['ok-t', 'Connected']; + if (!d.handshake) return ['warn-t', 'Not set up yet']; + return ['', `Last connected ${ago(d.handshake, now())}`]; +} + +function menuItems(d: Device, st: State): (MenuItem | null)[] { + return [ + // How devices at home reach it: only where the router actually lets them through. + ...(reachableFromHome(st.person, d) + ? [ + { label: 'Copy IP address', icon: 'copy', run: () => copy(d.address, 'IP address copied') }, + ...(d.hostname ? [{ label: 'Copy local address', icon: 'home', run: () => copy(d.hostname, 'Address copied') }] : []), + null, + ] + : []), + // A device the admin turned off can't be renamed, set up again or removed here (the router refuses). + ...(d.disabled + ? [] + : [ + { label: 'Rename', icon: 'edit', run: () => rename(d) }, + { label: 'Reconnect', icon: 'refresh', tone: 'warn' as const, run: () => reconnect(d) }, + { label: 'Remove', icon: 'trash', tone: 'bad' as const, run: () => removeDevice(d) }, + ]), + ]; +} + +/** "Today", "Yesterday", "Tue 13 Oct": a spark bar's day, on the router's calendar. */ +function dayName(back: number): string { + if (back === 0) return 'Today'; + if (back === 1) return 'Yesterday'; + return parseDay(addDays(today(), -back)).toLocaleDateString('en-GB', { weekday: 'short', day: 'numeric', month: 'short' }); +} + +/** Last 7 days as a number and bars; a bar under the pointer puts its own day in the number's place. */ +function usage(d: Device, stale: boolean): HTMLElement { + const week = d.spark.reduce((a, b) => a + b, 0); + const lbl = h('span', { class: 'use-lbl' }, 'Last 7 days'); + const val = h('span', { class: 'use-val num', 'data-t': `${d.id}:use` }, bytes(week)); + let side: HTMLElement; + if (stale) + side = h( + 'button', + { + type: 'button', + class: 'upd-pill', + 'aria-label': 'Update the connection', + title: 'Its settings changed: update the connection', + onclick: () => reconnect(d), + }, + ic('refresh'), + h('span', {}, 'Update'), + ); + else { + const max = Math.max(1, ...d.spark); + side = h('div', { class: 'spark' }); + d.spark.forEach((v, i) => { + const back = d.spark.length - 1 - i; + const b = h('i', { class: back === 0 ? 'today' : '' }); + b.style.height = `${Math.max(3, Math.round((v / max) * 34))}px`; + // What the pointer reads off the bars changes at once: no morph while it moves. + b.addEventListener('pointerenter', () => { + setText(lbl, dayName(back)); + setText(val, bytes(v)); + }); + b.addEventListener('pointerleave', () => { + setText(lbl, 'Last 7 days'); + setText(val, bytes(week)); + }); + side.appendChild(b); + }); + } + return h('div', { class: 'dev-use' }, h('div', { class: 'use-txt' }, lbl, val), side); +} + +function card(d: Device, st: State): HTMLElement { + const p = st.person; + const locked = !!st.locked; + // The device this page was opened from (through the tunnel): it is connected, so say which one it is instead. + const here = st.here === d.id; + const [cls, words] = here ? ['here-t', 'This device'] : statusOf(d, p); + const setUp = !d.handshake && !d.disabled; + const stale = d.config_stale && !setUp && !locked && !d.disabled; + // On one line; the exact time, or the whole wording, on hover. + const title = + !here && d.handshake && !d.online && !d.disabled && !d.config_stale + ? new Date(d.handshake * 1000).toLocaleString('en-GB') + : stale + ? 'Settings changed, update needed' + : words; + const items = menuItems(d, st); + const more = + locked || !items.length + ? null + : h( + 'button', + { type: 'button', class: 'knob more', 'aria-label': `${d.name} options`, 'aria-haspopup': 'menu', 'aria-expanded': 'false' }, + ic('more'), + ); + more?.addEventListener('click', () => openMenu(more, items)); + return h( + 'article', + { class: `dev${here ? ' is-here' : ''}${d.disabled ? ' off' : ''}`, 'data-id': d.id }, + h( + 'div', + { class: 'dev-top' }, + glass(d.kind, here ? 'blue' : 'grey'), + h( + 'div', + { class: 'dev-id' }, + h('span', { class: 'dev-name', 'data-t': `${d.id}:name` }, d.name), + h('span', { class: `dev-stat ${cls}`, title, 'data-t': `${d.id}:stat` }, words), + ), + more, + ), + // Stopped by the admin: a device never set up has nothing to show. + setUp && locked + ? null + : setUp + ? h( + 'button', + { + type: 'button', + class: 'btn tint block setup-btn', + 'aria-label': `Set up ${d.name}`, + onclick: (ev: Event) => openSetup(d, ev.currentTarget), + }, + ic('qr'), + h('span', {}, 'Connect'), + ) + : usage(d, stale), + ); +} + +/** Nothing yet: one card that says what comes, with the button. */ +const firstCard = (mobile: boolean) => + h( + 'div', + { class: 'dev first', 'data-id': 'first' }, + glass('plus', 'blue'), + h('b', {}, 'Add your first device'), + h('p', {}, 'Two steps, about a minute: get the app, then add the connection.'), + h( + 'button', + { type: 'button', class: 'btn accent block', onclick: startAdd }, + ic('plus'), + h('span', {}, mobile ? 'Add this phone' : 'Add this device'), + ), + ); + +const addCard = () => + h('button', { type: 'button', class: 'dev add', 'data-id': 'add', onclick: startAdd }, glass('plus'), h('span', {}, 'Add device')); + +/** The section, built once; `fill` puts the cards in. */ +export function devicesSection(): HTMLElement { + return h( + 'section', + { class: 'devices', id: 'devices', 'aria-label': 'Your devices' }, + h('div', { class: 'sec-head' }, h('h2', {}, 'Your devices'), h('span', { class: 'aside num' })), + h('div', { class: 'dgrid' }), + h('p', { class: 'note-s limit', hidden: true }), + ); +} + +/** The cards for this state, moving from where they were. */ +export function fillDevices(section: HTMLElement, st: State, o: RepaintOpts = {}) { + const p = st.person; + const grid = section.querySelector('.dgrid') as HTMLElement; + // A repaint (not the first paint, which brings everything in): what newly shows comes in too. + const repainting = grid.childElementCount > 0; + const first = new Map([...grid.querySelectorAll('[data-id]')].map((c) => [c.dataset.id, c.getBoundingClientRect()])); + // What each card said (a name, its status, its week): what changed morphs from it once the cards are in place. + const said = textsOf(grid); + // The device this page was opened from comes first. + const order = byDeviceState(p.devices).sort((a, b) => Number(b.id === st.here) - Number(a.id === st.here)); + const cards = order.map((d) => card(d, st)); + const free = st.locked ? 0 : Math.max(0, p.device_limit - p.devices.length); + const mobile = matchMedia('(max-width: 959px)').matches || /Android|iPhone|iPad/.test(navigator.userAgent); + if (!p.devices.length && free) cards.push(firstCard(mobile)); + // Paused or ended: the router refuses a new device, so there is no card to offer one (the notice says why). + else if (st.can_add && !st.locked) cards.push(addCard()); + grid.classList.toggle('empty', !p.devices.length); + grid.replaceChildren(...cards); + for (const c of cards) { + const f = first.get(c.dataset.id); + const l = c.getBoundingClientRect(); + if (c.dataset.id === o.pop) + play( + c, + [ + { opacity: 0, transform: 'scale(.9)', filter: 'blur(6px)' }, + { opacity: 1, transform: 'none', filter: 'none' }, + ], + { + duration: BOUNCY.duration, + easing: BOUNCY.easing, + }, + ); + else if (f && (f.left !== l.left || f.top !== l.top)) + play(c, [{ transform: `translate(${f.left - l.left}px, ${f.top - l.top}px)` }, { transform: 'none' }], { + duration: SMOOTH.duration, + easing: SMOOTH.easing, + }); + // New on a repaint (Add device once a slot frees up): it comes in the way a removed card leaves, a beat after. + else if (!f && repainting) + play( + c, + [ + { opacity: 0, transform: 'scale(.9)', filter: 'blur(6px)' }, + { opacity: getComputedStyle(c).opacity, transform: 'none', filter: 'none' }, + ], + { + duration: SMOOTH.duration, + delay: 60, + easing: SMOOTH.easing, + fill: 'backwards', + }, + ); + if (c.dataset.id === o.flash) + c.animate([{ boxShadow: 'inset 0 0 0 1.5px var(--ok)' }, { boxShadow: 'inset 0 0 0 1.5px transparent' }], { + duration: 1800, + easing: 'ease-out', + }); + } + if (repainting) morphChanged(grid, said); + const count = section.querySelector('.sec-head .aside') as HTMLElement; + const n = `${p.devices.length} of ${p.device_limit}`; + if (repainting) morphText(count, n); + else count.textContent = n; + // The admin may add devices past the limit. + count.classList.toggle('warn-t', p.devices.length > p.device_limit); + const limit = section.querySelector('.limit') as HTMLElement; + const was = limit.hidden; + const hide = st.can_add || !!st.locked; + limit.textContent = `You have reached your limit of ${p.device_limit} devices. Remove one to add another.`; + limit.getAnimations().forEach((a) => a.cancel()); + // A slot freed: the note fades the way it came, then leaves the layout. + if (repainting && !was && hide) { + const a = play( + limit, + [ + { opacity: 1, filter: 'none' }, + { opacity: 0, filter: 'blur(4px)' }, + ], + { duration: 200, easing: EASE_IN, fill: 'forwards' }, + ); + a.onfinish = () => { + limit.hidden = true; + a.cancel(); + }; + } else { + limit.hidden = hide; + if (repainting && was && !hide) + play( + limit, + [ + { opacity: 0, transform: 'translateY(6px)', filter: 'blur(4px)' }, + { opacity: 1, transform: 'none', filter: 'none' }, + ], + { duration: 420, easing: EASE_OUT }, + ); + } +} diff --git a/web/src/portal/page/frame.ts b/web/src/portal/page/frame.ts new file mode 100644 index 0000000..9258459 --- /dev/null +++ b/web/src/portal/page/frame.ts @@ -0,0 +1,61 @@ +// The page's frame: no navbar. The page fades out under the screen's top and +// bottom edges (the top fade only once it scrolls, so the breadcrumb at rest +// stays crisp), and opens with a breadcrumb: the Dawnline mark, the place (the +// server's name) and the person. The content goes in `body`. + +import { h, ic, markup } from '../dom'; +import { placeName, state } from '../state'; +import { showPageCode } from '../flows/page-code'; + +// The sun rises from behind the horizon once, on the visit's first paint. +const LOGO = + ''; + +let crumbsEl: HTMLElement | null = null; +let bodyEl: HTMLElement | null = null; +let pageEl: HTMLElement | null = null; + +/** The frame, built once into #app; returns the slot the page's content goes in. */ +export function frame(app: HTMLElement): HTMLElement { + if (bodyEl) return bodyEl; + crumbsEl = h('header', { class: 'crumbs' }); + bodyEl = h('div', { class: 'page-body' }); + app.replaceChildren( + h('div', { class: 'edge-fade top', 'aria-hidden': 'true' }), + h('div', { class: 'edge-fade bot', 'aria-hidden': 'true' }), + (pageEl = h('main', { class: 'page' }, crumbsEl, bodyEl)), + ); + const onScroll = () => document.body.classList.toggle('scrolled', scrollY > 2); + addEventListener('scroll', onScroll, { passive: true }); + onScroll(); + return bodyEl; +} + +/** One card in place of the page (the link gone, nothing loaded, access paused): it and the breadcrumb sit in the middle of the screen. */ +export function single(on: boolean) { + pageEl?.classList.toggle('single', on); +} + +/** + * The breadcrumb: the place, then the person (none when the link stopped + * working); at its end, this page's code for another device, on the page + * itself only (not over a card: paused, link gone, nothing loaded). + */ +export function crumbs(gone = false, card = false) { + if (!crumbsEl) return; + const p = gone ? null : state()?.person; + const place = h('span', { class: p ? '' : 'cur', 'aria-current': p ? null : 'page' }, placeName()); + crumbsEl.replaceChildren( + h('span', { class: 'cr-mark' }, markup(LOGO)), + h( + 'nav', + { class: 'cr-path', 'aria-label': 'Breadcrumb' }, + place, + p ? [ic('chevron'), h('span', { class: 'cur', 'aria-current': 'page' }, p.name)] : null, + ), + ...(p && !card + ? [h('button', { type: 'button', class: 'knob cr-qr', 'aria-label': 'Open on another device', onclick: showPageCode }, ic('qr'))] + : []), + ); +} diff --git a/web/src/portal/page/notices.ts b/web/src/portal/page/notices.ts new file mode 100644 index 0000000..89118fd --- /dev/null +++ b/web/src/portal/page/notices.ts @@ -0,0 +1,53 @@ +// What stops the person's devices, said once at the top of the page: paused, +// ended, out of data, outside the hours, the server off or missing, or access +// ending soon. A notice wears its tone (orange or red) in its tint. + +import type { Person } from '../../shared/types'; +import { daysLeft, date, endsIn, endsSoon } from '../../shared/format'; +import { h } from '../dom'; +import { clockOf, hoursFor } from '../days'; +import { state, today } from '../state'; +import { glass } from '../ui/glass'; + +export type Tone = 'warn' | 'bad'; + +export function notice(tone: Tone, icon: string, title: string | null, sub: string): HTMLElement { + return h( + 'div', + { class: `notice ${tone}` }, + glass(icon, tone === 'bad' ? 'red' : 'orange'), + h('div', { class: 't' }, title ? h('b', {}, title) : null, h('span', {}, sub)), + ); +} + +/** The admin's hours as the visitor reads them: "08:00–22:00 your time" (or the router's, said so). */ +export function hoursText(hours: string): string { + const hw = hoursFor(hours, state()?.tz_offset, -new Date().getTimezoneOffset()); + if (!hw) return `${hours.replace('-', '–')} (router time)`; + return `${clockOf(hw.from)}–${clockOf(hw.to)} ${hw.yours ? 'your time' : '(router time)'}`; +} + +/** Why the person's devices can't connect: icon, a short title, and a line that adds to it (never says it again). */ +export function stateNotice(p: Person): [string, string, string] { + switch (p.state) { + case 'server_off': + return ['server', 'Server is disabled', 'Your devices can’t connect until it’s enabled again.']; + case 'no_server': + return ['server', 'No server yet', 'You haven’t been added to one.']; + case 'quota': + return ['chart', 'Out of data', 'Nothing gets through until it resets.']; + case 'expired': + return ['calendar', 'Access ended', 'Your devices can’t connect until it’s extended.']; + case 'hours': + return ['clock', 'Outside your hours', `Open ${hoursText(p.hours)}.`]; + default: + return ['pause', 'Access paused', 'Your devices can’t connect until it’s resumed.']; + } +} + +/** The page's notice, or null when nothing stands in the way. */ +export function pageNotice(p: Person): HTMLElement | null { + if (p.state !== 'active') return notice(p.state === 'quota' || p.state === 'expired' ? 'bad' : 'warn', ...stateNotice(p)); + const left = daysLeft(p.expires, today()); + return endsSoon(p, left) ? notice('warn', 'calendar', `Access ${endsIn(left as number)}`, `On ${date(p.expires)}.`) : null; +} diff --git a/web/src/portal/portal.css b/web/src/portal/portal.css deleted file mode 100644 index 7b9f0c9..0000000 --- a/web/src/portal/portal.css +++ /dev/null @@ -1,2201 +0,0 @@ -/* Dawnline personal portal — Vercel-like, same palette as the Outline admin. */ -@font-face { - font-family: Geist; - src: url(geist-latin-wght-normal.woff2) format('woff2'); - font-weight: 100 900; - font-display: swap; - unicode-range: - U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2190-21FF, U+2212, U+2215; -} -@font-face { - font-family: Geist; - src: url(geist-cyrillic-wght-normal.woff2) format('woff2'); - font-weight: 100 900; - font-display: swap; - unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; -} -@font-face { - font-family: 'Geist Mono'; - src: url(geist-mono-latin-wght-normal.woff2) format('woff2'); - font-weight: 100 900; - font-display: swap; -} - -:root { - /* Motion (the rules are in the "Motion" section at the end): a strong ease-out for - arrivals, an ease-in for departures, iOS's sheet curve, and two springs sampled - into linear(): `--spring` settles with a 1.5% overshoot, `--spring-pop` with 12%. */ - --ease-out: cubic-bezier(0.23, 1, 0.32, 1); - --ease-in: cubic-bezier(0.55, 0, 1, 0.45); - --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1); - /* prettier-ignore */ - --spring: linear( - 0, 0.022, 0.079, 0.158, 0.249, 0.344, 0.438, 0.527, 0.61, 0.684, 0.749, 0.805, 0.852, 0.891, 0.923, 0.949, 0.969, 0.984, 0.996, 1.004, - 1.009, 1.013, 1.014, 1.015, 1.015, 1.014, 1.013, 1.012, 1.01, 1.009, 1.008, 1.006, 1.005, 1.004, 1.003, 1.002, 1.002, 1.001, 1.001, 1.001, 1 - ); - /* prettier-ignore */ - --spring-pop: linear( - 0, 0.034, 0.122, 0.244, 0.383, 0.526, 0.662, 0.785, 0.889, 0.974, 1.038, 1.083, 1.111, 1.124, 1.126, 1.119, 1.106, 1.09, 1.072, 1.054, - 1.038, 1.023, 1.01, 1, 0.993, 0.988, 0.985, 0.984, 0.984, 0.985, 0.987, 0.989, 0.992, 0.994, 0.996, 0.998, 0.999, 1, 1.001, 1.002, 1 - ); - --dur-press: 120ms; - --dur-hover: 150ms; - --dur-pop: 180ms; - --dur-swap: 260ms; - --dur-enter: 440ms; - --dur-sheet: 440ms; - --dur-exit: 160ms; - --bg: #fcfcfc; - --card: #ffffff; - --elevated: #ffffff; - --text: #0d0d0d; - --muted: #5d5d5d; - --faint: #8f8f8f; - --line: #0000001a; - --input: #00000026; - --soft: #0d0d0d0d; - --soft-hover: #0d0d0d1a; - --primary: #0d0d0d; - --primary-fg: #ffffff; - --accent: #3a83f7; - --info: #2c67c5; - --ok: #00a240; - --ok-wash: #00a24026; - --warn: #e25507; - --warn-wash: #e2550726; - --bad: #e02e2a; - --bad-wash: #e02e2a1f; - --chart: #3a83f7; - --track: #0d0d0d1a; - --scrim: #00000040; - --shadow: 0 1px 2px -1px #00000014; - --shadow-xl: 0 8px 16px -4px #0000001f; - --radius: 16px; - --mono: 'Geist Mono', ui-monospace, Menlo, monospace; - color-scheme: light dark; -} -@media (prefers-color-scheme: dark) { - :root { - --bg: #000000; - --card: #0a0a0a; - --elevated: #131313; - --text: #ededed; - --muted: #edededa6; - --faint: #ededed78; - --line: #ededed13; - --input: #ededed24; - --soft: #ededed0d; - --soft-hover: #ededed1a; - --primary: #ededed; - --primary-fg: #131313; - --accent: #006efe; - --info: #5ba2fe; - --ok: #40c977; - --ok-wash: #40c97726; - --warn: #ff8549; - --warn-wash: #ff854926; - --bad: #ff6764; - --bad-wash: #ff676422; - --chart: #3a83f7; - --track: #ededed1a; - --scrim: #00000099; - --shadow: none; - --shadow-xl: 0 8px 16px -4px #00000080; - } -} -* { - box-sizing: border-box; -} -html, -body { - margin: 0; -} -/* The page keeps its width when a sheet locks the scroll: no sideways jump behind the scrim. */ -html { - scrollbar-gutter: stable; -} -body { - background: var(--bg); - color: var(--text); - font: - 400 15px/22px Geist, - -apple-system, - system-ui, - 'Segoe UI', - sans-serif; - -webkit-font-smoothing: antialiased; - min-height: 100vh; - min-height: 100dvh; - /* An app, not a document: the arrow over text. Controls set the hand; what is typed - or copied by hand (fields, the key, the link, the configuration) keeps the I-beam. */ - cursor: default; -} -input, -textarea, -.linkrow .mono, -.conf { - cursor: text; -} -body.locked { - overflow: hidden; -} -a { - color: var(--info); - text-decoration: none; -} -a:hover { - text-decoration: underline; -} -/* Links drawn as controls (store badges, buttons) stay controls: no underline on hover. */ -a.btn:hover, -a.badge:hover { - text-decoration: none; -} -h1, -h2 { - margin: 0; - font-weight: 500; - letter-spacing: -0.01em; -} -h1 { - font-size: 24px; - line-height: 32px; -} -h2 { - font-size: 16px; - line-height: 24px; -} -.muted { - color: var(--muted); -} -.faint { - color: var(--faint); -} -.s { - font-size: 13px; - line-height: 18px; -} -.ok { - color: var(--ok); -} -.warn { - color: var(--warn); -} -.strong { - font-weight: 500; -} -.center { - text-align: center; -} -.mono { - font-family: var(--mono); - font-size: 12px; -} -.stack { - display: flex; - flex-direction: column; - gap: 2px; - min-width: 0; -} -.stack.gap { - gap: 10px; -} -.grow { - flex: 1; -} -.row { - display: flex; - align-items: center; - gap: 8px; - flex-wrap: wrap; -} -.row.gap { - gap: 8px; - flex-wrap: nowrap; -} -.row-baseline { - display: flex; - align-items: baseline; - gap: 10px; - flex-wrap: wrap; -} -.offscreen { - position: fixed; - left: -9999px; - opacity: 0; -} - -/* header */ -.top { - display: flex; - align-items: center; - justify-content: space-between; - gap: 12px; - padding: max(12px, env(safe-area-inset-top)) 16px 12px; - border-bottom: 1px solid var(--line); - position: sticky; - top: 0; - background: color-mix(in srgb, var(--bg) 85%, transparent); - backdrop-filter: saturate(180%) blur(12px); - z-index: 5; -} -.brand { - display: flex; - align-items: center; - gap: 8px; - font-weight: 500; - min-width: 0; -} -.brand .faint { - font-weight: 400; -} -.logo { - display: inline-flex; - width: 22px; - height: 22px; - color: var(--text); -} -.logo svg { - width: 100%; - height: 100%; -} -.wrap { - width: 100%; - max-width: 1048px; - margin: 0 auto; - padding: 20px 16px max(32px, env(safe-area-inset-bottom)); - display: flex; - flex-direction: column; - gap: 20px; -} - -/* greeting */ -.hello { - display: flex; - align-items: center; - gap: 12px; -} -.avatar { - width: 44px; - height: 44px; - border-radius: 50%; - background: var(--soft-hover); - display: inline-flex; - align-items: center; - justify-content: center; - font-size: 14px; - font-weight: 600; - position: relative; - flex: 0 0 auto; -} -.avatar.online::after { - content: ''; - position: absolute; - right: 0; - bottom: 0; - width: 10px; - height: 10px; - border-radius: 50%; - background: var(--ok); - box-shadow: 0 0 0 3px var(--bg); -} -.notice { - display: flex; - gap: 10px; - align-items: flex-start; - padding: 12px 14px; - border-radius: 12px; - background: var(--warn-wash); - font-size: 14px; -} -.notice.bad { - background: var(--bad-wash); -} -.notice .ic { - color: var(--warn); -} -.notice.bad .ic { - color: var(--bad); -} - -/* The page's notice, as in the admin's Overview: a row in a bordered list. */ -.alert { - display: flex; - gap: 12px; - align-items: center; - padding: 12px 16px; - border: 1px solid var(--line); - border-radius: 12px; - background: var(--card); - font-size: 14px; - line-height: 20px; -} -.alert-ic { - width: 30px; - height: 30px; - border-radius: 9px; - display: inline-flex; - align-items: center; - justify-content: center; - flex: none; - background: var(--warn-wash); - color: var(--warn); -} -.alert-ic.bad { - background: var(--bad-wash); - color: var(--bad); -} -.alert-ic .ic-svg { - width: 15px; - height: 15px; -} - -/* layout: phone = access then devices; desktop = devices | access */ -.layout { - display: grid; - grid-template-columns: minmax(0, 1fr); - gap: 20px; - grid-template-areas: 'access' 'devices'; -} -.access { - grid-area: access; -} -.devices { - grid-area: devices; - display: flex; - flex-direction: column; - gap: 12px; - min-width: 0; -} -.desktop-only { - display: none !important; -} -@media (min-width: 960px) { - .top { - padding-left: max(16px, calc((100vw - 1048px) / 2 + 16px)); - padding-right: max(16px, calc((100vw - 1048px) / 2 + 16px)); - } - .layout { - grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); - grid-template-areas: 'devices access'; - align-items: start; - gap: 16px; - } - .desktop-only { - display: inline-flex !important; - } - .wrap { - padding-top: 28px; - } -} - -/* cards */ -.card { - background: var(--card); - border: 1px solid var(--line); - border-radius: var(--radius); - padding: 16px; - box-shadow: var(--shadow); - min-width: 0; -} -.card-head { - display: flex; - align-items: center; - justify-content: space-between; - gap: 12px; -} -.access { - display: flex; - flex-direction: column; - gap: 12px; - min-width: 0; -} -.access-card { - display: flex; - flex-direction: column; - gap: 12px; -} -.reach { - display: flex; - align-items: center; - gap: 12px; - padding: 12px; - border-radius: 12px; - background: var(--soft); -} -.reach-ic { - width: 36px; - height: 36px; - border-radius: 10px; - display: inline-flex; - align-items: center; - justify-content: center; - flex: 0 0 auto; - background: color-mix(in srgb, var(--info) 14%, transparent); - color: var(--info); -} -.tile { - border: 1px solid var(--line); - border-radius: 14px; - padding: 14px; - display: flex; - flex-direction: column; - gap: 8px; - min-width: 0; -} -.tiles2 { - display: grid; - grid-template-columns: repeat(2, minmax(0, 1fr)); - gap: 8px; -} -.tile-label { - display: flex; - justify-content: space-between; - gap: 8px; - font-size: 12px; - font-weight: 500; - color: var(--faint); -} -.tile-value { - font-size: 20px; - line-height: 28px; - font-weight: 500; - letter-spacing: -0.01em; - font-variant-numeric: tabular-nums; -} -.tile-value.sm { - font-size: 16px; -} -.tile-value .faint { - font-size: 14px; - font-weight: 400; -} -.meter { - position: relative; - height: 6px; - border-radius: 999px; - background: var(--track); - cursor: default; -} -.meter i { - display: block; - height: 100%; - border-radius: 999px; - background: var(--accent); -} -.meter.warn i { - background: var(--warn); -} -.meter.bad i { - background: var(--bad); -} -.slots { - display: grid; - grid-auto-flow: column; - grid-auto-columns: minmax(0, 1fr); - gap: 3px; -} -.slots i { - display: block; - height: 4px; - border-radius: 999px; - background: var(--track); -} -.slots i.used { - background: var(--text); -} -.slots i.over { - background: color-mix(in srgb, var(--warn) 80%, transparent); -} - -/* devices */ -.dgrid { - display: grid; - grid-template-columns: minmax(0, 1fr); - gap: 10px; -} -@media (min-width: 640px) { - .dgrid { - grid-template-columns: repeat(2, minmax(0, 1fr)); - gap: 12px; - } -} -/* No devices yet: the add card takes the whole row instead of leaving a hole. */ -.dgrid > .slot.add:only-child { - grid-column: 1 / -1; -} -.dcard { - background: var(--card); - border: 1px solid var(--line); - border-radius: var(--radius); - padding: 14px; - display: flex; - flex-direction: column; - gap: 12px; - min-width: 0; - box-shadow: var(--shadow); -} -.dcard.online { - border-color: color-mix(in srgb, var(--ok) 35%, transparent); -} -.dcard.off { - opacity: 0.7; -} -.dhead { - display: flex; - align-items: center; - gap: 12px; -} -.dic { - width: 40px; - height: 40px; - border-radius: 12px; - background: var(--soft); - display: inline-flex; - align-items: center; - justify-content: center; - flex: 0 0 auto; - color: var(--muted); -} -.dic .ic-svg { - width: 20px; - height: 20px; -} -.dcard.online .dic { - background: var(--ok-wash); - color: var(--ok); -} -/* The device this page was opened from: blue tile, blue status, blue border. */ -.dcard.here { - border: 1.5px dotted color-mix(in srgb, var(--accent) 80%, transparent); -} -.dcard.here .dic { - background: color-mix(in srgb, var(--accent) 16%, transparent); - color: var(--info); -} -.dstat.here { - color: var(--info); -} -.dname { - font-weight: 500; - white-space: nowrap; - overflow: hidden; - text-overflow: ellipsis; -} -.dstat { - display: inline-flex; - align-items: center; - gap: 6px; - font-size: 13px; - color: var(--muted); -} -.dstat.ok { - color: var(--ok); -} -.dstat.warn { - color: var(--warn); -} -.duse { - display: flex; - align-items: flex-end; - justify-content: space-between; - gap: 12px; -} -.spark { - display: flex; - align-items: flex-end; - gap: 3px; - height: 26px; - width: 128px; -} -.spark i { - flex: 1; - display: block; - border-radius: 2px 2px 0 0; - background: var(--chart); - opacity: 0.85; - cursor: default; -} -.spark i.zero { - opacity: 0.22; -} -.spark i:hover { - opacity: 1; - filter: brightness(1.2); -} -/* Names at home (access card) */ -.names { - display: flex; - flex-direction: column; - gap: 10px; - padding: 12px; - border-radius: 12px; - border: 1px solid var(--line); -} -.names-head { - display: flex; - gap: 10px; - align-items: flex-start; -} -.names-ic { - width: 28px; - height: 28px; - border-radius: 8px; - display: inline-flex; - align-items: center; - justify-content: center; - flex: none; - background: color-mix(in srgb, var(--info) 14%, transparent); - color: var(--info); -} -.names-ic .ic-svg { - width: 15px; - height: 15px; -} -.names-list { - display: flex; - flex-wrap: wrap; - gap: 6px; -} -.name-chip { - all: unset; - box-sizing: border-box; - cursor: pointer; - display: inline-flex; - align-items: center; - gap: 6px; - height: 28px; - max-width: 100%; - padding: 0 9px 0 10px; - border-radius: 999px; - background: var(--soft); -} -.name-chip:hover { - background: var(--soft-hover); -} -.name-chip:focus-visible { - outline: 2px solid var(--accent); - outline-offset: 2px; -} -.name-chip .mono { - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; - min-width: 0; -} -.name-chip .ic-svg { - width: 13px; - height: 13px; - color: var(--faint); -} -.slot.add { - all: unset; - box-sizing: border-box; - cursor: pointer; - display: flex; - align-items: center; - gap: 14px; - padding: 16px; - min-height: 72px; - border: 1px dashed var(--input); - border-radius: var(--radius); - color: var(--text); - text-align: left; -} -.slot.add:hover { - background: var(--soft); - border-color: color-mix(in srgb, var(--text) 30%, transparent); -} -.slot-ic { - width: 40px; - height: 40px; - border-radius: 12px; - background: var(--soft); - display: inline-flex; - align-items: center; - justify-content: center; - flex: 0 0 auto; - color: var(--muted); -} -.slot.add:hover .slot-ic { - background: var(--primary); - color: var(--primary-fg); -} -.slot.add:focus-visible { - outline: 2px solid var(--accent); - outline-offset: 2px; -} -@media (min-width: 960px) { - .slot.add { - flex-direction: column; - justify-content: center; - gap: 10px; - min-height: 140px; - text-align: center; - color: var(--muted); - } - .slot.add .stack { - align-items: center; - } - .slot.add .strong { - color: var(--text); - } - .slot.add .slot-ic { - border-radius: 999px; - width: 36px; - height: 36px; - } -} - -/* buttons */ -.ic { - display: inline-flex; - line-height: 0; -} -.ic-svg { - width: 16px; - height: 16px; -} -.btn { - all: unset; - box-sizing: border-box; - cursor: pointer; - display: inline-flex; - align-items: center; - justify-content: center; - gap: 8px; - height: 40px; - padding: 0 16px; - border-radius: 999px; - font-size: 14px; - font-weight: 500; - background: var(--soft); - color: var(--text); - -webkit-tap-highlight-color: transparent; - white-space: nowrap; -} -.btn:hover { - background: var(--soft-hover); -} -.btn.primary { - background: var(--primary); - color: var(--primary-fg); -} -.btn.primary:hover { - opacity: 0.9; -} -.btn.danger-solid { - background: var(--bad); - color: #fff; -} -.btn.small { - height: 32px; - padding: 0 12px; - font-size: 13px; -} -.btn.big { - height: 48px; - font-size: 15px; -} -.btn.block { - display: flex; - width: 100%; -} -.btn[disabled] { - opacity: 0.45; - cursor: not-allowed; -} -.btn:focus-visible, -.kind:focus-visible, -.icon-btn:focus-visible, -.slot:focus-visible { - outline: 2px solid var(--accent); - outline-offset: 2px; -} -.icon-btn { - all: unset; - cursor: pointer; - width: 36px; - height: 36px; - display: inline-flex; - align-items: center; - justify-content: center; - border-radius: 50%; - color: var(--muted); - flex: 0 0 auto; -} -.icon-btn:hover { - background: var(--soft); - color: var(--text); -} -.icon-btn.soft { - background: var(--soft); -} -@media (pointer: coarse) { - .icon-btn { - width: 40px; - height: 40px; - } -} - -/* inputs */ -input[type='text'] { - width: 100%; - font: inherit; - color: var(--text); - background: var(--card); - border: 1px solid var(--input); - border-radius: 10px; - padding: 0 12px; - height: 44px; -} -input[type='text']:focus { - outline: none; - border-color: transparent; - box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 60%, transparent); -} -.lbl { - display: block; - font-size: 13px; - font-weight: 500; - color: var(--muted); - margin: 14px 2px 6px; -} -.err { - color: var(--bad); - min-height: 1.2em; - margin: 8px 2px; - font-size: 14px; -} -.kinds { - display: grid; - grid-template-columns: repeat(5, minmax(0, 1fr)); - gap: 6px; -} -.kind { - all: unset; - box-sizing: border-box; - cursor: pointer; - display: flex; - flex-direction: column; - align-items: center; - justify-content: center; - gap: 6px; - height: 63px; - min-width: 0; - border-radius: 12px; - box-shadow: inset 0 0 0 1px var(--line); - color: var(--muted); - font-size: 12.5px; - /* The body's 22px would leave its leading under the letters: the label sat low, more room under it than over the icon. */ - line-height: 15px; - font-weight: 500; - text-align: center; -} -.kind .ic { - /* The icon wrapper carries the text's line height otherwise: a gap twice the one set. */ - display: inline-flex; - line-height: 0; -} -.kind .ic-svg { - width: 20px; - height: 20px; -} -.kind:hover { - color: var(--text); - background: color-mix(in srgb, var(--text) 4%, transparent); -} -.kind.on { - box-shadow: inset 0 0 0 1.5px var(--accent); - color: var(--text); - background: color-mix(in srgb, var(--accent) 10%, transparent); -} -.kind.on .ic { - color: var(--accent); -} - -/* sign-in */ -.signin { - text-align: center; - max-width: 420px; - margin: 8vh auto 0; - width: 100%; - padding: 28px 20px; - display: flex; - flex-direction: column; - gap: 10px; -} -.hero-ic { - width: 52px; - height: 52px; - margin: 0 auto 6px; - border-radius: 16px; - display: grid; - place-items: center; - background: var(--primary); - color: var(--primary-fg); -} -.hero-ic .ic-svg { - width: 24px; - height: 24px; -} -.signin input { - text-align: center; - margin-top: 8px; -} - -/* dropdown menu */ -.menu { - position: absolute; - z-index: 30; - width: 230px; - padding: 4px; - border-radius: 14px; - background: var(--elevated); - border: 1px solid var(--line); - box-shadow: var(--shadow-xl); -} -.menu-item { - all: unset; - box-sizing: border-box; - cursor: pointer; - display: flex; - align-items: center; - gap: 10px; - width: 100%; - height: 40px; - padding: 0 12px; - border-radius: 10px; - font-size: 14px; -} -.menu-item:hover, -.menu-item:focus-visible { - background: var(--soft-hover); -} -.menu-item .ic { - color: var(--muted); -} -.menu-item.danger { - color: var(--bad); -} -.menu-item.danger .ic { - color: var(--bad); -} -/* Undoable but not harmless (Reconnect: new keys), as the admin's Pause. */ -.menu-item.warn, -.menu-item.warn .ic { - color: var(--warn); -} -.menu-sep { - height: 1px; - background: var(--line); - margin: 4px 8px; -} -@media (pointer: coarse) { - .menu-item { - height: 44px; - } -} - -/* sheet: bottom sheet on phones, centred dialog on desktop */ -.sheet { - position: fixed; - inset: 0; - z-index: 20; - display: flex; - align-items: flex-end; - justify-content: center; -} -.scrim { - position: absolute; - inset: 0; - background: var(--scrim); -} -.sheet-panel { - position: relative; - width: 100%; - max-width: 520px; - max-height: 92vh; - max-height: 92dvh; - overflow: auto; - background: var(--elevated); - border-radius: 20px 20px 0 0; - border: 1px solid var(--line); - border-bottom: 0; - padding: 6px 16px max(20px, env(safe-area-inset-bottom)); -} -.grab { - width: 36px; - height: 4px; - border-radius: 999px; - background: var(--input); - margin: 4px auto 8px; -} -.sheet-head { - display: flex; - align-items: flex-start; - justify-content: space-between; - gap: 8px; - padding: 4px 0 12px; -} -.sheet-head h2 { - font-size: 20px; - line-height: 28px; - font-weight: 600; -} -.sheet-body { - display: flex; - flex-direction: column; - gap: 14px; -} -@media (min-width: 640px) { - .sheet { - align-items: center; - } - .sheet-panel { - border-radius: 16px; - border-bottom: 1px solid var(--line); - padding: 20px; - max-width: 480px; - } - .grab { - display: none; - } -} -/* A question before something that cannot be undone (main.ts ask): narrow and centred, - the action's icon in its colour over the question, one line of what happens, two buttons. */ -.ask { - display: flex; - flex-direction: column; - align-items: center; - text-align: center; - gap: 8px; - padding-top: 6px; -} -.ask h2 { - font-size: 18px; - line-height: 24px; - font-weight: 600; -} -.ask p { - margin: 0; - font-size: 14px; - line-height: 20px; -} -.ask-ic { - width: 52px; - height: 52px; - border-radius: 16px; - display: grid; - place-items: center; - margin-bottom: 6px; -} -.ask-ic .ic-svg { - width: 24px; - height: 24px; -} -.ask-ic.bad { - background: var(--bad-wash); - color: var(--bad); -} -.ask-ic.warn { - background: var(--warn-wash); - color: var(--warn); -} -.ask-actions { - width: 100%; - margin-top: 10px; -} -@media (min-width: 640px) { - .sheet-panel.asks { - max-width: 360px; - padding: 24px 20px 20px; - } - .ask { - padding-top: 0; - } -} -.pane { - display: flex; - flex-direction: column; - gap: 10px; -} -/* The code, night look (shared/qr): light dots on a black card with a fine outline. - `.light`: the plain look, for scanners that read only dark on light. */ -.qr { - width: min(240px, 70vw); - aspect-ratio: 1; - background: #0a0a0a; - border-radius: 22px; - padding: 12px; - box-shadow: inset 0 0 0 1px #ffffff2e; -} -.qr.light { - background: #fff; - border-radius: 12px; - padding: 10px; - box-shadow: inset 0 0 0 1px var(--line); -} -.qr svg { - display: block; - width: 100%; - height: 100%; -} -.filecard { - display: flex; - align-items: center; - gap: 12px; - padding: 12px; - border-radius: 14px; - background: var(--soft); - min-width: 0; -} -.filecard > .stack { - flex: 1; - min-width: 0; -} -.filecard-ic { - width: 40px; - height: 46px; - border-radius: 8px; - flex: none; - display: inline-flex; - align-items: center; - justify-content: center; - font: 10px var(--mono); - color: var(--muted); - background: var(--card); - box-shadow: inset 0 0 0 1px var(--line); -} -.ellipsis { - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; - min-width: 0; -} -/* Phones: the config file name wraps instead of being cut */ -@media (max-width: 480px) { - .filecard .ellipsis { - white-space: normal; - overflow-wrap: anywhere; - } -} -.confbox { - border: 1px solid var(--line); - border-radius: 12px; -} -.confbox > summary { - list-style: none; - display: flex; - align-items: center; - gap: 8px; - padding: 8px 10px 8px 12px; - color: var(--text); -} -.confbox > summary::-webkit-details-marker { - display: none; -} -.confbox > summary > .ic:first-child { - transition: transform 200ms var(--ease-out); - color: var(--muted); -} -.confbox[open] > summary > .ic:first-child { - transform: rotate(90deg); -} -.confbox .grow { - flex: 1; -} -.confbox > .conf { - margin: 0; - border-top: 1px solid var(--line); - border-radius: 0 0 12px 12px; - background: none; -} -.conf-sec { - color: var(--accent, var(--info)); -} -.conf-k { - color: var(--faint); -} -.conf-mask { - padding: 0 6px; - border-radius: 4px; - background: var(--soft); - color: var(--muted); -} -.conf { - white-space: pre-wrap; - word-break: break-all; - font: 12px/18px var(--mono); - background: var(--soft); - border-radius: 10px; - padding: 12px; - max-height: 16rem; - overflow: auto; -} -details > summary { - cursor: pointer; - color: var(--muted); - font-size: 13px; - font-weight: 500; -} - -/* tooltip & toast */ -.tip { - position: fixed; - z-index: 50; - translate: -50% -100%; - padding: 6px 10px; - border-radius: 10px; - font-size: 12px; - line-height: 17px; - white-space: nowrap; - background: var(--elevated); - border: 1px solid var(--line); - box-shadow: var(--shadow-xl); - pointer-events: none; -} -.tip-title { - font-weight: 500; -} -.toast { - position: fixed; - left: 50%; - bottom: max(20px, env(safe-area-inset-bottom)); - translate: -50% 0; - z-index: 60; - background: var(--primary); - color: var(--primary-fg); - padding: 10px 16px; - border-radius: 999px; - font-weight: 500; - font-size: 14px; - max-width: 90vw; -} -.toast.bad { - background: var(--bad); - color: #fff; -} -/* First visit without a device: two steps and the add button, before the slot grid. */ -.firststeps { - grid-column: 1 / -1; - display: flex; - flex-direction: column; - gap: 12px; -} -.firststeps p { - margin: 0; - font-size: 14px; -} -.firststeps h2 { - margin: 0; - font-size: 17px; -} - -/* ---------- setting up a device: two numbered steps ---------- */ -.setup { - display: flex; - flex-direction: column; - gap: 12px; -} -.step { - border: 1px solid var(--line); - border-radius: 16px; - background: var(--card); - padding: 14px 16px 16px; - display: flex; - flex-direction: column; - gap: 12px; - min-width: 0; -} -.step-head { - display: flex; - align-items: center; - gap: 10px; -} -.step-n { - width: 22px; - height: 22px; - border-radius: 50%; - background: var(--soft); - display: inline-flex; - align-items: center; - justify-content: center; - font-size: 12px; - font-weight: 600; - flex: none; -} -.step-n:empty { - display: none; -} -.step-ic { - width: 28px; - height: 28px; - border-radius: 8px; - background: var(--soft); - display: inline-flex; - align-items: center; - justify-content: center; - flex: none; -} -.step-title { - font-weight: 600; - font-size: 16px; - display: flex; - align-items: center; - gap: 10px; - min-width: 0; - flex: 1; -} -.chip { - font-size: 11px; - padding: 2px 7px; - border-radius: 999px; - background: rgba(58, 131, 247, 0.16); - color: var(--accent); - white-space: nowrap; -} -.fold-link { - all: unset; - cursor: pointer; - font-size: 13px; - color: var(--muted); - padding: 4px 0; -} -.fold-link:hover { - color: var(--text); -} -.badge { - all: unset; - box-sizing: border-box; - cursor: pointer; - display: flex; - align-items: center; - gap: 12px; - padding: 8px 12px 8px 8px; - border-radius: 12px; - min-height: 56px; - background: var(--soft); - color: var(--text); - min-width: 0; -} -.badge:hover { - background: var(--soft-hover); -} -.badge.primary { - background: var(--primary); - color: var(--primary-fg); -} -.badge-ic { - width: 36px; - height: 36px; - border-radius: 10px; - flex: none; - display: inline-flex; - align-items: center; - justify-content: center; - background: rgba(127, 127, 127, 0.18); -} -.badge-ic .ic-svg { - width: 20px; - height: 20px; -} -.badge-txt { - display: flex; - flex-direction: column; - line-height: 1.2; - min-width: 0; - flex: 1; -} -.badge-top { - font-size: 11px; - opacity: 0.7; -} -.badge-main { - font-size: 15px; - font-weight: 600; - letter-spacing: -0.01em; - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; -} -.badge-chev { - opacity: 0.5; - display: inline-flex; - flex: none; -} -.badges2 { - display: grid; - grid-template-columns: repeat(2, minmax(0, 1fr)); - gap: 8px; -} -.badges2 .badge-chev { - display: none; -} -.pills { - display: flex; - flex-wrap: wrap; - gap: 6px; -} -.pill { - all: unset; - box-sizing: border-box; - cursor: pointer; - display: inline-flex; - align-items: center; - gap: 6px; - font-size: 13px; - padding: 7px 10px 7px 9px; - border-radius: 999px; - border: 1px solid var(--line); - color: var(--muted); - white-space: nowrap; -} -.pill .ic-svg { - width: 14px; - height: 14px; -} -.pill.on { - border-color: var(--accent); - background: rgba(58, 131, 247, 0.12); - color: var(--text); -} -.howto { - margin: 0; - padding: 0 4px 0 22px; - font-size: 13px; - color: var(--muted); - display: flex; - flex-direction: column; - gap: 4px; -} -.howto b { - font-weight: 500; - color: var(--text); -} -.linkrow { - display: flex; - align-items: center; - gap: 8px; - padding: 6px 6px 6px 12px; - border-radius: 12px; - background: var(--soft); - min-width: 0; -} -.linkrow .mono { - flex: 1; - min-width: 0; - font-size: 12px; - color: var(--muted); -} -.qr.small { - width: 148px; - flex: none; -} -/* A code and what to do with it, under it. (Not `.row.wrap`: `.wrap` is the page.) */ -.code-row { - display: flex; - flex-direction: column; - align-items: center; - gap: 12px; -} -.code-row > .stack { - align-self: stretch; -} -/* A dense code (an AmneziaVPN key): the full width of its card, edge to edge with the text, so a phone camera resolves the modules. */ -.qr.big { - width: 100%; -} -/* A small control that unfolds a choice, as opposed to a text link. */ -.pill-link { - all: unset; - box-sizing: border-box; - cursor: pointer; - display: inline-flex; - align-items: center; - gap: 4px; - font-size: 12px; - font-weight: 500; - padding: 5px 8px 5px 10px; - border-radius: 999px; - border: 1px solid var(--line); - color: var(--muted); - white-space: nowrap; -} -.pill-link:hover { - color: var(--text); - background: var(--soft); -} -.pill-link .ic-svg { - width: 13px; - height: 13px; - transform: rotate(90deg); -} -/* A line that belongs to the step's title, not to the content under it. */ -.step-sub { - margin-top: -8px; -} -/* A folded card: its head is the button that opens it, a chevron at the end. */ -.step-head.fold { - all: unset; - box-sizing: border-box; - cursor: pointer; - display: flex; - align-items: center; - gap: 10px; - width: 100%; - color: inherit; -} -.fold-chev { - display: inline-flex; - color: var(--muted); -} -.fold-chev .ic-svg { - width: 16px; - height: 16px; -} -.step.folded { - padding-bottom: 14px; -} - -/* Waiting for the first connection (waitpath.ts): the way from the device to the home router. */ -.way { - display: flex; - flex-direction: column; - gap: 10px; - padding: 12px 14px; - border-radius: 14px; - background: var(--soft); -} -.way-row { - display: flex; - align-items: center; - gap: 10px; -} -.way-end { - width: 36px; - height: 36px; - border-radius: 10px; - flex: none; - display: inline-flex; - align-items: center; - justify-content: center; - background: var(--soft-hover); - color: var(--muted); -} -.way-end .ic-svg { - width: 18px; - height: 18px; -} -.way-end.home { - color: var(--info); - background: color-mix(in srgb, var(--info) 14%, transparent); -} -.way-track { - position: relative; - flex: 1; - height: 8px; -} -/* One dotted line, three layers through the same dots: the dots, the light along them, the green that fills them. */ -.way-track::before, -.way-glow, -.way-fill { - position: absolute; - inset: 0; - -webkit-mask: radial-gradient(circle, #000 1.4px, transparent 1.9px) 0 50% / 9px 8px repeat-x; - mask: radial-gradient(circle, #000 1.4px, transparent 1.9px) 0 50% / 9px 8px repeat-x; -} -.way-track::before { - content: ''; - background: var(--faint); - opacity: 0.55; -} -.way-glow { - overflow: hidden; -} -.way-glow i { - position: absolute; - inset: 0; - background: linear-gradient(90deg, transparent 32%, var(--info) 50%, transparent 68%); - transform: translateX(-70%); -} -.way-fill { - background: var(--ok); - clip-path: inset(0 100% 0 0); -} -.way-text { - display: flex; - flex-direction: column; - align-items: center; - text-align: center; - gap: 2px; -} -.way-text > :empty { - display: none; -} -.way.done .way-end { - background: var(--ok-wash); - color: var(--ok); -} -.way.done .way-fill { - clip-path: inset(0); -} -.way.done .way-glow, -.way.stopped .way-glow { - opacity: 0; -} - -/* ---------- Motion ---------- */ -/* - * How the portal moves. A personal page opened now and then, so polish first - * (subtle, production-quiet), restraint where things are used often, and a - * little delight only where it is rare (the sunrise, the first connection): - * - arrivals ease out fast and come into focus: opacity, a short rise, a blur - * that clears; departures are shorter, smaller and ease in; - * - a press scales down at once; hover only changes colour; - * - Escape and other keys never animate; nothing loops except a spinner; - * - only transform, opacity, filter and clip-path move, plus a sheet's height - * (one fixed box, motion.ts followHeight); - * - prefers-reduced-motion keeps the fades and drops the travel (end of file). - * motion.ts measures and starts what needs script (heights, FLIP, swaps, pulls). - */ - -/* Press and hover: everything tappable. Placed last: the controls reset with `all: unset`. */ -.btn, -.badge, -.pill, -.kind, -.icon-btn, -.slot.add, -.slot-ic, -.name-chip, -.fold-link, -.pill-link, -.menu-item { - transition: - transform var(--dur-press) var(--ease-out), - background-color var(--dur-hover) var(--ease-out), - border-color var(--dur-hover) var(--ease-out), - box-shadow var(--dur-hover) var(--ease-out), - color var(--dur-hover) var(--ease-out), - opacity var(--dur-hover) var(--ease-out); -} -.btn:active, -.pill:active, -.kind:active, -.icon-btn:active, -.fold-link:active, -.pill-link:active { - transform: scale(0.97); -} -/* Wide surfaces give less: the same press reads larger on them. */ -.badge:active, -.slot.add:active { - transform: scale(0.985); -} -.name-chip:active { - transform: scale(0.96); -} -.btn[disabled]:active { - transform: none; -} -/* The ⋯ whose menu is open stays pressed. */ -.icon-btn[aria-expanded='true'] { - background: var(--soft-hover); - color: var(--text); -} -.kind .ic, -.menu-item .ic { - transition: color var(--dur-hover) var(--ease-out); -} -.spark i { - transition: - opacity 120ms var(--ease-out), - filter 120ms var(--ease-out); -} -input, -textarea { - transition: - border-color var(--dur-hover) var(--ease-out), - box-shadow var(--dur-hover) var(--ease-out); -} - -/* The visit's first paint: blocks rise in, in reading order (motion.ts intro sets --i). - The add slot's `all: unset` (two classes) would reset the animation: it is named here. */ -.intro, -.slot.add.intro { - animation: rise-in var(--dur-enter) var(--ease-out) backwards; - animation-delay: calc(40ms + var(--i, 0) * 45ms); -} -/* The sun rises from behind the horizon, once. */ -.top.first .sun { - animation: sunrise 900ms var(--ease-out) 120ms backwards; -} -/* The meters fill and the bars grow, after their cards have arrived. */ -.wrap.first .meter i { - animation: fill-x 800ms var(--ease-out) 300ms backwards; -} -.wrap.first .slots i.used, -.wrap.first .slots i.over { - animation: fill-x 480ms var(--ease-out) backwards; - animation-delay: calc(320ms + var(--i, 0) * 50ms); -} -.wrap.first .spark i { - transform-origin: bottom; - animation: grow-y 560ms var(--ease-out) backwards; - animation-delay: calc(320ms + var(--i, 0) * 30ms); -} -.wrap.first .avatar.online::after { - animation: pop-in 480ms var(--spring-pop) 420ms backwards; -} -.wrap.first .hero-ic { - animation: pop-in 520ms var(--spring-pop) 160ms backwards; -} - -/* A repaint: a new block rises in, a value that changed comes into focus, an icon swaps with a little spring. */ -.enter, -.slot.add.enter { - animation: rise-in 360ms var(--ease-out) backwards; -} -/* What a card just unfolded: one piece after the other (setup sheet). */ -.unfold { - animation: rise-in 320ms var(--ease-out) backwards; - animation-delay: calc(30ms + var(--i, 0) * 40ms); -} -.swap { - animation: focus-in var(--dur-swap) var(--ease-out) backwards; -} -.swap-ic { - animation: icon-in 280ms var(--spring) backwards; -} -.copied > .ic, -.copied .badge-ic .ic { - color: var(--ok); -} -.badge.primary.copied .badge-ic .ic { - color: inherit; -} - -/* Dropdown menu: grows out of its button, leaves quicker and smaller. */ -.menu { - opacity: 0; - transform: translateY(-4px) scale(0.96); - transform-origin: top right; - filter: blur(2px); - transition: - opacity var(--dur-pop) var(--ease-out), - transform 220ms var(--ease-out), - filter var(--dur-pop) var(--ease-out); -} -.menu.up { - transform: translateY(4px) scale(0.96); - transform-origin: bottom right; -} -.menu.show { - opacity: 1; - transform: none; - filter: none; -} -.menu.gone { - opacity: 0; - transform: scale(0.98); - filter: none; - pointer-events: none; - transition-duration: 120ms; - transition-timing-function: var(--ease-in); -} - -/* Tooltip: comes up out of the pointer once, then only follows it. */ -.tip { - opacity: 0; - transform: translateY(4px) scale(0.96); - transform-origin: 50% 100%; - transition: - opacity 120ms var(--ease-out), - transform var(--dur-pop) var(--ease-out); -} -.tip.show { - opacity: 1; - transform: none; -} - -/* Toast: rises into focus; goes quicker, barely moving. */ -.toast { - opacity: 0; - transform: translateY(12px) scale(0.96); - filter: blur(4px); - transition: - transform 380ms var(--ease-out), - opacity 240ms var(--ease-out), - filter 240ms var(--ease-out); -} -.toast.show { - opacity: 1; - transform: none; - filter: none; -} -.toast.gone { - opacity: 0; - transform: translateY(4px) scale(0.98); - filter: blur(2px); - transition-duration: var(--dur-exit); - transition-timing-function: var(--ease-in); -} - -/* Sheets. Phones: slides up on iOS's curve, can be pulled down (motion.ts pullToClose). */ -.scrim { - opacity: 0; - transition: opacity 300ms var(--ease-out); -} -.sheet.open .scrim { - opacity: 1; -} -.sheet.closing .scrim { - transition-duration: 260ms; -} -.sheet-panel { - transform: translateY(100%); - transition: transform var(--dur-sheet) var(--ease-drawer); -} -.sheet.open .sheet-panel { - transform: none; -} -.sheet.closing .sheet-panel { - transition-duration: 300ms; -} -.sheet-panel.dragging { - transition: none; -} -.sheet-panel.morphing { - overflow: hidden; -} -/* A question turning into a sheet: the width animates, the cap waits for the end. */ -.sheet-panel.morphing-w { - max-width: none; -} -@media (max-width: 639px) { - .grab, - .sheet-head, - .ask { - touch-action: none; - } - .grab { - cursor: grab; - } -} -/* Desktop: a dialog that comes into focus, its content settling just after it. */ -@media (min-width: 640px) { - .sheet-panel { - opacity: 0; - transform: translateY(8px) scale(0.96); - filter: blur(4px); - transition: - opacity 220ms var(--ease-out), - transform 320ms var(--ease-out), - filter 220ms var(--ease-out); - } - .sheet.open .sheet-panel { - opacity: 1; - transform: none; - filter: none; - } - .sheet.closing .sheet-panel { - opacity: 0; - transform: scale(0.98); - filter: blur(2px); - transition-duration: var(--dur-exit); - transition-timing-function: var(--ease-in); - } - .sheet.closing .scrim { - transition-duration: 180ms; - } - .sheet.fresh .sheet-inner > .sheet-head, - .sheet.fresh .sheet-body > :not(.setup), - .sheet.fresh .setup > * { - animation: settle-in 280ms var(--ease-out) backwards; - animation-delay: calc(20ms + var(--i, 0) * 25ms); - } -} -/* A question opens with its icon springing in. */ -.sheet.fresh .ask-ic { - animation: pop-in 520ms var(--spring-pop) 80ms backwards; -} -/* What a swap lifts out of the flow while it fades (motion.ts swap): under the new content, not over it. */ -.sheet-inner, -.setup { - position: relative; - isolation: isolate; -} -.ghost { - position: absolute; - z-index: -1; - pointer-events: none; -} - -/* Setup repaints (motion.ts restyle): what flipped starts from its other look; a card that - just folded shows its chevron with a little spring. */ -.fold.to-off .fold-chev { - animation: icon-in 280ms var(--spring) backwards; -} -.pill.to-on { - animation: pill-on var(--dur-pop) var(--ease-out); -} -.pill.to-off { - animation: pill-off var(--dur-pop) var(--ease-out); -} -.pill.to-on .ic, -.kind.on .ic { - animation: pop-sm 340ms var(--spring-pop); -} -/* A code that now encodes something else comes into focus out of a blur. */ -.qr.swap { - animation: qr-in 360ms var(--ease-out) backwards; -} -/* A key shown comes into focus; the mask fades back. */ -.conf-v.unmask { - animation: unmask 420ms var(--ease-out) backwards; -} -.conf-mask.unmask { - animation: focus-in 200ms var(--ease-out) backwards; -} -.confbox[open] > .conf { - animation: rise-in 260ms var(--ease-out) backwards; -} - -/* The first connection (waitpath.ts): a light runs along the way while the page waits; - connected, the dots fill green from the device to the router, then the router end lights. */ -.way-glow i { - animation: way-run 2s cubic-bezier(0.45, 0, 0.55, 1) infinite; -} -.way-glow { - transition: opacity 200ms var(--ease-out); -} -.way-fill { - transition: clip-path 700ms var(--ease-out) 80ms; -} -.way-end { - transition: - background-color 300ms var(--ease-out), - color 300ms var(--ease-out); -} -/* The green reaches the server last: it lights up when the dots get there. */ -.way.done .way-end.home { - transition-delay: 600ms; -} -.way.done .way-end.home .ic { - animation: pop-sm 420ms var(--spring-pop) 600ms; -} - -/* A button waiting for the router: the label gives way to a spinner (motion.ts busy). */ -.btn { - --spin: var(--text); -} -.btn.primary { - --spin: var(--primary-fg); -} -.btn.danger-solid { - --spin: #fff; -} -.btn.busy { - position: relative; - color: transparent !important; - cursor: progress; -} -.btn.busy[disabled] { - opacity: 1; -} -.btn.busy::after { - content: ''; - position: absolute; - inset: 0; - margin: auto; - width: 16px; - height: 16px; - border-radius: 50%; - border: 2px solid color-mix(in srgb, var(--spin) 28%, transparent); - border-top-color: var(--spin); - animation: - spin 700ms linear infinite, - focus-in var(--dur-hover) var(--ease-out); -} -.btn[disabled] { - transition: opacity var(--dur-hover) var(--ease-out); -} - -@keyframes rise-in { - from { - opacity: 0; - transform: translateY(8px); - filter: blur(4px); - } -} -@keyframes settle-in { - from { - opacity: 0; - transform: translateY(4px); - } -} -@keyframes focus-in { - from { - opacity: 0; - filter: blur(4px); - } -} -@keyframes fade { - from { - opacity: 0; - } -} -@keyframes icon-in { - from { - opacity: 0; - transform: scale(0.7); - filter: blur(3px); - } -} -@keyframes pop-in { - from { - opacity: 0; - transform: scale(0.7); - filter: blur(4px); - } -} -@keyframes pop-sm { - from { - transform: scale(0.82); - } -} -@keyframes sunrise { - from { - transform: translateY(10px); - } -} -@keyframes fill-x { - from { - clip-path: inset(0 100% 0 0 round 999px); - } - to { - clip-path: inset(0 0 0 0 round 999px); - } -} -@keyframes grow-y { - from { - transform: scaleY(0); - } -} -@keyframes pill-on { - from { - border-color: var(--line); - background-color: transparent; - color: var(--muted); - } -} -@keyframes pill-off { - from { - border-color: var(--accent); - background-color: rgba(58, 131, 247, 0.12); - color: var(--text); - } -} -@keyframes qr-in { - from { - opacity: 0; - transform: scale(0.98); - filter: blur(6px); - } -} -@keyframes unmask { - from { - opacity: 0.25; - filter: blur(5px); - } -} -/* The light goes along the way, then rests a beat before the next run. */ -@keyframes way-run { - 0% { - transform: translateX(-70%); - } - 72%, - 100% { - transform: translateX(70%); - } -} -@keyframes spin { - to { - transform: rotate(360deg); - } -} - -/* Less motion: what says "this changed" still fades in; nothing travels, scales, blurs or turns. */ -@media (prefers-reduced-motion: reduce) { - .intro, - .slot.add.intro, - .enter, - .slot.add.enter, - .unfold, - .swap, - .swap-ic, - .qr.swap, - .conf-v.unmask, - .confbox[open] > .conf, - .wrap.first .hero-ic, - .wrap.first .avatar.online::after, - .sheet.fresh .sheet-inner > .sheet-head, - .sheet.fresh .sheet-body > :not(.setup), - .sheet.fresh .setup > *, - .sheet.fresh .ask-ic { - animation-name: fade; - animation-duration: 200ms; - } - .top.first .sun, - .wrap.first .meter i, - .wrap.first .slots i.used, - .wrap.first .slots i.over, - .wrap.first .spark i, - .fold.to-off .fold-chev, - .pill.to-on .ic, - .kind.on .ic, - .way.done .way-end.home .ic { - animation: none; - } - /* The way holds still while waiting; connected, it turns green at once. */ - .way-glow { - display: none; - } - .way-fill { - transition: none; - } - .sheet-panel, - .sheet.open .sheet-panel, - .sheet.closing .sheet-panel, - .menu, - .menu.up, - .menu.gone, - .tip, - .toast, - .toast.gone { - transform: none; - filter: none; - } - .sheet-panel { - opacity: 0; - transition: opacity 200ms var(--ease-out); - } - .sheet.open .sheet-panel { - opacity: 1; - } - .confbox > summary > .ic:first-child { - transition: none; - } - .btn:active, - .badge:active, - .pill:active, - .kind:active, - .icon-btn:active, - .slot.add:active, - .name-chip:active, - .fold-link:active, - .pill-link:active { - transform: none; - } -} diff --git a/web/src/portal/setup.ts b/web/src/portal/setup.ts index d8a1232..04875ae 100644 --- a/web/src/portal/setup.ts +++ b/web/src/portal/setup.ts @@ -1,5 +1,5 @@ // Setting up a device: which app, where it comes from, and whether the page -// is open on the device being set up. Pure: the sheet in main.ts draws it. +// is open on the device being set up. Pure: the set-up sheet (flows/) draws it. import type { Kind } from '../shared/types'; @@ -33,45 +33,21 @@ export function sameDevice(kind: Kind, platform: Platform): boolean { return true; } -/** - * The systems a kind may run, when that is the person's call: a computer's - * desktop systems, any system for an "other" device (a TV box runs Android, a - * NAS Linux). A phone's or a tablet's is read from the browser. - */ -export const osGroup = (kind: Kind): Platform[] => - kind === 'computer' ? ['windows', 'mac', 'linux'] : kind === 'other' ? ['ios', 'android', 'windows', 'mac', 'linux'] : []; - export interface AppChoice { id: AppId; name: string; - /** The version this server needs, as "4.8.12" or ""; "current" when only the newest will do. */ - need: string; - sub: string; } -/** The apps that connect to a server with this disguise, the recommended one first. */ +/** The apps that connect to a server with this disguise, the recommended one first; any WireGuard app without one. */ export function appsFor(preset: Preset): AppChoice[] { - const need = { - off: { vpn: '', awg: '' }, - balanced: { vpn: '4.8.12', awg: '2.0' }, - max: { vpn: 'current', awg: '3.1' }, - legacy: { vpn: '', awg: '' }, - }[preset]; const out: AppChoice[] = [ - { id: 'vpn', name: APP_NAME.vpn, need: need.vpn, sub: 'Connects from a link, no files' }, - { id: 'awg', name: APP_NAME.awg, need: need.awg, sub: 'The light client: a file or a QR code' }, + { id: 'vpn', name: APP_NAME.vpn }, + { id: 'awg', name: APP_NAME.awg }, ]; - if (preset === 'off') out.push({ id: 'wg', name: APP_NAME.wg, need: '', sub: 'Any WireGuard app: this server has no disguise' }); + if (preset === 'off') out.push({ id: 'wg', name: APP_NAME.wg }); return out; } -/** "This server needs AmneziaVPN 4.8.12 or newer. …", or "" when any version will do. */ -export function updateLine(app: AppChoice): string { - if (!app.need) return ''; - const what = app.need === 'current' ? `the current version of ${app.name}` : `${app.name} ${app.need} or newer`; - return `This server needs ${what}. Installed a while ago? Update it in the store.`; -} - export type Mark = 'appstore' | 'googleplay' | 'windows' | 'apple' | 'linux' | 'openwrt' | 'github' | 'site'; export interface Store { @@ -157,7 +133,8 @@ export const routerStore = (app: AppId): Store => main: 'wireguard-tools', mark: 'openwrt', } - : { href: 'https://openwrt.org/packages/start', top: 'OpenWrt packages', main: 'amneziawg-tools + kmod', mark: 'openwrt' }; + : // One line on a phone: the kernel module goes on top. + { href: 'https://openwrt.org/packages/start', top: 'OpenWrt packages + kmod', main: 'amneziawg-tools', mark: 'openwrt' }; /** * Does AmneziaVPN here open a `vpn://` link? Only the Android app registers the @@ -234,13 +211,15 @@ export function setupFromHash(hash: string): string | null { return /^#setup=(d_[0-9a-f]{8})$/.exec(hash)?.[1] ?? null; } +/** The personal link that opens straight on "Add a device": for the device itself to add, from its own browser. */ +export const addLink = (page: string): string => `${page}#add`; + +/** Does the link ask to add a device (`#add`)? */ +export const wantsAdd = (hash: string): boolean => hash === '#add'; + /** * "the phone", "the computer": the device being set up, in a sentence. The * sheet's title already names it; the lines under it do not repeat the name. */ export const deviceNoun = (kind: Kind): string => ({ phone: 'phone', tablet: 'tablet', computer: 'computer', router: 'router', other: 'device' })[kind]; - -/** "This iPhone", "This Mac": the pill for the device in hand. */ -export const hereLabel = (platform: Platform): string => - ({ ios: 'This iPhone', android: 'This phone', windows: 'This PC', mac: 'This Mac', linux: 'This PC', unknown: 'This device' })[platform]; diff --git a/web/src/portal/state.ts b/web/src/portal/state.ts new file mode 100644 index 0000000..326f81c --- /dev/null +++ b/web/src/portal/state.ts @@ -0,0 +1,74 @@ +// The page's state: the router's last answer, its clock and calendar, where the +// page is open and what the server runs. Everything that draws reads it from +// here. It also holds the one hook back to the page (`repaint`), so a flow can +// redraw the page without knowing how the page is built (main.ts sets it). + +import type { Kind, Person } from '../shared/types'; +import { isoDay } from '../shared/format'; +import { platformOf, type Platform, type Preset } from './setup'; + +export interface State { + person: Person; + /** device_mesh: devices with home access reach each other through the tunnel. */ + /** awg_disguise: false = plain WireGuard, any WireGuard app connects. */ + server: { name?: string; endpoint: string; device_mesh?: boolean; awg_disguise?: boolean; preset?: Preset }; + /** The device this page was opened from (through the tunnel), if any. */ + here?: string | null; + can_add: boolean; + /** The admin stopped the person (paused, access ended): the page only shows. */ + locked?: boolean; + /** Over plain HTTP: the same link over HTTPS, where the connection settings are. */ + https_url?: string | null; + kinds: Kind[]; + version: string; + /** The router's day (YYYY-MM-DD) when it sends one; the browser's otherwise. */ + today?: string; + /** The router's clock (epoch seconds): relative times are measured against it, not the phone's. */ + now?: number; + /** The router's UTC offset in minutes: the admin sets hours in its time, the page shows the visitor's. */ + tz_offset?: number; +} + +let current: State | null = null; + +export const state = (): State | null => current; +export function setState(st: State | null) { + current = st; +} + +const app = document.getElementById('app')!; +/** The page's path: the personal link. Its last part is the code (no sessions). */ +export const base = app.dataset.base ?? ''; +export const code = /^\/[a-z]{6}-[a-z]{6}-[a-z]{6}$/.test(base) ? base.slice(1) : ''; +/** This page's own address, without the fragment: what a link to another device carries. */ +export const pageUrl = () => location.origin + location.pathname; + +/** Today on the router, for days left and chart labels. */ +export const today = () => current?.today ?? isoDay(new Date()); +/** Now on the router (seconds), for "last connected 3 min ago". */ +export const now = () => current?.now ?? Date.now() / 1000; + +/** The platform this page is open on (iPad on Safari says Mac; touch points tell). */ +export const platform = (): Platform => platformOf(navigator.userAgent, navigator.maxTouchPoints); +/** The server's disguise is off: plain WireGuard, so any WireGuard app connects. */ +export const plainWg = () => current?.server.awg_disguise === false; +/** The server's disguise generation, for which apps and versions connect. */ +export const preset = (): Preset => current?.server.preset ?? (plainWg() ? 'off' : 'max'); +/** The secure twin when this page is plain HTTP, else null. */ +export const httpsTwin = () => current?.https_url || null; +/** The place this page belongs to: the server's name, "Dawnline" where there is none to name. */ +export const placeName = () => current?.server.name || 'Dawnline'; + +export interface RepaintOpts { + /** A card that is new: it pops in. */ + pop?: string; + /** A card that just connected: a green ring fades on it. */ + flash?: string; +} +let painter: (o: RepaintOpts) => void = () => undefined; +/** main.ts: how to draw the page again. */ +export function onRepaint(fn: (o: RepaintOpts) => void) { + painter = fn; +} +/** Draw the page again from the current state (a flow changed something). */ +export const repaint = (o: RepaintOpts = {}) => painter(o); diff --git a/web/src/portal/styles/access.css b/web/src/portal/styles/access.css new file mode 100644 index 0000000..32d53a1 --- /dev/null +++ b/web/src/portal/styles/access.css @@ -0,0 +1,345 @@ +/* "Your access": what it reaches as two tiles and the names at home; the data as a ring in the head + and the month day by day inside; until when as the days left over a calendar of the weeks, and + the hours as a bar of the day. */ + +.reach2 { + display: grid; + grid-template-columns: repeat(2, minmax(0, 1fr)); + gap: 8px; +} +.reach-tile { + position: relative; + display: flex; + flex-direction: column; + gap: 1px; + padding: 12px 12px 12px 14px; + border-radius: 16px; + background: var(--field); + min-width: 0; +} +.reach-tile .rt-ic { + width: 28px; + height: 28px; + margin-bottom: 10px; +} +.reach-tile b { + font-size: 14px; + line-height: 20px; + font-weight: 500; + letter-spacing: -0.015em; +} +.reach-tile .rt-sub { + font-size: 12px; + line-height: 16px; + color: var(--text-2); +} +.reach-tile .rt-mark { + position: absolute; + top: 12px; + right: 12px; + width: 20px; + height: 20px; + border-radius: 50%; + display: grid; + place-items: center; + background: var(--ok-soft); + color: var(--ok); +} +.reach-tile .rt-mark .i { + width: 12px; + height: 12px; + stroke-width: 2.4; +} +.reach-tile.off b { + color: var(--text-2); +} +.reach-tile.off .rt-sub { + color: var(--text-3); +} +.reach-tile.off .rt-ic { + opacity: 0.45; +} +.reach-tile.off .rt-mark { + background: var(--knob); + color: var(--text-3); +} +.lbl-s { + font-size: 12px; + font-weight: 500; + color: var(--text-2); +} +.names { + display: flex; + flex-wrap: wrap; + gap: 6px; +} +.namechip { + display: inline-flex; + align-items: center; + gap: 8px; + height: 32px; + padding: 0 10px 0 12px; + border-radius: 10px; + background: var(--field); + font-family: var(--mono); + font-size: 13px; + letter-spacing: 0; + transition: + background-color 150ms, + transform 150ms var(--ease-out); +} +.namechip:hover { + background: var(--knob); +} +.namechip:active { + transform: scale(0.96); +} +.namechip .faint { + color: var(--text-3); +} +.namechip .i { + width: 14px; + height: 14px; + color: var(--text-2); +} + +.ring { + width: 16px; + height: 16px; + transform: rotate(-90deg); +} +.ring .trk { + stroke: var(--bar); +} +.ring .arc { + stroke: var(--accent); +} +.ring .arc.warn { + stroke: var(--warn); +} +.ring .arc.bad { + stroke: var(--bad); +} +.month { + display: flex; + flex-direction: column; + gap: 8px; +} +.mbars { + display: flex; + align-items: flex-end; + gap: 3px; + height: 64px; +} +.mbars i { + flex: 1; + border-radius: 2.5px; + background: var(--bar); + min-height: 3px; + transition: background-color 120ms; +} +.mbars i.future { + background: color-mix(in srgb, var(--bar) 45%, transparent); +} +.mbars i.today { + background: var(--accent); +} +.mbars i:not(.future):hover { + background: var(--text-2); +} +.month-axis { + position: relative; + display: flex; + justify-content: space-between; + font-size: 11px; + color: var(--text-3); + font-weight: 500; +} +.month-axis .td { + position: absolute; + transform: translateX(-50%); + color: var(--accent); +} +.month-axis .hide { + visibility: hidden; +} +.month-read { + display: flex; + justify-content: space-between; + align-items: baseline; + margin-top: 10px; + font-size: 13px; + color: var(--text-2); +} +.month-read b { + color: var(--text); + font-weight: 500; + font-size: 15px; + letter-spacing: -0.02em; +} +.meter { + height: 6px; + border-radius: 3px; + background: var(--bar); + overflow: hidden; +} +.meter > i { + display: block; + height: 100%; + border-radius: 3px; + background: var(--accent); +} +.meter > i.warn { + background: var(--warn); +} +.meter > i.bad { + background: var(--bad); +} + +.until { + display: flex; + align-items: center; + justify-content: space-between; + gap: 16px; + padding: 14px 16px; + border-radius: 16px; + background: var(--field); +} +.until-num { + display: flex; + flex-direction: column; + min-width: 0; +} +.until-num b { + font-size: 36px; + line-height: 40px; + font-weight: 600; + letter-spacing: -0.045em; +} +.until-num span { + font-size: 13px; + line-height: 18px; + color: var(--text-2); +} +.until-num .until-sub { + margin-top: 8px; + font-size: 12px; + color: var(--text-3); +} +.until.soon .until-num b { + color: var(--warn); +} +.cal { + display: flex; + flex-direction: column; + gap: 6px; + flex: none; +} +.cal-h, +.cal-g { + display: grid; + grid-template-columns: repeat(7, 10px); + gap: 5px; +} +.cal-h span { + font-size: 9px; + line-height: 10px; + font-weight: 600; + color: var(--text-3); + text-align: center; +} +.cal-g i { + width: 10px; + height: 10px; + border-radius: 3px; + background: color-mix(in srgb, var(--text) 16%, transparent); +} +.cal-g i.past { + background: color-mix(in srgb, var(--text) 5%, transparent); +} +.cal-g i.today { + background: var(--accent); +} +.cal-g i.end { + background: transparent; + box-shadow: inset 0 0 0 1.5px var(--accent); +} +.cal-g i.after { + background: transparent; +} +.until.soon .cal-g i.today { + background: var(--warn); +} +.until.soon .cal-g i.end { + box-shadow: inset 0 0 0 1.5px var(--warn); +} +.acc-row.open .cal-g i { + animation: cal-in 360ms var(--ease-out) backwards; + animation-delay: calc(var(--i) * 7ms); +} +@keyframes cal-in { + from { + opacity: 0; + transform: scale(0.4); + } +} +.hours { + display: flex; + flex-direction: column; + gap: 8px; + padding: 14px 16px; + border-radius: 16px; + background: var(--field); +} +.hours-top { + display: flex; + justify-content: space-between; + align-items: baseline; + font-size: 13px; + color: var(--text-2); +} +.hours-top b { + color: var(--text); + font-weight: 500; + font-size: 15px; + letter-spacing: -0.02em; +} +.hours-bar { + position: relative; + height: 8px; + border-radius: 4px; + background: color-mix(in srgb, var(--text) 8%, transparent); +} +.hours-bar i { + position: absolute; + top: 0; + bottom: 0; + border-radius: 4px; + background: color-mix(in srgb, var(--ok) 70%, transparent); +} +.hours-now { + position: absolute; + top: -4px; + width: 2px; + height: 16px; + margin-left: -1px; + border-radius: 1px; + background: var(--text); + box-shadow: 0 0 0 2px var(--field); +} +.hours-now.out { + background: var(--warn); +} +.hours-axis { + display: flex; + justify-content: space-between; + font-size: 10px; + color: var(--text-3); + font-weight: 500; +} + +@media (prefers-reduced-motion: reduce) { + .acc-row.open .cal-g i { + animation: none; + } +} diff --git a/web/src/portal/styles/accordion.css b/web/src/portal/styles/accordion.css new file mode 100644 index 0000000..f554d64 --- /dev/null +++ b/web/src/portal/styles/accordion.css @@ -0,0 +1,136 @@ +/* The bouncy accordion: rows touch while closed and share their rounded ends; an open row lifts + out with 10px gaps and its own corners (ui/accordion.ts animates between the two shapes). Inside + the sheet ("inset") the rows sit one step lighter than the sheet. */ + +.acc { + display: flex; + flex-direction: column; +} +.acc-row { + background: var(--raised); + overflow: hidden; + border-radius: 0; + padding: 0 8px; + transition: background-color 150ms; +} +.acc-row.rt { + border-top-left-radius: var(--r-row); + border-top-right-radius: var(--r-row); +} +.acc-row.rb { + border-bottom-left-radius: var(--r-row); + border-bottom-right-radius: var(--r-row); +} +.acc-row.open { + margin-block: 10px; +} +.acc-row.open:first-child { + margin-top: 0; +} +.acc-row.open:last-child { + margin-bottom: 0; +} +.acc-row:not(.open):not(.still):hover { + background: color-mix(in srgb, var(--raised), var(--knob) 40%); +} +.acc-head { + width: 100%; + display: flex; + align-items: center; + gap: 10px; + height: 52px; + padding: 0 6px 0 8px; + text-align: left; +} +.acc-row.still .acc-head { + cursor: default; + padding-right: 10px; +} +.acc-head .gi { + width: 22px; + height: 22px; +} +.acc-title { + flex: 1; + min-width: 0; + font-size: 15px; + font-weight: 500; + letter-spacing: -0.02em; + display: flex; + align-items: center; + gap: 8px; +} +.acc-title .t { + min-width: 0; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; +} +/* A row whose body shows its numbers drops them from its head while open. */ +.acc-val { + display: flex; + align-items: center; + gap: 8px; + color: var(--text-2); + font-size: 14px; + white-space: nowrap; + transition: + opacity 200ms var(--ease-out), + filter 200ms var(--ease-out), + transform 260ms var(--ease-out); +} +.acc-val > span { + display: inline-flex; + align-items: center; + gap: 8px; +} +.acc-row.open .acc-val.hide-open { + opacity: 0; + filter: blur(4px); + transform: translateX(8px); + pointer-events: none; +} +.acc-chev { + width: 16px; + height: 16px; + color: var(--text-2); + transform: rotate(90deg); + transition: transform var(--spring-soft-dur, 470ms) var(--spring-soft, ease); +} +.acc-row.open .acc-chev { + transform: rotate(-90deg); +} +.acc-body { + display: none; + padding: 0 8px 16px 40px; +} +.acc-row.open .acc-body, +.acc-row.closing .acc-body { + display: flex; + flex-direction: column; + gap: 12px; +} +.acc .desc { + margin: 0; + font-size: 14px; + line-height: 20px; + opacity: 0.6; +} +.acc.inset .acc-row { + background: var(--field); +} +.acc.inset .acc-row:not(.open):not(.still):hover { + background: color-mix(in srgb, var(--field), var(--knob) 50%); +} +.acc.inset .acc-body { + padding-left: 8px; +} +.acc.inset .seg { + background: color-mix(in srgb, var(--knob) 65%, var(--field)); +} + +@media (prefers-reduced-motion: reduce) { + .acc-chev { + transition: none; + } +} diff --git a/web/src/portal/styles/base.css b/web/src/portal/styles/base.css new file mode 100644 index 0000000..c2270a0 --- /dev/null +++ b/web/src/portal/styles/base.css @@ -0,0 +1,151 @@ +/* The ground every part stands on: the reset, the type, focus and selection, the small utilities, + the icons (line icons and the glass ones). */ + +* { + box-sizing: border-box; +} +html { + -webkit-text-size-adjust: 100%; + /* The page keeps its width when a sheet locks the scroll: no sideways jump behind the scrim. */ + scrollbar-gutter: stable; +} +body { + margin: 0; + background: var(--bg); + color: var(--text); + font: 400 15px/22px var(--font); + letter-spacing: -0.011em; + -webkit-font-smoothing: antialiased; + min-height: 100vh; + min-height: 100dvh; + /* An app, not a document: the arrow over text. Controls set the hand; what is typed or copied by + hand (fields, the link, the configuration) keeps the I-beam. */ + cursor: default; +} +body.locked { + overflow: hidden; +} +input, +textarea, +.linkrow .mono, +.conf { + cursor: text; +} +::selection { + background: var(--sel-bg); + color: var(--sel-fg); +} +button { + font: inherit; + color: inherit; + letter-spacing: inherit; + background: none; + border: 0; + padding: 0; + margin: 0; + cursor: pointer; + -webkit-tap-highlight-color: transparent; +} +button:disabled { + cursor: default; +} +a { + color: inherit; + text-decoration: none; +} +:focus { + outline: none; +} +:focus-visible { + outline: 2px solid color-mix(in srgb, var(--accent) 65%, transparent); + outline-offset: 2px; +} +[hidden] { + display: none !important; +} +.offscreen { + position: fixed; + left: -9999px; + top: 0; + opacity: 0; +} +.mono { + font-family: var(--mono); + letter-spacing: 0; +} +.num { + font-variant-numeric: tabular-nums; +} +.ok-t { + color: var(--ok); +} +.warn-t { + color: var(--warn); +} +.bad-t { + color: var(--bad); +} +.here-t { + color: var(--accent); +} + +/* line icons */ +.i { + width: 18px; + height: 18px; + flex: none; +} + +/* glass icons: the colours come from here (the CSP drops style attributes) */ +.gi { + width: 24px; + height: 24px; + flex: none; + overflow: visible; + --ta: var(--t-grey-a); + --tb: var(--t-grey-b); +} +.gi.t-blue { + --ta: var(--t-blue-a); + --tb: var(--t-blue-b); +} +.gi.t-green { + --ta: var(--t-green-a); + --tb: var(--t-green-b); +} +.gi.t-red { + --ta: var(--t-red-a); + --tb: var(--t-red-b); +} +.gi.t-orange { + --ta: var(--t-orange-a); + --tb: var(--t-orange-b); +} +.gi .ta { + stop-color: var(--ta); +} +.gi .tb { + stop-color: var(--tb); +} +.gi .fa { + stop-color: var(--gi-a); +} +.gi .fb { + stop-color: var(--gi-b); +} +.gi .fc { + stop-color: var(--ta); + stop-opacity: 0.28; +} +.gi .ge { + stroke: var(--gi-edge); +} +.gi .gr { + stroke: var(--gi-rim); +} +.gi .gd { + stroke: var(--gi-detail); +} +.gi .gdf { + color: var(--gi-detail); +} diff --git a/web/src/portal/styles/controls.css b/web/src/portal/styles/controls.css new file mode 100644 index 0000000..678312f --- /dev/null +++ b/web/src/portal/styles/controls.css @@ -0,0 +1,660 @@ +/* The controls every part uses: round knobs, buttons (and their busy orb), the field with its + go button, the icon picker, the kinds with their ring, badges, hints and menu paths, the link row, + QR codes and the row that puts a code beside its words. */ + +.knob { + width: 32px; + height: 32px; + border-radius: 50%; + background: var(--knob); + color: var(--text); + display: grid; + place-items: center; + flex: none; + transition: + transform 150ms var(--ease-out), + background-color 150ms; +} +.knob:hover { + background: color-mix(in srgb, var(--knob), var(--text) 6%); +} +.knob:active { + transform: scale(0.8); +} +.knob .i { + width: 16px; + height: 16px; +} +.knob.back .i { + transform: rotate(180deg); +} +.knob[aria-expanded='true'] { + background: color-mix(in srgb, var(--knob), var(--text) 10%); +} + +.btn { + height: 48px; + border-radius: 999px; + display: inline-flex; + align-items: center; + justify-content: center; + gap: 8px; + padding: 0 20px; + font-size: 16px; + font-weight: 500; + letter-spacing: -0.015em; + user-select: none; + -webkit-user-select: none; + transition: + transform 200ms var(--ease-out), + background-color 200ms var(--ease-out), + color 200ms var(--ease-out); +} +.btn:active { + transform: scale(0.95); +} +.btn.block { + width: 100%; +} +.btn.sm { + height: 40px; + font-size: 15px; + padding: 0 16px; +} +.btn.accent { + background: var(--accent); + color: var(--accent-ink); + font-weight: 600; +} +.btn.accent:hover { + background: color-mix(in srgb, var(--accent) 82%, transparent); +} +/* The quiet accent: a card's Connect, tinted rather than filled. */ +.btn.tint { + background: var(--accent-soft); + color: var(--accent); + font-weight: 600; +} +.btn.tint:hover { + background: color-mix(in srgb, var(--accent) 20%, transparent); +} +.btn.tint:active { + background: color-mix(in srgb, var(--accent) 24%, transparent); +} +.btn.soft { + background: var(--knob); + color: var(--text); +} +.btn.soft:hover { + background: color-mix(in srgb, var(--knob), var(--text) 6%); +} +.btn.red { + background: var(--bad); + color: #fff; + font-weight: 600; +} +/* Waiting for the router: the button keeps its size, its content blurs away and an orb comes up in + its place (ui/busy.ts runs the change). The orb is B4 Converge from aicss.dev's Orbs, at its own + 28px stage and twice its speed: one circle walks a triangle, sharp at each corner and smaller, + softer in between; a second breathes in the middle. */ +.busy { + position: relative; +} +.orb { + position: absolute; + inset: 0; + margin: auto; + width: 28px; + height: 28px; + overflow: hidden; + contain: strict; + pointer-events: none; +} +.orb i { + position: absolute; + left: 50%; + top: 50%; + width: 7px; + height: 7px; + margin: -3.5px 0 0 -3.5px; + border-radius: 50%; + background: currentColor; + animation: orb-converge 1.8s linear infinite both; +} +.orb i:nth-child(2) { + animation: orb-breathe 1.8s ease-in-out infinite both; +} +/* Top, bottom right, bottom left: a beat at each corner, then away (ease-in) and in (ease-out). */ +@keyframes orb-converge { + 0% { + transform: translate(0px, -5px) scale(1); + filter: blur(0); + animation-timing-function: linear; + } + 10% { + transform: translate(0px, -5px) scale(1); + filter: blur(0); + animation-timing-function: cubic-bezier(0.55, 0, 1, 0.45); + } + 22% { + transform: translate(2.15px, -1.25px) scale(0.72); + filter: blur(0.8px); + animation-timing-function: cubic-bezier(0.33, 1, 0.68, 1); + } + 33% { + transform: translate(4.3px, 2.5px) scale(1); + filter: blur(0); + animation-timing-function: linear; + } + 43% { + transform: translate(4.3px, 2.5px) scale(1); + filter: blur(0); + animation-timing-function: cubic-bezier(0.55, 0, 1, 0.45); + } + 55% { + transform: translate(0px, 2.5px) scale(0.72); + filter: blur(0.8px); + animation-timing-function: cubic-bezier(0.33, 1, 0.68, 1); + } + 66% { + transform: translate(-4.3px, 2.5px) scale(1); + filter: blur(0); + animation-timing-function: linear; + } + 77% { + transform: translate(-4.3px, 2.5px) scale(1); + filter: blur(0); + animation-timing-function: cubic-bezier(0.55, 0, 1, 0.45); + } + 88% { + transform: translate(-2.15px, -1.25px) scale(0.72); + filter: blur(0.8px); + animation-timing-function: cubic-bezier(0.33, 1, 0.68, 1); + } + 100% { + transform: translate(0px, -5px) scale(1); + filter: blur(0); + } +} +@keyframes orb-breathe { + 0%, + 100% { + opacity: 0.16; + filter: blur(2.4px); + transform: scale(1.2); + } + 50% { + opacity: 0.32; + filter: blur(1.6px); + transform: scale(0.98); + } +} + +.field { + height: 48px; + border-radius: var(--r-field); + background: var(--field); + display: flex; + align-items: center; + gap: 12px; + padding: 0 4px 0 16px; + overflow: hidden; + transition: box-shadow 200ms var(--ease-out); +} +.field:focus-within { + box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--text) 16%, transparent); +} +.field input { + flex: 1; + min-width: 0; + border: 0; + outline: 0; + background: transparent; + padding: 0; + font: 500 16px/24px var(--font); + color: var(--text); + letter-spacing: -0.012em; +} +.field input::placeholder { + color: var(--text-3); +} +.go { + width: 48px; + height: 40px; + border-radius: 12px; + background: var(--knob); + color: var(--text-3); + display: grid; + place-items: center; + flex: none; + transition: + background-color 200ms var(--ease-out), + color 200ms var(--ease-out), + transform 200ms var(--ease-out); +} +.go .i { + width: 20px; + height: 20px; +} +.go.ready { + background: var(--accent); + color: var(--accent-ink); +} +.go.ready:active { + transform: scale(0.9); +} +.go:not(.ready) { + cursor: not-allowed; +} + +/* The icon picker (skiper21's tabs): icons only, the picked one widens and shows its name. */ +.seg { + position: relative; + display: flex; + align-items: center; + height: 48px; + padding: 0 4px; + border-radius: var(--r-field); + background: var(--field); +} +.seg-pill { + position: absolute; + left: 0; + top: 4px; + height: 40px; + border-radius: 12px; + background: var(--seg); + box-shadow: var(--seg-shadow); + pointer-events: none; +} +.seg-b { + position: relative; + z-index: 1; + height: 40px; + font-size: 16px; + font-weight: 500; + color: var(--text-3); + white-space: nowrap; + transition: color 200ms var(--ease-out); +} +.seg-b.on { + color: var(--text); +} +.seg-b:not(.on):hover { + color: var(--text-2); +} +.appseg .seg-b { + flex: 0 0 56px; + display: flex; + align-items: center; + justify-content: center; + justify-content: safe center; + gap: 8px; + padding: 0 18px; + overflow: hidden; +} +.appseg .seg-b.on { + flex: 1 1 56px; +} +.appseg .seg-b .i { + width: 20px; + height: 20px; +} +.appseg .seg-l { + max-width: 0; + opacity: 0; + margin-left: -8px; + overflow: hidden; + white-space: nowrap; +} +.appseg .seg-b.on .seg-l { + max-width: 180px; + opacity: 1; + margin-left: 0; +} +/* Three apps on a phone: the icons take less room, so the picked one's name fits whole. */ +.appseg { + container-type: inline-size; +} +@container (max-width: 300px) { + .appseg .seg-b { + flex-basis: 44px; + padding: 0 12px; + } +} + +/* What a new device is: four tiles, the picked one ringed in place; the label under its tile. */ +.kinds { + display: grid; + grid-template-columns: repeat(var(--n, 4), minmax(0, 1fr)); + gap: 8px; + position: relative; + container-type: inline-size; +} +.kind { + position: relative; + z-index: 1; + display: flex; + flex-direction: column; + align-items: center; + gap: 8px; + min-width: 0; + color: var(--text-3); + font-size: 12px; + line-height: 16px; + font-weight: 500; + transition: color 200ms var(--ease-out); +} +.kind-tile { + width: 100%; + height: 56px; + border-radius: 14px; + background: var(--field); + display: grid; + place-items: center; + transition: + background-color 200ms var(--ease-out), + transform 200ms var(--ease-out), + box-shadow 220ms var(--ease-out); +} +.kind.on .kind-tile { + box-shadow: inset 0 0 0 1.5px var(--accent); +} +.kind-lbl { + white-space: nowrap; +} +.kind:hover .kind-tile, +.kind:focus-visible .kind-tile { + background: var(--knob); +} +.kind:active .kind-tile { + transform: scale(0.94); +} +.kind:focus-visible { + outline: none; +} +.kind:focus-visible .kind-lbl, +.kind.on { + color: var(--text); +} +.kind .gi { + width: 26px; + height: 26px; + filter: grayscale(1); + opacity: 0.55; + transition: + filter 260ms var(--ease-out), + opacity 260ms var(--ease-out); +} +.kind.on .gi { + filter: none; + opacity: 1; +} +@container (max-width: 330px) { + .kind-tile { + height: 50px; + } + .kind { + font-size: 11.5px; + } +} +.or { + display: flex; + align-items: center; + gap: 12px; + margin: 22px 0; + color: var(--text-3); + font-size: 12px; + font-weight: 500; + letter-spacing: 0.06em; +} +.or::before, +.or::after { + content: ''; + flex: 1; + height: 1px; + background: var(--line); +} + +/* A store (or an action) as a tile: its mark, two lines, a chevron or the open mark. */ +.badge { + width: 100%; + text-align: left; + display: flex; + align-items: center; + gap: 12px; + height: 60px; + padding: 0 14px 0 12px; + border-radius: 18px; + background: var(--field); + transition: + background-color 200ms, + transform 200ms var(--ease-out); +} +.badge:hover { + background: var(--knob); +} +.badge:active { + transform: scale(0.98); +} +.badge .b-ic { + width: 36px; + height: 36px; + border-radius: 10px; + background: var(--text); + color: var(--raised); + display: grid; + place-items: center; + flex: none; +} +.badge .b-ic .i { + width: 20px; + height: 20px; +} +.badge .b-t { + flex: 1; + min-width: 0; + display: flex; + flex-direction: column; +} +.badge .b-top { + font-size: 12px; + line-height: 16px; + color: var(--text-2); +} +.badge .b-main { + font-size: 15px; + line-height: 20px; + font-weight: 500; +} +.badge > .i { + color: var(--text-3); + width: 16px; + height: 16px; +} +/* Step 2 is neutral like the other tiles; only its mark keeps the accent. */ +.badge.primary .b-ic { + background: var(--accent-soft); + color: var(--accent); +} +.badges2 { + display: grid; + grid-template-columns: repeat(2, minmax(0, 1fr)); + gap: 8px; +} +.badges2 .badge { + padding: 0 10px; + gap: 10px; +} +.badges2 .badge > .i { + display: none; +} +.badges2 .b-ic { + width: 32px; + height: 32px; +} +.hint { + margin: 0; + font-size: 13px; + line-height: 18px; + color: var(--text-2); +} +.hint a, +.hint button { + color: var(--accent); + font-weight: 500; +} +.howto { + margin: 0; + padding: 0; + list-style: none; + display: flex; + flex-wrap: wrap; + align-items: center; + gap: 6px; + font-size: 13px; + color: var(--text-2); +} +.howto li { + display: inline-flex; + align-items: center; + gap: 6px; +} +.howto li + li::before { + content: '›'; + color: var(--text-3); +} +.howto b { + color: var(--text); + font-weight: 500; +} + +.linkrow { + display: flex; + align-items: center; + gap: 8px; + height: 44px; + padding: 0 4px 0 14px; + border-radius: 14px; + background: color-mix(in srgb, var(--knob) 72%, var(--field)); +} +.view > .linkrow { + background: var(--field); +} +.linkrow .mono { + flex: 1; + min-width: 0; + font-size: 13px; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + user-select: all; +} +.linkrow .knob { + width: 36px; + height: 36px; + border-radius: 10px; + background: transparent; +} +.linkrow .knob:hover { + background: var(--knob); +} + +/* QR codes: the night look on a dark theme, dark on white on a light one; a dense code fills its row. */ +.qrbox { + position: relative; + width: 148px; + height: 148px; + flex: none; + border-radius: 18px; + overflow: hidden; + background: var(--qr-bg); +} +.qrbox.light { + box-shadow: inset 0 0 0 1px var(--line); +} +.qrbox.big { + width: 208px; + height: 208px; + border-radius: 24px; + align-self: center; +} +.qrbox.big + .linkrow { + margin-top: 16px; +} +.qrbox.dense { + width: 100%; + max-width: none; + height: auto; + aspect-ratio: 1; + align-self: stretch; + border-radius: 22px; +} +.qrbox svg { + display: block; + width: 100%; + height: 100%; +} +/* A code swapping for another: the old one lies over the new one while it fades. */ +.qrbox > svg.old { + position: absolute; + inset: 0; +} +.coderow { + display: flex; + gap: 14px; + align-items: flex-start; +} +.coderow.stacked { + flex-direction: column; + align-items: stretch; +} +.coderow .side { + position: relative; + display: flex; + flex-direction: column; + gap: 8px; + min-width: 0; + font-size: 14px; + line-height: 20px; + color: var(--text-2); +} +.coderow .side b { + color: var(--text); + font-weight: 500; +} +.side .words { + display: flex; + flex-direction: column; + gap: 8px; +} +.side .words.old { + position: absolute; + left: 0; + right: 0; + top: 0; + pointer-events: none; +} +.side .arr { + color: var(--text-2); + font-weight: 400; + margin: 0 6px; +} +@media (max-width: 380px) { + .coderow { + flex-direction: column; + } +} + +@media (prefers-reduced-motion: reduce) { + /* The orb's own still frame: the front circle sharp, the other two a soft halo behind it. */ + .orb i { + animation: none; + opacity: 0.3; + filter: blur(1.4px); + } + .orb i:first-child { + opacity: 1; + filter: none; + } +} diff --git a/web/src/portal/styles/devices.css b/web/src/portal/styles/devices.css new file mode 100644 index 0000000..9c414d9 --- /dev/null +++ b/web/src/portal/styles/devices.css @@ -0,0 +1,201 @@ +/* "Your devices": the grid, a card per device (its glass icon, name and one-line status, ⋯; the week + as a number and bars, the Update pill, or Connect), the card that adds one, the first device. */ + +.dgrid { + display: grid; + gap: 10px; + grid-template-columns: minmax(0, 1fr); +} +@media (min-width: 560px) { + .dgrid { + grid-template-columns: repeat(2, minmax(0, 1fr)); + } +} +.dev { + background: var(--raised); + border-radius: var(--r-card); + padding: 8px; + display: flex; + flex-direction: column; + gap: 8px; + min-width: 0; +} +.dev.is-here { + box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 32%, transparent); +} +.dev.off { + opacity: 0.5; +} +.dev-top { + display: flex; + align-items: center; + gap: 12px; + padding: 8px 6px 6px 10px; +} +.dev-top .gi { + width: 32px; + height: 32px; +} +.dev-id { + flex: 1; + min-width: 0; + display: flex; + flex-direction: column; +} +.dev-name { + font-size: 16px; + line-height: 22px; + font-weight: 500; + letter-spacing: -0.02em; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; +} +/* Every card the same height: a one-line status. */ +.dev-stat { + font-size: 13px; + line-height: 18px; + color: var(--text-2); + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; +} +.dev-stat.ok-t { + color: var(--ok); +} +.dev-stat.warn-t { + color: var(--warn); +} +.dev-stat.here-t { + color: var(--accent); +} +.dev-use { + margin-top: auto; + background: var(--field); + border-radius: var(--r-row); + padding: 12px 14px 12px 16px; + display: flex; + align-items: flex-end; + justify-content: space-between; + gap: 12px; + min-height: 66px; +} +.use-txt { + display: flex; + flex-direction: column; + min-width: 0; +} +.use-lbl { + font-size: 13px; + line-height: 18px; + color: var(--text-2); + white-space: nowrap; +} +.use-val { + font-size: 17px; + line-height: 24px; + font-weight: 500; + letter-spacing: -0.02em; +} +.spark { + display: flex; + align-items: flex-end; + gap: 4px; + height: 34px; +} +.spark i { + width: 6px; + border-radius: 3px; + background: var(--bar); + transition: background-color 150ms; +} +.spark i.today { + background: var(--accent); +} +.spark i:hover { + background: var(--text-2); +} +.spark i.today:hover { + background: color-mix(in srgb, var(--accent) 75%, var(--text)); +} +.dev .setup-btn { + margin-top: auto; +} +.upd-pill { + display: inline-flex; + align-items: center; + align-self: center; + gap: 6px; + height: 32px; + padding: 0 12px 0 10px; + border-radius: 999px; + flex: none; + background: color-mix(in srgb, var(--warn) 14%, transparent); + color: var(--warn); + font-size: 13px; + font-weight: 600; + transition: + background-color 150ms, + transform 150ms var(--ease-out); +} +.upd-pill:hover { + background: color-mix(in srgb, var(--warn) 22%, transparent); +} +.upd-pill:active { + transform: scale(0.94); +} +.upd-pill .i { + width: 14px; + height: 14px; +} +.dev.add { + align-items: center; + justify-content: center; + min-height: 144px; + gap: 10px; + color: var(--text-2); + font-weight: 500; + transition: + background-color 200ms var(--ease-out), + transform 200ms var(--ease-out); +} +.dev.add:hover { + background: color-mix(in srgb, var(--raised), var(--knob) 45%); +} +.dev.add:active { + transform: scale(0.98); +} +.dev.add .gi { + width: 36px; + height: 36px; +} +/* Nothing yet: one card across the grid, what comes and the button. */ +.dev.first { + grid-column: 1 / -1; + align-items: center; + text-align: center; + padding: 28px 24px 24px; + gap: 6px; +} +.dev.first .gi { + width: 44px; + height: 44px; + margin-bottom: 8px; +} +.dev.first b { + font-size: 18px; + line-height: 24px; + font-weight: 500; + letter-spacing: -0.02em; +} +.dev.first p { + margin: 0 0 14px; + color: var(--text-2); + font-size: 14px; + line-height: 20px; + max-width: 34ch; + text-wrap: balance; +} +.dev.first .btn { + max-width: 320px; +} diff --git a/web/src/portal/styles/index.css b/web/src/portal/styles/index.css new file mode 100644 index 0000000..78e9921 --- /dev/null +++ b/web/src/portal/styles/index.css @@ -0,0 +1,13 @@ +/* Dawnline personal portal: the stylesheet, one file per part, joined into one portal.css by the + build (tsup.config.ts). Order matters only where a later part refines an earlier one. */ +@import './tokens.css'; +@import './base.css'; +@import './controls.css'; +@import './morph.css'; +@import './accordion.css'; +@import './page.css'; +@import './devices.css'; +@import './access.css'; +@import './sheet.css'; +@import './setup.css'; +@import './menu-toast.css'; diff --git a/web/src/portal/styles/menu-toast.css b/web/src/portal/styles/menu-toast.css new file mode 100644 index 0000000..672fe0c --- /dev/null +++ b/web/src/portal/styles/menu-toast.css @@ -0,0 +1,109 @@ +/* The ⋯ menu (a highlight that glides after the pointer, tinted for Reconnect and Remove) and the + toast slot at the bottom. */ + +.menu { + position: fixed; + z-index: 60; + min-width: 224px; + padding: 6px; + border-radius: 20px; + background: var(--field); + box-shadow: + var(--pop-shadow), + inset 0 0 0 1px var(--line); +} +.menu-hl { + position: absolute; + left: 6px; + right: 6px; + top: 6px; + height: 40px; + border-radius: 14px; + background: var(--knob); + opacity: 0; + transition: opacity 150ms var(--ease-out); + pointer-events: none; +} +.menu-hl.moving { + transition: + opacity 150ms var(--ease-out), + transform var(--spring-quick-dur, 300ms) var(--spring-quick, ease-out), + background-color 150ms; +} +.menu-hl.bad { + background: var(--bad-soft); +} +.menu-hl.warn { + background: color-mix(in srgb, var(--warn) 13%, transparent); +} +.mi { + position: relative; + z-index: 1; + display: flex; + align-items: center; + gap: 12px; + width: 100%; + height: 40px; + padding: 0 12px; + border-radius: 14px; + font-size: 14px; + font-weight: 500; + text-align: left; +} +.mi .i { + width: 16px; + height: 16px; + color: var(--text-2); +} +.mi.warn, +.mi.warn .i { + color: var(--warn); +} +.mi.bad, +.mi.bad .i { + color: var(--bad); +} +.menu-sep { + height: 1px; + margin: 6px 12px; + background: var(--line); +} + +/* One toast at a time; a new one comes in over the leaving one. */ +.toasts { + position: fixed; + left: 0; + right: 0; + height: 42px; + bottom: calc(24px + env(safe-area-inset-bottom, 0px)); + z-index: 70; + display: flex; + justify-content: center; + align-items: flex-end; + pointer-events: none; + padding-left: var(--gutter-l); + padding-right: var(--gutter-r); +} +.toast { + position: absolute; + display: flex; + align-items: center; + gap: 8px; + height: 42px; + padding: 0 18px 0 13px; + border-radius: 999px; + background: var(--toast); + color: var(--toast-fg); + font-size: 14px; + font-weight: 500; + box-shadow: var(--pop-shadow); + white-space: nowrap; +} +.toast .i { + width: 18px; + height: 18px; + color: var(--ok); +} +.toast.bad .i { + color: var(--bad); +} diff --git a/web/src/portal/styles/morph.css b/web/src/portal/styles/morph.css new file mode 100644 index 0000000..78b3e75 --- /dev/null +++ b/web/src/portal/styles/morph.css @@ -0,0 +1,27 @@ +/* A text morphing in place (ui/morph.ts): the new letters in the flow, the old ones laid over them + against the edge that stays put while they go; done, it is plain text again. */ +.mt { + position: relative; +} +.mt-ib { + display: inline-block; + white-space: nowrap; +} +.mt-new { + white-space: nowrap; +} +.mt-old { + position: absolute; + white-space: nowrap; + pointer-events: none; +} +.mt-new.w, +.mt-old.w { + white-space: inherit; +} +.mt-new i, +.mt-old i { + font-style: normal; + display: inline-block; + white-space: pre; +} diff --git a/web/src/portal/styles/page.css b/web/src/portal/styles/page.css new file mode 100644 index 0000000..5e52e45 --- /dev/null +++ b/web/src/portal/styles/page.css @@ -0,0 +1,238 @@ +/* The page's frame: the edge fades, the breadcrumb, the two columns and their heads, the notice that + says what stops the devices, and the card that stands alone when the link stopped working. */ + +/* The page fades out under the edges (iconiqui's dia-text, measured): on top a blur that thins out + over a darkening ramp, once the page scrolls; at the bottom only the ramp. Above the page, under + sheets, menus and toasts. */ +.edge-fade { + position: fixed; + left: 0; + right: 0; + z-index: 30; + pointer-events: none; +} +.edge-fade.top { + top: 0; + height: calc(80px + env(safe-area-inset-top, 0px)); + opacity: 0; + transition: opacity 200ms; + background: linear-gradient(var(--bg) 0%, color-mix(in srgb, var(--bg) 75%, transparent) 50%, transparent 100%); + -webkit-backdrop-filter: blur(12px); + backdrop-filter: blur(12px); + -webkit-mask-image: linear-gradient(#000 0%, rgba(0, 0, 0, 0.88) 44%, transparent 100%); + mask-image: linear-gradient(#000 0%, rgba(0, 0, 0, 0.88) 44%, transparent 100%); +} +body.scrolled .edge-fade.top { + opacity: 1; +} +.edge-fade.bot { + bottom: 0; + height: calc(96px + env(safe-area-inset-bottom, 0px)); + background: linear-gradient(to top in oklab, var(--bg) 0%, transparent 100%); +} + +/* The breadcrumb (iconiqui, measured): 32px high, the mark in a 32px box, 15px crumbs 6px apart + with a 14px chevron, the current one brighter. The mark is one colour: the text's. */ +.crumbs { + display: flex; + align-items: center; + gap: 10px; + height: 32px; + margin: 0 0 32px; +} +.cr-mark { + width: 32px; + height: 32px; + display: grid; + place-items: center; + flex: none; +} +.logo { + width: 24px; + height: 24px; + flex: none; + overflow: hidden; +} +.logo .sun, +.logo .bar { + fill: var(--text); +} +.cr-path { + flex: 1; + min-width: 0; + display: flex; + align-items: center; + gap: 6px; + font-size: 15px; + line-height: 22px; + letter-spacing: -0.15px; + color: var(--text-2); +} +.cr-path span { + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; +} +.cr-path .cur { + color: var(--text); + font-weight: 500; +} +.cr-path .i { + width: 14px; + height: 14px; +} + +/* Phones: one column, access first. From 960px: devices left, access right and sticky. The foot + clears the bottom fade at the end of the scroll. */ +.page { + max-width: 1072px; + margin: 0 auto; + padding-left: var(--gutter-l); + padding-right: var(--gutter-r); + padding-block: calc(40px + env(safe-area-inset-top, 0px)) 112px; +} +.cols { + display: grid; + gap: 40px; +} +.cols > .access { + order: -1; +} +@media (min-width: 960px) { + .cols { + grid-template-columns: minmax(0, 1fr) 384px; + gap: 36px; + align-items: start; + } + .cols > .access { + order: 0; + position: sticky; + top: calc(84px + env(safe-area-inset-top, 0px)); + } +} +.sec-head { + display: flex; + align-items: baseline; + gap: 8px; + padding: 0 4px 12px; +} +.sec-head h2 { + margin: 0; + font-size: 20px; + line-height: 28px; + font-weight: 500; + letter-spacing: -0.025em; +} +.sec-head .aside { + color: var(--text-3); + font-size: 14px; + font-weight: 500; +} +.sec-head .aside.warn-t { + color: var(--warn); +} +.note-s { + margin: 12px 4px 0; + color: var(--text-3); + font-size: 13px; + line-height: 18px; +} + +/* A notice wears its tone: the fill tinted, the rim a little stronger. */ +.notice { + display: flex; + align-items: center; + gap: 14px; + padding: 14px 18px 14px 14px; + border-radius: 24px; + background: var(--raised); + margin: 0 0 22px; +} +.notice .gi { + width: 36px; + height: 36px; +} +.notice .t { + display: flex; + flex-direction: column; + min-width: 0; +} +.notice b { + font-weight: 500; + font-size: 15px; + line-height: 22px; + letter-spacing: -0.02em; +} +.notice span { + color: var(--text-2); + font-size: 14px; + line-height: 20px; +} +.notice.warn { + background: color-mix(in srgb, var(--warn) 10%, var(--raised)); + box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--warn) 22%, transparent); +} +.notice.bad { + background: color-mix(in srgb, var(--bad) 10%, var(--raised)); + box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--bad) 22%, transparent); +} + +/* The page when there is nothing else: the link stopped working, or nothing could load. */ +/* One card in place of the page: the breadcrumb over it, the two together in the middle of the screen. */ +.page.single { + min-height: 100vh; + min-height: 100dvh; + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + padding-block: calc(24px + env(safe-area-inset-top, 0px)) calc(24px + env(safe-area-inset-bottom, 0px)); +} +/* Centred on its words, the mark hanging to their left, then nudged right by about half the mark's width: + to the eye the mark and words together sit in the middle. The row keeps room for the mark on both sides. */ +.page.single .crumbs { + position: relative; + left: 12px; + max-width: calc(100% - 84px); + margin: 0 0 16px; +} +.page.single .cr-mark { + position: absolute; + right: calc(100% + 10px); + top: 0; +} +.page.single .page-body { + width: 100%; + max-width: 400px; +} +.page.single .gone { + margin: 0; +} +.gone { + max-width: 400px; + margin: 12vh auto 0; + padding: 32px 24px 28px; + border-radius: var(--r-sheet); + background: var(--raised); + text-align: center; + display: flex; + flex-direction: column; + align-items: center; +} +.gone .gi { + width: 56px; + height: 56px; + margin-bottom: 16px; +} +.gone h1 { + margin: 0; + font-size: 22px; + line-height: 28px; + font-weight: 500; + letter-spacing: -0.03em; +} +.gone p { + margin: 6px 0 0; + color: var(--text-2); + text-wrap: balance; +} diff --git a/web/src/portal/styles/setup.css b/web/src/portal/styles/setup.css new file mode 100644 index 0000000..79166a0 --- /dev/null +++ b/web/src/portal/styles/setup.css @@ -0,0 +1,318 @@ +/* The set-up sheet: the numbered steps, the way from the device to the server while the page waits + (and its line morphing into " connected"), the .conf for a router, and the scan line that + speaks for both phone systems. */ + +.setup { + display: flex; + flex-direction: column; +} +.setup .notice { + margin: 0 0 16px; +} +/* The steps fold to nothing under the way round: their gap is a block inside them, not padding + (a border-box never folds below its padding). */ +.steps-gap { + height: 22px; +} +.step { + display: flex; + gap: 12px; +} +.step + .step { + margin-top: 20px; +} +.step-n { + width: 24px; + height: 24px; + border-radius: 50%; + background: var(--knob); + font-size: 13px; + font-weight: 600; + display: grid; + place-items: center; + flex: none; +} +.step-b { + flex: 1; + min-width: 0; + display: flex; + flex-direction: column; + gap: 10px; +} +.step-t { + font-size: 16px; + line-height: 24px; + font-weight: 500; + letter-spacing: -0.02em; +} +.step-box { + display: flex; + flex-direction: column; + gap: 10px; +} + +/* The way, as on the old portal: one dotted line, three layers through the same dots (the dots, the + light along them that runs and rests a beat, the green that fills them from the device); the + router's end lights up last, when the green gets there. */ +.way { + display: flex; + flex-direction: column; + padding: 12px 14px; + border-radius: 20px; + background: var(--field); + margin-bottom: 18px; +} +.way-row { + display: flex; + align-items: center; + gap: 10px; +} +.way-end { + width: 34px; + height: 34px; + border-radius: 11px; + background: var(--knob); + display: grid; + place-items: center; + flex: none; + color: var(--text-2); + transition: + background-color 400ms var(--ease-out), + color 400ms var(--ease-out); +} +.way-end .i { + width: 17px; + height: 17px; +} +.way-end.home { + color: var(--accent); + background: color-mix(in srgb, var(--accent) 14%, transparent); +} +.way-track { + position: relative; + flex: 1; + height: 8px; +} +.way-track::before, +.way-glow, +.way-fill { + content: ''; + position: absolute; + inset: 0; + -webkit-mask: radial-gradient(circle, #000 1.4px, transparent 1.9px) 0 50% / 9px 8px repeat-x; + mask: radial-gradient(circle, #000 1.4px, transparent 1.9px) 0 50% / 9px 8px repeat-x; +} +.way-track::before { + background: var(--text-3); + opacity: 0.8; +} +.way-glow { + overflow: hidden; + transition: opacity 200ms var(--ease-out); +} +.way-glow i { + position: absolute; + inset: 0; + background: linear-gradient(90deg, transparent 32%, var(--accent) 50%, transparent 68%); + transform: translateX(-70%); + animation: way-run 2s cubic-bezier(0.45, 0, 0.55, 1) infinite; +} +@keyframes way-run { + 0% { + transform: translateX(-70%); + } + 72%, + 100% { + transform: translateX(70%); + } +} +.way-fill { + background: var(--ok); + clip-path: inset(0 100% 0 0); + transition: clip-path 700ms var(--ease-out) 80ms; +} +.way.done .way-fill { + clip-path: inset(0); +} +.way.done .way-glow, +.way.stopped .way-glow { + opacity: 0; +} +.way.done .way-end { + color: var(--ok); + background: var(--ok-soft); +} +.way.done .way-end.home { + transition-delay: 600ms; +} +.way.done .way-end.home .i { + animation: way-pop 420ms var(--spring-bouncy, ease) 600ms backwards; +} +@keyframes way-pop { + from { + transform: scale(0.6); + } + to { + transform: none; + } +} +.way-text { + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + min-height: 30px; + margin-top: 10px; + text-align: center; +} +.way-text .t { + display: flex; + flex-direction: column; + align-items: center; + min-width: 0; +} +/* The line morphs into " connected" (ui/morph.ts) and turns green. */ +.way-text b { + position: relative; + display: inline-flex; + justify-content: center; + white-space: nowrap; + font-weight: 500; + font-size: 14px; + line-height: 20px; + transition: color 300ms var(--ease-out); +} +.way-text .ws { + color: var(--text-2); + font-size: 13px; + line-height: 18px; +} +.way.done .way-text b { + color: var(--ok); +} + +/* The .conf for a router: a file card, and the configuration folded with its keys masked. */ +.filecard { + display: flex; + flex-direction: column; + gap: 10px; + padding: 12px; + border-radius: 18px; + background: var(--field); +} +.fc-row { + display: flex; + align-items: center; + gap: 12px; + min-width: 0; +} +.filecard-ic { + width: 38px; + height: 46px; + border-radius: 9px; + background: var(--knob); + font: 600 10px/1 var(--mono); + display: grid; + place-items: center; + color: var(--text-2); + flex: none; +} +.filecard .t { + flex: 1; + min-width: 0; + display: flex; + flex-direction: column; +} +.filecard .t .mono { + font-size: 13px; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; +} +.filecard .t span:last-child { + font-size: 12px; + color: var(--text-2); + line-height: 16px; +} +.confbar { + display: flex; + gap: 8px; +} +.conf { + margin: 0; + padding: 12px 14px; + border-radius: 14px; + background: var(--field); + font: 12px/18px var(--mono); + max-height: 16rem; + overflow: auto; + white-space: pre; + color: var(--text-2); +} +.conf .k { + color: var(--text); +} +.conf .sec { + color: var(--accent); +} +.conf .mask { + color: var(--text-3); + letter-spacing: 1px; +} + +/* Where the app scans, for both phone systems: the mark and the word that differs change in place. */ +.osm { + white-space: normal; +} +.osm-ic { + display: inline-grid; + width: 1.05em; + height: 1.05em; + margin-right: 0.25em; + vertical-align: -0.16em; +} +.osm-ic > svg { + grid-area: 1 / 1; + width: 100%; + height: 100%; +} +.osm-ic .eye { + fill: var(--field); +} +.osm-p { + display: inline-block; + white-space: pre; +} +/* "In AmneziaWG:" and the path on one line; where they don't fit, the path goes under it whole, and + stays there while it morphs (never split, never a part dropping on its own). */ +.scanline { + display: flex; + flex-wrap: wrap; + align-items: baseline; + column-gap: 0.3em; +} +.scanline .osm { + white-space: nowrap; +} +/* A narrow screen: the path under the label for every app, so switching apps never moves it between lines. */ +@media (max-width: 440px) { + .scanline { + flex-direction: column; + align-items: flex-start; + } +} +.way-text b .mt-old { + color: var(--text-2); +} + +@media (prefers-reduced-motion: reduce) { + .way-glow { + display: none; + } + .way-fill { + transition: none; + } + .way.done .way-end.home .i { + animation: none; + } +} diff --git a/web/src/portal/styles/sheet.css b/web/src/portal/styles/sheet.css new file mode 100644 index 0000000..1177265 --- /dev/null +++ b/web/src/portal/styles/sheet.css @@ -0,0 +1,281 @@ +/* The sheet: a drawer floating at the bottom on every width, × and a view's own buttons pinned in its + corner, the views inside (head, line under it), and the question look (Remove, Reconnect). */ + +/* Closed, the sheet is out of the page (display, not visibility): each open computes its styles + afresh. Hidden by visibility, Chromium could keep the inherited "hidden" on the views' box after a + quick close and reopen (a double tap on Reconnect), and the sheet opened empty but for its buttons. */ +.sheet-root { + position: fixed; + inset: 0; + z-index: 50; + display: none; +} +.sheet-root.open { + display: block; +} +.scrim { + position: absolute; + inset: 0; + background: var(--scrim); + -webkit-backdrop-filter: blur(8px); + backdrop-filter: blur(8px); +} +.sheet { + position: absolute; + left: var(--gutter-l); + right: var(--gutter-r); + bottom: calc(16px + env(safe-area-inset-bottom, 0px)); + margin: 0 auto; + max-width: 400px; + max-height: calc(100% - 32px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)); + background: var(--raised); + border-radius: var(--r-sheet); + box-shadow: var(--sheet-shadow); + overflow: hidden; + display: flex; + flex-direction: column; +} +/* On a computer (and a tablet held wide): a dialog in the middle of the screen, which comes up from + its centre (ui/sheet.ts); a phone keeps the drawer at the bottom. The breakpoint is the one the + sheet widens at for a dense code. Centred by the layout, not a transform, so its text stays on the + pixel grid and its own transform stays free for the motion. */ +@media (min-width: 760px) { + .sheet-root.open { + display: flex; + align-items: center; + justify-content: center; + } + .sheet { + position: relative; + left: auto; + right: auto; + bottom: auto; + margin: 0; + width: calc(100% - var(--gutter-l) - var(--gutter-r)); + } +} +.sheet .x { + position: absolute; + z-index: 3; + right: 22px; + top: 22px; +} +.vp { + position: relative; + overflow: hidden; + flex: none; +} +.sheet-scroll { + flex: 1 1 auto; + min-height: 0; + overflow-y: auto; + overscroll-behavior: contain; +} +.view { + padding: 0 24px 24px; + display: flex; + flex-direction: column; +} +/* Pulled down by its head to close: the head takes the touch, the rest scrolls. */ +.vhead { + display: flex; + align-items: center; + gap: 12px; + height: 76px; + padding-right: 44px; + flex: none; + cursor: grab; + touch-action: none; +} +.vhead h2 { + flex: 1; + margin: 0; + font-size: 20px; + line-height: 28px; + font-weight: 500; + letter-spacing: -0.5px; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; +} +.vhead.center h2 { + text-align: center; +} +.vhead.with-acts { + padding-right: 126px; +} +.vsub { + margin: -16px 0 18px; + color: var(--text-2); + font-size: 14px; + line-height: 20px; +} +.vhead.center + .vsub { + text-align: center; + margin: -6px auto 24px; + max-width: 32ch; + text-wrap: balance; +} +.kinds-note { + margin: 14px 2px 16px; +} +.view > .hint.bad-t { + margin-top: 8px; +} +.secure-note { + margin-top: 12px; + text-align: center; +} + +/* A view's own buttons beside × and pinned like it: icons only, each the size and colour of ×; the + two join with tighter inner corners. */ +.sheet-acts { + position: absolute; + z-index: 3; + top: 22px; + right: 58px; +} +.hpill { + position: relative; + display: flex; + gap: 2px; +} +.hp-b { + display: grid; + place-items: center; + width: 38px; + height: 32px; + background: var(--knob); + color: var(--text); + transition: + background-color 150ms, + transform 150ms var(--ease-out); +} +.hp-b:first-of-type { + border-radius: 16px 6px 6px 16px; +} +.hp-b:last-of-type { + border-radius: 6px 16px 16px 6px; +} +.hp-b .i { + width: 16px; + height: 16px; +} +.hp-b:hover { + background: color-mix(in srgb, var(--knob), var(--text) 6%); +} +.hp-b:active { + transform: scale(0.94); +} +.hp-b.done { + color: var(--ok); +} +/* Their tooltip: a small toast-coloured pill under the keys, one for both. */ +.hp-tip { + position: absolute; + z-index: 4; + left: 0; + top: calc(100% + 8px); + height: 26px; + padding: 0 10px; + display: flex; + align-items: center; + border-radius: 999px; + background: var(--toast); + color: var(--toast-fg); + font: 500 12px/1 var(--font); + letter-spacing: -0.1px; + white-space: nowrap; + box-shadow: + 0 0 0 1px var(--line-glass), + var(--pop-shadow); + opacity: 0; + pointer-events: none; + overflow: hidden; + transform-origin: 50% 0; +} +.hp-tip.on { + opacity: 1; +} +.hp-tip .tt { + position: relative; + display: inline-flex; + justify-content: center; + white-space: nowrap; +} +.hp-tip .tt-m { + position: absolute; + left: 0; + top: 0; + visibility: hidden; + white-space: nowrap; +} +/* Connected: nothing is left to do here, so × and the view's buttons step away; the sheet then closes by itself. */ +.sheet .x, +.sheet-acts { + transition: + transform 150ms var(--ease-out), + background-color 150ms, + opacity 240ms var(--ease-out), + filter 240ms var(--ease-out), + scale 240ms var(--ease-out); +} +.sheet.arrived .x, +.sheet.arrived .sheet-acts { + opacity: 0; + filter: blur(3px); + scale: 0.9; + pointer-events: none; +} + +/* A question before something that cannot be undone. */ +.center-col { + display: flex; + flex-direction: column; + align-items: center; + text-align: center; +} +.center-col.ask { + padding-top: 28px; +} +.center-col.secure { + padding-top: 4px; +} +.center-col .gi.xl { + width: 64px; + height: 64px; + margin: 8px 0 16px; +} +.center-col h3 { + margin: 0; + font-size: 20px; + line-height: 28px; + font-weight: 500; + letter-spacing: -0.5px; +} +.center-col p { + margin: 6px 0 22px; + color: var(--text-2); + font-size: 15px; + line-height: 21px; + max-width: 30ch; + text-wrap: balance; +} +.center-col.secure p { + margin-top: 0; +} +.btnrow { + display: flex; + gap: 8px; + width: 100%; +} +.btnrow .btn { + flex: 1; +} +.btnrow2 { + display: grid; + gap: 8px; +} +.btnrow2 .btn { + width: 100%; +} diff --git a/web/src/portal/styles/tokens.css b/web/src/portal/styles/tokens.css new file mode 100644 index 0000000..f3af6ef --- /dev/null +++ b/web/src/portal/styles/tokens.css @@ -0,0 +1,130 @@ +/* The portal's fonts and tokens. Dark first (the skiper21 palette, measured), light by the system's + choice. Surfaces step up in brightness (ground → raised → field → knob) instead of borders; the + accent is the one sky blue, colour otherwise only means state (ok green, warn orange, bad red). */ + +@font-face { + font-family: Geist; + src: url(geist-latin-wght-normal.woff2) format('woff2'); + font-weight: 100 900; + font-display: swap; + unicode-range: + U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2190-21FF, U+2212, U+2215; +} +@font-face { + font-family: Geist; + src: url(geist-cyrillic-wght-normal.woff2) format('woff2'); + font-weight: 100 900; + font-display: swap; + unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; +} +@font-face { + font-family: 'Geist Mono'; + src: url(geist-mono-latin-wght-normal.woff2) format('woff2'); + font-weight: 100 900; + font-display: swap; +} + +:root { + color-scheme: dark; + --bg: #080808; + --raised: #121212; + --field: #161616; + --knob: #232323; + --seg: rgba(237, 237, 237, 0.05); + --seg-shadow: none; + --line: rgba(255, 255, 255, 0.06); + --text: #ededed; + --text-2: #8c8c8a; + --text-3: #4f4f4e; + --accent: #4eafff; + --accent-ink: #ffffff; + --accent-soft: rgba(78, 175, 255, 0.13); + --ok: #57d64b; + --ok-soft: rgba(87, 214, 75, 0.14); + --warn: #ff8a3d; + --bad: #ff5c5c; + --bad-soft: rgba(255, 92, 92, 0.13); + --sel-bg: rgba(131, 209, 255, 0.25); + --sel-fg: #64c6ff; + --scrim: rgba(8, 8, 8, 0.8); + --line-glass: rgba(255, 255, 255, 0.07); + --pop-shadow: 0 18px 48px -14px rgba(0, 0, 0, 0.75); + --sheet-shadow: 0 24px 64px -16px rgba(0, 0, 0, 0.6); + --bar: rgba(237, 237, 237, 0.13); + --toast: #232323; + --toast-fg: #ededed; + --qr-bg: #0a0a0a; + /* glass icons: the frosted pane, its rim and edge, the detail strokes; the tones' two stops */ + --gi-a: rgba(255, 255, 255, 0.58); + --gi-b: rgba(255, 255, 255, 0.14); + --gi-rim: rgba(255, 255, 255, 0.5); + --gi-edge: rgba(0, 0, 0, 0); + --gi-detail: #ffffff; + --t-grey-a: #cfcfcd; + --t-grey-b: #5a5a59; + --t-blue-a: #a6d9ff; + --t-blue-b: #1d84e6; + --t-green-a: #a8f29c; + --t-green-b: #3aa32c; + --t-red-a: #ffadad; + --t-red-b: #dc3a3a; + --t-orange-a: #ffc08f; + --t-orange-b: #ec6a12; + + --font: Geist, -apple-system, system-ui, 'Segoe UI', sans-serif; + --mono: 'Geist Mono', ui-monospace, 'SF Mono', Menlo, monospace; + --r-sheet: 36px; + --r-card: 28px; + --r-row: 20px; + --r-field: 16px; + --r-tile: 12px; + --ease-out: cubic-bezier(0.23, 1, 0.32, 1); + --gutter-l: max(16px, env(safe-area-inset-left, 0px)); + --gutter-r: max(16px, env(safe-area-inset-right, 0px)); +} + +@media (prefers-color-scheme: light) { + :root { + color-scheme: light; + --bg: #f2f2f1; + --raised: #ffffff; + --field: #f3f3f2; + --knob: #e8e8e7; + --seg: #ffffff; + --seg-shadow: 0 1px 2px rgba(0, 0, 0, 0.08), 0 0 0 0.5px rgba(0, 0, 0, 0.05); + --line: rgba(0, 0, 0, 0.07); + --text: #0b0b0b; + --text-2: #6d6d6b; + --text-3: #a6a6a4; + --accent: #2b9dff; + --accent-soft: rgba(43, 157, 255, 0.12); + --ok: #33a328; + --ok-soft: rgba(51, 163, 40, 0.12); + --warn: #ee6a12; + --bad: #e5484d; + --bad-soft: rgba(229, 72, 77, 0.1); + --sel-bg: rgba(78, 175, 255, 0.22); + --sel-fg: #0a76cf; + --scrim: rgba(236, 236, 235, 0.62); + --line-glass: rgba(0, 0, 0, 0.07); + --pop-shadow: 0 18px 44px -14px rgba(0, 0, 0, 0.2); + --sheet-shadow: 0 24px 64px -18px rgba(0, 0, 0, 0.22); + --bar: rgba(11, 11, 11, 0.11); + --toast: #0b0b0b; + --toast-fg: #f2f2f1; + --qr-bg: #ffffff; + --gi-a: rgba(250, 250, 249, 0.72); + --gi-b: rgba(206, 206, 204, 0.5); + --gi-rim: rgba(255, 255, 255, 0.9); + --gi-edge: rgba(0, 0, 0, 0.11); + --gi-detail: rgba(28, 28, 28, 0.72); + --t-grey-a: #a9a9a7; + --t-grey-b: #3d3d3c; + --t-blue-a: #7cc4ff; + --t-blue-b: #0a6fd6; + --t-green-a: #82e070; + --t-green-b: #2e8a22; + --t-red-a: #ff9090; + --t-red-b: #c92a2a; + } +} diff --git a/web/src/portal/ui/accordion.ts b/web/src/portal/ui/accordion.ts new file mode 100644 index 0000000..ebc142c --- /dev/null +++ b/web/src/portal/ui/accordion.ts @@ -0,0 +1,140 @@ +// The accordion (skiper103's motion, on a softer spring): rows touch while +// closed and share their rounded ends; an open row lifts out with 10 px gaps +// and its own corners. One row open at a time. A row with nothing to open is a +// plain head: no chevron, no click. Inside the sheet it tells the sheet first, +// so a code that comes into view gets its width. + +import { h, ic } from '../dom'; +import { EASE_IN, SOFT, play } from '../motion'; +import { planWidth, startWidth } from './sheet'; + +export interface AccItem { + icon: Element; + title: string; + /** Beside the title (a chip). */ + tag?: Node | null; + /** At the head's end (numbers). */ + val?: Node | null; + /** The body shows the same numbers: the head drops them while open. */ + valHide?: boolean; + body: (Node | null | false | undefined)[]; +} + +export interface Accordion { + el: HTMLElement; + /** The open row, or -1. */ + openIndex(): number; + /** Open this row (or none), without motion: a repaint keeps what was open. */ + setOpen(i: number): void; +} + +/** The properties the rows animate between their closed and open shapes. */ +const PROPS = [ + 'height', + 'marginTop', + 'marginBottom', + 'borderTopLeftRadius', + 'borderTopRightRadius', + 'borderBottomLeftRadius', + 'borderBottomRightRadius', +] as const; + +export function accordion( + items: AccItem[], + o: { inset?: boolean; open?: number; onToggle?: (i: number, open: boolean, instant: boolean) => void } = {}, +): Accordion { + const acc = h('div', { class: `acc${o.inset ? ' inset' : ''}` }); + const rows = items.map((it, i) => { + const kids = it.body.filter((k): k is Node => !!k); + const still = !kids.length; + const inner = [ + it.icon, + h('span', { class: 'acc-title' }, h('span', { class: 't' }, it.title), it.tag ?? null), + it.val ? h('span', { class: `acc-val${it.valHide ? ' hide-open' : ''}` }, it.val) : null, + ]; + const open = i === o.open && !still; + const headEl = still + ? h('div', { class: 'acc-head' }, ...inner) + : h( + 'button', + { type: 'button', class: 'acc-head', 'aria-expanded': String(open), onclick: () => toggle(r) }, + ...inner, + ic('chevron', 'i acc-chev'), + ); + const r = h( + 'div', + { class: `acc-row${still ? ' still' : ''}${open ? ' open' : ''}` }, + headEl, + h('div', { class: 'acc-body' }, ...kids), + ); + acc.appendChild(r); + return r; + }); + const bodyOf = (r: HTMLElement) => r.querySelector('.acc-body') as HTMLElement; + const corners = () => + rows.forEach((r, i) => { + const op = r.classList.contains('open'); + r.classList.toggle('rt', i === 0 || op || rows[i - 1].classList.contains('open')); + r.classList.toggle('rb', i === rows.length - 1 || op || rows[i + 1].classList.contains('open')); + }); + const read = (x: HTMLElement) => { + const cs = getComputedStyle(x); + const out: Record = {}; + for (const p of PROPS) out[p] = p === 'height' ? `${x.getBoundingClientRect().height}px` : cs[p]; + return out; + }; + const aria = () => + rows.forEach((x) => x.querySelector('button.acc-head')?.setAttribute('aria-expanded', String(x.classList.contains('open')))); + + function toggle(r: HTMLElement) { + const before = rows.map(read); + rows.forEach((x) => x.getAnimations().forEach((a) => a.cancel())); + rows.forEach((x) => + bodyOf(x) + .getAnimations() + .forEach((a) => a.cancel()), + ); + const willOpen = !r.classList.contains('open'); + const closing = rows.filter((x) => x.classList.contains('open') && (x === r || willOpen)); + rows.forEach((x) => { + x.classList.remove('closing'); + if (x !== r) x.classList.remove('open'); + }); + r.classList.toggle('open', willOpen); + corners(); + const plan = planWidth(); + rows.forEach((x, i) => { + const after = read(x); + if (!PROPS.some((p) => before[i][p] !== after[p])) return; + if (closing.includes(x)) x.classList.add('closing'); + play(x, [before[i], after], { duration: SOFT.duration, easing: SOFT.easing }).onfinish = () => x.classList.remove('closing'); + }); + closing.forEach((x) => + play(bodyOf(x), [{ opacity: 1 }, { opacity: 0, filter: 'blur(2px)' }], { duration: 160, easing: EASE_IN, fill: 'forwards' }), + ); + if (willOpen) + play( + bodyOf(r), + [ + { opacity: 0, filter: 'blur(2px)' }, + { opacity: 1, filter: 'blur(0px)' }, + ], + { duration: 300, easing: 'cubic-bezier(0,0,.58,1)' }, + ); + startWidth(plan); + aria(); + o.onToggle?.(rows.indexOf(r), willOpen, false); + } + + corners(); + return { + el: acc, + openIndex: () => rows.findIndex((x) => x.classList.contains('open')), + setOpen(i) { + rows.forEach((x, k) => x.classList.toggle('open', k === i && !x.classList.contains('still'))); + corners(); + aria(); + rows.forEach((x, k) => o.onToggle?.(k, x.classList.contains('open'), true)); + }, + }; +} diff --git a/web/src/portal/ui/busy.ts b/web/src/portal/ui/busy.ts new file mode 100644 index 0000000..a4677dc --- /dev/null +++ b/web/src/portal/ui/busy.ts @@ -0,0 +1,68 @@ +// A button held busy while the router answers: its content blurs away and an +// orb comes up through the blur in its place, then the other way round. The orb +// is B4 Converge from aicss.dev's Orbs (controls.css draws it). Each change starts +// from where the last one stands, so an answer that lands mid-change turns back +// without a jump. + +import { h } from '../dom'; +import { EASE_IN, EASE_OUT, play } from '../motion'; + +const SHOWN: Keyframe = { opacity: 1, filter: 'blur(0px)', transform: 'none' }; +const GONE: Keyframe = { opacity: 0, filter: 'blur(5px)', transform: 'scale(.86)' }; +const ORB_GONE: Keyframe = { opacity: 0, filter: 'blur(5px)', transform: 'scale(.6)' }; +/** Out quick, in a little later and slower: the two cross in the blur. */ +const OUT = { duration: 180, easing: EASE_IN, fill: 'forwards' } as const; +const IN = { duration: 340, delay: 70, easing: EASE_OUT, fill: 'backwards' } as const; +/** Until the orb is all the way in: a quicker answer waits for it, so the orb never just flickers. */ +export const BUSY_IN = IN.delay + IN.duration; + +const runs = new WeakMap(); + +/** Where an element stands now, mid-animation included. */ +function now(el: Element): Keyframe { + const s = getComputedStyle(el); + return { opacity: s.opacity, filter: s.filter === 'none' ? 'blur(0px)' : s.filter, transform: s.transform }; +} + +/** What gives way: the button's own elements (a bare word goes into a span first). */ +function content(btn: HTMLElement): Element[] { + for (const n of [...btn.childNodes]) + if (n.nodeType === Node.TEXT_NODE && n.textContent?.trim()) n.replaceWith(h('span', {}, n.textContent)); + return [...btn.children].filter((c) => !c.classList.contains('orb')); +} + +/** The new change takes over: the old one stops once the new one is in place (nothing paints between). */ +function hand(btn: HTMLElement, next: Animation[]) { + const old = runs.get(btn) ?? []; + runs.set(btn, next); + old.forEach((a) => a.cancel()); +} + +export function busyOn(btn: HTMLElement) { + btn.querySelector(':scope > .orb')?.remove(); + const parts = content(btn); + const from = parts.map(now); + const orb = h('span', { class: 'orb', 'aria-hidden': 'true' }, h('i'), h('i')); + btn.append(orb); + btn.classList.add('busy'); + btn.setAttribute('aria-busy', 'true'); + hand(btn, [...parts.map((p, i) => play(p, [from[i], GONE], OUT)), play(orb, [ORB_GONE, SHOWN], IN)]); +} + +export function busyOff(btn: HTMLElement) { + const orb = btn.querySelector(':scope > .orb'); + const parts = content(btn); + const next = [...(orb ? [play(orb, [now(orb), ORB_GONE], OUT)] : []), ...parts.map((p) => play(p, [now(p), SHOWN], IN))]; + hand(btn, next); + btn.removeAttribute('aria-busy'); + Promise.all(next.map((a) => a.finished)).then( + () => { + if (runs.get(btn) !== next) return; // busy again meanwhile + runs.delete(btn); + next.forEach((a) => a.cancel()); + orb?.remove(); + btn.classList.remove('busy'); + }, + () => {}, + ); +} diff --git a/web/src/portal/ui/codes.ts b/web/src/portal/ui/codes.ts new file mode 100644 index 0000000..5e3fe96 --- /dev/null +++ b/web/src/portal/ui/codes.ts @@ -0,0 +1,117 @@ +// What goes to another device: a QR code and the words that go with it, and a +// link as text with Copy and Share. Codes follow the theme: the night look +// (light dots on black) on a dark one, the same dots dark on white on a light +// one, redrawn in place when the system's theme changes. A dense code (an +// AmneziaVPN key) fills its row; the sheet widens for it (ui/sheet.ts). + +import { denseQr, qrSvg } from '../../shared/qr'; +import { h, ic } from '../dom'; +import { EASE_IN, EASE_OUT, play } from '../motion'; +import { placeName } from '../state'; +import { copy } from './feedback'; + +const LIGHT = matchMedia('(prefers-color-scheme: light)'); +const look = () => (LIGHT.matches ? 'day' : 'night'); + +function paint(box: HTMLElement, text: string) { + box.dataset.qr = text; + box.classList.toggle('dense', denseQr(text)); + box.classList.toggle('light', LIGHT.matches); + box.innerHTML = qrSvg(text, 3, true, look()); + // The modules across: how wide the sheet must be for a camera to read it. + box.dataset.mods = String((box.firstElementChild as SVGSVGElement | null)?.viewBox.baseVal.width ?? 0); +} + +export function qrBox(text: string, big = false): HTMLElement { + const box = h('div', { class: `qrbox${big ? ' big' : ''}` }); + paint(box, text); + return box; +} + +LIGHT.addEventListener('change', () => + document.querySelectorAll('.qrbox[data-qr]').forEach((b) => { + // Mid cross-fade a box holds two codes: the old one goes, the new one is drawn again. + b.querySelector('svg.old')?.remove(); + paint(b, b.dataset.qr!); + }), +); + +export interface CodeRow { + el: HTMLElement; + /** Another code in the same place: it comes in over the old one, which then goes; new words too, if given (else they stay, to change in place). */ + swap(next: string, words?: Node[]): void; +} + +/** A code and its words: side by side, or a dense code full width with the words under it. */ +export function codeRow(text: string, words: Node[]): CodeRow { + const box = qrBox(text); + let shown = h('div', { class: 'words' }, words); + const side = h('div', { class: 'side' }, shown); + const el = h('div', { class: `coderow${box.classList.contains('dense') ? ' stacked' : ''}` }, box, side); + return { + el, + swap(next, nextWords) { + // The same code for another app (AmneziaWG and WireGuard take one file): only the words change. + const oldSvg = box.dataset.qr === next ? null : box.querySelector('svg'); + if (oldSvg) { + paint(box, next); + el.classList.toggle('stacked', box.classList.contains('dense')); + const newSvg = box.querySelector('svg')!; + oldSvg.classList.add('old'); + box.appendChild(oldSvg); + // The new code comes in first, the old one goes after it: the place is never empty. + play(newSvg, [{ opacity: 0 }, { opacity: 1 }], { duration: 200, easing: EASE_OUT }); + play(oldSvg, [{ opacity: 1 }, { opacity: 0 }], { duration: 220, delay: 110, easing: EASE_IN, fill: 'forwards' }).onfinish = () => + oldSvg.remove(); + } + if (!nextWords) return; + const oldWords = shown; + shown = h('div', { class: 'words' }, nextWords); + side.appendChild(shown); + oldWords.classList.add('old'); + play( + shown, + [ + { opacity: 0, filter: 'blur(3px)' }, + { opacity: 1, filter: 'blur(0px)' }, + ], + { duration: 220, easing: EASE_OUT }, + ); + play( + oldWords, + [ + { opacity: 1, filter: 'blur(0px)' }, + { opacity: 0, filter: 'blur(3px)' }, + ], + { duration: 200, delay: 90, easing: EASE_IN, fill: 'forwards' }, + ).onfinish = () => oldWords.remove(); + }, + }; +} + +/** A link as text with Copy and, where the browser has one, the share sheet. */ +export function linkRow(url: string): HTMLElement { + const share = typeof navigator.share === 'function'; + return h( + 'div', + { class: 'linkrow' }, + h('span', { class: 'mono' }, url.replace(/^https?:\/\//, '')), + h( + 'button', + { type: 'button', class: 'knob', 'aria-label': 'Copy the link', onclick: (ev: Event) => copy(url, 'Link copied', ev.currentTarget) }, + ic('copy'), + ), + share + ? h( + 'button', + { + type: 'button', + class: 'knob', + 'aria-label': 'Share the link', + onclick: () => navigator.share({ url, title: placeName() }).catch(() => undefined), + }, + ic('share'), + ) + : null, + ); +} diff --git a/web/src/portal/ui/feedback.ts b/web/src/portal/ui/feedback.ts new file mode 100644 index 0000000..85f3424 --- /dev/null +++ b/web/src/portal/ui/feedback.ts @@ -0,0 +1,157 @@ +// What a tap answers with: a toast, a copy (and the check on the control that +// copied), a file shared or downloaded, a button held busy until the router +// answers. Toasts sit in one bottom slot, one at a time. + +import { h, ic } from '../dom'; +import { BOUNCY, EASE_IN, POP, calm, play } from '../motion'; +import { platform } from '../state'; +import { BUSY_IN, busyOff, busyOn } from './busy'; +import { morphText, textOf } from './morph'; + +let slot: HTMLElement | null = null; +let shown: HTMLElement | null = null; +let timer = 0; + +const leave = (t: HTMLElement, frames: Keyframe[], ms: number) => + (play(t, frames, { duration: ms, easing: EASE_IN, fill: 'forwards' }).onfinish = () => t.remove()); + +/** One toast at a time: a new one sends the last away first. */ +export function toast(msg: string, bad = false) { + slot ??= document.body.appendChild(h('div', { class: 'toasts' })); + if (shown) leave(shown, [{ opacity: 1 }, { opacity: 0, transform: 'scale(.96)', filter: 'blur(4px)' }], 140); + const t = h('div', { class: `toast${bad ? ' bad' : ''}`, role: 'status' }, ic(bad ? 'alert' : 'check'), h('span', {}, msg)); + slot.appendChild(t); + shown = t; + play( + t, + [ + { opacity: 0, transform: 'translateY(18px) scale(.9)', filter: 'blur(6px)' }, + { opacity: 1, transform: 'none', filter: 'none' }, + ], + { + duration: BOUNCY.duration, + easing: BOUNCY.easing, + }, + ); + clearTimeout(timer); + timer = window.setTimeout(() => { + if (shown !== t) return; + shown = null; + leave(t, [{ opacity: 1 }, { opacity: 0, transform: 'translateY(6px) scale(.96)', filter: 'blur(4px)' }], 180); + }, 2400); +} + +/** + * The control that copied says so for a moment: its icon turns into a check + * and a "Copy…" label (`.lbl`, a badge's main line) into "Copied". + */ +function copied(from: Element) { + if (from.classList.contains('copied')) return; + const icon = from.querySelector('svg.i'); + const label = from.querySelector('.lbl, .b-main'); + const was = label ? textOf(label) : ''; + from.classList.add('copied'); + let check: Element | null = null; + if (icon) { + check = ic('check', icon.getAttribute('class') ?? 'i'); + icon.replaceWith(check); + play( + check, + [ + { opacity: 0, transform: 'scale(.6)', filter: 'blur(3px)' }, + { opacity: 1, transform: 'none', filter: 'none' }, + ], + { + duration: POP.duration, + easing: POP.easing, + }, + ); + } + if (label && /^Copy/.test(was)) morphText(label, 'Copied'); + setTimeout(() => { + if (check && icon) check.replaceWith(icon); + if (label && /^Copy/.test(was)) morphText(label, was); + from.classList.remove('copied'); + }, 1600); +} + +/** `from`: the control that copied, which then shows a check for a moment. */ +export async function copy(text: string, what = 'Copied', from?: EventTarget | null) { + try { + await navigator.clipboard.writeText(text); + } catch { + const ta = h('textarea', { class: 'offscreen' }, text) as HTMLTextAreaElement; + document.body.appendChild(ta); + ta.select(); + const ok = document.execCommand('copy'); + ta.remove(); + if (!ok) return toast('Copying is blocked here. Select the text and copy it by hand.', true); + } + if (from instanceof Element) copied(from); + toast(what); +} + +/** + * On an iPhone a share sheet hands the file straight to the VPN app, where a + * download would land in Files. Returns the action, or null where files + * cannot be shared. + */ +export function shareFile(name: string, text: string): (() => Promise) | null { + const nav = navigator as Navigator & { canShare?: (d: unknown) => boolean }; + // Only iOS: there AmneziaWG, WireGuard and AmneziaVPN take a file from the + // share sheet. On Android neither app is a share target (and Chrome does not + // share .conf files), so a download goes into the app's own file picker; + // desktop browsers claim they can share files and then do nothing. + if (platform() !== 'ios') return null; + if (typeof nav.share !== 'function' || typeof File === 'undefined') return null; + const file = new File([text], name, { type: 'application/octet-stream' }); + if (!nav.canShare?.({ files: [file] })) return null; + return async () => { + try { + // The file alone: with a title, "Save to Files" also writes the title as a .txt. + await nav.share({ files: [file] }); + } catch (e) { + // Cancelled: nothing to do. Refused by the browser: the file still has to get out. + if ((e as Error)?.name !== 'AbortError') download(name, text); + } + }; +} + +export function download(name: string, text: string) { + // Not text/plain: Safari would save "name.conf.txt". + const url = URL.createObjectURL(new Blob([text], { type: 'application/octet-stream' })); + const a = h('a', { href: url, download: name, class: 'offscreen' }); + document.body.appendChild(a); + a.click(); + setTimeout(() => { + URL.revokeObjectURL(url); + a.remove(); + }, 1000); +} + +/** The file out: the share sheet where the browser hands it to an app, a download elsewhere. */ +export function sendFile(name: string, text: string) { + const share = shareFile(name, text); + if (share) void share(); + else download(name, text); +} + +/** + * Run an action once: its button goes busy (the orb) on the click and stays + * disabled until the router answers; a quick answer keeps the orb until it is + * all the way in. + */ +export async function once(btn: HTMLButtonElement, fn: () => Promise) { + if (btn.disabled) return; + btn.disabled = true; + busyOn(btn); + const t0 = performance.now(); + try { + await fn(); + } finally { + const wait = calm() ? 0 : BUSY_IN - (performance.now() - t0); + if (wait > 0) await new Promise((r) => setTimeout(r, wait)); + busyOff(btn); + btn.disabled = false; + } +} diff --git a/web/src/portal/ui/glass.ts b/web/src/portal/ui/glass.ts new file mode 100644 index 0000000..6f8b571 --- /dev/null +++ b/web/src/portal/ui/glass.ts @@ -0,0 +1,153 @@ +// Glass icons: a tinted back shape, the same shape blurred behind a frosted +// front pane, a rim, and the detail strokes on top. The shapes are ours; every +// colour comes from the stylesheet (tone classes and the --gi-* tokens), never +// from a style attribute, which the page's CSP would drop. + +import { iconSvg } from '../../shared/icons'; +import { markup } from '../dom'; + +export type Tone = 'grey' | 'blue' | 'green' | 'red' | 'orange'; + +interface Shape { + /** The tinted back shape. */ + b: string; + /** The frosted front pane. */ + f: string; + /** Detail strokes on the pane; null: the AmneziaVPN mark instead. */ + d: string | null; +} + +const GL: Record = { + phone: { + b: '', + f: '', + d: '', + }, + mobile: { + b: '', + f: '', + d: '', + }, + tablet: { + b: '', + f: '', + d: '', + }, + computer: { + b: '', + f: '', + d: '', + }, + router: { + b: '', + f: '', + d: '', + }, + other: { b: '', f: '', d: '' }, + plus: { + b: '', + f: '', + d: '', + }, + globe: { + b: '', + f: '', + d: '', + }, + home: { + b: '', + f: '', + d: '', + }, + shield: { + b: '', + f: '', + d: '', + }, + chart: { + b: '', + f: '', + d: '', + }, + calendar: { + b: '', + f: '', + d: '', + }, + clock: { b: '', f: '', d: '' }, + pause: { + b: '', + f: '', + d: '', + }, + server: { + b: '', + f: '', + d: '', + }, + link: { + b: '', + f: '', + d: '', + }, + key: { + b: '', + f: '', + d: '', + }, + lock: { + b: '', + f: '', + d: '', + }, + check: { + b: '', + f: '', + d: '', + }, + trash: { + b: '', + f: '', + d: '', + }, + refresh: { + b: '', + f: '', + d: '', + }, + app: { b: '', f: '', d: null }, + file: { + b: '', + f: '', + d: '', + }, +}; + +/** The AmneziaVPN mark without its own svg: drawn on the "app" pane. */ +const amneziaMark = () => + iconSvg('amnezia', '') + .replace(/^]*>/, '') + .replace(/<\/svg>$/, ''); + +let gid = 0; +/** A glass icon as markup (`cls`: its classes, e.g. "gi xl"). */ +export function glassSvg(name: string, tone: Tone = 'grey', cls = 'gi'): string { + const g = GL[name] ?? GL.other; + const id = `gl${++gid}`; + const detail = + g.d === null + ? `${amneziaMark()}` + : `${g.d}`; + return ( + `` + ); +} + +/** A glass icon as an element. */ +export const glass = (name: string, tone: Tone = 'grey', cls = 'gi'): Element => markup(glassSvg(name, tone, cls)); diff --git a/web/src/portal/ui/menu.ts b/web/src/portal/ui/menu.ts new file mode 100644 index 0000000..fdcb3d6 --- /dev/null +++ b/web/src/portal/ui/menu.ts @@ -0,0 +1,104 @@ +// The ⋯ menu: a small panel under (or over) its button, items with an icon, +// a highlight that glides after the pointer and takes the item's colour +// (orange for Reconnect, red for Remove). One at a time; it closes on a press +// outside, on scroll, on Escape and when its button is pressed again. + +import { h, ic } from '../dom'; +import { EASE_IN, POP, play } from '../motion'; + +export interface MenuItem { + label: string; + icon: string; + tone?: 'warn' | 'bad'; + run: () => unknown; +} + +let menuEl: HTMLElement | null = null; +/** The button the open menu belongs to: pressing it again closes the menu. */ +let anchorEl: HTMLElement | null = null; + +export const menuOpen = () => !!menuEl; + +/** `now`: gone at once (Escape, or another menu opening). */ +export function closeMenu(now = false) { + const m = menuEl; + if (!m) return; + menuEl = null; + anchorEl?.setAttribute('aria-expanded', 'false'); + anchorEl = null; + if (now) { + m.remove(); + return; + } + play(m, [{ opacity: 1 }, { opacity: 0, transform: 'scale(.96)', filter: 'blur(3px)' }], { + duration: 120, + easing: EASE_IN, + fill: 'forwards', + }).onfinish = () => m.remove(); +} + +/** `items`: null is a separator, kept only between items. */ +export function openMenu(anchor: HTMLElement, all: (MenuItem | null)[]) { + if (anchorEl === anchor && menuEl) return closeMenu(); + closeMenu(true); + const items = all.filter((it, i) => it || (i > 0 && all[i - 1] && all.slice(i + 1).some(Boolean))); + const hl = h('span', { class: 'menu-hl' }); + const m = h('div', { class: 'menu', role: 'menu' }, hl); + for (const it of items) { + if (!it) { + m.appendChild(h('div', { class: 'menu-sep' })); + continue; + } + const b = h( + 'button', + { + type: 'button', + role: 'menuitem', + class: `mi ${it.tone ?? ''}`, + onclick: () => { + closeMenu(); + it.run(); + }, + }, + ic(it.icon), + h('span', {}, it.label), + ); + // The highlight comes in where the pointer is, then glides from item to item. + b.addEventListener('pointerenter', () => { + hl.className = `menu-hl${hl.style.opacity === '1' ? ' moving' : ''} ${it.tone ?? ''}`; + hl.style.transform = `translateY(${b.offsetTop - 6}px)`; + hl.style.opacity = '1'; + }); + m.appendChild(b); + } + m.addEventListener('pointerleave', () => (hl.style.opacity = '0')); + document.body.appendChild(m); + const r = anchor.getBoundingClientRect(); + const w = m.offsetWidth; + const mh = m.offsetHeight; + // Under the button, or over it where the screen ends: it grows out of the button either way. + const below = r.bottom + 8 + mh < innerHeight - 8; + m.style.left = `${Math.max(12, Math.min(r.right - w, innerWidth - w - 12))}px`; + m.style.top = `${below ? r.bottom + 8 : r.top - 8 - mh}px`; + m.style.transformOrigin = `${below ? 'top' : 'bottom'} right`; + play( + m, + [ + { opacity: 0, transform: 'scale(.9)', filter: 'blur(4px)' }, + { opacity: 1, transform: 'none', filter: 'none' }, + ], + { + duration: POP.duration, + easing: POP.easing, + }, + ); + menuEl = m; + anchorEl = anchor; + anchor.setAttribute('aria-expanded', 'true'); +} + +document.addEventListener('pointerdown', (e) => { + const t = e.target as Element; + if (menuEl && !menuEl.contains(t) && !anchorEl?.contains(t)) closeMenu(); +}); +addEventListener('scroll', () => closeMenu(), { passive: true }); diff --git a/web/src/portal/ui/morph.ts b/web/src/portal/ui/morph.ts new file mode 100644 index 0000000..38b61e0 --- /dev/null +++ b/web/src/portal/ui/morph.ts @@ -0,0 +1,585 @@ +// Words that change in place morph letter by letter: the old letters lift away +// with a blur, the new ones rise in one after another, and the width glides +// between them. Every text the page or a sheet changes while it shows goes +// through `morphText`: a card's name and status after a repaint, the counts and +// values, a label that says "Copied", a line that says what happened (the way: +// "iPad connected"), and a menu path for another app or the other phone system +// (`menuLine`: where the app scans, iOS "Create", Android "Scan"). + +import { h, ic, markup, put, type Kid } from '../dom'; +import { EASE_IN, EASE_OUT, POP, SMOOTH, calm, play } from '../motion'; + +/** Each character as its own inline box, so each can move. */ +const letters = (w: string): HTMLElement[] => [...w].map((ch) => h('i', {}, ch)); + +interface Run { + /** What it is turning into. */ + text: string; + timer: number; +} +const runs = new WeakMap(); + +/** What `el` says: while it morphs, what it is turning into. */ +export const textOf = (el: HTMLElement): string => runs.get(el)?.text ?? el.textContent ?? ''; + +/** Where `el`'s words sit (their own box, not the element's). */ +function wordsBox(el: HTMLElement): DOMRect { + const r = document.createRange(); + r.selectNodeContents(el); + return r.getBoundingClientRect(); +} + +/** Where each character of `el`'s plain text starts, from the first (kerning and all). */ +function spacing(el: HTMLElement): number[] { + const node = el.firstChild; + if (!node || node.nodeType !== Node.TEXT_NODE) return []; + const r = document.createRange(); + const out: number[] = []; + let o = 0; + for (const ch of node.textContent ?? '') { + r.setStart(node, o); + r.setEnd(node, o + ch.length); + out.push(r.getBoundingClientRect().left); + o += ch.length; + } + return out.map((x) => x - out[0]); +} + +/** + * The letters stood where the plain text's characters stand. One by one they + * lose the font's kerning, so the word turning back into text would shift on + * its last frame; a nudge each and they land exactly on it. + */ +function space(box: Element, at: number[]) { + const kids = [...box.children] as HTMLElement[]; + if (!kids.length) return; + const start = kids[0].getBoundingClientRect().left; + kids.forEach((c, i) => { + if (!i || at[i] === undefined) return; + const dx = start + at[i] - c.getBoundingClientRect().left; + if (Math.abs(dx) > 0.01) c.style.marginLeft = `${dx}px`; + }); +} + +/** + * The letters both texts keep, in order: pairs of [old index, new index]. What + * they share at the start and at the end stays together; in between, the + * longest run of letters in common (a longest common subsequence). + */ +export function kept(a: string[], b: string[]): [number, number][] { + let p = 0; + while (p < a.length && p < b.length && a[p] === b[p]) p++; + let q = 0; + while (q < a.length - p && q < b.length - p && a[a.length - 1 - q] === b[b.length - 1 - q]) q++; + const A = a.slice(p, a.length - q); + const B = b.slice(p, b.length - q); + const L = Array.from({ length: A.length + 1 }, () => new Array(B.length + 1).fill(0)); + for (let i = A.length - 1; i >= 0; i--) + for (let j = B.length - 1; j >= 0; j--) L[i][j] = A[i] === B[j] ? L[i + 1][j + 1] + 1 : Math.max(L[i + 1][j], L[i][j + 1]); + const out: [number, number][] = []; + for (let i = 0; i < p; i++) out.push([i, i]); + for (let i = 0, j = 0; i < A.length && j < B.length; ) { + if (A[i] === B[j]) out.push([p + i++, p + j++]); + else if (L[i + 1][j] >= L[i][j + 1]) i++; + else j++; + } + for (let k = q; k > 0; k--) out.push([a.length - k, b.length - k]); + return out; +} + +/** A morph under way on `el` ends where it was going: its words as plain text. */ +function finish(el: HTMLElement) { + const r = runs.get(el); + if (!r) return; + clearTimeout(r.timer); + runs.delete(el); + el.getAnimations().forEach((a) => a.cancel()); + el.classList.remove('mt', 'mt-ib'); + el.textContent = r.text; +} + +/** Plain, at once: a morph under way on `el` stops where it is going. */ +export function setText(el: HTMLElement, text: string) { + finish(el); + el.textContent = text; +} + +export interface MorphOpts { + /** The words change as a whole instead: the old blur away where they stood as the new come in. */ + whole?: boolean; + /** false where something else moves what follows (a width gliding inside a wrapping list would reflow it mid-way). */ + glide?: boolean; + /** + * Where the old words stand on screen now, when `el` no longer holds them in + * the same layout (morphInto: put back, they could wrap another way): whole + * words go from there, and the width does not glide. + */ + at?: DOMRect; +} + +/** + * `el`'s text turns into `next`, letter by letter: the letters both say stay + * and slide to their new places, the others lift away or rise in. `from`: what + * it said before a repaint rebuilt it (the new element already says `next`). + * The old letters keep to the edge + * that stays put while the width changes (the start of a line, the end of a + * value on the right, the middle of a centred line). Done, it holds plain text + * again: a box that ends in an ellipsis keeps it. + */ +export function morphText(el: HTMLElement, next: string, from = textOf(el), o: MorphOpts = {}) { + const { whole = false, at } = o; + // Placed by the caller, the width does not glide: what follows is moved by the caller too. + const glide = (o.glide ?? true) && !at; + // Interrupted mid-way: the width carries on from where it is on screen, not from where that morph was going. + const midway = runs.has(el) ? el.getBoundingClientRect().width : null; + finish(el); + // Nothing to watch move: no motion asked for, or not on screen (a folded row, a closed sheet). + if (from === next || calm() || !el.getClientRects().length) { + el.textContent = next; + return; + } + const cs = getComputedStyle(el); + // Letters need a box whose width can glide; words that change whole keep the text's own flow (they + // may wrap), and what follows them is moved by the caller (morphInto) instead. + const flow = whole && cs.display === 'inline'; + if (cs.display === 'inline' && !whole) el.classList.add('mt-ib'); + if (cs.position === 'static') el.classList.add('mt'); + let r0: DOMRect | null = null; + let t0 = at ?? null; + let at0: number[] = []; + if (!t0) { + el.textContent = from; + r0 = el.getBoundingClientRect(); + t0 = wordsBox(el); + at0 = spacing(el); + } + el.textContent = next; + const r1 = el.getBoundingClientRect(); + const at1 = spacing(el); + const w0 = midway ?? r0?.width ?? r1.width; + const glides = glide && !flow && !!r0 && Math.abs(r1.width - w0) > 0.5; + const edge = !glides || !r0 || Math.abs(r1.left - r0.left) < 0.5 ? 'start' : Math.abs(r1.right - r0.right) < 0.5 ? 'end' : 'middle'; + + const neu = h('span', { class: whole ? 'mt-new w' : 'mt-new' }, whole ? next : letters(next)); + const old = h('span', { class: whole ? 'mt-old w' : 'mt-old', 'aria-hidden': 'true' }, whole ? from : letters(from)); + // Whole words wrap as they did: the old ones keep the width they took. + if (whole) old.style.width = `${t0.width + 1}px`; + el.replaceChildren(neu, old); + // Held at the plain text's width until the letters turn back into it, so what follows never steps. + if (glides) + play(el, [{ width: `${w0}px` }, { width: `${r1.width}px` }], { + duration: SMOOTH.duration, + easing: SMOOTH.easing, + fill: 'forwards', + }); + // The old letters go from exactly where they stood on screen, against the box as it is now: a box + // its text left empty sits lower (on the baseline), and would carry them down with it. + const r2 = el.getBoundingClientRect(); + const place = (dx: number, dy: number) => { + old.style.top = `${dy}px`; + if (edge === 'end') old.style.right = `${-dx}px`; + else if (edge === 'middle') { + old.style.left = '50%'; + old.style.translate = `calc(-50% + ${dx}px) 0`; + } else old.style.left = `${dx}px`; + }; + const x0 = edge === 'end' ? t0.right - r2.right : edge === 'middle' ? (t0.left + t0.right - r2.left - r2.right) / 2 : t0.left - r2.left; + place(x0, t0.top - r2.top); + // Then onto the old words exactly: the box's top is not the text's (the line's leading sits above it). + const t2 = wordsBox(old); + place(x0 + t0.left - t2.left, t0.top - r2.top + t0.top - t2.top); + if (whole) { + play( + old, + [ + { opacity: 1, filter: 'blur(0px)' }, + { opacity: 0, filter: 'blur(4px)' }, + ], + { duration: 180, easing: EASE_IN, fill: 'forwards' }, + ); + play( + neu, + [ + { opacity: 0, filter: 'blur(4px)' }, + { opacity: 1, filter: 'blur(0px)' }, + ], + { duration: 280, delay: 60, easing: EASE_OUT, fill: 'backwards' }, + ); + const ends = Math.max(340, glides ? SMOOTH.duration : 0) + 40; + runs.set(el, { text: next, timer: window.setTimeout(() => finish(el), ends) }); + return; + } + space(neu, at1); + space(old, at0); + + // The letters both texts keep slide from where they stood to where they go, on the width's spring; + // the old ones' places in the overlay stay empty. + const was = [...old.children] as HTMLElement[]; + const now = [...neu.children] as HTMLElement[]; + const pairs = kept([...from], [...next]); + const stays = new Set(pairs.map(([i]) => i)); + const comes = new Set(pairs.map(([, j]) => j)); + pairs.forEach(([i, j]) => { + const a = was[i].getBoundingClientRect(); + const b = now[j].getBoundingClientRect(); + was[i].style.visibility = 'hidden'; + if (Math.abs(a.left - b.left) > 0.5 || Math.abs(a.top - b.top) > 0.5) + play(now[j], [{ transform: `translate(${a.left - b.left}px, ${a.top - b.top}px)` }, { transform: 'none' }], { + duration: SMOOTH.duration, + easing: SMOOTH.easing, + }); + }); + const out = was.filter((_, i) => !stays.has(i)); + const inn = now.filter((_, j) => !comes.has(j)); + // A long text keeps the same overall sweep: the steps shorten instead. + const so = Math.min(12, 160 / Math.max(1, out.length)); + const si = Math.min(22, 260 / Math.max(1, inn.length)); + out.forEach((c, i) => + play( + c, + [ + { opacity: 1, filter: 'blur(0px)', transform: 'none' }, + { opacity: 0, filter: 'blur(4px)', transform: 'translateY(-0.45em)' }, + ], + { duration: 220, delay: i * so, easing: EASE_IN, fill: 'forwards' }, + ), + ); + inn.forEach((c, i) => + play( + c, + [ + { opacity: 0, filter: 'blur(4px)', transform: 'translateY(0.45em)' }, + { opacity: 1, filter: 'blur(0px)', transform: 'none' }, + ], + { duration: 380, delay: 120 + i * si, easing: EASE_OUT, fill: 'backwards' }, + ), + ); + const ends = + Math.max(220 + out.length * so, inn.length ? 120 + inn.length * si + 380 : 0, glides || pairs.length ? SMOOTH.duration : 0) + 40; + runs.set(el, { text: next, timer: window.setTimeout(() => finish(el), ends) }); +} + +/** The keyed texts under `root` (`data-t`), before a repaint rebuilds them. */ +export function textsOf(root: ParentNode): Map { + return new Map([...root.querySelectorAll('[data-t]')].map((el) => [el.dataset.t!, textOf(el)])); +} + +/** After the repaint: each keyed text that changed morphs from what it said. */ +export function morphChanged(root: ParentNode, was: Map) { + root.querySelectorAll('[data-t]').forEach((el) => { + const before = was.get(el.dataset.t!); + const now = el.textContent ?? ''; + if (before !== undefined && before !== now) morphText(el, now, before); + }); +} + +/** What a box shows, piece by piece, keyed by where each sits (child indexes): its kind, its words, its drawing, its place. */ +interface Piece { + kind: string; + text: string; + svg: string; + at: DOMRect | null; + /** Where its words stand (a morph under way: the words it is turning into). */ + words: DOMRect | null; + node: Node; +} +/** Its tag and classes, less a morph's own (a piece still changing is the same piece). */ +const kindOf = (el: Element) => `${el.tagName}.${[...el.classList].filter((c) => c !== 'mt' && c !== 'mt-ib').join(' ')}`; +/** A drawing as markup, less the ids each build makes up (a glass icon's gradients): the same icon twice is the same. */ +const drawing = (el: Element) => el.outerHTML.replace(/\bgl\d+/g, 'gl'); +function pieces(box: Element): Map { + const out = new Map(); + const walk = (n: Node, path: string) => + n.childNodes.forEach((c, i) => { + const p = `${path}/${i}`; + if (c.nodeType === Node.TEXT_NODE) { + if (c.textContent?.trim()) { + const r = document.createRange(); + r.selectNodeContents(c); + const at = r.getBoundingClientRect(); + out.set(p, { kind: '#text', text: c.textContent, svg: '', at, words: at, node: c }); + } + return; + } + if (!(c instanceof Element)) return; + const svg = c instanceof SVGElement ? drawing(c) : ''; + const words = c instanceof HTMLElement && !svg ? wordsBox(c.querySelector(':scope > .mt-new') ?? c) : null; + out.set(p, { kind: kindOf(c), text: c instanceof HTMLElement ? textOf(c) : '', svg, at: c.getBoundingClientRect(), words, node: c }); + if (!svg) walk(c, p); + }); + walk(box, ''); + return out; +} + +/** Something with nothing to change from comes in through a blur. */ +const appear = (el: Element) => + play( + el, + [ + { opacity: 0, filter: 'blur(4px)' }, + { opacity: 1, filter: 'blur(0px)' }, + ], + { duration: 280, delay: 60, easing: EASE_OUT, fill: 'backwards' }, + ); + +/** + * `box` refilled with `kids` and nothing blinks: what is the same stays still; + * a piece in the same place with other words blurs from the old words into the + * new where it stands; a drawing that changed comes in through a blur; a piece + * that changed its kind or its height (another block, a list that wraps over + * more lines) crosses whole, the old one blurring out exactly where it stood as + * the new one blurs in, and so does what is gone. A piece that kept its kind + * and size but moved glides from where it stood. Places are taken against the + * box, which its sheet moves as a whole; an old piece fades inside its own + * parent's new self (the same kind, in the same place), so it keeps its look. + */ +export function morphInto(box: HTMLElement, kids: Kid) { + const was = pieces(box); + const box0 = box.getBoundingClientRect(); + put(box, kids); + if (!was.size || calm()) return; + const box1 = box.getBoundingClientRect(); + /** Where something that stood at `r` in the box's old place stands now, the pieces having glided back there. */ + const here = (r: DOMRect | null) => r && new DOMRect(r.left - box0.left + box1.left, r.top - box0.top + box1.top, r.width, r.height); + const morphs: (() => void)[] = []; + /** An old piece, where it stood, the new parent it fades in and where that parent stood. */ + const ghosts: [Element, DOMRect, Element, DOMRect][] = []; + const seen = new Set(); + const cross = (el: Element, w: Piece | undefined, path: string) => { + const host = el.parentElement; + const from = path ? was.get(path)?.at : box0; + if (w?.at && w.node instanceof Element) ghosts.push(host && from ? [w.node, w.at, host, from] : [w.node, w.at, box, box0]); + morphs.push(() => appear(el)); + }; + /** Moves `el` from where it stood (`at`, in the box's old place) to where it is, less what its parent already carries. */ + const glideFrom = (el: Element, at: DOMRect, carried: [number, number]): [number, number] => { + const r = el.getBoundingClientRect(); + const dx = at.left - box0.left - (r.left - box1.left); + const dy = at.top - box0.top - (r.top - box1.top); + const ox = dx - carried[0]; + const oy = dy - carried[1]; + if (Math.abs(ox) > 0.5 || Math.abs(oy) > 0.5) + play(el, [{ transform: `translate(${ox}px, ${oy}px)` }, { transform: 'none' }], { duration: SMOOTH.duration, easing: SMOOTH.easing }); + return [dx, dy]; + }; + const walk = (n: Node, path: string, carried: [number, number]) => + [...n.childNodes].forEach((c, i) => { + const p = `${path}/${i}`; + seen.add(p); + const w = was.get(p); + if (c.nodeType === Node.TEXT_NODE) { + const t = c.textContent ?? ''; + if (!t.trim() || (w?.kind === '#text' && w.text === t)) return; + // A bare word among elements goes into a span of its own, so it can change (and glide from where its words were). + const s = h('span', {}, t); + c.replaceWith(s); + if (w?.at) glideFrom(s, w.at, carried); + morphs.push(() => + w?.kind === '#text' && t.length <= 40 && w.text.length <= 40 + ? morphText(s, t, w.text, { whole: true, at: here(w.words) ?? undefined }) + : appear(s), + ); + return; + } + if (!(c instanceof Element)) return; + const r = c.getBoundingClientRect(); + if (!w || w.kind !== kindOf(c) || (w.at && Math.abs(w.at.height - r.height) > 1 && !(c instanceof SVGElement))) + return cross(c, w, path); + // The same piece somewhere else in the box: it glides there (what it holds rides along, plus its own move). + const own = w.at ? glideFrom(c, w.at, carried) : carried; + if (c instanceof SVGElement) { + if (w.svg !== drawing(c)) morphs.push(() => appear(c)); + return; + } + if (!c.children.length && c instanceof HTMLElement) { + const t = c.textContent ?? ''; + if (t !== w.text) + morphs.push(() => + t.length <= 40 && w.text.length <= 40 + ? morphText(c, t, w.text, { whole: true, at: here(w.words) ?? undefined }) + : cross(c, w, path), + ); + return; + } + walk(c, p, own); + }); + walk(box, '', [0, 0]); + // What the new box no longer has goes the same way. + for (const [p, w] of was) + if (!seen.has(p) && p.lastIndexOf('/') === 0 && w.at && w.node instanceof Element) ghosts.push([w.node, w.at, box, box0]); + morphs.forEach((m) => m()); + // The old pieces that cross go from exactly where they stood in their parent (which glides from where it stood). + const hosts = new Map(); + for (const [, , host] of ghosts) { + if (!hosts.has(host) && getComputedStyle(host).position === 'static') host.classList.add('mt'); + hosts.set(host, (hosts.get(host) ?? 0) + 1); + } + for (const [g, at, host, from] of ghosts) { + const e = g as HTMLElement; + e.style.position = 'absolute'; + e.style.margin = '0'; + e.style.left = `${at.left - from.left - host.clientLeft}px`; + e.style.top = `${at.top - from.top - host.clientTop}px`; + e.style.width = `${at.width}px`; + e.style.pointerEvents = 'none'; + e.setAttribute('aria-hidden', 'true'); + host.appendChild(e); + play( + e, + [ + { opacity: 1, filter: 'blur(0px)' }, + { opacity: 0, filter: 'blur(4px)' }, + ], + { duration: 180, easing: EASE_IN, fill: 'forwards' }, + ).onfinish = () => { + e.remove(); + const n = hosts.get(host)! - 1; + hosts.set(host, n); + if (!n) host.classList.remove('mt'); + }; + } +} + +/** The Android robot's head; its eyes take the colour of what it sits on. */ +const ANDROID = + ''; +const marks = (): Element[] => [ic('apple'), markup(ANDROID)]; + +/** One step of a path, cut where iOS and Android word it differently: [what comes before, iOS word, Android word, what comes after]. */ +type Step = [string, string, string, string]; +function cut(ios: string, android: string): Step { + if (ios === android) return ['', ios, ios, '']; + const A = ios.split(' '); + const B = android.split(' '); + let p = 0; + while (p < A.length && p < B.length && A[p] === B[p]) p++; + let q = 0; + while (q < A.length - p && q < B.length - p && A[A.length - 1 - q] === B[B.length - 1 - q]) q++; + const pre = A.slice(0, p).join(' '); + const suf = A.slice(A.length - q).join(' '); + return [pre ? `${pre} ` : '', A.slice(p, A.length - q).join(' '), B.slice(p, B.length - q).join(' '), suf ? ` ${suf}` : '']; +} + +export interface MenuLine { + el: HTMLElement; + /** Another app's path in its place: each part morphs, the arrows stay, the system's mark comes or goes. */ + set(ios: string, android: string): void; +} + +/** + * A menu path ("+ → Create from QR code") for both phone systems in one line, + * its steps in bold with grey arrows between them. Where iOS and Android word a + * step differently, that word turns between the two every few seconds, the + * system's mark beside it. + */ +export function menuLine(ios: string, android: string): MenuLine { + const body = h('span', { 'aria-hidden': 'true' }); + const el = h('b', { class: 'osm', role: 'text' }, body); + let steps: Step[] = []; + let parts: { pre: HTMLElement; word: HTMLElement; suf: HTMLElement }[] = []; + /** The step that differs (its mark stands before its word), or -1. */ + let at = -1; + let icEl: HTMLElement | null = null; + /** Which system's wording shows: 0 iOS, 1 Android. */ + let k = 0; + const wordOf = (s: Step) => (k ? s[2] : s[1]); + const part = (t: string) => h('span', { class: 'osm-p' }, t); + + /** Drawn afresh, no motion (the first time, or a path with another number of steps). */ + const draw = () => { + at = steps.findIndex((s) => s[1] !== s[2]); + if (at < 0) k = 0; + parts = steps.map((s) => ({ pre: part(s[0]), word: part(wordOf(s)), suf: part(s[3]) })); + icEl = at >= 0 ? h('span', { class: 'osm-ic' }, marks()[k]) : null; + body.replaceChildren( + ...parts + .flatMap((p, i) => [i ? h('span', { class: 'arr' }, '›') : null, p.pre, i === at ? icEl : null, p.word, p.suf]) + .filter((n): n is HTMLElement => !!n), + ); + }; + + const MARK = { width: '1.05em', marginRight: '0.25em' }; + const markOut = (m: HTMLElement) => + (play( + m, + [ + { opacity: 1, filter: 'blur(0px)', ...MARK }, + { opacity: 0, filter: 'blur(3px)', width: '0px', marginRight: '0px' }, + ], + { duration: 220, easing: EASE_IN, fill: 'forwards' }, + ).onfinish = () => m.remove()); + const markIn = (m: HTMLElement) => + play( + m, + [ + { opacity: 0, filter: 'blur(3px)', width: '0px', marginRight: '0px' }, + { opacity: 1, filter: 'blur(0px)', ...MARK }, + ], + { duration: SMOOTH.duration, easing: SMOOTH.easing }, + ); + + const set = (i: string, a: string) => { + el.setAttribute('aria-label', (i === a ? i : `${i} (Android: ${a.split(' → ').pop()})`).replace(/ → /g, ' › ')); + const I = i.split(' → '); + const A = a.split(' → '); + const next = I.map((s, n) => cut(s, A[n] ?? s)); + if (!parts.length || next.length !== steps.length) { + steps = next; + return draw(); + } + const was = at; + steps = next; + at = steps.findIndex((s) => s[1] !== s[2]); + if (at < 0) k = 0; + // Another app's path: each part blurs from the old words into the new (the system's turn morphs, below). + steps.forEach((s, n) => { + morphText(parts[n].pre, s[0], undefined, { whole: true }); + morphText(parts[n].word, wordOf(s), undefined, { whole: true }); + morphText(parts[n].suf, s[3], undefined, { whole: true }); + }); + if (at === was) return; + if (icEl) markOut(icEl); + icEl = at >= 0 ? h('span', { class: 'osm-ic' }, marks()[k]) : null; + if (icEl) { + parts[at].word.before(icEl); + markIn(icEl); + } + }; + set(ios, android); + + // The other system's wording, every few seconds: its word morphs, its mark turns in. + const turn = () => { + if (!el.isConnected) return clearInterval(timer); + // Not on screen (a folded row): wait for the next turn. + if (at < 0 || !icEl || !el.offsetParent) return; + k = 1 - k; + morphText(parts[at].word, wordOf(steps[at])); + const oi = icEl.firstElementChild as Element; + const ni = marks()[k]; + if (calm()) { + oi.replaceWith(ni); + return; + } + icEl.appendChild(ni); + play( + oi, + [ + { opacity: 1, filter: 'blur(0px)', transform: 'none' }, + { opacity: 0, filter: 'blur(3px)', transform: 'scale(.5) rotate(-40deg)' }, + ], + { duration: 200, easing: EASE_IN, fill: 'forwards' }, + ).onfinish = () => oi.remove(); + play( + ni, + [ + { opacity: 0, filter: 'blur(3px)', transform: 'scale(.5) rotate(40deg)' }, + { opacity: 1, filter: 'blur(0px)', transform: 'none' }, + ], + { duration: POP.duration, delay: 80, easing: POP.easing, fill: 'backwards' }, + ); + }; + const timer = window.setInterval(turn, 3000); + return { el, set }; +} diff --git a/web/src/portal/ui/seg.ts b/web/src/portal/ui/seg.ts new file mode 100644 index 0000000..3d817c3 --- /dev/null +++ b/web/src/portal/ui/seg.ts @@ -0,0 +1,125 @@ +// The icon picker (the apps): icons only, the picked one widens and shows its +// name. The pill stretches like skiper21's tabs: its leading edge reaches the +// new item first and the trailing edge follows, so the name fading in is always +// inside it. Items grow by flex-grow (a share of the track, not pixels), so +// they stay right while the sheet around them changes width. + +import { h, ic } from '../dom'; +import { EASE_OUT, LEAD, SMOOTH, calm, play } from '../motion'; + +export interface SegItem { + value: T; + label: string; + icon: string; +} + +export interface IconSeg { + el: HTMLElement; + /** Show this value without telling anyone (another copy of the picker changed it). */ + sync(v: T): void; +} + +export function iconSeg(items: SegItem[], value: T, onPick: (v: T) => void): IconSeg { + const pill = h('span', { class: 'seg-pill' }); + const el = h('div', { class: 'seg appseg', role: 'tablist' }, pill); + const btns = items.map((it) => { + const b = h( + 'button', + { type: 'button', class: 'seg-b', role: 'tab', 'aria-label': it.label, title: it.label, onclick: () => pick(it.value) }, + ic(it.icon), + h('span', { class: 'seg-l' }, it.label), + ); + b.dataset.v = it.value; + el.appendChild(b); + return b; + }); + const labelOf = (b: HTMLElement) => b.querySelector('.seg-l') as HTMLElement; + const mark = () => + btns.forEach((b) => { + const on = b.dataset.v === value; + b.classList.toggle('on', on); + b.setAttribute('aria-selected', String(on)); + }); + const edges = (): [number, number] | null => { + const b = btns.find((x) => x.dataset.v === value); + return b && b.offsetWidth ? [b.offsetLeft, el.clientWidth - b.offsetLeft - b.offsetWidth] : null; + }; + const placePill = () => { + const e = edges(); + if (!e) return; + pill.style.left = `${e[0]}px`; + pill.style.right = `${e[1]}px`; + }; + + let raf = 0; + function pick(v: T) { + if (v === value) return; + const from = btns.findIndex((b) => b.dataset.v === value); + const to = btns.findIndex((b) => b.dataset.v === v); + const cs = getComputedStyle(pill); + const l0 = parseFloat(cs.left) || 0; + const r0 = parseFloat(cs.right) || 0; + const g0 = btns.map((b) => parseFloat(getComputedStyle(b).flexGrow) || 0); + const oldL = labelOf(btns[from]); + const oldW = oldL.getBoundingClientRect().width; + [...btns, ...btns.map(labelOf)].forEach((x) => x.getAnimations().forEach((a) => a.cancel())); + value = v; + mark(); + btns.forEach((b, i) => { + const g1 = i === to ? 1 : 0; + if (g0[i] !== g1) play(b, [{ flexGrow: g0[i] }, { flexGrow: g1 }], { duration: SMOOTH.duration, easing: SMOOTH.easing }); + }); + play( + oldL, + [ + { opacity: 1, maxWidth: `${oldW}px`, marginLeft: '0px' }, + { opacity: 0, maxWidth: '0px', marginLeft: '-8px' }, + ], + { duration: 220, easing: 'ease-out' }, + ); + play( + labelOf(btns[to]), + [ + { opacity: 0, filter: 'blur(4px)' }, + { opacity: 1, filter: 'none' }, + ], + { duration: 280, delay: 70, easing: EASE_OUT, fill: 'backwards' }, + ); + // The stretch: the leading edge follows the quick spring, the trailing edge the smooth one. + const right = to > from; + const lead = calm() ? SMOOTH : LEAD; + const t0 = performance.now(); + const end = Math.max(SMOOTH.duration, lead.duration); + const eL = right ? SMOOTH : lead; + const eR = right ? lead : SMOOTH; + cancelAnimationFrame(raf); + const step = () => { + const t = calm() ? end : performance.now() - t0; + const e = edges(); + if (!e) { + raf = 0; + return; + } + pill.style.left = `${l0 + (e[0] - l0) * eL.at(t)}px`; + pill.style.right = `${r0 + (e[1] - r0) * eR.at(t)}px`; + raf = t < end ? requestAnimationFrame(step) : 0; + if (!raf) placePill(); + }; + raf = requestAnimationFrame(step); + onPick(v); + } + + mark(); + new ResizeObserver(() => { + if (!raf) placePill(); + }).observe(el); + return { + el, + sync(v) { + if (v === value) return; + value = v; + mark(); + placePill(); + }, + }; +} diff --git a/web/src/portal/ui/sheet.ts b/web/src/portal/ui/sheet.ts new file mode 100644 index 0000000..cec4830 --- /dev/null +++ b/web/src/portal/ui/sheet.ts @@ -0,0 +1,477 @@ +// The sheet: one drawer floating at the bottom of the screen, on phones and +// desktops alike. It holds a stack of views (go/back), glides to each view's +// height, widens on a desktop for a dense QR code until the code gets its +// pixels, pins a view's own buttons beside ×, and closes by ×, the scrim, a +// pull down on its header, Escape, or the phone's back button (it is a history +// entry). Views are built by the flows; this module only moves them. + +import { h, ic } from '../dom'; +import { BOUNCY, DRAWER, EASE_IN, EASE_OUT, SMOOTH, SOFT, dismisses, play, rubber } from '../motion'; +import { closeMenu } from './menu'; + +/** A view: its root, and what the sheet reads from it. */ +export interface View { + el: HTMLElement; + /** The sheet's accessible name while this view shows (its title). */ + label: string; + /** A question (Remove, Reconnect): an alert dialog. */ + asks?: boolean; + /** Its own buttons, pinned beside × while it shows. */ + acts?: HTMLElement | null; +} +export type ViewFactory = () => View; + +let root: HTMLElement; +let scrim: HTMLElement; +let sheetEl: HTMLElement; +let closeBtn: HTMLElement; +let actsEl: HTMLElement; +let scroller: HTMLElement; +let vp: HTMLElement; + +let stack: ViewFactory[] = []; +let closed: (() => void) | null = null; +let left: (() => void) | null = null; +let ownsHistory = false; +let returnFocus: HTMLElement | null = null; + +export const sheetOpen = () => !!root?.classList.contains('open'); + +/* ---------- width: a dense code scans from a screen at about 3 px a module ---------- */ + +const SHEET_W = 400; +const QR_PAD = 80; +// 3.2 px a module: 6–7 device pixels on a retina screen, still a sure read for a phone camera. +const PX_PER_MODULE = 3.2; +/** A computer, or a tablet held wide: the sheet is a dialog in the middle (sheet.css), and may widen for a dense code. */ +const wide = () => matchMedia('(min-width: 760px)').matches; +let sheetW = SHEET_W; +let shownQr: HTMLElement | null = null; + +export interface WidthPlan { + from: number; + want: number; + reveal: HTMLElement | null; +} + +/** + * The width the sheet needs now, set at once so whatever measures the new + * layout (an accordion, the height glide) measures it at the final width; the + * plan then animates there on the same spring (`startWidth`), so nothing snaps. + */ +export function planWidth(): WidthPlan | null { + if (!root || !sheetOpen()) return null; + if (!wide()) { + if (sheetEl.style.maxWidth) sheetEl.style.maxWidth = ''; + sheetW = SHEET_W; + return null; + } + const qr = [...vp.querySelectorAll('.qrbox.dense')].find((b) => { + const row = b.closest('.acc-row'); + return b.offsetWidth && (!row || row.classList.contains('open')) && !b.closest('.leaving'); + }); + let want = SHEET_W; + if (qr) { + // The code itself fits the screen; the rest of the sheet may scroll around it. + const room = Math.min(innerWidth - 32 - QR_PAD, innerHeight - 120); + want = Math.max(SHEET_W, Math.round(Math.min(+(qr.dataset.mods ?? 0) * PX_PER_MODULE, room) + QR_PAD)); + } + const reveal = qr && qr !== shownQr ? qr : null; + shownQr = qr ?? null; + if (Math.abs(want - sheetW) < 8) return reveal ? { from: want, want, reveal } : null; + const from = parseFloat(getComputedStyle(sheetEl).maxWidth) || sheetW; + sheetW = want; + sheetEl + .getAnimations() + .filter((a) => (a.effect as KeyframeEffect | null)?.getKeyframes().some((k) => 'maxWidth' in k)) + .forEach((a) => a.cancel()); + sheetEl.style.maxWidth = `${want}px`; + return { from, want, reveal }; +} + +export function startWidth(p: WidthPlan | null) { + if (!p) return; + if (Math.abs(p.from - p.want) > 1) + play(sheetEl, [{ maxWidth: `${p.from}px` }, { maxWidth: `${p.want}px` }], { duration: SMOOTH.duration, easing: SMOOTH.easing }); + // The code has to be on screen whole: scroll it into view once the sheet has its size. + const q = p.reveal; + if (q) + setTimeout(() => { + if (!q.isConnected) return; + const a = scroller.getBoundingClientRect(); + const b = q.getBoundingClientRect(); + const d = b.bottom > a.bottom - 16 ? b.bottom - a.bottom + 16 : b.top < a.top + 16 ? b.top - a.top - 16 : 0; + if (d) scroller.scrollBy({ top: d, behavior: 'smooth' }); + }, BOUNCY.duration); +} + +/* ---------- the drawer ---------- */ + +function build() { + closeBtn = h('button', { type: 'button', class: 'knob x', 'aria-label': 'Close', onclick: () => closeSheet() }, ic('x')); + actsEl = h('div', { class: 'sheet-acts' }); + vp = h('div', { class: 'vp' }); + scroller = h('div', { class: 'sheet-scroll' }, vp); + sheetEl = h('div', { class: 'sheet', role: 'dialog', 'aria-modal': 'true' }, closeBtn, actsEl, scroller); + scrim = h('div', { class: 'scrim', onclick: () => closeSheet() }); + root = h('div', { class: 'sheet-root', 'aria-hidden': 'true' }, scrim, sheetEl); + document.body.appendChild(root); + new ResizeObserver(() => startWidth(planWidth())).observe(vp); + pullToClose(); +} + +function label(v: View) { + sheetEl.setAttribute('aria-label', v.label); + sheetEl.setAttribute('role', v.asks ? 'alertdialog' : 'dialog'); +} + +/** The view being left (a new one, or the sheet closing) lets go of what it holds. */ +function leave() { + const f = left; + left = null; + f?.(); +} + +/** What the current view holds and must stop (a poll): called when it is left. */ +export function onLeave(fn: () => void) { + left = fn; +} + +/** After this sheet closes (once). */ +export function onClosed(fn: () => void) { + closed = fn; +} + +export function openSheet(factory: ViewFactory) { + if (!root) build(); + closeMenu(true); + leave(); + if (sheetOpen()) { + // Already open: the new flow takes the place of the old one, history and all. + stack = [factory]; + swapView(factory()); + return; + } + returnFocus = document.activeElement instanceof HTMLElement ? document.activeElement : null; + stack = [factory]; + closed = null; + sheetW = SHEET_W; + shownQr = null; + sheetEl.style.maxWidth = ''; + sheetEl.classList.remove('arrived'); + const v = factory(); + vp.replaceChildren(v.el); + setActs(v, false); + label(v); + root.classList.add('open'); + root.setAttribute('aria-hidden', 'false'); + document.body.classList.add('locked'); + const p0 = planWidth(); + if (p0) startWidth({ ...p0, from: p0.want }); + sheetEl.getAnimations().forEach((a) => a.cancel()); + scrim.getAnimations().forEach((a) => a.cancel()); + sheetEl.style.transform = ''; + // A dialog comes up from its centre the way a ⋯ menu pops (menu.ts), on a softer spring; the drawer rises from the bottom edge. + if (wide()) + play( + sheetEl, + [ + { opacity: 0, transform: 'scale(.9)', filter: 'blur(4px)' }, + { opacity: 1, transform: 'none', filter: 'none' }, + ], + { duration: SOFT.duration, easing: SOFT.easing }, + ); + else play(sheetEl, [{ transform: 'translateY(calc(100% + 40px))' }, { transform: 'none' }], { duration: 500, easing: DRAWER }); + // The dim behind keeps time with the sheet: with the dialog's pop on a computer, with the drawer's rise on a phone. + play( + scrim, + [{ opacity: 0 }, { opacity: 1 }], + wide() ? { duration: SOFT.duration, easing: SOFT.easing } : { duration: 420, easing: 'ease-out' }, + ); + if (!ownsHistory) { + try { + history.pushState({ sheet: true }, ''); + ownsHistory = true; + } catch { + /* no history */ + } + } +} + +/** `now`: gone at once (Escape: what the keyboard does never animates). */ +export function closeSheet(now = false) { + if (!sheetOpen() || root.dataset.closing) return; + leave(); + if (ownsHistory) { + ownsHistory = false; + history.back(); + } + document.body.classList.remove('locked'); + const done = () => { + root.classList.remove('open'); + root.setAttribute('aria-hidden', 'true'); + delete root.dataset.closing; + sheetEl.style.transform = ''; + scrim.style.opacity = ''; + sheetEl.getAnimations().forEach((a) => a.cancel()); + scrim.getAnimations().forEach((a) => a.cancel()); + vp.getAnimations().forEach((a) => a.cancel()); + vp.replaceChildren(); + actsEl.replaceChildren(); + sheetEl.classList.remove('arrived'); + sheetEl.style.maxWidth = ''; + sheetW = SHEET_W; + stack = []; + if (returnFocus?.isConnected) returnFocus.focus({ preventScroll: true }); + returnFocus = null; + const f = closed; + closed = null; + f?.(); + }; + if (now) return done(); + root.dataset.closing = '1'; + const from = getComputedStyle(sheetEl).transform; + sheetEl.getAnimations().forEach((a) => a.cancel()); + play( + scrim, + [{ opacity: getComputedStyle(scrim).opacity }, { opacity: 0 }], + wide() ? { duration: 120, easing: EASE_IN, fill: 'forwards' } : { duration: 320, easing: 'ease-out', fill: 'forwards' }, + ); + const at = from === 'none' ? 'none' : from; + // A dialog goes the way a ⋯ menu does, quick and soft into its centre; the drawer goes down past the edge. + play( + sheetEl, + wide() + ? [ + { opacity: 1, transform: at, filter: 'blur(0px)' }, + { opacity: 0, transform: `${at === 'none' ? '' : at} scale(.96)`.trim(), filter: 'blur(3px)' }, + ] + : [{ transform: at }, { transform: 'translateY(calc(100% + 40px))' }], + wide() ? { duration: 120, easing: EASE_IN, fill: 'forwards' } : { duration: 420, easing: DRAWER, fill: 'forwards' }, + ).onfinish = done; +} + +// The phone's back button closes the sheet instead of leaving the page. +addEventListener('popstate', () => { + if (!sheetOpen()) return; + ownsHistory = false; + closeSheet(); +}); + +/** A view's own buttons beside ×: pinned with it while the sheet scrolls, they come and go with the view. */ +function setActs(v: View, anim = true) { + const neu = v.acts ?? null; + const old = actsEl.firstElementChild as HTMLElement | null; + if (neu === old) return; + // No motion asked, or the same buttons for a rebuilt view: swapped in place. + if (!anim || (old && neu && old.dataset.key === neu.dataset.key)) return actsEl.replaceChildren(...(neu ? [neu] : [])); + if (old) { + Object.assign(old.style, { position: 'absolute', right: '0', top: '0', pointerEvents: 'none' }); + play( + old, + [ + { opacity: 1, transform: 'none', filter: 'none' }, + { opacity: 0, transform: 'scale(.9)', filter: 'blur(3px)' }, + ], + { + duration: 180, + easing: 'cubic-bezier(.2,0,0,1)', + fill: 'forwards', + }, + ).onfinish = () => old.remove(); + } + if (neu) { + actsEl.appendChild(neu); + play( + neu, + [ + { opacity: 0, transform: 'scale(.9)', filter: 'blur(3px)' }, + { opacity: 1, transform: 'none', filter: 'none' }, + ], + { + duration: 260, + delay: 110, + easing: 'cubic-bezier(.2,0,0,1)', + fill: 'backwards', + }, + ); + } +} + +/** Another view in the open sheet: the old one fades out over the new one, the sheet glides to its height. */ +function swapView(v: View) { + label(v); + setActs(v); + sheetEl.classList.remove('arrived'); + const old = [...vp.children] as HTMLElement[]; + const h0 = vp.getBoundingClientRect().height; + vp.getAnimations().forEach((a) => a.cancel()); + old.forEach((o) => { + o.classList.add('leaving'); + Object.assign(o.style, { position: 'absolute', left: '0', right: '0', top: '0', pointerEvents: 'none' }); + o.inert = true; + }); + vp.appendChild(v.el); + // A tap that lands where the new view's button appears must not press it. + v.el.style.pointerEvents = 'none'; + setTimeout(() => (v.el.style.pointerEvents = ''), 320); + scroller.scrollTop = 0; + const plan = planWidth(); + const h1 = v.el.getBoundingClientRect().height; + play(vp, [{ height: `${h0}px` }, { height: `${h1}px` }], { duration: 360, easing: 'cubic-bezier(.25,1,.5,1)' }); + startWidth(plan); + old.forEach( + (o) => + (play( + o, + [ + { opacity: 1, transform: 'none', filter: 'none' }, + { opacity: 0, transform: 'scale(.96)', filter: 'blur(2px)' }, + ], + { + duration: 200, + easing: 'cubic-bezier(.2,0,0,1)', + fill: 'forwards', + }, + ).onfinish = () => o.remove()), + ); + play( + v.el, + [ + { opacity: 0, transform: 'scale(.96)', filter: 'blur(4px)' }, + { opacity: 1, transform: 'none', filter: 'none' }, + ], + { + duration: 280, + delay: 110, + easing: 'cubic-bezier(.2,0,0,1)', + fill: 'backwards', + }, + ); +} + +/** Further into a flow (Add → Open on the device). */ +export function go(factory: ViewFactory) { + if (!sheetOpen()) return openSheet(factory); + leave(); + stack.push(factory); + swapView(factory()); +} + +export function back() { + if (stack.length < 2) return; + leave(); + stack.pop(); + swapView(stack[stack.length - 1]()); +} + +/** + * Content inside the open sheet changed: it glides to its new height, what + * stayed but moved (a block above it grew or shrank) glides to its new place, + * the changed blocks come into focus. + */ +export function glide(change: () => void, focus: (Element | null | undefined)[] = []) { + if (!sheetOpen()) return change(); + const h0 = vp.getBoundingClientRect().height; + vp.getAnimations().forEach((a) => a.cancel()); + const view = vp.lastElementChild; + const was = new Map(); + view?.querySelectorAll('*').forEach((e) => { + if (!(e instanceof SVGElement) || e instanceof SVGSVGElement) was.set(e, e.getBoundingClientRect()); + }); + change(); + const plan = planWidth(); + const h1 = vp.getBoundingClientRect().height; + if (Math.abs(h1 - h0) > 1) play(vp, [{ height: `${h0}px` }, { height: `${h1}px` }], { duration: SMOOTH.duration, easing: SMOOTH.easing }); + startWidth(plan); + // Measured with the sheet back at its old size (its glides have just started): only what moved inside it moves. + const moved = new Set(); + for (const [e, r] of was) { + if (!e.isConnected || !r.width || !r.height) continue; + const n = e.getBoundingClientRect(); + if (!n.width || !n.height) continue; + const dx = r.left - n.left; + const dy = r.top - n.top; + if (Math.abs(dx) < 0.5 && Math.abs(dy) < 0.5) continue; + moved.add(e); + // Once, on the outermost that moved: what it holds moves with it. + let p = e.parentElement; + while (p && p !== view && !moved.has(p)) p = p.parentElement; + if (p && p !== view) continue; + play(e, [{ transform: `translate(${dx}px, ${dy}px)` }, { transform: 'none' }], { duration: SMOOTH.duration, easing: SMOOTH.easing }); + } + for (const el of focus) + if (el) + play( + el, + [ + { opacity: 0, filter: 'blur(4px)' }, + { opacity: 1, filter: 'none' }, + ], + { duration: 280, easing: EASE_OUT }, + ); +} + +/** The view's job is done (a device connected): ×, and the view's own buttons, step away. */ +export function settle() { + sheetEl?.classList.add('arrived'); +} + +/** The sheet scrolls back to the top (a device connected under a scrolled sheet). */ +export const scrollTop = () => scroller?.scrollTo({ top: 0, behavior: 'smooth' }); + +/** Is this element in the sheet that shows now (not one being swapped out)? */ +export const showing = (el: Element) => sheetOpen() && vp.contains(el) && !el.closest('.leaving'); + +/* ---------- pull down by the header to close ---------- */ + +function pullToClose() { + let drag: { y: number; t: number; dy: number; v: number } | null = null; + sheetEl.addEventListener('pointerdown', (e) => { + const t = e.target as Element; + if (!t.closest('.vhead') || t.closest('button, a, input')) return; + drag = { y: e.clientY, t: performance.now(), dy: 0, v: 0 }; + sheetEl.setPointerCapture(e.pointerId); + }); + sheetEl.addEventListener('pointermove', (e) => { + if (!drag) return; + const raw = e.clientY - drag.y; + const t = performance.now(); + // Down follows the finger; up resists, more the further it goes. + const dy = raw > 0 ? raw : -rubber(-raw, sheetEl.offsetHeight); + drag.v = (dy - drag.dy) / Math.max(1, t - drag.t); + drag.dy = dy; + drag.t = t; + sheetEl.style.transform = `translateY(${dy}px)`; + scrim.style.opacity = String(Math.max(0, 1 - Math.max(0, dy) / 420)); + }); + const end = () => { + if (!drag) return; + const { dy, v } = drag; + drag = null; + if (dismisses(dy, v, sheetEl.offsetHeight)) return closeSheet(); + const from = sheetEl.style.transform; + sheetEl.style.transform = ''; + scrim.style.opacity = ''; + if (dy !== 0) play(sheetEl, [{ transform: from }, { transform: 'none' }], { duration: SMOOTH.duration, easing: SMOOTH.easing }); + }; + sheetEl.addEventListener('pointerup', end); + sheetEl.addEventListener('pointercancel', end); +} + +/* ---------- the parts every view is made of ---------- */ + +/** A view's head: its title (and Back, inside a flow). */ +export function head(title: string, o: { back?: boolean; acts?: boolean } = {}): HTMLElement { + return h( + 'div', + { class: `vhead${o.back ? ' center' : ''}${o.acts ? ' with-acts' : ''}` }, + o.back ? h('button', { type: 'button', class: 'knob back', 'aria-label': 'Back', onclick: back }, ic('chevron')) : null, + h('h2', {}, title), + ); +} + +/** The line under a view's title. */ +export const sub = (text: string) => h('p', { class: 'vsub' }, text); +/** A small line of help. */ +export const hint = (...kids: (Node | string | null)[]) => h('p', { class: 'hint' }, ...kids); diff --git a/web/src/portal/waitpath.ts b/web/src/portal/waitpath.ts deleted file mode 100644 index 6d46478..0000000 --- a/web/src/portal/waitpath.ts +++ /dev/null @@ -1,60 +0,0 @@ -// The set-up sheets' "waiting for the first connection" card: the way from -// the device (its icon; the sheet's title names it) to the home server, a light -// running along its dots while the page waits; the dots fill green when it connects. -// It only draws and switches its states; main.ts (watchFirstConnection) -// decides when, and what leaves around it. A live region: the changes are read out. - -import type { Kind } from '../shared/types'; -import { h, ic } from './dom'; -import { grow, replay } from './motion'; - -export interface Way { - el: HTMLElement; - /** The first connection arrived. */ - connected(): void; - /** The page stopped asking (ten minutes): say so instead of waiting on forever. */ - gaveUp(): void; -} - -export function waitPath(kind: Kind): Way { - const title = h('span', { class: 'strong s' }, 'Waiting for the connection'); - // Nothing to add while it waits: the line comes with "You're all set" or the give-up. - const sub = h('span', { class: 'faint s' }); - // The router end: the server's icon, as on the admin's map. - const home = h('span', { class: 'way-end home' }, ic('server')); - const el = h( - 'div', - { class: 'way', role: 'status', 'aria-live': 'polite' }, - h( - 'div', - { class: 'way-row' }, - h('span', { class: 'way-end' }, ic(kind)), - h('span', { class: 'way-track' }, h('span', { class: 'way-glow' }, h('i')), h('span', { class: 'way-fill' })), - home, - ), - h('div', { class: 'way-text' }, title, sub), - ); - const say = (t: string, s: string) => { - if (title.textContent !== t) { - title.textContent = t; - replay(title, 'swap'); - } - if (sub.textContent === s) return; - // The line under the title only appears now: it opens rather than pushing the card. - const opens = !sub.textContent; - sub.textContent = s; - if (opens) grow(sub); - else replay(sub, 'swap'); - }; - return { - el, - connected: () => { - el.classList.add('done'); - say('Connected', 'You’re all set.'); - }, - gaveUp: () => { - el.classList.add('stopped'); - say('No connection yet', 'Close this and open it again to keep checking.'); - }, - }; -} diff --git a/web/src/shared/qr.ts b/web/src/shared/qr.ts index b415807..3e64397 100644 --- a/web/src/shared/qr.ts +++ b/web/src/shared/qr.ts @@ -4,15 +4,16 @@ // no mark and level L: every step up in correction adds modules, and a dense // code fails on the camera before it fails on damage. // -// Two looks. `plain`: black squares on white in one path (the admin's cards and +// Three looks. `plain`: black squares on white in one path (the admin's cards and // the invite image). `night`: light dots on black with rounded finder eyes (the -// portal). Light dots on dark lose a dense code to blur sooner, so a dense night -// code gets fuller dots: checked with a QR reader, r 0.42 lost a 1.5 KB key at -// 1.2 px of blur where r 0.48 read as well as the plain code. +// portal on a dark theme). `day`: the same dots and eyes, dark on white (the +// portal on a light theme). Light dots on dark lose a dense code to blur sooner, +// so a dense round code gets fuller dots: checked with a QR reader, r 0.42 lost +// a 1.5 KB key at 1.2 px of blur where r 0.48 read as well as the plain code. import qrcode from 'qrcode-generator'; -export type QrLook = 'plain' | 'night'; +export type QrLook = 'plain' | 'night' | 'day'; /** The icon's dome and bar (64×64 viewBox, see portal/icon.svg), in a colour. */ const mark = (fill: string) => @@ -20,6 +21,8 @@ const mark = (fill: string) => const NIGHT_BG = '#0a0a0a'; const NIGHT_FG = '#f2f2f2'; +/** The round looks' card and dots: light on black at night, dark on white by day. */ +const ROUND: Record<'night' | 'day', [bg: string, fg: string]> = { night: [NIGHT_BG, NIGHT_FG], day: ['#ffffff', NIGHT_BG] }; /** Long content: fewer modules matter more than the mark. */ export const denseQr = (text: string): boolean => text.length > 300; @@ -35,7 +38,9 @@ function rrect(x: number, y: number, w: number, h: number, r: number): string { export function qrSvg(text: string, margin = 3, logo = true, look: QrLook = 'plain'): string { const dense = denseQr(text); - const night = look === 'night'; + // The night and day looks draw the same round dots and eyes; only their colours differ. + const round = look !== 'plain'; + const [bg, fg] = round ? ROUND[look] : ['#fff', '#000']; const qr = qrcode(0, dense ? 'L' : 'H'); qr.addData(text, 'Byte'); qr.make(); @@ -47,10 +52,10 @@ export function qrSvg(text: string, margin = 3, logo = true, look: QrLook = 'pla const h0 = (n - hole) / 2, h1 = h0 + hole; const inHole = (x: number, y: number) => hole > 0 && x >= h0 && x < h1 && y >= h0 && y < h1; - // The three finder patterns, drawn whole as eyes in the night look. - const inEye = (x: number, y: number) => night && ((y < 7 && x < 7) || (y < 7 && x >= n - 7) || (y >= n - 7 && x < 7)); + // The three finder patterns, drawn whole as eyes in the round looks. + const inEye = (x: number, y: number) => round && ((y < 7 && x < 7) || (y < 7 && x >= n - 7) || (y >= n - 7 && x < 7)); let d = ''; - if (night) { + if (round) { const r = dense ? 0.48 : 0.42; for (let y = 0; y < n; y++) for (let x = 0; x < n; x++) @@ -72,7 +77,7 @@ export function qrSvg(text: string, margin = 3, logo = true, look: QrLook = 'pla } // Each eye: a 7×7 ring around a gap and a 3×3 pupil, one even-odd path. let eyes = ''; - if (night) + if (round) for (const [x, y] of [ [margin, margin], [margin + n - 7, margin], @@ -85,12 +90,12 @@ export function qrSvg(text: string, margin = 3, logo = true, look: QrLook = 'pla s = hole - pad * 2, o = h0 + margin + pad; logoTile = - `` + - `${mark(night ? NIGHT_BG : '#fff')}`; + `` + + `${mark(round ? bg : '#fff')}`; } const open = ``; - return night - ? `${open}` + - `${logoTile}` - : `${open}${logoTile}`; + return round + ? `${open}` + + `${logoTile}` + : `${open}${logoTile}`; } diff --git a/web/src/shared/types.ts b/web/src/shared/types.ts index 52142cb..7e43cab 100644 --- a/web/src/shared/types.ts +++ b/web/src/shared/types.ts @@ -52,6 +52,8 @@ export interface Person { online: number; last_seen: number; devices: Device[]; + /** Daily totals (rx+tx) from the 1st of this month to today, oldest first; portal only. */ + month_days?: number[]; /** Throughput, one point a minute (last 15): [ts, rx, tx] in bytes/s (rx = from devices); admin only. */ rate?: [number, number, number][]; // admin only (the personal link itself comes from person_links, not the status) diff --git a/web/tests/days.test.ts b/web/tests/days.test.ts new file mode 100644 index 0000000..51805b1 --- /dev/null +++ b/web/tests/days.test.ts @@ -0,0 +1,52 @@ +import { describe, expect, it } from 'vitest'; +import { calendar, clockOf, hoursFor, minuteAt, minuteOf, monthOf, stretches } from '../src/portal/days'; + +describe('days', () => { + it('lays the weeks to the end out Monday first, one cell a day', () => { + // Mon 19 Oct 2026 to Fri 23 Oct: one week. + const c = calendar('2026-10-19', '2026-10-23')!; + expect(c).toHaveLength(7); + expect(c.map((x) => x.kind)).toEqual(['today', 'left', 'left', 'left', 'end', 'after', 'after']); + // From a Wednesday: Monday and Tuesday are gone. + const w = calendar('2026-10-21', '2026-10-21')!; + expect(w.map((x) => x.kind).slice(0, 3)).toEqual(['past', 'past', 'today']); + expect(w[2].day).toBe('2026-10-21'); + }); + + it('gives up on a calendar past ten weeks', () => { + expect(calendar('2026-10-19', '2026-12-27')).not.toBeNull(); + expect(calendar('2026-10-19', '2027-03-01')).toBeNull(); + }); + + it('reads and writes clock times', () => { + expect(minuteOf('08:30')).toBe(510); + expect(minuteOf('8:05')).toBe(485); + expect(minuteOf('24:00')).toBeNull(); + expect(clockOf(510)).toBe('08:30'); + expect(clockOf(-30)).toBe('23:30'); + expect(clockOf(1440 + 60)).toBe('01:00'); + }); + + it('moves the hours into the visitor’s time', () => { + // Router on UTC+3, visitor on UTC+1: two hours earlier. + expect(hoursFor('08:00-23:00', 180, 60)).toEqual({ from: 360, to: 1260, yours: true }); + // Without the router's offset: its own time, as set. + expect(hoursFor('08:00-23:00', undefined, 60)).toEqual({ from: 480, to: 1380, yours: false }); + expect(hoursFor('nonsense', 0, 0)).toBeNull(); + }); + + it('splits a window over midnight into two stretches', () => { + expect(stretches({ from: 480, to: 1380, yours: true })).toEqual([[480, 1380]]); + expect(stretches({ from: 1320, to: 360, yours: true })).toEqual([ + [1320, 1440], + [0, 360], + ]); + }); + + it('finds the minute of the day and the days of the month', () => { + // 2026-10-19 12:00 UTC is 15:00 on UTC+3. + expect(minuteAt(Date.UTC(2026, 9, 19, 12) / 1000, 180)).toBe(900); + expect(monthOf('2026-10-19')).toEqual({ days: 31, day: 19 }); + expect(monthOf('2028-02-03')).toEqual({ days: 29, day: 3 }); + }); +}); diff --git a/web/tests/morph.test.ts b/web/tests/morph.test.ts new file mode 100644 index 0000000..3ae5bb4 --- /dev/null +++ b/web/tests/morph.test.ts @@ -0,0 +1,43 @@ +import { describe, expect, it } from 'vitest'; +import { kept } from '../src/portal/ui/morph'; + +/** The letters a morph keeps, as the new text shows them (the rest come in). */ +const keeps = (from: string, to: string) => + kept([...from], [...to]) + .map(([, j]) => [...to][j]) + .join(''); + +describe('kept letters', () => { + it('keeps what the two share at the end together', () => { + expect(kept([...'iPad'], [...'Kitchen iPad'])).toEqual([ + [0, 8], + [1, 9], + [2, 10], + [3, 11], + ]); + }); + + it('keeps what they share at the start and at the end, and changes only the middle', () => { + expect(keeps('2 of 3', '3 of 3')).toBe(' of 3'); + expect(keeps('Kitchen tablet', 'Kitchen iPad')).toBe('Kitchen a'); + }); + + it('finds the letters in common between two different words', () => { + expect(keeps('Scan', 'Create')).toBe('a'); + expect(keeps('Last 7 days', 'Thu 15 Oct')).toContain(' '); + }); + + it('keeps nothing between texts with nothing in common, and everything between equal ones', () => { + expect(kept([...'abc'], [...'xyz'])).toEqual([]); + expect(keeps('Connected', 'Connected')).toBe('Connected'); + }); + + it('pairs indexes in order on both sides', () => { + const pairs = kept([...'Not set up yet'], [...'Connected']); + pairs.forEach(([i, j], n) => { + if (!n) return; + expect(i).toBeGreaterThan(pairs[n - 1][0]); + expect(j).toBeGreaterThan(pairs[n - 1][1]); + }); + }); +}); diff --git a/web/tests/motion.test.ts b/web/tests/motion.test.ts index 25f3008..7837b84 100644 --- a/web/tests/motion.test.ts +++ b/web/tests/motion.test.ts @@ -1,5 +1,5 @@ import { describe, expect, it } from 'vitest'; -import { dismisses, morphMs, rubber } from '../src/portal/motion'; +import { BOUNCY, SMOOTH, dismisses, rubber, spring } from '../src/portal/motion'; describe('motion', () => { it('pulls past an edge with growing resistance, never further than the box', () => { @@ -21,9 +21,21 @@ describe('motion', () => { expect(dismisses(-40, 1, 500)).toBe(false); }); - it('times a height change by its distance, inside 220–380 ms', () => { - expect(morphMs(0)).toBe(220); - expect(morphMs(200)).toBe(270); - expect(morphMs(2000)).toBe(380); + it('samples springs into linear() that starts at 0 and ends at 1', () => { + for (const s of [BOUNCY, SMOOTH, spring(520, 24)]) { + expect(s.easing.startsWith('linear(0, ')).toBe(true); + expect(s.easing.endsWith(', 1)')).toBe(true); + expect(s.at(0)).toBe(0); + expect(s.at(s.duration)).toBe(1); + } + }); + + it('gives the bouncy spring its overshoot and the smooth one none', () => { + const peak = (s: typeof BOUNCY) => Math.max(...Array.from({ length: 200 }, (_, i) => s.at((s.duration * i) / 200))); + // skiper103: about 11% past the end, settled well inside a second. + expect(peak(BOUNCY)).toBeGreaterThan(1.08); + expect(peak(BOUNCY)).toBeLessThan(1.15); + expect(BOUNCY.duration).toBeLessThan(900); + expect(peak(SMOOTH)).toBeLessThanOrEqual(1); }); }); diff --git a/web/tests/netcheck.test.ts b/web/tests/netcheck.test.ts index a19bcd8..cf55d6b 100644 --- a/web/tests/netcheck.test.ts +++ b/web/tests/netcheck.test.ts @@ -79,7 +79,6 @@ import { portsHelp, quotaHelp, timeHelp, - titleHelp, urlHelp, } from '../src/admin/netcheck'; import { date, daysLeft } from '../src/shared/format'; @@ -131,7 +130,6 @@ describe('field helps', () => { expect(portsHelp('70000').bad).toBe(true); expect(urlHelp('vpn.example.com').bad).toBe(true); expect(urlHelp('https://example.com/x').bad).toBe(false); - expect(titleHelp('x'.repeat(65)).bad).toBe(true); expect(domainHelp('').bad).toBe(false); expect(domainHelp('').text).toContain('phone.myata.lan'); expect(domainHelp('Home.LAN').text).toBe('Lowercase only.'); diff --git a/web/tests/qr.test.ts b/web/tests/qr.test.ts index f421c2a..2a0b479 100644 --- a/web/tests/qr.test.ts +++ b/web/tests/qr.test.ts @@ -23,6 +23,16 @@ describe('qr', () => { expect(qrSvg(KEY, 3, true, 'night')).not.toContain(' { + const night = qrSvg(LINK, 3, true, 'night'); + const day = qrSvg(LINK, 3, true, 'day'); + expect(day).toMatch(//); + expect(day).toContain('fill-rule="evenodd"'); + expect(day).not.toContain('crispEdges'); + // The same dots and eyes as at night, in the other colours; the mark's tile turns dark. + expect(day.replace(/#ffffff/g, 'BG').replace(/#0a0a0a/g, 'FG')).toBe(night.replace(/#0a0a0a/g, 'BG').replace(/#f2f2f2/g, 'FG')); + }); + it('gives a dense night code fuller dots', () => { expect(qrSvg(LINK, 3, true, 'night')).toContain('a0.42 0.42'); expect(qrSvg(KEY, 3, true, 'night')).toContain('a0.48 0.48'); diff --git a/web/tests/setup.test.ts b/web/tests/setup.test.ts index c2705a3..9f6042a 100644 --- a/web/tests/setup.test.ts +++ b/web/tests/setup.test.ts @@ -1,5 +1,6 @@ import { describe, expect, it } from 'vitest'; import { + addLink, appsFor, deviceNoun, importPath, @@ -7,14 +8,13 @@ import { inWebview, keyFileName, opensKeyLinks, - osGroup, platformOf, sameDevice, scanPath, setupFromHash, setupLink, storeFor, - updateLine, + wantsAdd, } from '../src/portal/setup'; const IPHONE = @@ -45,6 +45,14 @@ describe('setup', () => { expect(setupFromHash('#setup=../../api')).toBeNull(); }); + it('links to "Add a device" for the device itself, and reads only that back', () => { + const page = 'https://engage.example.eu:4500/abcdef-ghijkl-mnopqr'; + expect(addLink(page)).toBe(`${page}#add`); + expect(wantsAdd('#add')).toBe(true); + expect(wantsAdd('#add=1')).toBe(false); + expect(wantsAdd('')).toBe(false); + }); + it('names the device being set up by its kind, not its name', () => { expect(deviceNoun('phone')).toBe('phone'); expect(deviceNoun('computer')).toBe('computer'); @@ -60,20 +68,9 @@ describe('setup', () => { expect(sameDevice('phone', 'unknown')).toBe(false); }); - it('lets the person pick the system of a computer or an "other" device', () => { - expect(osGroup('computer')).toEqual(['windows', 'mac', 'linux']); - expect(osGroup('other')).toEqual(['ios', 'android', 'windows', 'mac', 'linux']); - expect(osGroup('phone')).toEqual([]); - expect(osGroup('router')).toEqual([]); - }); - it('lists the apps a disguise allows, AmneziaVPN first', () => { expect(appsFor('max').map((a) => a.id)).toEqual(['vpn', 'awg']); expect(appsFor('off').map((a) => a.id)).toEqual(['vpn', 'awg', 'wg']); - expect(appsFor('balanced')[0].need).toBe('4.8.12'); - expect(updateLine(appsFor('balanced')[0])).toContain('4.8.12 or newer'); - expect(updateLine(appsFor('max')[0])).toContain('the current version'); - expect(updateLine(appsFor('off')[0])).toBe(''); }); it('sends people to the store first and to GitHub where no store has the app', () => { diff --git a/web/tsup.config.ts b/web/tsup.config.ts index df9a49e..19e453d 100644 --- a/web/tsup.config.ts +++ b/web/tsup.config.ts @@ -1,5 +1,5 @@ import { defineConfig } from 'tsup'; -import { transform, type Plugin } from 'esbuild'; +import { build, transform, type Plugin } from 'esbuild'; import fs from 'node:fs'; import path from 'node:path'; @@ -33,6 +33,21 @@ async function minifyCss(css: string): Promise { return (await transform(css, { loader: 'css', minify: true, legalComments: 'none' })).code.trim(); } +/** The portal's stylesheet: its parts (src/portal/styles, joined by @import) as one minified file. */ +async function portalCss(): Promise { + const r = await build({ + entryPoints: ['src/portal/styles/index.css'], + bundle: true, + minify: true, + write: false, + legalComments: 'none', + // The fonts sit next to the stylesheet on the router: their URLs stay as written. + external: ['*.woff2'], + logLevel: 'silent', + }); + return r.outputFiles[0].text.trim(); +} + // The admin styles are plain .css files under src/admin/styles, imported as // text and joined in styles/index.ts (rendered inside each view): each is // minified here. They get a namespace (and a path not ending in .css) of @@ -97,7 +112,7 @@ export default defineConfig([ o.charset = 'utf8'; }, onSuccess: async () => { - fs.writeFileSync(path.join(PORTAL_OUT, 'portal.css'), (await minifyCss(fs.readFileSync('src/portal/portal.css', 'utf8'))) + '\n'); + fs.writeFileSync(path.join(PORTAL_OUT, 'portal.css'), (await portalCss()) + '\n'); fs.copyFileSync('src/portal/icon.svg', path.join(PORTAL_OUT, 'icon.svg')); for (const f of fs.readdirSync('src/portal/fonts')) fs.copyFileSync(path.join('src/portal/fonts', f), path.join(PORTAL_OUT, f)); },