@jant/core 1.1.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (116) hide show
  1. package/bin/lib/site-snapshot.js +10 -0
  2. package/dist/{app-CKQ9PqAr.js → app-CbOZ2Irh.js} +7988 -5166
  3. package/dist/client/.vite/manifest.json +47 -47
  4. package/dist/client/_assets/chunks/{create-editor-BQkrw8Ax.js → create-editor-hWapNE40.js} +25 -25
  5. package/dist/client/_assets/chunks/footnote-rail-9zwl6jtV.js +2 -0
  6. package/dist/client/_assets/chunks/{settings-paths-B0bNUaih.js → settings-paths-BBVT8zKj.js} +1 -1
  7. package/dist/client/_assets/chunks/{slug-format-CYmQE5ln.js → slug-format-BuCPjSrB.js} +1 -1
  8. package/dist/client/_assets/chunks/sortable-list-DJXwkaOv.js +2 -0
  9. package/dist/client/_assets/chunks/types-DrYFqJH2.js +1 -0
  10. package/dist/client/_assets/chunks/unsafe-svg-CUrgo4Xg.js +1 -0
  11. package/dist/client/_assets/{client-Dp46QSht.js → client-BO8GOFfT.js} +12 -12
  12. package/dist/client/_assets/client-D8Rrsd73.css +2 -0
  13. package/dist/client/_assets/{client-auth-CG55rWb5.js → client-auth-CsUGM718.js} +1 -1
  14. package/dist/client/_assets/client-author-QPm1whbO.css +2 -0
  15. package/dist/client/_assets/client-compose-BB4U7Wz0.js +2004 -0
  16. package/dist/client/_assets/{client-manage-DnYdQAhf.js → client-manage-CI9-eh-8.js} +1 -1
  17. package/dist/client/_assets/{client-settings-CHgsIqXJ.js → client-settings-BnGPuqwc.js} +1 -1
  18. package/dist/index.js +1 -1
  19. package/dist/node.js +3 -2
  20. package/package.json +1 -1
  21. package/src/app.tsx +9 -0
  22. package/src/client/components/compose-types.ts +1 -0
  23. package/src/client/components/jant-compose-dialog.ts +1 -0
  24. package/src/client/components/jant-compose-editor.ts +30 -0
  25. package/src/client/components/jant-compose-fullscreen.ts +1 -0
  26. package/src/client/compose-bridge.ts +61 -1
  27. package/src/client/feed-video-player.ts +6 -0
  28. package/src/client/tiptap/bubble-menu.ts +25 -2
  29. package/src/client/tiptap/create-editor.ts +2 -0
  30. package/src/client/tiptap/extensions.ts +4 -0
  31. package/src/client/video-processor.ts +106 -52
  32. package/src/client/view-confirm.ts +108 -0
  33. package/src/client.ts +1 -0
  34. package/src/db/migrations/0035_brainy_next_avengers.sql +9 -0
  35. package/src/db/migrations/0036_gorgeous_smasher.sql +7 -0
  36. package/src/db/migrations/meta/0035_snapshot.json +2877 -0
  37. package/src/db/migrations/meta/0036_snapshot.json +2924 -0
  38. package/src/db/migrations/meta/_journal.json +14 -0
  39. package/src/db/migrations/pg/0033_cute_magdalene.sql +10 -0
  40. package/src/db/migrations/pg/0034_material_agent_brand.sql +8 -0
  41. package/src/db/migrations/pg/meta/0033_snapshot.json +3719 -0
  42. package/src/db/migrations/pg/meta/0034_snapshot.json +3766 -0
  43. package/src/db/migrations/pg/meta/_journal.json +14 -0
  44. package/src/db/pg/schema.ts +40 -0
  45. package/src/db/schema.ts +61 -0
  46. package/src/i18n/locales/public/en.po +5 -0
  47. package/src/i18n/locales/public/en.ts +1 -1
  48. package/src/i18n/locales/public/zh-Hans.po +5 -0
  49. package/src/i18n/locales/public/zh-Hans.ts +1 -1
  50. package/src/i18n/locales/public/zh-Hant.po +5 -0
  51. package/src/i18n/locales/public/zh-Hant.ts +1 -1
  52. package/src/i18n/locales/settings/en.po +149 -0
  53. package/src/i18n/locales/settings/en.ts +1 -1
  54. package/src/i18n/locales/settings/zh-Hans.po +149 -0
  55. package/src/i18n/locales/settings/zh-Hans.ts +1 -1
  56. package/src/i18n/locales/settings/zh-Hant.po +149 -0
  57. package/src/i18n/locales/settings/zh-Hant.ts +1 -1
  58. package/src/lib/env.ts +20 -0
  59. package/src/lib/github-app-state.ts +1 -1
  60. package/src/lib/github-app.ts +183 -1
  61. package/src/lib/markdown-manager.ts +129 -1
  62. package/src/lib/post-meta.ts +13 -3
  63. package/src/lib/referrer-aliases.ts +311 -0
  64. package/src/lib/render.tsx +10 -0
  65. package/src/lib/resolve-config.ts +14 -0
  66. package/src/lib/summary.ts +152 -54
  67. package/src/lib/tiptap-render.ts +1 -0
  68. package/src/lib/upload.ts +21 -1
  69. package/src/lib/video-playback.ts +55 -0
  70. package/src/lib/view-buffer.ts +201 -0
  71. package/src/lib/view-counting.ts +539 -0
  72. package/src/lib/view-token.ts +177 -0
  73. package/src/lib/view.ts +13 -1
  74. package/src/middleware/view-counter.ts +140 -0
  75. package/src/node/runtime.ts +4 -0
  76. package/src/preset.css +31 -14
  77. package/src/routes/api/media.ts +21 -3
  78. package/src/routes/dash/settings.tsx +433 -168
  79. package/src/routes/pages/archive.tsx +1 -0
  80. package/src/routes/pages/collection.tsx +6 -0
  81. package/src/routes/pages/collections.tsx +1 -0
  82. package/src/routes/pages/featured.tsx +1 -0
  83. package/src/routes/pages/home.tsx +1 -0
  84. package/src/routes/pages/page.tsx +3 -0
  85. package/src/routes/pages/smart-collection.tsx +2 -0
  86. package/src/routes/pages/subscribe.tsx +1 -0
  87. package/src/routes/view-confirm.ts +63 -0
  88. package/src/services/export-theme/assets/client-site.js +1 -1
  89. package/src/services/export-theme/styles/main.css +39 -21
  90. package/src/services/export.ts +2 -0
  91. package/src/services/index.ts +17 -0
  92. package/src/services/mcp.ts +31 -1
  93. package/src/services/media.ts +63 -0
  94. package/src/services/stats.ts +1130 -0
  95. package/src/styles/components-author.css +177 -0
  96. package/src/styles/components.css +11 -3
  97. package/src/styles/tokens.css +65 -30
  98. package/src/styles/ui.css +56 -13
  99. package/src/types/app-context.ts +9 -0
  100. package/src/types/bindings.ts +5 -0
  101. package/src/types/config.ts +54 -0
  102. package/src/types/views.ts +6 -0
  103. package/src/ui/compose/ComposeDialog.tsx +6 -0
  104. package/src/ui/dash/settings/SettingsRootContent.tsx +24 -6
  105. package/src/ui/dash/settings/StatsContent.tsx +855 -0
  106. package/src/ui/font-themes.ts +39 -6
  107. package/src/ui/layouts/BaseLayout.tsx +4 -2
  108. package/src/ui/layouts/SiteLayout.tsx +8 -3
  109. package/src/ui/shared/MediaGallery.tsx +19 -3
  110. package/dist/client/_assets/chunks/footnote-rail-B08scyhW.js +0 -2
  111. package/dist/client/_assets/chunks/sortable-list-t11Ma1Ek.js +0 -2
  112. package/dist/client/_assets/chunks/types-D5iF3H1a.js +0 -1
  113. package/dist/client/_assets/chunks/unsafe-svg-DZl-yjas.js +0 -1
  114. package/dist/client/_assets/client-B0-s9sqx.css +0 -2
  115. package/dist/client/_assets/client-author-CGVvrNZ8.css +0 -2
  116. package/dist/client/_assets/client-compose-DkUTuavR.js +0 -2004
@@ -416,6 +416,7 @@ export async function renderArchivePage(
416
416
  c: Context<Env>,
417
417
  queryOverrides?: Record<string, string>,
418
418
  ): Promise<Response> {
419
+ c.set("viewTarget", { kind: "path" });
419
420
  const { services, appConfig } = c.var;
420
421
  const pageSize = appConfig.archivePageSize;
421
422
  const { params, collections: preloadedCollections } =
@@ -85,6 +85,7 @@ export async function renderCollectionPage(
85
85
  slugExpressionOrSelection: string | ResolvedCollectionSelection,
86
86
  pagePathOverride?: string,
87
87
  ): Promise<Response | null> {
88
+ c.set("viewTarget", { kind: "path" });
88
89
  const page = parsePageNumber(c.req.query("page"));
89
90
  const paginatedPageTitle = formatPageLabel(page);
90
91
  const isAuthenticated = c.var.isAuthenticated;
@@ -122,6 +123,11 @@ export async function renderCollectionPage(
122
123
  (collection) => collection.id,
123
124
  );
124
125
  const isAggregate = selection.collections.length > 1;
126
+ // One collection is counted by id, whatever address it was opened at; an
127
+ // aggregate selection is a page of its own, counted by its path.
128
+ if (!isAggregate) {
129
+ c.set("viewTarget", { kind: "collection", id: primaryCollection.id });
130
+ }
125
131
  const requestedDefaultSort = isAggregate
126
132
  ? "newest"
127
133
  : primaryCollection.sortOrder;
@@ -37,6 +37,7 @@ export const collectionsPageRoutes = new Hono<Env>();
37
37
  export async function renderCollectionsDirectory(
38
38
  c: Context<Env>,
39
39
  ): Promise<Response> {
40
+ c.set("viewTarget", { kind: "path" });
40
41
  // The numbers have to match the collection pages these rows link to, so they
41
42
  // carry this reader's visibility and this view's language. Both come from the
42
43
  // request rather than from `navData` — `navData.isAuthenticated` is
@@ -32,6 +32,7 @@ export const featuredRoutes = new Hono<Env>();
32
32
  * @returns Featured page response
33
33
  */
34
34
  export async function renderFeaturedPage(c: Context<Env>): Promise<Response> {
35
+ c.set("viewTarget", { kind: "path" });
35
36
  // The chrome and the timeline are independent, so they load together. The
36
37
  // timeline only ever wanted `navData.isAuthenticated`, which is
37
38
  // `c.var.isAuthenticated` verbatim.
@@ -36,6 +36,7 @@ export const homeRoutes = new Hono<Env>();
36
36
  * @returns Home page response
37
37
  */
38
38
  export async function renderHomePage(c: Context<Env>): Promise<Response> {
39
+ c.set("viewTarget", { kind: "path" });
39
40
  const i18n = getI18n(c);
40
41
  const page = parsePageNumber(c.req.query("page"));
41
42
  const paginatedPageTitle = formatPageLabel(page);
@@ -310,6 +310,9 @@ async function renderPost(
310
310
  canonicalAlias?: string | null;
311
311
  } = {},
312
312
  ) {
313
+ // A preview is the author looking at their own draft, not a page read.
314
+ if (!options.isPreview) c.set("viewTarget", { kind: "post", id: post.id });
315
+
313
316
  // The chrome, the thread, and the translation links each need only the
314
317
  // post, so they load together. The chrome is scoped to the post's
315
318
  // language: a Japanese post's logo and nav lead into /ja, since the post
@@ -79,6 +79,7 @@ export async function renderSmartCollectionPage(
79
79
  c: Context<Env>,
80
80
  slug: string,
81
81
  ): Promise<Response | null> {
82
+ c.set("viewTarget", { kind: "path" });
82
83
  const page = parsePageNumber(c.req.query("page"));
83
84
  const paginatedPageTitle = formatPageLabel(page);
84
85
 
@@ -87,6 +88,7 @@ export async function renderSmartCollectionPage(
87
88
  getNavigationData(c),
88
89
  ]);
89
90
  if (!smartCollection) return null;
91
+ c.set("viewTarget", { kind: "smartCollection", id: smartCollection.id });
90
92
 
91
93
  const canonicalPagePath = getCollectionPagePath(smartCollection.slug);
92
94
  const viewer = {
@@ -50,6 +50,7 @@ export async function renderSubscribePage(c: Context<Env>): Promise<Response> {
50
50
  // With feeds off there is nothing to subscribe to, and the nav entry is
51
51
  // filtered out too — so the page 404s rather than listing dead addresses.
52
52
  if (!appConfig.rssFeedsEnabled) return c.notFound();
53
+ c.set("viewTarget", { kind: "path" });
53
54
 
54
55
  const navData = await getNavigationData(c);
55
56
  const i18n = getI18n(c);
@@ -0,0 +1,63 @@
1
+ /**
2
+ * View Confirmation Route
3
+ *
4
+ * `POST /_/seen` takes the view token a page carried (`lib/view-token.ts`)
5
+ * back from the browser that kept the page in view, and counts the view.
6
+ * The token says which page and where the reader came from; this route
7
+ * adds when. It answers 204 whatever it thinks of the token: a forger
8
+ * learns nothing, and a reader's browser has already moved on.
9
+ */
10
+
11
+ import { Hono } from "hono";
12
+ import type { Bindings } from "../types.js";
13
+ import type { AppVariables } from "../types/app-context.js";
14
+ import { getEnvString } from "../lib/env.js";
15
+ import { now } from "../lib/time.js";
16
+ import { viewBuffer, type ViewBuffer } from "../lib/view-buffer.js";
17
+ import { formatDayKey, formatHourKey } from "../lib/view-counting.js";
18
+ import { verifyViewToken } from "../lib/view-token.js";
19
+ import { viewSinkFor } from "../middleware/view-counter.js";
20
+
21
+ type Env = { Bindings: Bindings; Variables: AppVariables };
22
+
23
+ /**
24
+ * The confirmation route, mounted under `/_`.
25
+ *
26
+ * @param buffer - The buffer confirmed hits go to; tests pass their own
27
+ * @returns A Hono app with `POST /seen`
28
+ * @example
29
+ * app.route("/_", createViewConfirmRoutes());
30
+ */
31
+ export function createViewConfirmRoutes(buffer: ViewBuffer = viewBuffer) {
32
+ const routes = new Hono<Env>();
33
+
34
+ routes.post("/seen", async (c) => {
35
+ const { appConfig } = c.var;
36
+ const secret = getEnvString(c.env, "AUTH_SECRET");
37
+ if (appConfig.stats.enabled && !c.var.isAuthenticated && secret) {
38
+ const at = now();
39
+ const claims = await verifyViewToken(
40
+ secret,
41
+ (await c.req.text()).trim(),
42
+ at,
43
+ );
44
+ if (claims && claims.siteId === c.var.currentSite.id) {
45
+ buffer.add(
46
+ {
47
+ siteId: claims.siteId,
48
+ day: formatDayKey(at, appConfig.timeZone),
49
+ hour: formatHourKey(at, appConfig.timeZone),
50
+ page: claims.page,
51
+ referrer: claims.referrer,
52
+ },
53
+ viewSinkFor(c),
54
+ );
55
+ }
56
+ }
57
+ return c.body(null, 204);
58
+ });
59
+
60
+ return routes;
61
+ }
62
+
63
+ export const viewConfirmRoutes = createViewConfirmRoutes();
@@ -1,4 +1,4 @@
1
- var e=null,t=0,n=!1,r=null,i=null,a=0;function o(e){return!isFinite(e)||e<0?`0:00`:`${Math.floor(e/60)}:${String(Math.floor(e%60)).padStart(2,`0`)}`}function s(e){return e.querySelector(`audio.media-audio-el`)}function c(e){return e.querySelector(`[data-audio-range]`)}function l(e){return e.querySelector(`[data-audio-waveform]`)}function u(e,t){let n=`${(t*100).toFixed(1)}%`;e.style.background=`linear-gradient(to right, var(--site-text-primary) ${n}, transparent ${n})`}var d=new WeakMap,f=new WeakSet;async function p(e,t){let n=await(await fetch(e)).arrayBuffer(),r=new AudioContext;try{let e=(await r.decodeAudioData(n)).getChannelData(0),i=Math.max(1,Math.floor(e.length/t)),a=Array(t);for(let n=0;n<t;n++){let t=0,r=n*i,o=Math.min(r+i,e.length);for(let n=r;n<o;n++){let r=Math.abs(e[n]);r>t&&(t=r)}a[n]=t}let o=0;for(let e of a)e>o&&(o=e);if(o>0)for(let e=0;e<t;e++)a[e]/=o;return a}finally{await r.close()}}function ee(e=document){let t=e.querySelectorAll(`[data-audio-peaks]`),n=[];for(let e of t){let t=e.dataset.audioPeaks;if(!t)continue;let r=e.closest(`.media-audio-card`);if(r&&!d.has(r))try{let e=JSON.parse(t);if(!Array.isArray(e))continue;d.set(r,e),r.classList.add(`has-waveform`),n.push(r)}catch{}}n.length>0&&requestAnimationFrame(()=>{for(let e of n)h(e,0)})}async function m(e){if(d.has(e)||f.has(e))return;f.add(e);let t=e.querySelector(`audio.media-audio-el source`),n=l(e);if(!t?.src||!n)return;let r=n.getBoundingClientRect().width,i=Math.max(20,Math.floor(r/3));try{let n=await p(t.src,i);d.set(e,n),e.classList.add(`has-waveform`);let r=s(e),a=r?.duration??0;h(e,r&&isFinite(a)&&a>0?r.currentTime/a:0)}catch{}}function h(e,t){let n=d.get(e),r=l(e);if(!n||!r)return;let i=window.devicePixelRatio||1,a=r.getBoundingClientRect(),o=Math.round(a.width*i),s=Math.round(a.height*i);if(o===0||s===0)return;(r.width!==o||r.height!==s)&&(r.width=o,r.height=s);let c=r.getContext(`2d`);if(!c)return;c.clearRect(0,0,o,s);let u=n.length,f=o/u,p=Math.max(1,Math.round(f*.6)),ee=Math.round(2*i),m=s*.85,h=getComputedStyle(r).getPropertyValue(`--site-text-primary`).trim()||`#000`;for(let e=0;e<u;e++){let r=Math.round(e*f+(f-p)/2),a=Math.max(ee,Math.round(n[e]*m)),o=Math.round((s-a)/2);c.globalAlpha=(e+.5)/u<=t?.9:.2,c.fillStyle=h;let l=Math.min(p/2,i);c.beginPath(),c.roundRect(r,o,p,a,l),c.fill()}c.globalAlpha=1}function te(e,t){let{currentTime:r,duration:i}=t,a=isFinite(i)&&i>0,s=a?r/i:0;if(!n){let t=c(e);t&&a&&(t.value=String(Math.round(s*1e3)),u(t,s)),d.has(e)&&h(e,s);let n=e.querySelector(`[data-audio-time]`);n&&(n.textContent=a?`${o(r)} / ${o(i)}`:o(r))}}function ne(){if(!e)return;let n=s(e);n&&!n.paused&&(te(e,n),t=requestAnimationFrame(ne))}function re(){if(e){let t=s(e);t&&!t.paused&&t.pause(),e.classList.remove(`is-playing`),e=null}cancelAnimationFrame(t)}async function ie(n){let r=s(n);if(r){if(e&&e!==n&&re(),r.paused){e=n,n.classList.add(`is-playing`);try{await r.play()}catch{n.classList.remove(`is-playing`),e=null;return}t=requestAnimationFrame(ne),m(n)}else r.pause(),n.classList.remove(`is-playing`),cancelAnimationFrame(t),e=null}}function ae(e){let t=e.closest(`.media-audio-card`);if(!t)return;let n=s(t);if(!n)return;let r=Number(e.value)/1e3,i=n.duration;isFinite(i)&&i>0&&(n.currentTime=r*i)}function oe(e,t){let n=e.getBoundingClientRect();a=Math.max(0,Math.min(1,(t.clientX-n.left)/n.width));let r=e.closest(`.media-audio-card`);if(!r)return;h(r,a);let i=s(r),c=r.querySelector(`[data-audio-time]`);if(i&&c){let e=i.duration;isFinite(e)&&e>0&&(c.textContent=`${o(a*e)} / ${o(e)}`)}}async function se(n){let r=n.closest(`.media-audio-card`);if(!r)return;let i=s(r);if(i){if(i.paused){e&&e!==r&&re(),e=r,r.classList.add(`is-playing`);try{await i.play()}catch{r.classList.remove(`is-playing`),e=null;return}let n=i.duration;isFinite(n)&&n>0&&(i.currentTime=a*n),t=requestAnimationFrame(ne),m(r)}else{let e=i.duration;isFinite(e)&&e>0&&(i.currentTime=a*e)}}}document.addEventListener(`pointerdown`,e=>{let t=e.target;t.matches(`[data-audio-range]`)?(n=!0,r=t):t.matches(`[data-audio-waveform]`)&&(n=!0,i=t,oe(t,e))},!0),document.addEventListener(`pointermove`,e=>{n&&i&&oe(i,e)},!0),document.addEventListener(`pointerup`,()=>{n&&(r?(ae(r),r=null):i&&=(se(i),null)),n=!1},!0),document.addEventListener(`pointercancel`,()=>{r=null,i=null,n=!1},!0),document.addEventListener(`click`,e=>{let t=e.target.closest(`[data-audio-play]`);if(!t)return;e.preventDefault();let n=t.closest(`.media-audio-card`);n&&ie(n)}),document.addEventListener(`input`,e=>{let t=e.target;if(!t.matches(`[data-audio-range]`))return;let n=t.closest(`.media-audio-card`);if(!n)return;let r=s(n);if(!r)return;let i=Number(t.value)/1e3;u(t,i);let a=r.duration,c=n.querySelector(`[data-audio-time]`);c&&isFinite(a)&&a>0&&(c.textContent=`${o(i*a)} / ${o(a)}`)},!0),document.addEventListener(`ended`,n=>{let r=n.target;if(!r.closest)return;let i=r.closest(`.media-audio-card`);if(!i)return;i.classList.remove(`is-playing`),cancelAnimationFrame(t),e=null;let a=c(i);a&&(a.value=`0`,u(a,0)),d.has(i)&&h(i,0);let o=i.querySelector(`[data-audio-time]`);o&&(o.textContent=`0:00`)},!0),document.readyState===`loading`?document.addEventListener(`DOMContentLoaded`,()=>ee()):ee();var g=`jant:media-lightbox-toggle`,ce=`jant:media-video-playback-intent`,le=new Set;function ue(e){let t=e?.trim();return!!t&&le.has(t)}function de(e,t){let n=e?.trim();n&&(t?le.add(n):le.delete(n),document.dispatchEvent(new CustomEvent(ce,{detail:{mediaId:n,paused:t}})))}var fe=`75% 0px`,pe=.6,_=.25,me=160,v=new Set,he=new WeakMap,ge=new WeakSet,y=null,b=null,x=null,_e=!1,S=null,C=null,w=null;function ve(e){return e.length===0?null:[...e].sort((e,t)=>t.visibleArea===e.visibleArea?e.centerDistance===t.centerDistance?t.intersectionRatio-e.intersectionRatio:e.centerDistance-t.centerDistance:t.visibleArea-e.visibleArea)[0]??null}function ye(){return{x:(globalThis.innerWidth||document.documentElement.clientWidth||0)/2,y:(globalThis.innerHeight||document.documentElement.clientHeight||0)/2}}function be(e){return he.get(e)}function xe(e){return ue(e)}function T(e){return xe(e.dataset.feedVideoId)}function Se(e){return e.closest(`.media-video-wrap`)?.querySelector(`[data-feed-video-mute-toggle]`)??null}function E(e){let t=Se(e);if(!t)return;let n=x!==e||e.muted;t.dataset.muted=n?`true`:`false`,t.setAttribute(`aria-label`,n?`Play with sound`:`Mute video`)}function Ce(){for(let e of v)E(e)}function we(e){if(ge.has(e))return;let t=e.dataset.videoSrc;t&&(e.getAttribute(`src`)!==t&&(e.src=t),e.load(),ge.add(e))}function D(e){e?.pause()}function Te(e){if(T(e)){D(e);return}we(e),e.muted=x!==e,e.playsInline=!0,e.loop=!0,E(e),e.play().catch(()=>{})}function Ee(){for(let e of v)e.isConnected||(C?.unobserve(e),w?.unobserve(e),v.delete(e),e===y&&(y=null),e===b&&(b=null),e===x&&(x=null))}function De(){if(S=null,Ee(),document.hidden||_e){D(y);return}let e=[];for(let t of v){let n=be(t);n&&(T(t)||n.intersectionRatio<pe||e.push({video:t,...n}))}let t=null;if(b?.isConnected&&!T(b)){let e=be(b);e&&e.intersectionRatio>_?t=b:(!e||e.intersectionRatio<=_)&&(b=null)}else b&&T(b)&&(b=null);if(t||=ve(e)?.video??null,!t){let e=y?be(y):void 0;if(y&&!T(y)&&e&&e.intersectionRatio>_)return;D(y),y=null;return}t!==y&&(D(y),y=t),Te(t);for(let e of v)e!==t&&(D(e),E(e))}function O(){S!==null&&globalThis.clearTimeout(S),S=globalThis.setTimeout(De,me)}function Oe(e){let t=ye();for(let n of e){let e=n.target,r=n.boundingClientRect,i=r.left+r.width/2,a=r.top+r.height/2,o=n.intersectionRect.width*n.intersectionRect.height,s=Math.hypot(i-t.x,a-t.y);he.set(e,{intersectionRatio:n.intersectionRatio,visibleArea:o,centerDistance:s})}O()}function ke(e){for(let t of e)t.isIntersecting&&we(t.target)}function Ae(){C&&w||globalThis.IntersectionObserver!==void 0&&(C=new globalThis.IntersectionObserver(Oe,{threshold:[0,_,pe,1]}),w=new globalThis.IntersectionObserver(ke,{rootMargin:fe,threshold:0}))}function je(e){v.has(e)||(Ae(),C&&w&&(v.add(e),C.observe(e),w.observe(e),Se(e)?.addEventListener(`click`,Me),E(e)))}function Me(e){e.preventDefault(),e.stopPropagation();let t=e.currentTarget.closest(`.media-video-wrap`)?.querySelector(`[data-feed-short-video]`);if(!t)return;let n=t.dataset.feedVideoId?.trim();n&&de(n,!1),b=t,x!==t||t.muted?(x&&x!==t&&(x.muted=!0),x=t,y!==t&&(D(y),y=t),Te(t)):(x=null,t.muted=!0,E(t)),Ce(),O()}function Ne(e=document){let t=e.querySelectorAll(`[data-feed-short-video]`);for(let e of t)je(e);O()}document.addEventListener(g,e=>{_e=e.detail?.open===!0,_e&&D(y),O()}),document.addEventListener(ce,e=>{let t=e.detail,n=t?.mediaId?.trim();if(n&&typeof t.paused==`boolean`){for(let e of v)e.dataset.feedVideoId?.trim()===n&&t.paused&&(D(e),y===e&&(y=null),b===e&&(b=null));O()}}),document.addEventListener(`visibilitychange`,()=>{document.hidden&&D(y),O()}),document.readyState===`loading`?document.addEventListener(`DOMContentLoaded`,()=>Ne(),{once:!0}):queueMicrotask(()=>Ne());var Pe=4;function Fe(e){return e.querySelector(`[data-media-gallery]`)}function Ie(e){let t=Fe(e);if(!t)return;let{scrollLeft:n,scrollWidth:r,clientWidth:i}=t;e.classList.toggle(`can-scroll-start`,n>Pe),e.classList.toggle(`can-scroll-end`,n+i<r-Pe)}function Le(e){return Math.max(160,Math.round(e.clientWidth*.85))}function k(e,t){e.scrollBy({left:t*Le(e),behavior:`smooth`})}function Re(e,t){if(!(`ResizeObserver`in globalThis))return;let n=0,r=()=>{cancelAnimationFrame(n),n=requestAnimationFrame(()=>Ie(e))},i=new globalThis.ResizeObserver(r),a=()=>{i.disconnect(),i.observe(t);for(let e of t.children)i.observe(e)};a(),new globalThis.MutationObserver(()=>{a(),r()}).observe(t,{childList:!0})}function A(e){if(e.dataset.scrollHintReady===`1`)return;let t=Fe(e);t&&(e.dataset.scrollHintReady=`1`,Ie(e),t.addEventListener(`scroll`,()=>Ie(e),{passive:!0}),Re(e,t),e.querySelector(`.media-gallery-nav-prev`)?.addEventListener(`click`,()=>k(t,-1)),e.querySelector(`.media-gallery-nav-next`)?.addEventListener(`click`,()=>k(t,1)),t.addEventListener(`keydown`,e=>{if(e.target===t)switch(e.key){case`ArrowRight`:e.preventDefault(),k(t,1);break;case`ArrowLeft`:e.preventDefault(),k(t,-1);break;case`Home`:e.preventDefault(),t.scrollTo({left:0,behavior:`smooth`});break;case`End`:e.preventDefault(),t.scrollTo({left:t.scrollWidth,behavior:`smooth`})}}))}function ze(){document.querySelectorAll(`.media-gallery-scroll-wrap`).forEach(A)}var Be=new globalThis.MutationObserver(e=>{for(let t of e)for(let e of t.addedNodes)e instanceof HTMLElement&&(e.matches(`.media-gallery-scroll-wrap`)&&A(e),e.querySelectorAll(`.media-gallery-scroll-wrap`).forEach(A))});document.readyState===`loading`?document.addEventListener(`DOMContentLoaded`,()=>{ze(),Be.observe(document.body,{childList:!0,subtree:!0})}):(ze(),Be.observe(document.body,{childList:!0,subtree:!0}));var Ve=new WeakMap,He=new WeakMap,Ue=[{trigger:`.site-header-more-btn`,popover:`.site-header-more-popover`},{trigger:`.site-header-lang-btn`,popover:`.site-header-lang-popover`}];function We(e,t,n){let r=e.querySelector(t),i=e.querySelector(n);if(!r||!i||r.dataset.moreInitialized===`true`)return;r.dataset.moreInitialized=`true`;let a=new AbortController,o=a.signal;Ve.set(r,a);function s(){i.setAttribute(`aria-hidden`,`false`),r.setAttribute(`aria-expanded`,`true`),document.dispatchEvent(new CustomEvent(`basecoat:popover`,{detail:{source:r.parentElement}}))}function c(e=!1){i.setAttribute(`aria-hidden`,`true`),r.setAttribute(`aria-expanded`,`false`),e&&r.focus()}r.addEventListener(`click`,e=>{e.preventDefault(),e.stopPropagation(),r.getAttribute(`aria-expanded`)===`true`?c():s()},{signal:o}),document.addEventListener(`click`,e=>{e.target instanceof Node&&(r.parentElement?.contains(e.target)||c())},{signal:o}),document.addEventListener(`keydown`,e=>{e.key===`Escape`&&i.getAttribute(`aria-hidden`)===`false`&&c(!0)},{signal:o}),document.addEventListener(`basecoat:popover`,e=>{e.detail?.source!==r.parentElement&&c()},{signal:o})}var Ge=`jant:nav-fresh-visits`;function Ke(){let e=document.createElement(`span`);return e.className=`site-header-link-fresh`,e.setAttribute(`aria-hidden`,`true`),e.textContent=`*`,e}function qe(e){try{let t=JSON.parse(localStorage.getItem(Ge)||`{}`),n=location.pathname,r=e.querySelectorAll(`[data-fresh-at]`);for(let e of r){let r=new URL(e.href).pathname,i=parseInt(e.dataset.freshAt,10);if(r===n)t[r]=Math.floor(Date.now()/1e3);else{let n=t[r];if(!n||n<i){let t=e.querySelector(`svg`);e.insertBefore(Ke(),t)}}}localStorage.setItem(Ge,JSON.stringify(t))}catch{}}function Je(e=document){let t=e.querySelector(`.site-header-hamburger`),n=e.querySelector(`#site-nav-drawer`),r=e.querySelector(`.site-nav-drawer-backdrop`),i=n?.querySelector(`.site-nav-drawer-close`);qe(e);for(let{trigger:t,popover:n}of Ue)We(e,t,n);if(!t||!n||!r||t.dataset.drawerInitialized===`true`)return;t.dataset.drawerInitialized=`true`;let a=new AbortController,o=a.signal;He.set(t,a);function s(){n.setAttribute(`aria-hidden`,`false`),n.removeAttribute(`inert`),r.setAttribute(`aria-hidden`,`false`),t.setAttribute(`aria-expanded`,`true`),document.documentElement.classList.add(`drawer-open`);let e=n.querySelector(`.site-nav-drawer-close`)??n.querySelector(`a[href], button`);e&&e.focus()}function c(e=!0){n.setAttribute(`aria-hidden`,`true`),r.setAttribute(`aria-hidden`,`true`),t.setAttribute(`aria-expanded`,`false`),document.documentElement.classList.remove(`drawer-open`),n.addEventListener(`transitionend`,()=>{n.getAttribute(`aria-hidden`)===`true`&&n.setAttribute(`inert`,``)},{once:!0,signal:o}),e&&t.focus()}t.addEventListener(`click`,()=>{t.getAttribute(`aria-expanded`)===`true`?c():s()},{signal:o}),i?.addEventListener(`click`,()=>c(),{signal:o}),r.addEventListener(`click`,()=>c(),{signal:o}),n.addEventListener(`click`,e=>{e.target instanceof Element&&e.target.closest(`a[href]`)&&c(!1)},{signal:o}),n.addEventListener(`keydown`,e=>{e.key===`Escape`&&(e.preventDefault(),c())},{signal:o})}Je();var Ye=8;function Xe(e,t){let n=Number.parseFloat(e);return Number.isFinite(n)?n:t}function Ze(e){return Xe(getComputedStyle(e).getPropertyValue(`--site-thread-context-max-height`).trim(),240)}function Qe(e){if(e.dataset.threadContextToggleBound===`1`)return;e.dataset.threadContextToggleBound=`1`;let t=e.previousElementSibling;if(!(t instanceof HTMLElement)||t.dataset.threadContext===void 0)return;let n=e.querySelector(`.thread-context-toggle-label`),r=e.dataset.labelMore??`Show more`,i=e.dataset.labelLess??`Show less`,a=!1,o=t=>{e.setAttribute(`aria-expanded`,t?`true`:`false`),n&&(n.textContent=t?i:r)},s=()=>Array.from(t.querySelectorAll(`img`)).every(e=>e.complete),c=()=>{if(a)return;let n=Ze(t),r=t.scrollHeight>n+Ye;t.dataset.collapsed===void 0&&(t.dataset.collapsed=``),r?(e.hidden=!1,o(!1)):s()&&(e.hidden=!0)};if(c(),t.querySelectorAll(`img`).forEach(e=>{e.complete||(e.addEventListener(`load`,c,{once:!0}),e.addEventListener(`error`,c,{once:!0}))}),`ResizeObserver`in globalThis){let e=0;new globalThis.ResizeObserver(()=>{cancelAnimationFrame(e),e=requestAnimationFrame(c)}).observe(t)}let l=()=>{let e=!1,n=r=>{e||r&&r.propertyName!==`max-height`||(e=!0,t.removeEventListener(`transitionend`,n),t.dataset.collapsed===void 0&&(t.style.maxHeight=``))};t.addEventListener(`transitionend`,n),window.setTimeout(n,600)};e.addEventListener(`click`,()=>{a=!0,t.dataset.collapsed===void 0?(t.style.maxHeight=`${t.scrollHeight}px`,t.offsetHeight,requestAnimationFrame(()=>{t.dataset.collapsed=``,t.style.maxHeight=``}),o(!1)):(t.style.maxHeight=`${t.scrollHeight}px`,t.offsetHeight,delete t.dataset.collapsed,o(!0)),l()})}function $e(e=document){e.querySelectorAll(`[data-thread-context-toggle]`).forEach(Qe)}function et(e){let t=e.closest(`.thread-group-detail`);return t?t.querySelector(`.thread-detail-item`)===e:!1}function tt(){return globalThis.location.hash===`#continue`}function nt(e=document){let t=e.querySelector(`[data-post-current]`);if(!(t instanceof HTMLElement))return;let n=tt();if(globalThis.location.hash&&!n)return;let r=n?`auto`:`smooth`,i=et(t);requestAnimationFrame(()=>{(!i||n)&&t.scrollIntoView({behavior:r,block:`start`})})}document.addEventListener(`DOMContentLoaded`,()=>{$e(document),nt(document)});var j=globalThis,M=j.ShadowRoot&&(j.ShadyCSS===void 0||j.ShadyCSS.nativeShadow)&&`adoptedStyleSheets`in Document.prototype&&`replace`in CSSStyleSheet.prototype,rt=Symbol(),it=new WeakMap,at=class{constructor(e,t,n){if(this._$cssResult$=!0,n!==rt)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=t}get styleSheet(){let e=this.o,t=this.t;if(M&&e===void 0){let n=t!==void 0&&t.length===1;n&&(e=it.get(t)),e===void 0&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),n&&it.set(t,e))}return e}toString(){return this.cssText}},ot=e=>new at(typeof e==`string`?e:e+``,void 0,rt),st=(e,t)=>{if(M)e.adoptedStyleSheets=t.map(e=>e instanceof CSSStyleSheet?e:e.styleSheet);else for(let n of t){let t=document.createElement(`style`),r=j.litNonce;r!==void 0&&t.setAttribute(`nonce`,r),t.textContent=n.cssText,e.appendChild(t)}},ct=M?e=>e:e=>e instanceof CSSStyleSheet?(e=>{let t=``;for(let n of e.cssRules)t+=n.cssText;return ot(t)})(e):e,{is:lt,defineProperty:ut,getOwnPropertyDescriptor:dt,getOwnPropertyNames:ft,getOwnPropertySymbols:pt,getPrototypeOf:mt}=Object,N=globalThis,ht=N.trustedTypes,gt=ht?ht.emptyScript:``,_t=N.reactiveElementPolyfillSupport,P=(e,t)=>e,F={toAttribute(e,t){switch(t){case Boolean:e=e?gt:null;break;case Object:case Array:e=e==null?e:JSON.stringify(e)}return e},fromAttribute(e,t){let n=e;switch(t){case Boolean:n=e!==null;break;case Number:n=e===null?null:Number(e);break;case Object:case Array:try{n=JSON.parse(e)}catch{n=null}}return n}},vt=(e,t)=>!lt(e,t),yt={attribute:!0,type:String,converter:F,reflect:!1,useDefault:!1,hasChanged:vt};Symbol.metadata??=Symbol(`metadata`),N.litPropertyMetadata??=new WeakMap;var I=class extends HTMLElement{static addInitializer(e){this._$Ei(),(this.l??=[]).push(e)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(e,t=yt){if(t.state&&(t.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(e)&&((t=Object.create(t)).wrapped=!0),this.elementProperties.set(e,t),!t.noAccessor){let n=Symbol(),r=this.getPropertyDescriptor(e,n,t);r!==void 0&&ut(this.prototype,e,r)}}static getPropertyDescriptor(e,t,n){let{get:r,set:i}=dt(this.prototype,e)??{get(){return this[t]},set(e){this[t]=e}};return{get:r,set(t){let a=r?.call(this);i?.call(this,t),this.requestUpdate(e,a,n)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)??yt}static _$Ei(){if(this.hasOwnProperty(P(`elementProperties`)))return;let e=mt(this);e.finalize(),e.l!==void 0&&(this.l=[...e.l]),this.elementProperties=new Map(e.elementProperties)}static finalize(){if(this.hasOwnProperty(P(`finalized`)))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(P(`properties`))){let e=this.properties,t=[...ft(e),...pt(e)];for(let n of t)this.createProperty(n,e[n])}let e=this[Symbol.metadata];if(e!==null){let t=litPropertyMetadata.get(e);if(t!==void 0)for(let[e,n]of t)this.elementProperties.set(e,n)}this._$Eh=new Map;for(let[e,t]of this.elementProperties){let n=this._$Eu(e,t);n!==void 0&&this._$Eh.set(n,e)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(e){let t=[];if(Array.isArray(e)){let n=new Set(e.flat(1/0).reverse());for(let e of n)t.unshift(ct(e))}else e!==void 0&&t.push(ct(e));return t}static _$Eu(e,t){let n=t.attribute;return!1===n?void 0:typeof n==`string`?n:typeof e==`string`?e.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise(e=>this.enableUpdating=e),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach(e=>e(this))}addController(e){(this._$EO??=new Set).add(e),this.renderRoot!==void 0&&this.isConnected&&e.hostConnected?.()}removeController(e){this._$EO?.delete(e)}_$E_(){let e=new Map,t=this.constructor.elementProperties;for(let n of t.keys())this.hasOwnProperty(n)&&(e.set(n,this[n]),delete this[n]);e.size>0&&(this._$Ep=e)}createRenderRoot(){let e=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return st(e,this.constructor.elementStyles),e}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach(e=>e.hostConnected?.())}enableUpdating(e){}disconnectedCallback(){this._$EO?.forEach(e=>e.hostDisconnected?.())}attributeChangedCallback(e,t,n){this._$AK(e,n)}_$ET(e,t){let n=this.constructor.elementProperties.get(e),r=this.constructor._$Eu(e,n);if(r!==void 0&&!0===n.reflect){let i=(n.converter?.toAttribute===void 0?F:n.converter).toAttribute(t,n.type);this._$Em=e,i==null?this.removeAttribute(r):this.setAttribute(r,i),this._$Em=null}}_$AK(e,t){let n=this.constructor,r=n._$Eh.get(e);if(r!==void 0&&this._$Em!==r){let e=n.getPropertyOptions(r),i=typeof e.converter==`function`?{fromAttribute:e.converter}:e.converter?.fromAttribute===void 0?F:e.converter;this._$Em=r;let a=i.fromAttribute(t,e.type);this[r]=a??this._$Ej?.get(r)??a,this._$Em=null}}requestUpdate(e,t,n,r=!1,i){if(e!==void 0){let a=this.constructor;if(!1===r&&(i=this[e]),n??=a.getPropertyOptions(e),!((n.hasChanged??vt)(i,t)||n.useDefault&&n.reflect&&i===this._$Ej?.get(e)&&!this.hasAttribute(a._$Eu(e,n))))return;this.C(e,t,n)}!1===this.isUpdatePending&&(this._$ES=this._$EP())}C(e,t,{useDefault:n,reflect:r,wrapped:i},a){n&&!(this._$Ej??=new Map).has(e)&&(this._$Ej.set(e,a??t??this[e]),!0!==i||a!==void 0)||(this._$AL.has(e)||(this.hasUpdated||n||(t=void 0),this._$AL.set(e,t)),!0===r&&this._$Em!==e&&(this._$Eq??=new Set).add(e))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(e){Promise.reject(e)}let e=this.scheduleUpdate();return e!=null&&await e,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(let[e,t]of this._$Ep)this[e]=t;this._$Ep=void 0}let e=this.constructor.elementProperties;if(e.size>0)for(let[t,n]of e){let{wrapped:e}=n,r=this[t];!0!==e||this._$AL.has(t)||r===void 0||this.C(t,void 0,n,r)}}let e=!1,t=this._$AL;try{e=this.shouldUpdate(t),e?(this.willUpdate(t),this._$EO?.forEach(e=>e.hostUpdate?.()),this.update(t)):this._$EM()}catch(t){throw e=!1,this._$EM(),t}e&&this._$AE(t)}willUpdate(e){}_$AE(e){this._$EO?.forEach(e=>e.hostUpdated?.()),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(e)),this.updated(e)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(e){return!0}update(e){this._$Eq&&=this._$Eq.forEach(e=>this._$ET(e,this[e])),this._$EM()}updated(e){}firstUpdated(e){}};I.elementStyles=[],I.shadowRootOptions={mode:`open`},I[P(`elementProperties`)]=new Map,I[P(`finalized`)]=new Map,_t?.({ReactiveElement:I}),(N.reactiveElementVersions??=[]).push(`2.1.2`);var bt=globalThis,xt=e=>e,L=bt.trustedTypes,St=L?L.createPolicy(`lit-html`,{createHTML:e=>e}):void 0,Ct=`$lit$`,R=`lit$${Math.random().toFixed(9).slice(2)}$`,wt=`?`+R,Tt=`<${wt}>`,z=document,B=()=>z.createComment(``),V=e=>e===null||typeof e!=`object`&&typeof e!=`function`,Et=Array.isArray,Dt=e=>Et(e)||typeof e?.[Symbol.iterator]==`function`,Ot=`[
1
+ var e=null,t=0,n=!1,r=null,i=null,a=0;function o(e){return!isFinite(e)||e<0?`0:00`:`${Math.floor(e/60)}:${String(Math.floor(e%60)).padStart(2,`0`)}`}function s(e){return e.querySelector(`audio.media-audio-el`)}function c(e){return e.querySelector(`[data-audio-range]`)}function l(e){return e.querySelector(`[data-audio-waveform]`)}function u(e,t){let n=`${(t*100).toFixed(1)}%`;e.style.background=`linear-gradient(to right, var(--site-text-primary) ${n}, transparent ${n})`}var d=new WeakMap,f=new WeakSet;async function p(e,t){let n=await(await fetch(e)).arrayBuffer(),r=new AudioContext;try{let e=(await r.decodeAudioData(n)).getChannelData(0),i=Math.max(1,Math.floor(e.length/t)),a=Array(t);for(let n=0;n<t;n++){let t=0,r=n*i,o=Math.min(r+i,e.length);for(let n=r;n<o;n++){let r=Math.abs(e[n]);r>t&&(t=r)}a[n]=t}let o=0;for(let e of a)e>o&&(o=e);if(o>0)for(let e=0;e<t;e++)a[e]/=o;return a}finally{await r.close()}}function ee(e=document){let t=e.querySelectorAll(`[data-audio-peaks]`),n=[];for(let e of t){let t=e.dataset.audioPeaks;if(!t)continue;let r=e.closest(`.media-audio-card`);if(r&&!d.has(r))try{let e=JSON.parse(t);if(!Array.isArray(e))continue;d.set(r,e),r.classList.add(`has-waveform`),n.push(r)}catch{}}n.length>0&&requestAnimationFrame(()=>{for(let e of n)h(e,0)})}async function m(e){if(d.has(e)||f.has(e))return;f.add(e);let t=e.querySelector(`audio.media-audio-el source`),n=l(e);if(!t?.src||!n)return;let r=n.getBoundingClientRect().width,i=Math.max(20,Math.floor(r/3));try{let n=await p(t.src,i);d.set(e,n),e.classList.add(`has-waveform`);let r=s(e),a=r?.duration??0;h(e,r&&isFinite(a)&&a>0?r.currentTime/a:0)}catch{}}function h(e,t){let n=d.get(e),r=l(e);if(!n||!r)return;let i=window.devicePixelRatio||1,a=r.getBoundingClientRect(),o=Math.round(a.width*i),s=Math.round(a.height*i);if(o===0||s===0)return;(r.width!==o||r.height!==s)&&(r.width=o,r.height=s);let c=r.getContext(`2d`);if(!c)return;c.clearRect(0,0,o,s);let u=n.length,f=o/u,p=Math.max(1,Math.round(f*.6)),ee=Math.round(2*i),m=s*.85,h=getComputedStyle(r).getPropertyValue(`--site-text-primary`).trim()||`#000`;for(let e=0;e<u;e++){let r=Math.round(e*f+(f-p)/2),a=Math.max(ee,Math.round(n[e]*m)),o=Math.round((s-a)/2);c.globalAlpha=(e+.5)/u<=t?.9:.2,c.fillStyle=h;let l=Math.min(p/2,i);c.beginPath(),c.roundRect(r,o,p,a,l),c.fill()}c.globalAlpha=1}function te(e,t){let{currentTime:r,duration:i}=t,a=isFinite(i)&&i>0,s=a?r/i:0;if(!n){let t=c(e);t&&a&&(t.value=String(Math.round(s*1e3)),u(t,s)),d.has(e)&&h(e,s);let n=e.querySelector(`[data-audio-time]`);n&&(n.textContent=a?`${o(r)} / ${o(i)}`:o(r))}}function ne(){if(!e)return;let n=s(e);n&&!n.paused&&(te(e,n),t=requestAnimationFrame(ne))}function re(){if(e){let t=s(e);t&&!t.paused&&t.pause(),e.classList.remove(`is-playing`),e=null}cancelAnimationFrame(t)}async function ie(n){let r=s(n);if(r){if(e&&e!==n&&re(),r.paused){e=n,n.classList.add(`is-playing`);try{await r.play()}catch{n.classList.remove(`is-playing`),e=null;return}t=requestAnimationFrame(ne),m(n)}else r.pause(),n.classList.remove(`is-playing`),cancelAnimationFrame(t),e=null}}function ae(e){let t=e.closest(`.media-audio-card`);if(!t)return;let n=s(t);if(!n)return;let r=Number(e.value)/1e3,i=n.duration;isFinite(i)&&i>0&&(n.currentTime=r*i)}function oe(e,t){let n=e.getBoundingClientRect();a=Math.max(0,Math.min(1,(t.clientX-n.left)/n.width));let r=e.closest(`.media-audio-card`);if(!r)return;h(r,a);let i=s(r),c=r.querySelector(`[data-audio-time]`);if(i&&c){let e=i.duration;isFinite(e)&&e>0&&(c.textContent=`${o(a*e)} / ${o(e)}`)}}async function se(n){let r=n.closest(`.media-audio-card`);if(!r)return;let i=s(r);if(i){if(i.paused){e&&e!==r&&re(),e=r,r.classList.add(`is-playing`);try{await i.play()}catch{r.classList.remove(`is-playing`),e=null;return}let n=i.duration;isFinite(n)&&n>0&&(i.currentTime=a*n),t=requestAnimationFrame(ne),m(r)}else{let e=i.duration;isFinite(e)&&e>0&&(i.currentTime=a*e)}}}document.addEventListener(`pointerdown`,e=>{let t=e.target;t.matches(`[data-audio-range]`)?(n=!0,r=t):t.matches(`[data-audio-waveform]`)&&(n=!0,i=t,oe(t,e))},!0),document.addEventListener(`pointermove`,e=>{n&&i&&oe(i,e)},!0),document.addEventListener(`pointerup`,()=>{n&&(r?(ae(r),r=null):i&&=(se(i),null)),n=!1},!0),document.addEventListener(`pointercancel`,()=>{r=null,i=null,n=!1},!0),document.addEventListener(`click`,e=>{let t=e.target.closest(`[data-audio-play]`);if(!t)return;e.preventDefault();let n=t.closest(`.media-audio-card`);n&&ie(n)}),document.addEventListener(`input`,e=>{let t=e.target;if(!t.matches(`[data-audio-range]`))return;let n=t.closest(`.media-audio-card`);if(!n)return;let r=s(n);if(!r)return;let i=Number(t.value)/1e3;u(t,i);let a=r.duration,c=n.querySelector(`[data-audio-time]`);c&&isFinite(a)&&a>0&&(c.textContent=`${o(i*a)} / ${o(a)}`)},!0),document.addEventListener(`ended`,n=>{let r=n.target;if(!r.closest)return;let i=r.closest(`.media-audio-card`);if(!i)return;i.classList.remove(`is-playing`),cancelAnimationFrame(t),e=null;let a=c(i);a&&(a.value=`0`,u(a,0)),d.has(i)&&h(i,0);let o=i.querySelector(`[data-audio-time]`);o&&(o.textContent=`0:00`)},!0),document.readyState===`loading`?document.addEventListener(`DOMContentLoaded`,()=>ee()):ee();var g=`jant:media-lightbox-toggle`,ce=`jant:media-video-playback-intent`,le=new Set;function ue(e){let t=e?.trim();return!!t&&le.has(t)}function de(e,t){let n=e?.trim();n&&(t?le.add(n):le.delete(n),document.dispatchEvent(new CustomEvent(ce,{detail:{mediaId:n,paused:t}})))}var fe=`75% 0px`,pe=.6,_=.25,me=160,v=new Set,he=new WeakMap,ge=new WeakSet,y=null,b=null,x=null,_e=!1,S=null,C=null,w=null;function ve(e){return e.length===0?null:[...e].sort((e,t)=>t.visibleArea===e.visibleArea?e.centerDistance===t.centerDistance?t.intersectionRatio-e.intersectionRatio:e.centerDistance-t.centerDistance:t.visibleArea-e.visibleArea)[0]??null}function ye(){return{x:(globalThis.innerWidth||document.documentElement.clientWidth||0)/2,y:(globalThis.innerHeight||document.documentElement.clientHeight||0)/2}}function be(e){return he.get(e)}function xe(e){return ue(e)}function T(e){return xe(e.dataset.feedVideoId)}function Se(e){return e.closest(`.media-video-wrap`)?.querySelector(`[data-feed-video-mute-toggle]`)??null}function E(e){let t=Se(e);if(!t)return;let n=x!==e||e.muted;t.dataset.muted=n?`true`:`false`,t.setAttribute(`aria-label`,n?`Play with sound`:`Mute video`)}function Ce(){for(let e of v)E(e)}function we(e){if(ge.has(e))return;let t=e.dataset.videoSrc;t&&(e.getAttribute(`src`)!==t&&(e.src=t),e.load(),ge.add(e))}function D(e){e?.pause()}function Te(e){if(T(e)){D(e);return}we(e),e.muted=x!==e,e.playsInline=!0,e.loop=!0,E(e),e.play().catch(()=>{})}function Ee(){for(let e of v)e.isConnected||(C?.unobserve(e),w?.unobserve(e),v.delete(e),e===y&&(y=null),e===b&&(b=null),e===x&&(x=null))}function De(){if(S=null,Ee(),document.hidden||_e){D(y);return}let e=[];for(let t of v){let n=be(t);n&&(T(t)||n.intersectionRatio<pe||e.push({video:t,...n}))}let t=null;if(b?.isConnected&&!T(b)){let e=be(b);e&&e.intersectionRatio>_?t=b:(!e||e.intersectionRatio<=_)&&(b=null)}else b&&T(b)&&(b=null);if(t||=ve(e)?.video??null,!t){let e=y?be(y):void 0;if(y&&!T(y)&&e&&e.intersectionRatio>_)return;D(y),y=null;return}t!==y&&(D(y),y=t),Te(t);for(let e of v)e!==t&&(D(e),E(e))}function O(){S!==null&&(globalThis.clearTimeout(S),S=null),v.size!==0&&(S=globalThis.setTimeout(De,me))}function Oe(e){let t=ye();for(let n of e){let e=n.target,r=n.boundingClientRect,i=r.left+r.width/2,a=r.top+r.height/2,o=n.intersectionRect.width*n.intersectionRect.height,s=Math.hypot(i-t.x,a-t.y);he.set(e,{intersectionRatio:n.intersectionRatio,visibleArea:o,centerDistance:s})}O()}function ke(e){for(let t of e)t.isIntersecting&&we(t.target)}function Ae(){C&&w||globalThis.IntersectionObserver!==void 0&&(C=new globalThis.IntersectionObserver(Oe,{threshold:[0,_,pe,1]}),w=new globalThis.IntersectionObserver(ke,{rootMargin:fe,threshold:0}))}function je(e){v.has(e)||(Ae(),C&&w&&(v.add(e),C.observe(e),w.observe(e),Se(e)?.addEventListener(`click`,Me),E(e)))}function Me(e){e.preventDefault(),e.stopPropagation();let t=e.currentTarget.closest(`.media-video-wrap`)?.querySelector(`[data-feed-short-video]`);if(!t)return;let n=t.dataset.feedVideoId?.trim();n&&de(n,!1),b=t,x!==t||t.muted?(x&&x!==t&&(x.muted=!0),x=t,y!==t&&(D(y),y=t),Te(t)):(x=null,t.muted=!0,E(t)),Ce(),O()}function Ne(e=document){let t=e.querySelectorAll(`[data-feed-short-video]`);for(let e of t)je(e);O()}document.addEventListener(g,e=>{_e=e.detail?.open===!0,_e&&D(y),O()}),document.addEventListener(ce,e=>{let t=e.detail,n=t?.mediaId?.trim();if(n&&typeof t.paused==`boolean`){for(let e of v)e.dataset.feedVideoId?.trim()===n&&t.paused&&(D(e),y===e&&(y=null),b===e&&(b=null));O()}}),document.addEventListener(`visibilitychange`,()=>{document.hidden&&D(y),O()}),document.readyState===`loading`?document.addEventListener(`DOMContentLoaded`,()=>Ne(),{once:!0}):queueMicrotask(()=>Ne());var Pe=4;function Fe(e){return e.querySelector(`[data-media-gallery]`)}function Ie(e){let t=Fe(e);if(!t)return;let{scrollLeft:n,scrollWidth:r,clientWidth:i}=t;e.classList.toggle(`can-scroll-start`,n>Pe),e.classList.toggle(`can-scroll-end`,n+i<r-Pe)}function Le(e){return Math.max(160,Math.round(e.clientWidth*.85))}function k(e,t){e.scrollBy({left:t*Le(e),behavior:`smooth`})}function Re(e,t){if(!(`ResizeObserver`in globalThis))return;let n=0,r=()=>{cancelAnimationFrame(n),n=requestAnimationFrame(()=>Ie(e))},i=new globalThis.ResizeObserver(r),a=()=>{i.disconnect(),i.observe(t);for(let e of t.children)i.observe(e)};a(),new globalThis.MutationObserver(()=>{a(),r()}).observe(t,{childList:!0})}function A(e){if(e.dataset.scrollHintReady===`1`)return;let t=Fe(e);t&&(e.dataset.scrollHintReady=`1`,Ie(e),t.addEventListener(`scroll`,()=>Ie(e),{passive:!0}),Re(e,t),e.querySelector(`.media-gallery-nav-prev`)?.addEventListener(`click`,()=>k(t,-1)),e.querySelector(`.media-gallery-nav-next`)?.addEventListener(`click`,()=>k(t,1)),t.addEventListener(`keydown`,e=>{if(e.target===t)switch(e.key){case`ArrowRight`:e.preventDefault(),k(t,1);break;case`ArrowLeft`:e.preventDefault(),k(t,-1);break;case`Home`:e.preventDefault(),t.scrollTo({left:0,behavior:`smooth`});break;case`End`:e.preventDefault(),t.scrollTo({left:t.scrollWidth,behavior:`smooth`})}}))}function ze(){document.querySelectorAll(`.media-gallery-scroll-wrap`).forEach(A)}var Be=new globalThis.MutationObserver(e=>{for(let t of e)for(let e of t.addedNodes)e instanceof HTMLElement&&(e.matches(`.media-gallery-scroll-wrap`)&&A(e),e.querySelectorAll(`.media-gallery-scroll-wrap`).forEach(A))});document.readyState===`loading`?document.addEventListener(`DOMContentLoaded`,()=>{ze(),Be.observe(document.body,{childList:!0,subtree:!0})}):(ze(),Be.observe(document.body,{childList:!0,subtree:!0}));var Ve=new WeakMap,He=new WeakMap,Ue=[{trigger:`.site-header-more-btn`,popover:`.site-header-more-popover`},{trigger:`.site-header-lang-btn`,popover:`.site-header-lang-popover`}];function We(e,t,n){let r=e.querySelector(t),i=e.querySelector(n);if(!r||!i||r.dataset.moreInitialized===`true`)return;r.dataset.moreInitialized=`true`;let a=new AbortController,o=a.signal;Ve.set(r,a);function s(){i.setAttribute(`aria-hidden`,`false`),r.setAttribute(`aria-expanded`,`true`),document.dispatchEvent(new CustomEvent(`basecoat:popover`,{detail:{source:r.parentElement}}))}function c(e=!1){i.setAttribute(`aria-hidden`,`true`),r.setAttribute(`aria-expanded`,`false`),e&&r.focus()}r.addEventListener(`click`,e=>{e.preventDefault(),e.stopPropagation(),r.getAttribute(`aria-expanded`)===`true`?c():s()},{signal:o}),document.addEventListener(`click`,e=>{e.target instanceof Node&&(r.parentElement?.contains(e.target)||c())},{signal:o}),document.addEventListener(`keydown`,e=>{e.key===`Escape`&&i.getAttribute(`aria-hidden`)===`false`&&c(!0)},{signal:o}),document.addEventListener(`basecoat:popover`,e=>{e.detail?.source!==r.parentElement&&c()},{signal:o})}var Ge=`jant:nav-fresh-visits`;function Ke(){let e=document.createElement(`span`);return e.className=`site-header-link-fresh`,e.setAttribute(`aria-hidden`,`true`),e.textContent=`*`,e}function qe(e){try{let t=JSON.parse(localStorage.getItem(Ge)||`{}`),n=location.pathname,r=e.querySelectorAll(`[data-fresh-at]`);for(let e of r){let r=new URL(e.href).pathname,i=parseInt(e.dataset.freshAt,10);if(r===n)t[r]=Math.floor(Date.now()/1e3);else{let n=t[r];if(!n||n<i){let t=e.querySelector(`svg`);e.insertBefore(Ke(),t)}}}localStorage.setItem(Ge,JSON.stringify(t))}catch{}}function Je(e=document){let t=e.querySelector(`.site-header-hamburger`),n=e.querySelector(`#site-nav-drawer`),r=e.querySelector(`.site-nav-drawer-backdrop`),i=n?.querySelector(`.site-nav-drawer-close`);qe(e);for(let{trigger:t,popover:n}of Ue)We(e,t,n);if(!t||!n||!r||t.dataset.drawerInitialized===`true`)return;t.dataset.drawerInitialized=`true`;let a=new AbortController,o=a.signal;He.set(t,a);function s(){n.setAttribute(`aria-hidden`,`false`),n.removeAttribute(`inert`),r.setAttribute(`aria-hidden`,`false`),t.setAttribute(`aria-expanded`,`true`),document.documentElement.classList.add(`drawer-open`);let e=n.querySelector(`.site-nav-drawer-close`)??n.querySelector(`a[href], button`);e&&e.focus()}function c(e=!0){n.setAttribute(`aria-hidden`,`true`),r.setAttribute(`aria-hidden`,`true`),t.setAttribute(`aria-expanded`,`false`),document.documentElement.classList.remove(`drawer-open`),n.addEventListener(`transitionend`,()=>{n.getAttribute(`aria-hidden`)===`true`&&n.setAttribute(`inert`,``)},{once:!0,signal:o}),e&&t.focus()}t.addEventListener(`click`,()=>{t.getAttribute(`aria-expanded`)===`true`?c():s()},{signal:o}),i?.addEventListener(`click`,()=>c(),{signal:o}),r.addEventListener(`click`,()=>c(),{signal:o}),n.addEventListener(`click`,e=>{e.target instanceof Element&&e.target.closest(`a[href]`)&&c(!1)},{signal:o}),n.addEventListener(`keydown`,e=>{e.key===`Escape`&&(e.preventDefault(),c())},{signal:o})}Je();var Ye=8;function Xe(e,t){let n=Number.parseFloat(e);return Number.isFinite(n)?n:t}function Ze(e){return Xe(getComputedStyle(e).getPropertyValue(`--site-thread-context-max-height`).trim(),240)}function Qe(e){if(e.dataset.threadContextToggleBound===`1`)return;e.dataset.threadContextToggleBound=`1`;let t=e.previousElementSibling;if(!(t instanceof HTMLElement)||t.dataset.threadContext===void 0)return;let n=e.querySelector(`.thread-context-toggle-label`),r=e.dataset.labelMore??`Show more`,i=e.dataset.labelLess??`Show less`,a=!1,o=t=>{e.setAttribute(`aria-expanded`,t?`true`:`false`),n&&(n.textContent=t?i:r)},s=()=>Array.from(t.querySelectorAll(`img`)).every(e=>e.complete),c=()=>{if(a)return;let n=Ze(t),r=t.scrollHeight>n+Ye;t.dataset.collapsed===void 0&&(t.dataset.collapsed=``),r?(e.hidden=!1,o(!1)):s()&&(e.hidden=!0)};if(c(),t.querySelectorAll(`img`).forEach(e=>{e.complete||(e.addEventListener(`load`,c,{once:!0}),e.addEventListener(`error`,c,{once:!0}))}),`ResizeObserver`in globalThis){let e=0;new globalThis.ResizeObserver(()=>{cancelAnimationFrame(e),e=requestAnimationFrame(c)}).observe(t)}let l=()=>{let e=!1,n=r=>{e||r&&r.propertyName!==`max-height`||(e=!0,t.removeEventListener(`transitionend`,n),t.dataset.collapsed===void 0&&(t.style.maxHeight=``))};t.addEventListener(`transitionend`,n),window.setTimeout(n,600)};e.addEventListener(`click`,()=>{a=!0,t.dataset.collapsed===void 0?(t.style.maxHeight=`${t.scrollHeight}px`,t.offsetHeight,requestAnimationFrame(()=>{t.dataset.collapsed=``,t.style.maxHeight=``}),o(!1)):(t.style.maxHeight=`${t.scrollHeight}px`,t.offsetHeight,delete t.dataset.collapsed,o(!0)),l()})}function $e(e=document){e.querySelectorAll(`[data-thread-context-toggle]`).forEach(Qe)}function et(e){let t=e.closest(`.thread-group-detail`);return t?t.querySelector(`.thread-detail-item`)===e:!1}function tt(){return globalThis.location.hash===`#continue`}function nt(e=document){let t=e.querySelector(`[data-post-current]`);if(!(t instanceof HTMLElement))return;let n=tt();if(globalThis.location.hash&&!n)return;let r=n?`auto`:`smooth`,i=et(t);requestAnimationFrame(()=>{(!i||n)&&t.scrollIntoView({behavior:r,block:`start`})})}document.addEventListener(`DOMContentLoaded`,()=>{$e(document),nt(document)});var j=globalThis,M=j.ShadowRoot&&(j.ShadyCSS===void 0||j.ShadyCSS.nativeShadow)&&`adoptedStyleSheets`in Document.prototype&&`replace`in CSSStyleSheet.prototype,rt=Symbol(),it=new WeakMap,at=class{constructor(e,t,n){if(this._$cssResult$=!0,n!==rt)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=t}get styleSheet(){let e=this.o,t=this.t;if(M&&e===void 0){let n=t!==void 0&&t.length===1;n&&(e=it.get(t)),e===void 0&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),n&&it.set(t,e))}return e}toString(){return this.cssText}},ot=e=>new at(typeof e==`string`?e:e+``,void 0,rt),st=(e,t)=>{if(M)e.adoptedStyleSheets=t.map(e=>e instanceof CSSStyleSheet?e:e.styleSheet);else for(let n of t){let t=document.createElement(`style`),r=j.litNonce;r!==void 0&&t.setAttribute(`nonce`,r),t.textContent=n.cssText,e.appendChild(t)}},ct=M?e=>e:e=>e instanceof CSSStyleSheet?(e=>{let t=``;for(let n of e.cssRules)t+=n.cssText;return ot(t)})(e):e,{is:lt,defineProperty:ut,getOwnPropertyDescriptor:dt,getOwnPropertyNames:ft,getOwnPropertySymbols:pt,getPrototypeOf:mt}=Object,N=globalThis,ht=N.trustedTypes,gt=ht?ht.emptyScript:``,_t=N.reactiveElementPolyfillSupport,P=(e,t)=>e,F={toAttribute(e,t){switch(t){case Boolean:e=e?gt:null;break;case Object:case Array:e=e==null?e:JSON.stringify(e)}return e},fromAttribute(e,t){let n=e;switch(t){case Boolean:n=e!==null;break;case Number:n=e===null?null:Number(e);break;case Object:case Array:try{n=JSON.parse(e)}catch{n=null}}return n}},vt=(e,t)=>!lt(e,t),yt={attribute:!0,type:String,converter:F,reflect:!1,useDefault:!1,hasChanged:vt};Symbol.metadata??=Symbol(`metadata`),N.litPropertyMetadata??=new WeakMap;var I=class extends HTMLElement{static addInitializer(e){this._$Ei(),(this.l??=[]).push(e)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(e,t=yt){if(t.state&&(t.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(e)&&((t=Object.create(t)).wrapped=!0),this.elementProperties.set(e,t),!t.noAccessor){let n=Symbol(),r=this.getPropertyDescriptor(e,n,t);r!==void 0&&ut(this.prototype,e,r)}}static getPropertyDescriptor(e,t,n){let{get:r,set:i}=dt(this.prototype,e)??{get(){return this[t]},set(e){this[t]=e}};return{get:r,set(t){let a=r?.call(this);i?.call(this,t),this.requestUpdate(e,a,n)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)??yt}static _$Ei(){if(this.hasOwnProperty(P(`elementProperties`)))return;let e=mt(this);e.finalize(),e.l!==void 0&&(this.l=[...e.l]),this.elementProperties=new Map(e.elementProperties)}static finalize(){if(this.hasOwnProperty(P(`finalized`)))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(P(`properties`))){let e=this.properties,t=[...ft(e),...pt(e)];for(let n of t)this.createProperty(n,e[n])}let e=this[Symbol.metadata];if(e!==null){let t=litPropertyMetadata.get(e);if(t!==void 0)for(let[e,n]of t)this.elementProperties.set(e,n)}this._$Eh=new Map;for(let[e,t]of this.elementProperties){let n=this._$Eu(e,t);n!==void 0&&this._$Eh.set(n,e)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(e){let t=[];if(Array.isArray(e)){let n=new Set(e.flat(1/0).reverse());for(let e of n)t.unshift(ct(e))}else e!==void 0&&t.push(ct(e));return t}static _$Eu(e,t){let n=t.attribute;return!1===n?void 0:typeof n==`string`?n:typeof e==`string`?e.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise(e=>this.enableUpdating=e),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach(e=>e(this))}addController(e){(this._$EO??=new Set).add(e),this.renderRoot!==void 0&&this.isConnected&&e.hostConnected?.()}removeController(e){this._$EO?.delete(e)}_$E_(){let e=new Map,t=this.constructor.elementProperties;for(let n of t.keys())this.hasOwnProperty(n)&&(e.set(n,this[n]),delete this[n]);e.size>0&&(this._$Ep=e)}createRenderRoot(){let e=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return st(e,this.constructor.elementStyles),e}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach(e=>e.hostConnected?.())}enableUpdating(e){}disconnectedCallback(){this._$EO?.forEach(e=>e.hostDisconnected?.())}attributeChangedCallback(e,t,n){this._$AK(e,n)}_$ET(e,t){let n=this.constructor.elementProperties.get(e),r=this.constructor._$Eu(e,n);if(r!==void 0&&!0===n.reflect){let i=(n.converter?.toAttribute===void 0?F:n.converter).toAttribute(t,n.type);this._$Em=e,i==null?this.removeAttribute(r):this.setAttribute(r,i),this._$Em=null}}_$AK(e,t){let n=this.constructor,r=n._$Eh.get(e);if(r!==void 0&&this._$Em!==r){let e=n.getPropertyOptions(r),i=typeof e.converter==`function`?{fromAttribute:e.converter}:e.converter?.fromAttribute===void 0?F:e.converter;this._$Em=r;let a=i.fromAttribute(t,e.type);this[r]=a??this._$Ej?.get(r)??a,this._$Em=null}}requestUpdate(e,t,n,r=!1,i){if(e!==void 0){let a=this.constructor;if(!1===r&&(i=this[e]),n??=a.getPropertyOptions(e),!((n.hasChanged??vt)(i,t)||n.useDefault&&n.reflect&&i===this._$Ej?.get(e)&&!this.hasAttribute(a._$Eu(e,n))))return;this.C(e,t,n)}!1===this.isUpdatePending&&(this._$ES=this._$EP())}C(e,t,{useDefault:n,reflect:r,wrapped:i},a){n&&!(this._$Ej??=new Map).has(e)&&(this._$Ej.set(e,a??t??this[e]),!0!==i||a!==void 0)||(this._$AL.has(e)||(this.hasUpdated||n||(t=void 0),this._$AL.set(e,t)),!0===r&&this._$Em!==e&&(this._$Eq??=new Set).add(e))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(e){Promise.reject(e)}let e=this.scheduleUpdate();return e!=null&&await e,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(let[e,t]of this._$Ep)this[e]=t;this._$Ep=void 0}let e=this.constructor.elementProperties;if(e.size>0)for(let[t,n]of e){let{wrapped:e}=n,r=this[t];!0!==e||this._$AL.has(t)||r===void 0||this.C(t,void 0,n,r)}}let e=!1,t=this._$AL;try{e=this.shouldUpdate(t),e?(this.willUpdate(t),this._$EO?.forEach(e=>e.hostUpdate?.()),this.update(t)):this._$EM()}catch(t){throw e=!1,this._$EM(),t}e&&this._$AE(t)}willUpdate(e){}_$AE(e){this._$EO?.forEach(e=>e.hostUpdated?.()),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(e)),this.updated(e)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(e){return!0}update(e){this._$Eq&&=this._$Eq.forEach(e=>this._$ET(e,this[e])),this._$EM()}updated(e){}firstUpdated(e){}};I.elementStyles=[],I.shadowRootOptions={mode:`open`},I[P(`elementProperties`)]=new Map,I[P(`finalized`)]=new Map,_t?.({ReactiveElement:I}),(N.reactiveElementVersions??=[]).push(`2.1.2`);var bt=globalThis,xt=e=>e,L=bt.trustedTypes,St=L?L.createPolicy(`lit-html`,{createHTML:e=>e}):void 0,Ct=`$lit$`,R=`lit$${Math.random().toFixed(9).slice(2)}$`,wt=`?`+R,Tt=`<${wt}>`,z=document,B=()=>z.createComment(``),V=e=>e===null||typeof e!=`object`&&typeof e!=`function`,Et=Array.isArray,Dt=e=>Et(e)||typeof e?.[Symbol.iterator]==`function`,Ot=`[
2
2
  \f\r]`,H=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,kt=/-->/g,At=/>/g,U=RegExp(`>|${Ot}(?:([^\\s"'>=/]+)(${Ot}*=${Ot}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,`g`),jt=/'/g,Mt=/"/g,Nt=/^(?:script|style|textarea|title)$/i,Pt=e=>(t,...n)=>({_$litType$:e,strings:t,values:n}),W=Pt(1),G=Pt(2),K=Symbol.for(`lit-noChange`),q=Symbol.for(`lit-nothing`),Ft=new WeakMap,J=z.createTreeWalker(z,129);function It(e,t){if(!Et(e)||!e.hasOwnProperty(`raw`))throw Error(`invalid template strings array`);return St===void 0?t:St.createHTML(t)}var Lt=(e,t)=>{let n=e.length-1,r=[],i,a=t===2?`<svg>`:t===3?`<math>`:``,o=H;for(let t=0;t<n;t++){let n=e[t],s,c,l=-1,u=0;for(;u<n.length&&(o.lastIndex=u,c=o.exec(n),c!==null);)u=o.lastIndex,o===H?c[1]===`!--`?o=kt:c[1]===void 0?c[2]===void 0?c[3]!==void 0&&(o=U):(Nt.test(c[2])&&(i=RegExp(`</`+c[2],`g`)),o=U):o=At:o===U?c[0]===`>`?(o=i??H,l=-1):c[1]===void 0?l=-2:(l=o.lastIndex-c[2].length,s=c[1],o=c[3]===void 0?U:c[3]===`"`?Mt:jt):o===Mt||o===jt?o=U:o===kt||o===At?o=H:(o=U,i=void 0);let d=o===U&&e[t+1].startsWith(`/>`)?` `:``;a+=o===H?n+Tt:l>=0?(r.push(s),n.slice(0,l)+Ct+n.slice(l)+R+d):n+R+(l===-2?t:d)}return[It(e,a+(e[n]||`<?>`)+(t===2?`</svg>`:t===3?`</math>`:``)),r]},Rt=class e{constructor({strings:t,_$litType$:n},r){let i;this.parts=[];let a=0,o=0,s=t.length-1,c=this.parts,[l,u]=Lt(t,n);if(this.el=e.createElement(l,r),J.currentNode=this.el.content,n===2||n===3){let e=this.el.content.firstChild;e.replaceWith(...e.childNodes)}for(;(i=J.nextNode())!==null&&c.length<s;){if(i.nodeType===1){if(i.hasAttributes())for(let e of i.getAttributeNames())if(e.endsWith(Ct)){let t=u[o++],n=i.getAttribute(e).split(R),r=/([.?@])?(.*)/.exec(t);c.push({type:1,index:a,name:r[2],strings:n,ctor:r[1]===`.`?Vt:r[1]===`?`?Ht:r[1]===`@`?Ut:X}),i.removeAttribute(e)}else e.startsWith(R)&&(c.push({type:6,index:a}),i.removeAttribute(e));if(Nt.test(i.tagName)){let e=i.textContent.split(R),t=e.length-1;if(t>0){i.textContent=L?L.emptyScript:``;for(let n=0;n<t;n++)i.append(e[n],B()),J.nextNode(),c.push({type:2,index:++a});i.append(e[t],B())}}}else if(i.nodeType===8){if(i.data===wt)c.push({type:2,index:a});else{let e=-1;for(;(e=i.data.indexOf(R,e+1))!==-1;)c.push({type:7,index:a}),e+=R.length-1}}a++}}static createElement(e,t){let n=z.createElement(`template`);return n.innerHTML=e,n}};function Y(e,t,n=e,r){if(t===K)return t;let i=r===void 0?n._$Cl:n._$Co?.[r],a=V(t)?void 0:t._$litDirective$;return i?.constructor!==a&&(i?._$AO?.(!1),a===void 0?i=void 0:(i=new a(e),i._$AT(e,n,r)),r===void 0?n._$Cl=i:(n._$Co??=[])[r]=i),i!==void 0&&(t=Y(e,i._$AS(e,t.values),i,r)),t}var zt=class{constructor(e,t){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=t}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){let{el:{content:t},parts:n}=this._$AD,r=(e?.creationScope??z).importNode(t,!0);J.currentNode=r;let i=J.nextNode(),a=0,o=0,s=n[0];for(;s!==void 0;){if(a===s.index){let t;s.type===2?t=new Bt(i,i.nextSibling,this,e):s.type===1?t=new s.ctor(i,s.name,s.strings,this,e):s.type===6&&(t=new Wt(i,this,e)),this._$AV.push(t),s=n[++o]}a!==s?.index&&(i=J.nextNode(),a++)}return J.currentNode=z,r}p(e){let t=0;for(let n of this._$AV)n!==void 0&&(n.strings===void 0?n._$AI(e[t]):(n._$AI(e,n,t),t+=n.strings.length-2)),t++}},Bt=class e{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(e,t,n,r){this.type=2,this._$AH=q,this._$AN=void 0,this._$AA=e,this._$AB=t,this._$AM=n,this.options=r,this._$Cv=r?.isConnected??!0}get parentNode(){let e=this._$AA.parentNode,t=this._$AM;return t!==void 0&&e?.nodeType===11&&(e=t.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,t=this){e=Y(this,e,t),V(e)?e===q||e==null||e===``?(this._$AH!==q&&this._$AR(),this._$AH=q):e!==this._$AH&&e!==K&&this._(e):e._$litType$===void 0?e.nodeType===void 0?Dt(e)?this.k(e):this._(e):this.T(e):this.$(e)}O(e){return this._$AA.parentNode.insertBefore(e,this._$AB)}T(e){this._$AH!==e&&(this._$AR(),this._$AH=this.O(e))}_(e){this._$AH!==q&&V(this._$AH)?this._$AA.nextSibling.data=e:this.T(z.createTextNode(e)),this._$AH=e}$(e){let{values:t,_$litType$:n}=e,r=typeof n==`number`?this._$AC(e):(n.el===void 0&&(n.el=Rt.createElement(It(n.h,n.h[0]),this.options)),n);if(this._$AH?._$AD===r)this._$AH.p(t);else{let e=new zt(r,this),n=e.u(this.options);e.p(t),this.T(n),this._$AH=e}}_$AC(e){let t=Ft.get(e.strings);return t===void 0&&Ft.set(e.strings,t=new Rt(e)),t}k(t){Et(this._$AH)||(this._$AH=[],this._$AR());let n=this._$AH,r,i=0;for(let a of t)i===n.length?n.push(r=new e(this.O(B()),this.O(B()),this,this.options)):r=n[i],r._$AI(a),i++;i<n.length&&(this._$AR(r&&r._$AB.nextSibling,i),n.length=i)}_$AR(e=this._$AA.nextSibling,t){for(this._$AP?.(!1,!0,t);e!==this._$AB;){let t=xt(e).nextSibling;xt(e).remove(),e=t}}setConnected(e){this._$AM===void 0&&(this._$Cv=e,this._$AP?.(e))}},X=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,t,n,r,i){this.type=1,this._$AH=q,this._$AN=void 0,this.element=e,this.name=t,this._$AM=r,this.options=i,n.length>2||n[0]!==``||n[1]!==``?(this._$AH=Array(n.length-1).fill(new String),this.strings=n):this._$AH=q}_$AI(e,t=this,n,r){let i=this.strings,a=!1;if(i===void 0)e=Y(this,e,t,0),a=!V(e)||e!==this._$AH&&e!==K,a&&(this._$AH=e);else{let r=e,o,s;for(e=i[0],o=0;o<i.length-1;o++)s=Y(this,r[n+o],t,o),s===K&&(s=this._$AH[o]),a||=!V(s)||s!==this._$AH[o],s===q?e=q:e!==q&&(e+=(s??``)+i[o+1]),this._$AH[o]=s}a&&!r&&this.j(e)}j(e){e===q?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??``)}},Vt=class extends X{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===q?void 0:e}},Ht=class extends X{constructor(){super(...arguments),this.type=4}j(e){this.element.toggleAttribute(this.name,!!e&&e!==q)}},Ut=class extends X{constructor(e,t,n,r,i){super(e,t,n,r,i),this.type=5}_$AI(e,t=this){if((e=Y(this,e,t,0)??q)===K)return;let n=this._$AH,r=e===q&&n!==q||e.capture!==n.capture||e.once!==n.once||e.passive!==n.passive,i=e!==q&&(n===q||r);r&&this.element.removeEventListener(this.name,this,n),i&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){typeof this._$AH==`function`?this._$AH.call(this.options?.host??this.element,e):this._$AH.handleEvent(e)}},Wt=class{constructor(e,t,n){this.element=e,this.type=6,this._$AN=void 0,this._$AM=t,this.options=n}get _$AU(){return this._$AM._$AU}_$AI(e){Y(this,e)}},Gt=bt.litHtmlPolyfillSupport;Gt?.(Rt,Bt),(bt.litHtmlVersions??=[]).push(`3.3.3`);var Kt=(e,t,n)=>{let r=n?.renderBefore??t,i=r._$litPart$;if(i===void 0){let e=n?.renderBefore??null;r._$litPart$=i=new Bt(t.insertBefore(B(),e),e,void 0,n??{})}return i._$AI(e),i},qt=globalThis,Z=class extends I{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){let e=super.createRenderRoot();return this.renderOptions.renderBefore??=e.firstChild,e}update(e){let t=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(e),this._$Do=Kt(t,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return K}};Z._$litElement$=!0,Z.finalized=!0,qt.litElementHydrateSupport?.({LitElement:Z});var Jt=qt.litElementPolyfillSupport;Jt?.({LitElement:Z}),(qt.litElementVersions??=[]).push(`4.2.2`);function Q(e){if(!e.mimeType?.startsWith(`video/`)||!Number.isFinite(e.durationSeconds)||!e.durationSeconds||e.durationSeconds<=0||e.durationSeconds>15)return!1;let t=e.size;return!(typeof t==`number`&&t>12582912)}var Yt=640,Xt=8,Zt=72,Qt=704,$t=.9,en=.85;function $(e){if(!(!Number.isFinite(e)||!e||e<=0))return e}function tn(){return{width:globalThis.innerWidth||document.documentElement.clientWidth||0,height:globalThis.innerHeight||document.documentElement.clientHeight||0}}function nn(e,t){return{width:Math.max(0,e-(e<=Yt?Xt:Zt)*2),height:Math.max(0,t-32)}}function rn(e,t,n){let r=$(e?.width),i=$(e?.height);if(!r||!i)return null;let a=nn(t,n);if(a.width<=0||a.height<=0)return null;let o=Math.min(a.width/r,a.height/i);return{width:Math.max(1,Math.round(r*o)),height:Math.max(1,Math.round(i*o))}}function an(e,t,n){if(!e||e.mimeType?.startsWith(`video/`)||!$(e.width)||!$(e.height)||t<=0||n<=0)return!1;let r=$(e.width),i=$(e.height);if(!r||!i)return!1;let a=t<=Yt,o=nn(t,n),s=o.width,c=o.height;if(s<=0||c<=0)return!1;let l=r/i,u=Math.min(s,c*l);return l<$t&&u<(a?s:Math.min(s,Qt))*en}var on=class extends Z{static properties={_images:{state:!0},_currentIndex:{state:!0},_open:{state:!0},_viewportWidth:{state:!0},_viewportHeight:{state:!0},_videoCurrentTime:{state:!0},_videoDuration:{state:!0},_videoMuted:{state:!0},_videoPaused:{state:!0},_imageZoomed:{state:!0}};createRenderRoot(){return this.innerHTML=``,this}constructor(){super();let e=tn();this._images=[],this._currentIndex=0,this._open=!1,this._viewportWidth=e.width,this._viewportHeight=e.height,this._videoCurrentTime=0,this._videoDuration=0,this._videoMuted=!1,this._videoPaused=!1,this._imageZoomed=!1}connectedCallback(){super.connectedCallback(),document.addEventListener(`click`,this.#e),window.addEventListener(`resize`,this.#l),this.#u()}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener(`click`,this.#e),window.removeEventListener(`resize`,this.#l)}open(e,t){this.#u(),this.#d(),this._images=e,this._currentIndex=Math.max(0,Math.min(t,e.length-1)),this.#m(this._images[this._currentIndex]),this._imageZoomed=!1,this._open=!0,document.dispatchEvent(new CustomEvent(g,{detail:{open:!0}})),this.updateComplete.then(()=>{this.querySelector(`.media-lightbox`)?.showModal(),this.#f()})}close(){this.#d(),this.querySelector(`.media-lightbox`)?.close(),this._open=!1,document.dispatchEvent(new CustomEvent(g,{detail:{open:!1}}))}#e=e=>{let t=e.target,n=t.closest(`[data-lightbox-group] a[data-lightbox-index]`);if(n){let t=n.closest(`[data-lightbox-group]`);if(!t)return;e.preventDefault();let r=parseInt(n.dataset.lightboxIndex??`0`,10);try{let e=JSON.parse(t.dataset.lightboxGroup??`[]`);e.length>0&&this.open(e,r)}catch{}return}let r=t.closest(`[data-post-body] img`);if(r){e.preventDefault();let t=r.closest(`[data-post-body]`);if(!t)return;let n=Array.from(t.querySelectorAll(`img`)),i=n.map(e=>({url:e.src,alt:e.alt||``,width:$(e.naturalWidth||Number(e.getAttribute(`width`))),height:$(e.naturalHeight||Number(e.getAttribute(`height`)))})),a=n.indexOf(r);i.length>0&&this.open(i,Math.max(0,a))}};#t(){this._images.length<=1||(this.#d(),this._imageZoomed=!1,this._currentIndex=(this._currentIndex-1+this._images.length)%this._images.length)}#n(){this._images.length<=1||(this.#d(),this._imageZoomed=!1,this._currentIndex=(this._currentIndex+1)%this._images.length)}#r=e=>{let t=this._images[this._currentIndex];an(t,this._viewportWidth,this._viewportHeight)&&(e.stopPropagation(),this._imageZoomed=!this._imageZoomed)};#i=e=>{let t=e,n=e.target;if(t.key===`Escape`){e.preventDefault(),this.close();return}if(n instanceof HTMLInputElement||n instanceof HTMLButtonElement||n instanceof HTMLVideoElement)return;if(!this._images[this._currentIndex]?.mimeType?.startsWith(`video/`)){t.key===`ArrowLeft`?(e.preventDefault(),this.#t()):t.key===`ArrowRight`&&(e.preventDefault(),this.#n());return}let r=this.querySelector(`.media-lightbox-video`);r&&this.#a(t,r)};#a(e,t){let n=Number.isFinite(t.duration)&&t.duration>0?t.duration:null,r=e=>{let r=n==null?Math.max(0,e):Math.max(0,Math.min(e,n));t.currentTime=r,this._videoCurrentTime=r},i=e.key,a=i.toLowerCase();if(i===` `||a===`k`)e.preventDefault(),this.#x(t);else if(i===`ArrowLeft`)e.preventDefault(),r(t.currentTime-2);else if(i===`ArrowRight`)e.preventDefault(),r(t.currentTime+2);else if(i===`Home`)e.preventDefault(),r(0);else if(i===`End`)n!=null&&(e.preventDefault(),r(n));else if(i.length===1&&i>=`0`&&i<=`9`)n!=null&&(e.preventDefault(),r(Number(i)/10*n));else if(i===`ArrowUp`)e.preventDefault(),t.volume=Math.min(1,t.volume+.05);else if(i===`ArrowDown`)e.preventDefault(),t.volume=Math.max(0,t.volume-.05);else if(a===`m`){e.preventDefault();let n=!t.muted;t.muted=n,this._videoMuted=n}else a===`f`&&(e.preventDefault(),this.#o(t))}#o(e){let t=document,n=e;if(document.fullscreenElement??t.webkitFullscreenElement){document.exitFullscreen?document.exitFullscreen().catch(()=>{}):t.webkitExitFullscreen?.();return}e.requestFullscreen?e.requestFullscreen().catch(()=>{}):n.webkitRequestFullscreen?n.webkitRequestFullscreen():n.webkitEnterFullscreen&&n.webkitEnterFullscreen()}#s=e=>{let t=e.target;(t===e.currentTarget||t.classList.contains(`media-lightbox-content`)||t.classList.contains(`media-lightbox-stage`))&&this.close()};#c=()=>{this.#d(),this._open&&document.dispatchEvent(new CustomEvent(g,{detail:{open:!1}})),this._open=!1};#l=()=>{this.#u()};#u(){let e=tn();(e.width!==this._viewportWidth||e.height!==this._viewportHeight)&&(this._viewportWidth=e.width,this._viewportHeight=e.height)}#d(){this.querySelector(`.media-lightbox-video`)?.pause()}#f(){this.querySelector(`.media-lightbox-content`)?.focus()}#p=()=>{this.querySelector(`.media-lightbox-content`)?.focus({preventScroll:!0})};#m(e){this._videoCurrentTime=0,this._videoDuration=e?.durationSeconds&&e.durationSeconds>0?e.durationSeconds:0,this._videoMuted=!1,this._videoPaused=ue(e?.id)}#h(){let e=this._images[this._currentIndex];if(!Q(e)){this.#m(e);return}let t=this.querySelector(`.media-lightbox-video`);if(t){if(t.currentTime=0,t.muted=this._videoMuted,this._videoPaused=ue(e.id),this._videoPaused){t.pause();return}t.play().catch(()=>{this._videoPaused=!0})}}#g=e=>{let t=e.currentTarget;Number.isFinite(t.duration)&&t.duration>0&&(this._videoDuration=t.duration),this._videoCurrentTime=t.currentTime,t.muted=this._videoMuted};#_=e=>{let t=e.currentTarget;this._videoCurrentTime=t.currentTime,Number.isFinite(t.duration)&&t.duration>0&&(this._videoDuration=t.duration)};#v=()=>{this._videoPaused=!1};#y=()=>{this._videoPaused=!0};#b(e){let t=this._images[this._currentIndex],n=t?.id?.trim();n&&Q(t)&&de(n,e)}#x(e){if(e.paused){this._videoPaused=!1,this.#b(!1),e.play().catch(()=>{this._videoPaused=!0,this.#b(!0)});return}e.pause(),this._videoPaused=!0,this.#b(!0)}#S=()=>{let e=this.querySelector(`.media-lightbox-video`);e&&this.#x(e)};#C=e=>{let t=e.currentTarget,n=this.querySelector(`.media-lightbox-video`),r=Number.parseFloat(t.value);!n||!Number.isFinite(r)||r<0||(n.currentTime=r,this._videoCurrentTime=r)};#w=()=>{this._videoMuted=!this._videoMuted;let e=this.querySelector(`.media-lightbox-video`);e&&(e.muted=this._videoMuted)};updated(e){if(super.updated(e),!this._open||!e.has(`_currentIndex`)&&!e.has(`_open`)&&!e.has(`_imageZoomed`))return;let t=this.querySelector(`.media-lightbox-stage`);t&&(t.scrollTop=0,t.scrollLeft=0,(e.has(`_currentIndex`)||e.has(`_open`))&&(this.#h(),this.#f()))}render(){if(!this._open)return q;let e=this._images[this._currentIndex],t=this._images.length>1,n=e?.mimeType?.startsWith(`video/`),r=Q(e),i=an(e,this._viewportWidth,this._viewportHeight),a=i&&this._imageZoomed,o=r?rn(e,this._viewportWidth,this._viewportHeight):null,s=r&&!!o&&o.height>o.width,c=o?`--media-lightbox-short-width:${o.width}px;--media-lightbox-short-height:${o.height}px;`:q,l=this._videoDuration>0?this._videoDuration:e?.durationSeconds??1,u=Math.min(this._videoCurrentTime,l),d=l>0?u/l*100:0;return W`
3
3
  <dialog
4
4
  class=${`media-lightbox${r?` media-lightbox-short`:``}`}
@@ -91,17 +91,24 @@ h1 {
91
91
 
92
92
  h2 {
93
93
  font-size: var(--type-content-title);
94
- margin: 2.1rem 0 1.4rem;
94
+ margin: 2.6rem 0 0.9rem;
95
95
  }
96
96
 
97
97
  h3 {
98
98
  font-size: var(--type-content-subtitle);
99
- margin: 2rem 0 1.4rem;
99
+ margin: 2.2rem 0 0.75rem;
100
100
  }
101
101
 
102
102
  h4 {
103
103
  font-size: var(--type-content-body);
104
- font-weight: var(--fw-medium);
104
+ margin: 1.8rem 0 0.6rem;
105
+ }
106
+
107
+ /* The block after a heading gives up its own top margin, so the heading's
108
+ bottom margin is the whole gap; otherwise a paragraph's 1.4rem wins the
109
+ margin collapse and the heading floats 1.4rem from both neighbours. */
110
+ :is(h1, h2, h3, h4, h5, h6) + * {
111
+ margin-top: 0;
105
112
  }
106
113
 
107
114
  h5,
@@ -303,7 +310,9 @@ time {
303
310
  * max-width = body-max-width / 0.835 so the inner content area exactly
304
311
  * equals `--layout-body-max-width` on wide viewports. min() caps keep
305
312
  * padding from growing beyond 210px / 67px. Mobile widens to 5% / 5%
306
- * and the 55% content column collapses to 100% (via tokens.css).
313
+ * and the 55% content column collapses to 100% (via tokens.css). Below
314
+ * 1024px, where the sidenote gutter is gone, the frame narrows to the
315
+ * reading measure and centers, as on the main site.
307
316
  * ------------------------------------------------------------------------- */
308
317
 
309
318
  .site-page {
@@ -316,6 +325,8 @@ time {
316
325
  .site-page > main,
317
326
  .site-page > footer,
318
327
  .site-page > .home-branding-credit {
328
+ --site-frame-gutter-start: max(5%, 28px);
329
+ --site-frame-gutter-end: 5%;
319
330
  width: 100%;
320
331
  max-width: calc(var(--layout-body-max-width) / 0.835);
321
332
  padding-left: min(12.5%, 210px);
@@ -324,13 +335,17 @@ time {
324
335
  margin-right: auto;
325
336
  }
326
337
 
327
- @media (max-width: 760px) {
338
+ @media (max-width: 1024px) {
328
339
  .site-page > header,
329
340
  .site-page > main,
330
341
  .site-page > footer,
331
342
  .site-page > .home-branding-credit {
332
- padding-left: max(5%, 28px);
333
- padding-right: 5%;
343
+ max-width: calc(
344
+ var(--layout-reading-measure) + var(--site-frame-gutter-start) +
345
+ var(--site-frame-gutter-end)
346
+ );
347
+ padding-left: var(--site-frame-gutter-start);
348
+ padding-right: var(--site-frame-gutter-end);
334
349
  }
335
350
  }
336
351
 
@@ -344,6 +359,8 @@ time {
344
359
  * ------------------------------------------------------------------------- */
345
360
 
346
361
  .site-header {
362
+ /* The nav collapses by this width (Tiered responsive collapse, below). */
363
+ container: site-header / inline-size;
347
364
  padding-top: 24px;
348
365
  background-color: var(--site-page-bg);
349
366
  }
@@ -600,14 +617,15 @@ time {
600
617
 
601
618
  /* --- Tiered responsive collapse ---------------------------------------- *
602
619
  *
603
- * ≤960px — 5th+ inline link collapses into More (tier-lg)
604
- * ≤780px — also 4th collapses (tier-md)
605
- * ≤580px — also 3rd collapses (tier-sm)
620
+ * By the header's own width, as on the main site:
621
+ * < 802px — 5th+ inline link collapses into More (tier-lg)
622
+ * < 652px — also 4th collapses (tier-md)
623
+ * < 522px — also 3rd collapses (tier-sm)
606
624
  * The first two links always stay inline. No hamburger on static export —
607
625
  * at very narrow widths 2 inline links + More button is the floor.
608
626
  */
609
627
 
610
- @media (max-width: 960px) {
628
+ @container site-header (width < 802px) {
611
629
  .site-header-link-collapse-lg {
612
630
  display: none;
613
631
  }
@@ -625,7 +643,7 @@ time {
625
643
  }
626
644
  }
627
645
 
628
- @media (max-width: 780px) {
646
+ @container site-header (width < 652px) {
629
647
  .site-header-link-collapse-md {
630
648
  display: none;
631
649
  }
@@ -639,7 +657,7 @@ time {
639
657
  }
640
658
  }
641
659
 
642
- @media (max-width: 580px) {
660
+ @container site-header (width < 522px) {
643
661
  .site-header-link-collapse-sm {
644
662
  display: none;
645
663
  }
@@ -879,18 +897,18 @@ hr.feed-divider {
879
897
 
880
898
  .post-card > .post-card-summary :is(h1, h2),
881
899
  .post-card > .post-card-quote-commentary :is(h1, h2) {
882
- font-size: calc(var(--type-content-body) * 1.12);
883
- font-weight: var(--fw-medium);
884
- margin-top: 1.45rem;
885
- margin-bottom: 0.55rem;
900
+ font-size: calc(var(--type-content-body) * 1.2);
901
+ font-weight: var(--type-heading-weight);
902
+ margin-top: 1.6rem;
903
+ margin-bottom: 0.6rem;
886
904
  }
887
905
 
888
906
  .post-card > .post-card-summary :is(h3, h4),
889
907
  .post-card > .post-card-quote-commentary :is(h3, h4) {
890
- font-size: var(--type-content-body);
891
- font-weight: var(--fw-medium);
892
- margin-top: 1.2rem;
893
- margin-bottom: 0.45rem;
908
+ font-size: calc(var(--type-content-body) * 1.08);
909
+ font-weight: var(--type-heading-weight);
910
+ margin-top: 1.4rem;
911
+ margin-bottom: 0.5rem;
894
912
  }
895
913
 
896
914
  .post-card > .post-card-summary :is(h5, h6),
@@ -1877,6 +1877,8 @@ function buildHugoToml(config: SiteConfig): string {
1877
1877
  " [markup.goldmark]",
1878
1878
  " [markup.goldmark.renderer]",
1879
1879
  " unsafe = true",
1880
+ " [markup.goldmark.extensions.extras.mark]",
1881
+ " enable = true",
1880
1882
  "",
1881
1883
  // Emit an Atom 2005 feed at the site root (/index.xml). Per-section
1882
1884
  // feeds (featured, archive, each collection) are opted in via each
@@ -55,6 +55,7 @@ import {
55
55
  type GitHubAppInstallationsService,
56
56
  } from "./github-app-installations.js";
57
57
  import { createTelegramService, type TelegramService } from "./telegram.js";
58
+ import { createStatsService, type StatsService } from "./stats.js";
58
59
  import type { HostedControlPlaneClient } from "../lib/hosted-control-plane.js";
59
60
  import type { EnsureSingleSiteOptions } from "./site.js";
60
61
 
@@ -82,6 +83,7 @@ export interface Services {
82
83
  githubAppInstallations: GitHubAppInstallationsService;
83
84
  telegram: TelegramService;
84
85
  textAttachments: TextAttachmentService;
86
+ stats: StatsService;
85
87
  }
86
88
 
87
89
  export function createServices(
@@ -197,10 +199,25 @@ export function createServices(
197
199
  databaseSchema,
198
200
  ),
199
201
  telegram: createTelegramService(db, siteId, databaseSchema),
202
+ stats: createStatsService(db, siteId, databaseSchema, dialect, {
203
+ settings,
204
+ }),
200
205
  };
201
206
  }
202
207
 
203
208
  export type { SettingsService } from "./settings.js";
209
+ export type {
210
+ StatsService,
211
+ StatsOverview,
212
+ StatsPage,
213
+ StatsPageDetail,
214
+ StatsPageRow,
215
+ StatsReferrerRow,
216
+ StatsReferrers,
217
+ StatsSeries,
218
+ StatsSeriesPoint,
219
+ StatsWindow,
220
+ } from "./stats.js";
204
221
  export type { SiteService } from "./site.js";
205
222
  export type { PathService } from "./path.js";
206
223
  export type { PostService, PostFilters, PostDeleteDeps } from "./post.js";
@@ -168,7 +168,18 @@ const UploadMediaToolSchema = z.object({
168
168
  blurhash: z.string().max(200).optional(),
169
169
  waveform: z.string().max(2000).optional(),
170
170
  chars: z.number().int().nonnegative().optional(),
171
- posterBase64: z.string().min(1).optional(),
171
+ posterBase64: z
172
+ .string()
173
+ .min(1)
174
+ .optional()
175
+ .describe(
176
+ "Video only: a still for the clip as base64 WebP or PNG, shown in its place in the timeline, share cards, and feeds. Without one, readers' browsers draw a frame from the file.",
177
+ ),
178
+ });
179
+
180
+ const SetMediaPosterToolSchema = z.object({
181
+ id: MediaIdSchema.describe("Media TypeID of a video"),
182
+ posterBase64: z.string().min(1).describe("The poster as base64 WebP or PNG"),
172
183
  });
173
184
 
174
185
  const AddCollectionThreadToolSchema = z.object({
@@ -632,6 +643,25 @@ const mcpTools: McpToolDefinition[] = [
632
643
  return serializeMedia(updatedMedia, context.appConfig);
633
644
  },
634
645
  },
646
+ {
647
+ name: "jant_media_set_poster",
648
+ description:
649
+ "Give a video its poster, or replace the one it has, and return the updated media record.",
650
+ inputSchema: toolInputSchema(SetMediaPosterToolSchema),
651
+ async execute(args, context) {
652
+ const input = SetMediaPosterToolSchema.parse(args ?? {});
653
+ const media = await context.services.media.setPoster(
654
+ input.id,
655
+ decodeBase64Bytes(input.posterBase64, "posterBase64"),
656
+ { storage: requireStorage(context.storage) },
657
+ );
658
+ if (!media) {
659
+ throw new NotFoundError("Media");
660
+ }
661
+
662
+ return serializeMedia(media, context.appConfig);
663
+ },
664
+ },
635
665
  {
636
666
  name: "jant_media_delete",
637
667
  description: "Delete a media item and its stored object.",
@@ -25,8 +25,12 @@ import { markdownToTiptapJson } from "../lib/markdown-to-tiptap.js";
25
25
  import { extractBodyText } from "../lib/summary.js";
26
26
  import { now } from "../lib/time.js";
27
27
  import { supportsCopy, type StorageDriver } from "../lib/storage.js";
28
+ import { generateRandomId } from "../lib/nanoid.js";
28
29
  import {
30
+ detectPosterMimeType,
29
31
  generateStorageKey,
32
+ getPosterExtension,
33
+ getPosterStorageKey,
30
34
  imageExtensionForMimeType,
31
35
  isAllowedSideloadImageType,
32
36
  SITE_ASSET_STORAGE_KEY_LIKE_PATTERN,
@@ -314,6 +318,24 @@ export interface MediaService {
314
318
  attachToPost(postId: string, mediaIds: string[]): Promise<void>;
315
319
  detachFromPost(postId: string): Promise<void>;
316
320
  updateAlt(id: string, alt: string): Promise<void>;
321
+ /**
322
+ * Give a video its poster, or replace the one it has: the still that stands
323
+ * in for the clip in the timeline, share cards, and feeds. A replacement
324
+ * goes to a new key and the old object is deleted, since posters are served
325
+ * `immutable` and one rewritten in place would stay stale in caches.
326
+ *
327
+ * @param id - Media record ID
328
+ * @param bytes - The poster, as WebP or PNG bytes
329
+ * @param deps.storage - Storage driver the poster is written to
330
+ * @returns The updated record, or null when there is no such media
331
+ * @throws ValidationError when the media is not a video, or the bytes are
332
+ * neither WebP nor PNG
333
+ */
334
+ setPoster(
335
+ id: string,
336
+ bytes: Uint8Array,
337
+ deps: { storage: StorageDriver },
338
+ ): Promise<Media | null>;
317
339
  }
318
340
 
319
341
  export interface CreateMediaData {
@@ -954,6 +976,47 @@ export function createMediaService(
954
976
  .where(and(eq(media.siteId, siteId), eq(media.id, id)));
955
977
  },
956
978
 
979
+ async setPoster(id, bytes, { storage }) {
980
+ const record = await this.getById(id);
981
+ if (!record) return null;
982
+
983
+ if (!record.mimeType.startsWith("video/")) {
984
+ throw new ValidationError(
985
+ `Only a video takes a poster. This media is ${record.mimeType}.`,
986
+ );
987
+ }
988
+ const contentType = detectPosterMimeType(bytes);
989
+ if (!contentType) {
990
+ throw new ValidationError(
991
+ "Unsupported poster format. Only WebP and PNG are accepted.",
992
+ );
993
+ }
994
+
995
+ const previousKey = record.posterKey;
996
+ const posterKey = getPosterStorageKey(
997
+ siteId,
998
+ id,
999
+ getPosterExtension(contentType),
1000
+ previousKey ? generateRandomId(8) : undefined,
1001
+ );
1002
+ await storage.put(posterKey, bytes, { contentType });
1003
+ await db
1004
+ .update(media)
1005
+ .set({ posterKey, updatedAt: now() })
1006
+ .where(and(eq(media.siteId, siteId), eq(media.id, id)));
1007
+
1008
+ if (previousKey && previousKey !== posterKey) {
1009
+ // The poster is derived from the clip, so the one it replaces goes
1010
+ // straight away rather than through the recycle window.
1011
+ await storage.delete(previousKey).catch((err) => {
1012
+ // eslint-disable-next-line no-console -- Error logging is intentional
1013
+ console.error("Storage delete error:", err);
1014
+ });
1015
+ }
1016
+
1017
+ return this.getById(id);
1018
+ },
1019
+
957
1020
  async delete(id, storage) {
958
1021
  const record = await this.getById(id);
959
1022
  if (!record) return false;