From ae898a2787c473a4bfd5fc31113d52b02f7dddfc Mon Sep 17 00:00:00 2001 From: Lucio Chen Date: Wed, 4 Nov 2026 05:10:46 -0800 Subject: [PATCH] M7: hardening and final pass Co-Authored-By: Claude Opus 5.5 --- README.md | 6 +- docs/DESIGN.md | 14 +- internal/build/build.go | 22 ++- internal/process/processor.go | 11 +- internal/process/pyramid.go | 29 +++- internal/process/scramble.go | 213 +++++++++++++++++++++++++++++ internal/server/server.go | 30 +++- internal/site/site.go | 33 ++++- internal/site/static/app.css | 2 +- internal/site/static/app.js | 2 +- internal/site/static/worker.js | 2 +- internal/site/templates/404.html | 17 +++ internal/site/templates/album.html | 6 +- internal/site/templates/head.html | 4 + internal/site/templates/index.html | 10 +- packaging/Caddyfile | 10 +- packaging/nginx.conf | 9 ++ web/src/app.css | 71 ++++++++++ web/src/app.ts | 49 +++++-- web/src/cache.ts | 37 +++-- web/src/caption.ts | 20 ++- web/src/geometry.ts | 2 +- web/src/index.ts | 40 +++++- web/src/loader.ts | 54 ++++++-- web/src/scheduler.ts | 110 ++++++++++++--- web/src/scramble.ts | 65 +++++++++ web/src/strip.ts | 4 + web/src/types.ts | 3 + web/src/viewer.ts | 68 ++++++++- web/src/worker.ts | 42 +++++- 30 files changed, 878 insertions(+), 107 deletions(-) create mode 100644 internal/process/scramble.go create mode 100644 internal/site/templates/404.html create mode 100644 web/src/scramble.ts diff --git a/README.md b/README.md index bb14168..236df1f 100644 --- a/README.md +++ b/README.md @@ -86,7 +86,7 @@ Unknown fields are errors, so typos are caught. | `images.min_levels` | `6` | Minimum pyramid depth. | | `images.seed_px` | `48` | Long edge of the blurred placeholder. | | `images.tile_names` | `"hashed"` | Only `"hashed"` in v1. | -| `images.scramble_cells` | `false` | Reserved for M7. | +| `images.scramble_cells` | `false` | Shuffle the 64 px cells inside each tile with a per-photo key; the browser restores them when it decodes a tile. Forces tile overlap 0. Changing it reprocesses everything. | | `loading.budget_ms` | `3000` | Time budget per photo in the browser. | | `loading.max_dpr` | `2.0` | Highest device pixel ratio the loader honours. | | `loading.concurrency` | `6` | Parallel tile requests. | @@ -134,7 +134,7 @@ rsync writes to dotted temp names and renames at the end, which the watcher igno ## Web server -- **Serve mode**: LuPhoto serves `current` itself with the right headers (immutable caching for `/t/`, `/og/`, `/assets/`; one minute for HTML and JSON; CSP; hotlink 403 on `/t/*`; precompressed gzip; no directory listings). Put Caddy (`packaging/Caddyfile.serve`), nginx (`packaging/nginx.serve.conf`) or a Cloudflare Tunnel in front. +- **Serve mode**: LuPhoto serves `current` itself with the right headers (immutable caching for `/t/`, `/og/`, `/assets/`; one minute for HTML and JSON; CSP; hotlink 403 on `/t/*`; precompressed gzip; no directory listings; `404.html` for missing paths). Put Caddy (`packaging/Caddyfile.serve`), nginx (`packaging/nginx.serve.conf`) or a Cloudflare Tunnel in front. - **Export mode**: serve `/var/lib/luphoto/site/current` with `packaging/Caddyfile` or `packaging/nginx.conf`. Each build writes `.gz` files next to HTML, JSON, JS, CSS and SVG for `precompressed gzip` / `gzip_static`. - **Cloudflare**: `packaging/cloudflared.yml` and `packaging/cloudflare.md` (cache rules). @@ -173,7 +173,7 @@ This type-checks with `tsc --noEmit` (strict) and bundles with esbuild. Fonts ar /var/lib/luphoto/ site/ current -> builds/ - builds//index.html, index..json, a//index.html, a//manifest..json, assets/, t -> ../../t, og -> ../../og + builds//index.html, 404.html, index..json, a//index.html, a//manifest..json, assets/, t -> ../../t, og -> ../../og (plus .gz copies) t//.webp og/.jpg state/ diff --git a/docs/DESIGN.md b/docs/DESIGN.md index 0296547..ed3b724 100644 --- a/docs/DESIGN.md +++ b/docs/DESIGN.md @@ -11,7 +11,7 @@ uploads (rsync/SFTP) -> /srv/luphoto/albums -> watcher (debounce) -> processor ( -> serve mode (built-in HTTP) or export mode (folder for Caddy/nginx) -> Cloudflare Tunnel + cache -> browser canvas stitches visible tiles ``` -- Commands: `luphoto build` runs once; `luphoto serve` builds, watches and serves; `luphoto export` builds into the output folder and keeps watching. `-config` flag, default `/etc/luphoto/config.toml`. +- Commands: `luphoto build` runs once; `luphoto serve` builds, watches and serves; `luphoto export` builds into the output folder and keeps watching; `luphoto run` does `serve` or `export` as `server.mode` says (the systemd unit uses it); `luphoto version`. `-config` flag, default `/etc/luphoto/config.toml`. Rebuilds never overlap: changes during a build cause one follow-up build. - Tiling with libvips CLI (`vips`), installed by `apt install libvips-tools`. Support libvips 8.12 (Ubuntu 22.04) and 8.15 (Ubuntu 24.04): metadata stripping is `strip` on 8.12 and `keep=none` on 8.15+. - Front-end: plain TypeScript, no framework, bundled with esbuild, embedded in the binary with `go:embed`. Fixed Lucio brand. - Speed and memory matter: photos are processed in parallel by a bounded worker pool; hashing, EXIF reading and tile renaming run concurrently; the browser fetches tiles concurrently and decodes off the main thread. @@ -47,7 +47,7 @@ uploads (rsync/SFTP) -> /srv/luphoto/albums -> watcher (debounce) -> processor ( - `cover.crop` is `[x, y, w, h]` in original pixels; or `cover.focus_y` (0–1) picks a 32:9 band at full width. Default: first photo, focus_y 0.5. - `order` sorts ascending; albums without it sort newest `date` first, after ordered ones. `hidden: true` builds the album but leaves it off the index. - Album slug = folder name. Captions are plain text with `*emphasis*` and line breaks only. -- A broken album.json makes the build skip that album and log why; the previous build stays live. +- A broken album.json makes the build skip that album and log why; the previous build's version of that album stays live (it is carried into the new build). ## Processing each photo @@ -60,7 +60,7 @@ uploads (rsync/SFTP) -> /srv/luphoto/albums -> watcher (debounce) -> processor ( 7. Tile paths: `/t//.webp`. photo-hash = first 16 hex of SHA-256 over the original bytes + a processing-settings fingerprint. tile-id = first 16 hex of HMAC-SHA-256(site key, photo-hash|level|x|y). The site key is generated once and kept in the state folder. On disk and in developer tools the tiles are an unordered pile of patches; only the manifest maps them back. 8. Album manifest `/a//manifest..json`: per photo width, height, level sizes, tile grid per level, tile ids in row-major order per level, byte size of every tile, caption, title, alt, EXIF, slides, seed. Covers are pyramids too and are described in `/index..json`. -Incremental: a photo is reprocessed only when its photo-hash is new. Each build writes `builds//` (HTML, manifests, assets) next to a shared `t/` tile folder; the `current` symlink flips only when the build is complete. Keep the last `keep_builds` builds; delete tile folders no kept build references. Write everything to temporary names and rename, so readers never see partial files. +Incremental: a photo is reprocessed only when its photo-hash is new. Each build writes `builds//` (HTML, manifests, assets, `404.html`, and a `.gz` copy of every HTML, JSON, JS, CSS and SVG file for precompressed serving) next to a shared `t/` tile folder and a shared `og/` folder of 1200×630 Open Graph JPEGs cut around each album cover (the only non-tiled images; derived, small, metadata stripped); the `current` symlink flips only when the build is complete. Keep the last `keep_builds` builds; delete tile folders no kept build references. Write everything to temporary names and rename, so readers never see partial files. Storage: about 1.33× the top level, roughly 6–10 MB of tiles per Z8 photo. @@ -77,7 +77,7 @@ Moving to another photo aborts that photo's requests. Prefetch the next photo's ## Screens -Album index: full-width strips, 8 px apart on phones, 16 px on desktop. Header with the Lucio wordmark (Guoliang → Lucio morph on hover, the only animation on this screen); footer with the chop. Closed strip 32:6 showing the `collapsed_focus_y` band of the 32:9 cover, height `min(100vw*6/32, 28vh)`; open 32:9, height `min(100vw*9/32, 62vh)`; wider screens crop left/right, never stretch. Desktop: hover opens. Touch: the strip nearest the vertical centre opens while scrolling; tap enters. On open the height animates 240 ms, then the title fades in (light-on): mono date line, then the title in Bricolage Grotesque, bottom-left. Covers use the tile loader; closed strips load only the visible band; only strips near the viewport load. +Album index: full-width strips, 8 px apart on phones, 16 px on desktop. Header with the Lucio wordmark (Guoliang → Lucio morph on hover, the only animation on this screen); footer with the chop. Closed strip 32:6 showing the `collapsed_focus_y` band of the 32:9 cover, height `min(100vw*6/32, 28vh)`; open 32:9, height `min(100vw*9/32, 62vh)`; the cover is drawn cover-fit, never stretched (under the height caps a very wide screen crops top and bottom). Desktop: hover opens. Touch: the strip nearest the vertical centre opens while scrolling; tap enters. On open the height animates 240 ms, then the title fades in (light-on): mono date line, then the title in Bricolage Grotesque, bottom-left. Covers use the tile loader; closed strips load only the visible band; only strips near the viewport load. Album viewer: one photo at a time, contained in the viewport (fills height or width, never stretched), centred on graphite. Swipe right-to-left, ←/→, click-and-drag; one pointer-events handler for mouse and touch with flick velocity and rubber-band ends; Home/End; Esc returns to the index. `slides: N`: the photo is scaled so a 1/N-wide section fits the viewport; moving between its slides is a continuous pan. `/a//#7` opens photo 7. End card: chop, "— Lucio", the next album's strip. Reduced motion: crossfades. @@ -87,7 +87,7 @@ Lucio brand (source of truth: ../LUCIO_ip): graphite #111114 ground, paper #F3F1 ## Discouraging saves -No `` for photos, only canvas. Output never contains an original. Right-click, drag, selection and long-press callouts are disabled. Hashed tile names (above). Optional `scramble_cells` (off): shuffle 64 px cells inside each tile with a per-photo key and reorder when drawing. Hotlink: Referer check on `/t/*` in the built-in server and the Caddy/nginx examples. +No `` for photos, only canvas. Output never contains an original. Right-click, drag, selection and long-press callouts are disabled. Hashed tile names (above). Optional `scramble_cells` (off): shuffle the full 64 px cells inside each tile with a per-photo key (HMAC of the site key and photo-hash, then a seeded Fisher–Yates per tile; tile overlap is 0 when on); the client restores each tile once when it decodes it, before it is cached and drawn. Hotlink: Referer check on `/t/*` in the built-in server and the Caddy/nginx examples; an empty Referer and the site's own host are allowed. ## Config `/etc/luphoto/config.toml` @@ -128,14 +128,14 @@ block_context_menu = true hotlink_allow = ["photos.luciochen.com"] ``` -Defaults when a path is missing: running as root or under systemd uses `/var/lib/luphoto/site` and `/var/cache/luphoto`; otherwise `$XDG_DATA_HOME/luphoto/site` and `$XDG_CACHE_HOME/luphoto` (Go `os.UserCacheDir` equivalents). The site key lives in the state folder next to the output. SIGHUP re-reads the config and rebuilds. The watcher ignores `.part`, `.tmp`, dotfiles and rsync temp names. +Defaults when a path is missing: running as root or under systemd uses `/var/lib/luphoto/site` and `/var/cache/luphoto`; otherwise `$XDG_DATA_HOME/luphoto/site` and `$XDG_CACHE_HOME/luphoto` (Go `os.UserCacheDir` equivalents). The site key and the per-photo processing records live in the state folder (`state/`) next to the output. SIGHUP re-reads the config and rebuilds. The watcher ignores `.part`, `.tmp`, dotfiles and rsync temp names. ## Deployment - `.deb` via nfpm: binary, `/etc/luphoto/config.toml`, systemd unit, `luphoto` user, `/srv/luphoto/albums`. Depends on `libvips-tools`. Ubuntu 22.04/24.04, Debian 12; other distros: tarball + unit file. - systemd: read-only albums, read-write output and cache only, NoNewPrivileges, ProtectSystem=strict. - Cloudflare Tunnel; cache rule `/t/*` for a month; HTML and manifests short TTL; manifests are build-named, so no purging. -- Caddy (export): root `/var/lib/luphoto/site/current`, `/t/*` `public, max-age=31536000, immutable`, `/a/*` `max-age=60`, CSP `default-src 'self'; img-src 'self' blob: data:; frame-ancestors 'none'`, hotlink 403 on `/t/*`. Serve mode: `reverse_proxy 127.0.0.1:8080`, the built-in server sends the same headers. nginx equivalent provided. +- Caddy (export): root `/var/lib/luphoto/site/current`, `/t/*` `public, max-age=31536000, immutable`, `/a/*` `max-age=60`, `/og/*` and `/assets/*` immutable too, HTML and index JSON `max-age=60`, CSP `default-src 'self'; img-src 'self' blob: data:; font-src 'self'; worker-src 'self'; frame-ancestors 'none'`, `nosniff`, `Referrer-Policy: strict-origin-when-cross-origin`, hotlink 403 on `/t/*`, precompressed gzip, no directory listings, `404.html` for missing paths, GET/HEAD only. Serve mode: `reverse_proxy 127.0.0.1:8080`, the built-in server sends the same headers. nginx equivalent provided. ## Milestones diff --git a/internal/build/build.go b/internal/build/build.go index af3935f..b5783a5 100644 --- a/internal/build/build.go +++ b/internal/build/build.go @@ -337,13 +337,25 @@ func coverCrop(c *album.Cover, width, height int) ([4]int, error) { return [4]int{x, y, max(1, w), max(1, h)}, nil } +func (b *builder) overlap() int { + if b.cfg.Images.ScrambleCells { + return 0 + } + return b.cfg.Images.Overlap +} + func (b *builder) tiles() site.Tiles { - return site.Tiles{ + tiles := site.Tiles{ Format: b.cfg.Images.Format, TileSize: b.cfg.Images.TileSize, - Overlap: b.cfg.Images.Overlap, + Overlap: b.overlap(), Path: "/t/", } + if b.cfg.Images.ScrambleCells { + tiles.Scrambled = true + tiles.Cell = process.ScrambleCell + } + return tiles } func (b *builder) manifest(id string, plan *albumPlan, records map[string]*process.Record) *site.Manifest { @@ -507,6 +519,12 @@ func (b *builder) writeBuild(id string, manifests []*site.Manifest) error { if err == nil { err = fsutil.WritePublicAtomic(filepath.Join(stage, "index.html"), html) } + if err == nil { + html, err = fsutil.Render(func(w io.Writer) error { return site.RenderNotFound(w, id, page) }) + } + if err == nil { + err = fsutil.WritePublicAtomic(filepath.Join(stage, "404.html"), html) + } errs[len(manifests)] = err }() wg.Wait() diff --git a/internal/process/processor.go b/internal/process/processor.go index 0172aa2..c380877 100644 --- a/internal/process/processor.go +++ b/internal/process/processor.go @@ -34,11 +34,12 @@ type Level struct { } type Pyramid struct { - Hash string `json:"hash"` - Width int `json:"width"` - Height int `json:"height"` - Levels []Level `json:"levels"` - Seed string `json:"seed"` + Hash string `json:"hash"` + Width int `json:"width"` + Height int `json:"height"` + Levels []Level `json:"levels"` + Seed string `json:"seed"` + Scramble string `json:"scramble,omitempty"` } type Record struct { diff --git a/internal/process/pyramid.go b/internal/process/pyramid.go index b7ad99b..fac2331 100644 --- a/internal/process/pyramid.go +++ b/internal/process/pyramid.go @@ -22,6 +22,13 @@ import ( const minLongEdge = 100 +func (p *Processor) Overlap() int { + if p.images.ScrambleCells { + return 0 + } + return p.images.Overlap +} + func LevelSizes(width, height, minLevels int) [][2]int { sizes := [][2]int{{width, height}} for { @@ -155,6 +162,10 @@ func (p *Processor) process(ctx context.Context, job *Job) (*Record, error) { } } + scrambleSeed := "" + if p.images.ScrambleCells { + scrambleSeed = p.ScrambleSeed(job.Hash) + } levels := make([]Level, count) var seed string var firstErr error @@ -188,7 +199,17 @@ func (p *Processor) process(ctx context.Context, job *Job) (*Record, error) { go func(i int, src *refFile) { defer wg.Done() defer src.release() - level, err := p.cutLevel(ctx, job.Hash, src.path, stage, i, count, sizes[i]) + input := src.path + if p.images.ScrambleCells { + scrambled := filepath.Join(work, "s"+strconv.Itoa(i)+".v") + if err := ScrambleV(src.path, scrambled, scrambleSeed, i, p.images.TileSize, ScrambleCell); err != nil { + fail(fmt.Errorf("scramble level %d: %w", i, err)) + return + } + defer os.Remove(scrambled) + input = scrambled + } + level, err := p.cutLevel(ctx, job.Hash, input, stage, i, count, sizes[i]) if err != nil { fail(fmt.Errorf("level %d: %w", i, err)) return @@ -236,11 +257,11 @@ func (p *Processor) process(ctx context.Context, job *Job) (*Record, error) { committed = true rec := &Record{ - Pyramid: Pyramid{Hash: job.Hash, Width: width, Height: height, Levels: levels, Seed: seed}, + Pyramid: Pyramid{Hash: job.Hash, Width: width, Height: height, Levels: levels, Seed: seed, Scramble: scrambleSeed}, Kind: job.Kind, Format: p.images.Format, TileSize: p.images.TileSize, - Overlap: p.images.Overlap, + Overlap: p.Overlap(), Processed: time.Now().UTC().Truncate(time.Second), } if job.Kind == "photo" { @@ -351,7 +372,7 @@ func (p *Processor) cutLevel(ctx context.Context, hash, src, stage string, level "--layout", "dz", "--depth", "one", "--tile-size", strconv.Itoa(p.images.TileSize), - "--overlap", strconv.Itoa(p.images.Overlap), + "--overlap", strconv.Itoa(p.Overlap()), "--suffix", ext+p.vips.SaveOptions(quality)); err != nil { return Level{}, err } diff --git a/internal/process/scramble.go b/internal/process/scramble.go new file mode 100644 index 0000000..1152a2d --- /dev/null +++ b/internal/process/scramble.go @@ -0,0 +1,213 @@ +package process + +import ( + "crypto/hmac" + "crypto/sha256" + "encoding/binary" + "encoding/hex" + "errors" + "fmt" + "io" + "os" + "strconv" + "sync" +) + +const ( + ScrambleCell = 64 + scrambleWorkers = 2 + vipsHeaderSize = 64 +) + +var bandFormatSize = map[int32]int{0: 1, 1: 1, 2: 2, 3: 2, 4: 4, 5: 4, 6: 4, 7: 8, 8: 8, 9: 16} + +func (p *Processor) ScrambleSeed(hash string) string { + mac := hmac.New(sha256.New, p.key) + mac.Write([]byte("scramble|" + hash)) + return hex.EncodeToString(mac.Sum(nil))[:16] +} + +func tileSeed(seed string, level, x, y int) uint32 { + h := uint32(2166136261) + for _, c := range []byte(seed + "|" + strconv.Itoa(level) + "|" + strconv.Itoa(x) + "|" + strconv.Itoa(y)) { + h ^= uint32(c) + h *= 16777619 + } + return h +} + +type mulberry32 struct { + state uint32 +} + +func (m *mulberry32) next() float64 { + m.state += 0x6D2B79F5 + a := m.state + t := (a ^ (a >> 15)) * (a | 1) + t = (t + (t^(t>>7))*(t|61)) ^ t + return float64(t^(t>>14)) / 4294967296 +} + +func CellPermutation(n int, seed uint32) []int { + perm := make([]int, n) + for i := range perm { + perm[i] = i + } + rng := mulberry32{state: seed} + for i := n - 1; i > 0; i-- { + j := int(rng.next() * float64(i+1)) + perm[i], perm[j] = perm[j], perm[i] + } + return perm +} + +type vHeader struct { + width, height int + pixelBytes int +} + +func readVHeader(f *os.File) (vHeader, error) { + var raw [vipsHeaderSize]byte + if _, err := io.ReadFull(io.NewSectionReader(f, 0, vipsHeaderSize), raw[:]); err != nil { + return vHeader{}, err + } + var order binary.ByteOrder + switch { + case raw[0] == vipsMagicIntel[0] && raw[1] == vipsMagicIntel[1] && raw[2] == vipsMagicIntel[2] && raw[3] == vipsMagicIntel[3]: + order = binary.LittleEndian + case raw[0] == vipsMagicSparc[0] && raw[1] == vipsMagicSparc[1] && raw[2] == vipsMagicSparc[2] && raw[3] == vipsMagicSparc[3]: + order = binary.BigEndian + default: + return vHeader{}, errors.New("not a vips image") + } + width := int(int32(order.Uint32(raw[4:8]))) + height := int(int32(order.Uint32(raw[8:12]))) + bands := int(int32(order.Uint32(raw[12:16]))) + format := int32(order.Uint32(raw[20:24])) + coding := int32(order.Uint32(raw[24:28])) + size, ok := bandFormatSize[format] + if !ok || coding != 0 || width <= 0 || height <= 0 || bands <= 0 { + return vHeader{}, fmt.Errorf("unsupported vips image (format %d, coding %d)", format, coding) + } + return vHeader{width: width, height: height, pixelBytes: bands * size}, nil +} + +func ScrambleV(src, dst, seed string, level, tileSize, cell int) error { + in, err := os.Open(src) + if err != nil { + return err + } + defer in.Close() + header, err := readVHeader(in) + if err != nil { + return fmt.Errorf("%s: %w", src, err) + } + out, err := os.Create(dst) + if err != nil { + return err + } + ok := false + defer func() { + out.Close() + if !ok { + os.Remove(dst) + } + }() + if _, err := io.Copy(out, io.NewSectionReader(in, 0, vipsHeaderSize)); err != nil { + return err + } + rowBytes := int64(header.width) * int64(header.pixelBytes) + dataEnd := vipsHeaderSize + rowBytes*int64(header.height) + bands := (header.height + tileSize - 1) / tileSize + jobs := make(chan int) + errs := make([]error, scrambleWorkers) + var wg sync.WaitGroup + for w := 0; w < min(scrambleWorkers, bands); w++ { + wg.Add(1) + go func(w int) { + defer wg.Done() + buf := make([]byte, int64(min(tileSize, header.height))*rowBytes) + tmp := make([]byte, cell*cell*header.pixelBytes) + for band := range jobs { + if errs[w] != nil { + continue + } + errs[w] = scrambleBand(in, out, buf, tmp, header, band, rowBytes, seed, level, tileSize, cell) + } + }(w) + } + for band := 0; band < bands; band++ { + jobs <- band + } + close(jobs) + wg.Wait() + if err := errors.Join(errs...); err != nil { + return err + } + info, err := in.Stat() + if err != nil { + return err + } + if info.Size() > dataEnd { + if _, err := io.Copy(io.NewOffsetWriter(out, dataEnd), io.NewSectionReader(in, dataEnd, info.Size()-dataEnd)); err != nil { + return err + } + } + ok = true + return nil +} + +func scrambleBand(in, out *os.File, buf, tmp []byte, header vHeader, band int, rowBytes int64, seed string, level, tileSize, cell int) error { + top := band * tileSize + rows := min(tileSize, header.height-top) + data := buf[:int64(rows)*rowBytes] + offset := vipsHeaderSize + int64(top)*rowBytes + if _, err := in.ReadAt(data, offset); err != nil { + return err + } + cellRows := rows / cell + cellBytes := cell * header.pixelBytes + tiles := (header.width + tileSize - 1) / tileSize + for tx := 0; tx < tiles; tx++ { + width := min(tileSize, header.width-tx*tileSize) + cols := width / cell + n := cols * cellRows + if n < 2 { + continue + } + perm := CellPermutation(n, tileSeed(seed, level, tx, band)) + origin := tx * tileSize * header.pixelBytes + at := func(index, row int) []byte { + cy, cx := index/cols, index%cols + start := int64(cy*cell+row)*rowBytes + int64(origin+cx*cellBytes) + return data[start : start+int64(cellBytes)] + } + done := make([]bool, n) + for start := 0; start < n; start++ { + if done[start] || perm[start] == start { + done[start] = true + continue + } + for r := 0; r < cell; r++ { + copy(tmp[r*cellBytes:(r+1)*cellBytes], at(start, r)) + } + i := start + for { + done[i] = true + j := perm[i] + if j == start { + for r := 0; r < cell; r++ { + copy(at(i, r), tmp[r*cellBytes:(r+1)*cellBytes]) + } + break + } + for r := 0; r < cell; r++ { + copy(at(i, r), at(j, r)) + } + i = j + } + } + } + _, err := out.WriteAt(data, offset) + return err +} diff --git a/internal/server/server.go b/internal/server/server.go index 16dd07d..d9e4029 100644 --- a/internal/server/server.go +++ b/internal/server/server.go @@ -79,10 +79,6 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { } settings := h.settings.Load() clean := path.Clean("/" + r.URL.Path) - if !visible(clean) { - http.NotFound(w, r) - return - } if strings.HasPrefix(clean, "/t/") && hotlinked(r, settings.HotlinkAllow) { http.Error(w, "forbidden", http.StatusForbidden) return @@ -92,17 +88,21 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { http.Error(w, "no build published yet", http.StatusServiceUnavailable) return } + if !visible(clean) { + notFound(w, r, root) + return + } name := filepath.Join(root, filepath.FromSlash(clean)) info, err := os.Stat(name) if err != nil { - http.NotFound(w, r) + notFound(w, r, root) return } if info.IsDir() { index := filepath.Join(name, "index.html") indexInfo, err := os.Stat(index) if err != nil || !indexInfo.Mode().IsRegular() { - http.NotFound(w, r) + notFound(w, r, root) return } if !strings.HasSuffix(r.URL.Path, "/") { @@ -119,12 +119,28 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { name, info, clean = index, indexInfo, path.Join(clean, "index.html") } if !info.Mode().IsRegular() { - http.NotFound(w, r) + notFound(w, r, root) return } serveFile(w, r, clean, name, info) } +func notFound(w http.ResponseWriter, r *http.Request, root string) { + page, err := os.ReadFile(filepath.Join(root, "404.html")) + if err != nil { + http.NotFound(w, r) + return + } + header := w.Header() + header.Set("Content-Type", contentTypes[".html"]) + header.Set("Cache-Control", cacheShort) + header.Set("Content-Length", strconv.Itoa(len(page))) + w.WriteHeader(http.StatusNotFound) + if r.Method != http.MethodHead { + _, _ = w.Write(page) + } +} + func visible(clean string) bool { for _, part := range strings.Split(clean, "/") { if strings.HasPrefix(part, ".") { diff --git a/internal/site/site.go b/internal/site/site.go index 3db7797..8e5c360 100644 --- a/internal/site/site.go +++ b/internal/site/site.go @@ -6,6 +6,7 @@ import ( "html/template" "io" "net/url" + "unicode" "github.com/luciochen233/luphoto/internal/process" ) @@ -13,7 +14,16 @@ import ( //go:embed templates/*.html var templateFiles embed.FS -var templates = template.Must(template.ParseFS(templateFiles, "templates/*.html")) +var templates = template.Must(template.New("site").Funcs(template.FuncMap{"lang": Lang}).ParseFS(templateFiles, "templates/*.html")) + +func Lang(text string) string { + for _, r := range text { + if unicode.Is(unicode.Han, r) { + return "zh" + } + } + return "" +} const ( SiteName = "Photos · Lucio" @@ -21,10 +31,12 @@ const ( ) type Tiles struct { - Format string `json:"format"` - TileSize int `json:"tile_size"` - Overlap int `json:"overlap"` - Path string `json:"path"` + Format string `json:"format"` + TileSize int `json:"tile_size"` + Overlap int `json:"overlap"` + Path string `json:"path"` + Scrambled bool `json:"scrambled,omitempty"` + Cell int `json:"cell,omitempty"` } type Photo struct { @@ -184,3 +196,14 @@ func RenderAlbum(w io.Writer, m *Manifest, page Page) error { ManifestURL: ManifestURL(m.Build, m.Slug), }) } + +func RenderNotFound(w io.Writer, build string, page Page) error { + return templates.ExecuteTemplate(w, "404.html", head{ + Page: page, + Build: build, + Title: "Not found · Lucio", + Description: SiteDescription, + Path: "/404.html", + IndexURL: IndexURL(build), + }) +} diff --git a/internal/site/static/app.css b/internal/site/static/app.css index af3a63f..7e62e67 100644 --- a/internal/site/static/app.css +++ b/internal/site/static/app.css @@ -1 +1 @@ -:root{--lucio-graphite: #111114;--lucio-graphite-2: #1A1A1F;--lucio-graphite-3: #26262D;--lucio-paper: #F3F1EC;--lucio-paper-2: #E9E6DF;--lucio-paper-3: #D9D6CD;--lucio-beam: #FFF3CF;--lucio-beam-deep: #5E5238;--lucio-beam-glow: #FFFBF0;--lucio-steel: #8A94A6;--lucio-steel-deep: #3F4B60;--lucio-cinnabar: #C3361F;--lucio-cinnabar-light: #F08A77;--lucio-ash: #666A74;--lucio-ash-dark: #43464F;--lucio-ash-light: #A6A9B3;--lucio-font-display: "Bricolage Grotesque", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;--lucio-font-body: "IBM Plex Sans", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;--lucio-font-mono: "IBM Plex Mono", "JetBrains Mono", ui-monospace, "Cascadia Code", Consolas, monospace;--lucio-font-cjk-display: "Noto Serif SC", "Songti SC", "SimSun", serif;--lucio-font-cjk-body: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;--lucio-space-1: 4px;--lucio-space-2: 8px;--lucio-space-3: 12px;--lucio-space-4: 16px;--lucio-space-5: 24px;--lucio-space-6: 32px;--lucio-space-7: 48px;--lucio-space-8: 64px;--lucio-space-9: 96px;--lucio-space-10: 128px;--lucio-radius-none: 0px;--lucio-radius-sm: 4px;--lucio-radius-md: 8px;--lucio-radius-lg: 16px;--lucio-radius-icon: 22%;--lucio-shadow-glow: 0 0 0 1px rgba(255,243,207,.3), 0 8px 32px -8px rgba(255,243,207,.35);--lucio-motion-fast: .12s;--lucio-ease-fast: cubic-bezier(.2, 0, 0, 1);--lucio-motion-base: .24s;--lucio-ease-base: cubic-bezier(.2, 0, 0, 1);--lucio-motion-glow: .9s;--lucio-ease-glow: cubic-bezier(.16, 1, .3, 1)}@font-face{font-family:Bricolage Grotesque;font-style:normal;font-weight:200 800;font-display:swap;src:url("./bricolage-grotesque-latin-ext-wght-normal.EMW626ZA.woff2") format("woff2-variations");unicode-range:U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF}@font-face{font-family:Bricolage Grotesque;font-style:normal;font-weight:200 800;font-display:swap;src:url("./bricolage-grotesque-latin-wght-normal.HY2A4V5R.woff2") format("woff2-variations");unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD}@font-face{font-family:IBM Plex Sans;font-style:normal;font-weight:400;font-display:swap;src:url("./ibm-plex-sans-latin-ext-400-normal.EDOVP6TU.woff2") format("woff2");unicode-range:U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF}@font-face{font-family:IBM Plex Sans;font-style:normal;font-weight:400;font-display:swap;src:url("./ibm-plex-sans-latin-400-normal.COQVXTP6.woff2") format("woff2");unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD}@font-face{font-family:IBM Plex Sans;font-style:normal;font-weight:500;font-display:swap;src:url("./ibm-plex-sans-latin-ext-500-normal.SG2XNXKB.woff2") format("woff2");unicode-range:U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF}@font-face{font-family:IBM Plex Sans;font-style:normal;font-weight:500;font-display:swap;src:url("./ibm-plex-sans-latin-500-normal.JTONHBWS.woff2") format("woff2");unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD}@font-face{font-family:IBM Plex Sans;font-style:normal;font-weight:600;font-display:swap;src:url("./ibm-plex-sans-latin-ext-600-normal.ZNWKNRXL.woff2") format("woff2");unicode-range:U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF}@font-face{font-family:IBM Plex Sans;font-style:normal;font-weight:600;font-display:swap;src:url("./ibm-plex-sans-latin-600-normal.DTNZULF4.woff2") format("woff2");unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD}@font-face{font-family:IBM Plex Sans;font-style:italic;font-weight:400;font-display:swap;src:url("./ibm-plex-sans-latin-ext-400-italic.VMPJJ47P.woff2") format("woff2");unicode-range:U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF}@font-face{font-family:IBM Plex Sans;font-style:italic;font-weight:400;font-display:swap;src:url("./ibm-plex-sans-latin-400-italic.PR7YQ55B.woff2") format("woff2");unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD}@font-face{font-family:IBM Plex Mono;font-style:normal;font-weight:400;font-display:swap;src:url("./ibm-plex-mono-latin-ext-400-normal.T6XOR2FX.woff2") format("woff2");unicode-range:U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF}@font-face{font-family:IBM Plex Mono;font-style:normal;font-weight:400;font-display:swap;src:url("./ibm-plex-mono-latin-400-normal.A2WATXFY.woff2") format("woff2");unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD}@font-face{font-family:IBM Plex Mono;font-style:normal;font-weight:500;font-display:swap;src:url("./ibm-plex-mono-latin-ext-500-normal.LJE4XY22.woff2") format("woff2");unicode-range:U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF}@font-face{font-family:IBM Plex Mono;font-style:normal;font-weight:500;font-display:swap;src:url("./ibm-plex-mono-latin-500-normal.33HAQIPI.woff2") format("woff2");unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD}:root{color-scheme:dark;--strip-closed: min( 18.75vw , 28vh);--strip-open: min( 28.125vw , 62vh);--strip-gap: var(--lucio-space-2);--gutter: var(--lucio-space-4);--veil: rgba(17, 17, 20, .78)}@media (min-width: 768px){:root{--strip-gap: var(--lucio-space-4);--gutter: var(--lucio-space-6)}}html,body{margin:0;min-height:100%;background:var(--lucio-graphite);color:var(--lucio-paper);font-family:var(--lucio-font-body);font-size:17px;line-height:1.6;-webkit-font-smoothing:antialiased;text-rendering:optimizeLegibility}a{color:var(--lucio-paper);text-decoration-color:var(--lucio-ash-light);text-underline-offset:.15em}::selection{background:var(--lucio-graphite-3);color:var(--lucio-paper)}:focus-visible{outline:2px solid var(--lucio-beam);outline-offset:2px}.visually-hidden{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0}.strip-eyebrow,.next-eyebrow{font-family:var(--lucio-font-mono);font-size:12px;line-height:1.4;font-weight:500;letter-spacing:.08em;text-transform:uppercase;color:var(--lucio-ash-light)}.wordmark,.home-mark{display:block;color:var(--lucio-paper);text-decoration:none}.wordmark-text{font-family:var(--lucio-font-display);font-weight:700;font-size:28px;line-height:1;letter-spacing:-.01em}.has-svg .wordmark-text{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0)}.wordmark-svg{display:block;width:100%}.chop{display:block;width:clamp(28px,7vmin,72px);flex:none}.chop svg{display:block;width:100%;height:auto}.site-header{padding:var(--lucio-space-5) var(--gutter)}.site-header .wordmark{width:128px}.strips{display:flex;flex-direction:column;gap:var(--strip-gap)}.strip{position:relative;display:block;height:var(--strip-closed);overflow:hidden;background:var(--lucio-graphite-2);color:var(--lucio-paper);text-decoration:none;-webkit-touch-callout:none;-webkit-tap-highlight-color:transparent;user-select:none;-webkit-user-select:none;transition:height var(--lucio-motion-base) var(--lucio-ease-base)}.strip.is-open{height:var(--strip-open)}.strip:focus-visible{outline:2px solid var(--lucio-beam);outline-offset:-2px;box-shadow:var(--lucio-shadow-glow)}.strip-canvas{position:absolute;top:0;left:0;width:100%;display:block;will-change:transform;transition:transform var(--lucio-motion-base) var(--lucio-ease-base)}.strip:after{content:"";position:absolute;inset:0;background:linear-gradient(to top,var(--veil) 0%,rgba(17,17,20,.3) 40%,rgba(17,17,20,0) 68%);opacity:0;pointer-events:none;transition:opacity var(--lucio-motion-fast) var(--lucio-ease-fast)}.strip-text{position:absolute;left:var(--gutter);right:var(--gutter);bottom:var(--lucio-space-5);z-index:1;display:flex;flex-direction:column;gap:var(--lucio-space-1);max-width:68ch}.strip-eyebrow,.strip-title,.strip-subtitle{opacity:0;transition:opacity var(--lucio-motion-fast) var(--lucio-ease-fast)}.strip-title{font-family:var(--lucio-font-display);font-weight:600;font-size:clamp(22px,2.6vw,36px);line-height:1.15;letter-spacing:-.015em}.strip-subtitle{font-size:14px;line-height:1.5;color:var(--lucio-ash-light)}.strip.is-open:after,.strip.is-open .strip-eyebrow,.strip.is-open .strip-title,.strip.is-open .strip-subtitle{opacity:1;transition:opacity var(--lucio-motion-glow) var(--lucio-ease-glow) var(--lucio-motion-base)}.strip.is-open .strip-title{transition-delay:calc(var(--lucio-motion-base) + var(--lucio-motion-fast))}.strip.is-open .strip-subtitle{transition-delay:calc(var(--lucio-motion-base) + var(--lucio-motion-fast) * 2)}html:not(.has-strips) .strip:after,html:not(.has-strips) .strip-eyebrow,html:not(.has-strips) .strip-title,html:not(.has-strips) .strip-subtitle{opacity:1}.empty{margin:0;padding:var(--lucio-space-9) var(--gutter);color:var(--lucio-ash-light)}.site-footer{display:flex;align-items:flex-end;justify-content:space-between;gap:var(--lucio-space-4);padding:var(--lucio-space-7) var(--gutter) var(--lucio-space-6)}.footer-line{margin:0;font-size:14px;line-height:1.5;color:var(--lucio-ash-light)}.busy{position:fixed;top:50%;right:max(var(--lucio-space-6),calc(env(safe-area-inset-right) + var(--lucio-space-6)));width:56px;height:56px;margin-top:-28px;z-index:5;opacity:0;pointer-events:none;transition:opacity var(--lucio-motion-base) var(--lucio-ease-base)}.busy.is-visible{opacity:1}.busy svg{display:block}.progress{position:fixed;top:0;left:0;width:100%;height:2px;z-index:6;background:var(--lucio-beam);transform:scaleX(0);transform-origin:0 50%;opacity:0;pointer-events:none;transition:transform var(--lucio-motion-base) var(--lucio-ease-base),opacity var(--lucio-motion-base) var(--lucio-ease-base)}.progress.is-visible{opacity:1}.has-viewer body.viewer{position:fixed;inset:0;overflow:hidden;overscroll-behavior:none}.album-fallback{padding:var(--lucio-space-7) var(--gutter)}.has-viewer .album-fallback{display:none}.home-mark{position:fixed;top:max(var(--lucio-space-5),env(safe-area-inset-top));left:max(var(--lucio-space-5),env(safe-area-inset-left));z-index:4;width:88px;transition:opacity var(--lucio-motion-base) var(--lucio-ease-base)}.is-idle:not(.has-caption) .home-mark:not(:focus-visible){opacity:0}.stage{overflow:hidden;background:var(--lucio-graphite);touch-action:none;user-select:none;-webkit-user-select:none;-webkit-touch-callout:none;-webkit-tap-highlight-color:transparent;cursor:grab}.has-viewer .stage{position:fixed;inset:0}.stage.is-dragging{cursor:grabbing}.stage-canvas,.stage-fade{position:absolute;inset:0;width:100%;height:100%;display:block}.stage-fade{pointer-events:none;opacity:0;transition:opacity var(--lucio-motion-base) var(--lucio-ease-glow)}.caption{position:absolute;left:0;bottom:0;box-sizing:border-box;max-height:60%;overflow:hidden;padding:var(--lucio-space-8) var(--lucio-space-5) var(--lucio-space-5);background:linear-gradient(to top,#111114e6,#1111149e 55%,#11111400);opacity:0;pointer-events:none;transition:opacity var(--lucio-motion-base) var(--lucio-ease-base)}.caption.is-visible{opacity:1}.caption-meta{margin:0;font-family:var(--lucio-font-mono);font-size:12px;line-height:1.4;letter-spacing:.04em;color:var(--lucio-steel);font-variant-numeric:tabular-nums}.caption-title{margin:var(--lucio-space-2) 0 0;font-family:var(--lucio-font-display);font-size:22px;font-weight:600;line-height:1.2;letter-spacing:-.01em}.caption-text{margin:var(--lucio-space-2) 0 0;max-width:68ch;font-size:14px;line-height:1.5}.caption-text em{font-style:italic}.end-card{position:absolute;top:0;left:0;height:100%;display:flex;align-items:center;justify-content:center;will-change:transform}.next-album{display:block;color:var(--lucio-paper);text-decoration:none}.next-strip{position:relative;display:block;overflow:hidden}.next-album.has-strip .next-strip{background:var(--lucio-graphite-2)}.next-album.has-strip .next-strip:after{content:"";position:absolute;inset:0;background:linear-gradient(to top,var(--veil) 0%,rgba(17,17,20,0) 65%);pointer-events:none}.next-text{display:flex;flex-direction:column;gap:var(--lucio-space-1)}.next-album.has-strip .next-text{position:absolute;left:var(--lucio-space-5);bottom:var(--lucio-space-4);z-index:1}.next-title{font-family:var(--lucio-font-display);font-size:24px;font-weight:600;line-height:1.2;letter-spacing:-.01em}.next-album:hover .next-title{text-decoration:underline;text-decoration-color:var(--lucio-ash-light);text-underline-offset:.15em}.next-album:focus-visible{outline-offset:4px;box-shadow:var(--lucio-shadow-glow)}.signoff{position:absolute;right:var(--lucio-space-6);bottom:var(--lucio-space-6);display:flex;flex-direction:column;align-items:flex-end;gap:var(--lucio-space-2)}.signature{margin:0;font-family:var(--lucio-font-display);font-size:20px;font-weight:600;line-height:1.2}@media (prefers-reduced-motion: reduce){*,*:before,*:after{transition-duration:0ms!important;transition-delay:0ms!important;animation-duration:0ms!important}} +:root{--lucio-graphite: #111114;--lucio-graphite-2: #1A1A1F;--lucio-graphite-3: #26262D;--lucio-paper: #F3F1EC;--lucio-paper-2: #E9E6DF;--lucio-paper-3: #D9D6CD;--lucio-beam: #FFF3CF;--lucio-beam-deep: #5E5238;--lucio-beam-glow: #FFFBF0;--lucio-steel: #8A94A6;--lucio-steel-deep: #3F4B60;--lucio-cinnabar: #C3361F;--lucio-cinnabar-light: #F08A77;--lucio-ash: #666A74;--lucio-ash-dark: #43464F;--lucio-ash-light: #A6A9B3;--lucio-font-display: "Bricolage Grotesque", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;--lucio-font-body: "IBM Plex Sans", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;--lucio-font-mono: "IBM Plex Mono", "JetBrains Mono", ui-monospace, "Cascadia Code", Consolas, monospace;--lucio-font-cjk-display: "Noto Serif SC", "Songti SC", "SimSun", serif;--lucio-font-cjk-body: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;--lucio-space-1: 4px;--lucio-space-2: 8px;--lucio-space-3: 12px;--lucio-space-4: 16px;--lucio-space-5: 24px;--lucio-space-6: 32px;--lucio-space-7: 48px;--lucio-space-8: 64px;--lucio-space-9: 96px;--lucio-space-10: 128px;--lucio-radius-none: 0px;--lucio-radius-sm: 4px;--lucio-radius-md: 8px;--lucio-radius-lg: 16px;--lucio-radius-icon: 22%;--lucio-shadow-glow: 0 0 0 1px rgba(255,243,207,.3), 0 8px 32px -8px rgba(255,243,207,.35);--lucio-motion-fast: .12s;--lucio-ease-fast: cubic-bezier(.2, 0, 0, 1);--lucio-motion-base: .24s;--lucio-ease-base: cubic-bezier(.2, 0, 0, 1);--lucio-motion-glow: .9s;--lucio-ease-glow: cubic-bezier(.16, 1, .3, 1)}@font-face{font-family:Bricolage Grotesque;font-style:normal;font-weight:200 800;font-display:swap;src:url("./bricolage-grotesque-latin-ext-wght-normal.EMW626ZA.woff2") format("woff2-variations");unicode-range:U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF}@font-face{font-family:Bricolage Grotesque;font-style:normal;font-weight:200 800;font-display:swap;src:url("./bricolage-grotesque-latin-wght-normal.HY2A4V5R.woff2") format("woff2-variations");unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD}@font-face{font-family:IBM Plex Sans;font-style:normal;font-weight:400;font-display:swap;src:url("./ibm-plex-sans-latin-ext-400-normal.EDOVP6TU.woff2") format("woff2");unicode-range:U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF}@font-face{font-family:IBM Plex Sans;font-style:normal;font-weight:400;font-display:swap;src:url("./ibm-plex-sans-latin-400-normal.COQVXTP6.woff2") format("woff2");unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD}@font-face{font-family:IBM Plex Sans;font-style:normal;font-weight:500;font-display:swap;src:url("./ibm-plex-sans-latin-ext-500-normal.SG2XNXKB.woff2") format("woff2");unicode-range:U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF}@font-face{font-family:IBM Plex Sans;font-style:normal;font-weight:500;font-display:swap;src:url("./ibm-plex-sans-latin-500-normal.JTONHBWS.woff2") format("woff2");unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD}@font-face{font-family:IBM Plex Sans;font-style:normal;font-weight:600;font-display:swap;src:url("./ibm-plex-sans-latin-ext-600-normal.ZNWKNRXL.woff2") format("woff2");unicode-range:U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF}@font-face{font-family:IBM Plex Sans;font-style:normal;font-weight:600;font-display:swap;src:url("./ibm-plex-sans-latin-600-normal.DTNZULF4.woff2") format("woff2");unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD}@font-face{font-family:IBM Plex Sans;font-style:italic;font-weight:400;font-display:swap;src:url("./ibm-plex-sans-latin-ext-400-italic.VMPJJ47P.woff2") format("woff2");unicode-range:U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF}@font-face{font-family:IBM Plex Sans;font-style:italic;font-weight:400;font-display:swap;src:url("./ibm-plex-sans-latin-400-italic.PR7YQ55B.woff2") format("woff2");unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD}@font-face{font-family:IBM Plex Mono;font-style:normal;font-weight:400;font-display:swap;src:url("./ibm-plex-mono-latin-ext-400-normal.T6XOR2FX.woff2") format("woff2");unicode-range:U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF}@font-face{font-family:IBM Plex Mono;font-style:normal;font-weight:400;font-display:swap;src:url("./ibm-plex-mono-latin-400-normal.A2WATXFY.woff2") format("woff2");unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD}@font-face{font-family:IBM Plex Mono;font-style:normal;font-weight:500;font-display:swap;src:url("./ibm-plex-mono-latin-ext-500-normal.LJE4XY22.woff2") format("woff2");unicode-range:U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF}@font-face{font-family:IBM Plex Mono;font-style:normal;font-weight:500;font-display:swap;src:url("./ibm-plex-mono-latin-500-normal.33HAQIPI.woff2") format("woff2");unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD}:root{color-scheme:dark;--strip-closed: min( 18.75vw , 28vh);--strip-open: min( 28.125vw , 62vh);--strip-gap: var(--lucio-space-2);--gutter: var(--lucio-space-4);--veil: rgba(17, 17, 20, .78)}@media (min-width: 768px){:root{--strip-gap: var(--lucio-space-4);--gutter: var(--lucio-space-6)}}html,body{margin:0;min-height:100%;background:var(--lucio-graphite);color:var(--lucio-paper);font-family:var(--lucio-font-body);font-size:17px;line-height:1.6;-webkit-font-smoothing:antialiased;text-rendering:optimizeLegibility}a{color:var(--lucio-paper);text-decoration-color:var(--lucio-ash-light);text-underline-offset:.15em}::selection{background:var(--lucio-graphite-3);color:var(--lucio-paper)}:focus-visible{outline:2px solid var(--lucio-beam);outline-offset:2px}.visually-hidden{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0}.strip-eyebrow,.next-eyebrow{font-family:var(--lucio-font-mono);font-size:12px;line-height:1.4;font-weight:500;letter-spacing:.08em;text-transform:uppercase;color:var(--lucio-ash-light)}.wordmark,.home-mark{display:block;color:var(--lucio-paper);text-decoration:none}.wordmark-text{font-family:var(--lucio-font-display);font-weight:700;font-size:28px;line-height:1;letter-spacing:-.01em}.has-svg .wordmark-text{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0)}.wordmark-svg{display:block;width:100%}.chop{display:block;width:clamp(28px,7vmin,72px);flex:none}.chop svg{display:block;width:100%;height:auto}.site-header{padding:var(--lucio-space-5) var(--gutter)}.site-header .wordmark{width:128px}.strips{display:flex;flex-direction:column;gap:var(--strip-gap)}.strip{position:relative;display:block;height:var(--strip-closed);overflow:hidden;background:var(--lucio-graphite-2);color:var(--lucio-paper);text-decoration:none;-webkit-touch-callout:none;-webkit-tap-highlight-color:transparent;user-select:none;-webkit-user-select:none;transition:height var(--lucio-motion-base) var(--lucio-ease-base)}.strip.is-open{height:var(--strip-open)}.strip:focus-visible{outline:2px solid var(--lucio-beam);outline-offset:-2px;box-shadow:var(--lucio-shadow-glow)}.strip-canvas{position:absolute;top:0;left:0;width:100%;display:block;will-change:transform;transition:transform var(--lucio-motion-base) var(--lucio-ease-base)}.strip:after{content:"";position:absolute;inset:0;background:linear-gradient(to top,var(--veil) 0%,rgba(17,17,20,.3) 40%,rgba(17,17,20,0) 68%);opacity:0;pointer-events:none;transition:opacity var(--lucio-motion-fast) var(--lucio-ease-fast)}.strip-text{position:absolute;left:var(--gutter);right:var(--gutter);bottom:var(--lucio-space-5);z-index:1;display:flex;flex-direction:column;gap:var(--lucio-space-1);max-width:68ch}.strip-eyebrow,.strip-title,.strip-subtitle{opacity:0;transition:opacity var(--lucio-motion-fast) var(--lucio-ease-fast)}.strip-title{font-family:var(--lucio-font-display);font-weight:600;font-size:clamp(22px,2.6vw,36px);line-height:1.15;letter-spacing:-.015em}.strip-subtitle{font-size:14px;line-height:1.5;color:var(--lucio-ash-light)}.strip.is-open:after,.strip.is-open .strip-eyebrow,.strip.is-open .strip-title,.strip.is-open .strip-subtitle{opacity:1;transition:opacity var(--lucio-motion-glow) var(--lucio-ease-glow) var(--lucio-motion-base)}.strip.is-open .strip-title{transition-delay:calc(var(--lucio-motion-base) + var(--lucio-motion-fast))}.strip.is-open .strip-subtitle{transition-delay:calc(var(--lucio-motion-base) + var(--lucio-motion-fast) * 2)}html:not(.has-strips) .strip:after,html:not(.has-strips) .strip-eyebrow,html:not(.has-strips) .strip-title,html:not(.has-strips) .strip-subtitle{opacity:1}.empty{margin:0;padding:var(--lucio-space-9) var(--gutter);color:var(--lucio-ash-light)}.site-footer{display:flex;align-items:flex-end;justify-content:space-between;gap:var(--lucio-space-4);padding:var(--lucio-space-7) var(--gutter) var(--lucio-space-6)}.footer-line{margin:0;font-size:14px;line-height:1.5;color:var(--lucio-ash-light)}.busy{position:fixed;top:50%;right:max(var(--lucio-space-6),calc(env(safe-area-inset-right) + var(--lucio-space-6)));width:56px;height:56px;margin-top:-28px;z-index:5;opacity:0;pointer-events:none;transition:opacity var(--lucio-motion-base) var(--lucio-ease-base)}.busy.is-visible{opacity:1}.busy svg{display:block}.progress{position:fixed;top:0;left:0;width:100%;height:2px;z-index:6;background:var(--lucio-beam);transform:scaleX(0);transform-origin:0 50%;opacity:0;pointer-events:none;transition:transform var(--lucio-motion-base) var(--lucio-ease-base),opacity var(--lucio-motion-base) var(--lucio-ease-base)}.progress.is-visible{opacity:1}.has-viewer body.viewer{position:fixed;inset:0;overflow:hidden;overscroll-behavior:none}.album-fallback{padding:var(--lucio-space-7) var(--gutter)}.has-viewer .album-fallback{display:none}.home-mark{position:fixed;top:max(var(--lucio-space-5),env(safe-area-inset-top));left:max(var(--lucio-space-5),env(safe-area-inset-left));z-index:4;width:88px;transition:opacity var(--lucio-motion-base) var(--lucio-ease-base)}.is-idle:not(.has-caption) .home-mark:not(:focus-visible){opacity:0}.stage{overflow:hidden;background:var(--lucio-graphite);touch-action:none;user-select:none;-webkit-user-select:none;-webkit-touch-callout:none;-webkit-tap-highlight-color:transparent;cursor:grab}.has-viewer .stage{position:fixed;inset:0}.stage.is-dragging{cursor:grabbing}.stage-canvas,.stage-fade{position:absolute;inset:0;width:100%;height:100%;display:block}.stage-fade{pointer-events:none;opacity:0;transition:opacity var(--lucio-motion-base) var(--lucio-ease-glow)}.caption{position:absolute;left:0;bottom:0;box-sizing:border-box;max-height:60%;overflow:hidden;padding:var(--lucio-space-8) var(--lucio-space-5) var(--lucio-space-5);background:linear-gradient(to top,#111114e6,#1111149e 55%,#11111400);opacity:0;pointer-events:none;transition:opacity var(--lucio-motion-base) var(--lucio-ease-base)}.caption.is-visible{opacity:1}.caption-meta{margin:0;font-family:var(--lucio-font-mono);font-size:12px;line-height:1.4;letter-spacing:.04em;color:var(--lucio-steel);font-variant-numeric:tabular-nums}.caption-title{margin:var(--lucio-space-2) 0 0;font-family:var(--lucio-font-display);font-size:22px;font-weight:600;line-height:1.2;letter-spacing:-.01em}.caption-text{margin:var(--lucio-space-2) 0 0;max-width:68ch;font-size:14px;line-height:1.5}.caption-text em{font-style:italic}.end-card{position:absolute;top:0;left:0;height:100%;display:flex;align-items:center;justify-content:center;will-change:transform}.next-album{display:block;color:var(--lucio-paper);text-decoration:none}.next-strip{position:relative;display:block;overflow:hidden}.next-album.has-strip .next-strip{background:var(--lucio-graphite-2)}.next-album.has-strip .next-strip:after{content:"";position:absolute;inset:0;background:linear-gradient(to top,var(--veil) 0%,rgba(17,17,20,0) 65%);pointer-events:none}.next-text{display:flex;flex-direction:column;gap:var(--lucio-space-1)}.next-album.has-strip .next-text{position:absolute;left:var(--lucio-space-5);bottom:var(--lucio-space-4);z-index:1}.next-title{font-family:var(--lucio-font-display);font-size:24px;font-weight:600;line-height:1.2;letter-spacing:-.01em}.next-album:hover .next-title{text-decoration:underline;text-decoration-color:var(--lucio-ash-light);text-underline-offset:.15em}.next-album:focus-visible{outline-offset:4px;box-shadow:var(--lucio-shadow-glow)}.signoff{position:absolute;right:var(--lucio-space-6);bottom:var(--lucio-space-6);display:flex;flex-direction:column;align-items:flex-end;gap:var(--lucio-space-2)}.signature{margin:0;font-family:var(--lucio-font-display);font-size:20px;font-weight:600;line-height:1.2}@media (prefers-reduced-motion: reduce){*,*:before,*:after{transition-duration:0ms!important;transition-delay:0ms!important;animation-duration:0ms!important}}html{touch-action:manipulation;-webkit-text-size-adjust:100%;text-size-adjust:100%}.skip-link{position:absolute;top:var(--lucio-space-2);left:var(--lucio-space-4);z-index:10;padding:var(--lucio-space-2) var(--lucio-space-3);background:var(--lucio-graphite-2);color:var(--lucio-paper);font-size:14px;line-height:1.5;text-decoration:none;transform:translateY(-200%)}.skip-link:focus-visible{transform:none}.stage:focus-visible{outline:2px solid var(--lucio-beam);outline-offset:-2px}.strip{touch-action:manipulation}.load-error{color:var(--lucio-ash-light)}.message{padding:var(--lucio-space-9) var(--gutter) var(--lucio-space-8);max-width:68ch}.message-eyebrow{margin:0;font-family:var(--lucio-font-mono);font-size:12px;line-height:1.4;font-weight:500;letter-spacing:.08em;text-transform:uppercase;color:var(--lucio-ash-light)}.message-title{margin:var(--lucio-space-2) 0 var(--lucio-space-4);font-family:var(--lucio-font-display);font-size:36px;font-weight:700;line-height:1.15;letter-spacing:-.015em}.message-text{margin:0;color:var(--lucio-paper)}.message-text a{text-decoration:underline} diff --git a/internal/site/static/app.js b/internal/site/static/app.js index 8064dd9..263f811 100644 --- a/internal/site/static/app.js +++ b/internal/site/static/app.js @@ -1 +1 @@ -"use strict";(()=>{function dt(){let t=navigator.deviceMemory,e=typeof matchMedia=="function"&&matchMedia("(pointer: coarse)").matches,i=Math.min(screen.width,screen.height)<=820;return t!==void 0&&t<=4||e&&i?120*1048576:250*1048576}var U=class{constructor(t){this.budget=t;this.entries=new Map;this.used=0}get(t){let e=this.entries.get(t);return e&&(this.entries.delete(t),this.entries.set(t,e)),e}has(t){return this.entries.has(t)}put(t,e){let i=this.entries.get(t);if(i){i.bitmap!==e&&e.close();return}let s=e.width*e.height*4;this.entries.set(t,{bitmap:e,bytes:s,at:performance.now()}),this.used+=s,this.evict()}evict(){for(;this.used>this.budget&&this.entries.size>1;){let t=this.entries.keys().next();if(t.done)return;let e=this.entries.get(t.value);this.entries.delete(t.value),e&&(this.used-=e.bytes,e.bitmap.close())}}};(function(a){let t={from:"Guoliang",to:"Lucio",letters:[{ch:"G",kind:"keep",shared:"M8.50 22.00L8.50 78.00A13.50 13.50 0 0 0 22.00 91.50L58.00 91.50",fullA:"M80.00 8.50L58.00 8.50L22.00 8.50A13.50 13.50 0 0 0 8.50 22.00L8.50 78.00A13.50 13.50 0 0 0 22.00 91.50L58.00 91.50A13.50 13.50 0 0 0 71.50 78.00L71.50 56.00L41.50 56.00",fullB:"M8.50 0.00L8.50 22.00L8.50 78.00A13.50 13.50 0 0 0 22.00 91.50L58.00 91.50L80.00 91.50",out:[{d:"M80.00 8.50L58.00 8.50L22.00 8.50A13.50 13.50 0 0 0 8.50 22.00",P:79.21,j:"end"},{d:"M58.00 91.50A13.50 13.50 0 0 0 71.50 78.00L71.50 56.00L41.50 56.00",P:73.21,j:"start"}],in:[{d:"M8.50 22.00L8.50 0.00",P:22,j:"start"},{d:"M58.00 91.50L80.00 91.50",P:22,j:"start"}],x0:0,x1:0,dot:null},{ch:"u",kind:"keep",shared:"M8.50 38.00L8.50 60.00L8.50 78.00A13.50 13.50 0 0 0 22.00 91.50L38.00 91.50A13.50 13.50 0 0 0 51.50 78.00L51.50 60.00L51.50 38.00",fullA:"M8.50 38.00L8.50 60.00L8.50 78.00A13.50 13.50 0 0 0 22.00 91.50L38.00 91.50A13.50 13.50 0 0 0 51.50 78.00L51.50 60.00L51.50 38.00",fullB:"M8.50 38.00L8.50 60.00L8.50 78.00A13.50 13.50 0 0 0 22.00 91.50L38.00 91.50A13.50 13.50 0 0 0 51.50 78.00L51.50 60.00L51.50 38.00",out:[],in:[],x0:88.8,x1:88,dot:null},{ch:"o",kind:"keep",shared:"M38.00 46.50L22.00 46.50A13.50 13.50 0 0 0 8.50 60.00L8.50 78.00A13.50 13.50 0 0 0 22.00 91.50L38.00 91.50",fullA:"M38.00 91.50A13.50 13.50 0 0 0 51.50 78.00L51.50 60.00A13.50 13.50 0 0 0 38.00 46.50L22.00 46.50A13.50 13.50 0 0 0 8.50 60.00L8.50 78.00A13.50 13.50 0 0 0 22.00 91.50L38.00 91.50",fullB:"M60.00 46.50L38.00 46.50L22.00 46.50A13.50 13.50 0 0 0 8.50 60.00L8.50 78.00A13.50 13.50 0 0 0 22.00 91.50L38.00 91.50L60.00 91.50",out:[{d:"M38.00 91.50A13.50 13.50 0 0 0 51.50 78.00L51.50 60.00A13.50 13.50 0 0 0 38.00 46.50",P:60.41,j:"both"}],in:[{d:"M38.00 46.50L60.00 46.50",P:22,j:"start"},{d:"M38.00 91.50L60.00 91.50",P:22,j:"start"}],x0:159,x1:158.2,dot:null},{ch:"l",kind:"fade",d:"M8.50 0.00L8.50 100.00",x0:230.8,x1:230.8,dot:null},{ch:"i",kind:"keep",shared:"M8.50 38.00L8.50 100.00",fullA:"M8.50 38.00L8.50 100.00",fullB:"M8.50 38.00L8.50 100.00",out:[],in:[],x0:262.8,x1:227.9,dot:[0,14,17]},{ch:"a",kind:"fade",d:"M38.00 91.50L51.50 91.50L51.50 78.00L51.50 60.00L51.50 46.50L38.00 46.50L22.00 46.50A13.50 13.50 0 0 0 8.50 60.00L8.50 78.00A13.50 13.50 0 0 0 22.00 91.50L38.00 91.50",x0:291.6,x1:291.6,dot:null},{ch:"n",kind:"fade",d:"M51.50 100.00L51.50 78.00L51.50 60.00A13.50 13.50 0 0 0 38.00 46.50L22.00 46.50A13.50 13.50 0 0 0 8.50 60.00L8.50 78.00L8.50 100.00",x0:362.7,x1:362.7,dot:null},{ch:"g",kind:"keep",shared:"M38.00 91.50A13.50 13.50 0 0 0 51.50 78.00L51.50 60.00A13.50 13.50 0 0 0 38.00 46.50L22.00 46.50A13.50 13.50 0 0 0 8.50 60.00L8.50 78.00A13.50 13.50 0 0 0 22.00 91.50L38.00 91.50",fullA:"M0.00 127.50L38.00 127.50A13.50 13.50 0 0 0 51.50 114.00L51.50 60.00A13.50 13.50 0 0 0 38.00 46.50L22.00 46.50A13.50 13.50 0 0 0 8.50 60.00L8.50 78.00A13.50 13.50 0 0 0 22.00 91.50L38.00 91.50A13.50 13.50 0 0 0 51.50 78.00L51.50 60.00",fullB:"M38.00 91.50A13.50 13.50 0 0 0 51.50 78.00L51.50 60.00A13.50 13.50 0 0 0 38.00 46.50L22.00 46.50A13.50 13.50 0 0 0 8.50 60.00L8.50 78.00A13.50 13.50 0 0 0 22.00 91.50L38.00 91.50",out:[{d:"M51.50 60.00L51.50 114.00A13.50 13.50 0 0 1 38.00 127.50L0.00 127.50",P:113.21,j:"start"}],in:[],x0:432.9,x1:256.7,dot:null}],pad:17,vbw:526.9,vbh:170,stroke:17,raysT:"translate(0.000 22.727) scale(0.7727)"},e="M47.6 70.7L71.9 61.1L71.1 58.2L45.2 62.0ZM44.9 61.5L61.2 40.9L59.1 38.8L38.5 55.1ZM38.0 54.8L41.8 28.9L38.9 28.1L29.3 52.4Z",i="http://www.w3.org/2000/svg",s=(c,w)=>{let l=document.createElementNS(i,c);for(let u in w)l.setAttribute(u,w[u]);return l},n=()=>a.matchMedia&&a.matchMedia("(prefers-reduced-motion: reduce)").matches,r=c=>Math.max(0,Math.min(1,c)),o=c=>c*c*(3-2*c),d=.5;function h(c,w){let l=0,u=0,p=null,b=0;function C(y){let v=(y-b)/w;b=y,l=lf(1),reverse:()=>f(0),toggle:()=>f(u?0:1),set:y=>{cancelAnimationFrame(p),p=null,u=l=y,c(l)},stop:()=>{cancelAnimationFrame(p),p=null},get t(){return l}}}function g(c,w,l,u){let p=r(u)*w;if(c.style.visibility=p<.05?"hidden":"visible",l==="both"){let b=p/2;c.setAttribute("stroke-dasharray",b.toFixed(2)+" "+Math.max(0,w-2*b).toFixed(2)+" "+b.toFixed(2)),c.setAttribute("stroke-dashoffset","0")}else l==="end"?(c.setAttribute("stroke-dasharray",p.toFixed(2)+" "+(2*w+20).toFixed(2)),c.setAttribute("stroke-dashoffset",(-(w-p)).toFixed(2))):(c.setAttribute("stroke-dasharray",p.toFixed(2)+" "+(2*w+20).toFixed(2)),c.setAttribute("stroke-dashoffset","0"))}function k(c,w={}){let l=Object.assign({trigger:"hover",color:"currentColor",rays:"#FFF3CF",duration:450,autoDelay:1800},w),u=s("svg",{viewBox:"0 0 "+t.vbw+" "+t.vbh,role:"img","aria-label":"Guoliang Chen, Lucio"});u.style.display="block",u.style.width="100%",u.style.height="auto";let p=s("g",{transform:"translate("+t.pad+" "+t.pad+")",fill:"none",stroke:l.color,"stroke-width":t.stroke,"stroke-linejoin":"miter","stroke-linecap":"butt"});u.appendChild(p);let b=t.letters.map(v=>{let x=s("g",{transform:"translate("+v.x0+" 0)"});p.appendChild(x);let E=Object.assign({g:x,outEls:[],inEls:[]},v);if(v.kind==="fade")E.fadeEl=s("path",{d:v.d}),x.appendChild(E.fadeEl);else{E.fullA=s("path",{d:v.fullA}),x.appendChild(E.fullA),E.fullB=s("path",{d:v.fullB}),x.appendChild(E.fullB),v.shared&&x.appendChild(s("path",{d:v.shared}));for(let M of v.out){let A=s("path",{d:M.d});x.appendChild(A),E.outEls.push([A,M])}for(let M of v.in){let A=s("path",{d:M.d});x.appendChild(A),E.inEls.push([A,M])}}return v.dot&&(E.dotEl=s("rect",{x:v.dot[0],y:v.dot[1],width:v.dot[2],height:v.dot[2],rx:v.dot[2]*.22,fill:l.color,stroke:"none"}),x.appendChild(E.dotEl)),E}),C=s("path",{d:e,fill:l.rays,stroke:"none",opacity:0});p.appendChild(C),c.appendChild(u);function f(v){let x=o(r(v/d)),E=o(r((v-d)/(1-d)));for(let M of b){if(M.kind==="fade")M.fadeEl.setAttribute("opacity",(1-x).toFixed(3)),M.dotEl&&M.dotEl.setAttribute("opacity",(1-x).toFixed(3));else{for(let[A,S]of M.outEls)g(A,S.P,S.j,1-x);for(let[A,S]of M.inEls)g(A,S.P,S.j,x);M.fullA.style.visibility=x<=.001?"visible":"hidden",M.fullB.style.visibility=x>=.999?"visible":"hidden"}M.g.setAttribute("transform","translate("+(M.x0+(M.x1-M.x0)*E).toFixed(2)+" 0)")}C.setAttribute("transform","translate("+(b[0].x0+(b[0].x1-b[0].x0)*E).toFixed(2)+" 0) "+t.raysT),C.setAttribute("opacity",r((v-.8)/.2).toFixed(3))}let y=h(f,l.duration);return f(0),l.trigger==="hover"&&(c.addEventListener("mouseenter",y.play),c.addEventListener("mouseleave",y.reverse),c.addEventListener("focus",y.play),c.addEventListener("blur",y.reverse)),l.trigger==="click"&&c.addEventListener("click",y.toggle),l.trigger==="auto"&&setInterval(y.toggle,l.autoDelay+l.duration),Object.assign(y,{svg:u})}let L={C:[0,.75],L:[.25,.75],U:[.25,1],I:[.75,1],O:[.75,1.75]};function m(c,w,l){let u=w/2,p=l-u,b=u+p,C=p*Math.SQRT1_2,f=v=>v.toFixed(3);return{d:"M"+f(c-b+C)+" "+f(b-C)+"A"+f(p)+" "+f(p)+" 0 0 0 "+f(c-b)+" "+f(u)+"H"+f(b)+"A"+f(p)+" "+f(p)+" 0 0 0 "+f(u)+" "+f(b)+"V"+f(c-b)+"A"+f(p)+" "+f(p)+" 0 0 0 "+f(b)+" "+f(c-u)+"H"+f(c-b)+"A"+f(p)+" "+f(p)+" 0 0 0 "+f(c-u)+" "+f(c-b)+"V"+f(b)+"A"+f(p)+" "+f(p)+" 0 0 0 "+f(c-b+C)+" "+f(b-C)+"Z",P:4*(c-2*b)+2*Math.PI*p}}function T(c,w={}){let l=Object.assign({sequence:"LUCIO",color:"#F3F1EC",track:"#26262D",rays:"#FFF3CF",hold:480,morph:640,size:96,stroke:.17,radius:.22},w),u=120,p=u*l.stroke,b=u*l.radius,C=m(u,p,b),f=s("svg",{viewBox:"0 0 "+u+" "+u,width:l.size,height:l.size,role:"img","aria-label":"Loading"});l.track&&f.appendChild(s("path",{d:C.d,fill:"none",stroke:l.track,"stroke-width":p}));let y=s("path",{d:C.d,fill:"none",stroke:l.color,"stroke-width":p,"stroke-linecap":"butt"}),v=p/22,x=s("path",{d:e,fill:l.rays,transform:"translate("+(p-22*v).toFixed(3)+" "+(u-p-78*v).toFixed(3)+") scale("+v.toFixed(4)+")",opacity:0});f.appendChild(y),f.appendChild(x);let E=(R,H)=>{let I=Math.min(1,Math.max(0,H-R))*C.P;y.setAttribute("stroke-dasharray",I.toFixed(3)+" "+Math.max(0,C.P-I).toFixed(3)),y.setAttribute("stroke-dashoffset",(-R*C.P).toFixed(3))},M=(R,H)=>{let[I,B]=L[H];for(let F=-1;F<6;F++)if(I+F>=R[0]-1e-6&&B+F>=R[1]-1e-6)return[I+F,B+F];return[I,B]},A=l.sequence.split(""),S=0,P=L[A[0]].slice(),et,it,rt=!1;E(P[0],P[1]),x.setAttribute("opacity",A[0]==="L"?1:0);function ot(){if(rt)return;let R=(S+1)%A.length,H=M(P,A[R]),I=P.slice(),B=A[S]==="L",F=A[R]==="L",at=()=>{P=H;let _=Math.floor(P[0]);P[0]-=_,P[1]-=_,S=R,E(P[0],P[1]),x.setAttribute("opacity",F?1:0),it=setTimeout(ot,l.hold)};if(n()){at();return}let At=performance.now(),ht=_=>{let q=Math.min(1,(_-At)/l.morph),lt=q<.5?4*q*q*q:1-Math.pow(-2*q+2,3)/2;E(I[0]+(H[0]-I[0])*lt,I[1]+(H[1]-I[1])*lt),x.setAttribute("opacity",F?Math.max(0,(q-.6)/.4).toFixed(3):B?Math.max(0,1-q*2.5).toFixed(3):0),q<1?et=requestAnimationFrame(ht):at()};et=requestAnimationFrame(ht)}return it=setTimeout(ot,l.hold),c.appendChild(f),{svg:f,stop:()=>{rt=!0,cancelAnimationFrame(et),clearTimeout(it)}}}a.LucioMorph={wordmark:k,loader:T}})(window);var N={graphite:"#111114",graphite3:"#26262D",paper:"#F3F1EC",beam:"#FFF3CF"};function st(){return window.LucioMorph??null}function V(a,t){let e=st();if(!e)return null;let i=document.createElement("span");i.className="wordmark-svg",i.setAttribute("aria-hidden","true"),a.appendChild(i);let s=e.wordmark(i,{trigger:"manual",color:N.paper,rays:N.beam});return s.svg.setAttribute("aria-hidden","true"),s.svg.removeAttribute("role"),t||s.set(1),a.classList.add("has-svg"),s}function ct(){let a=document.getElementById("chop-template");if(!(a instanceof HTMLTemplateElement))return null;let t=a.content.firstElementChild;return t?t.cloneNode(!0):null}var Ct=400,D=class{constructor(t,e=()=>!0){this.canShow=e;this.handle=null;this.loader=null;this.timer=0;this.hideTimer=0;this.visible=!1;this.element=document.createElement("div"),this.element.className="busy",this.element.setAttribute("role","status"),this.element.setAttribute("aria-label","Loading"),t.appendChild(this.element)}watch(t){if(t===this.loader){this.update(t);return}this.loader=t,clearTimeout(this.timer),this.timer=0,this.hide(),this.update(t)}update(t){if(!t||t!==this.loader)return;let e=t.status;if(!e.active||e.sharp){clearTimeout(this.timer),this.timer=0,this.hide();return}if(!this.visible&&this.timer===0){let i=Math.max(0,Ct-(performance.now()-e.started));this.timer=window.setTimeout(()=>this.check(),i)}}check(){this.timer=0;let t=this.loader;if(!(!t||!t.status.active||t.status.sharp)){if(!this.canShow()){this.timer=window.setTimeout(()=>this.check(),100);return}this.show()}}show(){if(!this.visible){if(clearTimeout(this.hideTimer),this.visible=!0,!this.handle){let t=st();t&&(this.handle=t.loader(this.element,{size:56,color:N.paper,track:N.graphite3,rays:N.beam}),this.handle.svg.setAttribute("aria-hidden","true"))}this.element.classList.add("is-visible")}}hide(){this.visible&&(this.visible=!1,this.element.classList.remove("is-visible"),clearTimeout(this.hideTimer),this.hideTimer=window.setTimeout(()=>{!this.visible&&this.handle&&(this.handle.stop(),this.handle.svg.remove(),this.handle=null)},300))}},Y=class{constructor(t){this.loader=null;this.shown=!1;this.value=-1;this.element=document.createElement("div"),this.element.className="progress",this.element.setAttribute("aria-hidden","true"),t.appendChild(this.element)}watch(t){this.loader=t,this.value=-1,this.update(t)}update(t){if(!t||t!==this.loader)return;let e=t.status,i=e.active&&!e.sharp&&e.planned>0,s=e.planned>0?Math.min(1,e.done/e.planned):0;i!==this.shown&&(this.shown=i,this.element.classList.toggle("is-visible",i));let n=Math.round(s*1e3)/1e3;n!==this.value&&(this.value=n,this.element.style.transform="scaleX("+(i?n:1)+")")}};function X(a,t,e){let i=t*e;for(let s=0;s=i)return s;return a.levels.length-1}function K(a,t,e){let i=Math.max(0,t.u0*a.width),s=Math.min(a.width,t.u1*a.width),n=Math.max(0,t.v0*a.height),r=Math.min(a.height,t.v1*a.height);return s<=i||r<=n?null:{x0:Math.min(a.cols-1,Math.floor(i/e)),x1:Math.min(a.cols-1,Math.ceil(s/e)-1),y0:Math.min(a.rows-1,Math.floor(n/e)),y1:Math.min(a.rows-1,Math.ceil(r/e)-1)}}function ut(a,t,e,i){let s=a.levels[t],n=K(s,e,i);if(!n)return[];let r=(e.u0+e.u1)/2*s.width,o=(e.v0+e.v1)/2*s.height,d=[];for(let h=n.y0;h<=n.y1;h++)for(let g=n.x0;g<=n.x1;g++){let k=(g*i+Math.min((g+1)*i,s.width))/2,L=(h*i+Math.min((h+1)*i,s.height))/2;d.push({level:t,x:g,y:h,index:h*s.cols+g,distance:(k-r)**2+(L-o)**2})}return d.sort((h,g)=>h.distance-g.distance),d.map(({level:h,x:g,y:k,index:L})=>({level:h,x:g,y:k,index:L}))}function pt(a,t,e,i,s,n,r,o,d,h){let g=i*n,k=Math.min((i+1)*n,e.width),L=s*n,m=Math.min((s+1)*n,e.height),T=i>0?g-r:0,c=s>0?L-r:0,w=Math.round(o+g*h),l=Math.round(o+k*h),u=Math.round(d+L*h),p=Math.round(d+m*h);if(l<=w||p<=u)return;let b=Math.max(T,(w-o)/h),C=Math.min(T+t.width,(l-o)/h),f=Math.max(c,(u-d)/h),y=Math.min(c+t.height,(p-d)/h);C<=b||y<=f||a.drawImage(t,b-T,f-c,C-b,y-f,w,u,l-w,p-u)}var z=class extends Error{constructor(){super("aborted"),this.name="AbortError"}},Z=class{constructor(t,e){this.concurrency=t;this.byId=new Map;this.byKey=new Map;this.queue=[];this.workers=[];this.running=0;this.nextKey=1;this.nextSeq=1;this.nextWorker=0;if(typeof Worker>"u"||e==="")return;let i=(navigator.hardwareConcurrency??2)>=4?2:1;for(let s=0;sthis.onReply(o.data),n.onerror=()=>this.dropWorker(r),this.workers.push(n)}catch{break}}request(t,e,i,s){return s.aborted?Promise.reject(new z):new Promise((n,r)=>{let o=this.byId.get(t);o?i{h.waiters.delete(d)&&(r(new z),h.waiters.size===0&&setTimeout(()=>{h.waiters.size===0&&this.byKey.get(h.key)===h&&this.cancel(h)},0))},{once:!0}),this.pump()})}cancel(t){if(this.forget(t),!t.running){let e=this.queue.indexOf(t);e>=0&&this.queue.splice(e,1);return}t.running=!1,this.running--,t.controller?t.controller.abort():t.worker>=0&&this.workers[t.worker]&&this.workers[t.worker].postMessage({type:"abort",key:t.key}),this.pump()}forget(t){this.byId.get(t.id)===t&&this.byId.delete(t.id),this.byKey.delete(t.key)}pump(){for(;this.running0;){let t=0;for(let i=1;i0){let i=e[this.nextWorker++%e.length];t.worker=i,this.workers[i].postMessage({type:"fetch",key:t.key,url:t.url});return}t.worker=-1,t.controller=new AbortController,this.fetchOnMainThread(t,t.controller.signal)}liveWorkers(){let t=[];return this.workers.forEach((e,i)=>{e&&t.push(i)}),t}dropWorker(t){let e=this.workers[t];if(e){e.terminate(),delete this.workers[t];for(let i of this.byKey.values())i.running&&i.worker===t&&(i.worker=-1,i.controller=new AbortController,this.fetchOnMainThread(i,i.controller.signal))}}async fetchOnMainThread(t,e){let i=performance.now();try{let s=await fetch(t.url,{signal:e,credentials:"same-origin"});if(!s.ok)throw new Error("HTTP "+s.status);let n=await s.blob(),r=performance.now()-i,o=await createImageBitmap(n);this.onReply({key:t.key,ok:!0,bitmap:o,bytes:n.size,ms:r})}catch(s){this.onReply({key:t.key,ok:!1,bytes:0,ms:0,error:String(s)})}}onReply(t){let e=this.byKey.get(t.key);if(!e||!e.running){t.bitmap?.close();return}e.running=!1,this.running--,this.forget(e);let i=[...e.waiters];if(e.waiters.clear(),t.ok&&t.bitmap){let s={bitmap:t.bitmap,bytes:t.bytes,ms:t.ms};for(let n of i)n.resolve(s);i.length===0&&t.bitmap.close()}else{let s=new Error(t.error??"tile failed");for(let n of i)n.reject(s)}this.pump()}};var mt="luphoto.throughput";function ft(){try{let a=Number(sessionStorage.getItem(mt));return Number.isFinite(a)&&a>0?a:null}catch{return null}}function vt(){return ft()??1e3}function gt(a){let t=ft(),e=t===null?a:t*(1-.5)+a*.5;try{sessionStorage.setItem(mt,String(e))}catch{return e}return e}var nt=180,yt=3,G=4,W=class{constructor(t,e){this.pyramid=t;this.env=e;this.seedImage=null;this.seedPromise=null;this.session=null;this.prefetchController=null;this.finalLevel=-1;this.targetLevel=-1;this.status={active:!1,started:0,planned:0,done:0,sharp:!1}}tileUrl(t){let e=this.env.tiles;return e.path+this.pyramid.hash+"/"+t+"."+e.format}ensureSeed(){return this.seedPromise||(this.seedPromise=this.decodeSeed().then(()=>this.env.requestDraw(),()=>{})),this.seedPromise}async decodeSeed(){if(!this.pyramid.seed)return;let t=atob(this.pyramid.seed),e=new Uint8Array(t.length);for(let o=0;o(this.env.cache.put(s,n.bitmap),this.env.requestDraw(),n))}uncached(t,e){let i=this.pyramid.levels[t].tiles;return ut(this.pyramid,t,e,this.env.tiles.tile_size).filter(s=>!this.env.cache.has(i[s.index]))}uncachedBytes(t,e){let i=this.pyramid.levels[t].bytes,s=0;for(let n of this.uncached(t,e))s+=i[n.index];return s}fetchAll(t,e,i){return Promise.allSettled(t.map(s=>this.fetchTile(s,e,i)))}probeLevel(t,e){return Math.max(0,X(this.pyramid,t.displayWidth,e)-yt)}notify(){this.env.onStatus?.(this)}track(t,e,i){return this.status.planned+=t.length,this.notify(),Promise.allSettled(t.map(s=>this.fetchTile(s,0,i).finally(()=>{this.session===e&&(this.status.done++,this.notify())})))}start(t,e,i){this.stopSession();let s=new AbortController;this.session=s,this.targetLevel=-1,this.status.active=!0,this.status.started=performance.now(),this.status.planned=0,this.status.done=0,this.status.sharp=!1,this.notify(),this.run(t,e,s).then(()=>{this.session===s&&(this.session=null,this.status.active=!1,this.notify()),(!s.signal.aborted||s.signal.reason==="deadline")&&i()})}async run(t,e,i){let s=i.signal,n=performance.now(),r=this.env.settings.budgetMs,o=setTimeout(()=>i.abort("deadline"),r);try{if(await this.ensureSeed(),s.aborted)return;let d=X(this.pyramid,t.displayWidth,e),h=Math.max(0,d-yt),g=this.uncached(h,t).slice(0,2);if(g.length>0){let c=await this.track(g,i,s),w=0,l=0;for(let u of c)u.status==="fulfilled"&&(w+=u.value.bytes,l=Math.max(l,u.value.ms));w>0&&l>0&>(w/l)}if(s.aborted)return;this.finalLevel=Math.max(this.finalLevel,h);let k=vt(),L=r-(performance.now()-n),m=h;for(let c=d;c>h;c--)if(this.uncachedBytes(c,t)/k<=L*.8){m=c;break}let T=[];m-h>=2&&T.push(Math.floor((h+m)/2)),m>h&&T.push(m),this.finalLevel=m,this.targetLevel=m,this.env.requestDraw();for(let c of T)if(await this.track(this.uncached(c,t),i,s),s.aborted)return}finally{clearTimeout(o)}}prefetchProbe(t,e){let i=this.resetPrefetch();this.ensureSeed().then(()=>{i.signal.aborted||this.fetchAll(this.uncached(this.probeLevel(t,e),t),1,i.signal)})}prefetchLevel(t,e){if(e<0)return;let i=this.resetPrefetch();this.fetchAll(this.uncached(e,t),1,i.signal)}resetPrefetch(){return this.prefetchController?.abort(),this.prefetchController=new AbortController,this.prefetchController}stopPrefetch(){this.prefetchController?.abort(),this.prefetchController=null}stopSession(){this.session&&(this.session.abort("superseded"),this.session=null,this.status.active=!1,this.notify())}stop(){this.stopSession(),this.stopPrefetch()}draw(t){let{g:e,originX:i,originY:s,width:n,height:r,canvasWidth:o,canvasHeight:d}=t,h=Math.max(0,i),g=Math.max(0,s),k=Math.min(o,i+n),L=Math.min(d,s+r);if(k<=h||L<=g)return!1;this.seedPromise||this.ensureSeed();let m={displayWidth:t.displayWidth,u0:(h-i)/n,u1:(k-i)/n,v0:(g-s)/r,v1:(L-s)/r},T=this.env.tiles.tile_size,c=this.env.tiles.overlap,w=this.env.cache,l=this.pyramid.levels,u=X(this.pyramid,t.displayWidth,t.dpr),p=-1;for(let y=u;y>=0&&p<0;y--){let v=K(l[y],m,T);if(!v)continue;let x=!0;for(let E=v.y0;E<=v.y1&&x;E++)for(let M=v.x0;M<=v.x1;M++){let A=w.get(l[y].tiles[E*l[y].cols+M]);if(!A||t.now-A.at=0?Math.min(this.targetLevel,u):u,C=p>=b;C!==this.status.sharp&&(this.status.sharp=C,queueMicrotask(()=>this.notify()));let f=!1;for(let y=Math.max(0,p);y<=u;y++){let v=l[y],x=K(v,m,T);if(!x)continue;let E=n/v.width;e.imageSmoothingEnabled=!0,e.imageSmoothingQuality=E<1?"high":"medium";for(let M=x.y0;M<=x.y1;M++)for(let A=x.x0;A<=x.x1;A++){let S=w.get(v.tiles[M*v.cols+A]);if(!S)continue;let P=t.now-S.at;Pthis.requestDraw(),onStatus:()=>this.onStatus(this)})}get isOpen(){return this.expanded}layout(t){let e=this.cover,i=Math.max(t.width/e.width,t.open/e.height),s=e.width*i,n=e.height*i,r=(t.open-n)/2,o=r+this.focusY*n,d=Math.max(0,Math.min(t.open-t.closed,o-t.closed/2)),h=this.geometry;this.geometry={width:t.width,closed:t.closed,open:t.open,dpr:t.dpr,coverWidth:s,coverHeight:n,x:(t.width-s)/2,y:r,band:d},this.canvas&&(this.sizeCanvas(this.canvasOpen),this.drawNow()),this.near&&h&&(h.width!==t.width||h.closed!==t.closed||h.open!==t.open||h.dpr!==t.dpr)&&this.startSession()}attach(){if(this.canvas)return;let t=document.createElement("canvas");t.className="strip-canvas",t.setAttribute("aria-hidden","true");let e=t.getContext("2d",{alpha:!1});e&&(this.canvas=t,this.g=e,this.element.prepend(t),this.sizeCanvas(this.expanded),this.drawNow())}detach(){this.canvas&&(cancelAnimationFrame(this.frame),this.frame=0,this.canvas.width=0,this.canvas.height=0,this.canvas.remove(),this.canvas=null,this.g=null)}setNear(t){t!==this.near&&(this.near=t,t?this.startSession():this.loader.stop())}setOpen(t){if(t===this.expanded)return;this.expanded=t,this.element.classList.toggle("is-open",t),clearTimeout(this.settleTimer);let e=this.geometry,i=this.canvas;t?i&&this.canvasOpen?(i.style.transition="",i.style.transform="translate3d(0,0,0)"):i&&e&&(this.sizeCanvas(!0),i.style.transition="none",i.style.transform="translate3d(0,"+-e.band+"px,0)",this.drawNow(),requestAnimationFrame(()=>{requestAnimationFrame(()=>{this.expanded&&this.canvas===i&&(i.style.transition="",i.style.transform="translate3d(0,0,0)")})})):i&&e&&(i.style.transition="",i.style.transform="translate3d(0,"+-e.band+"px,0)",this.settleTimer=window.setTimeout(()=>{!this.expanded&&this.canvas===i&&(this.sizeCanvas(!1),this.drawNow())},Pt)),this.near&&this.startSession()}sizeCanvas(t){let e=this.canvas,i=this.geometry;if(!e||!i)return;this.canvasOpen=t;let s=t?i.open:i.closed,n=Math.max(1,Math.round(i.width*i.dpr)),r=Math.max(1,Math.round(s*i.dpr));(e.width!==n||e.height!==r)&&(e.width=n,e.height=r),e.style.height=s+"px",t||(e.style.transition="none",e.style.transform="translate3d(0,0,0)")}view(){let t=this.geometry;if(!t)return null;let e=this.expanded?0:t.band,i=this.expanded?t.open:t.closed;return{displayWidth:t.coverWidth,u0:Math.max(0,-t.x/t.coverWidth),u1:Math.min(1,(t.width-t.x)/t.coverWidth),v0:Math.max(0,(e-t.y)/t.coverHeight),v1:Math.min(1,(e+i-t.y)/t.coverHeight)}}startSession(){let t=this.view();!t||!this.geometry||this.loader.start(t,this.geometry.dpr,()=>{})}requestDraw(){this.frame===0&&this.canvas&&(this.frame=requestAnimationFrame(t=>{this.frame=0,this.draw(t)&&this.requestDraw()}))}drawNow(){this.draw(performance.now())&&this.requestDraw()}draw(t){let e=this.g,i=this.canvas,s=this.geometry;if(!e||!i||!s)return!1;e.setTransform(1,0,0,1,0,0),e.globalAlpha=1,e.fillStyle="#111114",e.fillRect(0,0,i.width,i.height);let n=this.canvasOpen?0:-s.band;return this.loader.draw({g:e,originX:s.x*s.dpr,originY:(s.y+n)*s.dpr,width:s.coverWidth*s.dpr,height:s.coverHeight*s.dpr,canvasWidth:i.width,canvasHeight:i.height,displayWidth:s.coverWidth,dpr:s.dpr,now:t})}};var It=24,J=class{constructor(t,e,i,s){this.root=t;this.settings=i;this.strips=[];this.onScreen=new Set;this.wordmark=null;this.opened=null;this.scrollFrame=0;this.sizeKey="";let n=Array.from(t.querySelectorAll("a.strip")),r=new Map(e.albums.map(d=>[d.slug,d]));for(let d of n){let h=r.get(d.dataset.slug??"");!h||!h.cover||this.strips.push(new O(d,h.cover,h.collapsed_focus_y??.5,s,g=>this.onStripStatus(g)))}this.hoverMode=matchMedia("(hover: hover) and (pointer: fine)");let o=document.querySelector(".site-header .wordmark");if(this.indicator=new D(document.body,()=>!this.wordmarkMoving()),o){this.wordmark=V(o,!0);let d=()=>{this.wordmark&&!this.indicator.visible&&this.wordmark.play()},h=()=>this.wordmark?.reverse();o.addEventListener("mouseenter",d),o.addEventListener("mouseleave",h),o.addEventListener("focus",d),o.addEventListener("blur",h)}document.documentElement.classList.add("has-strips"),this.measure(),this.observe(),this.bind()}wordmarkMoving(){let t=this.wordmark?.t??0;return t>0&&t<1}measure(){let t=this.root.clientWidth||window.innerWidth,e=window.innerHeight,i=Math.round(Math.min(t*6/32,e*.28)),s=Math.round(Math.min(t*9/32,e*.62)),n=Math.min(window.devicePixelRatio||1,this.settings.maxDpr),r=t+"x"+i+"x"+s+"@"+n;if(r!==this.sizeKey){this.sizeKey=r,this.root.style.setProperty("--strip-closed",i+"px"),this.root.style.setProperty("--strip-open",s+"px");for(let o of this.strips)o.layout({width:t,closed:i,open:s,dpr:n})}}observe(){let t=new Map(this.strips.map(n=>[n.element,n])),e=new IntersectionObserver(n=>{for(let r of n)t.get(r.target)?.setNear(r.isIntersecting)},{rootMargin:"100% 0px"}),i=new IntersectionObserver(n=>{for(let r of n){let o=t.get(r.target);o&&(r.isIntersecting?o.attach():o.detach())}},{rootMargin:"25% 0px"}),s=new IntersectionObserver(n=>{for(let r of n){let o=t.get(r.target);o&&(r.isIntersecting?this.onScreen.add(o):this.onScreen.delete(o))}this.watchFirst(),this.scheduleCentre()});for(let n of this.strips)e.observe(n.element),i.observe(n.element),s.observe(n.element)}watchFirst(){let t=this.strips.find(e=>this.onScreen.has(e))??null;this.indicator.watch(t?t.loader:null)}onStripStatus(t){this.indicator.update(t.loader)}bind(){for(let t of this.strips){let e=t.element;e.addEventListener("mouseenter",()=>{this.hoverMode.matches&&this.open(t)}),e.addEventListener("mouseleave",()=>{this.hoverMode.matches&&this.opened===t&&this.open(null)}),e.addEventListener("focus",()=>this.open(t)),e.addEventListener("blur",()=>{this.opened===t&&!this.hoverMode.matches?this.scheduleCentre():this.opened===t&&this.open(null)}),e.addEventListener("dragstart",i=>i.preventDefault()),this.settings.blockContextMenu&&e.addEventListener("contextmenu",i=>i.preventDefault())}window.addEventListener("scroll",()=>this.scheduleCentre(),{passive:!0}),new ResizeObserver(()=>{this.measure(),this.scheduleCentre()}).observe(this.root)}open(t){t!==this.opened&&(this.opened?.setOpen(!1),this.opened=t,t?.setOpen(!0))}scheduleCentre(){this.hoverMode.matches||this.scrollFrame!==0||(this.scrollFrame=requestAnimationFrame(()=>{this.scrollFrame=0,this.pickCentre()}))}pickCentre(){if(this.hoverMode.matches)return;let t=window.innerHeight/2,e=null,i=1/0,s=1/0;for(let n of this.onScreen){let r=n.element.getBoundingClientRect(),o=Math.abs(r.top+r.height/2-t);o{let n=Number(i);return Number.isFinite(n)&&n>0?n:s};return{page:t.page??"",build:t.build??"",slug:t.album??"",manifestUrl:t.manifest??"",indexUrl:t.index??"",workerUrl:t.worker??"",budgetMs:e(t.budgetMs,3e3),maxDpr:e(t.maxDpr,2),concurrency:Math.max(1,Math.round(e(t.concurrency,6))),blockContextMenu:t.blockContextMenu!=="false"}}function xt(a){return a<10?"0"+a:String(a)}function Rt(a){let t=(a.model??"").trim(),e=(a.make??"").trim(),i=e.split(/\s+/)[0]??"";i&&t.toLowerCase().startsWith(i.toLowerCase()+" ")&&(t=t.slice(i.length+1).trim());let s=/^([A-Za-z]{1,3}) (\d+[A-Za-z0-9]*)$/.exec(t);return s&&(t=s[1]+s[2]),t||e}function Ft(a){let t=/(\d+(?:\.\d+)?(?:-\d+(?:\.\d+)?)?)\s*mm\s*(?:F|f\/?)\s*([\d.]+(?:-[\d.]+)?)/.exec(a);return t?t[1]+" f/"+t[2]:a.trim()}function j(a){return String(Math.round(a*10)/10)}function qt(a){let t=a.trim();if(t.includes("/")||t.endsWith("s"))return t;let e=Number(t);if(!Number.isFinite(e)||e<=0)return t;if(e>=1)return j(e)+"s";let i=1/e;return i<10&&Math.abs(i-Math.round(i))>.05?"1/"+j(i):"1/"+Math.round(i)}function Ht(a,t,e,i){let s=[xt(a+1)+" / "+xt(t)],n=e.exif;if(i&&n){let r=Rt(n);r&&s.push(r),n.lens&&s.push(Ft(n.lens)),n.focal_length&&s.push(j(n.focal_length)+"mm"),n.f_number&&s.push("f/"+j(n.f_number)),n.exposure&&s.push(qt(n.exposure)),n.iso&&s.push("ISO "+n.iso)}return s.join(" \xB7 ")}function Nt(a,t){a.textContent="",t.split(/\r?\n/).forEach((e,i)=>{i>0&&a.appendChild(document.createElement("br"));let s=e.split("*"),n=(s.length-1)%2===0;s.forEach((r,o)=>{let d=o%2===1;if(d&&(n||o!==s.length-1)){let h=document.createElement("em");h.textContent=r,a.appendChild(h)}else a.appendChild(document.createTextNode((d?"*":"")+r))})})}var Q=class{constructor(t){this.visible=!1;this.placement="";this.element=document.createElement("section"),this.element.className="caption",this.element.setAttribute("aria-live","polite"),this.meta=document.createElement("p"),this.meta.className="caption-meta",this.title=document.createElement("h2"),this.title.className="caption-title",this.text=document.createElement("p"),this.text.className="caption-text",this.alt=document.createElement("p"),this.alt.className="visually-hidden",this.element.append(this.meta,this.title,this.text,this.alt),t.appendChild(this.element)}set(t,e,i,s){this.meta.textContent=Ht(e,i,t,s),this.title.textContent=t.title??"",this.title.hidden=!t.title,Nt(this.text,t.caption??""),this.text.hidden=!t.caption,this.alt.textContent=t.alt??""}show(t){t!==this.visible&&(this.visible=t,this.element.classList.toggle("is-visible",t))}place(t,e,i){let s=Math.round(t)+","+Math.round(e)+","+Math.round(i);if(s===this.placement)return;this.placement=s;let n=this.element.style;n.width=Math.round(e)+"px",n.transform="translate3d("+Math.round(t)+"px,"+-Math.round(i)+"px,0)"}};var $=24,Mt=10,Dt=300,Wt=.35,Lt=.35,Ot=.2,Bt=2500;function _t(a,t,e,i){let s=3*a,n=3*(e-a)-s,r=1-s-n,o=3*t,d=3*(i-t)-o,h=1-o-d,g=m=>((r*m+n)*m+s)*m,k=m=>((h*m+d)*m+o)*m,L=m=>(3*r*m+2*n)*m+s;return m=>{if(m<=0)return 0;if(m>=1)return 1;let T=m;for(let l=0;l<8;l++){let u=g(T)-m,p=L(T);if(Math.abs(u)<1e-5)return k(T);if(Math.abs(p)<1e-6)break;T-=u/p}let c=0,w=1;T=m;for(let l=0;l<24;l++){let u=g(T);if(Math.abs(u-m)<1e-5)break;uthis.requestDraw(),onStatus:i=>{this.indicator.update(i),this.progress.update(i)}}),this.loaders[t]=e),e}measure(){let t=this.stage.getBoundingClientRect();this.vw=Math.max(1,t.width),this.vh=Math.max(1,t.height),this.dpr=Math.min(window.devicePixelRatio||1,this.settings.maxDpr);let e=Math.max(1,Math.round(this.vw*this.dpr)),i=Math.max(1,Math.round(this.vh*this.dpr));(this.canvas.width!==e||this.canvas.height!==i)&&(this.canvas.width=e,this.canvas.height=i),this.layouts=[],this.stops=[];let s=0;this.manifest.photos.forEach((n,r)=>{let o=Math.max(1,n.slides||1),d=Math.min(this.vw/(n.width/o),this.vh/n.height),h=n.width*d,g=n.height*d,k=h/o,L=s+$/2+(this.vw-k)/2;this.layouts.push({scale:d,width:h,height:g,section:k,slides:o,start:s,left:L,top:(this.vh-g)/2});for(let m=0;m{this.pointerId===null&&document.body.classList.add("is-idle")},Bt)}stopForHash(){let t=/^#(\d+)$/.exec(location.hash);if(!t)return 0;let e=Math.min(this.manifest.photos.length,Math.max(1,Number(t[1])))-1,i=this.stops.findIndex(s=>s.photo===e);return i<0?0:i}bind(){let t=this.stage;t.addEventListener("pointerdown",e=>this.onPointerDown(e)),t.addEventListener("pointermove",e=>this.onPointerMove(e)),t.addEventListener("pointerup",e=>this.onPointerUp(e,!1)),t.addEventListener("pointercancel",e=>this.onPointerUp(e,!0)),t.addEventListener("pointerleave",e=>{e.pointerType==="mouse"&&this.pointerId===null&&(this.hover=!1,this.updateCaption())}),t.addEventListener("dragstart",e=>e.preventDefault()),t.addEventListener("selectstart",e=>e.preventDefault()),this.settings.blockContextMenu&&t.addEventListener("contextmenu",e=>e.preventDefault()),window.addEventListener("keydown",e=>this.onKey(e)),window.addEventListener("hashchange",()=>{let e=this.stopForHash();this.stops[e].photo!==this.stops[this.current].photo&&this.jump(e)}),new ResizeObserver(()=>this.onResize()).observe(t),this.fade.addEventListener("transitionend",()=>{this.fade.style.opacity==="0"&&(this.fade.width=1,this.fade.height=1)})}onResize(){let t=this.vw+"x"+this.vh+"@"+this.dpr;this.measure(),t!==this.vw+"x"+this.vh+"@"+this.dpr&&(this.tween=null,this.camera=this.stops[this.current].camera,this.requestDraw(),clearTimeout(this.resizeTimer),this.resizeTimer=window.setTimeout(()=>this.startSession(),200))}onKey(t){if(t.altKey||t.ctrlKey||t.metaKey)return;this.wake();let e=t.target;if(!(e&&(e.isContentEditable||/^(INPUT|TEXTAREA|SELECT)$/.test(e.tagName)))){switch(t.key){case"ArrowRight":this.go(this.current+1);break;case"ArrowLeft":this.go(this.current-1);break;case"Home":this.go(0);break;case"End":this.go(this.stops.length-2);break;case"Escape":location.assign("/");break;case"i":case"I":this.pinned=!this.pinned,this.updateCaption();break;default:return}t.preventDefault()}}onPointerDown(t){this.pointerId!==null||t.pointerType==="mouse"&&t.button!==0||t.target.closest("a, button")||(this.pointerId=t.pointerId,this.pointerType=t.pointerType,this.dragging=!1,this.downX=t.clientX,this.downY=t.clientY,this.downT=t.timeStamp,this.tween=null,this.downCamera=this.camera,this.samples=[{t:t.timeStamp,x:t.clientX}],this.stage.setPointerCapture(t.pointerId))}onPointerMove(t){if(t.pointerType==="mouse"&&this.wake(),this.pointerId===null){t.pointerType==="mouse"&&(this.hover=this.inCaptionZone(t.clientX,t.clientY),this.updateCaption());return}if(t.pointerId!==this.pointerId)return;let e=t.clientX-this.downX,i=t.clientY-this.downY;if(!this.dragging&&Math.hypot(e,i)>=Mt&&(this.dragging=!0,this.stage.classList.add("is-dragging"),this.updateCaption()),!!this.dragging){for(this.samples.push({t:t.timeStamp,x:t.clientX});this.samples.length>2&&t.timeStamp-this.samples[0].t>100;)this.samples.shift();this.camera=this.rubber(this.downCamera-e),this.requestDraw()}}onPointerUp(t,e){if(t.pointerId!==this.pointerId)return;this.stage.hasPointerCapture(t.pointerId)&&this.stage.releasePointerCapture(t.pointerId),this.pointerId=null;let i=this.dragging;this.dragging=!1,this.stage.classList.remove("is-dragging");let s=Math.hypot(t.clientX-this.downX,t.clientY-this.downY);if(!e&&!i&&sr.t&&t.timeStamp-o.t<100&&(n=(o.x-r.x)/(o.t-r.t));let d=this.nearestStop(this.camera);if(!e&&Math.abs(n)>Wt)if(n<0){let h=this.stops.findIndex(g=>g.camera>this.camera+1);d=h<0?this.stops.length-1:h}else{let h=0;this.stops.forEach((g,k)=>{g.camera=i.left&&t.clientX<=i.right&&t.clientY>=i.top&&t.clientY<=i.bottom&&(this.pinned=!this.pinned,this.updateCaption())}rubber(t){let e=this.stops[0].camera,i=this.stops[this.stops.length-1].camera;return ti?i+(t-i)*Lt:t}nearestStop(t){let e=0;return this.stops.forEach((i,s)=>{Math.abs(i.camera-t){this.current=e,this.camera=s});else{let n=Math.abs(s-this.camera);n>.5?this.tween={from:this.camera,to:s,start:performance.now(),duration:240+200*Math.min(1,n/this.vw)}:this.camera=s,this.current=e}e!==i?this.activate(i):this.updateCaption(),this.requestDraw()}jump(t){let e=this.current;this.tween=null,this.crossfade(()=>{this.current=t,this.camera=this.stops[t].camera}),this.activate(e),this.requestDraw()}crossfade(t){let e=this.fade;(e.width!==this.canvas.width||e.height!==this.canvas.height)&&(e.width=this.canvas.width,e.height=this.canvas.height);let i=e.getContext("2d");i&&i.drawImage(this.canvas,0,0),e.style.transition="none",e.style.opacity="1",t(),this.render(performance.now()),requestAnimationFrame(()=>{requestAnimationFrame(()=>{e.style.transition="",e.style.opacity="0"})})}activate(t){let e=this.stops[this.current],i=t>=0?this.stops[t]:null;if(i&&i.photo>=0&&i.photo!==e.photo&&this.loaders[i.photo]?.stop(),this.loaders.forEach((s,n)=>{s&&n!==e.photo&&n!==e.photo+1&&s.stopPrefetch()}),e.photo<0&&(this.indicator.watch(null),this.progress.watch(null)),e.photo>=0){let s=this.manifest.photos[e.photo];this.caption.set(s,e.photo,this.manifest.photos.length,this.manifest.show_exif),(t>=0||location.hash!=="")&&location.hash!=="#"+(e.photo+1)&&history.replaceState(history.state,"","#"+(e.photo+1)),this.startSession()}this.syncNextStrip(),this.updateCaption()}startSession(){let t=this.stops[this.current];if(t.photo<0)return;let e=this.current,i=this.loader(t.photo);i.start(this.viewAt(t),this.dpr,()=>{this.current===e&&this.prefetchAround(e)}),this.indicator.watch(i),this.progress.watch(i)}prefetchAround(t){let e=this.stops[t],i=this.stops[t+1];if(!(!i||i.photo<0)){if(i.photo===e.photo){let s=this.loader(e.photo);s.prefetchLevel(this.viewAt(i),s.finalLevel);let n=this.stops.find(r=>r.photo===e.photo+1);n&&this.loader(n.photo).prefetchProbe(this.viewAt(n),this.dpr);return}this.loader(i.photo).prefetchProbe(this.viewAt(i),this.dpr)}}viewAt(t){let e=this.layouts[t.photo],i=t.camera-this.vw/2,s=Math.max(i,e.left),n=Math.min(i+this.vw,e.left+e.width),r=Math.max(0,e.top),o=Math.min(this.vh,e.top+e.height);return{displayWidth:e.width,u0:(s-e.left)/e.width,u1:(n-e.left)/e.width,v0:(r-e.top)/e.height,v1:(o-e.top)/e.height}}photoRect(t){let e=this.layouts[t],i=e.left-(this.camera-this.vw/2);return{left:Math.max(0,i),right:Math.min(this.vw,i+e.width),top:Math.max(0,e.top),bottom:Math.min(this.vh,e.top+e.height)}}inCaptionZone(t,e){let i=this.stops[this.current];if(i.photo<0)return!1;let s=this.stage.getBoundingClientRect(),n=t-s.left,r=e-s.top,o=this.layouts[i.photo],d=this.photoRect(i.photo),h=o.top+o.height*(1-Ot);return n>=d.left&&n<=d.right&&r>=h&&r<=d.bottom}updateCaption(){let t=this.stops[this.current],e=t.photo>=0&&!this.dragging&&(this.pinned||this.hover);if(e){let i=this.photoRect(t.photo);this.caption.place(i.left,i.right-i.left,this.vh-i.bottom)}this.caption.show(e),document.body.classList.toggle("has-caption",e)}loadNextAlbum(){this.indexRequested||!this.settings.indexUrl||(this.indexRequested=!0,fetch(this.settings.indexUrl,{credentials:"same-origin"}).then(t=>t.ok?t.json():Promise.reject(new Error("index"))).then(t=>this.showNextAlbum(t)).catch(()=>{this.indexRequested=!1}))}showNextAlbum(t){let e=t.albums;if(e.length===0)return;let i=e.findIndex(o=>o.slug===this.manifest.slug),s=e[(i+1)%e.length];if(!s||s.slug===this.manifest.slug)return;this.nextLink.href="/a/"+encodeURIComponent(s.slug)+"/";let n=this.nextLink.querySelector(".next-eyebrow"),r=this.nextLink.querySelector(".next-title");n&&(n.textContent="Next album"+(s.date?" \xB7 "+s.date:"")),r&&(r.textContent=s.title),s.cover&&(this.nextStrip=new O(this.nextFrame,s.cover,s.collapsed_focus_y??.5,{...this.env,tiles:t.tiles},()=>{}),this.nextLink.classList.add("has-strip"),this.layoutNextStrip(),this.syncNextStrip())}requestDraw(){this.frame===0&&(this.frame=requestAnimationFrame(t=>{this.frame=0,this.render(t)}))}render(t){let e=!1;if(this.tween){let L=Math.min(1,(t-this.tween.start)/this.tween.duration);this.camera=this.tween.from+(this.tween.to-this.tween.from)*Ut(L),L>=1?(this.tween=null,this.updateCaption()):e=!0}let i=this.g,s=this.canvas.width,n=this.canvas.height;i.setTransform(1,0,0,1,0,0),i.globalAlpha=1,i.fillStyle="#111114",i.fillRect(0,0,s,n);let r=this.camera-this.vw/2,o=r+this.vw,d=this.dpr,h=this.stops[this.current].photo,g=Math.max(0,(h<0?this.layouts.length-1:h)-2),k=Math.min(this.layouts.length-1,(h<0?this.layouts.length-1:h)+2);for(let L=g;L<=k;L++){let m=this.layouts[L];m.left+m.widtho||this.loader(L).draw({g:i,originX:(m.left-r)*d,originY:m.top*d,width:m.width*d,height:m.height*d,canvasWidth:s,canvasHeight:n,displayWidth:m.width,dpr:d,now:t})&&(e=!0)}this.endCard.style.transform="translate3d("+Math.round(this.endLeft-r)+"px,0,0)",this.caption.element.classList.contains("is-visible")&&this.tween&&this.updateCaption(),e&&this.requestDraw()}};async function Et(a){let t=await fetch(a,{credentials:"same-origin"});if(!t.ok)throw new Error(a+" "+t.status);return await t.json()}function Tt(a){return{scheduler:new Z(a.concurrency,a.workerUrl),cache:new U(dt())}}async function Vt(a,t){let e=await Et(t.manifestUrl);if(e.photos.length===0)return;let{scheduler:i,cache:s}=Tt(t);document.documentElement.classList.add("has-viewer"),new tt(a,e,t,{scheduler:i,cache:s,settings:t,tiles:e.tiles})}async function Yt(a,t){let e=await Et(t.indexUrl),{scheduler:i,cache:s}=Tt(t);new J(a,e,t,{scheduler:i,cache:s,settings:t,tiles:e.tiles})}function kt(){let a=wt(document.body);if(a.page==="album"){let t=document.getElementById("stage");t&&Vt(t,a).catch(e=>{t.dataset.error=String(e),document.documentElement.classList.remove("has-viewer")})}else if(a.page==="index"){let t=document.getElementById("strips");t&&Yt(t,a).catch(e=>{t.dataset.error=String(e)})}}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",kt,{once:!0}):kt();})(); +"use strict";(()=>{(function(r){let t={from:"Guoliang",to:"Lucio",letters:[{ch:"G",kind:"keep",shared:"M8.50 22.00L8.50 78.00A13.50 13.50 0 0 0 22.00 91.50L58.00 91.50",fullA:"M80.00 8.50L58.00 8.50L22.00 8.50A13.50 13.50 0 0 0 8.50 22.00L8.50 78.00A13.50 13.50 0 0 0 22.00 91.50L58.00 91.50A13.50 13.50 0 0 0 71.50 78.00L71.50 56.00L41.50 56.00",fullB:"M8.50 0.00L8.50 22.00L8.50 78.00A13.50 13.50 0 0 0 22.00 91.50L58.00 91.50L80.00 91.50",out:[{d:"M80.00 8.50L58.00 8.50L22.00 8.50A13.50 13.50 0 0 0 8.50 22.00",P:79.21,j:"end"},{d:"M58.00 91.50A13.50 13.50 0 0 0 71.50 78.00L71.50 56.00L41.50 56.00",P:73.21,j:"start"}],in:[{d:"M8.50 22.00L8.50 0.00",P:22,j:"start"},{d:"M58.00 91.50L80.00 91.50",P:22,j:"start"}],x0:0,x1:0,dot:null},{ch:"u",kind:"keep",shared:"M8.50 38.00L8.50 60.00L8.50 78.00A13.50 13.50 0 0 0 22.00 91.50L38.00 91.50A13.50 13.50 0 0 0 51.50 78.00L51.50 60.00L51.50 38.00",fullA:"M8.50 38.00L8.50 60.00L8.50 78.00A13.50 13.50 0 0 0 22.00 91.50L38.00 91.50A13.50 13.50 0 0 0 51.50 78.00L51.50 60.00L51.50 38.00",fullB:"M8.50 38.00L8.50 60.00L8.50 78.00A13.50 13.50 0 0 0 22.00 91.50L38.00 91.50A13.50 13.50 0 0 0 51.50 78.00L51.50 60.00L51.50 38.00",out:[],in:[],x0:88.8,x1:88,dot:null},{ch:"o",kind:"keep",shared:"M38.00 46.50L22.00 46.50A13.50 13.50 0 0 0 8.50 60.00L8.50 78.00A13.50 13.50 0 0 0 22.00 91.50L38.00 91.50",fullA:"M38.00 91.50A13.50 13.50 0 0 0 51.50 78.00L51.50 60.00A13.50 13.50 0 0 0 38.00 46.50L22.00 46.50A13.50 13.50 0 0 0 8.50 60.00L8.50 78.00A13.50 13.50 0 0 0 22.00 91.50L38.00 91.50",fullB:"M60.00 46.50L38.00 46.50L22.00 46.50A13.50 13.50 0 0 0 8.50 60.00L8.50 78.00A13.50 13.50 0 0 0 22.00 91.50L38.00 91.50L60.00 91.50",out:[{d:"M38.00 91.50A13.50 13.50 0 0 0 51.50 78.00L51.50 60.00A13.50 13.50 0 0 0 38.00 46.50",P:60.41,j:"both"}],in:[{d:"M38.00 46.50L60.00 46.50",P:22,j:"start"},{d:"M38.00 91.50L60.00 91.50",P:22,j:"start"}],x0:159,x1:158.2,dot:null},{ch:"l",kind:"fade",d:"M8.50 0.00L8.50 100.00",x0:230.8,x1:230.8,dot:null},{ch:"i",kind:"keep",shared:"M8.50 38.00L8.50 100.00",fullA:"M8.50 38.00L8.50 100.00",fullB:"M8.50 38.00L8.50 100.00",out:[],in:[],x0:262.8,x1:227.9,dot:[0,14,17]},{ch:"a",kind:"fade",d:"M38.00 91.50L51.50 91.50L51.50 78.00L51.50 60.00L51.50 46.50L38.00 46.50L22.00 46.50A13.50 13.50 0 0 0 8.50 60.00L8.50 78.00A13.50 13.50 0 0 0 22.00 91.50L38.00 91.50",x0:291.6,x1:291.6,dot:null},{ch:"n",kind:"fade",d:"M51.50 100.00L51.50 78.00L51.50 60.00A13.50 13.50 0 0 0 38.00 46.50L22.00 46.50A13.50 13.50 0 0 0 8.50 60.00L8.50 78.00L8.50 100.00",x0:362.7,x1:362.7,dot:null},{ch:"g",kind:"keep",shared:"M38.00 91.50A13.50 13.50 0 0 0 51.50 78.00L51.50 60.00A13.50 13.50 0 0 0 38.00 46.50L22.00 46.50A13.50 13.50 0 0 0 8.50 60.00L8.50 78.00A13.50 13.50 0 0 0 22.00 91.50L38.00 91.50",fullA:"M0.00 127.50L38.00 127.50A13.50 13.50 0 0 0 51.50 114.00L51.50 60.00A13.50 13.50 0 0 0 38.00 46.50L22.00 46.50A13.50 13.50 0 0 0 8.50 60.00L8.50 78.00A13.50 13.50 0 0 0 22.00 91.50L38.00 91.50A13.50 13.50 0 0 0 51.50 78.00L51.50 60.00",fullB:"M38.00 91.50A13.50 13.50 0 0 0 51.50 78.00L51.50 60.00A13.50 13.50 0 0 0 38.00 46.50L22.00 46.50A13.50 13.50 0 0 0 8.50 60.00L8.50 78.00A13.50 13.50 0 0 0 22.00 91.50L38.00 91.50",out:[{d:"M51.50 60.00L51.50 114.00A13.50 13.50 0 0 1 38.00 127.50L0.00 127.50",P:113.21,j:"start"}],in:[],x0:432.9,x1:256.7,dot:null}],pad:17,vbw:526.9,vbh:170,stroke:17,raysT:"translate(0.000 22.727) scale(0.7727)"},e="M47.6 70.7L71.9 61.1L71.1 58.2L45.2 62.0ZM44.9 61.5L61.2 40.9L59.1 38.8L38.5 55.1ZM38.0 54.8L41.8 28.9L38.9 28.1L29.3 52.4Z",i="http://www.w3.org/2000/svg",s=(c,w)=>{let d=document.createElementNS(i,c);for(let u in w)d.setAttribute(u,w[u]);return d},n=()=>r.matchMedia&&r.matchMedia("(prefers-reduced-motion: reduce)").matches,o=c=>Math.max(0,Math.min(1,c)),a=c=>c*c*(3-2*c),l=.5;function h(c,w){let d=0,u=0,p=null,g=0;function A(y){let b=(y-g)/w;g=y,d=dv(1),reverse:()=>v(0),toggle:()=>v(u?0:1),set:y=>{cancelAnimationFrame(p),p=null,u=d=y,c(d)},stop:()=>{cancelAnimationFrame(p),p=null},get t(){return d}}}function m(c,w,d,u){let p=o(u)*w;if(c.style.visibility=p<.05?"hidden":"visible",d==="both"){let g=p/2;c.setAttribute("stroke-dasharray",g.toFixed(2)+" "+Math.max(0,w-2*g).toFixed(2)+" "+g.toFixed(2)),c.setAttribute("stroke-dashoffset","0")}else d==="end"?(c.setAttribute("stroke-dasharray",p.toFixed(2)+" "+(2*w+20).toFixed(2)),c.setAttribute("stroke-dashoffset",(-(w-p)).toFixed(2))):(c.setAttribute("stroke-dasharray",p.toFixed(2)+" "+(2*w+20).toFixed(2)),c.setAttribute("stroke-dashoffset","0"))}function M(c,w={}){let d=Object.assign({trigger:"hover",color:"currentColor",rays:"#FFF3CF",duration:450,autoDelay:1800},w),u=s("svg",{viewBox:"0 0 "+t.vbw+" "+t.vbh,role:"img","aria-label":"Guoliang Chen, Lucio"});u.style.display="block",u.style.width="100%",u.style.height="auto";let p=s("g",{transform:"translate("+t.pad+" "+t.pad+")",fill:"none",stroke:d.color,"stroke-width":t.stroke,"stroke-linejoin":"miter","stroke-linecap":"butt"});u.appendChild(p);let g=t.letters.map(b=>{let x=s("g",{transform:"translate("+b.x0+" 0)"});p.appendChild(x);let k=Object.assign({g:x,outEls:[],inEls:[]},b);if(b.kind==="fade")k.fadeEl=s("path",{d:b.d}),x.appendChild(k.fadeEl);else{k.fullA=s("path",{d:b.fullA}),x.appendChild(k.fullA),k.fullB=s("path",{d:b.fullB}),x.appendChild(k.fullB),b.shared&&x.appendChild(s("path",{d:b.shared}));for(let E of b.out){let S=s("path",{d:E.d});x.appendChild(S),k.outEls.push([S,E])}for(let E of b.in){let S=s("path",{d:E.d});x.appendChild(S),k.inEls.push([S,E])}}return b.dot&&(k.dotEl=s("rect",{x:b.dot[0],y:b.dot[1],width:b.dot[2],height:b.dot[2],rx:b.dot[2]*.22,fill:d.color,stroke:"none"}),x.appendChild(k.dotEl)),k}),A=s("path",{d:e,fill:d.rays,stroke:"none",opacity:0});p.appendChild(A),c.appendChild(u);function v(b){let x=a(o(b/l)),k=a(o((b-l)/(1-l)));for(let E of g){if(E.kind==="fade")E.fadeEl.setAttribute("opacity",(1-x).toFixed(3)),E.dotEl&&E.dotEl.setAttribute("opacity",(1-x).toFixed(3));else{for(let[S,C]of E.outEls)m(S,C.P,C.j,1-x);for(let[S,C]of E.inEls)m(S,C.P,C.j,x);E.fullA.style.visibility=x<=.001?"visible":"hidden",E.fullB.style.visibility=x>=.999?"visible":"hidden"}E.g.setAttribute("transform","translate("+(E.x0+(E.x1-E.x0)*k).toFixed(2)+" 0)")}A.setAttribute("transform","translate("+(g[0].x0+(g[0].x1-g[0].x0)*k).toFixed(2)+" 0) "+t.raysT),A.setAttribute("opacity",o((b-.8)/.2).toFixed(3))}let y=h(v,d.duration);return v(0),d.trigger==="hover"&&(c.addEventListener("mouseenter",y.play),c.addEventListener("mouseleave",y.reverse),c.addEventListener("focus",y.play),c.addEventListener("blur",y.reverse)),d.trigger==="click"&&c.addEventListener("click",y.toggle),d.trigger==="auto"&&setInterval(y.toggle,d.autoDelay+d.duration),Object.assign(y,{svg:u})}let L={C:[0,.75],L:[.25,.75],U:[.25,1],I:[.75,1],O:[.75,1.75]};function f(c,w,d){let u=w/2,p=d-u,g=u+p,A=p*Math.SQRT1_2,v=b=>b.toFixed(3);return{d:"M"+v(c-g+A)+" "+v(g-A)+"A"+v(p)+" "+v(p)+" 0 0 0 "+v(c-g)+" "+v(u)+"H"+v(g)+"A"+v(p)+" "+v(p)+" 0 0 0 "+v(u)+" "+v(g)+"V"+v(c-g)+"A"+v(p)+" "+v(p)+" 0 0 0 "+v(g)+" "+v(c-u)+"H"+v(c-g)+"A"+v(p)+" "+v(p)+" 0 0 0 "+v(c-u)+" "+v(c-g)+"V"+v(g)+"A"+v(p)+" "+v(p)+" 0 0 0 "+v(c-g+A)+" "+v(g-A)+"Z",P:4*(c-2*g)+2*Math.PI*p}}function T(c,w={}){let d=Object.assign({sequence:"LUCIO",color:"#F3F1EC",track:"#26262D",rays:"#FFF3CF",hold:480,morph:640,size:96,stroke:.17,radius:.22},w),u=120,p=u*d.stroke,g=u*d.radius,A=f(u,p,g),v=s("svg",{viewBox:"0 0 "+u+" "+u,width:d.size,height:d.size,role:"img","aria-label":"Loading"});d.track&&v.appendChild(s("path",{d:A.d,fill:"none",stroke:d.track,"stroke-width":p}));let y=s("path",{d:A.d,fill:"none",stroke:d.color,"stroke-width":p,"stroke-linecap":"butt"}),b=p/22,x=s("path",{d:e,fill:d.rays,transform:"translate("+(p-22*b).toFixed(3)+" "+(u-p-78*b).toFixed(3)+") scale("+b.toFixed(4)+")",opacity:0});v.appendChild(y),v.appendChild(x);let k=(R,D)=>{let I=Math.min(1,Math.max(0,D-R))*A.P;y.setAttribute("stroke-dasharray",I.toFixed(3)+" "+Math.max(0,A.P-I).toFixed(3)),y.setAttribute("stroke-dashoffset",(-R*A.P).toFixed(3))},E=(R,D)=>{let[I,_]=L[D];for(let F=-1;F<6;F++)if(I+F>=R[0]-1e-6&&_+F>=R[1]-1e-6)return[I+F,_+F];return[I,_]},S=d.sequence.split(""),C=0,P=L[S[0]].slice(),st,nt,lt=!1;k(P[0],P[1]),x.setAttribute("opacity",S[0]==="L"?1:0);function dt(){if(lt)return;let R=(C+1)%S.length,D=E(P,S[R]),I=P.slice(),_=S[C]==="L",F=S[R]==="L",ct=()=>{P=D;let Y=Math.floor(P[0]);P[0]-=Y,P[1]-=Y,C=R,k(P[0],P[1]),x.setAttribute("opacity",F?1:0),nt=setTimeout(dt,d.hold)};if(n()){ct();return}let qt=performance.now(),ut=Y=>{let q=Math.min(1,(Y-qt)/d.morph),mt=q<.5?4*q*q*q:1-Math.pow(-2*q+2,3)/2;k(I[0]+(D[0]-I[0])*mt,I[1]+(D[1]-I[1])*mt),x.setAttribute("opacity",F?Math.max(0,(q-.6)/.4).toFixed(3):_?Math.max(0,1-q*2.5).toFixed(3):0),q<1?st=requestAnimationFrame(ut):ct()};st=requestAnimationFrame(ut)}return nt=setTimeout(dt,d.hold),c.appendChild(v),{svg:v,stop:()=>{lt=!0,cancelAnimationFrame(st),clearTimeout(nt)}}}r.LucioMorph={wordmark:M,loader:T}})(window);var O={graphite:"#111114",graphite3:"#26262D",paper:"#F3F1EC",beam:"#FFF3CF"};function rt(){return window.LucioMorph??null}function W(r,t){let e=rt();if(!e)return null;let i=document.createElement("span");i.className="wordmark-svg",i.setAttribute("aria-hidden","true"),r.appendChild(i);let s=e.wordmark(i,{trigger:"manual",color:O.paper,rays:O.beam});return s.svg.setAttribute("aria-hidden","true"),s.svg.removeAttribute("role"),t||s.set(1),r.classList.add("has-svg"),s}function pt(){let r=document.getElementById("chop-template");if(!(r instanceof HTMLTemplateElement))return null;let t=r.content.firstElementChild;return t?t.cloneNode(!0):null}function Nt(r){let t=r.seed+"|"+r.level+"|"+r.x+"|"+r.y,e=2166136261;for(let i=0;i>>0;return e}function Dt(r,t){let e=new Array(r);for(let n=0;n{i=i+1831565813|0;let n=Math.imul(i^i>>>15,1|i);return n=n+Math.imul(n^n>>>7,61|n)^n,((n^n>>>14)>>>0)/4294967296};for(let n=r-1;n>0;n--){let o=Math.floor(s()*(n+1)),a=e[n];e[n]=e[o],e[o]=a}return e}function ft(r,t,e,i,s){r.drawImage(t,0,0);let n=s.cell,o=Math.floor(e/n),a=Math.floor(i/n),l=o*a;if(l<2)return;let h=Dt(l,Nt(s));for(let m=0;m"u"||e==="")return;let i=(navigator.hardwareConcurrency??2)>=4?2:1;for(let s=0;sthis.onReply(a.data,o),n.onerror=()=>this.dropWorker(o),this.workers.push(n)}catch{break}}request(t,e,i,s,n){return s.aborted?Promise.reject(new H):new Promise((o,a)=>{let l=this.byId.get(t);l?i{m.waiters.delete(h)&&(a(new H),m.waiters.size===0&&setTimeout(()=>{m.waiters.size===0&&this.byKey.get(m.key)===m&&this.cancel(m)},0))},{once:!0}),this.pump()})}cancelAll(){for(let t of[...this.byKey.values()]){let e=[...t.waiters];t.waiters.clear();for(let i of e)i.reject(new H);this.cancel(t)}}cancel(t){if(this.forget(t),!t.running){let e=this.queue.indexOf(t);e>=0&&this.queue.splice(e,1);return}t.running=!1,this.running--,t.controller?t.controller.abort():t.worker>=0&&this.workers[t.worker]&&this.workers[t.worker].postMessage({type:"abort",key:t.key}),this.pump()}forget(t){this.byId.get(t.id)===t&&this.byId.delete(t.id),this.byKey.delete(t.key)}pump(){for(;this.running0;){let t=0;for(let i=1;i0&&(!t.scramble||this.workersUnscramble)){let i=e[this.nextWorker++%e.length];t.worker=i,this.workers[i].postMessage({type:"fetch",key:t.key,url:t.url,scramble:t.scramble});return}this.runOnMainThread(t)}runOnMainThread(t){t.worker=-1,t.controller=new AbortController,this.fetchOnMainThread(t,t.controller.signal)}liveWorkers(){let t=[];return this.workers.forEach((e,i)=>{e&&t.push(i)}),t}dropWorker(t){let e=this.workers[t];if(e){e.terminate(),delete this.workers[t];for(let i of this.byKey.values())i.running&&i.worker===t&&this.runOnMainThread(i)}}async fetchOnMainThread(t,e){let i=performance.now();try{let s=await fetch(t.url,{signal:e,credentials:"same-origin"});if(!s.ok)throw new Error("HTTP "+s.status);let n=await s.blob(),o=performance.now()-i,a=await at(n);t.scramble&&(a=await Wt(a,t.scramble)),this.onReply({key:t.key,ok:!0,bitmap:a,bytes:n.size,ms:o},-1)}catch(s){this.onReply({key:t.key,ok:!1,bytes:0,ms:0,error:String(s)},-1)}}onReply(t,e){let i=this.byKey.get(t.key);if(!i||!i.running||i.worker!==e){t.bitmap&&N(t.bitmap);return}if(!t.ok&&e>=0&&(t.error==="unsupported-bitmap"||t.error==="unsupported-offscreen")){t.error==="unsupported-bitmap"?this.dropWorker(e):(this.workersUnscramble=!1,this.runOnMainThread(i));return}i.running=!1,this.running--,this.forget(i);let s=[...i.waiters];if(i.waiters.clear(),t.ok&&t.bitmap){let n={bitmap:t.bitmap,bytes:t.bytes,ms:t.ms};for(let o of s)o.resolve(n);s.length===0&&N(t.bitmap)}else{let n=new Error(t.error??"tile failed");for(let o of s)o.reject(n)}this.pump()}};var bt=1024*1024;function Ot(){let r=navigator.deviceMemory;if(typeof r=="number"&&r<=4)return!0;let t=typeof matchMedia=="function"&&matchMedia("(pointer: coarse)").matches,e=Math.min(screen.width,screen.height);return t&&e<=820}function gt(){return Ot()?120*bt:250*bt}var X=class{constructor(t){this.budget=t;this.entries=new Map;this.used=0}get(t){let e=this.entries.get(t);return e&&(this.entries.delete(t),this.entries.set(t,e)),e}has(t){return this.entries.has(t)}put(t,e){let i=this.entries.get(t);if(i){i.bitmap!==e&&N(e);return}let s=e.width*e.height*4;this.entries.set(t,{bitmap:e,bytes:s,at:performance.now()}),this.used+=s,this.trim(this.budget)}trim(t){for(;this.used>t&&this.entries.size>0;){let e=this.entries.keys().next();if(e.done)return;let i=this.entries.get(e.value);this.entries.delete(e.value),i&&(this.used-=i.bytes,N(i.bitmap))}}};var Bt=400,B=class{constructor(t,e=()=>!0){this.canShow=e;this.handle=null;this.loader=null;this.timer=0;this.hideTimer=0;this.visible=!1;this.element=document.createElement("div"),this.element.className="busy",this.element.setAttribute("role","status"),this.element.setAttribute("aria-label","Loading"),t.appendChild(this.element)}watch(t){if(t===this.loader){this.update(t);return}this.loader=t,clearTimeout(this.timer),this.timer=0,this.hide(),this.update(t)}update(t){if(!t||t!==this.loader)return;let e=t.status;if(!e.active||e.sharp){clearTimeout(this.timer),this.timer=0,this.hide();return}if(!this.visible&&this.timer===0){let i=Math.max(0,Bt-(performance.now()-e.started));this.timer=window.setTimeout(()=>this.check(),i)}}check(){this.timer=0;let t=this.loader;if(!(!t||!t.status.active||t.status.sharp)){if(!this.canShow()){this.timer=window.setTimeout(()=>this.check(),100);return}this.show()}}show(){if(!this.visible){if(clearTimeout(this.hideTimer),this.visible=!0,!this.handle){let t=rt();t&&(this.handle=t.loader(this.element,{size:56,color:O.paper,track:O.graphite3,rays:O.beam}),this.handle.svg.setAttribute("aria-hidden","true"))}this.element.classList.add("is-visible")}}hide(){this.visible&&(this.visible=!1,this.element.classList.remove("is-visible"),clearTimeout(this.hideTimer),this.hideTimer=window.setTimeout(()=>{!this.visible&&this.handle&&(this.handle.stop(),this.handle.svg.remove(),this.handle=null)},300))}},z=class{constructor(t){this.loader=null;this.shown=!1;this.value=-1;this.element=document.createElement("div"),this.element.className="progress",this.element.setAttribute("aria-hidden","true"),t.appendChild(this.element)}watch(t){this.loader=t,this.value=-1,this.update(t)}update(t){if(!t||t!==this.loader)return;let e=t.status,i=e.active&&!e.sharp&&e.planned>0,s=e.planned>0?Math.min(1,e.done/e.planned):0;i!==this.shown&&(this.shown=i,this.element.classList.toggle("is-visible",i));let n=Math.round(s*1e3)/1e3;n!==this.value&&(this.value=n,this.element.style.transform="scaleX("+(i?n:1)+")")}};function J(r,t,e){let i=t*e;for(let s=0;s=i)return s;return r.levels.length-1}function Z(r,t,e){let i=Math.max(0,t.u0*r.width),s=Math.min(r.width,t.u1*r.width),n=Math.max(0,t.v0*r.height),o=Math.min(r.height,t.v1*r.height);return s<=i||o<=n?null:{x0:Math.min(r.cols-1,Math.floor(i/e)),x1:Math.min(r.cols-1,Math.ceil(s/e)-1),y0:Math.min(r.rows-1,Math.floor(n/e)),y1:Math.min(r.rows-1,Math.ceil(o/e)-1)}}function yt(r,t,e,i){let s=r.levels[t],n=Z(s,e,i);if(!n)return[];let o=(e.u0+e.u1)/2*s.width,a=(e.v0+e.v1)/2*s.height,l=[];for(let h=n.y0;h<=n.y1;h++)for(let m=n.x0;m<=n.x1;m++){let M=(m*i+Math.min((m+1)*i,s.width))/2,L=(h*i+Math.min((h+1)*i,s.height))/2;l.push({level:t,x:m,y:h,index:h*s.cols+m,distance:(M-o)**2+(L-a)**2})}return l.sort((h,m)=>h.distance-m.distance),l.map(({level:h,x:m,y:M,index:L})=>({level:h,x:m,y:M,index:L}))}function wt(r,t,e,i,s,n,o,a,l,h){let m=i*n,M=Math.min((i+1)*n,e.width),L=s*n,f=Math.min((s+1)*n,e.height),T=i>0?m-o:0,c=s>0?L-o:0,w=Math.round(a+m*h),d=Math.round(a+M*h),u=Math.round(l+L*h),p=Math.round(l+f*h);if(d<=w||p<=u)return;let g=Math.max(T,(w-a)/h),A=Math.min(T+t.width,(d-a)/h),v=Math.max(c,(u-l)/h),y=Math.min(c+t.height,(p-l)/h);A<=g||y<=v||r.drawImage(t,g-T,v-c,A-g,y-v,w,u,d-w,p-u)}var xt="luphoto.throughput";function Mt(){try{let r=Number(sessionStorage.getItem(xt));return Number.isFinite(r)&&r>0?r:null}catch{return null}}function Lt(){return Mt()??1e3}function Et(r){let t=Mt(),e=t===null?r:t*(1-.5)+r*.5;try{sessionStorage.setItem(xt,String(e))}catch{return e}return e}var ht=180,Tt=400;function Ut(r,t){return new Promise((e,i)=>{if(t.aborted){i(new H);return}let s=setTimeout(()=>{t.removeEventListener("abort",n),e()},r),n=()=>{clearTimeout(s),i(new H)};t.addEventListener("abort",n,{once:!0})})}var kt=3,G=4,U=class{constructor(t,e){this.pyramid=t;this.env=e;this.seedImage=null;this.seedPromise=null;this.session=null;this.prefetchController=null;this.finalLevel=-1;this.targetLevel=-1;this.status={active:!1,started:0,planned:0,done:0,sharp:!1}}tileUrl(t){let e=this.env.tiles;return e.path+this.pyramid.hash+"/"+t+"."+e.format}ensureSeed(){return this.seedPromise||(this.seedPromise=this.decodeSeed().then(()=>this.env.requestDraw(),()=>{})),this.seedPromise}async decodeSeed(){if(!this.pyramid.seed)return;let t=atob(this.pyramid.seed),e=new Uint8Array(t.length);for(let a=0;a!this.env.cache.has(i[s.index]))}uncachedBytes(t,e){let i=this.pyramid.levels[t].bytes,s=0;for(let n of this.uncached(t,e))s+=i[n.index];return s}fetchAll(t,e,i){return Promise.allSettled(t.map(s=>this.fetchTile(s,e,i)))}probeLevel(t,e){return Math.max(0,J(this.pyramid,t.displayWidth,e)-kt)}notify(){this.env.onStatus?.(this)}track(t,e,i){return this.status.planned+=t.length,this.notify(),Promise.allSettled(t.map(s=>this.fetchTile(s,vt,i).finally(()=>{this.session===e&&(this.status.done++,this.notify())})))}start(t,e,i){this.stopSession();let s=new AbortController;this.session=s,this.targetLevel=-1,this.status.active=!0,this.status.started=performance.now(),this.status.planned=0,this.status.done=0,this.status.sharp=!1,this.notify(),this.run(t,e,s).then(()=>{this.session===s&&(this.session=null,this.status.active=!1,this.notify()),(!s.signal.aborted||s.signal.reason==="deadline")&&i()})}async run(t,e,i){let s=i.signal,n=performance.now(),o=this.env.settings.budgetMs,a=setTimeout(()=>i.abort("deadline"),o);try{if(await this.ensureSeed(),s.aborted)return;let l=J(this.pyramid,t.displayWidth,e),h=Math.max(0,l-kt),m=this.uncached(h,t).slice(0,2);if(m.length>0){let c=await this.track(m,i,s),w=0,d=0;for(let u of c)u.status==="fulfilled"&&(w+=u.value.bytes,d=Math.max(d,u.value.ms));w>0&&d>0&&Et(w/d)}if(s.aborted)return;this.finalLevel=Math.max(this.finalLevel,h);let M=Lt(),L=o-(performance.now()-n),f=h;for(let c=l;c>h;c--)if(this.uncachedBytes(c,t)/M<=L*.8){f=c;break}let T=[];f-h>=2&&T.push(Math.floor((h+f)/2)),f>h&&T.push(f),this.finalLevel=f,this.targetLevel=f,this.env.requestDraw();for(let c of T)if(await this.track(this.uncached(c,t),i,s),s.aborted)return}finally{clearTimeout(a)}}prefetchProbe(t,e){let i=this.resetPrefetch();this.ensureSeed().then(()=>{i.signal.aborted||this.fetchAll(this.uncached(this.probeLevel(t,e),t),ot,i.signal)})}prefetchLevel(t,e){if(e<0)return;let i=this.resetPrefetch();this.fetchAll(this.uncached(e,t),ot,i.signal)}resetPrefetch(){return this.prefetchController?.abort(),this.prefetchController=new AbortController,this.prefetchController}stopPrefetch(){this.prefetchController?.abort(),this.prefetchController=null}stopSession(){this.session&&(this.session.abort("superseded"),this.session=null,this.status.active=!1,this.notify())}stop(){this.stopSession(),this.stopPrefetch()}draw(t){let{g:e,originX:i,originY:s,width:n,height:o,canvasWidth:a,canvasHeight:l}=t,h=Math.max(0,i),m=Math.max(0,s),M=Math.min(a,i+n),L=Math.min(l,s+o);if(M<=h||L<=m)return!1;this.seedPromise||this.ensureSeed();let f={displayWidth:t.displayWidth,u0:(h-i)/n,u1:(M-i)/n,v0:(m-s)/o,v1:(L-s)/o},T=this.env.tiles.tile_size,c=this.env.tiles.overlap,w=this.env.cache,d=this.pyramid.levels,u=J(this.pyramid,t.displayWidth,t.dpr),p=-1;for(let y=u;y>=0&&p<0;y--){let b=Z(d[y],f,T);if(!b)continue;let x=!0;for(let k=b.y0;k<=b.y1&&x;k++)for(let E=b.x0;E<=b.x1;E++){let S=w.get(d[y].tiles[k*d[y].cols+E]);if(!S||t.now-S.at=0?Math.min(this.targetLevel,u):u,A=p>=g;A!==this.status.sharp&&(this.status.sharp=A,queueMicrotask(()=>this.notify()));let v=!1;for(let y=Math.max(0,p);y<=u;y++){let b=d[y],x=Z(b,f,T);if(!x)continue;let k=n/b.width;e.imageSmoothingEnabled=!0,e.imageSmoothingQuality=k<1?"high":"medium";for(let E=x.y0;E<=x.y1;E++)for(let S=x.x0;S<=x.x1;S++){let C=w.get(b.tiles[E*b.cols+S]);if(!C)continue;let P=t.now-C.at;Pthis.requestDraw(),onStatus:()=>this.onStatus(this)})}get isOpen(){return this.expanded}get isNear(){return this.near}layout(t){let e=this.cover,i=Math.max(t.width/e.width,t.open/e.height),s=e.width*i,n=e.height*i,o=(t.open-n)/2,a=o+this.focusY*n,l=Math.max(0,Math.min(t.open-t.closed,a-t.closed/2)),h=this.geometry;this.geometry={width:t.width,closed:t.closed,open:t.open,dpr:t.dpr,coverWidth:s,coverHeight:n,x:(t.width-s)/2,y:o,band:l},this.canvas&&(this.sizeCanvas(this.canvasOpen),this.drawNow()),this.near&&h&&(h.width!==t.width||h.closed!==t.closed||h.open!==t.open||h.dpr!==t.dpr)&&this.startSession()}attach(){if(this.canvas)return;let t=document.createElement("canvas");t.className="strip-canvas",t.setAttribute("aria-hidden","true");let e=t.getContext("2d",{alpha:!1});e&&(this.canvas=t,this.g=e,this.element.prepend(t),this.sizeCanvas(this.expanded),this.drawNow())}detach(){this.canvas&&(cancelAnimationFrame(this.frame),this.frame=0,this.canvas.width=0,this.canvas.height=0,this.canvas.remove(),this.canvas=null,this.g=null)}setNear(t){t!==this.near&&(this.near=t,t?this.startSession():this.loader.stop())}setOpen(t){if(t===this.expanded)return;this.expanded=t,this.element.classList.toggle("is-open",t),clearTimeout(this.settleTimer);let e=this.geometry,i=this.canvas;t?i&&this.canvasOpen?(i.style.transition="",i.style.transform="translate3d(0,0,0)"):i&&e&&(this.sizeCanvas(!0),i.style.transition="none",i.style.transform="translate3d(0,"+-e.band+"px,0)",this.drawNow(),requestAnimationFrame(()=>{requestAnimationFrame(()=>{this.expanded&&this.canvas===i&&(i.style.transition="",i.style.transform="translate3d(0,0,0)")})})):i&&e&&(i.style.transition="",i.style.transform="translate3d(0,"+-e.band+"px,0)",this.settleTimer=window.setTimeout(()=>{!this.expanded&&this.canvas===i&&(this.sizeCanvas(!1),this.drawNow())},Vt)),this.near&&this.startSession()}sizeCanvas(t){let e=this.canvas,i=this.geometry;if(!e||!i)return;this.canvasOpen=t;let s=t?i.open:i.closed,n=Math.max(1,Math.round(i.width*i.dpr)),o=Math.max(1,Math.round(s*i.dpr));(e.width!==n||e.height!==o)&&(e.width=n,e.height=o),e.style.height=s+"px",t||(e.style.transition="none",e.style.transform="translate3d(0,0,0)")}view(){let t=this.geometry;if(!t)return null;let e=this.expanded?0:t.band,i=this.expanded?t.open:t.closed;return{displayWidth:t.coverWidth,u0:Math.max(0,-t.x/t.coverWidth),u1:Math.min(1,(t.width-t.x)/t.coverWidth),v0:Math.max(0,(e-t.y)/t.coverHeight),v1:Math.min(1,(e+i-t.y)/t.coverHeight)}}startSession(){let t=this.view();!t||!this.geometry||this.loader.start(t,this.geometry.dpr,()=>{})}requestDraw(){this.frame===0&&this.canvas&&(this.frame=requestAnimationFrame(t=>{this.frame=0,this.draw(t)&&this.requestDraw()}))}drawNow(){this.draw(performance.now())&&this.requestDraw()}draw(t){let e=this.g,i=this.canvas,s=this.geometry;if(!e||!i||!s)return!1;e.setTransform(1,0,0,1,0,0),e.globalAlpha=1,e.fillStyle="#111114",e.fillRect(0,0,i.width,i.height);let n=this.canvasOpen?0:-s.band;return this.loader.draw({g:e,originX:s.x*s.dpr,originY:(s.y+n)*s.dpr,width:s.coverWidth*s.dpr,height:s.coverHeight*s.dpr,canvasWidth:i.width,canvasHeight:i.height,displayWidth:s.coverWidth,dpr:s.dpr,now:t})}};var _t=24,j=class{constructor(t,e,i,s){this.root=t;this.settings=i;this.env=s;this.strips=[];this.onScreen=new Set;this.inView=new Set;this.suspended=!1;this.wordmark=null;this.opened=null;this.scrollFrame=0;this.sizeKey="";let n=Array.from(t.querySelectorAll("a.strip")),o=new Map(e.albums.map(l=>[l.slug,l]));for(let l of n){let h=o.get(l.dataset.slug??"");!h||!h.cover||this.strips.push(new V(l,h.cover,h.collapsed_focus_y??.5,s,m=>this.onStripStatus(m)))}this.hoverMode=matchMedia("(hover: hover) and (pointer: fine)");let a=document.querySelector(".site-header .wordmark");if(this.indicator=new B(document.body,()=>!this.wordmarkMoving()),a){this.wordmark=W(a,!0);let l=()=>{this.wordmark&&!this.indicator.visible&&this.wordmark.play()},h=()=>this.wordmark?.reverse();a.addEventListener("mouseenter",l),a.addEventListener("mouseleave",h),a.addEventListener("focus",l),a.addEventListener("blur",h)}document.documentElement.classList.add("has-strips"),this.measure(),this.observe(),this.bind()}suspend(t){if(!this.suspended){this.suspended=!0;for(let e of this.strips)e.loader.stop(),t&&e.detach();this.env.scheduler.cancelAll(),this.env.cache.trim(t?0:this.env.cache.budget/4)}}resume(){if(this.suspended){this.suspended=!1;for(let t of this.strips)this.inView.has(t)&&t.attach(),t.isNear&&t.startSession()}}wordmarkMoving(){let t=this.wordmark?.t??0;return t>0&&t<1}measure(){let t=this.root.clientWidth||window.innerWidth,e=window.innerHeight,i=Math.round(Math.min(t*6/32,e*.28)),s=Math.round(Math.min(t*9/32,e*.62)),n=Math.min(window.devicePixelRatio||1,this.settings.maxDpr),o=t+"x"+i+"x"+s+"@"+n;if(o!==this.sizeKey){this.sizeKey=o,this.root.style.setProperty("--strip-closed",i+"px"),this.root.style.setProperty("--strip-open",s+"px");for(let a of this.strips)a.layout({width:t,closed:i,open:s,dpr:n})}}observe(){let t=new Map(this.strips.map(n=>[n.element,n])),e=new IntersectionObserver(n=>{for(let o of n)t.get(o.target)?.setNear(o.isIntersecting)},{rootMargin:"100% 0px"}),i=new IntersectionObserver(n=>{for(let o of n){let a=t.get(o.target);a&&(o.isIntersecting?(this.inView.add(a),this.suspended||a.attach()):(this.inView.delete(a),a.detach()))}},{rootMargin:"25% 0px"}),s=new IntersectionObserver(n=>{for(let o of n){let a=t.get(o.target);a&&(o.isIntersecting?this.onScreen.add(a):this.onScreen.delete(a))}this.watchFirst(),this.scheduleCentre()});for(let n of this.strips)e.observe(n.element),i.observe(n.element),s.observe(n.element)}watchFirst(){let t=this.strips.find(e=>this.onScreen.has(e))??null;this.indicator.watch(t?t.loader:null)}onStripStatus(t){this.indicator.update(t.loader)}bind(){for(let t of this.strips){let e=t.element;e.addEventListener("mouseenter",()=>{this.hoverMode.matches&&this.open(t)}),e.addEventListener("mouseleave",()=>{this.hoverMode.matches&&this.opened===t&&this.open(null)}),e.addEventListener("focus",()=>this.open(t)),e.addEventListener("blur",()=>{this.opened===t&&!this.hoverMode.matches?this.scheduleCentre():this.opened===t&&this.open(null)}),e.addEventListener("dragstart",i=>i.preventDefault()),this.settings.blockContextMenu&&e.addEventListener("contextmenu",i=>i.preventDefault())}window.addEventListener("scroll",()=>this.scheduleCentre(),{passive:!0}),new ResizeObserver(()=>{this.measure(),this.scheduleCentre()}).observe(this.root)}open(t){t!==this.opened&&(this.opened?.setOpen(!1),this.opened=t,t?.setOpen(!0))}scheduleCentre(){this.hoverMode.matches||this.scrollFrame!==0||(this.scrollFrame=requestAnimationFrame(()=>{this.scrollFrame=0,this.pickCentre()}))}pickCentre(){if(this.hoverMode.matches)return;let t=window.innerHeight/2,e=null,i=1/0,s=1/0;for(let n of this.onScreen){let o=n.element.getBoundingClientRect(),a=Math.abs(o.top+o.height/2-t);a{let n=Number(i);return Number.isFinite(n)&&n>0?n:s};return{page:t.page??"",build:t.build??"",slug:t.album??"",manifestUrl:t.manifest??"",indexUrl:t.index??"",workerUrl:t.worker??"",budgetMs:e(t.budgetMs,3e3),maxDpr:e(t.maxDpr,2),concurrency:Math.max(1,Math.round(e(t.concurrency,6))),blockContextMenu:t.blockContextMenu!=="false"}}var Yt=/[㐀-鿿豈-﫿]/;function Q(r,t){Yt.test(t)?r.lang="zh":r.removeAttribute("lang")}function At(r){return r<10?"0"+r:String(r)}function Kt(r){let t=(r.model??"").trim(),e=(r.make??"").trim(),i=e.split(/\s+/)[0]??"";i&&t.toLowerCase().startsWith(i.toLowerCase()+" ")&&(t=t.slice(i.length+1).trim());let s=/^([A-Za-z]{1,3}) (\d+[A-Za-z0-9]*)$/.exec(t);return s&&(t=s[1]+s[2]),t||e}function Xt(r){let t=/(\d+(?:\.\d+)?(?:-\d+(?:\.\d+)?)?)\s*mm\s*(?:F|f\/?)\s*([\d.]+(?:-[\d.]+)?)/.exec(r);return t?t[1]+" f/"+t[2]:r.trim()}function $(r){return String(Math.round(r*10)/10)}function zt(r){let t=r.trim();if(t.includes("/")||t.endsWith("s"))return t;let e=Number(t);if(!Number.isFinite(e)||e<=0)return t;if(e>=1)return $(e)+"s";let i=1/e;return i<10&&Math.abs(i-Math.round(i))>.05?"1/"+$(i):"1/"+Math.round(i)}function Jt(r,t,e,i){let s=[At(r+1)+" / "+At(t)],n=e.exif;if(i&&n){let o=Kt(n);o&&s.push(o),n.lens&&s.push(Xt(n.lens)),n.focal_length&&s.push($(n.focal_length)+"mm"),n.f_number&&s.push("f/"+$(n.f_number)),n.exposure&&s.push(zt(n.exposure)),n.iso&&s.push("ISO "+n.iso)}return s.join(" \xB7 ")}function Zt(r,t){r.textContent="",t.split(/\r?\n/).forEach((e,i)=>{i>0&&r.appendChild(document.createElement("br"));let s=e.split("*"),n=(s.length-1)%2===0;s.forEach((o,a)=>{let l=a%2===1;if(l&&(n||a!==s.length-1)){let h=document.createElement("em");h.textContent=o,r.appendChild(h)}else r.appendChild(document.createTextNode((l?"*":"")+o))})})}var tt=class{constructor(t){this.visible=!1;this.placement="";this.element=document.createElement("section"),this.element.className="caption",this.element.setAttribute("aria-label","Caption"),this.meta=document.createElement("p"),this.meta.className="caption-meta",this.title=document.createElement("h2"),this.title.className="caption-title",this.text=document.createElement("p"),this.text.className="caption-text",this.element.append(this.meta,this.title,this.text),t.appendChild(this.element)}set(t,e,i,s){this.meta.textContent=Jt(e,i,t,s),this.title.textContent=t.title??"",this.title.hidden=!t.title,Q(this.title,t.title??""),Zt(this.text,t.caption??""),this.text.hidden=!t.caption,Q(this.text,t.caption??"")}show(t){t!==this.visible&&(this.visible=t,this.element.classList.toggle("is-visible",t))}place(t,e,i){let s=Math.round(t)+","+Math.round(e)+","+Math.round(i);if(s===this.placement)return;this.placement=s;let n=this.element.style;n.width=Math.round(e)+"px",n.transform="translate3d("+Math.round(t)+"px,"+-Math.round(i)+"px,0)"}};var et=24,Ct=10,Gt=300,jt=.35,Pt=.35,Qt=.2,$t=2500;function te(r,t,e,i){let s=3*r,n=3*(e-r)-s,o=1-s-n,a=3*t,l=3*(i-t)-a,h=1-a-l,m=f=>((o*f+n)*f+s)*f,M=f=>((h*f+l)*f+a)*f,L=f=>(3*o*f+2*n)*f+s;return f=>{if(f<=0)return 0;if(f>=1)return 1;let T=f;for(let d=0;d<8;d++){let u=m(T)-f,p=L(T);if(Math.abs(u)<1e-5)return M(T);if(Math.abs(p)<1e-6)break;T-=u/p}let c=0,w=1;T=f;for(let d=0;d<24;d++){let u=m(T);if(Math.abs(u-f)<1e-5)break;uthis.requestDraw(),onStatus:i=>{this.indicator.update(i),this.progress.update(i)}}),this.loaders[t]=e),e}measure(){let t=this.stage.getBoundingClientRect();this.vw=Math.max(1,t.width),this.vh=Math.max(1,t.height),this.dpr=Math.min(window.devicePixelRatio||1,this.settings.maxDpr);let e=Math.max(1,Math.round(this.vw*this.dpr)),i=Math.max(1,Math.round(this.vh*this.dpr));(this.canvas.width!==e||this.canvas.height!==i)&&(this.canvas.width=e,this.canvas.height=i),this.layouts=[],this.stops=[];let s=0;this.manifest.photos.forEach((n,o)=>{let a=Math.max(1,n.slides||1),l=Math.min(this.vw/(n.width/a),this.vh/n.height),h=n.width*l,m=n.height*l,M=h/a,L=s+et/2+(this.vw-M)/2;this.layouts.push({scale:l,width:h,height:m,section:M,slides:a,start:s,left:L,top:(this.vh-m)/2});for(let f=0;f{this.pointerId===null&&document.body.classList.add("is-idle")},$t)}stopForHash(){let t=/^#(\d+)$/.exec(location.hash);if(!t)return 0;let e=Math.min(this.manifest.photos.length,Math.max(1,Number(t[1])))-1,i=this.stops.findIndex(s=>s.photo===e);return i<0?0:i}bind(){let t=this.stage;t.addEventListener("pointerdown",e=>this.onPointerDown(e)),t.addEventListener("pointermove",e=>this.onPointerMove(e)),t.addEventListener("pointerup",e=>this.onPointerUp(e,!1)),t.addEventListener("pointercancel",e=>this.onPointerUp(e,!0)),t.addEventListener("pointerleave",e=>{e.pointerType==="mouse"&&this.pointerId===null&&(this.hover=!1,this.updateCaption())}),t.addEventListener("dragstart",e=>e.preventDefault()),t.addEventListener("selectstart",e=>e.preventDefault()),this.settings.blockContextMenu&&t.addEventListener("contextmenu",e=>e.preventDefault()),window.addEventListener("keydown",e=>this.onKey(e)),window.addEventListener("hashchange",()=>{let e=this.stopForHash();this.stops[e].photo!==this.stops[this.current].photo&&this.jump(e)}),new ResizeObserver(()=>this.onResize()).observe(t),this.fade.addEventListener("transitionend",()=>{this.fade.style.opacity==="0"&&(this.fade.width=1,this.fade.height=1)})}onResize(){let t=this.vw+"x"+this.vh+"@"+this.dpr;this.measure(),t!==this.vw+"x"+this.vh+"@"+this.dpr&&(this.tween=null,this.camera=this.stops[this.current].camera,this.requestDraw(),clearTimeout(this.resizeTimer),this.resizeTimer=window.setTimeout(()=>this.startSession(),200))}onKey(t){if(t.altKey||t.ctrlKey||t.metaKey)return;this.wake();let e=t.target;if(!(e&&(e.isContentEditable||/^(INPUT|TEXTAREA|SELECT)$/.test(e.tagName)))){switch(t.key){case"ArrowRight":this.go(this.current+1);break;case"ArrowLeft":this.go(this.current-1);break;case"Home":this.go(0);break;case"End":this.go(this.stops.length-2);break;case"Escape":location.assign("/");break;case"i":case"I":this.pinned=!this.pinned,this.updateCaption();break;default:return}t.preventDefault()}}onPointerDown(t){this.pointerId!==null||t.pointerType==="mouse"&&t.button!==0||t.target.closest("a, button")||(this.pointerId=t.pointerId,this.pointerType=t.pointerType,this.dragging=!1,this.downX=t.clientX,this.downY=t.clientY,this.downT=t.timeStamp,this.tween=null,this.downCamera=this.camera,this.samples=[{t:t.timeStamp,x:t.clientX}],this.stage.setPointerCapture(t.pointerId))}onPointerMove(t){if(t.pointerType==="mouse"&&this.wake(),this.pointerId===null){t.pointerType==="mouse"&&(this.hover=this.inCaptionZone(t.clientX,t.clientY),this.updateCaption());return}if(t.pointerId!==this.pointerId)return;let e=t.clientX-this.downX,i=t.clientY-this.downY;if(!this.dragging&&Math.hypot(e,i)>=Ct&&(this.dragging=!0,this.stage.classList.add("is-dragging"),this.updateCaption()),!!this.dragging){for(this.samples.push({t:t.timeStamp,x:t.clientX});this.samples.length>2&&t.timeStamp-this.samples[0].t>100;)this.samples.shift();this.camera=this.rubber(this.downCamera-e),this.requestDraw()}}onPointerUp(t,e){if(t.pointerId!==this.pointerId)return;this.stage.hasPointerCapture(t.pointerId)&&this.stage.releasePointerCapture(t.pointerId),this.pointerId=null;let i=this.dragging;this.dragging=!1,this.stage.classList.remove("is-dragging");let s=Math.hypot(t.clientX-this.downX,t.clientY-this.downY);if(!e&&!i&&so.t&&t.timeStamp-a.t<100&&(n=(a.x-o.x)/(a.t-o.t));let l=this.nearestStop(this.camera);if(!e&&Math.abs(n)>jt)if(n<0){let h=this.stops.findIndex(m=>m.camera>this.camera+1);l=h<0?this.stops.length-1:h}else{let h=0;this.stops.forEach((m,M)=>{m.camera=i.left&&t.clientX<=i.right&&t.clientY>=i.top&&t.clientY<=i.bottom&&(this.pinned=!this.pinned,this.updateCaption())}rubber(t){let e=this.stops[0].camera,i=this.stops[this.stops.length-1].camera;return ti?i+(t-i)*Pt:t}nearestStop(t){let e=0;return this.stops.forEach((i,s)=>{Math.abs(i.camera-t){this.current=e,this.camera=s});else{let n=Math.abs(s-this.camera);n>.5?this.tween={from:this.camera,to:s,start:performance.now(),duration:240+200*Math.min(1,n/this.vw)}:this.camera=s,this.current=e}e!==i?this.activate(i):this.updateCaption(),this.requestDraw()}jump(t){let e=this.current;this.tween=null,this.crossfade(()=>{this.current=t,this.camera=this.stops[t].camera}),this.activate(e),this.requestDraw()}crossfade(t){let e=this.fade;(e.width!==this.canvas.width||e.height!==this.canvas.height)&&(e.width=this.canvas.width,e.height=this.canvas.height);let i=e.getContext("2d");i&&i.drawImage(this.canvas,0,0),e.style.transition="none",e.style.opacity="1",t(),this.render(performance.now()),requestAnimationFrame(()=>{requestAnimationFrame(()=>{e.style.transition="",e.style.opacity="0"})})}activate(t){let e=this.stops[this.current],i=t>=0?this.stops[t]:null;if(i&&i.photo>=0&&i.photo!==e.photo&&this.loaders[i.photo]?.stop(),this.loaders.forEach((s,n)=>{s&&n!==e.photo&&n!==e.photo+1&&s.stopPrefetch()}),e.photo<0&&(this.indicator.watch(null),this.progress.watch(null)),this.describe(e.photo,t>=0),e.photo>=0){let s=this.manifest.photos[e.photo];this.caption.set(s,e.photo,this.manifest.photos.length,this.manifest.show_exif),(t>=0||location.hash!=="")&&location.hash!=="#"+(e.photo+1)&&history.replaceState(history.state,"","#"+(e.photo+1)),this.startSession()}this.syncNextStrip(),this.updateCaption()}describe(t,e){let i=this.manifest.photos.length,s;if(t<0){let n=this.nextLink.querySelector(".next-title")?.textContent??"";s="End of album."+(n?" Next album: "+n+".":"")}else{let n=this.manifest.photos[t],o=n.alt||n.title||"";s="Photo "+(t+1)+" of "+i+(o?": "+o:"")}this.canvas.setAttribute("aria-label",s),clearTimeout(this.announceTimer),e&&(this.announceTimer=window.setTimeout(()=>{this.announcer.textContent=s},500))}suspend(t){if(!this.suspended){this.suspended=!0,this.tween=null;for(let e of this.loaders)e?.stop();this.nextStrip?.loader.stop(),this.env.scheduler.cancelAll(),this.env.cache.trim(t?0:this.env.cache.budget/4),t&&(this.nextStrip?.detach(),this.canvas.width=1,this.canvas.height=1,this.fade.width=1,this.fade.height=1)}}resume(){this.suspended&&(this.suspended=!1,this.canvas.width=0,this.measure(),this.camera=this.stops[this.current].camera,this.syncNextStrip(),this.startSession(),this.requestDraw())}startSession(){let t=this.stops[this.current];if(t.photo<0)return;let e=this.current,i=this.loader(t.photo);i.start(this.viewAt(t),this.dpr,()=>{this.current===e&&this.prefetchAround(e)}),this.indicator.watch(i),this.progress.watch(i)}prefetchAround(t){let e=this.stops[t],i=this.stops[t+1];if(!(!i||i.photo<0)){if(i.photo===e.photo){let s=this.loader(e.photo);s.prefetchLevel(this.viewAt(i),s.finalLevel);let n=this.stops.find(o=>o.photo===e.photo+1);n&&this.loader(n.photo).prefetchProbe(this.viewAt(n),this.dpr);return}this.loader(i.photo).prefetchProbe(this.viewAt(i),this.dpr)}}viewAt(t){let e=this.layouts[t.photo],i=t.camera-this.vw/2,s=Math.max(i,e.left),n=Math.min(i+this.vw,e.left+e.width),o=Math.max(0,e.top),a=Math.min(this.vh,e.top+e.height);return{displayWidth:e.width,u0:(s-e.left)/e.width,u1:(n-e.left)/e.width,v0:(o-e.top)/e.height,v1:(a-e.top)/e.height}}photoRect(t){let e=this.layouts[t],i=e.left-(this.camera-this.vw/2);return{left:Math.max(0,i),right:Math.min(this.vw,i+e.width),top:Math.max(0,e.top),bottom:Math.min(this.vh,e.top+e.height)}}inCaptionZone(t,e){let i=this.stops[this.current];if(i.photo<0)return!1;let s=this.stage.getBoundingClientRect(),n=t-s.left,o=e-s.top,a=this.layouts[i.photo],l=this.photoRect(i.photo),h=a.top+a.height*(1-Qt);return n>=l.left&&n<=l.right&&o>=h&&o<=l.bottom}updateCaption(){let t=this.stops[this.current],e=t.photo>=0&&!this.dragging&&(this.pinned||this.hover);if(e){let i=this.photoRect(t.photo);this.caption.place(i.left,i.right-i.left,this.vh-i.bottom)}this.caption.show(e),document.body.classList.toggle("has-caption",e)}loadNextAlbum(){this.indexRequested||!this.settings.indexUrl||(this.indexRequested=!0,fetch(this.settings.indexUrl,{credentials:"same-origin"}).then(t=>t.ok?t.json():Promise.reject(new Error("index"))).then(t=>this.showNextAlbum(t)).catch(()=>{this.indexRequested=!1}))}showNextAlbum(t){let e=t.albums;if(e.length===0)return;let i=e.findIndex(a=>a.slug===this.manifest.slug),s=e[(i+1)%e.length];if(!s||s.slug===this.manifest.slug)return;this.nextLink.href="/a/"+encodeURIComponent(s.slug)+"/";let n=this.nextLink.querySelector(".next-eyebrow"),o=this.nextLink.querySelector(".next-title");n&&(n.textContent="Next album"+(s.date?" \xB7 "+s.date:"")),o&&(o.textContent=s.title,Q(o,s.title)),s.cover&&(this.nextStrip=new V(this.nextFrame,s.cover,s.collapsed_focus_y??.5,{...this.env,tiles:t.tiles},()=>{}),this.nextLink.classList.add("has-strip"),this.layoutNextStrip(),this.syncNextStrip())}requestDraw(){this.frame===0&&(this.frame=requestAnimationFrame(t=>{this.frame=0,this.render(t)}))}render(t){let e=!1;if(this.tween){let L=Math.min(1,(t-this.tween.start)/this.tween.duration);this.camera=this.tween.from+(this.tween.to-this.tween.from)*ee(L),L>=1?(this.tween=null,this.updateCaption()):e=!0}let i=this.g,s=this.canvas.width,n=this.canvas.height;i.setTransform(1,0,0,1,0,0),i.globalAlpha=1,i.fillStyle="#111114",i.fillRect(0,0,s,n);let o=this.camera-this.vw/2,a=o+this.vw,l=this.dpr,h=this.stops[this.current].photo,m=Math.max(0,(h<0?this.layouts.length-1:h)-2),M=Math.min(this.layouts.length-1,(h<0?this.layouts.length-1:h)+2);for(let L=m;L<=M;L++){let f=this.layouts[L];f.left+f.widtha||this.loader(L).draw({g:i,originX:(f.left-o)*l,originY:f.top*l,width:f.width*l,height:f.height*l,canvasWidth:s,canvasHeight:n,displayWidth:f.width,dpr:l,now:t})&&(e=!0)}this.endCard.style.transform="translate3d("+Math.round(this.endLeft-o)+"px,0,0)",this.caption.element.classList.contains("is-visible")&&this.tween&&this.updateCaption(),e&&this.requestDraw()}};async function Rt(r){let t=await fetch(r,{credentials:"same-origin"});if(!t.ok)throw new Error(r+" "+t.status);return await t.json()}function Ft(r){return{scheduler:new K(r.concurrency,r.workerUrl),cache:new X(gt())}}async function ie(r,t){let e=await Rt(t.manifestUrl);if(e.photos.length===0)return;let{scheduler:i,cache:s}=Ft(t);document.documentElement.classList.add("has-viewer"),Ht(new it(r,e,t,{scheduler:i,cache:s,settings:t,tiles:e.tiles}))}async function se(r,t){let e=await Rt(t.indexUrl),{scheduler:i,cache:s}=Ft(t);Ht(new j(r,e,t,{scheduler:i,cache:s,settings:t,tiles:e.tiles}))}function Ht(r){document.addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"?r.suspend(!1):r.resume()}),window.addEventListener("pagehide",()=>r.suspend(!0)),window.addEventListener("pageshow",t=>{t.persisted&&r.resume()})}function ne(){document.documentElement.classList.remove("has-viewer"),document.querySelector(".load-error")?.removeAttribute("hidden")}function It(){let r=St(document.body);if(r.page==="album"){let t=document.getElementById("stage");t&&ie(t,r).catch(()=>ne())}else if(r.page==="notfound"){let t=document.querySelector(".site-header .wordmark");t&&W(t,!1)}else if(r.page==="index"){let t=document.getElementById("strips");t&&se(t,r).catch(()=>{document.documentElement.classList.remove("has-strips");let e=document.querySelector(".site-header .wordmark");e&&!e.classList.contains("has-svg")&&W(e,!1)})}}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",It,{once:!0}):It();})(); diff --git a/internal/site/static/worker.js b/internal/site/static/worker.js index 0f13b66..6cc7ad3 100644 --- a/internal/site/static/worker.js +++ b/internal/site/static/worker.js @@ -1 +1 @@ -"use strict";(()=>{var s=self,o=new Map;s.onmessage=t=>{let e=t.data;if(e.type==="abort"){o.get(e.key)?.abort(),o.delete(e.key);return}l(e)};async function l(t){let e=new AbortController;o.set(t.key,e);let i=performance.now();try{let r=await fetch(t.url,{signal:e.signal,credentials:"same-origin"});if(!r.ok)throw new Error("HTTP "+r.status);let a=await r.blob(),c=performance.now()-i,n=await createImageBitmap(a);if(e.signal.aborted)throw n.close(),new Error("aborted");s.postMessage({key:t.key,ok:!0,bitmap:n,bytes:a.size,ms:c},[n])}catch(r){s.postMessage({key:t.key,ok:!1,bytes:0,ms:0,error:String(r)})}finally{o.delete(t.key)}}})(); +"use strict";(()=>{function k(r){let n=r.seed+"|"+r.level+"|"+r.x+"|"+r.y,o=2166136261;for(let t=0;t>>0;return o}function v(r,n){let o=new Array(r);for(let e=0;e{t=t+1831565813|0;let e=Math.imul(t^t>>>15,1|t);return e=e+Math.imul(e^e>>>7,61|e)^e,((e^e>>>14)>>>0)/4294967296};for(let e=r-1;e>0;e--){let s=Math.floor(a()*(e+1)),m=o[e];o[e]=o[s],o[s]=m}return o}function g(r,n,o,t,a){r.drawImage(n,0,0);let e=a.cell,s=Math.floor(o/e),m=Math.floor(t/e),u=s*m;if(u<2)return;let d=v(u,k(a));for(let c=0;c{let n=r.data;if(n.type==="abort"){i.get(n.key)?.abort(),i.delete(n.key);return}S(n)};function x(r,n){if(!b)throw new Error("unsupported-offscreen");let o=new b(r.width,r.height),t=o.getContext("2d");if(!t)throw new Error("unsupported-offscreen");return g(t,r,r.width,r.height,n),r.close(),o.transferToImageBitmap()}async function S(r){if(!M){l.postMessage({key:r.key,ok:!1,bytes:0,ms:0,error:"unsupported-bitmap"});return}if(r.scramble&&!b){l.postMessage({key:r.key,ok:!1,bytes:0,ms:0,error:"unsupported-offscreen"});return}let n=new AbortController;i.set(r.key,n);let o=performance.now();try{let t=await fetch(r.url,{signal:n.signal,credentials:"same-origin"});if(!t.ok)throw new Error("HTTP "+t.status);let a=await t.blob(),e=performance.now()-o,s=await createImageBitmap(a);if(r.scramble&&(s=x(s,r.scramble)),n.signal.aborted)throw s.close(),new Error("aborted");l.postMessage({key:r.key,ok:!0,bitmap:s,bytes:a.size,ms:e},[s])}catch(t){let a=t instanceof Error?t.message:String(t);l.postMessage({key:r.key,ok:!1,bytes:0,ms:0,error:a})}finally{i.delete(r.key)}}})(); diff --git a/internal/site/templates/404.html b/internal/site/templates/404.html new file mode 100644 index 0000000..df6f566 --- /dev/null +++ b/internal/site/templates/404.html @@ -0,0 +1,17 @@ + + + +{{template "head" .}} + + + +
+

404

+

Nothing here

+

This page does not exist, or the album moved. All albums

+
+{{template "footer" .}} + + diff --git a/internal/site/templates/album.html b/internal/site/templates/album.html index 072ff69..9daebdc 100644 --- a/internal/site/templates/album.html +++ b/internal/site/templates/album.html @@ -5,12 +5,14 @@ + Lucio -
-

{{.AlbumTitle}}{{if .Subtitle}} · {{.Subtitle}}{{end}}

+
+

{{.AlbumTitle}}{{if .Subtitle}} · {{.Subtitle}}{{end}}

{{.Photos}} photos{{if .Date}} · {{end}}

+

All albums

diff --git a/internal/site/templates/head.html b/internal/site/templates/head.html index 4a3c12c..83deb8c 100644 --- a/internal/site/templates/head.html +++ b/internal/site/templates/head.html @@ -25,3 +25,7 @@ {{- end}} {{define "body-data"}} data-build="{{.Build}}" data-index="{{.IndexURL}}" data-worker="{{.Assets.Worker.URL}}" data-budget-ms="{{.BudgetMS}}" data-max-dpr="{{.MaxDPR}}" data-concurrency="{{.Concurrency}}" data-block-context-menu="{{.BlockContextMenu}}"{{end}} +{{define "footer"}}
+ +{{.Assets.Chop}} +
{{end}} diff --git a/internal/site/templates/index.html b/internal/site/templates/index.html index dfe04d5..ba6136f 100644 --- a/internal/site/templates/index.html +++ b/internal/site/templates/index.html @@ -5,22 +5,20 @@ + -
+

Photos by Lucio

{{- range .Albums}} -{{if .Date}}{{.Date}}{{end}}{{.Title}}{{if .Subtitle}}{{.Subtitle}}{{end}} +{{if .Date}}{{.Date}}{{end}}{{.Title}}{{if .Subtitle}}{{.Subtitle}}{{end}} {{- else}}

No albums yet.

{{- end}}
-
- -{{.Assets.Chop}} -
+{{template "footer" .}} diff --git a/packaging/Caddyfile b/packaging/Caddyfile index ba34cb8..39abea7 100644 --- a/packaging/Caddyfile +++ b/packaging/Caddyfile @@ -9,7 +9,7 @@ photos.luciochen.com { respond @hotlink 403 @hidden path */.* *.gz - respond @hidden 404 + error @hidden 404 @immutable path /t/* /og/* /assets/* header @immutable Cache-Control "public, max-age=31536000, immutable" @@ -30,4 +30,12 @@ photos.luciochen.com { file_server { precompressed gzip } + + handle_errors { + @notfound expression {err.status_code} == 404 + rewrite @notfound /404.html + file_server { + precompressed gzip + } + } } diff --git a/packaging/nginx.conf b/packaging/nginx.conf index b687dbf..b0900c2 100644 --- a/packaging/nginx.conf +++ b/packaging/nginx.conf @@ -19,6 +19,7 @@ server { disable_symlinks off; gzip_static on; server_tokens off; + error_page 404 /404.html; if ($request_method !~ ^(GET|HEAD)$) { return 405; @@ -28,6 +29,14 @@ server { return 404; } + location = /404.html { + internal; + add_header Cache-Control "public, max-age=60" always; + add_header Content-Security-Policy "default-src 'self'; img-src 'self' blob: data:; font-src 'self'; worker-src 'self'; frame-ancestors 'none'" always; + add_header X-Content-Type-Options nosniff always; + add_header Referrer-Policy strict-origin-when-cross-origin always; + } + location /t/ { if ($luphoto_hotlink) { return 403; diff --git a/web/src/app.css b/web/src/app.css index 70acfcc..417c2cb 100644 --- a/web/src/app.css +++ b/web/src/app.css @@ -490,3 +490,74 @@ html:not(.has-strips) .strip-subtitle { animation-duration: 0ms !important; } } + +html { + touch-action: manipulation; + -webkit-text-size-adjust: 100%; + text-size-adjust: 100%; +} + +.skip-link { + position: absolute; + top: var(--lucio-space-2); + left: var(--lucio-space-4); + z-index: 10; + padding: var(--lucio-space-2) var(--lucio-space-3); + background: var(--lucio-graphite-2); + color: var(--lucio-paper); + font-size: 14px; + line-height: 1.5; + text-decoration: none; + transform: translateY(-200%); +} + +.skip-link:focus-visible { + transform: none; +} + +.stage:focus-visible { + outline: 2px solid var(--lucio-beam); + outline-offset: -2px; +} + +.strip { + touch-action: manipulation; +} + +.load-error { + color: var(--lucio-ash-light); +} + +.message { + padding: var(--lucio-space-9) var(--gutter) var(--lucio-space-8); + max-width: 68ch; +} + +.message-eyebrow { + margin: 0; + font-family: var(--lucio-font-mono); + font-size: 12px; + line-height: 1.4; + font-weight: 500; + letter-spacing: 0.08em; + text-transform: uppercase; + color: var(--lucio-ash-light); +} + +.message-title { + margin: var(--lucio-space-2) 0 var(--lucio-space-4); + font-family: var(--lucio-font-display); + font-size: 36px; + font-weight: 700; + line-height: 1.15; + letter-spacing: -0.015em; +} + +.message-text { + margin: 0; + color: var(--lucio-paper); +} + +.message-text a { + text-decoration: underline; +} diff --git a/web/src/app.ts b/web/src/app.ts index f860bec..aa084b4 100644 --- a/web/src/app.ts +++ b/web/src/app.ts @@ -1,3 +1,4 @@ +import { mountWordmark } from "./brand"; import { TileCache, cacheBudget } from "./cache"; import { IndexPage } from "./index"; import { Scheduler } from "./scheduler"; @@ -23,13 +24,39 @@ async function startAlbum(stage: HTMLElement, settings: Settings): Promise } const { scheduler, cache } = shared(settings); document.documentElement.classList.add("has-viewer"); - new Viewer(stage, manifest, settings, { scheduler, cache, settings, tiles: manifest.tiles }); + lifecycle(new Viewer(stage, manifest, settings, { scheduler, cache, settings, tiles: manifest.tiles })); } async function startIndex(root: HTMLElement, settings: Settings): Promise { const index = await fetchJSON(settings.indexUrl); const { scheduler, cache } = shared(settings); - new IndexPage(root, index, settings, { scheduler, cache, settings, tiles: index.tiles }); + lifecycle(new IndexPage(root, index, settings, { scheduler, cache, settings, tiles: index.tiles })); +} + +interface Suspendable { + suspend(hidden: boolean): void; + resume(): void; +} + +function lifecycle(target: Suspendable): void { + document.addEventListener("visibilitychange", () => { + if (document.visibilityState === "hidden") { + target.suspend(false); + } else { + target.resume(); + } + }); + window.addEventListener("pagehide", () => target.suspend(true)); + window.addEventListener("pageshow", (event) => { + if (event.persisted) { + target.resume(); + } + }); +} + +function showLoadError(): void { + document.documentElement.classList.remove("has-viewer"); + document.querySelector(".load-error")?.removeAttribute("hidden"); } function boot(): void { @@ -37,16 +64,22 @@ function boot(): void { if (settings.page === "album") { const stage = document.getElementById("stage"); if (stage) { - startAlbum(stage, settings).catch((error: unknown) => { - stage.dataset.error = String(error); - document.documentElement.classList.remove("has-viewer"); - }); + startAlbum(stage, settings).catch(() => showLoadError()); + } + } else if (settings.page === "notfound") { + const header = document.querySelector(".site-header .wordmark"); + if (header) { + mountWordmark(header, false); } } else if (settings.page === "index") { const root = document.getElementById("strips"); if (root) { - startIndex(root, settings).catch((error: unknown) => { - root.dataset.error = String(error); + startIndex(root, settings).catch(() => { + document.documentElement.classList.remove("has-strips"); + const header = document.querySelector(".site-header .wordmark"); + if (header && !header.classList.contains("has-svg")) { + mountWordmark(header, false); + } }); } } diff --git a/web/src/cache.ts b/web/src/cache.ts index d8d9ab3..dc4b17d 100644 --- a/web/src/cache.ts +++ b/web/src/cache.ts @@ -1,5 +1,7 @@ +import { releaseImage, type TileImage } from "./scheduler"; + export interface CachedTile { - bitmap: ImageBitmap; + bitmap: TileImage; bytes: number; at: number; } @@ -8,22 +10,27 @@ interface NavigatorWithMemory extends Navigator { deviceMemory?: number; } -export function cacheBudget(): number { - const mb = 1024 * 1024; +const mb = 1024 * 1024; + +export function isConstrainedDevice(): boolean { const memory = (navigator as NavigatorWithMemory).deviceMemory; - const coarse = typeof matchMedia === "function" && matchMedia("(pointer: coarse)").matches; - const smallScreen = Math.min(screen.width, screen.height) <= 820; - if ((memory !== undefined && memory <= 4) || (coarse && smallScreen)) { - return 120 * mb; + if (typeof memory === "number" && memory <= 4) { + return true; } - return 250 * mb; + const coarse = typeof matchMedia === "function" && matchMedia("(pointer: coarse)").matches; + const shortSide = Math.min(screen.width, screen.height); + return coarse && shortSide <= 820; +} + +export function cacheBudget(): number { + return isConstrainedDevice() ? 120 * mb : 250 * mb; } export class TileCache { private readonly entries = new Map(); private used = 0; - constructor(private readonly budget: number) {} + constructor(readonly budget: number) {} get(id: string): CachedTile | undefined { const entry = this.entries.get(id); @@ -38,22 +45,22 @@ export class TileCache { return this.entries.has(id); } - put(id: string, bitmap: ImageBitmap): void { + put(id: string, bitmap: TileImage): void { const existing = this.entries.get(id); if (existing) { if (existing.bitmap !== bitmap) { - bitmap.close(); + releaseImage(bitmap); } return; } const bytes = bitmap.width * bitmap.height * 4; this.entries.set(id, { bitmap, bytes, at: performance.now() }); this.used += bytes; - this.evict(); + this.trim(this.budget); } - private evict(): void { - while (this.used > this.budget && this.entries.size > 1) { + trim(limit: number): void { + while (this.used > limit && this.entries.size > 0) { const oldest = this.entries.keys().next(); if (oldest.done) { return; @@ -62,7 +69,7 @@ export class TileCache { this.entries.delete(oldest.value); if (entry) { this.used -= entry.bytes; - entry.bitmap.close(); + releaseImage(entry.bitmap); } } } diff --git a/web/src/caption.ts b/web/src/caption.ts index 43efd34..9bd7b03 100644 --- a/web/src/caption.ts +++ b/web/src/caption.ts @@ -1,5 +1,15 @@ import type { Exif, Photo } from "./types"; +const han = /[㐀-鿿豈-﫿]/; + +export function setLang(element: HTMLElement, text: string): void { + if (han.test(text)) { + element.lang = "zh"; + } else { + element.removeAttribute("lang"); + } +} + function pad(n: number): string { return n < 10 ? "0" + n : String(n); } @@ -102,23 +112,20 @@ export class CaptionPanel { private readonly meta: HTMLElement; private readonly title: HTMLElement; private readonly text: HTMLElement; - private readonly alt: HTMLElement; private visible = false; private placement = ""; constructor(parent: HTMLElement) { this.element = document.createElement("section"); this.element.className = "caption"; - this.element.setAttribute("aria-live", "polite"); + this.element.setAttribute("aria-label", "Caption"); this.meta = document.createElement("p"); this.meta.className = "caption-meta"; this.title = document.createElement("h2"); this.title.className = "caption-title"; this.text = document.createElement("p"); this.text.className = "caption-text"; - this.alt = document.createElement("p"); - this.alt.className = "visually-hidden"; - this.element.append(this.meta, this.title, this.text, this.alt); + this.element.append(this.meta, this.title, this.text); parent.appendChild(this.element); } @@ -126,9 +133,10 @@ export class CaptionPanel { this.meta.textContent = metaLine(index, total, photo, showExif); this.title.textContent = photo.title ?? ""; this.title.hidden = !photo.title; + setLang(this.title, photo.title ?? ""); renderRichText(this.text, photo.caption ?? ""); this.text.hidden = !photo.caption; - this.alt.textContent = photo.alt ?? ""; + setLang(this.text, photo.caption ?? ""); } show(visible: boolean): void { diff --git a/web/src/geometry.ts b/web/src/geometry.ts index 1d39c7a..98506c9 100644 --- a/web/src/geometry.ts +++ b/web/src/geometry.ts @@ -70,7 +70,7 @@ export function visibleTiles(pyramid: Pyramid, levelIndex: number, view: View, t export function drawTile( g: CanvasRenderingContext2D, - bitmap: ImageBitmap, + bitmap: { width: number; height: number } & CanvasImageSource, level: Level, x: number, y: number, diff --git a/web/src/index.ts b/web/src/index.ts index 7efbe02..56d5e43 100644 --- a/web/src/index.ts +++ b/web/src/index.ts @@ -8,6 +8,8 @@ const hysteresis = 24; export class IndexPage { private readonly strips: Strip[] = []; private readonly onScreen = new Set(); + private readonly inView = new Set(); + private suspended = false; private readonly indicator: BusyIndicator; private readonly hoverMode: MediaQueryList; private wordmark: MorphHandle | null = null; @@ -19,7 +21,7 @@ export class IndexPage { private readonly root: HTMLElement, index: SiteIndex, private readonly settings: Settings, - env: StripEnv, + private readonly env: StripEnv, ) { const anchors = Array.from(root.querySelectorAll("a.strip")); const bySlug = new Map(index.albums.map((album) => [album.slug, album])); @@ -52,6 +54,36 @@ export class IndexPage { this.bind(); } + suspend(hidden: boolean): void { + if (this.suspended) { + return; + } + this.suspended = true; + for (const strip of this.strips) { + strip.loader.stop(); + if (hidden) { + strip.detach(); + } + } + this.env.scheduler.cancelAll(); + this.env.cache.trim(hidden ? 0 : this.env.cache.budget / 4); + } + + resume(): void { + if (!this.suspended) { + return; + } + this.suspended = false; + for (const strip of this.strips) { + if (this.inView.has(strip)) { + strip.attach(); + } + if (strip.isNear) { + strip.startSession(); + } + } + } + private wordmarkMoving(): boolean { const t = this.wordmark?.t ?? 0; return t > 0 && t < 1; @@ -93,8 +125,12 @@ export class IndexPage { continue; } if (entry.isIntersecting) { - strip.attach(); + this.inView.add(strip); + if (!this.suspended) { + strip.attach(); + } } else { + this.inView.delete(strip); strip.detach(); } } diff --git a/web/src/loader.ts b/web/src/loader.ts index 50744f5..bf7cfed 100644 --- a/web/src/loader.ts +++ b/web/src/loader.ts @@ -1,6 +1,7 @@ import type { TileCache } from "./cache"; import { drawTile, neededLevel, tileRange, visibleTiles, type TileRef, type View } from "./geometry"; -import { PRIORITY_CURRENT, PRIORITY_PREFETCH, type Scheduler, type TileResult } from "./scheduler"; +import { AbortError, PRIORITY_CURRENT, PRIORITY_PREFETCH, decodeBlob, releaseImage, type Scheduler, type TileResult } from "./scheduler"; +import type { ScrambleSpec } from "./scramble"; import { currentThroughput, recordThroughput } from "./throughput"; import type { Pyramid, Settings, Tiles } from "./types"; @@ -22,6 +23,25 @@ export interface LoadStatus { } const fadeMs = 180; +const retryMs = 400; + +function wait(ms: number, signal: AbortSignal): Promise { + return new Promise((resolve, reject) => { + if (signal.aborted) { + reject(new AbortError()); + return; + } + const timer = setTimeout(() => { + signal.removeEventListener("abort", stop); + resolve(); + }, ms); + const stop = () => { + clearTimeout(timer); + reject(new AbortError()); + }; + signal.addEventListener("abort", stop, { once: true }); + }); +} const probeStep = 3; const seedUpscale = 4; @@ -73,7 +93,7 @@ export class PhotoLoader { for (let i = 0; i < raw.length; i++) { bytes[i] = raw.charCodeAt(i); } - const bitmap = await createImageBitmap(new Blob([bytes], { type: "image/" + this.env.tiles.format })); + const bitmap = await decodeBlob(new Blob([bytes], { type: "image/" + this.env.tiles.format })); const canvas = document.createElement("canvas"); canvas.width = bitmap.width * seedUpscale; canvas.height = bitmap.height * seedUpscale; @@ -89,17 +109,31 @@ export class PhotoLoader { } const pad = seedUpscale * 2; g.drawImage(bitmap, -pad, -pad, canvas.width + pad * 2, canvas.height + pad * 2); - bitmap.close(); + releaseImage(bitmap); this.seedImage = canvas; } - private fetchTile(tile: TileRef, priority: number, signal: AbortSignal): Promise { - const id = this.pyramid.levels[tile.level].tiles[tile.index]; - return this.env.scheduler.request(id, this.tileUrl(id), priority, signal).then((result) => { - this.env.cache.put(id, result.bitmap); - this.env.requestDraw(); - return result; - }); + private async fetchTile(tile: TileRef, priority: number, signal: AbortSignal): Promise { + const level = this.pyramid.levels[tile.level]; + const id = level.tiles[tile.index]; + const tiles = this.env.tiles; + const scramble: ScrambleSpec | undefined = + tiles.scrambled && this.pyramid.scramble + ? { seed: this.pyramid.scramble, level: tile.level, x: tile.x, y: tile.y, cell: tiles.cell ?? 64 } + : undefined; + let result: TileResult; + try { + result = await this.env.scheduler.request(id, this.tileUrl(id), priority, signal, scramble); + } catch (error) { + if (signal.aborted || error instanceof AbortError) { + throw error; + } + await wait(retryMs + Math.random() * retryMs, signal); + result = await this.env.scheduler.request(id, this.tileUrl(id), priority, signal, scramble); + } + this.env.cache.put(id, result.bitmap); + this.env.requestDraw(); + return result; } private uncached(level: number, view: View): TileRef[] { diff --git a/web/src/scheduler.ts b/web/src/scheduler.ts index 8d95711..e5c91e3 100644 --- a/web/src/scheduler.ts +++ b/web/src/scheduler.ts @@ -1,8 +1,12 @@ +import { unscramble, type ScrambleSpec } from "./scramble"; + export const PRIORITY_CURRENT = 0; export const PRIORITY_PREFETCH = 1; +export type TileImage = ImageBitmap | HTMLImageElement | HTMLCanvasElement; + export interface TileResult { - bitmap: ImageBitmap; + bitmap: TileImage; bytes: number; ms: number; } @@ -16,6 +20,7 @@ interface Job { key: number; id: string; url: string; + scramble?: ScrambleSpec; priority: number; seq: number; waiters: Set; @@ -27,7 +32,7 @@ interface Job { interface WorkerReply { key: number; ok: boolean; - bitmap?: ImageBitmap; + bitmap?: TileImage; bytes: number; ms: number; error?: string; @@ -40,11 +45,56 @@ export class AbortError extends Error { } } +export function releaseImage(image: TileImage): void { + if ("close" in image) { + image.close(); + } else if (image instanceof HTMLCanvasElement) { + image.width = 0; + image.height = 0; + } +} + +export async function decodeBlob(blob: Blob): Promise { + if (typeof createImageBitmap === "function") { + return createImageBitmap(blob); + } + const url = URL.createObjectURL(blob); + try { + const image = new Image(); + image.decoding = "async"; + image.src = url; + await image.decode(); + return image; + } finally { + URL.revokeObjectURL(url); + } +} + +async function restore(image: TileImage, spec: ScrambleSpec): Promise { + const canvas = document.createElement("canvas"); + canvas.width = image.width; + canvas.height = image.height; + const g = canvas.getContext("2d"); + if (!g) { + return image; + } + unscramble(g, image, image.width, image.height, spec); + releaseImage(image); + if (typeof createImageBitmap === "function") { + const bitmap = await createImageBitmap(canvas); + canvas.width = 0; + canvas.height = 0; + return bitmap; + } + return canvas; +} + export class Scheduler { private readonly byId = new Map(); private readonly byKey = new Map(); private readonly queue: Job[] = []; private readonly workers: Worker[] = []; + private workersUnscramble = true; private running = 0; private nextKey = 1; private nextSeq = 1; @@ -59,7 +109,7 @@ export class Scheduler { try { const worker = new Worker(workerUrl); const index = this.workers.length; - worker.onmessage = (event: MessageEvent) => this.onReply(event.data); + worker.onmessage = (event: MessageEvent) => this.onReply(event.data, index); worker.onerror = () => this.dropWorker(index); this.workers.push(worker); } catch { @@ -68,7 +118,7 @@ export class Scheduler { } } - request(id: string, url: string, priority: number, signal: AbortSignal): Promise { + request(id: string, url: string, priority: number, signal: AbortSignal, scramble?: ScrambleSpec): Promise { if (signal.aborted) { return Promise.reject(new AbortError()); } @@ -83,6 +133,7 @@ export class Scheduler { key: this.nextKey++, id, url, + scramble, priority, seq: this.nextSeq++, waiters: new Set(), @@ -118,6 +169,17 @@ export class Scheduler { }); } + cancelAll(): void { + for (const job of [...this.byKey.values()]) { + const waiters = [...job.waiters]; + job.waiters.clear(); + for (const waiter of waiters) { + waiter.reject(new AbortError()); + } + this.cancel(job); + } + } + private cancel(job: Job): void { this.forget(job); if (!job.running) { @@ -163,12 +225,16 @@ export class Scheduler { private start(job: Job): void { const live = this.liveWorkers(); - if (live.length > 0) { + if (live.length > 0 && (!job.scramble || this.workersUnscramble)) { const index = live[this.nextWorker++ % live.length]; job.worker = index; - this.workers[index].postMessage({ type: "fetch", key: job.key, url: job.url }); + this.workers[index].postMessage({ type: "fetch", key: job.key, url: job.url, scramble: job.scramble }); return; } + this.runOnMainThread(job); + } + + private runOnMainThread(job: Job): void { job.worker = -1; job.controller = new AbortController(); void this.fetchOnMainThread(job, job.controller.signal); @@ -193,9 +259,7 @@ export class Scheduler { delete this.workers[index]; for (const job of this.byKey.values()) { if (job.running && job.worker === index) { - job.worker = -1; - job.controller = new AbortController(); - void this.fetchOnMainThread(job, job.controller.signal); + this.runOnMainThread(job); } } } @@ -209,17 +273,31 @@ export class Scheduler { } const blob = await response.blob(); const ms = performance.now() - started; - const bitmap = await createImageBitmap(blob); - this.onReply({ key: job.key, ok: true, bitmap, bytes: blob.size, ms }); + let image = await decodeBlob(blob); + if (job.scramble) { + image = await restore(image, job.scramble); + } + this.onReply({ key: job.key, ok: true, bitmap: image, bytes: blob.size, ms }, -1); } catch (error) { - this.onReply({ key: job.key, ok: false, bytes: 0, ms: 0, error: String(error) }); + this.onReply({ key: job.key, ok: false, bytes: 0, ms: 0, error: String(error) }, -1); } } - private onReply(reply: WorkerReply): void { + private onReply(reply: WorkerReply, from: number): void { const job = this.byKey.get(reply.key); - if (!job || !job.running) { - reply.bitmap?.close(); + if (!job || !job.running || job.worker !== from) { + if (reply.bitmap) { + releaseImage(reply.bitmap); + } + return; + } + if (!reply.ok && from >= 0 && (reply.error === "unsupported-bitmap" || reply.error === "unsupported-offscreen")) { + if (reply.error === "unsupported-bitmap") { + this.dropWorker(from); + } else { + this.workersUnscramble = false; + this.runOnMainThread(job); + } return; } job.running = false; @@ -233,7 +311,7 @@ export class Scheduler { waiter.resolve(result); } if (waiters.length === 0) { - reply.bitmap.close(); + releaseImage(reply.bitmap); } } else { const error = new Error(reply.error ?? "tile failed"); diff --git a/web/src/scramble.ts b/web/src/scramble.ts new file mode 100644 index 0000000..a4d5773 --- /dev/null +++ b/web/src/scramble.ts @@ -0,0 +1,65 @@ +export interface ScrambleSpec { + seed: string; + level: number; + x: number; + y: number; + cell: number; +} + +export function tileSeed(spec: ScrambleSpec): number { + const text = spec.seed + "|" + spec.level + "|" + spec.x + "|" + spec.y; + let h = 2166136261; + for (let i = 0; i < text.length; i++) { + h = Math.imul(h ^ text.charCodeAt(i), 16777619) >>> 0; + } + return h; +} + +export function cellPermutation(n: number, seed: number): number[] { + const perm = new Array(n); + for (let i = 0; i < n; i++) { + perm[i] = i; + } + let state = seed | 0; + const next = (): number => { + state = (state + 0x6d2b79f5) | 0; + let t = Math.imul(state ^ (state >>> 15), 1 | state); + t = (t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ t; + return ((t ^ (t >>> 14)) >>> 0) / 4294967296; + }; + for (let i = n - 1; i > 0; i--) { + const j = Math.floor(next() * (i + 1)); + const swap = perm[i]; + perm[i] = perm[j]; + perm[j] = swap; + } + return perm; +} + +export interface CellCanvas { + drawImage(image: CanvasImageSource, sx: number, sy: number, sw: number, sh: number, dx: number, dy: number, dw: number, dh: number): void; + drawImage(image: CanvasImageSource, dx: number, dy: number): void; +} + +export function unscramble(g: CellCanvas, image: CanvasImageSource, width: number, height: number, spec: ScrambleSpec): void { + g.drawImage(image, 0, 0); + const cell = spec.cell; + const cols = Math.floor(width / cell); + const rows = Math.floor(height / cell); + const n = cols * rows; + if (n < 2) { + return; + } + const perm = cellPermutation(n, tileSeed(spec)); + for (let i = 0; i < n; i++) { + const source = perm[i]; + if (source === i) { + continue; + } + const sx = (i % cols) * cell; + const sy = Math.floor(i / cols) * cell; + const dx = (source % cols) * cell; + const dy = Math.floor(source / cols) * cell; + g.drawImage(image, sx, sy, cell, cell, dx, dy, cell, cell); + } +} diff --git a/web/src/strip.ts b/web/src/strip.ts index adc2ec0..fb7096c 100644 --- a/web/src/strip.ts +++ b/web/src/strip.ts @@ -54,6 +54,10 @@ export class Strip { return this.expanded; } + get isNear(): boolean { + return this.near; + } + layout(size: StripSize): void { const cover = this.cover; const scale = Math.max(size.width / cover.width, size.open / cover.height); diff --git a/web/src/types.ts b/web/src/types.ts index b3b5c2c..57ff59c 100644 --- a/web/src/types.ts +++ b/web/src/types.ts @@ -14,6 +14,7 @@ export interface Pyramid { height: number; levels: Level[]; seed: string; + scramble?: string; } export interface Exif { @@ -40,6 +41,8 @@ export interface Tiles { tile_size: number; overlap: number; path: string; + scrambled?: boolean; + cell?: number; } export interface Manifest { diff --git a/web/src/viewer.ts b/web/src/viewer.ts index 7ea1ebf..30f9c69 100644 --- a/web/src/viewer.ts +++ b/web/src/viewer.ts @@ -1,5 +1,5 @@ import { cloneChop, mountWordmark } from "./brand"; -import { CaptionPanel } from "./caption"; +import { CaptionPanel, setLang } from "./caption"; import type { View } from "./geometry"; import { BusyIndicator, ProgressLine } from "./indicator"; import { PhotoLoader, type LoaderEnv } from "./loader"; @@ -106,6 +106,9 @@ export class Viewer { private readonly homeMark: HTMLElement | null; private nextStrip: Strip | null = null; private idleTimer = 0; + private announceTimer = 0; + private suspended = false; + private readonly announcer: HTMLElement; private readonly reducedMotion: MediaQueryList; private readonly loaders: Array; private layouts: PhotoLayout[] = []; @@ -139,7 +142,11 @@ export class Viewer { ) { this.canvas = document.createElement("canvas"); this.canvas.className = "stage-canvas"; - this.canvas.setAttribute("aria-hidden", "true"); + this.canvas.setAttribute("role", "img"); + this.announcer = document.createElement("p"); + this.announcer.className = "visually-hidden"; + this.announcer.setAttribute("aria-live", "polite"); + this.announcer.setAttribute("aria-atomic", "true"); this.fade = document.createElement("canvas"); this.fade.className = "stage-fade"; this.fade.setAttribute("aria-hidden", "true"); @@ -155,6 +162,7 @@ export class Viewer { this.nextFrame = this.endCard.querySelector(".next-strip") as HTMLElement; stage.prepend(this.canvas, this.fade); stage.appendChild(this.endCard); + stage.appendChild(this.announcer); this.caption = new CaptionPanel(stage); this.progress = new ProgressLine(document.body); this.indicator = new BusyIndicator(document.body); @@ -594,6 +602,7 @@ export class Viewer { this.indicator.watch(null); this.progress.watch(null); } + this.describe(stop.photo, previousStop >= 0); if (stop.photo >= 0) { const photo = this.manifest.photos[stop.photo]; this.caption.set(photo, stop.photo, this.manifest.photos.length, this.manifest.show_exif); @@ -606,6 +615,60 @@ export class Viewer { this.updateCaption(); } + private describe(photoIndex: number, announce: boolean): void { + const total = this.manifest.photos.length; + let label: string; + if (photoIndex < 0) { + const next = this.nextLink.querySelector(".next-title")?.textContent ?? ""; + label = "End of album." + (next ? " Next album: " + next + "." : ""); + } else { + const photo = this.manifest.photos[photoIndex]; + const name = photo.alt || photo.title || ""; + label = "Photo " + (photoIndex + 1) + " of " + total + (name ? ": " + name : ""); + } + this.canvas.setAttribute("aria-label", label); + clearTimeout(this.announceTimer); + if (announce) { + this.announceTimer = window.setTimeout(() => { + this.announcer.textContent = label; + }, 500); + } + } + + suspend(hidden: boolean): void { + if (this.suspended) { + return; + } + this.suspended = true; + this.tween = null; + for (const loader of this.loaders) { + loader?.stop(); + } + this.nextStrip?.loader.stop(); + this.env.scheduler.cancelAll(); + this.env.cache.trim(hidden ? 0 : this.env.cache.budget / 4); + if (hidden) { + this.nextStrip?.detach(); + this.canvas.width = 1; + this.canvas.height = 1; + this.fade.width = 1; + this.fade.height = 1; + } + } + + resume(): void { + if (!this.suspended) { + return; + } + this.suspended = false; + this.canvas.width = 0; + this.measure(); + this.camera = this.stops[this.current].camera; + this.syncNextStrip(); + this.startSession(); + this.requestDraw(); + } + private startSession(): void { const stop = this.stops[this.current]; if (stop.photo < 0) { @@ -723,6 +786,7 @@ export class Viewer { } if (title) { title.textContent = next.title; + setLang(title as HTMLElement, next.title); } if (next.cover) { this.nextStrip = new Strip( diff --git a/web/src/worker.ts b/web/src/worker.ts index 93bbd16..42888aa 100644 --- a/web/src/worker.ts +++ b/web/src/worker.ts @@ -1,7 +1,10 @@ +import { unscramble, type ScrambleSpec } from "./scramble"; + interface FetchMessage { type: "fetch"; key: number; url: string; + scramble?: ScrambleSpec; } interface AbortMessage { @@ -25,8 +28,17 @@ interface WorkerScope { postMessage(message: Outgoing, transfer?: Transferable[]): void; } +interface OffscreenLike { + getContext(kind: "2d"): CanvasRenderingContext2D | null; + transferToImageBitmap(): ImageBitmap; +} + +type OffscreenConstructor = new (width: number, height: number) => OffscreenLike; + const scope = self as unknown as WorkerScope; const controllers = new Map(); +const canDecode = typeof createImageBitmap === "function"; +const Offscreen = (self as unknown as { OffscreenCanvas?: OffscreenConstructor }).OffscreenCanvas; scope.onmessage = (event) => { const message = event.data; @@ -38,7 +50,29 @@ scope.onmessage = (event) => { void load(message); }; +function restore(bitmap: ImageBitmap, spec: ScrambleSpec): ImageBitmap { + if (!Offscreen) { + throw new Error("unsupported-offscreen"); + } + const canvas = new Offscreen(bitmap.width, bitmap.height); + const g = canvas.getContext("2d"); + if (!g) { + throw new Error("unsupported-offscreen"); + } + unscramble(g, bitmap, bitmap.width, bitmap.height, spec); + bitmap.close(); + return canvas.transferToImageBitmap(); +} + async function load(message: FetchMessage): Promise { + if (!canDecode) { + scope.postMessage({ key: message.key, ok: false, bytes: 0, ms: 0, error: "unsupported-bitmap" }); + return; + } + if (message.scramble && !Offscreen) { + scope.postMessage({ key: message.key, ok: false, bytes: 0, ms: 0, error: "unsupported-offscreen" }); + return; + } const controller = new AbortController(); controllers.set(message.key, controller); const started = performance.now(); @@ -49,14 +83,18 @@ async function load(message: FetchMessage): Promise { } const blob = await response.blob(); const ms = performance.now() - started; - const bitmap = await createImageBitmap(blob); + let bitmap = await createImageBitmap(blob); + if (message.scramble) { + bitmap = restore(bitmap, message.scramble); + } if (controller.signal.aborted) { bitmap.close(); throw new Error("aborted"); } scope.postMessage({ key: message.key, ok: true, bitmap, bytes: blob.size, ms }, [bitmap]); } catch (error) { - scope.postMessage({ key: message.key, ok: false, bytes: 0, ms: 0, error: String(error) }); + const text = error instanceof Error ? error.message : String(error); + scope.postMessage({ key: message.key, ok: false, bytes: 0, ms: 0, error: text }); } finally { controllers.delete(message.key); }