@panphora/clayjs 1.22.0 → 1.23.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 (177) hide show
  1. package/dist/all.js +1 -1
  2. package/dist/clay-dom.js +1 -1
  3. package/dist/clay-events.js +1 -1
  4. package/dist/clay-internals.js +1 -1
  5. package/dist/clay-options.js +1 -1
  6. package/dist/clay-router.js +1 -1
  7. package/dist/clay-ui.js +1 -1
  8. package/dist/clay-utils.js +1 -1
  9. package/dist/clay.js +1 -1
  10. package/dist/clay.standalone.js +1228 -715
  11. package/dist/m/attrs/{save-freeze-MTFVVYV5.js → save-freeze-JZHKRQLR.js} +1 -1
  12. package/dist/m/{c-TV7JHSRL.js → c-24PMUJIV.js} +1 -1
  13. package/dist/m/{c-NBNRLZXO.js → c-2AYVYEI4.js} +1 -1
  14. package/dist/m/{c-VIW5X35H.js → c-2L6O5PDS.js} +1 -1
  15. package/dist/m/{c-FNIGX4FI.js → c-2RYOGUQM.js} +1 -1
  16. package/dist/m/{c-LDUNOR57.js → c-2Z22FCFK.js} +13 -25
  17. package/dist/m/{c-DKFSOJCV.js → c-2ZVOEU4M.js} +1 -1
  18. package/dist/m/{c-BJPZCWAV.js → c-37NAONZA.js} +1 -1
  19. package/dist/m/{c-CSNE5EIF.js → c-4PO3YGDC.js} +1 -1
  20. package/dist/m/{c-UWT4CXQ4.js → c-5OJ7YF2N.js} +1 -1
  21. package/dist/m/{c-CAWNFER6.js → c-5TIZ2I64.js} +1 -1
  22. package/dist/m/{c-ZO6VL2SC.js → c-5WMXEKFH.js} +1 -1
  23. package/dist/m/{c-4TWARTLS.js → c-6RDOKLN7.js} +1 -1
  24. package/dist/m/{c-6RC66MYY.js → c-6TYGD5AB.js} +1 -1
  25. package/dist/m/c-A4IP6MBC.js +1 -0
  26. package/dist/m/{c-ZAHTFCXQ.js → c-ALDVFPWL.js} +1 -1
  27. package/dist/m/{c-LV5MABYD.js → c-AYVGD6A6.js} +1 -1
  28. package/dist/m/{c-N33TPVTL.js → c-B6O7AJYG.js} +1 -1
  29. package/dist/m/{c-P3WATEDR.js → c-BCGWJYXW.js} +1 -1
  30. package/dist/m/{c-4OGEVKR3.js → c-BGKAT2FL.js} +1 -1
  31. package/dist/m/{c-N7Y52HJH.js → c-BXYSDKAN.js} +1 -1
  32. package/dist/m/c-CRPIDGXC.js +78 -0
  33. package/dist/m/c-CUMXGHVD.js +1 -0
  34. package/dist/m/{c-Q5KAQJAG.js → c-DTMZ3ZHI.js} +1 -1
  35. package/dist/m/{c-GY4ODHO2.js → c-ELYIIYRS.js} +1 -1
  36. package/dist/m/{c-67LGZ52V.js → c-FCSZ3DC5.js} +1 -1
  37. package/dist/m/{c-NLWEZYKJ.js → c-FQGHR32O.js} +1 -1
  38. package/dist/m/{c-PCEMXY2K.js → c-G4PWUDD5.js} +1 -1
  39. package/dist/m/{c-6KBKYLPO.js → c-G6COVIZB.js} +1 -1
  40. package/dist/m/c-GBTVCJXC.js +1 -0
  41. package/dist/m/c-GC2HICFJ.js +1 -0
  42. package/dist/m/{c-TMT5TL65.js → c-HCNWJE4A.js} +2 -2
  43. package/dist/m/{c-DZBZ57EE.js → c-JCOQVZYS.js} +1 -1
  44. package/dist/m/{c-FAXQU7MQ.js → c-JGHEACGK.js} +1 -1
  45. package/dist/m/{c-PWBJVHA4.js → c-JGLX6TBK.js} +1 -1
  46. package/dist/m/c-JNRKHYWO.js +1 -0
  47. package/dist/m/{c-6UEFPHHE.js → c-KDXIJEEF.js} +1 -1
  48. package/dist/m/{c-FMCPQ4VT.js → c-L4KMT7FO.js} +2 -2
  49. package/dist/m/{c-OI2BYWVV.js → c-LCYPMULG.js} +1 -1
  50. package/dist/m/{c-4RFZROCF.js → c-LIGQYZ7M.js} +4 -4
  51. package/dist/m/{c-QHVCUTJV.js → c-LKIWEPAV.js} +1 -1
  52. package/dist/m/{c-EDSPKYMA.js → c-LUXAB2XI.js} +1 -1
  53. package/dist/m/{c-DEAFCHDO.js → c-LWIDDWAR.js} +2 -2
  54. package/dist/m/c-MPSKIU2I.js +1 -0
  55. package/dist/m/{c-6PBXRWDX.js → c-NK33MMYF.js} +1 -1
  56. package/dist/m/{c-F5AER2ID.js → c-NQLWOHLH.js} +1 -1
  57. package/dist/m/{c-L7K5EXU2.js → c-NTHUTABN.js} +1 -1
  58. package/dist/m/{c-4PHDUV3H.js → c-NW54NHKE.js} +1 -1
  59. package/dist/m/{c-3AXJDL2P.js → c-OG6GFSUX.js} +1 -1
  60. package/dist/m/{c-MTQHWQC3.js → c-OKEGUICD.js} +1 -1
  61. package/dist/m/c-OPONJ2UK.js +128 -0
  62. package/dist/m/{c-LF6HNVPU.js → c-OWQWOGYI.js} +1 -1
  63. package/dist/m/{c-FDAXZ2PM.js → c-P6Q2ZTFQ.js} +1 -1
  64. package/dist/m/c-PKCCHJ5X.js +1 -0
  65. package/dist/m/c-PWJSJEJU.js +1 -0
  66. package/dist/m/{c-Z7RJANGO.js → c-PXLTUYZC.js} +1 -1
  67. package/dist/m/c-QEN6HZCA.js +1 -0
  68. package/dist/m/{c-26KVJS6J.js → c-QGAPG7OM.js} +1 -1
  69. package/dist/m/{c-HWR6GMGK.js → c-QIR5CAKM.js} +1 -1
  70. package/dist/m/{c-QJFYVCJO.js → c-QM5LXRDT.js} +1 -1
  71. package/dist/m/{c-MRURHLKV.js → c-QUGCKMWF.js} +1 -1
  72. package/dist/m/{c-KE33W4RE.js → c-QYYUVLVG.js} +1 -1
  73. package/dist/m/c-RO73MKKR.js +1 -0
  74. package/dist/m/c-SBCBXKOZ.js +26 -0
  75. package/dist/m/{c-XDVAZDUE.js → c-SGRIYOAJ.js} +1 -1
  76. package/dist/m/c-SKF5HL4I.js +4 -0
  77. package/dist/m/{c-IWTTOC2V.js → c-SRPC3VBE.js} +1 -1
  78. package/dist/m/{c-XZJ5IK6Q.js → c-T5NK2TVY.js} +1 -1
  79. package/dist/m/{c-VFES2BP5.js → c-TANBH7FI.js} +1 -1
  80. package/dist/m/{c-H6DXQEH2.js → c-THGQQDYY.js} +1 -1
  81. package/dist/m/{c-BV6FQQXM.js → c-TSBVMWAH.js} +1 -1
  82. package/dist/m/{c-QTC6VGA4.js → c-UD5JZTDL.js} +1 -1
  83. package/dist/m/{c-ZYEJLZEY.js → c-UDGEFWNU.js} +1 -1
  84. package/dist/m/{c-ZSCBEB7I.js → c-UHUNXWKN.js} +1 -1
  85. package/dist/m/{c-FWFJUU3T.js → c-VIRFF5HG.js} +1 -1
  86. package/dist/m/{c-GPTKI7AQ.js → c-VYJ7O4RI.js} +1 -1
  87. package/dist/m/{c-TUGVINJR.js → c-W5E5P2TZ.js} +1 -1
  88. package/dist/m/{c-WWE67K5Y.js → c-W7IPVCAA.js} +1 -1
  89. package/dist/m/{c-HAVGDXAL.js → c-WJ5DRBHT.js} +1 -1
  90. package/dist/m/{c-V2J5C5MT.js → c-WQZTI5P2.js} +1 -1
  91. package/dist/m/c-X5WC4PX5.js +1 -0
  92. package/dist/m/{c-ZKELCT4T.js → c-XCFQEWW6.js} +2 -2
  93. package/dist/m/c-XLQ3BDMM.js +1 -0
  94. package/dist/m/{c-FLBUYV3P.js → c-XX75FFNL.js} +1 -1
  95. package/dist/m/{c-JHJR5BQX.js → c-YK2L436K.js} +1 -1
  96. package/dist/m/{c-MEWUGR4D.js → c-YYMZWQLR.js} +1 -1
  97. package/dist/m/core/{admin-attrs-ZG7R5V3E.js → admin-attrs-U7IJNYBG.js} +1 -1
  98. package/dist/m/core/{autosave-GI3WNJYN.js → autosave-F5YQCKVL.js} +1 -1
  99. package/dist/m/core/{conflict-notice-CEI3XY6A.js → conflict-notice-42H4ASLA.js} +1 -1
  100. package/dist/m/core/{persist-3OPWJKZS.js → persist-CJXIL7D4.js} +1 -1
  101. package/dist/m/core/{save-OJ5NSLS7.js → save-ESPSQPLV.js} +1 -1
  102. package/dist/m/core/{save-core-DX3RFVO3.js → save-core-6SQHOR6W.js} +1 -1
  103. package/dist/m/core/snapshot-FJP5IJL3.js +1 -0
  104. package/dist/m/core/{unsaved-warning-HGYH7O4H.js → unsaved-warning-HNQVTA2D.js} +1 -1
  105. package/dist/m/internals/{index-V4WC44FU.js → index-NRPNDTSA.js} +1 -1
  106. package/dist/m/loader-FBDE2UAB.js +1 -0
  107. package/dist/m/manifest-1D2F5CA5.js +1 -0
  108. package/dist/m/manifest-edit-F7CC5CFD.js +1 -0
  109. package/dist/m/manifest.json +1090 -1020
  110. package/dist/m/page/{editor-BQEPCJLG.js → editor-OSKOW6RS.js} +2 -2
  111. package/dist/m/plugins/{ai-edit-45A2J6LC.js → ai-edit-VV4QTINH.js} +1 -1
  112. package/dist/m/plugins/{cms-IFTKWF4S.js → cms-H7DTMUQX.js} +1 -1
  113. package/dist/m/plugins/{indicator-IPZJ35K6.js → indicator-WVPGMOZ7.js} +1 -1
  114. package/dist/m/plugins/{live-GPQXSXSM.js → live-DCUBKXY4.js} +1 -1
  115. package/dist/m/plugins/menu-Q4MFFQ6E.js +1 -0
  116. package/dist/m/plugins/{page-BAVLWCP6.js → page-OAWUJQEL.js} +2 -2
  117. package/dist/m/plugins/{page-view-P3UGJFDZ.js → page-view-DZ26ZDDQ.js} +1 -1
  118. package/dist/m/plugins/{people-Z4RGVQAV.js → people-5XRNRP5U.js} +1 -1
  119. package/dist/m/plugins/{quickcrop-E34PUYA3.js → quickcrop-WWF5I422.js} +2 -2
  120. package/dist/m/plugins/{richclay-S4NVJYIK.js → richclay-PGOOJ4OK.js} +2 -2
  121. package/dist/m/plugins/{sortable-WJZZBM7R.js → sortable-266HY6TR.js} +1 -1
  122. package/dist/m/plugins/{source-KVN6YNTY.js → source-6BKMK4PO.js} +1 -1
  123. package/dist/m/plugins/{upgrade-KTSICB22.js → upgrade-BNZVFHMZ.js} +1 -1
  124. package/dist/m/plugins/visitor-drafts-2AUYKAIJ.js +20 -0
  125. package/dist/m/plugins/{visitor-drafts-owner-MZP45XSG.js → visitor-drafts-owner-Z5B2OQBR.js} +1 -1
  126. package/dist/m/plugins/visitor-menu-4LQMKLPP.js +1 -0
  127. package/dist/m/plugins/{wire-SYVIBNSE.js → wire-W2EV36KZ.js} +1 -1
  128. package/dist/m/{reader-core-RUIFH32Y.js → reader-core-POFQCKRV.js} +2 -2
  129. package/dist/m/sync/{live-sync-RGQMMWK2.js → live-sync-XGUPHI3I.js} +1 -1
  130. package/dist/m/ui/{index-EZGLEM5P.js → index-VGYAKAKI.js} +1 -1
  131. package/dist/offline-manifest.json +636 -570
  132. package/docs/guide.md +36 -25
  133. package/package.json +1 -1
  134. package/src/core/save-replace.js +5 -2
  135. package/src/core/serialize-steps.js +10 -2
  136. package/src/core/snapshot.js +37 -1
  137. package/src/core/upgrade-run.js +16 -2
  138. package/src/loader-logic.js +6 -2
  139. package/src/plugins/menu/dom-items.js +45 -0
  140. package/src/plugins/menu/looks.js +32 -0
  141. package/src/plugins/menu/shell-style.js +143 -0
  142. package/src/plugins/menu/shell.js +398 -0
  143. package/src/plugins/menu/style.js +15 -116
  144. package/src/plugins/menu/variants.js +56 -10
  145. package/src/plugins/menu/visitor.js +78 -0
  146. package/src/plugins/menu.js +21 -313
  147. package/src/plugins/visitor-drafts/inert.js +1 -0
  148. package/src/plugins/visitor-drafts/intro-style.js +6 -0
  149. package/src/plugins/visitor-drafts/intro.js +77 -25
  150. package/src/plugins/visitor-drafts/owner-chip.js +18 -23
  151. package/src/plugins/visitor-drafts/prompt.js +2 -2
  152. package/src/plugins/visitor-drafts/store.js +58 -5
  153. package/src/plugins/visitor-drafts.js +1 -0
  154. package/src/plugins/visitor-menu.js +13 -0
  155. package/src/sync/live-sync.js +2 -1
  156. package/src/sync/page-relay.js +2 -2
  157. package/src/ui/page-colour.js +17 -9
  158. package/dist/m/c-5AQYL27I.js +0 -1
  159. package/dist/m/c-DP4X4JID.js +0 -1
  160. package/dist/m/c-ECY5AZMH.js +0 -1
  161. package/dist/m/c-EGTIAL6P.js +0 -1
  162. package/dist/m/c-HDWZEJHM.js +0 -183
  163. package/dist/m/c-ILGQ3UXQ.js +0 -1
  164. package/dist/m/c-JFST6QE7.js +0 -1
  165. package/dist/m/c-JH5FF4NL.js +0 -20
  166. package/dist/m/c-KV7R47FR.js +0 -1
  167. package/dist/m/c-MHI3GYKF.js +0 -1
  168. package/dist/m/c-NNNR7OXA.js +0 -3
  169. package/dist/m/c-VSPAFOKU.js +0 -1
  170. package/dist/m/core/snapshot-O7II2AGG.js +0 -1
  171. package/dist/m/loader-V6VI46HU.js +0 -1
  172. package/dist/m/manifest-83C18DED.js +0 -1
  173. package/dist/m/manifest-edit-B28C1985.js +0 -1
  174. package/dist/m/plugins/menu-UN3KRCOF.js +0 -1
  175. package/dist/m/plugins/visitor-drafts-2AWNT23K.js +0 -20
  176. /package/dist/m/plugins/{quickcrop-E34PUYA3.js.LEGAL.txt → quickcrop-WWF5I422.js.LEGAL.txt} +0 -0
  177. /package/dist/m/plugins/{richclay-S4NVJYIK.js.LEGAL.txt → richclay-PGOOJ4OK.js.LEGAL.txt} +0 -0
@@ -1,4 +1,4 @@
1
- /* clayjs 1.22.0 standalone build: every clayjs module in one file. https://clayjs.com/offline
1
+ /* clayjs 1.23.0 standalone build: every clayjs module in one file. https://clayjs.com/offline
2
2
  Third-party code inside keeps its own license (Sortable MIT, Squire MIT, DOMPurify Apache-2.0 OR MPL-2.0, MicroModal MIT, parse5 MIT, Highlights from Pierre Apache-2.0): https://clayjs.com/THIRD-PARTY-NOTICES.md */
3
3
  (() => {
4
4
  var __create = Object.create;
@@ -2110,6 +2110,7 @@
2110
2110
  currentCaptureId: () => currentCaptureId,
2111
2111
  getPageContents: () => getPageContents,
2112
2112
  noscriptBlocks: () => noscriptBlocks,
2113
+ noscriptsAsText: () => noscriptsAsText,
2113
2114
  onSnapshot: () => onSnapshot,
2114
2115
  originalSnapshotNode: () => originalSnapshotNode,
2115
2116
  prepareForCompare: () => prepareForCompare,
@@ -2220,6 +2221,22 @@
2220
2221
  collect(clone);
2221
2222
  return blocks;
2222
2223
  }
2224
+ function noscriptsAsText(doc) {
2225
+ const found = [];
2226
+ const collect = (node) => {
2227
+ for (const child of node.childNodes) {
2228
+ if (child.nodeType !== 1) continue;
2229
+ if (child.localName === "noscript" && child.namespaceURI === XHTML_NS) {
2230
+ if (child.firstChild) found.push(child);
2231
+ continue;
2232
+ }
2233
+ collect(child.localName === "template" && child.content ? child.content : child);
2234
+ }
2235
+ };
2236
+ collect(doc.documentElement ?? doc);
2237
+ for (const el12 of found) el12.replaceChildren(el12.ownerDocument.createTextNode(el12.innerHTML));
2238
+ return doc;
2239
+ }
2223
2240
  function swapNoscriptMarkers(blocks) {
2224
2241
  const nonce2 = Math.random().toString(36).slice(2);
2225
2242
  return blocks.map(([el12, kids], i2) => {
@@ -2517,7 +2534,16 @@
2517
2534
  for (const name of TAB_LOCAL_ROOT_ATTRS) bareRoot.removeAttribute(name);
2518
2535
  const shell = bareRoot.outerHTML;
2519
2536
  const endTag = `</${bareRoot.localName}>`;
2520
- return "<!DOCTYPE html>" + shell.slice(0, shell.length - endTag.length) + clone.innerHTML + endTag;
2537
+ const blocks = noscriptBlocks(clone);
2538
+ const raw = blocks.length ? swapNoscriptMarkers(blocks) : [];
2539
+ let inner;
2540
+ try {
2541
+ inner = clone.innerHTML;
2542
+ } finally {
2543
+ for (const [el12, kids] of blocks) el12.replaceChildren(...kids);
2544
+ }
2545
+ for (const [marker2, text6] of raw) inner = inner.split(marker2).join(text6);
2546
+ return "<!DOCTYPE html>" + shell.slice(0, shell.length - endTag.length) + inner + endTag;
2521
2547
  }
2522
2548
  function copyCaptureClone(clone) {
2523
2549
  return clonePreventingOnclone(clone);
@@ -2707,8 +2733,8 @@
2707
2733
  const pageView = handle?.loaded?.["plugins/page-view.js"];
2708
2734
  const sync = Array.isArray(handle?.view?.plugins) ? handle.view.plugins.includes("sync/live-sync.js") : Boolean(handle?.loaded?.["sync/live-sync.js"]);
2709
2735
  if (pageView) {
2710
- const start10 = pageView.restart ?? pageView.start;
2711
- start10({ sync, represented: accepted2 });
2736
+ const start11 = pageView.restart ?? pageView.start;
2737
+ start11({ sync, represented: accepted2 });
2712
2738
  if (!sync) return void 0;
2713
2739
  }
2714
2740
  const lane = syncLane(handle?.loaded?.["sync/live-sync.js"]);
@@ -3257,10 +3283,10 @@
3257
3283
  const under = el12.isConnected ? headingAbove(el12) : null;
3258
3284
  return under ? `${kind2} under ${under}` : kind2;
3259
3285
  }
3260
- function textContext(full, start10, end2) {
3261
- let before = full.slice(Math.max(0, start10 - CONTEXT), start10);
3286
+ function textContext(full, start11, end2) {
3287
+ let before = full.slice(Math.max(0, start11 - CONTEXT), start11);
3262
3288
  let after = full.slice(end2, end2 + CONTEXT);
3263
- let cutBefore = start10 - CONTEXT > 0;
3289
+ let cutBefore = start11 - CONTEXT > 0;
3264
3290
  let cutAfter = end2 + CONTEXT < full.length;
3265
3291
  if (cutBefore) {
3266
3292
  const i2 = before.indexOf(" ");
@@ -8125,15 +8151,15 @@
8125
8151
  const unconditional = clayTokensOf(node).includes(NO_COPY);
8126
8152
  const conditional2 = features === null ? markers.length > 0 : markers.some((marker2) => features.includes(marker2));
8127
8153
  if (!unconditional && !conditional2) return;
8128
- const start10 = node.sourceCodeLocation?.startOffset;
8129
- const end2 = typeof start10 === "number" ? endOffsetFor(node) : null;
8130
- if (typeof start10 === "number" && start10 >= 0 && end2 !== null && end2 > start10) ranges.push({ start: start10, end: end2 });
8154
+ const start11 = node.sourceCodeLocation?.startOffset;
8155
+ const end2 = typeof start11 === "number" ? endOffsetFor(node) : null;
8156
+ if (typeof start11 === "number" && start11 >= 0 && end2 !== null && end2 > start11) ranges.push({ start: start11, end: end2 });
8131
8157
  });
8132
8158
  return ranges.filter((range, index) => !ranges.some((other, otherIndex) => otherIndex !== index && other.start <= range.start && range.end <= other.end));
8133
8159
  }
8134
- function leadingRunStart(html, start10) {
8135
- const newline = html.lastIndexOf("\n", start10 - 1);
8136
- if (newline < 0 || /\S/.test(html.slice(newline + 1, start10))) return start10;
8160
+ function leadingRunStart(html, start11) {
8161
+ const newline = html.lastIndexOf("\n", start11 - 1);
8162
+ if (newline < 0 || /\S/.test(html.slice(newline + 1, start11))) return start11;
8137
8163
  return html[newline - 1] === "\r" ? newline - 1 : newline;
8138
8164
  }
8139
8165
  function spliceRanges(html, ranges) {
@@ -8141,9 +8167,9 @@
8141
8167
  let stripped = html;
8142
8168
  let limit2 = html.length;
8143
8169
  for (let index = sorted2.length - 1; index >= 0; index -= 1) {
8144
- const { start: start10, end: end2 } = sorted2[index];
8170
+ const { start: start11, end: end2 } = sorted2[index];
8145
8171
  if (end2 > limit2) continue;
8146
- const from = leadingRunStart(html, start10);
8172
+ const from = leadingRunStart(html, start11);
8147
8173
  if (from >= end2) continue;
8148
8174
  stripped = stripped.slice(0, from) + stripped.slice(end2);
8149
8175
  limit2 = from;
@@ -8838,7 +8864,7 @@
8838
8864
  scheme: darkInk(rgb) ? "light" : "dark"
8839
8865
  };
8840
8866
  }
8841
- function uiLook(rect, base2 = BEVEL_SURFACE) {
8867
+ function uiLook(rect, base2 = BEVEL_SURFACE, lean = 0.35) {
8842
8868
  let found = null;
8843
8869
  try {
8844
8870
  found = pageColour(rect);
@@ -8848,7 +8874,7 @@
8848
8874
  const { scheme: scheme2 } = found;
8849
8875
  const own = base2[scheme2], muted = (scheme2 === "dark" ? base2.mutedDark : base2.mutedLight).map((v9) => v9 / 255);
8850
8876
  let surface = null;
8851
- for (let w6 = 0.35; found.confidence >= 0.75 && !surface && w6 > 0.01; w6 -= 0.05) {
8877
+ for (let w6 = lean; found.confidence >= 0.75 && !surface && w6 > 0.01; w6 -= 0.05) {
8852
8878
  const mix3 = own.map((v9, k8) => Math.round(v9 + (found.colour[k8] - v9) * w6));
8853
8879
  if (contrast(mix3.map((v9) => v9 / 255), muted) >= 4.5) surface = `rgb(${mix3.join(" ")})`;
8854
8880
  }
@@ -8864,19 +8890,19 @@
8864
8890
  else for (const [prop, value] of Object.entries(props)) el12.style.setProperty(prop, value, "important");
8865
8891
  return look;
8866
8892
  }
8867
- function lookAt(el12, rect, base2) {
8868
- const look = uiLook(rect, base2);
8893
+ function lookAt(el12, rect, base2, lean) {
8894
+ const look = uiLook(rect, base2, lean);
8869
8895
  el12.style.setProperty("color-scheme", look.scheme, "important");
8870
8896
  if (look.surface) el12.style.setProperty("--bevel-surface", look.surface, "important");
8871
8897
  else el12.style.removeProperty("--bevel-surface");
8872
8898
  return look;
8873
8899
  }
8874
- function followLook(root4, target, base2) {
8900
+ function followLook(root4, target, base2, lean) {
8875
8901
  let timer = 0;
8876
8902
  const refresh3 = () => {
8877
8903
  timer = 0;
8878
8904
  const rect = target.getBoundingClientRect();
8879
- if (!document.hidden && root4.isConnected && rect.width && rect.height) lookAt(root4, rect, base2);
8905
+ if (!document.hidden && root4.isConnected && rect.width && rect.height) lookAt(root4, rect, base2, lean);
8880
8906
  };
8881
8907
  const soon = () => {
8882
8908
  clearTimeout(timer);
@@ -8891,6 +8917,14 @@
8891
8917
  watch2.observe(document.body, { attributes: true });
8892
8918
  watch2.observe(root4, { attributes: true, attributeFilter: ["data-corner", "hidden"] });
8893
8919
  refresh3();
8920
+ return () => {
8921
+ clearTimeout(timer);
8922
+ window.removeEventListener("scroll", soon, { capture: true });
8923
+ window.removeEventListener("resize", soon);
8924
+ document.removeEventListener("visibilitychange", soon);
8925
+ window.matchMedia?.("(prefers-color-scheme: dark)").removeEventListener?.("change", soon);
8926
+ watch2.disconnect();
8927
+ };
8894
8928
  }
8895
8929
  var pageScheme2, UI, REPLACED, BAD, TO_LMS, TO_LAB, FROM_LAB, FROM_LMS, clamp, multiply, lin, gamma, oklab, fromOklab, luminance, contrast, darkInk, distance, average, fade, inside, colours, painters, censusAt, censusSize, grid, BEVEL_SURFACE;
8896
8930
  var init_page_colour = __esm({
@@ -9442,16 +9476,16 @@
9442
9476
  if (measure !== "file" || typeof html !== "string") return html;
9443
9477
  const match = PAGE_TAG.exec(html);
9444
9478
  if (!match) return html;
9445
- let start10 = match.index;
9446
- let end2 = start10 + match[0].length;
9447
- const from = html.lastIndexOf("\n", start10 - 1) + 1;
9479
+ let start11 = match.index;
9480
+ let end2 = start11 + match[0].length;
9481
+ const from = html.lastIndexOf("\n", start11 - 1) + 1;
9448
9482
  const newline = html.indexOf("\n", end2);
9449
9483
  const to4 = newline === -1 ? html.length : newline + 1;
9450
- if (!/\S/.test(html.slice(from, start10)) && !/\S/.test(html.slice(end2, to4))) {
9451
- start10 = from;
9484
+ if (!/\S/.test(html.slice(from, start11)) && !/\S/.test(html.slice(end2, to4))) {
9485
+ start11 = from;
9452
9486
  end2 = to4;
9453
9487
  }
9454
- return html.slice(0, start10) + html.slice(end2);
9488
+ return html.slice(0, start11) + html.slice(end2);
9455
9489
  }
9456
9490
  function saveSize(html, maxBytes) {
9457
9491
  const bytes3 = new TextEncoder().encode(html).byteLength;
@@ -12466,9 +12500,17 @@
12466
12500
  const shell = bareRoot.outerHTML;
12467
12501
  const endTag = `</${bareRoot.localName}>`;
12468
12502
  const out = ["<!DOCTYPE html>", shell.slice(0, shell.length - endTag.length)];
12469
- yield* serializeChildrenSteps(clone, clonePreventingOnclone(clone, false), out, { bytes: 0 });
12503
+ const blocks = noscriptBlocks(clone);
12504
+ const raw = blocks.length ? swapNoscriptMarkers(blocks) : [];
12505
+ try {
12506
+ yield* serializeChildrenSteps(clone, clonePreventingOnclone(clone, false), out, { bytes: 0 });
12507
+ } finally {
12508
+ for (const [el12, kids] of blocks) el12.replaceChildren(...kids);
12509
+ }
12470
12510
  out.push(endTag);
12471
- return out.join("");
12511
+ let html = out.join("");
12512
+ for (const [marker2, text6] of raw) html = html.split(marker2).join(text6);
12513
+ return html;
12472
12514
  }
12473
12515
  var XHTML_NS2, SLICE_BYTES, SLICE_MIN_ELEMENTS;
12474
12516
  var init_serialize_steps = __esm({
@@ -13797,12 +13839,12 @@
13797
13839
  for (const { markers, tag: tag2 } of pending8) {
13798
13840
  for (const marker2 of markers) {
13799
13841
  for (let at8 = html.indexOf(marker2); at8 >= 0; at8 = html.indexOf(marker2, at8 + marker2.length)) {
13800
- const start10 = html.lastIndexOf("<", at8);
13801
- if (start10 < 0 || html.slice(start10 + 1, start10 + 1 + tag2.length).toLowerCase() !== tag2) continue;
13842
+ const start11 = html.lastIndexOf("<", at8);
13843
+ if (start11 < 0 || html.slice(start11 + 1, start11 + 1 + tag2.length).toLowerCase() !== tag2) continue;
13802
13844
  const close = tag2 === "style" ? html.indexOf("</style", at8) : at8;
13803
13845
  if (close < 0) continue;
13804
13846
  const end2 = html.indexOf(">", close);
13805
- if (end2 >= 0) spans.push([start10, end2 + 1]);
13847
+ if (end2 >= 0) spans.push([start11, end2 + 1]);
13806
13848
  }
13807
13849
  }
13808
13850
  }
@@ -24094,7 +24136,7 @@
24094
24136
  // src/sync/page-relay.js
24095
24137
  function pageRelay(pending8, acceptedHtml, identity) {
24096
24138
  if (!pending8.html.includes("data-page")) return pending8;
24097
- const parse2 = (html) => new DOMParser().parseFromString(html, "text/html");
24139
+ const parse2 = (html) => noscriptsAsText(new DOMParser().parseFromString(html, "text/html"));
24098
24140
  const outgoing = parse2(pending8.html);
24099
24141
  const article = outgoing.querySelector("article[data-page]");
24100
24142
  if (!article) return pending8;
@@ -26456,6 +26498,7 @@
26456
26498
  if (input == null) return input;
26457
26499
  const doc = typeof input === "string" ? new DOMParser().parseFromString(input, "text/html") : input;
26458
26500
  canonicalizeReceived(doc);
26501
+ noscriptsAsText(doc);
26459
26502
  emptyScratchpads(doc);
26460
26503
  return doc;
26461
26504
  }
@@ -28366,11 +28409,11 @@
28366
28409
  op.peel = chain.length;
28367
28410
  return !op.wrappers.slice(op.peel).some((w6) => chain.some((c4) => c4.tagName === w6.tagName));
28368
28411
  }
28369
- function peelBlock(fragment, start10, end2, live3) {
28412
+ function peelBlock(fragment, start11, end2, live3) {
28370
28413
  const outer = fragment.childNodes.length === 1 && isEl(fragment.firstChild) ? fragment.firstChild : null;
28371
28414
  if (!outer || !BLOCK_TAGS.has(outer.tagName)) return;
28372
28415
  const range = document.createRange();
28373
- range.setStart(...start10);
28416
+ range.setStart(...start11);
28374
28417
  range.setEnd(...end2);
28375
28418
  const block2 = scopeOf(range, live3);
28376
28419
  if (block2 === live3 || block2.tagName !== outer.tagName || block2.namespaceURI !== outer.namespaceURI || authored2(block2) !== authored2(outer)) return;
@@ -28412,21 +28455,21 @@
28412
28455
  if (!span) return null;
28413
28456
  const s3 = from + span.s;
28414
28457
  const e20 = from + span.e;
28415
- let start10 = pointAt(f3, s3, "start");
28416
- let end2 = s3 === e20 ? start10 : pointAt(f3, e20, "end");
28458
+ let start11 = pointAt(f3, s3, "start");
28459
+ let end2 = s3 === e20 ? start11 : pointAt(f3, e20, "end");
28417
28460
  op.parsed = op.encoding === "html" ? parse(op.fragment) : null;
28418
- if (op.parsed) peelBlock(op.parsed, start10, end2, live3);
28461
+ if (op.parsed) peelBlock(op.parsed, start11, end2, live3);
28419
28462
  if (op.parsed && hasBlock(op.parsed)) return null;
28420
28463
  op.wrappers = op.parsed ? wrappers(op.parsed) : [];
28421
28464
  if (op.parsed) idsIn(op.parsed, op.ids);
28422
28465
  op.plain = plainOf(op);
28423
- if (s3 === e20) start10 = end2 = hoist(start10, live3, op.wrappers);
28424
- op.range.setStart(...start10);
28466
+ if (s3 === e20) start11 = end2 = hoist(start11, live3, op.wrappers);
28467
+ op.range.setStart(...start11);
28425
28468
  op.range.setEnd(...end2);
28426
28469
  if (!reconcile(op, op.range, live3)) return null;
28427
28470
  const scope = scopeOf(op.range, live3);
28428
28471
  const g7 = scope === live3 ? f3 : project(scope);
28429
- const bs4 = offsetOf(g7, ...start10);
28472
+ const bs4 = offsetOf(g7, ...start11);
28430
28473
  const be10 = s3 === e20 ? bs4 : offsetOf(g7, ...end2);
28431
28474
  if (bs4 === null || be10 === null || g7.text.slice(bs4, be10) !== f3.text.slice(s3, e20)) return null;
28432
28475
  return { ...op, root: live3, f: f3, s: s3, e: e20, scope, before: g7.text, bs: bs4, be: be10 };
@@ -36267,7 +36310,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
36267
36310
  setTimer = setTimeout,
36268
36311
  clearTimer = clearTimeout
36269
36312
  } = {}) {
36270
- function start10({ captureId, html, attempts, initialOutcome, startedAt, onApplied, onUnknown }) {
36313
+ function start11({ captureId, html, attempts, initialOutcome, startedAt, onApplied, onUnknown }) {
36271
36314
  const deadline = startedAt + RECOVERY_WINDOW_MS;
36272
36315
  const ids = uniqueSaveIds(attempts);
36273
36316
  const timers = /* @__PURE__ */ new Set();
@@ -36385,7 +36428,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
36385
36428
  }
36386
36429
  };
36387
36430
  }
36388
- return { start: start10 };
36431
+ return { start: start11 };
36389
36432
  }
36390
36433
  var RECOVERY_WINDOW_MS, RECOVERY_ROUNDS_MS, QUERY_TIMEOUT_MS, MAX_HISTORY_IDS;
36391
36434
  var init_save_history = __esm({
@@ -53223,11 +53266,11 @@ ${parts.join("\n")}
53223
53266
  let at8 = 0;
53224
53267
  for (let item = flow._start; item && at8 < to4; item = item.right) {
53225
53268
  if (item.deleted || !item.countable) continue;
53226
- const start10 = at8;
53269
+ const start11 = at8;
53227
53270
  at8 += item.length;
53228
53271
  if (at8 <= from) continue;
53229
- const lo4 = Math.max(0, from - start10);
53230
- const hi5 = Math.min(item.length, to4 - start10);
53272
+ const lo4 = Math.max(0, from - start11);
53273
+ const hi5 = Math.min(item.length, to4 - start11);
53231
53274
  for (let offset = lo4; offset < hi5; offset++) out.push({ client: item.id.client, clock: item.id.clock + offset });
53232
53275
  }
53233
53276
  return out;
@@ -53426,15 +53469,15 @@ ${parts.join("\n")}
53426
53469
  if (!isCount(from) || !isCount(to4) || from > w6.tokens || to4 > w6.tokens) fail2(`Logical range ${from}..${to4} is outside the map`);
53427
53470
  const ranges = [];
53428
53471
  if (to4 <= from) return ranges;
53429
- let start10 = physicalAt(from);
53472
+ let start11 = physicalAt(from);
53430
53473
  for (const span of spans) {
53431
53474
  if (span.at <= from) continue;
53432
53475
  if (span.at > to4) break;
53433
- if (span.start > start10) ranges.push([start10, span.start]);
53434
- start10 = span.end;
53476
+ if (span.start > start11) ranges.push([start11, span.start]);
53477
+ start11 = span.end;
53435
53478
  }
53436
53479
  const end2 = physicalAt(to4);
53437
- if (end2 > start10) ranges.push([start10, end2]);
53480
+ if (end2 > start11) ranges.push([start11, end2]);
53438
53481
  return ranges;
53439
53482
  };
53440
53483
  return { segments, logicalLength: w6.tokens, physicalLength, toPhysical, toLogical, physicalRanges };
@@ -54797,10 +54840,10 @@ ${parts.join("\n")}
54797
54840
  displaced = (item, seen) => seen.some((vector) => item.clock >= (vector.get(item.client) ?? 0));
54798
54841
  mergeRanges = (list3) => {
54799
54842
  const spans = [];
54800
- for (const [start10, end2] of list3.sort((a2, b6) => a2[0] - b6[0])) {
54843
+ for (const [start11, end2] of list3.sort((a2, b6) => a2[0] - b6[0])) {
54801
54844
  const last = spans[spans.length - 1];
54802
- if (last && start10 <= last.end) last.end = Math.max(last.end, end2);
54803
- else spans.push({ start: start10, end: end2 });
54845
+ if (last && start11 <= last.end) last.end = Math.max(last.end, end2);
54846
+ else spans.push({ start: start11, end: end2 });
54804
54847
  }
54805
54848
  return spans;
54806
54849
  };
@@ -54828,16 +54871,16 @@ ${parts.join("\n")}
54828
54871
  let at8 = 0, cursor = 0;
54829
54872
  for (let item = flow._start; item && cursor < ranges.length; item = item.right) {
54830
54873
  if (item.deleted || !item.countable) continue;
54831
- const start10 = at8;
54874
+ const start11 = at8;
54832
54875
  at8 += item.length;
54833
54876
  const content = item.content;
54834
54877
  const isText = content instanceof nt2;
54835
54878
  if (!isText && !(content instanceof wt2)) continue;
54836
54879
  if (!isText && content.embed.b !== void 0) continue;
54837
- while (cursor < ranges.length && ranges[cursor][1] <= start10) cursor++;
54880
+ while (cursor < ranges.length && ranges[cursor][1] <= start11) cursor++;
54838
54881
  let range = cursor;
54839
54882
  while (range < ranges.length && ranges[range][0] < at8) {
54840
- collect(item, Math.max(start10, ranges[range][0]) - start10, Math.min(at8, ranges[range][1]) - start10);
54883
+ collect(item, Math.max(start11, ranges[range][0]) - start11, Math.min(at8, ranges[range][1]) - start11);
54841
54884
  if (ranges[range][1] >= at8) break;
54842
54885
  range++;
54843
54886
  }
@@ -55146,15 +55189,15 @@ ${parts.join("\n")}
55146
55189
  if (hiding && !it9.deleted) hiding.len += it9.length;
55147
55190
  continue;
55148
55191
  }
55149
- const start10 = starts.get(it9);
55150
- if (start10) {
55192
+ const start11 = starts.get(it9);
55193
+ if (start11) {
55151
55194
  if (it9.deleted) stops.push({ client: it9.id.client, clock: it9.id.clock, len: it9.length });
55152
- if (!hiding && exposed(start10.key)) {
55195
+ if (!hiding && exposed(start11.key)) {
55153
55196
  if (!it9.deleted) hideUnit(it9.length);
55154
- proj.push({ active: [{ blockId: start10.blockId, end: start10.end }], sourceKey: start10.key, root: null });
55197
+ proj.push({ active: [{ blockId: start11.blockId, end: start11.end }], sourceKey: start11.key, root: null });
55155
55198
  continue;
55156
55199
  }
55157
- const a2 = { legacy: true, key: start10.key, sourceKey: start10.key, blockId: start10.blockId, end: start10.end, sv: [], at: here, live: true, items: [], text: "" };
55200
+ const a2 = { legacy: true, key: start11.key, sourceKey: start11.key, blockId: start11.blockId, end: start11.end, sv: [], at: here, live: true, items: [], text: "" };
55158
55201
  if (hiding) hiding.active.push(a2);
55159
55202
  else hiding = { active: [a2], len: 0, resume: cur };
55160
55203
  hiding.len += 1;
@@ -55331,9 +55374,9 @@ ${parts.join("\n")}
55331
55374
  const item = block2.b.recovered ? pd.gone._map.get(attrKey(block2.b.sourceKey, "parent")) : pd.attrs.get(block2.b.baseId)?._map.get("parent");
55332
55375
  return item?.id ?? { clock: -1, client: -1 };
55333
55376
  };
55334
- for (const start10 of byId.keys()) {
55377
+ for (const start11 of byId.keys()) {
55335
55378
  const positions = /* @__PURE__ */ new Map(), chain = [];
55336
- let id = start10;
55379
+ let id = start11;
55337
55380
  while (byId.has(id) && !positions.has(id)) {
55338
55381
  positions.set(id, chain.length);
55339
55382
  chain.push(id);
@@ -55614,8 +55657,8 @@ ${parts.join("\n")}
55614
55657
  let a2 = i2, b6 = i2;
55615
55658
  while (a2 > 0 && mark2.isInSet(kids[a2 - 1].n.marks)) a2--;
55616
55659
  while (b6 < kids.length - 1 && mark2.isInSet(kids[b6 + 1].n.marks)) b6++;
55617
- const start10 = $p.start();
55618
- return { from: start10 + kids[a2].off, to: start10 + kids[b6].off + kids[b6].n.nodeSize, href: mark2.attrs.href };
55660
+ const start11 = $p.start();
55661
+ return { from: start11 + kids[a2].off, to: start11 + kids[b6].off + kids[b6].n.nodeSize, href: mark2.attrs.href };
55619
55662
  }
55620
55663
  function setLinkTr(st10, from, to4, href) {
55621
55664
  const tr4 = st10.tr.removeMark(from, to4, LINK);
@@ -56288,9 +56331,9 @@ ${parts.join("\n")}
56288
56331
  if (at8 > ents[lo4].at && at8 < ents[hi5].end) return [];
56289
56332
  const k8 = (next < 0 ? ents.length : next) - 1;
56290
56333
  const chain = chainAfter(ents, byId, k8);
56291
- const start10 = chain.indexOf(next < 0 ? null : parentOf2(ents[next].node));
56334
+ const start11 = chain.indexOf(next < 0 ? null : parentOf2(ents[next].node));
56292
56335
  const out = [];
56293
- for (const parent of chain.slice(Math.max(0, start10))) {
56336
+ for (const parent of chain.slice(Math.max(0, start11))) {
56294
56337
  const base2 = parent === null ? 0 : ents[byId.get(parent)].depth + 1;
56295
56338
  const prev = k8 >= 0 && isList(ents[k8].node) && parentOf2(ents[k8].node) === parent ? ents[k8].node : null;
56296
56339
  const top = isList(ents[lo4].node) ? prev ? prev.attrs.indent + 1 : 0 : 0;
@@ -58987,17 +59030,17 @@ ${parts.join("\n")}
58987
59030
  init_address();
58988
59031
  ({ InputRule } = po2);
58989
59032
  N8 = schema.nodes;
58990
- inlineCode = (st10, start10, end2) => st10.doc.rangeHasMark(start10, end2, schema.marks.code) || !!schema.marks.code.isInSet(st10.storedMarks || st10.selection.$from.marks());
58991
- blockRule = (re7, item, from = ["paragraph"], entire = false) => new InputRule(re7, (st10, match, start10, end2) => {
58992
- const $s4 = st10.doc.resolve(start10);
59033
+ inlineCode = (st10, start11, end2) => st10.doc.rangeHasMark(start11, end2, schema.marks.code) || !!schema.marks.code.isInSet(st10.storedMarks || st10.selection.$from.marks());
59034
+ blockRule = (re7, item, from = ["paragraph"], entire = false) => new InputRule(re7, (st10, match, start11, end2) => {
59035
+ const $s4 = st10.doc.resolve(start11);
58993
59036
  if (!st10.selection.empty || $s4.depth !== 1 || $s4.parentOffset !== 0 || !from.includes($s4.parent.type.name)) return null;
58994
- if (entire && end2 !== $s4.end() || inlineCode(st10, start10, end2)) return null;
58995
- return asStep(retype(st10.tr.delete(start10, end2), $s4.index(0), typeof item === "function" ? item(match) : item));
59037
+ if (entire && end2 !== $s4.end() || inlineCode(st10, start11, end2)) return null;
59038
+ return asStep(retype(st10.tr.delete(start11, end2), $s4.index(0), typeof item === "function" ? item(match) : item));
58996
59039
  });
58997
- dividerRule = new InputRule(/^---$/, (st10, match, start10, end2) => {
58998
- const $s4 = st10.doc.resolve(start10);
58999
- if (!st10.selection.empty || $s4.depth !== 1 || $s4.parent.type !== N8.paragraph || $s4.parentOffset !== 0 || $s4.parent.content.size !== end2 - start10) return null;
59000
- if (inlineCode(st10, start10, end2)) return null;
59040
+ dividerRule = new InputRule(/^---$/, (st10, match, start11, end2) => {
59041
+ const $s4 = st10.doc.resolve(start11);
59042
+ if (!st10.selection.empty || $s4.depth !== 1 || $s4.parent.type !== N8.paragraph || $s4.parentOffset !== 0 || $s4.parent.content.size !== end2 - start11) return null;
59043
+ if (inlineCode(st10, start11, end2)) return null;
59001
59044
  return asStep(replaceWithDivider(st10.tr, $s4.index(0)));
59002
59045
  });
59003
59046
  OPENS = `\\s\\(\\[\\{'\u2018\u201C"`;
@@ -59016,25 +59059,25 @@ ${parts.join("\n")}
59016
59059
  if (trailingBackslashes($at.parent.textBetween(0, $at.parentOffset, null, "\uFFFC")) % 2) return false;
59017
59060
  return $at.parentOffset === 0 || OPENS_ONE.test($at.parent.textBetween($at.parentOffset - 1, $at.parentOffset));
59018
59061
  };
59019
- inline = (st10, match, start10, end2, markOf) => {
59062
+ inline = (st10, match, start11, end2, markOf) => {
59020
59063
  const mark2 = markOf(match);
59021
59064
  if (!mark2 || !st10.selection.empty) return null;
59022
- if (start10 < 0 || start10 > end2 || end2 > st10.doc.content.size) return null;
59023
- const $start = st10.doc.resolve(start10), $end = st10.doc.resolve(end2);
59065
+ if (start11 < 0 || start11 > end2 || end2 > st10.doc.content.size) return null;
59066
+ const $start = st10.doc.resolve(start11), $end = st10.doc.resolve(end2);
59024
59067
  if (!$start.sameParent($end) || !$start.parent.inlineContent) return null;
59025
59068
  const [all, prefix, body2, close] = match;
59026
- if (inlineCode(st10, start10, end2)) return null;
59069
+ if (inlineCode(st10, start11, end2)) return null;
59027
59070
  const open4 = all.slice(prefix.length, all.length - body2.length - close.length);
59028
- const from = start10 + prefix.length;
59071
+ const from = start11 + prefix.length;
59029
59072
  if (!opensAt(st10, from)) return null;
59030
59073
  if (trailingBackslashes(all.slice(0, all.length - close.length)) % 2) return null;
59031
- const pending8 = all.length - (end2 - start10);
59074
+ const pending8 = all.length - (end2 - start11);
59032
59075
  if (pending8 < 0) return null;
59033
59076
  const tr4 = st10.tr;
59034
59077
  if (pending8) tr4.insertText(all.slice(-pending8), end2, end2);
59035
59078
  const bodyStart = from + open4.length;
59036
59079
  const bodyEnd = bodyStart + body2.length;
59037
- tr4.delete(bodyEnd, start10 + all.length);
59080
+ tr4.delete(bodyEnd, start11 + all.length);
59038
59081
  tr4.delete(from, bodyStart);
59039
59082
  tr4.addMark(from, from + body2.length, mark2);
59040
59083
  tr4.removeStoredMark(mark2.type);
@@ -59042,7 +59085,7 @@ ${parts.join("\n")}
59042
59085
  };
59043
59086
  inlineRule = (re7, markOf) => new InputRule(
59044
59087
  re7,
59045
- (st10, match, start10, end2) => inline(st10, match, start10, end2, markOf),
59088
+ (st10, match, start11, end2) => inline(st10, match, start11, end2, markOf),
59046
59089
  { inCodeMark: false }
59047
59090
  );
59048
59091
  markRule = (open4, close, type) => inlineRule(
@@ -59468,17 +59511,17 @@ ${parts.join("\n")}
59468
59511
  return setRect(view3, anchor, pos);
59469
59512
  }
59470
59513
  const doc = view3.dom.ownerDocument;
59471
- const start10 = pos;
59514
+ const start11 = pos;
59472
59515
  const move2 = (e20) => {
59473
59516
  const at8 = cellOfEvent(view3, e20);
59474
59517
  if (at8 === null) return;
59475
- const a2 = cellIds(view3.state.doc, start10), h = cellIds(view3.state.doc, at8);
59518
+ const a2 = cellIds(view3.state.doc, start11), h = cellIds(view3.state.doc, at8);
59476
59519
  if (!a2 || !h || a2.table !== h.table) return;
59477
59520
  const rect = rectKey.getState(view3.state);
59478
59521
  if (a2.row === h.row && a2.col === h.col && !rect) return;
59479
59522
  if (rect && rect.head[0] === h.row && rect.head[1] === h.col) return;
59480
59523
  e20.preventDefault();
59481
- setRect(view3, start10, at8);
59524
+ setRect(view3, start11, at8);
59482
59525
  };
59483
59526
  const up = () => {
59484
59527
  doc.removeEventListener("mouseover", move2);
@@ -60051,9 +60094,9 @@ ${parts.join("\n")}
60051
60094
  const li5 = event.target.closest?.('.page-li[data-kind="check"]');
60052
60095
  if (!li5 || !view3.dom.contains(li5)) return false;
60053
60096
  const box = li5.getBoundingClientRect();
60054
- const start10 = parseFloat(getComputedStyle(li5).paddingInlineStart) || 0;
60097
+ const start11 = parseFloat(getComputedStyle(li5).paddingInlineStart) || 0;
60055
60098
  const x5 = getComputedStyle(li5).direction === "rtl" ? box.right - event.clientX : event.clientX - box.left;
60056
- if (x5 < 0 || x5 > start10) return false;
60099
+ if (x5 < 0 || x5 > start11) return false;
60057
60100
  const pos = view3.posAtDOM(li5, 0) - 1;
60058
60101
  const node = view3.state.doc.nodeAt(pos);
60059
60102
  if (!node) return false;
@@ -61772,8 +61815,8 @@ ${INDENTS.map((n3) => `:where(article[data-page], .page-editor) .page-li[data-in
61772
61815
  const m7 = this.menu;
61773
61816
  if (!m7 || m7.slashAt === null) return;
61774
61817
  const { $head } = this.view.state.selection;
61775
- const start10 = $head.start();
61776
- if ($head.pos < m7.slashAt || m7.slashAt < start10 || this.view.state.doc.textBetween(m7.slashAt - 1, m7.slashAt) !== "/") return this.closeMenu();
61818
+ const start11 = $head.start();
61819
+ if ($head.pos < m7.slashAt || m7.slashAt < start11 || this.view.state.doc.textBetween(m7.slashAt - 1, m7.slashAt) !== "/") return this.closeMenu();
61777
61820
  m7.query = this.view.state.doc.textBetween(m7.slashAt, $head.pos);
61778
61821
  m7.active = 0;
61779
61822
  if (/\s$/.test(m7.query) && !this.menuItems(m7).length) return this.closeMenu();
@@ -63639,8 +63682,8 @@ ${INDENTS.map((n3) => `:where(article[data-page], .page-editor) .page-li[data-in
63639
63682
  const pos = cell?.getPos();
63640
63683
  if (pos == null || event.button || event.shiftKey || !view3.editable) return false;
63641
63684
  event.preventDefault();
63642
- const start10 = event.clientX < cell.contentDOM.getBoundingClientRect().left;
63643
- view3.dispatch(view3.state.tr.setSelection(TextSelection9.create(view3.state.doc, pos + 1 + (start10 ? 0 : cell.node.content.size))));
63685
+ const start11 = event.clientX < cell.contentDOM.getBoundingClientRect().left;
63686
+ view3.dispatch(view3.state.tr.setSelection(TextSelection9.create(view3.state.doc, pos + 1 + (start11 ? 0 : cell.node.content.size))));
63644
63687
  view3.focus();
63645
63688
  cell.openDate();
63646
63689
  return true;
@@ -64309,13 +64352,13 @@ ${INDENTS.map((n3) => `:where(article[data-page], .page-editor) .page-li[data-in
64309
64352
  });
64310
64353
  handle.addEventListener("pointerdown", (event) => {
64311
64354
  event.preventDefault();
64312
- const start10 = event.clientX;
64355
+ const start11 = event.clientX;
64313
64356
  const from = this.widthOfColumn(colId);
64314
64357
  this.freeze();
64315
64358
  const rtl = this.dom.ownerDocument.defaultView.getComputedStyle?.(this.dom).direction === "rtl";
64316
64359
  let width = from;
64317
64360
  const move2 = (e20) => {
64318
- width = widthOf3(from + (rtl ? start10 - e20.clientX : e20.clientX - start10)) ?? from;
64361
+ width = widthOf3(from + (rtl ? start11 - e20.clientX : e20.clientX - start11)) ?? from;
64319
64362
  this.showWidth(colId, width);
64320
64363
  };
64321
64364
  const up = () => {
@@ -68134,7 +68177,7 @@ ${text6}`;
68134
68177
  event.preventDefault();
68135
68178
  event.stopPropagation();
68136
68179
  const col = this.view.dom.getBoundingClientRect().width;
68137
- const start10 = this.frame.getBoundingClientRect().width;
68180
+ const start11 = this.frame.getBoundingClientRect().width;
68138
68181
  const rtl = this.dom.ownerDocument.defaultView.getComputedStyle(this.dom).direction === "rtl";
68139
68182
  const x0 = event.clientX;
68140
68183
  const target = event.currentTarget;
@@ -68142,7 +68185,7 @@ ${text6}`;
68142
68185
  let width = this.node.attrs.width;
68143
68186
  const move2 = (e20) => {
68144
68187
  const dx = (e20.clientX - x0) * (rtl ? -1 : 1);
68145
- width = Math.max(MIN_WIDTH2, Math.min(Math.floor(col) || MIN_WIDTH2, Math.round(start10 + dx)));
68188
+ width = Math.max(MIN_WIDTH2, Math.min(Math.floor(col) || MIN_WIDTH2, Math.round(start11 + dx)));
68146
68189
  this.frame.style.width = `${width}px`;
68147
68190
  };
68148
68191
  const done = (commit2) => {
@@ -68329,7 +68372,7 @@ ${text6}`;
68329
68372
  }
68330
68373
  function splitSelectors(selector) {
68331
68374
  const out = [];
68332
- let start10 = 0, quote2 = null, depth = 0;
68375
+ let start11 = 0, quote2 = null, depth = 0;
68333
68376
  for (let i2 = 0; i2 < selector.length; i2++) {
68334
68377
  const ch = selector[i2];
68335
68378
  if (quote2) {
@@ -68338,11 +68381,11 @@ ${text6}`;
68338
68381
  else if (ch === "(" || ch === "[") depth++;
68339
68382
  else if (ch === ")" || ch === "]") depth--;
68340
68383
  else if (ch === "," && depth === 0) {
68341
- out.push(selector.slice(start10, i2).trim());
68342
- start10 = i2 + 1;
68384
+ out.push(selector.slice(start11, i2).trim());
68385
+ start11 = i2 + 1;
68343
68386
  }
68344
68387
  }
68345
- out.push(selector.slice(start10).trim());
68388
+ out.push(selector.slice(start11).trim());
68346
68389
  return out.filter(Boolean);
68347
68390
  }
68348
68391
  function scopeCss(css, blockSelector) {
@@ -70095,7 +70138,7 @@ ${parsed2.documentElement.outerHTML}`;
70095
70138
  i2 += 1;
70096
70139
  if (key3[i2] !== "[") continue;
70097
70140
  let depth = 0, quoted = false;
70098
- const start10 = i2;
70141
+ const start11 = i2;
70099
70142
  for (; i2 < key3.length; i2++) {
70100
70143
  const ch = key3[i2];
70101
70144
  if (quoted) {
@@ -70108,7 +70151,7 @@ ${parsed2.documentElement.outerHTML}`;
70108
70151
  break;
70109
70152
  }
70110
70153
  }
70111
- if (i2 >= key3.length && key3[key3.length - 1] !== "]") throw new SyntaxError(`page: unterminated attrs in mark key ${key3.slice(start10)}`);
70154
+ if (i2 >= key3.length && key3[key3.length - 1] !== "]") throw new SyntaxError(`page: unterminated attrs in mark key ${key3.slice(start11)}`);
70112
70155
  }
70113
70156
  return false;
70114
70157
  }
@@ -74269,14 +74312,14 @@ ${mark2}`;
74269
74312
  function rewalk(pd, previous, marker2, change = null) {
74270
74313
  const formats = change?.formats ?? true, split2 = change?.split ?? null;
74271
74314
  const visible = previous.visible;
74272
- let index = -1, start10 = 0;
74315
+ let index = -1, start11 = 0;
74273
74316
  for (let i2 = 0; i2 < visible.length; i2++) {
74274
74317
  const seg = visible[i2];
74275
74318
  if (seg.brk && seg.brk.client === marker2.id.client && seg.brk.clock === marker2.id.clock) {
74276
74319
  index = i2;
74277
74320
  break;
74278
74321
  }
74279
- start10 += seg.len;
74322
+ start11 += seg.len;
74280
74323
  }
74281
74324
  if (index < 0) return null;
74282
74325
  const old = visible[index];
@@ -74290,7 +74333,7 @@ ${mark2}`;
74290
74333
  const first = { ...old, runs: [], len: 1 };
74291
74334
  if (old.items) first.items = [];
74292
74335
  let cur = first, bounded3 = false;
74293
- const origin = yAfter(previous.holes, start10);
74336
+ const origin = yAfter(previous.holes, start11);
74294
74337
  let at8 = origin + 1;
74295
74338
  for (let it9 = marker2.right; it9; it9 = it9.right) {
74296
74339
  if (it9.deleted) {
@@ -74358,7 +74401,7 @@ ${mark2}`;
74358
74401
  const next = { ...previous, visible: visible.slice(), tokens: previous.tokens + delta };
74359
74402
  next.visible.splice(index, 1, ...parts);
74360
74403
  if (delta) {
74361
- const end2 = start10 + prefix;
74404
+ const end2 = start11 + prefix;
74362
74405
  next.holes = previous.holes.map((h) => h.at >= end2 ? { at: h.at + delta, len: h.len } : h);
74363
74406
  next.hidden = previous.hidden.map((entry) => entry.at >= cut2 ? { ...entry, at: entry.at + delta, items: entry.items.map(moved) } : entry);
74364
74407
  for (let j9 = index + parts.length; j9 < next.visible.length; j9 += 1) {
@@ -74608,8 +74651,8 @@ ${mark2}`;
74608
74651
  if (p5 > 0 && isHigh2(charAt(oldToks[p5 - 1])) && (isLow(charAt(oldToks[p5])) || isLow(charAt(newToks[p5])))) p5--;
74609
74652
  if (s3 > 0 && isLow(charAt(oldToks[oldToks.length - s3])) && (isHigh2(charAt(oldToks[oldToks.length - s3 - 1])) || isHigh2(charAt(newToks[newToks.length - s3 - 1])))) s3--;
74610
74653
  const om = oldToks.slice(p5, oldToks.length - s3), nm = newToks.slice(p5, newToks.length - s3);
74611
- const start10 = ta4 + p5;
74612
- const end2 = start10 + om.length;
74654
+ const start11 = ta4 + p5;
74655
+ const end2 = start11 + om.length;
74613
74656
  const obs = om.filter((t2) => t2.k === "b").map((t2) => t2.id).join(",");
74614
74657
  const sameBreaks = om.some((t2) => t2.k === "b") && obs === nm.filter((t2) => t2.k === "b").map((t2) => t2.id).join(",");
74615
74658
  if (!sameBreaks) {
@@ -74626,7 +74669,7 @@ ${mark2}`;
74626
74669
  const softAt = /* @__PURE__ */ new Set();
74627
74670
  om.forEach((t2, j9) => {
74628
74671
  if (t2.k !== "b" || !t2.brk) return;
74629
- const abs = start10 + j9;
74672
+ const abs = start11 + j9;
74630
74673
  let next = abs + 1;
74631
74674
  while (next < bt9.length && bt9[next].k !== "b") next++;
74632
74675
  const whole = next <= end2 && next !== abs + 1;
@@ -74636,8 +74679,8 @@ ${mark2}`;
74636
74679
  softAt.add(abs);
74637
74680
  });
74638
74681
  const keep3 = [];
74639
- let from = start10;
74640
- for (let q9 = start10; q9 < end2; q9++) if (softAt.has(q9)) {
74682
+ let from = start11;
74683
+ for (let q9 = start11; q9 < end2; q9++) if (softAt.has(q9)) {
74641
74684
  if (q9 > from) keep3.push([from, q9]);
74642
74685
  from = q9 + 1;
74643
74686
  }
@@ -74651,13 +74694,13 @@ ${mark2}`;
74651
74694
  if (!pd.gone.has(removal2)) ctx.tx(() => pd.gone.set(removal2, { blockId: t2.id, end: nextDistinct(pd, key3, t2.id), sv: ctx.sv }));
74652
74695
  }
74653
74696
  }
74654
- if (nm.length) insertTokens(pd, map.toPhysical(start10, "before"), nm, ctx.tx, ctx.fences);
74697
+ if (nm.length) insertTokens(pd, map.toPhysical(start11, "before"), nm, ctx.tx, ctx.fences);
74655
74698
  return;
74656
74699
  }
74657
74700
  const dels = [];
74658
74701
  const inss = [];
74659
74702
  const attrs = [];
74660
- let cursor = start10, oi5 = 0, ni5 = 0;
74703
+ let cursor = start11, oi5 = 0, ni5 = 0;
74661
74704
  while (oi5 < om.length || ni5 < nm.length) {
74662
74705
  let ob = oi5;
74663
74706
  while (ob < om.length && om[ob].k !== "b") ob++;
@@ -74786,12 +74829,12 @@ ${mark2}`;
74786
74829
  let at8 = 0;
74787
74830
  for (let it9 = pd.flow._start; it9 && at8 < to4; it9 = it9.right) {
74788
74831
  if (it9.deleted || !it9.countable) continue;
74789
- const start10 = at8;
74832
+ const start11 = at8;
74790
74833
  at8 += it9.length;
74791
74834
  if (at8 <= from) continue;
74792
74835
  if (it9.content instanceof wt2 && it9.content.embed?.b !== void 0) continue;
74793
- const lo4 = Math.max(0, from - start10);
74794
- const hi5 = Math.min(it9.length, to4 - start10);
74836
+ const lo4 = Math.max(0, from - start11);
74837
+ const hi5 = Math.min(it9.length, to4 - start11);
74795
74838
  if (hi5 <= lo4) continue;
74796
74839
  pd.gone.set(textDeleteKey(it9.id.client, it9.id.clock + lo4, ctx.operationId), { length: hi5 - lo4, actor: pd.ydoc.clientID, sv: ctx.sv });
74797
74840
  }
@@ -74951,9 +74994,9 @@ ${mark2}`;
74951
74994
  init_format_codec();
74952
74995
  ({ AddMarkStep, RemoveMarkStep, AttrStep, ReplaceStep, Mapping } = mi2);
74953
74996
  tableRange = (doc, from, to4) => {
74954
- const start10 = doc.resolve(from), end2 = doc.resolve(to4);
74997
+ const start11 = doc.resolve(from), end2 = doc.resolve(to4);
74955
74998
  return [
74956
- start10.depth && start10.node(1).type.name === "table" ? start10.before(1) : from,
74999
+ start11.depth && start11.node(1).type.name === "table" ? start11.before(1) : from,
74957
75000
  end2.depth && end2.node(1).type.name === "table" ? end2.after(1) : to4
74958
75001
  ];
74959
75002
  };
@@ -75157,7 +75200,7 @@ ${mark2}`;
75157
75200
  let cursor2 = map.toPhysical(position, "before");
75158
75201
  const spans = [];
75159
75202
  for (const block2 of captured) {
75160
- const start10 = cursor2;
75203
+ const start11 = cursor2;
75161
75204
  let text6 = null, textAttrs = null;
75162
75205
  const flush = () => {
75163
75206
  if (text6 === null) return;
@@ -75180,7 +75223,7 @@ ${mark2}`;
75180
75223
  }
75181
75224
  }
75182
75225
  flush();
75183
- const dest = unitIds(pd.flow, start10, cursor2);
75226
+ const dest = unitIds(pd.flow, start11, cursor2);
75184
75227
  if (dest.length !== block2.units.length) throw new Error(`Copied ${block2.seg.id} as ${dest.length} units instead of ${block2.units.length}`);
75185
75228
  for (let i2 = 1; i2 < block2.units.length; i2++) spans.push({ dest: dest[i2], source: block2.units[i2].source });
75186
75229
  origins.recordBoundary(dest[0], block2.seg.recovered ? { blockId: block2.seg.id, kind: "copy", recoveryOf: block2.seg.sourceKey } : { blockId: block2.seg.id, kind: "copy" });
@@ -75323,25 +75366,25 @@ ${mark2}`;
75323
75366
  return true;
75324
75367
  }
75325
75368
  function docDiff(oldDoc, newDoc) {
75326
- let start10 = oldDoc.content.findDiffStart(newDoc.content);
75327
- if (start10 === null) return null;
75369
+ let start11 = oldDoc.content.findDiffStart(newDoc.content);
75370
+ if (start11 === null) return null;
75328
75371
  let { a: endA, b: endB } = oldDoc.content.findDiffEnd(newDoc.content);
75329
- const overlap = start10 - Math.min(endA, endB);
75372
+ const overlap = start11 - Math.min(endA, endB);
75330
75373
  if (overlap > 0) {
75331
75374
  endA += overlap;
75332
75375
  endB += overlap;
75333
75376
  }
75334
75377
  const oneTextblock = (doc, end2) => {
75335
- const $start = doc.resolve(start10);
75378
+ const $start = doc.resolve(start11);
75336
75379
  return $start.parent.isTextblock && $start.sameParent(doc.resolve(end2));
75337
75380
  };
75338
- if ((tableSpan(oldDoc, start10) || tableSpan(oldDoc, endA)) && !(oneTextblock(oldDoc, endA) && oneTextblock(newDoc, endB))) {
75339
- start10 = tableSpan(oldDoc, start10)?.[0] ?? start10;
75381
+ if ((tableSpan(oldDoc, start11) || tableSpan(oldDoc, endA)) && !(oneTextblock(oldDoc, endA) && oneTextblock(newDoc, endB))) {
75382
+ start11 = tableSpan(oldDoc, start11)?.[0] ?? start11;
75340
75383
  endA = tableSpan(oldDoc, endA)?.[1] ?? endA;
75341
75384
  endB = tableSpan(newDoc, endB)?.[1] ?? endB;
75342
- return { start: start10, endA, endB, tables: true };
75385
+ return { start: start11, endA, endB, tables: true };
75343
75386
  }
75344
- return { start: start10, endA, endB };
75387
+ return { start: start11, endA, endB };
75345
75388
  }
75346
75389
  function keepViewPos(derived2, current5 = null) {
75347
75390
  const previous = /* @__PURE__ */ new Map();
@@ -75874,7 +75917,7 @@ ${b6}`);
75874
75917
  const from = typeof step.from === "number" ? step.from : typeof step.pos === "number" ? step.pos : null;
75875
75918
  if (from === null) return false;
75876
75919
  const to4 = typeof step.to === "number" ? step.to : from + 1;
75877
- return ranges.some(([start10, end2]) => from < end2 && to4 > start10);
75920
+ return ranges.some(([start11, end2]) => from < end2 && to4 > start11);
75878
75921
  };
75879
75922
  tableSpan = (doc, pos) => {
75880
75923
  const $pos = doc.resolve(pos);
@@ -78461,16 +78504,16 @@ ${b6}`);
78461
78504
  return false;
78462
78505
  };
78463
78506
  offsetInBlock = (pd, index) => {
78464
- let at8 = 0, id = null, start10 = 0;
78507
+ let at8 = 0, id = null, start11 = 0;
78465
78508
  for (let it9 = pd.flow._start; it9; it9 = it9.right) {
78466
78509
  if (it9.content instanceof wt2 && it9.content.embed?.b !== void 0) {
78467
78510
  id = it9.content.embed.b;
78468
- start10 = at8 + it9.length;
78511
+ start11 = at8 + it9.length;
78469
78512
  }
78470
78513
  at8 += it9.length;
78471
- if (at8 > index && id !== null) return { id, offset: index - start10 };
78514
+ if (at8 > index && id !== null) return { id, offset: index - start11 };
78472
78515
  }
78473
- return id === null ? null : { id, offset: index - start10 };
78516
+ return id === null ? null : { id, offset: index - start11 };
78474
78517
  };
78475
78518
  placeInBlock = (doc, id, offset) => {
78476
78519
  let found = null;
@@ -81227,7 +81270,7 @@ ${doc.documentElement.outerHTML}`);
81227
81270
  function beginMove(item) {
81228
81271
  const from = item?.parentElement;
81229
81272
  if (!item || !from) return null;
81230
- const start10 = {
81273
+ const start11 = {
81231
81274
  item,
81232
81275
  from,
81233
81276
  children: [...from.children],
@@ -81236,56 +81279,56 @@ ${doc.documentElement.outerHTML}`);
81236
81279
  nodes: /* @__PURE__ */ new Set([item, ...item.querySelectorAll("*")]),
81237
81280
  held: false
81238
81281
  };
81239
- open.add(start10);
81240
- return start10;
81282
+ open.add(start11);
81283
+ return start11;
81241
81284
  }
81242
81285
  function isRuntimeAttribute(name, target) {
81243
81286
  if (!RUNTIME_ATTRS.has(name)) return false;
81244
- for (const start10 of open) if (start10.nodes.has(target)) return true;
81287
+ for (const start11 of open) if (start11.nodes.has(target)) return true;
81245
81288
  return false;
81246
81289
  }
81247
81290
  function isGestureItem(node) {
81248
- for (const start10 of open) if (start10.item === node) return true;
81291
+ for (const start11 of open) if (start11.item === node) return true;
81249
81292
  return false;
81250
81293
  }
81251
- function holdMove(start10) {
81294
+ function holdMove(start11) {
81252
81295
  const undo2 = engine2();
81253
- if (!start10 || start10.held || !undo2?.pause) return false;
81296
+ if (!start11 || start11.held || !undo2?.pause) return false;
81254
81297
  undo2.pause();
81255
- start10.held = true;
81298
+ start11.held = true;
81256
81299
  return true;
81257
81300
  }
81258
- function releaseMove(start10) {
81259
- if (!start10) return;
81260
- open.delete(start10);
81261
- if (!start10.held) return;
81262
- start10.held = false;
81301
+ function releaseMove(start11) {
81302
+ if (!start11) return;
81303
+ open.delete(start11);
81304
+ if (!start11.held) return;
81305
+ start11.held = false;
81263
81306
  engine2()?.resume?.();
81264
81307
  }
81265
81308
  function releaseAllMoves() {
81266
- for (const start10 of [...open]) releaseMove(start10);
81309
+ for (const start11 of [...open]) releaseMove(start11);
81267
81310
  }
81268
- function drifted(start10, result2) {
81269
- if (!start10.item.isConnected || start10.item.parentElement !== result2.to) return true;
81270
- const before = start10.children.filter((node) => node !== start10.item);
81271
- const after = [...start10.from.children].filter((node) => node !== start10.item);
81311
+ function drifted(start11, result2) {
81312
+ if (!start11.item.isConnected || start11.item.parentElement !== result2.to) return true;
81313
+ const before = start11.children.filter((node) => node !== start11.item);
81314
+ const after = [...start11.from.children].filter((node) => node !== start11.item);
81272
81315
  return !sameNodes(before, after);
81273
81316
  }
81274
- function sameSlot(start10, result2) {
81317
+ function sameSlot(start11, result2) {
81275
81318
  if (result2.from !== result2.to) return false;
81276
81319
  const now3 = [...result2.to.children];
81277
- return sameNodes(now3, start10.children);
81320
+ return sameNodes(now3, start11.children);
81278
81321
  }
81279
- function removal(start10) {
81280
- const member = (node) => node && node.parentNode === start10.from;
81281
- const next = member(start10.next) ? start10.next : null;
81322
+ function removal(start11) {
81323
+ const member = (node) => node && node.parentNode === start11.from;
81324
+ const next = member(start11.next) ? start11.next : null;
81282
81325
  return {
81283
81326
  kind: "remove",
81284
- parent: start10.from,
81285
- nodes: [start10.item],
81327
+ parent: start11.from,
81328
+ nodes: [start11.item],
81286
81329
  before: next,
81287
81330
  afterAuthored: next,
81288
- beforeAuthored: member(start10.previous) ? start10.previous : null
81331
+ beforeAuthored: member(start11.previous) ? start11.previous : null
81289
81332
  };
81290
81333
  }
81291
81334
  function addition(result2) {
@@ -81298,21 +81341,21 @@ ${doc.documentElement.outerHTML}`);
81298
81341
  beforeAuthored: result2.item.previousSibling
81299
81342
  };
81300
81343
  }
81301
- function recordMove(start10, result2) {
81302
- if (!start10 || !result2 || result2.item !== start10.item) return null;
81344
+ function recordMove(start11, result2) {
81345
+ if (!start11 || !result2 || result2.item !== start11.item) return null;
81303
81346
  const label = moveLabel(result2);
81304
- if (drifted(start10, result2)) {
81347
+ if (drifted(start11, result2)) {
81305
81348
  document.dispatchEvent(new CustomEvent("clay:undo-unavailable", {
81306
81349
  detail: { label, code: "conflicted" }
81307
81350
  }));
81308
81351
  return null;
81309
81352
  }
81310
- if (sameSlot(start10, result2)) return null;
81353
+ if (sameSlot(start11, result2)) return null;
81311
81354
  const undo2 = engine2();
81312
81355
  if (!undo2?.command || !undo2?.record) return null;
81313
- holdMove(start10);
81356
+ holdMove(start11);
81314
81357
  return undo2.command(label, () => {
81315
- undo2.record(removal(start10));
81358
+ undo2.record(removal(start11));
81316
81359
  undo2.record(addition(result2));
81317
81360
  });
81318
81361
  }
@@ -82320,15 +82363,15 @@ ${doc.documentElement.outerHTML}`);
82320
82363
  options.onEnd = function(evt) {
82321
82364
  if (!record6.admitted) return;
82322
82365
  const result2 = { item: evt.item, from: evt.from, to: evt.to, oldIndex: evt.oldIndex, newIndex: evt.newIndex };
82323
- const start10 = press;
82366
+ const start11 = press;
82324
82367
  press = null;
82325
82368
  if (restoring) {
82326
82369
  restoreRuntimeAttrs(restoring);
82327
82370
  restoring = null;
82328
82371
  }
82329
- if (start10) {
82330
- recordMove(start10, result2);
82331
- releaseMove(start10);
82372
+ if (start11) {
82373
+ recordMove(start11, result2);
82374
+ releaseMove(start11);
82332
82375
  }
82333
82376
  finishMove(result2, onsortedCode);
82334
82377
  };
@@ -82339,10 +82382,10 @@ ${doc.documentElement.outerHTML}`);
82339
82382
  let native = false;
82340
82383
  let ends = [];
82341
82384
  const endPress = () => {
82342
- const start10 = press;
82385
+ const start11 = press;
82343
82386
  press = null;
82344
82387
  restoring = null;
82345
- releaseMove(start10);
82388
+ releaseMove(start11);
82346
82389
  };
82347
82390
  const restoreSoon = () => {
82348
82391
  const pending8 = recorded;
@@ -82415,15 +82458,15 @@ ${doc.documentElement.outerHTML}`);
82415
82458
  if (beforeItem !== null && !isItemOf(toContainer, beforeItem)) return refusal4("anchor");
82416
82459
  if (from === toContainer && nextItem(from, item) === beforeItem) return { ok: true, moved: false };
82417
82460
  const oldIndex = elementIndex(from, item);
82418
- const start10 = beginMove(item);
82419
- holdMove(start10);
82461
+ const start11 = beginMove(item);
82462
+ holdMove(start11);
82420
82463
  let result2;
82421
82464
  try {
82422
82465
  toContainer.insertBefore(item, beforeItem);
82423
82466
  result2 = { item, from, to: toContainer, oldIndex, newIndex: elementIndex(toContainer, item) };
82424
- recordMove(start10, result2);
82467
+ recordMove(start11, result2);
82425
82468
  } finally {
82426
- releaseMove(start10);
82469
+ releaseMove(start11);
82427
82470
  }
82428
82471
  finishMove(result2, from.getAttribute("onsorted"));
82429
82472
  return { ok: true, moved: true, ...result2 };
@@ -83764,16 +83807,16 @@ ${doc.documentElement.outerHTML}`);
83764
83807
  const want = el12.tagName === "TEXTAREA" ? el12.getAttribute("data-value") ?? el12.textContent : el12.getAttribute("value") ?? "";
83765
83808
  if (el12.value === want) return;
83766
83809
  const focused = el12 === document.activeElement;
83767
- let start10, end2;
83810
+ let start11, end2;
83768
83811
  try {
83769
- start10 = el12.selectionStart;
83812
+ start11 = el12.selectionStart;
83770
83813
  end2 = el12.selectionEnd;
83771
83814
  } catch {
83772
83815
  }
83773
83816
  el12.value = want;
83774
- if (focused && start10 != null) {
83817
+ if (focused && start11 != null) {
83775
83818
  try {
83776
- el12.setSelectionRange(Math.min(start10, want.length), Math.min(end2, want.length));
83819
+ el12.setSelectionRange(Math.min(start11, want.length), Math.min(end2, want.length));
83777
83820
  } catch {
83778
83821
  }
83779
83822
  }
@@ -91140,15 +91183,15 @@ tr.hcms-shell.hcms-inline-ghost { display: table-row; }
91140
91183
  if (!handle && !onBox) return;
91141
91184
  e20.preventDefault();
91142
91185
  stage.setPointerCapture(e20.pointerId);
91143
- const start10 = { px: e20.clientX, py: e20.clientY, x: x5, y: y6, w: w6, h };
91186
+ const start11 = { px: e20.clientX, py: e20.clientY, x: x5, y: y6, w: w6, h };
91144
91187
  const corner = handle && [...handle.classList].find((c4) => /^qc-(nw|ne|sw|se)$/.test(c4))?.slice(3);
91145
91188
  const move2 = (ev) => {
91146
91189
  if (!corner) {
91147
- x5 = clamp3(start10.x + (ev.clientX - start10.px), 0, dispW - w6);
91148
- y6 = clamp3(start10.y + (ev.clientY - start10.py), 0, dispH - h);
91190
+ x5 = clamp3(start11.x + (ev.clientX - start11.px), 0, dispW - w6);
91191
+ y6 = clamp3(start11.y + (ev.clientY - start11.py), 0, dispH - h);
91149
91192
  } else {
91150
- const ax = corner.includes("w") ? start10.x + start10.w : start10.x;
91151
- const ay = corner.includes("n") ? start10.y + start10.h : start10.y;
91193
+ const ax = corner.includes("w") ? start11.x + start11.w : start11.x;
91194
+ const ay = corner.includes("n") ? start11.y + start11.h : start11.y;
91152
91195
  const goingE = corner.includes("e"), goingS = corner.includes("s");
91153
91196
  const rect = stage.getBoundingClientRect();
91154
91197
  const dx = Math.abs(ev.clientX - (rect.left + ax));
@@ -92430,20 +92473,26 @@ tr.hcms-shell.hcms-inline-ghost { display: table-row; }
92430
92473
  }
92431
92474
  });
92432
92475
 
92433
- // src/plugins/menu/claygoo.svg.js
92434
- var claygoo_svg_default;
92435
- var init_claygoo_svg = __esm({
92436
- "src/plugins/menu/claygoo.svg.js"() {
92437
- claygoo_svg_default = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="-45.87 -57.96 100.26 60.98" fill="currentColor" aria-hidden="true" focusable="false"><path fill-rule="evenodd" d="M44.35 -4.56Q40.03 -0.52 34.69 -0.39Q29.34 -0.25 24.81 -0.14Q20.27 -0.02 15.6 0Q10.93 0.02 6.41 0Q1.89 -0.02 -2.79 -0.02Q-7.48 -0.02 -12.11 -0.14Q-16.73 -0.25 -21.64 -0.27Q-26.55 -0.3 -31.72 -2.25Q-36.88 -4.2 -39.87 -9.12Q-42.87 -14.03 -42.8 -19.61Q-42.74 -25.18 -40.43 -29.94Q-38.12 -34.69 -34.82 -38.78Q-31.52 -42.87 -27.25 -45.6Q-22.98 -48.33 -18.35 -50.59Q-13.73 -52.85 -8.7 -53.88Q-3.68 -54.91 1.32 -54.93Q6.32 -54.96 11.44 -54.56Q16.55 -54.16 21.35 -52.2Q26.16 -50.24 30.69 -48.01Q35.22 -45.78 38.99 -42.18Q42.76 -38.59 45.67 -34.37Q48.59 -30.15 49.99 -24.87Q51.39 -19.59 50.04 -14.09Q48.68 -8.6 44.35 -4.56ZM0.66 -30.49C0.5 -28.73 -0.88 -27.42 -2.42 -27.57C-3.96 -27.71 -5.08 -29.25 -4.91 -31.01C-4.75 -32.77 -3.36 -34.08 -1.83 -33.94C-0.29 -33.79 0.83 -32.25 0.66 -30.49ZM13.61 -29.28C13.44 -27.52 12.06 -26.21 10.52 -26.35C8.98 -26.5 7.87 -28.04 8.03 -29.8C8.2 -31.56 9.58 -32.87 11.12 -32.73C12.66 -32.58 13.77 -31.04 13.61 -29.28ZM-1.23 -17.71Q-0.62 -17.35 -0.03 -17.08Q0.56 -16.81 1.15 -16.54Q1.73 -16.28 2.4 -16Q3.07 -15.72 3.87 -15.6Q4.66 -15.48 5.4 -15.55Q6.13 -15.62 6.77 -15.79Q7.41 -15.96 7.97 -16.23Q8.53 -16.5 9 -16.91Q9.46 -17.32 9.73 -17.9Q9.99 -18.47 10.08 -19.12Q10.17 -19.77 10.08 -20.42Q9.99 -21.06 9.45 -21.32Q8.91 -21.58 8.27 -21.38Q7.63 -21.17 6.99 -20.91Q6.36 -20.65 5.7 -20.61Q5.04 -20.56 4.33 -20.73Q3.62 -20.9 2.92 -21.14Q2.23 -21.39 1.54 -21.68Q0.85 -21.97 0.16 -22.27Q-0.52 -22.56 -1.22 -22.79Q-1.92 -23.03 -2.49 -22.61Q-3.05 -22.19 -3.23 -21.5Q-3.4 -20.81 -3.2 -20.09Q-3.01 -19.38 -3.02 -19.15Q-3.02 -18.93 -2.42 -18.5Q-1.83 -18.06 -1.23 -17.71Z"/></svg>';
92438
- }
92439
- });
92440
-
92441
- // src/plugins/menu/style.js
92442
- var MENU_SURFACE, MENU_BASE, MENU_FLOATING, MENU_SKIN, MENU_TOUCH, style_default;
92443
- var init_style2 = __esm({
92444
- "src/plugins/menu/style.js"() {
92445
- MENU_SURFACE = { light: [255, 252, 246], dark: [26, 29, 44], mutedLight: [107, 89, 66], mutedDark: [163, 169, 194] };
92446
- MENU_BASE = `.clay-menu-dock, .clay-menu-spots, .clay-seo {
92476
+ // src/plugins/menu/shell-style.js
92477
+ var MENU_SAFETY, SHELL_A, SHELL_B, SHELL_C, SHELL_BASE, SHELL_FLOATING, MENU_SKIN, MENU_TOUCH;
92478
+ var init_shell_style = __esm({
92479
+ "src/plugins/menu/shell-style.js"() {
92480
+ MENU_SAFETY = `@layer clay-menu-safety {
92481
+ .clay-menu-dock [hidden], .clay-menu-spots[hidden], .clay-menu-dock[hidden] { display: none !important; }
92482
+ .clay-menu :focus-visible:not(.clay-menu-edit) { outline: 2px solid var(--bevel-brass) !important; outline-offset: -2px !important; }
92483
+ @media (pointer: coarse), (max-width: 680px) {
92484
+ .clay-menu-goo, .clay-menu-list [part~="dismiss"], .clay-menu-list [part~="step"], .clay-menu-list [role^="menuitem"] { min-width: 44px !important; min-height: 44px !important; }
92485
+ }
92486
+ @media (prefers-reduced-motion: reduce) {
92487
+ .clay-menu-dock *, .clay-menu-dock *::before, .clay-menu-dock *::after { transition: none !important; animation: none !important; }
92488
+ }
92489
+ @media (forced-colors: active) {
92490
+ .clay-menu-list { border: 1px solid CanvasText !important; }
92491
+ .clay-menu :focus-visible:not(.clay-menu-edit) { outline-color: Highlight !important; }
92492
+ }
92493
+ }
92494
+ `;
92495
+ SHELL_A = `.clay-menu-dock, .clay-menu-spots, .clay-seo {
92447
92496
  --bevel-font-sans: system-ui, -apple-system, "Segoe UI", sans-serif;
92448
92497
  --bevel-font-serif: Newsreader, Georgia, "Times New Roman", serif;
92449
92498
  --bevel-font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
@@ -92486,13 +92535,100 @@ tr.hcms-shell.hcms-inline-ghost { display: table-row; }
92486
92535
 
92487
92536
  .clay-menu { box-sizing: border-box; display: inline-flex; align-items: center; gap: 2px; user-select: none; -webkit-user-select: none; }
92488
92537
 
92489
- .clay-menu-edit { position: relative; display: inline-flex; align-items: center; gap: 8px; height: 28px; margin: 0; padding: 0 8px 0 5px; border: 0; background: none; font: 500 13px/1 var(--bevel-font-sans); color: var(--bevel-ink); cursor: pointer; }
92538
+ `;
92539
+ SHELL_B = `.clay-menu-goo { position: relative; display: inline-grid; place-items: center; box-sizing: border-box; margin: 0; padding: 0; cursor: pointer; }
92540
+ .clay-menu-goo svg { display: block; }
92541
+ .clay-menu-dot { position: absolute; top: -1px; right: -2px; width: 8px; height: 8px; border-radius: 50%; background: var(--bevel-brass); box-shadow: 0 0 0 2px var(--bevel-surface); }
92542
+
92543
+ .clay-menu :focus-visible, .clay-roster:focus-visible { outline: 2px solid var(--bevel-brass); outline-offset: 2px; }
92544
+ .clay-menu-edit:focus-visible { outline: none; }
92545
+ .clay-menu-edit:focus-visible .clay-menu-track { outline: 2px solid var(--bevel-brass); outline-offset: 2px; }
92546
+
92547
+ `;
92548
+ SHELL_C = `/* Popovers: the menu, the people panel, the status note. Below the dock, above it in a bottom corner. */
92549
+ .clay-menu-list, .clay-people, .clay-menu-note { position: absolute; z-index: 1; top: calc(100% + 8px); right: 0; box-sizing: border-box; margin: 0; color: var(--bevel-ink); text-align: left; }
92550
+ .clay-people, .clay-menu-note { border: 1px solid var(--bevel-line-2); background: var(--bevel-surface); box-shadow: var(--clay-shadow); }
92551
+
92552
+ .clay-menu-list { width: max-content; max-width: calc(100vw - 24px); max-height: calc(100dvh - 72px); overflow-y: auto; overscroll-behavior: contain; }
92553
+ .clay-menu-list[popover] { position: fixed; inset: auto; margin: 0; }
92554
+ .clay-menu-list [role^="menuitem"] { box-sizing: border-box; display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; margin: 0; border: 0; background: none; text-align: left; text-decoration: none; cursor: pointer; }
92555
+ .clay-menu-list [role^="menuitem"]:hover:not([aria-disabled="true"]), .clay-menu-list [role^="menuitem"]:focus-visible { outline: none; background: var(--bevel-sunk); }
92556
+ .clay-menu-list [role^="menuitem"][aria-disabled="true"] { cursor: default; }
92557
+ .clay-menu-pair { display: flex; gap: 12px; padding: 3px 9px; }
92558
+ .clay-menu-list .clay-menu-pair [role="menuitem"] { flex: none; width: auto; justify-content: flex-start; gap: 9px; }
92559
+ .clay-menu-list kbd { flex: none; white-space: nowrap; }
92560
+ .clay-menu-row { display: flex; align-items: center; gap: 2px; }
92561
+ .clay-menu-list .clay-menu-row > [part~="item"] { flex: 1; width: auto; min-width: 0; }
92562
+ .clay-menu-list .clay-menu-row > [part~="dismiss"] { flex: none; width: 28px; justify-content: center; padding: 0; }
92563
+ .clay-menu-row > [part~="dismiss"] svg { display: block; width: 10px; height: 10px; fill: currentColor; }
92564
+ .clay-menu-upgrade { display: inline-flex; align-items: center; gap: 8px; }
92565
+ .clay-menu-upgrade::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--bevel-brass); }
92566
+ .clay-menu-toggle .clay-menu-track { flex: none; }
92567
+ .clay-menu-version { box-sizing: border-box; margin: 0; padding: 7px 9px; }
92568
+
92569
+ .clay-menu-note { z-index: 2; width: max-content; max-width: 264px; padding: 8px 12px; font-size: 13px; line-height: 1.45; }
92570
+
92571
+ .clay-menu-stepper { display: flex; align-items: center; gap: 2px; padding-left: 9px; font: 400 13px/1.35 var(--bevel-font-sans); color: var(--bevel-ink); }
92572
+ .clay-menu-stepper-label { flex: 1; margin-right: 12px; white-space: nowrap; }
92573
+ .clay-menu-stepper-value { min-width: 5.5em; text-align: center; white-space: nowrap; font-variant-numeric: tabular-nums; }
92574
+ .clay-menu-list .clay-menu-stepper [role="menuitem"] { flex: none; display: inline-grid; place-items: center; box-sizing: border-box; width: 36px; min-height: 36px; padding: 0; }
92575
+ .clay-menu-stepper svg { display: block; width: 16px; height: 16px; fill: currentColor; }
92576
+
92577
+ `;
92578
+ SHELL_BASE = SHELL_A + SHELL_B + SHELL_C;
92579
+ SHELL_FLOATING = `/* The dock: the roster (when a page opts in) and the capsule, fixed in one corner. */
92580
+ .clay-menu-dock { position: fixed; z-index: 2147482000; top: max(12px, env(safe-area-inset-top)); right: max(12px, env(safe-area-inset-right)); }
92581
+ .clay-menu-dock[data-corner$="left"] { right: auto; left: max(12px, env(safe-area-inset-left)); flex-direction: row-reverse; }
92582
+ .clay-menu-dock[data-corner^="bottom"] { top: auto; bottom: max(12px, env(safe-area-inset-bottom)); }
92583
+ .clay-menu-dock[data-corner$="left"] :is(.clay-menu-list, .clay-people, .clay-menu-note) { right: auto; left: 0; }
92584
+ .clay-menu-dock[data-corner^="bottom"] :is(.clay-menu-list, .clay-people, .clay-menu-note) { top: auto; bottom: calc(100% + 8px); }
92585
+ `;
92586
+ MENU_SKIN = `.clay-menu { height: 34px; padding: 0 4px 0 2px; border: 1px solid var(--bevel-line-3); background: var(--bevel-surface); box-shadow: var(--clay-shadow); }
92587
+ .clay-menu-goo { width: 28px; height: 28px; min-height: 0; border-radius: 0; border: 2px solid transparent; background: none; color: var(--bevel-ink); }
92588
+ .clay-menu-goo::before { content: ""; position: absolute; inset: -8px -8px -8px -4px; }
92589
+ .clay-menu-goo svg { width: 18px; height: auto; fill: currentColor; }
92590
+ .clay-menu-goo:hover svg { translate: 0 -1px; }
92591
+ .clay-menu-goo:active, .clay-menu-goo[aria-expanded="true"] { background: var(--bevel-face-in); border-color: var(--bevel-edge-in) var(--bevel-edge-in-hi) var(--bevel-edge-in-hi) var(--bevel-edge-in); }
92592
+ .clay-menu-goo:active svg, .clay-menu-goo[aria-expanded="true"] svg { translate: 1px 1px; }
92593
+ .clay-menu-list { min-width: 284px; padding: 6px; border: 1px solid var(--bevel-line-2); background: var(--bevel-surface); box-shadow: var(--clay-shadow); }
92594
+ .clay-menu-list [role^="menuitem"] { min-height: 32px; padding: 5px 9px; font: 400 13px/1.35 var(--bevel-font-sans); color: var(--bevel-ink); }
92595
+ .clay-menu-list [role^="menuitem"][aria-disabled="true"] { color: var(--bevel-faint); }
92596
+ .clay-menu-list [role^="menuitem"][aria-disabled="true"] kbd { opacity: .6; }
92597
+ .clay-menu-list .clay-menu-pair [role="menuitem"] { min-height: 30px; padding: 4px 6px 4px 9px; border: 1px solid var(--bevel-line); }
92598
+ .clay-menu-list kbd { font: 500 11px/1 var(--bevel-font-mono); padding: 3px 5px; border: 1px solid var(--bevel-line-2); background: var(--bevel-sunk); color: var(--bevel-muted); }
92599
+ .clay-menu-list [part~="quiet"] { font-size: 12px; color: var(--bevel-muted); }
92600
+ .clay-menu-sep { height: 1px; margin: 4px 2px; background: var(--bevel-line); }
92601
+ .clay-menu-version { font: 400 11.5px/1.4 var(--bevel-font-mono); color: var(--bevel-muted); }
92602
+ `;
92603
+ MENU_TOUCH = `@media (pointer: coarse), (max-width: 680px) {
92604
+ .clay-menu-list [role^="menuitem"] { min-height: 44px; font-size: 15px; }
92605
+ .clay-menu-list .clay-menu-pair [role="menuitem"] { min-height: 44px; }
92606
+ .clay-menu-list .clay-menu-stepper [role="menuitem"] { width: 44px; min-height: 44px; }
92607
+ :is(.clay-menu-dock, .clay-seo) :is(input, textarea, select) { font-size: 16px; }
92608
+ .clay-seo-input, .clay-people-input { min-height: 40px; }
92609
+ .clay-menu-btn { min-height: 40px; }
92610
+ }
92611
+ @media (prefers-reduced-motion: reduce) {
92612
+ .clay-menu-track, .clay-menu-thumb { transition: none; }
92613
+ }
92614
+ `;
92615
+ }
92616
+ });
92617
+
92618
+ // src/plugins/menu/style.js
92619
+ var MENU_SURFACE, OWNER_1, OWNER_2, OWNER_3, MENU_BASE, MENU_FLOATING, style_default;
92620
+ var init_style2 = __esm({
92621
+ "src/plugins/menu/style.js"() {
92622
+ init_shell_style();
92623
+ init_shell_style();
92624
+ MENU_SURFACE = { light: [255, 252, 246], dark: [26, 29, 44], mutedLight: [107, 89, 66], mutedDark: [163, 169, 194] };
92625
+ OWNER_1 = `.clay-menu-edit { position: relative; display: inline-flex; align-items: center; gap: 8px; height: 28px; margin: 0; padding: 0 8px 0 5px; border: 0; background: none; font: 500 13px/1 var(--bevel-font-sans); color: var(--bevel-ink); cursor: pointer; }
92490
92626
  .clay-menu-edit::before { content: ""; position: absolute; inset: -8px 0; }
92491
92627
  .clay-menu-track { position: relative; display: block; box-sizing: border-box; width: 36px; height: 20px; border: 1px solid var(--bevel-line-2); background: var(--bevel-sunk); transition: background-color .14s, border-color .14s; }
92492
92628
  .clay-menu-thumb { position: absolute; top: 2px; left: 2px; box-sizing: border-box; width: 14px; height: 14px; border: 2px solid; border-color: var(--bevel-knob-hi) var(--bevel-edge-lo) var(--bevel-edge-lo) var(--bevel-knob-hi); background: var(--bevel-knob); transition: translate .15s cubic-bezier(.4, 0, .2, 1); }
92493
- .clay-menu-edit:hover .clay-menu-track { border-color: var(--bevel-faint); }
92494
- .clay-menu-edit[aria-checked="true"] .clay-menu-track { background: #256056; border-color: light-dark(#256056, #3C7E72); }
92495
- .clay-menu-edit[aria-checked="true"] .clay-menu-thumb { translate: 16px 0; background: light-dark(var(--bevel-knob), #8EDCC5); border-color: light-dark(var(--bevel-knob-hi), #C2F0E2) light-dark(var(--bevel-edge-lo), #4F9C86) light-dark(var(--bevel-edge-lo), #4F9C86) light-dark(var(--bevel-knob-hi), #C2F0E2); }
92629
+ :is(.clay-menu-edit, .clay-menu-toggle):hover .clay-menu-track { border-color: var(--bevel-faint); }
92630
+ :is(.clay-menu-edit, .clay-menu-toggle)[aria-checked="true"] .clay-menu-track { background: #256056; border-color: light-dark(#256056, #3C7E72); }
92631
+ :is(.clay-menu-edit, .clay-menu-toggle)[aria-checked="true"] .clay-menu-thumb { translate: 16px 0; background: light-dark(var(--bevel-knob), #8EDCC5); border-color: light-dark(var(--bevel-knob-hi), #C2F0E2) light-dark(var(--bevel-edge-lo), #4F9C86) light-dark(var(--bevel-edge-lo), #4F9C86) light-dark(var(--bevel-knob-hi), #C2F0E2); }
92496
92632
  .clay-menu-edit[aria-busy="true"] { cursor: progress; color: var(--bevel-muted); }
92497
92633
  .clay-menu-edit[aria-busy="true"] .clay-menu-track { background: var(--bevel-line); border-color: var(--bevel-line-2); }
92498
92634
  .clay-menu-edit[aria-busy="true"] .clay-menu-thumb { translate: 8px 0; opacity: .7; }
@@ -92500,15 +92636,8 @@ tr.hcms-shell.hcms-inline-ghost { display: table-row; }
92500
92636
 
92501
92637
  .clay-menu-divider { width: 1px; height: 18px; margin: 0 2px; background: var(--bevel-line-2); }
92502
92638
 
92503
- .clay-menu-goo { position: relative; display: inline-grid; place-items: center; box-sizing: border-box; margin: 0; padding: 0; cursor: pointer; }
92504
- .clay-menu-goo svg { display: block; }
92505
- .clay-menu-dot { position: absolute; top: -1px; right: -2px; width: 8px; height: 8px; border-radius: 50%; background: var(--bevel-brass); box-shadow: 0 0 0 2px var(--bevel-surface); }
92506
-
92507
- .clay-menu :focus-visible, .clay-roster:focus-visible { outline: 2px solid var(--bevel-brass); outline-offset: 2px; }
92508
- .clay-menu-edit:focus-visible { outline: none; }
92509
- .clay-menu-edit:focus-visible .clay-menu-track { outline: 2px solid var(--bevel-brass); outline-offset: 2px; }
92510
-
92511
- /* The roster, beside the capsule, only on a page that opts in. Flat, like the capsule. */
92639
+ `;
92640
+ OWNER_2 = `/* The roster, beside the capsule, only on a page that opts in. Flat, like the capsule. */
92512
92641
  .clay-roster { box-sizing: border-box; display: inline-flex; align-items: center; gap: 8px; height: 34px; margin: 0; padding: 0 10px 0 5px; border: 1px solid var(--bevel-line-3); background: var(--bevel-surface); box-shadow: var(--clay-shadow); font: 400 12px/1 var(--bevel-font-mono); color: var(--bevel-muted); cursor: pointer; }
92513
92642
  .clay-roster:hover, .clay-roster[aria-expanded="true"] { background: var(--bevel-sunk); }
92514
92643
  .clay-roster-faces { display: inline-flex; }
@@ -92525,29 +92654,8 @@ tr.hcms-shell.hcms-inline-ghost { display: table-row; }
92525
92654
  .clay-avatar[data-tone="brass"] { background: var(--bevel-brass-soft); color: var(--bevel-brass); border-color: color-mix(in srgb, var(--bevel-brass) 35%, var(--bevel-brass-soft)); }
92526
92655
  .clay-avatar[data-tone="teal"] { background: var(--bevel-teal-soft); color: var(--bevel-teal); border-color: color-mix(in srgb, var(--bevel-teal) 35%, var(--bevel-teal-soft)); }
92527
92656
 
92528
- /* Popovers: the menu, the people panel, the status note. Below the dock, above it in a bottom corner. */
92529
- .clay-menu-list, .clay-people, .clay-menu-note { position: absolute; z-index: 1; top: calc(100% + 8px); right: 0; box-sizing: border-box; margin: 0; color: var(--bevel-ink); text-align: left; }
92530
- .clay-people, .clay-menu-note { border: 1px solid var(--bevel-line-2); background: var(--bevel-surface); box-shadow: var(--clay-shadow); }
92531
-
92532
- .clay-menu-list { width: max-content; max-width: calc(100vw - 24px); max-height: calc(100dvh - 72px); overflow-y: auto; overscroll-behavior: contain; }
92533
- .clay-menu-list[popover] { position: fixed; inset: auto; margin: 0; }
92534
- .clay-menu-list [role="menuitem"] { box-sizing: border-box; display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; margin: 0; border: 0; background: none; text-align: left; text-decoration: none; cursor: pointer; }
92535
- .clay-menu-list [role="menuitem"]:hover:not([aria-disabled="true"]), .clay-menu-list [role="menuitem"]:focus-visible { outline: none; background: var(--bevel-sunk); }
92536
- .clay-menu-list [role="menuitem"][aria-disabled="true"] { cursor: default; }
92537
- .clay-menu-pair { display: flex; gap: 12px; padding: 3px 9px; }
92538
- .clay-menu-list .clay-menu-pair [role="menuitem"] { flex: none; width: auto; justify-content: flex-start; gap: 9px; }
92539
- .clay-menu-list kbd { flex: none; white-space: nowrap; }
92540
- .clay-menu-row { display: flex; align-items: center; gap: 2px; }
92541
- .clay-menu-list .clay-menu-row > [part~="item"] { flex: 1; width: auto; min-width: 0; }
92542
- .clay-menu-list .clay-menu-row > [part~="dismiss"] { flex: none; width: 28px; justify-content: center; padding: 0; }
92543
- .clay-menu-row > [part~="dismiss"] svg { display: block; width: 10px; height: 10px; fill: currentColor; }
92544
- .clay-menu-upgrade { display: inline-flex; align-items: center; gap: 8px; }
92545
- .clay-menu-upgrade::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--bevel-brass); }
92546
- .clay-menu-version { margin: 0; }
92547
-
92548
- .clay-menu-note { z-index: 2; width: max-content; max-width: 264px; padding: 8px 12px; font-size: 13px; line-height: 1.45; }
92549
-
92550
- /* The people panel: no lines between people, one line between sections. */
92657
+ `;
92658
+ OWNER_3 = `/* The people panel: no lines between people, one line between sections. */
92551
92659
  .clay-people { width: 300px; max-width: calc(100vw - 24px); padding: 0; }
92552
92660
  .clay-people-head { display: flex; align-items: center; gap: 10px; padding: 10px 8px 10px 14px; border-bottom: 1px solid var(--bevel-line); }
92553
92661
  .clay-people-title { flex: 1; margin: 0; font: 500 16px/1.2 var(--bevel-font-serif); }
@@ -92580,13 +92688,8 @@ tr.hcms-shell.hcms-inline-ghost { display: table-row; }
92580
92688
  .clay-menu-btn-primary { --bevel-face: var(--bevel-ink); --bevel-edge-hi: color-mix(in srgb, var(--bevel-ink), light-dark(#FFFCF6, #FFFFFF) 22%); --bevel-edge-lo: color-mix(in srgb, var(--bevel-ink), light-dark(#0B0C13, #6A7090) 34%); color: var(--bevel-ground); }
92581
92689
  .clay-menu-btn-primary:hover { background: color-mix(in srgb, var(--bevel-ink), var(--bevel-ground) 12%); }
92582
92690
  `;
92583
- MENU_FLOATING = `/* The dock: the roster (when a page opts in) and the capsule, fixed in one corner. */
92584
- .clay-menu-dock { position: fixed; z-index: 2147482000; top: max(12px, env(safe-area-inset-top)); right: max(12px, env(safe-area-inset-right)); }
92585
- .clay-menu-dock[data-corner$="left"] { right: auto; left: max(12px, env(safe-area-inset-left)); flex-direction: row-reverse; }
92586
- .clay-menu-dock[data-corner^="bottom"] { top: auto; bottom: max(12px, env(safe-area-inset-bottom)); }
92587
- .clay-menu-dock[data-corner$="left"] :is(.clay-menu-list, .clay-people, .clay-menu-note) { right: auto; left: 0; }
92588
- .clay-menu-dock[data-corner^="bottom"] :is(.clay-menu-list, .clay-people, .clay-menu-note) { top: auto; bottom: calc(100% + 8px); }
92589
- .clay-menu-dock[data-dragging] .clay-menu { border-color: var(--bevel-brass); cursor: grabbing; }
92691
+ MENU_BASE = SHELL_A + OWNER_1 + SHELL_B + OWNER_2 + SHELL_C + OWNER_3;
92692
+ MENU_FLOATING = SHELL_FLOATING + `.clay-menu-dock[data-dragging] .clay-menu { border-color: var(--bevel-brass); cursor: grabbing; }
92590
92693
  .clay-menu-grip { position: relative; display: inline-grid; place-items: center; width: 18px; height: 28px; margin: 0; padding: 0; border: 0; background: none; color: var(--bevel-faint); cursor: grab; touch-action: none; }
92591
92694
  .clay-menu-grip::before { content: ""; position: absolute; inset: -8px -2px -8px -10px; }
92592
92695
  .clay-menu-grip:hover { color: var(--bevel-ink-2); }
@@ -92600,34 +92703,6 @@ tr.hcms-shell.hcms-inline-ghost { display: table-row; }
92600
92703
  .clay-menu-spot[data-to$="left"] { left: 12px; }
92601
92704
  .clay-menu-spot[data-to$="right"] { right: 12px; }
92602
92705
  .clay-menu-spot[data-near] { border: 2px solid var(--bevel-brass); background: var(--bevel-brass-soft); }
92603
- `;
92604
- MENU_SKIN = `.clay-menu { height: 34px; padding: 0 4px 0 2px; border: 1px solid var(--bevel-line-3); background: var(--bevel-surface); box-shadow: var(--clay-shadow); }
92605
- .clay-menu-goo { width: 28px; height: 28px; min-height: 0; border-radius: 0; border: 2px solid transparent; background: none; color: var(--bevel-ink); }
92606
- .clay-menu-goo::before { content: ""; position: absolute; inset: -8px -8px -8px -4px; }
92607
- .clay-menu-goo svg { width: 18px; height: auto; fill: currentColor; }
92608
- .clay-menu-goo:hover svg { translate: 0 -1px; }
92609
- .clay-menu-goo:active, .clay-menu-goo[aria-expanded="true"] { background: var(--bevel-face-in); border-color: var(--bevel-edge-in) var(--bevel-edge-in-hi) var(--bevel-edge-in-hi) var(--bevel-edge-in); }
92610
- .clay-menu-goo:active svg, .clay-menu-goo[aria-expanded="true"] svg { translate: 1px 1px; }
92611
- .clay-menu-list { min-width: 284px; padding: 6px; border: 1px solid var(--bevel-line-2); background: var(--bevel-surface); box-shadow: var(--clay-shadow); }
92612
- .clay-menu-list [role="menuitem"] { min-height: 32px; padding: 5px 9px; font: 400 13px/1.35 var(--bevel-font-sans); color: var(--bevel-ink); }
92613
- .clay-menu-list [role="menuitem"][aria-disabled="true"] { color: var(--bevel-faint); }
92614
- .clay-menu-list [role="menuitem"][aria-disabled="true"] kbd { opacity: .6; }
92615
- .clay-menu-list .clay-menu-pair [role="menuitem"] { min-height: 30px; padding: 4px 6px 4px 9px; border: 1px solid var(--bevel-line); }
92616
- .clay-menu-list kbd { font: 500 11px/1 var(--bevel-font-mono); padding: 3px 5px; border: 1px solid var(--bevel-line-2); background: var(--bevel-sunk); color: var(--bevel-muted); }
92617
- .clay-menu-list [part~="quiet"] { font-size: 12px; color: var(--bevel-muted); }
92618
- .clay-menu-sep { height: 1px; margin: 4px 2px; background: var(--bevel-line); }
92619
- .clay-menu-version { padding: 6px 9px 4px; font: 400 11.5px/1.4 var(--bevel-font-mono); color: var(--bevel-muted); }
92620
- `;
92621
- MENU_TOUCH = `@media (pointer: coarse), (max-width: 680px) {
92622
- .clay-menu-list [role="menuitem"] { min-height: 44px; font-size: 15px; }
92623
- .clay-menu-list .clay-menu-pair [role="menuitem"] { min-height: 44px; }
92624
- :is(.clay-menu-dock, .clay-seo) :is(input, textarea, select) { font-size: 16px; }
92625
- .clay-seo-input, .clay-people-input { min-height: 40px; }
92626
- .clay-menu-btn { min-height: 40px; }
92627
- }
92628
- @media (prefers-reduced-motion: reduce) {
92629
- .clay-menu-track, .clay-menu-thumb { transition: none; }
92630
- }
92631
92706
  `;
92632
92707
  style_default = MENU_BASE + MENU_FLOATING + MENU_SKIN + MENU_TOUCH;
92633
92708
  }
@@ -92764,10 +92839,10 @@ tr.hcms-shell.hcms-inline-ghost { display: table-row; }
92764
92839
  // src/plugins/menu/actions.js
92765
92840
  function whenPresent(get5, ms4 = READY_MS) {
92766
92841
  return new Promise((resolve2) => {
92767
- const start10 = Date.now();
92842
+ const start11 = Date.now();
92768
92843
  const tick = () => {
92769
92844
  const value = get5();
92770
- if (value || Date.now() - start10 >= ms4) resolve2(value || null);
92845
+ if (value || Date.now() - start11 >= ms4) resolve2(value || null);
92771
92846
  else setTimeout(tick, 50);
92772
92847
  };
92773
92848
  tick();
@@ -93189,6 +93264,40 @@ tr.hcms-shell.hcms-inline-ghost { display: table-row; }
93189
93264
  }
93190
93265
  });
93191
93266
 
93267
+ // src/plugins/menu/looks.js
93268
+ function wantedLook() {
93269
+ const name = document.documentElement.getAttribute("look");
93270
+ return name && looks().some((style3) => nameOf(style3) === name) ? name : null;
93271
+ }
93272
+ function activeLook() {
93273
+ const all = looks();
93274
+ const wanted = wantedLook();
93275
+ return all.find((style3) => nameOf(style3) === wanted) || all.find((style3) => style3.getAttribute("media") !== OFF) || all[0] || null;
93276
+ }
93277
+ function paintLook2(name = wantedLook()) {
93278
+ document.querySelector("style[clay-look-hint]")?.remove();
93279
+ if (!name) return;
93280
+ for (const style3 of looks()) {
93281
+ if (nameOf(style3) === name) style3.removeAttribute("media");
93282
+ else if (style3.getAttribute("media") !== OFF) style3.setAttribute("media", OFF);
93283
+ }
93284
+ }
93285
+ function recordLook(name) {
93286
+ if (!carriesLook()) return;
93287
+ if (name) document.documentElement.setAttribute("look", name);
93288
+ else document.documentElement.removeAttribute("look");
93289
+ }
93290
+ var OFF, looks, nameOf, labelOf2, carriesLook;
93291
+ var init_looks = __esm({
93292
+ "src/plugins/menu/looks.js"() {
93293
+ OFF = "not all";
93294
+ looks = () => [...document.querySelectorAll("head style[clay-variant]")];
93295
+ nameOf = (style3) => style3.getAttribute("clay-variant");
93296
+ labelOf2 = (style3) => style3.getAttribute("clay-variant-label") || `Variant ${nameOf(style3)}`;
93297
+ carriesLook = () => /"html@look"/.test(document.querySelector('script[data-rules-name~="api"]')?.textContent ?? "");
93298
+ }
93299
+ });
93300
+
93192
93301
  // src/plugins/menu/variants.js
93193
93302
  function savedName() {
93194
93303
  const all = looks();
@@ -93208,15 +93317,17 @@ tr.hcms-shell.hcms-inline-ghost { display: table-row; }
93208
93317
  }
93209
93318
  }
93210
93319
  function joinNames(list3) {
93211
- const named = list3.map((name) => `Variant ${name}`);
93320
+ const named = list3.map(labelFor);
93212
93321
  return named.length < 2 ? named.join("") : `${named.slice(0, -1).join(", ")} and ${named[named.length - 1]}`;
93213
93322
  }
93214
93323
  function attachVariants({ root: root4, capsule, addItem, removeItem, note, currentMode: currentMode2 }) {
93324
+ paintLook2();
93215
93325
  let previewing = null;
93216
93326
  let pending8 = null;
93217
93327
  let copy13 = null;
93218
93328
  let pill = null;
93219
93329
  let drawn = null;
93330
+ const wantsRow = Boolean(document.querySelector("[clay-menu-slot]")?.hasAttribute("clay-menu-looks"));
93220
93331
  const isEdit = () => currentMode2() === "edit";
93221
93332
  const shown3 = () => previewing ?? savedName();
93222
93333
  const storage2 = () => window.clay && window.clay.storage && window.clay.storage.session;
@@ -93250,6 +93361,7 @@ tr.hcms-shell.hcms-inline-ghost { display: table-row; }
93250
93361
  if (!names().includes(name)) return { ok: false, code: "unknown-variant" };
93251
93362
  pending8 = previewing = null;
93252
93363
  writeHead(CHOOSE_LABEL, () => {
93364
+ recordLook(name);
93253
93365
  for (const style3 of looks()) {
93254
93366
  if (nameOf(style3) === name) style3.removeAttribute("media");
93255
93367
  else if (style3.getAttribute("media") !== OFF) style3.setAttribute("media", OFF);
@@ -93267,6 +93379,7 @@ tr.hcms-shell.hcms-inline-ghost { display: table-row; }
93267
93379
  function keepNow(name) {
93268
93380
  pending8 = previewing = null;
93269
93381
  writeHead(KEEP_LABEL, () => {
93382
+ recordLook(name);
93270
93383
  for (const style3 of looks()) {
93271
93384
  if (nameOf(style3) === name) {
93272
93385
  style3.removeAttribute("clay-variant");
@@ -93284,7 +93397,7 @@ tr.hcms-shell.hcms-inline-ghost { display: table-row; }
93284
93397
  const name = savedName();
93285
93398
  const others = names().filter((other) => other !== name);
93286
93399
  if (!others.length) return Promise.resolve({ ok: false, code: "unknown-variant" });
93287
- const text6 = `Keep Variant ${name} and delete ${joinNames(others)}? The switcher goes away. Version history still has them.`;
93400
+ const text6 = `Keep ${labelFor(name)} and delete ${joinNames(others)}? The switcher goes away. Version history still has them.`;
93288
93401
  return Promise.resolve().then(() => (init_dialogs(), dialogs_exports)).then((m7) => m7.consent(text6)).then(
93289
93402
  () => {
93290
93403
  keepNow(name);
@@ -93349,20 +93462,46 @@ tr.hcms-shell.hcms-inline-ghost { display: table-row; }
93349
93462
  if (all.length < 2) {
93350
93463
  pill?.remove();
93351
93464
  pill = null;
93465
+ removeItem("clay.look");
93466
+ removeItem("clay.look.use");
93352
93467
  removeItem(KEEP_ID);
93353
93468
  return;
93354
93469
  }
93470
+ if (root4.hasAttribute("data-embedded")) {
93471
+ const name2 = shown3();
93472
+ if (wantsRow) {
93473
+ addItem({
93474
+ id: "clay.look",
93475
+ section: "start",
93476
+ stepper: {
93477
+ label: "Switch look",
93478
+ value: `${labelFor(name2)} ${all.indexOf(name2) + 1}/${all.length}`,
93479
+ prev: () => step(-1),
93480
+ next: () => step(1),
93481
+ prevLabel: "Previous look",
93482
+ nextLabel: "Next look"
93483
+ }
93484
+ });
93485
+ } else {
93486
+ removeItem("clay.look");
93487
+ }
93488
+ if (!isEdit() && previewing !== null) addItem({ id: "clay.look.use", section: "start", label: "Use this look", run: useShown });
93489
+ else removeItem("clay.look.use");
93490
+ if (isEdit()) addItem({ id: KEEP_ID, label: `Keep ${labelFor(savedName())}, remove the others\u2026`, run: () => keep3() });
93491
+ else removeItem(KEEP_ID);
93492
+ return;
93493
+ }
93355
93494
  if (!pill) pill = buildPill();
93356
93495
  if (!pill.isConnected) root4.insertBefore(pill, root4.querySelector(".clay-roster") ?? capsule);
93357
93496
  const name = shown3();
93358
93497
  const label = pill.querySelector(".clay-variants-name");
93359
- label.textContent = `Variant ${name} `;
93498
+ label.textContent = `${labelFor(name)} `;
93360
93499
  const count3 = document.createElement("small");
93361
93500
  count3.textContent = `(${all.indexOf(name) + 1}/${all.length})`;
93362
93501
  label.append(count3);
93363
93502
  pill.querySelector(".clay-variants-use").hidden = isEdit() || previewing === null;
93364
93503
  pill.querySelector(".clay-variants-keep").hidden = !isEdit();
93365
- if (isEdit()) addItem({ id: KEEP_ID, label: `Keep Variant ${savedName()}, remove the others\u2026`, run: () => keep3() });
93504
+ if (isEdit()) addItem({ id: KEEP_ID, label: `Keep ${labelFor(savedName())}, remove the others\u2026`, run: () => keep3() });
93366
93505
  else removeItem(KEEP_ID);
93367
93506
  }
93368
93507
  function refresh3() {
@@ -93383,16 +93522,23 @@ tr.hcms-shell.hcms-inline-ghost { display: table-row; }
93383
93522
  }
93384
93523
  refresh3();
93385
93524
  });
93525
+ const followRecord = () => {
93526
+ if (document.documentElement.hasAttribute("look") && names().length > 1) recordLook(savedName());
93527
+ };
93386
93528
  document.addEventListener("clay:sync-applied", () => {
93387
- if (current5()) refresh3();
93529
+ if (!current5()) return;
93530
+ followRecord();
93531
+ refresh3();
93388
93532
  });
93389
93533
  document.addEventListener("clay:undo-change", () => {
93390
- if (current5() && state2() !== drawn) refresh3();
93534
+ if (!current5() || state2() === drawn) return;
93535
+ followRecord();
93536
+ refresh3();
93391
93537
  });
93392
93538
  api = window.clay.variants = {
93393
93539
  list: () => {
93394
93540
  const active4 = savedName();
93395
- return names().map((name) => ({ name, label: `Variant ${name}`, active: name === active4 }));
93541
+ return names().map((name) => ({ name, label: labelFor(name), active: name === active4 }));
93396
93542
  },
93397
93543
  get active() {
93398
93544
  return savedName();
@@ -93409,20 +93555,442 @@ tr.hcms-shell.hcms-inline-ghost { display: table-row; }
93409
93555
  refresh3();
93410
93556
  }
93411
93557
  }
93412
- var OFF, RECEIPT, KEEP_ID, CHOOSE_LABEL, KEEP_LABEL, PREV, NEXT, looks, nameOf, names;
93558
+ var RECEIPT, KEEP_ID, CHOOSE_LABEL, KEEP_LABEL, PREV, NEXT, names, labelFor;
93413
93559
  var init_variants = __esm({
93414
93560
  "src/plugins/menu/variants.js"() {
93415
93561
  init_mode_refusal();
93416
- OFF = "not all";
93562
+ init_looks();
93417
93563
  RECEIPT = "variants-choose";
93418
93564
  KEEP_ID = "clay.variants.keep";
93419
93565
  CHOOSE_LABEL = "Change the page look";
93420
93566
  KEEP_LABEL = "Keep one page look";
93421
93567
  PREV = '<svg viewBox="0 0 6 10" aria-hidden="true" focusable="false"><rect x="4" width="2" height="2"/><rect x="2" y="2" width="2" height="2"/><rect y="4" width="2" height="2"/><rect x="2" y="6" width="2" height="2"/><rect x="4" y="8" width="2" height="2"/></svg>';
93422
93568
  NEXT = '<svg viewBox="0 0 6 10" aria-hidden="true" focusable="false"><rect width="2" height="2"/><rect x="2" y="2" width="2" height="2"/><rect x="4" y="4" width="2" height="2"/><rect x="2" y="6" width="2" height="2"/><rect y="8" width="2" height="2"/></svg>';
93423
- looks = () => [...document.querySelectorAll("head style[clay-variant]")];
93424
- nameOf = (style3) => style3.getAttribute("clay-variant");
93425
93569
  names = () => looks().map(nameOf);
93570
+ labelFor = (name) => {
93571
+ const style3 = looks().find((candidate) => nameOf(candidate) === name);
93572
+ return style3 ? labelOf2(style3) : `Variant ${name}`;
93573
+ };
93574
+ }
93575
+ });
93576
+
93577
+ // src/plugins/menu/dom-items.js
93578
+ async function removeAndSave(el12) {
93579
+ await window.clay?.ready;
93580
+ if (!canSave() || !el12.isConnected) return false;
93581
+ const undo2 = window.clay?.undo;
93582
+ if (undo2 && typeof undo2.commit === "function") undo2.commit("Remove this item", () => el12.remove());
93583
+ else el12.remove();
93584
+ window.clay?.save?.soon?.();
93585
+ return true;
93586
+ }
93587
+ function attachDomItems({ addItem, removeItem, beforeOpen }) {
93588
+ const shown3 = /* @__PURE__ */ new Set();
93589
+ function sync() {
93590
+ const seen = /* @__PURE__ */ new Set();
93591
+ for (const el12 of document.querySelectorAll(SELECTOR5)) {
93592
+ const key3 = el12.getAttribute("data-id") || el12.id;
93593
+ if (!key3) {
93594
+ console.warn("[clay] A clay-menu-item needs a data-id or an id.", el12);
93595
+ continue;
93596
+ }
93597
+ const id = `dom.${key3}`;
93598
+ seen.add(id);
93599
+ const dismiss5 = el12.getAttribute("clay-menu-dismiss");
93600
+ addItem({
93601
+ id,
93602
+ label: el12.textContent.trim(),
93603
+ href: el12.getAttribute("href") || "",
93604
+ section: el12.getAttribute("clay-menu-section") || void 0,
93605
+ quiet: el12.hasAttribute("clay-menu-quiet"),
93606
+ run: el12.hasAttribute("href") ? null : () => el12.click(),
93607
+ dismiss: dismiss5 && canSave() ? { label: dismiss5, run: () => removeAndSave(el12) } : void 0
93608
+ });
93609
+ }
93610
+ for (const id of shown3) if (!seen.has(id)) removeItem(id);
93611
+ shown3.clear();
93612
+ for (const id of seen) shown3.add(id);
93613
+ }
93614
+ beforeOpen.push(sync);
93615
+ for (const name of ["clay:drafts-restored", "clay:sync-applied", "clay:modechange"]) document.addEventListener(name, sync);
93616
+ sync();
93617
+ }
93618
+ var SELECTOR5, canSave;
93619
+ var init_dom_items = __esm({
93620
+ "src/plugins/menu/dom-items.js"() {
93621
+ SELECTOR5 = "[clay-menu-item]:not([cms-template])";
93622
+ canSave = () => window.clay?.mode === "edit" || window.clay?.mode === "draft";
93623
+ }
93624
+ });
93625
+
93626
+ // src/plugins/menu/claygoo.svg.js
93627
+ var claygoo_svg_default;
93628
+ var init_claygoo_svg = __esm({
93629
+ "src/plugins/menu/claygoo.svg.js"() {
93630
+ claygoo_svg_default = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="-45.87 -57.96 100.26 60.98" fill="currentColor" aria-hidden="true" focusable="false"><path fill-rule="evenodd" d="M44.35 -4.56Q40.03 -0.52 34.69 -0.39Q29.34 -0.25 24.81 -0.14Q20.27 -0.02 15.6 0Q10.93 0.02 6.41 0Q1.89 -0.02 -2.79 -0.02Q-7.48 -0.02 -12.11 -0.14Q-16.73 -0.25 -21.64 -0.27Q-26.55 -0.3 -31.72 -2.25Q-36.88 -4.2 -39.87 -9.12Q-42.87 -14.03 -42.8 -19.61Q-42.74 -25.18 -40.43 -29.94Q-38.12 -34.69 -34.82 -38.78Q-31.52 -42.87 -27.25 -45.6Q-22.98 -48.33 -18.35 -50.59Q-13.73 -52.85 -8.7 -53.88Q-3.68 -54.91 1.32 -54.93Q6.32 -54.96 11.44 -54.56Q16.55 -54.16 21.35 -52.2Q26.16 -50.24 30.69 -48.01Q35.22 -45.78 38.99 -42.18Q42.76 -38.59 45.67 -34.37Q48.59 -30.15 49.99 -24.87Q51.39 -19.59 50.04 -14.09Q48.68 -8.6 44.35 -4.56ZM0.66 -30.49C0.5 -28.73 -0.88 -27.42 -2.42 -27.57C-3.96 -27.71 -5.08 -29.25 -4.91 -31.01C-4.75 -32.77 -3.36 -34.08 -1.83 -33.94C-0.29 -33.79 0.83 -32.25 0.66 -30.49ZM13.61 -29.28C13.44 -27.52 12.06 -26.21 10.52 -26.35C8.98 -26.5 7.87 -28.04 8.03 -29.8C8.2 -31.56 9.58 -32.87 11.12 -32.73C12.66 -32.58 13.77 -31.04 13.61 -29.28ZM-1.23 -17.71Q-0.62 -17.35 -0.03 -17.08Q0.56 -16.81 1.15 -16.54Q1.73 -16.28 2.4 -16Q3.07 -15.72 3.87 -15.6Q4.66 -15.48 5.4 -15.55Q6.13 -15.62 6.77 -15.79Q7.41 -15.96 7.97 -16.23Q8.53 -16.5 9 -16.91Q9.46 -17.32 9.73 -17.9Q9.99 -18.47 10.08 -19.12Q10.17 -19.77 10.08 -20.42Q9.99 -21.06 9.45 -21.32Q8.91 -21.58 8.27 -21.38Q7.63 -21.17 6.99 -20.91Q6.36 -20.65 5.7 -20.61Q5.04 -20.56 4.33 -20.73Q3.62 -20.9 2.92 -21.14Q2.23 -21.39 1.54 -21.68Q0.85 -21.97 0.16 -22.27Q-0.52 -22.56 -1.22 -22.79Q-1.92 -23.03 -2.49 -22.61Q-3.05 -22.19 -3.23 -21.5Q-3.4 -20.81 -3.2 -20.09Q-3.01 -19.38 -3.02 -19.15Q-3.02 -18.93 -2.42 -18.5Q-1.83 -18.06 -1.23 -17.71Z"/></svg>';
93631
+ }
93632
+ });
93633
+
93634
+ // src/plugins/menu/shell.js
93635
+ function findSlot() {
93636
+ const slots = document.querySelectorAll("[clay-menu-slot]");
93637
+ if (slots.length > 1) console.warn("[clay] This page has more than one clay-menu-slot. The menu uses the first.");
93638
+ return slots[0] || null;
93639
+ }
93640
+ function pageSkin() {
93641
+ const style3 = document.querySelector("style[clay-menu-skin]");
93642
+ if (!style3) return null;
93643
+ if (style3.getAttribute("clay-menu-skin") !== SKIN_VERSION) {
93644
+ console.warn(`[clay] This runtime reads clay-menu-skin="${SKIN_VERSION}". The menu keeps its default look.`);
93645
+ return null;
93646
+ }
93647
+ return style3.textContent;
93648
+ }
93649
+ function createShell({ capsuleStart = "", sections = [null] } = {}) {
93650
+ const slotted = new Set(sections.flat().filter(Boolean));
93651
+ const slot3 = findSlot();
93652
+ const embedded = Boolean(slot3);
93653
+ const skin = embedded ? pageSkin() : null;
93654
+ const root4 = document.createElement("div");
93655
+ root4.className = "clay-menu-dock";
93656
+ root4.setAttribute("clay", "editor-ui");
93657
+ root4.setAttribute("part", "dock");
93658
+ if (embedded) root4.dataset.embedded = "";
93659
+ root4.dataset.corner = "top-right";
93660
+ root4.innerHTML = `<div class="clay-menu" part="capsule" clay="editor-ui">` + capsuleStart + `<button type="button" class="clay-menu-goo" part="button" aria-haspopup="menu" aria-expanded="false" aria-label="Clay menu">${claygoo_svg_default}</button></div><div class="clay-menu-list" part="list" role="menu" aria-label="Clay menu" hidden></div><div class="clay-menu-note" part="note" role="status" hidden></div>`;
93661
+ const goo = root4.querySelector(".clay-menu-goo");
93662
+ const list3 = root4.querySelector(".clay-menu-list");
93663
+ const noteEl = root4.querySelector(".clay-menu-note");
93664
+ const items = /* @__PURE__ */ new Map();
93665
+ const beforeOpen = [];
93666
+ if (embedded) {
93667
+ const icon2 = slot3.querySelector("template[clay-menu-icon]");
93668
+ if (icon2) goo.replaceChildren(icon2.content.cloneNode(true));
93669
+ const name = slot3.getAttribute("clay-menu-label");
93670
+ if (name) {
93671
+ goo.setAttribute("aria-label", name);
93672
+ goo.title = name;
93673
+ list3.setAttribute("aria-label", name);
93674
+ }
93675
+ }
93676
+ const topLayer = embedded && typeof list3.showPopover === "function";
93677
+ if (topLayer) list3.setAttribute("popover", "manual");
93678
+ function placeList() {
93679
+ const anchor = goo.getBoundingClientRect();
93680
+ const { offsetWidth: width, offsetHeight: height } = list3;
93681
+ const left = Math.max(EDGE_GAP, Math.min(anchor.right - width, window.innerWidth - width - EDGE_GAP));
93682
+ const below = anchor.bottom + EDGE_GAP;
93683
+ const top = below + height > window.innerHeight - EDGE_GAP ? Math.max(EDGE_GAP, anchor.top - height - EDGE_GAP) : below;
93684
+ list3.style.left = `${Math.round(left)}px`;
93685
+ list3.style.top = `${Math.round(top)}px`;
93686
+ }
93687
+ const focusedEl = () => root4.getRootNode().activeElement || null;
93688
+ const isOpen = () => !list3.hidden;
93689
+ function setExpanded(open5) {
93690
+ list3.hidden = !open5;
93691
+ goo.setAttribute("aria-expanded", open5 ? "true" : "false");
93692
+ if (!topLayer) return;
93693
+ if (open5) {
93694
+ list3.showPopover();
93695
+ placeList();
93696
+ } else if (list3.matches(":popover-open")) {
93697
+ list3.hidePopover();
93698
+ }
93699
+ }
93700
+ const buttons2 = () => [...list3.querySelectorAll('[role^="menuitem"]:not([aria-disabled="true"])')];
93701
+ function focusItem(index) {
93702
+ const all = buttons2();
93703
+ if (!all.length) return;
93704
+ all[(index + all.length) % all.length].focus();
93705
+ }
93706
+ function close() {
93707
+ if (!isOpen()) return;
93708
+ setExpanded(false);
93709
+ }
93710
+ function open4() {
93711
+ if (isOpen()) return;
93712
+ for (const fn5 of beforeOpen) fn5();
93713
+ render4();
93714
+ setExpanded(true);
93715
+ }
93716
+ function itemButton(item) {
93717
+ const link2 = item.href && !item.disabled;
93718
+ const button4 = document.createElement(link2 ? "a" : "button");
93719
+ if (link2) {
93720
+ button4.href = item.href;
93721
+ button4.target = "_blank";
93722
+ button4.rel = "noopener";
93723
+ } else {
93724
+ button4.type = "button";
93725
+ }
93726
+ button4.setAttribute("role", "menuitem");
93727
+ button4.setAttribute("part", item.quiet ? "item quiet" : "item");
93728
+ button4.dataset.menuId = item.id;
93729
+ if (item.badge && item.id === "upgrade") {
93730
+ const label = document.createElement("span");
93731
+ label.className = "clay-menu-upgrade";
93732
+ label.textContent = item.label;
93733
+ button4.append(label);
93734
+ } else {
93735
+ button4.textContent = item.label;
93736
+ }
93737
+ if (item.keys) {
93738
+ const kbd = document.createElement("kbd");
93739
+ kbd.textContent = item.keys;
93740
+ button4.append(kbd);
93741
+ }
93742
+ if (item.toggle) {
93743
+ button4.setAttribute("role", "menuitemcheckbox");
93744
+ button4.setAttribute("aria-checked", item.checked ? "true" : "false");
93745
+ button4.classList.add("clay-menu-toggle");
93746
+ button4.insertAdjacentHTML("beforeend", TRACK);
93747
+ }
93748
+ if (item.disabled) button4.setAttribute("aria-disabled", "true");
93749
+ button4.addEventListener("click", () => {
93750
+ if (item.disabled) return;
93751
+ if (!item.toggle && !item.keepOpen) close();
93752
+ if (item.run) item.run({ anchor: goo });
93753
+ });
93754
+ return button4;
93755
+ }
93756
+ function itemNode(item) {
93757
+ if (item.text) {
93758
+ const line = document.createElement("p");
93759
+ line.className = "clay-menu-version";
93760
+ line.setAttribute("part", "text");
93761
+ line.dataset.menuId = item.id;
93762
+ line.textContent = item.label;
93763
+ return line;
93764
+ }
93765
+ if (item.pair) {
93766
+ const pair2 = document.createElement("div");
93767
+ pair2.className = "clay-menu-pair";
93768
+ pair2.dataset.menuId = item.id;
93769
+ for (const part of item.pair) pair2.append(itemButton(part));
93770
+ return pair2;
93771
+ }
93772
+ if (item.stepper) return stepperRow(item);
93773
+ if (item.dismiss) return dismissibleRow(item);
93774
+ return itemButton(item);
93775
+ }
93776
+ function dismissibleRow(item) {
93777
+ const row = document.createElement("div");
93778
+ row.className = "clay-menu-row";
93779
+ row.dataset.menuId = item.id;
93780
+ const dismiss5 = document.createElement("button");
93781
+ dismiss5.type = "button";
93782
+ dismiss5.setAttribute("role", "menuitem");
93783
+ dismiss5.setAttribute("part", "dismiss");
93784
+ dismiss5.dataset.menuId = `${item.id}.dismiss`;
93785
+ dismiss5.setAttribute("aria-label", item.dismiss.label);
93786
+ dismiss5.title = item.dismiss.label;
93787
+ dismiss5.innerHTML = DISMISS_ICON;
93788
+ dismiss5.addEventListener("click", async () => {
93789
+ dismiss5.disabled = true;
93790
+ let result2;
93791
+ try {
93792
+ result2 = await item.dismiss.run?.();
93793
+ } catch (error2) {
93794
+ console.warn("[clay] A menu item could not be removed.", error2);
93795
+ dismiss5.disabled = false;
93796
+ note("That didn't work. Try again.");
93797
+ return;
93798
+ }
93799
+ if (result2 === false) {
93800
+ dismiss5.disabled = false;
93801
+ return;
93802
+ }
93803
+ removeItem(item.id);
93804
+ });
93805
+ row.append(itemButton(item), dismiss5);
93806
+ return row;
93807
+ }
93808
+ function stepperRow(item) {
93809
+ const { label, value, prevLabel, nextLabel } = item.stepper;
93810
+ const row = document.createElement("div");
93811
+ row.className = "clay-menu-stepper";
93812
+ row.setAttribute("part", "stepper");
93813
+ row.dataset.menuId = item.id;
93814
+ const text6 = document.createElement("span");
93815
+ text6.className = "clay-menu-stepper-label";
93816
+ text6.textContent = label;
93817
+ const shown3 = document.createElement("span");
93818
+ shown3.className = "clay-menu-stepper-value";
93819
+ shown3.setAttribute("aria-live", "polite");
93820
+ shown3.textContent = value;
93821
+ const step = (suffix, icon2, name) => {
93822
+ const button4 = document.createElement("button");
93823
+ button4.type = "button";
93824
+ button4.setAttribute("role", "menuitem");
93825
+ button4.setAttribute("part", "step");
93826
+ button4.setAttribute("aria-label", name);
93827
+ button4.dataset.menuId = `${item.id}.${suffix}`;
93828
+ button4.innerHTML = icon2;
93829
+ button4.addEventListener("click", () => items.get(item.id)?.stepper?.[suffix]?.());
93830
+ return button4;
93831
+ };
93832
+ row.append(text6, step("prev", ARROW_PREV, prevLabel), shown3, step("next", ARROW_NEXT, nextLabel));
93833
+ return row;
93834
+ }
93835
+ function grouped() {
93836
+ const inSection = (name) => [...items.values()].filter((item) => item.section === name);
93837
+ const extra = [...items.keys()].filter((id) => !slotted.has(id) && !items.get(id).section);
93838
+ const fixed = sections.map((ids) => (ids || extra).map((id) => items.get(id)).filter(Boolean));
93839
+ return [inSection("start"), ...fixed, inSection("end")].filter((group) => group.length);
93840
+ }
93841
+ function render4() {
93842
+ const now3 = focusedEl();
93843
+ const focused = now3 && list3.contains(now3) ? now3.dataset.menuId : null;
93844
+ list3.textContent = "";
93845
+ grouped().forEach((group, index) => {
93846
+ if (index) {
93847
+ const sep = document.createElement("div");
93848
+ sep.className = "clay-menu-sep";
93849
+ sep.setAttribute("role", "separator");
93850
+ sep.setAttribute("part", "separator");
93851
+ list3.append(sep);
93852
+ }
93853
+ for (const item of group) list3.append(itemNode(item));
93854
+ });
93855
+ const dot2 = goo.querySelector(".clay-menu-dot");
93856
+ const wanted = [...items.values()].some((item) => item.badge);
93857
+ if (wanted && !dot2) {
93858
+ const mark2 = document.createElement("span");
93859
+ mark2.className = "clay-menu-dot";
93860
+ mark2.setAttribute("aria-hidden", "true");
93861
+ goo.append(mark2);
93862
+ } else if (!wanted && dot2) {
93863
+ dot2.remove();
93864
+ }
93865
+ if (focused) {
93866
+ const again = buttons2().find((button4) => button4.dataset.menuId === focused);
93867
+ if (again) again.focus();
93868
+ else focusItem(0);
93869
+ }
93870
+ }
93871
+ const clean2 = ({ id, label, run: run5, badge, keys: keys2, disabled, href, keepOpen }) => ({
93872
+ id,
93873
+ href: typeof href === "string" ? href : "",
93874
+ label: String(label ?? ""),
93875
+ run: typeof run5 === "function" ? run5 : null,
93876
+ badge: Boolean(badge),
93877
+ keys: keys2 ? String(keys2) : "",
93878
+ disabled: Boolean(disabled),
93879
+ keepOpen: Boolean(keepOpen)
93880
+ });
93881
+ function addItem({ id, label, run: run5, badge, keys: keys2, disabled, text: text6, pair: pair2, href, section, quiet, dismiss: dismiss5, toggle: toggle3, checked, keepOpen, stepper } = {}) {
93882
+ if (!id) return null;
93883
+ const item = clean2({ id, label, run: run5, badge, keys: keys2, disabled, href, keepOpen });
93884
+ if (section === "start" || section === "end") item.section = section;
93885
+ if (quiet) item.quiet = true;
93886
+ if (stepper) {
93887
+ item.stepper = {
93888
+ label: String(stepper.label ?? ""),
93889
+ value: String(stepper.value ?? ""),
93890
+ prev: typeof stepper.prev === "function" ? stepper.prev : null,
93891
+ next: typeof stepper.next === "function" ? stepper.next : null,
93892
+ prevLabel: String(stepper.prevLabel || "Previous"),
93893
+ nextLabel: String(stepper.nextLabel || "Next")
93894
+ };
93895
+ const shown3 = [...list3.querySelectorAll(".clay-menu-stepper")].find((row) => row.dataset.menuId === id)?.querySelector(".clay-menu-stepper-value");
93896
+ const before = items.get(id);
93897
+ const same8 = before?.stepper && ["label", "prevLabel", "nextLabel"].every((key3) => before.stepper[key3] === item.stepper[key3]) && before.section === item.section && before.quiet === item.quiet;
93898
+ if (same8 && shown3) {
93899
+ items.set(id, item);
93900
+ shown3.textContent = item.stepper.value;
93901
+ return id;
93902
+ }
93903
+ }
93904
+ if (text6) item.text = true;
93905
+ if (Array.isArray(pair2)) item.pair = pair2.map(clean2);
93906
+ if (toggle3) {
93907
+ item.toggle = true;
93908
+ item.checked = Boolean(checked);
93909
+ }
93910
+ if (dismiss5) item.dismiss = { label: String(dismiss5.label || "Dismiss"), run: typeof dismiss5.run === "function" ? dismiss5.run : null };
93911
+ items.set(id, item);
93912
+ render4();
93913
+ return id;
93914
+ }
93915
+ function removeItem(id) {
93916
+ if (items.delete(id)) render4();
93917
+ }
93918
+ function note(text6) {
93919
+ if (!text6) return;
93920
+ noteEl.textContent = text6;
93921
+ noteEl.hidden = false;
93922
+ clearTimeout(noteTimer);
93923
+ noteTimer = setTimeout(() => {
93924
+ noteEl.hidden = true;
93925
+ noteEl.textContent = "";
93926
+ }, NOTE_MS);
93927
+ }
93928
+ let noteTimer = 0;
93929
+ goo.addEventListener("click", () => {
93930
+ if (isOpen()) close();
93931
+ else open4();
93932
+ });
93933
+ document.addEventListener("click", (event) => {
93934
+ if (isOpen() && !event.composedPath().includes(root4)) close();
93935
+ });
93936
+ root4.addEventListener("keydown", (event) => {
93937
+ if (event.key === "Escape") {
93938
+ if (!isOpen()) return;
93939
+ event.preventDefault();
93940
+ close();
93941
+ goo.focus();
93942
+ return;
93943
+ }
93944
+ if (event.target === goo && (event.key === "Enter" || event.key === " ")) {
93945
+ event.preventDefault();
93946
+ if (isOpen()) close();
93947
+ else {
93948
+ open4();
93949
+ focusItem(0);
93950
+ }
93951
+ return;
93952
+ }
93953
+ if (!isOpen()) return;
93954
+ if (event.key === "Enter" && list3.contains(event.target)) {
93955
+ event.preventDefault();
93956
+ event.target.click();
93957
+ return;
93958
+ }
93959
+ const all = buttons2();
93960
+ if (!all.length) return;
93961
+ const at8 = all.indexOf(focusedEl());
93962
+ if (event.key === "ArrowDown") {
93963
+ event.preventDefault();
93964
+ focusItem(at8 < 0 ? 0 : at8 + 1);
93965
+ } else if (event.key === "ArrowUp") {
93966
+ event.preventDefault();
93967
+ focusItem(at8 < 0 ? all.length - 1 : at8 - 1);
93968
+ }
93969
+ });
93970
+ function mount6(css) {
93971
+ const ui7 = mountEditorUI({ name: "menu", content: root4, css, parent: slot3 || document.body, attributes: { "clay-mode-toggle": "" } });
93972
+ if (embedded) {
93973
+ window.addEventListener("resize", close);
93974
+ window.addEventListener("scroll", () => {
93975
+ if (topLayer && isOpen()) placeList();
93976
+ }, { capture: true, passive: true });
93977
+ }
93978
+ return ui7;
93979
+ }
93980
+ return { root: root4, goo, list: list3, slot: slot3, embedded, skin, items, addItem, removeItem, render: render4, open: open4, close, isOpen, note, beforeOpen, focusedEl, mount: mount6 };
93981
+ }
93982
+ var SKIN_VERSION, EDGE_GAP, DISMISS_ICON, ARROW_PREV, ARROW_NEXT, TRACK, NOTE_MS;
93983
+ var init_shell = __esm({
93984
+ "src/plugins/menu/shell.js"() {
93985
+ init_claygoo_svg();
93986
+ init_editor_ui();
93987
+ SKIN_VERSION = "1";
93988
+ EDGE_GAP = 8;
93989
+ DISMISS_ICON = '<svg viewBox="0 0 10 10" aria-hidden="true" focusable="false"><path d="M1 0 5 4l4-4 1 1-4 4 4 4-1 1-4-4-4 4-1-1 4-4-4-4z"/></svg>';
93990
+ ARROW_PREV = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" aria-hidden="true" focusable="false"><path d="M224,128a8,8,0,0,1-8,8H59.31l58.35,58.34a8,8,0,0,1-11.32,11.32l-72-72a8,8,0,0,1,0-11.32l72-72a8,8,0,0,1,11.32,11.32L59.31,120H216A8,8,0,0,1,224,128Z"/></svg>';
93991
+ ARROW_NEXT = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" aria-hidden="true" focusable="false"><path d="M221.66,133.66l-72,72a8,8,0,0,1-11.32-11.32L196.69,136H40a8,8,0,0,1,0-16H196.69L138.34,61.66a8,8,0,0,1,11.32-11.32l72,72A8,8,0,0,1,221.66,133.66Z"/></svg>';
93992
+ TRACK = '<span class="clay-menu-track" aria-hidden="true"><span class="clay-menu-thumb"></span></span>';
93993
+ NOTE_MS = 6e3;
93426
93994
  }
93427
93995
  });
93428
93996
 
@@ -94410,247 +94978,36 @@ textarea.clay-seo-input.is-short { min-height: 32px; }
94410
94978
 
94411
94979
  // src/plugins/menu.js
94412
94980
  var menu_exports = {};
94413
- function findSlot() {
94414
- const slots = document.querySelectorAll("[clay-menu-slot]");
94415
- if (slots.length > 1) console.warn("[clay] This page has more than one clay-menu-slot. The menu uses the first.");
94416
- return slots[0] || null;
94417
- }
94418
- function pageSkin() {
94419
- const style3 = document.querySelector("style[clay-menu-skin]");
94420
- if (!style3) return null;
94421
- if (style3.getAttribute("clay-menu-skin") !== SKIN_VERSION) {
94422
- console.warn(`[clay] This runtime reads clay-menu-skin="${SKIN_VERSION}". The menu keeps its default look.`);
94423
- return null;
94424
- }
94425
- return style3.textContent;
94426
- }
94427
94981
  function mount3() {
94428
94982
  if (document.querySelector('clay-editor-ui[data-clay-ui="menu"]')) return;
94429
- const slot3 = findSlot();
94430
- const embedded = Boolean(slot3);
94431
- const skin = embedded ? pageSkin() : null;
94983
+ const shell = createShell({
94984
+ sections: SECTIONS,
94985
+ capsuleStart: `<button type="button" class="clay-menu-grip" aria-label="Move the menu. Drag it, or use the arrow keys to move it to another corner.">${GRIP}</button><button type="button" class="clay-menu-edit" part="edit" role="switch" aria-checked="false">` + TRACK + `<span class="clay-menu-label">Edit</span></button><span class="clay-menu-divider" aria-hidden="true"></span>`
94986
+ });
94987
+ const { root: root4, goo, slot: slot3, embedded, skin, addItem, removeItem, open: open4, close, note: showNote2, beforeOpen, focusedEl, mount: mountShell } = shell;
94432
94988
  const hideSwitch = embedded && slot3.hasAttribute("no-edit-switch");
94433
- const root4 = document.createElement("div");
94434
- root4.className = "clay-menu-dock";
94435
- root4.setAttribute("clay", "editor-ui");
94436
- root4.setAttribute("part", "dock");
94437
- if (embedded) root4.dataset.embedded = "";
94438
- root4.dataset.corner = "top-right";
94439
- root4.innerHTML = `<div class="clay-menu" part="capsule" clay="editor-ui"><button type="button" class="clay-menu-grip" aria-label="Move the menu. Drag it, or use the arrow keys to move it to another corner.">${GRIP}</button><button type="button" class="clay-menu-edit" part="edit" role="switch" aria-checked="false"><span class="clay-menu-track" aria-hidden="true"><span class="clay-menu-thumb"></span></span><span class="clay-menu-label">Edit</span></button><span class="clay-menu-divider" aria-hidden="true"></span><button type="button" class="clay-menu-goo" part="button" aria-haspopup="menu" aria-expanded="false" aria-label="Clay menu">${claygoo_svg_default}</button></div><div class="clay-menu-list" part="list" role="menu" aria-label="Clay menu" hidden></div><div class="clay-menu-note" part="note" role="status" hidden></div>`;
94440
94989
  const grip = root4.querySelector(".clay-menu-grip");
94441
94990
  const edit3 = root4.querySelector(".clay-menu-edit");
94442
- const goo = root4.querySelector(".clay-menu-goo");
94443
- const list3 = root4.querySelector(".clay-menu-list");
94444
- const noteEl = root4.querySelector(".clay-menu-note");
94445
- const items = /* @__PURE__ */ new Map();
94446
94991
  if (embedded) {
94447
94992
  grip.hidden = true;
94448
- const icon2 = slot3.querySelector("template[clay-menu-icon]");
94449
- if (icon2) goo.replaceChildren(icon2.content.cloneNode(true));
94450
- const name = slot3.getAttribute("clay-menu-label");
94451
- if (name) {
94452
- goo.setAttribute("aria-label", name);
94453
- goo.title = name;
94454
- list3.setAttribute("aria-label", name);
94455
- }
94456
94993
  if (hideSwitch) {
94457
94994
  edit3.hidden = true;
94458
94995
  root4.querySelector(".clay-menu-divider").hidden = true;
94459
94996
  }
94460
94997
  }
94461
- const topLayer = embedded && typeof list3.showPopover === "function";
94462
- if (topLayer) list3.setAttribute("popover", "manual");
94463
- function placeList() {
94464
- const anchor = goo.getBoundingClientRect();
94465
- const { offsetWidth: width, offsetHeight: height } = list3;
94466
- const left = Math.max(EDGE_GAP, Math.min(anchor.right - width, window.innerWidth - width - EDGE_GAP));
94467
- const below = anchor.bottom + EDGE_GAP;
94468
- const top = below + height > window.innerHeight - EDGE_GAP ? Math.max(EDGE_GAP, anchor.top - height - EDGE_GAP) : below;
94469
- list3.style.left = `${Math.round(left)}px`;
94470
- list3.style.top = `${Math.round(top)}px`;
94471
- }
94472
- const focusedEl = () => root4.getRootNode().activeElement || null;
94473
- const isOpen = () => !list3.hidden;
94474
- function setExpanded(open5) {
94475
- list3.hidden = !open5;
94476
- goo.setAttribute("aria-expanded", open5 ? "true" : "false");
94477
- if (!topLayer) return;
94478
- if (open5) {
94479
- list3.showPopover();
94480
- placeList();
94481
- } else if (list3.matches(":popover-open")) {
94482
- list3.hidePopover();
94483
- }
94484
- }
94485
- const buttons2 = () => [...list3.querySelectorAll('[role="menuitem"]:not([aria-disabled="true"])')];
94486
- function focusItem(index) {
94487
- const all = buttons2();
94488
- if (!all.length) return;
94489
- all[(index + all.length) % all.length].focus();
94490
- }
94491
- function close() {
94492
- if (!isOpen()) return;
94493
- setExpanded(false);
94494
- }
94495
94998
  let actions = null;
94496
94999
  let people2 = null;
94497
- function open4() {
94498
- if (isOpen()) return;
95000
+ beforeOpen.push(() => {
94499
95001
  people2?.close({ restore: false });
94500
95002
  actions?.refresh();
94501
- render4();
94502
- setExpanded(true);
94503
- }
94504
- function itemButton(item) {
94505
- const link2 = item.href && !item.disabled;
94506
- const button4 = document.createElement(link2 ? "a" : "button");
94507
- if (link2) {
94508
- button4.href = item.href;
94509
- button4.target = "_blank";
94510
- button4.rel = "noopener";
94511
- } else {
94512
- button4.type = "button";
94513
- }
94514
- button4.setAttribute("role", "menuitem");
94515
- button4.setAttribute("part", item.quiet ? "item quiet" : "item");
94516
- button4.dataset.menuId = item.id;
94517
- if (item.badge && item.id === "upgrade") {
94518
- const label = document.createElement("span");
94519
- label.className = "clay-menu-upgrade";
94520
- label.textContent = item.label;
94521
- button4.append(label);
94522
- } else {
94523
- button4.textContent = item.label;
94524
- }
94525
- if (item.keys) {
94526
- const kbd = document.createElement("kbd");
94527
- kbd.textContent = item.keys;
94528
- button4.append(kbd);
94529
- }
94530
- if (item.disabled) button4.setAttribute("aria-disabled", "true");
94531
- button4.addEventListener("click", () => {
94532
- if (item.disabled) return;
94533
- close();
94534
- if (item.run) item.run({ anchor: goo });
94535
- });
94536
- return button4;
94537
- }
94538
- function itemNode(item) {
94539
- if (item.text) {
94540
- const line = document.createElement("p");
94541
- line.className = "clay-menu-version";
94542
- line.setAttribute("part", "text");
94543
- line.dataset.menuId = item.id;
94544
- line.textContent = item.label;
94545
- return line;
94546
- }
94547
- if (item.pair) {
94548
- const pair2 = document.createElement("div");
94549
- pair2.className = "clay-menu-pair";
94550
- pair2.dataset.menuId = item.id;
94551
- for (const part of item.pair) pair2.append(itemButton(part));
94552
- return pair2;
94553
- }
94554
- if (item.dismiss) return dismissibleRow(item);
94555
- return itemButton(item);
94556
- }
94557
- function dismissibleRow(item) {
94558
- const row = document.createElement("div");
94559
- row.className = "clay-menu-row";
94560
- row.dataset.menuId = item.id;
94561
- const dismiss5 = document.createElement("button");
94562
- dismiss5.type = "button";
94563
- dismiss5.setAttribute("role", "menuitem");
94564
- dismiss5.setAttribute("part", "dismiss");
94565
- dismiss5.dataset.menuId = `${item.id}.dismiss`;
94566
- dismiss5.setAttribute("aria-label", item.dismiss.label);
94567
- dismiss5.title = item.dismiss.label;
94568
- dismiss5.innerHTML = DISMISS_ICON;
94569
- dismiss5.addEventListener("click", () => {
94570
- removeItem(item.id);
94571
- item.dismiss.run?.();
94572
- });
94573
- row.append(itemButton(item), dismiss5);
94574
- return row;
94575
- }
94576
- function sections() {
94577
- const inSection = (name) => [...items.values()].filter((item) => item.section === name);
94578
- const extra = [...items.keys()].filter((id) => !SLOTTED.has(id) && !items.get(id).section);
94579
- const fixed = SECTIONS.map((ids) => (ids || extra).map((id) => items.get(id)).filter(Boolean));
94580
- return [inSection("start"), ...fixed, inSection("end")].filter((group) => group.length);
94581
- }
94582
- function render4() {
94583
- const now3 = focusedEl();
94584
- const focused = now3 && list3.contains(now3) ? now3.dataset.menuId : null;
94585
- list3.textContent = "";
94586
- sections().forEach((group, index) => {
94587
- if (index) {
94588
- const sep = document.createElement("div");
94589
- sep.className = "clay-menu-sep";
94590
- sep.setAttribute("role", "separator");
94591
- sep.setAttribute("part", "separator");
94592
- list3.append(sep);
94593
- }
94594
- for (const item of group) list3.append(itemNode(item));
94595
- });
94596
- const dot2 = goo.querySelector(".clay-menu-dot");
94597
- const wanted = [...items.values()].some((item) => item.badge);
94598
- if (wanted && !dot2) {
94599
- const mark2 = document.createElement("span");
94600
- mark2.className = "clay-menu-dot";
94601
- mark2.setAttribute("aria-hidden", "true");
94602
- goo.append(mark2);
94603
- } else if (!wanted && dot2) {
94604
- dot2.remove();
94605
- }
94606
- if (focused) {
94607
- const again = buttons2().find((button4) => button4.dataset.menuId === focused);
94608
- if (again) again.focus();
94609
- else focusItem(0);
94610
- }
94611
- }
94612
- const clean2 = ({ id, label, run: run5, badge, keys: keys2, disabled, href }) => ({
94613
- id,
94614
- href: typeof href === "string" ? href : "",
94615
- label: String(label ?? ""),
94616
- run: typeof run5 === "function" ? run5 : null,
94617
- badge: Boolean(badge),
94618
- keys: keys2 ? String(keys2) : "",
94619
- disabled: Boolean(disabled)
94620
95003
  });
94621
- function addItem({ id, label, run: run5, badge, keys: keys2, disabled, text: text6, pair: pair2, href, section, quiet, dismiss: dismiss5 } = {}) {
94622
- if (!id) return null;
94623
- const item = clean2({ id, label, run: run5, badge, keys: keys2, disabled, href });
94624
- if (text6) item.text = true;
94625
- if (Array.isArray(pair2)) item.pair = pair2.map(clean2);
94626
- if (section === "start" || section === "end") item.section = section;
94627
- if (quiet) item.quiet = true;
94628
- if (dismiss5) item.dismiss = { label: String(dismiss5.label || "Dismiss"), run: typeof dismiss5.run === "function" ? dismiss5.run : null };
94629
- items.set(id, item);
94630
- render4();
94631
- return id;
94632
- }
94633
- function removeItem(id) {
94634
- if (items.delete(id)) render4();
94635
- }
94636
- function showNote2(text6) {
94637
- if (!text6) return;
94638
- noteEl.textContent = text6;
94639
- noteEl.hidden = false;
94640
- clearTimeout(noteTimer);
94641
- noteTimer = setTimeout(() => {
94642
- noteEl.hidden = true;
94643
- noteEl.textContent = "";
94644
- }, NOTE_MS);
94645
- }
94646
- let noteTimer = 0;
94647
95004
  let busy2 = false;
94648
95005
  const applyHidden = () => {
94649
95006
  root4.hidden = !canEdit && currentMode() !== "edit";
94650
95007
  };
94651
95008
  function setChecked() {
94652
95009
  edit3.setAttribute("aria-checked", currentMode() === "edit" ? "true" : "false");
94653
- if (hideSwitch) addItem({ id: "clay.mode", label: currentMode() === "edit" ? "View mode" : "Edit mode", section: "start", run: () => edit3.click() });
95010
+ if (hideSwitch) addItem({ id: "clay.mode", label: "Edit mode", toggle: true, checked: currentMode() === "edit", run: () => edit3.click() });
94654
95011
  }
94655
95012
  setChecked();
94656
95013
  document.addEventListener("clay:modechange", setChecked);
@@ -94681,47 +95038,6 @@ textarea.clay-seo-input.is-short { min-height: 32px; }
94681
95038
  setChecked();
94682
95039
  }
94683
95040
  });
94684
- goo.addEventListener("click", () => {
94685
- if (isOpen()) close();
94686
- else open4();
94687
- });
94688
- document.addEventListener("click", (event) => {
94689
- if (isOpen() && !event.composedPath().includes(root4)) close();
94690
- });
94691
- root4.addEventListener("keydown", (event) => {
94692
- if (event.key === "Escape") {
94693
- if (!isOpen()) return;
94694
- event.preventDefault();
94695
- close();
94696
- goo.focus();
94697
- return;
94698
- }
94699
- if (event.target === goo && (event.key === "Enter" || event.key === " ")) {
94700
- event.preventDefault();
94701
- if (isOpen()) close();
94702
- else {
94703
- open4();
94704
- focusItem(0);
94705
- }
94706
- return;
94707
- }
94708
- if (!isOpen()) return;
94709
- if (event.key === "Enter" && list3.contains(event.target)) {
94710
- event.preventDefault();
94711
- event.target.click();
94712
- return;
94713
- }
94714
- const all = buttons2();
94715
- if (!all.length) return;
94716
- const at8 = all.indexOf(focusedEl());
94717
- if (event.key === "ArrowDown") {
94718
- event.preventDefault();
94719
- focusItem(at8 < 0 ? 0 : at8 + 1);
94720
- } else if (event.key === "ArrowUp") {
94721
- event.preventDefault();
94722
- focusItem(at8 < 0 ? all.length - 1 : at8 - 1);
94723
- }
94724
- });
94725
95041
  const doc = document;
94726
95042
  let introObserver = null;
94727
95043
  let watched = null;
@@ -94763,14 +95079,9 @@ textarea.clay-seo-input.is-short { min-height: 32px; }
94763
95079
  const rect = root4.getBoundingClientRect();
94764
95080
  vars.textContent = `:root { --clay-menu-width: ${Math.ceil(rect.width)}px; --clay-menu-height: ${Math.ceil(rect.height)}px; }`;
94765
95081
  }
94766
- const css = embedded ? [MENU_BASE, skin ?? MENU_SKIN, MENU_TOUCH] : [MENU_BASE, MENU_FLOATING, MENU_SKIN, MENU_TOUCH];
94767
- const ui7 = mountEditorUI({ name: "menu", content: root4, css, parent: slot3 || document.body, attributes: { "clay-mode-toggle": "" } });
94768
- if (embedded) {
94769
- window.addEventListener("resize", close);
94770
- window.addEventListener("scroll", () => {
94771
- if (topLayer && isOpen()) placeList();
94772
- }, { capture: true, passive: true });
94773
- } else {
95082
+ const css = embedded ? [MENU_SAFETY, MENU_BASE, skin ?? MENU_SKIN, MENU_TOUCH] : [MENU_SAFETY, MENU_BASE, MENU_FLOATING, MENU_SKIN, MENU_TOUCH];
95083
+ const ui7 = mountShell(css);
95084
+ if (!embedded) {
94774
95085
  attachPlacement({
94775
95086
  dock: root4,
94776
95087
  container: ui7.shadow,
@@ -94792,6 +95103,7 @@ textarea.clay-seo-input.is-short { min-height: 32px; }
94792
95103
  actions = attachActions({ addItem, note: showNote2, currentMode });
94793
95104
  people2 = attachPeople({ root: root4, capsule: root4.querySelector(".clay-menu"), addItem, removeItem, closeMenu: close, note: showNote2 });
94794
95105
  attachVariants({ root: root4, capsule: root4.querySelector(".clay-menu"), addItem, removeItem, note: showNote2, currentMode });
95106
+ attachDomItems({ addItem, removeItem, beforeOpen });
94795
95107
  if (SEO_ITEM) {
94796
95108
  addItem({
94797
95109
  id: "seo",
@@ -94816,25 +95128,22 @@ textarea.clay-seo-input.is-short { min-height: 32px; }
94816
95128
  mounted = true;
94817
95129
  mount3();
94818
95130
  }
94819
- var SEO_ITEM, SKIN_VERSION, EDGE_GAP, DISMISS_ICON, NOTE_MS, INTRO_GAP, GRIP, SECTIONS, SLOTTED, currentMode, mounted, followCapability, shouldMount;
95131
+ var SEO_ITEM, INTRO_GAP, GRIP, SECTIONS, currentMode, mounted, followCapability, shouldMount;
94820
95132
  var init_menu = __esm({
94821
95133
  "src/plugins/menu.js"() {
94822
95134
  init_is_edit_mode();
94823
95135
  init_dom_ready();
94824
- init_claygoo_svg();
94825
95136
  init_mode_refusal();
94826
95137
  init_style2();
94827
95138
  init_placement();
94828
95139
  init_actions();
94829
95140
  init_people2();
94830
95141
  init_variants();
95142
+ init_dom_items();
94831
95143
  init_page_colour();
94832
- init_editor_ui();
95144
+ init_shell();
95145
+ init_shell_style();
94833
95146
  SEO_ITEM = true;
94834
- SKIN_VERSION = "1";
94835
- EDGE_GAP = 8;
94836
- DISMISS_ICON = '<svg viewBox="0 0 10 10" aria-hidden="true" focusable="false"><path d="M1 0 5 4l4-4 1 1-4 4 4 4-1 1-4-4-4 4-1-1 4-4-4-4z"/></svg>';
94837
- NOTE_MS = 6e3;
94838
95147
  INTRO_GAP = 12;
94839
95148
  GRIP = '<svg viewBox="0 0 6 12" aria-hidden="true" focusable="false"><rect width="2" height="2"/><rect x="4" width="2" height="2"/><rect y="5" width="2" height="2"/><rect x="4" y="5" width="2" height="2"/><rect y="10" width="2" height="2"/><rect x="4" y="10" width="2" height="2"/></svg>';
94840
95149
  SECTIONS = [
@@ -94843,9 +95152,8 @@ textarea.clay-seo-input.is-short { min-height: 32px; }
94843
95152
  ["clay.duplicate", "clay.download", "clay.export", "clay.reveal"],
94844
95153
  ["clay.versions"],
94845
95154
  null,
94846
- ["upgrade"]
95155
+ ["clay.mode", "upgrade"]
94847
95156
  ];
94848
- SLOTTED = new Set(SECTIONS.flat().filter(Boolean));
94849
95157
  currentMode = () => window.clay && typeof window.clay.mode === "string" ? window.clay.mode : mode;
94850
95158
  mounted = false;
94851
95159
  followCapability = null;
@@ -95794,7 +96102,7 @@ textarea.clay-seo-input.is-short { min-height: 32px; }
95794
96102
  itemOf = (el12) => el12.getAttribute("like") || el12.id;
95795
96103
  if (typeof document !== "undefined") {
95796
96104
  document.addEventListener("click", onClick2);
95797
- const start10 = () => {
96105
+ const start11 = () => {
95798
96106
  if (document.querySelector("[like]")) refresh2();
95799
96107
  let queued3 = false;
95800
96108
  new MutationObserver((records3) => {
@@ -95809,8 +96117,8 @@ textarea.clay-seo-input.is-short { min-height: 32px; }
95809
96117
  });
95810
96118
  }).observe(document.body, { childList: true, subtree: true });
95811
96119
  };
95812
- if (document.readyState === "loading") document.addEventListener("DOMContentLoaded", start10);
95813
- else start10();
96120
+ if (document.readyState === "loading") document.addEventListener("DOMContentLoaded", start11);
96121
+ else start11();
95814
96122
  }
95815
96123
  like = { toggle: toggle2, refresh: refresh2, counts: () => counts ? structuredClone(counts) : null };
95816
96124
  like_default = like;
@@ -95884,8 +96192,8 @@ textarea.clay-seo-input.is-short { min-height: 32px; }
95884
96192
  const before = document.createRange();
95885
96193
  before.selectNodeContents(target);
95886
96194
  before.setEnd(range.startContainer, range.startOffset);
95887
- const start10 = before.toString().length;
95888
- return { text: text6, start: start10, end: start10 + text6.length };
96195
+ const start11 = before.toString().length;
96196
+ return { text: text6, start: start11, end: start11 + text6.length };
95889
96197
  }
95890
96198
  function quoteFromSelection(scope) {
95891
96199
  const range = liveRange();
@@ -95926,9 +96234,9 @@ textarea.clay-seo-input.is-short { min-height: 32px; }
95926
96234
  enableContentEditable();
95927
96235
  }
95928
96236
  function candidateFrom(html, tag2) {
95929
- const start10 = html.search(new RegExp("<" + tag2 + "(\\s|>)", "i"));
95930
- if (start10 === -1) return null;
95931
- const cleaned = html.slice(start10).replace(/\s*`{1,3}\s*$/, "");
96237
+ const start11 = html.search(new RegExp("<" + tag2 + "(\\s|>)", "i"));
96238
+ if (start11 === -1) return null;
96239
+ const cleaned = html.slice(start11).replace(/\s*`{1,3}\s*$/, "");
95932
96240
  if (tag2.toLowerCase() === "body") {
95933
96241
  return new DOMParser().parseFromString(cleaned, "text/html").body;
95934
96242
  }
@@ -98472,6 +98780,32 @@ textarea.clay-seo-input.is-short { min-height: 32px; }
98472
98780
  let base2 = null;
98473
98781
  let unparked = null;
98474
98782
  let stopped2 = false;
98783
+ let own = null;
98784
+ const newId4 = () => Math.random().toString(36).slice(2, 10) + Math.random().toString(36).slice(2, 6);
98785
+ const resetKey = key3 + ":reset";
98786
+ function rootId() {
98787
+ try {
98788
+ return "root:" + (storage2?.getItem(resetKey) ?? "");
98789
+ } catch {
98790
+ return "root:";
98791
+ }
98792
+ }
98793
+ function legacyId(raw) {
98794
+ let hash = 2166136261;
98795
+ for (let i2 = 0; i2 < raw.length; i2++) hash = Math.imul(hash ^ raw.charCodeAt(i2), 16777619);
98796
+ return "legacy:" + (hash >>> 0).toString(36) + "." + raw.length.toString(36);
98797
+ }
98798
+ function lineageOf3(record6, raw) {
98799
+ if (!record6) return null;
98800
+ if (!record6.id) return [legacyId(raw)];
98801
+ return Array.isArray(record6.ancestry) ? [record6.id, ...record6.ancestry].slice(0, LINEAGE2) : null;
98802
+ }
98803
+ function forked(record6) {
98804
+ if (!own || own.raw !== lastRaw || !own.ancestry || !record6?.id || record6.id === own.id) return false;
98805
+ const seen = record6.ancestry;
98806
+ if (!Array.isArray(seen) || seen.includes(own.id)) return false;
98807
+ return seen.includes(own.ancestry[0]) || seen.length >= LINEAGE2;
98808
+ }
98475
98809
  function getRaw() {
98476
98810
  try {
98477
98811
  if (!storage2) return null;
@@ -98627,15 +98961,15 @@ textarea.clay-seo-input.is-short { min-height: 32px; }
98627
98961
  function merge2(mine) {
98628
98962
  const current5 = getRaw();
98629
98963
  const record6 = current5 == null ? null : parse2(current5);
98630
- if (!record6) return { data: mine, stored: null };
98964
+ if (!record6) return { data: mine, stored: null, ancestry: [rootId()], parentData: base2 };
98631
98965
  let data = mine;
98632
98966
  if (current5 !== lastRaw) {
98633
- const merged2 = merge3(base2, mine, record6.data);
98967
+ const merged2 = merge3(forked(record6) ? own.parentData : base2, mine, record6.data);
98634
98968
  if (merged2.conflict) keepConflict(current5);
98635
98969
  data = merged2.value;
98636
98970
  }
98637
98971
  data = complete(data, record6.data);
98638
- return { data, stored: same6(data, record6.data) ? current5 : null };
98972
+ return { data, stored: same6(data, record6.data) ? current5 : null, ancestry: lineageOf3(record6, current5), parentData: record6.data };
98639
98973
  }
98640
98974
  function adopt7(data) {
98641
98975
  const fitted = fit(data);
@@ -98660,8 +98994,9 @@ textarea.clay-seo-input.is-short { min-height: 32px; }
98660
98994
  doc.dispatchEvent(new CustomEvent("clay:drafts-saved", { detail: { data: mine, unchanged: true } }));
98661
98995
  return mine;
98662
98996
  }
98663
- const { data, stored } = merge2(mine);
98664
- const raw = stored ?? JSON.stringify({ v: RECORD_VERSION, savedAt: now3().toISOString(), data });
98997
+ const { data, stored, ancestry, parentData } = merge2(mine);
98998
+ const id = newId4();
98999
+ const raw = stored ?? JSON.stringify({ v: RECORD_VERSION, savedAt: now3().toISOString(), id, ancestry, data });
98665
99000
  if (!stored) {
98666
99001
  try {
98667
99002
  if (!storage2) throw new Error("no storage");
@@ -98669,6 +99004,7 @@ textarea.clay-seo-input.is-short { min-height: 32px; }
98669
99004
  } catch (error2) {
98670
99005
  throw storageFailure(doc, error2);
98671
99006
  }
99007
+ own = { id, ancestry, parentData, raw };
98672
99008
  }
98673
99009
  const taken2 = Object.keys(mine).filter((name) => !fitsInto(mine[name], data[name]));
98674
99010
  if (taken2.length) adopt7(Object.fromEntries(taken2.map((name) => [name, data[name]])));
@@ -98693,8 +99029,14 @@ textarea.clay-seo-input.is-short { min-height: 32px; }
98693
99029
  function adoptExternal() {
98694
99030
  if (stopped2) return false;
98695
99031
  const raw = getRaw();
99032
+ if (raw == null && lastRaw != null && !changed2()) {
99033
+ stopped2 = true;
99034
+ window.location.reload();
99035
+ return true;
99036
+ }
98696
99037
  if (raw == null || raw === lastRaw || changed2()) return false;
98697
99038
  const record6 = parse2(raw);
99039
+ if (forked(record6) && typeof window.clay?.getHTML === "function") return writeLive();
98698
99040
  const adopted = record6 && adopt7(record6.data);
98699
99041
  if (!adopted) return false;
98700
99042
  lastRaw = raw;
@@ -98709,16 +99051,21 @@ textarea.clay-seo-input.is-short { min-height: 32px; }
98709
99051
  storage2.removeItem(key3);
98710
99052
  } catch {
98711
99053
  }
99054
+ try {
99055
+ storage2.setItem(resetKey, newId4());
99056
+ } catch {
99057
+ }
98712
99058
  }
98713
99059
  return { slot: slot3, key: key3, rules, read: read2, restore: restore3, write: write3, writeLive, flush, changed: changed2, adoptExternal, park, clear: clear2, snapshot };
98714
99060
  }
98715
- var KEY_PREFIX, RECORD_VERSION, legacyKey, draftKey, isPlain4, hasIds, sameIds, savedAtOf;
99061
+ var KEY_PREFIX, RECORD_VERSION, LINEAGE2, legacyKey, draftKey, isPlain4, hasIds, sameIds, savedAtOf;
98716
99062
  var init_store3 = __esm({
98717
99063
  "src/plugins/visitor-drafts/store.js"() {
98718
99064
  init_hyper_html_api_data_vendor();
98719
99065
  init_draft_mode();
98720
99066
  KEY_PREFIX = "clay:visitor-drafts:";
98721
99067
  RECORD_VERSION = 1;
99068
+ LINEAGE2 = 32;
98722
99069
  legacyKey = (slot3) => KEY_PREFIX + slot3;
98723
99070
  draftKey = (slot3, path = draftPath()) => `${KEY_PREFIX}${slot3}@${path}`;
98724
99071
  isPlain4 = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
@@ -99125,7 +99472,7 @@ textarea.clay-seo-input.is-short { min-height: 32px; }
99125
99472
  if (t2) {
99126
99473
  const act = t2.getAttribute("data-hcp");
99127
99474
  if (act === "open") {
99128
- set3("card", "open");
99475
+ set3("card", root4.getAttribute("data-hcp-reason") === "error" ? void 0 : "open");
99129
99476
  linkEl.focus();
99130
99477
  } else if (act === "minimize") {
99131
99478
  set3("mini");
@@ -99170,7 +99517,7 @@ textarea.clay-seo-input.is-short { min-height: 32px; }
99170
99517
  function clearError() {
99171
99518
  if (root4.getAttribute("data-hcp-reason") === "error") root4.setAttribute("data-hcp-reason", "use");
99172
99519
  }
99173
- const api = { set: set3, root: root4, showError, clearError };
99520
+ const api = { set: set3, root: root4, showError, clearError, download: () => linkEl.click() };
99174
99521
  document.addEventListener("input", onUse, true);
99175
99522
  document.addEventListener("change", onUse, true);
99176
99523
  document.addEventListener("focusin", onFocusIn);
@@ -99237,6 +99584,7 @@ textarea.clay-seo-input.is-short { min-height: 32px; }
99237
99584
  editOriginal,
99238
99585
  backToDraft,
99239
99586
  downloadUrl: () => DOWNLOAD_URL,
99587
+ download: () => Promise.resolve(false),
99240
99588
  source: null
99241
99589
  };
99242
99590
  }
@@ -99319,6 +99667,7 @@ textarea.clay-seo-input.is-short { min-height: 32px; }
99319
99667
  });
99320
99668
  }
99321
99669
  function liftOff() {
99670
+ unfollow?.();
99322
99671
  removeEventListener("scroll", lift);
99323
99672
  removeEventListener("resize", lift);
99324
99673
  document.removeEventListener(BOTTOM_UI_CHANGED, lift);
@@ -99334,6 +99683,7 @@ textarea.clay-seo-input.is-short { min-height: 32px; }
99334
99683
  window.addEventListener("hashchange", lift);
99335
99684
  chip3.addEventListener("transitionend", lift);
99336
99685
  lift();
99686
+ const unfollow = followLook(chip3, chip3, void 0, OWNER_LEAN);
99337
99687
  chip3.liftOff = liftOff;
99338
99688
  chip3.unmount = () => {
99339
99689
  liftOff();
@@ -99341,12 +99691,14 @@ textarea.clay-seo-input.is-short { min-height: 32px; }
99341
99691
  };
99342
99692
  return chip3;
99343
99693
  }
99344
- var COPY, CHIP_CSS, ownerChip;
99694
+ var OWNER_LEAN, COPY, CHIP_CSS, ownerChip;
99345
99695
  var init_owner_chip = __esm({
99346
99696
  "src/plugins/visitor-drafts/owner-chip.js"() {
99347
99697
  init_is_edit_mode();
99348
99698
  init_bottom_ui();
99349
99699
  init_editor_ui();
99700
+ init_page_colour();
99701
+ OWNER_LEAN = 0.8;
99350
99702
  COPY = {
99351
99703
  draft: "You're seeing a private draft, like a visitor.",
99352
99704
  draftAction: "Edit the original",
@@ -99355,29 +99707,17 @@ textarea.clay-seo-input.is-short { min-height: 32px; }
99355
99707
  close: "Hide this note"
99356
99708
  };
99357
99709
  CHIP_CSS = `.clay-owner {
99358
- --hcp-ground: #FDF8F0;
99359
- --hcp-surface: #FFFCF6;
99360
- --hcp-sunk: #F4ECDF;
99361
- --hcp-ink: #2B241B;
99362
- --hcp-ink-2: #4A4033;
99363
- --hcp-muted: #6B5942;
99364
- --hcp-line: #E8DCC6;
99365
- --hcp-line-2: #D8C8AF;
99366
- --hcp-brass: #8F6310;
99367
- --hcp-shadow: 0 1px 2px rgba(23, 28, 36, .06), 0 14px 34px -14px rgba(43, 36, 27, .32);
99710
+ --hcp-surface: light-dark(#FFFCF6, #11131E);
99711
+ --hcp-ground: var(--bevel-surface, var(--hcp-surface));
99712
+ --hcp-ink: light-dark(#2B241B, #ECEAF2);
99713
+ --hcp-ink-2: light-dark(#4A4033, #C9CDE0);
99714
+ --hcp-muted: light-dark(#6B5942, #8A90AB);
99715
+ --hcp-line-2: color-mix(in srgb, var(--hcp-ink) 22%, var(--hcp-ground));
99716
+ --hcp-brass: light-dark(#8F6310, #D9A445);
99717
+ --hcp-shadow: 0 1px 2px light-dark(rgba(23, 28, 36, .06), rgba(0, 0, 0, .4)), 0 14px 34px -14px light-dark(rgba(43, 36, 27, .32), rgba(0, 0, 0, .7));
99368
99718
  --hcp-sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
99369
99719
  --hcp-lift: 0px;
99370
- color-scheme: light;
99371
- }
99372
- @media (prefers-color-scheme: dark) {
99373
- .clay-owner {
99374
- --hcp-surface: #11131E; --hcp-sunk: #1A1D2C;
99375
- --hcp-ink: #ECEAF2; --hcp-ink-2: #C9CDE0; --hcp-muted: #8A90AB;
99376
- --hcp-line: #262B42; --hcp-line-2: #353B52;
99377
- --hcp-brass: #D9A445;
99378
- --hcp-shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 16px 38px -14px rgba(0, 0, 0, .7);
99379
- color-scheme: dark;
99380
- }
99720
+ color-scheme: light dark;
99381
99721
  }
99382
99722
  .clay-owner, .clay-owner *, .clay-owner *::before, .clay-owner *::after {
99383
99723
  box-sizing: border-box; margin: 0; padding: 0; border: 0;
@@ -99390,8 +99730,8 @@ textarea.clay-seo-input.is-short { min-height: 32px; }
99390
99730
  max-width: min(460px, calc(100vw - 24px));
99391
99731
  padding: 8px 8px 8px 12px;
99392
99732
  font-family: var(--hcp-sans); font-size: 13px; font-weight: 400; line-height: 1.45;
99393
- color: var(--hcp-ink-2); text-align: left; background: var(--hcp-surface);
99394
- border: 1px solid var(--hcp-line-2); border-left: 3px solid var(--hcp-brass);
99733
+ color: var(--hcp-ink-2); text-align: left; background: var(--hcp-ground);
99734
+ border: 1px solid var(--hcp-line-2);
99395
99735
  box-shadow: var(--hcp-shadow);
99396
99736
  -webkit-font-smoothing: antialiased;
99397
99737
  }
@@ -99449,6 +99789,12 @@ body:has(> .clay-intro) { height: auto !important; overflow: visible !important;
99449
99789
  .clay-intro__close:focus-visible { opacity: 1; outline: 2px solid currentColor; outline-offset: 2px; }
99450
99790
  .clay-intro__close svg { display: block; width: 12px; height: 12px; fill: currentColor; stroke: none; }
99451
99791
  @media (pointer: coarse) { .clay-intro__close { width: 44px; height: 44px; top: 4px; right: 4px; } }
99792
+ .clay-intro__close[data-manual] {
99793
+ width: auto; height: 36px; padding: 0 14px;
99794
+ border-radius: 999px; font-size: 12px; font-weight: 500;
99795
+ text-transform: uppercase; letter-spacing: .04em; white-space: nowrap;
99796
+ }
99797
+ @media (pointer: coarse), (max-width: 680px) { .clay-intro__close[data-manual] { height: 44px; } }
99452
99798
  `;
99453
99799
  }
99454
99800
  });
@@ -99486,16 +99832,7 @@ body:has(> .clay-intro) { height: auto !important; overflow: visible !important;
99486
99832
  if (next) next.focus({ preventScroll: true });
99487
99833
  else document.body.focus({ preventScroll: true });
99488
99834
  }
99489
- function mountIntro({ memory, template, appName, hadDraft }) {
99490
- if (!template || !template.content.textContent.trim() && !template.content.querySelector("img, svg, video, canvas")) return null;
99491
- if (!forced()) {
99492
- if (memory.get().intro.done || hadDraft) return null;
99493
- if (bootPhase.servedHash) return null;
99494
- if (window.matchMedia && window.matchMedia("print").matches) return null;
99495
- }
99496
- return mount4({ memory, template, appName });
99497
- }
99498
- function mount4({ memory, template, appName }) {
99835
+ function buildSection({ template, appName, labelText, onClose }) {
99499
99836
  stylesOnce();
99500
99837
  const section = document.createElement("section");
99501
99838
  section.className = "clay-intro";
@@ -99506,10 +99843,43 @@ body:has(> .clay-intro) { height: auto !important; overflow: visible !important;
99506
99843
  const close = document.createElement("button");
99507
99844
  close.type = "button";
99508
99845
  close.className = "clay-intro__close";
99509
- close.setAttribute("aria-label", COPY2.close);
99510
- close.innerHTML = '<svg width="12" height="12" viewBox="0 0 12 12" fill="currentColor" aria-hidden="true"><path d="M1.4 0 6 4.6 10.6 0 12 1.4 7.4 6 12 10.6 10.6 12 6 7.4 1.4 12 0 10.6 4.6 6 0 1.4z"/></svg>';
99511
- close.addEventListener("click", () => dismiss5("closed"));
99846
+ if (labelText) {
99847
+ close.textContent = labelText;
99848
+ close.setAttribute("data-manual", "");
99849
+ } else {
99850
+ close.setAttribute("aria-label", COPY2.close);
99851
+ close.innerHTML = '<svg width="12" height="12" viewBox="0 0 12 12" fill="currentColor" aria-hidden="true"><path d="M1.4 0 6 4.6 10.6 0 12 1.4 7.4 6 12 10.6 10.6 12 6 7.4 1.4 12 0 10.6 4.6 6 0 1.4z"/></svg>';
99852
+ }
99853
+ close.addEventListener("click", () => onClose());
99512
99854
  mountEditorUI({ name: "intro-close", content: close, css: [CLOSE_CSS], parent: section });
99855
+ section.addEventListener("click", (event) => {
99856
+ if (event.target.closest("[visitor-intro-dismiss]")) {
99857
+ onClose();
99858
+ return;
99859
+ }
99860
+ if (event.target.closest("[visitor-intro-start]")) {
99861
+ event.preventDefault();
99862
+ window.scrollTo({ top: window.scrollY + section.getBoundingClientRect().bottom, behavior: "smooth" });
99863
+ }
99864
+ });
99865
+ return section;
99866
+ }
99867
+ function mountIntro({ memory, template, appName, hadDraft }) {
99868
+ if (!template || !template.content.textContent.trim() && !template.content.querySelector("img, svg, video, canvas")) return null;
99869
+ if (template.getAttribute("visitor-intro") === "manual") {
99870
+ const printing = window.matchMedia && window.matchMedia("print").matches;
99871
+ const open4 = forced() || !(memory.get().intro.done || hadDraft || bootPhase.servedHash || printing);
99872
+ return mountManual({ memory, template, appName, open: open4 });
99873
+ }
99874
+ if (!forced()) {
99875
+ if (memory.get().intro.done || hadDraft) return null;
99876
+ if (bootPhase.servedHash) return null;
99877
+ if (window.matchMedia && window.matchMedia("print").matches) return null;
99878
+ }
99879
+ return mount4({ memory, template, appName });
99880
+ }
99881
+ function mount4({ memory, template, appName }) {
99882
+ const section = buildSection({ template, appName, onClose: () => dismiss5("closed") });
99513
99883
  let gone = false;
99514
99884
  let frame = 0;
99515
99885
  function dismiss5(reason) {
@@ -99538,21 +99908,44 @@ body:has(> .clay-intro) { height: auto !important; overflow: visible !important;
99538
99908
  if (bottom < 1 || atEnd && bottom < innerHeight) dismiss5("scrolled");
99539
99909
  });
99540
99910
  }
99541
- section.addEventListener("click", (event) => {
99542
- if (event.target.closest("[visitor-intro-dismiss]")) {
99543
- dismiss5("closed");
99544
- return;
99545
- }
99546
- if (event.target.closest("[visitor-intro-start]")) {
99547
- event.preventDefault();
99548
- window.scrollTo({ top: window.scrollY + section.getBoundingClientRect().bottom, behavior: "smooth" });
99549
- }
99550
- });
99551
99911
  document.body.prepend(section);
99552
99912
  announceBottomUi();
99553
99913
  addEventListener("scroll", onScroll, { passive: true });
99554
99914
  return section;
99555
99915
  }
99916
+ function mountManual({ memory, template, appName, open: open4 }) {
99917
+ let section = null;
99918
+ const showRow = (wanted) => {
99919
+ const menu = window.clay?.menu;
99920
+ if (!menu) return;
99921
+ if (wanted) menu.addItem({ id: "clay.intro", label: COPY2.show, run: show3 });
99922
+ else menu.removeItem("clay.intro");
99923
+ };
99924
+ function attach() {
99925
+ section ??= buildSection({ template, appName, labelText: COPY2.hide, onClose: hide });
99926
+ document.body.prepend(section);
99927
+ announceBottomUi();
99928
+ showRow(false);
99929
+ }
99930
+ function hide() {
99931
+ memory.get().intro.done = "closed";
99932
+ memory.save();
99933
+ section.remove();
99934
+ announceBottomUi();
99935
+ showRow(true);
99936
+ focusApp();
99937
+ }
99938
+ function show3() {
99939
+ memory.get().intro.done = null;
99940
+ memory.save();
99941
+ attach();
99942
+ window.scrollTo(0, 0);
99943
+ }
99944
+ document.addEventListener("clay:menu-ready", () => showRow(!section?.isConnected));
99945
+ if (open4) attach();
99946
+ else showRow(true);
99947
+ return section;
99948
+ }
99556
99949
  var COPY2, FOCUSABLE2, TEXT_ENTRY, NON_TEXT_INPUT;
99557
99950
  var init_intro = __esm({
99558
99951
  "src/plugins/visitor-drafts/intro.js"() {
@@ -99562,6 +99955,8 @@ body:has(> .clay-intro) { height: auto !important; overflow: visible !important;
99562
99955
  init_boot_phase();
99563
99956
  COPY2 = {
99564
99957
  close: "Hide this introduction",
99958
+ hide: "Hide intro",
99959
+ show: "Show intro",
99565
99960
  label: (appName) => `About ${appName}`
99566
99961
  };
99567
99962
  FOCUSABLE2 = "a[href], button, input, select, textarea, [tabindex]:not([tabindex='-1'])";
@@ -99620,14 +100015,14 @@ body:has(> .clay-intro) { height: auto !important; overflow: visible !important;
99620
100015
  downloadLink = downloadUrl(source);
99621
100016
  const appName = document.querySelector('meta[name="application-name"]')?.content?.trim() || document.title.split(/:|\s\|\s/)[0].trim() || "This app";
99622
100017
  const template = document.querySelector("template[visitor-intro]");
99623
- const start10 = () => {
100018
+ const start11 = () => {
99624
100019
  ready7 = mountPrompt({ memory, appName, link: downloadLink }).then((prompt) => mountIntroLate({ memory, template, appName, hadDraft: result2.hadDraft }).then(() => prompt)).then((prompt) => {
99625
100020
  document.addEventListener("clay:drafts-store-failed", () => prompt.showError());
99626
100021
  document.addEventListener("clay:drafts-saved", () => prompt.clearError());
99627
100022
  return (isOwner ? mountChip() : Promise.resolve(null)).then(() => prompt);
99628
100023
  });
99629
100024
  };
99630
- document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", start10, { once: true }) : start10();
100025
+ document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", start11, { once: true }) : start11();
99631
100026
  setDraftFlush(() => store.flush());
99632
100027
  window.addEventListener("storage", (event) => {
99633
100028
  if (event.key === store.key) store.adoptExternal();
@@ -99668,6 +100063,10 @@ body:has(> .clay-intro) { height: auto !important; overflow: visible !important;
99668
100063
  editOriginal,
99669
100064
  backToDraft,
99670
100065
  downloadUrl: () => downloadLink,
100066
+ download: () => ready7.then((prompt) => {
100067
+ store.flush();
100068
+ return prompt?.download();
100069
+ }),
99671
100070
  source
99672
100071
  } : inertVisitorDrafts();
99673
100072
  }
@@ -99751,6 +100150,106 @@ body:has(> .clay-intro) { height: auto !important; overflow: visible !important;
99751
100150
  }
99752
100151
  });
99753
100152
 
100153
+ // src/plugins/menu/visitor.js
100154
+ var visitor_exports = {};
100155
+ __export(visitor_exports, {
100156
+ start: () => start6
100157
+ });
100158
+ function attachLooks({ addItem, removeItem, slot: slot3 }) {
100159
+ const announce4 = () => {
100160
+ const name = activeLook() && nameOf(activeLook());
100161
+ document.dispatchEvent(new CustomEvent("clay:variant-change", { detail: { active: name, shown: name } }));
100162
+ };
100163
+ const draw = () => {
100164
+ const all = looks();
100165
+ if (all.length < 2 || !slot3?.hasAttribute("clay-menu-looks")) return removeItem("clay.look");
100166
+ const current5 = activeLook();
100167
+ const by = (delta) => () => choose(nameOf(all[(all.indexOf(activeLook()) + delta + all.length) % all.length]));
100168
+ addItem({
100169
+ id: "clay.look",
100170
+ section: "start",
100171
+ stepper: {
100172
+ label: "Switch look",
100173
+ value: `${labelOf2(current5)} ${all.indexOf(current5) + 1}/${all.length}`,
100174
+ prev: by(-1),
100175
+ next: by(1),
100176
+ prevLabel: "Previous look",
100177
+ nextLabel: "Next look"
100178
+ }
100179
+ });
100180
+ };
100181
+ const choose = (name) => {
100182
+ if (!looks().some((style3) => nameOf(style3) === name)) return { ok: false, code: "unknown-variant" };
100183
+ document.documentElement.setAttribute("look", name);
100184
+ paintLook2(name);
100185
+ window.clay?.save?.soon?.();
100186
+ draw();
100187
+ announce4();
100188
+ return { ok: true };
100189
+ };
100190
+ if (looks().length >= 2) {
100191
+ window.clay.variants = {
100192
+ list: () => looks().map((style3) => ({ name: nameOf(style3), label: labelOf2(style3), active: style3 === activeLook() })),
100193
+ get active() {
100194
+ return activeLook() && nameOf(activeLook());
100195
+ },
100196
+ get shown() {
100197
+ return activeLook() && nameOf(activeLook());
100198
+ },
100199
+ preview: choose,
100200
+ choose,
100201
+ keep: () => Promise.resolve({ ok: false, code: "not-editing" })
100202
+ };
100203
+ document.addEventListener("clay:drafts-restored", () => {
100204
+ draw();
100205
+ announce4();
100206
+ });
100207
+ draw();
100208
+ }
100209
+ }
100210
+ function startOver() {
100211
+ return Promise.resolve().then(() => (init_dialogs(), dialogs_exports)).then((m7) => m7.consent(START_OVER)).then(() => window.clay.visitorDrafts.reset(), () => false);
100212
+ }
100213
+ function start6() {
100214
+ if (document.querySelector('clay-editor-ui[data-clay-ui="menu"]')) return;
100215
+ const shell = createShell({ sections: [null] });
100216
+ const { slot: slot3, embedded, skin, addItem, removeItem, open: open4, close, note, goo } = shell;
100217
+ shell.mount(embedded ? [MENU_SAFETY, SHELL_BASE, skin ?? MENU_SKIN, MENU_TOUCH] : [MENU_SAFETY, SHELL_BASE, SHELL_FLOATING, MENU_SKIN, MENU_TOUCH]);
100218
+ attachLooks({ addItem, removeItem, slot: slot3 });
100219
+ addItem({ id: "clay.download", label: "Download a copy", run: () => window.clay.visitorDrafts.download() });
100220
+ addItem({ id: "clay.start-over", label: "Start over", run: startOver });
100221
+ attachDomItems(shell);
100222
+ window.clay.menu = { addItem, removeItem, open: open4, close, note, embedded, button: goo };
100223
+ document.dispatchEvent(new CustomEvent("clay:menu-ready"));
100224
+ }
100225
+ var START_OVER;
100226
+ var init_visitor = __esm({
100227
+ "src/plugins/menu/visitor.js"() {
100228
+ init_shell();
100229
+ init_dom_items();
100230
+ init_shell_style();
100231
+ init_looks();
100232
+ START_OVER = "Start over? Your changes in this browser are deleted, and the page goes back to how its owner saved it.";
100233
+ }
100234
+ });
100235
+
100236
+ // src/plugins/visitor-menu.js
100237
+ var visitor_menu_exports = {};
100238
+ var init_visitor_menu = __esm({
100239
+ "src/plugins/visitor-menu.js"() {
100240
+ init_is_edit_mode();
100241
+ init_dom_ready();
100242
+ init_looks();
100243
+ if (isDraftMode) {
100244
+ paintLook2();
100245
+ document.addEventListener("clay:drafts-restored", () => paintLook2());
100246
+ dom_ready_default(() => {
100247
+ Promise.resolve().then(() => (init_visitor(), visitor_exports)).then((m7) => m7.start()).catch((error2) => console.warn("visitor-menu: the menu did not load", error2));
100248
+ });
100249
+ }
100250
+ }
100251
+ });
100252
+
99754
100253
  // src/plugins/bind-text.js
99755
100254
  var bind_text_exports = {};
99756
100255
  __export(bind_text_exports, {
@@ -100894,7 +101393,7 @@ body:has(> .clay-intro) { height: auto !important; overflow: visible !important;
100894
101393
  renderSave: () => renderSave,
100895
101394
  renderSaveSteps: () => renderSaveSteps,
100896
101395
  repairGeneration: () => repairGeneration,
100897
- start: () => start6,
101396
+ start: () => start7,
100898
101397
  stats: () => stats,
100899
101398
  text: () => text5,
100900
101399
  unpaired: () => unpaired
@@ -101281,7 +101780,7 @@ body:has(> .clay-intro) { height: auto !important; overflow: visible !important;
101281
101780
  state.refetch = false;
101282
101781
  setSaveRenderer(null);
101283
101782
  }
101284
- function start6({ context: context2 = null, latest = null } = {}) {
101783
+ function start7({ context: context2 = null, latest = null } = {}) {
101285
101784
  return install9(window.location.href, context2, 0, true, latest);
101286
101785
  }
101287
101786
  var state, SUPERSEDED_RETRIES, now2, SLICED_STEP_BUDGET_MS, SUPERSEDED2, PROJECTED_MAP_PREFIX, isProjected, MAX_PRINT_ROUNDS, installed5, repairGeneration;
@@ -101576,10 +102075,11 @@ body:has(> .clay-intro) { height: auto !important; overflow: visible !important;
101576
102075
  }
101577
102076
  async function replace(html, { etag } = {}) {
101578
102077
  if (typeof html !== "string" || html === "") return failed();
102078
+ const pinned = etag !== void 0;
101579
102079
  const given = typeof etag === "string" && etag ? etag : null;
101580
102080
  if (!conditionalSaves()) await seedEtag();
101581
102081
  if (!conditionalSaves()) return { ok: false, code: "unsupported" };
101582
- const stamp3 = given || lastSeenEtag();
102082
+ const stamp3 = pinned ? given : lastSeenEtag();
101583
102083
  if (!stamp3) return { ok: false, code: "conflict" };
101584
102084
  const controller2 = new AbortController();
101585
102085
  const timeoutId = setTimeout(() => controller2.abort(), TIMEOUT_MS);
@@ -102876,6 +103376,13 @@ body:has(> .clay-intro) { height: auto !important; overflow: visible !important;
102876
103376
  return { ok: false, code: "flush", state: flushed.state, message: "This document has changes that could not be saved. Nothing was changed." };
102877
103377
  }
102878
103378
  }
103379
+ if (etag === void 0 && !lastSeenEtag()) {
103380
+ try {
103381
+ await seedEtag();
103382
+ } catch {
103383
+ }
103384
+ }
103385
+ const stamp3 = etag !== void 0 ? etag : lastSeenEtag();
102879
103386
  let source3 = doc;
102880
103387
  if (pageClay.isEditMode && typeof pageClay.getHTML === "function") {
102881
103388
  try {
@@ -102883,13 +103390,15 @@ body:has(> .clay-intro) { height: auto !important; overflow: visible !important;
102883
103390
  } catch {
102884
103391
  return { ok: false, code: "failed", message: SAVE_FAILED2 };
102885
103392
  }
103393
+ } else {
103394
+ source3 = new DOMParser().parseFromString("<!DOCTYPE html>\n" + doc.documentElement.outerHTML, "text/html");
102886
103395
  }
102887
103396
  const prepared = await prepare(update2, { doc: source3, loc, fetchFn });
102888
103397
  if (!prepared.ok) return prepared;
102889
103398
  const save2 = typeof replace3 === "function" ? replace3 : pageClay.save && typeof pageClay.save.replace === "function" ? pageClay.save.replace : replace;
102890
103399
  let result2;
102891
103400
  try {
102892
- result2 = await save2(prepared.html, { etag: etag !== void 0 ? etag : lastSeenEtag() });
103401
+ result2 = await save2(prepared.html, { etag: stamp3 });
102893
103402
  } catch {
102894
103403
  return { ok: false, code: "failed", message: SAVE_FAILED2 };
102895
103404
  }
@@ -102960,7 +103469,7 @@ body:has(> .clay-intro) { height: auto !important; overflow: visible !important;
102960
103469
  return false;
102961
103470
  }
102962
103471
  }
102963
- async function start7(update2, options = {}) {
103472
+ async function start8(update2, options = {}) {
102964
103473
  const doc = options.doc || document;
102965
103474
  const clay6 = options.clay || (typeof window !== "undefined" ? window.clay : null) || {};
102966
103475
  if (clay6.isDraftMode) return null;
@@ -103057,7 +103566,7 @@ body:has(> .clay-intro) { height: auto !important; overflow: visible !important;
103057
103566
  __export(upgrade_run_exports, {
103058
103567
  apply: () => apply,
103059
103568
  prepare: () => prepare,
103060
- start: () => start7
103569
+ start: () => start8
103061
103570
  });
103062
103571
  var init_upgrade_run2 = __esm({
103063
103572
  "src/plugins/upgrade-run.js"() {
@@ -103072,7 +103581,7 @@ body:has(> .clay-intro) { height: auto !important; overflow: visible !important;
103072
103581
  checkUpdate: () => checkUpdate2,
103073
103582
  findUpdate: () => findUpdate,
103074
103583
  replace: () => replace2,
103075
- start: () => start8
103584
+ start: () => start9
103076
103585
  });
103077
103586
  function readMeta(doc, name) {
103078
103587
  const el12 = doc.querySelector(`meta[name="${name}"]`);
@@ -103228,7 +103737,7 @@ body:has(> .clay-intro) { height: auto !important; overflow: visible !important;
103228
103737
  }
103229
103738
  return null;
103230
103739
  }
103231
- async function start8(options = {}) {
103740
+ async function start9(options = {}) {
103232
103741
  if (started3) return null;
103233
103742
  started3 = true;
103234
103743
  const clay6 = window.clay;
@@ -103264,9 +103773,9 @@ body:has(> .clay-intro) { height: auto !important; overflow: visible !important;
103264
103773
  if (bootClay && bootClay.canEdit && !bootClay.isDraftMode) {
103265
103774
  document.addEventListener("clay:upgrade-requested", onUpgradeRequested);
103266
103775
  const ready10 = bootClay.ready;
103267
- if (ready10 && typeof ready10.then === "function") ready10.then(() => start8(), () => {
103776
+ if (ready10 && typeof ready10.then === "function") ready10.then(() => start9(), () => {
103268
103777
  });
103269
- else start8();
103778
+ else start9();
103270
103779
  }
103271
103780
  }
103272
103781
  });
@@ -107758,24 +108267,24 @@ https://github.com/highlightjs/highlight.js/issues/2277`), x5 = n3, E6 = a2), h
107758
108267
  if (tw.start < lastEnd - EPSILON) {
107759
108268
  throw new Error(`uimotion: two ${tweens[0].prop} tweens overlap on the same element at ${Math.round(tw.start)} ms (the earlier one ends at ${Math.round(lastEnd)} ms, from ${lastTween.source ?? "a step"})`);
107760
108269
  }
107761
- const start10 = Math.max(tw.start, lastEnd);
108270
+ const start11 = Math.max(tw.start, lastEnd);
107762
108271
  const from = tw.from ?? cur;
107763
108272
  const to4 = tw.toInitial ? initialValue(keys2) : tw.to ?? from;
107764
108273
  const last = keys2[keys2.length - 1];
107765
- if (keys2.length && !same7(from, cur)) keys2.push({ t: start10, v: cur, ease: ease.linear });
107766
- if (!(last && last.t === start10 && same7(last.v, from))) keys2.push({ t: start10, v: from, ease: ease.linear });
108274
+ if (keys2.length && !same7(from, cur)) keys2.push({ t: start11, v: cur, ease: ease.linear });
108275
+ if (!(last && last.t === start11 && same7(last.v, from))) keys2.push({ t: start11, v: from, ease: ease.linear });
107767
108276
  const head = keys2[keys2.length - 1];
107768
108277
  if (tw.path) {
107769
108278
  for (let i2 = 1; i2 <= SAMPLES; i2++) {
107770
108279
  const u4 = i2 / SAMPLES;
107771
- keys2.push({ t: start10 + tw.dur * u4, v: tw.path(bezierAt(tw.ease, u4)), ease: ease.linear });
108280
+ keys2.push({ t: start11 + tw.dur * u4, v: tw.path(bezierAt(tw.ease, u4)), ease: ease.linear });
107772
108281
  }
107773
108282
  } else {
107774
108283
  head.ease = tw.ease;
107775
- keys2.push({ t: start10 + tw.dur, v: to4, ease: ease.linear });
108284
+ keys2.push({ t: start11 + tw.dur, v: to4, ease: ease.linear });
107776
108285
  }
107777
108286
  cur = keys2[keys2.length - 1].v;
107778
- lastEnd = start10 + tw.dur;
108287
+ lastEnd = start11 + tw.dur;
107779
108288
  lastTween = tw;
107780
108289
  }
107781
108290
  return keys2;
@@ -107804,7 +108313,7 @@ https://github.com/highlightjs/highlight.js/issues/2277`), x5 = n3, E6 = a2), h
107804
108313
  return new Scene(stage, options);
107805
108314
  }
107806
108315
  function rewind(s3, keep3 = []) {
107807
- return s3.step("rewind", (start10) => {
108316
+ return s3.step("rewind", (start11) => {
107808
108317
  const groups = /* @__PURE__ */ new Map();
107809
108318
  for (const tw of s3.tweens) {
107810
108319
  if (tw.prop === "opacity" && keep3.includes(tw.el)) continue;
@@ -107817,7 +108326,7 @@ https://github.com/highlightjs/highlight.js/issues/2277`), x5 = n3, E6 = a2), h
107817
108326
  for (const [prop, list3] of props) {
107818
108327
  const keys2 = resolve(list3, s3.resets);
107819
108328
  const v9 = initialValue(keys2);
107820
- if (!same7(valueAt(keys2, start10, prop), v9)) s3.add(el12, prop, start10, 0, v9, { ease: "linear" });
108329
+ if (!same7(valueAt(keys2, start11, prop), v9)) s3.add(el12, prop, start11, 0, v9, { ease: "linear" });
107821
108330
  }
107822
108331
  }
107823
108332
  return 0;
@@ -107854,7 +108363,7 @@ https://github.com/highlightjs/highlight.js/issues/2277`), x5 = n3, E6 = a2), h
107854
108363
  io4?.disconnect();
107855
108364
  doc.removeEventListener("visibilitychange", sync);
107856
108365
  };
107857
- const start10 = (force) => {
108366
+ const start11 = (force) => {
107858
108367
  if (done) return;
107859
108368
  if (!stage.isConnected) return stop6();
107860
108369
  const w6 = stage.offsetWidth;
@@ -107882,7 +108391,7 @@ https://github.com/highlightjs/highlight.js/issues/2277`), x5 = n3, E6 = a2), h
107882
108391
  queued3 = false;
107883
108392
  const f3 = queuedForce;
107884
108393
  queuedForce = false;
107885
- start10(f3);
108394
+ start11(f3);
107886
108395
  });
107887
108396
  };
107888
108397
  const ro4 = new ResizeObserver(() => stage.isConnected ? queue2(false) : stop6());
@@ -107894,7 +108403,7 @@ https://github.com/highlightjs/highlight.js/issues/2277`), x5 = n3, E6 = a2), h
107894
108403
  io4?.observe(stage);
107895
108404
  doc.addEventListener("visibilitychange", sync);
107896
108405
  if (doc.fonts && doc.fonts.status !== "loaded") doc.fonts.ready.then(() => queue2(true));
107897
- start10(false);
108406
+ start11(false);
107898
108407
  return { stop: stop6, get scene() {
107899
108408
  return s3;
107900
108409
  } };
@@ -107985,13 +108494,13 @@ https://github.com/highlightjs/highlight.js/issues/2277`), x5 = n3, E6 = a2), h
107985
108494
  const resume = this.animations ? { time: this.time, playing: this.playing } : null;
107986
108495
  this.animations?.forEach((a2) => a2.cancel());
107987
108496
  this.animations = null;
107988
- const start10 = this.nextStart();
108497
+ const start11 = this.nextStart();
107989
108498
  this.mode = null;
107990
- this.source = `${name} at ${Math.round(start10)} ms`;
108499
+ this.source = `${name} at ${Math.round(start11)} ms`;
107991
108500
  const before = this.tweens.length;
107992
- let end2 = start10 + build6(start10);
108501
+ let end2 = start11 + build6(start11);
107993
108502
  for (const tw of this.tweens.slice(before)) end2 = Math.max(end2, tw.start + tw.dur);
107994
- this.last = { start: start10, end: end2 };
108503
+ this.last = { start: start11, end: end2 };
107995
108504
  this.t = Math.max(this.t, end2);
107996
108505
  if (resume) {
107997
108506
  this.seek(resume.time);
@@ -107999,11 +108508,11 @@ https://github.com/highlightjs/highlight.js/issues/2277`), x5 = n3, E6 = a2), h
107999
108508
  }
108000
108509
  return this;
108001
108510
  }
108002
- add(el12, prop, start10, dur, to4, { from, ease: e20 = "standard", path } = {}) {
108511
+ add(el12, prop, start11, dur, to4, { from, ease: e20 = "standard", path } = {}) {
108003
108512
  this.tweens.push({
108004
108513
  el: el12,
108005
108514
  prop,
108006
- start: start10,
108515
+ start: start11,
108007
108516
  dur,
108008
108517
  from: from == null ? void 0 : vec(prop, from),
108009
108518
  to: to4 == null ? void 0 : vec(prop, to4),
@@ -108100,8 +108609,8 @@ https://github.com/highlightjs/highlight.js/issues/2277`), x5 = n3, E6 = a2), h
108100
108609
  this.stage.append(el12);
108101
108610
  this.cursor = el12;
108102
108611
  const [w6, h] = this.stageSize();
108103
- const start10 = this.cursorStart ?? [w6 * 0.7, h * 0.85];
108104
- this.tweens.push({ el: el12, prop: "translate", start: 0, dur: 0, to: start10, from: start10, ease: ease.linear, source: "cursor start" });
108612
+ const start11 = this.cursorStart ?? [w6 * 0.7, h * 0.85];
108613
+ this.tweens.push({ el: el12, prop: "translate", start: 0, dur: 0, to: start11, from: start11, ease: ease.linear, source: "cursor start" });
108105
108614
  return el12;
108106
108615
  }
108107
108616
  with(offset = 0) {
@@ -108116,26 +108625,26 @@ https://github.com/highlightjs/highlight.js/issues/2277`), x5 = n3, E6 = a2), h
108116
108625
  return this.step("wait", () => ms4);
108117
108626
  }
108118
108627
  set(target, values) {
108119
- return this.step("set", (start10) => {
108628
+ return this.step("set", (start11) => {
108120
108629
  for (const el12 of this.els(target)) {
108121
- for (const [prop, v9] of Object.entries(values)) this.add(el12, prop, start10, 0, v9, { ease: "linear" });
108630
+ for (const [prop, v9] of Object.entries(values)) this.add(el12, prop, start11, 0, v9, { ease: "linear" });
108122
108631
  }
108123
108632
  return 0;
108124
108633
  });
108125
108634
  }
108126
108635
  tween(target, prop, to4, { duration = 300, delay = 0, stagger = 0, ...opts } = {}) {
108127
- return this.step("tween", (start10) => {
108636
+ return this.step("tween", (start11) => {
108128
108637
  const list3 = this.els(target);
108129
- list3.forEach((el12, i2) => this.add(el12, prop, start10 + delay + i2 * stagger, duration, to4, opts));
108638
+ list3.forEach((el12, i2) => this.add(el12, prop, start11 + delay + i2 * stagger, duration, to4, opts));
108130
108639
  return delay + (list3.length - 1) * stagger + duration;
108131
108640
  });
108132
108641
  }
108133
108642
  rise(target, opts) {
108134
108643
  const o3 = { ...defaults.rise, ...opts };
108135
- return this.step("rise", (start10) => {
108644
+ return this.step("rise", (start11) => {
108136
108645
  const list3 = this.els(target);
108137
108646
  list3.forEach((el12, i2) => {
108138
- const t2 = start10 + i2 * o3.stagger;
108647
+ const t2 = start11 + i2 * o3.stagger;
108139
108648
  this.add(el12, "translate", t2, o3.duration, [0, 0], { from: [0, o3.distance], ease: o3.ease });
108140
108649
  this.add(el12, "opacity", t2, o3.fadeDuration, 1, { from: o3.fade, ease: "linear" });
108141
108650
  });
@@ -108144,10 +108653,10 @@ https://github.com/highlightjs/highlight.js/issues/2277`), x5 = n3, E6 = a2), h
108144
108653
  }
108145
108654
  cascade(target, opts) {
108146
108655
  const o3 = { ...defaults.cascade, ...opts };
108147
- return this.step("cascade", (start10) => {
108656
+ return this.step("cascade", (start11) => {
108148
108657
  const list3 = this.els(target);
108149
108658
  list3.forEach((el12, i2) => {
108150
- const t2 = start10 + i2 * o3.stagger;
108659
+ const t2 = start11 + i2 * o3.stagger;
108151
108660
  this.add(el12, "translate", t2, o3.duration, [0, 0], { from: [-o3.dx, -o3.dy], ease: o3.ease });
108152
108661
  this.add(el12, "opacity", t2, o3.fadeDuration, 1, { from: o3.fade, ease: "out" });
108153
108662
  });
@@ -108156,14 +108665,14 @@ https://github.com/highlightjs/highlight.js/issues/2277`), x5 = n3, E6 = a2), h
108156
108665
  }
108157
108666
  pop(target, opts) {
108158
108667
  const o3 = { ...defaults.pop, ...opts };
108159
- return this.step("pop", (start10) => {
108668
+ return this.step("pop", (start11) => {
108160
108669
  for (const el12 of this.els(target)) {
108161
- if (o3.fade !== false) this.add(el12, "opacity", start10, o3.fadeDuration, 1, { from: o3.fade, ease: "linear" });
108670
+ if (o3.fade !== false) this.add(el12, "opacity", start11, o3.fadeDuration, 1, { from: o3.fade, ease: "linear" });
108162
108671
  if (o3.overshoot) {
108163
- this.add(el12, "scale", start10, o3.up, o3.peak, { from: o3.from, ease: "linear" });
108164
- this.add(el12, "scale", start10 + o3.up, o3.down, 1, { ease: "linear" });
108672
+ this.add(el12, "scale", start11, o3.up, o3.peak, { from: o3.from, ease: "linear" });
108673
+ this.add(el12, "scale", start11 + o3.up, o3.down, 1, { ease: "linear" });
108165
108674
  } else {
108166
- this.add(el12, "scale", start10, o3.duration, 1, { from: o3.from, ease: o3.ease });
108675
+ this.add(el12, "scale", start11, o3.duration, 1, { from: o3.from, ease: o3.ease });
108167
108676
  }
108168
108677
  }
108169
108678
  return o3.overshoot ? o3.up + o3.down : o3.duration;
@@ -108171,21 +108680,21 @@ https://github.com/highlightjs/highlight.js/issues/2277`), x5 = n3, E6 = a2), h
108171
108680
  }
108172
108681
  exit(target, opts) {
108173
108682
  const o3 = { ...defaults.exit, ...opts };
108174
- return this.step("exit", (start10) => {
108683
+ return this.step("exit", (start11) => {
108175
108684
  for (const el12 of this.els(target)) {
108176
- const d2 = this.current(el12, "translate", start10);
108177
- this.add(el12, "translate", start10, o3.duration, [d2[0], d2[1] - o3.distance], { ease: o3.ease });
108178
- this.add(el12, "opacity", start10, o3.duration, o3.opacity, { ease: "linear" });
108685
+ const d2 = this.current(el12, "translate", start11);
108686
+ this.add(el12, "translate", start11, o3.duration, [d2[0], d2[1] - o3.distance], { ease: o3.ease });
108687
+ this.add(el12, "opacity", start11, o3.duration, o3.opacity, { ease: "linear" });
108179
108688
  }
108180
108689
  return o3.duration;
108181
108690
  });
108182
108691
  }
108183
108692
  slideOff(target, opts) {
108184
108693
  const o3 = { ...defaults.slideOff, ...opts };
108185
- return this.step("slideOff", (start10) => {
108694
+ return this.step("slideOff", (start11) => {
108186
108695
  const list3 = this.els(target);
108187
108696
  list3.forEach((el12, i2) => {
108188
- const t2 = start10 + i2 * o3.stagger;
108697
+ const t2 = start11 + i2 * o3.stagger;
108189
108698
  const d2 = this.current(el12, "translate", t2);
108190
108699
  this.add(el12, "translate", t2, o3.duration, [d2[0] + o3.dx, d2[1] + o3.dy], { ease: o3.ease });
108191
108700
  this.add(el12, "opacity", t2, o3.duration, 0, { ease: "linear" });
@@ -108195,15 +108704,15 @@ https://github.com/highlightjs/highlight.js/issues/2277`), x5 = n3, E6 = a2), h
108195
108704
  }
108196
108705
  hover(target, opts) {
108197
108706
  const o3 = { ...defaults.hover, ...opts };
108198
- return this.step("hover", (start10) => {
108707
+ return this.step("hover", (start11) => {
108199
108708
  for (const el12 of this.els(target)) {
108200
- const d2 = this.current(el12, "translate", start10);
108201
- const s3 = this.current(el12, "scale", start10);
108202
- const r45 = this.current(el12, "rotate", start10);
108203
- const back = start10 + o3.duration + o3.hold;
108204
- this.add(el12, "translate", start10, o3.duration, [d2[0], d2[1] - o3.lift], { ease: o3.ease });
108205
- this.add(el12, "scale", start10, o3.duration, [s3[0] * o3.scale, s3[1] * o3.scale], { ease: o3.ease });
108206
- this.add(el12, "rotate", start10, o3.duration, [r45[0] + o3.rotate], { ease: o3.ease });
108709
+ const d2 = this.current(el12, "translate", start11);
108710
+ const s3 = this.current(el12, "scale", start11);
108711
+ const r45 = this.current(el12, "rotate", start11);
108712
+ const back = start11 + o3.duration + o3.hold;
108713
+ this.add(el12, "translate", start11, o3.duration, [d2[0], d2[1] - o3.lift], { ease: o3.ease });
108714
+ this.add(el12, "scale", start11, o3.duration, [s3[0] * o3.scale, s3[1] * o3.scale], { ease: o3.ease });
108715
+ this.add(el12, "rotate", start11, o3.duration, [r45[0] + o3.rotate], { ease: o3.ease });
108207
108716
  this.add(el12, "translate", back, o3.back, d2, { ease: o3.ease });
108208
108717
  this.add(el12, "scale", back, o3.back, s3, { ease: o3.ease });
108209
108718
  this.add(el12, "rotate", back, o3.back, r45, { ease: o3.ease });
@@ -108218,24 +108727,24 @@ https://github.com/highlightjs/highlight.js/issues/2277`), x5 = n3, E6 = a2), h
108218
108727
  }
108219
108728
  press(target, opts) {
108220
108729
  const o3 = { ...defaults.press, ...opts };
108221
- return this.step("press", (start10) => {
108222
- for (const el12 of this.els(target)) this.pulse(el12, start10, o3.scale, o3.up, o3.down);
108730
+ return this.step("press", (start11) => {
108731
+ for (const el12 of this.els(target)) this.pulse(el12, start11, o3.scale, o3.up, o3.down);
108223
108732
  return o3.up + o3.down;
108224
108733
  });
108225
108734
  }
108226
108735
  move(target, opts) {
108227
108736
  const o3 = { ...defaults.move, ...opts };
108228
- return this.step("move", (start10) => {
108737
+ return this.step("move", (start11) => {
108229
108738
  const c4 = this.cursorEl();
108230
- const a2 = this.current(c4, "translate", start10);
108739
+ const a2 = this.current(c4, "translate", start11);
108231
108740
  const el12 = Array.isArray(target) ? null : this.el(target);
108232
108741
  const aim = (t2) => el12 ? this.pointAt(el12, t2, o3.offset) : target;
108233
108742
  const timeFor = (d2) => o3.duration ?? (d2 < 120 ? 290 : Math.min(1e3, 400 + d2 * 1.2));
108234
- let b6 = aim(start10);
108743
+ let b6 = aim(start11);
108235
108744
  let dur = 0;
108236
108745
  for (let i2 = 0; i2 < 3; i2++) {
108237
108746
  dur = timeFor(Math.hypot(b6[0] - a2[0], b6[1] - a2[1]));
108238
- b6 = aim(start10 + dur);
108747
+ b6 = aim(start11 + dur);
108239
108748
  }
108240
108749
  const dist = Math.hypot(b6[0] - a2[0], b6[1] - a2[1]);
108241
108750
  if (dist < 1) return 0;
@@ -108243,7 +108752,7 @@ https://github.com/highlightjs/highlight.js/issues/2277`), x5 = n3, E6 = a2), h
108243
108752
  let n3 = [-(b6[1] - a2[1]) / dist, (b6[0] - a2[0]) / dist];
108244
108753
  if (n3[1] < 0) n3 = [-n3[0], -n3[1]];
108245
108754
  const ctrl = [(a2[0] + b6[0]) / 2 + n3[0] * bow, (a2[1] + b6[1]) / 2 + n3[1] * bow];
108246
- this.add(c4, "translate", start10, dur, b6, { ease: o3.ease, path: (u4) => quad(a2, ctrl, b6, u4) });
108755
+ this.add(c4, "translate", start11, dur, b6, { ease: o3.ease, path: (u4) => quad(a2, ctrl, b6, u4) });
108247
108756
  return dur;
108248
108757
  });
108249
108758
  }
@@ -108258,8 +108767,8 @@ https://github.com/highlightjs/highlight.js/issues/2277`), x5 = n3, E6 = a2), h
108258
108767
  this.mode = { at: this.last.end };
108259
108768
  }
108260
108769
  }
108261
- return this.step("click", (start10) => {
108262
- const t2 = start10 + o3.settle;
108770
+ return this.step("click", (start11) => {
108771
+ const t2 = start11 + o3.settle;
108263
108772
  this.pulse(this.cursorEl(), t2, o3.cursorScale, o3.up, o3.down);
108264
108773
  if (target != null && !Array.isArray(target) && o3.press) this.pulse(this.el(target), t2, o3.targetScale, o3.up, o3.up);
108265
108774
  return o3.settle + o3.up + o3.down;
@@ -108267,39 +108776,39 @@ https://github.com/highlightjs/highlight.js/issues/2277`), x5 = n3, E6 = a2), h
108267
108776
  }
108268
108777
  ripple(target, opts) {
108269
108778
  const o3 = { ...defaults.ripple, ...opts };
108270
- return this.step("ripple", (start10) => {
108779
+ return this.step("ripple", (start11) => {
108271
108780
  for (const el12 of this.els(target)) {
108272
- this.add(el12, "scale", start10, o3.duration, 1, { from: o3.from, ease: o3.ease });
108273
- this.add(el12, "opacity", start10, 0, o3.fade, { from: 0, ease: "linear" });
108274
- this.add(el12, "opacity", start10 + o3.fadeAt, o3.fadeDuration, 0, { ease: "linear" });
108781
+ this.add(el12, "scale", start11, o3.duration, 1, { from: o3.from, ease: o3.ease });
108782
+ this.add(el12, "opacity", start11, 0, o3.fade, { from: 0, ease: "linear" });
108783
+ this.add(el12, "opacity", start11 + o3.fadeAt, o3.fadeDuration, 0, { ease: "linear" });
108275
108784
  }
108276
108785
  return Math.max(o3.duration, o3.fadeAt + o3.fadeDuration);
108277
108786
  });
108278
108787
  }
108279
108788
  flip(target, opts) {
108280
108789
  const o3 = { ...defaults.flip, ...opts };
108281
- return this.step("flip", (start10) => {
108790
+ return this.step("flip", (start11) => {
108282
108791
  for (const el12 of this.els(target)) {
108283
- const r45 = this.current(el12, "rotate", start10);
108284
- this.add(el12, "rotate", start10, o3.duration, [r45[0] + o3.deg], { ease: o3.ease });
108792
+ const r45 = this.current(el12, "rotate", start11);
108793
+ this.add(el12, "rotate", start11, o3.duration, [r45[0] + o3.deg], { ease: o3.ease });
108285
108794
  }
108286
108795
  return o3.duration;
108287
108796
  });
108288
108797
  }
108289
108798
  grow(target, opts) {
108290
108799
  const o3 = { ...defaults.grow, ...opts };
108291
- return this.step("grow", (start10) => {
108800
+ return this.step("grow", (start11) => {
108292
108801
  const list3 = this.els(target);
108293
108802
  const from = o3.axis === "x" ? [o3.from, 1] : [1, o3.from];
108294
- list3.forEach((el12, i2) => this.add(el12, "scale", start10 + i2 * o3.stagger, o3.duration, [1, 1], { from, ease: o3.ease }));
108803
+ list3.forEach((el12, i2) => this.add(el12, "scale", start11 + i2 * o3.stagger, o3.duration, [1, 1], { from, ease: o3.ease }));
108295
108804
  return (list3.length - 1) * o3.stagger + o3.duration;
108296
108805
  });
108297
108806
  }
108298
108807
  zoom(target, opts) {
108299
108808
  const o3 = { ...defaults.zoom, ...opts };
108300
- return this.step("zoom", (start10) => {
108809
+ return this.step("zoom", (start11) => {
108301
108810
  const el12 = this.el(target);
108302
- const end2 = start10 + o3.duration;
108811
+ const end2 = start11 + o3.duration;
108303
108812
  const s3 = vec("scale", o3.scale);
108304
108813
  let d2 = [0, 0];
108305
108814
  if (o3.to) {
@@ -108313,25 +108822,25 @@ https://github.com/highlightjs/highlight.js/issues/2277`), x5 = n3, E6 = a2), h
108313
108822
  const y6 = (p5[1] - c4[1]) * s3[1];
108314
108823
  d2 = [f3[0] - c4[0] - (x5 * Math.cos(r45) - y6 * Math.sin(r45)), f3[1] - c4[1] - (x5 * Math.sin(r45) + y6 * Math.cos(r45))];
108315
108824
  }
108316
- this.add(el12, "scale", start10, o3.duration, s3, { ease: o3.ease });
108317
- this.add(el12, "translate", start10, o3.duration, d2, { ease: o3.ease });
108825
+ this.add(el12, "scale", start11, o3.duration, s3, { ease: o3.ease });
108826
+ this.add(el12, "translate", start11, o3.duration, d2, { ease: o3.ease });
108318
108827
  return o3.duration;
108319
108828
  });
108320
108829
  }
108321
108830
  zoomOut(target, opts) {
108322
108831
  const o3 = { ...defaults.zoomOut, ...opts };
108323
- return this.step("zoomOut", (start10) => {
108832
+ return this.step("zoomOut", (start11) => {
108324
108833
  const el12 = this.el(target);
108325
- this.add(el12, "scale", start10, o3.duration, 1, { ease: o3.ease });
108326
- this.add(el12, "translate", start10, o3.duration, [0, 0], { ease: o3.ease });
108834
+ this.add(el12, "scale", start11, o3.duration, 1, { ease: o3.ease });
108835
+ this.add(el12, "translate", start11, o3.duration, [0, 0], { ease: o3.ease });
108327
108836
  return o3.duration;
108328
108837
  });
108329
108838
  }
108330
108839
  reset(opts) {
108331
108840
  const o3 = { ...defaults.reset, ...opts };
108332
- return this.step("reset", (start10) => {
108333
- if (this.stillAt == null) this.stillAt = start10;
108334
- this.resets.push({ start: start10, dur: o3.duration, ease: toBezier(o3.ease), source: `reset at ${Math.round(start10)} ms` });
108841
+ return this.step("reset", (start11) => {
108842
+ if (this.stillAt == null) this.stillAt = start11;
108843
+ this.resets.push({ start: start11, dur: o3.duration, ease: toBezier(o3.ease), source: `reset at ${Math.round(start11)} ms` });
108335
108844
  return o3.duration;
108336
108845
  });
108337
108846
  }
@@ -111926,8 +112435,8 @@ ${t2}` : `"use strict"; return (${t2});`;
111926
112435
  }
111927
112436
  return null;
111928
112437
  }
111929
- function checkSiblings(start10, direction) {
111930
- let sibling = start10[direction];
112438
+ function checkSiblings(start11, direction) {
112439
+ let sibling = start11[direction];
111931
112440
  while (sibling) {
111932
112441
  const found = checkDeep(sibling);
111933
112442
  if (found) return found;
@@ -112780,7 +113289,7 @@ ${t2}` : `"use strict"; return (${t2});`;
112780
113289
  get: () => get4,
112781
113290
  parseHash: () => parseHash,
112782
113291
  set: () => set2,
112783
- start: () => start9,
113292
+ start: () => start10,
112784
113293
  stop: () => stop5
112785
113294
  });
112786
113295
  function parseHash(hash) {
@@ -112903,7 +113412,7 @@ ${t2}` : `"use strict"; return (${t2});`;
112903
113412
  observer2.observe(document.body, { childList: true, subtree: true });
112904
113413
  }
112905
113414
  }
112906
- function start9() {
113415
+ function start10() {
112907
113416
  if (started4) return;
112908
113417
  started4 = true;
112909
113418
  mirrorRoot(parseHash(location.hash));
@@ -112941,7 +113450,7 @@ ${t2}` : `"use strict"; return (${t2});`;
112941
113450
  route = { get: get4, set: set2, apply: apply2 };
112942
113451
  clay5 = window.clay = window.clay || {};
112943
113452
  clay5.route = route;
112944
- start9();
113453
+ start10();
112945
113454
  route_default = route;
112946
113455
  }
112947
113456
  });
@@ -113246,6 +113755,9 @@ ${t2}` : `"use strict"; return (${t2});`;
113246
113755
  // owner editing the original, gets the owner module: the chip when it applies and
113247
113756
  // the inert `clay.visitorDrafts`, without the drafts UI's 24 KB.
113248
113757
  "visitor-drafts": { path: "plugins/visitor-drafts.js", ownerPath: "plugins/visitor-drafts-owner.js", editOnly: false, default: false },
113758
+ // `draft: true` loads it only in a visitor's draft. The key is short on purpose: every
113759
+ // reader downloads this file, and the reader's Brotli ceiling counts it.
113760
+ "visitor-menu": { path: "plugins/visitor-menu.js", editOnly: true, draft: true },
113249
113761
  // An editor textarea outside the saved records, bound to one record's text
113250
113762
  // element. Edit mode only: the page that asks for it is the page whose owner
113251
113763
  // writes in it.
@@ -113301,12 +113813,13 @@ ${t2}` : `"use strict"; return (${t2});`;
113301
113813
  "plugins/demo.js": () => Promise.resolve().then(() => (init_demo(), demo_exports)),
113302
113814
  "plugins/visitor-drafts.js": () => Promise.resolve().then(() => (init_visitor_drafts(), visitor_drafts_exports)),
113303
113815
  "plugins/visitor-drafts-owner.js": () => Promise.resolve().then(() => (init_visitor_drafts_owner(), visitor_drafts_owner_exports)),
113816
+ "plugins/visitor-menu.js": () => Promise.resolve().then(() => (init_visitor_menu(), visitor_menu_exports)),
113304
113817
  "plugins/bind-text.js": () => Promise.resolve().then(() => (init_bind_text(), bind_text_exports)),
113305
113818
  "plugins/source.js": () => Promise.resolve().then(() => (init_source2(), source_exports)),
113306
113819
  "plugins/derive.js": () => Promise.resolve().then(() => (init_derive(), derive_exports)),
113307
113820
  "plugins/upgrade.js": () => Promise.resolve().then(() => (init_upgrade(), upgrade_exports))
113308
113821
  };
113309
- var PLUGIN_ORDER = ["visitor-drafts", "richclay", "indicator", "sortable", "undo", "unsent", "quickcrop", "upload", "people", "menu", "upgrade", "cms", "page-view", "sync", "live", "page", "message", "like", "wire", "ai-edit", "demo", "derive", "bind-text", "source"];
113822
+ var PLUGIN_ORDER = ["visitor-drafts", "visitor-menu", "richclay", "indicator", "sortable", "undo", "unsent", "quickcrop", "upload", "people", "menu", "upgrade", "cms", "page-view", "sync", "live", "page", "message", "like", "wire", "ai-edit", "demo", "derive", "bind-text", "source"];
113310
113823
  var IMPLIES = { cms: ["quickcrop", "upload", "menu"], "ai-edit": ["wire"], page: ["live", "sync", "upload"] };
113311
113824
  var DISPLACES = { page: ["richclay"] };
113312
113825
  var LATE = /* @__PURE__ */ new Set(["source", "sortable", "menu", "upgrade"]);
@@ -113368,7 +113881,7 @@ ${t2}` : `"use strict"; return (${t2});`;
113368
113881
  for (const name of PLUGIN_ORDER) {
113369
113882
  if (!enabled.has(name)) continue;
113370
113883
  const spec = PLUGIN_PATHS[name];
113371
- if (spec.editOnly && !isEditMode2) continue;
113884
+ if (spec.editOnly && !isEditMode2 || spec.draft && !isDraftMode2) continue;
113372
113885
  (LATE.has(name) ? late : plugins).push(spec.ownerPath && !isDraftMode2 ? spec.ownerPath : spec.path);
113373
113886
  }
113374
113887
  return { core, plugins, late };