@heycys/gallery 0.1.1 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (473) hide show
  1. package/THIRD-PARTY-NOTICES.md +2 -2
  2. package/browser/editor/components/align.mjs +58 -0
  3. package/browser/editor/components/code/index.mjs +1 -1
  4. package/browser/editor/components/columns/page.mjs +4 -4
  5. package/browser/editor/components/embed/index.mjs +2 -2
  6. package/browser/editor/components/embed/page.mjs +1 -1
  7. package/browser/editor/components/file/page.mjs +4 -4
  8. package/browser/editor/components/flowchart/add.mjs +7 -6
  9. package/browser/editor/components/flowchart/page.mjs +1 -1
  10. package/browser/editor/components/heading/index.mjs +7 -6
  11. package/browser/editor/components/icons.mjs +11 -0
  12. package/browser/editor/components/image/crop.mjs +6 -9
  13. package/browser/editor/components/image/index.mjs +2 -0
  14. package/browser/editor/components/image/page.mjs +172 -90
  15. package/browser/editor/components/installed/index.mjs +15 -4
  16. package/browser/editor/components/installed/page.mjs +103 -25
  17. package/browser/editor/components/installed/served.mjs +6 -5
  18. package/browser/editor/components/instances.mjs +18 -0
  19. package/browser/editor/components/list/page.mjs +3 -6
  20. package/browser/editor/components/media/icons.mjs +13 -8
  21. package/browser/editor/components/media/page.mjs +5 -3
  22. package/browser/editor/components/media/toolbar.mjs +12 -3
  23. package/browser/editor/components/paragraph/index.mjs +4 -3
  24. package/browser/editor/components/registry.mjs +30 -9
  25. package/browser/editor/components/table/index.mjs +61 -2
  26. package/browser/editor/components/table/page.mjs +1 -1
  27. package/browser/editor/page/after/index.mjs +288 -0
  28. package/browser/editor/page/align.mjs +91 -0
  29. package/browser/editor/page/annotate/card.mjs +3 -6
  30. package/browser/editor/page/autosave.mjs +310 -37
  31. package/browser/editor/page/beside.mjs +5 -6
  32. package/browser/editor/page/block-menu/index.mjs +6 -3
  33. package/browser/editor/page/blocks.mjs +3 -1
  34. package/browser/editor/page/board/client.mjs +57 -0
  35. package/browser/editor/page/board/hint.mjs +182 -0
  36. package/browser/editor/page/board/history.mjs +119 -0
  37. package/browser/editor/page/board/index.mjs +1059 -0
  38. package/browser/editor/page/board/motion.mjs +177 -0
  39. package/browser/editor/page/board/settings.mjs +210 -0
  40. package/browser/editor/page/caret.mjs +1 -1
  41. package/browser/editor/page/changes/bar.mjs +6 -14
  42. package/browser/editor/page/changes/index.mjs +2 -2
  43. package/browser/editor/page/clipboard/import/html.mjs +29 -6
  44. package/browser/editor/page/clipboard/import/inline.mjs +32 -0
  45. package/browser/editor/page/clipboard/import/markdown.mjs +58 -13
  46. package/browser/editor/page/clipboard/import/read.mjs +6 -1
  47. package/browser/editor/page/clipboard/import/to-blocks.mjs +44 -12
  48. package/browser/editor/page/clipboard/import/yuque.mjs +622 -0
  49. package/browser/editor/page/clipboard/index.mjs +133 -15
  50. package/browser/editor/page/clipboard/own/blocks.mjs +13 -14
  51. package/browser/editor/page/clipboard/own/chart-keys.mjs +41 -28
  52. package/browser/editor/page/clipboard/own/describe.mjs +6 -2
  53. package/browser/editor/page/clipboard/own/selection.mjs +1 -1
  54. package/browser/editor/page/columns/index.mjs +48 -46
  55. package/browser/editor/page/commit.mjs +80 -22
  56. package/browser/editor/page/conflicts.mjs +7 -7
  57. package/browser/editor/page/core.mjs +34 -16
  58. package/browser/editor/page/custom-page.mjs +110 -0
  59. package/browser/editor/page/editor.mjs +71 -17
  60. package/browser/editor/page/emoji-picker/styles.mjs +7 -12
  61. package/browser/editor/page/emoji-picker/upload.mjs +2 -2
  62. package/browser/editor/page/handle/index.mjs +5 -8
  63. package/browser/editor/page/history.mjs +41 -6
  64. package/browser/editor/page/insert/index.mjs +20 -22
  65. package/browser/editor/page/links/index.mjs +5 -3
  66. package/browser/editor/page/links/pages.mjs +27 -9
  67. package/browser/editor/page/look.mjs +54 -3
  68. package/browser/editor/page/margin.mjs +18 -3
  69. package/browser/editor/page/media-menu/index.mjs +6 -7
  70. package/browser/editor/page/menu.mjs +33 -14
  71. package/browser/editor/page/notices.mjs +2 -2
  72. package/browser/editor/page/page-objects.mjs +9 -2
  73. package/browser/editor/page/panel.mjs +4 -9
  74. package/browser/editor/page/present-links.mjs +15 -5
  75. package/browser/editor/page/present-shell.mjs +63 -0
  76. package/browser/editor/page/resize/index.mjs +42 -29
  77. package/browser/editor/page/selection/index.mjs +10 -2
  78. package/browser/editor/page/served.mjs +14 -0
  79. package/browser/editor/page/session.mjs +48 -4
  80. package/browser/editor/page/slash-menu/index.mjs +3 -3
  81. package/browser/editor/page/table/binding.mjs +87 -0
  82. package/browser/editor/page/table/cells.mjs +102 -46
  83. package/browser/editor/page/table/index.mjs +24 -9
  84. package/browser/editor/page/table/pictures.mjs +299 -0
  85. package/browser/editor/page/table/views.mjs +103 -0
  86. package/browser/editor/page/table/widths.mjs +82 -10
  87. package/browser/editor/page/text-select/index.mjs +26 -12
  88. package/browser/editor/page/todo-writes.mjs +75 -0
  89. package/browser/editor/page/typing/index.mjs +97 -15
  90. package/browser/editor/page/typing/leave.mjs +19 -5
  91. package/browser/editor/page/ui.mjs +13 -0
  92. package/browser/shared/block-packs.mjs +419 -0
  93. package/browser/shared/board-places.mjs +224 -0
  94. package/browser/shared/card-size.mjs +59 -0
  95. package/browser/shared/colors.mjs +3 -2
  96. package/browser/shared/component-catalog.mjs +330 -46
  97. package/browser/shared/component-source.mjs +39 -0
  98. package/browser/shared/components/heading.mjs +2 -1
  99. package/browser/shared/components/index.mjs +12 -3
  100. package/browser/shared/components/installed.mjs +35 -3
  101. package/browser/shared/components/page.mjs +20 -8
  102. package/browser/shared/components/paragraph.mjs +8 -1
  103. package/browser/shared/components/state.mjs +5 -1
  104. package/browser/shared/components/table.mjs +1 -0
  105. package/browser/shared/document-look.mjs +10 -5
  106. package/browser/shared/drafts.mjs +432 -0
  107. package/browser/shared/emoji/line-icons.mjs +37 -0
  108. package/browser/shared/extension-sidebar.mjs +126 -0
  109. package/browser/shared/extensions.mjs +79 -0
  110. package/browser/shared/file-table.mjs +101 -0
  111. package/browser/shared/http.mjs +9 -0
  112. package/browser/shared/i18n/en.mjs +330 -27
  113. package/browser/shared/json-layout.mjs +47 -0
  114. package/browser/shared/net-cache.mjs +133 -0
  115. package/browser/shared/net-keys.mjs +32 -0
  116. package/browser/shared/net-policy.mjs +177 -0
  117. package/browser/shared/outline-shape.mjs +128 -0
  118. package/browser/shared/outline.mjs +359 -67
  119. package/browser/shared/pack-manifest.mjs +88 -0
  120. package/browser/shared/page-address.mjs +6 -3
  121. package/browser/shared/page-cards.mjs +308 -0
  122. package/browser/shared/page-links.mjs +69 -6
  123. package/browser/shared/pages.mjs +500 -0
  124. package/browser/shared/paths.mjs +6 -0
  125. package/browser/shared/pinyin.mjs +92 -0
  126. package/browser/shared/present-step.mjs +17 -0
  127. package/browser/shared/preview-server.mjs +3 -7
  128. package/browser/shared/session.mjs +8 -1
  129. package/browser/shared/shipped-blocks.mjs +299 -0
  130. package/browser/shared/sidebar-head.mjs +70 -0
  131. package/browser/shared/table-chart.mjs +33 -1
  132. package/browser/shared/todos.mjs +83 -0
  133. package/browser/shared/user-directory.mjs +24 -0
  134. package/browser/shared/versions.mjs +14 -0
  135. package/browser/shared/web-links.mjs +139 -0
  136. package/browser/shared/workspace-columns.mjs +120 -0
  137. package/browser/shared/workspace-name.mjs +154 -0
  138. package/browser/shared/workspace-query.mjs +125 -0
  139. package/browser/shared/workspace-registry.mjs +272 -0
  140. package/browser/shared/workspace.mjs +171 -20
  141. package/dist/chunk-2OHANJ6Q.mjs +2 -0
  142. package/dist/chunk-3MBRL2PM.mjs +16 -0
  143. package/dist/chunk-4OKWZY5E.mjs +2 -0
  144. package/dist/chunk-4OZWXZE5.mjs +5 -0
  145. package/dist/chunk-5K44HLTZ.mjs +2 -0
  146. package/dist/{chunk-5ZKJ3H4P.mjs → chunk-5XA2ZBAE.mjs} +3 -3
  147. package/dist/{chunk-4FS7Z7WR.mjs → chunk-67N2QJYT.mjs} +1 -1
  148. package/dist/chunk-6KBYRA2C.mjs +2 -0
  149. package/dist/chunk-6N3PX4XX.mjs +8 -0
  150. package/dist/{chunk-V5JTW2LH.mjs → chunk-6QBHU4DF.mjs} +1 -1
  151. package/dist/chunk-7JDX4E65.mjs +13 -0
  152. package/dist/chunk-7M2BQQGZ.mjs +2 -0
  153. package/dist/chunk-7OG26PGF.mjs +2 -0
  154. package/dist/chunk-AHN3NFKJ.mjs +3 -0
  155. package/dist/chunk-ALZ6ZENZ.mjs +3 -0
  156. package/dist/chunk-AR5D57ZD.mjs +170 -0
  157. package/dist/{chunk-W3BGBJQW.mjs → chunk-BFJGHSQN.mjs} +1 -1
  158. package/dist/{chunk-LS4F7JUM.mjs → chunk-BZ5RAF7L.mjs} +1 -1
  159. package/dist/chunk-CMA72MAG.mjs +2 -0
  160. package/dist/{chunk-LCTHTZIL.mjs → chunk-DAZL73VK.mjs} +91 -91
  161. package/dist/{chunk-Y6RLRPG3.mjs → chunk-DJISHPUL.mjs} +1 -1
  162. package/dist/chunk-DR73Y2UJ.mjs +3 -0
  163. package/dist/{chunk-FDLXYYG4.mjs → chunk-EAIFITAV.mjs} +1 -1
  164. package/dist/{chunk-TMYZB6AV.mjs → chunk-EKNHM3P4.mjs} +1 -1
  165. package/dist/chunk-EP25HDAJ.mjs +2 -0
  166. package/dist/{chunk-GB5SOYQJ.mjs → chunk-ERLAIBOA.mjs} +2 -2
  167. package/dist/chunk-EURLTOTZ.mjs +4 -0
  168. package/dist/chunk-F4ZA6JRZ.mjs +3 -0
  169. package/dist/chunk-F6HVDZR4.mjs +2 -0
  170. package/dist/chunk-FDMAXMQA.mjs +2 -0
  171. package/dist/chunk-FETSREUN.mjs +5 -0
  172. package/dist/chunk-GHOYKMQ3.mjs +4 -0
  173. package/dist/{chunk-2B5E4CDJ.mjs → chunk-GPIWQ4X4.mjs} +1 -1
  174. package/dist/chunk-HDWTZ763.mjs +12 -0
  175. package/dist/chunk-HPOI4ZX7.mjs +6 -0
  176. package/dist/{chunk-BGGDRNYQ.mjs → chunk-HXG7EOPJ.mjs} +1 -1
  177. package/dist/chunk-IA4PSIMD.mjs +2 -0
  178. package/dist/{chunk-E7LWZRXY.mjs → chunk-ITOH5EGO.mjs} +1 -1
  179. package/dist/chunk-IV64FFI4.mjs +2 -0
  180. package/dist/chunk-J43Z6LSS.mjs +2 -0
  181. package/dist/chunk-J5PUIV3Y.mjs +4 -0
  182. package/dist/chunk-JA7G53PC.mjs +2 -0
  183. package/dist/chunk-JEUK3ZO7.mjs +2 -0
  184. package/dist/chunk-JLTZF4LA.mjs +2 -0
  185. package/dist/chunk-JZT7I2OJ.mjs +2 -0
  186. package/dist/chunk-K5XATEOO.mjs +2 -0
  187. package/dist/chunk-L2SUIS5S.mjs +2 -0
  188. package/dist/chunk-L7UP52JO.mjs +2 -0
  189. package/dist/chunk-LM4XFQHZ.mjs +2 -0
  190. package/dist/chunk-MN7BZL4R.mjs +2 -0
  191. package/dist/chunk-MTYYHM2G.mjs +15 -0
  192. package/dist/chunk-MXUBKDRO.mjs +15 -0
  193. package/dist/chunk-NAMN3RAF.mjs +2 -0
  194. package/dist/{chunk-SYGN7GLU.mjs → chunk-OEXWRJME.mjs} +1 -1
  195. package/dist/chunk-OFHXGWOX.mjs +2 -0
  196. package/dist/chunk-ORID3AE7.mjs +166 -0
  197. package/dist/chunk-PAREWQGB.mjs +4 -0
  198. package/dist/chunk-PGDE24N5.mjs +2 -0
  199. package/dist/chunk-POTA2FV4.mjs +2 -0
  200. package/dist/chunk-PUOQ65NC.mjs +2 -0
  201. package/dist/chunk-Q4UEPUWF.mjs +2 -0
  202. package/dist/chunk-QE5RG76S.mjs +549 -0
  203. package/dist/chunk-R2ZDLJYT.mjs +10 -0
  204. package/dist/{chunk-7DTINW6U.mjs → chunk-SQ6Y2ZMA.mjs} +2 -2
  205. package/dist/chunk-SWUTTZCN.mjs +2 -0
  206. package/dist/chunk-TANZRINB.mjs +2 -0
  207. package/dist/chunk-TR7TWGHB.mjs +2 -0
  208. package/dist/chunk-U5XL7D6A.mjs +3 -0
  209. package/dist/{chunk-XNROSH2T.mjs → chunk-U7NZI6N4.mjs} +2 -2
  210. package/dist/chunk-UGWMMEJ5.mjs +15 -0
  211. package/dist/chunk-UJQJKNGK.mjs +2 -0
  212. package/dist/chunk-UYVCQK3H.mjs +22 -0
  213. package/dist/chunk-VFX2KNHP.mjs +4 -0
  214. package/dist/chunk-VS7JIGJW.mjs +24 -0
  215. package/dist/chunk-W7665ZEC.mjs +6 -0
  216. package/dist/chunk-WQDQWCX5.mjs +2 -0
  217. package/dist/chunk-YI43RG4P.mjs +2 -0
  218. package/dist/chunk-YLPSMDIS.mjs +5 -0
  219. package/dist/chunk-YNAWBAYN.mjs +3 -0
  220. package/dist/chunk-YROX2O22.mjs +2 -0
  221. package/dist/chunk-ZDLPUOAG.mjs +6 -0
  222. package/dist/{chunk-IVDLMMBD.mjs → chunk-ZHEHPMBK.mjs} +1 -1
  223. package/dist/chunk-ZQS6H473.mjs +16 -0
  224. package/dist/chunk-ZTHICSSF.mjs +2 -0
  225. package/dist/chunk-ZWWC4KLF.mjs +20 -0
  226. package/dist/cli.mjs +1 -1
  227. package/dist/server.mjs +1 -1
  228. package/dist/{chunk-U6KNPJPR.mjs → update-fetch.mjs} +1 -1
  229. package/dist/worker.mjs +1 -1
  230. package/kit/board.css +95 -0
  231. package/kit/board.js +250 -0
  232. package/kit/charts.js +5 -71
  233. package/kit/code.js +17 -17
  234. package/kit/report.css +335 -18
  235. package/kit/runtime.js +1638 -125
  236. package/kit/state.js +10 -1
  237. package/kit/tables.js +130 -43
  238. package/kit/ui.js +79 -35
  239. package/package.json +2 -1
  240. package/packs/gallery/card/component.json +14 -0
  241. package/packs/gallery/card/example.html +10 -0
  242. package/packs/gallery/card/preview.svg +1 -0
  243. package/packs/gallery/card/style.css +6 -0
  244. package/packs/gallery/card/template.html +6 -0
  245. package/packs/gallery/card/writing.md +14 -0
  246. package/packs/gallery/chart-card/component.json +15 -0
  247. package/packs/gallery/chart-card/example.html +14 -0
  248. package/packs/gallery/chart-card/kit.js +130 -0
  249. package/packs/gallery/chart-card/preview.svg +1 -0
  250. package/packs/gallery/chart-card/style.css +42 -0
  251. package/packs/gallery/chart-card/template.html +13 -0
  252. package/packs/gallery/chart-card/writing.md +20 -0
  253. package/packs/gallery/chart-view/component.json +20 -0
  254. package/packs/gallery/chart-view/example.html +13 -0
  255. package/packs/gallery/chart-view/kit.js +355 -0
  256. package/packs/gallery/chart-view/preview.svg +1 -0
  257. package/packs/gallery/chart-view/style.css +94 -0
  258. package/packs/gallery/chart-view/template.html +3 -0
  259. package/packs/gallery/chart-view/writing.md +22 -0
  260. package/packs/gallery/countdown/component.json +18 -0
  261. package/packs/gallery/countdown/example.html +3 -0
  262. package/packs/gallery/countdown/kit.js +216 -0
  263. package/packs/gallery/countdown/preview.svg +1 -0
  264. package/packs/gallery/countdown/style.css +118 -0
  265. package/packs/gallery/countdown/template.html +3 -0
  266. package/packs/gallery/countdown/writing.md +22 -0
  267. package/packs/gallery/habit/component.json +14 -0
  268. package/packs/gallery/habit/example.html +3 -0
  269. package/packs/gallery/habit/kit.js +334 -0
  270. package/packs/gallery/habit/preview.svg +1 -0
  271. package/packs/gallery/habit/style.css +174 -0
  272. package/packs/gallery/habit/template.html +3 -0
  273. package/packs/gallery/habit/writing.md +21 -0
  274. package/packs/gallery/heatmap/component.json +18 -0
  275. package/packs/gallery/heatmap/example.html +3 -0
  276. package/packs/gallery/heatmap/kit.js +513 -0
  277. package/packs/gallery/heatmap/preview.svg +1 -0
  278. package/packs/gallery/heatmap/style.css +189 -0
  279. package/packs/gallery/heatmap/template.html +3 -0
  280. package/packs/gallery/heatmap/writing.md +21 -0
  281. package/packs/gallery/kanban/component.json +18 -0
  282. package/packs/gallery/kanban/example.html +12 -0
  283. package/packs/gallery/kanban/kit.js +540 -0
  284. package/packs/gallery/kanban/preview.svg +1 -0
  285. package/packs/gallery/kanban/style.css +212 -0
  286. package/packs/gallery/kanban/template.html +3 -0
  287. package/packs/gallery/kanban/writing.md +20 -0
  288. package/packs/gallery/metric/component.json +22 -0
  289. package/packs/gallery/metric/example.html +15 -0
  290. package/packs/gallery/metric/kit.js +248 -0
  291. package/packs/gallery/metric/preview.svg +1 -0
  292. package/packs/gallery/metric/style.css +92 -0
  293. package/packs/gallery/metric/template.html +3 -0
  294. package/packs/gallery/metric/writing.md +23 -0
  295. package/packs/gallery/note/component.json +14 -0
  296. package/packs/gallery/note/example.html +3 -0
  297. package/packs/gallery/note/kit.js +129 -0
  298. package/packs/gallery/note/preview.svg +1 -0
  299. package/packs/gallery/note/style.css +97 -0
  300. package/packs/gallery/note/template.html +3 -0
  301. package/packs/gallery/note/writing.md +18 -0
  302. package/packs/gallery/pack.json +8 -0
  303. package/packs/gallery/recent/component.json +13 -0
  304. package/packs/gallery/recent/example.html +1 -0
  305. package/packs/gallery/recent/kit.js +293 -0
  306. package/packs/gallery/recent/preview.svg +1 -0
  307. package/packs/gallery/recent/style.css +85 -0
  308. package/packs/gallery/recent/template.html +1 -0
  309. package/packs/gallery/recent/writing.md +15 -0
  310. package/packs/gallery/static/component.json +13 -0
  311. package/packs/gallery/static/example.html +11 -0
  312. package/packs/gallery/static/preview.svg +1 -0
  313. package/packs/gallery/static/style.css +171 -0
  314. package/packs/gallery/static/template.html +1 -0
  315. package/packs/gallery/static/writing.md +18 -0
  316. package/packs/gallery/stats/component.json +13 -0
  317. package/packs/gallery/stats/example.html +1 -0
  318. package/packs/gallery/stats/kit.js +347 -0
  319. package/packs/gallery/stats/preview.svg +1 -0
  320. package/packs/gallery/stats/style.css +73 -0
  321. package/packs/gallery/stats/template.html +1 -0
  322. package/packs/gallery/stats/writing.md +11 -0
  323. package/packs/gallery/today/component.json +12 -0
  324. package/packs/gallery/today/example.html +1 -0
  325. package/packs/gallery/today/kit.js +220 -0
  326. package/packs/gallery/today/preview.svg +1 -0
  327. package/packs/gallery/today/style.css +149 -0
  328. package/packs/gallery/today/template.html +1 -0
  329. package/packs/gallery/today/writing.md +14 -0
  330. package/packs/gallery/todos/component.json +19 -0
  331. package/packs/gallery/todos/example.html +3 -0
  332. package/packs/gallery/todos/kit.js +489 -0
  333. package/packs/gallery/todos/preview.svg +1 -0
  334. package/packs/gallery/todos/style.css +214 -0
  335. package/packs/gallery/todos/template.html +3 -0
  336. package/packs/gallery/todos/writing.md +30 -0
  337. package/packs/gallery/weather/component.json +19 -0
  338. package/packs/gallery/weather/example.html +3 -0
  339. package/packs/gallery/weather/kit.js +387 -0
  340. package/packs/gallery/weather/preview.svg +1 -0
  341. package/packs/gallery/weather/style.css +140 -0
  342. package/packs/gallery/weather/template.html +3 -0
  343. package/packs/gallery/weather/writing.md +26 -0
  344. package/packs/gallery-soft/countdown/component.json +18 -0
  345. package/packs/gallery-soft/countdown/example.html +3 -0
  346. package/packs/gallery-soft/countdown/kit.js +206 -0
  347. package/packs/gallery-soft/countdown/preview.svg +1 -0
  348. package/packs/gallery-soft/countdown/style.css +211 -0
  349. package/packs/gallery-soft/countdown/template.html +3 -0
  350. package/packs/gallery-soft/countdown/writing.md +24 -0
  351. package/packs/gallery-soft/habit/component.json +14 -0
  352. package/packs/gallery-soft/habit/example.html +3 -0
  353. package/packs/gallery-soft/habit/kit.js +366 -0
  354. package/packs/gallery-soft/habit/preview.svg +1 -0
  355. package/packs/gallery-soft/habit/style.css +251 -0
  356. package/packs/gallery-soft/habit/template.html +3 -0
  357. package/packs/gallery-soft/habit/writing.md +23 -0
  358. package/packs/gallery-soft/heatmap/component.json +18 -0
  359. package/packs/gallery-soft/heatmap/example.html +3 -0
  360. package/packs/gallery-soft/heatmap/kit.js +498 -0
  361. package/packs/gallery-soft/heatmap/preview.svg +1 -0
  362. package/packs/gallery-soft/heatmap/style.css +181 -0
  363. package/packs/gallery-soft/heatmap/template.html +3 -0
  364. package/packs/gallery-soft/heatmap/writing.md +23 -0
  365. package/packs/gallery-soft/note/component.json +14 -0
  366. package/packs/gallery-soft/note/example.html +3 -0
  367. package/packs/gallery-soft/note/kit.js +162 -0
  368. package/packs/gallery-soft/note/preview.svg +1 -0
  369. package/packs/gallery-soft/note/style.css +148 -0
  370. package/packs/gallery-soft/note/template.html +3 -0
  371. package/packs/gallery-soft/note/writing.md +20 -0
  372. package/packs/gallery-soft/pack.json +8 -0
  373. package/packs/gallery-soft/recent/component.json +13 -0
  374. package/packs/gallery-soft/recent/example.html +1 -0
  375. package/packs/gallery-soft/recent/kit.js +335 -0
  376. package/packs/gallery-soft/recent/preview.svg +1 -0
  377. package/packs/gallery-soft/recent/style.css +160 -0
  378. package/packs/gallery-soft/recent/template.html +1 -0
  379. package/packs/gallery-soft/recent/writing.md +17 -0
  380. package/packs/gallery-soft/static/component.json +13 -0
  381. package/packs/gallery-soft/static/example.html +12 -0
  382. package/packs/gallery-soft/static/preview.svg +1 -0
  383. package/packs/gallery-soft/static/style.css +186 -0
  384. package/packs/gallery-soft/static/template.html +1 -0
  385. package/packs/gallery-soft/static/writing.md +20 -0
  386. package/packs/gallery-soft/stats/component.json +13 -0
  387. package/packs/gallery-soft/stats/example.html +1 -0
  388. package/packs/gallery-soft/stats/kit.js +341 -0
  389. package/packs/gallery-soft/stats/preview.svg +1 -0
  390. package/packs/gallery-soft/stats/style.css +119 -0
  391. package/packs/gallery-soft/stats/template.html +1 -0
  392. package/packs/gallery-soft/stats/writing.md +13 -0
  393. package/packs/gallery-soft/today/component.json +12 -0
  394. package/packs/gallery-soft/today/example.html +1 -0
  395. package/packs/gallery-soft/today/kit.js +222 -0
  396. package/packs/gallery-soft/today/preview.svg +1 -0
  397. package/packs/gallery-soft/today/style.css +178 -0
  398. package/packs/gallery-soft/today/template.html +1 -0
  399. package/packs/gallery-soft/today/writing.md +16 -0
  400. package/packs/gallery-soft/todos/component.json +19 -0
  401. package/packs/gallery-soft/todos/example.html +3 -0
  402. package/packs/gallery-soft/todos/kit.js +527 -0
  403. package/packs/gallery-soft/todos/preview.svg +1 -0
  404. package/packs/gallery-soft/todos/style.css +212 -0
  405. package/packs/gallery-soft/todos/template.html +3 -0
  406. package/packs/gallery-soft/todos/writing.md +32 -0
  407. package/packs/gallery-soft/weather/component.json +19 -0
  408. package/packs/gallery-soft/weather/example.html +3 -0
  409. package/packs/gallery-soft/weather/kit.js +411 -0
  410. package/packs/gallery-soft/weather/preview.svg +1 -0
  411. package/packs/gallery-soft/weather/style.css +185 -0
  412. package/packs/gallery-soft/weather/template.html +3 -0
  413. package/packs/gallery-soft/weather/writing.md +28 -0
  414. package/release.json +12 -10
  415. package/sdk/doc-kit.d.ts +396 -5
  416. package/sdk/doc-state.d.ts +2 -0
  417. package/skill/SKILL.md +56 -23
  418. package/skill/references/block-script.md +140 -0
  419. package/skill/references/building-blocks.md +257 -0
  420. package/skill/references/extensions.md +59 -0
  421. package/skill/references/pages-and-data.md +225 -0
  422. package/skill/references/writing-html.md +8 -4
  423. package/skill/sdk/doc-kit.d.ts +396 -5
  424. package/skill/sdk/doc-state.d.ts +2 -0
  425. package/web/assets/index-BM_K-Auu.css +1 -0
  426. package/web/assets/index-DRslOBiv.js +15 -0
  427. package/web/index.html +2 -2
  428. package/dist/chunk-3HIRPVLU.mjs +0 -2
  429. package/dist/chunk-5MHMDLZD.mjs +0 -4
  430. package/dist/chunk-64K7IPLO.mjs +0 -255
  431. package/dist/chunk-6QXGZM36.mjs +0 -8
  432. package/dist/chunk-6RGJOMJP.mjs +0 -16
  433. package/dist/chunk-AJ73XJF3.mjs +0 -2
  434. package/dist/chunk-AUZGSZJH.mjs +0 -13
  435. package/dist/chunk-BFE45AKL.mjs +0 -2
  436. package/dist/chunk-BXO2ZY5P.mjs +0 -2
  437. package/dist/chunk-CEH4MRCC.mjs +0 -2
  438. package/dist/chunk-CY2FNNAB.mjs +0 -16
  439. package/dist/chunk-DFUDV4LX.mjs +0 -2
  440. package/dist/chunk-DKXG4XDG.mjs +0 -2
  441. package/dist/chunk-EZQ34M3F.mjs +0 -124
  442. package/dist/chunk-EZY3WC6Z.mjs +0 -15
  443. package/dist/chunk-FUKQNOQS.mjs +0 -9
  444. package/dist/chunk-JPOSLGOC.mjs +0 -6
  445. package/dist/chunk-JVHHHGEA.mjs +0 -3
  446. package/dist/chunk-L3QKH4OK.mjs +0 -26
  447. package/dist/chunk-LAE5NQ4B.mjs +0 -2
  448. package/dist/chunk-LEF6DRCK.mjs +0 -59
  449. package/dist/chunk-NO5NJCHO.mjs +0 -2
  450. package/dist/chunk-NQPVAU63.mjs +0 -2
  451. package/dist/chunk-NSKUTQ5J.mjs +0 -5
  452. package/dist/chunk-O35FIXRB.mjs +0 -2
  453. package/dist/chunk-P2CAZPDP.mjs +0 -3
  454. package/dist/chunk-PL6GHLGD.mjs +0 -15
  455. package/dist/chunk-QJIR2BLP.mjs +0 -6
  456. package/dist/chunk-QUPLVPB2.mjs +0 -7
  457. package/dist/chunk-R7BNENLY.mjs +0 -4
  458. package/dist/chunk-S6O4UHLC.mjs +0 -2
  459. package/dist/chunk-SGJWQKEI.mjs +0 -2
  460. package/dist/chunk-TX6JH7TR.mjs +0 -2
  461. package/dist/chunk-TYK6VNAB.mjs +0 -10
  462. package/dist/chunk-UALRNVSE.mjs +0 -4
  463. package/dist/chunk-V3HXVQEM.mjs +0 -2
  464. package/dist/chunk-V5VXUJKG.mjs +0 -2
  465. package/dist/chunk-VBXMADMP.mjs +0 -2
  466. package/dist/chunk-VNV55RUA.mjs +0 -2
  467. package/dist/chunk-VPD2PS35.mjs +0 -2
  468. package/dist/chunk-W4VKN3GF.mjs +0 -7
  469. package/dist/chunk-W5BXXPDJ.mjs +0 -3
  470. package/dist/chunk-XUNHRCOG.mjs +0 -6
  471. package/skill/references/building-components.md +0 -367
  472. package/web/assets/index-Bh74DfsV.css +0 -1
  473. package/web/assets/index-UW0RyFFt.js +0 -13
@@ -0,0 +1,16 @@
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 je}from"./chunk-JEUK3ZO7.mjs";import{a as Te,b as Ne,c as Xe,d as Ze,g as Oe,h as et}from"./chunk-PUOQ65NC.mjs";import{g as Qe}from"./chunk-ITOH5EGO.mjs";import{b as Se}from"./chunk-ZQS6H473.mjs";import{p as Ee}from"./chunk-MXUBKDRO.mjs";import{a as le}from"./chunk-HYMEEXKN.mjs";import{a as ve,f as Ye,p as ze}from"./chunk-HDWTZ763.mjs";import T from"node:fs/promises";import he from"node:os";import x from"node:path";import{pathToFileURL as Re}from"node:url";import{instancesOf as ot,isInstance as bt}from"../browser/shared/components/index.mjs";import{ATTRIBUTE as $t,FALLBACK as xt,INSTANCE as de,SLOT as vt,SLOT_PART as tt}from"../browser/shared/components/installed.mjs";import{jsonIn as Et}from"../browser/shared/json-layout.mjs";import{QUERY_ROUTE as St}from"../browser/shared/workspace-query.mjs";import{documentDirectory as jt,documentFiles as Tt,layoutOf as it,listDocumentSlugs as Nt,PACKAGE_MANIFEST as Ot}from"../browser/shared/workspace.mjs";var At="in a browser, under the export's policy",ce=(e=null)=>e?`the instances in ${e}, in a browser under the export's policy`:"the workspace's documents",q="component-check",ae=[360,736,1024],Ae=["light","dark"],Lt=[1024,360],nt=1e4,rt=6e4,se=3e4,Dn=12e4,lt=2e3,Rt=3e3,Dt=60,Mn=15e3,Mt=2,Pt=8,Ct=se/2,_t=/^(?:wasm-)?eval$/,It=new Set(["TargetCloseError","ConnectionClosedError"]),Pn=e=>e.evaluateOnNewDocument(Ft,St);function Ft(e){let t=globalThis.fetch;if(typeof t!="function"||globalThis.__galleryQueries)return;let i={pending:new Map,count:0};globalThis.__galleryQueries=i,globalThis.fetch=function(r,n){let a=t.apply(this,arguments);try{let p=new URL(typeof r=="string"?r:r?.url??String(r),location.href);if(p.pathname===e){let u=++i.count,w=/\/__gallery\/components\/([a-z0-9-]+\/[a-z0-9-]+)\/kit\.js/.exec(new Error().stack??"");i.pending.set(u,{kind:p.searchParams.get("kind"),block:w?w[1]:null,at:Date.now()});let l=()=>{i.pending.delete(u)};Promise.resolve(a).then(l,l)}}catch{}return a}}var oe=e=>String(e?.message??e).split(`
3
+ `)[0],ct=(e,t)=>`<!doctype html><html lang="zh-CN"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><title>${e}</title></head><body><main class="doc-page" data-doc-id="${e}">${t}
4
+ </main></body></html>
5
+ `,Bt=({example:e,template:t})=>`<p>example.html</p>${e}
6
+ <hr><p>template.html</p>${t}`,Ht=e=>{for(let t=e.parentNode;t;t=t.parentNode)if(bt(t))return!0;return!1},dt=(e,t)=>ot(e,t).filter(i=>!Ht(i)),De=(e,t)=>dt(le(e),t).map(({sourceCodeLocation:{startLine:i,startOffset:r,endOffset:n}})=>({line:i,markup:e.slice(r,n)}));async function ht(e,t){let i=x.join(t,"components",...e.id.split("/"));for(let r of[Ot,"template.html",...e.files]){let n=ze(e,r);if(!n)continue;let a=await T.readFile(n);await T.mkdir(x.dirname(x.join(i,r)),{recursive:!0}),await T.writeFile(x.join(i,r),r==="kit.js"?`${a}
7
+ //# sourceURL=kit.js
8
+ `:a)}}async function Wt(e,{example:t,template:i},r){await ht(e,r);let n=x.join(r,q);await T.mkdir(n);let a=`${t}
9
+ `,p=Se(ct(q,Bt({example:t,template:i}))).text;await T.writeFile(x.join(n,"doc.html"),p),await T.writeFile(x.join(n,"doc.json"),JSON.stringify({title:q,description:q,type:"component"}));let w=await(await Ee({directory:r}))(q),l=x.join(r,"export.html");await T.writeFile(l,w);let f=a.split(`
10
+ `).length-1,s=De(p,e).map(({line:c})=>c>f?{file:"template.html",line:c-f}:{file:"example.html",line:c});return{html:w,file:l,places:s,source:p}}function qt({match:e,instance:t,slot:i,parts:r,boards:n}){if(!Object.entries(r).some(([l,{edit:f}])=>f==="data"&&!n.includes(l)))return[];let a=[...document.querySelectorAll(e)].filter(l=>!l.parentElement.closest(t)),p=l=>l.parentElement?.closest(`${t}, ${i}`)??null,u=l=>`<${l.localName}${l.classList.length?` class="${l.getAttribute("class")}"`:""}>`,w=l=>{let f=(l.textContent||l.getAttribute("aria-label")||l.getAttribute("placeholder")||l.getAttribute("title")||"").replace(/\s+/g," ").trim().slice(0,24);return`${u(l)}${f?` "${f}"`:""}`};return a.flatMap((l,f)=>{let s=[...l.querySelectorAll("button, input, select, textarea")].filter(c=>p(c)===l).filter(c=>{if(c.disabled||c.readOnly||c.type==="hidden")return!1;let h=c.getBoundingClientRect(),b=getComputedStyle(c);return h.width>0&&h.height>0&&b.visibility!=="hidden"&&b.display!=="none"});return s.length?[{at:f,what:s.slice(0,3).map(w).join(", "),counts:[s.length]}]:[]})}async function Gt({match:e,instance:t,slotPart:i,slotName:r,fallback:n,parts:a,boards:p,at:u,source:w,still:l,step:f,times:s,typed:c,typing:h}){let b=()=>[...document.querySelectorAll(e)].filter(o=>!o.parentElement.closest(t)),k=o=>new Promise(d=>setTimeout(d,o)),g=()=>new Promise(o=>{requestAnimationFrame(o),setTimeout(o,100)}),m=async o=>{await g(),await g();let d=o.outerHTML;for(let y=0,v=Date.now()+l;y<3;){if(Date.now()>v)return null;await k(f);let E=o.outerHTML;y=E===d?y+1:0,d=E}return d},_=o=>{let d=document.createElement("template");return d.innerHTML=o,d.content.firstElementChild},$=o=>`<${o.localName}${o.classList.length?` class="${o.getAttribute("class")}"`:""}>`,S=o=>o.nodeType===1?$(o):`the words "${o.data.trim().slice(0,40)}"`,B=o=>[...o.childNodes].filter(d=>d.nodeType===1||d.nodeType===3&&d.data.trim()),H=(o,d)=>["style","class"].includes(d)&&!o.getAttribute(d)?.trim()?null:o.getAttribute(d),D=(o,d)=>{for(let E of new Set([...o.getAttributeNames(),...d.getAttributeNames()]))if(H(o,E)!==H(d,E))return`${E} on ${$(d)}, ${JSON.stringify(H(o,E))} then ${JSON.stringify(H(d,E))}`;let[y,v]=[B(o),B(d)];for(let E=0;E<Math.max(y.length,v.length);E++){let[N,M]=[y[E],v[E]];if(!N||!M)return`${$(d)} ${N?`without ${S(N)}`:`with ${S(M)} more`}`;if(N.nodeType!==M.nodeType||N.localName!==M.localName||N.nodeType===3&&N.data.trim()!==M.data.trim())return`in ${$(d)}, ${S(N)} then ${S(M)}`;let I=N.nodeType===1?D(N,M):null;if(I)return I}return null},pe=o=>{let d=new Map;for(let y of o)d.set($(y),(d.get($(y))??0)+1);return d},Ce=()=>[...document.querySelectorAll("*")].filter(o=>!o.closest(t)),_e=o=>[...o.at(-1).keys()].filter(d=>o.length>2&&o.every((y,v)=>v===0||(y.get(d)??0)>(o[v-1].get(d)??0))),Ie=o=>o.parentElement?.closest(`${t}, ${i}`)??null,Fe=o=>[...o.querySelectorAll(i)].filter(d=>Ie(d)===o),G=o=>{let d=o.cloneNode(!0);return Fe(d).forEach(y=>y.replaceChildren()),d},Z=o=>Fe(o).map(d=>{let y=[];for(let v=d.parentElement;v&&v!==o;v=v.parentElement)y.unshift($(v));return{name:d.getAttribute(r),place:y.join(" > "),blocks:[...DocKit.dehydrate(d.cloneNode(!0)).children].map(v=>v.localName).join(" "),html:DocKit.dehydrate(d.cloneNode(!0)).outerHTML}}),ue=(o,d,y,{markup:v=!0}={})=>o.flatMap(({name:E,place:N,blocks:M,html:I})=>{let A=d.find(W=>W.name===E),X=A?A.place!==N?`moved the slot ${E} (${A.place?`in ${A.place}`:"straight in the instance"}, where the file has it ${N?`in ${N}`:"straight in the instance"})`:A.blocks!==M?`changed the blocks the slot ${E} holds (${M||"none"}, then ${A.blocks||"none"})`:v&&A.html!==I?`changed what the slot ${E} holds`:null:`took the slot ${E} off the instance`;return X?[{kind:"written-in",part:E,how:`${X}, ${y}`}]:[]}),Be=o=>d=>Ie(d)===o,we=(o,d=()=>!0)=>Object.entries(a).filter(([,{edit:y}])=>d(y)).flatMap(([y,v])=>[...o.querySelectorAll(v.at)].filter(Be(o)).map(E=>({name:y,node:E}))),ee=o=>we(o,d=>d==="text"),K=o=>Object.entries(a).filter(([,{edit:d}])=>d==="data").map(([d,y])=>({name:d,node:[...o.querySelectorAll(y.at)].find(Be(o))})).filter(({node:d})=>d),C=[],V=b()[u];if(!V)return[{kind:"gone"}];if(V.hasAttribute(n))return[{kind:"fallback"}];let fe=await m(V);if(fe===null)return[{kind:"moving"}];let ie=_(w),He=Z(V);C.push(...ue(Z(ie),He,"as it mounts",{markup:!1}));let me=ee(ie);ee(V).forEach(({name:o,node:d},y)=>{me[y]&&me[y].node.innerHTML!==d.innerHTML&&C.push({kind:"redrawn",part:o,how:`the file says ${JSON.stringify(me[y].node.textContent.trim())}, the page ${JSON.stringify(d.textContent.trim())}`})});let ge=DocKit.dehydrate(V.cloneNode(!0)),[We,qe]=[G(ie),G(ge)],ke=D(We,qe);if(ke){let o=we(qe),d=we(We).find(({node:y},v)=>o[v]&&D(y,o[v].node))?.name;C.push({kind:"left",what:ke,...d?{part:d}:{}})}let ft=K(ge);for(let[o,{name:d,node:y}]of K(ie).entries())!ke&&ft[o]?.node.innerHTML!==y.innerHTML&&C.push({kind:"data",part:d});let Q=[],ye=new MutationObserver(o=>Q.push(...o));ye.observe(document.documentElement,{subtree:!0,childList:!0,characterData:!0});let Ge=new Set,Ue=o=>{Q.push(...ye.takeRecords());for(let{name:d,node:y}of o)(!y.isConnected||Q.some(({target:v})=>y.contains(v)))&&Ge.add(d);Q.length=0},be=[fe],$e=[pe(Ce())],Je=o=>{be.push(o),$e.push(pe(Ce())),C.push(...ue(He,Z(j),"as it mounts again"))},j=ge,xe=ee(j);Q.length=0,V.replaceWith(j);let U=await m(j);if(Ue(xe),U!==null){Je(U);for(let o=0;o<s&&U!==null;o++){let d=j.cloneNode(!0);xe=ee(d),Q.length=0,j.replaceWith(d),j=d,U=await m(j),Ue(xe),U!==null&&Je(U)}}ye.disconnect(),U===null&&C.push({kind:"moving"});for(let o of Ge)C.push({kind:"redrawn",part:o,how:"a mount changes it"});let Ke=be.map(o=>pe(G(_(o)).querySelectorAll("*"))),Ve=_e(Ke);for(let o of Ve)C.push({kind:"piles",what:o,counts:Ke.map(d=>d.get(o)??0)});for(let o of _e($e))C.push({kind:"piles",what:o,outside:!0,counts:$e.map(d=>d.get(o)??0)});if(!Ve.length){let o=be.slice(1).map(d=>D(G(_(fe)),G(_(d)))).find(Boolean);o&&C.push({kind:"changed",what:o})}let re=U===null?[]:ee(j).filter(({node:o})=>o.textContent.trim()),mt=[...new Set([...new Map(re.map(o=>[o.name,o])).values(),...re])].slice(0,c),gt=Date.now()+h;for(let{node:o}of mt){if(Date.now()>gt)break;let d=document.createTreeWalker(o,NodeFilter.SHOW_TEXT).nextNode(),y=d.data;d.data=`${y}\u2026`;let v=re.map(({node:N})=>N.textContent);await m(j);let E=re.find(({node:N},M)=>!N.isConnected||N.textContent!==v[M]);if(E){C.push({kind:"redrawn",part:E.name,how:"a change of its words does not stand"});break}d.data=y,await m(j)}return U!==null&&K(j).length>0&&C.push(...await kt()),C;async function kt(){let o=[],d=null,y=!1,v="as it hears that it can write (the editable signal)",E=[],N=I=>{if(I.target!==j)return;let{parts:A,run:X}=I.detail,W=A.map(({part:O})=>O.innerHTML),P=A.map(({part:O})=>O.cloneNode(!0)),te=X(Object.fromEntries(A.map(({name:O},R)=>[O,P[R]]))),J=A.find(({part:O},R)=>O.innerHTML!==W[R]),Y=A.find(({part:O},R)=>P[R].cloneNode(!1).outerHTML!==O.cloneNode(!1).outerHTML);if(J&&A.forEach(({part:O},R)=>{O.innerHTML=W[R]}),!y){let O=J??Y??A.find((R,ne)=>P[ne].innerHTML!==W[ne]);O&&!E.some(R=>R.when===v)?E.push({kind:"unasked",part:O.name,when:v}):te&&!O&&I.preventDefault();return}J?d??=`it writes the part ${J.name} on the page, not the draft context.edit hands it, so the editor refuses the edit`:te&&Y&&(d??=`it changes the part ${Y.name}'s own tag or attributes, which are the file's: a change writes what a part holds, so the editor refuses the edit`),!(J||!te||Y)&&(A.forEach(({part:O},R)=>{o.push({part:O,before:W[R]}),O.replaceChildren(...P[R].childNodes)}),I.preventDefault())};document.addEventListener("doc-component-edit",N);try{return[...await M(),...E]}finally{document.removeEventListener("doc-component-edit",N)}async function M(){dispatchEvent(new Event("doc-editable")),await m(j),v="as it mounts";let I=j.cloneNode(!0);j.replaceWith(I),j=I;let A=await m(j);v="as it hears its part changed (the source signal)";let X=Z(j),W=DocKit.dehydrate(j.cloneNode(!0)),P=[];y=!0;try{if(!DocKit.example(j))return K(j).every(({name:F})=>p.includes(F))?[]:[{kind:"no-example"}]}catch(F){return[{kind:"example",what:`it throws: ${F?.message??F}`}]}finally{y=!1}let te=await m(j),J=DocKit.dehydrate(j.cloneNode(!0)),Y=Object.fromEntries(K(J).map(({name:F,node:z},yt)=>[F,z.innerHTML,K(W)[yt]?.node.innerHTML]).filter(([,F,z])=>F!==z));d?P.push({kind:"example",what:d}):o.length===0?P.push({kind:"example",what:"context.edit was not taken: it was not called, or it answered false, and the console says why"}):Object.keys(Y).length===0?P.push({kind:"example",what:"it changes nothing a part holds"}):P.push({kind:"wrote",parts:Y});for(let F of[W,J])for(let{node:z}of K(F))z.textContent="";let O=D(G(W),G(J));O&&P.push({kind:"example",what:`it changes what is no data part: ${O}`}),P.push(...ue(X,Z(j),"as its example makes its edit"));for(let{part:F,before:z}of o.reverse())F.innerHTML=z;let R=await m(j),ne=A!==null&&R!==null?D(G(_(A)),G(_(R))):null;return te===null||R===null?P.push({kind:"moving"}):ne&&!O&&P.push({kind:"undo",what:ne}),P}}}var Ut=e=>e.map(({name:t,removed:i,added:r,lines:n})=>`${t} (-${i} +${r} of its ${n} line${n===1?"":"s"})`).join(" and "),Jt="a write changes the lines it means and no others: a row moved by context.rows, which takes the blank before it along, JSON written back by context.editJSON and laid out in template.html and example.html as it writes it (block-script.md, Two examples)";function Le(e,t){try{return JSON.parse(e),Et(e,JSON.parse(t))===t}catch{return!1}}var Kt="it changes nothing a part holds";function Vt({kind:e,what:t,part:i,how:r,when:n,counts:a,outside:p,parts:u,back:w,line:l,json:f},s,{script:c}){let h=k=>({...s,what:k}),b=k=>({...s,what:k,note:!0});switch(e){case"wrote":return{...s,told:!0,what:`its example wrote ${Ut(u)}; the server took it${w?"; put back as an undo does, it shows what it showed":""}`};case"laid":return b(`its example's write lays the part ${i} out anew (${r}): ${Jt}${f?`; this write is context.editJSON's, and what the file held is laid out otherwise: lay ${i} out as it writes it`:""}`);case"drops":return{...b(`${t} listens for dragover and not for dragenter: a drop goes where both are cancelled, and the move that enters it asks dragenter alone, so that a release then (on a card's words, its padding) drops nothing: cancel dragenter as dragover is cancelled (preventDefault)`),file:"kit.js",line:l};case"controls":return{...b(`where nothing is written (this look is an export: context.canEdit() is false) the instance of ${s.file}${s.line?`:${s.line}`:""} still shows ${t}${a[0]>3?` and ${a[0]-3} more`:""}, enabled, and the block has a data part: a reader presses a control that writes to no effect, and the export says the block can be edited. Draw a control that writes only while context.canEdit(), and hide it by the hidden attribute (the kit holds [hidden] over any display the style gives it) or disable it; ignore this for a control that only changes what a reader looks at, a filter or a tab, which an export keeps. Compare 1024-light.png with edit-1024-light.png: the second is what a reader who can edit sees`),file:"kit.js",line:void 0};case"gone":return h("the page does not hold this instance");case"fallback":return h(c?"its component failed or never started: the instance shows what it holds, read-only":"the instance shows as one of no custom block");case"moving":return b("what it shows never holds still (an animation?), so its mounts could not be compared");case"redrawn":return h(`the component redraws its text part ${i}: ${r}. A text part is the file's, what the user types in: read it, and draw in what is the component's`);case"left":return h(`dehydrate does not leave it as the file has it, so a copy of the view would hold what the kit made of it: ${t}. ${i?`That stands in its part ${i}, which is the file's: read a part, and draw in what is the component's`:"Name what it draws in the manifest's runtime, or take it off in dehydrate"}`);case"data":return h(`a mount changes its data part ${i}, so that a page would write what the component left there, with nothing edited: read a data part, and change it by context.edit alone`);case"no-example":return b("it has a data part and its component offers no example of an edit, so nothing has tried the way back to the file: give DocKit.component an example(host, context) that makes a small context.edit");case"example":return t===Kt?{...s,file:"kit.js",line:void 0,what:`its example(host, context) changes nothing a part holds on the instance of ${s.file}${s.line?`:${s.line}`:""}: the check runs it on every instance of example.html and of template.html, and template.html's is empty, with nothing to change a value of (the first entry of a list it does not hold yet). Make example() make a change that works on an empty instance too (add an entry, set a field), and have it call the function a reader's control calls, so that it tries the code a reader runs`}:h(`its example: ${t}`);case"refused":return h("what its example wrote cannot go in the file: a script, a handler, an address of code, data-block-id or data-ge-*, what does not read back as itself, or what is no JSON in a script of data");case"undo":return h(`with what its example wrote put back, as an undo does, it does not show what it showed: ${t}: draw from the part, and on the source signal`);case"unasked":return h(`it writes its data part ${i} with no reader's gesture, ${n}, once the page takes edits: a page would write it each time it opened. Call context.edit on a gesture alone, a press, a drop or a key, and draw what the part holds as it is`);case"written-in":return h(`kit.js ${r}: a slot is the document's, its blocks the reader's: read it with context.part, never write in it or move it, and draw outside it`);case"piles":return h(p?`${t} piles up outside the instance on each put-back (${a.join(", then ")} of them), so an undo adds another: a component draws in its instance, and what it has to put elsewhere it takes away again in destroy`:`${t} piles up on each put-back (${a.join(", then ")} of them): it is declared in neither the manifest's runtime nor dehydrate, so an undo adds another`);default:return h(`a mount does not give the same DOM again: ${t}`)}}var Yt=e=>[...new Map(e.toReversed().map(t=>[`${t.finding.kind}|${t.finding.part??""}|${["piles","example"].includes(t.finding.kind)?t.finding.what:""}|${t.finding.when??""}|${t.finding.line??""}`,t])).values()].toReversed(),zt=4e6;function Me(e,t,i=(r,n)=>r===n){let[r,n]=[e.split(`
11
+ `),t.split(`
12
+ `)],a=0;for(;a<r.length&&a<n.length&&i(r[a],n[a]);)a++;let p=0;for(;p<r.length-a&&p<n.length-a&&i(r[r.length-1-p],n[n.length-1-p]);)p++;let[u,w]=[r.slice(a,r.length-p),n.slice(a,n.length-p)];if(u.length===0&&w.length===0)return[];if(u.length*w.length>zt)return[{removed:u,added:w}];let l=Array.from({length:u.length+1},()=>new Uint32Array(w.length+1));for(let c=u.length-1;c>=0;c--)for(let h=w.length-1;h>=0;h--)l[c][h]=i(u[c],w[h])?l[c+1][h+1]+1:Math.max(l[c+1][h],l[c][h+1]);let f=[],s=null;for(let c=0,h=0;c<u.length||h<w.length;)c<u.length&&h<w.length&&i(u[c],w[h])?(s=null,c++,h++):(s||f.push(s={removed:[],added:[]}),h<w.length&&(c===u.length||l[c][h+1]>=l[c+1][h])?s.added.push(w[h++]):s.removed.push(u[c++]));return f}function Qt(e,t){let i=n=>n.filter(a=>a.trim()).length,r=Me(e,t);return{removed:r.reduce((n,a)=>n+i(a.removed),0),added:r.reduce((n,a)=>n+i(a.added),0),lines:i(e.split(`
13
+ `))}}function Cn(e,t){let i=r=>r.map(n=>n.trim()).filter(Boolean);return Me(e,t).map(({removed:r,added:n})=>({removed:i(r),added:i(n)})).filter(({removed:r,added:n})=>r.length+n.length>0)}function at(e,t){let i=0,r=0;for(let[n,a]of e.entries())if(n>0&&i>0&&i<t&&r++,i+=a.replace(/\s+/g,"").length,i>=t)break;return r}function Xt(e,t){let i=r=>r.filter(n=>!n.trim()).length;for(let{removed:r,added:n}of Me(e,t,(a,p)=>a.trim()===p.trim())){if(i(n)>i(r))return"a line left blank";let[a,p]=[r.join("").replace(/\s+/g,""),n.join("").replace(/\s+/g,"")],u=0;for(;u<a.length&&u<p.length&&a[u]===p[u];)u++;let w=0;for(;w<a.length-u&&w<p.length-u&&a[a.length-1-w]===p[p.length-1-w];)w++;for(let[l,f,s]of[[u,r,n],[w,r.toReversed(),n.toReversed()]]){let[c,h]=[at(f,l)+1,at(s,l)+1];if(c!==h)return`${c} line${c===1?"":"s"} became ${h}`}}return null}function Zt(e,t){let i=Xt(e,t);return i&&!(Le(e,t)&&Le(e,e))?i:null}function en(e,{source:t,found:i,at:r,findings:n}){let a=Qe(t,dt(le(t),i)[r],e.parts,new Map([[i.id,i]]));if(!a)return[{kind:"refused"}];let p=Object.keys(e.parts),u=a.map(({start:l,end:f,text:s},c)=>({name:p[c],before:t.slice(l,f),after:s}));return[{kind:"wrote",back:!n.some(({kind:l})=>l==="undo"||l==="moving"),parts:u.map(({name:l,before:f,after:s})=>({name:l,...Qt(f,s)}))},...u.flatMap(({name:l,before:f,after:s})=>{let c=Zt(f,s);return c?[{kind:"laid",part:l,how:c,json:Le(f,s)}]:[]})]}var tn=2e3;function nn({match:e,instance:t,at:i,most:r}){let n=[...document.querySelectorAll(e)].filter(a=>!a.parentElement.closest(t))[i];return n?[window,document,n,...n.querySelectorAll("*")].slice(0,r):[]}function an(e){return e.map((t,i)=>i<2?{parent:i-1,named:""}:{parent:i===2?1:e.indexOf(t.parentElement),named:`<${t.localName}${t.classList.length?` class="${t.getAttribute("class")}"`:""}>`})}function sn(){let e=new DragEvent("dragenter",{bubbles:!0,cancelable:!0,composed:!0,dataTransfer:new DataTransfer});return this.dispatchEvent(e),e.defaultPrevented}async function on(e,{match:t,at:i}){let r=new Map,n=({scriptId:a,url:p})=>r.set(a,p);e.on("Debugger.scriptParsed",n);try{await e.send("Debugger.enable"),await e.send("Debugger.setSkipAllPauses",{skip:!0});let{result:a}=await e.send("Runtime.evaluate",{expression:`(${nn})(${JSON.stringify({match:t,instance:de,at:i,most:tn})})`,objectGroup:"drops"}),{result:p}=await e.send("Runtime.callFunctionOn",{objectId:a.objectId,functionDeclaration:String(an),arguments:[{objectId:a.objectId}],returnByValue:!0}),{result:u}=await e.send("Runtime.getProperties",{objectId:a.objectId,ownProperties:!0}),w=u.filter(({name:c,value:h})=>/^\d+$/.test(c)&&h?.objectId).sort((c,h)=>Number(c.name)-Number(h.name)),l=[];for(let{value:c}of w)l.push((await e.send("DOMDebugger.getEventListeners",{objectId:c.objectId})).listeners);let f=(c,h)=>l[c]?.some(b=>b.type===h),s=[];for(let c=2;c<l.length;c++){let h=l[c].find(k=>k.type==="dragover"&&r.get(k.scriptId)==="kit.js");if(!h)continue;let b=!1;for(let k=c;k>=2&&!b;k=p.value[k].parent)b=f(k,"dragenter");if(!b&&(f(0,"dragenter")||f(1,"dragenter"))){let{result:k}=await e.send("Runtime.callFunctionOn",{objectId:w[c].value.objectId,functionDeclaration:String(sn),returnByValue:!0});b=k.value===!0}b||s.push({kind:"drops",what:p.value[c].named,line:h.lineNumber+1})}return s}finally{e.off("Debugger.scriptParsed",n),await e.send("Runtime.releaseObjectGroup",{objectGroup:"drops"}).catch(()=>{}),await e.send("Debugger.disable").catch(()=>{})}}function rn(e,t){let i={errors:new Map,notes:new Set,failed:new Set,dialogs:new Set,windows:0,opened:[],asked:1,pending:[]},r=n=>{let[a]=n.split(`
14
+ `);i.errors.has(a)||i.errors.set(a,Number(/\bkit\.js:(\d+)/.exec(n)?.[1])||null)};return e.on("pageerror",n=>r(n.stack??n.message)),e.on("console",n=>{let a=n.type();!["error","warn","warning"].includes(a)||!Xe(n,t,["kit.js"])||i.pending.push(Promise.all(n.args().map(p=>p.evaluate(u=>u instanceof Error?u.stack:String(u)).catch(()=>""))).then(p=>{let u=p.join(" ")||n.text();a==="error"?r(u):i.notes.add(u.split(`
15
+ `)[0])}))}),e.on("requestfailed",n=>{n.frame()===e.mainFrame()&&!n.isNavigationRequest()&&i.failed.add(n.url())}),e.on("request",n=>{n.isNavigationRequest()&&n.frame()===e.mainFrame()&&i.opened.push(n.url())}),i}async function ln(e,t){let i=await e.createCDPSession();return await i.send("Page.enable"),i.on("Page.javascriptDialogOpening",({type:r})=>{t.add(r),i.send("Page.handleJavaScriptDialog",{accept:!1}).catch(()=>{})}),i}function L(e,t,i=se){let r=0,n=()=>Object.assign(new Error(t),{stuck:!0,doing:t,limit:i}),a=new Promise((u,w)=>{r=setTimeout(()=>w(n()),i)}),p=e.catch(u=>{throw It.has(u.name)?n():Object.assign(u,{doing:t})});return Promise.race([p,a]).finally(()=>clearTimeout(r))}var cn=e=>`${Number((e/1e3).toFixed(1))} s`,pt=e=>`the browser did not answer within ${cn(e.limit)}, waiting until ${e.doing}`,Pe=e=>new Promise(t=>{if(!e.connected)return t(!0);e.once("disconnected",()=>t(!0)),setTimeout(()=>t(!1),lt)});function dn({match:e,instance:t}){let{clientWidth:i,scrollWidth:r}=document.documentElement;if(r<=i+1)return null;let n=[...document.querySelectorAll(e)].filter(a=>!a.parentElement.closest(t));return{wide:r,at:n.findIndex(a=>[a,...a.querySelectorAll("*")].some(p=>p.getBoundingClientRect().right>i+1))}}var st=16,hn="#8f8f8f";async function pn(e,t,i){let r=await Promise.all(t.map(async n=>`data:image/png;base64,${(await T.readFile(n)).toString("base64")}`));await e.setViewport({width:ae.reduce((n,a)=>n+a,0)+st*(ae.length-1),height:900}),await e.setContent(`<!doctype html><body style="margin: 0; display: flex; align-items: flex-start; gap: ${st}px; background: ${hn}">${r.map((n,a)=>`<img src="${n}" width="${ae[a]}" alt="" style="display: block">`).join("")}</body>`,{waitUntil:"load"}),await e.screenshot({path:i,fullPage:!0})}async function ut(e,{file:t,html:i,source:r,places:n,found:a,out:p,loading:u,answer:w=se}){let l=(m,_)=>L(m,_,w),f=await l(e.createBrowserContext(),"a browser context opened"),s=await l(f.newPage(),"a tab opened"),c=Re(t).href,h=rn(s,c),b=await l(ln(s,h.dialogs),"the tab was set to refuse dialogs");f.on("targetcreated",m=>{m.type()==="page"&&(h.windows+=1,m.page().then(_=>_?.close()).then(()=>s.bringToFront()).catch(()=>{}))});let k={heard:h,blocked:[],late:[],taken:[],overviews:[],edited:[],asExport:[],answers:[],wide:[],stuck:null,stopped:null,gone:null},g=async m=>k.late.push(...await L(et(s,{timeout:nt}),m,3*nt+se));await l(Ze(s),"the tab was set to keep what the policy blocks"),await l(s.setViewport({width:736,height:900}),"the window went to 736px"),await l(s.emulateMediaFeatures([{name:"prefers-color-scheme",value:"light"}]),"the light theme came");try{await L(s.goto(c,{waitUntil:"load",timeout:0}),"the page opened",u),await g("the page opened");for(let $ of Ae){await L(s.emulateMediaFeatures([{name:"prefers-color-scheme",value:$}]),`the ${$} theme came`);for(let S of ae){if(await L(s.setViewport({width:S,height:900}),`the window went to ${S}px`),await g(`it was drawn at ${S}px`),$===Ae[0]){let H=await L(s.evaluate(dn,{match:a.match,instance:de}),`it was measured at ${S}px`);H&&k.wide.push({width:S,...H})}let B=x.join(p,`${S}-${$}.png`);await L(s.screenshot({path:B,fullPage:!0}),`it was pictured at ${S}px`),k.taken.push(B)}}await L(s.emulateMediaFeatures([{name:"prefers-color-scheme",value:"light"}]),"the light theme came"),await L(s.setViewport({width:736,height:900}),"the window went to 736px");let m=De(i,a);for(let{at:$,...S}of await L(s.evaluate(qt,{match:a.match,instance:de,slot:tt,parts:a.parts,boards:a.settings?.length?[ve]:[]}),"the page was asked what each instance still shows"))k.answers.push({finding:{kind:"controls",...S},place:n[$]});let _=a.files.includes("kit.js")&&Object.values(a.parts).some(({edit:$})=>$==="data");for(let $=0;$<m.length;$++){let S=await L(s.evaluate(Gt,{match:a.match,instance:de,slotPart:tt,slotName:vt,fallback:xt,parts:a.parts,boards:a.settings?.length?[ve]:[],at:$,source:m[$].markup,still:Rt,step:Dt,times:Mt,typed:Pt,typing:Ct}),"an instance was put back"),B=S.find(({kind:D})=>D==="wrote"),H=[...S.filter(D=>D!==B),...B?en(B,{source:r,found:a,at:$,findings:S}):[]];_&&!S.some(({kind:D})=>D==="gone"||D==="fallback")&&H.push(...await L(on(b,{match:a.match,at:$}),"the page was asked what an instance listens to")),k.answers.push(...H.map(D=>({finding:D,place:n[$]})))}k.blocked=await L(s.evaluate(()=>globalThis.__qaViolations),"the page was asked what it blocked"),h.asked+=1,await L(s.goto(c,{waitUntil:"load",timeout:0}),"the page opened again",u),await g("the page opened again"),await L(s.evaluate(()=>dispatchEvent(new Event("doc-editable"))),"the page was told it takes edits"),await g("it was drawn as the editing page draws it");for(let $ of Lt){await L(s.setViewport({width:$,height:900}),`the window went to ${$}px`),await g(`it was drawn at ${$}px as the editing page draws it`);let S=x.join(p,`edit-${$}-light.png`);await L(s.screenshot({path:S,fullPage:!0}),`it was pictured at ${$}px as the editing page draws it`),k.edited.push(S),(await T.readFile(S)).equals(await T.readFile(x.join(p,`${$}-light.png`)))&&k.asExport.push(S)}k.blocked.push(...await L(s.evaluate(()=>globalThis.__qaViolations),"the page was asked what it blocked"));for(let $ of Ae){let S=x.join(p,`overview-${$}.png`);await L(pn(s,ae.map(B=>x.join(p,`${B}-${$}.png`)),S),`the ${$} pictures were put side by side`),k.overviews.push(S)}}catch(m){if(m.syscall)throw m;await Pe(e)?k.gone=m.doing??"the page answered":m.stuck?k.stuck=m.doing:k.stopped=oe(m)}return await Promise.race([Promise.all(h.pending),new Promise(m=>setTimeout(m,lt).unref())]),k}var un=(e,t)=>e.startsWith(t)?e.slice(t.length):e;function wn(e,t,i){let r=new Map;for(let{url:n,directive:a,source:p,line:u}of e){if(_t.test(n)){let l=!p&&u>0;r.set(`${n}|${p}|${u}`,{file:l?"kit.js":"the page",...l?{line:u}:{},what:"the export's policy blocks code made from words (eval, new Function, a string given to setTimeout): an export runs none"});continue}let w=/^[a-z][a-z0-9+.-]*$/.test(n)?t.filter(l=>l.startsWith(`${n}:`)):[];for(let l of w.length?w:[n])r.set(`${l}|${a}`,{file:"the page",what:`the export's policy blocks ${un(l,i)||"something"} (${a}): ${a==="img-src"?"a picture of an instance is a data: address, or a file its style names":"an export holds all it needs"}`})}return[...r.values()]}function wt({heard:e,blocked:t,late:i,answers:r,wide:n,stuck:a,stopped:p},{places:u,script:w,folder:l}){let f=Yt(r).map(({finding:g,place:m})=>Vt(g,m,{script:w})),s=[...e.failed],c=s.filter(g=>!t.some(m=>m.url&&g.startsWith(m.url))),h=e.opened.length>e.asked?"it loads itself again (location.reload(), a new location.href), so a reader's page would not stay":a?`it stopped answering while waiting until ${a}${w?": a script that never ends, or a component that changes what it hears (a text part, on its source signal)":""}`:p&&`the look at it stopped: ${p}`,b=n.map(({width:g,wide:m})=>`${m}px wide in a ${g}px window`).join(", "),k=u[n.find(({at:g})=>g>=0)?.at]??{file:"the page"};return{problems:[...[...e.errors].map(([g,m])=>({file:m?"kit.js":"the page",line:m,what:`the console says ${g}`})),...wn(t,s,l),...c.map(g=>({file:"the page",what:`it could not load ${g.slice(0,120)}`})),...[...e.dialogs].map(g=>({file:"the page",what:`it opens a dialog (${g}), which stops a reader's page until it is answered: show what it says in the instance`})),...e.windows?[{file:"the page",what:"it opens a window, which takes a reader away from the page: show it in the instance, or link to it"}]:[],...h?[{file:"the page",what:h}]:[],...n.length?[{...k,what:`the page is ${b}: a reader scrolls the whole page sideways, and gallery qa fails it: let it fit the window (max-width: 100%), or put what is wider in a frame of its own that scrolls`}]:[],...f.filter(({note:g,told:m})=>!g&&!m)],notes:[...[...e.notes].map(g=>({file:"the page",what:`the console says ${g}`})),...f.filter(({note:g})=>g),...i.map(g=>({file:"the page",what:`waited for ${g}`}))],told:f.filter(({told:g})=>g)}}async function _n(e,t,{example:i,template:r},{find:n=Te,start:a=Oe,loading:p=rt,answer:u=se}={}){let w=At,l=null,f=null;try{l=await T.mkdtemp(x.join(he.tmpdir(),"gallery-component-check-"));let s=await Wt(t,{example:i,template:r},l),c=n();if(!c)return{title:w,unverified:"no Chrome, Edge or Chromium found (GALLERY_BROWSER=<its executable> picks one)"};try{f=await a({executablePath:c,args:Ne()})}catch(g){return{title:w,unverified:`the browser ${c} did not start, twice, each time with a fresh profile (${oe(g)}; GALLERY_BROWSER=<its executable> picks another)`}}let h=x.join(it(e).qa,"components",...t.id.split("/"));await T.rm(h,{recursive:!0,force:!0}),await T.mkdir(h,{recursive:!0});let b=await ut(f.browser,{...s,found:t,out:h,loading:p,answer:u}),k=wt(b,{places:s.places,script:t.files.includes("kit.js"),folder:Re(`${l}${x.sep}`).href});return b.gone?{title:w,...k,unverified:`the browser went while waiting until ${b.gone}, so it says nothing of the block`}:{title:w,...k,...b.taken.length?{pictures:{folder:h,overviews:b.overviews.map(g=>x.basename(g)),each:b.taken.map(g=>x.basename(g)),edited:b.edited.map(g=>x.basename(g)),asExport:b.asExport.map(g=>x.basename(g))}}:{}}}catch(s){return s.reason==="check"?{title:w,problems:s.failures.map(c=>({file:"the export",what:c}))}:s.syscall?{title:w,unverified:`cannot write ${je(s.syscall==="mkdtemp"?he.tmpdir():s.path)} (${s.code})`}:f&&await Pe(f.browser)?{title:w,unverified:"the browser went before the page opened"}:s.stuck?{title:w,problems:[{file:"the page",what:`${pt(s)}, so the look stopped and the browser was closed`}]}:{title:w,problems:[{file:"the page",what:`the look at it stopped: ${oe(s)}`}]}}finally{await f?.close(),l&&await T.rm(l,{recursive:!0,force:!0,maxRetries:5,retryDelay:200}).catch(()=>{})}}async function fn(e,t){let i=[];for(let r of await Nt(e)){let n=jt(r,e),a=Tt(n).html,p=await T.readFile(a,"utf8").catch(()=>null);if(p===null)continue;let u=ot(le(p),t),w=f=>{for(let s=f.parentNode;s;s=s.parentNode)if(u.includes(s))return!0;return!1},l=u.filter(f=>!w(f)).map(({sourceCodeLocation:{startLine:f,startOffset:s,endOffset:c}})=>({line:f,markup:p.slice(s,c)}));l.length&&i.push({slug:r,place:`${r}/${x.basename(a)}`,directory:n,instances:l})}return i}async function mn(e,t,i,r){let n=t.instances.map(({line:s,markup:c})=>`<p>${t.place}:${s}</p>${c}`).join(`
16
+ `);for(let s of new Set([e.id,...[...n.matchAll(new RegExp(`${$t}="([^"]+)"`,"g"))].map(([,c])=>c)])){let c=s===e.id?e:i.get(s);c&&await ht(c,r)}let a=x.join(r,q);await T.mkdir(a),await T.cp(x.join(t.directory,"assets"),x.join(a,"assets"),{recursive:!0}).catch(s=>{if(s.code!=="ENOENT")throw s});let p=Se(ct(q,n)).text;await T.writeFile(x.join(a,"doc.html"),p),await T.writeFile(x.join(a,"doc.json"),JSON.stringify({title:q,description:q,type:"component"}));let w=await(await Ee({directory:r}))(q),l=x.join(r,"export.html");await T.writeFile(l,w);let f=De(p,e).map((s,c)=>({file:t.place,line:t.instances[c]?.line??null}));return{html:w,file:l,places:f,source:p}}async function In(e,t,{find:i=Te,start:r=Oe,loading:n=rt}={}){let a=await fn(e,t);if(a.length===0)return[{title:ce(),none:`none holds an instance of ${t.id}`}];let p=i();if(!p)return[{title:ce(),unverified:"no Chrome, Edge or Chromium found (GALLERY_BROWSER=<its executable> picks one)"}];let u;try{u=await r({executablePath:p,args:Ne()})}catch(f){return[{title:ce(),unverified:`the browser ${p} did not start, twice, each time with a fresh profile (${oe(f)}; GALLERY_BROWSER=<its executable> picks another)`}]}let{packages:w}=Ye(e),l=[];try{for(let f of a){let s=ce(f.place),c=null;try{c=await T.mkdtemp(x.join(he.tmpdir(),"gallery-component-check-"));let h=await mn(t,f,w,c),b=x.join(it(e).qa,"components",...t.id.split("/"),"documents",f.slug);await T.rm(b,{recursive:!0,force:!0}),await T.mkdir(b,{recursive:!0});let k=await ut(u.browser,{...h,found:t,out:b,loading:n}),g=wt(k,{places:h.places,script:t.files.includes("kit.js"),folder:Re(`${c}${x.sep}`).href});if(k.gone){l.push({title:s,...g,unverified:`the browser went while waiting until ${k.gone}, so it says nothing of these instances`});break}l.push({title:s,...g,...k.taken.length?{pictures:{folder:b,overviews:k.overviews.map(m=>x.basename(m)),each:k.taken.map(m=>x.basename(m)),edited:k.edited.map(m=>x.basename(m)),asExport:k.asExport.map(m=>x.basename(m)),documents:!0}}:{}})}catch(h){if(h.reason==="check")l.push({title:s,problems:h.failures.map(b=>({file:f.place,what:`its instances, exported alone: ${b}`}))});else if(h.syscall)l.push({title:s,unverified:`cannot write ${je(h.syscall==="mkdtemp"?he.tmpdir():h.path)} (${h.code})`});else if(await Pe(u.browser)){l.push({title:s,unverified:"the browser went before the page opened"});break}else if(h.stuck){l.push({title:s,problems:[{file:"the page",what:`${pt(h)}, so the look at them stopped, the browser was closed, and no document after them was looked at`}]});break}else l.push({title:s,problems:[{file:"the page",what:`the look at them stopped: ${oe(h)}`}]})}finally{c&&await T.rm(c,{recursive:!0,force:!0,maxRetries:5,retryDelay:200}).catch(()=>{})}}}finally{await u.close()}return l}export{At as a,ce as b,rt as c,se as d,Dn as e,Rt as f,Dt as g,Mn as h,Pn as i,oe as j,ct as k,Ut as l,Jt as m,Qt as n,Cn as o,Zt as p,ln as q,L as r,cn as s,pt as t,Pe as u,_n as v,In as w};
@@ -0,0 +1,2 @@
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}from"./chunk-ZQS6H473.mjs";import"./chunk-UMHUSOPJ.mjs";import"./chunk-VFX2KNHP.mjs";import"./chunk-VS7JIGJW.mjs";import"./chunk-HDWTZ763.mjs";import"./chunk-A55HN5OK.mjs";import"./chunk-5L7RYZCL.mjs";export{g as changeLines,c as handedInSource,f as headerChanged,e as inStep,a as naturalize,d as pendingBlockIds,h as readOnlyTexts,j as scriptKept,b as shownSource,i as writingNotes};
@@ -0,0 +1,5 @@
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 y from"node:fs";import{fileURLToPath as S}from"node:url";import{namedPlace as h}from"../browser/shared/page-address.mjs";import{pageLinks as w}from"../browser/shared/page-links.mjs";import{reportsDirectory as b}from"../browser/shared/paths.mjs";import{listReportSlugs as g,slugPattern as x}from"../browser/shared/reports.mjs";import{RESERVED as v,isSlugName as N,listTrash as O}from"../browser/shared/workspace.mjs";var m=e=>/^--.|^-[A-Za-z]/.test(e),a=class extends Error{constructor(n){super(n),this.name="UsageError"}};function A(e){let n=y.readFileSync(S(e),"utf8").split(/\r?\n/),t=n.findIndex(s=>!s.startsWith("//"));return n.slice(0,t===-1?n.length:t).map(s=>s.replace(/^\/\/ ?/,"")).join(`
3
+ `)}var E=e=>/^Usage: (gallery \S+|npm run \S+|node \S+)/.exec(e)?.[1]??"this command",P=e=>e.split(`
4
+ `)[0],R=(e,n,t=P(e))=>{let s=E(e);return`${n}
5
+ ${t} (${s}${s.startsWith("npm run")?" --":""} --help says more)`},T=e=>{let n=e.indexOf("--");return(n===-1?e:e.slice(0,n)).some(t=>t==="--help"||t==="-h")};function $({options:e=[],values:n=[],argv:t=process.argv.slice(2)}={}){let s=t.indexOf("--"),[o,r]=s===-1?[t,[]]:[t.slice(0,s),t.slice(s+1)],l=[],u=new Set,p=new Map;for(let c=0;c<o.length;c++){let i=o[c],[f,k]=i.startsWith("--")&&i.includes("=")?[i.slice(0,i.indexOf("=")),i.slice(i.indexOf("=")+1)]:[i,void 0];if(!m(i))l.push(i);else if(n.includes(f)){let d=k??(c+1<o.length&&!m(o[c+1])?o[++c]:void 0);if(!d)throw new a(`${f} takes a value`);p.set(f,d)}else if(e.includes(i))u.add(i);else throw new a(`Unknown option: ${i}`)}return{positional:[...l,...r],options:u,values:p}}function U(e){if(!x.test(e))throw new a(`Not a document's slug: ${e} (lowercase kebab-case).`);if(v.has(e))throw new a(`Not a document's slug: ${e} (a name the workspace keeps for itself).`);return e}async function L(e){let n=await O(b),t=n.filter(({kind:r})=>r==="document"),s=h(e,w(t));if(s)return`${e} is a document in the trash ("${t.find(({slug:r})=>r===s.slug).title}"): it has to be restored in the workbench first.`;let o=n.find(({kind:r,slug:l})=>r==="page"&&l===e);return o?`${e} is a custom page in the trash ("${o.title}"), not a document: once it is restored in the workbench, gallery page open ${e} opens it.`:null}async function W(e){let n=(await g()).filter(N),t=h(e,w(n.map(o=>({slug:o}))));if(t)return t;let s=await L(e);if(s)throw new a(s);if(!x.test(e))throw new a(`Not a document's slug, link or address: ${e} (gallery list shows them).`);return{slug:U(e),block:null}}async function D({options:e=[],values:n=[],argv:t,noneIsAll:s=!1}={}){let{positional:o,options:r,values:l}=$({options:["--all",...e],values:n,argv:t}),u=r.has("--all");if(u&&o.length>0)throw new a("Name documents or pass --all, not both.");if(!u&&o.length===0&&!s)throw new a("Name a document (or pass --all).");let p=await Promise.all(o.map(W));return{slugs:u||o.length===0?await g():[...new Set(p.map(({slug:c})=>c))],options:r,values:l}}async function Z(e,{documents:n=!1,...t}={}){let s=A(e),o=t.argv??process.argv.slice(2);T(o)&&(console.log(s),process.exit(0));try{return n?await D({...t,argv:o}):$({...t,argv:o})}catch(r){if(!(r instanceof a))throw r;console.error(R(s,r.message)),process.exit(2)}}export{m as a,a as b,A as c,R as d,T as e,$ as f,U as g,L as h,W as i,D as j,Z as k};
@@ -0,0 +1,2 @@
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{d as m,i as g,k as p}from"./chunk-5XA2ZBAE.mjs";import{b as a,f as l,i as c}from"./chunk-4OZWXZE5.mjs";import"./chunk-5L7RYZCL.mjs";import{reportsDirectory as i}from"../browser/shared/paths.mjs";import{joinDefaultTree as b,joinedLine as k}from"../browser/shared/drafts.mjs";var D=5e3;async function v(f){let{positional:s,options:u}=l({options:["--no-browser"],argv:f});if(s.length>1)throw new a("Name one document at most.");let{slug:o=null,block:w=null}=s.length?await c(s[0]):{};console.log(`\u5DE5\u4F5C\u533A\uFF1A${i}`);let e=await g({slug:o,baseline:o!==null});if(e.ok||console.error(e.message),e.reason==="missing"){let{HOME:n,pageExists:d}=await import("../browser/shared/pages.mjs"),{missingPageSaid:E,HOME_NOT_MADE:r}=await import("./chunk-UJQJKNGK.mjs");d(o,i)?console.error(`"${o}" is a custom page, not a document: gallery page open ${o} opens it and gives its address.`):o===n&&await E(o,i)===r&&console.error(r)}if(o!==null&&e.reason!=="missing"){let{roundBegins:n}=await import("./chunk-SWUTTZCN.mjs");await n(o,e.ok?{}:{wait:D})}if(o!==null&&e.reason!=="missing"){let n=k(await b(i,o));n&&console.log(n)}e.ok||process.exit(1);let t=await p(o,e,w);for(let n of t)console.log(n);console.log(await m(t,u))}export{v as run};
@@ -1,8 +1,8 @@
1
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{spawn as J}from"node:child_process";import P from"node:fs";import m from"node:fs/promises";import Q from"node:os";import k from"node:path";import{escapeMarkup as X}from"../browser/shared/escape.mjs";import{spawn as C}from"node:child_process";import{existsSync as H,readFileSync as M}from"node:fs";import w from"node:path";var V=e=>!["","0",void 0].includes(e),z=(e,r)=>(r.PATH??"").split(w.delimiter).some(t=>t&&H(w.join(t,e))),U=()=>{try{return process.platform==="linux"&&/microsoft/i.test(M("/proc/version","utf8"))}catch{return!1}};function K(e,{platform:r=process.platform,env:t=process.env,wsl:s=U()}={}){let n=encodeURI(e);return V(t.GALLERY_NO_BROWSER)?{skip:"GALLERY_NO_BROWSER is set"}:r==="win32"?{command:w.join(t.SystemRoot||t.windir||"C:\\Windows","System32","rundll32.exe"),args:["url.dll,FileProtocolHandler",n]}:r==="darwin"?{command:"open",args:[n]}:s?{command:"cmd.exe",args:["/c","start",'""',n.replace(/[&^]/g,"^$&")]}:!t.DISPLAY&&!t.WAYLAND_DISPLAY?{skip:"no display here (neither DISPLAY nor WAYLAND_DISPLAY is set)"}:z("xdg-open",t)?{command:"xdg-open",args:[n]}:{skip:"xdg-open is not installed"}}var q="Opened it in the default browser (if that is not Chrome or Edge, open the address there to edit).",T=e=>e.opened?q:`Not opened in a browser: ${e.why}.`;async function O(e,r){let t=K(e,r);return t.skip?{opened:!1,why:t.skip}:new Promise(s=>{let n;try{n=C(t.command,t.args,{detached:!0,stdio:"ignore",windowsHide:!0})}catch(o){return s({opened:!1,why:`${w.basename(t.command)} did not start (${o.code??o.message})`})}n.once("error",o=>s({opened:!1,why:`${w.basename(t.command)} did not start (${o.code??o.message})`})),n.once("spawn",()=>{n.unref(),s({opened:!0})})})}import{packageRoot as Z,previewLogFile as f,projectRoot as G,release as I,reportsDirectory as h}from"../browser/shared/paths.mjs";import{fullAddress as ee}from"../browser/shared/page-address.mjs";import{findPreviewServer as te,galleryVersion as F,portIsFree as re,previewServerFor as ne,readAnnouncement as oe}from"../browser/shared/preview-server.mjs";import{documentLinks as se}from"../browser/shared/reports.mjs";import{documentDirectory as ie,documentFiles as ae,layoutOf as ce}from"../browser/shared/workspace.mjs";var $="\u4EA4\u7ED9\u7528\u6237\uFF08\u73B0\u5728\u5C31\u628A\u8FD9\u4E2A\u5730\u5740\u7ED9\u7528\u6237\uFF1B\u7528 Chrome \u6216 Edge \u6253\u5F00\uFF09\uFF1A",le="Agent \u81EA\u7528\uFF08\u53EA\u6709\u6587\u6863\u9875\uFF0C\u4E0D\u4EA4\u7ED9\u7528\u6237\uFF09\uFF1A",de=e=>`send the user ${e} now, in a message of its own, before any other step; then `;function Ve(e,r){let t=e.at(-1)??"";return`Next: ${t.startsWith($)?de(t.slice($.length)):""}${r}`}async function ze(e,r){let t=e.at(-1)??"";return t.startsWith($)?r.has("--no-browser")?"Not opened in a browser (--no-browser).":T(await O(t.slice($.length))):null}var D="GALLERY_NO_PREVIEW",pe=e=>!["","0",void 0].includes(e),Ue=e=>e.has("--no-preview")||pe(process.env[D]),ue=4317,fe=20,me=(e=process.env)=>{let r=Number(e.GALLERY_PORT);return Number.isInteger(r)&&r>0&&r<65536?r:ue},we=6e4,he=5*1024*1024,$e=k.join(G,"node_modules","vite","bin","vite.js"),ye=k.join(Z,"dist","server.mjs"),ge=e=>new Promise(r=>setTimeout(r,e)),A={reportsDirectory:h},Y=ce(h),R=(e,r)=>`http://127.0.0.1:${e}/generated/${r}.html`,ve=(e,r)=>`${R(e,r)}?agent`,j=e=>`http://127.0.0.1:${e}/`,xe=(e,r)=>se().then(({links:t})=>t,()=>null).then(t=>ee(`http://127.0.0.1:${e}`,r,t));async function ke({first:e=me(),count:r=fe}={}){let t=Number((await m.readFile(Y.lastPortFile,"utf8").catch(()=>"")).trim()),s=Array.from({length:Math.max(0,r)},(n,o)=>e+o);return Number.isInteger(t)&&t>0&&t<65536?[t,...s.filter(n=>n!==t)]:s}async function Le(){return await m.mkdir(k.dirname(f),{recursive:!0}),await m.stat(f).then(r=>r.size,()=>0)>he&&await m.rename(f,`${f}.1`).catch(()=>{}),P.openSync(f,"a")}async function Se(e,r){if(!I){let{writeSharedAssets:p}=await import("./chunk-VNV55RUA.mjs");await p()}let t=await Le();P.writeSync(t,`
2
+ import{spawn as J}from"node:child_process";import P from"node:fs";import m from"node:fs/promises";import Q from"node:os";import k from"node:path";import{escapeMarkup as X}from"../browser/shared/escape.mjs";import{spawn as C}from"node:child_process";import{existsSync as H,readFileSync as M}from"node:fs";import w from"node:path";var V=e=>!["","0",void 0].includes(e),z=(e,r)=>(r.PATH??"").split(w.delimiter).some(t=>t&&H(w.join(t,e))),U=()=>{try{return process.platform==="linux"&&/microsoft/i.test(M("/proc/version","utf8"))}catch{return!1}};function K(e,{platform:r=process.platform,env:t=process.env,wsl:s=U()}={}){let n=encodeURI(e);return V(t.GALLERY_NO_BROWSER)?{skip:"GALLERY_NO_BROWSER is set"}:r==="win32"?{command:w.join(t.SystemRoot||t.windir||"C:\\Windows","System32","rundll32.exe"),args:["url.dll,FileProtocolHandler",n]}:r==="darwin"?{command:"open",args:[n]}:s?{command:"cmd.exe",args:["/c","start",'""',n.replace(/[&^]/g,"^$&")]}:!t.DISPLAY&&!t.WAYLAND_DISPLAY?{skip:"no display here (neither DISPLAY nor WAYLAND_DISPLAY is set)"}:z("xdg-open",t)?{command:"xdg-open",args:[n]}:{skip:"xdg-open is not installed"}}var q="Opened it in the default browser (if that is not Chrome or Edge, open the address there to edit).",T=e=>e.opened?q:`Not opened in a browser: ${e.why}.`;async function O(e,r){let t=K(e,r);return t.skip?{opened:!1,why:t.skip}:new Promise(s=>{let n;try{n=C(t.command,t.args,{detached:!0,stdio:"ignore",windowsHide:!0})}catch(o){return s({opened:!1,why:`${w.basename(t.command)} did not start (${o.code??o.message})`})}n.once("error",o=>s({opened:!1,why:`${w.basename(t.command)} did not start (${o.code??o.message})`})),n.once("spawn",()=>{n.unref(),s({opened:!0})})})}import{packageRoot as Z,previewLogFile as f,projectRoot as G,release as I,reportsDirectory as h}from"../browser/shared/paths.mjs";import{fullAddress as ee}from"../browser/shared/page-address.mjs";import{findPreviewServer as te,galleryVersion as F,portIsFree as re,previewServerFor as ne,readAnnouncement as oe}from"../browser/shared/preview-server.mjs";import{documentLinks as se}from"../browser/shared/reports.mjs";import{documentDirectory as ie,documentFiles as ae,layoutOf as ce}from"../browser/shared/workspace.mjs";var $="\u4EA4\u7ED9\u7528\u6237\uFF08\u73B0\u5728\u5C31\u628A\u8FD9\u4E2A\u5730\u5740\u7ED9\u7528\u6237\uFF1B\u7528 Chrome \u6216 Edge \u6253\u5F00\uFF09\uFF1A",le="Agent \u81EA\u7528\uFF08\u53EA\u6709\u6587\u6863\u9875\uFF0C\u4E0D\u4EA4\u7ED9\u7528\u6237\uFF09\uFF1A",de=e=>`send the user ${e} now, in a message of its own, before any other step; then `;function Ve(e,r){let t=e.at(-1)??"";return`Next: ${t.startsWith($)?de(t.slice($.length)):""}${r}`}async function ze(e,r){let t=e.at(-1)??"";return t.startsWith($)?r.has("--no-browser")?"Not opened in a browser (--no-browser).":T(await O(t.slice($.length))):null}var D="GALLERY_NO_PREVIEW",pe=e=>!["","0",void 0].includes(e),Ue=e=>e.has("--no-preview")||pe(process.env[D]),ue=4317,fe=20,me=(e=process.env)=>{let r=Number(e.GALLERY_PORT);return Number.isInteger(r)&&r>0&&r<65536?r:ue},we=6e4,he=5*1024*1024,$e=k.join(G,"node_modules","vite","bin","vite.js"),ye=k.join(Z,"dist","server.mjs"),ge=e=>new Promise(r=>setTimeout(r,e)),A={reportsDirectory:h},Y=ce(h),R=(e,r)=>`http://127.0.0.1:${e}/generated/${r}.html`,ve=(e,r)=>`${R(e,r)}?agent`,j=e=>`http://127.0.0.1:${e}/`,xe=(e,r)=>se().then(({links:t})=>t,()=>null).then(t=>ee(`http://127.0.0.1:${e}`,r,t));async function ke({first:e=me(),count:r=fe}={}){let t=Number((await m.readFile(Y.lastPortFile,"utf8").catch(()=>"")).trim()),s=Array.from({length:Math.max(0,r)},(n,o)=>e+o);return Number.isInteger(t)&&t>0&&t<65536?[t,...s.filter(n=>n!==t)]:s}async function Le(){return await m.mkdir(k.dirname(f),{recursive:!0}),await m.stat(f).then(r=>r.size,()=>0)>he&&await m.rename(f,`${f}.1`).catch(()=>{}),P.openSync(f,"a")}async function Se(e,r){if(!I){let{writeSharedAssets:p}=await import("./chunk-WQDQWCX5.mjs");await p()}let t=await Le();P.writeSync(t,`
3
3
  [${new Date().toISOString()}] ${r}: Gallery ${F} on 127.0.0.1:${e} for ${h}
4
- `);let[s,n]=I?[[ye,"--port",String(e)],Q.homedir()]:[[$e,"--host","127.0.0.1","--port",String(e),"--strictPort"],G],o=J(process.execPath,s,{cwd:n,env:{...process.env,GALLERY_WORKSPACE:k.resolve(h),GALLERY_SERVER_KIND:"cli"},detached:!0,stdio:["ignore",t,t],windowsHide:!0});return P.closeSync(t),o.unref(),o}async function be({slug:e=null,command:r=`gallery open${e?` ${e}`:""}`,ports:t=null,starting:s=we,baseline:n=!1}={}){let o=()=>!0;if(e){let a=ae(ie(e,h)),c=await m.readFile(a.html,"utf8").catch(()=>null);if(c===null)return{ok:!1,reason:"missing",message:`No document "${e}": ${a.html} does not exist (gallery new ${e} "<\u6807\u9898>" makes one; gallery list lists those there are).`};n&&await import("./chunk-SGJWQKEI.mjs").then(({previewBaseline:x})=>x(e,c));let i=await m.readFile(a.json,"utf8").then(JSON.parse).catch(()=>({})),v=[/<title>([^<]*)<\/title>/i.exec(c)?.[1]?.trim(),typeof i.title=="string"?i.title.trim():""].filter(Boolean);o=x=>v.length===0||v.some(_=>x.includes(_)||x.includes(X(_)))}let p=t??await ke(),L=p.length?`${Math.min(...p)} to ${Math.max(...p)}`:"none",S=`gallery open${e?` ${e}`:""}`,E=async(a,c=[])=>{let i=await ne({...A,ports:p.slice(a),start:v=>Se(v,r)});return i.busy?.newer?{failed:{ok:!1,reason:"newer",message:`A newer Gallery (${i.busy.version}) serves this workspace (port ${i.busy.port}, pid ${i.busy.pid}) and gave no answer in 10s; this is Gallery ${F}. Update this one (npm i -g @heycys/gallery@latest), or run ${S} again in a while.`}}:i.busy?{failed:{ok:!1,reason:"busy",message:`This workspace's Gallery server (port ${i.busy.port}, pid ${i.busy.pid}) took the request and gave no answer in 10s: it is busy or stuck. Run ${S} again in a while, or stop that process first (gallery stop): a second server of this workspace is not started beside it.`}}:i.stuck?{failed:{ok:!1,reason:"stuck",message:`An older Gallery's server serves this workspace and did not stop: ${i.stuck.message}`}}:i.port===null?{failed:{ok:!1,reason:"ports",message:`No server of this workspace runs, and no port from ${L} is free to start one on: stop a server on one of them (or name another first port: GALLERY_PORT=<n>), then run ${S}.`}}:{...i,passed:[...c,...i.passed]}},u=await E(0);if(u.failed)return u.failed;let{port:l,started:d,passed:b,replaced:W}=u,y=u.running??null,N=Date.now()+s,g="",B=async()=>{if(e){let c=await fetch(`${R(l,e)}?present`,{signal:AbortSignal.timeout(5e3)}).catch(()=>null),i=c?.ok?await c.text():"";return g=c?i?`HTTP ${c.status} without the title`:`HTTP ${c.status}`:"no answer",!!(i&&o(i))}let a=await fetch(`http://127.0.0.1:${l}/__gallery/workspace/info`,{signal:AbortSignal.timeout(5e3)}).catch(()=>null);return g=a?`HTTP ${a.status}`:"no answer",!!a?.ok};for(;;await ge(300)){if(Date.now()>N)return{ok:!1,reason:"timeout",message:`${e?R(l,e):j(l)} did not answer${e?" with the document's title":""} in ${s/1e3}s (${g})${d?`; the server's output is in ${f}`:""}.`};if(d){let a=await te({...A,answering:!0});if(a&&a.pid!==d.pid){if(d.exitCode===null)try{process.kill(d.pid)}catch{}({port:l}=a),y={pid:a.pid,kind:(await oe(A))?.kind??"cli",version:null},d=null;continue}if(!a&&d.exitCode===null){g="the server started has not announced itself yet";continue}if(!a){if(!await re(l)){if(u=await E(p.indexOf(l)+1,[...b,`${l} (taken by another program while the server started)`]),u.failed)return u.failed;({port:l,started:d,passed:b}=u),y=u.running??null,N=Date.now()+s;continue}let c=await m.readFile(f,"utf8").catch(()=>"");return{ok:!1,reason:"stopped",message:`The Gallery server on port ${l} stopped (exit ${d.exitCode}). Its last words (${f}):
4
+ `);let[s,n]=I?[[ye,"--port",String(e)],Q.homedir()]:[[$e,"--host","127.0.0.1","--port",String(e),"--strictPort"],G],o=J(process.execPath,s,{cwd:n,env:{...process.env,GALLERY_WORKSPACE:k.resolve(h),GALLERY_SERVER_KIND:"cli"},detached:!0,stdio:["ignore",t,t],windowsHide:!0});return P.closeSync(t),o.unref(),o}async function be({slug:e=null,command:r=`gallery open${e?` ${e}`:""}`,ports:t=null,starting:s=we,baseline:n=!1}={}){let o=()=>!0;if(e){let a=ae(ie(e,h)),c=await m.readFile(a.html,"utf8").catch(()=>null);if(c===null)return{ok:!1,reason:"missing",message:`No document "${e}": ${a.html} does not exist (gallery new ${e} "<\u6807\u9898>" makes one; gallery list lists those there are).`};n&&await import("./chunk-FDMAXMQA.mjs").then(({previewBaseline:x})=>x(e,c));let i=await m.readFile(a.json,"utf8").then(JSON.parse).catch(()=>({})),v=[/<title>([^<]*)<\/title>/i.exec(c)?.[1]?.trim(),typeof i.title=="string"?i.title.trim():""].filter(Boolean);o=x=>v.length===0||v.some(_=>x.includes(_)||x.includes(X(_)))}let p=t??await ke(),L=p.length?`${Math.min(...p)} to ${Math.max(...p)}`:"none",S=`gallery open${e?` ${e}`:""}`,E=async(a,c=[])=>{let i=await ne({...A,ports:p.slice(a),start:v=>Se(v,r)});return i.busy?.newer?{failed:{ok:!1,reason:"newer",message:`A newer Gallery (${i.busy.version}) serves this workspace (port ${i.busy.port}, pid ${i.busy.pid}) and gave no answer in 10s; this is Gallery ${F}. Update this one (npm i -g @heycys/gallery@latest), or run ${S} again in a while.`}}:i.busy?{failed:{ok:!1,reason:"busy",message:`This workspace's Gallery server (port ${i.busy.port}, pid ${i.busy.pid}) took the request and gave no answer in 10s: it is busy or stuck. Run ${S} again in a while, or stop that process first (gallery stop): a second server of this workspace is not started beside it.`}}:i.stuck?{failed:{ok:!1,reason:"stuck",message:`An older Gallery's server serves this workspace and did not stop: ${i.stuck.message}`}}:i.port===null?{failed:{ok:!1,reason:"ports",message:`No server of this workspace runs, and no port from ${L} is free to start one on: stop a server on one of them (or name another first port: GALLERY_PORT=<n>), then run ${S}.`}}:{...i,passed:[...c,...i.passed]}},u=await E(0);if(u.failed)return u.failed;let{port:l,started:d,passed:b,replaced:W}=u,y=u.running??null,N=Date.now()+s,g="",B=async()=>{if(e){let c=await fetch(`${R(l,e)}?present`,{signal:AbortSignal.timeout(5e3)}).catch(()=>null),i=c?.ok?await c.text():"";return g=c?i?`HTTP ${c.status} without the title`:`HTTP ${c.status}`:"no answer",!!(i&&o(i))}let a=await fetch(`http://127.0.0.1:${l}/__gallery/workspace/info`,{signal:AbortSignal.timeout(5e3)}).catch(()=>null);return g=a?`HTTP ${a.status}`:"no answer",!!a?.ok};for(;;await ge(300)){if(Date.now()>N)return{ok:!1,reason:"timeout",message:`${e?R(l,e):j(l)} did not answer${e?" with the document's title":""} in ${s/1e3}s (${g})${d?`; the server's output is in ${f}`:""}.`};if(d){let a=await te({...A,answering:!0});if(a&&a.pid!==d.pid){if(d.exitCode===null)try{process.kill(d.pid)}catch{}({port:l}=a),y={pid:a.pid,kind:(await oe(A))?.kind??"cli",version:null},d=null;continue}if(!a&&d.exitCode===null){g="the server started has not announced itself yet";continue}if(!a){if(!await re(l)){if(u=await E(p.indexOf(l)+1,[...b,`${l} (taken by another program while the server started)`]),u.failed)return u.failed;({port:l,started:d,passed:b}=u),y=u.running??null,N=Date.now()+s;continue}let c=await m.readFile(f,"utf8").catch(()=>"");return{ok:!1,reason:"stopped",message:`The Gallery server on port ${l} stopped (exit ${d.exitCode}). Its last words (${f}):
5
5
  ${c.split(`
6
6
  `).slice(-15).join(`
7
7
  `)}`}}}if(await B())break}return await m.writeFile(Y.lastPortFile,`${l}
8
- `).catch(()=>{}),{ok:!0,port:l,pid:d?.pid??y?.pid??null,kind:y?.kind??"cli",started:!!d,replaced:W??null,passed:b}}var Ae=e=>e.length<2?e.join(""):`${e.slice(0,-1).join(", ")} and ${e.at(-1)}`;function Pe({port:e,pid:r,kind:t,started:s,replaced:n,passed:o=[]}){let p=[`pid ${r}`,...t==="dev"?["npm run dev's"]:[],...s?[`started now${o.length?`, after passing over ${Ae(o)}`:""}`]:[],...n?[`it replaced Gallery ${n.version??"an older version"}'s server, pid ${n.pid}`]:[]],L=s?`; its log: ${f}`:"";return`This workspace's Gallery server runs on port ${e} (${p.join(", ")}${L}). This command is done; the server runs on after it (nothing to wait for or keep running).`}async function Re(e,r,t=null){return[Pe(r),...e?[`${le}${ve(r.port,e)}`]:[],`${$}${e?await xe(r.port,{slug:e,block:t}):j(r.port)}`]}async function Ke(e,{skipped:r,command:t,ports:s=null}){let n=`gallery open ${e} starts it and prints the address to give the user`;if(r)return[`Preview: not started (--no-preview or ${D}): ${n}.`];let o=await be({slug:e,command:t,ports:s});return o.ok?Re(e,o):[`Preview: not started: ${o.message}`,`When that is fixed, ${n}.`]}export{Ve as a,ze as b,Ue as c,ve as d,j as e,ke as f,be as g,Re as h,Ke as i};
8
+ `).catch(()=>{}),{ok:!0,port:l,pid:d?.pid??y?.pid??null,kind:y?.kind??"cli",started:!!d,replaced:W??null,passed:b}}var Ae=e=>e.length<2?e.join(""):`${e.slice(0,-1).join(", ")} and ${e.at(-1)}`;function Pe({port:e,pid:r,kind:t,started:s,replaced:n,passed:o=[]}){let p=[`pid ${r}`,...t==="dev"?["npm run dev's"]:[],...s?[`started now${o.length?`, after passing over ${Ae(o)}`:""}`]:[],...n?[`it replaced Gallery ${n.version??"an older version"}'s server, pid ${n.pid}`]:[]],L=s?`; its log: ${f}`:"";return`This workspace's Gallery server runs on port ${e} (${p.join(", ")}${L}). This command is done; the server runs on after it (nothing to wait for or keep running).`}async function Re(e,r,t=null){return[Pe(r),...e?[`${le}${ve(r.port,e)}`]:[],`${$}${e?await xe(r.port,{slug:e,block:t}):j(r.port)}`]}async function Ke(e,{skipped:r,command:t,ports:s=null}){let n=`gallery open ${e} starts it and prints the address to give the user`;if(r)return[`Preview: not started (--no-preview or ${D}): ${n}.`];let o=await be({slug:e,command:t,ports:s});return o.ok?Re(e,o):[`Preview: not started: ${o.message}`,`When that is fixed, ${n}.`]}export{$ as a,le as b,Ve as c,ze as d,Ue as e,ve as f,j as g,ke as h,be as i,Pe as j,Re as k,Ke as l};
@@ -1,2 +1,2 @@
1
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 p}from"./chunk-6RGJOMJP.mjs";import{f as b}from"./chunk-AUZGSZJH.mjs";import{k as d}from"./chunk-6QXGZM36.mjs";import{g as k}from"./chunk-CY2FNNAB.mjs";import v from"node:fs/promises";import h from"node:path";import{editStateDirectory as m,reportsDirectory as f}from"../browser/shared/paths.mjs";import{findPreviewServer as $}from"../browser/shared/preview-server.mjs";import{documentDirectory as S,documentFiles as g,isDocumentSource as j}from"../browser/shared/workspace.mjs";var u=e=>h.resolve(e),D=e=>h.basename(g(h.dirname(e)).json),N={busy:"it kept changing while it was being written (an Agent writing it?); nothing written. Run the export again.",timeout:"the workspace's Gallery server did not answer in 30s; nothing written. Run the export again."};async function w(e,n,o="hand-in",l=3e4){let t=`127.0.0.1:${e.port}`,s;try{s=await fetch(`http://${t}/__gallery/edit/${o}`,{method:"POST",headers:{"Content-Type":"application/json",Origin:`http://${t}`,"X-Gallery-Token":e.token},body:JSON.stringify({slug:n,workspace:f}),signal:AbortSignal.timeout(l)})}catch(a){return a.name==="TimeoutError"?{ok:!1,reason:"timeout"}:null}let i=await s.json().catch(()=>null);return typeof i?.ok!="boolean"||["elsewhere","token","host","origin"].includes(i.reason)?null:i}async function P(e){let n=await $({reportsDirectory:f}),o=null,l=[],t=new Map,s=[];for(let i of e){let{html:a,json:c}=g(S(i,f)),r=n?await w(n,i):null;if(r===null&&(o??=p({reportsDirectory:f,stateDirectory:m,finish:d}),r=await o.handIn(i),r.ok&&await o.settleNotes(i)),!r.ok){r.reason!=="missing"&&t.set(i,[`${u(a)} was not handed in: ${N[r.reason]??r.message??r.reason}`]);continue}if(r.repeated?.length){t.set(i,b(r.repeated));continue}s.push(...L(a,r)),r.written&&(r.changes.length&&s.push(...k(a,r.changes,{reread:!1})),r.added&&s.push(...T(a,r.given,r.added)),l.push(u(a))),O(r)&&l.push(u(c))}return{written:l,failures:t,lines:s}}async function _(e){let n=await $({reportsDirectory:f});if(n){for(let o of e)if(await w(n,o,"settle")===null)return}}async function C(e,{wait:n=3e4}={}){try{let o=await $({reportsDirectory:f}),l=o?await w(o,e,"round",n):null;return l!==null?l.ok?l.ended===!0:null:await p({reportsDirectory:f,stateDirectory:m,finish:d}).beginRound(e)}catch{return null}}async function H(e){try{let n=p({reportsDirectory:f,stateDirectory:m,finish:d}),{html:o}=g(S(e,f));await n.noteTaken(e,await v.readFile(o,"utf8"))}catch{}}var O=({title:e=null,icon:n=null})=>!!(e&&typeof e.from=="string"&&e.from!==e.to||n&&!n.missing),x=10;function T(e,n,o=n?.length??0,{pending:l=!1}={}){let t=`${o} block${o===1?"":"s"}`;if(l){let i=[`ids ${u(e)}: ${t} without an id yet: the export gives ${o===1?"it":"each"} one`];return o>x?i:[...i,...n.map(({line:a,tag:c})=>` line ${a} ${c}`)]}let s=[`ids ${u(e)}: ${t} given an id`];return!n||o>x?s:[...s,...n.map(({line:i,tag:a,id:c})=>` line ${i} ${a} \u2192 ${c}`)]}function L(e,{title:n=null,icon:o=null}={},{pending:l=!1}={}){let t=u(h.dirname(e)),s=D(e),i=(c,r,y)=>l?`${c} not ${r} yet (${y}): the export writes ${c.includes(" and ")?"them":"it"}`:`${c} written ${r}: ${y}`,a=[];if(n){let c=[...n.page?["<title>"]:[],...typeof n.from=="string"&&n.from!==n.to?[`${s}'s title`]:[]];c.length&&a.push(`title ${t}: ${i(c.join(" and "),"as its h1 says it",JSON.stringify(n.to))}`)}return o?.missing?a.push(`icon ${t}: ${s} has the icon ${JSON.stringify(o.from)} and the page's header none: write it there (<div class="doc-icon">\u2026</div> before the h1) or take "icon" out of ${s} (the export leaves ${s}'s as it is)`):o&&a.push(`icon ${t}: ${i(`${s}'s icon`,"as its header has it",o.to===null?"none":JSON.stringify(o.to))}`),a}function K(e,{by:n="this export"}={}){let o=e.length===1,l=[...e.filter(t=>j(h.basename(t))).map(t=>h.basename(t)).filter((t,s,i)=>i.indexOf(t)===s).map(t=>`${t}: the kit's markup, block ids`),...e.filter(t=>/^(doc|report)\.json$/.test(h.basename(t))).map(t=>h.basename(t)).filter((t,s,i)=>i.indexOf(t)===s).map(t=>`${t}: the title or icon said above`)];return`Re-read ${e.join(", ")} before editing ${o?"it":"them"}: ${n} wrote ${o?"it":"them"} (${l.join("; ")}).`}export{P as a,_ as b,C as c,H as d,T as e,L as f,K as g};
2
+ import{h as p}from"./chunk-ZWWC4KLF.mjs";import{g as k}from"./chunk-ZQS6H473.mjs";import{g as b}from"./chunk-MXUBKDRO.mjs";import{k as d}from"./chunk-6N3PX4XX.mjs";import v from"node:fs/promises";import h from"node:path";import{editStateDirectory as m,reportsDirectory as f}from"../browser/shared/paths.mjs";import{findPreviewServer as $}from"../browser/shared/preview-server.mjs";import{documentDirectory as S,documentFiles as g,isDocumentSource as j}from"../browser/shared/workspace.mjs";var u=e=>h.resolve(e),D=e=>h.basename(g(h.dirname(e)).json),N={busy:"it kept changing while it was being written (an Agent writing it?); nothing written. Run the export again.",timeout:"the workspace's Gallery server did not answer in 30s; nothing written. Run the export again."};async function w(e,n,o="hand-in",l=3e4){let t=`127.0.0.1:${e.port}`,s;try{s=await fetch(`http://${t}/__gallery/edit/${o}`,{method:"POST",headers:{"Content-Type":"application/json",Origin:`http://${t}`,"X-Gallery-Token":e.token},body:JSON.stringify({slug:n,workspace:f}),signal:AbortSignal.timeout(l)})}catch(a){return a.name==="TimeoutError"?{ok:!1,reason:"timeout"}:null}let i=await s.json().catch(()=>null);return typeof i?.ok!="boolean"||["elsewhere","token","host","origin"].includes(i.reason)?null:i}async function P(e){let n=await $({reportsDirectory:f}),o=null,l=[],t=new Map,s=[];for(let i of e){let{html:a,json:c}=g(S(i,f)),r=n?await w(n,i):null;if(r===null&&(o??=p({reportsDirectory:f,stateDirectory:m,finish:d}),r=await o.handIn(i),r.ok&&await o.settleNotes(i)),!r.ok){r.reason!=="missing"&&t.set(i,[`${u(a)} was not handed in: ${N[r.reason]??r.message??r.reason}`]);continue}if(r.repeated?.length){t.set(i,b(r.repeated));continue}s.push(...L(a,r)),r.written&&(r.changes.length&&s.push(...k(a,r.changes,{reread:!1})),r.added&&s.push(...T(a,r.given,r.added)),l.push(u(a))),O(r)&&l.push(u(c))}return{written:l,failures:t,lines:s}}async function _(e){let n=await $({reportsDirectory:f});if(n){for(let o of e)if(await w(n,o,"settle")===null)return}}async function C(e,{wait:n=3e4}={}){try{let o=await $({reportsDirectory:f}),l=o?await w(o,e,"round",n):null;return l!==null?l.ok?l.ended===!0:null:await p({reportsDirectory:f,stateDirectory:m,finish:d}).beginRound(e)}catch{return null}}async function H(e){try{let n=p({reportsDirectory:f,stateDirectory:m,finish:d}),{html:o}=g(S(e,f));await n.noteTaken(e,await v.readFile(o,"utf8"))}catch{}}var O=({title:e=null,icon:n=null})=>!!(e&&typeof e.from=="string"&&e.from!==e.to||n&&!n.missing),x=10;function T(e,n,o=n?.length??0,{pending:l=!1}={}){let t=`${o} block${o===1?"":"s"}`;if(l){let i=[`ids ${u(e)}: ${t} without an id yet: the export gives ${o===1?"it":"each"} one`];return o>x?i:[...i,...n.map(({line:a,tag:c})=>` line ${a} ${c}`)]}let s=[`ids ${u(e)}: ${t} given an id`];return!n||o>x?s:[...s,...n.map(({line:i,tag:a,id:c})=>` line ${i} ${a} \u2192 ${c}`)]}function L(e,{title:n=null,icon:o=null}={},{pending:l=!1}={}){let t=u(h.dirname(e)),s=D(e),i=(c,r,y)=>l?`${c} not ${r} yet (${y}): the export writes ${c.includes(" and ")?"them":"it"}`:`${c} written ${r}: ${y}`,a=[];if(n){let c=[...n.page?["<title>"]:[],...typeof n.from=="string"&&n.from!==n.to?[`${s}'s title`]:[]];c.length&&a.push(`title ${t}: ${i(c.join(" and "),"as its h1 says it",JSON.stringify(n.to))}`)}return o?.missing?a.push(`icon ${t}: ${s} has the icon ${JSON.stringify(o.from)} and the page's header none: write it there (<div class="doc-icon">\u2026</div> before the h1) or take "icon" out of ${s} (the export leaves ${s}'s as it is)`):o&&a.push(`icon ${t}: ${i(`${s}'s icon`,"as its header has it",o.to===null?"none":JSON.stringify(o.to))}`),a}function K(e,{by:n="this export"}={}){let o=e.length===1,l=[...e.filter(t=>j(h.basename(t))).map(t=>h.basename(t)).filter((t,s,i)=>i.indexOf(t)===s).map(t=>`${t}: the kit's markup, block ids`),...e.filter(t=>/^(doc|report)\.json$/.test(h.basename(t))).map(t=>h.basename(t)).filter((t,s,i)=>i.indexOf(t)===s).map(t=>`${t}: the title or icon said above`)];return`Re-read ${e.join(", ")} before editing ${o?"it":"them"}: ${n} wrote ${o?"it":"them"} (${l.join("; ")}).`}export{P as a,_ as b,C as c,H as d,T as e,L as f,K as g};
@@ -0,0 +1,2 @@
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}from"./chunk-OEXWRJME.mjs";import"./chunk-EAIFITAV.mjs";import"./chunk-67N2QJYT.mjs";import"./chunk-ZWWC4KLF.mjs";import"./chunk-IA4PSIMD.mjs";import"./chunk-F4ZA6JRZ.mjs";import"./chunk-7M2BQQGZ.mjs";import"./chunk-ITOH5EGO.mjs";import"./chunk-ZQS6H473.mjs";import"./chunk-4OZWXZE5.mjs";import"./chunk-MXUBKDRO.mjs";import"./chunk-HXG7EOPJ.mjs";import"./chunk-ZTHICSSF.mjs";import"./chunk-6N3PX4XX.mjs";import"./chunk-PAREWQGB.mjs";import"./chunk-BFJGHSQN.mjs";import"./chunk-U5XL7D6A.mjs";import"./chunk-HYMEEXKN.mjs";import"./chunk-UMHUSOPJ.mjs";import"./chunk-R2ZDLJYT.mjs";import"./chunk-VFX2KNHP.mjs";import"./chunk-VS7JIGJW.mjs";import"./chunk-HDWTZ763.mjs";import"./chunk-A55HN5OK.mjs";import"./chunk-5L7RYZCL.mjs";export{a as noDocuments,b as run};
@@ -0,0 +1,8 @@
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 g}from"./chunk-HYMEEXKN.mjs";import{createRequire as re}from"node:module";import{typescriptFile as ae}from"../browser/shared/paths.mjs";var ce=re(import.meta.url),B=null;function fe(){return B??=ce(ae??"typescript"),B}var b=new Proxy({},{get:(e,n)=>fe()[n]});import _ from"node:fs/promises";import h from"node:path";import{COMPONENTS as D,instancesOf as ue}from"../browser/shared/components/index.mjs";import{PACKAGE_MARK as q}from"../browser/shared/components/installed.mjs";import{MATH_IGNORED_TAGS as pe}from"../browser/shared/components/math.mjs";import{attr as x,elementsOf as O,walk as y}from"../browser/shared/html-tree.mjs";import I from"node:path";import de from"node:vm";var L=()=>{throw new Error("esbuild is not in the release: Gallery 0.2.0 calls it only in a source checkout")},Le=L,J=L;var Te=new Proxy({},{get:L});import{projectRoot as le}from"../browser/shared/paths.mjs";var T=I.join(le,"src","shared","components","index.mjs");function F(e){let{outputFiles:n}=J({stdin:{contents:`import { FLOWS, FLOW_BLOCKS, runtimeDescriptions } from ${JSON.stringify(e)}; module.exports = { descriptions: runtimeDescriptions(), flows: FLOWS, blockFlows: FLOW_BLOCKS };`,resolveDir:I.dirname(e),loader:"js"},bundle:!0,write:!1,format:"cjs",platform:"node",logLevel:"silent"}),s={module:{exports:null}};return de.runInNewContext(n[0].text,s),JSON.parse(JSON.stringify(s.module.exports))}var W=(e=T)=>F(e).descriptions,G=(e=T)=>F(e).flows,U=(e=T)=>F(e).blockFlows;import{kitPublicDirectory as me,projectRoot as H,release as Y,vendorDirectory as z}from"../browser/shared/paths.mjs";var P=h.join(H,"node_modules"),he=h.join(P,"d3","dist","d3.min.js"),S=Y?h.join(z,"katex"):h.join(P,"katex","dist"),xe=h.join(S,"fonts"),He=h.join(S,"contrib","mhchem.min.js"),u=[{id:"styles",file:"report.css",build:{styles:"styles/index.css"},always:!0},{id:"katex-styles",vendor:{path:"/vendor/katex/katex.min.css",source:h.join(S,"katex.min.css")}},{id:"runtime",file:"runtime.js",build:{bundle:"runtime/index.js",options:()=>({minify:!1,define:{__COMPONENT_RUNTIME__:JSON.stringify(W()),__COMPONENT_FLOWS__:JSON.stringify(G()),__COMPONENT_BLOCK_FLOWS__:JSON.stringify(U())}})},api:"DocKit",always:!0},{id:"code",file:"code.js",build:{bundle:"code.js",options:{minify:!0,legalComments:"inline"}},api:"DocCode",after:["runtime"]},{id:"state",file:"state.js",build:{read:"state.js"},api:"DocState",always:!0},{id:"sheets",file:"sheets.js",build:{read:"sheets.js"},api:"DocSheets",after:["runtime","state"]},{id:"tokens",file:"tokens.js",build:{read:"tokens.js"},api:"DocTokens",always:!0},{id:"ui",file:"ui.js",build:{bundle:"ui.js",options:{minify:!1}},added:!0,after:["runtime","state","tokens"]},{id:"dialogs",file:"dialogs.js",build:{read:"dialogs.js"},api:"DocDialogs",after:["runtime"]},{id:"katex",vendor:{path:"/vendor/katex/katex.min.js",source:h.join(S,"katex.min.js")},umd:!0},{id:"katex-auto-render",vendor:{path:"/vendor/katex/auto-render.min.js",source:h.join(S,"contrib","auto-render.min.js")},umd:!0,after:["katex"]},{id:"math",file:"math.js",build:{bundle:"math-bundle.js",options:{minify:!1,legalComments:"inline",alias:{katex:h.join(H,"src","render","kit","page-katex.js")},nodePaths:[h.join(P,"katex")]}},api:"DocMath",after:["runtime","katex-styles","katex","katex-auto-render"]},{id:"d3",vendor:{path:"/vendor/d3.v7.9.0.min.js",source:he},api:"d3",umd:!0},{id:"charts",file:"charts.js",build:{bundle:"charts/index.js",options:{minify:!1}},api:"DocCharts",after:["runtime","tokens"]},{id:"tables",file:"tables.js",build:{bundle:"tables/index.js",options:{minify:!1}},api:"DocTables",after:["runtime"]},{id:"board-styles",file:"board.css",build:{styles:"board/index.css"},page:!0},{id:"board",file:"board.js",build:{bundle:"board/index.js",options:{minify:!1}},page:!0}],m=e=>e.file?`/kit/${e.file}`:e.vendor.path,ge=e=>e.file?h.join(me,e.file):h.join(z,...e.vendor.path.split("/").slice(2));if(Y)for(let e of u)e.vendor&&(e.vendor.source=ge(e));var k=e=>m(e).endsWith(".css"),E=e=>e.file?"data-doc-kit":"data-doc-vendor",C=e=>u.find(n=>n.id===e),w=(e,n=m(e))=>k(e)?`<link rel="stylesheet" href="${n}" ${E(e)}="${e.id}">`:`<script src="${n}" ${E(e)}="${e.id}"></script>`,we=u.map(e=>({id:e.id,tag:w(e),always:!!e.always,element:k(e)?"style":"script",attribute:E(e)}));function Ye(e,n=m){let s=new Set,i=t=>{s.has(t)||(s.add(t),C(t)?.after?.forEach(i))};return e.forEach(i),u.filter(t=>s.has(t.id)&&!t.always&&!t.added).map(t=>w(t,n(t)))}function ye(e=u,n=D){let s=[],i=e.map(t=>t.id);for(let t of new Set(i.filter((a,o)=>i.indexOf(a)!==o)))s.push(`the asset "${t}" is listed twice`);for(let t of e){!!t.file==!!t.vendor&&s.push(`the asset "${t.id}" is a kit file (file) or a vendor file (vendor), one of them`),t.file&&!["read","bundle","styles"].some(o=>typeof t.build?.[o]=="string")&&s.push(`the kit file "${t.file}" does not say how it is made (build: read, bundle or styles)`),t.vendor&&!(t.vendor.path&&t.vendor.source)&&s.push(`the vendor asset "${t.id}" needs its public path and its source`);for(let o of t.after??[])i.includes(o)?i.indexOf(o)>i.indexOf(t.id)&&s.push(`the asset "${t.id}" loads after "${o}", which the list puts after it`):s.push(`the asset "${t.id}" loads after "${o}", which is no asset`);let a=n.filter(o=>(o.assets??[]).includes(t.id));!t.always&&!t.api&&!t.added&&!t.page&&a.length===0&&s.push(`no report would keep the asset "${t.id}": it is not always kept, defines no global and no component needs it`)}for(let t of n)for(let a of t.assets??[])i.includes(a)||s.push(`the component "${t.id}" needs "${a}", which is no asset`);return s}{let e=ye();if(e.length>0)throw new Error(`src/render/assets.mjs: ${e.join("; ")}`)}var K=/^(?:|module|(?:text|application)\/(?:x-)?(?:javascript|ecmascript)|text\/javascript1\.[0-5]|text\/(?:jscript|livescript))$/,be=/^application\/(?:\S+\+)?json$/,N=e=>(x(e,"type")??"").trim().toLowerCase();function V(e){let n=b.createSourceFile("report.js",e,b.ScriptTarget.Latest,!1,b.ScriptKind.JS),s=[],i=[n];for(;i.length>0;){let t=i.pop();if(t.kind>=b.SyntaxKind.FirstJSDocNode&&t.kind<=b.SyntaxKind.LastJSDocNode)continue;let a=t.getChildren(n);a.length===0&&s.push(e.slice(t.getStart(n),t.end));for(let o=a.length-1;o>=0;o-=1)i.push(a[o])}return s.join(" ")}var Q=e=>new RegExp(`\\b(?:${e.filter(n=>n.api).map(n=>n.api).join("|")})\\b`);function $e(e,n){let s=[],i=t=>{n.test(t)&&s.push(V(t))};return y(e,t=>{t.tagName==="script"&&x(t,"src")===void 0&&K.test(N(t))&&i(t.childNodes.map(a=>a.value??"").join(""));for(let{name:a,value:o}of t.attrs??[]){if(/^on/.test(a)){i(o);continue}let c=o.replace(/[\t\n\r]/g,"").replace(/^[\x00-\x20]+/,"");if(!/^javascript:/i.test(c))continue;let r=c.slice(11);try{r=decodeURIComponent(r)}catch{}i(r)}}),s.join(`
3
+ `)}function je(e,n){let s=[],i=(o,c)=>{for(let r of o.childNodes??[]){let f=r.sourceCodeLocation;r.nodeName==="#comment"||c&&r.nodeName==="#text"?f&&s.push([f.startOffset,f.endOffset]):r.tagName==="script"?i(r,be.test(N(r))):r.tagName&&i(r.content??r,c||pe.includes(r.tagName))}};i(e,!1);let t="",a=0;for(let[o,c]of s.sort((r,f)=>r[0]-f[0]))o<a||(t+=`${n.slice(a,o)} `,a=c);return t+n.slice(a)}function R(e,n=u,s=D){let i=n.reduce((f,d)=>f.replaceAll(w(d),""),e),t=g(i),a=je(t,i),o=$e(t,Q(n)),c=new Set,r=f=>{c.has(f)||(c.add(f),(n.find(d=>d.id===f)?.after??[]).forEach(r))};for(let f of s){if(!(f.assets??[]).length)continue;((f.uses??[]).some(l=>l.test(a))||f.match&&ue(t,f).length>0)&&f.assets.forEach(r)}for(let f of n)f.api&&new RegExp(`\\b${f.api}\\b`).test(o)&&r(f.id);return c}function ze(e,n=D){let s=R(e,u,n),i=[];for(let t of u){let a=w(t);if(t.always||t.added||s.has(t.id)||!e.includes(a))continue;let o=a.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");e=e.replace(new RegExp(`[ \\t]*${o}[ \\t]*\\r?\\n?`),""),i.push(t.id)}return{html:e,removed:i,used:s}}function M(e,n){let s=[];return y(n,i=>{let t=Z(i),a=t===void 0?void 0:u.find(c=>m(c)===t.trim()),o=i.sourceCodeLocation;!a||!o||s.push({asset:a,start:o.startOffset,end:o.endOffset,line:o.startLine,exact:e.slice(o.startOffset,o.endOffset)===w(a)})},{inTemplates:!1}),s}var X=e=>e.tagName==="style"||e.tagName==="link"&&(x(e,"rel")??"").toLowerCase().split(/\s+/).includes("stylesheet"),Z=e=>e.tagName==="script"?x(e,"src"):X(e)?x(e,"href"):void 0,j=e=>!!e.sourceCodeLocation,A=e=>e.includes(`\r
4
+ `)?`\r
5
+ `:`
6
+ `;function $(e,n,{closing:s=!1}={}){let i=n===0?0:e.lastIndexOf(`
7
+ `,n-1)+1,t=e.slice(i,n);if(!/^[ \t]*$/.test(t))return{at:n,text:o=>o};let a=s?`${t} `:t;return{at:i,text:o=>`${a}${o}${A(e)}`}}function v(e,n){let s=/^[ \t]*/.exec(e.slice(e.lastIndexOf(`
8
+ `,n-1)+1))[0];return{at:n,text:i=>`${A(e)}${s}${i}`}}function ee(e){let n;return y(e,s=>{!n&&s.tagName==="main"&&(n=s)},{inTemplates:!1}),n}var ke="http://www.w3.org/1999/xhtml";function Oe(e){let n=e;for(let s=e.parentNode;s?.tagName;s=s.parentNode)s.namespaceURI!==ke&&(n=s);return n}function te(e,n,s){let i=O(n).find(o=>o.tagName==="html"),t=O(i??{}).find(o=>o.tagName==="head"),a=O(i??{}).find(o=>o.tagName==="body");if(s){let o=O(t??{}).filter(j),c=o.find(X);if(c)return $(e,c.sourceCodeLocation.startOffset);if(t?.sourceCodeLocation?.endTag)return $(e,t.sourceCodeLocation.endTag.startOffset,{closing:!0});if(o.length>0)return v(e,o.at(-1).sourceCodeLocation.endOffset);if(t?.sourceCodeLocation)return v(e,t.sourceCodeLocation.startTag.endOffset);let r=a?.sourceCodeLocation?.startTag?.startOffset??O(a??{}).find(j)?.sourceCodeLocation.startOffset;if(r!==void 0)return $(e,r)}else{let o=ee(n),c=d=>{for(let l=d.parentNode;l;l=l.parentNode)if(l===o)return!1;return!o?.sourceCodeLocation||d.sourceCodeLocation.startOffset>o.sourceCodeLocation.startOffset},r;if(y(a??{},d=>{!r&&d.tagName==="script"&&j(d)&&K.test(N(d))&&c(d)&&(r=d)},{inTemplates:!1}),r)return $(e,Oe(r).sourceCodeLocation.startOffset);let f=a?.sourceCodeLocation?.endTag??i?.sourceCodeLocation?.endTag;if(f)return $(e,f.startOffset,{closing:!0})}return{at:e.length,text:o=>`${A(e)}${o}`}}function oe(e,n,{free:s}){let i=M(e,n),t=new Map;for(let a of[!0,!1]){let o=u.filter(d=>k(d)===a),c=d=>i.find(l=>l.asset===d),r=o.map(c).find(Boolean),f=r?$(e,r.start):s?te(e,n,a):null;for(let d of o){let l=c(d);l?(t.set(d.id,{at:l.start,written:l}),f=v(e,l.end)):f&&t.set(d.id,f)}}return t}function ne(e,n,{tree:s=g(e),free:i,href:t=m}){let a=[];for(let[r,f]of oe(e,s,{free:i})){let d=C(r);f.written?f.written.exact&&t(d)!==m(d)&&a.push({at:f.written.start,end:f.written.end,text:w(d,t(d))}):n.has(r)&&a.push({at:f.at,end:f.at,text:f.text(w(d,t(d)))})}if(a.length===0)return e;a.sort((r,f)=>r.at-f.at);let o="",c=0;for(let{at:r,end:f,text:d}of a)o+=e.slice(c,r)+d,c=f;return o+e.slice(c)}function Ve(e,{used:n=R(e),href:s=m,page:i=!1}={}){let t=g(e),a=x(ee(t)??{},"data-doc-id")!==void 0,o=new Set(u.filter(c=>c.always||n.has(c.id)||c.added&&(a||i)||c.page&&i).map(c=>c.id));return ne(e,o,{tree:t,free:!0,href:s})}function Qe(e){let n=R(e);return ne(e,new Set(u.filter(s=>!s.always&&!s.added&&n.has(s.id)).map(s=>s.id)),{free:!1})}function Xe(e,{styles:n,scripts:s}){let i=g(e),t=[];y(i,r=>{let f=u.find(d=>m(d)===Z(r)?.trim().split("?")[0]);f&&j(r)&&t.push({style:k(f),end:r.sourceCodeLocation.endOffset})},{inTemplates:!1});let a=[[!0,n],[!1,s]].filter(([,r])=>r.length>0).map(([r,f])=>{let d=t.filter(p=>p.style===r).at(-1),l=d?v(e,d.end):te(e,i,r);return{at:l.at,text:f.map(l.text).join("")}}),o="",c=0;for(let{at:r,text:f}of a.sort((d,l)=>d.at-l.at))o+=e.slice(c,r)+f,c=r;return o+e.slice(c)}function Ze(e,n=g(e)){let s=[],i=[];if(y(n,o=>{let c=["data-doc-kit","data-doc-vendor"].find(r=>x(o,r)?.endsWith("-inline"))??(x(o,q)===void 0?void 0:q);c&&j(o)&&i.push({line:o.sourceCodeLocation.startLine,mark:`${c}="${x(o,c)}"`})},{inTemplates:!1}),i.length>0){let o=i.length>1?`, and ${i.length-1} more on line${i.length>2?"s":""} ${se(i.slice(1).map(({line:c})=>c))}`:"";s.push(`line ${i[0].line}: an export's inline copy of the kit (${i[0].mark}${o}), which a document's source never holds (the kit's tags are put in as the document is shown, so it would load twice): bring an exported file in with \u5BFC\u5165 instead of copying it in`)}let t=M(e,n);for(let{asset:o,line:c,exact:r}of t)r||s.push(`line ${c}: ${m(o)} is not loaded by the kit's own tag, ${w(o)}: take the tag out (the kit's tags are put in as the document is shown and exported)`);for(let o of u){let c=t.filter(r=>r.asset===o).map(r=>r.line);c.length>1&&s.push(`${m(o)} is loaded ${c.length} times (lines ${c.join(", ")}): keep one tag, or none`)}let a=o=>t.find(c=>c.asset===o);for(let o of u){let c=a(o);if(c)for(let r of o.after??[]){let f=a(C(r));f&&f.start>c.start&&s.push(`line ${c.line}: ${m(f.asset)} (line ${f.line}) must load before ${m(o)}`)}}return[...new Set(s)]}var se=e=>e.length>1?`${e.slice(0,-1).join(", ")} and ${e.at(-1)}`:e[0];function et(e,n=g(e)){let s=Q(u),i=[],t;return y(n,a=>{if(a.tagName!=="script"||x(a,"src")!==void 0||!j(a)||N(a)==="module"||!K.test(N(a)))return;let o=a.childNodes.map(p=>p.value??"").join("");if(!s.test(o))return;let c=V(o);t??=oe(e,n,{free:!0});let{startOffset:r,startLine:f}=a.sourceCodeLocation,d=u.filter(p=>p.api&&new RegExp(`\\b${p.api}\\b`).test(c)&&t.get(p.id).at>r),l=d.filter(p=>!t.get(p.id).written);l.length>0&&i.push(`line ${f}: this script names ${se(l.map(p=>p.api))} before the kit's scripts load (they are put in after </main>): move the script after </main>`);for(let p of d.filter(ie=>t.get(ie.id).written))i.push(`line ${f}: this script names ${p.api} before ${m(p)} loads (line ${t.get(p.id).written.line}): move the script after that tag`)},{inTemplates:!1}),i}function tt(e,n){let s=new Set,i="",t=0;for(let{asset:a,start:o,end:c,exact:r}of M(e,g(e)))!r||s.has(a.id)||(s.add(a.id),i+=e.slice(t,o)+n(we.find(f=>f.id===a.id)),t=c);return i+e.slice(t)}var ot=new Set(u.filter(e=>!k(e)).map(m)),nt=new Set(u.filter(k).map(m));async function Se({inlineFonts:e=!1}={}){let n=await _.readFile(C("katex-styles").vendor.source,"utf8");if(n=n.replace(/src:url\((fonts\/[^)]+\.woff2)\) format\("woff2"\),url\(fonts\/[^)]+\.woff\) format\("woff"\),url\(fonts\/[^)]+\.ttf\) format\("truetype"\)/g,'src:url($1) format("woff2")'),!e)return n;let s=[...new Set([...n.matchAll(/url\(fonts\/([^)]+\.woff2)\)/g)].map(i=>i[1]))];for(let i of s){let t=await _.readFile(h.join(xe,i));n=n.replaceAll(`url(fonts/${i})`,`url(data:font/woff2;base64,${t.toString("base64")})`)}return n}function st(e,{inline:n=!1}={}){return e.id==="katex-styles"?Se({inlineFonts:n}):_.readFile(e.vendor.source,"utf8")}export{b as a,Le as b,xe as c,He as d,u as e,m as f,ge as g,Ye as h,ze as i,Ve as j,Qe as k,Xe as l,Ze as m,et as n,tt as o,ot as p,nt as q,st as r};
@@ -1,5 +1,5 @@
1
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{$ as cr,$a as Ai,A as P,Aa as lr,Ab as pr,B as q,Bb as Gi,C as Ct,Ca as Oi,Cb as Xi,D as hi,Dc as rn,F as pi,Fb as Ji,G as fi,Gb as Yi,H as ne,I as b,Ib as Zi,J as Ne,K as mi,La as E,Ma as j,N as _e,Na as Ni,Nb as Qi,Oa as _i,P as gi,Pa as fe,Q as Et,Qa as Bi,S as wi,Sb as en,T as yi,U as vi,V as xi,Z as Be,_a as Fi,a as or,aa as bi,b as re,ca as Ci,cb as oe,d as Re,db as Ui,e as Oe,ea as J,f as Ze,fa as Ei,fb as hr,g as ci,gb as Li,ha as dr,ia as Si,ib as Mi,j as di,ja as Fe,jb as qi,k as ui,kb as ji,la as Pi,mb as $i,n as li,na as ki,nb as ae,o as ar,oa as Ii,ob as Hi,p as ie,pa as Di,pb as zi,q as bt,qa as St,ra as Ti,sb as Wi,sc as tn,t as D,tc as sn,va as Pt,w as L,wa as Ri,wb as Ki,xb as Vi,ya as ur,yb as Qe,zb as et}from"./chunk-7DTINW6U.mjs";import"./chunk-YEY3RSFQ.mjs";import"./chunk-UH4SIXTR.mjs";import"./chunk-Y34NR5JL.mjs";import{b as xt,c as T}from"./chunk-W7XHE4CT.mjs";import{d as ai}from"./chunk-5L7RYZCL.mjs";var Ve={};ai(Ve,{BidiServer:()=>Fs,EventEmitter:()=>K,OutgoingMessage:()=>X});function nn(n){return{all:n=n||new Map,on:function(e,t){var s=n.get(e);s?s.push(t):n.set(e,[t])},off:function(e,t){var s=n.get(e);s&&(t?s.splice(s.indexOf(t)>>>0,1):n.set(e,[]))},emit:function(e,t){var s=n.get(e);s&&s.slice().map(function(r){r(t)}),(s=n.get("*"))&&s.slice().map(function(r){r(e,t)})}}}var K=class{#e=nn();on(e,t){return this.#e.on(e,t),this}once(e,t){let s=r=>{t(r),this.off(e,s)};return this.on(e,s)}off(e,t){return this.#e.off(e,t),this}emit(e,t){this.#e.emit(e,t)}removeAllListeners(e){return e?this.#e.all.delete(e):this.#e.all.clear(),this}};var S;(function(n){n.bidi="bidi",n.cdp="cdp",n.debug="debug",n.debugError="debug:error",n.debugInfo="debug:info",n.debugWarn="debug:warn"})(S||(S={}));var on,tt=class{static LOGGER_PREFIX=`${S.debug}:queue`;#e;#t;#s=[];#r=!1;constructor(e,t){this.#t=e,this.#e=t}add(e,t){this.#s.push([e,t]),this.#i()}async#i(){if(!this.#r){for(this.#r=!0;this.#s.length>0;){let e=this.#s.shift();if(!e)continue;let[t,s]=e;this.#e?.(on.LOGGER_PREFIX)?.("Processing event:",s),await t.then(r=>{if(r.kind==="error"){this.#e?.(S.debugError)?.("Event threw before sending:",r.error.message,r.error.stack);return}return this.#t(r.value)}).catch(r=>{this.#e?.(S.debugError)?.("Event was not processed:",r?.message)})}this.#r=!1}}};on=tt;var C={};ai(C,{BiDiModule:()=>kt,Bluetooth:()=>Ae,BrowsingContext:()=>Tt,EVENT_NAMES:()=>ro,Input:()=>Rt,Log:()=>Dt,Network:()=>Ot,Script:()=>It,Speculation:()=>Ue});var kt;(function(n){n.Bluetooth="bluetooth",n.Browser="browser",n.BrowsingContext="browsingContext",n.Cdp="goog:cdp",n.Input="input",n.Log="log",n.Network="network",n.Script="script",n.Session="session",n.Speculation="speculation"})(kt||(kt={}));var It;(function(n){let e;(function(t){t.Message="script.message",t.RealmCreated="script.realmCreated",t.RealmDestroyed="script.realmDestroyed"})(e=n.EventNames||(n.EventNames={}))})(It||(It={}));var Dt;(function(n){let e;(function(t){t.LogEntryAdded="log.entryAdded"})(e=n.EventNames||(n.EventNames={}))})(Dt||(Dt={}));var Tt;(function(n){let e;(function(t){t.ContextCreated="browsingContext.contextCreated",t.ContextDestroyed="browsingContext.contextDestroyed",t.DomContentLoaded="browsingContext.domContentLoaded",t.DownloadEnd="browsingContext.downloadEnd",t.DownloadWillBegin="browsingContext.downloadWillBegin",t.FragmentNavigated="browsingContext.fragmentNavigated",t.HistoryUpdated="browsingContext.historyUpdated",t.Load="browsingContext.load",t.NavigationAborted="browsingContext.navigationAborted",t.NavigationCommitted="browsingContext.navigationCommitted",t.NavigationFailed="browsingContext.navigationFailed",t.NavigationStarted="browsingContext.navigationStarted",t.UserPromptClosed="browsingContext.userPromptClosed",t.UserPromptOpened="browsingContext.userPromptOpened"})(e=n.EventNames||(n.EventNames={}))})(Tt||(Tt={}));var Rt;(function(n){let e;(function(t){t.FileDialogOpened="input.fileDialogOpened"})(e=n.EventNames||(n.EventNames={}))})(Rt||(Rt={}));var Ot;(function(n){let e;(function(t){t.AuthRequired="network.authRequired",t.BeforeRequestSent="network.beforeRequestSent",t.FetchError="network.fetchError",t.ResponseCompleted="network.responseCompleted",t.ResponseStarted="network.responseStarted"})(e=n.EventNames||(n.EventNames={}))})(Ot||(Ot={}));var Ae;(function(n){let e;(function(t){t.RequestDevicePromptUpdated="bluetooth.requestDevicePromptUpdated",t.GattConnectionAttempted="bluetooth.gattConnectionAttempted",t.CharacteristicEventGenerated="bluetooth.characteristicEventGenerated",t.DescriptorEventGenerated="bluetooth.descriptorEventGenerated"})(e=n.EventNames||(n.EventNames={}))})(Ae||(Ae={}));var Ue;(function(n){let e;(function(t){t.PrefetchStatusUpdated="speculation.prefetchStatusUpdated"})(e=n.EventNames||(n.EventNames={}))})(Ue||(Ue={}));var ro=new Set([...Object.values(kt),...Object.values(Ae.EventNames),...Object.values(Tt.EventNames),...Object.values(Rt.EventNames),...Object.values(Dt.EventNames),...Object.values(Ot.EventNames),...Object.values(It.EventNames),...Object.values(Ue.EventNames)]);var F=class extends Error{error;message;stacktrace;constructor(e,t,s){super(),this.error=e,this.message=t,this.stacktrace=s}toErrorResponse(e){return{type:"error",id:e,error:this.error,message:this.message,stacktrace:this.stacktrace}}},x=class extends F{constructor(e,t){super("invalid argument",e,t)}},xe=class extends F{constructor(e,t){super("invalid selector",e,t)}};var st=class extends F{constructor(e,t){super("move target out of bounds",e,t)}},Nt=class extends F{constructor(e,t){super("no such alert",e,t)}},ce=class extends F{constructor(e,t){super("no such element",e,t)}},V=class extends F{constructor(e,t){super("no such frame",e,t)}},rt=class extends F{constructor(e,t){super("no such handle",e,t)}},_t=class extends F{constructor(e,t){super("no such history entry",e,t)}},Bt=class extends F{constructor(e,t){super("no such intercept",e,t)}},Y=class extends F{constructor(e,t){super("no such node",e,t)}},Le=class extends F{constructor(e,t){super("no such request",e,t)}},it=class extends F{constructor(e,t){super("no such script",e,t)}},G=class extends F{constructor(e,t){super("no such user context",e,t)}};var Ft=class extends F{constructor(e,t){super("unknown command",e,t)}},O=class extends F{constructor(e,t=new Error().stack){super("unknown error",e,t)}},nt=class extends F{constructor(e,t){super("unable to capture screen",e,t)}};var R=class extends F{constructor(e,t){super("unsupported operation",e,t)}};var At=class extends F{constructor(e,t){super("unable to set cookie",e,t)}},be=class extends F{constructor(e,t){super("unable to set file input",e,t)}};var Ut=class extends F{constructor(e,t){super("invalid web extension",e,t)}},Lt=class extends F{constructor(e,t){super("no such web extension",e,t)}},Me=class extends F{constructor(e,t){super("no such network collector",e,t)}},me=class extends F{constructor(e,t){super("no such network data",e,t)}};var Mt=class{parseDisableSimulationParameters(e){return e}parseHandleRequestDevicePromptParams(e){return e}parseSimulateAdapterParameters(e){return e}parseSimulateAdvertisementParameters(e){return e}parseSimulateCharacteristicParameters(e){return e}parseSimulateCharacteristicResponseParameters(e){return e}parseSimulateDescriptorParameters(e){return e}parseSimulateDescriptorResponseParameters(e){return e}parseSimulateGattConnectionResponseParameters(e){return e}parseSimulateGattDisconnectionParameters(e){return e}parseSimulatePreconnectedPeripheralParameters(e){return e}parseSimulateServiceParameters(e){return e}parseCreateUserContextParameters(e){return e}parseRemoveUserContextParameters(e){return e}parseSetClientWindowStateParameters(e){return e}parseSetDownloadBehaviorParameters(e){return e}parseActivateParams(e){return e}parseCaptureScreenshotParams(e){return e}parseCloseParams(e){return e}parseCreateParams(e){return e}parseGetTreeParams(e){return e}parseHandleUserPromptParams(e){return e}parseLocateNodesParams(e){return e}parseNavigateParams(e){return e}parsePrintParams(e){return e}parseReloadParams(e){return e}parseSetBypassCspParams(e){return e}parseSetViewportParams(e){return e}parseStartScreencastParams(e){return e}parseStopScreencastParams(e){return e}parseTraverseHistoryParams(e){return e}parseGetSessionParams(e){return e}parseResolveRealmParams(e){return e}parseSendCommandParams(e){return e}parseSetClientHintsOverrideParams(e){return e}parseSetForcedColorsModeThemeOverrideParams(e){return e}parseSetGeolocationOverrideParams(e){return e}parseSetLocaleOverrideParams(e){return e}parseSetNetworkConditionsParams(e){return e}parseSetScreenOrientationOverrideParams(e){return e}parseSetScreenSettingsOverrideParams(e){return e}parseSetScriptingEnabledParams(e){return e}parseSetScrollbarTypeOverrideParams(e){return e}parseSetTimezoneOverrideParams(e){return e}parseSetTouchOverrideParams(e){return e}parseSetUserAgentOverrideParams(e){return e}parseAddPreloadScriptParams(e){return e}parseCallFunctionParams(e){return e}parseDisownParams(e){return e}parseEvaluateParams(e){return e}parseGetRealmsParams(e){return e}parseRemovePreloadScriptParams(e){return e}parsePerformActionsParams(e){return e}parseReleaseActionsParams(e){return e}parseSetFilesParams(e){return e}parseAddDataCollectorParams(e){return e}parseAddInterceptParams(e){return e}parseContinueRequestParams(e){return e}parseContinueResponseParams(e){return e}parseContinueWithAuthParams(e){return e}parseDisownDataParams(e){return e}parseFailRequestParams(e){return e}parseGetDataParams(e){return e}parseProvideResponseParams(e){return e}parseRemoveDataCollectorParams(e){return e}parseRemoveInterceptParams(e){return e}parseSetCacheBehaviorParams(e){return e}parseSetExtraHeadersParams(e){return e}parseSetPermissionsParams(e){return e}parseSubscribeParams(e){return e}parseUnsubscribeParams(e){return e}parseDeleteCookiesParams(e){return e}parseGetCookiesParams(e){return e}parseSetCookieParams(e){return e}parseInstallParams(e){return e}parseUninstallParams(e){return e}parseSetVirtualWalletBehaviorParams(e){return e}};var qt=class{#e;#t;#s;#r;constructor(e,t,s,r){this.#e=e,this.#t=t,this.#s=s,this.#r=r}close(){return setTimeout(()=>this.#e.sendCommand("Browser.close").catch(()=>{}),0),{}}async createUserContext(e){let t=e,s=this.#s.getGlobalConfig();if(t.acceptInsecureCerts!==void 0&&t.acceptInsecureCerts===!1&&s.acceptInsecureCerts===!0)throw new O(`Cannot set user context's "acceptInsecureCerts" to false, when a capability "acceptInsecureCerts" is set to true`);let r={};if(t.proxy){let o=no(t.proxy);o&&(r.proxyServer=o),t.proxy.noProxy&&(r.proxyBypassList=t.proxy.noProxy.join(","))}else{e["goog:proxyServer"]!==void 0&&(r.proxyServer=e["goog:proxyServer"]);let o=e["goog:proxyBypassList"]??void 0;o&&(r.proxyBypassList=o.join(","))}let i=await this.#e.sendCommand("Target.createBrowserContext",r);return await this.#a(s.downloadBehavior??null,i.browserContextId),this.#s.updateUserContextConfig(i.browserContextId,{acceptInsecureCerts:e.acceptInsecureCerts,userPromptHandler:e.unhandledPromptBehavior}),{userContext:i.browserContextId}}async removeUserContext(e){let t=e.userContext;if(t==="default")throw new x("`default` user context cannot be removed");try{await this.#e.sendCommand("Target.disposeBrowserContext",{browserContextId:t})}catch(s){throw s.message.startsWith("Failed to find context with id")?new G(s.message):s}return{}}async getUserContexts(){return{userContexts:await this.#r.getUserContexts()}}async#i(e){let t=await this.#e.sendCommand("Browser.getWindowForTarget",{targetId:e});return{active:!1,clientWindow:`${t.windowId}`,state:t.bounds.windowState??"normal",height:t.bounds.height??0,width:t.bounds.width??0,x:t.bounds.left??0,y:t.bounds.top??0}}async setClientWindowState(e){let{clientWindow:t}=e,s={windowState:e.state};e.state==="normal"&&(e.width!==void 0&&(s.width=e.width),e.height!==void 0&&(s.height=e.height),e.x!==void 0&&(s.left=e.x),e.y!==void 0&&(s.top=e.y));let r=Number.parseInt(t);if(isNaN(r))throw new x("no such client window");await this.#e.sendCommand("Browser.setWindowBounds",{windowId:r,bounds:s});let i=await this.#e.sendCommand("Browser.getWindowBounds",{windowId:r});return{active:!1,clientWindow:`${r}`,state:i.bounds.windowState??"normal",height:i.bounds.height??0,width:i.bounds.width??0,x:i.bounds.left??0,y:i.bounds.top??0}}async getClientWindows(){let e=this.#t.getTopLevelContexts().map(i=>i.cdpTarget.id),t=await Promise.all(e.map(async i=>await this.#i(i))),s=new Set,r=new Array;for(let i of t)s.has(i.clientWindow)||(s.add(i.clientWindow),r.push(i));return{clientWindows:r}}#o(e){if(e===null)return{behavior:"default"};if(e?.type==="denied")return{behavior:"deny"};if(e?.type==="allowed")return{behavior:"allow",downloadPath:e.destinationFolder};throw new O("Unexpected download behavior")}async#a(e,t){await this.#e.sendCommand("Browser.setDownloadBehavior",{...this.#o(e),browserContextId:t==="default"?void 0:t,eventsEnabled:!0})}async setDownloadBehavior(e){let t;return e.userContexts===void 0?t=(await this.#r.getUserContexts()).map(s=>s.userContext):t=Array.from(await this.#r.verifyUserContextIdList(e.userContexts)),e.userContexts===void 0?this.#s.updateGlobalConfig({downloadBehavior:e.downloadBehavior}):e.userContexts.map(s=>this.#s.updateUserContextConfig(s,{downloadBehavior:e.downloadBehavior})),await Promise.all(t.map(async s=>{let r=this.#s.getActiveConfig(void 0,s).downloadBehavior??null;await this.#a(r,s)})),{}}};function no(n){if(!(n.proxyType==="direct"||n.proxyType==="system")){if(n.proxyType==="pac")throw new R("PAC proxy configuration is not supported per user context");if(n.proxyType==="autodetect")throw new R("Autodetect proxy is not supported per user context");if(n.proxyType==="manual"){let e=[];if(n.httpProxy!==void 0&&e.push(`http=${n.httpProxy}`),n.sslProxy!==void 0&&e.push(`https=${n.sslProxy}`),n.socksProxy!==void 0||n.socksVersion!==void 0){if(n.socksProxy===void 0)throw new x("'socksVersion' cannot be set without 'socksProxy'");if(n.socksVersion===void 0||typeof n.socksVersion!="number"||!Number.isInteger(n.socksVersion)||n.socksVersion<0||n.socksVersion>255)throw new x("'socksVersion' must be between 0 and 255");e.push(`socks=socks${n.socksVersion}://${n.socksProxy}`)}return e.length===0?void 0:e.join(";")}throw new O("Unknown proxy type")}}var jt=class{#e;#t;#s;#r;constructor(e,t,s,r){this.#e=e,this.#t=t,this.#s=s,this.#r=r}getSession(e){let t=e.context,s=this.#e.getContext(t).cdpTarget.cdpSessionId;return s===void 0?{}:{session:s}}resolveRealm(e){let t=e.realm,s=this.#t.getRealm({realmId:t});if(s===void 0)throw new O(`Could not find realm ${e.realm}`);return{executionContextId:s.executionContextId}}async sendCommand(e){return{result:await(e.session?this.#s.getCdpClient(e.session):this.#r).sendCommand(e.method,e.params),session:e.session}}};var $t=class{#e;#t;#s;#r;#i;constructor(e,t,s,r,i){this.#s=r,this.#i=s,this.#e=e,this.#t=t,this.#r=i,this.#r.addSubscribeHook(C.BrowsingContext.EventNames.ContextCreated,this.#a.bind(this))}getTree(e){return{contexts:(e.root===void 0?this.#t.getTopLevelContexts():[this.#t.getContext(e.root)]).map(s=>s.serializeToBidiValue(e.maxDepth??Number.MAX_VALUE))}}async create(e){let t,s="default";if(e.referenceContext!==void 0){if(t=this.#t.getContext(e.referenceContext),!t.isTopLevelContext())throw new x("referenceContext should be a top-level context");s=t.userContext}e.userContext!==void 0&&(s=e.userContext);let r=this.#t.getAllContexts().filter(c=>c.userContext===s),i=!1;switch(e.type){case"tab":i=!1;break;case"window":i=!0;break}r.length||(i=!0);let o;try{o=await this.#e.sendCommand("Target.createTarget",{url:"about:blank",newWindow:i,browserContextId:s==="default"?void 0:s,background:e.background===!0})}catch(c){throw c.message.startsWith("Failed to find browser context with id")||c.message==="browserContextId"?new G(`The context ${s} was not found`):c}let a=await this.#t.waitForContext(o.targetId);return await a.lifecycleLoaded(),{context:a.id}}navigate(e){return this.#t.getContext(e.context).navigate(e.url,e.wait??"none")}reload(e){return this.#t.getContext(e.context).reload(e.ignoreCache??!1,e.wait??"none")}async activate(e){let t=this.#t.getContext(e.context);if(!t.isTopLevelContext())throw new x("Activation is only supported on the top-level context");return await t.activate(),{}}async captureScreenshot(e){return await this.#t.getContext(e.context).captureScreenshot(e)}async print(e){return await this.#t.getContext(e.context).print(e)}async setViewport(e){if((e.viewport?.height??0)>1e7||(e.viewport?.width??0)>1e7)throw new R("Viewport dimension over 10000000 are not supported");let s={};e.devicePixelRatio!==void 0&&(s.devicePixelRatio=e.devicePixelRatio),e.viewport!==void 0&&(s.viewport=e.viewport);let r=await this.#o(e.context,e.userContexts);for(let i of e.userContexts??[])this.#s.updateUserContextConfig(i,s);return e.context!==void 0&&this.#s.updateBrowsingContextConfig(e.context,s),await Promise.all(r.map(async i=>{let o=this.#s.getActiveConfig(i.id,i.userContext);await i.setViewport(o.viewport??null,o.devicePixelRatio??null,o.screenOrientation??null)})),{}}async#o(e,t){if(e===void 0&&t===void 0)throw new x("Either userContexts or context must be provided");if(e!==void 0&&t!==void 0)throw new x("userContexts and context are mutually exclusive");if(e!==void 0){let r=this.#t.getContext(e);if(!r.isTopLevelContext())throw new x("Emulating viewport is only supported on the top-level context");return[r]}await this.#i.verifyUserContextIdList(t);let s=[];for(let r of t){let i=this.#t.getTopLevelContexts().filter(o=>o.userContext===r);s.push(...i)}return[...new Set(s).values()]}async traverseHistory(e){let t=this.#t.getContext(e.context);if(!t)throw new x(`No browsing context with id ${e.context}`);if(!t.isTopLevelContext())throw new x("Traversing history is only supported on the top-level context");return await t.traverseHistory(e.delta),{}}async handleUserPrompt(e){let t=this.#t.getContext(e.context);try{await t.handleUserPrompt(e.accept,e.userText)}catch(s){throw s.message?.includes("No dialog is showing")?new Nt("No dialog is showing"):s}return{}}async close(e){let t=this.#t.getContext(e.context);if(!t.isTopLevelContext())throw new x(`Non top-level browsing context ${t.id} cannot be closed.`);let s=t.cdpTarget.parentCdpClient;try{let r=new Promise(i=>{let o=a=>{a.targetId===e.context&&(s.off("Target.detachedFromTarget",o),i())};s.on("Target.detachedFromTarget",o)});try{e.promptUnload?await t.close():await s.sendCommand("Target.closeTarget",{targetId:e.context})}catch(i){if(!s.isCloseError(i))throw i}await r}catch(r){if(!(r.code===-32e3&&r.message==="Not attached to an active page"))throw r}return{}}async locateNodes(e){return await this.#t.getContext(e.context).locateNodes(e)}#a(e){return[this.#t.getContext(e),...this.#t.getContext(e).allChildren].forEach(r=>{this.#r.registerEvent({type:"event",method:C.BrowsingContext.EventNames.ContextCreated,params:r.serializeToBidiValue()},r.id)}),Promise.resolve()}};var Ht=class{#e;#t;#s;constructor(e,t,s){this.#e=t,this.#t=e,this.#s=s}async setGeolocationOverride(e){if("coordinates"in e&&"error"in e)throw new x("Coordinates and error cannot be set at the same time");let t=null;if("coordinates"in e){if((e.coordinates?.altitude??null)===null&&(e.coordinates?.altitudeAccuracy??null)!==null)throw new x("Geolocation altitudeAccuracy can be set only with altitude");t=e.coordinates}else if("error"in e){if(e.error.type!=="positionUnavailable")throw new x(`Unknown geolocation error ${e.error.type}`);t=e.error}else throw new x("Coordinates or error should be set");let s=await this.#r(e.contexts,e.userContexts);for(let r of e.contexts??[])this.#s.updateBrowsingContextConfig(r,{geolocation:t});for(let r of e.userContexts??[])this.#s.updateUserContextConfig(r,{geolocation:t});return await Promise.all(s.map(async r=>{let i=this.#s.getActiveConfig(r.id,r.userContext);await r.setGeolocationOverride(i.geolocation??null)})),{}}async setLocaleOverride(e){let t=e.locale??null;if(t!==null&&!oo(t))throw new x(`Invalid locale "${t}"`);let s=await this.#r(e.contexts,e.userContexts);for(let r of e.contexts??[])this.#s.updateBrowsingContextConfig(r,{locale:t});for(let r of e.userContexts??[])this.#s.updateUserContextConfig(r,{locale:t});return await Promise.all(s.map(async r=>{let i=this.#s.getActiveConfig(r.id,r.userContext);await Promise.all([r.setLocaleOverride(i.locale??null),r.setUserAgentAndAcceptLanguage(i.userAgent,i.locale,i.clientHints)])})),{}}async setScriptingEnabled(e){let t=e.enabled,s=await this.#r(e.contexts,e.userContexts);for(let r of e.contexts??[])this.#s.updateBrowsingContextConfig(r,{scriptingEnabled:t});for(let r of e.userContexts??[])this.#s.updateUserContextConfig(r,{scriptingEnabled:t});return await Promise.all(s.map(async r=>{let i=this.#s.getActiveConfig(r.id,r.userContext);await r.setScriptingEnabled(i.scriptingEnabled??null)})),{}}async setScrollbarTypeOverride(e){let t=await this.#r(e.contexts,e.userContexts);for(let s of e.contexts??[])this.#s.updateBrowsingContextConfig(s,{scrollbarType:e.scrollbarType});for(let s of e.userContexts??[])this.#s.updateUserContextConfig(s,{scrollbarType:e.scrollbarType});return await Promise.all(t.map(async s=>{let r=this.#s.getActiveConfig(s.id,s.userContext);await s.setScrollbarTypeOverride(r.scrollbarType??null)})),{}}async setScreenOrientationOverride(e){let t=await this.#r(e.contexts,e.userContexts);for(let s of e.contexts??[])this.#s.updateBrowsingContextConfig(s,{screenOrientation:e.screenOrientation});for(let s of e.userContexts??[])this.#s.updateUserContextConfig(s,{screenOrientation:e.screenOrientation});return await Promise.all(t.map(async s=>{let r=this.#s.getActiveConfig(s.id,s.userContext);await s.setViewport(r.viewport??null,r.devicePixelRatio??null,r.screenOrientation??null)})),{}}async setScreenSettingsOverride(e){let t=await this.#r(e.contexts,e.userContexts);for(let s of e.contexts??[])this.#s.updateBrowsingContextConfig(s,{screenArea:e.screenArea});for(let s of e.userContexts??[])this.#s.updateUserContextConfig(s,{screenArea:e.screenArea});return await Promise.all(t.map(async s=>{let r=this.#s.getActiveConfig(s.id,s.userContext);await s.setViewport(r.viewport??null,r.devicePixelRatio??null,r.screenOrientation??null)})),{}}async#r(e,t,s=!1){if(e===void 0&&t===void 0){if(s)return this.#t.getTopLevelContexts();throw new x("Either user contexts or browsing contexts must be provided")}if(e!==void 0&&t!==void 0)throw new x("User contexts and browsing contexts are mutually exclusive");let r=[];if(e===void 0){if(t.length===0)throw new x("user context should be provided");await this.#e.verifyUserContextIdList(t);for(let i of t){let o=this.#t.getTopLevelContexts().filter(a=>a.userContext===i);r.push(...o)}}else{if(e.length===0)throw new x("browsing context should be provided");for(let i of e){let o=this.#t.getContext(i);if(!o.isTopLevelContext())throw new x("The command is only supported on the top-level context");r.push(o)}}return[...new Set(r).values()]}async setTimezoneOverride(e){let t=e.timezone??null;if(t!==null&&!ao(t))throw new x(`Invalid timezone "${t}"`);t!==null&&co(t)&&(t=`GMT${t}`);let s=await this.#r(e.contexts,e.userContexts);for(let r of e.contexts??[])this.#s.updateBrowsingContextConfig(r,{timezone:t});for(let r of e.userContexts??[])this.#s.updateUserContextConfig(r,{timezone:t});return await Promise.all(s.map(async r=>{let i=this.#s.getActiveConfig(r.id,r.userContext);await r.setTimezoneOverride(i.timezone??null)})),{}}async setTouchOverride(e){let t=e.maxTouchPoints,s=await this.#r(e.contexts,e.userContexts,!0);for(let r of e.contexts??[])this.#s.updateBrowsingContextConfig(r,{maxTouchPoints:t});for(let r of e.userContexts??[])this.#s.updateUserContextConfig(r,{maxTouchPoints:t});return e.contexts===void 0&&e.userContexts===void 0&&this.#s.updateGlobalConfig({maxTouchPoints:t}),await Promise.all(s.map(async r=>{let i=this.#s.getActiveConfig(r.id,r.userContext);await r.setTouchOverride(i.maxTouchPoints??null)})),{}}async setUserAgentOverrideParams(e){if(e.userAgent==="")throw new R("empty user agent string is not supported");let t=await this.#r(e.contexts,e.userContexts,!0);for(let s of e.contexts??[])this.#s.updateBrowsingContextConfig(s,{userAgent:e.userAgent});for(let s of e.userContexts??[])this.#s.updateUserContextConfig(s,{userAgent:e.userAgent});return e.contexts===void 0&&e.userContexts===void 0&&this.#s.updateGlobalConfig({userAgent:e.userAgent}),await Promise.all(t.map(async s=>{let r=this.#s.getActiveConfig(s.id,s.userContext);await s.setUserAgentAndAcceptLanguage(r.userAgent,r.locale,r.clientHints)})),{}}async setClientHintsOverride(e){let t=e.clientHints??null,s=await this.#r(e.contexts,e.userContexts,!0);for(let r of e.contexts??[])this.#s.updateBrowsingContextConfig(r,{clientHints:t});for(let r of e.userContexts??[])this.#s.updateUserContextConfig(r,{clientHints:t});return e.contexts===void 0&&e.userContexts===void 0&&this.#s.updateGlobalConfig({clientHints:t}),await Promise.all(s.map(async r=>{let i=this.#s.getActiveConfig(r.id,r.userContext);await r.setUserAgentAndAcceptLanguage(i.userAgent,i.locale,i.clientHints)})),{}}async setNetworkConditions(e){let t=await this.#r(e.contexts,e.userContexts,!0);for(let s of e.contexts??[])this.#s.updateBrowsingContextConfig(s,{emulatedNetworkConditions:e.networkConditions});for(let s of e.userContexts??[])this.#s.updateUserContextConfig(s,{emulatedNetworkConditions:e.networkConditions});if(e.contexts===void 0&&e.userContexts===void 0&&this.#s.updateGlobalConfig({emulatedNetworkConditions:e.networkConditions}),e.networkConditions!==null&&e.networkConditions.type!=="offline")throw new R(`Unsupported network conditions ${e.networkConditions.type}`);return await Promise.all(t.map(async s=>{let r=this.#s.getActiveConfig(s.id,s.userContext);await s.setEmulatedNetworkConditions(r.emulatedNetworkConditions??null)})),{}}};function oo(n){try{return new Intl.Locale(n),!0}catch(e){if(e instanceof RangeError)return!1;throw e}}function ao(n){try{return Intl.DateTimeFormat(void 0,{timeZone:n}),!0}catch(e){if(e instanceof RangeError)return!1;throw e}}function co(n){return/^[+-](?:2[0-3]|[01]\d)(?::[0-5]\d)?$/.test(n)}function _(n,e){if(!n)throw new Error(e??"Internal assertion failed.")}function fr(n){return zt(n)&&n.length>1}function zt(n){return[...new Intl.Segmenter("en",{granularity:"grapheme"}).segment(n)].length===1}var Wt=class{type="none"},ot=class{type="key";pressed=new Set;#e=0;get modifiers(){return this.#e}get alt(){return(this.#e&1)===1}set alt(e){this.#t(e,1)}get ctrl(){return(this.#e&2)===2}set ctrl(e){this.#t(e,2)}get meta(){return(this.#e&4)===4}set meta(e){this.#t(e,4)}get shift(){return(this.#e&8)===8}set shift(e){this.#t(e,8)}#t(e,t){e?this.#e|=t:this.#e&=~t}},Kt=class n{static#e=500;static#t=2;count=0;#s;#r;#i;constructor(e,t,s){this.#s=e,this.#r=t,this.#i=s}compare(e){return e.#i-this.#i>n.#e||Math.abs(e.#s-this.#s)>n.#t||Math.abs(e.#r-this.#r)>n.#t}},Vt=class{type="pointer";subtype;pointerId;pressed=new Set;x=0;y=0;radiusX;radiusY;force;constructor(e,t){this.pointerId=e,this.subtype=t}get buttons(){let e=0;for(let t of this.pressed)switch(t){case 0:e|=1;break;case 1:e|=4;break;case 2:e|=2;break;case 3:e|=8;break;case 4:e|=16;break}return e}#e=new Map;setClickCount(e,t){let s=this.#e.get(e);return(!s||s.compare(t))&&(s=t),++s.count,this.#e.set(e,s),s.count}getClickCount(e){return this.#e.get(e)?.count??0}resetClickCount(){this.#e=new Map}},Gt=class{type="wheel"};function mr(n){switch(n){case"\uE000":return"Unidentified";case"\uE001":return"Cancel";case"\uE002":return"Help";case"\uE003":return"Backspace";case"\uE004":return"Tab";case"\uE005":return"Clear";case"\uE006":case"\uE007":return"Enter";case"\uE008":return"Shift";case"\uE009":return"Control";case"\uE00A":return"Alt";case"\uE00B":return"Pause";case"\uE00C":return"Escape";case"\uE00D":return" ";case"\uE00E":return"PageUp";case"\uE00F":return"PageDown";case"\uE010":return"End";case"\uE011":return"Home";case"\uE012":return"ArrowLeft";case"\uE013":return"ArrowUp";case"\uE014":return"ArrowRight";case"\uE015":return"ArrowDown";case"\uE016":return"Insert";case"\uE017":return"Delete";case"\uE018":return";";case"\uE019":return"=";case"\uE01A":return"0";case"\uE01B":return"1";case"\uE01C":return"2";case"\uE01D":return"3";case"\uE01E":return"4";case"\uE01F":return"5";case"\uE020":return"6";case"\uE021":return"7";case"\uE022":return"8";case"\uE023":return"9";case"\uE024":return"*";case"\uE025":return"+";case"\uE026":return",";case"\uE027":return"-";case"\uE028":return".";case"\uE029":return"/";case"\uE031":return"F1";case"\uE032":return"F2";case"\uE033":return"F3";case"\uE034":return"F4";case"\uE035":return"F5";case"\uE036":return"F6";case"\uE037":return"F7";case"\uE038":return"F8";case"\uE039":return"F9";case"\uE03A":return"F10";case"\uE03B":return"F11";case"\uE03C":return"F12";case"\uE03D":return"Meta";case"\uE040":return"ZenkakuHankaku";case"\uE050":return"Shift";case"\uE051":return"Control";case"\uE052":return"Alt";case"\uE053":return"Meta";case"\uE054":return"PageUp";case"\uE055":return"PageDown";case"\uE056":return"End";case"\uE057":return"Home";case"\uE058":return"ArrowLeft";case"\uE059":return"ArrowUp";case"\uE05A":return"ArrowRight";case"\uE05B":return"ArrowDown";case"\uE05C":return"Insert";case"\uE05D":return"Delete";default:return n}}function gr(n){switch(n){case"`":case"~":return"Backquote";case"\\":case"|":return"Backslash";case"\uE003":return"Backspace";case"[":case"{":return"BracketLeft";case"]":case"}":return"BracketRight";case",":case"<":return"Comma";case"0":case")":return"Digit0";case"1":case"!":return"Digit1";case"2":case"@":return"Digit2";case"3":case"#":return"Digit3";case"4":case"$":return"Digit4";case"5":case"%":return"Digit5";case"6":case"^":return"Digit6";case"7":case"&":return"Digit7";case"8":case"*":return"Digit8";case"9":case"(":return"Digit9";case"=":case"+":return"Equal";case">":return"IntlBackslash";case"a":case"A":return"KeyA";case"b":case"B":return"KeyB";case"c":case"C":return"KeyC";case"d":case"D":return"KeyD";case"e":case"E":return"KeyE";case"f":case"F":return"KeyF";case"g":case"G":return"KeyG";case"h":case"H":return"KeyH";case"i":case"I":return"KeyI";case"j":case"J":return"KeyJ";case"k":case"K":return"KeyK";case"l":case"L":return"KeyL";case"m":case"M":return"KeyM";case"n":case"N":return"KeyN";case"o":case"O":return"KeyO";case"p":case"P":return"KeyP";case"q":case"Q":return"KeyQ";case"r":case"R":return"KeyR";case"s":case"S":return"KeyS";case"t":case"T":return"KeyT";case"u":case"U":return"KeyU";case"v":case"V":return"KeyV";case"w":case"W":return"KeyW";case"x":case"X":return"KeyX";case"y":case"Y":return"KeyY";case"z":case"Z":return"KeyZ";case"-":case"_":return"Minus";case".":return"Period";case"'":case'"':return"Quote";case";":case":":return"Semicolon";case"/":case"?":return"Slash";case"\uE00A":return"AltLeft";case"\uE052":return"AltRight";case"\uE009":return"ControlLeft";case"\uE051":return"ControlRight";case"\uE006":return"Enter";case"\uE00B":return"Pause";case"\uE03D":return"MetaLeft";case"\uE053":return"MetaRight";case"\uE008":return"ShiftLeft";case"\uE050":return"ShiftRight";case" ":case"\uE00D":return"Space";case"\uE004":return"Tab";case"\uE017":return"Delete";case"\uE010":return"End";case"\uE002":return"Help";case"\uE011":return"Home";case"\uE016":return"Insert";case"\uE00F":return"PageDown";case"\uE00E":return"PageUp";case"\uE015":return"ArrowDown";case"\uE012":return"ArrowLeft";case"\uE014":return"ArrowRight";case"\uE013":return"ArrowUp";case"\uE00C":return"Escape";case"\uE031":return"F1";case"\uE032":return"F2";case"\uE033":return"F3";case"\uE034":return"F4";case"\uE035":return"F5";case"\uE036":return"F6";case"\uE037":return"F7";case"\uE038":return"F8";case"\uE039":return"F9";case"\uE03A":return"F10";case"\uE03B":return"F11";case"\uE03C":return"F12";case"\uE019":return"NumpadEqual";case"\uE01A":case"\uE05C":return"Numpad0";case"\uE01B":case"\uE056":return"Numpad1";case"\uE01C":case"\uE05B":return"Numpad2";case"\uE01D":case"\uE055":return"Numpad3";case"\uE01E":case"\uE058":return"Numpad4";case"\uE01F":return"Numpad5";case"\uE020":case"\uE05A":return"Numpad6";case"\uE021":case"\uE057":return"Numpad7";case"\uE022":case"\uE059":return"Numpad8";case"\uE023":case"\uE054":return"Numpad9";case"\uE025":return"NumpadAdd";case"\uE026":return"NumpadComma";case"\uE028":case"\uE05D":return"NumpadDecimal";case"\uE029":return"NumpadDivide";case"\uE007":return"NumpadEnter";case"\uE024":return"NumpadMultiply";case"\uE027":return"NumpadSubtract";default:return}}function wr(n){switch(n){case"\uE007":case"\uE008":case"\uE009":case"\uE00A":case"\uE03D":return 1;case"\uE019":case"\uE01A":case"\uE01B":case"\uE01C":case"\uE01D":case"\uE01E":case"\uE01F":case"\uE020":case"\uE021":case"\uE022":case"\uE023":case"\uE024":case"\uE025":case"\uE026":case"\uE027":case"\uE028":case"\uE029":case"\uE054":case"\uE055":case"\uE056":case"\uE057":case"\uE058":case"\uE059":case"\uE05A":case"\uE05B":case"\uE05C":case"\uE05D":return 3;case"\uE050":case"\uE051":case"\uE052":case"\uE053":return 2;default:return 0}}var yr={0:48,1:49,2:50,3:51,4:52,5:53,6:54,7:55,8:56,9:57,Abort:3,Help:6,Backspace:8,Tab:9,Numpad5:12,NumpadEnter:13,Enter:13,"\\r":13,"\\n":13,ShiftLeft:16,ShiftRight:16,ControlLeft:17,ControlRight:17,AltLeft:18,AltRight:18,Pause:19,CapsLock:20,Escape:27,Convert:28,NonConvert:29,Space:32,Numpad9:33,PageUp:33,Numpad3:34,PageDown:34,End:35,Numpad1:35,Home:36,Numpad7:36,ArrowLeft:37,Numpad4:37,Numpad8:38,ArrowUp:38,ArrowRight:39,Numpad6:39,Numpad2:40,ArrowDown:40,Select:41,Open:43,PrintScreen:44,Insert:45,Numpad0:45,Delete:46,NumpadDecimal:46,Digit0:48,Digit1:49,Digit2:50,Digit3:51,Digit4:52,Digit5:53,Digit6:54,Digit7:55,Digit8:56,Digit9:57,KeyA:65,KeyB:66,KeyC:67,KeyD:68,KeyE:69,KeyF:70,KeyG:71,KeyH:72,KeyI:73,KeyJ:74,KeyK:75,KeyL:76,KeyM:77,KeyN:78,KeyO:79,KeyP:80,KeyQ:81,KeyR:82,KeyS:83,KeyT:84,KeyU:85,KeyV:86,KeyW:87,KeyX:88,KeyY:89,KeyZ:90,MetaLeft:91,MetaRight:92,ContextMenu:93,NumpadMultiply:106,NumpadAdd:107,NumpadSubtract:109,NumpadDivide:111,F1:112,F2:113,F3:114,F4:115,F5:116,F6:117,F7:118,F8:119,F9:120,F10:121,F11:122,F12:123,F13:124,F14:125,F15:126,F16:127,F17:128,F18:129,F19:130,F20:131,F21:132,F22:133,F23:134,F24:135,NumLock:144,ScrollLock:145,AudioVolumeMute:173,AudioVolumeDown:174,AudioVolumeUp:175,MediaTrackNext:176,MediaTrackPrevious:177,MediaStop:178,MediaPlayPause:179,Semicolon:186,Equal:187,NumpadEqual:187,Comma:188,Minus:189,Period:190,Slash:191,Backquote:192,BracketLeft:219,Backslash:220,BracketRight:221,Quote:222,AltGraph:225,Props:247,Cancel:3,Clear:12,Shift:16,Control:17,Alt:18,Accept:30,ModeChange:31," ":32,Print:42,Execute:43,"\\u0000":46,a:65,b:66,c:67,d:68,e:69,f:70,g:71,h:72,i:73,j:74,k:75,l:76,m:77,n:78,o:79,p:80,q:81,r:82,s:83,t:84,u:85,v:86,w:87,x:88,y:89,z:90,Meta:91,"*":106,"+":107,"-":109,"/":111,";":186,"=":187,",":188,".":190,"`":192,"[":219,"\\\\":220,"]":221,"'":222,Attn:246,CrSel:247,ExSel:248,EraseEof:249,Play:250,ZoomOut:251,")":48,"!":49,"@":50,"#":51,$:52,"%":53,"^":54,"&":55,"(":57,A:65,B:66,C:67,D:68,E:69,F:70,G:71,H:72,I:73,J:74,K:75,L:76,M:77,N:78,O:79,P:80,Q:81,R:82,S:83,T:84,U:85,V:86,W:87,X:88,Y:89,Z:90,":":186,"<":188,_:189,">":190,"?":191,"~":192,"{":219,"|":220,"}":221,'"':222,Camera:44,EndCall:95,VolumeDown:182,VolumeUp:183};var uo=(n=>{let e=n.getClientRects()[0],t=Math.max(0,Math.min(e.x,e.x+e.width)),s=Math.min(window.innerWidth,Math.max(e.x,e.x+e.width)),r=Math.max(0,Math.min(e.y,e.y+e.height)),i=Math.min(window.innerHeight,Math.max(e.y,e.y+e.height));return[t+(s-t>>1),r+(i-r>>1)]}).toString(),lo=(()=>navigator.platform.toLowerCase().includes("mac")).toString();async function ho(n,e){let s=await(await n.getOrCreateHiddenSandbox()).callFunction(uo,!1,{type:"undefined"},[e]);if(s.type==="exception")throw new ce(`Origin element ${e.sharedId} was not found`);_(s.result.type==="array"),_(s.result.value?.[0]?.type==="number"),_(s.result.value?.[1]?.type==="number");let{result:{value:[{value:r},{value:i}]}}=s;return{x:r,y:i}}var Ce=class{static isMacOS=async e=>{let s=await(await e.getOrCreateHiddenSandbox()).callFunction(lo,!1);return _(s.type!=="exception"),_(s.result.type==="boolean"),s.result.value};#e;#t=0;#s=0;#r;#i;#o;constructor(e,t,s,r){this.#e=t,this.#r=e,this.#i=s,this.#o=r}get#a(){return this.#e.getContext(this.#i)}async dispatchActions(e){await this.#r.queue.run(async()=>{for(let t of e)await this.dispatchTickActions(t)})}async dispatchTickActions(e){this.#t=performance.now(),this.#s=0;for(let{action:s}of e)"duration"in s&&s.duration!==void 0&&(this.#s=Math.max(this.#s,s.duration));let t=[new Promise(s=>setTimeout(s,this.#s))];for(let s of e)t.push(this.#d(s));await Promise.all(t)}async#d({id:e,action:t}){let s=this.#r.get(e),r=this.#r.getGlobalKeyState();switch(t.type){case"keyDown":{await this.#u(s,t),this.#r.cancelList.push({id:e,action:{...t,type:"keyUp"}});break}case"keyUp":{await this.#m(s,t);break}case"pause":break;case"pointerDown":{await this.#n(s,r,t),this.#r.cancelList.push({id:e,action:{...t,type:"pointerUp"}});break}case"pointerMove":{await this.#h(s,r,t);break}case"pointerUp":{await this.#l(s,r,t);break}case"scroll":{await this.#p(s,r,t);break}}}async#n(e,t,s){let{button:r}=s;if(e.pressed.has(r))return;e.pressed.add(r);let{x:i,y:o,subtype:a}=e,{width:c,height:d,pressure:u,twist:l,tangentialPressure:y}=s,{tiltX:f,tiltY:h}=dn(s),{modifiers:p}=t,{radiusX:m,radiusY:v}=un(c??1,d??1);switch(a){case"mouse":case"pen":await this.#a.cdpTarget.cdpClient.sendCommand("Input.dispatchMouseEvent",{type:"mousePressed",x:i,y:o,modifiers:p,button:Xt(r),buttons:e.buttons,clickCount:e.setClickCount(r,new Kt(i,o,performance.now())),pointerType:a,tangentialPressure:y,tiltX:f,tiltY:h,twist:l,force:u});break;case"touch":await this.#a.cdpTarget.cdpClient.sendCommand("Input.dispatchTouchEvent",{type:"touchStart",touchPoints:[{x:i,y:o,radiusX:m,radiusY:v,tangentialPressure:y,tiltX:f,tiltY:h,twist:l,force:u,id:e.pointerId}],modifiers:p});break}e.radiusX=m,e.radiusY=v,e.force=u}#l(e,t,s){let{button:r}=s;if(!e.pressed.has(r))return;e.pressed.delete(r);let{x:i,y:o,force:a,radiusX:c,radiusY:d,subtype:u}=e,{modifiers:l}=t;switch(u){case"mouse":case"pen":return this.#a.cdpTarget.cdpClient.sendCommand("Input.dispatchMouseEvent",{type:"mouseReleased",x:i,y:o,modifiers:l,button:Xt(r),buttons:e.buttons,clickCount:e.getClickCount(r),pointerType:u});case"touch":return this.#a.cdpTarget.cdpClient.sendCommand("Input.dispatchTouchEvent",{type:"touchEnd",touchPoints:[{x:i,y:o,id:e.pointerId,force:a,radiusX:c,radiusY:d}],modifiers:l})}}async#h(e,t,s){let{x:r,y:i,subtype:o}=e,{width:a,height:c,pressure:d,twist:u,tangentialPressure:l,x:y,y:f,origin:h="viewport",duration:p=this.#s}=s,{tiltX:m,tiltY:v}=dn(s),{radiusX:I,radiusY:B}=un(a??1,c??1),{targetX:U,targetY:he}=await this.#f(h,y,f,r,i);if(U<0||he<0)throw new st(`Cannot move beyond viewport (x: ${U}, y: ${he})`);let Ie;do{let De=p>0?(performance.now()-this.#t)/p:1;Ie=De>=1;let Q,ee;if(Ie?(Q=U,ee=he):(Q=Math.round(De*(U-r)+r),ee=Math.round(De*(he-i)+i)),e.x!==Q||e.y!==ee){let{modifiers:Te}=t;switch(o){case"mouse":await this.#a.cdpTarget.cdpClient.sendCommand("Input.dispatchMouseEvent",{type:"mouseMoved",x:Q,y:ee,modifiers:Te,clickCount:0,button:Xt(e.pressed.values().next().value??5),buttons:e.buttons,pointerType:o,tangentialPressure:l,tiltX:m,tiltY:v,twist:u,force:d});break;case"pen":e.pressed.size!==0&&await this.#a.cdpTarget.cdpClient.sendCommand("Input.dispatchMouseEvent",{type:"mouseMoved",x:Q,y:ee,modifiers:Te,clickCount:0,button:Xt(e.pressed.values().next().value??5),buttons:e.buttons,pointerType:o,tangentialPressure:l,tiltX:m,tiltY:v,twist:u,force:d??.5});break;case"touch":e.pressed.size!==0&&await this.#a.cdpTarget.cdpClient.sendCommand("Input.dispatchTouchEvent",{type:"touchMove",touchPoints:[{x:Q,y:ee,radiusX:I,radiusY:B,tangentialPressure:l,tiltX:m,tiltY:v,twist:u,force:d,id:e.pointerId}],modifiers:Te});break}e.x=Q,e.y=ee,e.radiusX=I,e.radiusY=B,e.force=d}}while(!Ie)}async#c(){if(this.#a.id===this.#a.cdpTarget.id)return{x:0,y:0};let{backendNodeId:e}=await this.#a.cdpTarget.cdpClient.sendCommand("DOM.getFrameOwner",{frameId:this.#a.id}),{model:t}=await this.#a.cdpTarget.cdpClient.sendCommand("DOM.getBoxModel",{backendNodeId:e});return{x:t.content[0],y:t.content[1]}}async#f(e,t,s,r,i){let o,a,c=await this.#c();switch(e){case"viewport":o=t+c.x,a=s+c.y;break;case"pointer":o=r+t+c.x,a=i+s+c.y;break;default:{let{x:d,y:u}=await ho(this.#a,e.element);o=d+t+c.x,a=u+s+c.y;break}}return{targetX:o,targetY:a}}async#p(e,t,s){let{deltaX:r,deltaY:i,x:o,y:a,origin:c="viewport",duration:d=this.#s}=s;if(c==="pointer")throw new x('"pointer" origin is invalid for scrolling.');let{targetX:u,targetY:l}=await this.#f(c,o,a,0,0);if(u<0||l<0)throw new st(`Cannot move beyond viewport (x: ${u}, y: ${l})`);let y=0,f=0,h;do{let p=d>0?(performance.now()-this.#t)/d:1;h=p>=1;let m,v;if(h?(m=r-y,v=i-f):(m=Math.round(p*r-y),v=Math.round(p*i-f)),m!==0||v!==0){let{modifiers:I}=t;await this.#a.cdpTarget.cdpClient.sendCommand("Input.dispatchMouseEvent",{type:"mouseWheel",deltaX:m,deltaY:v,x:u,y:l,modifiers:I}),y+=m,f+=v}}while(!h)}async#u(e,t){let s=t.value;if(!zt(s))throw new x(`Invalid key value: ${s}`);let r=fr(s),i=mr(s),o=e.pressed.has(i),a=gr(s),c=wr(s);switch(i){case"Alt":e.alt=!0;break;case"Shift":e.shift=!0;break;case"Control":e.ctrl=!0;break;case"Meta":e.meta=!0;break}e.pressed.add(i);let{modifiers:d}=e,u=an(i,e,r),l=cn(a??"",e)??u,y;if(this.#o&&e.meta)switch(a){case"KeyA":y="SelectAll";break;case"KeyC":y="Copy";break;case"KeyV":y=e.shift?"PasteAndMatchStyle":"Paste";break;case"KeyX":y="Cut";break;case"KeyZ":y=e.shift?"Redo":"Undo";break;default:}let f=[this.#a.cdpTarget.cdpClient.sendCommand("Input.dispatchKeyEvent",{type:l?"keyDown":"rawKeyDown",windowsVirtualKeyCode:yr[i],key:i,code:a,text:l,unmodifiedText:u,autoRepeat:o,isSystemKey:e.alt||void 0,location:c<3?c:void 0,isKeypad:c===3,modifiers:d,commands:y?[y]:void 0})];i==="Escape"&&!e.alt&&(this.#o&&!e.ctrl&&!e.meta||!this.#o)&&f.push(this.#a.cdpTarget.cdpClient.sendCommand("Input.cancelDragging")),await Promise.all(f)}#m(e,t){let s=t.value;if(!zt(s))throw new x(`Invalid key value: ${s}`);let r=fr(s),i=mr(s);if(!e.pressed.has(i))return;let o=gr(s),a=wr(s);switch(i){case"Alt":e.alt=!1;break;case"Shift":e.shift=!1;break;case"Control":e.ctrl=!1;break;case"Meta":e.meta=!1;break}e.pressed.delete(i);let{modifiers:c}=e,d=an(i,e,r),u=cn(o??"",e)??d;return this.#a.cdpTarget.cdpClient.sendCommand("Input.dispatchKeyEvent",{type:"keyUp",windowsVirtualKeyCode:yr[i],key:i,code:o,text:u,unmodifiedText:d,location:a<3?a:void 0,isSystemKey:e.alt||void 0,isKeypad:a===3,modifiers:c})}},an=(n,e,t)=>t?n:n==="Enter"?"\r":[...n].length===1?e.shift?n.toLocaleUpperCase("en-US"):n:void 0,cn=(n,e)=>{if(e.ctrl){switch(n){case"Digit2":if(e.shift)return"\0";break;case"KeyA":return"";case"KeyB":return"";case"KeyC":return"";case"KeyD":return"";case"KeyE":return"";case"KeyF":return"";case"KeyG":return"\x07";case"KeyH":return"\b";case"KeyI":return" ";case"KeyJ":return`
2
+ import{$ as cr,$a as Ai,A as P,Aa as lr,Ab as pr,B as q,Bb as Gi,C as Ct,Ca as Oi,Cb as Xi,D as hi,Dc as rn,F as pi,Fb as Ji,G as fi,Gb as Yi,H as ne,I as b,Ib as Zi,J as Ne,K as mi,La as E,Ma as j,N as _e,Na as Ni,Nb as Qi,Oa as _i,P as gi,Pa as fe,Q as Et,Qa as Bi,S as wi,Sb as en,T as yi,U as vi,V as xi,Z as Be,_a as Fi,a as or,aa as bi,b as re,ca as Ci,cb as oe,d as Re,db as Ui,e as Oe,ea as J,f as Ze,fa as Ei,fb as hr,g as ci,gb as Li,ha as dr,ia as Si,ib as Mi,j as di,ja as Fe,jb as qi,k as ui,kb as ji,la as Pi,mb as $i,n as li,na as ki,nb as ae,o as ar,oa as Ii,ob as Hi,p as ie,pa as Di,pb as zi,q as bt,qa as St,ra as Ti,sb as Wi,sc as tn,t as D,tc as sn,va as Pt,w as L,wa as Ri,wb as Ki,xb as Vi,ya as ur,yb as Qe,zb as et}from"./chunk-SQ6Y2ZMA.mjs";import"./chunk-Y34NR5JL.mjs";import"./chunk-YEY3RSFQ.mjs";import{b as xt,c as T}from"./chunk-W7XHE4CT.mjs";import"./chunk-UH4SIXTR.mjs";import{d as ai}from"./chunk-5L7RYZCL.mjs";var Ve={};ai(Ve,{BidiServer:()=>Fs,EventEmitter:()=>K,OutgoingMessage:()=>X});function nn(n){return{all:n=n||new Map,on:function(e,t){var s=n.get(e);s?s.push(t):n.set(e,[t])},off:function(e,t){var s=n.get(e);s&&(t?s.splice(s.indexOf(t)>>>0,1):n.set(e,[]))},emit:function(e,t){var s=n.get(e);s&&s.slice().map(function(r){r(t)}),(s=n.get("*"))&&s.slice().map(function(r){r(e,t)})}}}var K=class{#e=nn();on(e,t){return this.#e.on(e,t),this}once(e,t){let s=r=>{t(r),this.off(e,s)};return this.on(e,s)}off(e,t){return this.#e.off(e,t),this}emit(e,t){this.#e.emit(e,t)}removeAllListeners(e){return e?this.#e.all.delete(e):this.#e.all.clear(),this}};var S;(function(n){n.bidi="bidi",n.cdp="cdp",n.debug="debug",n.debugError="debug:error",n.debugInfo="debug:info",n.debugWarn="debug:warn"})(S||(S={}));var on,tt=class{static LOGGER_PREFIX=`${S.debug}:queue`;#e;#t;#s=[];#r=!1;constructor(e,t){this.#t=e,this.#e=t}add(e,t){this.#s.push([e,t]),this.#i()}async#i(){if(!this.#r){for(this.#r=!0;this.#s.length>0;){let e=this.#s.shift();if(!e)continue;let[t,s]=e;this.#e?.(on.LOGGER_PREFIX)?.("Processing event:",s),await t.then(r=>{if(r.kind==="error"){this.#e?.(S.debugError)?.("Event threw before sending:",r.error.message,r.error.stack);return}return this.#t(r.value)}).catch(r=>{this.#e?.(S.debugError)?.("Event was not processed:",r?.message)})}this.#r=!1}}};on=tt;var C={};ai(C,{BiDiModule:()=>kt,Bluetooth:()=>Ae,BrowsingContext:()=>Tt,EVENT_NAMES:()=>ro,Input:()=>Rt,Log:()=>Dt,Network:()=>Ot,Script:()=>It,Speculation:()=>Ue});var kt;(function(n){n.Bluetooth="bluetooth",n.Browser="browser",n.BrowsingContext="browsingContext",n.Cdp="goog:cdp",n.Input="input",n.Log="log",n.Network="network",n.Script="script",n.Session="session",n.Speculation="speculation"})(kt||(kt={}));var It;(function(n){let e;(function(t){t.Message="script.message",t.RealmCreated="script.realmCreated",t.RealmDestroyed="script.realmDestroyed"})(e=n.EventNames||(n.EventNames={}))})(It||(It={}));var Dt;(function(n){let e;(function(t){t.LogEntryAdded="log.entryAdded"})(e=n.EventNames||(n.EventNames={}))})(Dt||(Dt={}));var Tt;(function(n){let e;(function(t){t.ContextCreated="browsingContext.contextCreated",t.ContextDestroyed="browsingContext.contextDestroyed",t.DomContentLoaded="browsingContext.domContentLoaded",t.DownloadEnd="browsingContext.downloadEnd",t.DownloadWillBegin="browsingContext.downloadWillBegin",t.FragmentNavigated="browsingContext.fragmentNavigated",t.HistoryUpdated="browsingContext.historyUpdated",t.Load="browsingContext.load",t.NavigationAborted="browsingContext.navigationAborted",t.NavigationCommitted="browsingContext.navigationCommitted",t.NavigationFailed="browsingContext.navigationFailed",t.NavigationStarted="browsingContext.navigationStarted",t.UserPromptClosed="browsingContext.userPromptClosed",t.UserPromptOpened="browsingContext.userPromptOpened"})(e=n.EventNames||(n.EventNames={}))})(Tt||(Tt={}));var Rt;(function(n){let e;(function(t){t.FileDialogOpened="input.fileDialogOpened"})(e=n.EventNames||(n.EventNames={}))})(Rt||(Rt={}));var Ot;(function(n){let e;(function(t){t.AuthRequired="network.authRequired",t.BeforeRequestSent="network.beforeRequestSent",t.FetchError="network.fetchError",t.ResponseCompleted="network.responseCompleted",t.ResponseStarted="network.responseStarted"})(e=n.EventNames||(n.EventNames={}))})(Ot||(Ot={}));var Ae;(function(n){let e;(function(t){t.RequestDevicePromptUpdated="bluetooth.requestDevicePromptUpdated",t.GattConnectionAttempted="bluetooth.gattConnectionAttempted",t.CharacteristicEventGenerated="bluetooth.characteristicEventGenerated",t.DescriptorEventGenerated="bluetooth.descriptorEventGenerated"})(e=n.EventNames||(n.EventNames={}))})(Ae||(Ae={}));var Ue;(function(n){let e;(function(t){t.PrefetchStatusUpdated="speculation.prefetchStatusUpdated"})(e=n.EventNames||(n.EventNames={}))})(Ue||(Ue={}));var ro=new Set([...Object.values(kt),...Object.values(Ae.EventNames),...Object.values(Tt.EventNames),...Object.values(Rt.EventNames),...Object.values(Dt.EventNames),...Object.values(Ot.EventNames),...Object.values(It.EventNames),...Object.values(Ue.EventNames)]);var F=class extends Error{error;message;stacktrace;constructor(e,t,s){super(),this.error=e,this.message=t,this.stacktrace=s}toErrorResponse(e){return{type:"error",id:e,error:this.error,message:this.message,stacktrace:this.stacktrace}}},x=class extends F{constructor(e,t){super("invalid argument",e,t)}},xe=class extends F{constructor(e,t){super("invalid selector",e,t)}};var st=class extends F{constructor(e,t){super("move target out of bounds",e,t)}},Nt=class extends F{constructor(e,t){super("no such alert",e,t)}},ce=class extends F{constructor(e,t){super("no such element",e,t)}},V=class extends F{constructor(e,t){super("no such frame",e,t)}},rt=class extends F{constructor(e,t){super("no such handle",e,t)}},_t=class extends F{constructor(e,t){super("no such history entry",e,t)}},Bt=class extends F{constructor(e,t){super("no such intercept",e,t)}},Y=class extends F{constructor(e,t){super("no such node",e,t)}},Le=class extends F{constructor(e,t){super("no such request",e,t)}},it=class extends F{constructor(e,t){super("no such script",e,t)}},G=class extends F{constructor(e,t){super("no such user context",e,t)}};var Ft=class extends F{constructor(e,t){super("unknown command",e,t)}},O=class extends F{constructor(e,t=new Error().stack){super("unknown error",e,t)}},nt=class extends F{constructor(e,t){super("unable to capture screen",e,t)}};var R=class extends F{constructor(e,t){super("unsupported operation",e,t)}};var At=class extends F{constructor(e,t){super("unable to set cookie",e,t)}},be=class extends F{constructor(e,t){super("unable to set file input",e,t)}};var Ut=class extends F{constructor(e,t){super("invalid web extension",e,t)}},Lt=class extends F{constructor(e,t){super("no such web extension",e,t)}},Me=class extends F{constructor(e,t){super("no such network collector",e,t)}},me=class extends F{constructor(e,t){super("no such network data",e,t)}};var Mt=class{parseDisableSimulationParameters(e){return e}parseHandleRequestDevicePromptParams(e){return e}parseSimulateAdapterParameters(e){return e}parseSimulateAdvertisementParameters(e){return e}parseSimulateCharacteristicParameters(e){return e}parseSimulateCharacteristicResponseParameters(e){return e}parseSimulateDescriptorParameters(e){return e}parseSimulateDescriptorResponseParameters(e){return e}parseSimulateGattConnectionResponseParameters(e){return e}parseSimulateGattDisconnectionParameters(e){return e}parseSimulatePreconnectedPeripheralParameters(e){return e}parseSimulateServiceParameters(e){return e}parseCreateUserContextParameters(e){return e}parseRemoveUserContextParameters(e){return e}parseSetClientWindowStateParameters(e){return e}parseSetDownloadBehaviorParameters(e){return e}parseActivateParams(e){return e}parseCaptureScreenshotParams(e){return e}parseCloseParams(e){return e}parseCreateParams(e){return e}parseGetTreeParams(e){return e}parseHandleUserPromptParams(e){return e}parseLocateNodesParams(e){return e}parseNavigateParams(e){return e}parsePrintParams(e){return e}parseReloadParams(e){return e}parseSetBypassCspParams(e){return e}parseSetViewportParams(e){return e}parseStartScreencastParams(e){return e}parseStopScreencastParams(e){return e}parseTraverseHistoryParams(e){return e}parseGetSessionParams(e){return e}parseResolveRealmParams(e){return e}parseSendCommandParams(e){return e}parseSetClientHintsOverrideParams(e){return e}parseSetForcedColorsModeThemeOverrideParams(e){return e}parseSetGeolocationOverrideParams(e){return e}parseSetLocaleOverrideParams(e){return e}parseSetNetworkConditionsParams(e){return e}parseSetScreenOrientationOverrideParams(e){return e}parseSetScreenSettingsOverrideParams(e){return e}parseSetScriptingEnabledParams(e){return e}parseSetScrollbarTypeOverrideParams(e){return e}parseSetTimezoneOverrideParams(e){return e}parseSetTouchOverrideParams(e){return e}parseSetUserAgentOverrideParams(e){return e}parseAddPreloadScriptParams(e){return e}parseCallFunctionParams(e){return e}parseDisownParams(e){return e}parseEvaluateParams(e){return e}parseGetRealmsParams(e){return e}parseRemovePreloadScriptParams(e){return e}parsePerformActionsParams(e){return e}parseReleaseActionsParams(e){return e}parseSetFilesParams(e){return e}parseAddDataCollectorParams(e){return e}parseAddInterceptParams(e){return e}parseContinueRequestParams(e){return e}parseContinueResponseParams(e){return e}parseContinueWithAuthParams(e){return e}parseDisownDataParams(e){return e}parseFailRequestParams(e){return e}parseGetDataParams(e){return e}parseProvideResponseParams(e){return e}parseRemoveDataCollectorParams(e){return e}parseRemoveInterceptParams(e){return e}parseSetCacheBehaviorParams(e){return e}parseSetExtraHeadersParams(e){return e}parseSetPermissionsParams(e){return e}parseSubscribeParams(e){return e}parseUnsubscribeParams(e){return e}parseDeleteCookiesParams(e){return e}parseGetCookiesParams(e){return e}parseSetCookieParams(e){return e}parseInstallParams(e){return e}parseUninstallParams(e){return e}parseSetVirtualWalletBehaviorParams(e){return e}};var qt=class{#e;#t;#s;#r;constructor(e,t,s,r){this.#e=e,this.#t=t,this.#s=s,this.#r=r}close(){return setTimeout(()=>this.#e.sendCommand("Browser.close").catch(()=>{}),0),{}}async createUserContext(e){let t=e,s=this.#s.getGlobalConfig();if(t.acceptInsecureCerts!==void 0&&t.acceptInsecureCerts===!1&&s.acceptInsecureCerts===!0)throw new O(`Cannot set user context's "acceptInsecureCerts" to false, when a capability "acceptInsecureCerts" is set to true`);let r={};if(t.proxy){let o=no(t.proxy);o&&(r.proxyServer=o),t.proxy.noProxy&&(r.proxyBypassList=t.proxy.noProxy.join(","))}else{e["goog:proxyServer"]!==void 0&&(r.proxyServer=e["goog:proxyServer"]);let o=e["goog:proxyBypassList"]??void 0;o&&(r.proxyBypassList=o.join(","))}let i=await this.#e.sendCommand("Target.createBrowserContext",r);return await this.#a(s.downloadBehavior??null,i.browserContextId),this.#s.updateUserContextConfig(i.browserContextId,{acceptInsecureCerts:e.acceptInsecureCerts,userPromptHandler:e.unhandledPromptBehavior}),{userContext:i.browserContextId}}async removeUserContext(e){let t=e.userContext;if(t==="default")throw new x("`default` user context cannot be removed");try{await this.#e.sendCommand("Target.disposeBrowserContext",{browserContextId:t})}catch(s){throw s.message.startsWith("Failed to find context with id")?new G(s.message):s}return{}}async getUserContexts(){return{userContexts:await this.#r.getUserContexts()}}async#i(e){let t=await this.#e.sendCommand("Browser.getWindowForTarget",{targetId:e});return{active:!1,clientWindow:`${t.windowId}`,state:t.bounds.windowState??"normal",height:t.bounds.height??0,width:t.bounds.width??0,x:t.bounds.left??0,y:t.bounds.top??0}}async setClientWindowState(e){let{clientWindow:t}=e,s={windowState:e.state};e.state==="normal"&&(e.width!==void 0&&(s.width=e.width),e.height!==void 0&&(s.height=e.height),e.x!==void 0&&(s.left=e.x),e.y!==void 0&&(s.top=e.y));let r=Number.parseInt(t);if(isNaN(r))throw new x("no such client window");await this.#e.sendCommand("Browser.setWindowBounds",{windowId:r,bounds:s});let i=await this.#e.sendCommand("Browser.getWindowBounds",{windowId:r});return{active:!1,clientWindow:`${r}`,state:i.bounds.windowState??"normal",height:i.bounds.height??0,width:i.bounds.width??0,x:i.bounds.left??0,y:i.bounds.top??0}}async getClientWindows(){let e=this.#t.getTopLevelContexts().map(i=>i.cdpTarget.id),t=await Promise.all(e.map(async i=>await this.#i(i))),s=new Set,r=new Array;for(let i of t)s.has(i.clientWindow)||(s.add(i.clientWindow),r.push(i));return{clientWindows:r}}#o(e){if(e===null)return{behavior:"default"};if(e?.type==="denied")return{behavior:"deny"};if(e?.type==="allowed")return{behavior:"allow",downloadPath:e.destinationFolder};throw new O("Unexpected download behavior")}async#a(e,t){await this.#e.sendCommand("Browser.setDownloadBehavior",{...this.#o(e),browserContextId:t==="default"?void 0:t,eventsEnabled:!0})}async setDownloadBehavior(e){let t;return e.userContexts===void 0?t=(await this.#r.getUserContexts()).map(s=>s.userContext):t=Array.from(await this.#r.verifyUserContextIdList(e.userContexts)),e.userContexts===void 0?this.#s.updateGlobalConfig({downloadBehavior:e.downloadBehavior}):e.userContexts.map(s=>this.#s.updateUserContextConfig(s,{downloadBehavior:e.downloadBehavior})),await Promise.all(t.map(async s=>{let r=this.#s.getActiveConfig(void 0,s).downloadBehavior??null;await this.#a(r,s)})),{}}};function no(n){if(!(n.proxyType==="direct"||n.proxyType==="system")){if(n.proxyType==="pac")throw new R("PAC proxy configuration is not supported per user context");if(n.proxyType==="autodetect")throw new R("Autodetect proxy is not supported per user context");if(n.proxyType==="manual"){let e=[];if(n.httpProxy!==void 0&&e.push(`http=${n.httpProxy}`),n.sslProxy!==void 0&&e.push(`https=${n.sslProxy}`),n.socksProxy!==void 0||n.socksVersion!==void 0){if(n.socksProxy===void 0)throw new x("'socksVersion' cannot be set without 'socksProxy'");if(n.socksVersion===void 0||typeof n.socksVersion!="number"||!Number.isInteger(n.socksVersion)||n.socksVersion<0||n.socksVersion>255)throw new x("'socksVersion' must be between 0 and 255");e.push(`socks=socks${n.socksVersion}://${n.socksProxy}`)}return e.length===0?void 0:e.join(";")}throw new O("Unknown proxy type")}}var jt=class{#e;#t;#s;#r;constructor(e,t,s,r){this.#e=e,this.#t=t,this.#s=s,this.#r=r}getSession(e){let t=e.context,s=this.#e.getContext(t).cdpTarget.cdpSessionId;return s===void 0?{}:{session:s}}resolveRealm(e){let t=e.realm,s=this.#t.getRealm({realmId:t});if(s===void 0)throw new O(`Could not find realm ${e.realm}`);return{executionContextId:s.executionContextId}}async sendCommand(e){return{result:await(e.session?this.#s.getCdpClient(e.session):this.#r).sendCommand(e.method,e.params),session:e.session}}};var $t=class{#e;#t;#s;#r;#i;constructor(e,t,s,r,i){this.#s=r,this.#i=s,this.#e=e,this.#t=t,this.#r=i,this.#r.addSubscribeHook(C.BrowsingContext.EventNames.ContextCreated,this.#a.bind(this))}getTree(e){return{contexts:(e.root===void 0?this.#t.getTopLevelContexts():[this.#t.getContext(e.root)]).map(s=>s.serializeToBidiValue(e.maxDepth??Number.MAX_VALUE))}}async create(e){let t,s="default";if(e.referenceContext!==void 0){if(t=this.#t.getContext(e.referenceContext),!t.isTopLevelContext())throw new x("referenceContext should be a top-level context");s=t.userContext}e.userContext!==void 0&&(s=e.userContext);let r=this.#t.getAllContexts().filter(c=>c.userContext===s),i=!1;switch(e.type){case"tab":i=!1;break;case"window":i=!0;break}r.length||(i=!0);let o;try{o=await this.#e.sendCommand("Target.createTarget",{url:"about:blank",newWindow:i,browserContextId:s==="default"?void 0:s,background:e.background===!0})}catch(c){throw c.message.startsWith("Failed to find browser context with id")||c.message==="browserContextId"?new G(`The context ${s} was not found`):c}let a=await this.#t.waitForContext(o.targetId);return await a.lifecycleLoaded(),{context:a.id}}navigate(e){return this.#t.getContext(e.context).navigate(e.url,e.wait??"none")}reload(e){return this.#t.getContext(e.context).reload(e.ignoreCache??!1,e.wait??"none")}async activate(e){let t=this.#t.getContext(e.context);if(!t.isTopLevelContext())throw new x("Activation is only supported on the top-level context");return await t.activate(),{}}async captureScreenshot(e){return await this.#t.getContext(e.context).captureScreenshot(e)}async print(e){return await this.#t.getContext(e.context).print(e)}async setViewport(e){if((e.viewport?.height??0)>1e7||(e.viewport?.width??0)>1e7)throw new R("Viewport dimension over 10000000 are not supported");let s={};e.devicePixelRatio!==void 0&&(s.devicePixelRatio=e.devicePixelRatio),e.viewport!==void 0&&(s.viewport=e.viewport);let r=await this.#o(e.context,e.userContexts);for(let i of e.userContexts??[])this.#s.updateUserContextConfig(i,s);return e.context!==void 0&&this.#s.updateBrowsingContextConfig(e.context,s),await Promise.all(r.map(async i=>{let o=this.#s.getActiveConfig(i.id,i.userContext);await i.setViewport(o.viewport??null,o.devicePixelRatio??null,o.screenOrientation??null)})),{}}async#o(e,t){if(e===void 0&&t===void 0)throw new x("Either userContexts or context must be provided");if(e!==void 0&&t!==void 0)throw new x("userContexts and context are mutually exclusive");if(e!==void 0){let r=this.#t.getContext(e);if(!r.isTopLevelContext())throw new x("Emulating viewport is only supported on the top-level context");return[r]}await this.#i.verifyUserContextIdList(t);let s=[];for(let r of t){let i=this.#t.getTopLevelContexts().filter(o=>o.userContext===r);s.push(...i)}return[...new Set(s).values()]}async traverseHistory(e){let t=this.#t.getContext(e.context);if(!t)throw new x(`No browsing context with id ${e.context}`);if(!t.isTopLevelContext())throw new x("Traversing history is only supported on the top-level context");return await t.traverseHistory(e.delta),{}}async handleUserPrompt(e){let t=this.#t.getContext(e.context);try{await t.handleUserPrompt(e.accept,e.userText)}catch(s){throw s.message?.includes("No dialog is showing")?new Nt("No dialog is showing"):s}return{}}async close(e){let t=this.#t.getContext(e.context);if(!t.isTopLevelContext())throw new x(`Non top-level browsing context ${t.id} cannot be closed.`);let s=t.cdpTarget.parentCdpClient;try{let r=new Promise(i=>{let o=a=>{a.targetId===e.context&&(s.off("Target.detachedFromTarget",o),i())};s.on("Target.detachedFromTarget",o)});try{e.promptUnload?await t.close():await s.sendCommand("Target.closeTarget",{targetId:e.context})}catch(i){if(!s.isCloseError(i))throw i}await r}catch(r){if(!(r.code===-32e3&&r.message==="Not attached to an active page"))throw r}return{}}async locateNodes(e){return await this.#t.getContext(e.context).locateNodes(e)}#a(e){return[this.#t.getContext(e),...this.#t.getContext(e).allChildren].forEach(r=>{this.#r.registerEvent({type:"event",method:C.BrowsingContext.EventNames.ContextCreated,params:r.serializeToBidiValue()},r.id)}),Promise.resolve()}};var Ht=class{#e;#t;#s;constructor(e,t,s){this.#e=t,this.#t=e,this.#s=s}async setGeolocationOverride(e){if("coordinates"in e&&"error"in e)throw new x("Coordinates and error cannot be set at the same time");let t=null;if("coordinates"in e){if((e.coordinates?.altitude??null)===null&&(e.coordinates?.altitudeAccuracy??null)!==null)throw new x("Geolocation altitudeAccuracy can be set only with altitude");t=e.coordinates}else if("error"in e){if(e.error.type!=="positionUnavailable")throw new x(`Unknown geolocation error ${e.error.type}`);t=e.error}else throw new x("Coordinates or error should be set");let s=await this.#r(e.contexts,e.userContexts);for(let r of e.contexts??[])this.#s.updateBrowsingContextConfig(r,{geolocation:t});for(let r of e.userContexts??[])this.#s.updateUserContextConfig(r,{geolocation:t});return await Promise.all(s.map(async r=>{let i=this.#s.getActiveConfig(r.id,r.userContext);await r.setGeolocationOverride(i.geolocation??null)})),{}}async setLocaleOverride(e){let t=e.locale??null;if(t!==null&&!oo(t))throw new x(`Invalid locale "${t}"`);let s=await this.#r(e.contexts,e.userContexts);for(let r of e.contexts??[])this.#s.updateBrowsingContextConfig(r,{locale:t});for(let r of e.userContexts??[])this.#s.updateUserContextConfig(r,{locale:t});return await Promise.all(s.map(async r=>{let i=this.#s.getActiveConfig(r.id,r.userContext);await Promise.all([r.setLocaleOverride(i.locale??null),r.setUserAgentAndAcceptLanguage(i.userAgent,i.locale,i.clientHints)])})),{}}async setScriptingEnabled(e){let t=e.enabled,s=await this.#r(e.contexts,e.userContexts);for(let r of e.contexts??[])this.#s.updateBrowsingContextConfig(r,{scriptingEnabled:t});for(let r of e.userContexts??[])this.#s.updateUserContextConfig(r,{scriptingEnabled:t});return await Promise.all(s.map(async r=>{let i=this.#s.getActiveConfig(r.id,r.userContext);await r.setScriptingEnabled(i.scriptingEnabled??null)})),{}}async setScrollbarTypeOverride(e){let t=await this.#r(e.contexts,e.userContexts);for(let s of e.contexts??[])this.#s.updateBrowsingContextConfig(s,{scrollbarType:e.scrollbarType});for(let s of e.userContexts??[])this.#s.updateUserContextConfig(s,{scrollbarType:e.scrollbarType});return await Promise.all(t.map(async s=>{let r=this.#s.getActiveConfig(s.id,s.userContext);await s.setScrollbarTypeOverride(r.scrollbarType??null)})),{}}async setScreenOrientationOverride(e){let t=await this.#r(e.contexts,e.userContexts);for(let s of e.contexts??[])this.#s.updateBrowsingContextConfig(s,{screenOrientation:e.screenOrientation});for(let s of e.userContexts??[])this.#s.updateUserContextConfig(s,{screenOrientation:e.screenOrientation});return await Promise.all(t.map(async s=>{let r=this.#s.getActiveConfig(s.id,s.userContext);await s.setViewport(r.viewport??null,r.devicePixelRatio??null,r.screenOrientation??null)})),{}}async setScreenSettingsOverride(e){let t=await this.#r(e.contexts,e.userContexts);for(let s of e.contexts??[])this.#s.updateBrowsingContextConfig(s,{screenArea:e.screenArea});for(let s of e.userContexts??[])this.#s.updateUserContextConfig(s,{screenArea:e.screenArea});return await Promise.all(t.map(async s=>{let r=this.#s.getActiveConfig(s.id,s.userContext);await s.setViewport(r.viewport??null,r.devicePixelRatio??null,r.screenOrientation??null)})),{}}async#r(e,t,s=!1){if(e===void 0&&t===void 0){if(s)return this.#t.getTopLevelContexts();throw new x("Either user contexts or browsing contexts must be provided")}if(e!==void 0&&t!==void 0)throw new x("User contexts and browsing contexts are mutually exclusive");let r=[];if(e===void 0){if(t.length===0)throw new x("user context should be provided");await this.#e.verifyUserContextIdList(t);for(let i of t){let o=this.#t.getTopLevelContexts().filter(a=>a.userContext===i);r.push(...o)}}else{if(e.length===0)throw new x("browsing context should be provided");for(let i of e){let o=this.#t.getContext(i);if(!o.isTopLevelContext())throw new x("The command is only supported on the top-level context");r.push(o)}}return[...new Set(r).values()]}async setTimezoneOverride(e){let t=e.timezone??null;if(t!==null&&!ao(t))throw new x(`Invalid timezone "${t}"`);t!==null&&co(t)&&(t=`GMT${t}`);let s=await this.#r(e.contexts,e.userContexts);for(let r of e.contexts??[])this.#s.updateBrowsingContextConfig(r,{timezone:t});for(let r of e.userContexts??[])this.#s.updateUserContextConfig(r,{timezone:t});return await Promise.all(s.map(async r=>{let i=this.#s.getActiveConfig(r.id,r.userContext);await r.setTimezoneOverride(i.timezone??null)})),{}}async setTouchOverride(e){let t=e.maxTouchPoints,s=await this.#r(e.contexts,e.userContexts,!0);for(let r of e.contexts??[])this.#s.updateBrowsingContextConfig(r,{maxTouchPoints:t});for(let r of e.userContexts??[])this.#s.updateUserContextConfig(r,{maxTouchPoints:t});return e.contexts===void 0&&e.userContexts===void 0&&this.#s.updateGlobalConfig({maxTouchPoints:t}),await Promise.all(s.map(async r=>{let i=this.#s.getActiveConfig(r.id,r.userContext);await r.setTouchOverride(i.maxTouchPoints??null)})),{}}async setUserAgentOverrideParams(e){if(e.userAgent==="")throw new R("empty user agent string is not supported");let t=await this.#r(e.contexts,e.userContexts,!0);for(let s of e.contexts??[])this.#s.updateBrowsingContextConfig(s,{userAgent:e.userAgent});for(let s of e.userContexts??[])this.#s.updateUserContextConfig(s,{userAgent:e.userAgent});return e.contexts===void 0&&e.userContexts===void 0&&this.#s.updateGlobalConfig({userAgent:e.userAgent}),await Promise.all(t.map(async s=>{let r=this.#s.getActiveConfig(s.id,s.userContext);await s.setUserAgentAndAcceptLanguage(r.userAgent,r.locale,r.clientHints)})),{}}async setClientHintsOverride(e){let t=e.clientHints??null,s=await this.#r(e.contexts,e.userContexts,!0);for(let r of e.contexts??[])this.#s.updateBrowsingContextConfig(r,{clientHints:t});for(let r of e.userContexts??[])this.#s.updateUserContextConfig(r,{clientHints:t});return e.contexts===void 0&&e.userContexts===void 0&&this.#s.updateGlobalConfig({clientHints:t}),await Promise.all(s.map(async r=>{let i=this.#s.getActiveConfig(r.id,r.userContext);await r.setUserAgentAndAcceptLanguage(i.userAgent,i.locale,i.clientHints)})),{}}async setNetworkConditions(e){let t=await this.#r(e.contexts,e.userContexts,!0);for(let s of e.contexts??[])this.#s.updateBrowsingContextConfig(s,{emulatedNetworkConditions:e.networkConditions});for(let s of e.userContexts??[])this.#s.updateUserContextConfig(s,{emulatedNetworkConditions:e.networkConditions});if(e.contexts===void 0&&e.userContexts===void 0&&this.#s.updateGlobalConfig({emulatedNetworkConditions:e.networkConditions}),e.networkConditions!==null&&e.networkConditions.type!=="offline")throw new R(`Unsupported network conditions ${e.networkConditions.type}`);return await Promise.all(t.map(async s=>{let r=this.#s.getActiveConfig(s.id,s.userContext);await s.setEmulatedNetworkConditions(r.emulatedNetworkConditions??null)})),{}}};function oo(n){try{return new Intl.Locale(n),!0}catch(e){if(e instanceof RangeError)return!1;throw e}}function ao(n){try{return Intl.DateTimeFormat(void 0,{timeZone:n}),!0}catch(e){if(e instanceof RangeError)return!1;throw e}}function co(n){return/^[+-](?:2[0-3]|[01]\d)(?::[0-5]\d)?$/.test(n)}function _(n,e){if(!n)throw new Error(e??"Internal assertion failed.")}function fr(n){return zt(n)&&n.length>1}function zt(n){return[...new Intl.Segmenter("en",{granularity:"grapheme"}).segment(n)].length===1}var Wt=class{type="none"},ot=class{type="key";pressed=new Set;#e=0;get modifiers(){return this.#e}get alt(){return(this.#e&1)===1}set alt(e){this.#t(e,1)}get ctrl(){return(this.#e&2)===2}set ctrl(e){this.#t(e,2)}get meta(){return(this.#e&4)===4}set meta(e){this.#t(e,4)}get shift(){return(this.#e&8)===8}set shift(e){this.#t(e,8)}#t(e,t){e?this.#e|=t:this.#e&=~t}},Kt=class n{static#e=500;static#t=2;count=0;#s;#r;#i;constructor(e,t,s){this.#s=e,this.#r=t,this.#i=s}compare(e){return e.#i-this.#i>n.#e||Math.abs(e.#s-this.#s)>n.#t||Math.abs(e.#r-this.#r)>n.#t}},Vt=class{type="pointer";subtype;pointerId;pressed=new Set;x=0;y=0;radiusX;radiusY;force;constructor(e,t){this.pointerId=e,this.subtype=t}get buttons(){let e=0;for(let t of this.pressed)switch(t){case 0:e|=1;break;case 1:e|=4;break;case 2:e|=2;break;case 3:e|=8;break;case 4:e|=16;break}return e}#e=new Map;setClickCount(e,t){let s=this.#e.get(e);return(!s||s.compare(t))&&(s=t),++s.count,this.#e.set(e,s),s.count}getClickCount(e){return this.#e.get(e)?.count??0}resetClickCount(){this.#e=new Map}},Gt=class{type="wheel"};function mr(n){switch(n){case"\uE000":return"Unidentified";case"\uE001":return"Cancel";case"\uE002":return"Help";case"\uE003":return"Backspace";case"\uE004":return"Tab";case"\uE005":return"Clear";case"\uE006":case"\uE007":return"Enter";case"\uE008":return"Shift";case"\uE009":return"Control";case"\uE00A":return"Alt";case"\uE00B":return"Pause";case"\uE00C":return"Escape";case"\uE00D":return" ";case"\uE00E":return"PageUp";case"\uE00F":return"PageDown";case"\uE010":return"End";case"\uE011":return"Home";case"\uE012":return"ArrowLeft";case"\uE013":return"ArrowUp";case"\uE014":return"ArrowRight";case"\uE015":return"ArrowDown";case"\uE016":return"Insert";case"\uE017":return"Delete";case"\uE018":return";";case"\uE019":return"=";case"\uE01A":return"0";case"\uE01B":return"1";case"\uE01C":return"2";case"\uE01D":return"3";case"\uE01E":return"4";case"\uE01F":return"5";case"\uE020":return"6";case"\uE021":return"7";case"\uE022":return"8";case"\uE023":return"9";case"\uE024":return"*";case"\uE025":return"+";case"\uE026":return",";case"\uE027":return"-";case"\uE028":return".";case"\uE029":return"/";case"\uE031":return"F1";case"\uE032":return"F2";case"\uE033":return"F3";case"\uE034":return"F4";case"\uE035":return"F5";case"\uE036":return"F6";case"\uE037":return"F7";case"\uE038":return"F8";case"\uE039":return"F9";case"\uE03A":return"F10";case"\uE03B":return"F11";case"\uE03C":return"F12";case"\uE03D":return"Meta";case"\uE040":return"ZenkakuHankaku";case"\uE050":return"Shift";case"\uE051":return"Control";case"\uE052":return"Alt";case"\uE053":return"Meta";case"\uE054":return"PageUp";case"\uE055":return"PageDown";case"\uE056":return"End";case"\uE057":return"Home";case"\uE058":return"ArrowLeft";case"\uE059":return"ArrowUp";case"\uE05A":return"ArrowRight";case"\uE05B":return"ArrowDown";case"\uE05C":return"Insert";case"\uE05D":return"Delete";default:return n}}function gr(n){switch(n){case"`":case"~":return"Backquote";case"\\":case"|":return"Backslash";case"\uE003":return"Backspace";case"[":case"{":return"BracketLeft";case"]":case"}":return"BracketRight";case",":case"<":return"Comma";case"0":case")":return"Digit0";case"1":case"!":return"Digit1";case"2":case"@":return"Digit2";case"3":case"#":return"Digit3";case"4":case"$":return"Digit4";case"5":case"%":return"Digit5";case"6":case"^":return"Digit6";case"7":case"&":return"Digit7";case"8":case"*":return"Digit8";case"9":case"(":return"Digit9";case"=":case"+":return"Equal";case">":return"IntlBackslash";case"a":case"A":return"KeyA";case"b":case"B":return"KeyB";case"c":case"C":return"KeyC";case"d":case"D":return"KeyD";case"e":case"E":return"KeyE";case"f":case"F":return"KeyF";case"g":case"G":return"KeyG";case"h":case"H":return"KeyH";case"i":case"I":return"KeyI";case"j":case"J":return"KeyJ";case"k":case"K":return"KeyK";case"l":case"L":return"KeyL";case"m":case"M":return"KeyM";case"n":case"N":return"KeyN";case"o":case"O":return"KeyO";case"p":case"P":return"KeyP";case"q":case"Q":return"KeyQ";case"r":case"R":return"KeyR";case"s":case"S":return"KeyS";case"t":case"T":return"KeyT";case"u":case"U":return"KeyU";case"v":case"V":return"KeyV";case"w":case"W":return"KeyW";case"x":case"X":return"KeyX";case"y":case"Y":return"KeyY";case"z":case"Z":return"KeyZ";case"-":case"_":return"Minus";case".":return"Period";case"'":case'"':return"Quote";case";":case":":return"Semicolon";case"/":case"?":return"Slash";case"\uE00A":return"AltLeft";case"\uE052":return"AltRight";case"\uE009":return"ControlLeft";case"\uE051":return"ControlRight";case"\uE006":return"Enter";case"\uE00B":return"Pause";case"\uE03D":return"MetaLeft";case"\uE053":return"MetaRight";case"\uE008":return"ShiftLeft";case"\uE050":return"ShiftRight";case" ":case"\uE00D":return"Space";case"\uE004":return"Tab";case"\uE017":return"Delete";case"\uE010":return"End";case"\uE002":return"Help";case"\uE011":return"Home";case"\uE016":return"Insert";case"\uE00F":return"PageDown";case"\uE00E":return"PageUp";case"\uE015":return"ArrowDown";case"\uE012":return"ArrowLeft";case"\uE014":return"ArrowRight";case"\uE013":return"ArrowUp";case"\uE00C":return"Escape";case"\uE031":return"F1";case"\uE032":return"F2";case"\uE033":return"F3";case"\uE034":return"F4";case"\uE035":return"F5";case"\uE036":return"F6";case"\uE037":return"F7";case"\uE038":return"F8";case"\uE039":return"F9";case"\uE03A":return"F10";case"\uE03B":return"F11";case"\uE03C":return"F12";case"\uE019":return"NumpadEqual";case"\uE01A":case"\uE05C":return"Numpad0";case"\uE01B":case"\uE056":return"Numpad1";case"\uE01C":case"\uE05B":return"Numpad2";case"\uE01D":case"\uE055":return"Numpad3";case"\uE01E":case"\uE058":return"Numpad4";case"\uE01F":return"Numpad5";case"\uE020":case"\uE05A":return"Numpad6";case"\uE021":case"\uE057":return"Numpad7";case"\uE022":case"\uE059":return"Numpad8";case"\uE023":case"\uE054":return"Numpad9";case"\uE025":return"NumpadAdd";case"\uE026":return"NumpadComma";case"\uE028":case"\uE05D":return"NumpadDecimal";case"\uE029":return"NumpadDivide";case"\uE007":return"NumpadEnter";case"\uE024":return"NumpadMultiply";case"\uE027":return"NumpadSubtract";default:return}}function wr(n){switch(n){case"\uE007":case"\uE008":case"\uE009":case"\uE00A":case"\uE03D":return 1;case"\uE019":case"\uE01A":case"\uE01B":case"\uE01C":case"\uE01D":case"\uE01E":case"\uE01F":case"\uE020":case"\uE021":case"\uE022":case"\uE023":case"\uE024":case"\uE025":case"\uE026":case"\uE027":case"\uE028":case"\uE029":case"\uE054":case"\uE055":case"\uE056":case"\uE057":case"\uE058":case"\uE059":case"\uE05A":case"\uE05B":case"\uE05C":case"\uE05D":return 3;case"\uE050":case"\uE051":case"\uE052":case"\uE053":return 2;default:return 0}}var yr={0:48,1:49,2:50,3:51,4:52,5:53,6:54,7:55,8:56,9:57,Abort:3,Help:6,Backspace:8,Tab:9,Numpad5:12,NumpadEnter:13,Enter:13,"\\r":13,"\\n":13,ShiftLeft:16,ShiftRight:16,ControlLeft:17,ControlRight:17,AltLeft:18,AltRight:18,Pause:19,CapsLock:20,Escape:27,Convert:28,NonConvert:29,Space:32,Numpad9:33,PageUp:33,Numpad3:34,PageDown:34,End:35,Numpad1:35,Home:36,Numpad7:36,ArrowLeft:37,Numpad4:37,Numpad8:38,ArrowUp:38,ArrowRight:39,Numpad6:39,Numpad2:40,ArrowDown:40,Select:41,Open:43,PrintScreen:44,Insert:45,Numpad0:45,Delete:46,NumpadDecimal:46,Digit0:48,Digit1:49,Digit2:50,Digit3:51,Digit4:52,Digit5:53,Digit6:54,Digit7:55,Digit8:56,Digit9:57,KeyA:65,KeyB:66,KeyC:67,KeyD:68,KeyE:69,KeyF:70,KeyG:71,KeyH:72,KeyI:73,KeyJ:74,KeyK:75,KeyL:76,KeyM:77,KeyN:78,KeyO:79,KeyP:80,KeyQ:81,KeyR:82,KeyS:83,KeyT:84,KeyU:85,KeyV:86,KeyW:87,KeyX:88,KeyY:89,KeyZ:90,MetaLeft:91,MetaRight:92,ContextMenu:93,NumpadMultiply:106,NumpadAdd:107,NumpadSubtract:109,NumpadDivide:111,F1:112,F2:113,F3:114,F4:115,F5:116,F6:117,F7:118,F8:119,F9:120,F10:121,F11:122,F12:123,F13:124,F14:125,F15:126,F16:127,F17:128,F18:129,F19:130,F20:131,F21:132,F22:133,F23:134,F24:135,NumLock:144,ScrollLock:145,AudioVolumeMute:173,AudioVolumeDown:174,AudioVolumeUp:175,MediaTrackNext:176,MediaTrackPrevious:177,MediaStop:178,MediaPlayPause:179,Semicolon:186,Equal:187,NumpadEqual:187,Comma:188,Minus:189,Period:190,Slash:191,Backquote:192,BracketLeft:219,Backslash:220,BracketRight:221,Quote:222,AltGraph:225,Props:247,Cancel:3,Clear:12,Shift:16,Control:17,Alt:18,Accept:30,ModeChange:31," ":32,Print:42,Execute:43,"\\u0000":46,a:65,b:66,c:67,d:68,e:69,f:70,g:71,h:72,i:73,j:74,k:75,l:76,m:77,n:78,o:79,p:80,q:81,r:82,s:83,t:84,u:85,v:86,w:87,x:88,y:89,z:90,Meta:91,"*":106,"+":107,"-":109,"/":111,";":186,"=":187,",":188,".":190,"`":192,"[":219,"\\\\":220,"]":221,"'":222,Attn:246,CrSel:247,ExSel:248,EraseEof:249,Play:250,ZoomOut:251,")":48,"!":49,"@":50,"#":51,$:52,"%":53,"^":54,"&":55,"(":57,A:65,B:66,C:67,D:68,E:69,F:70,G:71,H:72,I:73,J:74,K:75,L:76,M:77,N:78,O:79,P:80,Q:81,R:82,S:83,T:84,U:85,V:86,W:87,X:88,Y:89,Z:90,":":186,"<":188,_:189,">":190,"?":191,"~":192,"{":219,"|":220,"}":221,'"':222,Camera:44,EndCall:95,VolumeDown:182,VolumeUp:183};var uo=(n=>{let e=n.getClientRects()[0],t=Math.max(0,Math.min(e.x,e.x+e.width)),s=Math.min(window.innerWidth,Math.max(e.x,e.x+e.width)),r=Math.max(0,Math.min(e.y,e.y+e.height)),i=Math.min(window.innerHeight,Math.max(e.y,e.y+e.height));return[t+(s-t>>1),r+(i-r>>1)]}).toString(),lo=(()=>navigator.platform.toLowerCase().includes("mac")).toString();async function ho(n,e){let s=await(await n.getOrCreateHiddenSandbox()).callFunction(uo,!1,{type:"undefined"},[e]);if(s.type==="exception")throw new ce(`Origin element ${e.sharedId} was not found`);_(s.result.type==="array"),_(s.result.value?.[0]?.type==="number"),_(s.result.value?.[1]?.type==="number");let{result:{value:[{value:r},{value:i}]}}=s;return{x:r,y:i}}var Ce=class{static isMacOS=async e=>{let s=await(await e.getOrCreateHiddenSandbox()).callFunction(lo,!1);return _(s.type!=="exception"),_(s.result.type==="boolean"),s.result.value};#e;#t=0;#s=0;#r;#i;#o;constructor(e,t,s,r){this.#e=t,this.#r=e,this.#i=s,this.#o=r}get#a(){return this.#e.getContext(this.#i)}async dispatchActions(e){await this.#r.queue.run(async()=>{for(let t of e)await this.dispatchTickActions(t)})}async dispatchTickActions(e){this.#t=performance.now(),this.#s=0;for(let{action:s}of e)"duration"in s&&s.duration!==void 0&&(this.#s=Math.max(this.#s,s.duration));let t=[new Promise(s=>setTimeout(s,this.#s))];for(let s of e)t.push(this.#d(s));await Promise.all(t)}async#d({id:e,action:t}){let s=this.#r.get(e),r=this.#r.getGlobalKeyState();switch(t.type){case"keyDown":{await this.#u(s,t),this.#r.cancelList.push({id:e,action:{...t,type:"keyUp"}});break}case"keyUp":{await this.#m(s,t);break}case"pause":break;case"pointerDown":{await this.#n(s,r,t),this.#r.cancelList.push({id:e,action:{...t,type:"pointerUp"}});break}case"pointerMove":{await this.#h(s,r,t);break}case"pointerUp":{await this.#l(s,r,t);break}case"scroll":{await this.#p(s,r,t);break}}}async#n(e,t,s){let{button:r}=s;if(e.pressed.has(r))return;e.pressed.add(r);let{x:i,y:o,subtype:a}=e,{width:c,height:d,pressure:u,twist:l,tangentialPressure:y}=s,{tiltX:f,tiltY:h}=dn(s),{modifiers:p}=t,{radiusX:m,radiusY:v}=un(c??1,d??1);switch(a){case"mouse":case"pen":await this.#a.cdpTarget.cdpClient.sendCommand("Input.dispatchMouseEvent",{type:"mousePressed",x:i,y:o,modifiers:p,button:Xt(r),buttons:e.buttons,clickCount:e.setClickCount(r,new Kt(i,o,performance.now())),pointerType:a,tangentialPressure:y,tiltX:f,tiltY:h,twist:l,force:u});break;case"touch":await this.#a.cdpTarget.cdpClient.sendCommand("Input.dispatchTouchEvent",{type:"touchStart",touchPoints:[{x:i,y:o,radiusX:m,radiusY:v,tangentialPressure:y,tiltX:f,tiltY:h,twist:l,force:u,id:e.pointerId}],modifiers:p});break}e.radiusX=m,e.radiusY=v,e.force=u}#l(e,t,s){let{button:r}=s;if(!e.pressed.has(r))return;e.pressed.delete(r);let{x:i,y:o,force:a,radiusX:c,radiusY:d,subtype:u}=e,{modifiers:l}=t;switch(u){case"mouse":case"pen":return this.#a.cdpTarget.cdpClient.sendCommand("Input.dispatchMouseEvent",{type:"mouseReleased",x:i,y:o,modifiers:l,button:Xt(r),buttons:e.buttons,clickCount:e.getClickCount(r),pointerType:u});case"touch":return this.#a.cdpTarget.cdpClient.sendCommand("Input.dispatchTouchEvent",{type:"touchEnd",touchPoints:[{x:i,y:o,id:e.pointerId,force:a,radiusX:c,radiusY:d}],modifiers:l})}}async#h(e,t,s){let{x:r,y:i,subtype:o}=e,{width:a,height:c,pressure:d,twist:u,tangentialPressure:l,x:y,y:f,origin:h="viewport",duration:p=this.#s}=s,{tiltX:m,tiltY:v}=dn(s),{radiusX:I,radiusY:B}=un(a??1,c??1),{targetX:U,targetY:he}=await this.#f(h,y,f,r,i);if(U<0||he<0)throw new st(`Cannot move beyond viewport (x: ${U}, y: ${he})`);let Ie;do{let De=p>0?(performance.now()-this.#t)/p:1;Ie=De>=1;let Q,ee;if(Ie?(Q=U,ee=he):(Q=Math.round(De*(U-r)+r),ee=Math.round(De*(he-i)+i)),e.x!==Q||e.y!==ee){let{modifiers:Te}=t;switch(o){case"mouse":await this.#a.cdpTarget.cdpClient.sendCommand("Input.dispatchMouseEvent",{type:"mouseMoved",x:Q,y:ee,modifiers:Te,clickCount:0,button:Xt(e.pressed.values().next().value??5),buttons:e.buttons,pointerType:o,tangentialPressure:l,tiltX:m,tiltY:v,twist:u,force:d});break;case"pen":e.pressed.size!==0&&await this.#a.cdpTarget.cdpClient.sendCommand("Input.dispatchMouseEvent",{type:"mouseMoved",x:Q,y:ee,modifiers:Te,clickCount:0,button:Xt(e.pressed.values().next().value??5),buttons:e.buttons,pointerType:o,tangentialPressure:l,tiltX:m,tiltY:v,twist:u,force:d??.5});break;case"touch":e.pressed.size!==0&&await this.#a.cdpTarget.cdpClient.sendCommand("Input.dispatchTouchEvent",{type:"touchMove",touchPoints:[{x:Q,y:ee,radiusX:I,radiusY:B,tangentialPressure:l,tiltX:m,tiltY:v,twist:u,force:d,id:e.pointerId}],modifiers:Te});break}e.x=Q,e.y=ee,e.radiusX=I,e.radiusY=B,e.force=d}}while(!Ie)}async#c(){if(this.#a.id===this.#a.cdpTarget.id)return{x:0,y:0};let{backendNodeId:e}=await this.#a.cdpTarget.cdpClient.sendCommand("DOM.getFrameOwner",{frameId:this.#a.id}),{model:t}=await this.#a.cdpTarget.cdpClient.sendCommand("DOM.getBoxModel",{backendNodeId:e});return{x:t.content[0],y:t.content[1]}}async#f(e,t,s,r,i){let o,a,c=await this.#c();switch(e){case"viewport":o=t+c.x,a=s+c.y;break;case"pointer":o=r+t+c.x,a=i+s+c.y;break;default:{let{x:d,y:u}=await ho(this.#a,e.element);o=d+t+c.x,a=u+s+c.y;break}}return{targetX:o,targetY:a}}async#p(e,t,s){let{deltaX:r,deltaY:i,x:o,y:a,origin:c="viewport",duration:d=this.#s}=s;if(c==="pointer")throw new x('"pointer" origin is invalid for scrolling.');let{targetX:u,targetY:l}=await this.#f(c,o,a,0,0);if(u<0||l<0)throw new st(`Cannot move beyond viewport (x: ${u}, y: ${l})`);let y=0,f=0,h;do{let p=d>0?(performance.now()-this.#t)/d:1;h=p>=1;let m,v;if(h?(m=r-y,v=i-f):(m=Math.round(p*r-y),v=Math.round(p*i-f)),m!==0||v!==0){let{modifiers:I}=t;await this.#a.cdpTarget.cdpClient.sendCommand("Input.dispatchMouseEvent",{type:"mouseWheel",deltaX:m,deltaY:v,x:u,y:l,modifiers:I}),y+=m,f+=v}}while(!h)}async#u(e,t){let s=t.value;if(!zt(s))throw new x(`Invalid key value: ${s}`);let r=fr(s),i=mr(s),o=e.pressed.has(i),a=gr(s),c=wr(s);switch(i){case"Alt":e.alt=!0;break;case"Shift":e.shift=!0;break;case"Control":e.ctrl=!0;break;case"Meta":e.meta=!0;break}e.pressed.add(i);let{modifiers:d}=e,u=an(i,e,r),l=cn(a??"",e)??u,y;if(this.#o&&e.meta)switch(a){case"KeyA":y="SelectAll";break;case"KeyC":y="Copy";break;case"KeyV":y=e.shift?"PasteAndMatchStyle":"Paste";break;case"KeyX":y="Cut";break;case"KeyZ":y=e.shift?"Redo":"Undo";break;default:}let f=[this.#a.cdpTarget.cdpClient.sendCommand("Input.dispatchKeyEvent",{type:l?"keyDown":"rawKeyDown",windowsVirtualKeyCode:yr[i],key:i,code:a,text:l,unmodifiedText:u,autoRepeat:o,isSystemKey:e.alt||void 0,location:c<3?c:void 0,isKeypad:c===3,modifiers:d,commands:y?[y]:void 0})];i==="Escape"&&!e.alt&&(this.#o&&!e.ctrl&&!e.meta||!this.#o)&&f.push(this.#a.cdpTarget.cdpClient.sendCommand("Input.cancelDragging")),await Promise.all(f)}#m(e,t){let s=t.value;if(!zt(s))throw new x(`Invalid key value: ${s}`);let r=fr(s),i=mr(s);if(!e.pressed.has(i))return;let o=gr(s),a=wr(s);switch(i){case"Alt":e.alt=!1;break;case"Shift":e.shift=!1;break;case"Control":e.ctrl=!1;break;case"Meta":e.meta=!1;break}e.pressed.delete(i);let{modifiers:c}=e,d=an(i,e,r),u=cn(o??"",e)??d;return this.#a.cdpTarget.cdpClient.sendCommand("Input.dispatchKeyEvent",{type:"keyUp",windowsVirtualKeyCode:yr[i],key:i,code:o,text:u,unmodifiedText:d,location:a<3?a:void 0,isSystemKey:e.alt||void 0,isKeypad:a===3,modifiers:c})}},an=(n,e,t)=>t?n:n==="Enter"?"\r":[...n].length===1?e.shift?n.toLocaleUpperCase("en-US"):n:void 0,cn=(n,e)=>{if(e.ctrl){switch(n){case"Digit2":if(e.shift)return"\0";break;case"KeyA":return"";case"KeyB":return"";case"KeyC":return"";case"KeyD":return"";case"KeyE":return"";case"KeyF":return"";case"KeyG":return"\x07";case"KeyH":return"\b";case"KeyI":return" ";case"KeyJ":return`
3
3
  `;case"KeyK":return"\v";case"KeyL":return"\f";case"KeyM":return"\r";case"KeyN":return"";case"KeyO":return"";case"KeyP":return"";case"KeyQ":return"";case"KeyR":return"";case"KeyS":return"";case"KeyT":return"";case"KeyU":return"";case"KeyV":return"";case"KeyW":return"";case"KeyX":return"";case"KeyY":return"";case"KeyZ":return"";case"BracketLeft":return"\x1B";case"Backslash":return"";case"BracketRight":return"";case"Digit6":if(e.shift)return"";break;case"Minus":return""}return""}if(e.alt)return""};function Xt(n){switch(n){case 0:return"left";case 1:return"middle";case 2:return"right";case 3:return"back";case 4:return"forward";default:return"none"}}function dn(n){let e=n.altitudeAngle??Math.PI/2,t=n.azimuthAngle??0,s=0,r=0;if(e===0&&((t===0||t===2*Math.PI)&&(s=Math.PI/2),t===Math.PI/2&&(r=Math.PI/2),t===Math.PI&&(s=-Math.PI/2),t===3*Math.PI/2&&(r=-Math.PI/2),t>0&&t<Math.PI/2&&(s=Math.PI/2,r=Math.PI/2),t>Math.PI/2&&t<Math.PI&&(s=-Math.PI/2,r=Math.PI/2),t>Math.PI&&t<3*Math.PI/2&&(s=-Math.PI/2,r=-Math.PI/2),t>3*Math.PI/2&&t<2*Math.PI&&(s=Math.PI/2,r=-Math.PI/2)),e!==0){let o=Math.tan(e);s=Math.atan(Math.cos(t)/o),r=Math.atan(Math.sin(t)/o)}let i=180/Math.PI;return{tiltX:Math.round(s*i),tiltY:Math.round(r*i)}}function un(n,e){return{radiusX:n?n/2:.5,radiusY:e?e/2:.5}}var Jt=class{#e=!1;#t=[];acquire(){let e={resolved:!1};return this.#e?new Promise(t=>{this.#t.push(()=>t(this.#s.bind(this,e)))}):(this.#e=!0,Promise.resolve(this.#s.bind(this,e)))}#s(e){if(e.resolved)throw new Error("Cannot release more than once.");e.resolved=!0;let t=this.#t.shift();if(!t){this.#e=!1;return}t()}async run(e){let t=await this.acquire();try{return await e()}finally{t()}}};var Yt=class{cancelList=[];#e=new Map;#t=new Jt;getOrCreate(e,t,s){let r=this.#e.get(e);if(!r){switch(t){case"none":r=new Wt;break;case"key":r=new ot;break;case"pointer":{let i=s==="mouse"?0:2,o=new Set;for(let[,a]of this.#e)a.type==="pointer"&&o.add(a.pointerId);for(;o.has(i);)++i;r=new Vt(i,s);break}case"wheel":r=new Gt;break;default:throw new x(`Expected "none", "key", "pointer", or "wheel". Found unknown source type ${t}.`)}return this.#e.set(e,r),r}if(r.type!==t)throw new x(`Input source type of ${e} is ${r.type}, but received ${t}.`);return r}get(e){let t=this.#e.get(e);if(!t)throw new O("Internal error.");return t}getGlobalKeyState(){let e=new ot;for(let[,t]of this.#e)if(t.type==="key"){for(let s of t.pressed)e.pressed.add(s);e.alt||=t.alt,e.ctrl||=t.ctrl,e.meta||=t.meta,e.shift||=t.shift}return e}get queue(){return this.#t}};var Zt=class extends WeakMap{get(e){return _(e.isTopLevelContext()),this.has(e)||this.set(e,new Yt),super.get(e)}};var Qt=class{#e;#t=new Zt;constructor(e){this.#e=e}async performActions(e){let t=this.#e.getContext(e.context),s=this.#t.get(t.top),r=this.#s(e,s);return await new Ce(s,this.#e,e.context,await Ce.isMacOS(t).catch(()=>!1)).dispatchActions(r),{}}async releaseActions(e){let t=this.#e.getContext(e.context),s=t.top,r=this.#t.get(s);return await new Ce(r,this.#e,e.context,await Ce.isMacOS(t).catch(()=>!1)).dispatchTickActions(r.cancelList.reverse()),this.#t.delete(s),{}}async setFiles(e){let s=await this.#e.getContext(e.context).getOrCreateHiddenSandbox(),r;try{r=await s.callFunction(String(function(c){if(!(this instanceof HTMLInputElement))return this instanceof Element?1:0;if(this.type!=="file")return 2;if(this.disabled)return 3;if(c>1&&!this.multiple)return 4}),!1,e.element,[{type:"number",value:e.files.length}])}catch{throw new Y(`Could not find element ${e.element.sharedId}`)}if(_(r.type==="success"),r.result.type==="number")switch(r.result.value){case 0:throw new ce(`Could not find element ${e.element.sharedId}`);case 1:throw new be(`Element ${e.element.sharedId} is not a input`);case 2:throw new be(`Input element ${e.element.sharedId} is not a file type`);case 3:throw new be(`Input element ${e.element.sharedId} is disabled`);case 4:throw new be("Cannot set multiple files on a non-multiple input element")}if(e.files.length===0)return await s.callFunction(String(function(){if(this.files?.length===0){this.dispatchEvent(new Event("cancel",{bubbles:!0}));return}this.files=new DataTransfer().files,this.dispatchEvent(new Event("input",{bubbles:!0,composed:!0})),this.dispatchEvent(new Event("change",{bubbles:!0}))}),!1,e.element),{};let i=[];for(let a=0;a<e.files.length;++a){let c=await s.callFunction(String(function(y){return this.files?.item(y)}),!1,e.element,[{type:"number",value:0}],"root");if(_(c.type==="success"),c.result.type!=="object")break;let{handle:d}=c.result;_(d!==void 0);let{path:u}=await s.cdpClient.sendCommand("DOM.getFileInfo",{objectId:d});i.push(u),s.disown(d).catch(void 0)}i.sort();let o=[...e.files].sort();if(i.length!==e.files.length||o.some((a,c)=>i[c]!==a)){let{objectId:a}=await s.deserializeForCdp(e.element);_(a!==void 0),await s.cdpClient.sendCommand("DOM.setFileInputFiles",{files:e.files,objectId:a})}else await s.callFunction(String(function(){this.dispatchEvent(new Event("cancel",{bubbles:!0}))}),!1,e.element);return{}}#s(e,t){let s=[];for(let r of e.actions){switch(r.type){case"pointer":{r.parameters??={pointerType:"mouse"},r.parameters.pointerType??="mouse";let o=t.getOrCreate(r.id,"pointer",r.parameters.pointerType);if(o.subtype!==r.parameters.pointerType)throw new x(`Expected input source ${r.id} to be ${o.subtype}; got ${r.parameters.pointerType}.`);o.resetClickCount();break}default:t.getOrCreate(r.id,r.type)}let i=r.actions.map(o=>({id:r.id,action:o}));for(let o=0;o<i.length;o++)s.length===o&&s.push([]),s[o].push(i[o])}return s}};function ln(n){return"atob"in globalThis?globalThis.atob(n):Buffer.from(n,"base64").toString("ascii")}function vr(n){let e=n.reduce((t,s)=>`${t}${s.name}: ${s.value.value}\r
4
4
  `,"");return new TextEncoder().encode(e).length}function hn(n){return po(new TextEncoder().encode(n))}function po(n){let t=[];for(let r=0;r<n.length;r+=65534){let i=n.subarray(r,r+65534);t.push(String.fromCodePoint.apply(null,i))}let s=t.join("");return btoa(s)}function es(n){return n?Object.entries(n).map(([e,t])=>({name:e,value:{type:"string",value:t}})):[]}function ts(n){if(n!==void 0)return n.map(({name:e,value:t})=>({name:e,value:t.value}))}function pn(n){return n===void 0?void 0:{name:"Cookie",value:{type:"string",value:n.reduce((t,s,r)=>{r>0&&(t+=";");let i=s.value.type==="base64"?btoa(s.value.value):s.value.value;return t+=`${s.name}=${i}`,t},"")}}}function fn(n){switch(n){case"default":return"Default";case"cancel":return"CancelAuth";case"provideCredentials":return"ProvideCredentials"}}function at(n){let e={name:n.name,value:{type:"string",value:n.value},domain:n.domain,path:n.path,size:n.size,httpOnly:n.httpOnly,secure:n.secure,sameSite:n.sameSite===void 0?"none":fo(n.sameSite),...n.expires>=0?{expiry:Math.round(n.expires)}:void 0};return e["goog:session"]=n.session,e["goog:priority"]=n.priority,e["goog:sourceScheme"]=n.sourceScheme,e["goog:sourcePort"]=n.sourcePort,n.partitionKey!==void 0&&(e["goog:partitionKey"]=n.partitionKey),n.partitionKeyOpaque!==void 0&&(e["goog:partitionKeyOpaque"]=n.partitionKeyOpaque),e}function ss(n){return n.type==="base64"?ln(n.value):n.value}function mn(n,e){let t=ss(n.cookie.value),s={name:n.cookie.name,value:t,domain:n.cookie.domain,path:n.cookie.path??"/",secure:n.cookie.secure??!1,httpOnly:n.cookie.httpOnly??!1,...e.sourceOrigin!==void 0&&{partitionKey:{hasCrossSiteAncestor:!1,topLevelSite:e.sourceOrigin}},...n.cookie.expiry!==void 0&&{expires:n.cookie.expiry},...n.cookie.sameSite!==void 0&&{sameSite:mo(n.cookie.sameSite)}};return n.cookie["goog:url"]!==void 0&&(s.url=n.cookie["goog:url"]),n.cookie["goog:priority"]!==void 0&&(s.priority=n.cookie["goog:priority"]),n.cookie["goog:sourceScheme"]!==void 0&&(s.sourceScheme=n.cookie["goog:sourceScheme"]),n.cookie["goog:sourcePort"]!==void 0&&(s.sourcePort=n.cookie["goog:sourcePort"]),s}function fo(n){switch(n){case"Strict":return"strict";case"None":return"none";case"Lax":return"lax";default:return"lax"}}function mo(n){switch(n){case"none":return"None";case"strict":return"Strict";case"default":case"lax":return"Lax"}throw new x(`Unknown 'sameSite' value ${n}`)}function xr(n){return["ftp","file","http","https","ws","wss"].includes(n.replace(/:$/,""))}function go(n){return n.protocol.replace(/:$/,"")}function gn(n,e){let t=new URL(e);return!(n.protocol!==void 0&&n.protocol!==go(t)||n.hostname!==void 0&&n.hostname!==t.hostname||n.port!==void 0&&n.port!==t.port||n.pathname!==void 0&&n.pathname!==t.pathname||n.search!==void 0&&n.search!==t.search)}function wn(n){let e=0;for(let t of n)e+=atob(t.bytes??"").length;return e}function z(n,e=0){return!n||n<=0||n+e<=0?0:n+e}var je=class n{#e;#t;#s;#r;constructor(e,t,s,r){this.#s=s,this.#e=e,this.#t=t,this.#r=r}async addIntercept(e){this.#e.verifyTopLevelContextsList(e.contexts);let t=e.urlPatterns??[],s=n.parseUrlPatterns(t),r=this.#t.addIntercept({urlPatterns:s,phases:e.phases,contexts:e.contexts});return await this.#i(),{intercept:r}}async continueRequest(e){if(e.url!==void 0&&n.parseUrlString(e.url),e.method!==void 0&&!n.isMethodValid(e.method))throw new x(`Method '${e.method}' is invalid.`);e.headers&&n.validateHeaders(e.headers);let t=this.#a(e.request,["beforeRequestSent"]);try{await t.continueRequest(e)}catch(s){throw n.wrapInterceptionError(s)}return{}}async continueResponse(e){e.headers&&n.validateHeaders(e.headers);let t=this.#a(e.request,["authRequired","responseStarted"]);try{await t.continueResponse(e)}catch(s){throw n.wrapInterceptionError(s)}return{}}async continueWithAuth(e){let t=e.request;return await this.#a(t,["authRequired"]).continueWithAuth(e),{}}async failRequest({request:e}){let t=this.#o(e);if(t.interceptPhase==="authRequired")throw new x(`Request '${e}' in 'authRequired' phase cannot be failed`);if(!t.interceptPhase)throw new Le(`No blocked request found for network id '${e}'`);return await t.failRequest("Failed"),{}}async provideResponse(e){e.headers&&n.validateHeaders(e.headers);let t=this.#a(e.request,["beforeRequestSent","responseStarted","authRequired"]);try{await t.provideResponse(e)}catch(s){throw n.wrapInterceptionError(s)}return{}}async#i(){await Promise.all(this.#e.getAllContexts().map(e=>e.cdpTarget.toggleNetwork()))}async removeIntercept(e){return this.#t.removeIntercept(e.intercept),await this.#i(),{}}async setCacheBehavior(e){let t=this.#e.verifyTopLevelContextsList(e.contexts);if(t.size===0)return this.#t.defaultCacheBehavior=e.cacheBehavior,await Promise.all(this.#e.getAllContexts().map(r=>r.cdpTarget.toggleSetCacheDisabled())),{};let s=e.cacheBehavior==="bypass";return await Promise.all([...t.values()].map(r=>r.cdpTarget.toggleSetCacheDisabled(s))),{}}#o(e){let t=this.#t.getRequestById(e);if(!t)throw new Le(`Network request with ID '${e}' doesn't exist`);return t}#a(e,t){let s=this.#o(e);if(!s.interceptPhase)throw new Le(`No blocked request found for network id '${e}'`);if(s.interceptPhase&&!t.includes(s.interceptPhase))throw new x(`Blocked request for network id '${e}' is in '${s.interceptPhase}' phase`);return s}static validateHeaders(e){for(let t of e){let s;if(t.value.type==="string"?s=t.value.value:s=atob(t.value.value),s!==s.trim()||s.includes(`
5
5
  `)||s.includes("\0"))throw new x(`Header value '${s}' is not acceptable value`)}}static isMethodValid(e){return/^[!#$%&'*+\-.^_`|~a-zA-Z\d]+$/.test(e)}static parseUrlString(e){try{return new URL(e)}catch(t){throw new x(`Invalid URL '${e}': ${t}`)}}static parseUrlPatterns(e){return e.map(t=>{let s="",r=!0,i=!0,o=!0,a=!0,c=!0;switch(t.type){case"string":{s=qe(t.pattern);break}case"pattern":{if(t.protocol===void 0)r=!1,s+="http";else{if(t.protocol==="")throw new x("URL pattern must specify a protocol");if(t.protocol=qe(t.protocol),!t.protocol.match(/^[a-zA-Z+-.]+$/))throw new x("Forbidden characters");s+=t.protocol}let u=s.toLocaleLowerCase();if(s+=":",xr(u)&&(s+="//"),t.hostname===void 0)u!=="file"&&(s+="placeholder"),i=!1;else{if(t.hostname==="")throw new x("URL pattern must specify a hostname");if(t.protocol==="file")throw new x("URL pattern protocol cannot be 'file'");t.hostname=qe(t.hostname);let l=!1;for(let y of t.hostname){if(y==="/"||y==="?"||y==="#")throw new x("'/', '?', '#' are forbidden in hostname");if(!l&&y===":")throw new x("':' is only allowed inside brackets in hostname");y==="["&&(l=!0),y==="]"&&(l=!1)}s+=t.hostname}if(t.port===void 0)o=!1;else{if(t.port==="")throw new x("URL pattern must specify a port");if(t.port=qe(t.port),s+=":",!t.port.match(/^\d+$/))throw new x("Forbidden characters");s+=t.port}if(t.pathname===void 0)a=!1;else{if(t.pathname=qe(t.pathname),t.pathname[0]!=="/"&&(s+="/"),t.pathname.includes("#")||t.pathname.includes("?"))throw new x("Forbidden characters");s+=t.pathname}if(t.search===void 0)c=!1;else{if(t.search=qe(t.search),t.search[0]!=="?"&&(s+="?"),t.search.includes("#"))throw new x("Forbidden characters");s+=t.search}break}}let d=u=>{let l={"ftp:":21,"file:":null,"http:":80,"https:":443,"ws:":80,"wss:":443};if(xr(u.protocol)&&l[u.protocol]!==null&&(!u.port||String(l[u.protocol])===u.port))return"";if(u.port)return u.port};try{let u=new URL(s);return{protocol:r?u.protocol.replace(/:$/,""):void 0,hostname:i?u.hostname:void 0,port:o?d(u):void 0,pathname:a&&u.pathname?u.pathname:void 0,search:c?u.search:void 0}}catch(u){throw new x(`${u.message} '${s}'`)}})}static wrapInterceptionError(e){return e?.message.includes("Invalid header")||e?.message.includes("Unsafe header")?new x(e.message):e}async addDataCollector(e){if(e.userContexts!==void 0&&e.contexts!==void 0)throw new x("'contexts' and 'userContexts' are mutually exclusive");if(e.userContexts!==void 0&&await this.#s.verifyUserContextIdList(e.userContexts),e.contexts!==void 0){for(let s of e.contexts)if(!this.#e.getContext(s).isTopLevelContext())throw new x("Data collectors are available only on top-level browsing contexts")}let t=this.#t.addDataCollector(e);return await this.#i(),{collector:t}}async getData(e){return await this.#t.getCollectedData(e)}async removeDataCollector(e){return this.#t.removeDataCollector(e),await this.#i(),{}}disownData(e){return this.#t.disownData(e),{}}async#d(e,t){if(e===void 0&&t===void 0)return this.#e.getTopLevelContexts();if(e!==void 0&&t!==void 0)throw new x("User contexts and browsing contexts are mutually exclusive");let s=[];if(t!==void 0){if(t.length===0)throw new x("user context should be provided");await this.#s.verifyUserContextIdList(t);for(let r of t){let i=this.#e.getTopLevelContexts().filter(o=>o.userContext===r);s.push(...i)}}if(e!==void 0){if(e.length===0)throw new x("browsing context should be provided");for(let r of e){let i=this.#e.getContext(r);if(!i.isTopLevelContext())throw new x("The command is only supported on the top-level context");s.push(i)}}return[...new Set(s).values()]}async setExtraHeaders(e){let t=await this.#d(e.contexts,e.userContexts),s=vo(e.headers);return e.userContexts===void 0&&e.contexts===void 0&&this.#r.updateGlobalConfig({extraHeaders:s}),e.userContexts!==void 0&&e.userContexts.forEach(r=>{this.#r.updateUserContextConfig(r,{extraHeaders:s})}),e.contexts!==void 0&&e.contexts.forEach(r=>{this.#r.updateBrowsingContextConfig(r,{extraHeaders:s})}),await Promise.all(t.map(async r=>{let i=this.#r.getActiveConfig(r.id,r.userContext).extraHeaders??{};await r.setExtraHeaders(i)})),{}}};function qe(n){let e=new Set(["(",")","*","{","}"]),t="",s=!1;for(let r of n){if(!s){if(e.has(r))throw new x("Forbidden characters");if(r==="\\"){s=!0;continue}}t+=r,s=!1}return t}var wo=new Set([" "," ",`