@tdacorp/hyle-sdk 0.17.0 → 0.21.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 (86) hide show
  1. package/README.md +155 -28
  2. package/dist/check-routes-bin.js +38 -13
  3. package/dist/chunk-56Y24XBV.js +840 -0
  4. package/dist/{chunk-MGSUQBDW.js → chunk-75JFLML4.js} +176 -14
  5. package/dist/chunk-HJX57NLI.js +1105 -0
  6. package/dist/chunk-K5VDLROQ.js +145 -0
  7. package/dist/{chunk-BUJFMR3M.js → chunk-QVYQM5R2.js} +15 -6
  8. package/dist/chunk-U74B7AUG.js +398 -0
  9. package/dist/{chunk-6VOHFFA5.js → chunk-X2TLYM7Y.js} +2 -2
  10. package/dist/client-41fU6OY2.d.cts +201 -0
  11. package/dist/client-LwzHwqpM.d.ts +201 -0
  12. package/dist/code-copy.cjs +72 -0
  13. package/dist/code-copy.d.cts +15 -0
  14. package/dist/code-copy.d.ts +15 -0
  15. package/dist/code-copy.js +48 -0
  16. package/dist/comments.cjs +728 -275
  17. package/dist/comments.d.cts +66 -3
  18. package/dist/comments.d.ts +66 -3
  19. package/dist/comments.js +409 -326
  20. package/dist/{diagram-viewer-FJPED4SN.js → diagram-viewer-XY3CG75U.js} +62 -21
  21. package/dist/{embed-BmdwA2G9.d.cts → embed-BUFRQboD.d.ts} +2 -2
  22. package/dist/{embed-DNTZ2UXv.d.ts → embed-CYt-q13P.d.cts} +2 -2
  23. package/dist/fragment-alias.cjs +51 -0
  24. package/dist/fragment-alias.d.cts +7 -0
  25. package/dist/fragment-alias.d.ts +7 -0
  26. package/dist/fragment-alias.js +27 -0
  27. package/dist/html.cjs +881 -0
  28. package/dist/html.d.cts +20 -0
  29. package/dist/html.d.ts +20 -0
  30. package/dist/html.js +45 -0
  31. package/dist/index.cjs +181 -14
  32. package/dist/index.d.cts +14 -62
  33. package/dist/index.d.ts +14 -62
  34. package/dist/index.js +11 -1
  35. package/dist/{labels-nmukKYgL.d.ts → labels-CrA-iqTN.d.cts} +9 -0
  36. package/dist/{labels-nmukKYgL.d.cts → labels-CrA-iqTN.d.ts} +9 -0
  37. package/dist/mermaid-diagram.cjs +401 -125
  38. package/dist/mermaid-diagram.d.cts +23 -7
  39. package/dist/mermaid-diagram.d.ts +23 -7
  40. package/dist/mermaid-diagram.js +204 -51
  41. package/dist/mermaid-image.cjs +134 -60
  42. package/dist/mermaid-image.d.cts +4 -3
  43. package/dist/mermaid-image.d.ts +4 -3
  44. package/dist/mermaid-image.js +27 -28
  45. package/dist/next.cjs +627 -264
  46. package/dist/next.d.cts +11 -8
  47. package/dist/next.d.ts +11 -8
  48. package/dist/next.js +39 -12
  49. package/dist/print-coordinator.cjs +157 -0
  50. package/dist/print-coordinator.d.cts +27 -0
  51. package/dist/print-coordinator.d.ts +27 -0
  52. package/dist/print-coordinator.js +83 -0
  53. package/dist/react.cjs +556 -226
  54. package/dist/react.d.cts +136 -29
  55. package/dist/react.d.ts +136 -29
  56. package/dist/react.js +23 -3
  57. package/dist/reactions.cjs +653 -0
  58. package/dist/reactions.d.cts +27 -0
  59. package/dist/reactions.d.ts +27 -0
  60. package/dist/reactions.js +364 -0
  61. package/dist/{resolve-Ae7UFjsQ.d.ts → resolve-BjAK0k_Y.d.ts} +2 -2
  62. package/dist/{resolve-euZ4-aC9.d.cts → resolve-eI1muCKL.d.cts} +2 -2
  63. package/dist/revalidation-callback-BQl77tQR.d.cts +75 -0
  64. package/dist/revalidation-callback-BQl77tQR.d.ts +75 -0
  65. package/dist/sanitize-ijiWjEm9.d.cts +23 -0
  66. package/dist/sanitize-ijiWjEm9.d.ts +23 -0
  67. package/dist/styles.css +96 -25
  68. package/dist/toc-spy.cjs +59 -0
  69. package/dist/toc-spy.d.cts +15 -0
  70. package/dist/toc-spy.d.ts +15 -0
  71. package/dist/toc-spy.js +35 -0
  72. package/dist/{types-Czt887Iv.d.cts → types-3F0wqD-o.d.cts} +26 -2
  73. package/dist/{types-Czt887Iv.d.ts → types-3F0wqD-o.d.ts} +26 -2
  74. package/dist/use-cache.cjs +37 -11
  75. package/dist/use-cache.d.cts +12 -5
  76. package/dist/use-cache.d.ts +12 -5
  77. package/dist/use-cache.js +7 -7
  78. package/dist/youtube-facade.cjs +50 -0
  79. package/dist/youtube-facade.d.cts +17 -0
  80. package/dist/youtube-facade.d.ts +17 -0
  81. package/dist/youtube-facade.js +26 -0
  82. package/package.json +16 -3
  83. package/dist/chunk-DMK4XQLU.js +0 -1556
  84. package/dist/chunk-PJMJMP66.js +0 -63
  85. package/dist/revalidation-callback-D7Ms_Puz.d.cts +0 -42
  86. package/dist/revalidation-callback-D7Ms_Puz.d.ts +0 -42
package/dist/next.cjs CHANGED
@@ -92,6 +92,18 @@ var Cp1ClientError = class extends Error {
92
92
  };
93
93
 
94
94
  // src/client.ts
95
+ var RENDERER_VERSION = "4";
96
+ function applyCredential(headers, credential, method, url) {
97
+ if (!credential.auth) {
98
+ headers.set("authorization", `Bearer ${credential.token}`);
99
+ return void 0;
100
+ }
101
+ const { workspaceId } = credential;
102
+ return credential.auth({ method, url }).then((extra) => {
103
+ for (const [name, value] of Object.entries(extra)) headers.set(name, value);
104
+ headers.set("cp-workspace", workspaceId);
105
+ });
106
+ }
95
107
  var DEFAULT_TIMEOUT_MS = 1e4;
96
108
  var DEFAULT_MAX_RESPONSE_BYTES = 5 * 1024 * 1024;
97
109
  var LOOPBACK = /* @__PURE__ */ new Set(["localhost", "127.0.0.1", "[::1]"]);
@@ -133,14 +145,16 @@ function checkBaseUrl(baseUrl, allowInsecureHttp) {
133
145
  }
134
146
  function createHyleClient(options) {
135
147
  checkBaseUrl(options.baseUrl, options.allowInsecureHttp);
136
- if (!options.token) throw new TypeError("token is required");
148
+ if (!options.auth && !options.token) throw new TypeError("token is required");
137
149
  const base = options.baseUrl.replace(/\/+$/, "");
138
150
  const fetchImpl = options.fetch ?? fetch;
139
151
  async function get(pathname, query, init) {
140
152
  const url = new URL(`${base}${pathname}`);
141
153
  url.search = query.toString();
142
154
  const headers = new Headers(init?.headers);
143
- headers.set("authorization", `Bearer ${options.token}`);
155
+ headers.set("cp-renderer-version", RENDERER_VERSION);
156
+ const applied = applyCredential(headers, options, "GET", url.toString());
157
+ if (applied) await applied;
144
158
  const timeout = AbortSignal.timeout(options.timeoutMs ?? DEFAULT_TIMEOUT_MS);
145
159
  const signal = init?.signal ? AbortSignal.any([init.signal, timeout]) : timeout;
146
160
  const res = await fetchImpl(url.toString(), { ...init, method: "GET", headers, redirect: "error", signal });
@@ -180,16 +194,28 @@ function createHyleClient(options) {
180
194
  if (data?.cp === 1 && data.kind === "mounts" && isMounts(data)) return data;
181
195
  throw failure(reply2);
182
196
  }
197
+ async function pushPosts(opts) {
198
+ if (!/^[a-z0-9]([a-z0-9-]*[a-z0-9])?$/.test(opts.section)) throw new TypeError("section must be a section slug");
199
+ const query = new URLSearchParams();
200
+ if (opts.cursor !== void 0) query.set("cursor", opts.cursor);
201
+ const reply2 = await get(`/cp1/read/sections/${opts.section}/posts`, query, opts.init);
202
+ const data = reply2.parsed?.data;
203
+ if (data?.cp === 1 && data.kind === "push_posts" && Array.isArray(data.posts) && typeof data.complete === "boolean") return data;
204
+ throw failure(reply2);
205
+ }
183
206
  async function asset(file, opts = {}) {
184
207
  if (!ASSET_FILE.test(file)) throw new TypeError("asset file must be <uuid>[.<ext>]");
185
- const headers = new Headers({ authorization: `Bearer ${options.token}` });
208
+ const url = `${base}/cp1/read/assets/${file}`;
209
+ const headers = new Headers();
210
+ const applied = applyCredential(headers, options, "GET", url);
211
+ if (applied) await applied;
186
212
  for (const name of ["range", "if-range", "if-none-match"]) {
187
213
  const value = opts.headers?.[name];
188
214
  if (value) headers.set(name, value);
189
215
  }
190
- return fetchImpl(`${base}/cp1/read/assets/${file}`, { method: "GET", headers, redirect: "error", signal: AbortSignal.timeout(opts.timeoutMs ?? options.timeoutMs ?? DEFAULT_TIMEOUT_MS) });
216
+ return fetchImpl(url, { method: "GET", headers, redirect: "error", signal: AbortSignal.timeout(opts.timeoutMs ?? options.timeoutMs ?? DEFAULT_TIMEOUT_MS) });
191
217
  }
192
- return { resolve, mounts, asset };
218
+ return { resolve, mounts, pushPosts, asset };
193
219
  }
194
220
 
195
221
  // src/delivery-dedupe.ts
@@ -266,6 +292,35 @@ function isValidCacheTag(tag2) {
266
292
  // src/revalidation-callback.ts
267
293
  var MAX_BODY_BYTES = 65536;
268
294
  var MAX_TAGS = 1e3;
295
+ var HOOK_WAIT_MS = 3e3;
296
+ var COMMENT_EVENT_TYPES = ["comment.held", "comment.reply", "comment.approved", "comment.hidden"];
297
+ var isRecord = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
298
+ var isText = (v) => typeof v === "string" && v.length > 0;
299
+ var isTextOrNull = (v) => v === null || isText(v);
300
+ var isEventPath = (v) => typeof v === "string" && v.startsWith("/") && !v.startsWith("//") && v.length <= 2048 && !/[\\\u0000-\u001f\u007f]/.test(v);
301
+ function parseCommentEvent(payload) {
302
+ if (!isRecord(payload) || payload.cp !== 1 || !isRecord(payload.data)) return void 0;
303
+ const type = COMMENT_EVENT_TYPES.find((t) => t === payload.type);
304
+ const { id, created_at, workspace_id, event_id, data } = payload;
305
+ if (!type || !isText(id) || !isText(created_at) || !isText(workspace_id) || !isText(event_id)) return void 0;
306
+ const { comment_id, parent_comment_id, publication_path, reader_sub, parent_reader_sub, status } = data;
307
+ if (!isText(comment_id) || !isTextOrNull(parent_comment_id) || !isEventPath(publication_path) || !isTextOrNull(reader_sub) || !isTextOrNull(parent_reader_sub)) return void 0;
308
+ if (status !== "held" && status !== "visible" && status !== "hidden") return void 0;
309
+ return { cp: 1, id, type, created_at, workspace_id, event_id, data: { comment_id, parent_comment_id, publication_path, reader_sub, parent_reader_sub, status } };
310
+ }
311
+ async function runHook(hook, event) {
312
+ let timer;
313
+ try {
314
+ await Promise.race([
315
+ Promise.resolve().then(() => hook(event)),
316
+ new Promise((_, reject) => timer = setTimeout(() => reject(new Error("timeout")), HOOK_WAIT_MS))
317
+ ]);
318
+ } catch {
319
+ console.error(`hyle: onCommentEvent failed or timed out for ${event.type} ${event.id}`);
320
+ } finally {
321
+ clearTimeout(timer);
322
+ }
323
+ }
269
324
  function createRevalidationCallbackRoute(options) {
270
325
  const dedupe = new DeliveryDedupe(options.dedupeCapacity);
271
326
  return {
@@ -300,7 +355,7 @@ function createRevalidationCallbackRoute(options) {
300
355
  if (body.workspace_id !== options.workspaceId) {
301
356
  return okResponse(0);
302
357
  }
303
- const deliveryId = req.headers.get("hyle-delivery-id");
358
+ const deliveryId = typeof body.id === "string" ? body.id : void 0;
304
359
  if (deliveryId && dedupe.has(deliveryId)) {
305
360
  return okResponse(0);
306
361
  }
@@ -315,6 +370,9 @@ function createRevalidationCallbackRoute(options) {
315
370
  return new Response(null, { status: 500 });
316
371
  }
317
372
  if (deliveryId) dedupe.add(deliveryId);
373
+ const hook = options.onCommentEvent;
374
+ const event = hook && parseCommentEvent(body);
375
+ if (hook && event) await runHook(hook, event);
318
376
  return okResponse(purged);
319
377
  }
320
378
  };
@@ -456,9 +514,16 @@ var SHAPES = {
456
514
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M9 1.8v3h3" })
457
515
  ] }),
458
516
  chev: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "m6 3.5 4.5 4.5L6 12.5" }),
517
+ "chev-up": /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "m3.5 10 4.5-4.5L12.5 10" }),
459
518
  "chev-down": /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "m3.5 6 4.5 4.5L12.5 6" }),
460
519
  "chev-left": /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M10 3.5 5.5 8 10 12.5" }),
461
520
  x: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "m4 4 8 8M12 4l-8 8" }),
521
+ important: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M3 2.5h10a1 1 0 0 1 1 1v7a1 1 0 0 1-1 1H8l-3.5 2.8v-2.8H3a1 1 0 0 1-1-1v-7a1 1 0 0 1 1-1zM8 5v2.8M8 9.5v.1" }),
522
+ copy: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
523
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("rect", { x: "5.5", y: "5.5", width: "8", height: "8", rx: "1.3" }),
524
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M10.5 5.5v-2a1 1 0 0 0-1-1h-6a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2" })
525
+ ] }),
526
+ check: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "m3 8.5 3.2 3L13 4.5" }),
462
527
  heart: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M8 13.5S2.2 10 2.2 6.1A3 3 0 0 1 8 5a3 3 0 0 1 5.8 1.1C13.8 10 8 13.5 8 13.5z" }),
463
528
  reply: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M6.5 3.5 2.5 7.5l4 4M2.5 7.5h6a5 5 0 0 1 5 5" }),
464
529
  clock: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
@@ -497,8 +562,15 @@ var isScalar = (v) => typeof v === "string" || typeof v === "number" || typeof v
497
562
  var matches = (re) => (v) => typeof v === "string" && re.test(v);
498
563
  var ID_PREFIX = "user-content-";
499
564
  var scopeId = (id) => id.startsWith(ID_PREFIX) ? id : ID_PREFIX + id;
500
- var ID_BODY = /^[\p{L}\p{N}_:.-]{1,180}$/u;
501
- var isIdValue = (v) => typeof v === "string" && ID_BODY.test(v.startsWith(ID_PREFIX) ? v.slice(ID_PREFIX.length) : v);
565
+ var ID_BODY = /^[\p{L}\p{M}\p{N}\p{Pc}:.-]{1,180}$/u;
566
+ function isIdValue(v) {
567
+ if (typeof v !== "string") return false;
568
+ try {
569
+ return ID_BODY.test(decodeURIComponent(v.startsWith(ID_PREFIX) ? v.slice(ID_PREFIX.length) : v));
570
+ } catch {
571
+ return false;
572
+ }
573
+ }
502
574
  var CLASS_TOKEN = /^[A-Za-z_][\w:-]*$/;
503
575
  var classTokens = (v) => {
504
576
  const tokens = Array.isArray(v) ? v : typeof v === "string" ? v.split(/\s+/) : [];
@@ -511,6 +583,7 @@ var isLength = matches(/^[\d.]+(em|px|%)?$/);
511
583
  var STYLE_PROPS = /* @__PURE__ */ new Set(["height", "vertical-align", "margin-left", "margin-right", "margin-top", "margin-bottom", "top", "width", "min-width", "border-bottom-width", "padding-left"]);
512
584
  var STYLE_LENGTH = /^(-?\d+(?:\.\d+)?)(em|px|%)?$/;
513
585
  var MAX_STYLE_MAGNITUDE = 100;
586
+ var MAX_MARGIN_MAGNITUDE = 20;
514
587
  function isKatexStyle(v, ctx2) {
515
588
  if (typeof v !== "string" || !ctx2.katex) return false;
516
589
  return v.split(";").filter((d) => d !== "").every((decl) => {
@@ -518,7 +591,8 @@ function isKatexStyle(v, ctx2) {
518
591
  if (extra.length > 0 || prop === void 0 || value === void 0) return false;
519
592
  if (prop === "position") return value === "relative";
520
593
  const m = STYLE_LENGTH.exec(value);
521
- return STYLE_PROPS.has(prop) && m !== null && Math.abs(Number(m[1])) <= MAX_STYLE_MAGNITUDE;
594
+ const max = prop.startsWith("margin-") ? MAX_MARGIN_MAGNITUDE : MAX_STYLE_MAGNITUDE;
595
+ return STYLE_PROPS.has(prop) && m !== null && Math.abs(Number(m[1])) <= max;
522
596
  });
523
597
  }
524
598
  function isSafeUrl(value, kind) {
@@ -551,6 +625,8 @@ function diagramRender(value) {
551
625
  const m = typeof value === "string" ? RENDER_REF.exec(value) : null;
552
626
  return m ? { src: hostAssetSrc(m[1]), width: Number(m[2]), height: Number(m[3]) } : void 0;
553
627
  }
628
+ var YOUTUBE_WATCH = /^https:\/\/www\.youtube\.com\/watch\?v=([A-Za-z0-9_-]{11})$/;
629
+ var youtubeId = (href) => typeof href === "string" ? YOUTUBE_WATCH.exec(href)?.[1] : void 0;
554
630
  var heading = { id: isIdValue, className: isClass };
555
631
  var ATTRS = new Map(
556
632
  Object.entries({
@@ -566,6 +642,7 @@ var ATTRS = new Map(
566
642
  tbody: {},
567
643
  tr: {},
568
644
  ol: {},
645
+ kbd: {},
569
646
  ul: { className: isClass },
570
647
  li: { id: isIdValue, className: isClass },
571
648
  h1: heading,
@@ -574,8 +651,8 @@ var ATTRS = new Map(
574
651
  h4: heading,
575
652
  h5: heading,
576
653
  h6: heading,
577
- a: { href: isHref, id: isIdValue, ariaDescribedBy: isIdValue, ariaLabel: isString, dataFootnoteRef: isScalar, dataFootnoteBackref: isScalar, className: isClass },
578
- img: { src: isSrc, alt: isString, width: isPixels, height: isPixels },
654
+ a: { href: isHref, id: isIdValue, ariaDescribedBy: isIdValue, ariaLabel: isString, dataFootnoteRef: isScalar, dataFootnoteBackref: isScalar, dataEmbed: matches(/^youtube$/), className: isClass },
655
+ img: { src: isSrc, alt: isString, title: isString, width: isPixels, height: isPixels },
579
656
  table: {},
580
657
  th: { scope: matches(/^(row|col|rowgroup|colgroup)$/), align: isAlign },
581
658
  td: { align: isAlign },
@@ -598,8 +675,10 @@ function textOf(node, depth = 0) {
598
675
  if (node.type === "text") return typeof node.value === "string" ? node.value : "";
599
676
  return Array.isArray(node.children) ? node.children.map((c) => textOf(c, depth + 1)).join("") : "";
600
677
  }
678
+ var holdsEmbed = (node, depth = 0) => isObject(node) && depth <= MAX_DEPTH && (isObject(node.properties) && "dataEmbed" in node.properties || Array.isArray(node.children) && node.children.some((c) => holdsEmbed(c, depth + 1)));
679
+ var collapse = (text) => text.replace(/\s+/g, " ").trim();
601
680
  var CALLOUT_MARKER = /^\s*\[!(NOTE|TIP|IMPORTANT|WARNING|CAUTION)\]\s*/i;
602
- var CALLOUT_KIND = { note: "note", tip: "tip", important: "warning", warning: "warning", caution: "caution" };
681
+ var CALLOUT_KIND = { note: "note", tip: "tip", important: "important", warning: "warning", caution: "caution" };
603
682
  function toCallout(children) {
604
683
  const first = children.find((c) => c.type === "element");
605
684
  const lead = first?.tagName === "p" ? first.children[0] : void 0;
@@ -611,6 +690,21 @@ function toCallout(children) {
611
690
  const kind = CALLOUT_KIND[(marker[1] ?? "note").toLowerCase()] ?? "note";
612
691
  return { type: "element", tagName: "callout", properties: { kind }, children: [...body, ...children.slice(children.indexOf(first) + 1)] };
613
692
  }
693
+ var isBlank = (node) => node.type === "text" && node.value.trim() === "";
694
+ function soleElement(children) {
695
+ const [only, ...more] = children.filter((c) => !isBlank(c));
696
+ return more.length === 0 && only?.type === "element" ? only : void 0;
697
+ }
698
+ function toFigure(children) {
699
+ const only = soleElement(children);
700
+ const img = only?.tagName === "a" ? soleElement(only.children) : only;
701
+ if (!only || img?.tagName !== "img" || typeof img.properties.src !== "string") return void 0;
702
+ const { title, ...properties } = img.properties;
703
+ const bare = { ...img, properties };
704
+ const media = only === img ? bare : { ...only, children: [bare] };
705
+ const caption = typeof title === "string" && title.trim() ? [{ type: "element", tagName: "figcaption", properties: {}, children: [{ type: "text", value: title }] }] : [];
706
+ return { type: "element", tagName: "figure", properties: { dataSlotComponent: "Image" }, children: [media, ...caption] };
707
+ }
614
708
  function clean(node, depth, ctx2, budget) {
615
709
  if (!isObject(node) || depth > MAX_DEPTH) return [];
616
710
  if (++budget.nodes > MAX_NODES) throw new HastLimitError("content has too many nodes");
@@ -644,6 +738,11 @@ function clean(node, depth, ctx2, budget) {
644
738
  }
645
739
  for (const key of ["id", "ariaDescribedBy"]) if (typeof properties[key] === "string") properties[key] = scopeId(properties[key]);
646
740
  if (tag2 === "a" && typeof properties.href === "string" && properties.href.trim().startsWith("#")) properties.href = `#${scopeId(properties.href.trim().slice(1))}`;
741
+ if (tag2 === "a" && properties.dataEmbed !== void 0 && youtubeId(properties.href) === void 0) delete properties.dataEmbed;
742
+ if (tag2 === "p") {
743
+ const figure = toFigure(children);
744
+ if (figure) return [figure];
745
+ }
647
746
  if (tag2 === "blockquote") {
648
747
  const callout = toCallout(children);
649
748
  if (callout) return [callout];
@@ -655,9 +754,9 @@ function sanitizeHast(tree, title, description) {
655
754
  const raw = isObject(tree) && tree.type === "root" && Array.isArray(tree.children) ? tree.children : [];
656
755
  const elements = raw.filter((n) => isObject(n) && n.type === "element");
657
756
  const [first] = elements;
658
- const skip = title !== void 0 && isObject(first) && first.tagName === "h1" && textOf(first).trim() === title.trim() ? first : void 0;
757
+ const skip = title !== void 0 && isObject(first) && first.tagName === "h1" && collapse(textOf(first)) === collapse(title) ? first : void 0;
659
758
  const lead = elements[skip ? 1 : 0];
660
- const repeat = description && isObject(lead) && lead.tagName === "p" && textOf(lead).trim().startsWith(description.trim()) ? lead : void 0;
759
+ const repeat = description && isObject(lead) && lead.tagName === "p" && collapse(textOf(lead)).startsWith(collapse(description)) && !holdsEmbed(lead) ? lead : void 0;
661
760
  const budget = { nodes: 0, text: 0 };
662
761
  return { type: "root", children: raw.filter((n) => n !== skip && n !== repeat).flatMap((n) => clean(n, 0, { katex: false }, budget)) };
663
762
  }
@@ -696,6 +795,7 @@ var COMMENT_LABELS_EN = {
696
795
  removed: "This comment was removed.",
697
796
  removedByModerator: "This comment was removed by a moderator.",
698
797
  removedByAuthor: "This comment was deleted by its author.",
798
+ unrenderable: "This comment cannot be displayed.",
699
799
  depthEnd: "Replies end at this depth",
700
800
  held: "Awaiting approval.",
701
801
  heldBanner: "Thanks, your comment is awaiting approval",
@@ -722,8 +822,39 @@ var COMMENT_LABELS_EN = {
722
822
  bannedBody: "Commenting is not available for your account on this site. You can still read every comment. If you think this is a mistake, contact the site team.",
723
823
  expired: "Your session ended. Sign in again to post. Your text is kept.",
724
824
  more: "Load more comments",
725
- truncated: "Showing the first 500 comments.",
726
- justNow: "just now"
825
+ truncated: "Only the first part of this discussion is shown.",
826
+ justNow: "just now",
827
+ react: "React",
828
+ reactions: "Reactions",
829
+ reactionLike: "Like",
830
+ reactionLove: "Love",
831
+ reactionInsightful: "Insightful",
832
+ reactionCelebrate: "Celebrate",
833
+ reactionSignIn: "Sign in to react, ",
834
+ reactionAddedLive: "{kind} reaction added",
835
+ reactionRemovedLive: "{kind} reaction removed",
836
+ reactionsLoading: "Loading reactions",
837
+ reactionsError: "Reactions could not be loaded",
838
+ votesOn: "Votes on the comment by {name}",
839
+ score: "Score {n}",
840
+ upvote: "Upvote",
841
+ downvote: "Downvote",
842
+ upvoteSignIn: "Sign in to upvote",
843
+ downvoteSignIn: "Sign in to downvote",
844
+ upvotedLive: "Upvoted. Score {n}",
845
+ downvotedLive: "Downvoted. Score {n}",
846
+ voteRemovedLive: "Vote removed. Score {n}",
847
+ voteRefused: "That vote was not accepted. You cannot vote on your own comment.",
848
+ slowDown: "Too many actions in a short time. Wait a moment and try again.",
849
+ sort: "Sort comments",
850
+ sortNewest: "Newest",
851
+ sortTop: "Top",
852
+ sortedNewestLive: "Showing newest comments first",
853
+ sortedTopLive: "Showing top comments first",
854
+ sortError: "The comments could not be sorted. Please try again.",
855
+ newerLater: "Newer comments appear after you load more.",
856
+ moreError: "More comments could not be loaded. Please try again.",
857
+ loadedLive: "{n} comments loaded"
727
858
  };
728
859
  var COMMENT_LABELS_FR = {
729
860
  heading: "Commentaires",
@@ -758,6 +889,7 @@ var COMMENT_LABELS_FR = {
758
889
  removed: "Ce commentaire a \xE9t\xE9 retir\xE9.",
759
890
  removedByModerator: "Ce commentaire a \xE9t\xE9 retir\xE9 par un mod\xE9rateur.",
760
891
  removedByAuthor: "Ce commentaire a \xE9t\xE9 supprim\xE9 par son auteur.",
892
+ unrenderable: "Ce commentaire ne peut pas \xEAtre affich\xE9.",
761
893
  depthEnd: "Les r\xE9ponses s'arr\xEAtent \xE0 ce niveau",
762
894
  held: "En attente d'approbation.",
763
895
  heldBanner: "Merci, votre commentaire est en attente d'approbation",
@@ -784,8 +916,39 @@ var COMMENT_LABELS_FR = {
784
916
  bannedBody: "Les commentaires ne sont pas disponibles pour votre compte sur ce site. Vous pouvez toujours tout lire. Si vous pensez \xE0 une erreur, contactez l'\xE9quipe du site.",
785
917
  expired: "Votre session a expir\xE9. Reconnectez-vous pour publier. Votre texte est conserv\xE9.",
786
918
  more: "Charger plus de commentaires",
787
- truncated: "Affichage des 500 premiers commentaires.",
788
- justNow: "\xE0 l'instant"
919
+ truncated: "Seul le d\xE9but de cette discussion est affich\xE9.",
920
+ justNow: "\xE0 l'instant",
921
+ react: "R\xE9agir",
922
+ reactions: "R\xE9actions",
923
+ reactionLike: "J'aime",
924
+ reactionLove: "J'adore",
925
+ reactionInsightful: "Instructif",
926
+ reactionCelebrate: "Bravo",
927
+ reactionSignIn: "Connectez-vous pour r\xE9agir, ",
928
+ reactionAddedLive: "R\xE9action {kind} ajout\xE9e",
929
+ reactionRemovedLive: "R\xE9action {kind} retir\xE9e",
930
+ reactionsLoading: "Chargement des r\xE9actions",
931
+ reactionsError: "Les r\xE9actions n'ont pas pu \xEAtre charg\xE9es",
932
+ votesOn: "Votes sur le commentaire de {name}",
933
+ score: "Score {n}",
934
+ upvote: "Voter pour",
935
+ downvote: "Voter contre",
936
+ upvoteSignIn: "Connectez-vous pour voter pour",
937
+ downvoteSignIn: "Connectez-vous pour voter contre",
938
+ upvotedLive: "Vote pour enregistr\xE9. Score {n}",
939
+ downvotedLive: "Vote contre enregistr\xE9. Score {n}",
940
+ voteRemovedLive: "Vote retir\xE9. Score {n}",
941
+ voteRefused: "Ce vote a \xE9t\xE9 refus\xE9. Vous ne pouvez pas voter pour votre propre commentaire.",
942
+ slowDown: "Trop d'actions en peu de temps. Patientez un instant et r\xE9essayez.",
943
+ sort: "Trier les commentaires",
944
+ sortNewest: "R\xE9cents",
945
+ sortTop: "Meilleurs",
946
+ sortedNewestLive: "Commentaires les plus r\xE9cents en premier",
947
+ sortedTopLive: "Meilleurs commentaires en premier",
948
+ sortError: "Les commentaires n'ont pas pu \xEAtre tri\xE9s. R\xE9essayez.",
949
+ newerLater: "Les commentaires plus r\xE9cents apparaissent apr\xE8s le chargement de la suite.",
950
+ moreError: "La suite des commentaires n'a pas pu \xEAtre charg\xE9e. R\xE9essayez.",
951
+ loadedLive: "{n} commentaires charg\xE9s"
789
952
  };
790
953
  var COMMENT_LABELS_ES = {
791
954
  heading: "Comentarios",
@@ -820,6 +983,7 @@ var COMMENT_LABELS_ES = {
820
983
  removed: "Este comentario fue eliminado.",
821
984
  removedByModerator: "Un moderador elimin\xF3 este comentario.",
822
985
  removedByAuthor: "Su autor elimin\xF3 este comentario.",
986
+ unrenderable: "Este comentario no se puede mostrar.",
823
987
  depthEnd: "Las respuestas terminan en este nivel",
824
988
  held: "Pendiente de aprobaci\xF3n.",
825
989
  heldBanner: "Gracias, tu comentario est\xE1 pendiente de aprobaci\xF3n",
@@ -846,8 +1010,39 @@ var COMMENT_LABELS_ES = {
846
1010
  bannedBody: "Los comentarios no est\xE1n disponibles para tu cuenta en este sitio. A\xFAn puedes leerlos todos. Si crees que es un error, contacta con el equipo del sitio.",
847
1011
  expired: "Tu sesi\xF3n termin\xF3. Inicia sesi\xF3n de nuevo para publicar. Tu texto se conserva.",
848
1012
  more: "Cargar m\xE1s comentarios",
849
- truncated: "Se muestran los primeros 500 comentarios.",
850
- justNow: "ahora mismo"
1013
+ truncated: "Solo se muestra la primera parte de esta conversaci\xF3n.",
1014
+ justNow: "ahora mismo",
1015
+ react: "Reaccionar",
1016
+ reactions: "Reacciones",
1017
+ reactionLike: "Me gusta",
1018
+ reactionLove: "Me encanta",
1019
+ reactionInsightful: "Interesante",
1020
+ reactionCelebrate: "Celebrar",
1021
+ reactionSignIn: "Inicia sesi\xF3n para reaccionar, ",
1022
+ reactionAddedLive: "Reacci\xF3n {kind} a\xF1adida",
1023
+ reactionRemovedLive: "Reacci\xF3n {kind} eliminada",
1024
+ reactionsLoading: "Cargando reacciones",
1025
+ reactionsError: "No se pudieron cargar las reacciones",
1026
+ votesOn: "Votos del comentario de {name}",
1027
+ score: "Puntuaci\xF3n {n}",
1028
+ upvote: "Votar a favor",
1029
+ downvote: "Votar en contra",
1030
+ upvoteSignIn: "Inicia sesi\xF3n para votar a favor",
1031
+ downvoteSignIn: "Inicia sesi\xF3n para votar en contra",
1032
+ upvotedLive: "Voto a favor registrado. Puntuaci\xF3n {n}",
1033
+ downvotedLive: "Voto en contra registrado. Puntuaci\xF3n {n}",
1034
+ voteRemovedLive: "Voto retirado. Puntuaci\xF3n {n}",
1035
+ voteRefused: "No se acept\xF3 el voto. No puedes votar tu propio comentario.",
1036
+ slowDown: "Demasiadas acciones en poco tiempo. Espera un momento e int\xE9ntalo de nuevo.",
1037
+ sort: "Ordenar comentarios",
1038
+ sortNewest: "Recientes",
1039
+ sortTop: "Destacados",
1040
+ sortedNewestLive: "Comentarios m\xE1s recientes primero",
1041
+ sortedTopLive: "Comentarios destacados primero",
1042
+ sortError: "No se pudieron ordenar los comentarios. Int\xE9ntalo de nuevo.",
1043
+ newerLater: "Los comentarios m\xE1s recientes aparecen al cargar m\xE1s.",
1044
+ moreError: "No se pudieron cargar m\xE1s comentarios. Int\xE9ntalo de nuevo.",
1045
+ loadedLive: "{n} comentarios cargados"
851
1046
  };
852
1047
 
853
1048
  // src/react/viewer/labels.ts
@@ -859,15 +1054,15 @@ var VIEWER_LABELS_EN = {
859
1054
  zoomIn: "Zoom in",
860
1055
  zoomOut: "Zoom out",
861
1056
  fit: "Fit to window",
862
- actual: "Actual size",
1057
+ actual: "100%: actual size",
863
1058
  search: "Find in diagram",
864
1059
  searchPlaceholder: "Find",
865
1060
  noMatch: "No match",
866
1061
  matchOf: "{n} of {total}",
867
- copySource: "Copy diagram source",
868
- downloadSvg: "Download SVG",
869
- downloadPng: "Download PNG",
870
- copyImage: "Copy as image",
1062
+ copySource: "MMD: copy diagram source",
1063
+ downloadSvg: "SVG: download",
1064
+ downloadPng: "PNG: download",
1065
+ copyImage: "IMG: copy as image",
871
1066
  pngScale: "PNG scale",
872
1067
  fullscreen: "Fullscreen",
873
1068
  exitFullscreen: "Exit fullscreen",
@@ -880,7 +1075,16 @@ var VIEWER_LABELS_EN = {
880
1075
  legendDownstream: "Downstream",
881
1076
  outgoing: "outgoing",
882
1077
  tracing: "{label}: {up} upstream, {down} downstream",
883
- map: "Overview map"
1078
+ map: "Overview map",
1079
+ largeTitle: "Large diagram, not drawn automatically",
1080
+ largeBody: "Drawing a diagram this size can freeze this page for a few seconds, so it waits until you ask. Press Draw diagram: it takes a couple of seconds (a few more on a phone) and the page may pause while it works.",
1081
+ drawLarge: "Draw diagram",
1082
+ drawing: "Drawing\u2026",
1083
+ drawingBody: "Drawing the diagram\u2026 this takes a couple of seconds.",
1084
+ drawAgain: "Draw again",
1085
+ showSource: "Show full source",
1086
+ hideSource: "Show less",
1087
+ printPreparing: "Preparing diagrams for print\u2026 Esc cancels between steps."
884
1088
  };
885
1089
  var VIEWER_LABELS_FR = {
886
1090
  expand: "Agrandir le sch\xE9ma",
@@ -890,15 +1094,15 @@ var VIEWER_LABELS_FR = {
890
1094
  zoomIn: "Zoom avant",
891
1095
  zoomOut: "Zoom arri\xE8re",
892
1096
  fit: "Ajuster \xE0 la fen\xEAtre",
893
- actual: "Taille r\xE9elle",
1097
+ actual: "100% : taille r\xE9elle",
894
1098
  search: "Rechercher dans le sch\xE9ma",
895
1099
  searchPlaceholder: "Rechercher",
896
1100
  noMatch: "Aucun r\xE9sultat",
897
1101
  matchOf: "{n} sur {total}",
898
- copySource: "Copier la source du sch\xE9ma",
899
- downloadSvg: "T\xE9l\xE9charger le SVG",
900
- downloadPng: "T\xE9l\xE9charger le PNG",
901
- copyImage: "Copier comme image",
1102
+ copySource: "MMD : copier la source du sch\xE9ma",
1103
+ downloadSvg: "SVG : t\xE9l\xE9charger",
1104
+ downloadPng: "PNG : t\xE9l\xE9charger",
1105
+ copyImage: "IMG : copier comme image",
902
1106
  pngScale: "\xC9chelle du PNG",
903
1107
  fullscreen: "Plein \xE9cran",
904
1108
  exitFullscreen: "Quitter le plein \xE9cran",
@@ -911,7 +1115,16 @@ var VIEWER_LABELS_FR = {
911
1115
  legendDownstream: "En aval",
912
1116
  outgoing: "sortants",
913
1117
  tracing: "{label} : {up} en amont, {down} en aval",
914
- map: "Carte d'ensemble"
1118
+ map: "Carte d'ensemble",
1119
+ largeTitle: "Grand sch\xE9ma, non dessin\xE9 automatiquement",
1120
+ largeBody: "Dessiner un sch\xE9ma de cette taille peut figer la page quelques secondes, il attend donc votre demande. Appuyez sur Dessiner le sch\xE9ma : cela prend quelques secondes (un peu plus sur un t\xE9l\xE9phone) et la page peut se figer pendant ce temps.",
1121
+ drawLarge: "Dessiner le sch\xE9ma",
1122
+ drawing: "Dessin en cours\u2026",
1123
+ drawingBody: "Dessin du sch\xE9ma\u2026 cela prend quelques secondes.",
1124
+ drawAgain: "Redessiner",
1125
+ showSource: "Afficher toute la source",
1126
+ hideSource: "R\xE9duire",
1127
+ printPreparing: "Pr\xE9paration des sch\xE9mas pour l'impression\u2026 \xC9chap annule entre deux \xE9tapes."
915
1128
  };
916
1129
  var VIEWER_LABELS_ES = {
917
1130
  expand: "Ampliar el diagrama",
@@ -921,15 +1134,15 @@ var VIEWER_LABELS_ES = {
921
1134
  zoomIn: "Acercar",
922
1135
  zoomOut: "Alejar",
923
1136
  fit: "Ajustar a la ventana",
924
- actual: "Tama\xF1o real",
1137
+ actual: "100%: tama\xF1o real",
925
1138
  search: "Buscar en el diagrama",
926
1139
  searchPlaceholder: "Buscar",
927
1140
  noMatch: "Sin resultados",
928
1141
  matchOf: "{n} de {total}",
929
- copySource: "Copiar el c\xF3digo del diagrama",
930
- downloadSvg: "Descargar SVG",
931
- downloadPng: "Descargar PNG",
932
- copyImage: "Copiar como imagen",
1142
+ copySource: "MMD: copiar el c\xF3digo del diagrama",
1143
+ downloadSvg: "SVG: descargar",
1144
+ downloadPng: "PNG: descargar",
1145
+ copyImage: "IMG: copiar como imagen",
933
1146
  pngScale: "Escala del PNG",
934
1147
  fullscreen: "Pantalla completa",
935
1148
  exitFullscreen: "Salir de pantalla completa",
@@ -942,7 +1155,16 @@ var VIEWER_LABELS_ES = {
942
1155
  legendDownstream: "Aguas abajo",
943
1156
  outgoing: "salientes",
944
1157
  tracing: "{label}: {up} aguas arriba, {down} aguas abajo",
945
- map: "Mapa general"
1158
+ map: "Mapa general",
1159
+ largeTitle: "Diagrama grande, no se dibuja autom\xE1ticamente",
1160
+ largeBody: "Dibujar un diagrama de este tama\xF1o puede bloquear la p\xE1gina unos segundos, as\xED que espera a que lo pidas. Pulsa Dibujar el diagrama: tarda un par de segundos (algo m\xE1s en un tel\xE9fono) y la p\xE1gina puede detenerse mientras tanto.",
1161
+ drawLarge: "Dibujar el diagrama",
1162
+ drawing: "Dibujando\u2026",
1163
+ drawingBody: "Dibujando el diagrama\u2026 tarda un par de segundos.",
1164
+ drawAgain: "Dibujar de nuevo",
1165
+ showSource: "Mostrar todo el c\xF3digo",
1166
+ hideSource: "Mostrar menos",
1167
+ printPreparing: "Preparando los diagramas para imprimir\u2026 Esc cancela entre pasos."
946
1168
  };
947
1169
 
948
1170
  // src/react/strings.ts
@@ -961,6 +1183,14 @@ var en = {
961
1183
  warning: "Heads up",
962
1184
  tip: "Tip",
963
1185
  caution: "Caution",
1186
+ important: "Important",
1187
+ copyCode: "Copy code",
1188
+ copied: "Copied",
1189
+ copyBlocked: "Copy blocked",
1190
+ done: "Done",
1191
+ notDone: "Not done",
1192
+ playVideo: "Play video",
1193
+ videoFrame: "YouTube video",
964
1194
  diagram: "Diagram",
965
1195
  diagramError: "This diagram could not be rendered.",
966
1196
  diagramLoading: "Loading the diagram",
@@ -1013,6 +1243,14 @@ var fr = {
1013
1243
  warning: "Attention",
1014
1244
  tip: "Astuce",
1015
1245
  caution: "Danger",
1246
+ important: "Important",
1247
+ copyCode: "Copier le code",
1248
+ copied: "Copi\xE9",
1249
+ copyBlocked: "Copie bloqu\xE9e",
1250
+ done: "Termin\xE9",
1251
+ notDone: "\xC0 faire",
1252
+ playVideo: "Lire la vid\xE9o",
1253
+ videoFrame: "Vid\xE9o YouTube",
1016
1254
  diagram: "Sch\xE9ma",
1017
1255
  diagramError: "Ce sch\xE9ma n'a pas pu \xEAtre affich\xE9.",
1018
1256
  diagramLoading: "Chargement du sch\xE9ma",
@@ -1065,6 +1303,14 @@ var es = {
1065
1303
  warning: "Atenci\xF3n",
1066
1304
  tip: "Consejo",
1067
1305
  caution: "Peligro",
1306
+ important: "Importante",
1307
+ copyCode: "Copiar el c\xF3digo",
1308
+ copied: "Copiado",
1309
+ copyBlocked: "Copia bloqueada",
1310
+ done: "Hecho",
1311
+ notDone: "Pendiente",
1312
+ playVideo: "Reproducir el v\xEDdeo",
1313
+ videoFrame: "V\xEDdeo de YouTube",
1068
1314
  diagram: "Diagrama",
1069
1315
  diagramError: "No se pudo mostrar este diagrama.",
1070
1316
  diagramLoading: "Cargando el diagrama",
@@ -1122,14 +1368,15 @@ function formatDate(iso, locale, options = { dateStyle: "medium" }) {
1122
1368
  }
1123
1369
 
1124
1370
  // src/react/content.tsx
1371
+ var import_youtube_facade = require("./youtube-facade.cjs");
1125
1372
  var import_jsx_runtime3 = require("react/jsx-runtime");
1126
1373
  function plainText(node) {
1127
1374
  if (typeof node === "string" || typeof node === "number") return String(node);
1128
1375
  if (Array.isArray(node)) return node.map(plainText).join("");
1129
1376
  return (0, import_react.isValidElement)(node) ? plainText(node.props.children) : "";
1130
1377
  }
1131
- var CALLOUT_ICON = { note: "info", tip: "check-circle", warning: "alert", caution: "x-circle" };
1132
- function buildComponents(c, s) {
1378
+ var CALLOUT_ICON = { note: "info", tip: "check-circle", important: "important", warning: "alert", caution: "x-circle" };
1379
+ function buildComponents(c, s, { opensWithImage, interactive }) {
1133
1380
  const Link = c.Link ?? "a";
1134
1381
  const Img = c.Image ?? "img";
1135
1382
  const A = ({ href, children, ...rest }) => {
@@ -1140,10 +1387,11 @@ function buildComponents(c, s) {
1140
1387
  }
1141
1388
  return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("a", { href: url, rel: "noopener noreferrer", ...rest, children });
1142
1389
  };
1143
- let images = 0;
1390
+ let eager = opensWithImage;
1144
1391
  const Image = (props) => {
1145
1392
  if (typeof props.src !== "string") return null;
1146
- const first = images++ === 0;
1393
+ const first = eager;
1394
+ eager = false;
1147
1395
  return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Img, { loading: first ? "eager" : "lazy", ...first ? { fetchPriority: "high" } : {}, decoding: "async", ...props });
1148
1396
  };
1149
1397
  const Pre = ({ children, ...rest }) => {
@@ -1152,13 +1400,22 @@ function buildComponents(c, s) {
1152
1400
  const pre = /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("pre", { tabIndex: 0, ...rest, children });
1153
1401
  if (c.CodeBlock) return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(c.CodeBlock, { code: plainText(children), language, children: pre });
1154
1402
  return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("figure", { className: "hyle-codeblock", "data-slot-component": "CodeBlock", children: [
1155
- language ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("header", { children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "lang", children: language }) }) : null,
1403
+ language || interactive ? /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("header", { children: [
1404
+ language ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "lang", children: language }) : null,
1405
+ interactive ? /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
1406
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("button", { type: "button", "aria-label": s.copyCode, children: [
1407
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Icon, { name: "copy" }),
1408
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Icon, { name: "check" })
1409
+ ] }),
1410
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "hyle-sr", role: "status" })
1411
+ ] }) : null
1412
+ ] }) : null,
1156
1413
  pre
1157
1414
  ] });
1158
1415
  };
1159
1416
  const Table = ({ children, ...rest }) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "hyle-table", tabIndex: 0, role: "region", "aria-label": s.table, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("table", { ...rest, children }) });
1160
1417
  const Callout = ({ kind, children }) => {
1161
- const k = ["note", "tip", "warning", "caution"].includes(String(kind)) ? kind : "note";
1418
+ const k = Object.hasOwn(CALLOUT_ICON, String(kind)) ? kind : "note";
1162
1419
  const title = s[k];
1163
1420
  if (c.Callout) return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(c.Callout, { kind: k, title, children });
1164
1421
  return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("aside", { className: "hyle-callout", "data-kind": k, "data-slot-component": "Callout", role: "note", children: [
@@ -1184,17 +1441,27 @@ function buildComponents(c, s) {
1184
1441
  };
1185
1442
  const Heading = (level) => function HyleHeading({ id, children, ...rest }) {
1186
1443
  const Tag = `h${level}`;
1444
+ const anchored = typeof id === "string" && !String(rest.className ?? "").split(" ").includes("sr-only");
1187
1445
  return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(Tag, { id, ...rest, children: [
1188
- typeof id === "string" ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("a", { className: "hyle-anchor", href: `#${id}`, "aria-label": s.anchor, children: "#" }) : null,
1446
+ anchored ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("a", { className: "hyle-anchor", href: `#${id}`, "aria-label": s.anchor }) : null,
1189
1447
  children
1190
1448
  ] });
1191
1449
  };
1192
- const defaults = { a: A, img: Image, pre: Pre, table: Table, callout: Callout, iframe: Frame, h2: Heading(2), h3: Heading(3), h4: Heading(4) };
1450
+ const Checkbox = (props) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("input", { ...props, "aria-label": props.checked ? s.done : s.notDone });
1451
+ const Paragraph = ({ children, ...rest }) => {
1452
+ const [only, ...more] = import_react.Children.toArray(children).filter((n) => typeof n !== "string" || n.trim() !== "");
1453
+ if (more.length === 0 && (0, import_react.isValidElement)(only) && only.props["data-embed"] === "youtube") {
1454
+ const id = youtubeId(only.props.href);
1455
+ if (id) return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_youtube_facade.YouTubeFacade, { videoId: id, playLabel: s.playVideo, frameTitle: s.videoFrame, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { children: only }) });
1456
+ }
1457
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { ...rest, children });
1458
+ };
1459
+ const defaults = { a: A, img: Image, pre: Pre, table: Table, input: Checkbox, callout: Callout, iframe: Frame, h2: Heading(2), h3: Heading(3), h4: Heading(4), ...interactive ? { p: Paragraph } : {} };
1193
1460
  const overrides = ["a", "img", "code", "pre", "table", "blockquote", "h1", "h2", "h3", "h4", "h5", "h6"];
1194
1461
  for (const key of overrides) if (c[key]) defaults[key] = c[key];
1195
1462
  return defaults;
1196
1463
  }
1197
- function HastContent({ tree, title, description, components = {}, locale }) {
1464
+ function renderHast({ tree, title, description, components = {}, locale }, interactive) {
1198
1465
  let root;
1199
1466
  try {
1200
1467
  root = sanitizeHast(tree, title, description);
@@ -1206,11 +1473,13 @@ function HastContent({ tree, title, description, components = {}, locale }) {
1206
1473
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { children: s.contentError })
1207
1474
  ] });
1208
1475
  }
1476
+ const lead = root.children.find((n) => n.type !== "text" || n.value.trim() !== "");
1477
+ const opensWithImage = lead?.type === "element" && lead.tagName === "figure";
1209
1478
  return (0, import_hast_util_to_jsx_runtime.toJsxRuntime)(root, {
1210
1479
  Fragment: import_react.Fragment,
1211
1480
  jsx: import_jsx_runtime2.jsx,
1212
1481
  jsxs: import_jsx_runtime2.jsxs,
1213
- components: buildComponents(components, stringsFor(locale)),
1482
+ components: buildComponents(components, stringsFor(locale), { opensWithImage, interactive }),
1214
1483
  elementAttributeNameCase: "react",
1215
1484
  stylePropertyNameCase: "dom"
1216
1485
  });
@@ -1219,15 +1488,41 @@ function TrustedServerHtml({ html }) {
1219
1488
  return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { dangerouslySetInnerHTML: { __html: hostAssetHtml(html) } });
1220
1489
  }
1221
1490
 
1491
+ // src/react/body.tsx
1492
+ var import_react2 = require("react");
1493
+ var import_code_copy = require("./code-copy.cjs");
1494
+ var import_fragment_alias = require("./fragment-alias.cjs");
1495
+ var import_jsx_runtime4 = require("react/jsx-runtime");
1496
+ function ProseBody({ id, className, lang, ...content }) {
1497
+ const generated = (0, import_react2.useId)();
1498
+ const rootId = id ?? `hyle-body${generated}`;
1499
+ const s = stringsFor(content.locale);
1500
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
1501
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { id: rootId, className, lang, children: renderHast(content, true) }),
1502
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_code_copy.CodeCopy, { rootId, copyLabel: s.copyCode, copiedLabel: s.copied, blockedLabel: s.copyBlocked }),
1503
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_fragment_alias.FragmentAlias, {})
1504
+ ] });
1505
+ }
1506
+
1222
1507
  // src/react/index.ts
1223
1508
  var import_mermaid_diagram2 = require("./mermaid-diagram.cjs");
1509
+ var import_print_coordinator = require("./print-coordinator.cjs");
1224
1510
 
1225
1511
  // src/react/pages.tsx
1226
1512
  var import_comments = require("./comments.cjs");
1227
1513
 
1228
1514
  // src/react/comments-api.ts
1515
+ var REACTION_KINDS = ["like", "love", "insightful", "celebrate"];
1516
+ var isCursor = (v) => typeof v === "string" && /^[A-Za-z0-9_-]{1,200}$/.test(v);
1229
1517
  var isObject2 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
1230
1518
  var count = (v) => typeof v === "number" && Number.isFinite(v) && v >= 0 ? Math.trunc(v) : 0;
1519
+ function parseCounts(v) {
1520
+ if (!isObject2(v)) return void 0;
1521
+ return Object.fromEntries(REACTION_KINDS.map((kind) => [kind, count(v[kind])]).filter(([, n]) => n > 0));
1522
+ }
1523
+ var toVote = (v) => v === 1 || v === -1 ? v : null;
1524
+ var toUnrenderable = (v) => v === true ? { unrenderable: true } : {};
1525
+ var toMine = (v) => Array.isArray(v) ? { my_reactions: REACTION_KINDS.filter((kind) => v.includes(kind)) } : {};
1231
1526
  function toComment(raw) {
1232
1527
  if (!isObject2(raw) || typeof raw.id !== "string" || typeof raw.created_at !== "string") return void 0;
1233
1528
  const depth = typeof raw.depth === "number" ? Math.min(4, Math.max(1, Math.trunc(raw.depth))) : 1;
@@ -1235,6 +1530,7 @@ function toComment(raw) {
1235
1530
  const name = typeof raw.author_name === "string" ? raw.author_name : author;
1236
1531
  const body = isObject2(raw.body) && raw.body.format === "hast" ? { format: "hast", tree: raw.body.tree } : null;
1237
1532
  const removed = raw.removed === true || body === null;
1533
+ const reactions = parseCounts(raw.reaction_counts);
1238
1534
  return {
1239
1535
  id: raw.id,
1240
1536
  parent_id: typeof raw.parent_id === "string" ? raw.parent_id : null,
@@ -1243,11 +1539,14 @@ function toComment(raw) {
1243
1539
  created_at: raw.created_at,
1244
1540
  edited_at: typeof raw.edited_at === "string" ? raw.edited_at : null,
1245
1541
  like_count: count(raw.like_count),
1542
+ ...Number.isSafeInteger(raw.score) ? { score: raw.score } : {},
1543
+ ...reactions ? { reaction_counts: reactions } : {},
1246
1544
  removed,
1247
1545
  ...removed && (raw.removed_by === "moderator" || raw.removed_by === "author") ? { removed_by: raw.removed_by } : {},
1546
+ ...removed ? {} : toUnrenderable(raw.unrenderable),
1248
1547
  body,
1249
1548
  // Viewer members exist only on a live comment of a viewer-aware listing; a tombstone never carries them.
1250
- ...!removed && typeof raw.mine === "boolean" ? { mine: raw.mine, liked_by_me: raw.liked_by_me === true, can_edit_until: typeof raw.can_edit_until === "string" ? raw.can_edit_until : null } : {}
1549
+ ...!removed && typeof raw.mine === "boolean" ? { mine: raw.mine, liked_by_me: raw.liked_by_me === true, can_edit_until: typeof raw.can_edit_until === "string" ? raw.can_edit_until : null, ..."my_vote" in raw ? { my_vote: toVote(raw.my_vote) } : {}, ...toMine(raw.my_reactions) } : {}
1251
1550
  };
1252
1551
  }
1253
1552
  function toHeld(raw) {
@@ -1261,20 +1560,22 @@ function toHeld(raw) {
1261
1560
  created_at: raw.created_at,
1262
1561
  edited_at: typeof raw.edited_at === "string" ? raw.edited_at : null,
1263
1562
  can_edit_until: typeof raw.can_edit_until === "string" ? raw.can_edit_until : null,
1563
+ ...toUnrenderable(raw.unrenderable),
1264
1564
  body: { format: "hast", tree: raw.body.tree }
1265
1565
  };
1266
1566
  }
1267
1567
  function parseListing(data) {
1268
1568
  if (!isObject2(data) || data.kind !== "comments" || !Array.isArray(data.comments)) return void 0;
1269
1569
  const comments = data.comments.map(toComment).filter((c) => c !== void 0);
1270
- const viewer = Array.isArray(data.mine_held) ? { liked_by_me: data.liked_by_me === true, mine_held: data.mine_held.slice(0, 5).map(toHeld).filter((h) => h !== void 0) } : {};
1271
- return { cp: 1, kind: "comments", publication_id: String(data.publication_id ?? ""), comment_count: count(data.comment_count), like_count: count(data.like_count), truncated: data.truncated === true, comments, ...viewer };
1570
+ const viewer = Array.isArray(data.mine_held) ? { liked_by_me: data.liked_by_me === true, ...toMine(data.my_reactions), mine_held: data.mine_held.slice(0, 5).map(toHeld).filter((h) => h !== void 0) } : {};
1571
+ const reactions = parseCounts(data.reaction_counts);
1572
+ return { cp: 1, kind: "comments", publication_id: String(data.publication_id ?? ""), comment_count: count(data.comment_count), like_count: count(data.like_count), ...reactions ? { reaction_counts: reactions } : {}, truncated: data.truncated === true, next_cursor: isCursor(data.next_cursor) ? data.next_cursor : null, comments, ...viewer };
1272
1573
  }
1273
1574
  var untilMs = (iso) => {
1274
1575
  const t = iso ? Date.parse(iso) : NaN;
1275
1576
  return Number.isFinite(t) ? t : void 0;
1276
1577
  };
1277
- function buildThread(listing, localHeld) {
1578
+ function buildThread(listing, localHeld, unseen = [], newestOnTop = false) {
1278
1579
  const byId = /* @__PURE__ */ new Map();
1279
1580
  const roots = [];
1280
1581
  const place = (node, parentId) => {
@@ -1292,11 +1593,16 @@ function buildThread(listing, localHeld) {
1292
1593
  mine: !removed && c.mine === true,
1293
1594
  canEditUntil: untilMs(c.can_edit_until),
1294
1595
  likedByMe: !removed && c.liked_by_me === true,
1596
+ myReactions: removed ? void 0 : c.my_reactions,
1295
1597
  name: removed ? null : c.author_name ?? null,
1296
1598
  createdAt: c.created_at,
1297
1599
  editedAt: c.edited_at,
1298
1600
  likes: c.like_count,
1601
+ score: c.score,
1602
+ myVote: c.my_vote,
1603
+ reactions: c.reaction_counts,
1299
1604
  tree: c.body?.tree,
1605
+ unrenderable: c.unrenderable,
1300
1606
  text: void 0,
1301
1607
  kids: []
1302
1608
  };
@@ -1314,23 +1620,49 @@ function buildThread(listing, localHeld) {
1314
1620
  for (const h of listing.mine_held ?? []) {
1315
1621
  heldIds.add(h.id);
1316
1622
  const parent = h.parent_id ? byId.get(h.parent_id) : void 0;
1317
- addHeld({ id: h.id, depth: Math.min(4, (parent?.depth ?? h.depth - 1) + 1), status: "held", removedBy: void 0, mine: true, canEditUntil: untilMs(h.can_edit_until), likedByMe: false, name: h.author_name, createdAt: h.created_at, editedAt: h.edited_at, likes: 0, tree: h.body?.tree, text: void 0, kids: [] }, h.parent_id, true);
1623
+ addHeld({ id: h.id, depth: Math.min(4, (parent?.depth ?? h.depth - 1) + 1), status: "held", removedBy: void 0, mine: true, canEditUntil: untilMs(h.can_edit_until), likedByMe: false, name: h.author_name, createdAt: h.created_at, editedAt: h.edited_at, likes: 0, tree: h.body?.tree, unrenderable: h.unrenderable, text: void 0, kids: [] }, h.parent_id, true);
1318
1624
  }
1319
1625
  if (listing.mine_held === void 0) {
1320
1626
  for (const h of localHeld) {
1321
1627
  if (byId.has(h.id) || heldIds.has(h.id)) continue;
1322
1628
  const parent = h.parentId ? byId.get(h.parentId) : void 0;
1323
- addHeld({ id: h.id, depth: Math.min(4, (parent?.depth ?? 0) + 1), status: "held", removedBy: void 0, mine: true, canEditUntil: void 0, likedByMe: false, name: h.name, createdAt: h.createdAt, editedAt: null, likes: 0, tree: void 0, text: h.text, kids: [] }, h.parentId, false);
1629
+ addHeld(localNode(h, "held", parent), h.parentId, false);
1324
1630
  }
1325
1631
  }
1632
+ for (const u of [...unseen].reverse()) {
1633
+ if (byId.has(u.id) || heldIds.has(u.id) || u.status === "held" && listing.mine_held === void 0) continue;
1634
+ const parent = u.parentId ? byId.get(u.parentId) : void 0;
1635
+ const node = localNode(u, u.status, parent);
1636
+ if (u.status === "held") addHeld(node, u.parentId, true);
1637
+ else if (parent) parent.kids.push(node);
1638
+ else if (newestOnTop) roots.unshift(node);
1639
+ else roots.push(node);
1640
+ byId.set(u.id, node);
1641
+ }
1326
1642
  return [...mine, ...roots];
1327
1643
  }
1644
+ var localNode = (c, status, parent) => ({
1645
+ id: c.id,
1646
+ depth: Math.min(4, (parent?.depth ?? 0) + 1),
1647
+ status,
1648
+ removedBy: void 0,
1649
+ mine: true,
1650
+ canEditUntil: void 0,
1651
+ likedByMe: false,
1652
+ name: c.name,
1653
+ createdAt: c.createdAt,
1654
+ editedAt: null,
1655
+ likes: 0,
1656
+ tree: void 0,
1657
+ text: c.text,
1658
+ kids: []
1659
+ });
1328
1660
 
1329
1661
  // src/react/comments-body.tsx
1330
1662
  var import_hast_util_to_jsx_runtime2 = require("hast-util-to-jsx-runtime");
1331
- var import_react2 = require("react");
1332
- var import_jsx_runtime4 = require("react/jsx-runtime");
1663
+ var import_react3 = require("react");
1333
1664
  var import_jsx_runtime5 = require("react/jsx-runtime");
1665
+ var import_jsx_runtime6 = require("react/jsx-runtime");
1334
1666
  var ALLOWED = /* @__PURE__ */ new Set(["p", "a", "em", "strong", "del", "code", "pre", "blockquote", "ul", "ol", "li", "br"]);
1335
1667
  var LINK_REL = "nofollow ugc noopener noreferrer";
1336
1668
  function narrow(node) {
@@ -1353,45 +1685,45 @@ function CommentBody({ tree }) {
1353
1685
  if (error instanceof HastLimitError) return null;
1354
1686
  throw error;
1355
1687
  }
1356
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "hyle-cm-body", children: (0, import_hast_util_to_jsx_runtime2.toJsxRuntime)({ type: "root", children }, { Fragment: import_react2.Fragment, jsx: import_jsx_runtime4.jsx, jsxs: import_jsx_runtime4.jsxs, elementAttributeNameCase: "react", stylePropertyNameCase: "dom" }) });
1688
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "hyle-cm-body", children: (0, import_hast_util_to_jsx_runtime2.toJsxRuntime)({ type: "root", children }, { Fragment: import_react3.Fragment, jsx: import_jsx_runtime5.jsx, jsxs: import_jsx_runtime5.jsxs, elementAttributeNameCase: "react", stylePropertyNameCase: "dom" }) });
1357
1689
  }
1358
1690
 
1359
1691
  // src/react/embed.tsx
1360
- var import_jsx_runtime6 = require("react/jsx-runtime");
1692
+ var import_jsx_runtime7 = require("react/jsx-runtime");
1361
1693
  function HyleListView({ items, layout = "list", title, headingLevel = 2, moreHref, olderHref, ...base }) {
1362
1694
  const c = ctx(base, "en");
1363
1695
  const { s, Link } = c;
1364
1696
  const Row = base.slots?.["list.item"];
1365
1697
  const Heading = `h${headingLevel}`;
1366
1698
  const safe = items.filter((item) => item.canonical_path.startsWith("/"));
1367
- if (safe.length === 0) return base.slots?.["list.empty"] ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "hyle hyle-embed", "data-layout": layout, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Slot, { name: "list.empty", slots: base.slots }) }) : null;
1368
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "hyle hyle-embed", "data-layout": layout, lang: c.locale, children: [
1369
- title ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Heading, { className: "hyle-title", children: title }) : null,
1370
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("ul", { className: "hyle-items", children: safe.map((item) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("li", { children: Row ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Row, { item, href: c.href(item.canonical_path), locale: c.locale }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(Link, { className: "hyle-item", href: c.href(item.canonical_path), children: [
1371
- item.published_at ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("time", { dateTime: item.published_at, title: item.published_at, children: formatDate(item.published_at, c.locale) }) : null,
1372
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { children: [
1373
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "t", children: item.title }),
1374
- item.description ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { children: item.description }) : null
1699
+ if (safe.length === 0) return base.slots?.["list.empty"] ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "hyle hyle-embed", "data-layout": layout, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Slot, { name: "list.empty", slots: base.slots }) }) : null;
1700
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "hyle hyle-embed", "data-layout": layout, lang: c.locale, children: [
1701
+ title ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Heading, { className: "hyle-title", children: title }) : null,
1702
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("ul", { className: "hyle-items", children: safe.map((item) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("li", { children: Row ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Row, { item, href: c.href(item.canonical_path), locale: c.locale }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Link, { className: "hyle-item", href: c.href(item.canonical_path), children: [
1703
+ item.published_at ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("time", { dateTime: item.published_at, title: item.published_at, children: formatDate(item.published_at, c.locale) }) : null,
1704
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { children: [
1705
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "t", children: item.title }),
1706
+ item.description ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("p", { children: item.description }) : null
1375
1707
  ] })
1376
1708
  ] }) }, item.canonical_path)) }),
1377
- olderHref ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(OlderNav, { href: olderHref, c }) : null,
1378
- moreHref ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("a", { className: "hyle-more", href: moreHref, children: s.viewAll }) : null
1709
+ olderHref ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(OlderNav, { href: olderHref, c }) : null,
1710
+ moreHref ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("a", { className: "hyle-more", href: moreHref, children: s.viewAll }) : null
1379
1711
  ] });
1380
1712
  }
1381
1713
  function HyleArticleView({ article, headingLevel = 2, ...base }) {
1382
1714
  const { publication: pub } = article;
1383
1715
  const c = ctx(base, pub.locale);
1384
1716
  const Heading = `h${headingLevel}`;
1385
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "hyle hyle-embed", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("article", { lang: c.locale, children: [
1386
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("header", { className: "hyle-head", children: [
1387
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Heading, { className: "hyle-title", children: pub.title }),
1388
- pub.description ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { className: "hyle-desc", children: pub.description }) : null,
1389
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "hyle-meta", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("time", { dateTime: pub.published_at, title: pub.published_at, children: formatDate(pub.published_at, c.locale) }) }) })
1717
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "hyle hyle-embed", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("article", { lang: c.locale, children: [
1718
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("header", { className: "hyle-head", children: [
1719
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Heading, { className: "hyle-title", children: pub.title }),
1720
+ pub.description ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("p", { className: "hyle-desc", children: pub.description }) : null,
1721
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "hyle-meta", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("time", { dateTime: pub.published_at, title: pub.published_at, children: formatDate(pub.published_at, c.locale) }) }) })
1390
1722
  ] }),
1391
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Body, { article, components: base.components, locale: c.locale }),
1392
- pub.canonical_path.startsWith("/") ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("a", { className: "hyle-more", href: c.href(pub.canonical_path, pub.locale), rel: "bookmark", children: [
1723
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Body, { article, components: base.components, locale: c.locale }),
1724
+ pub.canonical_path.startsWith("/") ? /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("a", { className: "hyle-more", href: c.href(pub.canonical_path, pub.locale), rel: "bookmark", children: [
1393
1725
  c.s.readAtSource,
1394
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { className: "hyle-sr", children: [
1726
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("span", { className: "hyle-sr", children: [
1395
1727
  ": ",
1396
1728
  pub.title
1397
1729
  ] })
@@ -1400,35 +1732,35 @@ function HyleArticleView({ article, headingLevel = 2, ...base }) {
1400
1732
  }
1401
1733
  var initials = (name) => name.trim().split(/\s+/).slice(0, 2).map((w) => [...w][0] ?? "").join("").toUpperCase() || "?";
1402
1734
  function StaticThread({ nodes, locale, s, level = 1 }) {
1403
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("ol", { className: "hyle-cm-list", role: "list", children: nodes.map((node) => {
1404
- const kids = node.kids.length > 0 && level < 32 ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(StaticThread, { nodes: node.kids, locale, s, level: level + 1 }) : null;
1735
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("ol", { className: "hyle-cm-list", role: "list", children: nodes.map((node) => {
1736
+ const kids = node.kids.length > 0 && level < 32 ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(StaticThread, { nodes: node.kids, locale, s, level: level + 1 }) : null;
1405
1737
  if (node.status === "removed") {
1406
1738
  const why = node.removedBy === "moderator" ? s.removedByModerator : node.removedBy === "author" ? s.removedByAuthor : s.removed;
1407
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("li", { className: "hyle-cm", "data-depth": node.depth, "data-status": "removed", "data-removed-by": node.removedBy, children: [
1408
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("article", { "aria-label": why, children: [
1409
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "hyle-avatar", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Icon, { name: "ban" }) }),
1410
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "hyle-cm-main", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "hyle-cm-body", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { children: why }) }) })
1739
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("li", { className: "hyle-cm", "data-depth": node.depth, "data-status": "removed", "data-removed-by": node.removedBy, children: [
1740
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("article", { "aria-label": why, children: [
1741
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "hyle-avatar", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Icon, { name: "ban" }) }),
1742
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "hyle-cm-main", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "hyle-cm-body", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("p", { children: why }) }) })
1411
1743
  ] }),
1412
1744
  kids
1413
1745
  ] }, node.id);
1414
1746
  }
1415
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("li", { className: "hyle-cm", "data-depth": node.depth, "data-status": "visible", children: [
1416
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("article", { children: [
1417
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "hyle-avatar", "aria-hidden": "true", children: initials(node.name ?? "") }),
1418
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "hyle-cm-main", children: [
1419
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "hyle-cm-by", children: [
1420
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("b", { children: node.name }),
1421
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { children: [
1422
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("time", { dateTime: node.createdAt, title: node.createdAt, children: formatDate(node.createdAt, locale) }),
1423
- node.editedAt ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
1747
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("li", { className: "hyle-cm", "data-depth": node.depth, "data-status": "visible", children: [
1748
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("article", { children: [
1749
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "hyle-avatar", "aria-hidden": "true", children: initials(node.name ?? "") }),
1750
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "hyle-cm-main", children: [
1751
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "hyle-cm-by", children: [
1752
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("b", { children: node.name }),
1753
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("span", { children: [
1754
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("time", { dateTime: node.createdAt, title: node.createdAt, children: formatDate(node.createdAt, locale) }),
1755
+ node.editedAt ? /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
1424
1756
  " ",
1425
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { "aria-hidden": "true", children: "\xB7" }),
1757
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { "aria-hidden": "true", children: "\xB7" }),
1426
1758
  " ",
1427
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: s.edited })
1759
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { children: s.edited })
1428
1760
  ] }) : null
1429
1761
  ] })
1430
1762
  ] }),
1431
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(CommentBody, { tree: node.tree })
1763
+ node.unrenderable ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "hyle-cm-body", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("p", { children: s.unrenderable }) }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(CommentBody, { tree: node.tree })
1432
1764
  ] })
1433
1765
  ] }),
1434
1766
  kids
@@ -1439,26 +1771,26 @@ function HyleCommentsView({ listing, locale }) {
1439
1771
  const thread = buildThread(listing, []);
1440
1772
  if (thread.length === 0) return null;
1441
1773
  const s = stringsFor(locale).comments;
1442
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "hyle hyle-embed", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("section", { className: "hyle-comments", "aria-label": s.heading, "data-slot-component": "Comments", lang: locale, children: [
1443
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "hyle-cm-head", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("h2", { children: [
1774
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "hyle hyle-embed", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("section", { className: "hyle-comments", "aria-label": s.heading, "data-slot-component": "Comments", lang: locale, children: [
1775
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "hyle-cm-head", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("h2", { children: [
1444
1776
  s.heading,
1445
1777
  " ",
1446
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "hyle-cm-count", "aria-label": s.countLabel.replace("{n}", String(listing.comment_count)), children: listing.comment_count })
1778
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "hyle-cm-count", "aria-label": s.countLabel.replace("{n}", String(listing.comment_count)), children: listing.comment_count })
1447
1779
  ] }) }),
1448
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(StaticThread, { nodes: thread, locale, s }),
1449
- listing.truncated ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { className: "hyle-cm-note", children: s.truncated }) : null
1780
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(StaticThread, { nodes: thread, locale, s }),
1781
+ listing.truncated ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("p", { className: "hyle-cm-note", children: s.truncated }) : null
1450
1782
  ] }) });
1451
1783
  }
1452
1784
  function HyleCommentsFallback({ locale }) {
1453
1785
  const s = stringsFor(locale).comments;
1454
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "hyle hyle-embed", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("section", { className: "hyle-comments", "aria-label": s.heading, "data-slot-component": "Comments", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { role: "status", "aria-live": "polite", "aria-busy": "true", children: [
1455
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "hyle-sr", children: s.loading }),
1456
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { "aria-hidden": "true", children: [0, 1, 2].map((i) => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "hyle-cm-sk", children: [
1457
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "hyle-sk c" }),
1458
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { children: [
1459
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "hyle-sk l", style: { width: 120 } }),
1460
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "hyle-sk l", style: { width: "100%" } }),
1461
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "hyle-sk l", style: { width: "72%" } })
1786
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "hyle hyle-embed", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("section", { className: "hyle-comments", "aria-label": s.heading, "data-slot-component": "Comments", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { role: "status", "aria-live": "polite", "aria-busy": "true", children: [
1787
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "hyle-sr", children: s.loading }),
1788
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { "aria-hidden": "true", children: [0, 1, 2].map((i) => /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "hyle-cm-sk", children: [
1789
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "hyle-sk c" }),
1790
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { children: [
1791
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "hyle-sk l", style: { width: 120 } }),
1792
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "hyle-sk l", style: { width: "100%" } }),
1793
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "hyle-sk l", style: { width: "72%" } })
1462
1794
  ] })
1463
1795
  ] }, i)) })
1464
1796
  ] }) }) });
@@ -1588,13 +1920,14 @@ function listJsonLd({ list, origin, href, path, locale, description, jsonLd, cur
1588
1920
  }
1589
1921
 
1590
1922
  // src/react/pages.tsx
1591
- var import_jsx_runtime7 = require("react/jsx-runtime");
1923
+ var import_toc_spy = require("./toc-spy.cjs");
1924
+ var import_jsx_runtime8 = require("react/jsx-runtime");
1592
1925
  function Slot({ name, slots, tag: Tag = "div", className }) {
1593
1926
  const fill = slots?.[name];
1594
- return fill ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Tag, { "data-slot": name, className, children: fill }) : null;
1927
+ return fill ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Tag, { "data-slot": name, className, children: fill }) : null;
1595
1928
  }
1596
1929
  function Shell({ children }) {
1597
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "hyle", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "hyle-page", children }) });
1930
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "hyle", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "hyle-page", children }) });
1598
1931
  }
1599
1932
  function ctx(p, fallbackLocale) {
1600
1933
  const locale = p.locale ?? fallbackLocale;
@@ -1603,29 +1936,29 @@ function ctx(p, fallbackLocale) {
1603
1936
  function Pager({ prev, next, c }) {
1604
1937
  if (!prev && !next) return null;
1605
1938
  const { Link, s } = c;
1606
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("nav", { className: "hyle-pager", "aria-label": s.pager, children: [
1607
- prev ? /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Link, { href: c.href(prev.canonical_path), rel: "prev", children: [
1608
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("span", { className: "dir", children: [
1609
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Icon, { name: "chev-left" }),
1939
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("nav", { className: "hyle-pager", "aria-label": s.pager, children: [
1940
+ prev ? /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(Link, { href: c.href(prev.canonical_path), rel: "prev", children: [
1941
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("span", { className: "dir", children: [
1942
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Icon, { name: "chev-left" }),
1610
1943
  s.prev
1611
1944
  ] }),
1612
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "ttl", children: prev.title })
1613
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "none", "aria-hidden": "true" }),
1614
- next ? /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Link, { href: c.href(next.canonical_path), rel: "next", className: "next", children: [
1615
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("span", { className: "dir", children: [
1945
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "ttl", children: prev.title })
1946
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "none", "aria-hidden": "true" }),
1947
+ next ? /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(Link, { href: c.href(next.canonical_path), rel: "next", className: "next", children: [
1948
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("span", { className: "dir", children: [
1616
1949
  s.next,
1617
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Icon, { name: "chev" })
1950
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Icon, { name: "chev" })
1618
1951
  ] }),
1619
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "ttl", children: next.title })
1952
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "ttl", children: next.title })
1620
1953
  ] }) : null
1621
1954
  ] });
1622
1955
  }
1623
1956
  function OlderNav({ href, c }) {
1624
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("nav", { className: "hyle-pagination", "aria-label": c.s.pager, children: [
1625
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "sp" }),
1626
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(c.Link, { className: "hyle-btn sm", href, rel: "next", children: [
1957
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("nav", { className: "hyle-pagination", "aria-label": c.s.pager, children: [
1958
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "sp" }),
1959
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(c.Link, { className: "hyle-btn sm", href, rel: "next", children: [
1627
1960
  c.s.older,
1628
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Icon, { name: "chev" })
1961
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Icon, { name: "chev" })
1629
1962
  ] })
1630
1963
  ] });
1631
1964
  }
@@ -1636,54 +1969,60 @@ function TocList({ toc }) {
1636
1969
  if (entry.depth === 3 && last) last.subs.push(entry);
1637
1970
  else groups.push({ entry, subs: [] });
1638
1971
  }
1639
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("ul", { children: groups.map(({ entry, subs }) => /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("li", { children: [
1640
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("a", { href: `#${scopeId(entry.id)}`, children: entry.text }),
1641
- subs.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("ul", { children: subs.map((sub) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("a", { href: `#${scopeId(sub.id)}`, children: sub.text }) }, sub.id)) }) : null
1972
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("ul", { children: groups.map(({ entry, subs }) => /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("li", { children: [
1973
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("a", { href: `#${scopeId(entry.id)}`, children: entry.text }),
1974
+ subs.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("ul", { children: subs.map((sub) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("a", { href: `#${scopeId(sub.id)}`, children: sub.text }) }, sub.id)) }) : null
1642
1975
  ] }, entry.id)) });
1643
1976
  }
1644
- function Toc({ toc, c, aside }) {
1977
+ function Toc({ toc, c, aside, spy, className }) {
1645
1978
  const entries = toc.filter((t) => t.depth === 2 || t.depth === 3);
1646
1979
  if (entries.length === 0 && !aside) return { narrow: null, wide: null };
1647
1980
  const { s } = c;
1981
+ const classes = (own) => className ? `${className} ${own}` : own;
1648
1982
  return {
1649
- narrow: entries.length === 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("details", { className: "hyle-toc-m", children: [
1650
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("summary", { children: [
1651
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Icon, { name: "file" }),
1983
+ narrow: entries.length === 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("details", { className: classes("hyle-toc-m"), children: [
1984
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("summary", { children: [
1985
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Icon, { name: "file" }),
1652
1986
  s.toc,
1653
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Icon, { name: "chev-down", className: "hyle-chev" })
1987
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Icon, { name: "chev-down", className: "hyle-chev" })
1654
1988
  ] }),
1655
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("nav", { className: "hyle-toc-list", "aria-label": s.toc, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(TocList, { toc: entries }) })
1989
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("nav", { className: "hyle-toc-list", "aria-label": s.toc, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(TocList, { toc: entries }) })
1656
1990
  ] }),
1657
- wide: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("aside", { className: "hyle-toc-d", "aria-label": s.toc, children: [
1658
- entries.length === 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
1659
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("p", { className: "hyle-toc-title", children: s.toc }),
1660
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("nav", { className: "hyle-toc-list", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(TocList, { toc: entries }) })
1991
+ wide: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("aside", { className: classes("hyle-toc-d"), "aria-label": s.toc, children: [
1992
+ entries.length === 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
1993
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { className: "hyle-toc-title", children: s.toc }),
1994
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("nav", { className: "hyle-toc-list", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(TocList, { toc: entries }) })
1661
1995
  ] }),
1662
- aside
1996
+ aside,
1997
+ spy && entries.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_toc_spy.TocSpy, { ids: entries.map((t) => scopeId(t.id)) }) : null
1663
1998
  ] })
1664
1999
  };
1665
2000
  }
1666
2001
  function Body({ article, components, locale }) {
1667
2002
  const { content, publication } = article;
1668
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "hyle-body hyle-prose", lang: article.fallback ? void 0 : publication.locale, children: content.format === "hast" ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(HastContent, { tree: content.tree, title: publication.title, description: publication.description, components: components ?? {}, locale }) : content.format === "html" ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(TrustedServerHtml, { html: content.html }) : null });
2003
+ const lang = article.fallback ? void 0 : publication.locale;
2004
+ if (content.format === "hast") {
2005
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ProseBody, { className: "hyle-body hyle-prose", lang, tree: content.tree, title: publication.title, description: publication.description, components: components ?? {}, locale });
2006
+ }
2007
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "hyle-body hyle-prose", lang, children: content.format === "html" ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(TrustedServerHtml, { html: content.html }) : null });
1669
2008
  }
1670
2009
  function Languages({ alternates, current, c }) {
1671
2010
  if (alternates.length < 2) return null;
1672
2011
  const { Link, s } = c;
1673
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("nav", { className: "hyle-langs", "aria-label": s.languages, children: [
1674
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { children: s.readIn }),
1675
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("ul", { children: alternates.map((a) => {
2012
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("nav", { className: "hyle-langs", "aria-label": s.languages, children: [
2013
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { children: s.readIn }),
2014
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("ul", { children: alternates.map((a) => {
1676
2015
  const label = languageName(a.locale, a.locale);
1677
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("li", { children: a.locale === current ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("a", { href: c.href(a.canonical_path, a.locale), hrefLang: a.locale, lang: a.locale, "aria-current": "true", children: label }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Link, { href: c.href(a.canonical_path, a.locale), hrefLang: a.locale, lang: a.locale, children: label }) }, a.locale);
2016
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("li", { children: a.locale === current ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("a", { href: c.href(a.canonical_path, a.locale), hrefLang: a.locale, lang: a.locale, "aria-current": "true", children: label }) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Link, { href: c.href(a.canonical_path, a.locale), hrefLang: a.locale, lang: a.locale, children: label }) }, a.locale);
1678
2017
  }) })
1679
2018
  ] });
1680
2019
  }
1681
2020
  function LdScript({ json: json2 }) {
1682
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("script", { type: "application/ld+json", dangerouslySetInnerHTML: { __html: json2 } });
2021
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("script", { type: "application/ld+json", dangerouslySetInnerHTML: { __html: json2 } });
1683
2022
  }
1684
2023
  function Crumbs({ items, c }) {
1685
2024
  const { Link } = c;
1686
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("nav", { className: "hyle-crumbs", "aria-label": c.s.crumbs, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("ol", { children: items.map((b, i) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("li", { "aria-current": i === items.length - 1 ? "page" : void 0, children: i === items.length - 1 ? b.title : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Link, { href: crumbHref(c.href, b.canonical_path, c.locale), children: b.title }) }, b.canonical_path)) }) });
2025
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("nav", { className: "hyle-crumbs", "aria-label": c.s.crumbs, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("ol", { children: items.map((b, i) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("li", { "aria-current": i === items.length - 1 ? "page" : void 0, children: i === items.length - 1 ? b.title : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Link, { href: crumbHref(c.href, b.canonical_path, c.locale), children: b.title }) }, b.canonical_path)) }) });
1687
2026
  }
1688
2027
  function ArticlePage({ article, engagement, origin, jsonLd, imageUrl, imageWidth, imageHeight, related, ...base }) {
1689
2028
  const { publication: pub } = article;
@@ -1693,66 +2032,66 @@ function ArticlePage({ article, engagement, origin, jsonLd, imageUrl, imageWidth
1693
2032
  const author = articleAuthor(article, jsonLd)?.name;
1694
2033
  const modified = modifiedAt(pub);
1695
2034
  const words = wordCountOf(pub);
1696
- const toc = Toc({ toc: article.toc, c, aside: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Slot, { name: "article.aside", slots: base.slots, className: "hyle-slot-wrap" }) });
2035
+ const toc = Toc({ toc: article.toc, c, spy: true, aside: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Slot, { name: "article.aside", slots: base.slots, className: "hyle-slot-wrap" }) });
1697
2036
  const notTranslated = article.fallback ? s.fallbackTitle.replace("{language}", languageName(article.fallback.requested_locale, c.locale)) : void 0;
1698
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Shell, { children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("article", { className: "hyle-article", "data-hyle-page": "article", lang: c.locale, children: [
1699
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("header", { className: "hyle-head", children: [
1700
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Slot, { name: "article.before", slots: base.slots, className: "hyle-eyebrow" }),
1701
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Crumbs, { items: breadcrumbItems(article, jsonLd), c }),
1702
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("h1", { className: "hyle-title", children: pub.title }),
1703
- pub.description ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("p", { className: "hyle-desc", children: pub.description }) : null,
1704
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "hyle-meta", children: [
1705
- author ? /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("span", { children: [
1706
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "hyle-avatar", "aria-hidden": "true", children: author.slice(0, 2).toUpperCase() }),
1707
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("span", { children: [
1708
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("span", { className: "hyle-sr", children: [
2037
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Shell, { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("article", { className: "hyle-article", "data-hyle-page": "article", lang: c.locale, children: [
2038
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("header", { className: "hyle-head", children: [
2039
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Slot, { name: "article.before", slots: base.slots, className: "hyle-eyebrow" }),
2040
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Crumbs, { items: breadcrumbItems(article, jsonLd), c }),
2041
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("h1", { className: "hyle-title", children: pub.title }),
2042
+ pub.description ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { className: "hyle-desc", children: pub.description }) : null,
2043
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "hyle-meta", children: [
2044
+ author ? /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("span", { children: [
2045
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "hyle-avatar", "aria-hidden": "true", children: author.slice(0, 2).toUpperCase() }),
2046
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("span", { children: [
2047
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("span", { className: "hyle-sr", children: [
1709
2048
  s.by,
1710
2049
  " "
1711
2050
  ] }),
1712
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "by", children: author })
2051
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "by", children: author })
1713
2052
  ] })
1714
2053
  ] }) : null,
1715
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("span", { children: [
1716
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Icon, { name: "calendar" }),
1717
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("time", { dateTime: pub.published_at, title: pub.published_at, children: formatDate(pub.published_at, c.locale) })
2054
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("span", { children: [
2055
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Icon, { name: "calendar" }),
2056
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("time", { dateTime: pub.published_at, title: pub.published_at, children: formatDate(pub.published_at, c.locale) })
1718
2057
  ] }),
1719
- modified ? /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("span", { children: [
1720
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Icon, { name: "calendar" }),
2058
+ modified ? /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("span", { children: [
2059
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Icon, { name: "calendar" }),
1721
2060
  s.updated,
1722
2061
  " ",
1723
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("time", { dateTime: modified, title: modified, children: formatDate(modified, c.locale) })
2062
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("time", { dateTime: modified, title: modified, children: formatDate(modified, c.locale) })
1724
2063
  ] }) : null,
1725
- words ? /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("span", { children: [
1726
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Icon, { name: "clock" }),
2064
+ words ? /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("span", { children: [
2065
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Icon, { name: "clock" }),
1727
2066
  s.readingTime.replace("{n}", String(readingMinutes(words)))
1728
2067
  ] }) : null,
1729
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("span", { children: [
1730
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Icon, { name: "globe" }),
1731
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { lang: pub.locale, children: languageName(pub.locale, c.locale) })
2068
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("span", { children: [
2069
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Icon, { name: "globe" }),
2070
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { lang: pub.locale, children: languageName(pub.locale, c.locale) })
1732
2071
  ] }),
1733
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Slot, { name: "article.meta", slots: base.slots, tag: "span" })
2072
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Slot, { name: "article.meta", slots: base.slots, tag: "span" })
1734
2073
  ] }),
1735
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Languages, { alternates: article.alternates, current: pub.locale, c }),
1736
- notTranslated ? /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "hyle-banner", "data-kind": "warn", role: "status", children: [
1737
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Icon, { name: "alert" }),
1738
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { children: [
1739
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("b", { children: notTranslated }),
2074
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Languages, { alternates: article.alternates, current: pub.locale, c }),
2075
+ notTranslated ? /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "hyle-banner", "data-kind": "warn", role: "status", children: [
2076
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Icon, { name: "alert" }),
2077
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { children: [
2078
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("b", { children: notTranslated }),
1740
2079
  " ",
1741
2080
  s.fallbackBody
1742
2081
  ] })
1743
2082
  ] }) : null
1744
2083
  ] }),
1745
2084
  toc.narrow,
1746
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Body, { article, components: base.components, locale: c.locale }),
1747
- engagement ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_comments.Comments, { path: pub.canonical_path, endpoint: engagement.endpoint ?? "/api/hyle/engage", signInHref: engagement.signInHref, locale: c.locale, labels: s.comments }) : null,
1748
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Pager, { prev: article.prev, next: article.next, c }),
1749
- related ? /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
1750
- related.items.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(HyleListView, { items: related.items, title: related.title ?? s.moreInSection, ...base, locale: c.locale }) : null,
1751
- article.children.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(HyleListView, { items: article.children.map((child) => ({ ...child, description: null, published_at: "" })), title: s.subPages, ...base, locale: c.locale }) : null
2085
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Body, { article, components: base.components, locale: c.locale }),
2086
+ engagement ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_comments.Comments, { path: pub.canonical_path, endpoint: engagement.endpoint ?? "/api/hyle/engage", signInHref: engagement.signInHref, locale: c.locale, labels: s.comments }) : null,
2087
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Pager, { prev: article.prev, next: article.next, c }),
2088
+ related ? /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
2089
+ related.items.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(HyleListView, { items: related.items, title: related.title ?? s.moreInSection, ...base, locale: c.locale }) : null,
2090
+ article.children.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(HyleListView, { items: article.children.map((child) => ({ ...child, description: null, published_at: "" })), title: s.subPages, ...base, locale: c.locale }) : null
1752
2091
  ] }) : null,
1753
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Slot, { name: "article.after", slots: base.slots, className: "hyle-after" }),
2092
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Slot, { name: "article.after", slots: base.slots, className: "hyle-after" }),
1754
2093
  toc.wide,
1755
- jsonLdOrigin ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(LdScript, { json: articleJsonLd({ article, origin: jsonLdOrigin, href: c.href, jsonLd, imageUrl, imageWidth, imageHeight }) }) : null
2094
+ jsonLdOrigin ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(LdScript, { json: articleJsonLd({ article, origin: jsonLdOrigin, href: c.href, jsonLd, imageUrl, imageWidth, imageHeight }) }) : null
1756
2095
  ] }) });
1757
2096
  }
1758
2097
  function ListPage({ list, olderHref, description, origin, path, jsonLd, cursor, ...base }) {
@@ -1763,46 +2102,47 @@ function ListPage({ list, olderHref, description, origin, path, jsonLd, cursor,
1763
2102
  for (const item of list.items) groups.set(item.published_at.slice(0, 7), [...groups.get(item.published_at.slice(0, 7)) ?? [], item]);
1764
2103
  const notTranslated = list.fallback ? s.fallbackTitle.replace("{language}", languageName(list.fallback.requested_locale, c.locale)) : void 0;
1765
2104
  const jsonLdOrigin = bareOrigin(origin);
1766
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Shell, { children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "hyle-listpage", "data-hyle-page": "list", lang: c.locale, children: [
1767
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("header", { className: "hyle-head", children: [
1768
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("h1", { className: "hyle-title", children: list.section.title }),
1769
- description ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("p", { className: "hyle-desc", children: description }) : null,
1770
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Slot, { name: "list.header", slots: base.slots, className: "hyle-slot-wrap" }),
1771
- notTranslated ? /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "hyle-banner", "data-kind": "warn", role: "status", children: [
1772
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Icon, { name: "alert" }),
1773
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { children: [
1774
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("b", { children: notTranslated }),
2105
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Shell, { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "hyle-listpage", "data-hyle-page": "list", lang: c.locale, children: [
2106
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("header", { className: "hyle-head", children: [
2107
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("h1", { className: "hyle-title", children: list.section.title }),
2108
+ description ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { className: "hyle-desc", children: description }) : null,
2109
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Slot, { name: "list.header", slots: base.slots, className: "hyle-slot-wrap" }),
2110
+ notTranslated ? /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "hyle-banner", "data-kind": "warn", role: "status", children: [
2111
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Icon, { name: "alert" }),
2112
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { children: [
2113
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("b", { children: notTranslated }),
1775
2114
  " ",
1776
2115
  s.fallbackBody
1777
2116
  ] })
1778
2117
  ] }) : null
1779
2118
  ] }),
1780
- list.items.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "hyle-empty", "data-slot-state": "empty", children: [
1781
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Icon, { name: "file" }),
1782
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("h2", { children: s.emptyTitle }),
1783
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("p", { children: s.emptyBody }),
1784
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Slot, { name: "list.empty", slots: base.slots })
1785
- ] }) : [...groups].map(([month, items]) => /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("section", { "aria-label": formatDate(`${month}-01`, c.locale, { month: "long", year: "numeric" }), children: [
1786
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("h2", { className: "hyle-year", children: formatDate(`${month}-01`, c.locale, { month: "long", year: "numeric" }) }),
1787
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("ul", { className: "hyle-items", children: items.map((item) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("li", { children: Row ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Row, { item, href: c.href(item.canonical_path), locale: c.locale }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Link, { className: "hyle-item", href: c.href(item.canonical_path), children: [
1788
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("time", { dateTime: item.published_at, title: item.published_at, children: formatDate(item.published_at, c.locale) }),
1789
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { children: [
1790
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "t", children: item.title }),
1791
- item.description ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("p", { children: item.description }) : null
2119
+ list.items.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "hyle-empty", "data-slot-state": "empty", children: [
2120
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Icon, { name: "file" }),
2121
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("h2", { children: s.emptyTitle }),
2122
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { children: s.emptyBody }),
2123
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Slot, { name: "list.empty", slots: base.slots })
2124
+ ] }) : [...groups].map(([month, items]) => /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("section", { "aria-label": formatDate(`${month}-01`, c.locale, { month: "long", year: "numeric" }), children: [
2125
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("h2", { className: "hyle-year", children: formatDate(`${month}-01`, c.locale, { month: "long", year: "numeric" }) }),
2126
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("ul", { className: "hyle-items", children: items.map((item) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("li", { children: Row ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Row, { item, href: c.href(item.canonical_path), locale: c.locale }) : /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(Link, { className: "hyle-item", href: c.href(item.canonical_path), children: [
2127
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("time", { dateTime: item.published_at, title: item.published_at, children: formatDate(item.published_at, c.locale) }),
2128
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { children: [
2129
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "t", children: item.title }),
2130
+ item.description ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { children: item.description }) : null
1792
2131
  ] })
1793
2132
  ] }) }, item.canonical_path)) })
1794
2133
  ] }, month)),
1795
- olderHref ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(OlderNav, { href: olderHref, c }) : null,
1796
- jsonLdOrigin && path ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(LdScript, { json: listJsonLd({ list, origin: jsonLdOrigin, href: c.href, path, locale: c.locale, description, jsonLd, cursor }) }) : null
2134
+ olderHref ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(OlderNav, { href: olderHref, c }) : null,
2135
+ jsonLdOrigin && path ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(LdScript, { json: listJsonLd({ list, origin: jsonLdOrigin, href: c.href, path, locale: c.locale, description, jsonLd, cursor }) }) : null
1797
2136
  ] }) });
1798
2137
  }
1799
2138
 
1800
2139
  // src/react/index.ts
1801
2140
  var import_comments2 = require("./comments.cjs");
2141
+ var import_reactions = require("./reactions.cjs");
1802
2142
 
1803
2143
  // src/react/docs.tsx
1804
2144
  var import_docs_enhance = require("./docs-enhance.cjs");
1805
- var import_jsx_runtime8 = require("react/jsx-runtime");
2145
+ var import_jsx_runtime9 = require("react/jsx-runtime");
1806
2146
  var ROOT_ID = "hyle-docs";
1807
2147
  var NAV_ID = "hyle-docs-nav";
1808
2148
  function navTreeOf(article) {
@@ -1826,15 +2166,15 @@ function pathTo(nodes, path) {
1826
2166
  }
1827
2167
  function Branch({ nodes, current, onPath, c }) {
1828
2168
  const { Link } = c;
1829
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("ul", { children: nodes.map((node) => {
1830
- const link = /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Link, { href: c.href(node.canonical_path), ...node.canonical_path === current ? { "aria-current": "page" } : {}, children: node.title });
1831
- if (node.children.length === 0) return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("li", { children: link }, node.canonical_path);
1832
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("details", { ...onPath.has(node.canonical_path) ? { open: true } : {}, children: [
1833
- /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("summary", { children: [
1834
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Icon, { name: "chev" }),
2169
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("ul", { children: nodes.map((node) => {
2170
+ const link = /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Link, { href: c.href(node.canonical_path), ...node.canonical_path === current ? { "aria-current": "page" } : {}, children: node.title });
2171
+ if (node.children.length === 0) return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("li", { children: link }, node.canonical_path);
2172
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("details", { ...onPath.has(node.canonical_path) ? { open: true } : {}, children: [
2173
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("summary", { children: [
2174
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Icon, { name: "chev" }),
1835
2175
  link
1836
2176
  ] }),
1837
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Branch, { nodes: node.children, current, onPath, c })
2177
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Branch, { nodes: node.children, current, onPath, c })
1838
2178
  ] }) }, node.canonical_path);
1839
2179
  }) });
1840
2180
  }
@@ -1848,47 +2188,47 @@ function DocsPage({ article, ...base }) {
1848
2188
  const siteName = article.breadcrumbs[0]?.title ?? "";
1849
2189
  const headingIds = article.toc.filter((t) => t.depth === 2 || t.depth === 3).map((t) => scopeId(t.id));
1850
2190
  const notTranslated = article.fallback ? s.fallbackTitle.replace("{language}", languageName(article.fallback.requested_locale, c.locale)) : void 0;
1851
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Shell, { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "hyle-docs", id: ROOT_ID, lang: c.locale, children: [
1852
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_docs_enhance.DocsEnhance, { headingIds, rootId: ROOT_ID }),
1853
- /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("button", { type: "button", className: "hyle-nav-bar", popoverTarget: NAV_ID, children: [
1854
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Icon, { name: "file" }),
2191
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Shell, { children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "hyle-docs", id: ROOT_ID, lang: c.locale, children: [
2192
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_docs_enhance.DocsEnhance, { headingIds, rootId: ROOT_ID }),
2193
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("button", { type: "button", className: "hyle-nav-bar", popoverTarget: NAV_ID, children: [
2194
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Icon, { name: "file" }),
1855
2195
  s.menu,
1856
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "cur", children: pub.title }),
1857
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Icon, { name: "chev-down", className: "hyle-chev" })
2196
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "cur", children: pub.title }),
2197
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Icon, { name: "chev-down", className: "hyle-chev" })
1858
2198
  ] }),
1859
- /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("aside", { className: "hyle-nav-d", id: NAV_ID, popover: "auto", "aria-label": s.docs, children: [
1860
- /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "hyle-side-head", children: [
1861
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("b", { children: siteName }),
1862
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Slot, { name: "docs.version", slots: base.slots, tag: "span" }),
1863
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("button", { type: "button", className: "hyle-nav-x", popoverTarget: NAV_ID, popoverTargetAction: "hide", "aria-label": s.closeMenu, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Icon, { name: "x" }) })
2199
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("aside", { className: "hyle-nav-d", id: NAV_ID, popover: "auto", "aria-label": s.docs, children: [
2200
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "hyle-side-head", children: [
2201
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("b", { children: siteName }),
2202
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Slot, { name: "docs.version", slots: base.slots, tag: "span" }),
2203
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("button", { type: "button", className: "hyle-nav-x", popoverTarget: NAV_ID, popoverTargetAction: "hide", "aria-label": s.closeMenu, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Icon, { name: "x" }) })
1864
2204
  ] }),
1865
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Slot, { name: "docs.sidebar-header", slots: base.slots, className: "hyle-side-slot" }),
1866
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("nav", { className: "hyle-tree", "aria-label": s.docs, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Branch, { nodes: tree, current: pub.canonical_path, onPath, c }) }),
1867
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Slot, { name: "docs.sidebar-footer", slots: base.slots, className: "hyle-side-slot" })
2205
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Slot, { name: "docs.sidebar-header", slots: base.slots, className: "hyle-side-slot" }),
2206
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("nav", { className: "hyle-tree", "aria-label": s.docs, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Branch, { nodes: tree, current: pub.canonical_path, onPath, c }) }),
2207
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Slot, { name: "docs.sidebar-footer", slots: base.slots, className: "hyle-side-slot" })
1868
2208
  ] }),
1869
- /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "hyle-docs-main", "data-hyle-page": "docs", children: [
1870
- notTranslated ? /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "hyle-banner", "data-kind": "warn", role: "status", children: [
1871
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Icon, { name: "alert" }),
1872
- /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { children: [
1873
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("b", { children: notTranslated }),
2209
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "hyle-docs-main", "data-hyle-page": "docs", children: [
2210
+ notTranslated ? /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "hyle-banner", "data-kind": "warn", role: "status", children: [
2211
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Icon, { name: "alert" }),
2212
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
2213
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("b", { children: notTranslated }),
1874
2214
  " ",
1875
2215
  s.fallbackBody
1876
2216
  ] })
1877
2217
  ] }) : null,
1878
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("nav", { className: "hyle-crumbs", "aria-label": s.crumbs, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("ol", { children: article.breadcrumbs.map((b, i) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("li", { "aria-current": i === article.breadcrumbs.length - 1 ? "page" : void 0, children: i === article.breadcrumbs.length - 1 ? b.title : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Link, { href: c.href(b.canonical_path), children: b.title }) }, b.canonical_path)) }) }),
1879
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("h1", { className: "hyle-title", children: pub.title }),
1880
- pub.description ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { className: "hyle-desc", children: pub.description }) : null,
1881
- /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("p", { className: "hyle-updated", children: [
1882
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Icon, { name: "calendar" }),
2218
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("nav", { className: "hyle-crumbs", "aria-label": s.crumbs, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("ol", { children: article.breadcrumbs.map((b, i) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("li", { "aria-current": i === article.breadcrumbs.length - 1 ? "page" : void 0, children: i === article.breadcrumbs.length - 1 ? b.title : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Link, { href: c.href(b.canonical_path), children: b.title }) }, b.canonical_path)) }) }),
2219
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("h1", { className: "hyle-title", children: pub.title }),
2220
+ pub.description ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { className: "hyle-desc", children: pub.description }) : null,
2221
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("p", { className: "hyle-updated", children: [
2222
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Icon, { name: "calendar" }),
1883
2223
  s.updated,
1884
2224
  " ",
1885
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("time", { dateTime: pub.updated_at, title: pub.updated_at, children: formatDate(pub.updated_at, c.locale) })
2225
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("time", { dateTime: pub.updated_at, title: pub.updated_at, children: formatDate(pub.updated_at, c.locale) })
1886
2226
  ] }),
1887
2227
  toc.narrow,
1888
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Body, { article, components: base.components, locale: c.locale }),
1889
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Pager, { prev: article.prev, next: article.next, c }),
1890
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Slot, { name: "docs.after", slots: base.slots, className: "hyle-after" }),
1891
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "hyle-docs-end", "aria-hidden": "true" })
2228
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Body, { article, components: base.components, locale: c.locale }),
2229
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Pager, { prev: article.prev, next: article.next, c }),
2230
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Slot, { name: "docs.after", slots: base.slots, className: "hyle-after" }),
2231
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "hyle-docs-end", "aria-hidden": "true" })
1892
2232
  ] }),
1893
2233
  toc.wide
1894
2234
  ] }) });
@@ -1928,7 +2268,7 @@ function safeRedirectTarget(to) {
1928
2268
  }
1929
2269
 
1930
2270
  // src/next/resolve.ts
1931
- var DEFAULT_REVALIDATE = 300;
2271
+ var DEFAULT_REVALIDATE = 86400;
1932
2272
  var MAX_TAGS2 = 64;
1933
2273
  function workspaceTags(workspaceId, sections = []) {
1934
2274
  const workspaceTag = `hyle:1:ws:${workspaceId}`;
@@ -1987,6 +2327,7 @@ function isRejectedRequest(error) {
1987
2327
  var import_navigation2 = require("next/navigation");
1988
2328
 
1989
2329
  // src/next/engage.ts
2330
+ var import_node_crypto3 = require("crypto");
1990
2331
  var ENGAGE_CSRF_HEADER = "x-hyle-engage";
1991
2332
  var DEFAULT_TIMEOUT_MS2 = 1e4;
1992
2333
  var DEFAULT_SHARE_MS = 3e3;
@@ -2020,9 +2361,8 @@ function match(segments) {
2020
2361
  methods: ["GET", "POST"],
2021
2362
  rebuild: (method, body, url) => {
2022
2363
  if (method === "GET") {
2023
- const keys = [...url.searchParams.keys()];
2024
- const path = url.searchParams.get("path");
2025
- return keys.length === 1 && isSitePath2(path) ? { upstream: "/comments", query: new URLSearchParams({ path }) } : void 0;
2364
+ const query = listingQuery(url.searchParams);
2365
+ return query && { upstream: "/comments", query };
2026
2366
  }
2027
2367
  const clean2 = pick(body, ["path", "body", "parent_id"], ["path", "body"]);
2028
2368
  if (!clean2 || !isSitePath2(clean2.path) || !isCommentText(clean2.body)) return void 0;
@@ -2049,15 +2389,38 @@ function match(segments) {
2049
2389
  methods: ["PUT", "DELETE"],
2050
2390
  rebuild: (_method, body) => {
2051
2391
  const type = body?.subject_type;
2052
- const clean2 = type === "article" ? pick(body, ["subject_type", "path"], ["subject_type", "path"]) : type === "comment" ? pick(body, ["subject_type", "comment_id"], ["subject_type", "comment_id"]) : void 0;
2053
- if (!clean2) return void 0;
2392
+ const subject = type === "article" ? "path" : type === "comment" ? "comment_id" : void 0;
2393
+ const clean2 = subject && pick(body, ["subject_type", subject, "kind"], ["subject_type", subject]);
2394
+ if (!clean2 || clean2.kind !== void 0 && !REACTION_KINDS.includes(clean2.kind)) return void 0;
2054
2395
  const valid = type === "article" ? isSitePath2(clean2.path) : typeof clean2.comment_id === "string" && UUID2.test(clean2.comment_id);
2055
2396
  return valid ? { upstream: "/reactions", body: clean2 } : void 0;
2056
2397
  }
2057
2398
  };
2058
2399
  }
2400
+ if (a === "votes" && b === void 0) {
2401
+ return {
2402
+ action: (m) => m === "PUT" ? "votes.set" : "votes.remove",
2403
+ methods: ["PUT", "DELETE"],
2404
+ rebuild: (method, body) => {
2405
+ const keys = method === "PUT" ? ["comment_id", "value"] : ["comment_id"];
2406
+ const clean2 = pick(body, keys, keys);
2407
+ if (!clean2 || typeof clean2.comment_id !== "string" || !UUID2.test(clean2.comment_id)) return void 0;
2408
+ if (method === "PUT" && clean2.value !== 1 && clean2.value !== -1) return void 0;
2409
+ return { upstream: "/votes", body: clean2 };
2410
+ }
2411
+ };
2412
+ }
2059
2413
  return void 0;
2060
2414
  }
2415
+ function listingQuery(params) {
2416
+ const keys = [...params.keys()];
2417
+ if (new Set(keys).size !== keys.length || keys.some((k) => k !== "path" && k !== "cursor" && k !== "sort")) return void 0;
2418
+ const path = params.get("path");
2419
+ const cursor = params.get("cursor");
2420
+ const sort = params.get("sort");
2421
+ if (!isSitePath2(path) || cursor !== null && !isCursor(cursor) || sort !== null && sort !== "new" && sort !== "top") return void 0;
2422
+ return new URLSearchParams({ path, ...cursor === null ? {} : { cursor }, ...sort === null ? {} : { sort } });
2423
+ }
2061
2424
  function pick(body, allowed, required) {
2062
2425
  if (!body || Object.keys(body).some((k) => !allowed.includes(k)) || !required.every((k) => k in body)) return void 0;
2063
2426
  return Object.fromEntries(allowed.filter((k) => k in body).map((k) => [k, body[k]]));
@@ -2166,7 +2529,7 @@ function createEngagementRoute(options) {
2166
2529
  entry.result.then(
2167
2530
  (o) => {
2168
2531
  if (cache.get(key) !== entry) return;
2169
- if (o.status !== 200 && o.status !== 404 || o.noShare || o.text.length > MAX_SHARED_ENTRY_BYTES) return forget(key, entry);
2532
+ if (![200, 400, 404].includes(o.status) || o.noShare || o.text.length > MAX_SHARED_ENTRY_BYTES) return forget(key, entry);
2170
2533
  entry.bytes = o.text.length;
2171
2534
  cacheBytes += entry.bytes;
2172
2535
  while ((cacheBytes > MAX_SHARED_BYTES || cache.size > MAX_SHARED) && cache.size > 0) {
@@ -2229,7 +2592,7 @@ function createEngagementRoute(options) {
2229
2592
  }
2230
2593
  if (route.local === "session") {
2231
2594
  const who = await reader(req, config);
2232
- return json(200, { data: { reader: who ? { name: who.reader.name } : null } });
2595
+ return json(200, { data: { reader: who ? { id: (0, import_node_crypto3.createHash)("sha256").update(who.reader.sub).digest("base64url"), name: who.reader.name } : null } });
2233
2596
  }
2234
2597
  let assertion;
2235
2598
  let viewer = null;
@@ -2275,7 +2638,7 @@ ${built.query.toString()}`, () => listing(viewer, call)) : await call();
2275
2638
  }
2276
2639
 
2277
2640
  // src/next/embed.tsx
2278
- var import_jsx_runtime9 = require("react/jsx-runtime");
2641
+ var import_jsx_runtime10 = require("react/jsx-runtime");
2279
2642
  async function resolveEmbed(options, run) {
2280
2643
  try {
2281
2644
  return { result: await run() };
@@ -2293,7 +2656,7 @@ async function HyleList({ options, limit = 5, locale, layout, title, headingLeve
2293
2656
  const { result, failure } = await resolveEmbed(options, () => resolve(path, route.locale, limit, validCursor(cursor)));
2294
2657
  if (failure !== void 0) return failure;
2295
2658
  const next = olderHref && result?.kind === "list" ? validCursor(result.next_cursor) : void 0;
2296
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(HyleListView, { items: result?.kind === "list" ? result.items : [], layout, title, headingLevel, moreHref, olderHref: next ? olderHref?.(next) : void 0, components: options.components, slots: options.slots, locale: route.locale, toHref: route.toHref });
2659
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(HyleListView, { items: result?.kind === "list" ? result.items : [], layout, title, headingLevel, moreHref, olderHref: next ? olderHref?.(next) : void 0, components: options.components, slots: options.slots, locale: route.locale, toHref: route.toHref });
2297
2660
  }
2298
2661
  async function HyleArticle({ options, path, locale, headingLevel }) {
2299
2662
  if (!isSitePath2(path)) return null;
@@ -2302,7 +2665,7 @@ async function HyleArticle({ options, path, locale, headingLevel }) {
2302
2665
  const { result, failure } = await resolveEmbed(options, () => resolve(path, route.locale));
2303
2666
  if (failure !== void 0) return failure;
2304
2667
  if (result?.kind !== "article") return null;
2305
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(HyleArticleView, { article: result, headingLevel, components: options.components, slots: options.slots, locale: route.locale, toHref: route.toHref });
2668
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(HyleArticleView, { article: result, headingLevel, components: options.components, slots: options.slots, locale: route.locale, toHref: route.toHref });
2306
2669
  }
2307
2670
  var MAX_LISTING_BYTES = 4 * 1024 * 1024;
2308
2671
  var COMMENTS_TIMEOUT_MS = 1e4;
@@ -2334,13 +2697,13 @@ async function HyleComments({ options, path, revalidate = 60, interactive }) {
2334
2697
  return null;
2335
2698
  }
2336
2699
  if (!listing) return null;
2337
- if (!interactive) return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(HyleCommentsView, { listing, locale });
2700
+ if (!interactive) return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(HyleCommentsView, { listing, locale });
2338
2701
  const config = interactive === true ? {} : interactive;
2339
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "hyle hyle-embed", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_comments2.Comments, { path, endpoint: config.endpoint ?? "/api/hyle/engage", signInHref: config.signInHref, locale, labels: stringsFor(locale).comments, initial: listing, initialAt: fetchedAt }) });
2702
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "hyle hyle-embed", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_comments2.Comments, { path, endpoint: config.endpoint ?? "/api/hyle/engage", signInHref: config.signInHref, locale, labels: stringsFor(locale).comments, initial: listing, initialAt: fetchedAt }) });
2340
2703
  }
2341
2704
 
2342
2705
  // src/next/page.tsx
2343
- var import_jsx_runtime10 = require("react/jsx-runtime");
2706
+ var import_jsx_runtime11 = require("react/jsx-runtime");
2344
2707
  function hylePage(options) {
2345
2708
  const resolve = resolverFor(options);
2346
2709
  async function relatedItems(article) {
@@ -2361,13 +2724,13 @@ function hylePage(options) {
2361
2724
  const image = articleImage(options, result);
2362
2725
  const related = options.related && options.layout !== "docs" ? await relatedItems(result) : void 0;
2363
2726
  const props = { article: result, components: options.components, slots: options.slots, locale, toHref };
2364
- return options.layout === "docs" ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(DocsPage, { ...props }) : /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(ArticlePage, { ...props, origin: options.siteOrigin, jsonLd: options.jsonLd, imageUrl: image?.url, imageWidth: image?.width, imageHeight: image?.height, related, ...options.engagement ? { engagement: options.engagement } : {} });
2727
+ return options.layout === "docs" ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(DocsPage, { ...props }) : /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(ArticlePage, { ...props, origin: options.siteOrigin, jsonLd: options.jsonLd, imageUrl: image?.url, imageWidth: image?.width, imageHeight: image?.height, related, ...options.engagement ? { engagement: options.engagement } : {} });
2365
2728
  }
2366
2729
  case "list": {
2367
2730
  const list = options.list?.title ? { ...result, section: { ...result.section, title: options.list.title } } : result;
2368
2731
  const next = options.paginate === "searchParams" ? validCursor(result.next_cursor) : void 0;
2369
2732
  const olderHref = next ? `${toHref(path)}?cursor=${next}` : void 0;
2370
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(ListPage, { list, ...olderHref ? { olderHref } : {}, ...options.list?.description ? { description: options.list.description } : {}, components: options.components, slots: options.slots, locale, toHref, origin: options.siteOrigin, path, jsonLd: options.jsonLd, cursor });
2733
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(ListPage, { list, ...olderHref ? { olderHref } : {}, ...options.list?.description ? { description: options.list.description } : {}, components: options.components, slots: options.slots, locale, toHref, origin: options.siteOrigin, path, jsonLd: options.jsonLd, cursor });
2371
2734
  }
2372
2735
  case "redirect": {
2373
2736
  const to = safeRedirectTarget(result.to);
@@ -2622,7 +2985,7 @@ function createRevalidateRoute(options) {
2622
2985
  if (!workspaceId || secrets.length === 0) return new Response(null, { status: 503 });
2623
2986
  const key = `${workspaceId}\0${secrets.join("\0")}`;
2624
2987
  if (cached?.key !== key) {
2625
- cached = { key, route: createRevalidationCallbackRoute({ workspaceId, secrets, revalidateTag: (tag2) => (0, import_cache.revalidateTag)(tag2, { expire: 0 }) }) };
2988
+ cached = { key, route: createRevalidationCallbackRoute({ workspaceId, secrets, revalidateTag: (tag2) => (0, import_cache.revalidateTag)(tag2, { expire: 0 }), onCommentEvent: options.onCommentEvent }) };
2626
2989
  }
2627
2990
  return cached.route.POST(req);
2628
2991
  }
@@ -2932,7 +3295,7 @@ function createAssetRoute(options) {
2932
3295
  }
2933
3296
 
2934
3297
  // src/next/og.tsx
2935
- var import_jsx_runtime11 = require("react/jsx-runtime");
3298
+ var import_jsx_runtime12 = require("react/jsx-runtime");
2936
3299
  var SIZE = { width: 1200, height: 630 };
2937
3300
  var MAX_TITLE = 140;
2938
3301
  function createOgImageRoute(options) {
@@ -2962,9 +3325,9 @@ function createOgImageRoute(options) {
2962
3325
  const chars = [...title];
2963
3326
  const shown = chars.length > MAX_TITLE ? `${chars.slice(0, MAX_TITLE - 1).join("")}\u2026` : title;
2964
3327
  return new import_og.ImageResponse(
2965
- /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { style: { display: "flex", flexDirection: "column", justifyContent: "space-between", width: "100%", height: "100%", padding: 80, background: "#111827", color: "#ffffff" }, children: [
2966
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { style: { fontSize: 64, fontWeight: 700, lineHeight: 1.2 }, children: shown }),
2967
- options.siteName ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { style: { fontSize: 32, color: "#9ca3af" }, children: options.siteName }) : null
3328
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { style: { display: "flex", flexDirection: "column", justifyContent: "space-between", width: "100%", height: "100%", padding: 80, background: "#111827", color: "#ffffff" }, children: [
3329
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { style: { fontSize: 64, fontWeight: 700, lineHeight: 1.2 }, children: shown }),
3330
+ options.siteName ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { style: { fontSize: 32, color: "#9ca3af" }, children: options.siteName }) : null
2968
3331
  ] }),
2969
3332
  // shortcut: @vercel/og fetches Google Fonts / emoji assets at render time for non-Latin titles and emoji (no switch to disable it), upgrade to a satori render with bundled fonts if a host needs zero egress.
2970
3333
  { ...SIZE, headers: { "cache-control": "public, max-age=3600, s-maxage=31536000, immutable" } }