@heycys/gallery 0.1.0 → 0.1.2

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 (465) hide show
  1. package/THIRD-PARTY-NOTICES.md +51 -1
  2. package/browser/editor/components/callout/index.mjs +40 -15
  3. package/browser/editor/components/columns/page.mjs +45 -32
  4. package/browser/editor/components/details/index.mjs +2 -1
  5. package/browser/editor/components/dialog/index.mjs +2 -1
  6. package/browser/editor/components/dialog/page.mjs +0 -18
  7. package/browser/editor/components/divider/index.mjs +1 -1
  8. package/browser/editor/components/embed/index.mjs +2 -2
  9. package/browser/editor/components/figure/page.mjs +10 -1
  10. package/browser/editor/components/file/page.mjs +2 -2
  11. package/browser/editor/components/flowchart/add.mjs +7 -6
  12. package/browser/editor/components/flowchart/page.mjs +1 -1
  13. package/browser/editor/components/heading/index.mjs +2 -0
  14. package/browser/editor/components/heading/page.mjs +6 -0
  15. package/browser/editor/components/highlight/index.mjs +4 -20
  16. package/browser/editor/components/icons.mjs +13 -2
  17. package/browser/editor/components/image/crop.mjs +6 -9
  18. package/browser/editor/components/image/page.mjs +2 -2
  19. package/browser/editor/components/installed/index.mjs +82 -29
  20. package/browser/editor/components/installed/page.mjs +146 -34
  21. package/browser/editor/components/installed/served.mjs +6 -5
  22. package/browser/editor/components/instances.mjs +18 -0
  23. package/browser/editor/components/kit.mjs +3 -0
  24. package/browser/editor/components/list/page.mjs +3 -6
  25. package/browser/editor/components/media/page.mjs +44 -14
  26. package/browser/editor/components/pages.mjs +2 -2
  27. package/browser/editor/components/registry.mjs +68 -33
  28. package/browser/editor/components/section/index.mjs +2 -1
  29. package/browser/editor/components/set-apart.mjs +24 -0
  30. package/browser/editor/components/table/index.mjs +64 -5
  31. package/browser/editor/components/table/page.mjs +30 -19
  32. package/browser/editor/page/annotate/anchors.mjs +4 -3
  33. package/browser/editor/page/annotate/card.mjs +3 -6
  34. package/browser/editor/page/annotate/index.mjs +61 -34
  35. package/browser/editor/page/autosave.mjs +357 -38
  36. package/browser/editor/page/beside.mjs +5 -5
  37. package/browser/editor/page/block-menu/colors.mjs +3 -1
  38. package/browser/editor/page/block-menu/index.mjs +8 -6
  39. package/browser/editor/page/blocks.mjs +16 -7
  40. package/browser/editor/page/board/client.mjs +57 -0
  41. package/browser/editor/page/board/hint.mjs +145 -0
  42. package/browser/editor/page/board/history.mjs +119 -0
  43. package/browser/editor/page/board/index.mjs +970 -0
  44. package/browser/editor/page/board/settings.mjs +209 -0
  45. package/browser/editor/page/caret.mjs +5 -2
  46. package/browser/editor/page/changes/bar.mjs +94 -0
  47. package/browser/editor/page/changes/ghost.mjs +206 -0
  48. package/browser/editor/page/changes/gone-words.mjs +94 -0
  49. package/browser/editor/page/changes/index.mjs +447 -0
  50. package/browser/editor/page/changes/words.mjs +27 -0
  51. package/browser/editor/page/clipboard/import/colors.mjs +3 -3
  52. package/browser/editor/page/clipboard/import/html.mjs +29 -6
  53. package/browser/editor/page/clipboard/import/inline.mjs +32 -0
  54. package/browser/editor/page/clipboard/import/markdown.mjs +58 -13
  55. package/browser/editor/page/clipboard/import/read.mjs +6 -1
  56. package/browser/editor/page/clipboard/import/to-blocks.mjs +44 -12
  57. package/browser/editor/page/clipboard/import/yuque.mjs +622 -0
  58. package/browser/editor/page/clipboard/index.mjs +156 -26
  59. package/browser/editor/page/clipboard/own/blocks.mjs +25 -16
  60. package/browser/editor/page/clipboard/own/chart-keys.mjs +41 -28
  61. package/browser/editor/page/clipboard/own/describe.mjs +16 -7
  62. package/browser/editor/page/clipboard/own/export.mjs +6 -6
  63. package/browser/editor/page/clipboard/own/selection.mjs +3 -3
  64. package/browser/editor/page/clipboard/own/writers.mjs +0 -11
  65. package/browser/editor/page/columns/index.mjs +48 -46
  66. package/browser/editor/page/commit.mjs +98 -25
  67. package/browser/editor/page/conflicts.mjs +13 -33
  68. package/browser/editor/page/convert.mjs +8 -7
  69. package/browser/editor/page/core.mjs +81 -27
  70. package/browser/editor/page/custom-page.mjs +106 -0
  71. package/browser/editor/page/drag/index.mjs +40 -24
  72. package/browser/editor/page/drag/preview.mjs +9 -4
  73. package/browser/editor/page/editor.mjs +120 -28
  74. package/browser/editor/page/emoji-picker/emoji-tab.mjs +22 -13
  75. package/browser/editor/page/emoji-picker/grid.mjs +7 -5
  76. package/browser/editor/page/emoji-picker/icon-tab.mjs +4 -4
  77. package/browser/editor/page/emoji-picker/icons.mjs +0 -1
  78. package/browser/editor/page/emoji-picker/index.mjs +11 -9
  79. package/browser/editor/page/emoji-picker/styles.mjs +156 -2
  80. package/browser/editor/page/emoji-picker/support.mjs +6 -4
  81. package/browser/editor/page/emoji-picker/upload.mjs +14 -13
  82. package/browser/editor/page/fills.mjs +5 -3
  83. package/browser/editor/page/fold/index.mjs +348 -0
  84. package/browser/editor/page/fold/rule.mjs +125 -0
  85. package/browser/editor/page/folded.mjs +23 -0
  86. package/browser/editor/page/format-bar/bar.mjs +2 -1
  87. package/browser/editor/page/format-bar/index.mjs +1 -1
  88. package/browser/editor/page/geometry.mjs +8 -6
  89. package/browser/editor/page/handle/index.mjs +22 -14
  90. package/browser/editor/page/hints/index.mjs +1 -1
  91. package/browser/editor/page/history.mjs +24 -4
  92. package/browser/editor/page/insert/index.mjs +30 -17
  93. package/browser/editor/page/links/index.mjs +5 -3
  94. package/browser/editor/page/links/pages.mjs +27 -9
  95. package/browser/editor/page/long-runs.mjs +75 -0
  96. package/browser/editor/page/look.mjs +69 -6
  97. package/browser/editor/page/margin.mjs +63 -27
  98. package/browser/editor/page/media-menu/index.mjs +6 -7
  99. package/browser/editor/page/menu.mjs +86 -31
  100. package/browser/editor/page/merge.mjs +24 -0
  101. package/browser/editor/page/notices.mjs +3 -3
  102. package/browser/editor/page/offered.mjs +1 -1
  103. package/browser/editor/page/outline/folds.mjs +11 -10
  104. package/browser/editor/page/outline/index.mjs +131 -45
  105. package/browser/editor/page/outline/list.mjs +23 -11
  106. package/browser/editor/page/outline/read.mjs +1 -1
  107. package/browser/editor/page/outline/strip.mjs +7 -1
  108. package/browser/editor/page/page-objects.mjs +13 -2
  109. package/browser/editor/page/panel.mjs +9 -13
  110. package/browser/editor/page/present-links.mjs +11 -2
  111. package/browser/editor/page/resize/index.mjs +42 -29
  112. package/browser/editor/page/selection/delete.mjs +8 -6
  113. package/browser/editor/page/selection/index.mjs +10 -3
  114. package/browser/editor/page/served.mjs +14 -0
  115. package/browser/editor/page/session.mjs +101 -6
  116. package/browser/editor/page/slash-menu/index.mjs +3 -3
  117. package/browser/editor/page/table/cell-bar.mjs +4 -1
  118. package/browser/editor/page/table/cells.mjs +103 -47
  119. package/browser/editor/page/table/icons.mjs +3 -1
  120. package/browser/editor/page/table/index.mjs +40 -16
  121. package/browser/editor/page/table/pictures.mjs +299 -0
  122. package/browser/editor/page/table/views.mjs +150 -0
  123. package/browser/editor/page/table/widths.mjs +9 -4
  124. package/browser/editor/page/text-select/index.mjs +43 -14
  125. package/browser/editor/page/todo-writes.mjs +75 -0
  126. package/browser/editor/page/tooltip.mjs +1 -1
  127. package/browser/editor/page/type-grid.mjs +4 -3
  128. package/browser/editor/page/typing/code-edges.mjs +63 -17
  129. package/browser/editor/page/typing/index.mjs +65 -9
  130. package/browser/editor/page/typing/leave.mjs +1 -1
  131. package/browser/editor/page/ui.mjs +13 -0
  132. package/browser/shared/annotations.mjs +8 -10
  133. package/browser/shared/block-packs.mjs +404 -0
  134. package/browser/shared/board-places.mjs +224 -0
  135. package/browser/shared/card-size.mjs +59 -0
  136. package/browser/shared/code-folds.mjs +5 -1
  137. package/browser/shared/colors.mjs +17 -14
  138. package/browser/shared/component-catalog.mjs +345 -54
  139. package/browser/shared/component-source.mjs +37 -0
  140. package/browser/shared/components/callout.mjs +4 -2
  141. package/browser/shared/components/index.mjs +72 -9
  142. package/browser/shared/components/installed.mjs +110 -8
  143. package/browser/shared/components/page.mjs +22 -3
  144. package/browser/shared/components/state.mjs +5 -1
  145. package/browser/shared/components/table.mjs +1 -1
  146. package/browser/shared/components/text.mjs +2 -2
  147. package/browser/shared/document-look.mjs +183 -0
  148. package/browser/shared/drafts.mjs +432 -0
  149. package/browser/shared/emoji/data/LICENSE-lucide.txt +43 -0
  150. package/browser/shared/emoji/data/README.md +4 -2
  151. package/browser/shared/emoji/data/categories.json +1 -1
  152. package/browser/shared/emoji/data/keywords-en.json +1 -1
  153. package/browser/shared/emoji/data/keywords-zh.json +1 -1
  154. package/browser/shared/emoji/data/names.json +1 -1
  155. package/browser/shared/emoji/data/positions.json +1 -1
  156. package/browser/shared/emoji/data/twemoji-index.json +1 -1
  157. package/browser/shared/emoji/data/twemoji-svg.bin +0 -0
  158. package/browser/shared/emoji/data.mjs +10 -12
  159. package/browser/shared/emoji/emoji.mjs +8 -7
  160. package/browser/shared/emoji/icon-value.mjs +4 -3
  161. package/browser/shared/extension-sidebar.mjs +126 -0
  162. package/browser/shared/extensions.mjs +79 -0
  163. package/browser/shared/file-table.mjs +101 -0
  164. package/browser/shared/html-tree.mjs +11 -5
  165. package/browser/shared/i18n/en.mjs +374 -35
  166. package/browser/shared/json-layout.mjs +47 -0
  167. package/browser/shared/long-runs.mjs +39 -0
  168. package/browser/shared/net-cache.mjs +133 -0
  169. package/browser/shared/net-keys.mjs +32 -0
  170. package/browser/shared/net-policy.mjs +177 -0
  171. package/browser/shared/new-names.mjs +5 -2
  172. package/browser/shared/outline-shape.mjs +128 -0
  173. package/browser/shared/outline.mjs +458 -0
  174. package/browser/shared/pack-manifest.mjs +77 -0
  175. package/browser/shared/page-address.mjs +6 -3
  176. package/browser/shared/page-cards.mjs +308 -0
  177. package/browser/shared/page-links.mjs +69 -6
  178. package/browser/shared/pages.mjs +388 -0
  179. package/browser/shared/paths.mjs +6 -0
  180. package/browser/shared/preferences.mjs +10 -4
  181. package/browser/shared/preview-server.mjs +3 -7
  182. package/browser/shared/session.mjs +13 -5
  183. package/browser/shared/shipped-blocks.mjs +299 -0
  184. package/browser/shared/table-chart.mjs +33 -1
  185. package/browser/shared/todos.mjs +83 -0
  186. package/browser/shared/user-directory.mjs +24 -0
  187. package/browser/shared/versions.mjs +14 -0
  188. package/browser/shared/web-links.mjs +134 -0
  189. package/browser/shared/workspace-columns.mjs +120 -0
  190. package/browser/shared/workspace-look.mjs +91 -0
  191. package/browser/shared/workspace-name.mjs +154 -0
  192. package/browser/shared/workspace-query.mjs +125 -0
  193. package/browser/shared/workspace-registry.mjs +272 -0
  194. package/browser/shared/workspace.mjs +171 -20
  195. package/browser/shared/zoom.mjs +5 -5
  196. package/dist/chunk-2NRBY6AJ.mjs +2 -0
  197. package/dist/chunk-32ZUEFZ7.mjs +2 -0
  198. package/dist/chunk-35NQ4PLQ.mjs +2 -0
  199. package/dist/chunk-3KJHLHUO.mjs +2 -0
  200. package/dist/chunk-3NJACR4W.mjs +2 -0
  201. package/dist/chunk-4AV456RQ.mjs +2 -0
  202. package/dist/chunk-4OZWXZE5.mjs +5 -0
  203. package/dist/chunk-5XYHDBJ5.mjs +2 -0
  204. package/dist/chunk-5ZJA7CXT.mjs +2 -0
  205. package/dist/chunk-6A53MZYZ.mjs +2 -0
  206. package/dist/chunk-6EXH3ORZ.mjs +166 -0
  207. package/dist/chunk-6EZ7FNIK.mjs +3 -0
  208. package/dist/{chunk-UXUK4PMC.mjs → chunk-6QBHU4DF.mjs} +1 -1
  209. package/dist/{chunk-6U2SLSDN.mjs → chunk-6VTU6KEO.mjs} +1 -1
  210. package/dist/chunk-B4P2CM2J.mjs +3 -0
  211. package/dist/chunk-BPL64HGA.mjs +4 -0
  212. package/dist/chunk-BVEFGE4B.mjs +2 -0
  213. package/dist/chunk-BZ5RAF7L.mjs +2 -0
  214. package/dist/chunk-CRJEG7MT.mjs +2 -0
  215. package/dist/{chunk-B3VTYBYR.mjs → chunk-D4CKRD3V.mjs} +91 -91
  216. package/dist/chunk-D4EURAX4.mjs +4 -0
  217. package/dist/chunk-DQCE7TJY.mjs +5 -0
  218. package/dist/chunk-DR73Y2UJ.mjs +3 -0
  219. package/dist/{chunk-TMYZB6AV.mjs → chunk-EKNHM3P4.mjs} +1 -1
  220. package/dist/{chunk-DB4WKGYF.mjs → chunk-ERLAIBOA.mjs} +2 -2
  221. package/dist/chunk-EURLTOTZ.mjs +4 -0
  222. package/dist/chunk-FJYN7RTH.mjs +4 -0
  223. package/dist/chunk-FWNRPMCJ.mjs +12 -0
  224. package/dist/chunk-FWW4CSAZ.mjs +2 -0
  225. package/dist/{chunk-2B5E4CDJ.mjs → chunk-GPIWQ4X4.mjs} +1 -1
  226. package/dist/chunk-GY3FAUVM.mjs +2 -0
  227. package/dist/chunk-HLYV7RIH.mjs +2 -0
  228. package/dist/chunk-HMYTM3GT.mjs +15 -0
  229. package/dist/chunk-IA4PSIMD.mjs +2 -0
  230. package/dist/chunk-JEUK3ZO7.mjs +2 -0
  231. package/dist/chunk-JVHHHGEA.mjs +3 -0
  232. package/dist/chunk-KTKHRC6H.mjs +2 -0
  233. package/dist/chunk-L7UP52JO.mjs +2 -0
  234. package/dist/chunk-MHW7ZKOU.mjs +2 -0
  235. package/dist/chunk-N76HWBA3.mjs +10 -0
  236. package/dist/chunk-N7AZZLGT.mjs +548 -0
  237. package/dist/chunk-NAMN3RAF.mjs +2 -0
  238. package/dist/{chunk-YXAUQPVK.mjs → chunk-NFMCP2HI.mjs} +3 -3
  239. package/dist/chunk-NG375ILQ.mjs +2 -0
  240. package/dist/chunk-NVRNLK25.mjs +6 -0
  241. package/dist/chunk-NWFBE2YA.mjs +2 -0
  242. package/dist/chunk-NWR2LT5B.mjs +2 -0
  243. package/dist/chunk-OJKMINIU.mjs +20 -0
  244. package/dist/chunk-OUUP3WKT.mjs +2 -0
  245. package/dist/chunk-OW5NWPOJ.mjs +10 -0
  246. package/dist/chunk-PAREWQGB.mjs +4 -0
  247. package/dist/chunk-POQSE4C2.mjs +2 -0
  248. package/dist/chunk-PUOQ65NC.mjs +2 -0
  249. package/dist/{chunk-Z52HTUW7.mjs → chunk-PVER7LSC.mjs} +2 -2
  250. package/dist/chunk-PZDLJJTJ.mjs +3 -0
  251. package/dist/chunk-Q47PLKIJ.mjs +15 -0
  252. package/dist/chunk-Q4UEPUWF.mjs +2 -0
  253. package/dist/chunk-QKXMPUXC.mjs +2 -0
  254. package/dist/chunk-QOUEFUCH.mjs +16 -0
  255. package/dist/chunk-RFDZXFJF.mjs +13 -0
  256. package/dist/chunk-RKPWLGZ3.mjs +4 -0
  257. package/dist/chunk-RMECZA2K.mjs +2 -0
  258. package/dist/{chunk-EUX7IC5J.mjs → chunk-SQ6Y2ZMA.mjs} +2 -2
  259. package/dist/chunk-SX4LJYT6.mjs +8 -0
  260. package/dist/chunk-SXHBYZST.mjs +16 -0
  261. package/dist/chunk-TANZRINB.mjs +2 -0
  262. package/dist/chunk-TEZAWDSQ.mjs +2 -0
  263. package/dist/chunk-UBBRTJ2R.mjs +24 -0
  264. package/dist/chunk-UFNYFFKO.mjs +20 -0
  265. package/dist/chunk-UGWYKHBL.mjs +170 -0
  266. package/dist/chunk-UKSHDZZ6.mjs +2 -0
  267. package/dist/chunk-UMHUSOPJ.mjs +2 -0
  268. package/dist/chunk-UNOYVIYR.mjs +2 -0
  269. package/dist/chunk-V6RIYQZZ.mjs +4 -0
  270. package/dist/chunk-VJPFVNNW.mjs +15 -0
  271. package/dist/chunk-VS3ZMVGX.mjs +5 -0
  272. package/dist/chunk-VTKNEYT3.mjs +6 -0
  273. package/dist/chunk-VXACTLO3.mjs +3 -0
  274. package/dist/chunk-W3BGBJQW.mjs +2 -0
  275. package/dist/chunk-YI43RG4P.mjs +2 -0
  276. package/dist/chunk-YQGT4AB2.mjs +6 -0
  277. package/dist/chunk-ZB4H7ZN4.mjs +2 -0
  278. package/dist/{chunk-ACOPDCNB.mjs → chunk-ZHEHPMBK.mjs} +1 -1
  279. package/dist/chunk-ZTHICSSF.mjs +2 -0
  280. package/dist/chunk-ZUNVAXLH.mjs +2 -0
  281. package/dist/chunk-ZWPMCK7P.mjs +2 -0
  282. package/dist/cli.mjs +1 -1
  283. package/dist/server.mjs +1 -1
  284. package/dist/{chunk-EVJ3BX3M.mjs → update-fetch.mjs} +1 -1
  285. package/dist/worker.mjs +1 -1
  286. package/kit/board.css +95 -0
  287. package/kit/board.js +250 -0
  288. package/kit/charts.js +5 -71
  289. package/kit/code.js +14 -14
  290. package/kit/math.js +18 -2
  291. package/kit/report.css +500 -151
  292. package/kit/runtime.js +1720 -170
  293. package/kit/state.js +10 -1
  294. package/kit/tables.js +172 -37
  295. package/kit/ui.js +166 -27
  296. package/package.json +2 -1
  297. package/packs/gallery/card/component.json +14 -0
  298. package/packs/gallery/card/example.html +10 -0
  299. package/packs/gallery/card/preview.svg +1 -0
  300. package/packs/gallery/card/style.css +6 -0
  301. package/packs/gallery/card/template.html +6 -0
  302. package/packs/gallery/card/writing.md +14 -0
  303. package/packs/gallery/chart-card/component.json +15 -0
  304. package/packs/gallery/chart-card/example.html +14 -0
  305. package/packs/gallery/chart-card/kit.js +130 -0
  306. package/packs/gallery/chart-card/preview.svg +1 -0
  307. package/packs/gallery/chart-card/style.css +42 -0
  308. package/packs/gallery/chart-card/template.html +13 -0
  309. package/packs/gallery/chart-card/writing.md +20 -0
  310. package/packs/gallery/chart-view/component.json +20 -0
  311. package/packs/gallery/chart-view/example.html +13 -0
  312. package/packs/gallery/chart-view/kit.js +355 -0
  313. package/packs/gallery/chart-view/preview.svg +1 -0
  314. package/packs/gallery/chart-view/style.css +94 -0
  315. package/packs/gallery/chart-view/template.html +3 -0
  316. package/packs/gallery/chart-view/writing.md +22 -0
  317. package/packs/gallery/countdown/component.json +18 -0
  318. package/packs/gallery/countdown/example.html +3 -0
  319. package/packs/gallery/countdown/kit.js +156 -0
  320. package/packs/gallery/countdown/preview.svg +1 -0
  321. package/packs/gallery/countdown/style.css +130 -0
  322. package/packs/gallery/countdown/template.html +3 -0
  323. package/packs/gallery/countdown/writing.md +22 -0
  324. package/packs/gallery/habit/component.json +14 -0
  325. package/packs/gallery/habit/example.html +3 -0
  326. package/packs/gallery/habit/kit.js +295 -0
  327. package/packs/gallery/habit/preview.svg +1 -0
  328. package/packs/gallery/habit/style.css +246 -0
  329. package/packs/gallery/habit/template.html +3 -0
  330. package/packs/gallery/habit/writing.md +21 -0
  331. package/packs/gallery/heatmap/component.json +18 -0
  332. package/packs/gallery/heatmap/example.html +3 -0
  333. package/packs/gallery/heatmap/kit.js +351 -0
  334. package/packs/gallery/heatmap/preview.svg +1 -0
  335. package/packs/gallery/heatmap/style.css +201 -0
  336. package/packs/gallery/heatmap/template.html +3 -0
  337. package/packs/gallery/heatmap/writing.md +21 -0
  338. package/packs/gallery/kanban/component.json +18 -0
  339. package/packs/gallery/kanban/example.html +12 -0
  340. package/packs/gallery/kanban/kit.js +540 -0
  341. package/packs/gallery/kanban/preview.svg +1 -0
  342. package/packs/gallery/kanban/style.css +212 -0
  343. package/packs/gallery/kanban/template.html +3 -0
  344. package/packs/gallery/kanban/writing.md +20 -0
  345. package/packs/gallery/metric/component.json +22 -0
  346. package/packs/gallery/metric/example.html +15 -0
  347. package/packs/gallery/metric/kit.js +248 -0
  348. package/packs/gallery/metric/preview.svg +1 -0
  349. package/packs/gallery/metric/style.css +92 -0
  350. package/packs/gallery/metric/template.html +3 -0
  351. package/packs/gallery/metric/writing.md +23 -0
  352. package/packs/gallery/note/component.json +14 -0
  353. package/packs/gallery/note/example.html +3 -0
  354. package/packs/gallery/note/kit.js +102 -0
  355. package/packs/gallery/note/preview.svg +1 -0
  356. package/packs/gallery/note/style.css +76 -0
  357. package/packs/gallery/note/template.html +3 -0
  358. package/packs/gallery/note/writing.md +18 -0
  359. package/packs/gallery/pack.json +8 -0
  360. package/packs/gallery/recent/component.json +13 -0
  361. package/packs/gallery/recent/example.html +1 -0
  362. package/packs/gallery/recent/kit.js +238 -0
  363. package/packs/gallery/recent/preview.svg +1 -0
  364. package/packs/gallery/recent/style.css +158 -0
  365. package/packs/gallery/recent/template.html +1 -0
  366. package/packs/gallery/recent/writing.md +15 -0
  367. package/packs/gallery/static/component.json +13 -0
  368. package/packs/gallery/static/example.html +11 -0
  369. package/packs/gallery/static/preview.svg +1 -0
  370. package/packs/gallery/static/style.css +138 -0
  371. package/packs/gallery/static/template.html +1 -0
  372. package/packs/gallery/static/writing.md +18 -0
  373. package/packs/gallery/stats/component.json +13 -0
  374. package/packs/gallery/stats/example.html +1 -0
  375. package/packs/gallery/stats/kit.js +166 -0
  376. package/packs/gallery/stats/preview.svg +1 -0
  377. package/packs/gallery/stats/style.css +151 -0
  378. package/packs/gallery/stats/template.html +1 -0
  379. package/packs/gallery/stats/writing.md +11 -0
  380. package/packs/gallery/today/component.json +12 -0
  381. package/packs/gallery/today/example.html +1 -0
  382. package/packs/gallery/today/kit.js +185 -0
  383. package/packs/gallery/today/preview.svg +1 -0
  384. package/packs/gallery/today/style.css +120 -0
  385. package/packs/gallery/today/template.html +1 -0
  386. package/packs/gallery/today/writing.md +14 -0
  387. package/packs/gallery/todos/component.json +19 -0
  388. package/packs/gallery/todos/example.html +3 -0
  389. package/packs/gallery/todos/kit.js +342 -0
  390. package/packs/gallery/todos/preview.svg +1 -0
  391. package/packs/gallery/todos/style.css +267 -0
  392. package/packs/gallery/todos/template.html +3 -0
  393. package/packs/gallery/todos/writing.md +30 -0
  394. package/packs/gallery/weather/component.json +19 -0
  395. package/packs/gallery/weather/example.html +3 -0
  396. package/packs/gallery/weather/kit.js +312 -0
  397. package/packs/gallery/weather/preview.svg +1 -0
  398. package/packs/gallery/weather/style.css +258 -0
  399. package/packs/gallery/weather/template.html +3 -0
  400. package/packs/gallery/weather/writing.md +26 -0
  401. package/packs/gallery-soft/pack.json +8 -0
  402. package/release.json +13 -11
  403. package/sdk/doc-kit.d.ts +404 -7
  404. package/sdk/doc-state.d.ts +2 -0
  405. package/skill/SKILL.md +71 -26
  406. package/skill/references/block-script.md +140 -0
  407. package/skill/references/building-blocks.md +257 -0
  408. package/skill/references/example-report.html +1 -1
  409. package/skill/references/extensions.md +59 -0
  410. package/skill/references/pages-and-data.md +221 -0
  411. package/skill/references/writing-html.md +9 -7
  412. package/skill/sdk/doc-kit.d.ts +404 -7
  413. package/skill/sdk/doc-state.d.ts +2 -0
  414. package/web/assets/index-BK2e_07w.js +13 -0
  415. package/web/assets/index-CWFI83mF.css +1 -0
  416. package/web/index.html +2 -2
  417. package/browser/editor/components/callout/page.mjs +0 -13
  418. package/dist/chunk-2PBALTR3.mjs +0 -57
  419. package/dist/chunk-3LA3EMDE.mjs +0 -15
  420. package/dist/chunk-5FRMCDPY.mjs +0 -16
  421. package/dist/chunk-5LEK2CBS.mjs +0 -2
  422. package/dist/chunk-5OFN5AHC.mjs +0 -2
  423. package/dist/chunk-5SIYS5HN.mjs +0 -2
  424. package/dist/chunk-5TEK3RAD.mjs +0 -2
  425. package/dist/chunk-6CYG3Z4V.mjs +0 -2
  426. package/dist/chunk-7GHT2UCA.mjs +0 -15
  427. package/dist/chunk-7QQBR7PB.mjs +0 -2
  428. package/dist/chunk-ATCJYAR4.mjs +0 -2
  429. package/dist/chunk-C7HWOBIF.mjs +0 -2
  430. package/dist/chunk-E7VYDG2X.mjs +0 -2
  431. package/dist/chunk-EZY3WC6Z.mjs +0 -15
  432. package/dist/chunk-FQGQH4KM.mjs +0 -2
  433. package/dist/chunk-G7TOXONE.mjs +0 -6
  434. package/dist/chunk-GPF4YWWB.mjs +0 -9
  435. package/dist/chunk-GYQV7Y4J.mjs +0 -120
  436. package/dist/chunk-HMHK3EQ6.mjs +0 -2
  437. package/dist/chunk-HQQMJCQJ.mjs +0 -10
  438. package/dist/chunk-IERUOGC3.mjs +0 -6
  439. package/dist/chunk-ITNLYXXV.mjs +0 -3
  440. package/dist/chunk-L4DVONOG.mjs +0 -2
  441. package/dist/chunk-LAE5NQ4B.mjs +0 -2
  442. package/dist/chunk-LC7YNQFG.mjs +0 -2
  443. package/dist/chunk-LHTFLRB6.mjs +0 -4
  444. package/dist/chunk-NFIBI4IP.mjs +0 -26
  445. package/dist/chunk-NSKUTQ5J.mjs +0 -5
  446. package/dist/chunk-O52JMOCZ.mjs +0 -2
  447. package/dist/chunk-P2CAZPDP.mjs +0 -3
  448. package/dist/chunk-QMQUXTU4.mjs +0 -12
  449. package/dist/chunk-QVWVFC5K.mjs +0 -6
  450. package/dist/chunk-QYKCJ7FG.mjs +0 -8
  451. package/dist/chunk-QZY6Q64C.mjs +0 -2
  452. package/dist/chunk-TDQP3DKQ.mjs +0 -10
  453. package/dist/chunk-TX6JH7TR.mjs +0 -2
  454. package/dist/chunk-UNUEWH4S.mjs +0 -2
  455. package/dist/chunk-V4CPWKMZ.mjs +0 -2
  456. package/dist/chunk-VACRB2NE.mjs +0 -3
  457. package/dist/chunk-W63L7367.mjs +0 -7
  458. package/dist/chunk-W7CXPCRV.mjs +0 -6
  459. package/dist/chunk-XINNG4F2.mjs +0 -4
  460. package/dist/chunk-YL2DPWVS.mjs +0 -4
  461. package/dist/chunk-YZ5Z6H4W.mjs +0 -4
  462. package/dist/chunk-ZBIM6ARY.mjs +0 -216
  463. package/skill/references/building-components.md +0 -327
  464. package/web/assets/index-B6Ai3wsa.js +0 -13
  465. package/web/assets/index-SYPC3EZy.css +0 -1
@@ -1,15 +0,0 @@
1
- import { createRequire as __galleryRequire } from "node:module"; import { fileURLToPath as __galleryPath } from "node:url"; const require = __galleryRequire(import.meta.url); const __filename = __galleryPath(import.meta.url); const __dirname = __galleryPath(new URL(".", import.meta.url));
2
- import{a as b}from"./chunk-LAE5NQ4B.mjs";import{c as j,d as x,k as w}from"./chunk-NSKUTQ5J.mjs";import"./chunk-5L7RYZCL.mjs";import l from"node:fs";import a from"node:path";import{pathToFileURL as E}from"node:url";import{projectRoot as f}from"../browser/shared/paths.mjs";import{sha256 as L}from"../browser/shared/files.mjs";var g=["SKILL.md","references/writing-html.md","references/building-components.md","references/example-report.html","sdk","agents/openai.yaml"],u="## Before anything: the gallery command";function F(n){let[s,t]=n.split(/[.+-]/).map(Number);return{range:`^${n}`,takes:`${n} or a later ${s===0?`0.${t}`:s}.x`}}function K(n,s){let t=n.indexOf(`
3
- ${u}
4
- `);if(t<0)throw new Error(`SKILL.md has no section "${u}" (the version range of the command stands there)`);let e=n.indexOf(`
5
- ## `,t+u.length+1),r=e<0?n.length:e,{range:i,takes:o}=F(s),c=n.slice(t,r).replace(/\^\d+\.\d+\.\d+(?:-[\w.]+)?/g,i).replace(/\b\d+\.\d+\.\d+(?:-[\w.]+)? or a later \d+(?:\.\d+)?\.x\b/g,o);return n.slice(0,t)+c+n.slice(r)}function y(n=f){let s=g.filter(i=>!l.existsSync(a.join(n,i)));if(s.length)return s.map(i=>`the skill takes ${i}, which is not there`);let t=A(g,n),e=i=>l.readFileSync(a.join(n,i),"utf8"),r=P(t,e).map(i=>`${i}, which the skill does not hold: link only what it holds`);for(let i of t.filter(o=>o.startsWith("sdk/")&&o.endsWith(".ts")))for(let[,o]of e(i).matchAll(/\bfrom\s+["']([^"']+)["']|\bimport\(\s*["']([^"']+)["']\s*\)/g))o&&(!o.startsWith("./")||o.includes("/../"))&&r.push(`${i} imports ${o}, outside sdk/: write the types it needs in sdk/`);return r}function O(n,{root:s=f,version:t=JSON.parse(l.readFileSync(a.join(s,"package.json"),"utf8")).version}={}){let e=y(s);if(e.length)throw new Error(`The skill cannot be made:
6
- ${e.map(r=>` ${r}`).join(`
7
- `)}`);l.rmSync(n,{recursive:!0,force:!0});for(let r of A(g,s)){let i=a.join(n,r);l.mkdirSync(a.dirname(i),{recursive:!0}),r==="SKILL.md"?l.writeFileSync(i,K(l.readFileSync(a.join(s,r),"utf8"),t)):l.copyFileSync(a.join(s,r),i)}return S(n)}function S(n,s=""){let t=[];for(let e of l.readdirSync(n,{withFileTypes:!0}).sort((r,i)=>r.name.localeCompare(i.name))){let r=s?`${s}/${e.name}`:e.name;e.isDirectory()?t.push(...S(a.join(n,e.name),r)):e.isFile()&&t.push(r)}return t}function A(n,s=f){return n.flatMap(t=>{let e=a.join(s,t);return l.existsSync(e)?l.statSync(e).isDirectory()?S(e,t):[t]:[]})}function N(n){let s=null;return n.split(`
8
- `).map(t=>{let e=/^\s*(`{3,}|~{3,})(.*)$/.exec(t);return s?(e&&e[1][0]===s[0]&&e[1].length>=s.length&&!e[2].trim()&&(s=null),""):e&&!(e[1][0]==="`"&&e[2].includes("`"))?(s=e[1],""):t}).join(`
9
- `)}function v(n){let s=N(n).replace(/(`+)(?!`)(?:(?!\n[ \t]*\n)[\s\S])*?[^`]\1(?!`)/g,e=>" ".repeat(e.length));return[...[...s.matchAll(/\]\(\s*(?:<([^<>\n]*)>|((?:[^\s()<>]|\([^\s()<>]*\))+))(?:\s+(?:"[^"\n]*"|'[^'\n]*'|\([^()\n]*\)))?\s*\)/g)].map(e=>[e.index,e[1]??e[2]]),...[...s.matchAll(/^ {0,3}\[(?!\^)[^\]\n]+\]:[ \t]*(?:<([^<>\n]*)>|(\S+))/gm)].map(e=>[e.index,e[1]??e[2]]),...[...s.matchAll(/<(?:a|img)\s[^>]*?\b(?:href|src)\s*=\s*(?:"([^"]*)"|'([^']*)')/gi)].map(e=>[e.index,e[1]??e[2]])].sort(([e],[r])=>e-r).map(([,e])=>e)}function z(n,s){if(/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i.test(s))return null;let[,t,e=""]=/^([^?#]*)(?:\?[^#]*)?(?:#(.*))?$/s.exec(s),r=o=>{try{return decodeURIComponent(o)}catch{return o}};return{file:t?a.posix.normalize(a.posix.join(a.posix.dirname(n),r(t))).replace(/\/$/,""):n,anchor:r(e)}}function P(n,s){let t=new Set(n),e=new Set(n.flatMap(i=>i.split("/").slice(0,-1).map((o,c,p)=>p.slice(0,c+1).join("/")))),r=[];for(let i of n.filter(o=>/\.md$/i.test(o)))for(let o of v(s(i))){let c=z(i,o);!c||c.file===i||!t.has(c.file)&&!e.has(c.file)&&r.push(`${i} links ${o}`)}return r}function C(n,{root:s=f,version:t=JSON.parse(l.readFileSync(a.join(s,"package.json"),"utf8")).version}={}){let e=y(s);if(e.length)throw new Error(`The skill cannot be made:
10
- ${e.map(m=>` ${m}`).join(`
11
- `)}`);let r=a.join(n,"skill","gallery"),i=`gallery-skill-${t}.zip`,o=a.join(n,i);l.rmSync(a.join(n,"skill"),{recursive:!0,force:!0}),l.existsSync(a.join(n,"gallery","PACKAGE-MANIFEST.json"))&&l.rmSync(a.join(n,"gallery"),{recursive:!0,force:!0});for(let m of l.existsSync(n)?l.readdirSync(n):[])/^gallery-skill-.+\.zip(?:\.sha256)?$|^PACKAGE-MANIFEST\.json$/.test(m)&&l.rmSync(a.join(n,m),{force:!0});let c=O(r,{root:s,version:t}),p=c.map(m=>({name:`gallery/${m}`,data:l.readFileSync(a.join(r,m))})),d=b(p);l.writeFileSync(o,d);let k=L(d);l.writeFileSync(`${o}.sha256`,`${k} ${i}
12
- `);let{range:$}=F(t),T={name:"gallery",version:t,archive:i,holds:"The Agent's documents (SKILL.md, references/writing-html.md, references/building-components.md, the example references/example-report.html), the SDK's types (sdk/) and Codex's display metadata (agents/openai.yaml). The tools are the npm package @heycys/gallery, which SKILL.md has the Agent check for and install (with the user's consent); gallery skill install writes this same skill.",skillEntrypoint:"SKILL.md",requires:`@heycys/gallery@${$}`,files:p.map(({name:m,data:h})=>({path:m.slice(8),bytes:h.byteLength,sha256:L(h)}))};l.writeFileSync(a.join(n,"PACKAGE-MANIFEST.json"),`${JSON.stringify(T,null,2)}
13
- `);let I=p.reduce((m,{data:h})=>m+h.byteLength,0);return{archive:o,skill:r,files:c,bytes:I,zipBytes:d.byteLength,sha256:k,range:$}}if(import.meta.url===E(process.argv[1]).href){let{positional:n}=await w(import.meta.url);n.length>0&&(console.error(x(j(import.meta.url),`Unknown argument: ${n[0]} (skill:package takes none: there is one skill).`)),process.exit(2));let s=y();s.length>0&&(console.error(`Not packaged:
14
- ${s.map(e=>` ${e}`).join(`
15
- `)}`),process.exit(1));let t=C(a.join(f,"release"));console.log(`Packaged ${t.archive} (${t.files.length} files, ${t.bytes.toLocaleString("en-US")} bytes; the ZIP ${t.zipBytes.toLocaleString("en-US")} bytes), for @heycys/gallery ${t.range}`),console.log(`The skill's folder: ${t.skill}`),console.log(`SHA-256 ${t.sha256}`)}export{u as BOOTSTRAP,g as SKILL_FILES,O as buildSkill,P as deadLinks,A as filesOf,z as linkTarget,v as linksOf,S as listFiles,C as packageSkill,y as skillProblems,F as skillRange,K as withRange,N as withoutSamples};
@@ -1,2 +0,0 @@
1
- import { createRequire as __galleryRequire } from "node:module"; import { fileURLToPath as __galleryPath } from "node:url"; const require = __galleryRequire(import.meta.url); const __filename = __galleryPath(import.meta.url); const __dirname = __galleryPath(new URL(".", import.meta.url));
2
- import{a as i,b as k}from"./chunk-TX6JH7TR.mjs";import{a as g,b as y,c as x,i as $}from"./chunk-YXAUQPVK.mjs";import{b as f,f as w,g as u}from"./chunk-NSKUTQ5J.mjs";import{b as d}from"./chunk-YZ5Z6H4W.mjs";import{existsSync as j}from"node:fs";import n from"node:path";import{reportsDirectory as c}from"../browser/shared/paths.mjs";import{keptName as D,layoutOf as E,listTrash as L}from"../browser/shared/workspace.mjs";var T="\u65B0\u6587\u6863";async function S(o,t=c){return D(o)?`"${o}" is a name the workspace keeps for itself: choose another slug.`:j(n.join(E(t).pages,o))?`"${o}" is the \u5199\u4F5C\u504F\u597D page's slug: choose another slug.`:j(n.join(t,o))?`Document already exists: ${i(n.join(t,o))}`:(await L(t)).some(s=>s.slug===o)?`"${o}" is a document's in the trash: choose another slug.`:null}async function C(o){let{positional:t,options:s}=w({options:["--no-preview","--no-browser"],argv:o}),[e,l,h=T]=t;if(t.length<2||t.length>3||!e||!l?.trim()||!h.trim())throw new f("Name the slug and the title (then a description, if you choose one), each quoted when it has spaces.");u(e);let p=await S(e);p&&(console.error(p),process.exit(1));try{await d(e,l,h)}catch(r){if(r.code!=="EEXIST")throw r;console.error(await S(e)??`Document already exists: ${i(n.join(c,e))}`),process.exit(1)}console.log(`Created ${i(n.join(c,e,"doc.html"))} and doc.json`);for(let r of await k())console.log(r);let a=await $(e,{skipped:x(s),command:`gallery new ${e}`});console.log(g(a,"replace the starter section with the document's skeleton (each section's heading) as soon as you can outline it, then write it a section at a time, as ordinary HTML, so that the user watches it grow (gallery check fails while the starter section remains).")),console.log(`Hand in: gallery export ${e}, then gallery qa ${e}`);let m=await y(a,s);m&&console.log(m);for(let r of a)console.log(r)}export{T as a,S as b,C as c};
@@ -1,6 +0,0 @@
1
- import { createRequire as __galleryRequire } from "node:module"; import { fileURLToPath as __galleryPath } from "node:url"; const require = __galleryRequire(import.meta.url); const __filename = __galleryPath(import.meta.url); const __dirname = __galleryPath(new URL(".", import.meta.url));
2
- import{b as O}from"./chunk-ITNLYXXV.mjs";import{a as M}from"./chunk-NFIBI4IP.mjs";var b=3e4,j=12e4,k=1500,S=1e4,W=h=>h.reduce((a,{key:c,tag:r})=>a.set(`${c}
3
- ${r}`,(a.get(`${c}
4
- ${r}`)??0)+1),new Map);function U({now:h=Date.now,hold:a=b,limit:c=j,quiet:r=k}={}){let i=new Map,l=new Map,w=new Map,$=new Map,p=new Map;return{wrote(t,e){$.set(t,M(e))},judge(t,{source:e,mtime:m}){if(e===null)return i.delete(t),w.delete(t),{held:!1,signs:[],wait:0,own:!1};let d=M(e),n=p.get(t)?.hash===d?p.get(t).signs:null;n||(n=O(e),p.set(t,{hash:d,signs:n}));let f=h(),x=(o,s=!1)=>(i.delete(t),l.set(t,W(n)),w.set(t,e),{held:!1,signs:[],wait:o,own:s});if($.get(t)===d)return x(0,!0);let g=l.get(t)??new Map,I=W(n);if([...I].some(([o,s])=>s>(g.get(o)??0))){let o=Math.min(m,f),s=i.get(t)??o;i.set(t,s);let T=Math.min(a-(f-o),c-(f-s));if(T>0)return{held:!0,signs:n.filter(({key:D,tag:L})=>I.get(`${D}
5
- ${L}`)>(g.get(`${D}
6
- ${L}`)??0)),wait:T,own:!1,taken:w.get(t)}}return x(Math.min(r,Math.max(0,r-(f-m))))}}}export{b as a,j as b,k as c,S as d,U as e};
@@ -1,9 +0,0 @@
1
- import { createRequire as __galleryRequire } from "node:module"; import { fileURLToPath as __galleryPath } from "node:url"; const require = __galleryRequire(import.meta.url); const __filename = __galleryPath(import.meta.url); const __dirname = __galleryPath(new URL(".", import.meta.url));
2
- import{b as we,c as pe,d as ge,e as J,g as R,h as me,i as X,j as $e,k as ye,l as $,m as ke}from"./chunk-3LA3EMDE.mjs";import{a as H}from"./chunk-TX6JH7TR.mjs";import{d as ce,g as de}from"./chunk-YXAUQPVK.mjs";import{a as U}from"./chunk-UNUEWH4S.mjs";import{a as Q,c as F}from"./chunk-G7TOXONE.mjs";import{a as he,b as fe,e as ue}from"./chunk-LC7YNQFG.mjs";import"./chunk-ITNLYXXV.mjs";import{b as v,i as ie}from"./chunk-NSKUTQ5J.mjs";import"./chunk-QMQUXTU4.mjs";import"./chunk-HQQMJCQJ.mjs";import"./chunk-QYKCJ7FG.mjs";import"./chunk-YZ5Z6H4W.mjs";import"./chunk-VACRB2NE.mjs";import{a as re}from"./chunk-HYMEEXKN.mjs";import"./chunk-TDQP3DKQ.mjs";import{b as z}from"./chunk-5FRMCDPY.mjs";import"./chunk-E7VYDG2X.mjs";import"./chunk-NFIBI4IP.mjs";import{c as Y,g as le}from"./chunk-W63L7367.mjs";import"./chunk-A55HN5OK.mjs";import"./chunk-5L7RYZCL.mjs";import C from"node:fs/promises";import P from"node:path";import{isInstance as K,partOf as Fe}from"../browser/shared/components/index.mjs";import{ATTRIBUTE as ae,FALLBACK as Re,FIELDS as _e,INSTANCE as Se,PACKAGE_ID as je}from"../browser/shared/components/installed.mjs";import{attr as ee,walk as Pe}from"../browser/shared/html-tree.mjs";import{documentDirectory as Be,documentFiles as He,layoutOf as se,packageFolders as Ue}from"../browser/shared/workspace.mjs";var be=10,te=6,qe=3,Ge=100,Le=1024,Ie=900,Ve=4e3,V=3e4,Ke=1500,ne=3e4,oe=500,We=5e3,Ze=200,B=e=>new Promise(t=>setTimeout(t,e));async function Ye(e){let{_keyDefinitions:t}=await import("./chunk-43B75J5T.mjs"),n=Object.hasOwn(t,e)?[e]:e.split("+"),a=new Set(["Control","Shift","Alt","Meta"]);if(n.some(o=>!Object.hasOwn(t,o))||n.slice(0,-1).some(o=>!a.has(o)))throw new v(`Not a key: ${e} (a key as a browser names it, Enter, Space, Escape, Tab, ArrowRight, a letter or a digit, after modifiers joined by "+": Shift+Tab, Control+Enter).`);return n}async function ze(e,t){let n=["--press","--drag","--key"].filter(a=>e.has(a));if(n.length!==1)throw new v(n.length?`One gesture at a time: ${n.join(" or ")}.`:"Say the gesture: --press <selector>, --drag <selector> --to <selector> or --key <selector> <key>.");if(e.has("--to")&&!e.has("--drag"))throw new v("--to goes with --drag: --drag <selector> --to <selector>.");if(e.has("--drag")&&!e.has("--to"))throw new v("--drag takes --to: --drag <selector> --to <selector>, where it is dropped.");return e.has("--press")?{kind:"press",at:e.get("--press")}:e.has("--drag")?{kind:"drag",at:e.get("--drag"),to:e.get("--to")}:{kind:"key",at:e.get("--key"),keys:await Ye(t),key:t}}var Qe=e=>{let t=e.parentNode;for(;t&&!K(t);)t=t.parentNode;return t??null};function Ne(e){let t=[];return Pe(re(e),n=>{K(n)&&t.push({element:n,id:ee(n,ae),blockId:ee(n,"data-block-id")??null,line:n.sourceCodeLocation?.startLine})},{stop:K}),t}var Je=(e,{id:t,blockId:n})=>n??(e.filter(a=>a.id===t).length===1?t:null);function Xe(e,t,{slug:n,name:a}){let o=()=>e.map(i=>` ${Je(e,i)??"(no id yet: gallery export gives it one)"} ${i.id} at ${a}:${i.line}`).join(`
3
- `);if(t===null){if(e.length===1)return 0;throw new v(`${n} holds ${e.length} instances: name one, gallery component try ${n} <instance id> \u2026
4
- ${o()}`)}let r=e.findIndex(({blockId:i})=>i===t);if(r>=0)return r;let l=t.includes("/")?t:`local/${t}`,s=je.test(l)?e.flatMap((i,c)=>i.id===l?[c]:[]):[];if(s.length===1)return s[0];throw new v(s.length?`${n} holds ${s.length} instances of ${l}: name one by its id
5
- ${o()}`:`${n} holds no instance ${t}:
6
- ${o()}`)}var et=e=>e.replace(/\s+data-block-id="[^"]*"/g,""),ve=e=>et(z(e).text);function xe(e,t,n){let a=Ne(e)[t]?.element;if(!a||ee(a,ae)!==n.id)return null;let o=[],r=Object.entries(n.parts).map(([c,{at:u}])=>{let p=Fe(a,u).filter(h=>h.sourceCodeLocation?.endTag&&!K(h)&&Qe(h)===a).map(({sourceCodeLocation:{startTag:h,endTag:d}})=>({start:h.endOffset,end:d.startOffset}));return o.push(...p),{name:c,text:p.map(({start:h,end:d})=>e.slice(h,d)).join(`
7
- `)}}),l=o.sort((c,u)=>c.start-u.start||u.end-c.end).filter((c,u)=>!o.slice(0,u).some(p=>p.start<=c.start&&c.end<=p.end)),s="",i=0;for(let{start:c,end:u}of l)s+=e.slice(i,c),i=u;return{parts:r,outside:s+e.slice(i)}}function tt(e,t,n,a){let[o,r]=[xe(e,n,a),xe(t,n,a)];return!o||!r?{parts:[],outside:null,gone:!0}:{parts:o.parts.flatMap(({name:s,text:i},c)=>i===r.parts[c].text?[]:[{name:s,...X(i,r.parts[c].text),how:$e(i,r.parts[c].text)}]),outside:o.outside===r.outside?null:X(o.outside,r.outside),gone:!1}}async function nt(e,t){let{components:n,marker:a}=se(e);return await Oe([t,a,n])+U+F+oe}async function Oe(e){let t=[...e];for(let a of e)for(let o of await C.readdir(a,{recursive:!0,withFileTypes:!0}).catch(()=>[]))t.push(P.join(o.parentPath,o.name));let n=await Promise.all(t.map(a=>C.stat(a).then(({mtimeMs:o})=>o,()=>0)));return Math.max(...n)}var ot=e=>fetch(`${e}/__gallery/workspace/components`,{signal:AbortSignal.timeout(2e3)}).then(t=>t.ok?t.json():null).then(t=>Array.isArray(t?.packages)?t.packages:null,()=>null);async function at(e,t,n){let{components:a,marker:o}=se(e),r=Ue(e).find(k=>k.id.toLowerCase()===t)?.folder??P.join(a,...t.split("/")),[l,s]=await Promise.all([Oe([o,r]),ot(n)]),{packages:i,problems:c,settings:u}=Y(e),p=s?.find(k=>k.id===t)??null,h=s?p?.state??"none":null,d=h==="normal"||h==="hidden",f=u.disabled.includes(t),m=c.get(t),y=m&&!f&&d?le("en",m.problem):null,S=s!==null&&i.has(t)&&!d;return{by:l+(y?Q:U+F),held:y,behind:S,off:f,stamp:(i.get(t)??m)?.stamp??null,state:h,reason:p?.reason?.en??null}}var Ce=({state:e,reason:t})=>e==="none"?"no such package":t?`it as not loading (${t})`:"it turned off";function st(e,{said:t,unparsed:n=null,off:a,behind:o=!1,state:r,reason:l}){let s="the instance shows what it holds, read-only, so a reader can do nothing with it";return n?`${s}: its kit.js did not parse, so no component of it started, and the console says ${n}`:t.length?`${s}: its component failed as the page started it, and the console says ${t.join("; ")}`:a?`${s}: ${e} is turned off in \u8BBE\u7F6E \u203A \u7EC4\u4EF6`:o?`${s}: the server has not taken ${e} as components/ holds it, where it loads: its catalog in use has ${Ce({state:r,reason:l})}`:r==="disabled"&&!l?`${s}: ${e} is turned off in \u8BBE\u7F6E \u203A \u7EC4\u4EF6`:r==="broken"||r==="disabled"?`${s}: the server has ${e} as not loading (${l}): gallery component check ${e} says why`:r==="none"?`${s}: the server has not taken ${e} as components/ holds it (its catalog in use has no such package)`:r?`${s}: the page was served before the server took ${e} as components/ holds it, and did not load itself again with it`:`${s}: its component failed or never started, and the console said nothing of it`}var it=(e,t,n)=>t.held?`${e} does not load as components/ holds it (${t.held}), and the server keeps it as it was until components/ has not changed for ${Q/1e3}s, as it keeps a package written file by file`:t.behind?`components/ holds ${e} as loading, and the server's catalog in use still has ${Ce(t)}: it takes what components/ holds once that has not changed for ${F/1e3}s`:n?`${e} or gallery.json changed a moment ago, and the server takes the change once components/ has not changed for ${F/1e3}s, the page served before loading itself again for it`:`the server took ${e} as components/ holds it, and the page served before is to load itself again with it`,rt=(e,t,n)=>t.held?`the server still keeps ${e} as it was`:t.behind?`the server has still not taken ${e} as components/ holds it`:`the server took ${e} as components/ holds it, and the page did not load itself again with it in ${n/1e3}s`;async function lt({root:e,id:t,origin:n,loadedAt:a,loaded:o,told:r=We,say:l=s=>console.log(s)}){let s=Date.now(),i,c=0,u=0,p=!1;for(;;await B(Ze)){let h=await at(e,t,n),d=Date.now();i!==void 0&&h.stamp!==i&&(c=d),i=h.stamp,h.behind&&!u&&(u=d);let f=Math.max(h.by,...[c,u].filter(Boolean).map(y=>y+U+F)),m=o()?"the page loaded itself again":h.off?`gallery.json turns ${t} off now`:a>=f?`the page was asked for after the server took ${t} as components/ holds it`:d>f+r?rt(t,h,r):null;if(m)return p&&l(`Waited ${((d-s)/1e3).toFixed(1)}s: ${m}`),h;p||f-d<=oe&&d-s<=oe||(p=!0,l(`Waiting: ${it(t,h,f>d)}, ${Math.ceil((f+r-d)/1e3)}s more at most`))}}function ct({instance:e,at:t}){return[...document.querySelectorAll(e)].filter(n=>!n.parentElement?.closest(e))[t]??null}function dt(e,t){let n=d=>`<${d.localName}${d.classList.length?` class="${d.getAttribute("class")}"`:""}>`,a;try{a=e.querySelector(t)}catch{return{invalid:!0}}if(!a)return{none:!0,held:[...new Set([...e.querySelectorAll("[class]")].filter(d=>d.getClientRects().length>0).flatMap(d=>[...d.classList].map(f=>`.${f}`)))].slice(0,16)};let o=((a instanceof HTMLElement?a.innerText:a.textContent)??"").replace(/\s+/g," ").trim(),r={named:n(a),words:o.length>40?`${o.slice(0,40)}\u2026`:o},l=[...a.getClientRects()].filter(({width:d,height:f})=>d>0&&f>0);if(!l.length)return{...r,hidden:!0};let{left:s,top:i,right:c,bottom:u,width:p,height:h}=l.reduce((d,f)=>d.width*d.height>=f.width*f.height?d:f);return{...r,box:{left:s,top:i,right:c,bottom:u,x:s+p/2,y:i+h/2}}}function ht(e,{selector:t,x:n,y:a}){let o=e.querySelector(t),r=document.elementFromPoint(n,a);return!r||o.contains(r)?null:`<${r.localName}${r.classList.length?` class="${r.getAttribute("class")}"`:""}>`}function ft(e,{at:t,to:n}){let[a,o]=[e.querySelector(t),e.querySelector(n)];return a===o?"same":a.contains(o)?"inside":null}function ut(e){let t=a=>a instanceof Element?`<${a.localName}${a.classList.length?` class="${a.getAttribute("class")}"`:""}>`:"the page",n={edits:[],states:[],started:null,dropped:null,effect:null};addEventListener("doc-component-edit",a=>{a.target===e&&n.edits.push({taken:a.defaultPrevented,parts:(a.detail?.parts??[]).map(({name:o})=>o)})}),new MutationObserver(a=>{for(let{oldValue:o}of a)n.states.push(o);n.states.push(document.documentElement.getAttribute("data-ge-save"))}).observe(document.documentElement,{attributes:!0,attributeFilter:["data-ge-save"],attributeOldValue:!0}),document.addEventListener("dragstart",a=>{n.started=t(a.target)},!0),document.addEventListener("drop",a=>{n.dropped=t(a.target)},!0),document.addEventListener("dragend",a=>{n.effect=a.dataTransfer?.dropEffect??null},!0),globalThis.__galleryTry=n}async function wt(e,{still:t,step:n}){let a=()=>new Promise(r=>{requestAnimationFrame(r),setTimeout(r,100)});await a(),await a();let o=e.outerHTML;for(let r=0,l=Date.now()+t;r<3;){if(Date.now()>l)return null;await new Promise(i=>setTimeout(i,n));let s=e.outerHTML;r=s===o?r+1:0,o=s}return o}function pt(e,t,{left:n,top:a,right:o,bottom:r}){let l=0;for(let[s,i,c,u]of[[e.x,t.x,n,o],[e.y,t.y,a,r]]){if(i===s)continue;let[p,h]=[(c-s)/(i-s),(u-s)/(i-s)];l=Math.max(l,Math.min(p,h))}return l*Math.hypot(t.x-e.x,t.y-e.y)}function gt(e,t){let n=Math.hypot(t.x-e.x,t.y-e.y),a=i=>n===0?{x:e.x,y:e.y}:{x:e.x+(t.x-e.x)*i/n,y:e.y+(t.y-e.y)*i/n},o=Math.min(te,n),r=pt(e,t,t)-qe,l=r>o?r:n,s=[a(o/2),a(o)];for(let i=1;i<=be;i++)s.push(a(o+(l-o)*i/be));return l!==n&&s.push({x:t.x,y:t.y}),s}var W={press:"press",drag:"drag",key:"key"},q=(e,{named:t,words:n})=>`${e} (${t}${n?` "${n}"`:""})`,Ee=e=>Object.assign(new v(e),{unfound:!0});async function mt(e,t,n){let a=async i=>{let c=await $(t.evaluate(dt,i),"the page was asked what the selector finds");if(c.invalid)throw new v(`Not a selector: ${i}.`);if(c.none)throw Ee(`Nothing in the instance is ${i}${c.held.length?`: what it shows has ${c.held.join(", ")}`:": it shows nothing with a class"}.`);if(c.hidden)throw Ee(`${i} finds ${c.named} in the instance, which is not shown (it has no box on the page), so a reader cannot reach it: name what it shows.`);return c},o=await a(n.at);if(n.kind==="press"){let{x:i,y:c}=o.box,u=await $(t.evaluate(ht,{selector:n.at,x:i,y:c}),"the page was asked what stands at the press");return await e.mouse.move(i,c),await e.mouse.down(),await e.mouse.up(),{said:`a press on ${q(n.at,o)}, with the pointer at its middle`,over:u}}if(n.kind==="drag"){let i=await a(n.to),c=await $(t.evaluate(ft,{at:n.at,to:n.to}),"the page was asked where the drag ends");if(c)throw new v(`${c==="same"?`--drag and --to find the same element, ${o.named}`:`--to ${n.to} finds ${i.named}, which stands in what --drag ${n.at} finds, ${o.named}`}: a drag ends where it is dropped, on another element of the instance (another column, another row), which --to names.`);if(Math.hypot(i.box.x-o.box.x,i.box.y-o.box.y)<te)throw new v(`The middles of what --drag ${n.at} and --to ${n.to} find stand less than ${te}px apart, too near for a drag to start: name with --to where it is dropped, further off.`);let u=gt(o.box,i.box);await e.mouse.move(o.box.x,o.box.y),await e.mouse.down();for(let{x:p,y:h}of u)await e.mouse.move(p,h);return await B(Ge),await e.mouse.up(),{said:`a drag of ${q(n.at,o)} to ${q(n.to,i)}, with the pointer in ${u.length} moves, released as it comes onto it`}}let r=await t.$(n.at);await $(r.focus(),"the focus went to the element");let l=await $(e.evaluate(i=>document.activeElement===i||i.contains(document.activeElement)?null:`<${document.activeElement?.localName??"body"}>`,r),"the page was asked where the focus is"),s=n.keys.slice(0,-1);for(let i of s)await e.keyboard.down(i);await e.keyboard.press(n.keys.at(-1));for(let i of s.toReversed())await e.keyboard.up(i);return{said:`${n.key} pressed with the focus given to ${q(n.at,o)}, as Tab gives it`,unfocused:l}}var $t=e=>fetch(`${e}/__gallery/workspace/info`,{signal:AbortSignal.timeout(2e3)}).then(t=>t.ok,()=>!1);async function Te(e,t,n){let a=Date.now();for(let o=0,r=0;;await B(100)){let{seen:l,now:s}=await $(e.evaluate(c=>({seen:globalThis.__galleryTry.states.slice(c),now:document.documentElement.getAttribute("data-ge-save")}),t),"the page was asked where saving stands"),i=s!=="saved"||l.some(c=>c!=="saved");if(i&&s==="saved")return"saved";if(s==="stopped"||s==="reloading")return s;if(o=s==="held"?o+1:0,o>=3)return"held";if(r=s==="offline"?r+1:0,r>0&&r%10===0&&!await $t(n))return"offline";if(!i&&Date.now()-a>Ke)return"unchanged";if(Date.now()-a>ne)return s}}var _=e=>({held:"a card waits for a reader: someone else changed the part meanwhile, and the page held its write for the reader there, which closing the page dropped",offline:"the page could not reach the server (offline)",stopped:"the page stopped saving (stopped): the server refused its write",reloading:"the page loaded itself again (doc.html or a package it holds changed meanwhile)",waiting:`it waited ${ne/1e3}s to be saved and never was`,syncing:`its save took more than ${ne/1e3}s`})[e];function yt(e,{parts:t,outside:n,gone:a},{gesture:o,name:r,held:l=!1,keep:s=!1}){let i=n?`; outside the instance's parts -${n.removed} +${n.added} lines someone else wrote meanwhile, which stay`:"";return a?{unverified:`${e}, and ${r} holds the instance no more where it stood: someone else wrote the file meanwhile`}:t.length===0?{unverified:`${e}: ${r} is as it was${n?" in the instance's parts":""} (data-block-id aside)${i}`}:l?{unverified:`${e}: what ${r} holds of ${R(t)} is someone else's, which stays${i}`}:s?{unverified:`${e}: ${r} holds what the ${o} wrote, ${R(t)}, kept (--keep)${i}`}:{problem:`${e}, and ${r} holds what the ${o} wrote, ${R(t)}${i}: put that back yourself, ${r} read again first${n?", keeping what someone else wrote":""}`}}function kt(e,t,{over:n,unfocused:a,refusals:o,name:r}){let l=[];return n&&l.push(`the press landed on ${n}, which stands over it there`),a&&l.push(`the element takes no focus (a button, a field or a tabindex), so the key went to ${a}`),t.started&&!t.dropped?l.push(`an HTML5 drag started (dragstart on ${t.started}) and nothing took its drop where it was released (dragend's dropEffect ${t.effect??"none"}): a list a card is dropped on cancels dragenter as well as dragover (preventDefault), or a release as the pointer comes onto it drops nothing`):t.dropped&&t.edits.length===0&&l.push(`it was dropped on ${t.dropped}, and no context.edit came of it`),t.edits.some(({taken:s})=>s)?l.push("context.edit was taken, and its change left what the parts hold as it was"):t.edits.length?l.push(`context.edit was called and the page refused it${o.length?`: the console says ${o.join("; ")}`:""}`):t.started||l.push(`no context.edit came of it: the component answers no ${e} there, or asked while context.canEdit() was false`),`the ${W[e]} wrote nothing to ${r}: ${l.join("; ")}`}async function bt(e,t){let n={own:new Map,others:new Map,dialogs:new Map,pending:[],page:0,from:0},a=new RegExp(`/__gallery/components/${t}/kit\\.js[^:\\s)]*:(\\d+)`),o=(l,s,{at:i="",unparsed:c=!1}={})=>{if(s<n.from)return;let u=l.split(`
8
- `)[0],p=a.exec(l)??a.exec(i);l.includes(t)||p?n.own.set(u,{line:Number(p?.[1])||null,page:s,unparsed:c&&a.test(i)}):n.others.set(u,{page:s})};e.on("request",l=>{l.isNavigationRequest()&&l.frame()===e.mainFrame()&&(n.page+=1)}),e.on("console",l=>{if(!["error","warn","warning"].includes(l.type())||/^Failed to load resource/.test(l.text()))return;let{page:s}=n;n.pending.push(Promise.all(l.args().map(i=>i.evaluate(c=>c instanceof Error?c.stack:String(c)).catch(()=>""))).then(i=>o(i.join(" ")||l.text(),s)))});let r=await ye(e,{add:l=>n.dialogs.set(l,{page:n.page})});return r.on("Runtime.exceptionThrown",({exceptionDetails:{exception:l,text:s,url:i,lineNumber:c,stackTrace:u}})=>{o(l?.description??String(l?.value??s),n.page,{at:i?`${i}:${c+1}`:"",unparsed:!u&&l?.className==="SyntaxError"})}),await r.send("Runtime.enable"),n}function vt(e){e.from=e.page;for(let t of[e.own,e.others,e.dialogs])for(let[n,{page:a}]of t)a<e.from&&t.delete(n)}var G=e=>Promise.race([Promise.all(e.pending),B(2e3)]);async function xt(e){let t=n=>e.waitForSelector(n,{timeout:V}).catch(a=>{if(a.name==="TimeoutError")throw a;return e.waitForSelector(n,{timeout:V})});try{return await t("[data-doc-ready]"),await t("html[data-ge-editing][data-ge-save]"),await e.waitForFunction(()=>globalThis.__galleryTryEditable===!0&&document.documentElement.getAttribute("data-ge-save")==="saved",{timeout:V}),!0}catch(n){if(n.name!=="TimeoutError")throw n;return!1}}async function Et(e,{at:t,id:n}){let a=await $(e.evaluateHandle(ct,{instance:Se,at:t}),"the page was asked for the instance"),o=await $(a.evaluate((r,{fallback:l,id:s})=>!(r instanceof Element)||r.getAttribute("data-doc-component")!==s?null:(DocKit.reveal?.(r),{fallback:r.hasAttribute(l),height:r.getBoundingClientRect().height}),{fallback:Re,id:n}),"the page was asked for the instance");return o?(await e.setViewport({width:Le,height:Math.min(Ve,Math.max(Ie,Math.ceil(o.height)+240))}),await $(a.evaluate(r=>r.scrollIntoView({block:"center",behavior:"instant"})),"the instance was brought into view"),await $(a.evaluate(wt,{still:pe,step:ge}),"the instance held still"),{host:a,fallback:o.fallback}):null}async function Tt(e){await $(e.evaluate(({instance:t,fields:n})=>{let a=document.activeElement;a instanceof HTMLElement&&a.closest(t)&&a.matches(n)&&a.blur()},{instance:Se,fields:_e}),"the focus left the instance's field"),await e.keyboard.down("Control"),await e.keyboard.press("z"),await e.keyboard.up("Control")}var At=3;async function St(e,{root:t,address:n,at:a,gesture:o,keep:r,file:l,name:s,line:i,found:c,out:u}){let p=await e.createBrowserContext(),h=await p.newPage(),d=await bt(h,c.id),f={problems:[],notes:[]},m=(w,b=`${s}:${i}`)=>f.problems.push({where:b,what:w}),y=W[o.kind],S=new URL(n).origin,k=0,M=0;h.on("request",w=>{!w.isNavigationRequest()||w.frame()!==h.mainFrame()||(k+=1,M=Date.now())});let L=null,N=null,T=async()=>tt(ve(N),ve(await C.readFile(l,"utf8").catch(()=>"")),a,c),A=(w,b,I=!1)=>{let D=yt(w,b,{gesture:y,name:s,held:I,keep:r});return D.problem&&m(D.problem),{...f,unverified:D.unverified}};await h.evaluateOnNewDocument(()=>addEventListener("doc-editable",()=>{globalThis.__galleryTryEditable=!0})),await h.setViewport({width:Le,height:Ie}),await h.emulateMediaFeatures([{name:"prefers-color-scheme",value:"light"}]);try{await $(h.goto(n,{waitUntil:"load",timeout:0}),"the page opened",we);let w=null,b=null;for(let x=1;!w;x++){let g=k;try{if(!await xt(h))return{...f,unverified:`the page did not come to edit in ${V/1e3}s, so nothing was tried`};if(w=await Et(h,{at:a,id:c.id}),!w)return{...f,unverified:`the page does not hold the instance where ${s} has it (${s} changed meanwhile?), so nothing was tried`};if(await B(Math.max(0,await nt(t,l)-Date.now())),w.fallback&&(b=await lt({root:t,id:c.id,origin:S,loadedAt:M,loaded:()=>k!==g})),k!==g)throw new Error("the page loaded itself again");if(w.fallback)break;if(N=await C.readFile(l,"utf8"),await $(w.host.evaluate(ut),"the page was asked to listen"),k!==g)throw new Error("the page loaded itself again")}catch(E){if(k===g||x===At)throw E;w=null,vt(d)}}let{host:I}=w;if(w.fallback){await G(d);let x=[...d.own].map(([g,{line:E,unparsed:De}])=>({words:`${g}${E?` (kit.js:${E})`:""}`,unparsed:De}));return d.own.clear(),m(st(c.id,{said:x.map(({words:g})=>g),unparsed:x.find(({unparsed:g})=>g)?.words??null,...b})),await Ae(I,f,u)}L=k;let D=await mt(h,I,o);f.gesture=D.said;let Z=await Te(h,0,S),Me=await $(h.evaluate(()=>globalThis.__galleryTry),"the page was asked what it heard");await Ae(I,f,u);let O=await T();if(_(Z))return A(`after the ${y}, ${_(Z)}`,O,Z==="held");if(O.gone)return A(`after the ${y}`,O);if(f.others=O.outside,O.parts.length===0){await G(d);let x=[...d.own.keys()].filter(g=>g.includes("context.edit"));for(let g of x)d.own.delete(g);return m(kt(o.kind,Me,{...D,refusals:x,name:s})),f}f.wrote={parts:O.parts,plain:z(N).changes.length>0};for(let{name:x,how:g}of O.parts)g&&f.notes.push({where:`${s}:${i}`,what:`the ${y}'s write lays the part ${x} out anew (${g}): ${me}`});if(!r){let x=await $(h.evaluate(()=>globalThis.__galleryTry.states.length),"the page was asked where saving stands");await Tt(h);let g=await Te(h,x,S),E=await T();if(k>L)return A(`after the ${y}, ${_("reloading")}`,E);if(_(g))return A(`after one Ctrl+Z, ${_(g)}`,E,g==="held");if(E.gone)return A("after one Ctrl+Z",E);g==="unchanged"?m(`one Ctrl+Z wrote nothing, so ${s} keeps what the ${y} wrote: put the part back yourself, ${s} read again first`):E.parts.length?m(`after one Ctrl+Z ${s} is not as it was, ${R(E.parts)} still differing: put that back yourself, ${s} read again first`):f.undone=!0,f.others=E.outside??f.others}return f.others&&(f.unverified=`someone else wrote ${s} meanwhile, outside the instance's parts (the user's page, an Agent), which stays${r?"":": try it again once the file holds still"}`),f}catch(w){if(w instanceof v){if(!w.unfound||(await G(d),d.own.size===0&&d.dialogs.size===0))throw w;return m(`${w.message[0].toLowerCase()}${w.message.slice(1).replace(/\.$/,"")}; its component did not draw it, and the console says why`),f}let b=L===null?null:await T();if(b&&k>L)return A(`after the ${y}, ${_("reloading")}`,b);if(await ke(e)){let I=`the browser went while waiting until ${w.doing??"the page answered"}`;return b?A(I,b):{...f,unverified:`${I}, so nothing was tried`}}return w.stuck?m(`the page stopped answering while waiting until ${w.doing}: a script that never ends, or a component that changes what it hears`,"the page"):m(`the trial stopped: ${J(w)}`,"the page"),b?A(`after the ${y} the trial stopped`,b):f}finally{await G(d);for(let[w,{line:b}]of d.own)f.problems.push({where:b?`kit.js:${b}`:"the page",what:`the console says ${w}`});for(let w of d.others.keys())f.notes.push({where:"the page",what:`the console says ${w}`});for(let w of d.dialogs.keys())f.problems.push({where:"the page",what:`it opened a dialog (${w}), which stops a reader's page until it is answered: show what it says in the instance`});await p.close().catch(()=>{})}}async function Ae(e,t,n){let a=P.join(n,"after.png");try{await $(e.screenshot({path:a}),"the instance was pictured"),t.picture=a}catch(o){if(o.stuck)throw o}return t}var j={gesture:"Gesture: ",wrote:"Wrote: ",undone:"Undone: ",kept:"Kept (--keep): ",picture:"Picture of the instance after the "},Lt="nothing outside the instance changed (data-block-id aside)";function It({slug:e,name:t,gesture:{kind:n},keep:a},o){let r=[];o.gesture&&r.push(`${j.gesture}${o.gesture}`);for(let{where:s,what:i}of o.problems)r.push(` FAIL ${s}: ${i}`);for(let{where:s,what:i}of o.notes)r.push(` note ${s}: ${i}`);if(o.wrote){let s=o.wrote.plain?"; and the page wrote the document's plain HTML as the kit's markup, as its first save of an edit does (gallery check and gallery export say what, by line, once), which stays":"",i=o.others?`; outside the instance's parts -${o.others.removed} +${o.others.added} lines someone else wrote meanwhile (the user's page, an Agent), which stay`:`; ${Lt}`;r.push(`${j.wrote}${R(o.wrote.parts)}${i}${s}`),a?r.push(`${j.kept}${t} holds what it wrote`):o.undone&&r.push(`${j.undone}one Ctrl+Z, and ${o.others?`the instance's parts in ${t} are as they were`:`${t} is as it was`} (data-block-id aside${o.wrote.plain?", its plain HTML the kit's markup":""})`)}o.picture&&r.push(`${j.picture}${W[n]}: ${H(o.picture)}`);let l=o.problems.length;return l?{lines:[...r,`FAIL ${e}: ${l} problem${l===1?"":"s"}`],code:1}:o.unverified?{lines:[...r,`UNVERIFIED ${e}: ${o.unverified}`],code:3}:{lines:[...r,`OK ${e}: the ${W[n]} wrote ${o.wrote.parts.map(({name:s})=>s).join(" and ")}${a?", kept (--keep)":", and one Ctrl+Z took it back"}`],code:0}}async function Kt(e,{named:t,values:n,key:a,keep:o}){let r=await ze(n,a);if(t.length===0)throw new v("Name the document: gallery component try <slug> [<instance id>] and the gesture.");if(t.length>2)throw new v("gallery component try takes a document and an instance's id at most.");let{slug:l,block:s}=await ie(t[0]),i=He(Be(l,e)).html,c=await C.readFile(i,"utf8").catch(()=>null);c===null&&(console.error(`No document "${l}": ${H(i)} does not exist (gallery list lists those there are).`),process.exit(1));let u=Ne(c);u.length===0&&(console.error(`${l} holds no instance of a component package (an element with ${ae}): gallery component list says which there are, and gallery component show <id> how to write one.`),process.exit(1));let p=P.basename(i),h=Xe(u,t[1]??s,{slug:l,name:p}),{id:d,line:f}=u[h],m=Y(e),y=m.packages.get(d);if(!y){let T=m.problems.get(d);console.error(T?.off?`${d} is turned off in \u8BBE\u7F6E \u203A \u7EC4\u4EF6: its instances show what they hold, read-only, so a reader can do nothing with them.`:T?`${d} does not load, so its instances show what they hold, read-only: gallery component check ${d} says why.`:`No component ${d} in this workspace, so its instance shows what it holds, read-only: gallery component list says which there are.`),process.exit(1)}console.log(`${d} in ${l}, ${p}:${f}: ${H(i)}`);let S=await de({slug:l,command:`gallery component try ${l}`});if(!S.ok){console.log(`UNVERIFIED ${l}: ${S.message}`),process.exitCode=3;return}let k=ce(S.port,l);console.log(`Page: ${k} (the document's page alone, editable: the Agent's own; the server runs on after this command)`);let M=he();if(!M){console.log(`UNVERIFIED ${l}: no Chrome, Edge or Chromium found (GALLERY_BROWSER=<its executable> picks one), so nothing was tried`),process.exitCode=3;return}let L;try{L=await ue({executablePath:M,args:fe()})}catch(T){console.log(`UNVERIFIED ${l}: the browser ${M} did not start, twice, each time with a fresh profile (${J(T)}; GALLERY_BROWSER=<its executable> picks another), so nothing was tried`),process.exitCode=3;return}let N=P.join(se(e).qa,l,"try");try{await C.rm(N,{recursive:!0,force:!0}),await C.mkdir(N,{recursive:!0});let{lines:T,code:A}=It({slug:l,name:p,gesture:r,keep:o},await St(L.browser,{root:e,address:k,at:h,gesture:r,keep:o,file:i,name:p,line:f,found:y,out:N}));console.log(T.join(`
9
- `)),process.exitCode=A}finally{await L.close()}}export{Lt as INSIDE_ALONE,j as TRY_LINES,ve as asShown,tt as changesOf,Xe as chosenInstance,yt as cutOffSaid,gt as dragPath,st as fallbackSaid,ze as gestureOf,Ne as instancesIn,Ye as keysOf,bt as listen,kt as nothingSaid,vt as takenAgain,at as takenBy,nt as toldBy,It as trialSaid,Kt as tryCommand,lt as untilTaken,et as withoutIds};
@@ -1,120 +0,0 @@
1
- import { createRequire as __galleryRequire } from "node:module"; import { fileURLToPath as __galleryPath } from "node:url"; const require = __galleryRequire(import.meta.url); const __filename = __galleryPath(import.meta.url); const __dirname = __galleryPath(new URL(".", import.meta.url));
2
- import{e as it}from"./chunk-7GHT2UCA.mjs";import{b as mt}from"./chunk-UNUEWH4S.mjs";import{a as ct,g as lt,h as dt}from"./chunk-LC7YNQFG.mjs";import{k as we}from"./chunk-6U2SLSDN.mjs";import{a as at,b as st}from"./chunk-W7CXPCRV.mjs";import{a as ot}from"./chunk-LAE5NQ4B.mjs";import{b as Ze,c as Qe,d as ie,e as qe,f as ge,h as et,l as tt,o as nt,p as rt}from"./chunk-QMQUXTU4.mjs";import{d as Ve,e as pe,f as _e,g as Fe,h as Ye,k as he}from"./chunk-QYKCJ7FG.mjs";import{b as We,c as ze}from"./chunk-YZ5Z6H4W.mjs";import{d as Ue}from"./chunk-VACRB2NE.mjs";import{a as fe}from"./chunk-NFIBI4IP.mjs";import{a as Be,d as Y,g as He,h as Ge,l as Ke,m as Je,r as Xe,s as Te}from"./chunk-W63L7367.mjs";import Oe from"node:fs";import Fr from"node:fs/promises";import Pr from"node:http";import{editStateDirectory as Rr,kitPublicDirectory as Ar,release as Dr,releaseFile as Ee,reportsDirectory as Ne,vendorDirectory as Lr,workbenchDirectory as Ir}from"../browser/shared/paths.mjs";import{serve as Qt}from"../browser/shared/http.mjs";import{ensureWorkspace as Mr,layoutOf as Nr}from"../browser/shared/workspace.mjs";import ce from"node:fs/promises";import M from"node:path";import{Z as en}from"../browser/shared/layers.mjs";import{escapeMarkup as Pe}from"../browser/shared/escape.mjs";import{layoutNotesScript as tn}from"../browser/shared/qa-levels.mjs";var ye=30,nn=`
3
- [data-doc-dev].doc-checks { position: fixed; z-index: ${en.checks}; left: 12px; bottom: 12px; max-width: min(520px, calc(100vw - 24px));
4
- font: 13px/1.5 system-ui, sans-serif; color: light-dark(#37352f, #e3e2e0); }
5
- [data-doc-dev].doc-checks[hidden] { display: none; }
6
- [data-doc-dev].doc-checks > summary { display: inline-flex; gap: 6px; align-items: center; padding: 4px 10px; border-radius: 999px; cursor: pointer;
7
- list-style: none; color: light-dark(#a1352b, #f19c92); background: light-dark(#fce9e7, #3b2321);
8
- box-shadow: 0 0 0 1px light-dark(rgb(161 53 43 / 18%), rgb(241 156 146 / 22%)); user-select: none; }
9
- [data-doc-dev].doc-checks > summary::-webkit-details-marker { display: none; }
10
- [data-doc-dev].doc-checks > div { margin-top: 6px; padding: 8px 12px; max-height: 50vh; overflow: auto; border-radius: 10px;
11
- background: light-dark(#ffffff, #252525); box-shadow: 0 0 0 1px light-dark(rgb(42 28 0 / 7%), #383836), 0 20px 24px light-dark(rgb(25 25 25 / 5%), rgb(0 0 0 / 20%)); }
12
- [data-doc-dev].doc-checks ul { margin: 0; padding-left: 18px; }
13
- [data-doc-dev].doc-checks li { margin: 2px 0; overflow-wrap: anywhere; }
14
- [data-doc-dev].doc-checks p { margin: 6px 0 0; color: light-dark(#787774, #9b9a97); }
15
- [data-doc-dev].doc-checks .doc-checks-live:not(:first-child) { margin-top: 8px; }
16
- @media print { [data-doc-dev].doc-checks { display: none; } }`,rn=`(() => {
17
- document.currentScript.remove();
18
- ${tn()}
19
- const panel = document.querySelector("details.doc-checks[data-doc-dev]");
20
- if (!panel) return;
21
- const failures = Number(panel.dataset.failures) || 0;
22
- const live = panel.querySelector(".doc-checks-live ul");
23
- // The note's words in the UI's language (the root's data-ge-language).
24
- const english = document.documentElement.getAttribute("data-ge-language") === "en";
25
- const WORDS = english
26
- ? { card: "Chart card", table: "Table", named: (kind, name) => kind + " \u201C" + name + "\u201D", first: (name) => "Table (first column \u201C" + name + "\u201D)", colon: ": ",
27
- failing: (count) => "Checks failed \xB7 " + count, more: (count) => count + " more", all: (slug) => "gallery check " + slug + " runs every check (TypeScript too)." }
28
- : { card: "\u56FE\u8868\u5361\u7247", table: "\u8868\u683C", named: (kind, name) => kind + "\u300C" + name + "\u300D", first: (name) => "\u8868\u683C\uFF08\u9996\u5217\u300C" + name + "\u300D\uFF09", colon: "\uFF1A",
29
- failing: (count) => "\u68C0\u67E5\u672A\u901A\u8FC7 \xB7 " + count + " \u9879", more: (count) => "\u8FD8\u6709 " + count + " \u9879", all: (slug) => "gallery check " + slug + " \u8DD1\u5168\u90E8\u68C0\u67E5\uFF08\u542B TypeScript\uFF09\u3002" };
30
- const more = panel.querySelector("[data-more]");
31
- if (more) more.textContent = WORDS.more(more.dataset.more);
32
- const all = panel.querySelector("[data-all]");
33
- if (all) all.textContent = WORDS.all(all.dataset.all);
34
- const tidy = (node) => (node?.textContent ?? "").replace(/\\s+/g, " ").trim().slice(0, 40);
35
- const what = (host) => {
36
- const card = host.closest("figure");
37
- const title = card?.querySelector(":scope > h3, :scope > figcaption");
38
- const table = host.closest(".doc-table-wrap, table");
39
- const caption = table?.querySelector("caption");
40
- const header = table?.querySelector("th");
41
- return title ? WORDS.named(WORDS.card, tidy(title)) : card ? WORDS.card : caption && tidy(caption) ? WORDS.named(WORDS.table, tidy(caption)) : header ? WORDS.first(tidy(header)) : host.localName;
42
- };
43
- // A chart that drew nothing says why in its card (the kit's line, in the same language): that line, else the note in words.
44
- const said = (host, name, note) => (name === "data-missing" && tidy(host.querySelector(".doc-chart-message"))) || noteInWords(note, { english });
45
- let shown = "";
46
- let frame = 0;
47
- const draw = () => {
48
- frame = 0;
49
- const notes = [...document.querySelectorAll("[data-doc-layout]")].filter((host) => !host.closest("[data-doc-dev]"))
50
- .flatMap((host) => layoutNotesOf(host.getAttribute("data-doc-layout"), document.documentElement.clientWidth)
51
- .filter(({ level }) => level === "fail")
52
- .map(({ note, name }) => ({ line: what(host) + WORDS.colon + said(host, name, note), note })));
53
- const key = notes.map(({ line }) => line).join("\\n");
54
- if (key === shown) return;
55
- shown = key;
56
- live.replaceChildren(...notes.map(({ line, note }) => Object.assign(document.createElement("li"), { textContent: line, title: note })));
57
- live.parentElement.hidden = notes.length === 0;
58
- const failing = failures + notes.length;
59
- panel.querySelector("summary").textContent = failing ? WORDS.failing(failing) : "";
60
- panel.hidden = failing === 0;
61
- };
62
- const later = (records) => {
63
- if (!globalThis.document?.defaultView) return; // the page is gone
64
- if (!frame && records.some((record) => !record.target.closest?.("[data-doc-dev]"))) frame = requestAnimationFrame(draw);
65
- };
66
- new MutationObserver(later).observe(document.documentElement, { subtree: true, childList: true, attributes: true, attributeFilter: ["data-doc-layout"] });
67
- addEventListener("resize", () => { if (!frame) frame = requestAnimationFrame(draw); });
68
- draw();
69
- })();`;function ft(n,r,o={},{directory:d}={}){let s=et({slug:n,html:r,metadata:o,...d?{directory:d}:{}}),m=s.slice(0,ye).map(y=>`<li>${Pe(y)}</li>`).join(""),a=s.length>ye?`<p data-more="${s.length-ye}">\u8FD8\u6709 ${s.length-ye} \u9879</p>`:"",h=s.length?`<ul>${m}</ul>${a}<p data-all="${Pe(n)}">gallery check ${Pe(n)} \u8DD1\u5168\u90E8\u68C0\u67E5\uFF08\u542B TypeScript\uFF09\u3002</p>`:"";return`<details class="doc-checks" data-doc-dev data-failures="${s.length}"${s.length?"":" hidden"}><summary>${s.length?`\u68C0\u67E5\u672A\u901A\u8FC7 \xB7 ${s.length} \u9879`:""}</summary><div>${h}<div class="doc-checks-live" hidden><ul></ul></div></div><style>${nn}</style></details>
70
- <script data-doc-dev>${rn}</script>`}import{browserDirectory as ar,editStateDirectory as sr,kitSourceDirectory as zt,release as ir,reportsDirectory as N}from"../browser/shared/paths.mjs";import{sendJson as At,serve as Ut,serveFound as le}from"../browser/shared/http.mjs";import{languageScript as cr}from"../browser/shared/i18n/index.mjs";import{announcePreviewServer as lr,galleryVersion as dr}from"../browser/shared/preview-server.mjs";import{slugPattern as Bt}from"../browser/shared/reports.mjs";import{ATTRIBUTE as Dt,PACKAGE_ID as mr}from"../browser/shared/components/installed.mjs";import{COMPONENTS_FOLDER as Lt,WORKSPACE_FILE as It,documentDirectory as Mt,documentFiles as fr,isDocumentFile as ur,isDocumentSource as pr,isSlugName as hr,layoutOf as gr}from"../browser/shared/workspace.mjs";import{createHash as yn,randomBytes as kn}from"node:crypto";import D from"node:fs";import Re from"node:os";import X from"node:path";import{Transform as vn}from"node:stream";import{pipeline as xn}from"node:stream/promises";import{exportSourceOf as bn}from"../browser/shared/export-wrap.mjs";import{writeAtomic as Ae}from"../browser/shared/files.mjs";import{sendJson as A}from"../browser/shared/http.mjs";import{said as De,saying as Sn}from"../browser/shared/i18n/index.mjs";import{IMPORT_LIMIT as wt}from"../browser/shared/import-types.mjs";import{mediaUrl as $n}from"../browser/shared/media.mjs";import{fullAddress as Cn}from"../browser/shared/page-address.mjs";import{documentLinks as yt,slugPattern as kt}from"../browser/shared/reports.mjs";import{documentDirectory as jn,documentFiles as vt,pageSlug as On}from"../browser/shared/workspace.mjs";import{readWritingPreferences as En,saysAnything as Tn,unshownLines as _n}from"../browser/shared/writing-preferences.mjs";import ut from"node:fs/promises";import fn from"node:path";import{Worker as on}from"node:worker_threads";import{refusal as an,said as sn}from"../browser/shared/i18n/index.mjs";var cn=6e4,G=null,ln=0,ke=0,oe=new Map;function dn(){G=new on(new URL("./worker.mjs",import.meta.url)),G.on("message",({id:r,result:o,error:d})=>{let s=oe.get(r);s&&(oe.delete(r),d?s.reject(Object.assign(new Error(d.message),d)):s.resolve(o),oe.size===0&&(G?.unref(),mn()))});let n=r=>{for(let o of oe.values())o.reject(r);oe.clear(),G=null};G.on("error",n),G.on("exit",r=>n(an(sn("\u8F6C\u6362\u8FDB\u7A0B\u610F\u5916\u9000\u51FA\uFF08{0}\uFF09",r))))}function mn(){clearTimeout(ke),ke=setTimeout(()=>{if(oe.size===0&&G){let n=G;G=null,n.removeAllListeners("exit"),n.terminate()}},cn),ke.unref?.()}function Z(n,r){clearTimeout(ke),G||dn();let o=++ln;return new Promise((d,s)=>{oe.set(o,{resolve:d,reject:s}),G.ref(),G.postMessage({id:o,type:n,payload:r})})}import{pageLanguage as un}from"../browser/shared/components/page.mjs";function ve(n){return String(n??"").replace(/[\\/:*?"<>|\u0000-\u001f\u007f]/g," ").replace(/\s+/g," ").trim().slice(0,100).trim()||"Untitled"}function xe(n,r){let o=n.lastIndexOf("."),[d,s]=o>0?[n.slice(0,o),n.slice(o)]:[n,""];for(let m=0;;m+=1){let a=m===0?n:`${d} ${m}${s}`;if(!r.has(a.toLowerCase()))return r.add(a.toLowerCase()),a}}function be(n,r){let o=n.split("/").slice(0,-1),d=r.split("/"),s=0;for(;s<o.length&&s<d.length-1&&o[s]===d[s];)s+=1;return[...o.slice(s).map(()=>".."),...d.slice(s)].map(a=>a===".."?a:encodeURIComponent(a).replace(/\(/g,"%28").replace(/\)/g,"%29")).join("/")}import{documentDirectory as pn,documentFiles as hn}from"../browser/shared/workspace.mjs";var pt={markdown:"md",html:"html",pdf:"pdf"},gn={markdown:"text/markdown; charset=utf-8",html:"text/html; charset=utf-8",pdf:"application/pdf"},wn=n=>typeof n=="number"&&n>.1&&n<2;function ht(n){let{format:r,content:o="everything",subpages:d=!1,folders:s=!0,paper:m="A4",scale:a=1}=n??{};return Object.hasOwn(pt,r)&&["everything","no_files"].includes(o)&&typeof d=="boolean"&&typeof s=="boolean"&&["A4","A3","Letter","Legal","Tabloid"].includes(m)&&wn(a)}async function gt(n,r,o){let{format:d,content:s="everything",subpages:m=!1,folders:a=!0,paper:h="A4",scale:c=1}=r,y=pt[d],w=s==="everything",b=[],O=new Map,W=k=>O.get(k)??O.set(k,new Set).get(k),P=async(k,F)=>{let K=await o.titleOf(k),z=xe(`${ve(K)}.${y}`,W(F)),U=F?`${F}/${z}`:z,Q=a?U.slice(0,-(y.length+1)):"";if(b.push({slug:k,title:K,file:U,folder:Q,files:F?`${F}/assets`:"assets"}),m)for(let q of await o.childrenOf(k))await P(q,Q)};await P(n,"");let{links:E}=await o.links(),T=(k,F)=>Qe(F,k.slug,K=>{let z=d==="pdf"?null:b.find(U=>U.slug===K)?.file??null;return z&&be(k.file,z)},{blocks:d!=="markdown",links:E}),L=[],V=[];for(let k of b)if(d==="markdown"){await o.check(k.slug);let F=pn(k.slug,o.reportsDirectory),K=ie(await ut.readFile(hn(F).html,"utf8"),{slug:k.slug,mode:"words",reportsDirectory:o.reportsDirectory}),z=T(k,K),U=w&&!!ct(),{text:Q,files:q,charts:ee,charted:ne}=await Z("markdown",{source:z,title:k.title,pictures:U}),H=Q,te=new Map;if(q.forEach(({src:f,name:p},e)=>{te.has(f)||(te.set(f,`${k.files}/${xe(ve(p),W(k.files))}`),w&&V.push({from:fn.join(F,f),name:te.get(f)}));let t=te.get(f);H=H.replace(`\0F${e}\0`,()=>be(k.file,t))}),U&&ee>0&&H.includes("\0C")){let f=await dt(await o.offline(k.slug,{files:!0})).catch(()=>[]);H=H.replace(/^.*\u0000C(\d+)\u0000.*$/gm,(p,e)=>{let t=f[Number(e)];if(!t)return"\0gone\0";let i=`${k.files}/${xe(un(z)==="en"?ne[Number(e)]?"Chart.png":"Figure.png":ne[Number(e)]?"\u56FE\u8868.png":"\u56FE.png",W(k.files))}`;return L.push({name:i,data:t,later:!0}),p.replace(`\0C${e}\0`,()=>be(k.file,i))}).replace(/\n*\u0000gone\u0000\n*/g,`
71
-
72
- `).replace(/^\n+|\n+$/g,"")}L.push({name:k.file,data:H})}else d==="html"?L.push({name:k.file,data:T(k,await o.offline(k.slug,{files:w}))}):L.push({name:k.file,data:await lt(T(k,await o.offline(k.slug,{files:w})),{paper:h,scale:c})});for(let k of V){let F=await ut.readFile(k.from).catch(()=>null);F&&L.push({name:k.name,data:F})}let B=[...L.filter(k=>!k.later&&b.some(F=>F.file===k.name)),...L.filter(k=>k.later||!b.some(F=>F.file===k.name))];return B.length===1?{name:B[0].name,type:gn[d],data:Buffer.isBuffer(B[0].data)?B[0].data:Buffer.from(B[0].data,"utf8")}:{name:`${ve(b[0].title)}.zip`,type:"application/zip",data:ot(B)}}var Fn=3600*1e3,Le=new Set,xt=!1,Pn=n=>{Le.add(n),!xt&&(xt=!0,process.once("exit",()=>{for(let r of Le)try{D.rmSync(r,{recursive:!0,force:!0})}catch{}}))},Rn=/^u-[a-f0-9]{16}$/;function bt({edits:n,workspace:r,reports:o,reportsDirectory:d,offline:s}){let m=null,a=()=>m??=D.promises.mkdtemp(X.join(Re.tmpdir(),"gallery-uploads-")).then(f=>(Pn(f),f)),h=new Map,c=(f,p,e)=>[f,{ok:!1,reason:p,...Sn(e)}],y=f=>D.promises.access(f).then(()=>!0,()=>!1),w=f=>jn(f,d),b=f=>vt(w(f)),O=async f=>{try{return JSON.parse(await D.promises.readFile(b(f).json,"utf8")).title||f}catch{return f}};function W(f){if(f.method!=="POST")return[405,{ok:!1,reason:"method"}];let p=f.headers.host??"",e=f.socket.localPort;return p!==`127.0.0.1:${e}`&&p!==`localhost:${e}`?[403,{ok:!1,reason:"host"}]:f.headers.origin!==`http://${p}`?[403,{ok:!1,reason:"origin"}]:f.headers["x-gallery-token"]!==n.token?[403,{ok:!1,reason:"token"}]:/^application\/octet-stream\b/i.test(f.headers["content-type"]??"")?Number(f.headers["content-length"]??0)>wt?c(413,"size","\u6587\u4EF6\u592A\u5927\uFF08\u6700\u591A 5GB\uFF09"):null:[415,{ok:!1,reason:"type"}]}async function P(){for(let[f,p]of h)Date.now()-p.at<Fn||(h.delete(f),await D.promises.rm(p.file,{force:!0}).catch(()=>{}))}async function E(f,p){let e=W(f);if(e)return f.resume(),A(p,...e);let t=new URL(f.url,"http://localhost").searchParams.get("name")?.replace(/[\u0000-\u001f]/g,"").trim()??"";if(!t||t.length>255)return f.resume(),A(p,...c(400,"name","\u6587\u4EF6\u540D\u4E0D\u5BF9"));await P();let i=`u-${kn(8).toString("hex")}`,l=X.join(await a(),i),u=0,g=new vn({transform(x,j,_){u+=x.length,_(u>wt?Object.assign(new Error("too-large"),{reason:"size"}):null,x)}});try{await xn(f,g,D.createWriteStream(l))}catch(x){return await D.promises.rm(l,{force:!0}).catch(()=>{}),x.reason==="size"?A(p,...c(413,"size","\u6587\u4EF6\u592A\u5927\uFF08\u6700\u591A 5GB\uFF09")):A(p,...c(400,"body","\u6587\u4EF6\u6CA1\u6709\u4F20\u5B8C"))}return h.set(i,{file:l,name:t,at:Date.now()}),A(p,200,{ok:!0,id:i})}async function T(f,p){let e=await n.check(f);if(e.error)return A(p,...e.error);let{slug:t,options:i}=e.body??{};if(typeof t!="string"||!kt.test(t)||!await y(b(t).html))return A(p,...c(404,"missing","\u627E\u4E0D\u5230\u8FD9\u4EFD\u6587\u6863"));if(!ht(i))return A(p,...c(400,"options","\u5BFC\u51FA\u9009\u9879\u4E0D\u5BF9"));try{let l=await s(),u=new Map,g=v=>(u.has(v)||u.set(v,n.handIn(v,{reader:!0}).then(C=>{if(!C.ok)throw Object.assign(new Error(C.message??C.reason),{reason:C.reason});if(C.repeated.length)throw Object.assign(new Error("check"),{reason:"check",slug:v,failures:ge(C.repeated)})})),u.get(v)),x=new Map,j={reportsDirectory:d,titleOf:O,childrenOf:async v=>(await r.outline()).children[v]??[],links:()=>yt(d),offline:async(v,C)=>{await g(v);let I=await l(v,C),J=i.format==="markdown"?null:bn(I);return J&&x.set(v,J),I},check:async v=>(await g(v),l.check(v))},{name:_,type:R,data:$}=await gt(t,i,j);x.size&&await(await we([...x.keys()])).keep([...x.keys()],x),p.writeHead(200,{"Content-Type":R,"Content-Length":$.length,"Content-Disposition":`attachment; filename*=UTF-8''${encodeURIComponent(_)}`,"X-File-Name":encodeURIComponent(_),"Cache-Control":"no-store"}),p.end($)}catch(l){if(l.reason==="check"){let u=await O(l.slug),g=l.component?De("\u300C{0}\u300D\u91CC\u7684\u7EC4\u4EF6 {1} \u6709\u9519\u8BEF\uFF0C\u6CA1\u6709\u751F\u6210\u6587\u4EF6\uFF1A\u53EF\u4EE5\u8BA9 AI \u68C0\u67E5\u8FD9\u4EFD\u6587\u6863\u5E76\u4FEE\u597D",u,l.component):l.failures.length>1?De("\u300C{0}\u300D\u6CA1\u6709\u901A\u8FC7\u5BFC\u51FA\u524D\u7684\u68C0\u67E5\uFF0C\u6CA1\u6709\u751F\u6210\u6587\u4EF6\uFF1A{1}\uFF08\u5171 {2} \u5904\uFF1A\u53EF\u4EE5\u8BA9 AI \u68C0\u67E5\u8FD9\u4EFD\u6587\u6863\uFF0C\u5217\u51FA\u5168\u90E8\u5E76\u4FEE\u597D\uFF09",u,l.failures[0],l.failures.length):De("\u300C{0}\u300D\u6CA1\u6709\u901A\u8FC7\u5BFC\u51FA\u524D\u7684\u68C0\u67E5\uFF0C\u6CA1\u6709\u751F\u6210\u6587\u4EF6\uFF1A{1}",u,l.failures[0]);return A(p,...c(422,"check",g))}A(p,...c(l.reason==="browser"?422:l.reason==="busy"?409:l.reason==="missing"?404:500,l.reason??"export",l))}}async function L(f,p){let e=await n.check(f);if(e.error)return A(p,...e.error);let{slug:t}=e.body??{},i=(await n.readTaken(t,{wait:0}))?.text??null;if(i===null)return A(p,...c(404,"missing","\u627E\u4E0D\u5230\u8FD9\u4EFD\u6587\u6863"));let l=`http://${f.headers.host}`,{named:u}=await yt(d),g=Ze(ie(i,{slug:t,mode:"words",reportsDirectory:d}),t,R=>R.slug&&Cn(l,R,u),u),{text:x,files:j}=await Z("markdown",{source:g,title:await O(t),pictures:!1}),_=x.replace(/\u0000F(\d+)\u0000/g,(R,$)=>{let{src:v,kind:C}=j[Number($)];return encodeURI(`${l}${$n(C==="image"?"asset":"file",t,v)}`)});return A(p,200,{ok:!0,text:_})}let V=async f=>{let p=await n.readTaken(f,{wait:0});return{source:p?.text??"",version:p?.version??null}},B=async(f,p=null)=>{let{source:e,version:t}=p??await V(f),i="\u5199\u4F5C\u504F\u597D",{text:l,files:u}=await Z("markdown",{source:e,title:i,pictures:!1}),g=l.split(`
73
- `).slice(1).join(`
74
- `).replace(/^[\s>]*(?:```.*|\d+\.|- \[x\])/gm,"").replace(/<\/?aside>/g,"");if(!/[\p{L}\p{N}]|\u0000F\d+\u0000/u.test(g))return{markdown:`# ${i}
75
- `,empty:!0,version:t};let x=X.relative(d,w(f)).split(X.sep).join("/");return{markdown:`${l.replace(/\u0000F(\d+)\u0000/g,(j,_)=>encodeURI(`${x}/${u[Number(_)].src}`))}
76
- `,empty:!1,version:t}},k=f=>b(f).json,F=async f=>{try{let p=JSON.parse(await D.promises.readFile(k(f),"utf8"));return p&&typeof p=="object"?p:null}catch{return null}},K=f=>yn("sha256").update(f).digest("hex").slice(0,16);async function z(f,p,e,t){let i=await F(f);if(!i||e===null)return;let{synced:l,...u}=i,g={file:K(p),page:e,unshown:t},x=i.madeSame;l===void 0&&x?.file===g.file&&x?.page===g.page&&JSON.stringify(x?.unshown)===JSON.stringify(t)||await Ae(k(f),`${JSON.stringify({...u,madeSame:g},null,2)}
77
- `)}async function U(f,p){let e=await D.promises.mkdtemp(X.join(Re.tmpdir(),"gallery-preferences-"));try{let i=(await Z("import",{uploads:[{file:p,name:"preferences.md"}],scratch:e})).pages[0]??{nodes:[],raws:[],files:[],icon:null,lang:null},l=w(f),u=await F(f)??{},g=vt(l).html,x=await D.promises.readFile(g,"utf8").catch(()=>""),j=/<html\b[^>]*\slang="([^"]*)"/i.exec(x)?.[1]??null,{html:_}=await ze(f,u.title||"\u5199\u4F5C\u504F\u597D",u.description||"",{blank:!0,lang:j}),R=typeof u.icon=="string"&&u.icon?u.icon:null,$=await Z("fill",{source:_,nodes:i.nodes,icon:R,raws:i.raws,lang:i.lang});i.files.length&&await D.promises.mkdir(X.join(l,"assets"),{recursive:!0});for(let{from:C,name:I}of i.files){let J=X.join(l,"assets",I);await y(J)||await D.promises.copyFile(C,J)}let v=await D.promises.readFile(g,"utf8").catch(()=>null);v!==null&&n.keepVersion?.(f,v),await Ae(g,he($))}finally{await D.promises.rm(e,{recursive:!0,force:!0}).catch(()=>{})}}async function Q(f,p){let e=await n.check(f);if(e.error)return A(p,...e.error);let t=e.body?.opening===!0,i=await On(d);if(!i)return A(p,...c(404,"missing","\u8FD8\u6CA1\u6709\u5199\u4F5C\u504F\u597D"));let l=null,u=(g,x)=>[200,{ok:!0,path:X.resolve(l),remade:g,unshown:x}];return n.respond(async()=>{let g;({file:l,text:g}=await En(d));let x=await V(i),j=(await F(i))?.madeSame??null,_=j===null||j.page===x.version,R=j!==null&&_&&j.file===K(g);if(t&&R&&Array.isArray(j.unshown))return u(!1,j.unshown);let[$,v,C,I]=[g,"",x.version,!1];if(t&&!_)await U(i,l),{markdown:v,version:C}=await B(i),I=!0;else{let S=await B(i,x),re=g.trim()===S.markdown.trim()||S.empty&&!Tn(g);v=S.markdown,t?!re&&!R&&(await U(i,l),{markdown:v,version:C}=await B(i),I=!0):re||(await Ae(l,S.markdown),$=S.markdown)}let J=_n($,v);return await z(i,$,C,J),u(I,J)})(f,p)}async function q(f,p){let e=await n.check(f);if(e.error)return A(p,...e.error);let{uploads:t,parent:i="",from:l,language:u}=e.body??{},g={said:typeof l=="string"&&l.includes("{0}")&&l.length<=60?l:"\u5BFC\u5165\u81EA {0}",lang:u==="en"?"en":null};if(!Array.isArray(t)||t.length===0||t.length>1e3||!t.every(v=>typeof v=="string"&&Rn.test(v)))return A(p,...c(400,"body"));let x=t.map(v=>h.get(v)).filter(Boolean);if(x.length!==t.length)return A(p,...c(410,"gone","\u4E0A\u4F20\u7684\u6587\u4EF6\u5DF2\u8FC7\u671F\uFF0C\u8BF7\u91CD\u65B0\u5BFC\u5165"));for(let v of t)h.delete(v);let j=typeof i=="string"&&kt.test(i)&&await y(X.join(d,i))?i:"",_=await D.promises.mkdtemp(X.join(Re.tmpdir(),"gallery-import-")),R=()=>Promise.all([D.promises.rm(_,{recursive:!0,force:!0}),...x.map(({file:v})=>D.promises.rm(v,{force:!0}))]).catch(()=>{}),$;try{$=await Z("import",{uploads:x.map(({file:v,name:C})=>({file:v,name:C})),scratch:_})}catch(v){return await R(),A(p,...c(500,"convert",v))}return n.respond(async()=>{try{let{made:v,top:C}=await at($.pages,{create:o.create,slugOf:()=>r.freeSlug("doc"),folderOf:w,fill:I=>Z("fill",I),place:r.place,under:j,...g});return[200,{ok:!0,pages:v.length,reports:C,skipped:$.skipped,missing:ee($.pages)}]}finally{await R()}})(f,p)}let ee=f=>[...new Set(f.flatMap(function p(e){return[...(e.notes??[]).filter(t=>t.kind==="picture-missing").map(t=>t.name),...e.children.flatMap(p)]}))],ne={export:T,markdown:L,upload:E,import:q,preferences:Q};function H(f,p,e){return Object.hasOwn(ne,e)?ne[e](f,p).catch(t=>{p.headersSent||A(p,...c(500,"transfer",t))}):A(p,404,{ok:!1,reason:"unknown"})}async function te(){let f=m;m=null,h.clear();let p=await f?.catch(()=>null);p&&(Le.delete(p),await D.promises.rm(p,{recursive:!0,force:!0}).catch(()=>{}))}return{handle:H,close:te}}function St({settled:n,tell:r,delay:o=120,recheck:d=1e3}){let s=new Map,m=(a,h=o)=>{clearTimeout(s.get(a));let c=setTimeout(async()=>{let y=await n(a).catch(()=>({source:null,held:!1,wait:0}));if(s.get(a)===c){if(y.held)return m(a,Math.min(Math.max(y.wait,50),d));if(y.wait>0)return m(a,y.wait);await r(a,y)}},h);s.set(a,c)};return m}import An from"node:fs/promises";import{packageScript as Dn}from"../browser/shared/export-wrap.mjs";import{serveFound as Ln}from"../browser/shared/http.mjs";import{extensionOf as In,mediaTypeOf as Mn}from"../browser/shared/media.mjs";var Nn="/__gallery/components/",Wn=/^\/__gallery\/components\/([a-z0-9][a-z0-9-]*\/[a-z0-9][a-z0-9-]*)\/(.+)$/,zn={js:"text/javascript; charset=utf-8",mjs:"text/javascript; charset=utf-8",css:"text/css; charset=utf-8",wasm:"application/wasm"};async function $t(n,r,o,{root:d}){if(!n.startsWith(Nn))return!1;let[,s,m]=Wn.exec(n)??[],a=s?Y(d).packages.get(s):null,h=a?.files.includes(m)?Ke(a,m):null,c=h?await An.readFile(h).catch(()=>null):null,y=c&&m==="kit.js"?Buffer.from(Dn(c.toString("utf8").replace(/^\uFEFF/,""))):c,w=y&&r===a.stamp&&r===Je(a);return Ln(o,y,{type:y?zn[In(m)]??Mn(m):void 0,headers:{"X-Content-Type-Options":"nosniff","Cache-Control":w?"max-age=31536000, immutable":"no-store"}}),!0}import{LISTED_BLOCKS as Ct}from"../browser/editor/components/registry.mjs";import{PACKAGE_ID as Un}from"../browser/shared/components/installed.mjs";import{inLanguage as jt,refusal as Bn,said as Se}from"../browser/shared/i18n/index.mjs";function Ot({root:n,taken:r}){let o=()=>{let m=Y(n);return{packages:Xe(m),blocks:Ct.map(({id:a,name:h,hideable:c})=>({id:a,name:{zh:jt("zh",h),en:jt("en",h)},hidden:c&&m.settings.hidden.includes(a),hideable:c})),problem:Ge(m)}},d=({id:m,hidden:a,disabled:h})=>{if(![a,h].every(y=>y===void 0||typeof y=="boolean"))return Se("\u5F00\u5173\u7684\u503C\u4E0D\u5BF9");let c=Ct.find(y=>y.id===m);return c?h!==void 0?Se("\u5185\u7F6E\u5757\u53EA\u80FD\u9690\u85CF\uFF0C\u4E0D\u80FD\u505C\u7528"):a&&!c.hideable?Se("\u8FD9\u4E2A\u5757\u4E0D\u80FD\u9690\u85CF"):null:typeof m=="string"&&Un.test(m)?null:Se("\u6CA1\u6709\u8FD9\u4E2A\u7EC4\u4EF6")};return{read:o,write:async m=>{let a=d(m);if(a)throw Bn(a);return await Be(n,m),r(),o()}}}import Hn from"node:path";import{exportsDirectory as Gn}from"../browser/shared/paths.mjs";async function Et(n,r){let o=Hn.join(Gn,`${r}.html`),d=await we([r]),s=await n.handInReport(r,{reader:!0});if(!s.ok)return{problems:[],refused:{reason:s.reason,message:s.message},file:o};if(s.repeated.length)return{problems:ge(s.repeated),file:o};let{exported:m,failures:a}=await rt([r]);return await d.keep(m.map(h=>h.slug)),{problems:a.get(r)??[],file:o}}import Kn from"node:fs/promises";import Jn from"node:path";import{MEDIA_ROUTES as Tt,mediaTypeOf as Xn}from"../browser/shared/media.mjs";import{serveFound as Vn}from"../browser/shared/http.mjs";import{slugPattern as Yn}from"../browser/shared/reports.mjs";import{documentDirectory as Zn}from"../browser/shared/workspace.mjs";var Qn={asset:n=>({"Content-Type":Xn(n),"Cache-Control":"no-cache"}),file:()=>({"Content-Type":"application/octet-stream","Content-Disposition":"attachment","X-Content-Type-Options":"nosniff","Cache-Control":"no-cache"}),embed:n=>/\.pdf$/i.test(n)?{"Content-Type":"application/pdf","X-Content-Type-Options":"nosniff","Cache-Control":"no-cache"}:{"Content-Type":"text/html; charset=utf-8","Content-Security-Policy":"sandbox allow-scripts allow-popups allow-forms allow-modals","X-Content-Type-Options":"nosniff","Cache-Control":"no-cache"}},qn=new RegExp(`^/__gallery/edit/(${Object.keys(Tt).join("|")})/([^/]+)/(assets/[^/]+)$`);async function _t(n,r,{reportsDirectory:o}){let[,d,s,m]=qn.exec(n)??[];if(!d)return!1;let a=Yn.test(s)&&Tt[d](m)?await Kn.readFile(Jn.join(Zn(s,o),m)).catch(()=>null):null;return Vn(r,a,{headers:Qn[d](m)}),!0}function Ft({max:n=20}={}){let r=new Map;return{get(o,d,s){let m=`${o} ${d}`,a=r.get(m);return!a||a.text!==s?null:(r.delete(m),r.set(m,a),a.page)},set(o,d,s,m){let a=`${o} ${d}`;for(r.delete(a),r.set(a,{slug:o,text:s,page:m});r.size>n;)r.delete(r.keys().next().value)},clear(){r.clear()},forget(o){for(let[d,s]of r)s.slug===o&&r.delete(d)},get size(){return r.size}}}import{createHash as er}from"node:crypto";import{readFileSync as tr}from"node:fs";import Pt from"node:fs/promises";import nr from"node:path";import{release as rr,releaseFile as or}from"../browser/shared/paths.mjs";async function $e(n){let r=await Promise.all(n.map(d=>Pt.stat(d).then(({mtimeMs:s,size:m})=>`${s} ${m}`,()=>"none"))),o=er("sha256");return n.forEach((d,s)=>o.update(`${d}\0${r[s]}
78
- `)),o.digest("hex").slice(0,16)}function Rt(n,r){let o=null,d=async()=>(await Promise.all(n.map(async s=>(await Pt.readdir(s,{recursive:!0,withFileTypes:!0}).catch(()=>[])).filter(a=>a.isFile()).map(a=>nr.join(a.parentPath,a.name))))).flat().filter(r).sort();return{files:()=>o??=d(),changed:()=>{o=null}}}var Ie=rr?JSON.parse(tr(or,"utf8")).stamps:null;var Ht=Bt.source.slice(1,-1),wr=new RegExp(`^/generated/(${Ht})\\.html$`),yr=new RegExp(`^/(${Ht})/(?:doc|report)\\.html$`),Gt="/__gallery/events",ae=ar,Kt=/^\/__gallery\/edit\/(v\/[a-f0-9]{16}\/)?src\/((?:shared(?:\/components|\/emoji|\/i18n)?\/|editor\/(?:page|components)(?:\/[a-z]+(?:-[a-z]+)*){0,2}\/(?!files?\.mjs))[a-z]+(?:-[a-z]+)*\.mjs)$/,kr=/^\/__gallery\/edit\/(?:v\/[a-f0-9]{16}\/)?src\/(shared\/emoji\/data\/[a-z]+(?:-[a-z]+)*\.(json|bin))$/,Ce=[M.join(ae,"editor","page"),M.join(ae,"editor","components"),M.join(ae,"shared")],vr=n=>Kt.test(`/__gallery/edit/src/${M.relative(ae,n).split(M.sep).join("/")}`);var xr=[zt,M.join(ae,"shared","components")],Na=[zt,...Ce],je={"Cache-Control":"no-store"},Nt={"Cache-Control":"max-age=31536000, immutable"},Wt=(n,r,o)=>Ut(n,{type:r,headers:je,body:o});function br(n){let r=n.headers?.host??"",o=n.socket?.localPort;return!!o&&(r===`127.0.0.1:${o}`||r===`localhost:${o}`)}var Sr=(n,r,o)=>`<script>
79
- (() => {
80
- document.currentScript.remove();
81
- const solo = new URLSearchParams(location.search).has("solo");
82
- let catalog = "${o}";
83
- const holds = (ids) => document.querySelector(ids === undefined ? "[${Dt}]" : ids.split(",").map((id) => '[${Dt}="' + id + '"]').join());
84
- const events = new EventSource("${Gt}?slug=${n}");
85
- events.onmessage = (event) => {
86
- const [kind, next, ids] = event.data.split(" ");
87
- if (kind === "notes") return void window.dispatchEvent(new CustomEvent("doc-annotations-changed", { detail: { version: next ?? "" } }));
88
- if (kind === "settings") return void window.dispatchEvent(new CustomEvent("doc-settings-changed", { detail: { hidden: next ? next.split(",") : [], disabled: ids ? ids.split(",") : [] } }));
89
- if (kind === "components") {
90
- if (document.readyState === "loading") return void document.addEventListener("DOMContentLoaded", () => events.onmessage(event), { once: true });
91
- if (solo || next === catalog) return;
92
- catalog = next;
93
- if (!holds(ids)) return void window.dispatchEvent(new CustomEvent("doc-catalog-changed", { detail: { ids: ids === undefined ? null : ids.split(",").filter(Boolean) } }));
94
- }
95
- if (window.__galleryEditBusy) {
96
- window.dispatchEvent(new CustomEvent({ report: "doc-source-changed", assets: "doc-assets-changed", components: "doc-components-changed" }[kind], { detail: { version: next ?? null } }));
97
- return;
98
- }
99
- if (kind === "report" && next === "${r}") return;
100
- if (window.__galleryEditReload) return window.__galleryEditReload(); // in a workbench: swapped in, no reload seen
101
- location.reload();
102
- };
103
- })();
104
- </script>`;function $r(n,r){let o=M.relative(n,r).split(M.sep);if(o[0]===".."||M.isAbsolute(o[0])||o[0]==="")return null;if(o.length===1&&o[0]===It)return{slug:null,name:It,packages:!0};let d=o[0]===".gallery"&&o[1]==="pages"&&o.length>=3,[s,...m]=d?o.slice(2):o,a=!d&&(process.platform==="win32"?s.toLowerCase():s)===Lt;return!(a||Bt.test(s))||s==="exports"||m.some(h=>h.startsWith("."))?null:{slug:a?Lt:s,name:m.length===1?m[0]:null,...a?{packages:a}:{}}}function Me(n){let r=y=>process.platform==="win32"?M.resolve(y).toLowerCase():M.resolve(y),{gallery:o,pages:d,exports:s}=gr(n),[m,a,h]=[r(o),r(d),r(s)],c=(y,w)=>y===w||y.startsWith(w+M.sep);return y=>{let w=r(y);return c(w,m)&&w!==m&&!c(w,a)||c(w,h)}}var de=(n,r,o)=>new RegExp(`</${r}>`,"i").test(n)?n.replace(new RegExp(`</${r}>`,"i"),()=>` ${o}
105
- </${r}>`):`${n}
106
- ${o}`;function Jt({stateDirectory:n=sr,logger:r=console,kind:o="dev",workbenchPage:d=null,closeServer:s=async()=>{},exit:m=()=>process.exit(0)}={}){let a=new Set,h=(e,t="",i="report")=>{for(let l of a)(!e||l.slug===e)&&l.response.write(`data: ${e?`${i} ${t}`:"assets"}
107
-
108
- `)},c=it({stateDirectory:n,finish:he,log:e=>r.info?.(`[gallery] ${e}`)}),y=(e,t,i,{lang:l=null,page:u=!1}={})=>We(e,t,i,{blank:!0,lang:l,page:u}),w=null,b=null,O=()=>b??=(async()=>{for(let e of a)e.response.end();a.clear(),await Promise.race([s().catch(()=>{}),new Promise(e=>setTimeout(e,3e3))]),await w?.().catch(()=>{}),await P.close(),m()})(),W=st({server:{kind:o,version:dr,stop:O},edits:c,reports:{create:y,export:e=>Et(c,e),words:(e,t)=>ie(e,{slug:t,mode:"words",reportsDirectory:N})},components:Ot({root:N,taken:()=>ee.taken()})}),P=bt({edits:c,workspace:W,reports:{create:y},reportsDirectory:N,offline:nt}),E=(e,t,{present:i=!1,editorModule:l,kit:u}={})=>{let g=t,x="",j="",_=!0;try{i||({html:g,snippet:x,head:j}=c.preview(e,t,{editor:l,kitTags:$=>Ye($,u)}))}catch($){_=!1,r.warn(`[gallery] text editing unavailable for ${e}: ${$.message}`)}if({html:g}=qe(g,{slug:e,mode:"preview",kit:u}),g=de(g,"head",Sr(e,fe(t),Y(N).stamp)),g=de(g,"head",`<script data-doc-dev>${cr()}</script>`),j&&(g=de(g,"head",j)),i)return{html:de(g,"head",`<style data-doc-present>.doc-display { display: none !important; }</style>
109
- <script type="module" src="/__gallery/edit/src/editor/page/present-links.mjs" data-doc-dev></script>`),whole:_};let R="";try{R=ft(e,t)}catch($){_=!1,r.warn(`[gallery] checks unavailable for ${e}: ${$.message}`)}return R&&(g=de(g,"body",R)),{html:x?de(g,"body",x):g,whole:_}},T=Ft(),L=Rt(Ce,vr),V=e=>{let t=Mt(e,N);return[t,M.join(t,"assets")]},B=()=>Ie?.editor??L.files().then($e),k=e=>Ie?.kit?.[e.id]??$e([Fe(e)]),F=async(e,t,{present:i})=>{let[l,u,g]=await Promise.all([i?"":B(),Promise.all(pe.map(k)),$e(V(e))]),x=[i?"present":l,...u,g,Y(N).stamp].join(" "),j=T.get(e,x,t);if(j!==null)return i||c.opened(t),j;let _=new Map(pe.map((C,I)=>[C,u[I]])),R=i?void 0:`/__gallery/edit/v/${l}/src/editor/page/editor.mjs`,{html:$,whole:v}=E(e,t,{present:i,editorModule:R,kit:C=>`${_e(C)}?v=${_.get(C)}`});return v&&T.set(e,x,t,$),$};async function K(e,t,i){try{if(!br(e))return At(t,403,{ok:!1,reason:"host"});let l=new URL(e.url||"/","http://localhost"),u=decodeURI(l.pathname);if(u===Gt){t.writeHead(200,{"Content-Type":"text/event-stream","Cache-Control":"no-store",Connection:"keep-alive"}),t.write(`retry: 3000
110
-
111
- `);let S={slug:l.searchParams.get("slug"),response:t};a.add(S);let{stamp:re,settings:qt}=Y(N);t.write(`data: components ${re}
112
-
113
- `),t.write(`data: ${Te(qt)}
114
-
115
- `),e.on("close",()=>a.delete(S));return}if(u==="/__gallery/edit/commit")return c.commit(e,t);if(u==="/__gallery/edit/reverted")return c.reverted(e,t);if(u==="/__gallery/edit/hand-in")return c.handInRequest(e,t);if(u==="/__gallery/edit/settle")return c.settleRequest(e,t);if(u==="/__gallery/edit/upload")return c.upload(e,t);if(u==="/__gallery/edit/unfurl")return c.unfurl(e,t);if(u==="/__gallery/edit/emoji-library"){if(e.method==="POST")return c.addEmoji(e,t);let[S,re]=await c.listEmojis();return At(t,S,re)}if(u==="/__gallery/edit/icon"){let S=Ue({value:l.searchParams.get("value")??"",slug:l.searchParams.get("slug"),tab:l.searchParams.has("tab")});return le(t,S?.body,{type:S?.type,headers:{"Cache-Control":"max-age=31536000, immutable"}})}if(await _t(u,t,{reportsDirectory:N})||await $t(u,l.searchParams.get("v"),t,{root:N}))return;let g=u.match(/^\/__gallery\/edit\/emoji-library\/([^/]+)$/)?.[1];if(g){let S=await c.readEmoji(g);return le(t,S?.body,{type:S?.type,headers:{"Cache-Control":"no-cache"}})}if(u==="/__gallery/edit/frameable")return c.frameable(e,t);if(u==="/__gallery/edit/annotations")return c.annotations(e,t);let x=u.match(/^\/__gallery\/transfer\/([a-z]+)$/)?.[1];if(x)return P.handle(e,t,x);let j=u.match(/^\/__gallery\/workspace\/([a-z]+)$/)?.[1];if(j)return W.handle(e,t,j);let[,_,R]=u.match(Kt)??[];if(R){let S=await ce.readFile(M.join(ae,R),"utf8").catch(()=>null);return le(t,S,{type:"text/javascript; charset=utf-8",headers:_?Nt:je})}let $=l.searchParams.has("v")&&pe.find(S=>_e(S)===u);if($){let S=await ce.readFile(Fe($)).catch(()=>null);return le(t,S,{type:u.endsWith(".css")?"text/css; charset=utf-8":"text/javascript; charset=utf-8",headers:Nt})}if(u==="/__gallery/edit/mhchem.js"){let S=await ce.readFile(Ve).catch(()=>null);return le(t,S,{type:"text/javascript; charset=utf-8",headers:je})}let[,v,C]=u.match(kr)??[];if(v){let S=await ce.readFile(M.join(ae,v)).catch(()=>null);return le(t,S,{type:C==="json"?"application/json; charset=utf-8":"application/octet-stream",headers:{"Cache-Control":"max-age=86400"}})}if(d&&(u==="/"||u==="/index.html"))return Wt(t,"text/html; charset=utf-8",await d(l.pathname,e));let I=u.match(wr)?.[1];if(!I){let S=u.match(yr)?.[1];return hr(S)&&await ce.access(fr(Mt(S,N)).html).then(()=>!0,()=>!1)?Ut(t,{status:302,headers:{Location:`/generated/${S}.html${l.search}`,...je}}):i()}let J=await c.readTaken(I);if(J===null)return i();Wt(t,"text/html; charset=utf-8",await F(I,J.text,{present:l.searchParams.has("present")}))}catch(l){i(l)}}let z=new Map,U=(e,t)=>{clearTimeout(z.get(e)),z.set(e,setTimeout(t,120))},Q=St({settled:c.settled,async tell(e,t){let i=await c.read(e,t.source).catch(l=>(r.error(`[gallery] ${e}: ${l.message}`),{version:fe(t.source??"")}));h(e,i?.version??fe("")),c.checkAnnotations(e).catch(l=>r.error(`[gallery] ${e}: annotations not checked: ${l.message}`))}}),q=({id:e,problem:t,off:i})=>i||r.warn(`[gallery] component package ${e} does not load: ${He("en",t)}`),ee=mt({root:N,tell({stamp:e,problems:t,settings:i},l){for(let u of l)t.has(u)&&q(t.get(u));for(let{response:u}of a)u.write(`data: components ${e} ${l.filter(g=>mr.test(g)).join(",")}
116
-
117
- `),u.write(`data: ${Te(i)}
118
-
119
- `)}});for(let e of Y(N).problems.values())q(e);let ne=Me(N),H=(e,t)=>!ir&&t.some(i=>e.startsWith(i+M.sep));function te(e,t){if(e==="reset"){T.clear(),L.changed(),ee.changed();return}if(ne(t))return;let i=$r(N,t);if(i?.packages&&ee.changed(),i?.slug&&!(i.name&&ur(i.name))&&T.forget(i.slug),i&&(/^(doc|report)\.json$/.test(i.name??"")||/^(add|unlink)Dir$/.test(e)&&i.name===null)&&T.clear(),/^(add|unlink)(Dir)?$/.test(e)&&H(t,Ce)&&L.changed(),i?.name&&(pr(i.name)||/^(doc|report)\.json$/.test(i.name)))Q(i.slug);else if(i?.name==="annotations.json"){let{slug:l}=i;U(`notes:${l}`,async()=>{let u=await ce.readFile(t,"utf8").catch(()=>null);h(l,u===null?"":fe(u),"notes")})}else H(t,xr)?U("kit",async()=>{try{await tt({fresh:!0}),h()}catch(l){r.error(`[gallery] shared kit rebuild failed: ${l.message}`)}}):H(t,Ce)&&U("editor",()=>h())}async function f(e){w=await lr({reportsDirectory:N,port:e,token:c.token,kind:o})}async function p(){for(let e of z.values())clearTimeout(e);ee.close(),await w?.().catch(()=>{}),w=null,await P.close()}return{handle:K,changed:te,listening:f,close:p,stop:O,edits:c,get listeners(){return a.size}}}import Cr from"node:fs/promises";import me from"node:path";import{serve as Xt}from"../browser/shared/http.mjs";var jr={".html":"text/html; charset=utf-8",".js":"text/javascript; charset=utf-8",".mjs":"text/javascript; charset=utf-8",".css":"text/css; charset=utf-8",".json":"application/json; charset=utf-8",".map":"application/json; charset=utf-8",".svg":"image/svg+xml",".png":"image/png",".ico":"image/x-icon",".woff2":"font/woff2",".woff":"font/woff",".ttf":"font/ttf",".txt":"text/plain; charset=utf-8"},Or=n=>jr[me.extname(n).toLowerCase()]??"application/octet-stream";function Er(n,r){if(/%(?:2f|5c|00)/i.test(r)||/[\\\0]/.test(r))return null;let o;try{o=decodeURIComponent(r)}catch{return null}let d=o.split("/");if(d.some(a=>a===""||a==="."||a===".."||/[\\\0:]/.test(a)))return null;let s=me.resolve(n,...d),m=me.relative(n,s);return m&&!m.startsWith("..")&&!me.isAbsolute(m)?s:null}async function Vt(n,r,{web:o,kit:d,vendor:s}){if(n.method!=="GET"&&n.method!=="HEAD")return!1;let m=new URL(n.url||"/","http://localhost").pathname,a=null,h=null;if(m==="/"||m==="/index.html"){if(!o)return!1;[a,h]=[me.join(o,"index.html"),{"Cache-Control":"no-store"}]}else{let w=[["/assets/",o&&me.join(o,"assets"),"max-age=31536000, immutable"],["/kit/",d,"no-cache"],["/vendor/",s,"no-cache"]].find(([b,O])=>O&&m.startsWith(b));if(!w)return!1;a=Er(w[1],m.slice(w[0].length)),h={"Cache-Control":w[2]}}let c=a?await Cr.readFile(a).catch(()=>null):null;return c?(Xt(r,{type:Or(a),headers:{...h,"X-Content-Type-Options":"nosniff"},body:n.method==="HEAD"?void 0:c}),!0):(Xt(r,{status:404}),!0)}import se from"node:fs";import ue from"node:path";import{isSlugName as Yt,layoutOf as Tr}from"../browser/shared/workspace.mjs";function _r(n){let{components:r,gallery:o,pages:d}=Tr(n),s=(h,c)=>{try{return se.readdirSync(h,{withFileTypes:!0}).filter(y=>y.isDirectory()&&c(y.name)).map(y=>ue.join(h,y.name))}catch{return[]}},m=[...s(n,h=>Yt(h)),...s(d,h=>Yt(h))],a=h=>[h,...s(h,c=>!c.startsWith(".")).flatMap(a)];return[...new Set([n,...[o,d].filter(h=>se.existsSync(h)),...m,...m.map(h=>ue.join(h,"assets")).filter(h=>se.existsSync(h)),...se.existsSync(r)?a(r):[]])]}function Zt(n,r,{folders:o=process.platform==="linux"}={}){let d=Me(n),s=(w,b)=>{d(b)||ue.basename(b).startsWith(".")||se.stat(b,(O,W)=>{if(O)return r(O.code==="ENOENT"?"unlink":"change",b);let P=W.isDirectory();r(w==="rename"?P?"addDir":"add":P?"addDir":"change",b)})},m=()=>{};if(!o)try{let w=se.watch(n,{recursive:!0},(b,O)=>O?s(b,ue.join(n,O.toString())):r("reset",n));return w.on("error",m),{close:()=>w.close()}}catch(w){if(w.code!=="ERR_FEATURE_UNAVAILABLE_ON_PLATFORM")throw w}let a=new Map,h=null,c=()=>{let w=new Set(_r(n));for(let[b,O]of a)w.has(b)||(O.close(),a.delete(b));for(let b of w)if(!a.has(b))try{let O=se.watch(b,(W,P)=>{if(!P)return r("reset",b);W==="rename"&&y(),s(W,ue.join(b,P.toString()))});O.on("error",m),a.set(b,O)}catch{}},y=()=>{h??=setTimeout(()=>{h=null,c()},50)};return c(),{close(){clearTimeout(h);for(let w of a.values())w.close();a.clear()},get folders(){return[...a.keys()]}}}async function as({port:n,web:r=Ir,kind:o=process.env.GALLERY_SERVER_KIND==="dev"?"dev":"cli",stateDirectory:d=Rr,exit:s=(c=0)=>process.exit(c),watch:m=!0,signals:a=!0,log:h=console}={}){await Mr(Ne);let c=null,y=null,w=null,b=Nr(Ne),O=async()=>{y?.close(),w&&Oe.unwatchFile(Ee,w),await Fr.writeFile(b.lastPortFile,`${n}
120
- `).catch(()=>{}),await new Promise(E=>{c.close(()=>E()),c.closeAllConnections()})},P=Jt({stateDirectory:d,logger:{info:E=>h.log(E),warn:E=>h.warn(E),error:E=>h.error(E)},kind:o,closeServer:O,exit:()=>s(0)});if(c=Pr.createServer((E,T)=>{P.handle(E,T,async L=>{if(L){h.error(`[gallery] ${E.method} ${E.url}: ${L.stack??L.message}`),T.headersSent?T.end():Qt(T,{status:500});return}try{if(await Vt(E,T,{web:r,kit:Ar,vendor:Lr}))return}catch(V){h.error(`[gallery] ${E.url}: ${V.message}`)}T.headersSent||Qt(T,{status:404})})}),c.keepAliveTimeout=5e3,await new Promise((E,T)=>{c.once("error",T),c.listen(n,"127.0.0.1",()=>{c.off("error",T),E()})}),n=c.address().port,await P.listening(n),m&&(y=Zt(Ne,P.changed)),Dr){let E=Oe.readFileSync(Ee,"utf8");w=()=>{let T=null;try{T=Oe.readFileSync(Ee,"utf8")}catch{}T!==E&&(h.log("[gallery] The package was replaced (another version installed): this server stops; the next gallery command starts the new one."),P.stop())},Oe.watchFile(Ee,{interval:3e3,persistent:!1},w)}if(a)for(let E of["SIGINT","SIGTERM","SIGHUP"])process.once(E,()=>P.stop());return{server:c,port:n,routes:P,async close(){await O(),await P.close()}}}export{as as a};
@@ -1,2 +0,0 @@
1
- import { createRequire as __galleryRequire } from "node:module"; import { fileURLToPath as __galleryPath } from "node:url"; const require = __galleryRequire(import.meta.url); const __filename = __galleryPath(import.meta.url); const __dirname = __galleryPath(new URL(".", import.meta.url));
2
- import{a,b,c,d,e,f,g,h,i,j,k,l}from"./chunk-6U2SLSDN.mjs";import"./chunk-ITNLYXXV.mjs";import"./chunk-HQQMJCQJ.mjs";import"./chunk-QYKCJ7FG.mjs";import"./chunk-HYMEEXKN.mjs";import"./chunk-TDQP3DKQ.mjs";import"./chunk-5FRMCDPY.mjs";import"./chunk-E7VYDG2X.mjs";import"./chunk-NFIBI4IP.mjs";import"./chunk-W63L7367.mjs";import"./chunk-A55HN5OK.mjs";import"./chunk-5L7RYZCL.mjs";export{e as BASELINE_FROM,h as adoptIdless,g as baselineOf,b as blocksOf,k as exportBaselines,j as exportedText,i as hasBaseline,d as packageStamps,c as pageOf,l as previewBaseline,a as rankOf,f as readBaseline};
@@ -1,10 +0,0 @@
1
- import { createRequire as __galleryRequire } from "node:module"; import { fileURLToPath as __galleryPath } from "node:url"; const require = __galleryRequire(import.meta.url); const __filename = __galleryPath(import.meta.url); const __dirname = __galleryPath(new URL(".", import.meta.url));
2
- import{a as i,l as C}from"./chunk-QYKCJ7FG.mjs";import{a as g,c as w}from"./chunk-HYMEEXKN.mjs";import{d as j,k as A,l as S}from"./chunk-W63L7367.mjs";import f from"node:path";import{attr as P,hasClass as H,walk as D}from"../browser/shared/html-tree.mjs";import{projectRoot as F,sdkDirectory as L,typeRoots as V}from"../browser/shared/paths.mjs";var Y=new Set(["application/ecmascript","application/javascript","application/x-ecmascript","application/x-javascript","text/ecmascript","text/javascript","text/javascript1.0","text/javascript1.1","text/javascript1.2","text/javascript1.3","text/javascript1.4","text/javascript1.5","text/jscript","text/livescript","text/x-ecmascript","text/x-javascript"]);function y(t,{diffs:s=!1,tree:r=g(t)}={}){let n=[];return D(r,a=>{if(a.tagName!=="script"||P(a,"src")!==void 0)return;let o=(P(a,"type")||"").trim().toLowerCase(),l=s&&o==="application/json"&&a.parentNode?.tagName?a.parentNode:null,e=l&&H(l,"doc-diff")?"__declaredDiff(":void 0;if(!e&&o&&o!=="module"&&!Y.has(o))return;let{startTag:c,endTag:p}=a.sourceCodeLocation??{};c&&n.push({start:c.endOffset,end:p?.startOffset??t.length,module:o==="module",...e?{call:e}:{}})},{inTemplates:!1}),n}function O(t,s,r=[]){let n=[],a=0,o="",l=e=>e.replace(/[^\r\n]/g," ");for(let{start:e,end:c,call:p}of s){let u=o+l(t.slice(a+o.length,e));if(p){let h=q(u,p,o.length);if(h===null){r.push(e);continue}u=h}n.push(u,t.slice(e,c)),a=c,o=p?");":""}return n.push(o+l(t.slice(a+o.length)),`
3
- export {};
4
- `),n.join("")}function q(t,s,r){let n=t.length;for(;;){let a=Math.max(t.lastIndexOf(`
5
- `,n-1)+1,r),o=t[n-1]==="\r"?n-1:n;if(o-a>=s.length)return t.slice(0,o-s.length)+s+t.slice(o);if(a<=r)return null;n=a-1}}function Ct(t,s=g(t)){return O(t,y(t,{tree:s}))}var X=new Set(["href","src","action","formaction"]),Z=t=>{try{return decodeURIComponent(t)}catch{return t}};function Q(t,s){let r=y(t,{tree:s}).map(({start:n,end:a})=>({code:t.slice(n,a),start:n,where:"the document's script"}));return D(s,n=>{for(let{name:a,value:o}of n.attrs){let l=n.sourceCodeLocation?.attrs?.[a]?.startLine??n.sourceCodeLocation?.startLine,e=X.has(a)?o.replace(/[\t\n\r]/g,"").replace(/^[\u0000-\u0020]+/,""):"";/^on[a-z]+$/.test(a)?r.push({code:o,line:l,where:`the ${a} attribute of <${n.tagName}>`}):/^javascript:/i.test(e)&&r.push({code:Z(e.slice(11)),line:l,where:`the javascript: address of <${n.tagName} ${a}>`})}},{inTemplates:!1}),r}var R=new Set(["fetch","XMLHttpRequest","WebSocket","EventSource","sendBeacon","import"]),E=new Set(["window","globalThis","self"]),tt=t=>i.isIdentifier(t)?t.text==="navigator":i.isPropertyAccessExpression(t)&&t.name.text==="navigator"&&i.isIdentifier(t.expression)&&E.has(t.expression.text);function I(t){let{initializer:s}=i.walkUpBindingElementsAndPatterns(t);return!!s&&i.isIdentifier(s)&&E.has(s.text)}function et(t){let s=t.parent;return i.isPropertyAccessExpression(s)&&s.name===t?i.isIdentifier(s.expression)&&E.has(s.expression.text):i.isBindingElement(s)&&s.propertyName===t?I(s):!((i.isPropertyAssignment(s)||i.isMethodDeclaration(s)||i.isPropertyDeclaration(s)||i.isGetAccessorDeclaration(s)||i.isSetAccessorDeclaration(s))&&s.name===t)}function st(t,s){return i.isIdentifier(t)&&s.has(t.text)&&et(t)?{name:t.text,reference:i.isPropertyAccessExpression(t.parent)&&t.parent.name===t?t.parent:t}:i.isElementAccessExpression(t)&&i.isIdentifier(t.expression)&&E.has(t.expression.text)&&i.isStringLiteralLike(t.argumentExpression)&&s.has(t.argumentExpression.text)?{name:t.argumentExpression.text,reference:t}:i.isPropertyAccessExpression(t)&&s.has(t.name.text)&&t.name.text==="sendBeacon"&&tt(t.expression)?{name:"sendBeacon",reference:t}:s.has("import")&&i.isCallExpression(t)&&t.expression.kind===i.SyntaxKind.ImportKeyword?{name:"import",reference:t.expression}:null}function rt(t,s){let r=new Map,n=(e,c)=>{let p=e.parent;for(;p&&!c(p);)p=p.parent;return p??t},a=e=>i.isFunctionLike(e)||i.isBlock(e)||i.isCaseBlock(e)||i.isForStatement(e)||i.isForInStatement(e)||i.isForOfStatement(e),o=e=>i.isFunctionExpression(e)||i.isClassExpression(e)?e:i.isFunctionDeclaration(e)||i.isClassDeclaration(e)?n(e,a):i.isCatchClause(e.parent)?e.parent:n(e,i.getCombinedNodeFlags(e)&i.NodeFlags.BlockScoped?a:i.isFunctionLike),l=e=>{(i.isParameter(e)||i.isVariableDeclaration(e)||i.isBindingElement(e)||i.isFunctionDeclaration(e)||i.isClassDeclaration(e)||i.isFunctionExpression(e)||i.isClassExpression(e))&&e.name&&i.isIdentifier(e.name)&&s.has(e.name.text)&&!(i.isBindingElement(e)&&I(e))&&r.set(e.name.text,[...r.get(e.name.text)??[],o(e)]),i.forEachChild(e,l)};return l(t),r}function nt(t,s=[]){for(let r=t;r;r=r.parent)if(s.includes(r))return!0;return!1}function Pt(t,s,{tree:r=g(t)}={}){let n=[];for(let{code:a,start:o,line:l,where:e}of Q(t,r))for(let{name:c,how:p,at:u}of k(a,s))n.push({name:c,how:p,line:l??w(t,o+u),where:e});return n.sort((a,o)=>a.line-o.line)}function k(t,s){if(![...s].some(l=>t.includes(l)))return[];let r=[],n=i.createSourceFile("code.js",t,i.ScriptTarget.Latest,!0,i.ScriptKind.JS),a=rt(n,s),o=l=>{let e=st(l,s),c=e?.reference.parent;if(e&&!i.isTypeOfExpression(c)&&!(i.isIdentifier(e.reference)&&nt(l,a.get(e.name)))){let p=(i.isCallExpression(c)||i.isNewExpression(c))&&c.expression===e.reference?i.isNewExpression(c)?"new":"call":"use";r.push({name:e.name,how:p,at:l.getStart(n)})}i.forEachChild(l,o)};return o(n),r}var it=new Set([2304,2552]),at=new Set([2300,2451,2448,2449,2450]),M=t=>it.has(t)||at.has(t)||t>=1e3&&t<2e3;function ot(t,s,r){if(!t.file||r.has(t)||M(t.code))return!1;let n=t.start??-1;return s.some(a=>!a.call&&a.start<=n&&n<a.end)}var ct=(t,s)=>/\bNumberValue\b/.test(t)||/\bd3\.(?:min|max|extent)\(/.test(s)?"; here d3 reads values of no type as strings: give the data its shape once with JSDoc, /** @type {Array<{ label: string, value: number }>} */ const rows = data;, and d3.min or d3.max may give undefined (?? 0)":"";function B(t){let s={allowJs:!0,checkJs:!0,noEmit:!0,allowUmdGlobalAccess:!0,strict:!0,noImplicitAny:!1,target:i.ScriptTarget.ES2022,module:i.ModuleKind.ESNext,moduleResolution:i.ModuleResolutionKind.Bundler,lib:["lib.es2022.d.ts","lib.dom.d.ts","lib.dom.iterable.d.ts"],types:["d3"],typeRoots:V,skipLibCheck:!1},r=i.createCompilerHost(s),n=r.readFile.bind(r),a=r.fileExists.bind(r);return r.readFile=o=>t.get(f.resolve(o))??n(o),r.fileExists=o=>t.has(f.resolve(o))||a(o),i.createProgram([f.join(L,"index.d.ts"),...t.keys()],s,r)}var lt=/\bDoc[A-Z]\w*/,pt=(t,s)=>lt.test(s)||(t.relatedInformation??[]).some(({file:r})=>r&&f.resolve(r.fileName).startsWith(L+f.sep)),N={katex:"katex","katex-auto-render":"renderMathInElement"};function Nt(t,{assets:s=[]}={}){let r=f.join(F,"reports","__package__","kit.js"),n=t.replace(/^([ \t]*)(?:<!--|-->)/gm,"$1//"),a=s.filter(c=>Object.hasOwn(N,c)).map(c=>`declare const ${N[c]}: any;
6
- `),o=B(new Map([[r,`${n}
7
- export {};
8
- `],...a.length?[[f.join(f.dirname(r),"assets.d.ts"),a.join("")]]:[]])),l=new Set(o.getSyntacticDiagnostics()),e=new Map;for(let c of i.getPreEmitDiagnostics(o)){if(!c.file||f.resolve(c.file.fileName)!==r)continue;let{line:p}=c.file.getLineAndCharacterOfPosition(c.start??0),u=i.flattenDiagnosticMessageText(c.messageText," "),h=`${p} ${u}`;e.has(h)||e.set(h,{line:p+1,code:c.code,message:u,refused:l.has(c)||M(c.code)||pt(c,u)})}return[...e.values()]}function Dt(t){let s=new Map,r=new Map,n=new Map,a=[];for(let e of t){let c=y(e.html,{diffs:!0}),p=[c.filter(m=>!m.module),...c.filter(m=>m.module).map(m=>[m])],u=f.join(F,"reports",f.basename(f.dirname(e.htmlPath)),f.basename(e.htmlPath)),h=[];p.forEach((m,x)=>{let d=`${u}.${x}.js`;s.set(d,O(e.html,m,h)),r.set(d,f.resolve(e.htmlPath)),n.set(d,m)});for(let m of h){let x=e.html.slice(0,m).split(`
9
- `),d=f.resolve(e.htmlPath);a.push({htmlPath:f.resolve(e.htmlPath),text:`${d}:${x.length}:${x.at(-1).length+1} a declared diff's options could not be checked: write its <script type="application/json"> tag on a line of its own`})}}let o=B(s),l=new Set(o.getSyntacticDiagnostics());return[...a,...i.getPreEmitDiagnostics(o).map(e=>{let c=e.file?.getLineAndCharacterOfPosition(e.start||0),p=e.file?r.get(f.resolve(e.file.fileName))??null:null,u=p||e.file?.fileName,h=u?f.resolve(u):"SDK",m=i.flattenDiagnosticMessageText(e.messageText," "),x=p!==null&&ot(e,n.get(f.resolve(e.file.fileName))??[],l);return{htmlPath:p,text:`${h}${c?`:${c.line+1}:${c.character+1}`:""} TS${e.code}: ${m}`,typeOnly:x,...x?{note:`line ${c.line+1}: TS${e.code} in the document's script (column ${c.character+1}): ${m} (strict TypeScript's word on a type: a note, not a failure; the browser runs the script as written: guard the value where it can really be null or of another type${ct(m,e.file.text.split(`
10
- `)[c.line]??"")})`}:{}}})]}import{readFileSync as K}from"node:fs";import{isInstance as _}from"../browser/shared/components/index.mjs";import{ATTRIBUTE as G,PACKAGE_MARK as $}from"../browser/shared/components/installed.mjs";import{cssReferences as U,cssWithAddresses as ft}from"../browser/shared/css-references.mjs";import{packageScript as ut,scriptText as mt,styleText as ht}from"../browser/shared/export-wrap.mjs";import{attr as b,walk as W}from"../browser/shared/html-tree.mjs";import{mediaTypeOf as xt}from"../browser/shared/media.mjs";var gt=new RegExp(G,"i");function Jt(t,{packages:s}=j(),r=null){if(!gt.test(t))return[];let n=new Set;return W(r??g(t),a=>{_(a)&&n.add(b(a,G))},{stop:_}),[...n].map(a=>s.get(a)).filter(Boolean)}function zt(t,s){if(s.length===0)return t;let r=s.map(A);return C(t,{styles:r.flatMap(({styles:n})=>n),scripts:r.flatMap(({scripts:n})=>n)})}function T(t,s){try{return K(S(t,s)).toString("utf8").replace(/^\uFEFF/,"")}catch{return null}}var J=/^(?:data:|#|$)/i,dt=/^(?:[a-z][a-z0-9+.-]*:|\/)/i,z=t=>t.replace(/^\.\//,"").replace(/[?#].*$/,""),wt=(t,s)=>ft(s,U(s),({value:r,kind:n})=>{let a=z(r);if(n==="import"||J.test(r)||!t.files.includes(a))return null;let o=S(t,a);return o&&`data:${xt(a)};base64,${K(o).toString("base64")}`}),v=new Set(["eval","Function"]),Et=new Set([...R,...v]),St={call:t=>`calls ${t}(\u2026)`,new:t=>`creates new ${t}(\u2026)`,use:t=>`uses ${t}`};function yt(t){if(!t.files.includes("style.css"))return[];let s=T(t,"style.css")??"";return U(s).flatMap(({value:r,kind:n,index:a})=>{let o=n==="import"?"has an @import, which an export cannot hold: write what it imports into style.css":J.test(r)?null:dt.test(r)?`loads ${r}: external resources are not portable`:t.files.includes(z(r))?null:`names ${r}, which an export cannot hold: put the file in the package and name it in its assets`;return o?[{line:w(s,a),what:o}]:[]})}function kt(t){if(!t.files.includes("kit.js"))return[];let s=T(t,"kit.js")??"";return k(s,Et).filter(({name:r,how:n})=>n!=="use"||!v.has(r)).map(({name:r,how:n,at:a})=>({line:w(s,a),what:`${St[n](r)}: ${v.has(r)?"an export runs no code made from words":"the export blocks the network; put its data in the instance"}`}))}var Ht=t=>t.flatMap(s=>[...yt(s).map(({what:r})=>`${s.id}: its style.css ${r}`),...kt(s).map(({line:r,what:n})=>`${s.id}: line ${r} of its kit.js ${n}`)]);function $t(t,s){let r=`${$}="${t.id}"`,n=T(t,s);return n===null?null:s==="kit.js"?`<script ${r}>${mt(ut(n))}</script>`:`<style ${r}>${ht(wt(t,n))}</style>`}function Vt(t,{packages:s}){if(!t.includes($))return t;let r=[];W(g(t),o=>{let l=s.get(b(o,$)),e=o.tagName==="link"?"style.css":o.tagName==="script"&&b(o,"src")!==void 0?"kit.js":null,c=o.sourceCodeLocation,p=l&&e&&c?$t(l,e):null;p&&r.push({start:c.startOffset,end:c.endOffset,copy:p})},{inTemplates:!1});let n="",a=0;for(let{start:o,end:l,copy:e}of r)n+=t.slice(a,o)+e,a=l;return n+t.slice(a)}export{Ct as a,R as b,Pt as c,k as d,Nt as e,Dt as f,Jt as g,zt as h,T as i,yt as j,kt as k,Ht as l,Vt as m};
@@ -1,6 +0,0 @@
1
- import { createRequire as __galleryRequire } from "node:module"; import { fileURLToPath as __galleryPath } from "node:url"; const require = __galleryRequire(import.meta.url); const __filename = __galleryPath(import.meta.url); const __dirname = __galleryPath(new URL(".", import.meta.url));
2
- import{a as he,b as qt}from"./chunk-342HXE3Q.mjs";import{b as le,f as ce,g as de}from"./chunk-XINNG4F2.mjs";import"./chunk-7GHT2UCA.mjs";import"./chunk-G7TOXONE.mjs";import{a as oe,b as ne,c as se,d as ae,e as ie,f as re}from"./chunk-LC7YNQFG.mjs";import{a as We,b as Vt,c as Qt,d as Zt,f as te,g as je,h as ee,k as Le,l as Ie}from"./chunk-6U2SLSDN.mjs";import"./chunk-P2CAZPDP.mjs";import"./chunk-ITNLYXXV.mjs";import{b as Wt,j as Kt}from"./chunk-NSKUTQ5J.mjs";import"./chunk-QMQUXTU4.mjs";import{g as Jt}from"./chunk-HQQMJCQJ.mjs";import"./chunk-QYKCJ7FG.mjs";import"./chunk-YZ5Z6H4W.mjs";import"./chunk-VACRB2NE.mjs";import{a as Xt}from"./chunk-HYMEEXKN.mjs";import"./chunk-TDQP3DKQ.mjs";import"./chunk-5FRMCDPY.mjs";import{a as Pt}from"./chunk-E7VYDG2X.mjs";import"./chunk-NFIBI4IP.mjs";import"./chunk-W63L7367.mjs";import"./chunk-A55HN5OK.mjs";import"./chunk-5L7RYZCL.mjs";import{spawnSync as Fe}from"node:child_process";import vt from"node:fs/promises";import ht from"node:path";import{pathToFileURL as Pe}from"node:url";import{MATH_IGNORED_TAGS as Ve}from"../browser/shared/components/math.mjs";import{exportPackagesOf as _e,exportSourceOf as De,packagesSaid as He}from"../browser/shared/export-wrap.mjs";import{sha256 as fe}from"../browser/shared/files.mjs";import{attr as ue}from"../browser/shared/html-tree.mjs";import{projectRoot as ze,qaDirectory as Ue,reportsDirectory as Rt}from"../browser/shared/paths.mjs";import{documentDirectory as jt,documentFiles as Lt}from"../browser/shared/workspace.mjs";import{KINDS as Uo,LEVELS as At,LOOKS as pe,WIDE as Go,WIDTHS as ge,layoutNotesOf as Ge,levelOf as Me}from"../browser/shared/qa-levels.mjs";import{tableHidesScript as Ye}from"../browser/shared/table-hides.mjs";var Ke=new Set(["code-scrolls","formula-scrolls"]),Ce=(e,n)=>e.level??Me(e.kind,n),Xe=(e,n)=>["fail","warn"].includes(Ce(e,n))||Ke.has(e.kind)&&Me(e.kind,n)==="info",Je=4,Ee=12,Qe=8,Ze=2,me=200,to=2e3,we=600;function eo({block:e,above:n=null,below:s=null}){let c=[e,n,s].filter(Boolean),r=Math.min(...c.map(h=>h.left)),u=Math.max(...c.map(h=>h.right)),w=n?Math.max(Math.min(n.top,e.top),e.top-me):e.top,d=s?Math.min(Math.max(s.bottom,e.bottom),e.bottom+me):e.bottom,$=(h,q)=>({x:Math.max(0,r),y:Math.max(0,h),width:u-r,height:q-Math.max(0,h)});return e.bottom-e.top<=to?[{part:"",clip:$(w,d)}]:[{part:"top",clip:$(w,e.top+we)},{part:"bottom",clip:$(e.bottom-we,d)}]}function $e(e,n=""){if(e.startsWith("data:"))return`${e.slice(0,30)}\u2026 (${e.length} characters)`;let s=n.slice(0,n.lastIndexOf("/")+1);if(s&&e.startsWith(s)&&e.length>s.length)try{return decodeURIComponent(e.slice(s.length))}catch{return e.slice(s.length)}return e.length>60?`\u2026${e.slice(-59)}`:e}var It=e=>String(e??"").replace(/\s+/g," ").trim(),Mt=(e,n=40)=>{let s=It(e);return`"${s.length>n?`${s.slice(0,n-1)}\u2026`:s}"`},oo=e=>String(e??"").replace(/\s+/g,"").slice(0,120);function no(e,n="doc.html"){let s=new Map,c=new Map,r=new Map,u=($,h)=>(h&&$.sourceCodeLocation.attrs?.[h]||$.sourceCodeLocation).startLine,w=new Map,d=$=>{if($.nodeName==="#text")return $.value;if(!$.tagName&&$.nodeName!=="#document"||$.tagName==="template")return"";let h=($.childNodes??[]).map(d).join("");if(!$.tagName||!$.sourceCodeLocation)return h;let q=ue($,"data-block-id");q!==void 0&&!s.has(q)&&s.set(q,u($,"data-block-id"));let L=ue($,"id");L!==void 0&&!c.has(L)&&c.set(L,u($,"id"));let U=oo(h);if(U.length>=2){let m=`${$.tagName}|${U}`;w.has(m)||w.set(m,[]),w.get(m).push($.sourceCodeLocation)}return h};d(Xt(e));for(let[$,h]of w)r.set($,h.sort((q,L)=>q.startOffset-L.startOffset).map(q=>q.startLine));return{blocks:s,ids:c,texts:r,name:n}}function so(e,n){if(!e)return"the page";let s=n.name??"doc.html",c=h=>{let q=h&&n.texts.get(`${h.tag}|${h.words}`);return q?.[Math.min(h.nth??0,q.length-1)]},r=e.table||e.header?.text,u=e.card?` card ${Mt(e.card.text)}`:r?` table ${Mt(r)}`:"",w=e.blocks?.find(h=>n.blocks.has(h));if(w!==void 0)return`${s}:${n.blocks.get(w)} [data-block-id="${w}"]${u}`;if(c(e.card))return`${s}:${c(e.card)} card ${Mt(e.card.text)}`;if(c(e.header))return`${s}:${c(e.header)} table ${Mt(r)}`;let d=e.texts?.find(c);if(d)return`${s}:${c(d)} ${d===e.texts[0]&&d.tag===e.tag?"":`${e.element} in `}<${d.tag}> ${Mt(d.text,32)}`;let $=e.ids?.find(h=>n.ids.has(h));return $!==void 0?`${s}:${n.ids.get($)} #${$}${u}`:c(e.section)?`${s}:${c(e.section)} ${e.element} in the section ${Mt(e.section.text)}`:`${e.element}${u} (not found in ${s})`}function Ut(e){let n=new Date(e),s=u=>String(u).padStart(2,"0"),c=-n.getTimezoneOffset(),r=`${c<0?"-":"+"}${s(Math.floor(Math.abs(c)/60))}:${s(Math.abs(c)%60)}`;return`${n.getFullYear()}-${s(n.getMonth()+1)}-${s(n.getDate())}T${s(n.getHours())}:${s(n.getMinutes())}:${s(n.getSeconds())}${r}`}function ao(e,n,s={said:"",now:""}){return e===n?s.said===s.now?{stale:!1,why:""}:{stale:!0,packaged:!0,why:`it holds ${s.said||"no component package"}, the workspace has ${s.now||"none of them"}`}:{stale:!0,why:e?`made from a text whose sha256 is ${e.slice(0,12)}\u2026, the file's is ${n.slice(0,12)}\u2026`:"it does not say which text it was made from: made before exports said it, or before the kit's names were doc-* (2026-10-26), whose pages gallery qa no longer reads"}}async function Gt(e,{made:n=!1}={}){let s=Lt(jt(e,Rt)).html,c=qt(e),[r,u]=await Promise.all([vt.readFile(s).catch(()=>null),vt.stat(c).catch(()=>null)]);if(!r)return{problem:`${e}: no document (${s})`};if(!u)return{problem:`${e}: no export (${c}): run gallery export ${e} first`,missing:!0};let w=await vt.readFile(c),d=w.toString("utf8"),$=De(d),h={said:_e(d),now:He(Jt(r.toString("utf8")))},{stale:q,why:L,packaged:U=!1}=ao($,fe(r),h);return q&&!n?{problem:`${e}: ${c} is not of ${s} as it is now (${L}): run gallery export ${e} first`,stale:!0,why:L,edited:!!$&&!U,packaged:U}:{file:c,sha256:fe(w),time:u.mtimeMs}}function io(e,n){let s=e.map((w,d)=>({length:1,weight:n[d],previous:-1})),c=(w,d)=>w.length>d.length||w.length===d.length&&w.weight>d.weight;e.forEach((w,d)=>{for(let $=0;$<d;$++){if(e[$]>=w)continue;let h={length:s[$].length+1,weight:s[$].weight+n[d],previous:$};c(h,s[d])&&(s[d]=h)}});let r=-1;s.forEach((w,d)=>{(r<0||c(w,s[r]))&&(r=d)});let u=[];for(let w=r;w>=0;w=s[w].previous)u.unshift(w);return u}function qe(e,n){let s=n?.places??{},c=new Set((n?.moved??[]).filter(u=>e.has(u))),r=new Map;for(let[u,{parent:w,size:d=0}]of e){let $=s[u];if($){if($[0]!==w){c.add(u);continue}r.has(w)||r.set(w,[]),r.get(w).push({id:u,at:$[1],size:d})}}for(let u of r.values()){let w=new Set(io(u.map(({at:d})=>d),u.map(({size:d})=>d)).map(d=>u[d].id));for(let{id:d}of u)w.has(d)||c.add(d)}return c}function ro(e,n,s,{named:c=null,verified:r=!0,failed:u=!1,seen:w=null,page:d=void 0,packages:$=void 0}={}){if(!r||u||c&&!n)return null;let h=w??new Set([...s.ids,...[...s.held?.values()??[]].flat()]),q=!n,L=q||s.pageChanged?s.cards??[]:[],U=[...n?.unseen??[],...L],m={blocks:{},places:{},moved:q?[]:[...qe(e,n)].filter(x=>!h.has(x)),unseen:[...new Set(U)].filter(x=>e.has(x)&&!h.has(x))};for(let[x,{hash:H,parent:M,at:Z}]of e){let X=q||h.has(x)?H:n.blocks[x];X!==void 0&&(m.blocks[x]=X),m.places[x]=[M,Z]}let C=!q&&(c||s.tiles)?n.page:d;typeof C=="string"&&(m.page=C);let D=!q&&(c||s.tiles)?n.packages:$&&Object.fromEntries(Object.entries($).map(([x,H])=>[x,(s.restyled?.get(x)??[]).every(M=>h.has(M))?H:n.packages[x]]));return D&&Object.keys(D).length&&(m.packages=D),m}function Ae(e){let n=new Map;for(let s of e){let c=new Set(s.held?.covered??[]);for(let r of s.held?.missed??[])c.has(r)||n.set(r,[...n.get(r)??[],s.label??String(s.width)])}return n}function lo(e,n){let s=Ae(n);return new Set([...e.ids,...[...e.held?.values()??[]].flat().filter(c=>!s.has(c))])}function xe(e){let n=e.time?` of ${Ut(e.time)}`:"";return e.from==="export"?`the export${n} (the document before these changes)`:e.from==="preview"?`gallery open${n} (the document before these changes)`:"the last look"}var co=3;function ho(e,n,s=null,{tiles:c=!1,page:r=void 0,packages:u=void 0}={}){let w={rest:[],unknown:[],moved:new Set,around:new Map,held:new Map,groups:[],cards:[],pageChanged:!1,changed:new Set,restyled:new Map,left:null},d=[...e.keys()],$=new Map(d.map((a,O)=>[a,O])),h=n?qe(e,n):new Set,q=a=>typeof n?.packages?.[a]=="string"&&typeof u?.[a]=="string"&&n.packages[a]!==u[a],L=n?d.filter(a=>q(e.get(a).package)&&n.blocks[a]===e.get(a).hash&&!h.has(a)):[],U=new Map;for(let a of L)U.set(e.get(a).package,[...U.get(e.get(a).package)??[],a]);let m=new Set(L),C=n?d.filter(a=>n.blocks[a]!==e.get(a).hash||h.has(a)||m.has(a)):[],D=new Set((n?.unseen??[]).filter(a=>e.has(a)&&!C.includes(a))),x=(a,O)=>{let G=null;for(let et=e.get(a).parent;et!==null&&e.has(et);et=e.get(et).parent)O.has(et)&&(G=et);return G},H=new Set(C),M=new Set(C.filter(a=>e.get(a).card||h.has(a))),Z=a=>H.has(a)&&!h.has(a)&&x(a,M)===null,X=new Map;for(let a of d)for(let O=e.get(a).parent;O!==null&&e.has(O);O=e.get(O).parent){let G=X.get(O)??{all:0,changed:0};G.all+=1,Z(a)&&(G.changed+=1),X.set(O,G)}let gt=d.filter(a=>!e.get(a).card&&X.has(a)&&X.get(a).changed>=co&&X.get(a).changed*2>=X.get(a).all);if(s){let a=[...new Set(s)].filter(o=>e.has(o)),O=new Set(a),G=new Map;for(let o of d){let l=O.has(o)?null:x(o,O);l!==null&&G.set(l,[...G.get(l)??[],o])}let et="the blocks named",$t=new Set([...a,...[...G.values()].flat()]),yt=!!n&&typeof n.page=="string"&&typeof r=="string"&&n.page!==r,xt=new Set([...C.filter(o=>e.get(o).card||h.has(o)),...gt]),bt=!n||yt?d.filter(o=>e.get(o).card&&!C.includes(o)):[],Ft=new Set([...xt,...bt]),Nt=[...C,...gt.filter(o=>!H.has(o))].sort((o,l)=>$.get(o)-$.get(l)).filter(o=>!$t.has(o)&&x(o,xt)===null),Tt=Nt.filter(o=>m.has(o)),t={changed:Nt.filter(o=>!m.has(o)),...Tt.length?{restyled:Tt,packages:[...new Set(Tt.map(o=>e.get(o).package))]}:{},cards:bt.filter(o=>!$t.has(o)&&x(o,Ft)===null).sort((o,l)=>e.get(o).rank-e.get(l).rank||$.get(o)-$.get(l)),since:n?xe(n):"",first:!n};return{...w,ids:a,why:et,groups:[{kind:"named",why:et,ids:a,rest:[]}],held:G,pageChanged:yt,changed:new Set(C),restyled:U,left:t,unknown:[...new Set(s)].filter(o=>!e.has(o))}}if(e.size===0)return{...w,ids:[],why:"the document has no block ids (never handed in): the whole page in tiles instead",tiles:!0};if(c)return{...w,ids:[],why:null,tiles:!0};let p=(...a)=>(O,G)=>a.reduce((et,$t)=>et||$t(O)-$t(G),0),A=a=>e.get(a).rank,J=a=>$.get(a),Q=n?xe(n):"",k=!!n&&typeof n.page=="string"&&typeof r=="string"&&n.page!==r,v=d.filter(a=>e.get(a).card&&!C.includes(a)),F=!n||k||C.length===0?v:v.filter(a=>D.has(a)),tt=new Set([...C.filter(a=>e.get(a).card||h.has(a)),...gt]),ct=new Set([...tt,...F]),nt=new Map,at=(a,O)=>a.filter(G=>{let et=x(G,O);return et!==null&&nt.set(et,[...nt.get(et)??[],G]),et===null}),_=[...at(C,tt),...gt.filter(a=>!H.has(a)&&x(a,tt)===null)].sort(p(a=>+!h.has(a),A,J)),ft=_.filter(a=>m.has(a)),dt=_.filter(a=>!m.has(a)),it=at(F,ct).sort(p(a=>+!D.has(a),A,J)),rt="the cards (chart cards, code blocks, whole blocks, components, flowcharts and Sheet areas, then columns and the other figures, then tables)",b=it.some(a=>D.has(a))?", those no look has pictured yet first":"",z=typeof n?.page=="string"&&typeof r=="string",P=n?k?`${rt.replace("the cards","the cards, not changed themselves")}${b}: the document's own <script> or <style> changed since ${Q}, which may draw any of them`:C.length?"the cards no look has pictured yet (not changed themselves)":`${rt}${b}: no block changed since ${Q}${z?", nor the document's own <script> or <style>":""}`:`${rt}: no earlier look to compare with`,K=[...dt.length?[{kind:"changed",why:`the blocks changed since ${Q}${h.size?" (a moved block pictured with the edges of the blocks before and after it, the moved ones first)":""}`,all:dt}]:[],...ft.length?[{kind:"changed",why:`the instances of a package changed since ${Q} (${[...new Set(ft.map(a=>e.get(a).package))].join(", ")})`,all:ft}]:[],...it.length||!_.length?[{kind:"cards",why:P,all:it}]:[]],R=Ee;for(let a of K)a.ids=a.all.slice(0,R),a.rest=a.all.slice(a.ids.length),R-=a.ids.length,delete a.all;let I=K.flatMap(a=>a.ids),i=a=>{let{parent:O,at:G}=e.get(a),et=$t=>d.find(yt=>e.get(yt).parent===O&&e.get(yt).at===G+$t)??null;return[et(-1),et(1)]},T=new Map(I.filter(a=>h.has(a)).map(a=>[a,i(a)])),N=new Map(I.filter(a=>nt.has(a)).map(a=>[a,nt.get(a)]));return{...w,ids:I,why:K[0].why,groups:K,rest:K.flatMap(a=>a.rest),moved:new Set(I.filter(a=>h.has(a))),around:T,held:N,cards:F,pageChanged:k,changed:new Set(C),restyled:U}}function fo(e){let n=m=>!!m.closest("[data-doc-dev]"),s=[...document.querySelectorAll("details")].filter(m=>!n(m)),c=s.filter(m=>!m.open).length;s.forEach(m=>{m.open||m.setAttribute("data-qa-closed",""),m.open=!0});let r=[...document.images].filter(m=>!n(m));r.forEach(m=>{m.loading==="lazy"&&(m.loading="eager")});let u=[...document.querySelectorAll("dialog")].filter(m=>!n(m)&&!m.open);u.forEach((m,C)=>{m.dataset.qaCard=String(C)});let w=m=>m.parentElement?.closest("dialog[data-qa-card]")??null,d=[...document.querySelectorAll("[data-doc-sheets] > .doc-sheet-tabs > [data-sheet-tab]")].filter(m=>!n(m));d.forEach((m,C)=>{m.dataset.qaTab=String(C)});let $=m=>m.parentElement.parentElement,h=m=>{let C=[];for(let D=m.closest("[data-doc-sheet]");D;D=D.parentElement.closest("[data-doc-sheet]")){let x=d.find(H=>$(H)===D.parentElement&&H.getAttribute("data-sheet-tab")===D.getAttribute("data-doc-sheet"));x&&C.unshift(Number(x.dataset.qaTab))}return C},q=d.map((m,C)=>{let D=[...h($(m)),C],x=[...$(m).children].find(M=>M.getAttribute("data-doc-sheet")===m.getAttribute("data-sheet-tab"));x&&(x.dataset.qaPanel=String(C));let H=w(m);return{index:C,chain:D,card:H?Number(H.dataset.qaCard):null,label:(m.textContent??"").replace(/\s+/g," ").trim(),shown:D.every(M=>d[M].getAttribute("aria-selected")==="true"),panel:!!x}}),L=u.map((m,C)=>{let D=`[href="#${CSS.escape(m.id)}"]`,x=[...m.querySelectorAll("h1, h2, h3, h4")].find(M=>M.textContent.trim())??document.querySelector(D),H=[];for(let M=w(m);M;M=w(M))H.unshift(Number(M.dataset.qaCard));return{index:C,chain:h(m),within:H,label:(x?.textContent||m.id||"").replace(/\s+/g," ").trim()}}),U=Promise.all(r.map(m=>m.decode().catch(()=>{})));return Promise.race([U.then(()=>!0),new Promise(m=>setTimeout(()=>m(!1),e))]).then(m=>({details:s.length,closed:c,images:r.length,loaded:m,sheets:q,cards:L}))}function ye(e){let n=document.querySelector(`[data-qa-card="${e}"]`);return n?(n.open||(globalThis.DocDialogs?globalThis.DocDialogs.open(n,null):typeof n.showModal=="function"?n.showModal():n.setAttribute("open","")),document.activeElement?.blur?.(),Promise.all(n.getAnimations({subtree:!0}).map(s=>s.finished.catch(()=>{}))).then(()=>n.open&&n.getClientRects().length>0)):Promise.resolve(!1)}function _t(e){let n=document.querySelector(`[data-qa-card="${e}"]`);n?.open&&(globalThis.DocDialogs?globalThis.DocDialogs.close(n):typeof n.close=="function"?n.close():n.removeAttribute("open"))}async function uo({selector:e,up:n=0,margin:s=0,frames:c=2}){let r=document.querySelector(e);for(let v=0;v<n&&r;v++)r=r.parentElement;if(!r||r.getClientRects().length===0)return null;let u=r.getBoundingClientRect();r.scrollIntoView({block:"nearest",inline:"nearest"});let w=r.getBoundingClientRect();if(u.top!==w.top||u.left!==w.left){let v=()=>new Promise(Y=>{requestAnimationFrame(()=>Y()),setTimeout(Y,100)});for(let Y=0;Y<c;Y++)await v()}let d=v=>v===document.body||v===document.documentElement,$=(v,Y,F)=>{let{left:tt,top:ct,right:nt,bottom:at}=v;for(let _=Y;_&&!d(_);_=_.parentElement){let ft=getComputedStyle(_),dt=ft.overflowX!=="visible",it=ft.overflowY!=="visible";if(dt||it){let rt=_.getBoundingClientRect();dt&&([tt,nt]=[Math.max(tt,rt.left),Math.min(nt,rt.right)]),it&&([ct,at]=[Math.max(ct,rt.top),Math.min(at,rt.bottom)])}if(_===F)break}return nt>tt&&at>ct?{left:tt,top:ct,right:nt,bottom:at}:null},h=v=>parseFloat(v)||0,q=(v,Y)=>{let F=getComputedStyle(v,Y);if(["none","normal"].includes(F.content)||F.display==="none"||!["absolute","fixed"].includes(F.position))return null;let tt=F.position==="fixed"?null:getComputedStyle(v).position!=="static"?v:v.offsetParent,ct=tt?tt.getBoundingClientRect():{left:0,top:0,right:innerWidth,bottom:innerHeight},nt=tt?getComputedStyle(tt):null,at={left:ct.left+h(nt?.borderLeftWidth),top:ct.top+h(nt?.borderTopWidth),right:ct.right-h(nt?.borderRightWidth),bottom:ct.bottom-h(nt?.borderBottomWidth)},_=(b,z)=>F.boxSizing==="border-box"?0:h(F[`padding${b}`])+h(F[`padding${z}`])+h(F[`border${b}Width`])+h(F[`border${z}Width`]),ft=h(F.width)+_("Left","Right"),dt=h(F.height)+_("Top","Bottom"),it=F.left!=="auto"?at.left+h(F.left)+h(F.marginLeft):F.right!=="auto"?at.right-h(F.right)-h(F.marginRight)-ft:null,rt=F.top!=="auto"?at.top+h(F.top)+h(F.marginTop):F.bottom!=="auto"?at.bottom-h(F.bottom)-h(F.marginBottom)-dt:null;return it===null||rt===null||!(ft>0)||!(dt>0)?null:$({left:it,top:rt,right:it+ft,bottom:rt+dt},v,r)},L=[r.getBoundingClientRect()],U=[r];for(let v of r.querySelectorAll("*"))v instanceof SVGElement&&v.ownerSVGElement||v.matches("script, style, template")||v.getClientRects().length===0||getComputedStyle(v).visibility!=="hidden"&&(U.push(v),L.push($(v.getBoundingClientRect(),v.parentElement,r)));for(let v of U)L.push(q(v,"::before"),q(v,"::after"));let m=document.createRange(),C=document.createTreeWalker(r,NodeFilter.SHOW_TEXT);for(let v=C.nextNode();v;v=C.nextNode())if(!(!v.nodeValue.trim()||!v.parentElement||v.parentElement.closest("svg, script, style, template"))){m.selectNodeContents(v);for(let Y of m.getClientRects())L.push($(Y,v.parentElement,r))}m.detach();let D=L.filter(Boolean),x={left:Math.min(...D.map(v=>v.left)),top:Math.min(...D.map(v=>v.top)),right:Math.max(...D.map(v=>v.right)),bottom:Math.max(...D.map(v=>v.bottom))},H=$(x,r.parentElement,null)??x,M=!1;for(let v=r;v&&!M;v=v.parentElement)M=getComputedStyle(v).position==="fixed";let Z=visualViewport.pageLeft,X=visualViewport.pageTop,[gt,p]=M?[Z+innerWidth,X+innerHeight]:[document.documentElement.scrollWidth,document.documentElement.scrollHeight],A=Math.max(M?Z:0,H.left+Z-s),J=Math.max(M?X:0,H.top+X-s),Q=Math.min(gt,H.right+Z+s),k=Math.min(p,H.bottom+X+s);return Q>A&&k>J?{clip:{x:A,y:J,width:Q-A,height:k-J},fixed:M}:null}function be(e){for(let s of e){let c=document.querySelector(`[data-qa-tab="${s}"]`);c&&c.getAttribute("aria-selected")!=="true"&&c.click()}let n=document.querySelector(`[data-qa-panel="${e.at(-1)}"]`);return!!(n&&!n.hidden&&n.getClientRects().length>0)}function Dt({scope:e,next:n,ignored:s=[],place:c,slack:r=4,whole:u=[],drawn:w=[]}){let d=e?document.querySelector(e):document.body,$=[];if(!d)return{found:$,next:n};let h=document.documentElement.clientWidth,q=Math.round,L=t=>String(t??"").replace(/\s+/g," ").trim(),U=(t,o=32)=>{let l=L(t);return`"${l.length>o?`${l.slice(0,o-1)}\u2026`:l}"`},m=t=>!!t.closest?.("[data-doc-dev]"),C=t=>{if(!t.isConnected||t.getClientRects().length===0)return!1;for(let o=t;o&&o.nodeType===1;o=o.parentElement){let l=getComputedStyle(o);if(l.visibility==="hidden"||l.display==="none"||Number(l.opacity)===0||o.matches(".katex-mathml, .sr-only, [role=tooltip], [data-doc-dev]"))return!1}return!0},D=t=>`${t.localName}${[...t.classList].filter(o=>!o.startsWith("is-")).slice(0,2).map(o=>`.${o}`).join("")}`,x=t=>(t.textContent??"").replace(/\s+/g,"").slice(0,120),H=new Map,M=t=>{let o=x(t);if(!H.has(t.localName)){let y=new Map;for(let B of document.getElementsByTagName(t.localName)){if(m(B))continue;let j=x(B);y.has(j)||y.set(j,[]),y.get(j).push(B)}H.set(t.localName,y)}let l=H.get(t.localName).get(o)?.indexOf(t)??0;return{tag:t.localName,words:o,nth:Math.max(0,l),text:L(t.textContent).slice(0,80)}},Z=t=>{let o=t.cloneNode(!0);for(let l of o.querySelectorAll(".doc-tab"))l.before(" \xB7 ");return L(o.textContent).replace(/^· /,"")},X=t=>{let o=t.matches("table")?t:t.querySelector("table"),l=t.closest(".doc-table-wrap")??t,y=l.getAttribute("data-doc-chart-source")?.trim(),j=(y?[...document.querySelectorAll("[data-doc-chart-data]")].find(S=>S.getAttribute("data-doc-chart-data").trim()===y&&!m(S)):null)?.closest("figure")?.querySelector(":scope > h2, :scope > h3, :scope > h4, :scope > figcaption"),f=l.previousElementSibling;return L(o?.caption?.textContent)||L(j?.textContent)||(f?.matches("p.doc-note")?Z(f):"")||L(o?.querySelector("th")?.textContent??o?.rows[0]?.cells[0]?.textContent)},gt=t=>{let o=t.nodeType===1?t:t.parentElement,l=[],y=[];for(let g=o;g&&g!==document.documentElement;g=g.parentElement)g.hasAttribute("data-block-id")&&l.push(g.getAttribute("data-block-id")),g.id&&!g.hasAttribute("data-qa-tab")&&!g.hasAttribute("data-qa-panel")&&y.push(g.id);let B=[];for(let g=o,W=0;g&&W<4&&!g.matches("body, main, section, [data-doc-sheet], [data-doc-sheets], .doc-columns, .doc-column");g=g.parentElement,W++){let ot=M(g);ot.words.length>=2&&B.push(ot)}let j=o.closest("figure")?.querySelector(":scope > h3, :scope > figcaption, :scope > .doc-figure-caption"),f=o.closest(".doc-table-wrap, table"),S=f?.querySelector("th"),E=o.closest("section")?.querySelector(":scope > h2, :scope > h3, :scope > h4");return{blocks:l,ids:y,texts:B,tag:o.localName,element:D(o),card:j?M(j):null,header:S?M(S):null,table:f?X(f).slice(0,80):null,section:E?M(E):null}};if(c){let t=document.querySelector(c);return{found:$,next:n,anchor:t?gt(t):null}}let p=t=>(t.dataset.qaShot||(t.dataset.qaShot=String(++n)),Number(t.dataset.qaShot)),A=(t,o,l,{picture:y=o,url:B,measured:j,scroll:f,level:S}={})=>$.push({kind:t,what:l,anchor:o?gt(o):null,shot:y?p(y):null,seen:!!(y&&C(y)),url:B,measured:j,scroll:f,...S?{level:S}:{}}),J=t=>t.closest("figure")??t.closest("[data-doc-chart]")??t,Q=t=>{let o=t.getBoundingClientRect();return o.width>0&&o.height>0},k=(t,o,{x:l=!0,y=!0}={})=>Math.max(l?o.left-t.left:-1/0,l?t.right-o.right:-1/0,y?o.top-t.top:-1/0,y?t.bottom-o.bottom:-1/0),v=t=>({left:Math.min(...t.map(o=>o.x)),right:Math.max(...t.map(o=>o.x)),top:Math.min(...t.map(o=>o.y)),bottom:Math.max(...t.map(o=>o.y))}),Y=t=>{let o=t.getBBox(),l=t.getScreenCTM();return v([[o.x,o.y],[o.x+o.width,o.y],[o.x+o.width,o.y+o.height],[o.x,o.y+o.height]].map(([y,B])=>new DOMPoint(y,B).matrixTransform(l)))},F=t=>{let o=[];for(let l=t.parentElement;l&&l!==document.documentElement;l=l.parentElement){let y=getComputedStyle(l);l instanceof SVGSVGElement&&y.overflow!=="visible"&&o.push(["the svg's edge",l.getBoundingClientRect(),{}]);let B=/url\(\s*["']?#([^)"']+)/.exec(`${l.getAttribute?.("clip-path")??""} ${y.clipPath??""}`)?.[1],j=B?document.getElementById(B):null,f=j?.getAttribute("clipPathUnits")!=="objectBoundingBox"?j?.querySelector("rect"):null;if(f&&l.getScreenCTM){let[S,E,g,W]=["x","y","width","height"].map(ot=>f[ot].baseVal.value);o.push(["a clip-path",v([[S,E],[S+g,E+W]].map(([ot,lt])=>new DOMPoint(ot,lt).matrixTransform(l.getScreenCTM()))),{}])}if(!(l instanceof SVGElement)){let S=/hidden|clip/.test(y.overflowX),E=/hidden|clip/.test(y.overflowY);(S||E)&&o.push([D(l),l.getBoundingClientRect(),{x:S,y:E}])}}return o},tt=t=>`${t.slice(0,4).join("; ")}${t.length>4?`; ${t.length-4} more`:""}`,ct=t=>!t.matches("script, [data-doc-dev]")&&(t.matches("svg, canvas")||t.querySelector("svg, canvas")||C(t)&&Q(t));for(let t of d.querySelectorAll("[data-doc-chart]"))m(t)||!C(t)||[...t.children].some(ct)||A("chart-empty",t,`the ${t.getAttribute("data-doc-chart")||"chart"} chart drew nothing`,{picture:J(t)});let nt=[...d.querySelectorAll("svg")].filter(t=>{if(t.parentElement.closest("svg")||m(t)||t.closest(".katex, .doc-icon, button")||!C(t))return!1;let o=t.getBoundingClientRect();return t.closest("[data-doc-chart], figure")||o.width>=120&&o.height>=60}),at={across:.6,down:.25},_=new Map;for(let t of nt){let o=J(t),l=o.getBoundingClientRect(),y=[],B=[],j=[...t.querySelectorAll("text")].filter(E=>!E.closest("defs, clipPath, mask, pattern, marker, symbol")&&L(E.textContent)&&C(E));for(let E of j){let g=Y(E),W=F(E).map(([ot,lt,ut])=>[ot,k(g,lt,ut)]).find(([,ot])=>ot>1.5);W?y.push(`${U(E.textContent,24)} ${q(W[1])}px past ${W[0]}`):k(g,l)>1.5&&B.push(`${U(E.textContent,24)} ${q(k(g,l))}px past the card's edge`)}y.length&&A("chart-text-clipped",t,tt(y),{picture:o}),B.length&&A("chart-text-outside",t,tt(B),{picture:o});let f=E=>{let g=/^(-?)[$¥€£]?(\d[\d,]*(?:\.\d+)?)\s*(?:%|‰|[kKMBG]|万|亿)?$/.exec(E.replace(/[−–]/g,"-"));return g?+`${g[1]}${g[2].replace(/,/g,"")}`:NaN},S=E=>E.every(Number.isFinite)&&E[1]!==E[0]&&E.slice(2).every((g,W)=>Math.abs(g-E[W+1]-(E[1]-E[0]))<=1e-9*Math.max(1,Math.abs(g)));for(let E of t.querySelectorAll("g")){let g=[...E.children].filter(V=>V.matches("g.tick")&&C(V)),W=g.map(V=>V.querySelector("text")).filter(V=>V&&L(V.textContent)&&C(V)),ot=W.map(V=>L(V.textContent));if(ot.length<2||ot.length!==g.length||!S(ot.map(f)))continue;let lt=W.map(V=>{let kt=V.getScreenCTM(),Ne=(parseFloat(getComputedStyle(V).fontSize)||0)*(kt?Math.hypot(kt.c,kt.d):1);return{label:V,box:Y(V),size:Ne,turned:!!kt&&Math.abs(kt.b)>.001*Math.abs(kt.a)}});if(lt.some(V=>V.turned||!(V.size>0)))continue;let ut=lt.map(({box:V})=>[(V.left+V.right)/2,(V.top+V.bottom)/2]),st=Math.max(...ut.map(([V])=>V))-Math.min(...ut.map(([V])=>V))>=Math.max(...ut.map(([,V])=>V))-Math.min(...ut.map(([,V])=>V)),mt=({box:V,size:kt})=>st?[V.left,V.right]:[(V.top+V.bottom-kt)/2,(V.top+V.bottom+kt)/2],St=[...lt].sort((V,kt)=>mt(V)[0]-mt(kt)[0]),wt=null;for(let V=1;V<St.length;V++){let kt=mt(St[V])[0]-mt(St[V-1])[1];(!wt||kt<wt.gap)&&(wt={gap:kt,pair:[St[V-1],St[V]]})}let Ct=Math.max(...lt.map(V=>V.size));if(!wt||wt.gap>=at[st?"across":"down"]*Ct)continue;for(let{label:V}of lt)_.set(V,E);let[Bt,Et]=wt.pair.map(({label:V})=>U(V.textContent,16)),Te=wt.gap<0?`${Bt} and ${Et} overlapping by ${q(-wt.gap)}px`:`${Bt} and ${Et} ${q(wt.gap)}px apart`;A("ticks",t,`${ot.length} tick labels ${st?"across":"down"} a ${q(st?t.getBoundingClientRect().width:t.getBoundingClientRect().height)}px chart crowd: ${Te}, under ${st?"a digit's width and a hair":"a quarter of a line"} at their ${q(Ct)}px (${ot.slice(0,6).join(", ")}${ot.length>6?", \u2026":""})`,{picture:o})}}let ft=t=>{let o=t.getBBox(),l=t instanceof SVGTextElement&&parseFloat(getComputedStyle(t).fontSize)||o.height,y=o.y+Math.max(0,(o.height-l)/2),B=y+Math.min(o.height,l),j=t.getScreenCTM();return[[o.x,y],[o.x+o.width,y],[o.x+o.width,B],[o.x,B]].map(([f,S])=>new DOMPoint(f,S).matrixTransform(j))},dt=(t,o)=>{let l=1/0;for(let y of[t,o])for(let B=0;B<y.length;B++){let j=y[B],f=y[(B+1)%y.length],S=Math.hypot(f.x-j.x,f.y-j.y);if(S===0)continue;let E={x:-(f.y-j.y)/S,y:(f.x-j.x)/S},g=ut=>ut.map(st=>st.x*E.x+st.y*E.y),[W,ot]=[g(t),g(o)],lt=Math.min(Math.max(...W),Math.max(...ot))-Math.max(Math.min(...W),Math.min(...ot));if(lt<=0)return 0;l=Math.min(l,lt)}return l===1/0?0:l},it=t=>[...t.querySelectorAll("text")].filter(o=>!o.closest("defs, clipPath, mask, pattern, marker, symbol")&&L(o.textContent)&&C(o));for(let t of nt){let o=it(t).map(y=>({label:y,outline:ft(y)})),l=[];o.forEach(({label:y,outline:B},j)=>{for(let f of o.slice(j+1))_.has(y)&&_.get(y)===_.get(f.label)||dt(B,f.outline)>1.5&&l.push(`${U(y.textContent,20)} and ${U(f.label.textContent,20)} overlap`)}),l.length&&A("chart-text-overlap",t,tt(l),{picture:J(t)})}let rt=11;for(let t of nt){if(!t.hasAttribute("viewBox"))continue;let o=[];for(let B of it(t)){let j=B.getScreenCTM(),f=parseFloat(getComputedStyle(B).fontSize);if(!j||!(f>0))continue;let S=f*Math.hypot(j.c,j.d);S<rt-.05&&o.push(`${U(B.textContent,24)} at ${S.toFixed(1)}px (font-size ${+f.toFixed(2)})`)}if(!o.length)continue;let l=t.viewBox.baseVal,y=`${o.length} text${o.length>1?"s":""}`;A("svg-text-small",t,`${y} of a drawing scaled by its viewBox (${+l.width.toFixed(2)}\xD7${+l.height.toFixed(2)} drawn ${q(t.getBoundingClientRect().width)}px wide) render below ${rt}px: ${tt(o)}`,{picture:J(t)})}let b=new Set;for(let t of d.querySelectorAll(".doc-table-wrap")){if(m(t)||!C(t))continue;b.add(t);let o=t.querySelector("table");if(!o)continue;let l=Math.max(t.clientWidth,o.offsetWidth),y=Math.max(t.clientHeight,o.offsetHeight),B=l>t.clientWidth+r,j=y>t.clientHeight+r,f=X(t);(B||j)&&A("table-scrolls",t,[B&&`${l}px wide in a ${t.clientWidth}px frame`,j&&`${y}px tall in a ${t.clientHeight}px frame`].filter(Boolean).join(", "),{scroll:{sideways:B,down:j,name:f}});let S=globalThis.__qaTableHides(t,o);S.said&&A("table-columns",t,`${S.said}: the table is ${l}px wide in a ${t.clientWidth}px frame`),S.shown<S.rows&&!t.style.getPropertyValue("--doc-table-height")&&A("table-rows",t,`the frame shows ${S.shown} of ${S.rows} rows: a reader scrolls inside it for the other ${S.rows-S.shown}; style="--doc-table-height: none" on its div.doc-table-wrap shows every row (or split the table where its content divides)`)}let z=t=>!!t.closest("details[data-qa-closed]"),P="in a disclosure closed in the file: a reader who opens it scrolls";for(let t of d.querySelectorAll(".doc-code, .doc-diff")){if(m(t)||!C(t))continue;let o=t.querySelector(":scope > pre, :scope > .doc-diff-body");if(o&&C(o)){let y=z(t);if(o.scrollHeight>o.clientHeight+r){let B=[t,o].map(E=>E.style.getPropertyValue("--doc-code-height").trim()).find(Boolean),j=o.getBoundingClientRect().top+o.clientTop+o.clientHeight,f=[...o.querySelectorAll(".doc-code-line")].filter(E=>E.getClientRects().length>0&&E.getBoundingClientRect().top>=j-1).length,S=y?`, ${P} inside it for the rest`:B?`, the block's own height (--doc-code-height: ${B}, the author's or the reader's): a reader scrolls inside it for the rest`:": a reader scrolls inside it for the rest";A("code-scrolls",t,`the code is ${o.scrollHeight}px tall, its frame ${o.clientHeight}px${f?` (its last ${f} line${f===1?"":"s"} below it)`:""}${S}`,{level:y||B?"info":void 0})}if(o.scrollWidth>o.clientWidth+r){let B=t.classList.contains("doc-code--nowrap"),j=y?`, ${P} sideways for the rest`:B?", its lines left unwrapped (doc-code--nowrap, the author's or the reader's choice): a reader scrolls sideways for the rest of its long lines":": a reader scrolls sideways for the rest";A("code-scrolls",t,`the code is ${o.scrollWidth}px wide, its frame ${o.clientWidth}px${j}`,{level:y||B?"info":void 0})}}let l=t.querySelector(":scope > .doc-code-title");l&&C(l)&&l.scrollWidth>l.clientWidth+1&&A("code-title-cut",t,`its title ${U(l.textContent,48)} is cut to fit its header (${l.scrollWidth}px of words in ${l.clientWidth}px)`)}for(let t of d.querySelectorAll(".doc-math-block")){if(m(t)||!C(t)||t.scrollWidth<=t.clientWidth+r)continue;let o=z(t);A("formula-scrolls",t,`the formula is ${t.scrollWidth}px wide, its frame ${t.clientWidth}px${o?`, ${P} it sideways for the rest`:": a reader scrolls it sideways for the rest"}`,{level:o?"info":void 0})}for(let t of d.querySelectorAll("[data-doc-layout]"))m(t)||!C(t)||A("layout",t,t.getAttribute("data-doc-layout"),{picture:t.closest("figure, .doc-table-wrap")??t,measured:b.has(t)});let K=document.createTreeWalker(d,NodeFilter.SHOW_TEXT),R=new Map;for(let t=K.nextNode();t;t=K.nextNode()){if(!/\\\(|\\\[|\$\$/.test(t.nodeValue))continue;let o=t.parentElement;if(!o||o.closest([...s,".katex","[data-doc-dev]"].join(", "))||!C(o))continue;let l=o.closest("p, li, h1, h2, h3, h4, td, th, figcaption, summary, blockquote, dd, dt")??o;R.has(l)||R.set(l,t.nodeValue)}for(let[t,o]of R){let l=o.search(/\\\(|\\\[|\$\$/);A("raw-formula",t,`${U(o.slice(l,l+40),40)} is shown as written: the kit's math did not render it`)}for(let t of d.querySelectorAll(".katex-error"))m(t)||!C(t)||A("formula-error",t,`${U(t.textContent,32)}: ${L(t.getAttribute("title"))||"KaTeX could not read it"}`);let I=t=>`"${globalThis.__qaUrlName?.(t,document.baseURI)??t}"`,i=t=>{try{return new URL(t,document.baseURI).href}catch{return t}},T=t=>[...["src","href","poster","data"].filter(o=>t.hasAttribute(o)&&!(o==="href"&&t.matches("a, area"))).map(o=>t.getAttribute(o)),...(t.getAttribute("srcset")??"").split(",").map(o=>o.trim().split(/\s+/)[0]),...[t.getAttribute("style"),t.localName==="style"?t.textContent:""].flatMap(o=>[...String(o??"").matchAll(/url\(\s*["']?([^"')]+)/g)].map(l=>l[1]))].filter(o=>o&&!o.trim().startsWith("#")).map(i),N=[...document.querySelectorAll("*")].filter(t=>!m(t)).flatMap(t=>T(t).map(o=>({node:t,address:o}))),a=new Set;for(let{url:t,directive:o}of globalThis.__qaViolations??[]){let l=/^[a-z][a-z\d+.-]*$/i.test(t)?`${t.toLowerCase()}:`:null,y=N.find(j=>l?!a.has(j)&&j.address.startsWith(l):j.address===t);y&&l&&a.add(y);let B=y?.node??null;e&&!(B&&d.contains(B))||A("blocked",B,`${o} blocked ${I(y?.address??t)}${B?` (${D(B)})`:""}: the export holds every file it shows`,{url:y?.address??t})}for(let t of d.querySelectorAll("img")){if(m(t)||t.complete&&t.naturalWidth>0)continue;let o=t.currentSrc||t.src?i(t.currentSrc||t.src):"";A("image",t,`${o?I(o):"a picture with no src"} did not load`,{picture:t.closest("figure")??t,url:o})}let O=new Set(u),G=new Set(w),et=document.createRange(),$t="button, select, input, textarea, [data-doc-dev]",yt=(t,o)=>t!==o&&(t.matches($t)||[...t.classList].some(l=>l.startsWith("doc-"))),xt=(t,o,l)=>{let y=[],B=!1;for(let j=t,f=!0;j&&j!==document.body&&j!==document.documentElement;j=j.parentElement,f=!1){let S=getComputedStyle(j);if((!f||l)&&(B&&(S.position!=="static"||S.transform!=="none")&&(B=!1),!B)){if(/auto|scroll/.test(S.overflowY))break;/hidden|clip/.test(S.overflowY)&&!yt(j,o)&&y.push(j)}if(S.position==="fixed")break;S.position==="absolute"&&(B=!0)}return y},bt=t=>t.getBoundingClientRect().bottom-(parseFloat(getComputedStyle(t).borderBottomWidth)||0),Ft=t=>{let o=getComputedStyle(t),l=y=>!/^(transparent|rgba\(.*,\s*0\))$/.test(y);return l(o.backgroundColor)||o.backgroundImage!=="none"||["Top","Right","Bottom","Left"].some(y=>parseFloat(o[`border${y}Width`])>0&&o[`border${y}Style`]!=="none"&&l(o[`border${y}Color`]))},Nt="rect, circle, ellipse, line, polyline, polygon, path, use",Tt=(t,o)=>{let l=new Map,y=(f,S,E,g)=>{if(!l.has(f)&&l.size>=3)return;let W=l.get(f)??{words:[],marks:[],depth:0,height:f.getBoundingClientRect().height};E&&W.words.push(E),g&&W.marks.push(g),W.depth=Math.max(W.depth,S),l.set(f,W)},B=f=>f.getBoundingClientRect().height>1.5,j=document.createTreeWalker(t,NodeFilter.SHOW_TEXT);for(let f=j.nextNode();f;f=j.nextNode()){let S=f.parentElement;if(!f.nodeValue.trim()||!S||S.closest("svg, script, style, template, .katex")||!C(S)||o(S))continue;let E=xt(S,t,!0).filter(B);if(E.length===0)continue;let g=getComputedStyle(S),W=parseFloat(g.lineHeight);for(let ot of f.nodeValue.matchAll(/\S+/g)){let lt=ot.index+ot[0].length;et.setStart(f,ot.index),et.setEnd(f,lt);let ut=[...et.getClientRects()];for(let st of ut){let mt=Number.isFinite(W)?Math.max(0,(st.height-W)/2):0,St=E.find(Ct=>st.bottom-bt(Ct)>1.5+mt);if(!St)continue;let wt=ot.index;if(ut.length>1){let Ct=bt(St)+1.5+mt;for(let Bt=lt-1;wt<Bt;){let Et=wt+Bt>>1;et.setStart(f,Et),et.setEnd(f,Et+1),(et.getClientRects()[0]?.bottom??0)>Ct?Bt=Et:wt=Et+1}}y(St,Math.max(...ut.map(Ct=>Ct.bottom))-bt(St),f.nodeValue.slice(wt,lt),null);break}}}for(let f of t.querySelectorAll("*")){let S=f instanceof SVGElement&&f.matches(Nt)&&!f.closest("defs, clipPath, mask, pattern, marker, symbol"),E=!S&&!(f instanceof SVGElement)&&!f.matches("img, picture, video, canvas, iframe, object, embed, script, style, template")&&f.children.length===0&&!f.textContent.trim()&&Ft(f);if(!S&&!E||!C(f))continue;let g=f.getBoundingClientRect();if(g.width<=0&&g.height<=0)continue;let W=S?f.ownerSVGElement:null,ot=[...W&&getComputedStyle(W).overflowY!=="visible"?[W]:[],...xt(W??f,t,!!W)].filter(B),lt=st=>{let mt=st.getBoundingClientRect();return g.left>=mt.left-1.5&&g.right<=mt.right+1.5&&g.top>=mt.top-1.5},ut=ot.find(st=>g.bottom-bt(st)>1.5&&lt(st));ut&&y(ut,g.bottom-bt(ut),null,S?f.localName:D(f))}return l};for(let t of d.querySelectorAll("[data-block-id]")){let o=t.getAttribute("data-block-id"),l=G.has(o);if(!l&&!O.has(o)||m(t)||!C(t))continue;let y=f=>f.closest(".doc-chart-message")||f.closest("h2, h3, h4, p, figcaption")?.parentElement===t,B=new Map,j=document.createTreeWalker(t,NodeFilter.SHOW_TEXT);for(let f=j.nextNode();f&&B.size<3;f=j.nextNode()){let S=f.parentElement;if(!f.nodeValue.trim()||!S||S.closest("svg, script, style, template, .katex")||!C(S)||l&&y(S))continue;let E=S;for(;E!==t&&["inline","contents"].includes(getComputedStyle(E).display);)E=E.parentElement;let g=!1;for(let st=S;st&&!g;st=st===t?null:st.parentElement){let mt=getComputedStyle(st);g=mt.overflowX!=="visible"||mt.overflowY!=="visible"}if(g)continue;let W=getComputedStyle(E),ot=E.getBoundingClientRect(),lt=ot.left+parseFloat(W.borderLeftWidth)+parseFloat(W.paddingLeft),ut=ot.right-parseFloat(W.borderRightWidth)-parseFloat(W.paddingRight);for(let st of f.nodeValue.matchAll(/\S+/g)){et.setStart(f,st.index),et.setEnd(f,st.index+st[0].length);let mt=[...et.getClientRects()],St=Math.max(0,...mt.flatMap(Ct=>[Ct.right-ut,lt-Ct.left]));if(St<=1.5||mt.some(Ct=>Ct.right>h+1))continue;let wt=B.get(E)??{words:[],reach:0,width:ut-lt};wt.words.push(st[0]),wt.reach=Math.max(wt.reach,St),B.set(E,wt)}}for(let[f,{words:S,reach:E,width:g}]of B)A("overflow-in-block",f,`the words ${U(S.join(" "),40)} run ${q(E)}px past the side of ${D(f)} (${q(g)}px wide for its words), over what is beside it`,{picture:t});for(let[f,{words:S,marks:E,depth:g,height:W}]of Tt(t,l?y:()=>!1)){let ot=[S.length&&`the words ${U(S.join(" "),40)}`,E.length&&`${E.length===1?"a mark":`${E.length} marks`} (${[...new Set(E)].slice(0,3).join(", ")})`].filter(Boolean).join(" and "),lt=S.length===0&&E.length===1;A("cut-in-block",f,`${ot} ${lt?"reaches":"reach"} ${q(g)}px past the bottom of ${D(f)} (${q(W)}px tall, its overflow ${getComputedStyle(f).overflowY}), cut off there`,{picture:t})}}if(et.detach(),document.documentElement.scrollWidth>h+1){let t=g=>{for(let W=g.parentElement;W&&W!==document.body;W=W.parentElement)if(getComputedStyle(W).overflowX!=="visible")return!1;return g.nodeType!==1||getComputedStyle(g).position!=="fixed"},o=[...d.querySelectorAll("*")].filter(g=>!(g instanceof SVGElement&&g.ownerSVGElement)&&!m(g)&&g.getBoundingClientRect().right>h+1&&C(g)&&t(g)),l=o.filter(g=>!o.includes(g.parentElement)).slice(0,3),y=`the page is ${document.documentElement.scrollWidth}px wide in a ${h}px window`,B=new Set(o),j=g=>{for(let W=g.parentElement;W;W=W.parentElement)if(B.has(W))return!0;return!1},f=new Map,S=document.createRange(),E=document.createTreeWalker(d,NodeFilter.SHOW_TEXT);for(let g=E.nextNode();g&&f.size<3;g=E.nextNode()){let W=g.parentElement;if(!W||!g.nodeValue.trim()||W.closest("svg, script, style, template")||m(W)||j(g)||!C(W)||!t(g)||(S.selectNodeContents(g),![...S.getClientRects()].some(st=>st.right>h+1)))continue;let ot=W.closest("[data-block-id]")??W;if(f.has(ot))continue;let lt=[],ut=0;for(let st of g.nodeValue.matchAll(/\S+/g)){S.setStart(g,st.index),S.setEnd(g,st.index+st[0].length);let mt=Math.max(...[...S.getClientRects()].map(St=>St.right),0);mt<=h+1||(lt.push(st[0]),ut=Math.max(ut,mt))}lt.length&&f.set(ot,{node:W,words:lt.join(" "),right:ut})}S.detach(),l.length===0&&f.size===0&&!e&&A("overflow",null,y);for(let g of l)A("overflow",g,`${y}: ${D(g)} ${U(g.textContent,24)} reaches ${q(g.getBoundingClientRect().right)}px`);for(let[g,{node:W,words:ot,right:lt}]of f)A("overflow",W,`${y}: the words ${U(ot,60)} in ${D(g)} run past its edge to ${q(lt)}px (a text that cannot break)`,{picture:g})}return{found:$,next:n}}function po(){let e=s=>!!s.closest("[data-doc-dev]"),n=s=>[...document.querySelectorAll(s)].filter(c=>!e(c)).length;return{charts:n("[data-doc-chart]"),tables:n(".doc-table-wrap"),height:document.documentElement.scrollHeight}}var Ot=2e4,Se=1800;function ke(e,n,s){let c=0,r=new Promise((u,w)=>{c=setTimeout(()=>w(new Error(`${s}: no answer in ${n/1e3}s`)),n)});return Promise.race([e,r]).finally(()=>clearTimeout(c))}var Yt=e=>`${e.kind}|${JSON.stringify(e.anchor)}|${e.what}`;async function go(e,n,s,{out:c,tiles:r=!1,blocks:u=[],around:w=new Map,held:d=new Map,whole:$=[],drawn:h=[],known:q=null}){let{width:L,height:U=900,label:m=String(L)}=typeof s=="number"?{width:s}:s,C=m.replace("\xD7","x"),D=await e.createBrowserContext(),x=await D.newPage();x.setDefaultTimeout(Ot);let H=[],M=[],Z=new Set,X=new Map,gt=new Set,p=new Set,A=new Set,J="",Q=0,k=(b,z,P={})=>H.push({kind:b,what:z,anchor:null,shot:null,seen:!1,state:J,...P}),v=Pe(n).href,Y=b=>`"${$e(b,v)}"`,F=b=>c.folders?.get(b)??c.blocks,tt=b=>b.replace(/[^\w-]/g,"_");x.on("pageerror",b=>k("error",`uncaught ${It(b.message).slice(0,200)}`)),x.on("console",b=>{b.type()==="error"&&se(b,v)&&k("error",`console: ${It(b.text()).slice(0,200)}`)}),x.on("requestfailed",b=>{b.frame()===x.mainFrame()&&k("request",`${Y(b.url())}: ${b.failure()?.errorText??"failed"}`,{url:b.url()})}),x.on("response",b=>{b.status()>=400&&b.request().frame()===x.mainFrame()&&k("request",`${Y(b.url())}: HTTP ${b.status()}`,{url:b.url()})}),await ae(x),await x.evaluateOnNewDocument(`globalThis.__qaUrlName = ${$e}; globalThis.__qaTableHides = ${Ye()};`),await x.setViewport({width:L,height:U}),await x.emulateMediaFeatures([{name:"prefers-color-scheme",value:"light"}]);let ct=async b=>{for(let z of await re(x,{timeout:Ot}))k("unverified",`${b}: waited for ${z}`)},nt=async(b,z,P,K)=>ke(x.screenshot({path:P,clip:b,captureBeyondViewport:!z}),Ot,"the picture").then(()=>!0,R=>(k("unverified",`no picture of ${K} (${R.message})`),!1)),at=async(b,z,P,K=0)=>{let R=await x.evaluate(uo,{selector:b,up:K,margin:Qe,frames:Ze}).catch(I=>({error:I}));return R?.clip?await nt(R.clip,R.fixed,z,P)?R.clip:null:(k("unverified",`no picture of ${P} (${R?.error?.message??"the element is gone or shows nothing"})`),null)},_=(b,z)=>b.left<z.x+z.width&&b.right>z.x&&b.top<z.y+z.height&&b.bottom>z.y,ft=async()=>{let b=u.filter(P=>!gt.has(P)),z=await x.evaluate((P,K,R)=>{let I=new Map(P.map((O,G)=>[O,G])),i=O=>!!O&&!O.closest("[data-doc-dev], dialog:not([open])")&&O.getClientRects().length>0,T=O=>O===null?null:[...document.querySelectorAll("[data-block-id]")].find(G=>G.getAttribute("data-block-id")===O&&i(G))??null,N=O=>{if(!O)return null;let G=O.getBoundingClientRect();return{left:G.left+scrollX,right:G.right+scrollX,top:G.top+scrollY,bottom:G.bottom+scrollY}},a=[];for(let O of document.querySelectorAll("[data-block-id]")){let G=I.get(O.getAttribute("data-block-id"));if(G===void 0||!i(O))continue;I.delete(O.getAttribute("data-block-id")),O.setAttribute("data-qa-block",String(G));let[et,$t]=K[G]??[],yt=(R[G]??[]).map(xt=>[xt,[...O.querySelectorAll("[data-block-id]")].find(bt=>bt.getAttribute("data-block-id")===xt&&i(bt))]).filter(([,xt])=>xt);a.push({index:G,boxes:K[G]?{block:N(O),above:N(T(et)),below:N(T($t))}:null,held:yt.map(([xt,bt])=>({id:xt,box:N(bt)}))})}return a},b,b.map(P=>w.get(P)??null),b.map(P=>d.get(P)??[]));for(let{index:P,boxes:K,held:R}of z){let I=b[P];gt.add(I);let i=`${C}-${tt(I)}`,T=[];if(!K){let N=ht.join(F(I),`${i}.png`),a=await at(`[data-qa-block="${P}"]`,N,`the block ${I}`);a&&(M.push({block:I,file:N}),T.push(a))}for(let{part:N,clip:a}of K?eo(K):[]){let O=ht.join(F(I),`${i}${N?`-${N}`:""}.png`);await nt(a,!1,O,`the block ${I}${N?` (its ${N})`:""}`)&&(M.push({block:I,file:O}),T.push(a))}for(let{id:N,box:a}of R)T.some(O=>_(a,O))?p.add(N):p.has(N)||A.add(N);await x.evaluate(N=>document.querySelector(`[data-qa-block="${N}"]`)?.removeAttribute("data-qa-block"),P)}},dt=async(b,z,P)=>{let K=[...d].filter(([I])=>gt.has(I)).map(([I,i])=>[I,i.filter(T=>!p.has(T))]).filter(([,I])=>I.length);if(!K.length)return;let R=await x.evaluate((I,i)=>{let T=document.querySelector(I);if(!T)return[];let N=a=>[...T.querySelectorAll("[data-block-id]")].some(O=>O.getAttribute("data-block-id")===a&&O.getClientRects().length>0);return i.map(([a,O])=>[a,O.filter(N)]).filter(([,a])=>a.length)},b,K);for(let[I,i]of R){let T=ht.join(F(I),`${C}-${tt(I)}-${z}.png`);if(await at(b,T,`the block ${I} (${z})`,P)){M.push({block:I,part:z,file:T});for(let N of i)p.add(N),A.delete(N)}}},it=async b=>{let z=await x.evaluate(Dt,{scope:b,next:Q,ignored:Ve,slack:Je,whole:$,drawn:h});Q=z.next;let P=z.found.flatMap(R=>R.kind!=="layout"?[R]:Ge(R.what,L).filter(({kind:I})=>!(R.measured&&["table-columns","table-rows"].includes(I))).map(({kind:I,note:i})=>({...R,kind:I,what:`the kit notes ${i}`})));for(let R of P){let I=R.shot===null?null:`${R.kind}|${R.shot}|${R.what}`,i=I&&X.get(I);if(i)!i.seen&&R.seen&&Object.assign(i,R,{state:J});else{let T={...R,state:J};H.push(T),I&&X.set(I,T)}}let K=new Set(H.filter(R=>R.kind==="blocked").map(R=>R.url));for(let R of H){if(R.shot===null||!R.seen||Z.has(R.shot)||!Xe(R,L)||q?.has(Yt(R))||["request","image"].includes(R.kind)&&K.has(R.url))continue;Z.add(R.shot);let I=ht.join(c.flagged,`${C}-${String(R.shot).padStart(2,"0")}-${R.kind}.png`);await at(`[data-qa-shot="${R.shot}"]`,I,R.kind)&&M.push({shot:R.shot,file:I})}u.length&&await ft()},rt=b=>{let z=new Set(H.filter(K=>K.kind==="blocked").map(K=>K.url));return{findings:H.filter(K=>!(["request","image"].includes(K.kind)&&z.has(K.url))&&!q?.has(Yt(K))),counts:b,pictures:M,held:{covered:[...p],missed:[...A]}}};try{try{let i=new Promise(N=>x.once("domcontentloaded",N)),T=x.goto(v,{waitUntil:"load",timeout:6e4});if(T.catch(()=>{}),await Promise.race([i,T]),x.url()!==v)throw new Error(`the browser shows ${x.url()}`)}catch(i){return k("unverified",`the page did not load: ${i.message}`),rt(null)}await ct("the page as it opens");let b=await x.evaluate(fo,Ot);b.loaded||k("unverified",`the pictures (${b.images}) not all loaded in ${Ot/1e3}s`),b.closed&&await ct(`the page with its ${b.closed} closed disclosure${b.closed===1?"":"s"} opened`),await it(null);let z=async(i,T,N,a=null)=>{for(let O=i,G=1;O<T;O+=Se,G++){let et=ht.join(c.tiles,`${C}-${N}${String(G).padStart(2,"0")}.png`);await ke(x.screenshot({path:et,clip:{x:0,y:O,width:L,height:Math.min(Se,T-O)},captureBeyondViewport:!0}),Ot,"a tile").then(()=>M.push({tile:!0,sheet:a,file:et}),$t=>k("unverified",`no tile ${N}${G} (${$t.message})`))}};r&&await z(0,await x.evaluate(()=>document.documentElement.scrollHeight),"");let P=async(i,T=null)=>{if(!await x.evaluate(be,i.chain)){let{anchor:N}=await x.evaluate(Dt,{next:Q,place:`[data-qa-tab="${i.index}"]`});return k("unverified","this Sheet could not be shown: its tab was clicked and its panel stayed hidden",{anchor:N}),!1}if(await ct("the Sheet shown"),await it(`[data-qa-panel="${i.index}"]`),await dt(`[data-qa-panel="${i.index}"]`,`sheet${i.index+1}`,1),r&&T)await K(T,`sheet${i.index+1}-`);else if(r){let N=await x.evaluate(a=>{let O=document.querySelector(`[data-qa-panel="${a}"]`)?.getBoundingClientRect();return O&&O.height>0?{top:Math.max(0,O.top+scrollY),bottom:O.bottom+scrollY}:null},i.index);N&&await z(N.top,N.bottom,`sheet${i.index+1}-`,{number:i.index+1,label:i.label})}return!0},K=async(i,T="")=>{for(let N=1;N<=20;N++){let a=await x.evaluate((G,et)=>{let $t=document.querySelector(`[data-qa-card="${G}"]`),yt=$t?.querySelector(".doc-dialog-content")??$t;if(!yt)return null;if(et)yt.scrollTop=0;else{let bt=yt.scrollTop;if(yt.scrollTop+=Math.max(40,yt.clientHeight-24),yt.scrollTop===bt)return null}let xt=$t.getBoundingClientRect();return{x:xt.left+visualViewport.pageLeft,y:xt.top+visualViewport.pageTop,width:xt.width,height:xt.height}},i.index,N===1);if(!a)break;let O=ht.join(c.tiles,`${C}-card${i.index+1}-${T}${String(N).padStart(2,"0")}.png`);await nt(a,!0,O,`the detail card ${Mt(i.label,24)}, tile ${T}${N}`)&&M.push({tile:!0,card:{number:i.index+1,label:i.label,part:T},file:O})}},R=0;for(let i of b.sheets)i.shown||!i.panel||i.card!==null||(J=`Sheet ${Mt(i.label,24)}`,await P(i)&&(R+=1));let I=0;for(let i of b.cards){J=`detail card ${Mt(i.label,24)}`;let T=`[data-qa-card="${i.index}"]`;i.chain.length&&await x.evaluate(be,i.chain);for(let N of i.within)await x.evaluate(ye,N);if(!await x.evaluate(ye,i.index)){let{anchor:N}=await x.evaluate(Dt,{next:Q,place:T});k("unverified","this detail card could not be opened",{anchor:N});for(let a of i.within.toReversed())await x.evaluate(_t,a);continue}I+=1,await ct("the detail card opened"),await it(T),await dt(T,`card${i.index+1}`,0),r&&await K(i);for(let N of b.sheets)N.card!==i.index||N.shown||!N.panel||(J=`detail card ${Mt(i.label,24)}, Sheet ${Mt(N.label,24)}`,await P(N,i)&&(R+=1));await x.evaluate(_t,i.index);for(let N of i.within.toReversed())await x.evaluate(_t,N)}return J="",rt({...await x.evaluate(po),details:b.details,closed:b.closed,sheets:R,cards:b.cards.length,cardsOpened:I})}catch(b){return k("unverified",`the look ended early: ${b.message}`),rt(null)}finally{await D.close().catch(()=>{})}}var Be=e=>e.split(ht.sep).join("/"),pt=(e,n,s=`${n}s`)=>`${e} ${e===1?n:s}`,Ht=e=>`${e.join(", ")}px`,mo=e=>e.includes("\xD7")?e:`${e}px`;function wo({details:e,closed:n}){if(e===0)return"0 disclosures";let s=n===0?"open in the file":`${n===e?"":`${n} `}closed in the file, opened for the pictures`;return`${pt(e,"disclosure")} (${s})`}function $o(e,n=null){let s=new Map;for(let c of e){let r=n?ht.relative(n,c):"",u=Be(n&&r&&!r.startsWith("..")&&!ht.isAbsolute(r)?r:c),w=/^(.*\/)?(\d+(?:x\d+)?)-([^/]+)$/.exec(u),d=w?`${w[1]??""}\0${w[3]}`:u;s.has(d)||s.set(d,w?{head:w[1]??"",tail:w[3],looks:[]}:{whole:u});let $=s.get(d);w&&!$.looks.includes(w[2])&&$.looks.push(w[2])}return[...s.values()].map(c=>c.whole??`${c.head}${c.looks.length>1?`{${c.looks.join(",")}}`:c.looks[0]}-${c.tail}`)}var Oe=(e="<slug>")=>`more pictures: gallery qa ${e} --tiles (the page, each Sheet panel and each detail card in tiles), gallery qa ${e} --blocks <id,\u2026> (the blocks you name)`,en=Oe(),Re=he,ve='look at the export yourself at 1024, 736 and 360px, its disclosures and detail cards opened (SKILL.md, "Export, check and look"), and say so when you hand the document over.',xo=e=>It(e?.message).replace(/\s*Use a different `?userDataDir`? or stop the running browser first\.?/gi,"").slice(0,300),zt={overflow:"a reader scrolls the whole page sideways. Words that cannot break where they stand (a long path, URL or name): wrap each in <code>, which breaks where it must and keeps it whole for the reader to copy; an element wider than the window (a picture, a drawing, a width of your own): let it fit (max-width: 100%) or put it in a frame that scrolls; never cut or rewrite a path to silence this","table-columns":"not a failure. If the reader must see the column on a desktop, write its long values compactly (a cell of numbers stays on one line, so its longest value sets the column's width: a range as a\u2013b, fewer digits), move a unit out of its header into the line above the table, shorten the header, or split the table; never delete a column to silence this","chart-text-overlap":"not a failure. If the reader must read both, shorten the labels (a unit belongs in the axis's title), move one (above its row, or a leader line) or give the drawing more room at this width; never delete a label or a category to silence this","code-scrolls":'not a failure. A reader scrolls inside the frame (40 lines) for the rest; if every line must show at once, write style="--doc-code-height: none" on its <pre>; never delete code to silence this',"formula-scrolls":"not a failure. A reader scrolls the formula sideways for the rest; if it must show whole at this width, break it into lines (\\begin{aligned} \u2026 \\end{aligned}) or into two formulas; never cut a term to silence this","overflow-in-block":"not a failure. If the words run over others in the picture, give their box room at this width (a wider column in an @media rule of your <style>, or a smaller font there), or let them break (a dash or a space where a line may end); never cut the words to silence this","cut-in-block":"not a failure. If the reader must see what is cut, let the box grow with what it holds (min-height instead of height or max-height, or none), give it room at this width in an @media rule of your <style>, or let it scroll (overflow: auto); never delete the words to silence this",ticks:"not a failure. If the numbers crowd in the picture, give that axis fewer ticks at this width with axis.tickValues([...]), at most four on a phone (the domain's ends and middle; ticks(n) is only a hint to d3 and can still draw five or more), or shorter numbers (the unit in the axis's title: 2k, 1.5\u4E07); never take the axis out to silence this","svg-text-small":"not a failure. The viewBox scales the drawing's text with it: give the text a larger font-size in the viewBox's units (a viewBox 800 wide drawn 340px wide scales by 0.43, so 26 units read as 11px), or lay the drawing out for narrow widths (a viewBox of its own under an @media rule, a chart of your own drawn from its width, or HTML that wraps); never drop the labels to silence this"},yo='not a failure. A reader scrolls sideways for the rest of its long lines; if the reader must see them whole at this width, let them wrap (take data-wrap="false" off its <pre>) or break them where the code allows; a tree or a log whose lines must stay whole may scroll; never cut a line to silence this';function bo(e){if(e.kind!=="code-scrolls")return zt[e.kind]?[zt[e.kind]]:[];let n=[...e.said.keys()],s=n.some(c=>/ wide, its frame /.test(c));return[...!s||n.some(c=>/ tall, its frame /.test(c))?[zt["code-scrolls"]]:[],...s?[yo]:[]]}var So="none is a failure: each says what to do if it matters to the reader (never delete a column or a label to silence one)",ko="a reader scrolls it: not a problem";function vo(e,n,s=null,{folder:c=null,slug:r="<slug>"}={}){let u=[],w=Object.fromEntries(At.map(p=>[p,0])),d=new Map,$=new Set,h=new Map,q=[],L=p=>$o(p,c),U=p=>p.label??String(p.width),m=new Map(e.flatMap(p=>p.pictures.filter(A=>A.shot!==void 0).map(A=>[`${U(p)}|${A.shot}`,A.file])));for(let p of e){let{width:A,findings:J,counts:Q}=p,k=U(p),v=new Set,Y=Object.fromEntries(At.map(_=>[_,0])),F={right:0,down:0,all:0};for(let _ of J){let ft=`${_.kind}|${_.shot??""}|${_.what}`;if(v.has(ft))continue;v.add(ft);let dt=Ce(_,A);Y[dt]+=1;let it=so(_.anchor,n);if(_.kind==="table-scrolls"){let{sideways:R=!1,down:I=!1,name:i=""}=_.scroll??{};Object.assign(F,{all:F.all+1,right:F.right+Number(R),down:F.down+Number(I)});let T=`${it}|${i}`;h.has(T)||h.set(T,{place:it,name:i,right:[],down:[]}),R&&!h.get(T).right.includes(k)&&h.get(T).right.push(k),I&&!h.get(T).down.includes(k)&&h.get(T).down.push(k)}if(dt==="info"&&$.add(`${_.kind}|${it}`),dt==="info"&&["table-scrolls","table-columns","table-rows"].includes(_.kind))continue;let rt=`${At.indexOf(dt)}|${_.kind}|${it}`;d.has(rt)||(d.set(rt,{level:dt,kind:_.kind,place:it,said:new Map}),dt!=="info"&&(w[dt]+=1));let b=d.get(rt).said,z=`${_.state?`[${_.state}] `:""}${_.what}`;b.has(z)||b.set(z,{labels:[],pictures:[]});let P=b.get(z);P.labels.includes(k)||P.labels.push(k);let K=m.get(`${k}|${_.shot}`);K&&!P.pictures.includes(K)&&P.pictures.push(K)}let tt=[F.right&&`\u2192 ${F.right}`,F.down&&`\u2193 ${F.down}`].filter(Boolean).join(", "),ct=`${pt(F.all,"table scrolls","tables scroll")}${tt?` (${tt})`:""}`,nt=Q?.cards?`, ${pt(Q.cards,"detail card")} (${Q.cardsOpened===Q.cards?"closed in the file, opened in turn":`${Q.cardsOpened??0} of them opened`})`:"",at=p.laptop?"; only what the 1024px look did not find":Q?`; ${pt(Q.charts,"chart")}, ${pt(Q.tables,"table")}, ${wo(Q)}, ${pt(Q.sheets,"Sheet")} shown besides the first${nt}, page ${Q.height}px tall`:"";q.push({label:k,fail:Y.fail,warn:Y.warn,line:`${p.laptop?k:`${k.padStart(4)}px`} fail ${Y.fail} \xB7 warn ${Y.warn} \xB7 unverified ${Y.unverified} \xB7 ${ct}${at}`})}let C=[...d.values()].sort((p,A)=>At.indexOf(p.level)-At.indexOf(A.level)),D=e.flatMap(p=>p.pictures);if(c&&D.length&&u.push(`Pictures of this run in ${Be(c)}/ (each path below is in it):`),s){let p=new Map;for(let k of D)k.block!==void 0&&p.set(k.block,[...p.get(k.block)??[],k.file]);let A=Ae(e),J=k=>`${s.tags?.get(k)?`${s.tags.get(k)} `:""}${k}`,Q=`at ${ge.slice(0,-1).join(", ")} and ${ge.at(-1)}px`;s.tiles&&s.why&&u.push(`${s.why[0].toUpperCase()}${s.why.slice(1)}.`);for(let k of s.groups??[]){if(!k.ids.length&&!k.rest.length)continue;let v=!k.ids.length&&s.groups.some(Y=>Y!==k&&Y.ids.length)?`: none this run (the ${Ee} blocks a run pictures went to the changed blocks above)`:"";u.push(`${k.why[0].toUpperCase()}${k.why.slice(1)}${k.ids.length?`, ${Q}`:v}:`);for(let Y of k.ids){let F=n.blocks.get(Y),tt=`${F?`${n.name??"doc.html"}:${F}`:`(not in ${n.name??"doc.html"})`} ${Y}${s.tags?.get(Y)?` ${s.tags.get(Y)}`:""}`,ct=p.get(Y)??[],nt=s.moved?.has(Y)?" (moved: with the edges of the blocks before and after it)":"",at=s.held?.get(Y)??[],_=at.filter(P=>s.changed?.has(P)).length,ft=k.kind==="named"?pt(at.length,"block"):[_&&pt(_,"changed block"),at.length-_&&pt(at.length-_,"card")].filter(Boolean).join(" and "),dt=D.some(P=>P.block===Y&&P.part)?", pictured again with each Sheet panel or detail card that holds one":"",it=at.filter(P=>A.has(P)),rt=[...new Set(it.flatMap(P=>A.get(P)))].map(P=>P.includes("\xD7")?P:`${P}px`).join(", "),b=it.length?`; ${it.length} of them not pictured at ${rt}: gallery qa ${r} --blocks ${it.join(",")}`:"",z=at.length?` (with the ${ft} it holds${dt}${b})`:"";u.push(ct.length?` ${tt}${nt}${z}: ${L(ct).join(", ")}`:` ${tt}${nt}${z}: not shown at any width (hidden)`)}if(k.rest.length){let Y=pt(k.rest.length,{changed:"changed block",cards:"card"}[k.kind]??"block"),F=`${k.rest.slice(0,6).map(J).join(", ")}${k.rest.length>6?", \u2026":""}`;u.push(` ${k.ids.length?"and ":""}${Y}${k.ids.length?" more":""}, not pictured (${F}): gallery qa ${r} --blocks ${k.rest.join(",")}`)}}s.unknown.length&&u.push(` no block of ${n.name??"doc.html"} has the id${s.unknown.length===1?"":"s"} ${s.unknown.join(", ")}`)}let x=[];for(let p of C)for(let{pictures:A}of p.said.values())x.push(...A.filter(J=>!x.includes(J)));x.length&&u.push("The elements flagged below, look at these first:",...L(x).map(p=>` ${p}`));let H=D.filter(p=>p.tile),M=H.filter(p=>!p.sheet&&!p.card);M.length&&u.push(`The page as it opens (each Sheet area with the panel it shows first): ${pt(M.length,"tile")} in ${L([ht.dirname(M[0].file)])[0]}/ (<width>-<n>.png)`);let Z=new Map;for(let{sheet:p}of H)p&&Z.set(p.number,{...p,count:(Z.get(p.number)?.count??0)+1});Z.size&&u.push(`Each other Sheet panel, shown in turn: ${pt(H.filter(p=>p.sheet).length,"tile")} in ${L([ht.dirname(H.find(p=>p.sheet).file)])[0]}/ (<width>-sheet<i>-<n>.png): ${[...Z.values()].map(({number:p,label:A,count:J})=>`sheet${p} ${Mt(A,24)} ${pt(J,"tile")}`).join(", ")}`);let X=new Map;for(let{card:p}of H)p&&X.set(p.number,{...p,count:(X.get(p.number)?.count??0)+1});X.size&&u.push(`Each detail card, opened in turn as the window shows it, its content scrolled a tile at a time: ${pt(H.filter(p=>p.card).length,"tile")} in ${L([ht.dirname(H.find(p=>p.card).file)])[0]}/ (<width>-card<i>-<n>.png${H.some(p=>p.card?.part)?"; with another panel of a Sheet in it shown, <width>-card<i>-sheet<j>-<n>.png":""}): ${[...X.values()].map(({number:p,label:A,count:J})=>`card${p} ${Mt(A,24)} ${pt(J,"tile")}`).join(", ")}`);for(let{place:p,name:A,right:J,down:Q}of h.values()){let k=/^(?:doc|report)\.html:\d+/.exec(p)?.[0]??p;u.push(`${"INFO".padEnd(10)} table-scrolls: ${k}${A?` ${Mt(A,32)}`:""}: ${[J.length&&`\u2192 ${Ht(J)}`,Q.length&&`\u2193 ${Ht(Q)}`].filter(Boolean).join("; ")} (${ko})`)}for(let p of C){u.push(`${p.level.toUpperCase().padEnd(10)} ${p.kind}: ${p.place}`);for(let[A,{labels:J,pictures:Q}]of p.said)u.push(` ${Ht(J)}: ${A}${Q.length?` (${L(Q).join(", ")})`:""}`);for(let A of bo(p))u.push(` ${A}`)}u.push(...q.map(({line:p})=>p));let gt=Mo(s,r);return gt&&u.push(gt),w.info=$.size,{lines:u,levels:w,looks:q.map(({label:p,fail:A,warn:J})=>({label:p,fail:A,warn:J}))}}function Mo(e,n="<slug>"){let{changed:s=[],restyled:c=[],packages:r=[],cards:u=[],since:w="the last look",first:d=!1}=e?.left??{};if(!s.length&&!c.length&&!u.length)return null;let $=q=>`${q.slice(0,6).map(L=>`${e.tags?.get(L)?`${e.tags.get(L)} `:""}${L}`).join(", ")}${q.length>6?", \u2026":""}`;return`Not pictured by this run, which pictures the blocks named alone: ${[s.length&&`${pt(s.length,"block")} changed or moved since ${w} (${$(s)})`,c.length&&`${pt(c.length,"instance")} of a package changed since ${w}, ${r.join(", ")} (${$(c)})`,u.length&&(d?`no earlier look: ${pt(u.length,"card")} never pictured (${$(u)})`:`${pt(u.length,"card")} the change of the document's own <script> or <style> since ${w} may draw again (${$(u)})`)].filter(Boolean).join("; ")}. gallery qa ${n} pictures them.`}function Co(e,n,s=[],{unpictured:c=!1}={}){let r=n.map(({label:q,fail:L,warn:U})=>`${mo(q)} fail ${L}, warn ${U}`).join("; "),u=r?` (${r})`:"",w=Oe(s.length===1?s[0].slug:void 0),d={stale:"its file had changed since its export",missing:"it had none yet"},$=s.filter(({first:q})=>q).map(({slug:q,first:L})=>`${s.length>1?`${q} was`:"It was"} exported first by this run (${d[L]}).`),h=`${$.length?`. ${$.join(" ")}`:""}${s.map(({file:q})=>`
3
- ${Re}${q}`).join("")}`;if(e.fail)return`failures at ${pt(e.fail,"place")}${u}: fix them in the document's doc.html (report.html in an older document), then run this again (it exports first); ${w}${h}`;if(e.unverified)return`nothing failed${u}; not verified at ${pt(e.unverified,"place")}: say so when you hand the document over; ${w}${h}`;if(e.warn)return`nothing failed${u}; warnings at ${pt(e.warn,"place")} to look at, ${So}; ${w}${h}`;if(c){let q=s.length===1?s[0].slug:"<slug>";return`nothing found${u}, and no picture taken: a plain run pictures the cards and the blocks changed since the last look, and the document has no card (a chart or a drawing, code, a whole block, a component, a flowchart, a Sheet area, columns, a figure, a table) and no block changed; run gallery qa ${q} --tiles to picture the page, each Sheet panel and each detail card in tiles, open those pictures and look at the document once yourself; gallery qa ${q} --blocks <id,\u2026> pictures the blocks you name${h}`}return`nothing found${u}: open the pictures above and look at the document once yourself; ${w}${h}`}function Eo(e,{missing:n=!1,edited:s=!1,packaged:c=!1}={}){let r=qt(e),u=ht.basename(Lt(jt(e,Rt)).html);return`exporting first: ${n?`no export yet (${r})`:s?`${u} changed since the last export (${r})`:c?`a component package it uses changed since the last export (${r})`:`the last export (${r}) does not say which text it was made from (an older Gallery's)`}, as gallery export ${e} does (--no-export: refuse instead)`}async function qo(e){for(let[r,{missing:u,edited:w,packaged:d}]of e)console.log(`${r}: ${Eo(r,{missing:u,edited:w,packaged:d})}`);let n=new Map(await Promise.all(e.map(async([r])=>[r,await vt.stat(qt(r)).then(u=>u.mtimeMs,()=>null)]))),s=Fe(process.execPath,[ht.join(ze,"bin","gallery.mjs"),"export",...e.map(([r])=>r)],{cwd:Rt,encoding:"utf8",env:{...process.env,GALLERY_WORKSPACE:Rt},maxBuffer:256*1024*1024});s.stdout&&process.stdout.write(s.stdout),s.stderr&&process.stderr.write(s.stderr),s.error&&console.error(`the export did not run: ${s.error.message}`);let c=[];for(let[r]of e){let u=await vt.stat(qt(r)).then(w=>w.mtimeMs,()=>null);u!==null&&u!==n.get(r)&&!(await Gt(r,{made:!0})).problem&&c.push(r)}return c}var Ao=e=>String(e??"").split(/[\s,]+/).filter(Boolean);function Bo(e,n){let s=Vt(e);return[...new Set(n)].filter(c=>!s.has(c))}var Oo=(e,n)=>`--blocks: no block of ${e} has the id${n.length===1?"":"s"} ${n.join(", ")}: nothing was looked at and no picture removed. Name ids as gallery qa prints them (data-block-id in the file).`;async function on(e){let{slugs:n,options:s,values:c}=await Kt({options:["--tiles","--no-export"],values:["--blocks"],argv:e}),r=c.has("--blocks")?Ao(c.get("--blocks")):null;if(r?.length===0)throw new Wt("--blocks takes block ids: --blocks <id,\u2026>");if(r&&n.length!==1)throw new Wt("--blocks names blocks of one document: name one.");let u=new Map,w=[];for(let M of n){let Z=await Gt(M);Z.problem&&!((Z.stale||Z.missing)&&!s.has("--no-export"))&&w.push(Z.problem),u.set(M,Z)}if(w.length&&(console.error(w.join(`
4
- `)),process.exit(2)),r){let M=Lt(jt(n[0],Rt)).html,Z=Bo(Pt(await vt.readFile(M,"utf8").catch(()=>"")),r);if(Z.length)throw new Wt(Oo(ht.resolve(M),Z))}await le(n),await ce(n),await de(n);let d=[...u].filter(([,M])=>M.stale||M.missing),$=new Map(d.map(([M,Z])=>[M,Z.missing?"missing":"stale"]));if(d.length){let M=await qo(d),Z=d.map(([X])=>X).filter(X=>!M.includes(X));for(let X of M)u.set(X,await Gt(X,{made:!0}));Z.length&&(console.error(`${Z.join(", ")}: the export failed (above), so nothing was looked at: fix what it says, then run this again`),process.exit(1))}let h=u,q=[...h].map(([M,{file:Z}])=>({slug:M,file:Z,first:$.get(M)??null})),L=(M,Z)=>{for(let[X,{sha256:gt,time:p}]of h)console.log(`${X}: ${qt(X)} sha256 ${gt}, exported ${Ut(p)}`);console.log(`UNVERIFIED ${M}: nothing was looked at. ${Z}`);for(let{file:X}of q)console.log(`${Re}${X}`);process.exit(3)},U=oe();U||L("no Chrome, Edge or Chromium found (GALLERY_BROWSER=<its executable> picks one)",`Install Chrome or Edge, or ${ve}`);let m=await ie({executablePath:U,args:ne()}).catch(M=>L(`the browser ${U} did not start, twice, each time with a fresh profile (${xo(M)}; GALLERY_BROWSER=<its executable> picks another)`,`Run gallery qa once more; if it says UNVERIFIED again, ${ve}`)),{browser:C}=m,D=Object.fromEntries(At.map(M=>[M,0])),x=new Map,H=!1;try{for(let[M,{file:Z,sha256:X,time:gt}]of h){let p=ht.join(Ue,M),A=ht.join(p,"blocks.json");console.log(`${M}: ${qt(M)} sha256 ${X}, exported ${Ut(gt)} (${ht.basename(U)}, headless)`);let J=Lt(jt(M,Rt)).html,Q=Pt(await vt.readFile(J,"utf8")),k=Vt(Q),v=ee(k,te(await vt.readFile(A,"utf8").catch(()=>null))),Y=Qt(Q),F=Zt(Q),tt=ho(k,v,r,{tiles:s.has("--tiles")&&!r,page:Y,packages:F}),ct=s.has("--tiles")||!!tt.tiles;(ct||tt.ids.length)&&(H=!0);let nt={flagged:ht.join(p,"flagged"),blocks:ht.join(p,r?"blocks":"changed"),tiles:ht.join(p,"tiles")},at=ht.join(p,"cards");nt.folders=new Map(tt.groups.flatMap(i=>i.ids.map(T=>[T,i.kind==="cards"?at:nt.blocks])));let _=[nt.flagged,...r?[nt.blocks]:tt.tiles?[]:[nt.blocks,at],...ct?[nt.tiles]:[]],ft=(await Promise.all(_.map(async i=>[i,(await vt.readdir(i).catch(()=>[])).filter(T=>T.endsWith(".png")).length]))).filter(([,i])=>i>0);ft.length&&console.log(`The pictures of the run before in ${ft.map(([i])=>`${ht.basename(i)}/`).join(", ")} (${pt(ft.reduce((i,[,T])=>i+T,0),"file")}) were removed: this run's replace them.`);for(let i of _)await vt.rm(i,{recursive:!0,force:!0});for(let i of await vt.readdir(p).catch(()=>[]))i.endsWith(".png")&&await vt.rm(ht.join(p,i),{force:!0});for(let i of _)await vt.mkdir(i,{recursive:!0});let dt=[...k].filter(([,{whole:i}])=>i).map(([i])=>i),it=[...k].filter(([,{figure:i}])=>i).map(([i])=>i),rt=[],b=null;for(let i of pe){let T=await go(C,Z,i,{out:nt,tiles:ct&&!i.laptop,blocks:i.laptop?[]:tt.ids,around:tt.around,held:i.laptop?new Map:tt.held,whole:dt,drawn:it,known:i.laptop?b:null});rt.push({...i,...T}),T.pictures.length&&(H=!0),!i.laptop&&i.width===pe.find(N=>N.laptop)?.width&&(b=new Set(T.findings.map(Yt)))}let{lines:z,levels:P,looks:K}=vo(rt,no(Q,ht.basename(J)),{...tt,tags:new Map([...k].map(([i,{tag:T}])=>[i,T]))},{folder:p,slug:M});console.log(z.join(`
5
- `));for(let i of At)D[i]+=P[i];for(let{label:i,fail:T,warn:N}of K){let a=x.get(i)??{label:i,fail:0,warn:0};x.set(i,{label:i,fail:a.fail+T,warn:a.warn+N})}let R=rt.every(i=>i.counts&&!i.findings.some(T=>T.kind==="unverified")),I=ro(k,v,tt,{named:r,verified:R,failed:P.fail>0,seen:lo(tt,rt),page:Y,packages:F})??v;I&&await vt.writeFile(A,`${JSON.stringify(I)}
6
- `)}}finally{await m.close()}console.log(Co(D,[...x.values()],q,{unpictured:!H})),process.exitCode=D.fail?1:D.unverified?3:0}export{zt as ADVICE,Ee as BLOCK_PICTURES,yo as CODE_SIDEWAYS,Re as HAND_OVER,Qe as INK_MARGIN,Uo as KINDS,At as LEVELS,pe as LOOKS,ve as LOOK_YOURSELF,en as MORE_PICTURES,co as MOSTLY_CHANGED,we as MOVED_PART,to as MOVED_WHOLE,me as NEIGHBOUR_EDGE,Ke as PICTURED_INFO,ko as SCROLLS,Ze as SCROLL_FRAMES,Je as SCROLL_SLACK,So as WARNED,Go as WIDE,ge as WIDTHS,ee as adoptIdless,bo as adviceOf,je as baselineOf,xe as baselineSaid,Vt as blocksOf,ho as blocksToPicture,vo as describeLooks,wo as disclosuresSaid,Le as exportBaselines,Gt as exportOf,Eo as exportingFirst,Yt as findingKey,Ce as findingLevel,uo as inkOf,Ge as layoutNotesOf,Me as levelOf,go as lookAt,Ae as missedWidths,Oe as morePictures,qe as movedBlocks,eo as movedClips,Ao as namedBlocks,ro as nextBaseline,Mo as notPicturedLine,Qt as pageOf,Xe as picturedAt,$o as picturesSaid,so as placeOf,Ie as previewBaseline,We as rankOf,te as readBaseline,on as run,lo as seenOf,no as sourceIndex,ao as staleExport,xo as startFailure,Ut as timeOf,Bo as unknownBlocks,Oo as unknownBlocksSaid,$e as urlName,Co as verdictOf,oo as wordsOf};