Peach: Local-first video metadata scraper and media manager.
fix(web): 补齐标注字段身份与懒加载图片尺寸
longmeidao674d9a991987
diff --git a/docs/FRONTEND.md b/docs/FRONTEND.mdindex 702798759..95693a68b 100644--- a/docs/FRONTEND.md+++ b/docs/FRONTEND.md@@ -275,6 +275,7 @@ npm --prefix frontend run build:agentation # 在要用它的那份检出里构`peach-react.js` 的压缩改掉了。要在 Tailwind 类名之外给智能体更稳的抓手,给区块加`data-component`(Agentation 默认采集的属性之一)。- Agentation 自己的全局快捷键已关闭,避免与 Peach 的 Esc、方向键冲突,只用工具栏按钮操作。+- 标注工具挂在自己的容器里;适配入口为它的 Shadow DOM 表单字段补齐名称。- 标注同步到本机 `agentation-mcp`(`http://localhost:4747`),智能体用它的 MCP 工具直接读、回复和标记已处理,不必复制粘贴。服务由注册了它的 Claude Code 会话拉起:`claude mcp add agentation -- npx -y agentation-mcp server`,注册后新开的会话才有这组工具。diff --git a/frontend/e2e/feed-cover.test.ts b/frontend/e2e/feed-cover.test.tsindex c311d4d48..cc9a55db4 100644--- a/frontend/e2e/feed-cover.test.ts+++ b/frontend/e2e/feed-cover.test.ts@@ -28,6 +28,12 @@ describe('新作封面显示时机',()=>{});const page=await context.newPage();const remote='https://covers.example.test/framing.svg';+ const audits=await context.newCDPSession(page), lazyIssues:string[]=[];+ audits.on('Audits.issueAdded',({issue})=>{+ if(issue.code==='LazyLoadImageIssue'&&issue.details.lazyLoadImageIssueDetails?.url===remote)+ lazyIssues.push(issue.details.lazyLoadImageIssueDetails.url);+ });+ await audits.send('Audits.enable');await page.route(remote,async route=>{if(delay)await new Promise(resolve=>setTimeout(resolve,delay));await route.fulfill({contentType:'image/svg+xml',body:'<svg xmlns="http://www.w3.org/2000/svg" width="1500" height="1000"><rect width="796" height="1000" fill="#f00"/><rect x="796" width="704" height="1000" fill="#0f0"/></svg>'});@@ -49,6 +55,11 @@ describe('新作封面显示时机',()=>{return samples;});assert.equal(new Set(positions).size,1,'可见封面的取景保持稳定');+ assert.deepEqual(lazyIssues,[],'正封裁切图在 DevTools 中有明确尺寸');+ const ratio=await image.evaluate((img:HTMLImageElement)=>{+ const box=img.getBoundingClientRect();return box.width/box.height;+ });+ assert.ok(Math.abs(ratio-1.5)<.01,'裁切使用源图宽高比');assert.deepEqual(await page.evaluate(()=>(window as any).__unframed),[],'已加载封面在取景完成前保持隐藏');await page.evaluate(()=>{history.pushState({},'','/stats');window.dispatchEvent(new PopStateEvent('popstate'))});await page.locator('#feedNew').waitFor({state:'hidden'});diff --git a/frontend/e2e/smoke.test.ts b/frontend/e2e/smoke.test.tsindex 042f6f3ba..d0e2282d6 100644--- a/frontend/e2e/smoke.test.ts+++ b/frontend/e2e/smoke.test.ts@@ -136,6 +136,15 @@ async function assertHolds(page: Page, problems: string[], where: string): Promiassert.ok(box.scrollWidth <= box.viewportWidth,`${where}:横向溢出,scrollWidth ${box.scrollWidth} > 视口 ${box.viewportWidth}`);assert.deepEqual(box.offenders, [], `${where}:有元素越出视口右边缘`);+ if (where === '/') {+ const images = await page.locator('img[loading="lazy"]').evaluateAll(nodes => ({+ count: nodes.length,+ missing: nodes.filter(node => !(Number(node.getAttribute('width')) > 0 && Number(node.getAttribute('height')) > 0))+ .map(node => node.getAttribute('src')),+ }));+ assert.ok(images.count > 0, '首页没有懒加载图片');+ assert.deepEqual(images.missing, [], '首页懒加载图片需要声明尺寸');+ }}describe('路由冒烟', () => {diff --git a/frontend/src/card-art/framing.ts b/frontend/src/card-art/framing.tsindex 7aeb9bd21..ec82fd270 100644--- a/frontend/src/card-art/framing.ts+++ b/frontend/src/card-art/framing.ts@@ -118,6 +118,7 @@ export function posterPanel(img: HTMLImageElement, ratio: number): void {if (!faceSourceScale(img.naturalWidth, img.naturalHeight, imgW, imgH)) return;const frame = panelFrame({ x0, y0, x1, y1, px: [imgW, imgH] }, ratio);if (!frame) return;+ img.style.setProperty('--panel-aspect', `${img.naturalWidth} / ${img.naturalHeight}`);img.classList.add('panel');img.style.setProperty('--panel-clip',`${frame.clip.top}% ${frame.clip.right}% ${frame.clip.bottom}% ${frame.clip.left}%`);diff --git a/frontend/src/card-art/markup.ts b/frontend/src/card-art/markup.tsindex 548d3b019..c2b089428 100644--- a/frontend/src/card-art/markup.ts+++ b/frontend/src/card-art/markup.ts@@ -99,7 +99,7 @@ export function entityFaceImg({忘了开的代价是页面上一张明显错位的图,而它只在回落发生时才现形。 *//* `decoding="async"` 让解码离开主线程:一屏几十张图同时落地时,同步解码把滚动和点击一起压住,而这些图一张都不参与首屏的排版——框的尺寸由 CSS 定死。 */- return `<img src="${src}" alt="${alt}"${lazy ? ' loading="lazy"' : ''} decoding="async"${framed ? framedStyle : ''} `+ return `<img src="${src}" width="128" height="128" alt="${alt}"${lazy ? ' loading="lazy"' : ''} decoding="async"${framed ? framedStyle : ''} `+ `${faceBox}${imageFallbackAttrs({dropStyle: (dropStyle || !!faceBox || !!framedStyle) && framed,fallbacks,@@ -199,7 +199,7 @@ export function coverImage(item: CoverItem, layout: 'big' | 'small', eager = falconst box = pb ? ` data-posterbox="${[pb.x0, (pb.px || [])[0], (pb.px || [])[1], pb.y0, pb.x1, pb.y1].map(Number).join(' ')}"` : '';// 小图看整张(含剧照拼贴),大图只取右侧正封。return `<img class="poster cover ${layout === 'small' ? 'whole' : 'front'}" src="${src}"- alt="" loading="${eager ? 'eager' : 'lazy'}"${face}${box} data-drop="self">`;+ width="640" height="360" alt="" loading="${eager ? 'eager' : 'lazy'}"${face}${box} data-drop="self">`;}/** 封面格的两种图:官方封套(取景链接管)或预览图。空串是这一条没有可用的图。 */@@ -223,7 +223,7 @@ export function javArtwork(item: CoverItem, layout: 'big' | 'small', eager: boolconst frame = (coverMarkup.match(/ data-(?:c[xy]|posterbox)="[^"]*"/g) || []).join('');const image = kind === 'cover'? coverMarkup- : `<img class="poster" src="${thumb}" alt="" loading="${eager ? 'eager' : 'lazy'}"${frame}>`;+ : `<img class="poster" src="${thumb}" width="640" height="360" alt="" loading="${eager ? 'eager' : 'lazy'}"${frame}>`;return {kind: kind === 'cover' ? 'cover' : 'thumb',html: image.replace('<img ', `<img data-jav-image="${item.id}" data-jav-cover="${esc(cover)}" data-jav-thumb="${esc(thumb)}" data-jav-image-layout="${layout}" `),@@ -238,7 +238,7 @@ export function cardArtwork(item: CoverItem & { follow_thumb_url?: string | nullif (item.follow_thumb_url) {return {kind: 'thumb',- html: `<img class="poster" src="${esc(item.follow_thumb_url)}" alt="" loading="${eager ? 'eager' : 'lazy'}" referrerpolicy="no-referrer">`,+ html: `<img class="poster" src="${esc(item.follow_thumb_url)}" width="640" height="360" alt="" loading="${eager ? 'eager' : 'lazy'}" referrerpolicy="no-referrer">`,};}return mixFace(item, size, eager, javImage);@@ -249,7 +249,7 @@ export function cardArtwork(item: CoverItem & { follow_thumb_url?: string | nullexport function mixFace(item: CoverItem, size: 'big' | 'small', eager: boolean, javImage: unknown): Artwork {if (item.is_jav) return javArtwork(item, size, eager, javImage);if (!item.has_thumb && !item.has_local_poster) return NO_ARTWORK;- return { kind: 'thumb', html: `<img class="poster" src="/poster?id=${item.id}&c=4" alt="" loading="${eager ? 'eager' : 'lazy'}">` };+ return { kind: 'thumb', html: `<img class="poster" src="/poster?id=${item.id}&c=4" width="640" height="360" alt="" loading="${eager ? 'eager' : 'lazy'}">` };}/** 播放队列一行的小图:Mix 画面按小图取,没有可用的图就写「无预览」占住那一格。 */diff --git a/frontend/src/dev/agentation-fields.ts b/frontend/src/dev/agentation-fields.tsnew file mode 100644index 000000000..994db1ff6--- /dev/null+++ b/frontend/src/dev/agentation-fields.ts@@ -0,0 +1,22 @@+/** 标注工具里的字段有独立表单身份,现有 id/name 由工具自己管理。 */+export function identifyAgentationFields(host: HTMLElement): () => void {+ let sequence = 0;+ const watched = new WeakSet<Node>();+ const identify = (root: HTMLElement | ShadowRoot) => {+ if (!watched.has(root)) {+ watched.add(root);+ observer.observe(root, { childList: true, subtree: true });+ }+ for (const field of root.querySelectorAll<HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement>(+ 'input,textarea,select',+ )) {+ if (!field.id && !field.name) field.name = `peach-agentation-field-${++sequence}`;+ }+ for (const child of root.querySelectorAll('*')) {+ if (child.shadowRoot) identify(child.shadowRoot);+ }+ };+ const observer = new MutationObserver(() => identify(host));+ identify(host);+ return () => observer.disconnect();+}diff --git a/frontend/src/dev/agentation.tsx b/frontend/src/dev/agentation.tsxindex bb443fc12..82e9e7d82 100644--- a/frontend/src/dev/agentation.tsx+++ b/frontend/src/dev/agentation.tsx@@ -6,13 +6,16 @@import { Agentation } from 'agentation';import { createRoot } from 'react-dom/client';+import { identifyAgentationFields } from './agentation-fields';+/** 本机 `agentation-mcp` 的 HTTP 端口。服务没起时标注照样存在浏览器里,起来后自动补传。 */const ENDPOINT = 'http://localhost:4747';const host = document.createElement('div');host.dataset.agentation = '';+identifyAgentationFields(host);document.body.append(host);// Peach 自己占着全局快捷键(Esc 收起面板、方向键翻图),标注工具只走工具栏按钮。createRoot(host).render(- <Agentation appName="Peach" endpoint={ENDPOINT} enableKeyboardShortcuts={false} />,+ <Agentation appName="Peach" endpoint={ENDPOINT} portalContainer={host} enableKeyboardShortcuts={false} />,);diff --git a/frontend/src/react/components/media-card.tsx b/frontend/src/react/components/media-card.tsxindex 0c8dcf2df..1b2f250b8 100644--- a/frontend/src/react/components/media-card.tsx+++ b/frontend/src/react/components/media-card.tsx@@ -301,7 +301,7 @@ function ResourceCard({ item, selected, selectMode, helpers, actions, onOpen }:<span data-media-glyph=""><Icon name={glyph} /><b>{label}</b></span>{image? <span data-media-art="thumb" dangerouslySetInnerHTML={{- __html: `<img class="poster" src="/photo-thumb?id=${item.id}" alt="" loading="lazy" data-drop="self">`,+ __html: `<img class="poster" src="/photo-thumb?id=${item.id}" width="640" height="360" alt="" loading="lazy" data-drop="self">`,}} />: null}<div data-media-badge="" dangerouslySetInnerHTML={{ __html: helpers.badgeHtml(item.location || '', item.cost || '') }} />diff --git a/frontend/src/react/components/mix-card.tsx b/frontend/src/react/components/mix-card.tsxindex 7dc9f3ee8..176124e62 100644--- a/frontend/src/react/components/mix-card.tsx+++ b/frontend/src/react/components/mix-card.tsx@@ -75,7 +75,7 @@ function Poster({ src }: { src: string }) {const [broken, setBroken] = useState(false);if (broken) return null;return (- <img data-mix-poster="" src={src} alt="" loading="lazy" onError={() => setBroken(true)}+ <img data-mix-poster="" src={src} width={640} height={360} alt="" loading="lazy" onError={() => setBroken(true)}className="absolute inset-0 block size-full object-contain" />);}diff --git a/frontend/test/card-art/markup.test.ts b/frontend/test/card-art/markup.test.tsindex 56d64c558..ac96ee0c1 100644--- a/frontend/test/card-art/markup.test.ts+++ b/frontend/test/card-art/markup.test.ts@@ -57,6 +57,8 @@ describe('entityFaceImg:实体图优先,取不到退代表作头像', () =>const lazy = parse(entityFaceImg({ id: 3, hasImage: true }))!;expect(lazy.getAttribute('loading')).toBe('lazy');expect(lazy.getAttribute('decoding')).toBe('async');+ expect(lazy.width).toBeGreaterThan(0);+ expect(lazy.height).toBeGreaterThan(0);expect(parse(entityFaceImg({ id: 3, hasImage: true, lazy: false }))!.hasAttribute('loading')).toBe(false);});@@ -162,6 +164,8 @@ describe('coverImage:官方封面', () => {expect(img.dataset.cy).toBe('0.6');expect(img.dataset.posterbox).toBe('421 800 538 0 800 538');expect(img.getAttribute('loading')).toBe('lazy');+ expect(img.width).toBeGreaterThan(0);+ expect(img.height).toBeGreaterThan(0);expect(img.dataset.drop).toBe('self');});@@ -225,8 +229,11 @@ describe('cardArtwork 与队列小图', () => {});it('其余取本地预览格;没有就是空的', () => {- expect(cardArtwork({ id: 1, has_local_poster: true }, 'big', false, 'cover').html)- .toBe('<img class="poster" src="/poster?id=1&c=4" alt="" loading="lazy">');+ const img = parse(cardArtwork({ id: 1, has_local_poster: true }, 'big', false, 'cover').html)!;+ expect(img.getAttribute('src')).toBe('/poster?id=1&c=4');+ expect(img.getAttribute('loading')).toBe('lazy');+ expect(img.width).toBeGreaterThan(0);+ expect(img.height).toBeGreaterThan(0);expect(cardArtwork({ id: 1 }, 'big', false, 'cover').kind).toBe('');});diff --git a/frontend/test/dev/agentation-fields.test.ts b/frontend/test/dev/agentation-fields.test.tsnew file mode 100644index 000000000..7e47af110--- /dev/null+++ b/frontend/test/dev/agentation-fields.test.ts@@ -0,0 +1,39 @@+import { describe, expect, it } from 'vitest';++import { identifyAgentationFields } from '../../src/dev/agentation-fields';++describe('标注工具字段身份', () => {+ it('已有身份保留,动态加入的字段获得各自的名称', async () => {+ const host = document.createElement('div');+ host.innerHTML = '<input id="existing"><textarea name="comment"></textarea><textarea aria-label="Webhook URL"></textarea>';+ const stop = identifyAgentationFields(host);+ try {+ expect(host.querySelector('input')!.name).toBe('');+ expect(host.querySelector('[name="comment"]')).not.toBeNull();+ const webhook = host.querySelector<HTMLTextAreaElement>('[aria-label="Webhook URL"]')!;+ expect(webhook.name).not.toBe('');+ const comment = document.createElement('textarea');+ host.append(comment);+ await new Promise(resolve => setTimeout(resolve, 0));+ expect(comment.name).not.toBe('');+ expect(comment.name).not.toBe(webhook.name);+ host.append(document.createElement('span'));+ await new Promise(resolve => setTimeout(resolve, 0));+ expect(webhook.name).not.toBe(comment.name);+ const shadowHost = document.createElement('div');+ const shadow = shadowHost.attachShadow({ mode: 'open' });+ shadow.innerHTML = '<textarea aria-label="Shadow comment"></textarea>';+ host.append(shadowHost);+ await new Promise(resolve => setTimeout(resolve, 0));+ const shadowComment = shadow.querySelector('textarea')!;+ expect(shadowComment.name).not.toBe('');+ expect(shadowComment.name).not.toBe(comment.name);+ const nested = document.createElement('input');+ shadow.append(nested);+ await new Promise(resolve => setTimeout(resolve, 0));+ expect(nested.name).not.toBe('');+ } finally {+ stop();+ }+ });+});diff --git a/web/app.js b/web/app.jsindex b1449eb53..9f5e4ba5d 100644--- a/web/app.js+++ b/web/app.js@@ -2337,7 +2337,7 @@ function revealRoutedPage(container){没检出脸就两样都不写,圆标按样式表里的默认取景摆。 */function followWorkMark([key,label,,icon,focus]){const fallback=esc(String(label||'').slice(0,2));- return icon?`<img src="/work-icon?work=${encodeURIComponent(key)}" alt="" loading="lazy"${facePos(focus)}${faceBoxAttrs(focus)}>`:fallback;+ return icon?`<img src="/work-icon?work=${encodeURIComponent(key)}" width="128" height="128" alt="" loading="lazy"${facePos(focus)}${faceBoxAttrs(focus)}>`:fallback;}/* ── 管的那一页 ──@@ -3495,7 +3495,7 @@ function hideSearchMenu(){searchControl?.close()}function searchCoverImage(card){const kind=card?javImageKind({...card,is_jav:!!card.code},appSettings.javImage):'';return kind==='cover'?coverImage(card,'big')- :kind?`<img class="poster still" src="/poster?id=${card.id}&c=4" alt="" loading="lazy" data-drop="self">`+ :kind?`<img class="poster still" src="/poster?id=${card.id}&c=4" width="640" height="360" alt="" loading="lazy" data-drop="self">`:'<span class="nopic">无预览</span>';}const searchActions={diff --git a/web/css/19-immersive.css b/web/css/19-immersive.cssindex 5d6c0e59c..030e4c27a 100644--- a/web/css/19-immersive.css+++ b/web/css/19-immersive.css@@ -140,7 +140,7 @@四个值都由 `panelFrame` 算好:沿折痕和按比例算出来的框满高贴右缘,top 为 0、height 为 100%,纵向一个像素都不裁;只有人手工横着框才用得上另两个轴。 */.poster.cover.front.panel{inset:var(--panel-top,0%) auto auto var(--panel-left,0%);width:auto;- max-width:none;height:var(--panel-height,100%);object-fit:fill;+ max-width:none;height:var(--panel-height,100%);aspect-ratio:var(--panel-aspect);object-fit:fill;clip-path:inset(var(--panel-clip,0 0 0 0))}.poster.cover.front[data-frame="front"]{object-fit:contain;object-position:50% 50%}/* 剧照比大图容器宽得多,裁的是横向,所以横向锚点必须跟着人走。没检出时回落diff --git a/web/dist/peach-react.js b/web/dist/peach-react.jsindex 63b5dfbae..03a2d79df 100644--- a/web/dist/peach-react.js+++ b/web/dist/peach-react.js@@ -34427,7 +34427,7 @@ function yle({ item: e, selected: t, selectMode: n, helpers: r, actions: i, onOp}),l ? /* @__PURE__ */ (0, B.jsx)("span", {"data-media-art": "thumb",- dangerouslySetInnerHTML: { __html: `<img class="poster" src="/photo-thumb?id=${e.id}" alt="" loading="lazy" data-drop="self">` }+ dangerouslySetInnerHTML: { __html: `<img class="poster" src="/photo-thumb?id=${e.id}" width="640" height="360" alt="" loading="lazy" data-drop="self">` }}) : null,/* @__PURE__ */ (0, B.jsx)("div", {"data-media-badge": "",@@ -34579,6 +34579,8 @@ function Tle({ src: e }) {return t ? null : /* @__PURE__ */ (0, B.jsx)("img", {"data-mix-poster": "",src: e,+ width: 640,+ height: 360,alt: "",loading: "lazy",onError: () => n(!0),diff --git a/web/dist/peach-ui.js b/web/dist/peach-ui.jsindex 1a6734bf2..ced06e69d 100644--- a/web/dist/peach-ui.js+++ b/web/dist/peach-ui.js@@ -4044,7 +4044,7 @@ function Ra({ kind: e = "performer", id: t = null, hasImage: n = !1, version: rlet h = !!(t && n), g = h ? Na(`/entity-image?kind=${e}&id=${t}${m ? "&thumb=1" : ""}`, r) : "", _ = i ? `/avatar?id=${i}` : "", v = !!o, y = v ? Fa(o, c, s) : g || _ || (a ? `/link-mark?id=${a}` : "");if (!y) return "";let ee = v ? [g, _].filter(Boolean) : h && _ ? [_] : [], te = h && !v, b = te ? Ua(p) : "", ne = d || Ha(p);- return `<img src="${y}" alt="${l}"${u ? " loading=\"lazy\"" : ""} decoding="async"${te ? ne : ""} ${b}${Ta({+ return `<img src="${y}" width="128" height="128" alt="${l}"${u ? " loading=\"lazy\"" : ""} decoding="async"${te ? ne : ""} ${b}${Ta({dropStyle: (f || !!b || !!ne) && te,fallbacks: ee})}>`;@@ -4096,7 +4096,7 @@ function Wa(e, t, n = !1) {o.y1].map(Number).join(" ")}"` : "";return `<img class="poster cover ${t === "small" ? "whole" : "front"}" src="${r}"- alt="" loading="${n ? "eager" : "lazy"}"${a}${s} data-drop="self">`;+ width="640" height="360" alt="" loading="${n ? "eager" : "lazy"}"${a}${s} data-drop="self">`;}var Ga = {kind: "",@@ -4105,7 +4105,7 @@ var Ga = {function Ka(e, n, r, i) {let a = ie(e, i);if (!a) return Ga;- let o = e.has_cover && e.code ? Pa(e, !0) : "", s = e.has_thumb || e.has_local_poster ? `/poster?id=${e.id}&c=4` : "", c = Wa(e, n, r), l = (c.match(/ data-(?:c[xy]|posterbox)="[^"]*"/g) || []).join(""), u = a === "cover" ? c : `<img class="poster" src="${s}" alt="" loading="${r ? "eager" : "lazy"}"${l}>`;+ let o = e.has_cover && e.code ? Pa(e, !0) : "", s = e.has_thumb || e.has_local_poster ? `/poster?id=${e.id}&c=4` : "", c = Wa(e, n, r), l = (c.match(/ data-(?:c[xy]|posterbox)="[^"]*"/g) || []).join(""), u = a === "cover" ? c : `<img class="poster" src="${s}" width="640" height="360" alt="" loading="${r ? "eager" : "lazy"}"${l}>`;return {kind: a === "cover" ? "cover" : "thumb",html: u.replace("<img ", `<img data-jav-image="${e.id}" data-jav-cover="${t(o)}" data-jav-thumb="${t(s)}" data-jav-image-layout="${n}" `)@@ -4114,13 +4114,13 @@ function Ka(e, n, r, i) {function qa(e, n, r, i) {return e.is_jav ? Ka(e, n, r, i) : e.follow_thumb_url ? {kind: "thumb",- html: `<img class="poster" src="${t(e.follow_thumb_url)}" alt="" loading="${r ? "eager" : "lazy"}" referrerpolicy="no-referrer">`+ html: `<img class="poster" src="${t(e.follow_thumb_url)}" width="640" height="360" alt="" loading="${r ? "eager" : "lazy"}" referrerpolicy="no-referrer">`} : Ja(e, n, r, i);}function Ja(e, t, n, r) {return e.is_jav ? Ka(e, t, n, r) : !e.has_thumb && !e.has_local_poster ? Ga : {kind: "thumb",- html: `<img class="poster" src="/poster?id=${e.id}&c=4" alt="" loading="${n ? "eager" : "lazy"}">`+ html: `<img class="poster" src="/poster?id=${e.id}&c=4" width="640" height="360" alt="" loading="${n ? "eager" : "lazy"}">`};}function Ya(e, t) {@@ -4218,7 +4218,7 @@ function ro(e, t) {y1: s,px: [r, i]}, t);- c && (e.classList.add("panel"), e.style.setProperty("--panel-clip", `${c.clip.top}% ${c.clip.right}% ${c.clip.bottom}% ${c.clip.left}%`), e.style.setProperty("--panel-left", `${c.left}%`), e.style.setProperty("--panel-top", `${c.top}%`), e.style.setProperty("--panel-height", `${c.height}%`), io(e));+ c && (e.style.setProperty("--panel-aspect", `${e.naturalWidth} / ${e.naturalHeight}`), e.classList.add("panel"), e.style.setProperty("--panel-clip", `${c.clip.top}% ${c.clip.right}% ${c.clip.bottom}% ${c.clip.left}%`), e.style.setProperty("--panel-left", `${c.left}%`), e.style.setProperty("--panel-top", `${c.top}%`), e.style.setProperty("--panel-height", `${c.height}%`), io(e));}function io(e) {e.closest(".pic,[data-media-pic]")?.style.setProperty("--cover-blur", `url("${e.dataset.thumbSrc || e.currentSrc || e.src}")`);