@heycys/gallery 0.1.2 → 0.2.1

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 (338) 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/embed/page.mjs +1 -1
  5. package/browser/editor/components/file/page.mjs +4 -4
  6. package/browser/editor/components/heading/index.mjs +7 -6
  7. package/browser/editor/components/icon/page.mjs +6 -4
  8. package/browser/editor/components/icons.mjs +5 -2
  9. package/browser/editor/components/image/index.mjs +2 -0
  10. package/browser/editor/components/image/page.mjs +172 -90
  11. package/browser/editor/components/installed/index.mjs +6 -2
  12. package/browser/editor/components/installed/page.mjs +80 -13
  13. package/browser/editor/components/media/icons.mjs +13 -8
  14. package/browser/editor/components/media/page.mjs +5 -3
  15. package/browser/editor/components/media/toolbar.mjs +12 -3
  16. package/browser/editor/components/paragraph/index.mjs +4 -3
  17. package/browser/editor/components/registry.mjs +17 -5
  18. package/browser/editor/components/table/index.mjs +4 -2
  19. package/browser/editor/page/after/index.mjs +288 -0
  20. package/browser/editor/page/align.mjs +91 -0
  21. package/browser/editor/page/beside.mjs +5 -6
  22. package/browser/editor/page/block-menu/index.mjs +6 -3
  23. package/browser/editor/page/blocks.mjs +3 -1
  24. package/browser/editor/page/board/hint.mjs +64 -27
  25. package/browser/editor/page/board/index.mjs +160 -71
  26. package/browser/editor/page/board/motion.mjs +177 -0
  27. package/browser/editor/page/board/settings.mjs +4 -3
  28. package/browser/editor/page/clipboard/import/read.mjs +20 -2
  29. package/browser/editor/page/clipboard/index.mjs +10 -3
  30. package/browser/editor/page/clipboard/own/blocks.mjs +3 -4
  31. package/browser/editor/page/clipboard/own/describe.mjs +6 -2
  32. package/browser/editor/page/commit.mjs +2 -2
  33. package/browser/editor/page/core.mjs +3 -1
  34. package/browser/editor/page/custom-page.mjs +15 -11
  35. package/browser/editor/page/editor.mjs +31 -14
  36. package/browser/editor/page/history.mjs +19 -4
  37. package/browser/editor/page/insert/index.mjs +20 -22
  38. package/browser/editor/page/menu.mjs +15 -7
  39. package/browser/editor/page/page-objects.mjs +3 -7
  40. package/browser/editor/page/present-links.mjs +5 -4
  41. package/browser/editor/page/present-shell.mjs +63 -0
  42. package/browser/editor/page/selection/index.mjs +10 -2
  43. package/browser/editor/page/table/binding.mjs +87 -0
  44. package/browser/editor/page/table/icons.mjs +0 -2
  45. package/browser/editor/page/table/index.mjs +10 -14
  46. package/browser/editor/page/table/views.mjs +5 -52
  47. package/browser/editor/page/table/widths.mjs +82 -10
  48. package/browser/editor/page/typing/index.mjs +44 -12
  49. package/browser/editor/page/typing/leave.mjs +19 -5
  50. package/browser/shared/block-packs.mjs +23 -8
  51. package/browser/shared/component-catalog.mjs +15 -8
  52. package/browser/shared/component-source.mjs +3 -1
  53. package/browser/shared/components/heading.mjs +2 -1
  54. package/browser/shared/components/installed.mjs +1 -1
  55. package/browser/shared/components/page.mjs +2 -0
  56. package/browser/shared/components/paragraph.mjs +8 -1
  57. package/browser/shared/components/table.mjs +1 -0
  58. package/browser/shared/document-copy.mjs +43 -0
  59. package/browser/shared/drafts.mjs +10 -3
  60. package/browser/shared/emoji/icon-value.mjs +2 -2
  61. package/browser/shared/emoji/line-icons.mjs +37 -0
  62. package/browser/shared/extensions.mjs +83 -7
  63. package/browser/shared/http.mjs +9 -0
  64. package/browser/shared/i18n/en.mjs +50 -17
  65. package/browser/shared/outline-shape.mjs +6 -0
  66. package/browser/shared/outline.mjs +165 -12
  67. package/browser/shared/pack-manifest.mjs +12 -1
  68. package/browser/shared/pages.mjs +169 -57
  69. package/browser/shared/pinyin.mjs +92 -0
  70. package/browser/shared/present-step.mjs +17 -0
  71. package/browser/shared/sidebar-head.mjs +70 -0
  72. package/browser/shared/web-links.mjs +5 -0
  73. package/browser/shared/workspace-columns.mjs +11 -7
  74. package/dist/{chunk-N7AZZLGT.mjs → chunk-2GKGEVMR.mjs} +29 -24
  75. package/dist/chunk-2OHANJ6Q.mjs +2 -0
  76. package/dist/{chunk-HYMEEXKN.mjs → chunk-2RKIHJI2.mjs} +1 -1
  77. package/dist/{chunk-742D2WWJ.mjs → chunk-36FIRJIF.mjs} +2 -2
  78. package/dist/{chunk-BPL64HGA.mjs → chunk-3A5I2GJK.mjs} +1 -1
  79. package/dist/{chunk-RFDZXFJF.mjs → chunk-3OFXMN6N.mjs} +1 -1
  80. package/dist/chunk-46ACXOU5.mjs +2 -0
  81. package/dist/{chunk-PUOQ65NC.mjs → chunk-4AMTKWDO.mjs} +1 -1
  82. package/dist/{chunk-VTKNEYT3.mjs → chunk-4DNHHJSL.mjs} +1 -1
  83. package/dist/chunk-5DPABPBI.mjs +2 -0
  84. package/dist/chunk-5IIH335D.mjs +3 -0
  85. package/dist/chunk-5L26JUYA.mjs +2 -0
  86. package/dist/{chunk-3NJACR4W.mjs → chunk-5MEXZ2UF.mjs} +1 -1
  87. package/dist/{chunk-ZHEHPMBK.mjs → chunk-6MPKCH3P.mjs} +1 -1
  88. package/dist/{chunk-C564NU2H.mjs → chunk-74RPP2M2.mjs} +1 -1
  89. package/dist/chunk-7M2BQQGZ.mjs +2 -0
  90. package/dist/{chunk-VXACTLO3.mjs → chunk-7M7UPWU6.mjs} +1 -1
  91. package/dist/{chunk-ZB4H7ZN4.mjs → chunk-7N2LPG33.mjs} +1 -1
  92. package/dist/{chunk-UBBRTJ2R.mjs → chunk-7XDYK3UC.mjs} +1 -1
  93. package/dist/chunk-AEMVZYZQ.mjs +166 -0
  94. package/dist/{chunk-POQSE4C2.mjs → chunk-AFGUR7SY.mjs} +1 -1
  95. package/dist/{chunk-QKXMPUXC.mjs → chunk-AMDGVDNV.mjs} +1 -1
  96. package/dist/{chunk-KTKHRC6H.mjs → chunk-ASAXY2DJ.mjs} +1 -1
  97. package/dist/{chunk-NVRNLK25.mjs → chunk-BYSF5UMM.mjs} +2 -2
  98. package/dist/{chunk-U3SSPL4K.mjs → chunk-CCSGFCLZ.mjs} +1 -1
  99. package/dist/{chunk-NWFBE2YA.mjs → chunk-CG3UHDKH.mjs} +1 -1
  100. package/dist/chunk-CPS4SRPF.mjs +5 -0
  101. package/dist/{chunk-B4P2CM2J.mjs → chunk-CZ5KJSGK.mjs} +1 -1
  102. package/dist/chunk-DAMVDXR3.mjs +2 -0
  103. package/dist/{chunk-NG375ILQ.mjs → chunk-DH6GMDNN.mjs} +1 -1
  104. package/dist/chunk-DHB7UZ7F.mjs +3 -0
  105. package/dist/{chunk-MHW7ZKOU.mjs → chunk-DKR7LFIY.mjs} +1 -1
  106. package/dist/chunk-DLFZJJEE.mjs +2 -0
  107. package/dist/{chunk-6EZ7FNIK.mjs → chunk-F4ZA6JRZ.mjs} +1 -1
  108. package/dist/{chunk-6VTU6KEO.mjs → chunk-FCK6NXON.mjs} +1 -1
  109. package/dist/{chunk-ZWPMCK7P.mjs → chunk-FX42XU6J.mjs} +1 -1
  110. package/dist/chunk-FXQBADMN.mjs +5 -0
  111. package/dist/{chunk-W3BGBJQW.mjs → chunk-G4YP7GVC.mjs} +1 -1
  112. package/dist/{chunk-V6XZ4VIR.mjs → chunk-GWOYMENX.mjs} +1 -1
  113. package/dist/chunk-HATA2W7X.mjs +2 -0
  114. package/dist/{chunk-YI43RG4P.mjs → chunk-HBAUKKQH.mjs} +1 -1
  115. package/dist/{chunk-MAFIGVXY.mjs → chunk-HM4E43VM.mjs} +1 -1
  116. package/dist/{chunk-CRJEG7MT.mjs → chunk-JI6T3A4Y.mjs} +1 -1
  117. package/dist/{chunk-NFMCP2HI.mjs → chunk-JJNRIFND.mjs} +2 -2
  118. package/dist/chunk-JL6R4FG4.mjs +4 -0
  119. package/dist/{chunk-UMHUSOPJ.mjs → chunk-JXLSHVJ2.mjs} +1 -1
  120. package/dist/{chunk-FJYN7RTH.mjs → chunk-KFZBYDIS.mjs} +1 -1
  121. package/dist/{chunk-ZTHICSSF.mjs → chunk-KH24LWAT.mjs} +1 -1
  122. package/dist/{chunk-RKPWLGZ3.mjs → chunk-KUILYI7H.mjs} +1 -1
  123. package/dist/{chunk-RMECZA2K.mjs → chunk-L7W624FD.mjs} +1 -1
  124. package/dist/chunk-LE44MD3O.mjs +4 -0
  125. package/dist/{chunk-4K5KC6V2.mjs → chunk-LV24RY2E.mjs} +1 -1
  126. package/dist/{chunk-43B75J5T.mjs → chunk-MKTX5PGV.mjs} +1 -1
  127. package/dist/{chunk-LKX55H76.mjs → chunk-NAGMRVW4.mjs} +1 -1
  128. package/dist/{chunk-D4CKRD3V.mjs → chunk-NFABH3QW.mjs} +2 -2
  129. package/dist/{chunk-PVER7LSC.mjs → chunk-NIW7F7LU.mjs} +2 -2
  130. package/dist/{chunk-PAREWQGB.mjs → chunk-NWRZXELO.mjs} +1 -1
  131. package/dist/{chunk-OJKMINIU.mjs → chunk-OU3S466R.mjs} +15 -15
  132. package/dist/{chunk-5ZJA7CXT.mjs → chunk-PAFSFVYB.mjs} +1 -1
  133. package/dist/chunk-QCEATQC4.mjs +2 -0
  134. package/dist/{chunk-Y34NR5JL.mjs → chunk-QJ3TFJLQ.mjs} +1 -1
  135. package/dist/{chunk-IA4PSIMD.mjs → chunk-QK3VISCA.mjs} +1 -1
  136. package/dist/{chunk-ZUNVAXLH.mjs → chunk-QXVNUASA.mjs} +1 -1
  137. package/dist/{chunk-GRAXKKG4.mjs → chunk-QZ35UAB4.mjs} +1 -1
  138. package/dist/{chunk-UGWYKHBL.mjs → chunk-S2Y7VI4H.mjs} +2 -2
  139. package/dist/{chunk-OW5NWPOJ.mjs → chunk-SAHS56QM.mjs} +1 -1
  140. package/dist/{chunk-QOUEFUCH.mjs → chunk-SOD23RGL.mjs} +1 -1
  141. package/dist/chunk-TDWJKOLN.mjs +2 -0
  142. package/dist/{chunk-V6RIYQZZ.mjs → chunk-TOE6DPLH.mjs} +1 -1
  143. package/dist/chunk-UGO5N3EI.mjs +15 -0
  144. package/dist/{chunk-Q47PLKIJ.mjs → chunk-UGWMMEJ5.mjs} +1 -1
  145. package/dist/{chunk-NWR2LT5B.mjs → chunk-V5JRSGZF.mjs} +1 -1
  146. package/dist/{chunk-BZ5RAF7L.mjs → chunk-VA3KAQZD.mjs} +1 -1
  147. package/dist/chunk-VG5JEIUQ.mjs +12 -0
  148. package/dist/{chunk-UNOYVIYR.mjs → chunk-VGTMLQWZ.mjs} +1 -1
  149. package/dist/chunk-VKSRM7EY.mjs +22 -0
  150. package/dist/{chunk-YQGT4AB2.mjs → chunk-VNUWREXU.mjs} +1 -1
  151. package/dist/{chunk-AGDILNWB.mjs → chunk-VPVOAJ7X.mjs} +1 -1
  152. package/dist/{chunk-HLYV7RIH.mjs → chunk-WCWYNFDF.mjs} +1 -1
  153. package/dist/chunk-WTEGUPFG.mjs +16 -0
  154. package/dist/{chunk-N76HWBA3.mjs → chunk-XKOHV4H6.mjs} +1 -1
  155. package/dist/{chunk-HMYTM3GT.mjs → chunk-XMKHCUI6.mjs} +1 -1
  156. package/dist/{chunk-OUUP3WKT.mjs → chunk-XQRUG4G3.mjs} +1 -1
  157. package/dist/{chunk-32ZUEFZ7.mjs → chunk-YBB5LWZK.mjs} +1 -1
  158. package/dist/{chunk-SX4LJYT6.mjs → chunk-YFJU3O7G.mjs} +1 -1
  159. package/dist/chunk-YPPJVDQI.mjs +2 -0
  160. package/dist/chunk-ZANMKAWS.mjs +2 -0
  161. package/dist/{chunk-6QBHU4DF.mjs → chunk-ZCP7BTOZ.mjs} +1 -1
  162. package/dist/{chunk-ERLAIBOA.mjs → chunk-ZEY2RLBT.mjs} +2 -2
  163. package/dist/{chunk-SQ6Y2ZMA.mjs → chunk-ZO7SFB2E.mjs} +2 -2
  164. package/dist/cli.mjs +1 -1
  165. package/dist/server.mjs +1 -1
  166. package/dist/worker.mjs +1 -1
  167. package/kit/board.css +5 -5
  168. package/kit/code.js +15 -15
  169. package/kit/math.js +1 -1
  170. package/kit/report.css +123 -44
  171. package/kit/runtime.js +45 -7
  172. package/kit/tables.js +2 -0
  173. package/kit/ui.js +2 -0
  174. package/package.json +1 -1
  175. package/packs/gallery/chart-view/kit.js +3 -3
  176. package/packs/gallery/chart-view/writing.md +1 -1
  177. package/packs/gallery/countdown/component.json +1 -1
  178. package/packs/gallery/countdown/kit.js +89 -29
  179. package/packs/gallery/countdown/preview.svg +1 -1
  180. package/packs/gallery/countdown/style.css +88 -100
  181. package/packs/gallery/countdown/writing.md +2 -2
  182. package/packs/gallery/habit/component.json +3 -3
  183. package/packs/gallery/habit/kit.js +114 -75
  184. package/packs/gallery/habit/preview.svg +1 -1
  185. package/packs/gallery/habit/style.css +133 -205
  186. package/packs/gallery/habit/writing.md +2 -2
  187. package/packs/gallery/heatmap/component.json +2 -2
  188. package/packs/gallery/heatmap/kit.js +335 -173
  189. package/packs/gallery/heatmap/preview.svg +1 -1
  190. package/packs/gallery/heatmap/style.css +158 -170
  191. package/packs/gallery/heatmap/writing.md +2 -2
  192. package/packs/gallery/kanban/kit.js +3 -3
  193. package/packs/gallery/kanban/writing.md +1 -1
  194. package/packs/gallery/metric/kit.js +3 -3
  195. package/packs/gallery/metric/writing.md +1 -1
  196. package/packs/gallery/note/component.json +3 -3
  197. package/packs/gallery/note/kit.js +40 -13
  198. package/packs/gallery/note/preview.svg +1 -1
  199. package/packs/gallery/note/style.css +51 -30
  200. package/packs/gallery/note/writing.md +2 -2
  201. package/packs/gallery/recent/component.json +2 -2
  202. package/packs/gallery/recent/kit.js +141 -86
  203. package/packs/gallery/recent/preview.svg +1 -1
  204. package/packs/gallery/recent/style.css +53 -126
  205. package/packs/gallery/recent/writing.md +2 -2
  206. package/packs/gallery/static/component.json +2 -2
  207. package/packs/gallery/static/preview.svg +1 -1
  208. package/packs/gallery/static/style.css +99 -66
  209. package/packs/gallery/static/writing.md +2 -2
  210. package/packs/gallery/stats/component.json +3 -3
  211. package/packs/gallery/stats/kit.js +253 -72
  212. package/packs/gallery/stats/preview.svg +1 -1
  213. package/packs/gallery/stats/style.css +64 -142
  214. package/packs/gallery/stats/writing.md +2 -2
  215. package/packs/gallery/today/component.json +2 -2
  216. package/packs/gallery/today/kit.js +62 -27
  217. package/packs/gallery/today/preview.svg +1 -1
  218. package/packs/gallery/today/style.css +101 -72
  219. package/packs/gallery/today/writing.md +2 -2
  220. package/packs/gallery/todos/component.json +1 -1
  221. package/packs/gallery/todos/kit.js +218 -71
  222. package/packs/gallery/todos/preview.svg +1 -1
  223. package/packs/gallery/todos/style.css +170 -223
  224. package/packs/gallery/todos/writing.md +1 -1
  225. package/packs/gallery/weather/component.json +2 -2
  226. package/packs/gallery/weather/kit.js +165 -90
  227. package/packs/gallery/weather/preview.svg +1 -1
  228. package/packs/gallery/weather/style.css +100 -218
  229. package/packs/gallery/weather/writing.md +1 -1
  230. package/packs/gallery-soft/countdown/component.json +18 -0
  231. package/packs/gallery-soft/countdown/example.html +3 -0
  232. package/packs/gallery-soft/countdown/kit.js +206 -0
  233. package/packs/gallery-soft/countdown/preview.svg +1 -0
  234. package/packs/gallery-soft/countdown/style.css +211 -0
  235. package/packs/gallery-soft/countdown/template.html +3 -0
  236. package/packs/gallery-soft/countdown/writing.md +24 -0
  237. package/packs/gallery-soft/habit/component.json +14 -0
  238. package/packs/gallery-soft/habit/example.html +3 -0
  239. package/packs/gallery-soft/habit/kit.js +366 -0
  240. package/packs/gallery-soft/habit/preview.svg +1 -0
  241. package/packs/gallery-soft/habit/style.css +251 -0
  242. package/packs/gallery-soft/habit/template.html +3 -0
  243. package/packs/gallery-soft/habit/writing.md +23 -0
  244. package/packs/gallery-soft/heatmap/component.json +18 -0
  245. package/packs/gallery-soft/heatmap/example.html +3 -0
  246. package/packs/gallery-soft/heatmap/kit.js +498 -0
  247. package/packs/gallery-soft/heatmap/preview.svg +1 -0
  248. package/packs/gallery-soft/heatmap/style.css +181 -0
  249. package/packs/gallery-soft/heatmap/template.html +3 -0
  250. package/packs/gallery-soft/heatmap/writing.md +23 -0
  251. package/packs/gallery-soft/note/component.json +14 -0
  252. package/packs/gallery-soft/note/example.html +3 -0
  253. package/packs/gallery-soft/note/kit.js +162 -0
  254. package/packs/gallery-soft/note/preview.svg +1 -0
  255. package/packs/gallery-soft/note/style.css +148 -0
  256. package/packs/gallery-soft/note/template.html +3 -0
  257. package/packs/gallery-soft/note/writing.md +20 -0
  258. package/packs/gallery-soft/recent/component.json +13 -0
  259. package/packs/gallery-soft/recent/example.html +1 -0
  260. package/packs/gallery-soft/recent/kit.js +335 -0
  261. package/packs/gallery-soft/recent/preview.svg +1 -0
  262. package/packs/gallery-soft/recent/style.css +160 -0
  263. package/packs/gallery-soft/recent/template.html +1 -0
  264. package/packs/gallery-soft/recent/writing.md +17 -0
  265. package/packs/gallery-soft/static/component.json +13 -0
  266. package/packs/gallery-soft/static/example.html +12 -0
  267. package/packs/gallery-soft/static/preview.svg +1 -0
  268. package/packs/gallery-soft/static/style.css +186 -0
  269. package/packs/gallery-soft/static/template.html +1 -0
  270. package/packs/gallery-soft/static/writing.md +20 -0
  271. package/packs/gallery-soft/stats/component.json +13 -0
  272. package/packs/gallery-soft/stats/example.html +1 -0
  273. package/packs/gallery-soft/stats/kit.js +341 -0
  274. package/packs/gallery-soft/stats/preview.svg +1 -0
  275. package/packs/gallery-soft/stats/style.css +119 -0
  276. package/packs/gallery-soft/stats/template.html +1 -0
  277. package/packs/gallery-soft/stats/writing.md +13 -0
  278. package/packs/gallery-soft/today/component.json +12 -0
  279. package/packs/gallery-soft/today/example.html +1 -0
  280. package/packs/gallery-soft/today/kit.js +222 -0
  281. package/packs/gallery-soft/today/preview.svg +1 -0
  282. package/packs/gallery-soft/today/style.css +178 -0
  283. package/packs/gallery-soft/today/template.html +1 -0
  284. package/packs/gallery-soft/today/writing.md +16 -0
  285. package/packs/gallery-soft/todos/component.json +19 -0
  286. package/packs/gallery-soft/todos/example.html +3 -0
  287. package/packs/gallery-soft/todos/kit.js +527 -0
  288. package/packs/gallery-soft/todos/preview.svg +1 -0
  289. package/packs/gallery-soft/todos/style.css +212 -0
  290. package/packs/gallery-soft/todos/template.html +3 -0
  291. package/packs/gallery-soft/todos/writing.md +32 -0
  292. package/packs/gallery-soft/weather/component.json +19 -0
  293. package/packs/gallery-soft/weather/example.html +3 -0
  294. package/packs/gallery-soft/weather/kit.js +411 -0
  295. package/packs/gallery-soft/weather/preview.svg +1 -0
  296. package/packs/gallery-soft/weather/style.css +185 -0
  297. package/packs/gallery-soft/weather/template.html +3 -0
  298. package/packs/gallery-soft/weather/writing.md +28 -0
  299. package/release.json +10 -10
  300. package/skill/SKILL.md +15 -14
  301. package/skill/references/building-blocks.md +4 -4
  302. package/skill/references/extensions.md +11 -7
  303. package/skill/references/pages-and-data.md +13 -9
  304. package/skill/references/writing-html.md +2 -0
  305. package/web/assets/index-BHC5ZOMh.js +15 -0
  306. package/web/assets/index-xP0uw3a0.css +1 -0
  307. package/web/index.html +2 -2
  308. package/dist/chunk-2NRBY6AJ.mjs +0 -2
  309. package/dist/chunk-35NQ4PLQ.mjs +0 -2
  310. package/dist/chunk-3KJHLHUO.mjs +0 -2
  311. package/dist/chunk-4AV456RQ.mjs +0 -2
  312. package/dist/chunk-5XYHDBJ5.mjs +0 -2
  313. package/dist/chunk-6A53MZYZ.mjs +0 -2
  314. package/dist/chunk-6EXH3ORZ.mjs +0 -166
  315. package/dist/chunk-BVEFGE4B.mjs +0 -2
  316. package/dist/chunk-D4EURAX4.mjs +0 -4
  317. package/dist/chunk-DQCE7TJY.mjs +0 -5
  318. package/dist/chunk-FWNRPMCJ.mjs +0 -12
  319. package/dist/chunk-FWW4CSAZ.mjs +0 -2
  320. package/dist/chunk-GY3FAUVM.mjs +0 -2
  321. package/dist/chunk-JVHHHGEA.mjs +0 -3
  322. package/dist/chunk-L7UP52JO.mjs +0 -2
  323. package/dist/chunk-NAMN3RAF.mjs +0 -2
  324. package/dist/chunk-PZDLJJTJ.mjs +0 -3
  325. package/dist/chunk-SXHBYZST.mjs +0 -16
  326. package/dist/chunk-TEZAWDSQ.mjs +0 -2
  327. package/dist/chunk-UFNYFFKO.mjs +0 -20
  328. package/dist/chunk-UKSHDZZ6.mjs +0 -2
  329. package/dist/chunk-VJPFVNNW.mjs +0 -15
  330. package/dist/chunk-VS3ZMVGX.mjs +0 -5
  331. package/web/assets/index-BK2e_07w.js +0 -13
  332. package/web/assets/index-CWFI83mF.css +0 -1
  333. /package/dist/{chunk-YEY3RSFQ.mjs → chunk-5MMN3N5J.mjs} +0 -0
  334. /package/dist/{chunk-UH4SIXTR.mjs → chunk-74UW7QSL.mjs} +0 -0
  335. /package/dist/{chunk-W7XHE4CT.mjs → chunk-EKGYYOSP.mjs} +0 -0
  336. /package/dist/{chunk-QAIHRH3I.mjs → chunk-KNZJT4ET.mjs} +0 -0
  337. /package/dist/{chunk-A55HN5OK.mjs → chunk-N3DSBH5S.mjs} +0 -0
  338. /package/dist/{chunk-QR6A54KJ.mjs → chunk-ZW2A6GBW.mjs} +0 -0
@@ -1,6 +1,6 @@
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 re,J as ae,K as ne,O as ie,P as ce,a as C,b as Q,c as F,g as X,h as Z,n as D,o as ee,r as te,s as se,t as oe}from"./chunk-RFDZXFJF.mjs";import{j as K}from"./chunk-QOUEFUCH.mjs";import{d as le}from"./chunk-6A53MZYZ.mjs";import{i as q}from"./chunk-NFMCP2HI.mjs";import{a as L}from"./chunk-JEUK3ZO7.mjs";import{a as M,b as z,g as J}from"./chunk-PUOQ65NC.mjs";import{b as x,c as T}from"./chunk-UFNYFFKO.mjs";import{b as E}from"./chunk-4OZWXZE5.mjs";import{f as H,j as Y}from"./chunk-FWNRPMCJ.mjs";import{b as V,e as pe}from"./chunk-A55HN5OK.mjs";pe();import N from"node:fs/promises";import P from"node:path";import{isInstance as ge}from"../browser/shared/components/index.mjs";import{ATTRIBUTE as me}from"../browser/shared/components/installed.mjs";import{attr as we,walk as $e}from"../browser/shared/html-tree.mjs";import{pageExists as ye,pageFiles as be}from"../browser/shared/pages.mjs";import{layoutOf as Ee}from"../browser/shared/workspace.mjs";var xe="card ids aside",ke="nothing else in page.html changed (card ids aside)",Se=e=>new Promise(s=>setTimeout(s,e)),Te=/^\/__gallery\/pages\/[a-z0-9-]+\/cards$/,de=e=>{let s=null;return $e(V(e,{sourceCodeLocationInfo:!0}),n=>{s??=ge(n)?n:null},{inTemplates:!1}),s},fe=(e,s)=>{let n=s.node.sourceCodeLocation.startTag.endOffset;return{frame:e.slice(s.start,n).replace(/\s+data-[xywh]="[^"]*"/g,""),rest:e.slice(n,s.end)}};function Ce(e,s,n,a){let[o,d]=[x(e).cards,x(s).cards],c=[],t=r=>`card ${r.id}${r.block?` (${r.block})`:""}`,l=r=>["x","y","w","h"].map(i=>`${i} ${we(r.node,`data-${i}`)??"-"}`).join(", ");for(let r of o){let i=d.find(g=>g.id===r.id);if(!i){c.push(`${t(r)} taken out`);continue}let m=r.board!==i.board;(m||l(r)!==l(i))&&c.push(`${t(r)}'s place, ${l(r)}${m?` on ${r.board}`:""} then ${l(i)}${m?` on ${i.board}`:""}`);let[h,p]=[fe(e,r),fe(s,i)];if(h.frame===p.frame&&h.rest===p.rest)continue;if(r.id!==n){c.push(t(r));continue}h.frame!==p.frame&&c.push(`${t(r)}'s own frame (an attribute of its <section> but its place)`);let[f,$]=[D(h.rest,de,a),D(p.rest,de,a)];!f||!$?c.push(`${t(r)}'s instance`):f.outside!==$.outside&&c.push(`${t(r)} itself, outside its data parts (a part edited as text or none, or what its instance holds besides its parts)`)}for(let r of d)o.some(i=>i.id===r.id)||c.push(`a ${t(r)} put in`);let w=(r,i)=>{let m="",h=0;for(let p of[...i].sort((f,$)=>f.start-$.start))m+=r.slice(h,p.start),h=p.end;return(m+r.slice(h)).replace(/\s+/g," ")};return(w(e,o)!==w(s,d)||!c.length)&&c.push("the page's own HTML outside its cards (its head, its style, its header)"),c.join("; ")}function Ie(e,s,{card:n,found:a}){let[o,d]=[T(e).text,T(s).text],t=ee(o,d,l=>x(l).cards.find(w=>w.id===n)?.instance??null,a);return t.outside&&(t.outside={...t.outside,what:Ce(o,d,n,a)}),t}async function Oe(e){try{return await e.waitForSelector("[data-doc-ready]",{timeout:C}).catch(s=>{if(s.name==="TimeoutError")throw s;return e.waitForSelector("[data-doc-ready]",{timeout:C})}),await e.waitForFunction(()=>globalThis.__galleryTryEditable===!0&&!!document.querySelector("script[data-ge-page]"),{timeout:C}),!0}catch(s){if(s.name!=="TimeoutError")throw s;return!1}}function ve(e){return e?.startsWith("stopped")?`the page service refused the board's write (${e.slice(7).trim()||"no reason given"}), and the page showed itself again as the file holds it`:{refused:"the page service refused the board's write: the card was changed or taken out meanwhile (someone else's write of page.html), and the page showed itself again as the file holds it",offline:"the page could not reach the server (offline)",reloading:"the page loaded itself again (page.html or a custom block it holds changed meanwhile, or the page service refused a write)",syncing:`its write took more than ${F/1e3}s to be answered`}[e]}function Ae(e){let s=[],n=new Map;return e.on("request",a=>{if(a.method()!=="POST"||!Te.test(new URL(a.url()).pathname))return;let o={done:!1,status:null,answer:null,failed:null};s.push(o),n.set(a,o)}),e.on("response",a=>{let o=n.get(a.request());o&&(o.status=a.status(),o.done=!0,o.status!==200&&a.json().then(d=>{o.answer=d},()=>{}))}),e.on("requestfailed",a=>{let o=n.get(a);o&&(o.failed=a.failure()?.errorText??"failed",o.done=!0)}),{mark:async()=>s.length,async until(a){let o=Date.now();for(let d=0;;await Se(100)){let c=s.slice(a);if(c.length===0){if(Date.now()-o>Q)return"unchanged";continue}if(c.some(l=>!l.done)){if(d=0,Date.now()-o>F)return"syncing";continue}if(++d<4)continue;if(c.some(l=>l.failed))return"offline";let t=c.find(l=>l.status!==200);return t?t.answer?.refused||t.status===409&&!t.answer?"refused":`stopped ${t.answer?.reason??`HTTP ${t.status}`}`:"saved"}}}}function Re({card:e,found:s}){let n={...s,parts:Object.fromEntries(Object.entries(s.parts).filter(([,a])=>a.edit==="data"))};return{where:{card:e},ready:Oe,saves:Ae,changes:(a,o)=>Ie(a,o,{card:e,found:n}),plain:()=>!1,stayed:ve,outside:"problem",outsideSaid:a=>`card ${e}'s data parts: ${a.what}, where a reader's gesture on the card is to change its data parts alone`,aside:xe,inside:ke,framed:a=>a.closest(".gallery-card")??a}}var Le=e=>` ${e.id} ${e.block??"(no instance)"} x ${e.x}, y ${e.y}, w ${e.w}, h ${e.h}${e.board?` on board ${e.board}`:""}`;async function Ke(e,{named:s,values:n,seconds:a={},keep:o,replace:d=!1}){if(s.length===0)throw new E("Name the page and the card: gallery page try <slug> <card id> and the gesture.");if(s.length===1)throw new E(`Name the card of ${s[0]} to try: gallery page try ${s[0]} <card id> and the gesture (its data-card-id; gallery page check ${s[0]} lists the cards).`);if(s.length>2)throw new E("gallery page try takes a page's slug and a card's id.");let c=await X(n,a,d),[t,l]=s,w=n.has("--steps")?P.resolve(n.get("--steps")):null,r=c?[c]:await Z(w),i=be(t,e);ye(t,e)||(console.error(await le(t,e)),process.exit(1));let m=await N.readFile(i.html,"utf8"),{cards:h}=x(T(m).text),p=h.find(u=>u.id===l);if(!p)throw new E(h.length?`${t} has no card ${l}: its cards are
2
+ import{E as re,J as ae,K as ne,O as ie,P as ce,a as C,b as Q,c as F,g as X,h as Z,n as D,o as ee,r as te,s as se,t as oe}from"./chunk-3OFXMN6N.mjs";import{j as K}from"./chunk-SOD23RGL.mjs";import{d as le}from"./chunk-5L26JUYA.mjs";import{i as q}from"./chunk-JJNRIFND.mjs";import{a as L}from"./chunk-JEUK3ZO7.mjs";import{a as M,b as z,g as J}from"./chunk-4AMTKWDO.mjs";import{b as x,c as T}from"./chunk-VKSRM7EY.mjs";import{b as E}from"./chunk-4OZWXZE5.mjs";import{f as H,j as Y}from"./chunk-VG5JEIUQ.mjs";import{b as V,e as pe}from"./chunk-N3DSBH5S.mjs";pe();import N from"node:fs/promises";import P from"node:path";import{isInstance as ge}from"../browser/shared/components/index.mjs";import{ATTRIBUTE as me}from"../browser/shared/components/installed.mjs";import{attr as we,walk as $e}from"../browser/shared/html-tree.mjs";import{pageExists as ye,pageFiles as be}from"../browser/shared/pages.mjs";import{layoutOf as Ee}from"../browser/shared/workspace.mjs";var xe="card ids aside",ke="nothing else in page.html changed (card ids aside)",Se=e=>new Promise(s=>setTimeout(s,e)),Te=/^\/__gallery\/pages\/[a-z0-9-]+\/cards$/,de=e=>{let s=null;return $e(V(e,{sourceCodeLocationInfo:!0}),n=>{s??=ge(n)?n:null},{inTemplates:!1}),s},fe=(e,s)=>{let n=s.node.sourceCodeLocation.startTag.endOffset;return{frame:e.slice(s.start,n).replace(/\s+data-[xywh]="[^"]*"/g,""),rest:e.slice(n,s.end)}};function Ce(e,s,n,a){let[o,d]=[x(e).cards,x(s).cards],c=[],t=r=>`card ${r.id}${r.block?` (${r.block})`:""}`,l=r=>["x","y","w","h"].map(i=>`${i} ${we(r.node,`data-${i}`)??"-"}`).join(", ");for(let r of o){let i=d.find(g=>g.id===r.id);if(!i){c.push(`${t(r)} taken out`);continue}let m=r.board!==i.board;(m||l(r)!==l(i))&&c.push(`${t(r)}'s place, ${l(r)}${m?` on ${r.board}`:""} then ${l(i)}${m?` on ${i.board}`:""}`);let[h,p]=[fe(e,r),fe(s,i)];if(h.frame===p.frame&&h.rest===p.rest)continue;if(r.id!==n){c.push(t(r));continue}h.frame!==p.frame&&c.push(`${t(r)}'s own frame (an attribute of its <section> but its place)`);let[f,$]=[D(h.rest,de,a),D(p.rest,de,a)];!f||!$?c.push(`${t(r)}'s instance`):f.outside!==$.outside&&c.push(`${t(r)} itself, outside its data parts (a part edited as text or none, or what its instance holds besides its parts)`)}for(let r of d)o.some(i=>i.id===r.id)||c.push(`a ${t(r)} put in`);let w=(r,i)=>{let m="",h=0;for(let p of[...i].sort((f,$)=>f.start-$.start))m+=r.slice(h,p.start),h=p.end;return(m+r.slice(h)).replace(/\s+/g," ")};return(w(e,o)!==w(s,d)||!c.length)&&c.push("the page's own HTML outside its cards (its head, its style, its header)"),c.join("; ")}function Ie(e,s,{card:n,found:a}){let[o,d]=[T(e).text,T(s).text],t=ee(o,d,l=>x(l).cards.find(w=>w.id===n)?.instance??null,a);return t.outside&&(t.outside={...t.outside,what:Ce(o,d,n,a)}),t}async function Oe(e){try{return await e.waitForSelector("[data-doc-ready]",{timeout:C}).catch(s=>{if(s.name==="TimeoutError")throw s;return e.waitForSelector("[data-doc-ready]",{timeout:C})}),await e.waitForFunction(()=>globalThis.__galleryTryEditable===!0&&!!document.querySelector("script[data-ge-page]"),{timeout:C}),!0}catch(s){if(s.name!=="TimeoutError")throw s;return!1}}function ve(e){return e?.startsWith("stopped")?`the page service refused the board's write (${e.slice(7).trim()||"no reason given"}), and the page showed itself again as the file holds it`:{refused:"the page service refused the board's write: the card was changed or taken out meanwhile (someone else's write of page.html), and the page showed itself again as the file holds it",offline:"the page could not reach the server (offline)",reloading:"the page loaded itself again (page.html or a custom block it holds changed meanwhile, or the page service refused a write)",syncing:`its write took more than ${F/1e3}s to be answered`}[e]}function Ae(e){let s=[],n=new Map;return e.on("request",a=>{if(a.method()!=="POST"||!Te.test(new URL(a.url()).pathname))return;let o={done:!1,status:null,answer:null,failed:null};s.push(o),n.set(a,o)}),e.on("response",a=>{let o=n.get(a.request());o&&(o.status=a.status(),o.done=!0,o.status!==200&&a.json().then(d=>{o.answer=d},()=>{}))}),e.on("requestfailed",a=>{let o=n.get(a);o&&(o.failed=a.failure()?.errorText??"failed",o.done=!0)}),{mark:async()=>s.length,async until(a){let o=Date.now();for(let d=0;;await Se(100)){let c=s.slice(a);if(c.length===0){if(Date.now()-o>Q)return"unchanged";continue}if(c.some(l=>!l.done)){if(d=0,Date.now()-o>F)return"syncing";continue}if(++d<4)continue;if(c.some(l=>l.failed))return"offline";let t=c.find(l=>l.status!==200);return t?t.answer?.refused||t.status===409&&!t.answer?"refused":`stopped ${t.answer?.reason??`HTTP ${t.status}`}`:"saved"}}}}function Re({card:e,found:s}){let n={...s,parts:Object.fromEntries(Object.entries(s.parts).filter(([,a])=>a.edit==="data"))};return{where:{card:e},ready:Oe,saves:Ae,changes:(a,o)=>Ie(a,o,{card:e,found:n}),plain:()=>!1,stayed:ve,outside:"problem",outsideSaid:a=>`card ${e}'s data parts: ${a.what}, where a reader's gesture on the card is to change its data parts alone`,aside:xe,inside:ke,framed:a=>a.closest(".gallery-card")??a}}var Le=e=>` ${e.id} ${e.block??"(no instance)"} x ${e.x}, y ${e.y}, w ${e.w}, h ${e.h}${e.board?` on board ${e.board}`:""}`;async function Ke(e,{named:s,values:n,seconds:a={},keep:o,replace:d=!1}){if(s.length===0)throw new E("Name the page and the card: gallery page try <slug> <card id> and the gesture.");if(s.length===1)throw new E(`Name the card of ${s[0]} to try: gallery page try ${s[0]} <card id> and the gesture (its data-card-id; gallery page check ${s[0]} lists the cards).`);if(s.length>2)throw new E("gallery page try takes a page's slug and a card's id.");let c=await X(n,a,d),[t,l]=s,w=n.has("--steps")?P.resolve(n.get("--steps")):null,r=c?[c]:await Z(w),i=be(t,e);ye(t,e)||(console.error(await le(t,e)),process.exit(1));let m=await N.readFile(i.html,"utf8"),{cards:h}=x(T(m).text),p=h.find(u=>u.id===l);if(!p)throw new E(h.length?`${t} has no card ${l}: its cards are
3
3
  ${h.map(Le).join(`
4
- `)}`:`${t} has no card yet: gallery page add ${t} <block> puts one on it.`);let f=P.basename(i.html),$=p.node.sourceCodeLocation?.startLine??null;p.instance||(console.error(`Card ${l} of ${t} (${f}:${$}) holds no instance of a custom block (an element with ${me}): there is nothing on it to try.`),process.exit(1));let g=p.block,_=H(e),k=_.packages.get(g);if(!k){let u=_.problems.get(g);console.error(u?.off?`${g} is turned off in \u8BBE\u7F6E \u203A \u7EC4\u4EF6\u5217\u8868: its card says so on the page and runs nothing.`:u?`${g} does not load (${Y("en",u.problem)}), so its card runs nothing: gallery block check ${g} says why.`:`No custom block ${g} in this workspace, so its card runs nothing: gallery block list says which there are${g.startsWith("gallery/")?`, and gallery block add ${g.slice(8)} puts one of Gallery's own in`:""}.`),process.exit(1)}k.places.includes("page")||(console.error(`${g} is a block of documents (its manifest's places has no "page"): on a custom page its card says so and runs nothing, so there is nothing to try there (gallery block try tries it in a document).`),process.exit(1)),console.log(`${g} in card ${l} of ${t}, at ${f}:${$}: ${L(i.html)}`),w&&console.log(`Steps: ${r.length} from ${L(w)}, made one after another in one page`);let S=await q({command:`gallery page try ${t}`});if(!S.ok){console.log(`UNVERIFIED ${t}: ${S.message}`),process.exitCode=3;return}let{pageAloneOf:j}=await import("./chunk-2NRBY6AJ.mjs");await oe(e);let B=[],G=async u=>{let b=await te(e,{directory:i.folder,files:i,text:u});return B.push(b.slug),b},I=Re({card:l,found:k});try{let u=o?{slug:t,file:i.html}:await G(m),b=j(S.port,u.slug);console.log(o?`Page: ${b} (the custom page alone, editable: the Agent's own; --keep: what ${re(r)} write stays in ${f}, and every page open on it shows it, the user's too; the server runs on after this command)`:`Page: ${b} (a scratch copy of ${t}, its page alone, editable, made for this trial and gone at its end: ${f} is not written, and no page of the user's shows the trial; the server runs on after this command)`);let O=M();if(!O){console.log(`UNVERIFIED ${t}: no Chrome, Edge or Chromium found (GALLERY_BROWSER=<its executable> picks one), so nothing was tried`),process.exitCode=3;return}let v;try{v=await J({executablePath:O,args:z()})}catch(R){console.log(`UNVERIFIED ${t}: the browser ${O} did not start, twice, each time with a fresh profile (${K(R)}; GALLERY_BROWSER=<its executable> picks another), so nothing was tried`),process.exitCode=3;return}let A=P.join(Ee(e).qa,t,"try");try{await N.rm(A,{recursive:!0,force:!0}),await N.mkdir(A,{recursive:!0});let R=async y=>{if(o)return{address:b,file:u.file};let W=await G(y);return{address:j(S.port,W.slug),file:W.file}},U;try{U=await ae(v.browser,{root:e,address:b,fresh:R,steps:r,keep:o,file:u.file,name:f,line:$,found:k,out:A,host:I})}catch(y){if(y instanceof E&&y.made&&console.log(ce({name:f,steps:r,keep:o,host:I},y.made).join(`
4
+ `)}`:`${t} has no card yet: gallery page add ${t} <block> puts one on it.`);let f=P.basename(i.html),$=p.node.sourceCodeLocation?.startLine??null;p.instance||(console.error(`Card ${l} of ${t} (${f}:${$}) holds no instance of a custom block (an element with ${me}): there is nothing on it to try.`),process.exit(1));let g=p.block,_=H(e),k=_.packages.get(g);if(!k){let u=_.problems.get(g);console.error(u?.off?`${g} is turned off in \u8BBE\u7F6E \u203A \u7EC4\u4EF6\u5217\u8868: its card says so on the page and runs nothing.`:u?`${g} does not load (${Y("en",u.problem)}), so its card runs nothing: gallery block check ${g} says why.`:`No custom block ${g} in this workspace, so its card runs nothing: gallery block list says which there are${g.startsWith("gallery/")?`, and gallery block add ${g.slice(8)} puts one of Gallery's own in`:""}.`),process.exit(1)}k.places.includes("page")||(console.error(`${g} is a block of documents (its manifest's places has no "page"): on a custom page its card says so and runs nothing, so there is nothing to try there (gallery block try tries it in a document).`),process.exit(1)),console.log(`${g} in card ${l} of ${t}, at ${f}:${$}: ${L(i.html)}`),w&&console.log(`Steps: ${r.length} from ${L(w)}, made one after another in one page`);let S=await q({command:`gallery page try ${t}`});if(!S.ok){console.log(`UNVERIFIED ${t}: ${S.message}`),process.exitCode=3;return}let{pageAloneOf:j}=await import("./chunk-DAMVDXR3.mjs");await oe(e);let B=[],G=async u=>{let b=await te(e,{directory:i.folder,files:i,text:u});return B.push(b.slug),b},I=Re({card:l,found:k});try{let u=o?{slug:t,file:i.html}:await G(m),b=j(S.port,u.slug);console.log(o?`Page: ${b} (the custom page alone, editable: the Agent's own; --keep: what ${re(r)} write stays in ${f}, and every page open on it shows it, the user's too; the server runs on after this command)`:`Page: ${b} (a scratch copy of ${t}, its page alone, editable, made for this trial and gone at its end: ${f} is not written, and no page of the user's shows the trial; the server runs on after this command)`);let O=M();if(!O){console.log(`UNVERIFIED ${t}: no Chrome, Edge or Chromium found (GALLERY_BROWSER=<its executable> picks one), so nothing was tried`),process.exitCode=3;return}let v;try{v=await J({executablePath:O,args:z()})}catch(R){console.log(`UNVERIFIED ${t}: the browser ${O} did not start, twice, each time with a fresh profile (${K(R)}; GALLERY_BROWSER=<its executable> picks another), so nothing was tried`),process.exitCode=3;return}let A=P.join(Ee(e).qa,t,"try");try{await N.rm(A,{recursive:!0,force:!0}),await N.mkdir(A,{recursive:!0});let R=async y=>{if(o)return{address:b,file:u.file};let W=await G(y);return{address:j(S.port,W.slug),file:W.file}},U;try{U=await ae(v.browser,{root:e,address:b,fresh:R,steps:r,keep:o,file:u.file,name:f,line:$,found:k,out:A,host:I})}catch(y){if(y instanceof E&&y.made&&console.log(ce({name:f,steps:r,keep:o,host:I},y.made).join(`
5
5
  `)),y.stuck)return ne(t,y,f,o);throw y}let{lines:ue,code:he}=ie({slug:t,name:f,steps:r,keep:o,host:I},U);console.log(ue.join(`
6
6
  `)),process.exitCode=he}finally{await v.close()}}finally{for(let u of B)await se(e,u)}}export{xe as a,ke as b,de as c,Ce as d,Ie as e,Ae as f,Re as g,Ke as h};
@@ -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{a as je}from"./chunk-YEY3RSFQ.mjs";import{c as $e}from"./chunk-W7XHE4CT.mjs";import{a as p,c as S,e as N}from"./chunk-5L7RYZCL.mjs";var T=S((Tr,He)=>{"use strict";var Ve=["nodebuffer","arraybuffer","fragments"],ze=typeof Blob<"u";ze&&Ve.push("blob");He.exports={BINARY_TYPES:Ve,CLOSE_TIMEOUT:3e4,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:ze,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var X=S((kr,re)=>{"use strict";var{EMPTY_BUFFER:Qt}=T(),xe=Buffer[Symbol.species];function Jt(t,e){if(t.length===0)return Qt;if(t.length===1)return t[0];let s=Buffer.allocUnsafe(e),r=0;for(let i=0;i<t.length;i++){let n=t[i];s.set(n,r),r+=n.length}return r<e?new xe(s.buffer,s.byteOffset,r):s}function Ye(t,e,s,r,i){for(let n=0;n<i;n++)s[r+n]=t[n]^e[n&3]}function Ke(t,e){for(let s=0;s<t.length;s++)t[s]^=e[s&3]}function es(t){return t.length===t.buffer.byteLength?t.buffer:t.buffer.slice(t.byteOffset,t.byteOffset+t.length)}function Se(t){if(Se.readOnly=!0,Buffer.isBuffer(t))return t;let e;return t instanceof ArrayBuffer?e=new xe(t):ArrayBuffer.isView(t)?e=new xe(t.buffer,t.byteOffset,t.byteLength):(e=Buffer.from(t),Se.readOnly=!1),e}re.exports={concat:Jt,mask:Ye,toArrayBuffer:es,toBuffer:Se,unmask:Ke};if(!process.env.WS_NO_BUFFER_UTIL)try{let t=p("bufferutil");re.exports.mask=function(e,s,r,i,n){n<48?Ye(e,s,r,i,n):t.mask(e,s,r,i,n)},re.exports.unmask=function(e,s){e.length<32?Ke(e,s):t.unmask(e,s)}}catch{}});var Qe=S((Cr,Ze)=>{"use strict";var Xe=Symbol("kDone"),Ee=Symbol("kRun"),ve=class{constructor(e){this[Xe]=()=>{this.pending--,this[Ee]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[Ee]()}[Ee](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[Xe])}}};Ze.exports=ve});var G=S((Lr,st)=>{"use strict";var Z=p("zlib"),Je=X(),ts=Qe(),{kStatusCode:et}=T(),ss=Buffer[Symbol.species],rs=Buffer.from([0,0,255,255]),ne=Symbol("permessage-deflate"),k=Symbol("total-length"),W=Symbol("callback"),P=Symbol("buffers"),q=Symbol("error"),ie,be=class{constructor(e){if(this._options=e||{},this._threshold=this._options.threshold!==void 0?this._options.threshold:1024,this._maxPayload=this._options.maxPayload|0,this._isServer=!!this._options.isServer,this._deflate=null,this._inflate=null,this.params=null,!ie){let s=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;ie=new ts(s)}}static get extensionName(){return"permessage-deflate"}offer(){let e={};return this._options.serverNoContextTakeover&&(e.server_no_context_takeover=!0),this._options.clientNoContextTakeover&&(e.client_no_context_takeover=!0),this._options.serverMaxWindowBits&&(e.server_max_window_bits=this._options.serverMaxWindowBits),this._options.clientMaxWindowBits?e.client_max_window_bits=this._options.clientMaxWindowBits:this._options.clientMaxWindowBits==null&&(e.client_max_window_bits=!0),e}accept(e){return e=this.normalizeParams(e),this.params=this._isServer?this.acceptAsServer(e):this.acceptAsClient(e),this.params}cleanup(){if(this._inflate&&(this._inflate.close(),this._inflate=null),this._deflate){let e=this._deflate[W];this._deflate.close(),this._deflate=null,e&&e(new Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(e){let s=this._options,r=e.find(i=>!(s.serverNoContextTakeover===!1&&i.server_no_context_takeover||i.server_max_window_bits&&(s.serverMaxWindowBits===!1||typeof s.serverMaxWindowBits=="number"&&s.serverMaxWindowBits>i.server_max_window_bits)||typeof s.clientMaxWindowBits=="number"&&(typeof i.client_max_window_bits=="number"?s.clientMaxWindowBits>i.client_max_window_bits:!i.client_max_window_bits)));if(!r)throw new Error("None of the extension offers can be accepted");return s.serverNoContextTakeover&&(r.server_no_context_takeover=!0),s.clientNoContextTakeover&&(r.client_no_context_takeover=!0),typeof s.serverMaxWindowBits=="number"&&(r.server_max_window_bits=s.serverMaxWindowBits),typeof s.clientMaxWindowBits=="number"?r.client_max_window_bits=s.clientMaxWindowBits:(r.client_max_window_bits===!0||s.clientMaxWindowBits===!1)&&delete r.client_max_window_bits,r}acceptAsClient(e){let s=e[0];if(this._options.clientNoContextTakeover===!1&&s.client_no_context_takeover)throw new Error('Unexpected parameter "client_no_context_takeover"');if(!s.client_max_window_bits)typeof this._options.clientMaxWindowBits=="number"&&(s.client_max_window_bits=this._options.clientMaxWindowBits);else if(this._options.clientMaxWindowBits===!1||typeof this._options.clientMaxWindowBits=="number"&&s.client_max_window_bits>this._options.clientMaxWindowBits)throw new Error('Unexpected or invalid parameter "client_max_window_bits"');return s}normalizeParams(e){return e.forEach(s=>{Object.keys(s).forEach(r=>{let i=s[r];if(i.length>1)throw new Error(`Parameter "${r}" must have only a single value`);if(i=i[0],r==="client_max_window_bits"){if(i!==!0){let n=+i;if(!Number.isInteger(n)||n<8||n>15)throw new TypeError(`Invalid value for parameter "${r}": ${i}`);i=n}else if(!this._isServer)throw new TypeError(`Invalid value for parameter "${r}": ${i}`)}else if(r==="server_max_window_bits"){let n=+i;if(!Number.isInteger(n)||n<8||n>15)throw new TypeError(`Invalid value for parameter "${r}": ${i}`);i=n}else if(r==="client_no_context_takeover"||r==="server_no_context_takeover"){if(i!==!0)throw new TypeError(`Invalid value for parameter "${r}": ${i}`)}else throw new Error(`Unknown parameter "${r}"`);s[r]=i})}),e}decompress(e,s,r){ie.add(i=>{this._decompress(e,s,(n,o)=>{i(),r(n,o)})})}compress(e,s,r){ie.add(i=>{this._compress(e,s,(n,o)=>{i(),r(n,o)})})}_decompress(e,s,r){let i=this._isServer?"client":"server";if(!this._inflate){let n=`${i}_max_window_bits`,o=typeof this.params[n]!="number"?Z.Z_DEFAULT_WINDOWBITS:this.params[n];this._inflate=Z.createInflateRaw({...this._options.zlibInflateOptions,windowBits:o}),this._inflate[ne]=this,this._inflate[k]=0,this._inflate[P]=[],this._inflate.on("error",ns),this._inflate.on("data",tt)}this._inflate[W]=r,this._inflate.write(e),s&&this._inflate.write(rs),this._inflate.flush(()=>{let n=this._inflate[q];if(n){this._inflate.close(),this._inflate=null,r(n);return}let o=Je.concat(this._inflate[P],this._inflate[k]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[k]=0,this._inflate[P]=[],s&&this.params[`${i}_no_context_takeover`]&&this._inflate.reset()),r(null,o)})}_compress(e,s,r){let i=this._isServer?"server":"client";if(!this._deflate){let n=`${i}_max_window_bits`,o=typeof this.params[n]!="number"?Z.Z_DEFAULT_WINDOWBITS:this.params[n];this._deflate=Z.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:o}),this._deflate[k]=0,this._deflate[P]=[],this._deflate.on("data",is)}this._deflate[W]=r,this._deflate.write(e),this._deflate.flush(Z.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let n=Je.concat(this._deflate[P],this._deflate[k]);s&&(n=new ss(n.buffer,n.byteOffset,n.length-4)),this._deflate[W]=null,this._deflate[k]=0,this._deflate[P]=[],s&&this.params[`${i}_no_context_takeover`]&&this._deflate.reset(),r(null,n)})}};st.exports=be;function is(t){this[P].push(t),this[k]+=t.length}function tt(t){if(this[k]+=t.length,this[ne]._maxPayload<1||this[k]<=this[ne]._maxPayload){this[P].push(t);return}this[q]=new RangeError("Max payload size exceeded"),this[q].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[q][et]=1009,this.removeListener("data",tt),this.reset()}function ns(t){if(this[ne]._inflate=null,this[q]){this[W](this[q]);return}t[et]=1007,this[W](t)}});var $=S((Nr,oe)=>{"use strict";var{isUtf8:rt}=p("buffer"),{hasBlob:os}=T(),as=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0];function fs(t){return t>=1e3&&t<=1014&&t!==1004&&t!==1005&&t!==1006||t>=3e3&&t<=4999}function we(t){let e=t.length,s=0;for(;s<e;)if((t[s]&128)===0)s++;else if((t[s]&224)===192){if(s+1===e||(t[s+1]&192)!==128||(t[s]&254)===192)return!1;s+=2}else if((t[s]&240)===224){if(s+2>=e||(t[s+1]&192)!==128||(t[s+2]&192)!==128||t[s]===224&&(t[s+1]&224)===128||t[s]===237&&(t[s+1]&224)===160)return!1;s+=3}else if((t[s]&248)===240){if(s+3>=e||(t[s+1]&192)!==128||(t[s+2]&192)!==128||(t[s+3]&192)!==128||t[s]===240&&(t[s+1]&240)===128||t[s]===244&&t[s+1]>143||t[s]>244)return!1;s+=4}else return!1;return!0}function ls(t){return os&&typeof t=="object"&&typeof t.arrayBuffer=="function"&&typeof t.type=="string"&&typeof t.stream=="function"&&(t[Symbol.toStringTag]==="Blob"||t[Symbol.toStringTag]==="File")}oe.exports={isBlob:ls,isValidStatusCode:fs,isValidUTF8:we,tokenChars:as};if(rt)oe.exports.isValidUTF8=function(t){return t.length<24?we(t):rt(t)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let t=p("utf-8-validate");oe.exports.isValidUTF8=function(e){return e.length<32?we(e):t(e)}}catch{}});var Le=S((Pr,ht)=>{"use strict";var{Writable:hs}=p("stream"),it=G(),{BINARY_TYPES:cs,EMPTY_BUFFER:nt,kStatusCode:us,kWebSocket:ds}=T(),{concat:Oe,toArrayBuffer:_s,unmask:ms}=X(),{isValidStatusCode:ps,isValidUTF8:ot}=$(),ae=Buffer[Symbol.species],v=0,at=1,ft=2,lt=3,Te=4,ke=5,fe=6,Ce=class extends hs{constructor(e={}){super(),this._allowSynchronousEvents=e.allowSynchronousEvents!==void 0?e.allowSynchronousEvents:!0,this._binaryType=e.binaryType||cs[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxBufferedChunks=e.maxBufferedChunks|0,this._maxFragments=e.maxFragments|0,this._maxPayload=e.maxPayload|0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[ds]=void 0,this._bufferedBytes=0,this._buffers=[],this._compressed=!1,this._payloadLength=0,this._mask=void 0,this._fragmented=0,this._masked=!1,this._fin=!1,this._opcode=0,this._totalPayloadLength=0,this._messageLength=0,this._numFragments=0,this._fragments=[],this._errored=!1,this._loop=!1,this._state=v}_write(e,s,r){if(this._opcode===8&&this._state==v)return r();if(this._maxBufferedChunks>0&&this._buffers.length>=this._maxBufferedChunks){r(this.createError(RangeError,"Too many buffered chunks",!1,1008,"WS_ERR_TOO_MANY_BUFFERED_PARTS"));return}this._bufferedBytes+=e.length,this._buffers.push(e),this.startLoop(r)}consume(e){if(this._bufferedBytes-=e,e===this._buffers[0].length)return this._buffers.shift();if(e<this._buffers[0].length){let r=this._buffers[0];return this._buffers[0]=new ae(r.buffer,r.byteOffset+e,r.length-e),new ae(r.buffer,r.byteOffset,e)}let s=Buffer.allocUnsafe(e);do{let r=this._buffers[0],i=s.length-e;e>=r.length?s.set(this._buffers.shift(),i):(s.set(new Uint8Array(r.buffer,r.byteOffset,e),i),this._buffers[0]=new ae(r.buffer,r.byteOffset+e,r.length-e)),e-=r.length}while(e>0);return s}startLoop(e){this._loop=!0;do switch(this._state){case v:this.getInfo(e);break;case at:this.getPayloadLength16(e);break;case ft:this.getPayloadLength64(e);break;case lt:this.getMask();break;case Te:this.getData(e);break;case ke:case fe:this._loop=!1;return}while(this._loop);this._errored||e()}getInfo(e){if(this._bufferedBytes<2){this._loop=!1;return}let s=this.consume(2);if((s[0]&48)!==0){let i=this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");e(i);return}let r=(s[0]&64)===64;if(r&&!this._extensions[it.extensionName]){let i=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(i);return}if(this._fin=(s[0]&128)===128,this._opcode=s[0]&15,this._payloadLength=s[1]&127,this._opcode===0){if(r){let i=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(i);return}if(!this._fragmented){let i=this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");e(i);return}this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented){let i=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");e(i);return}this._compressed=r}else if(this._opcode>7&&this._opcode<11){if(!this._fin){let i=this.createError(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");e(i);return}if(r){let i=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(i);return}if(this._payloadLength>125||this._opcode===8&&this._payloadLength===1){let i=this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");e(i);return}}else{let i=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");e(i);return}if(!this._fin&&!this._fragmented&&(this._fragmented=this._opcode),this._masked=(s[1]&128)===128,this._isServer){if(!this._masked){let i=this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK");e(i);return}}else if(this._masked){let i=this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");e(i);return}this._payloadLength===126?this._state=at:this._payloadLength===127?this._state=ft:this.haveLength(e)}getPayloadLength16(e){if(this._bufferedBytes<2){this._loop=!1;return}this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength(e)}getPayloadLength64(e){if(this._bufferedBytes<8){this._loop=!1;return}let s=this.consume(8),r=s.readUInt32BE(0);if(r>Math.pow(2,21)-1){let i=this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH");e(i);return}this._payloadLength=r*Math.pow(2,32)+s.readUInt32BE(4),this.haveLength(e)}haveLength(e){if(this._payloadLength&&this._opcode<8&&(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0)){let s=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");e(s);return}this._masked?this._state=lt:this._state=Te}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=Te}getData(e){let s=nt;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;return}s=this.consume(this._payloadLength),this._masked&&(this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3])!==0&&ms(s,this._mask)}if(this._opcode>7){this.controlMessage(s,e);return}if(this._maxFragments>0&&++this._numFragments>this._maxFragments){let r=this.createError(RangeError,"Too many message fragments",!1,1008,"WS_ERR_TOO_MANY_BUFFERED_PARTS");e(r);return}if(this._compressed){this._state=ke,this.decompress(s,e);return}s.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(s)),this.dataMessage(e)}decompress(e,s){this._extensions[it.extensionName].decompress(e,this._fin,(i,n)=>{if(i)return s(i);if(n.length){if(this._messageLength+=n.length,this._messageLength>this._maxPayload&&this._maxPayload>0){let o=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");s(o);return}this._fragments.push(n)}this.dataMessage(s),this._state===v&&this.startLoop(s)})}dataMessage(e){if(!this._fin){this._state=v;return}let s=this._messageLength,r=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._numFragments=0,this._fragments=[],this._opcode===2){let i;this._binaryType==="nodebuffer"?i=Oe(r,s):this._binaryType==="arraybuffer"?i=_s(Oe(r,s)):this._binaryType==="blob"?i=new Blob(r):i=r,this._allowSynchronousEvents?(this.emit("message",i,!0),this._state=v):(this._state=fe,setImmediate(()=>{this.emit("message",i,!0),this._state=v,this.startLoop(e)}))}else{let i=Oe(r,s);if(!this._skipUTF8Validation&&!ot(i)){let n=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");e(n);return}this._state===ke||this._allowSynchronousEvents?(this.emit("message",i,!1),this._state=v):(this._state=fe,setImmediate(()=>{this.emit("message",i,!1),this._state=v,this.startLoop(e)}))}}controlMessage(e,s){if(this._opcode===8){if(e.length===0)this._loop=!1,this.emit("conclude",1005,nt),this.end();else{let r=e.readUInt16BE(0);if(!ps(r)){let n=this.createError(RangeError,`invalid status code ${r}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");s(n);return}let i=new ae(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!ot(i)){let n=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");s(n);return}this._loop=!1,this.emit("conclude",r,i),this.end()}this._state=v;return}this._allowSynchronousEvents?(this.emit(this._opcode===9?"ping":"pong",e),this._state=v):(this._state=fe,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",e),this._state=v,this.startLoop(s)}))}createError(e,s,r,i,n){this._loop=!1,this._errored=!0;let o=new e(r?`Invalid WebSocket frame: ${s}`:s);return Error.captureStackTrace(o,this.createError),o.code=n,o[us]=i,o}};ht.exports=Ce});var Be=S((Rr,dt)=>{"use strict";var{Duplex:Br}=p("stream"),{randomFillSync:gs}=p("crypto"),{types:{isUint8Array:ys}}=p("util"),ct=G(),{EMPTY_BUFFER:xs,kWebSocket:Ss,NOOP:Es}=T(),{isBlob:j,isValidStatusCode:vs}=$(),{mask:ut,toBuffer:R}=X(),b=Symbol("kByteLength"),bs=Buffer.alloc(4),le=8*1024,U,V=le,w=0,ws=1,Os=2,Ne=class t{constructor(e,s,r){this._extensions=s||{},r&&(this._generateMask=r,this._maskBuffer=Buffer.alloc(4)),this._socket=e,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._queue=[],this._state=w,this.onerror=Es,this[Ss]=void 0}static frame(e,s){let r,i=!1,n=2,o=!1;s.mask&&(r=s.maskBuffer||bs,s.generateMask?s.generateMask(r):(V===le&&(U===void 0&&(U=Buffer.alloc(le)),gs(U,0,le),V=0),r[0]=U[V++],r[1]=U[V++],r[2]=U[V++],r[3]=U[V++]),o=(r[0]|r[1]|r[2]|r[3])===0,n=6);let a;typeof e=="string"?(!s.mask||o)&&s[b]!==void 0?a=s[b]:(e=Buffer.from(e),a=e.length):(a=e.length,i=s.mask&&s.readOnly&&!o);let l=a;a>=65536?(n+=8,l=127):a>125&&(n+=2,l=126);let f=Buffer.allocUnsafe(i?a+n:n);return f[0]=s.fin?s.opcode|128:s.opcode,s.rsv1&&(f[0]|=64),f[1]=l,l===126?f.writeUInt16BE(a,2):l===127&&(f[2]=f[3]=0,f.writeUIntBE(a,4,6)),s.mask?(f[1]|=128,f[n-4]=r[0],f[n-3]=r[1],f[n-2]=r[2],f[n-1]=r[3],o?[f,e]:i?(ut(e,r,f,n,a),[f]):(ut(e,r,e,0,a),[f,e])):[f,e]}close(e,s,r,i){let n;if(e===void 0)n=xs;else{if(typeof e!="number"||!vs(e))throw new TypeError("First argument must be a valid error code number");if(s===void 0||!s.length)n=Buffer.allocUnsafe(2),n.writeUInt16BE(e,0);else{let a=Buffer.byteLength(s);if(a>123)throw new RangeError("The message must not be greater than 123 bytes");if(n=Buffer.allocUnsafe(2+a),n.writeUInt16BE(e,0),typeof s=="string")n.write(s,2);else if(ys(s))n.set(s,2);else throw new TypeError("Second argument must be a string or a Uint8Array")}}let o={[b]:n.length,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state!==w?this.enqueue([this.dispatch,n,!1,o,i]):this.sendFrame(t.frame(n,o),i)}ping(e,s,r){let i,n;if(typeof e=="string"?(i=Buffer.byteLength(e),n=!1):j(e)?(i=e.size,n=!1):(e=R(e),i=e.length,n=R.readOnly),i>125)throw new RangeError("The data size must not be greater than 125 bytes");let o={[b]:i,fin:!0,generateMask:this._generateMask,mask:s,maskBuffer:this._maskBuffer,opcode:9,readOnly:n,rsv1:!1};j(e)?this._state!==w?this.enqueue([this.getBlobData,e,!1,o,r]):this.getBlobData(e,!1,o,r):this._state!==w?this.enqueue([this.dispatch,e,!1,o,r]):this.sendFrame(t.frame(e,o),r)}pong(e,s,r){let i,n;if(typeof e=="string"?(i=Buffer.byteLength(e),n=!1):j(e)?(i=e.size,n=!1):(e=R(e),i=e.length,n=R.readOnly),i>125)throw new RangeError("The data size must not be greater than 125 bytes");let o={[b]:i,fin:!0,generateMask:this._generateMask,mask:s,maskBuffer:this._maskBuffer,opcode:10,readOnly:n,rsv1:!1};j(e)?this._state!==w?this.enqueue([this.getBlobData,e,!1,o,r]):this.getBlobData(e,!1,o,r):this._state!==w?this.enqueue([this.dispatch,e,!1,o,r]):this.sendFrame(t.frame(e,o),r)}send(e,s,r){let i=this._extensions[ct.extensionName],n=s.binary?2:1,o=s.compress,a,l;typeof e=="string"?(a=Buffer.byteLength(e),l=!1):j(e)?(a=e.size,l=!1):(e=R(e),a=e.length,l=R.readOnly),this._firstFragment?(this._firstFragment=!1,o&&i&&i.params[i._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(o=a>=i._threshold),this._compress=o):(o=!1,n=0),s.fin&&(this._firstFragment=!0);let f={[b]:a,fin:s.fin,generateMask:this._generateMask,mask:s.mask,maskBuffer:this._maskBuffer,opcode:n,readOnly:l,rsv1:o};j(e)?this._state!==w?this.enqueue([this.getBlobData,e,this._compress,f,r]):this.getBlobData(e,this._compress,f,r):this._state!==w?this.enqueue([this.dispatch,e,this._compress,f,r]):this.dispatch(e,this._compress,f,r)}getBlobData(e,s,r,i){this._bufferedBytes+=r[b],this._state=Os,e.arrayBuffer().then(n=>{if(this._socket.destroyed){let a=new Error("The socket was closed while the blob was being read");process.nextTick(Pe,this,a,i);return}this._bufferedBytes-=r[b];let o=R(n);s?this.dispatch(o,s,r,i):(this._state=w,this.sendFrame(t.frame(o,r),i),this.dequeue())}).catch(n=>{process.nextTick(Ts,this,n,i)})}dispatch(e,s,r,i){if(!s){this.sendFrame(t.frame(e,r),i);return}let n=this._extensions[ct.extensionName];this._bufferedBytes+=r[b],this._state=ws,n.compress(e,r.fin,(o,a)=>{if(this._socket.destroyed){let l=new Error("The socket was closed while data was being compressed");Pe(this,l,i);return}this._bufferedBytes-=r[b],this._state=w,r.readOnly=!1,this.sendFrame(t.frame(a,r),i),this.dequeue()})}dequeue(){for(;this._state===w&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=e[3][b],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][b],this._queue.push(e)}sendFrame(e,s){e.length===2?(this._socket.cork(),this._socket.write(e[0]),this._socket.write(e[1],s),this._socket.uncork()):this._socket.write(e[0],s)}};dt.exports=Ne;function Pe(t,e,s){typeof s=="function"&&s(e);for(let r=0;r<t._queue.length;r++){let i=t._queue[r],n=i[i.length-1];typeof n=="function"&&n(e)}}function Ts(t,e,s){Pe(t,e,s),t.onerror(e)}});var vt=S((Ur,Et)=>{"use strict";var{kForOnEventAttribute:Q,kListener:Re}=T(),_t=Symbol("kCode"),mt=Symbol("kData"),pt=Symbol("kError"),gt=Symbol("kMessage"),yt=Symbol("kReason"),z=Symbol("kTarget"),xt=Symbol("kType"),St=Symbol("kWasClean"),C=class{constructor(e){this[z]=null,this[xt]=e}get target(){return this[z]}get type(){return this[xt]}};Object.defineProperty(C.prototype,"target",{enumerable:!0});Object.defineProperty(C.prototype,"type",{enumerable:!0});var I=class extends C{constructor(e,s={}){super(e),this[_t]=s.code===void 0?0:s.code,this[yt]=s.reason===void 0?"":s.reason,this[St]=s.wasClean===void 0?!1:s.wasClean}get code(){return this[_t]}get reason(){return this[yt]}get wasClean(){return this[St]}};Object.defineProperty(I.prototype,"code",{enumerable:!0});Object.defineProperty(I.prototype,"reason",{enumerable:!0});Object.defineProperty(I.prototype,"wasClean",{enumerable:!0});var H=class extends C{constructor(e,s={}){super(e),this[pt]=s.error===void 0?null:s.error,this[gt]=s.message===void 0?"":s.message}get error(){return this[pt]}get message(){return this[gt]}};Object.defineProperty(H.prototype,"error",{enumerable:!0});Object.defineProperty(H.prototype,"message",{enumerable:!0});var J=class extends C{constructor(e,s={}){super(e),this[mt]=s.data===void 0?null:s.data}get data(){return this[mt]}};Object.defineProperty(J.prototype,"data",{enumerable:!0});var ks={addEventListener(t,e,s={}){for(let i of this.listeners(t))if(!s[Q]&&i[Re]===e&&!i[Q])return;let r;if(t==="message")r=function(n,o){let a=new J("message",{data:o?n:n.toString()});a[z]=this,he(e,this,a)};else if(t==="close")r=function(n,o){let a=new I("close",{code:n,reason:o.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});a[z]=this,he(e,this,a)};else if(t==="error")r=function(n){let o=new H("error",{error:n,message:n.message});o[z]=this,he(e,this,o)};else if(t==="open")r=function(){let n=new C("open");n[z]=this,he(e,this,n)};else return;r[Q]=!!s[Q],r[Re]=e,s.once?this.once(t,r):this.on(t,r)},removeEventListener(t,e){for(let s of this.listeners(t))if(s[Re]===e&&!s[Q]){this.removeListener(t,s);break}}};Et.exports={CloseEvent:I,ErrorEvent:H,Event:C,EventTarget:ks,MessageEvent:J};function he(t,e,s){typeof t=="object"&&t.handleEvent?t.handleEvent.call(t,s):t.call(e,s)}});var ce=S((Ir,bt)=>{"use strict";var{tokenChars:ee}=$();function O(t,e,s){t[e]===void 0?t[e]=[s]:t[e].push(s)}function Cs(t){let e=Object.create(null),s=Object.create(null),r=!1,i=!1,n=!1,o,a,l=-1,f=-1,h=-1,c=0;for(;c<t.length;c++)if(f=t.charCodeAt(c),o===void 0)if(h===-1&&ee[f]===1)l===-1&&(l=c);else if(c!==0&&(f===32||f===9))h===-1&&l!==-1&&(h=c);else if(f===59||f===44){if(l===-1)throw new SyntaxError(`Unexpected character at index ${c}`);h===-1&&(h=c);let g=t.slice(l,h);f===44?(O(e,g,s),s=Object.create(null)):o=g,l=h=-1}else throw new SyntaxError(`Unexpected character at index ${c}`);else if(a===void 0)if(h===-1&&ee[f]===1)l===-1&&(l=c);else if(f===32||f===9)h===-1&&l!==-1&&(h=c);else if(f===59||f===44){if(l===-1)throw new SyntaxError(`Unexpected character at index ${c}`);h===-1&&(h=c),O(s,t.slice(l,h),!0),f===44&&(O(e,o,s),s=Object.create(null),o=void 0),l=h=-1}else if(f===61&&l!==-1&&h===-1)a=t.slice(l,c),l=h=-1;else throw new SyntaxError(`Unexpected character at index ${c}`);else if(i){if(ee[f]!==1)throw new SyntaxError(`Unexpected character at index ${c}`);l===-1?l=c:r||(r=!0),i=!1}else if(n)if(ee[f]===1)l===-1&&(l=c);else if(f===34&&l!==-1)n=!1,h=c;else if(f===92)i=!0;else throw new SyntaxError(`Unexpected character at index ${c}`);else if(f===34&&t.charCodeAt(c-1)===61)n=!0;else if(h===-1&&ee[f]===1)l===-1&&(l=c);else if(l!==-1&&(f===32||f===9))h===-1&&(h=c);else if(f===59||f===44){if(l===-1)throw new SyntaxError(`Unexpected character at index ${c}`);h===-1&&(h=c);let g=t.slice(l,h);r&&(g=g.replace(/\\/g,""),r=!1),O(s,a,g),f===44&&(O(e,o,s),s=Object.create(null),o=void 0),a=void 0,l=h=-1}else throw new SyntaxError(`Unexpected character at index ${c}`);if(l===-1||n||f===32||f===9)throw new SyntaxError("Unexpected end of input");h===-1&&(h=c);let _=t.slice(l,h);return o===void 0?O(e,_,s):(a===void 0?O(s,_,!0):r?O(s,a,_.replace(/\\/g,"")):O(s,a,_),O(e,o,s)),e}function Ls(t){return Object.keys(t).map(e=>{let s=t[e];return Array.isArray(s)||(s=[s]),s.map(r=>[e].concat(Object.keys(r).map(i=>{let n=r[i];return Array.isArray(n)||(n=[n]),n.map(o=>o===!0?i:`${i}=${o}`).join("; ")})).join("; ")).join(", ")}).join(", ")}bt.exports={format:Ls,parse:Cs}});var me=S((Mr,It)=>{"use strict";var Ns=p("events"),Ps=p("https"),Bs=p("http"),Tt=p("net"),Rs=p("tls"),{randomBytes:Us,createHash:Is}=p("crypto"),{Duplex:Dr,Readable:Ar}=p("stream"),{URL:Ue}=p("url"),B=G(),Ds=Le(),As=Be(),{isBlob:Ms}=$(),{BINARY_TYPES:wt,CLOSE_TIMEOUT:Fs,EMPTY_BUFFER:ue,GUID:Ws,kForOnEventAttribute:Ie,kListener:qs,kStatusCode:Gs,kWebSocket:y,NOOP:kt}=T(),{EventTarget:{addEventListener:$s,removeEventListener:js}}=vt(),{format:Vs,parse:zs}=ce(),{toBuffer:Hs}=X(),Ct=Symbol("kAborted"),De=[8,13],L=["CONNECTING","OPEN","CLOSING","CLOSED"],Ys=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,d=class t extends Ns{constructor(e,s,r){super(),this._binaryType=wt[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=ue,this._closeTimer=null,this._errorEmitted=!1,this._extensions={},this._paused=!1,this._protocol="",this._readyState=t.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,e!==null?(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,s===void 0?!r||r.protocols===void 0?s=[]:Array.isArray(r.protocols)?s=r.protocols:s=[r.protocols]:Array.isArray(s)||(typeof s=="object"&&s!==null?(r=s,r.protocols===void 0?s=[]:Array.isArray(r.protocols)?s=r.protocols:s=[r.protocols]):s=[s]),Lt(this,e,s,r)):(this._autoPong=r.autoPong,this._closeTimeout=r.closeTimeout,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(e){wt.includes(e)&&(this._binaryType=e,this._receiver&&(this._receiver._binaryType=e))}get bufferedAmount(){return this._socket?this._socket._writableState.length+this._sender._bufferedBytes:this._bufferedAmount}get extensions(){return Object.keys(this._extensions).join()}get isPaused(){return this._paused}get onclose(){return null}get onerror(){return null}get onopen(){return null}get onmessage(){return null}get protocol(){return this._protocol}get readyState(){return this._readyState}get url(){return this._url}setSocket(e,s,r){let i=new Ds({allowSynchronousEvents:r.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxBufferedChunks:r.maxBufferedChunks,maxFragments:r.maxFragments,maxPayload:r.maxPayload,skipUTF8Validation:r.skipUTF8Validation}),n=new As(e,this._extensions,r.generateMask);this._receiver=i,this._sender=n,this._socket=e,i[y]=this,n[y]=this,e[y]=this,i.on("conclude",Zs),i.on("drain",Qs),i.on("error",Js),i.on("message",er),i.on("ping",tr),i.on("pong",sr),n.onerror=rr,e.setTimeout&&e.setTimeout(0),e.setNoDelay&&e.setNoDelay(),s.length>0&&e.unshift(s),e.on("close",Bt),e.on("data",_e),e.on("end",Rt),e.on("error",Ut),this._readyState=t.OPEN,this.emit("open")}emitClose(){if(!this._socket){this._readyState=t.CLOSED,this.emit("close",this._closeCode,this._closeMessage);return}this._extensions[B.extensionName]&&this._extensions[B.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=t.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(e,s){if(this.readyState!==t.CLOSED){if(this.readyState===t.CONNECTING){E(this,this._req,"WebSocket was closed before the connection was established");return}if(this.readyState===t.CLOSING){this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end();return}this._sender.close(e,s,!this._isServer,r=>{r||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())}),this._readyState=t.CLOSING,Pt(this)}}pause(){this.readyState===t.CONNECTING||this.readyState===t.CLOSED||(this._paused=!0,this._socket.pause())}ping(e,s,r){if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(r=e,e=s=void 0):typeof s=="function"&&(r=s,s=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){Ae(this,e,r);return}s===void 0&&(s=!this._isServer),this._sender.ping(e||ue,s,r)}pong(e,s,r){if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(r=e,e=s=void 0):typeof s=="function"&&(r=s,s=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){Ae(this,e,r);return}s===void 0&&(s=!this._isServer),this._sender.pong(e||ue,s,r)}resume(){this.readyState===t.CONNECTING||this.readyState===t.CLOSED||(this._paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(e,s,r){if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof s=="function"&&(r=s,s={}),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){Ae(this,e,r);return}let i={binary:typeof e!="string",mask:!this._isServer,compress:!0,fin:!0,...s};this._extensions[B.extensionName]||(i.compress=!1),this._sender.send(e||ue,i,r)}terminate(){if(this.readyState!==t.CLOSED){if(this.readyState===t.CONNECTING){E(this,this._req,"WebSocket was closed before the connection was established");return}this._socket&&(this._readyState=t.CLOSING,this._socket.destroy())}}};Object.defineProperty(d,"CONNECTING",{enumerable:!0,value:L.indexOf("CONNECTING")});Object.defineProperty(d.prototype,"CONNECTING",{enumerable:!0,value:L.indexOf("CONNECTING")});Object.defineProperty(d,"OPEN",{enumerable:!0,value:L.indexOf("OPEN")});Object.defineProperty(d.prototype,"OPEN",{enumerable:!0,value:L.indexOf("OPEN")});Object.defineProperty(d,"CLOSING",{enumerable:!0,value:L.indexOf("CLOSING")});Object.defineProperty(d.prototype,"CLOSING",{enumerable:!0,value:L.indexOf("CLOSING")});Object.defineProperty(d,"CLOSED",{enumerable:!0,value:L.indexOf("CLOSED")});Object.defineProperty(d.prototype,"CLOSED",{enumerable:!0,value:L.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(t=>{Object.defineProperty(d.prototype,t,{enumerable:!0})});["open","error","close","message"].forEach(t=>{Object.defineProperty(d.prototype,`on${t}`,{enumerable:!0,get(){for(let e of this.listeners(t))if(e[Ie])return e[qs];return null},set(e){for(let s of this.listeners(t))if(s[Ie]){this.removeListener(t,s);break}typeof e=="function"&&this.addEventListener(t,e,{[Ie]:!0})}})});d.prototype.addEventListener=$s;d.prototype.removeEventListener=js;It.exports=d;function Lt(t,e,s,r){let i={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:Fs,protocolVersion:De[1],maxBufferedChunks:262144,maxFragments:16384,maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...r,socketPath:void 0,hostname:void 0,protocol:void 0,protocols:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0};if(t._autoPong=i.autoPong,t._closeTimeout=i.closeTimeout,!De.includes(i.protocolVersion))throw new RangeError(`Unsupported protocol version: ${i.protocolVersion} (supported versions: ${De.join(", ")})`);let n;if(e instanceof Ue)n=e;else try{n=new Ue(e)}catch{throw new SyntaxError(`Invalid URL: ${e}`)}n.protocol==="http:"?n.protocol="ws:":n.protocol==="https:"&&(n.protocol="wss:"),t._url=n.href;let o=n.protocol==="wss:",a=n.protocol==="ws+unix:",l;if(n.protocol!=="ws:"&&!o&&!a?l=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`:a&&!n.pathname?l="The URL's pathname is empty":n.hash&&(l="The URL contains a fragment identifier"),l){let u=new SyntaxError(l);if(t._redirects===0)throw u;de(t,u);return}let f=o?443:80,h=Us(16).toString("base64"),c=o?Ps.request:Bs.request,_=new Set,g;if(i.createConnection=i.createConnection||(o?Xs:Ks),i.defaultPort=i.defaultPort||f,i.port=n.port||f,i.host=n.hostname.startsWith("[")?n.hostname.slice(1,-1):n.hostname,i.headers={...i.headers,"Sec-WebSocket-Version":i.protocolVersion,"Sec-WebSocket-Key":h,Connection:"Upgrade",Upgrade:"websocket"},i.path=n.pathname+n.search,i.timeout=i.handshakeTimeout,i.perMessageDeflate&&(g=new B({...i.perMessageDeflate,isServer:!1,maxPayload:i.maxPayload}),i.headers["Sec-WebSocket-Extensions"]=Vs({[B.extensionName]:g.offer()})),s.length){for(let u of s){if(typeof u!="string"||!Ys.test(u)||_.has(u))throw new SyntaxError("An invalid or duplicated subprotocol was specified");_.add(u)}i.headers["Sec-WebSocket-Protocol"]=s.join(",")}if(i.origin&&(i.protocolVersion<13?i.headers["Sec-WebSocket-Origin"]=i.origin:i.headers.Origin=i.origin),(n.username||n.password)&&(i.auth=`${n.username}:${n.password}`),a){let u=i.path.split(":");i.socketPath=u[0],i.path=u[1]}let m;if(i.followRedirects){if(t._redirects===0){t._originalIpc=a,t._originalSecure=o,t._originalHostOrSocketPath=a?i.socketPath:n.host;let u=r&&r.headers;if(r={...r,headers:{}},u)for(let[x,M]of Object.entries(u))r.headers[x.toLowerCase()]=M}else if(t.listenerCount("redirect")===0){let u=a?t._originalIpc?i.socketPath===t._originalHostOrSocketPath:!1:t._originalIpc?!1:n.host===t._originalHostOrSocketPath;(!u||t._originalSecure&&!o)&&(delete i.headers.authorization,delete i.headers.cookie,u||delete i.headers.host,i.auth=void 0)}i.auth&&!r.headers.authorization&&(r.headers.authorization="Basic "+Buffer.from(i.auth).toString("base64")),m=t._req=c(i),t._redirects&&t.emit("redirect",t.url,m)}else m=t._req=c(i);i.timeout&&m.on("timeout",()=>{E(t,m,"Opening handshake has timed out")}),m.on("error",u=>{m===null||m[Ct]||(m=t._req=null,de(t,u))}),m.on("response",u=>{let x=u.headers.location,M=u.statusCode;if(x&&i.followRedirects&&M>=300&&M<400){if(++t._redirects>i.maxRedirects){E(t,m,"Maximum redirects exceeded");return}m.abort();let Y;try{Y=new Ue(x,e)}catch{let F=new SyntaxError(`Invalid URL: ${x}`);de(t,F);return}Lt(t,Y,s,r)}else t.emit("unexpected-response",m,u)||E(t,m,`Unexpected server response: ${u.statusCode}`)}),m.on("upgrade",(u,x,M)=>{if(t.emit("upgrade",u),t.readyState!==d.CONNECTING)return;m=t._req=null;let Y=u.headers.upgrade;if(Y===void 0||Y.toLowerCase()!=="websocket"){E(t,x,"Invalid Upgrade header");return}let We=Is("sha1").update(h+Ws).digest("base64");if(u.headers["sec-websocket-accept"]!==We){E(t,x,"Invalid Sec-WebSocket-Accept header");return}let F=u.headers["sec-websocket-protocol"],K;if(F!==void 0?_.size?_.has(F)||(K="Server sent an invalid subprotocol"):K="Server sent a subprotocol but none was requested":_.size&&(K="Server sent no subprotocol"),K){E(t,x,K);return}F&&(t._protocol=F);let qe=u.headers["sec-websocket-extensions"];if(qe!==void 0){if(!g){E(t,x,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let ge;try{ge=zs(qe)}catch{E(t,x,"Invalid Sec-WebSocket-Extensions header");return}let Ge=Object.keys(ge);if(Ge.length!==1||Ge[0]!==B.extensionName){E(t,x,"Server indicated an extension that was not requested");return}try{g.accept(ge[B.extensionName])}catch{E(t,x,"Invalid Sec-WebSocket-Extensions header");return}t._extensions[B.extensionName]=g}t.setSocket(x,M,{allowSynchronousEvents:i.allowSynchronousEvents,generateMask:i.generateMask,maxBufferedChunks:i.maxBufferedChunks,maxFragments:i.maxFragments,maxPayload:i.maxPayload,skipUTF8Validation:i.skipUTF8Validation})}),i.finishRequest?i.finishRequest(m,t):m.end()}function de(t,e){t._readyState=d.CLOSING,t._errorEmitted=!0,t.emit("error",e),t.emitClose()}function Ks(t){return t.path=t.socketPath,Tt.connect(t)}function Xs(t){return t.path=void 0,!t.servername&&t.servername!==""&&(t.servername=Tt.isIP(t.host)?"":t.host),Rs.connect(t)}function E(t,e,s){t._readyState=d.CLOSING;let r=new Error(s);Error.captureStackTrace(r,E),e.setHeader?(e[Ct]=!0,e.abort(),e.socket&&!e.socket.destroyed&&e.socket.destroy(),process.nextTick(de,t,r)):(e.destroy(r),e.once("error",t.emit.bind(t,"error")),e.once("close",t.emitClose.bind(t)))}function Ae(t,e,s){if(e){let r=Ms(e)?e.size:Hs(e).length;t._socket?t._sender._bufferedBytes+=r:t._bufferedAmount+=r}if(s){let r=new Error(`WebSocket is not open: readyState ${t.readyState} (${L[t.readyState]})`);process.nextTick(s,r)}}function Zs(t,e){let s=this[y];s._closeFrameReceived=!0,s._closeMessage=e,s._closeCode=t,s._socket[y]!==void 0&&(s._socket.removeListener("data",_e),process.nextTick(Nt,s._socket),t===1005?s.close():s.close(t,e))}function Qs(){let t=this[y];t.isPaused||t._socket.resume()}function Js(t){let e=this[y];e._socket[y]!==void 0&&(e._socket.removeListener("data",_e),process.nextTick(Nt,e._socket),e.close(t[Gs])),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t))}function Ot(){this[y].emitClose()}function er(t,e){this[y].emit("message",t,e)}function tr(t){let e=this[y];e._autoPong&&e.pong(t,!this._isServer,kt),e.emit("ping",t)}function sr(t){this[y].emit("pong",t)}function Nt(t){t.resume()}function rr(t){let e=this[y];e.readyState!==d.CLOSED&&(e.readyState===d.OPEN&&(e._readyState=d.CLOSING,Pt(e)),this._socket.end(),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t)))}function Pt(t){t._closeTimer=setTimeout(t._socket.destroy.bind(t._socket),t._closeTimeout)}function Bt(){let t=this[y];if(this.removeListener("close",Bt),this.removeListener("data",_e),this.removeListener("end",Rt),t._readyState=d.CLOSING,!this._readableState.endEmitted&&!t._closeFrameReceived&&!t._receiver._writableState.errorEmitted&&this._readableState.length!==0){let e=this.read(this._readableState.length);t._receiver.write(e)}t._receiver.end(),this[y]=void 0,clearTimeout(t._closeTimer),t._receiver._writableState.finished||t._receiver._writableState.errorEmitted?t.emitClose():(t._receiver.on("error",Ot),t._receiver.on("finish",Ot))}function _e(t){this[y]._receiver.write(t)||this.pause()}function Rt(){let t=this[y];t._readyState=d.CLOSING,t._receiver.end(),this.end()}function Ut(){let t=this[y];this.removeListener("error",Ut),this.on("error",kt),t&&(t._readyState=d.CLOSING,this.destroy())}});var Ft=S((Wr,Mt)=>{"use strict";var Fr=me(),{Duplex:ir}=p("stream");function Dt(t){t.emit("close")}function nr(){!this.destroyed&&this._writableState.finished&&this.destroy()}function At(t){this.removeListener("error",At),this.destroy(),this.listenerCount("error")===0&&this.emit("error",t)}function or(t,e){let s=!0,r=new ir({...e,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return t.on("message",function(n,o){let a=!o&&r._readableState.objectMode?n.toString():n;r.push(a)||t.pause()}),t.once("error",function(n){r.destroyed||(s=!1,r.destroy(n))}),t.once("close",function(){r.destroyed||r.push(null)}),r._destroy=function(i,n){if(t.readyState===t.CLOSED){n(i),process.nextTick(Dt,r);return}let o=!1;t.once("error",function(l){o=!0,n(l)}),t.once("close",function(){o||n(i),process.nextTick(Dt,r)}),s&&t.terminate()},r._final=function(i){if(t.readyState===t.CONNECTING){t.once("open",function(){r._final(i)});return}t._socket!==null&&(t._socket._writableState.finished?(i(),r._readableState.endEmitted&&r.destroy()):(t._socket.once("finish",function(){i()}),t.close()))},r._read=function(){t.isPaused&&t.resume()},r._write=function(i,n,o){if(t.readyState===t.CONNECTING){t.once("open",function(){r._write(i,n,o)});return}t.send(i,o)},r.on("end",nr),r.on("error",At),r}Mt.exports=or});var Me=S((qr,Wt)=>{"use strict";var{tokenChars:ar}=$();function fr(t){let e=new Set,s=-1,r=-1,i=0;for(i;i<t.length;i++){let o=t.charCodeAt(i);if(r===-1&&ar[o]===1)s===-1&&(s=i);else if(i!==0&&(o===32||o===9))r===-1&&s!==-1&&(r=i);else if(o===44){if(s===-1)throw new SyntaxError(`Unexpected character at index ${i}`);r===-1&&(r=i);let a=t.slice(s,r);if(e.has(a))throw new SyntaxError(`The "${a}" subprotocol is duplicated`);e.add(a),s=r=-1}else throw new SyntaxError(`Unexpected character at index ${i}`)}if(s===-1||r!==-1)throw new SyntaxError("Unexpected end of input");let n=t.slice(s,i);if(e.has(n))throw new SyntaxError(`The "${n}" subprotocol is duplicated`);return e.add(n),e}Wt.exports={parse:fr}});var Ht=S(($r,zt)=>{"use strict";var lr=p("events"),pe=p("http"),{Duplex:Gr}=p("stream"),{createHash:hr}=p("crypto"),qt=ce(),D=G(),cr=Me(),ur=me(),{CLOSE_TIMEOUT:dr,GUID:_r,kWebSocket:mr}=T(),pr=/^[+/0-9A-Za-z]{22}==$/,Gt=0,$t=1,Vt=2,Fe=class extends lr{constructor(e,s){if(super(),e={allowSynchronousEvents:!0,autoPong:!0,maxBufferedChunks:256*1024,maxFragments:16*1024,maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:dr,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:ur,...e},e.port==null&&!e.server&&!e.noServer||e.port!=null&&(e.server||e.noServer)||e.server&&e.noServer)throw new TypeError('One and only one of the "port", "server", or "noServer" options must be specified');if(e.port!=null?(this._server=pe.createServer((r,i)=>{let n=pe.STATUS_CODES[426];i.writeHead(426,{"Content-Length":n.length,"Content-Type":"text/plain"}),i.end(n)}),this._server.listen(e.port,e.host,e.backlog,s)):e.server&&(this._server=e.server),this._server){let r=this.emit.bind(this,"connection");this._removeListeners=gr(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(i,n,o)=>{this.handleUpgrade(i,n,o,r)}})}e.perMessageDeflate===!0&&(e.perMessageDeflate={}),e.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=e,this._state=Gt}address(){if(this.options.noServer)throw new Error('The server is operating in "noServer" mode');return this._server?this._server.address():null}close(e){if(this._state===Vt){e&&this.once("close",()=>{e(new Error("The server is not running"))}),process.nextTick(te,this);return}if(e&&this.once("close",e),this._state!==$t)if(this._state=$t,this.options.noServer||this.options.server)this._server&&(this._removeListeners(),this._removeListeners=this._server=null),this.clients?this.clients.size?this._shouldEmitClose=!0:process.nextTick(te,this):process.nextTick(te,this);else{let s=this._server;this._removeListeners(),this._removeListeners=this._server=null,s.close(()=>{te(this)})}}shouldHandle(e){if(this.options.path){let s=e.url.indexOf("?");if((s!==-1?e.url.slice(0,s):e.url)!==this.options.path)return!1}return!0}handleUpgrade(e,s,r,i){s.on("error",jt);let n=e.headers["sec-websocket-key"],o=e.headers.upgrade,a=+e.headers["sec-websocket-version"];if(e.method!=="GET"){A(this,e,s,405,"Invalid HTTP method");return}if(o===void 0||o.toLowerCase()!=="websocket"){A(this,e,s,400,"Invalid Upgrade header");return}if(n===void 0||!pr.test(n)){A(this,e,s,400,"Missing or invalid Sec-WebSocket-Key header");return}if(a!==13&&a!==8){A(this,e,s,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}if(!this.shouldHandle(e)){se(s,400);return}let l=e.headers["sec-websocket-protocol"],f=new Set;if(l!==void 0)try{f=cr.parse(l)}catch{A(this,e,s,400,"Invalid Sec-WebSocket-Protocol header");return}let h=e.headers["sec-websocket-extensions"],c={};if(this.options.perMessageDeflate&&h!==void 0){let _=new D({...this.options.perMessageDeflate,isServer:!0,maxPayload:this.options.maxPayload});try{let g=qt.parse(h);g[D.extensionName]&&(_.accept(g[D.extensionName]),c[D.extensionName]=_)}catch{A(this,e,s,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let _={origin:e.headers[`${a===8?"sec-websocket-origin":"origin"}`],secure:!!(e.socket.authorized||e.socket.encrypted),req:e};if(this.options.verifyClient.length===2){this.options.verifyClient(_,(g,m,u,x)=>{if(!g)return se(s,m||401,u,x);this.completeUpgrade(c,n,f,e,s,r,i)});return}if(!this.options.verifyClient(_))return se(s,401)}this.completeUpgrade(c,n,f,e,s,r,i)}completeUpgrade(e,s,r,i,n,o,a){if(!n.readable||!n.writable)return n.destroy();if(n[mr])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>Gt)return se(n,503);let f=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${hr("sha1").update(s+_r).digest("base64")}`],h=new this.options.WebSocket(null,void 0,this.options);if(r.size){let c=this.options.handleProtocols?this.options.handleProtocols(r,i):r.values().next().value;c&&(f.push(`Sec-WebSocket-Protocol: ${c}`),h._protocol=c)}if(e[D.extensionName]){let c=e[D.extensionName].params,_=qt.format({[D.extensionName]:[c]});f.push(`Sec-WebSocket-Extensions: ${_}`),h._extensions=e}this.emit("headers",f,i),n.write(f.concat(`\r
2
+ import{a as je}from"./chunk-5MMN3N5J.mjs";import{c as $e}from"./chunk-EKGYYOSP.mjs";import{a as p,c as S,e as N}from"./chunk-5L7RYZCL.mjs";var T=S((Tr,He)=>{"use strict";var Ve=["nodebuffer","arraybuffer","fragments"],ze=typeof Blob<"u";ze&&Ve.push("blob");He.exports={BINARY_TYPES:Ve,CLOSE_TIMEOUT:3e4,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:ze,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var X=S((kr,re)=>{"use strict";var{EMPTY_BUFFER:Qt}=T(),xe=Buffer[Symbol.species];function Jt(t,e){if(t.length===0)return Qt;if(t.length===1)return t[0];let s=Buffer.allocUnsafe(e),r=0;for(let i=0;i<t.length;i++){let n=t[i];s.set(n,r),r+=n.length}return r<e?new xe(s.buffer,s.byteOffset,r):s}function Ye(t,e,s,r,i){for(let n=0;n<i;n++)s[r+n]=t[n]^e[n&3]}function Ke(t,e){for(let s=0;s<t.length;s++)t[s]^=e[s&3]}function es(t){return t.length===t.buffer.byteLength?t.buffer:t.buffer.slice(t.byteOffset,t.byteOffset+t.length)}function Se(t){if(Se.readOnly=!0,Buffer.isBuffer(t))return t;let e;return t instanceof ArrayBuffer?e=new xe(t):ArrayBuffer.isView(t)?e=new xe(t.buffer,t.byteOffset,t.byteLength):(e=Buffer.from(t),Se.readOnly=!1),e}re.exports={concat:Jt,mask:Ye,toArrayBuffer:es,toBuffer:Se,unmask:Ke};if(!process.env.WS_NO_BUFFER_UTIL)try{let t=p("bufferutil");re.exports.mask=function(e,s,r,i,n){n<48?Ye(e,s,r,i,n):t.mask(e,s,r,i,n)},re.exports.unmask=function(e,s){e.length<32?Ke(e,s):t.unmask(e,s)}}catch{}});var Qe=S((Cr,Ze)=>{"use strict";var Xe=Symbol("kDone"),Ee=Symbol("kRun"),ve=class{constructor(e){this[Xe]=()=>{this.pending--,this[Ee]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[Ee]()}[Ee](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[Xe])}}};Ze.exports=ve});var G=S((Lr,st)=>{"use strict";var Z=p("zlib"),Je=X(),ts=Qe(),{kStatusCode:et}=T(),ss=Buffer[Symbol.species],rs=Buffer.from([0,0,255,255]),ne=Symbol("permessage-deflate"),k=Symbol("total-length"),W=Symbol("callback"),P=Symbol("buffers"),q=Symbol("error"),ie,be=class{constructor(e){if(this._options=e||{},this._threshold=this._options.threshold!==void 0?this._options.threshold:1024,this._maxPayload=this._options.maxPayload|0,this._isServer=!!this._options.isServer,this._deflate=null,this._inflate=null,this.params=null,!ie){let s=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;ie=new ts(s)}}static get extensionName(){return"permessage-deflate"}offer(){let e={};return this._options.serverNoContextTakeover&&(e.server_no_context_takeover=!0),this._options.clientNoContextTakeover&&(e.client_no_context_takeover=!0),this._options.serverMaxWindowBits&&(e.server_max_window_bits=this._options.serverMaxWindowBits),this._options.clientMaxWindowBits?e.client_max_window_bits=this._options.clientMaxWindowBits:this._options.clientMaxWindowBits==null&&(e.client_max_window_bits=!0),e}accept(e){return e=this.normalizeParams(e),this.params=this._isServer?this.acceptAsServer(e):this.acceptAsClient(e),this.params}cleanup(){if(this._inflate&&(this._inflate.close(),this._inflate=null),this._deflate){let e=this._deflate[W];this._deflate.close(),this._deflate=null,e&&e(new Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(e){let s=this._options,r=e.find(i=>!(s.serverNoContextTakeover===!1&&i.server_no_context_takeover||i.server_max_window_bits&&(s.serverMaxWindowBits===!1||typeof s.serverMaxWindowBits=="number"&&s.serverMaxWindowBits>i.server_max_window_bits)||typeof s.clientMaxWindowBits=="number"&&(typeof i.client_max_window_bits=="number"?s.clientMaxWindowBits>i.client_max_window_bits:!i.client_max_window_bits)));if(!r)throw new Error("None of the extension offers can be accepted");return s.serverNoContextTakeover&&(r.server_no_context_takeover=!0),s.clientNoContextTakeover&&(r.client_no_context_takeover=!0),typeof s.serverMaxWindowBits=="number"&&(r.server_max_window_bits=s.serverMaxWindowBits),typeof s.clientMaxWindowBits=="number"?r.client_max_window_bits=s.clientMaxWindowBits:(r.client_max_window_bits===!0||s.clientMaxWindowBits===!1)&&delete r.client_max_window_bits,r}acceptAsClient(e){let s=e[0];if(this._options.clientNoContextTakeover===!1&&s.client_no_context_takeover)throw new Error('Unexpected parameter "client_no_context_takeover"');if(!s.client_max_window_bits)typeof this._options.clientMaxWindowBits=="number"&&(s.client_max_window_bits=this._options.clientMaxWindowBits);else if(this._options.clientMaxWindowBits===!1||typeof this._options.clientMaxWindowBits=="number"&&s.client_max_window_bits>this._options.clientMaxWindowBits)throw new Error('Unexpected or invalid parameter "client_max_window_bits"');return s}normalizeParams(e){return e.forEach(s=>{Object.keys(s).forEach(r=>{let i=s[r];if(i.length>1)throw new Error(`Parameter "${r}" must have only a single value`);if(i=i[0],r==="client_max_window_bits"){if(i!==!0){let n=+i;if(!Number.isInteger(n)||n<8||n>15)throw new TypeError(`Invalid value for parameter "${r}": ${i}`);i=n}else if(!this._isServer)throw new TypeError(`Invalid value for parameter "${r}": ${i}`)}else if(r==="server_max_window_bits"){let n=+i;if(!Number.isInteger(n)||n<8||n>15)throw new TypeError(`Invalid value for parameter "${r}": ${i}`);i=n}else if(r==="client_no_context_takeover"||r==="server_no_context_takeover"){if(i!==!0)throw new TypeError(`Invalid value for parameter "${r}": ${i}`)}else throw new Error(`Unknown parameter "${r}"`);s[r]=i})}),e}decompress(e,s,r){ie.add(i=>{this._decompress(e,s,(n,o)=>{i(),r(n,o)})})}compress(e,s,r){ie.add(i=>{this._compress(e,s,(n,o)=>{i(),r(n,o)})})}_decompress(e,s,r){let i=this._isServer?"client":"server";if(!this._inflate){let n=`${i}_max_window_bits`,o=typeof this.params[n]!="number"?Z.Z_DEFAULT_WINDOWBITS:this.params[n];this._inflate=Z.createInflateRaw({...this._options.zlibInflateOptions,windowBits:o}),this._inflate[ne]=this,this._inflate[k]=0,this._inflate[P]=[],this._inflate.on("error",ns),this._inflate.on("data",tt)}this._inflate[W]=r,this._inflate.write(e),s&&this._inflate.write(rs),this._inflate.flush(()=>{let n=this._inflate[q];if(n){this._inflate.close(),this._inflate=null,r(n);return}let o=Je.concat(this._inflate[P],this._inflate[k]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[k]=0,this._inflate[P]=[],s&&this.params[`${i}_no_context_takeover`]&&this._inflate.reset()),r(null,o)})}_compress(e,s,r){let i=this._isServer?"server":"client";if(!this._deflate){let n=`${i}_max_window_bits`,o=typeof this.params[n]!="number"?Z.Z_DEFAULT_WINDOWBITS:this.params[n];this._deflate=Z.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:o}),this._deflate[k]=0,this._deflate[P]=[],this._deflate.on("data",is)}this._deflate[W]=r,this._deflate.write(e),this._deflate.flush(Z.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let n=Je.concat(this._deflate[P],this._deflate[k]);s&&(n=new ss(n.buffer,n.byteOffset,n.length-4)),this._deflate[W]=null,this._deflate[k]=0,this._deflate[P]=[],s&&this.params[`${i}_no_context_takeover`]&&this._deflate.reset(),r(null,n)})}};st.exports=be;function is(t){this[P].push(t),this[k]+=t.length}function tt(t){if(this[k]+=t.length,this[ne]._maxPayload<1||this[k]<=this[ne]._maxPayload){this[P].push(t);return}this[q]=new RangeError("Max payload size exceeded"),this[q].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[q][et]=1009,this.removeListener("data",tt),this.reset()}function ns(t){if(this[ne]._inflate=null,this[q]){this[W](this[q]);return}t[et]=1007,this[W](t)}});var $=S((Nr,oe)=>{"use strict";var{isUtf8:rt}=p("buffer"),{hasBlob:os}=T(),as=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0];function fs(t){return t>=1e3&&t<=1014&&t!==1004&&t!==1005&&t!==1006||t>=3e3&&t<=4999}function we(t){let e=t.length,s=0;for(;s<e;)if((t[s]&128)===0)s++;else if((t[s]&224)===192){if(s+1===e||(t[s+1]&192)!==128||(t[s]&254)===192)return!1;s+=2}else if((t[s]&240)===224){if(s+2>=e||(t[s+1]&192)!==128||(t[s+2]&192)!==128||t[s]===224&&(t[s+1]&224)===128||t[s]===237&&(t[s+1]&224)===160)return!1;s+=3}else if((t[s]&248)===240){if(s+3>=e||(t[s+1]&192)!==128||(t[s+2]&192)!==128||(t[s+3]&192)!==128||t[s]===240&&(t[s+1]&240)===128||t[s]===244&&t[s+1]>143||t[s]>244)return!1;s+=4}else return!1;return!0}function ls(t){return os&&typeof t=="object"&&typeof t.arrayBuffer=="function"&&typeof t.type=="string"&&typeof t.stream=="function"&&(t[Symbol.toStringTag]==="Blob"||t[Symbol.toStringTag]==="File")}oe.exports={isBlob:ls,isValidStatusCode:fs,isValidUTF8:we,tokenChars:as};if(rt)oe.exports.isValidUTF8=function(t){return t.length<24?we(t):rt(t)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let t=p("utf-8-validate");oe.exports.isValidUTF8=function(e){return e.length<32?we(e):t(e)}}catch{}});var Le=S((Pr,ht)=>{"use strict";var{Writable:hs}=p("stream"),it=G(),{BINARY_TYPES:cs,EMPTY_BUFFER:nt,kStatusCode:us,kWebSocket:ds}=T(),{concat:Oe,toArrayBuffer:_s,unmask:ms}=X(),{isValidStatusCode:ps,isValidUTF8:ot}=$(),ae=Buffer[Symbol.species],v=0,at=1,ft=2,lt=3,Te=4,ke=5,fe=6,Ce=class extends hs{constructor(e={}){super(),this._allowSynchronousEvents=e.allowSynchronousEvents!==void 0?e.allowSynchronousEvents:!0,this._binaryType=e.binaryType||cs[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxBufferedChunks=e.maxBufferedChunks|0,this._maxFragments=e.maxFragments|0,this._maxPayload=e.maxPayload|0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[ds]=void 0,this._bufferedBytes=0,this._buffers=[],this._compressed=!1,this._payloadLength=0,this._mask=void 0,this._fragmented=0,this._masked=!1,this._fin=!1,this._opcode=0,this._totalPayloadLength=0,this._messageLength=0,this._numFragments=0,this._fragments=[],this._errored=!1,this._loop=!1,this._state=v}_write(e,s,r){if(this._opcode===8&&this._state==v)return r();if(this._maxBufferedChunks>0&&this._buffers.length>=this._maxBufferedChunks){r(this.createError(RangeError,"Too many buffered chunks",!1,1008,"WS_ERR_TOO_MANY_BUFFERED_PARTS"));return}this._bufferedBytes+=e.length,this._buffers.push(e),this.startLoop(r)}consume(e){if(this._bufferedBytes-=e,e===this._buffers[0].length)return this._buffers.shift();if(e<this._buffers[0].length){let r=this._buffers[0];return this._buffers[0]=new ae(r.buffer,r.byteOffset+e,r.length-e),new ae(r.buffer,r.byteOffset,e)}let s=Buffer.allocUnsafe(e);do{let r=this._buffers[0],i=s.length-e;e>=r.length?s.set(this._buffers.shift(),i):(s.set(new Uint8Array(r.buffer,r.byteOffset,e),i),this._buffers[0]=new ae(r.buffer,r.byteOffset+e,r.length-e)),e-=r.length}while(e>0);return s}startLoop(e){this._loop=!0;do switch(this._state){case v:this.getInfo(e);break;case at:this.getPayloadLength16(e);break;case ft:this.getPayloadLength64(e);break;case lt:this.getMask();break;case Te:this.getData(e);break;case ke:case fe:this._loop=!1;return}while(this._loop);this._errored||e()}getInfo(e){if(this._bufferedBytes<2){this._loop=!1;return}let s=this.consume(2);if((s[0]&48)!==0){let i=this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");e(i);return}let r=(s[0]&64)===64;if(r&&!this._extensions[it.extensionName]){let i=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(i);return}if(this._fin=(s[0]&128)===128,this._opcode=s[0]&15,this._payloadLength=s[1]&127,this._opcode===0){if(r){let i=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(i);return}if(!this._fragmented){let i=this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");e(i);return}this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented){let i=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");e(i);return}this._compressed=r}else if(this._opcode>7&&this._opcode<11){if(!this._fin){let i=this.createError(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");e(i);return}if(r){let i=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(i);return}if(this._payloadLength>125||this._opcode===8&&this._payloadLength===1){let i=this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");e(i);return}}else{let i=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");e(i);return}if(!this._fin&&!this._fragmented&&(this._fragmented=this._opcode),this._masked=(s[1]&128)===128,this._isServer){if(!this._masked){let i=this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK");e(i);return}}else if(this._masked){let i=this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");e(i);return}this._payloadLength===126?this._state=at:this._payloadLength===127?this._state=ft:this.haveLength(e)}getPayloadLength16(e){if(this._bufferedBytes<2){this._loop=!1;return}this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength(e)}getPayloadLength64(e){if(this._bufferedBytes<8){this._loop=!1;return}let s=this.consume(8),r=s.readUInt32BE(0);if(r>Math.pow(2,21)-1){let i=this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH");e(i);return}this._payloadLength=r*Math.pow(2,32)+s.readUInt32BE(4),this.haveLength(e)}haveLength(e){if(this._payloadLength&&this._opcode<8&&(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0)){let s=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");e(s);return}this._masked?this._state=lt:this._state=Te}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=Te}getData(e){let s=nt;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;return}s=this.consume(this._payloadLength),this._masked&&(this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3])!==0&&ms(s,this._mask)}if(this._opcode>7){this.controlMessage(s,e);return}if(this._maxFragments>0&&++this._numFragments>this._maxFragments){let r=this.createError(RangeError,"Too many message fragments",!1,1008,"WS_ERR_TOO_MANY_BUFFERED_PARTS");e(r);return}if(this._compressed){this._state=ke,this.decompress(s,e);return}s.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(s)),this.dataMessage(e)}decompress(e,s){this._extensions[it.extensionName].decompress(e,this._fin,(i,n)=>{if(i)return s(i);if(n.length){if(this._messageLength+=n.length,this._messageLength>this._maxPayload&&this._maxPayload>0){let o=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");s(o);return}this._fragments.push(n)}this.dataMessage(s),this._state===v&&this.startLoop(s)})}dataMessage(e){if(!this._fin){this._state=v;return}let s=this._messageLength,r=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._numFragments=0,this._fragments=[],this._opcode===2){let i;this._binaryType==="nodebuffer"?i=Oe(r,s):this._binaryType==="arraybuffer"?i=_s(Oe(r,s)):this._binaryType==="blob"?i=new Blob(r):i=r,this._allowSynchronousEvents?(this.emit("message",i,!0),this._state=v):(this._state=fe,setImmediate(()=>{this.emit("message",i,!0),this._state=v,this.startLoop(e)}))}else{let i=Oe(r,s);if(!this._skipUTF8Validation&&!ot(i)){let n=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");e(n);return}this._state===ke||this._allowSynchronousEvents?(this.emit("message",i,!1),this._state=v):(this._state=fe,setImmediate(()=>{this.emit("message",i,!1),this._state=v,this.startLoop(e)}))}}controlMessage(e,s){if(this._opcode===8){if(e.length===0)this._loop=!1,this.emit("conclude",1005,nt),this.end();else{let r=e.readUInt16BE(0);if(!ps(r)){let n=this.createError(RangeError,`invalid status code ${r}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");s(n);return}let i=new ae(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!ot(i)){let n=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");s(n);return}this._loop=!1,this.emit("conclude",r,i),this.end()}this._state=v;return}this._allowSynchronousEvents?(this.emit(this._opcode===9?"ping":"pong",e),this._state=v):(this._state=fe,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",e),this._state=v,this.startLoop(s)}))}createError(e,s,r,i,n){this._loop=!1,this._errored=!0;let o=new e(r?`Invalid WebSocket frame: ${s}`:s);return Error.captureStackTrace(o,this.createError),o.code=n,o[us]=i,o}};ht.exports=Ce});var Be=S((Rr,dt)=>{"use strict";var{Duplex:Br}=p("stream"),{randomFillSync:gs}=p("crypto"),{types:{isUint8Array:ys}}=p("util"),ct=G(),{EMPTY_BUFFER:xs,kWebSocket:Ss,NOOP:Es}=T(),{isBlob:j,isValidStatusCode:vs}=$(),{mask:ut,toBuffer:R}=X(),b=Symbol("kByteLength"),bs=Buffer.alloc(4),le=8*1024,U,V=le,w=0,ws=1,Os=2,Ne=class t{constructor(e,s,r){this._extensions=s||{},r&&(this._generateMask=r,this._maskBuffer=Buffer.alloc(4)),this._socket=e,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._queue=[],this._state=w,this.onerror=Es,this[Ss]=void 0}static frame(e,s){let r,i=!1,n=2,o=!1;s.mask&&(r=s.maskBuffer||bs,s.generateMask?s.generateMask(r):(V===le&&(U===void 0&&(U=Buffer.alloc(le)),gs(U,0,le),V=0),r[0]=U[V++],r[1]=U[V++],r[2]=U[V++],r[3]=U[V++]),o=(r[0]|r[1]|r[2]|r[3])===0,n=6);let a;typeof e=="string"?(!s.mask||o)&&s[b]!==void 0?a=s[b]:(e=Buffer.from(e),a=e.length):(a=e.length,i=s.mask&&s.readOnly&&!o);let l=a;a>=65536?(n+=8,l=127):a>125&&(n+=2,l=126);let f=Buffer.allocUnsafe(i?a+n:n);return f[0]=s.fin?s.opcode|128:s.opcode,s.rsv1&&(f[0]|=64),f[1]=l,l===126?f.writeUInt16BE(a,2):l===127&&(f[2]=f[3]=0,f.writeUIntBE(a,4,6)),s.mask?(f[1]|=128,f[n-4]=r[0],f[n-3]=r[1],f[n-2]=r[2],f[n-1]=r[3],o?[f,e]:i?(ut(e,r,f,n,a),[f]):(ut(e,r,e,0,a),[f,e])):[f,e]}close(e,s,r,i){let n;if(e===void 0)n=xs;else{if(typeof e!="number"||!vs(e))throw new TypeError("First argument must be a valid error code number");if(s===void 0||!s.length)n=Buffer.allocUnsafe(2),n.writeUInt16BE(e,0);else{let a=Buffer.byteLength(s);if(a>123)throw new RangeError("The message must not be greater than 123 bytes");if(n=Buffer.allocUnsafe(2+a),n.writeUInt16BE(e,0),typeof s=="string")n.write(s,2);else if(ys(s))n.set(s,2);else throw new TypeError("Second argument must be a string or a Uint8Array")}}let o={[b]:n.length,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state!==w?this.enqueue([this.dispatch,n,!1,o,i]):this.sendFrame(t.frame(n,o),i)}ping(e,s,r){let i,n;if(typeof e=="string"?(i=Buffer.byteLength(e),n=!1):j(e)?(i=e.size,n=!1):(e=R(e),i=e.length,n=R.readOnly),i>125)throw new RangeError("The data size must not be greater than 125 bytes");let o={[b]:i,fin:!0,generateMask:this._generateMask,mask:s,maskBuffer:this._maskBuffer,opcode:9,readOnly:n,rsv1:!1};j(e)?this._state!==w?this.enqueue([this.getBlobData,e,!1,o,r]):this.getBlobData(e,!1,o,r):this._state!==w?this.enqueue([this.dispatch,e,!1,o,r]):this.sendFrame(t.frame(e,o),r)}pong(e,s,r){let i,n;if(typeof e=="string"?(i=Buffer.byteLength(e),n=!1):j(e)?(i=e.size,n=!1):(e=R(e),i=e.length,n=R.readOnly),i>125)throw new RangeError("The data size must not be greater than 125 bytes");let o={[b]:i,fin:!0,generateMask:this._generateMask,mask:s,maskBuffer:this._maskBuffer,opcode:10,readOnly:n,rsv1:!1};j(e)?this._state!==w?this.enqueue([this.getBlobData,e,!1,o,r]):this.getBlobData(e,!1,o,r):this._state!==w?this.enqueue([this.dispatch,e,!1,o,r]):this.sendFrame(t.frame(e,o),r)}send(e,s,r){let i=this._extensions[ct.extensionName],n=s.binary?2:1,o=s.compress,a,l;typeof e=="string"?(a=Buffer.byteLength(e),l=!1):j(e)?(a=e.size,l=!1):(e=R(e),a=e.length,l=R.readOnly),this._firstFragment?(this._firstFragment=!1,o&&i&&i.params[i._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(o=a>=i._threshold),this._compress=o):(o=!1,n=0),s.fin&&(this._firstFragment=!0);let f={[b]:a,fin:s.fin,generateMask:this._generateMask,mask:s.mask,maskBuffer:this._maskBuffer,opcode:n,readOnly:l,rsv1:o};j(e)?this._state!==w?this.enqueue([this.getBlobData,e,this._compress,f,r]):this.getBlobData(e,this._compress,f,r):this._state!==w?this.enqueue([this.dispatch,e,this._compress,f,r]):this.dispatch(e,this._compress,f,r)}getBlobData(e,s,r,i){this._bufferedBytes+=r[b],this._state=Os,e.arrayBuffer().then(n=>{if(this._socket.destroyed){let a=new Error("The socket was closed while the blob was being read");process.nextTick(Pe,this,a,i);return}this._bufferedBytes-=r[b];let o=R(n);s?this.dispatch(o,s,r,i):(this._state=w,this.sendFrame(t.frame(o,r),i),this.dequeue())}).catch(n=>{process.nextTick(Ts,this,n,i)})}dispatch(e,s,r,i){if(!s){this.sendFrame(t.frame(e,r),i);return}let n=this._extensions[ct.extensionName];this._bufferedBytes+=r[b],this._state=ws,n.compress(e,r.fin,(o,a)=>{if(this._socket.destroyed){let l=new Error("The socket was closed while data was being compressed");Pe(this,l,i);return}this._bufferedBytes-=r[b],this._state=w,r.readOnly=!1,this.sendFrame(t.frame(a,r),i),this.dequeue()})}dequeue(){for(;this._state===w&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=e[3][b],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][b],this._queue.push(e)}sendFrame(e,s){e.length===2?(this._socket.cork(),this._socket.write(e[0]),this._socket.write(e[1],s),this._socket.uncork()):this._socket.write(e[0],s)}};dt.exports=Ne;function Pe(t,e,s){typeof s=="function"&&s(e);for(let r=0;r<t._queue.length;r++){let i=t._queue[r],n=i[i.length-1];typeof n=="function"&&n(e)}}function Ts(t,e,s){Pe(t,e,s),t.onerror(e)}});var vt=S((Ur,Et)=>{"use strict";var{kForOnEventAttribute:Q,kListener:Re}=T(),_t=Symbol("kCode"),mt=Symbol("kData"),pt=Symbol("kError"),gt=Symbol("kMessage"),yt=Symbol("kReason"),z=Symbol("kTarget"),xt=Symbol("kType"),St=Symbol("kWasClean"),C=class{constructor(e){this[z]=null,this[xt]=e}get target(){return this[z]}get type(){return this[xt]}};Object.defineProperty(C.prototype,"target",{enumerable:!0});Object.defineProperty(C.prototype,"type",{enumerable:!0});var I=class extends C{constructor(e,s={}){super(e),this[_t]=s.code===void 0?0:s.code,this[yt]=s.reason===void 0?"":s.reason,this[St]=s.wasClean===void 0?!1:s.wasClean}get code(){return this[_t]}get reason(){return this[yt]}get wasClean(){return this[St]}};Object.defineProperty(I.prototype,"code",{enumerable:!0});Object.defineProperty(I.prototype,"reason",{enumerable:!0});Object.defineProperty(I.prototype,"wasClean",{enumerable:!0});var H=class extends C{constructor(e,s={}){super(e),this[pt]=s.error===void 0?null:s.error,this[gt]=s.message===void 0?"":s.message}get error(){return this[pt]}get message(){return this[gt]}};Object.defineProperty(H.prototype,"error",{enumerable:!0});Object.defineProperty(H.prototype,"message",{enumerable:!0});var J=class extends C{constructor(e,s={}){super(e),this[mt]=s.data===void 0?null:s.data}get data(){return this[mt]}};Object.defineProperty(J.prototype,"data",{enumerable:!0});var ks={addEventListener(t,e,s={}){for(let i of this.listeners(t))if(!s[Q]&&i[Re]===e&&!i[Q])return;let r;if(t==="message")r=function(n,o){let a=new J("message",{data:o?n:n.toString()});a[z]=this,he(e,this,a)};else if(t==="close")r=function(n,o){let a=new I("close",{code:n,reason:o.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});a[z]=this,he(e,this,a)};else if(t==="error")r=function(n){let o=new H("error",{error:n,message:n.message});o[z]=this,he(e,this,o)};else if(t==="open")r=function(){let n=new C("open");n[z]=this,he(e,this,n)};else return;r[Q]=!!s[Q],r[Re]=e,s.once?this.once(t,r):this.on(t,r)},removeEventListener(t,e){for(let s of this.listeners(t))if(s[Re]===e&&!s[Q]){this.removeListener(t,s);break}}};Et.exports={CloseEvent:I,ErrorEvent:H,Event:C,EventTarget:ks,MessageEvent:J};function he(t,e,s){typeof t=="object"&&t.handleEvent?t.handleEvent.call(t,s):t.call(e,s)}});var ce=S((Ir,bt)=>{"use strict";var{tokenChars:ee}=$();function O(t,e,s){t[e]===void 0?t[e]=[s]:t[e].push(s)}function Cs(t){let e=Object.create(null),s=Object.create(null),r=!1,i=!1,n=!1,o,a,l=-1,f=-1,h=-1,c=0;for(;c<t.length;c++)if(f=t.charCodeAt(c),o===void 0)if(h===-1&&ee[f]===1)l===-1&&(l=c);else if(c!==0&&(f===32||f===9))h===-1&&l!==-1&&(h=c);else if(f===59||f===44){if(l===-1)throw new SyntaxError(`Unexpected character at index ${c}`);h===-1&&(h=c);let g=t.slice(l,h);f===44?(O(e,g,s),s=Object.create(null)):o=g,l=h=-1}else throw new SyntaxError(`Unexpected character at index ${c}`);else if(a===void 0)if(h===-1&&ee[f]===1)l===-1&&(l=c);else if(f===32||f===9)h===-1&&l!==-1&&(h=c);else if(f===59||f===44){if(l===-1)throw new SyntaxError(`Unexpected character at index ${c}`);h===-1&&(h=c),O(s,t.slice(l,h),!0),f===44&&(O(e,o,s),s=Object.create(null),o=void 0),l=h=-1}else if(f===61&&l!==-1&&h===-1)a=t.slice(l,c),l=h=-1;else throw new SyntaxError(`Unexpected character at index ${c}`);else if(i){if(ee[f]!==1)throw new SyntaxError(`Unexpected character at index ${c}`);l===-1?l=c:r||(r=!0),i=!1}else if(n)if(ee[f]===1)l===-1&&(l=c);else if(f===34&&l!==-1)n=!1,h=c;else if(f===92)i=!0;else throw new SyntaxError(`Unexpected character at index ${c}`);else if(f===34&&t.charCodeAt(c-1)===61)n=!0;else if(h===-1&&ee[f]===1)l===-1&&(l=c);else if(l!==-1&&(f===32||f===9))h===-1&&(h=c);else if(f===59||f===44){if(l===-1)throw new SyntaxError(`Unexpected character at index ${c}`);h===-1&&(h=c);let g=t.slice(l,h);r&&(g=g.replace(/\\/g,""),r=!1),O(s,a,g),f===44&&(O(e,o,s),s=Object.create(null),o=void 0),a=void 0,l=h=-1}else throw new SyntaxError(`Unexpected character at index ${c}`);if(l===-1||n||f===32||f===9)throw new SyntaxError("Unexpected end of input");h===-1&&(h=c);let _=t.slice(l,h);return o===void 0?O(e,_,s):(a===void 0?O(s,_,!0):r?O(s,a,_.replace(/\\/g,"")):O(s,a,_),O(e,o,s)),e}function Ls(t){return Object.keys(t).map(e=>{let s=t[e];return Array.isArray(s)||(s=[s]),s.map(r=>[e].concat(Object.keys(r).map(i=>{let n=r[i];return Array.isArray(n)||(n=[n]),n.map(o=>o===!0?i:`${i}=${o}`).join("; ")})).join("; ")).join(", ")}).join(", ")}bt.exports={format:Ls,parse:Cs}});var me=S((Mr,It)=>{"use strict";var Ns=p("events"),Ps=p("https"),Bs=p("http"),Tt=p("net"),Rs=p("tls"),{randomBytes:Us,createHash:Is}=p("crypto"),{Duplex:Dr,Readable:Ar}=p("stream"),{URL:Ue}=p("url"),B=G(),Ds=Le(),As=Be(),{isBlob:Ms}=$(),{BINARY_TYPES:wt,CLOSE_TIMEOUT:Fs,EMPTY_BUFFER:ue,GUID:Ws,kForOnEventAttribute:Ie,kListener:qs,kStatusCode:Gs,kWebSocket:y,NOOP:kt}=T(),{EventTarget:{addEventListener:$s,removeEventListener:js}}=vt(),{format:Vs,parse:zs}=ce(),{toBuffer:Hs}=X(),Ct=Symbol("kAborted"),De=[8,13],L=["CONNECTING","OPEN","CLOSING","CLOSED"],Ys=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,d=class t extends Ns{constructor(e,s,r){super(),this._binaryType=wt[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=ue,this._closeTimer=null,this._errorEmitted=!1,this._extensions={},this._paused=!1,this._protocol="",this._readyState=t.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,e!==null?(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,s===void 0?!r||r.protocols===void 0?s=[]:Array.isArray(r.protocols)?s=r.protocols:s=[r.protocols]:Array.isArray(s)||(typeof s=="object"&&s!==null?(r=s,r.protocols===void 0?s=[]:Array.isArray(r.protocols)?s=r.protocols:s=[r.protocols]):s=[s]),Lt(this,e,s,r)):(this._autoPong=r.autoPong,this._closeTimeout=r.closeTimeout,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(e){wt.includes(e)&&(this._binaryType=e,this._receiver&&(this._receiver._binaryType=e))}get bufferedAmount(){return this._socket?this._socket._writableState.length+this._sender._bufferedBytes:this._bufferedAmount}get extensions(){return Object.keys(this._extensions).join()}get isPaused(){return this._paused}get onclose(){return null}get onerror(){return null}get onopen(){return null}get onmessage(){return null}get protocol(){return this._protocol}get readyState(){return this._readyState}get url(){return this._url}setSocket(e,s,r){let i=new Ds({allowSynchronousEvents:r.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxBufferedChunks:r.maxBufferedChunks,maxFragments:r.maxFragments,maxPayload:r.maxPayload,skipUTF8Validation:r.skipUTF8Validation}),n=new As(e,this._extensions,r.generateMask);this._receiver=i,this._sender=n,this._socket=e,i[y]=this,n[y]=this,e[y]=this,i.on("conclude",Zs),i.on("drain",Qs),i.on("error",Js),i.on("message",er),i.on("ping",tr),i.on("pong",sr),n.onerror=rr,e.setTimeout&&e.setTimeout(0),e.setNoDelay&&e.setNoDelay(),s.length>0&&e.unshift(s),e.on("close",Bt),e.on("data",_e),e.on("end",Rt),e.on("error",Ut),this._readyState=t.OPEN,this.emit("open")}emitClose(){if(!this._socket){this._readyState=t.CLOSED,this.emit("close",this._closeCode,this._closeMessage);return}this._extensions[B.extensionName]&&this._extensions[B.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=t.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(e,s){if(this.readyState!==t.CLOSED){if(this.readyState===t.CONNECTING){E(this,this._req,"WebSocket was closed before the connection was established");return}if(this.readyState===t.CLOSING){this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end();return}this._sender.close(e,s,!this._isServer,r=>{r||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())}),this._readyState=t.CLOSING,Pt(this)}}pause(){this.readyState===t.CONNECTING||this.readyState===t.CLOSED||(this._paused=!0,this._socket.pause())}ping(e,s,r){if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(r=e,e=s=void 0):typeof s=="function"&&(r=s,s=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){Ae(this,e,r);return}s===void 0&&(s=!this._isServer),this._sender.ping(e||ue,s,r)}pong(e,s,r){if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(r=e,e=s=void 0):typeof s=="function"&&(r=s,s=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){Ae(this,e,r);return}s===void 0&&(s=!this._isServer),this._sender.pong(e||ue,s,r)}resume(){this.readyState===t.CONNECTING||this.readyState===t.CLOSED||(this._paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(e,s,r){if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof s=="function"&&(r=s,s={}),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){Ae(this,e,r);return}let i={binary:typeof e!="string",mask:!this._isServer,compress:!0,fin:!0,...s};this._extensions[B.extensionName]||(i.compress=!1),this._sender.send(e||ue,i,r)}terminate(){if(this.readyState!==t.CLOSED){if(this.readyState===t.CONNECTING){E(this,this._req,"WebSocket was closed before the connection was established");return}this._socket&&(this._readyState=t.CLOSING,this._socket.destroy())}}};Object.defineProperty(d,"CONNECTING",{enumerable:!0,value:L.indexOf("CONNECTING")});Object.defineProperty(d.prototype,"CONNECTING",{enumerable:!0,value:L.indexOf("CONNECTING")});Object.defineProperty(d,"OPEN",{enumerable:!0,value:L.indexOf("OPEN")});Object.defineProperty(d.prototype,"OPEN",{enumerable:!0,value:L.indexOf("OPEN")});Object.defineProperty(d,"CLOSING",{enumerable:!0,value:L.indexOf("CLOSING")});Object.defineProperty(d.prototype,"CLOSING",{enumerable:!0,value:L.indexOf("CLOSING")});Object.defineProperty(d,"CLOSED",{enumerable:!0,value:L.indexOf("CLOSED")});Object.defineProperty(d.prototype,"CLOSED",{enumerable:!0,value:L.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(t=>{Object.defineProperty(d.prototype,t,{enumerable:!0})});["open","error","close","message"].forEach(t=>{Object.defineProperty(d.prototype,`on${t}`,{enumerable:!0,get(){for(let e of this.listeners(t))if(e[Ie])return e[qs];return null},set(e){for(let s of this.listeners(t))if(s[Ie]){this.removeListener(t,s);break}typeof e=="function"&&this.addEventListener(t,e,{[Ie]:!0})}})});d.prototype.addEventListener=$s;d.prototype.removeEventListener=js;It.exports=d;function Lt(t,e,s,r){let i={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:Fs,protocolVersion:De[1],maxBufferedChunks:262144,maxFragments:16384,maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...r,socketPath:void 0,hostname:void 0,protocol:void 0,protocols:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0};if(t._autoPong=i.autoPong,t._closeTimeout=i.closeTimeout,!De.includes(i.protocolVersion))throw new RangeError(`Unsupported protocol version: ${i.protocolVersion} (supported versions: ${De.join(", ")})`);let n;if(e instanceof Ue)n=e;else try{n=new Ue(e)}catch{throw new SyntaxError(`Invalid URL: ${e}`)}n.protocol==="http:"?n.protocol="ws:":n.protocol==="https:"&&(n.protocol="wss:"),t._url=n.href;let o=n.protocol==="wss:",a=n.protocol==="ws+unix:",l;if(n.protocol!=="ws:"&&!o&&!a?l=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`:a&&!n.pathname?l="The URL's pathname is empty":n.hash&&(l="The URL contains a fragment identifier"),l){let u=new SyntaxError(l);if(t._redirects===0)throw u;de(t,u);return}let f=o?443:80,h=Us(16).toString("base64"),c=o?Ps.request:Bs.request,_=new Set,g;if(i.createConnection=i.createConnection||(o?Xs:Ks),i.defaultPort=i.defaultPort||f,i.port=n.port||f,i.host=n.hostname.startsWith("[")?n.hostname.slice(1,-1):n.hostname,i.headers={...i.headers,"Sec-WebSocket-Version":i.protocolVersion,"Sec-WebSocket-Key":h,Connection:"Upgrade",Upgrade:"websocket"},i.path=n.pathname+n.search,i.timeout=i.handshakeTimeout,i.perMessageDeflate&&(g=new B({...i.perMessageDeflate,isServer:!1,maxPayload:i.maxPayload}),i.headers["Sec-WebSocket-Extensions"]=Vs({[B.extensionName]:g.offer()})),s.length){for(let u of s){if(typeof u!="string"||!Ys.test(u)||_.has(u))throw new SyntaxError("An invalid or duplicated subprotocol was specified");_.add(u)}i.headers["Sec-WebSocket-Protocol"]=s.join(",")}if(i.origin&&(i.protocolVersion<13?i.headers["Sec-WebSocket-Origin"]=i.origin:i.headers.Origin=i.origin),(n.username||n.password)&&(i.auth=`${n.username}:${n.password}`),a){let u=i.path.split(":");i.socketPath=u[0],i.path=u[1]}let m;if(i.followRedirects){if(t._redirects===0){t._originalIpc=a,t._originalSecure=o,t._originalHostOrSocketPath=a?i.socketPath:n.host;let u=r&&r.headers;if(r={...r,headers:{}},u)for(let[x,M]of Object.entries(u))r.headers[x.toLowerCase()]=M}else if(t.listenerCount("redirect")===0){let u=a?t._originalIpc?i.socketPath===t._originalHostOrSocketPath:!1:t._originalIpc?!1:n.host===t._originalHostOrSocketPath;(!u||t._originalSecure&&!o)&&(delete i.headers.authorization,delete i.headers.cookie,u||delete i.headers.host,i.auth=void 0)}i.auth&&!r.headers.authorization&&(r.headers.authorization="Basic "+Buffer.from(i.auth).toString("base64")),m=t._req=c(i),t._redirects&&t.emit("redirect",t.url,m)}else m=t._req=c(i);i.timeout&&m.on("timeout",()=>{E(t,m,"Opening handshake has timed out")}),m.on("error",u=>{m===null||m[Ct]||(m=t._req=null,de(t,u))}),m.on("response",u=>{let x=u.headers.location,M=u.statusCode;if(x&&i.followRedirects&&M>=300&&M<400){if(++t._redirects>i.maxRedirects){E(t,m,"Maximum redirects exceeded");return}m.abort();let Y;try{Y=new Ue(x,e)}catch{let F=new SyntaxError(`Invalid URL: ${x}`);de(t,F);return}Lt(t,Y,s,r)}else t.emit("unexpected-response",m,u)||E(t,m,`Unexpected server response: ${u.statusCode}`)}),m.on("upgrade",(u,x,M)=>{if(t.emit("upgrade",u),t.readyState!==d.CONNECTING)return;m=t._req=null;let Y=u.headers.upgrade;if(Y===void 0||Y.toLowerCase()!=="websocket"){E(t,x,"Invalid Upgrade header");return}let We=Is("sha1").update(h+Ws).digest("base64");if(u.headers["sec-websocket-accept"]!==We){E(t,x,"Invalid Sec-WebSocket-Accept header");return}let F=u.headers["sec-websocket-protocol"],K;if(F!==void 0?_.size?_.has(F)||(K="Server sent an invalid subprotocol"):K="Server sent a subprotocol but none was requested":_.size&&(K="Server sent no subprotocol"),K){E(t,x,K);return}F&&(t._protocol=F);let qe=u.headers["sec-websocket-extensions"];if(qe!==void 0){if(!g){E(t,x,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let ge;try{ge=zs(qe)}catch{E(t,x,"Invalid Sec-WebSocket-Extensions header");return}let Ge=Object.keys(ge);if(Ge.length!==1||Ge[0]!==B.extensionName){E(t,x,"Server indicated an extension that was not requested");return}try{g.accept(ge[B.extensionName])}catch{E(t,x,"Invalid Sec-WebSocket-Extensions header");return}t._extensions[B.extensionName]=g}t.setSocket(x,M,{allowSynchronousEvents:i.allowSynchronousEvents,generateMask:i.generateMask,maxBufferedChunks:i.maxBufferedChunks,maxFragments:i.maxFragments,maxPayload:i.maxPayload,skipUTF8Validation:i.skipUTF8Validation})}),i.finishRequest?i.finishRequest(m,t):m.end()}function de(t,e){t._readyState=d.CLOSING,t._errorEmitted=!0,t.emit("error",e),t.emitClose()}function Ks(t){return t.path=t.socketPath,Tt.connect(t)}function Xs(t){return t.path=void 0,!t.servername&&t.servername!==""&&(t.servername=Tt.isIP(t.host)?"":t.host),Rs.connect(t)}function E(t,e,s){t._readyState=d.CLOSING;let r=new Error(s);Error.captureStackTrace(r,E),e.setHeader?(e[Ct]=!0,e.abort(),e.socket&&!e.socket.destroyed&&e.socket.destroy(),process.nextTick(de,t,r)):(e.destroy(r),e.once("error",t.emit.bind(t,"error")),e.once("close",t.emitClose.bind(t)))}function Ae(t,e,s){if(e){let r=Ms(e)?e.size:Hs(e).length;t._socket?t._sender._bufferedBytes+=r:t._bufferedAmount+=r}if(s){let r=new Error(`WebSocket is not open: readyState ${t.readyState} (${L[t.readyState]})`);process.nextTick(s,r)}}function Zs(t,e){let s=this[y];s._closeFrameReceived=!0,s._closeMessage=e,s._closeCode=t,s._socket[y]!==void 0&&(s._socket.removeListener("data",_e),process.nextTick(Nt,s._socket),t===1005?s.close():s.close(t,e))}function Qs(){let t=this[y];t.isPaused||t._socket.resume()}function Js(t){let e=this[y];e._socket[y]!==void 0&&(e._socket.removeListener("data",_e),process.nextTick(Nt,e._socket),e.close(t[Gs])),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t))}function Ot(){this[y].emitClose()}function er(t,e){this[y].emit("message",t,e)}function tr(t){let e=this[y];e._autoPong&&e.pong(t,!this._isServer,kt),e.emit("ping",t)}function sr(t){this[y].emit("pong",t)}function Nt(t){t.resume()}function rr(t){let e=this[y];e.readyState!==d.CLOSED&&(e.readyState===d.OPEN&&(e._readyState=d.CLOSING,Pt(e)),this._socket.end(),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t)))}function Pt(t){t._closeTimer=setTimeout(t._socket.destroy.bind(t._socket),t._closeTimeout)}function Bt(){let t=this[y];if(this.removeListener("close",Bt),this.removeListener("data",_e),this.removeListener("end",Rt),t._readyState=d.CLOSING,!this._readableState.endEmitted&&!t._closeFrameReceived&&!t._receiver._writableState.errorEmitted&&this._readableState.length!==0){let e=this.read(this._readableState.length);t._receiver.write(e)}t._receiver.end(),this[y]=void 0,clearTimeout(t._closeTimer),t._receiver._writableState.finished||t._receiver._writableState.errorEmitted?t.emitClose():(t._receiver.on("error",Ot),t._receiver.on("finish",Ot))}function _e(t){this[y]._receiver.write(t)||this.pause()}function Rt(){let t=this[y];t._readyState=d.CLOSING,t._receiver.end(),this.end()}function Ut(){let t=this[y];this.removeListener("error",Ut),this.on("error",kt),t&&(t._readyState=d.CLOSING,this.destroy())}});var Ft=S((Wr,Mt)=>{"use strict";var Fr=me(),{Duplex:ir}=p("stream");function Dt(t){t.emit("close")}function nr(){!this.destroyed&&this._writableState.finished&&this.destroy()}function At(t){this.removeListener("error",At),this.destroy(),this.listenerCount("error")===0&&this.emit("error",t)}function or(t,e){let s=!0,r=new ir({...e,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return t.on("message",function(n,o){let a=!o&&r._readableState.objectMode?n.toString():n;r.push(a)||t.pause()}),t.once("error",function(n){r.destroyed||(s=!1,r.destroy(n))}),t.once("close",function(){r.destroyed||r.push(null)}),r._destroy=function(i,n){if(t.readyState===t.CLOSED){n(i),process.nextTick(Dt,r);return}let o=!1;t.once("error",function(l){o=!0,n(l)}),t.once("close",function(){o||n(i),process.nextTick(Dt,r)}),s&&t.terminate()},r._final=function(i){if(t.readyState===t.CONNECTING){t.once("open",function(){r._final(i)});return}t._socket!==null&&(t._socket._writableState.finished?(i(),r._readableState.endEmitted&&r.destroy()):(t._socket.once("finish",function(){i()}),t.close()))},r._read=function(){t.isPaused&&t.resume()},r._write=function(i,n,o){if(t.readyState===t.CONNECTING){t.once("open",function(){r._write(i,n,o)});return}t.send(i,o)},r.on("end",nr),r.on("error",At),r}Mt.exports=or});var Me=S((qr,Wt)=>{"use strict";var{tokenChars:ar}=$();function fr(t){let e=new Set,s=-1,r=-1,i=0;for(i;i<t.length;i++){let o=t.charCodeAt(i);if(r===-1&&ar[o]===1)s===-1&&(s=i);else if(i!==0&&(o===32||o===9))r===-1&&s!==-1&&(r=i);else if(o===44){if(s===-1)throw new SyntaxError(`Unexpected character at index ${i}`);r===-1&&(r=i);let a=t.slice(s,r);if(e.has(a))throw new SyntaxError(`The "${a}" subprotocol is duplicated`);e.add(a),s=r=-1}else throw new SyntaxError(`Unexpected character at index ${i}`)}if(s===-1||r!==-1)throw new SyntaxError("Unexpected end of input");let n=t.slice(s,i);if(e.has(n))throw new SyntaxError(`The "${n}" subprotocol is duplicated`);return e.add(n),e}Wt.exports={parse:fr}});var Ht=S(($r,zt)=>{"use strict";var lr=p("events"),pe=p("http"),{Duplex:Gr}=p("stream"),{createHash:hr}=p("crypto"),qt=ce(),D=G(),cr=Me(),ur=me(),{CLOSE_TIMEOUT:dr,GUID:_r,kWebSocket:mr}=T(),pr=/^[+/0-9A-Za-z]{22}==$/,Gt=0,$t=1,Vt=2,Fe=class extends lr{constructor(e,s){if(super(),e={allowSynchronousEvents:!0,autoPong:!0,maxBufferedChunks:256*1024,maxFragments:16*1024,maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:dr,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:ur,...e},e.port==null&&!e.server&&!e.noServer||e.port!=null&&(e.server||e.noServer)||e.server&&e.noServer)throw new TypeError('One and only one of the "port", "server", or "noServer" options must be specified');if(e.port!=null?(this._server=pe.createServer((r,i)=>{let n=pe.STATUS_CODES[426];i.writeHead(426,{"Content-Length":n.length,"Content-Type":"text/plain"}),i.end(n)}),this._server.listen(e.port,e.host,e.backlog,s)):e.server&&(this._server=e.server),this._server){let r=this.emit.bind(this,"connection");this._removeListeners=gr(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(i,n,o)=>{this.handleUpgrade(i,n,o,r)}})}e.perMessageDeflate===!0&&(e.perMessageDeflate={}),e.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=e,this._state=Gt}address(){if(this.options.noServer)throw new Error('The server is operating in "noServer" mode');return this._server?this._server.address():null}close(e){if(this._state===Vt){e&&this.once("close",()=>{e(new Error("The server is not running"))}),process.nextTick(te,this);return}if(e&&this.once("close",e),this._state!==$t)if(this._state=$t,this.options.noServer||this.options.server)this._server&&(this._removeListeners(),this._removeListeners=this._server=null),this.clients?this.clients.size?this._shouldEmitClose=!0:process.nextTick(te,this):process.nextTick(te,this);else{let s=this._server;this._removeListeners(),this._removeListeners=this._server=null,s.close(()=>{te(this)})}}shouldHandle(e){if(this.options.path){let s=e.url.indexOf("?");if((s!==-1?e.url.slice(0,s):e.url)!==this.options.path)return!1}return!0}handleUpgrade(e,s,r,i){s.on("error",jt);let n=e.headers["sec-websocket-key"],o=e.headers.upgrade,a=+e.headers["sec-websocket-version"];if(e.method!=="GET"){A(this,e,s,405,"Invalid HTTP method");return}if(o===void 0||o.toLowerCase()!=="websocket"){A(this,e,s,400,"Invalid Upgrade header");return}if(n===void 0||!pr.test(n)){A(this,e,s,400,"Missing or invalid Sec-WebSocket-Key header");return}if(a!==13&&a!==8){A(this,e,s,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}if(!this.shouldHandle(e)){se(s,400);return}let l=e.headers["sec-websocket-protocol"],f=new Set;if(l!==void 0)try{f=cr.parse(l)}catch{A(this,e,s,400,"Invalid Sec-WebSocket-Protocol header");return}let h=e.headers["sec-websocket-extensions"],c={};if(this.options.perMessageDeflate&&h!==void 0){let _=new D({...this.options.perMessageDeflate,isServer:!0,maxPayload:this.options.maxPayload});try{let g=qt.parse(h);g[D.extensionName]&&(_.accept(g[D.extensionName]),c[D.extensionName]=_)}catch{A(this,e,s,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let _={origin:e.headers[`${a===8?"sec-websocket-origin":"origin"}`],secure:!!(e.socket.authorized||e.socket.encrypted),req:e};if(this.options.verifyClient.length===2){this.options.verifyClient(_,(g,m,u,x)=>{if(!g)return se(s,m||401,u,x);this.completeUpgrade(c,n,f,e,s,r,i)});return}if(!this.options.verifyClient(_))return se(s,401)}this.completeUpgrade(c,n,f,e,s,r,i)}completeUpgrade(e,s,r,i,n,o,a){if(!n.readable||!n.writable)return n.destroy();if(n[mr])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>Gt)return se(n,503);let f=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${hr("sha1").update(s+_r).digest("base64")}`],h=new this.options.WebSocket(null,void 0,this.options);if(r.size){let c=this.options.handleProtocols?this.options.handleProtocols(r,i):r.values().next().value;c&&(f.push(`Sec-WebSocket-Protocol: ${c}`),h._protocol=c)}if(e[D.extensionName]){let c=e[D.extensionName].params,_=qt.format({[D.extensionName]:[c]});f.push(`Sec-WebSocket-Extensions: ${_}`),h._extensions=e}this.emit("headers",f,i),n.write(f.concat(`\r
3
3
  `).join(`\r
4
4
  `)),n.removeListener("error",jt),h.setSocket(n,o,{allowSynchronousEvents:this.options.allowSynchronousEvents,maxBufferedChunks:this.options.maxBufferedChunks,maxFragments:this.options.maxFragments,maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation}),this.clients&&(this.clients.add(h),h.on("close",()=>{this.clients.delete(h),this._shouldEmitClose&&!this.clients.size&&process.nextTick(te,this)})),a(h,i)}};zt.exports=Fe;function gr(t,e){for(let s of Object.keys(e))t.on(s,e[s]);return function(){for(let r of Object.keys(e))t.removeListener(r,e[r])}}function te(t){t._state=Vt,t.emit("close")}function jt(){this.destroy()}function se(t,e,s,r){s=s||pe.STATUS_CODES[e],r={Connection:"close","Content-Type":"text/html","Content-Length":Buffer.byteLength(s),...r},t.once("finish",t.destroy),t.end(`HTTP/1.1 ${e} ${pe.STATUS_CODES[e]}\r
5
5
  `+Object.keys(r).map(i=>`${i}: ${r[i]}`).join(`\r
@@ -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 H,f as K,g as Q}from"./chunk-OJKMINIU.mjs";import{d as D,f as E,g as T,h as F}from"./chunk-FWNRPMCJ.mjs";import{existsSync as R}from"node:fs";var U=120;function W(n,I){let p=({packages:s,problems:c})=>new Map([...s,...c].map(([a,{stamp:t}])=>[a,t])),[l,f]=[p(n),p(I)];return[...new Set([...l.keys(),...f.keys()])].filter(s=>l.get(s)!==f.get(s)).sort()}function A({root:n,tell:I,delay:p=U,quiet:l=Q,hold:f=H,limit:s=K,now:c=Date.now,timers:a={set:(t,m)=>setTimeout(t,m),clear:t=>clearTimeout(t)}}){let t=null,m=0,u=null,r=new Map;T(n);let M=i=>{t&&m<=c()+i||(a.clear(t),m=c()+i,t=a.set(w,i),t.unref?.())};function w({settled:i=!1}={}){t=null;let d=T(n),o=E(n,d.settings),b=c();o.stamp!==u?.stamp&&(u={stamp:o.stamp,at:b});let y=b-u.at;if(y<l&&!i)return M(l-y);let g=new Map(o.packages),k=new Map(o.problems),h=1/0;for(let[e,L]of d.packages){if(!(!o.settings.disabled.includes(e)&&(k.has(e)||!g.has(e)&&R(L.folder)))){r.delete(e);continue}r.has(e)||r.set(e,u.at);let O=Math.min(f-y,s-(b-r.get(e)));if(O<=0){r.delete(e);continue}g.set(e,L),k.delete(e),h=Math.min(h,O)}let{settings:C,packs:S}=o,x=D({packages:g,problems:k,settings:C,packs:S});if(x!==d.stamp){let e={packages:g,problems:k,settings:C,packs:S,stamp:x};F(n,e),I(e,W(d,e))}h!==1/0&&M(h)}return{changed:()=>M(p),taken(){a.clear(t),w({settled:!0})},close(){a.clear(t),t=null}}}export{U as a,A as b};
2
+ import{e as H,f as K,g as Q}from"./chunk-OU3S466R.mjs";import{d as D,f as E,g as T,h as F}from"./chunk-VG5JEIUQ.mjs";import{existsSync as R}from"node:fs";var U=120;function W(n,I){let p=({packages:s,problems:c})=>new Map([...s,...c].map(([a,{stamp:t}])=>[a,t])),[l,f]=[p(n),p(I)];return[...new Set([...l.keys(),...f.keys()])].filter(s=>l.get(s)!==f.get(s)).sort()}function A({root:n,tell:I,delay:p=U,quiet:l=Q,hold:f=H,limit:s=K,now:c=Date.now,timers:a={set:(t,m)=>setTimeout(t,m),clear:t=>clearTimeout(t)}}){let t=null,m=0,u=null,r=new Map;T(n);let M=i=>{t&&m<=c()+i||(a.clear(t),m=c()+i,t=a.set(w,i),t.unref?.())};function w({settled:i=!1}={}){t=null;let d=T(n),o=E(n,d.settings),b=c();o.stamp!==u?.stamp&&(u={stamp:o.stamp,at:b});let y=b-u.at;if(y<l&&!i)return M(l-y);let g=new Map(o.packages),k=new Map(o.problems),h=1/0;for(let[e,L]of d.packages){if(!(!o.settings.disabled.includes(e)&&(k.has(e)||!g.has(e)&&R(L.folder)))){r.delete(e);continue}r.has(e)||r.set(e,u.at);let O=Math.min(f-y,s-(b-r.get(e)));if(O<=0){r.delete(e);continue}g.set(e,L),k.delete(e),h=Math.min(h,O)}let{settings:C,packs:S}=o,x=D({packages:g,problems:k,settings:C,packs:S});if(x!==d.stamp){let e={packages:g,problems:k,settings:C,packs:S,stamp:x};F(n,e),I(e,W(d,e))}h!==1/0&&M(h)}return{changed:()=>M(p),taken(){a.clear(t),w({settled:!0})},close(){a.clear(t),t=null}}}export{U as a,A as b};
@@ -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{c as _}from"./chunk-BYSF5UMM.mjs";import{n as G,p as Le,r as Ee,s as Ne,t as Ie,x as Oe}from"./chunk-3OFXMN6N.mjs";import{c as he,d as pe,e as ue,f as fe,g as we,h as ge,i as me,j as z,l as $e,n as Y,o as ke,q as be,r as ye,s as xe,t as ve,u as Se}from"./chunk-SOD23RGL.mjs";import{M as Ae}from"./chunk-4DNHHJSL.mjs";import"./chunk-342HXE3Q.mjs";import"./chunk-3A5I2GJK.mjs";import{d as Ce,g as je}from"./chunk-5L26JUYA.mjs";import"./chunk-S2Y7VI4H.mjs";import"./chunk-XQRUG4G3.mjs";import{i as ie}from"./chunk-JJNRIFND.mjs";import{a as W}from"./chunk-JEUK3ZO7.mjs";import"./chunk-CG3UHDKH.mjs";import{a as re,b as le,e as de,f as K,g as ce}from"./chunk-4AMTKWDO.mjs";import"./chunk-QXVNUASA.mjs";import"./chunk-FCK6NXON.mjs";import"./chunk-OU3S466R.mjs";import"./chunk-QK3VISCA.mjs";import"./chunk-2OHANJ6Q.mjs";import"./chunk-F4ZA6JRZ.mjs";import"./chunk-7M2BQQGZ.mjs";import"./chunk-TOE6DPLH.mjs";import"./chunk-WTEGUPFG.mjs";import"./chunk-2GKGEVMR.mjs";import{a as H,b as j,c as P,d as D,f as oe}from"./chunk-VKSRM7EY.mjs";import{a as te,e as B,f as ae}from"./chunk-LE44MD3O.mjs";import{b as se}from"./chunk-4OZWXZE5.mjs";import"./chunk-XMKHCUI6.mjs";import"./chunk-SAHS56QM.mjs";import"./chunk-KH24LWAT.mjs";import"./chunk-YFJU3O7G.mjs";import"./chunk-NWRZXELO.mjs";import{j as ne}from"./chunk-G4YP7GVC.mjs";import"./chunk-DHB7UZ7F.mjs";import"./chunk-2RKIHJI2.mjs";import"./chunk-JXLSHVJ2.mjs";import"./chunk-XKOHV4H6.mjs";import"./chunk-KFZBYDIS.mjs";import"./chunk-7XDYK3UC.mjs";import{f as Z,j as ee}from"./chunk-VG5JEIUQ.mjs";import{b as X,e as _e}from"./chunk-N3DSBH5S.mjs";import"./chunk-5L7RYZCL.mjs";_e();import{existsSync as Ue}from"node:fs";import R from"node:fs/promises";import O from"node:path";import{isInstance as Ke}from"../browser/shared/components/index.mjs";import{ATTRIBUTE as He,INSTANCE as Ye}from"../browser/shared/components/installed.mjs";import{attr as M,hasClass as q,walk as Re}from"../browser/shared/html-tree.mjs";import{assetFile as Qe,imageFile as Te,referencedFile as Me}from"../browser/shared/media.mjs";import{pageAssetAddress as Ve,pageExists as Je,pageFiles as Xe}from"../browser/shared/pages.mjs";import{layoutOf as U}from"../browser/shared/workspace.mjs";var Q=[1280,1920,600],De=["light","dark"],Ze=900,et=3e4,tt=new Set(["iframe","frame","object","embed"]),at=/^\d+$/,ot={x:[0,11],y:[0,1/0],w:[1,12],h:[1,24]};function st(e,{catalog:g,folder:o,slug:h}){let i=[],s=d=>d?.sourceCodeLocation?.startLine??1,n=(d,a)=>i.push({line:typeof d=="number"?d:s(d),what:a}),t=X(e.replace(/^/," "),{sourceCodeLocationInfo:!0}),c=[],f=[];Re(t,d=>{d.tagName&&(d.tagName==="main"&&q(d,"gallery-page")&&c.push(d),q(d,"gallery-board")&&f.push(d),q(d,"gallery-card")&&!q(d.parentNode,"gallery-board")&&n(d,`a card (class gallery-card) that is no board's child: each card stands right in a <div class="gallery-board" data-board-id="\u2026">, which lays it out, and this one is laid out by none`))},{inTemplates:!1}),c.length===0&&(f.length>0||j(e).cards.length>0)&&n(1,`no <main class="gallery-page">: a page's boards stand in one (it is how a block knows it is on a page: context.place "page", and how the page follows the theme)`);let y=new Map;for(let d of f){let a=d.parentNode;for(;a&&!(a.tagName==="main"&&q(a,"gallery-page"));)a=a.parentNode;c.length&&!a&&n(d,`a board outside <main class="gallery-page">: its cards' blocks would not know they are on a page`);let r=M(d,"data-board-id");r===void 0||r===""?n(d,"a board with no data-board-id: write one (main, side\u2026), of lowercase letters, digits and hyphens, once in the page"):H.test(r)?y.has(r)?n(d,`data-board-id="${r}" again (line ${y.get(r)} has it): each board's id is its own`):y.set(r,s(d)):n(d,`data-board-id="${r}": a board's id is lowercase letters, digits and single hyphens (main, side-2)`)}let S=new Map,N=new Map;for(let d of j(e).cards){let{node:a}=d,r=M(a,"data-card-id"),k=r&&H.test(r)?`card ${r}`:"this card";r===void 0||r===""?n(a,"a card with no data-card-id: write one (c<n>, the lowest none holds, or a name of your own), of lowercase letters, digits and hyphens: its place, its writes and the reader's state go by it"):H.test(r)?S.has(r)?n(a,`data-card-id="${r}" again (line ${S.get(r)} has it): each card's id is its own, and the page's writes go by it`):S.set(r,s(a)):n(a,`data-card-id="${r}": a card's id is lowercase letters, digits and single hyphens (c3, water)`);let u=0;Re(a,x=>{x!==a&&Ke(x)&&(u+=1)},{inTemplates:!1}),u===0?n(a,`${k} holds no instance of a custom block (an element with ${He}): a card is one block's instance, gallery/static's for what only shows`):u>1?n(a,`${k} holds ${u} instances: a card holds one (put each on a card of its own)`):d.instance&&d.instance.parentNode!==a&&n(d.instance,`${k}'s instance stands inside another element of the card: write it right in the card's <section>`);let b={};for(let x of["x","y","w","h"]){let A=M(a,`data-${x}`),[L,E]=ot[x];A===void 0?n(a,`${k} has no data-${x}: a card says its place and size in whole cells, data-x data-y data-w data-h`):at.test(A.trim())?Number(A)<L||Number(A)>E?n(a,`${k}'s data-${x}="${A}": ${x} is ${E===1/0?`${L} or more`:`${L} to ${E}`}${x==="w"?" (a row is 12 cells)":""}`):b[x]=Number(A):n(a,`${k}'s data-${x}="${A}" is no whole number`)}b.x!==void 0&&b.w!==void 0&&b.x+b.w>12?n(a,`${k} reaches past the row's end: data-x ${b.x} and data-w ${b.w} make ${b.x+b.w}, and a row is 12 cells (x + w is 12 at most)`):Object.keys(b).length===4&&N.set(d.board,[...N.get(d.board)??[],{id:r??null,...b,line:s(a)}]),d.block&&nt(d.block,g,x=>n(d.instance,`${k}'s block ${d.block}: ${x}`))}for(let d of N.values())for(let a=0;a<d.length;a++)for(let r=a+1;r<d.length;r++){let[k,u]=[d[a],d[r]];k.x<u.x+u.w&&u.x<k.x+k.w&&k.y<u.y+u.h&&u.y<k.y+k.h&&n(u.line,`card ${u.id??"here"} (x ${u.x}, y ${u.y}, ${u.w} \xD7 ${u.h}) shares cells with card ${k.id??`at line ${k.line}`} (x ${k.x}, y ${k.y}, ${k.w} \xD7 ${k.h}): no two cards of a board overlap; move one to a free spot (gallery page add finds one for a new card)`)}return i.push(...it(e,{folder:o,slug:h})),i.sort((d,a)=>d.line-a.line)}function nt(e,g,o){let h=g.packages.get(e);if(h){h.places.includes("page")||o(`a block of documents (its manifest's places has no "page"): on a custom page its card says so and runs nothing`);return}let i=g.problems.get(e);g.settings.disabled.includes(e)?o("turned off in \u8BBE\u7F6E \u203A \u7EC4\u4EF6\u5217\u8868: its card says so and runs nothing (the user turns it on again)"):i?o(`it does not load (${ee("en",i.problem)}): gallery block check ${e} says why`):ae(e)&&B(e)?o(`one of Gallery's own blocks, not yet in this workspace: gallery block add ${B(e).pack===te?B(e).name:e} puts it in`):o("no custom block of that id in this workspace: gallery block list lists them")}function it(e,{folder:g,slug:o}){let h=[],i=`${Ve(o,"assets/")}`;for(let s of ne(e,()=>!0)){let n=s.value.trim(),t=["a","area"].includes(s.node.tagName)&&s.how==="href",c=Me(n)??(n.startsWith(i)?Me(n.slice(i.length-7)):null),f=`"${n.length>60?`${n.slice(0,60)}\u2026`:n}"`,y=s.how==="css"?`<style>'s url() ${f}`:`<${s.node.tagName}>'s ${s.how==="style"?"style url()":s.how} ${f}`;if(c!==null){Qe(c)?tt.has(s.node.tagName)&&!Te(c)?h.push({line:s.line,what:`${y}: a frame of a file of the page's assets/ downloads it and shows nothing, as the server hands out a page's own file that is no picture, stylesheet or script for saving only: write what it shows in the page itself, frame a site by its https address, or offer the file with a link, <a href="${c}" download>`}):Ue(O.join(g,c))||h.push({line:s.line,what:`${y}: ${c} is not in the page's folder (${W(O.join(g,"assets"))}): put the file there${Te(c)?"":", or link to it"}`}):h.push({line:s.line,what:`${y} names a file the server serves none by: the page's own files go right in pages/${o}/assets/, each named with letters, digits, dots, dashes and underscores (assets/cover.png)`});continue}t||!n||/^(?:[a-z][a-z0-9+.-]*:|\/|#|\?)/i.test(n)||h.push({line:s.line,what:`${y} is relative to /pages/${o}, where nothing is served: put the file in pages/${o}/assets/ and write assets/<file>`})}return h}function rt(e,g){let o=P(e).text,h=[];for(let i of j(o).cards){let s=i.block?g.packages.get(i.block):null;if(!s?.settings?.some(f=>f.required)||!s.parts.settings)continue;let n=G(D(o,i),_,{...s,parts:{settings:s.parts.settings}})?.parts.find(({name:f})=>f==="settings"),t={};try{t=n?.text.trim()?JSON.parse(n.text):{}}catch{continue}let c=je(s,t);c.length&&h.push({id:i.id,block:i.block,line:i.node.sourceCodeLocation?.startLine??1,empty:c})}return h}var lt=({id:e,block:g,empty:o})=>`card ${e} (${g}) holds no ${o.map(({key:h,label:i,zh:s})=>`${h} (${s&&s!==i?`${i}, ${s}`:i})`).join(" and no ")} in its settings, which it cannot show anything without: it shows its ask for one (the grip at its top right \u203A \u8BBE\u7F6E\u2026), and no picture of the page shows what it is for. Ask the user for it, or take it from what the workspace says (\u5199\u4F5C\u504F\u597D, the documents), write it in the card's settings part, and tell them in the handoff which you did`,dt=(e,g=!1)=>{let o=h=>M(e.node,`data-${h}`)??"-";return`x ${o("x")}, y ${o("y")}, ${o("w")} \xD7 ${o("h")}${g?` on ${e.board??"-"}`:""}`},Fe=e=>`${e.board},${M(e.node,"data-x")},${M(e.node,"data-y")}`,Pe=e=>`${M(e.node,"data-w")},${M(e.node,"data-h")}`;function ct(e,g,o){let[h,i]=[P(e).text,P(g).text],[s,n]=[j(h).cards,j(i).cards],t=new Set([...s,...n].map(a=>a.board)).size>1,c=a=>dt(a,t),f={added:[],removed:[],moved:[],resized:[],data:[],markup:[],page:null,kept:0};for(let a of s)n.some(r=>r.id===a.id)||f.removed.push({id:a.id,block:a.block,cells:c(a)});for(let a of n)s.some(r=>r.id===a.id)||f.added.push({id:a.id,block:a.block,cells:c(a)});for(let a of n){let r=s.find($=>$.id===a.id);if(!r)continue;let[k,u]=[Fe(r)!==Fe(a),Pe(r)!==Pe(a)];k&&f.moved.push({id:a.id,block:a.block,was:c(r),now:c(a)}),u&&f.resized.push({id:a.id,block:a.block,was:c(r),now:c(a)});let[b,x]=[D(h,r),D(i,a)];if(b===x){!k&&!u&&(f.kept+=1);continue}let A=r.block===a.block?o.packages.get(a.block):null,L=A?{...A,parts:Object.fromEntries(Object.entries(A.parts).filter(([,$])=>$.edit==="data"))}:null,[E,l]=L?[G(b,_,L),G(x,_,L)]:[null,null];if(!E||!l){f.markup.push({id:a.id,block:A?a.block:null});continue}let v=E.parts.flatMap(({name:$,text:m},I)=>m===l.parts[I].text?[]:[{name:$,...Y(m,l.parts[I].text),runs:ke(m,l.parts[I].text)}]);v.length&&f.data.push({id:a.id,block:a.block,parts:v}),E.outside!==l.outside&&f.markup.push({id:a.id,block:a.block})}let y=(a,r)=>{let k="",u=0;for(let b of[...r].sort((x,A)=>x.start-A.start))k+=a.slice(u,b.start),u=b.end;return k+a.slice(u)},[S,N]=[y(h,s),y(i,n)],d=a=>a.replace(/\s+/g," ");return d(S)!==d(N)&&(f.page=Y(S.replace(/^\s*\n/gm,""),N.replace(/^\s*\n/gm,""))),f}var ze="(the user's, on the page)",We="(put there by Gallery)";function ht(e,g){let o=n=>{let t=new Map;for(let c of g)if(c.by===n)for(let[f,y]of Object.entries(c.cards??{}))t.set(f,new Set([...t.get(f)??[],...Array.isArray(y)?y:[]]));return t},h=o("page"),i=o("gallery"),s=n=>t=>{let c=!!h.get(t.id)?.has(n);return{...t,user:c,...!c&&i.get(t.id)?.has(n)?{gallery:!0}:{}}};return{...e,added:e.added.map(s("added")),removed:e.removed.map(s("removed")),moved:e.moved.map(s("cells")),resized:e.resized.map(s("cells")),data:e.data.map(s("content")),markup:e.markup.map(s("content"))}}function pt(e,g){let o=({id:t,block:c})=>`${t}${c?` (${c})`:""}`,h=t=>t.user?` ${ze}`:t.gallery?` ${We}`:"",i=[];for(let t of e.added)i.push(` added ${o(t)} at ${t.cells}${h(t)}`);for(let t of e.removed)i.push(` removed ${o(t)}, which stood at ${t.cells}${h(t)}`);for(let t of e.moved)i.push(` moved ${o(t)}: ${t.was} then ${t.now}${h(t)}`);for(let t of e.resized)e.moved.some(c=>c.id===t.id)||i.push(` resized ${o(t)}: ${t.was} then ${t.now}${h(t)}`);for(let t of e.data)i.push(` data ${o(t)}: ${$e(t.parts)}${h(t)}`,...Le(t.parts).map(c=>` ${c}`));for(let t of e.markup)i.push(` markup ${o(t)}: its markup outside its place and its data parts${t.block?"":" (a block the workspace has not: its markup whole)"}${h(t)}`);if(e.page&&i.push(` page its own HTML outside the cards: -${e.page.removed} +${e.page.added} of its ${e.page.lines} line${e.page.lines===1?"":"s"}`),i.length===0)return[`No change since ${g}: every card where it was, with the data it had.`];let s=["added","removed","moved","resized","data","markup"].some(t=>e[t].some(c=>c.user)),n=["added","removed","moved","resized","data","markup"].some(t=>e[t].some(c=>c.gallery));return[`Changes since ${g}:`,...i,...e.kept?[e.kept===1?" The other card as it was.":` The other ${e.kept} cards as they were.`]:[],...s?[` Each change marked ${ze} is the user's own gesture on the page since then (a move, a resize, a card added or deleted there, what they typed in it), which the page wrote: leave it as it is, never put it back.`]:[],...n?[` Each change marked ${We} is Gallery's own doing, not the user's and not yours: the cards it put on the home page when it made it (\u95EE\u5019\u4E0E\u65E5\u671F, \u4FBF\u7B7E): leave it as it is.`]:[]]}async function ut(e,g){let{qa:o,state:h}=U(e),i=O.join(o,g,"checked.html"),s=await R.readFile(i,"utf8").catch(()=>null);if(s!==null){let{mtime:y}=await R.stat(i);return{text:s,since:`the last check that found nothing (${qe(y)}, local time, ${W(i)})`,at:y.getTime()}}let n=O.join(h,"pages",g),t=(await R.readdir(n).catch(()=>[])).filter(y=>/^\d{15}-\d{4}\.html$/.test(y)).sort();if(t.length===0)return null;let c=O.join(n,t.at(-1)),f=Number(t.at(-1).slice(0,15));return{text:await R.readFile(c,"utf8"),since:`the page as it was before its last write (${qe(new Date(f))}, local time; used because no check has passed yet)`,at:f}}var qe=e=>`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")} ${String(e.getHours()).padStart(2,"0")}:${String(e.getMinutes()).padStart(2,"0")}`;function ft(e,g){let o=t=>`<${t.localName}${t.getAttribute("src")?` src="${t.getAttribute("src").slice(0,80)}"`:""}>`,h=[...document.querySelectorAll(".gallery-board > .gallery-card")].map(t=>{let c=t.parentElement.getBoundingClientRect(),f=t.getBoundingClientRect(),y=[...t.children].find(S=>S.matches(e));return{id:t.getAttribute("data-card-id"),block:y?.getAttribute(g)??null,out:f.width>0&&(f.left<c.left-1||f.right>c.right+1),tall:t.scrollHeight>t.clientHeight+1?{needs:t.scrollHeight,has:t.clientHeight}:null,wide:t.scrollWidth>t.clientWidth+1?{needs:t.scrollWidth,has:t.clientWidth}:null,fallback:!!y?.hasAttribute("data-doc-fallback"),error:(t.querySelector(".doc-kit-error")?.textContent??"").trim()||null,broken:[...t.querySelectorAll("img")].filter(S=>S.complete&&S.naturalWidth===0).map(o)}}),i=[...document.querySelectorAll("img")].filter(t=>!t.closest(".gallery-card")&&t.complete&&t.naturalWidth===0).map(o),s=document.documentElement.scrollWidth,n=[...globalThis.__galleryQueries?.pending.values()??[]].map(({kind:t,block:c,at:f})=>({kind:t,block:c,waited:Date.now()-f}));return{cards:h,broken:i,stuck:n,wide:s>innerWidth+1?s:0,columns:document.querySelector(".gallery-board")?.getAttribute("data-columns")??null}}async function wt(e,{address:g,out:o,readers:h=new Set,wait:i=ge,limits:s={}}){let{loading:n=he,ready:t=et,answer:c=pe,closing:f=de,looking:y=ue}=s,S=new Map,N=new Map,d=[],a=!1,r=(l,v,$,m,I=S)=>{if(a)return;let w=I.get(l)??{card:v,what:$,looks:[]};w.looks.push(m),I.set(l,w)},k="a browser context opened",u=(l,v,$=c)=>(k=v,ye(l,v,$)),b=Q.flatMap(l=>De.map(v=>({width:l,theme:v,view:`${l} ${v}`}))),x=null,A=async({width:l,theme:v,view:$})=>{let m=await u(x.newPage(),"a tab opened");try{m.on("pageerror",p=>r(`error ${z(p)}`,null,`the page threw: ${z(p)}`,$)),m.on("console",p=>{p.type()==="error"&&!/^Failed to load resource/.test(p.text())&&r(`console ${p.text().split(`
3
+ `)[0]}`,null,`the console says ${p.text().split(`
4
+ `)[0]}`,$)}),m.on("response",p=>{let C=new URL(p.url());p.status()>=400&&C.origin===new URL(g).origin&&C.pathname!=="/favicon.ico"&&r(`request ${C.pathname}`,null,`${C.pathname} answered ${p.status()}`,$)}),await u(be(m,{add:p=>r(`dialog ${p}`,null,`it opened a dialog (${p}), which stops a reader's page until it is answered`,$)}),"the tab was set to refuse dialogs"),await u(me(m),"the tab was set to watch the page's reads of the workspace"),await u(m.setViewport({width:l,height:Ze}),`the window went to ${l}px`),await u(m.emulateMediaFeatures([{name:"prefers-color-scheme",value:v}]),`the ${v} theme came`),await u(m.goto(g,{waitUntil:"load",timeout:0}),"the page opened",n),await u(m.waitForSelector("html[data-doc-ready][data-doc-drawn]",{timeout:0}),"the page was drawn (its html got data-doc-drawn)",t),await u(m.evaluate(()=>document.fonts?.ready.then(()=>!0)),"the page's fonts loaded");let I=await u(m.$("main"),"the page's main was found")??await u(m.$("body"),"the page's body was found");await u(I.evaluate(Oe,{still:fe,step:we,wait:i}),"the page held still");let w=await u(m.evaluate(ft,Ye,He),"the page was looked at");for(let{kind:p,block:C,waited:Ge}of w.stuck){let V=w.cards.filter(F=>C?F.block===C:h.has(F.block)),J=F=>`the workspace had not answered ${F} read of "${p}" ${Math.round(Ge/1e3)} s after it asked, so its picture shows it before it drew what it reads, which the picture then does not tell (open the page in Gallery to see it)`;if(V.length)for(let F of V)r(`unanswered ${F.id} ${p}`,F.id,J("its"),$,N);else r(`unanswered ${p}`,null,J("a card's"),$,N)}w.wide&&r("wide",null,`the page is ${w.wide}px wide in a window ${l}px wide: something of its own reaches past the window (a width of its own, a long word), and a reader scrolls it sideways`,$);for(let p of w.broken)r(`broken ${p}`,null,`a picture that does not load: ${p}`,$);for(let p of w.cards){p.fallback&&r(`fallback ${p.id}`,p.id,`its block failed: the card shows what its instance holds, read-only${p.error?` (${p.error.slice(0,200)})`:""}`,$),p.out&&r(`out ${p.id}`,p.id,"it is drawn out of its board",$),p.tall&&r(`tall ${p.id}`,p.id,`what it holds does not fit it: ${p.tall.needs}px high in a card that shows ${p.tall.has}px, the rest scrolling inside the card (give the card more cells, data-h, or a size its block lists; a block whose content grows says card.fit "content")`,$),p.wide&&r(`wide ${p.id}`,p.id,`what it holds is wider than the card: ${p.wide.needs}px in a card ${p.wide.has}px wide`,$);for(let C of p.broken)r(`broken ${p.id} ${C}`,p.id,`a picture that does not load: ${C}`,$)}let T=O.join(o,`${l}-${v}.png`);await u(m.screenshot({path:T,fullPage:!0}),"the page was pictured"),a||d.push(T)}finally{await K(m.close(),f)}},L=l=>({problems:[...S.values()],notes:[...N.values()],pictures:d,unverified:null,stuck:!1,...l}),E=null;try{x=await u(e.createBrowserContext(),"a browser context opened");for(let l of b)E=l,await gt(A(l),y,()=>k);return L({})}catch(l){return await Se(e)?L({unverified:`the browser went while it looked (${z(l)})`}):l.stuck?(r("stopped",null,mt(l,b.indexOf(E??b[0])<b.length-1),(E??b[0]).view),L({stuck:!0})):L({unverified:`the look stopped: ${z(l)}`})}finally{a=!0,await K(x?.close(),f)}}function gt(e,g,o){let h=0,i=new Promise((s,n)=>{h=setTimeout(()=>n(Object.assign(new Error(o()),{stuck:!0,doing:o(),limit:g,whole:!0})),g)});return Promise.race([e,i]).finally(()=>clearTimeout(h))}function mt(e,g){return`${e.whole?`the look was not done in ${xe(e.limit)}, waiting until ${e.doing}`:ve(e)}; the look stopped here and the browser was closed${g?", so the looks after it were not made":""}. A script of the page that never ends does this, and so may a browser that stalled: run the check once more, and if it stops at the same place again, the page holds it up`}function Be(e){let g=[...new Set(e.map(i=>i.split(" ")[0]))],o=[...new Set(e.map(i=>i.split(" ")[1]))],h=i=>i.length<2?i.join(""):`${i.slice(0,-1).join(", ")} and ${i.at(-1)}`;return`at ${h(g)}px${o.length===De.length?"":`, ${h(o)}`}`}async function Ht(e,g){if(g.length!==1)throw new se("gallery page check takes one page's slug.");let[o]=g,h=Xe(o,e);Je(o,e)||(console.error(await Ce(o,e)),process.exit(1));let i=new Date,s=await R.readFile(h.html,"utf8"),n=O.basename(h.html),t=Z(e),{boards:c,cards:f}=j(s);console.log(`${o}: ${W(h.html)}, ${c.length} board${c.length===1?"":"s"} and ${f.length} card${f.length===1?"":"s"}`);let y=[],S=st(s,{catalog:t,folder:h.folder,slug:o});for(let{line:l,what:v}of S)y.push(` FAIL ${n}:${l}: ${v}`);console.log(S.length?`Structure: ${S.length} problem${S.length===1?"":"s"}`:"Structure: nothing wrong (the page's own HTML, scripts and frames its own; every board's and card's id once, one instance a card, the cells on the board and none shared, every block one a page runs, every file of assets/ there)");for(let l of y)console.log(l);for(let l of j(P(s).text).cards)console.log(` ${l.id} ${l.block??"(no instance)"} x ${l.x}, y ${l.y}, ${l.w} \xD7 ${l.h}${c.length>1?` on ${l.board}`:""} ${n}:${l.node.sourceCodeLocation?.startLine}`);let N=rt(s,t);for(let l of N)console.log(` note ${n}:${l.line}: ${lt(l)}`);let d=await ut(e,o),a=d?await oe(U(e).state,o,d.at):[];console.log((d?pt(ht(ct(d.text,s,t),a),d.since):["No earlier version to tell changes against: the next check that finds nothing keeps this one, and says what changed since."]).join(`
5
+ `));let r=new Map(j(P(s).text).cards.map(l=>[l.id,l.node.sourceCodeLocation?.startLine??1])),k=(l,v=null,$=0)=>{if(l)return{line:`FAIL ${o}: ${l} problem${l===1?"":"s"}`,code:1};if(v)return{line:`UNVERIFIED ${o}: ${v}; its structure was checked, and nothing is wrong with it`,code:3};let m=N.length?`; and ${N.length===1?"one card asks":`${N.length} cards ask`} for a setting no one gave (see "note" above): ${N.map(({id:I,empty:w})=>`${I} (${w.map(({key:T})=>T).join(", ")})`).join(", ")}`:"";return{line:`OK ${o}: its structure, and its ${f.length} card${f.length===1?"":"s"} at ${Q.join(", ")}px in light and dark${$?`; but ${$===1?"one card was":`${$} cards were`} pictured before the workspace answered it (see "note" above), so ${$===1?"its picture does":"their pictures do"} not show what ${$===1?"it reads":"they read"}`:""}${m}`,code:0}},u=await ie({command:`gallery page check ${o}`}),b=async(l,v,$=0)=>{let{line:m,code:I}=k(l,v,$);if(console.log(m),I===0){let w=O.join(U(e).qa,o,"checked.html");await R.mkdir(O.dirname(w),{recursive:!0}),await R.writeFile(w,s),await R.utimes(w,i,i)}process.exitCode=I};if(!u.ok)return b(S.length,`${u.message}, so the page was not looked at`);let x=re();if(!x)return b(S.length,"no Chrome, Edge or Chromium found (GALLERY_BROWSER=<its executable> picks one), so the page was not looked at");await Ie(e);let A=await Ee(e,{directory:h.folder,files:h,text:s}),L=O.join(U(e).qa,o,"check"),E=null;try{let{pageAloneOf:l}=await import("./chunk-DAMVDXR3.mjs"),v=l(u.port,A.slug);console.log(`Looked at: ${v} (a scratch copy of ${o}, gone at the end: nothing a block does as it opens writes ${n}), at ${Q.join(", ")}px, light and dark`);try{E=await ce({executablePath:x,args:le()})}catch(w){return b(S.length,`the browser ${x} did not start, twice (${z(w)}), so the page was not looked at`)}await R.rm(L,{recursive:!0,force:!0}),await R.mkdir(L,{recursive:!0});let $=new Set([...t.packages.values()].filter(({needs:w})=>w?.includes("workspace")).map(({id:w})=>w)),m=await wt(E.browser,{address:v,out:L,readers:$});m.stuck&&(await E.close(),E=null);for(let{card:w,what:T,looks:p}of m.problems)console.log(` FAIL ${n}:${w?r.get(w)??1:1}: ${w?`card ${w}: `:""}${T} (${Be(p)})`);let I=new Map(j(s).cards.map(w=>[w.id,w.block]));for(let{card:w,what:T,looks:p}of m.notes)console.log(` note ${n}:${w?r.get(w)??1:1}: ${w?`card ${w}${I.get(w)?` (${I.get(w)})`:""}: `:""}${T} (${Be(p)})`);return m.pictures.length&&(console.log(`Pictures of the page in ${W(L)}: ${m.pictures.map(w=>O.basename(w)).join(", ")}`),console.log(Ae([{folder:O.dirname(L),files:m.pictures}]))),b(S.length+m.problems.length,m.unverified,new Set(m.notes.map(({card:w})=>w??"")).size)}finally{await E?.close(),await Ne(e,A.slug)}}export{We as GALLERYS_MARK,Q as LOOK_WIDTHS,De as THEMES,ze as USERS_MARK,ut as baselineOf,pt as changesSaid,rt as emptyRequired,lt as emptyRequiredSaid,wt as look,ht as markedTheUsers,ct as pageChanges,Ht as pageCheckCommand,st as structureProblems};
@@ -1,3 +1,3 @@
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{k as u}from"./chunk-SX4LJYT6.mjs";import n from"node:fs/promises";import d from"node:path";import{writeAtomic as h}from"../browser/shared/files.mjs";import{documentFiles as A}from"../browser/shared/workspace.mjs";var I=s=>n.access(s).then(()=>!0,()=>!1);async function q(s,{create:y,slugOf:F,folderOf:j,fill:p,place:x,under:N="",said:J="\u5BFC\u5165\u81EA {0}",lang:O=null}){let e=[],c=[];async function f(t,r,S){let i=await F(t,S);await y(i,t.title,J.replace("{0}",()=>t.from),{lang:O});let a=j(i),{html:l,json:m}=A(a),k=await n.readFile(l,"utf8");await h(l,u(await p({source:k,nodes:t.nodes,icon:t.icon,own:t.own,raws:t.raws,lang:t.lang}))),t.files.length&&await n.mkdir(d.join(a,"assets"),{recursive:!0});for(let{from:o,name:v}of t.files){let w=d.join(a,"assets",v);await I(w)||await n.copyFile(o,w)}if(t.icon){let o=JSON.parse(await n.readFile(m,"utf8"));await h(m,`${JSON.stringify({...o,icon:t.icon},null,2)}
2
+ import{k as u}from"./chunk-YFJU3O7G.mjs";import n from"node:fs/promises";import d from"node:path";import{writeAtomic as h}from"../browser/shared/files.mjs";import{documentFiles as A}from"../browser/shared/workspace.mjs";var I=s=>n.access(s).then(()=>!0,()=>!1);async function q(s,{create:y,slugOf:F,folderOf:j,fill:p,place:x,under:N="",said:J="\u5BFC\u5165\u81EA {0}",lang:O=null}){let e=[],c=[];async function f(t,r,S){let i=await F(t,S);await y(i,t.title,J.replace("{0}",()=>t.from),{lang:O});let a=j(i),{html:l,json:m}=A(a),k=await n.readFile(l,"utf8");await h(l,u(await p({source:k,nodes:t.nodes,icon:t.icon,own:t.own,raws:t.raws,lang:t.lang}))),t.files.length&&await n.mkdir(d.join(a,"assets"),{recursive:!0});for(let{from:o,name:v}of t.files){let w=d.join(a,"assets",v);await I(w)||await n.copyFile(o,w)}if(t.icon){let o=JSON.parse(await n.readFile(m,"utf8"));await h(m,`${JSON.stringify({...o,icon:t.icon},null,2)}
3
3
  `)}await x(i,r),e.push(i);for(let o of t.children??[])await f(o,i,null);return i}for(let[t,r]of s.entries())c.push(await f(r,N,t));return{made:e,top:c}}export{q as a};
@@ -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}from"./chunk-5L26JUYA.mjs";import"./chunk-S2Y7VI4H.mjs";import"./chunk-JJNRIFND.mjs";import"./chunk-JEUK3ZO7.mjs";import"./chunk-QXVNUASA.mjs";import"./chunk-2OHANJ6Q.mjs";import"./chunk-2GKGEVMR.mjs";import"./chunk-VKSRM7EY.mjs";import"./chunk-LE44MD3O.mjs";import"./chunk-4OZWXZE5.mjs";import"./chunk-SAHS56QM.mjs";import"./chunk-YFJU3O7G.mjs";import"./chunk-2RKIHJI2.mjs";import"./chunk-7XDYK3UC.mjs";import"./chunk-VG5JEIUQ.mjs";import"./chunk-N3DSBH5S.mjs";import"./chunk-5L7RYZCL.mjs";export{c as HOME_NOT_MADE,g as emptyRequiredOf,d as missingPageSaid,a as pageAddressOf,b as pageAloneOf,h as run,e as setsOf,f as settingsGiven};
@@ -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{g as a,h as b,i as c,j as d,k as e,l as f,m as g,n as h,o as i,p as j,q as k,r as l,s as m,t as n,u as o,v as p,w as q}from"./chunk-HMYTM3GT.mjs";import"./chunk-OW5NWPOJ.mjs";import"./chunk-ZTHICSSF.mjs";import"./chunk-SX4LJYT6.mjs";import"./chunk-PAREWQGB.mjs";import"./chunk-W3BGBJQW.mjs";import"./chunk-JVHHHGEA.mjs";import"./chunk-HYMEEXKN.mjs";import"./chunk-UMHUSOPJ.mjs";import"./chunk-FWNRPMCJ.mjs";import"./chunk-A55HN5OK.mjs";import"./chunk-5L7RYZCL.mjs";export{h as buildReports,d as checkReports,f as checkSelectedReports,b as exportFailures,k as exportReports,p as failureSummary,e as handInBlockers,l as notesByKind,m as notesOf,j as offlineReports,o as printFailures,c as quickFailures,a as repeatedIdFailures,q as reportFailures,n as reportNotes,i as withExportPolicy,g as writeSharedAssets};
2
+ import{g as a,h as b,i as c,j as d,k as e,l as f,m as g,n as h,o as i,p as j,q as k,r as l,s as m,t as n,u as o,v as p,w as q}from"./chunk-XMKHCUI6.mjs";import"./chunk-SAHS56QM.mjs";import"./chunk-KH24LWAT.mjs";import"./chunk-YFJU3O7G.mjs";import"./chunk-NWRZXELO.mjs";import"./chunk-G4YP7GVC.mjs";import"./chunk-DHB7UZ7F.mjs";import"./chunk-2RKIHJI2.mjs";import"./chunk-JXLSHVJ2.mjs";import"./chunk-VG5JEIUQ.mjs";import"./chunk-N3DSBH5S.mjs";import"./chunk-5L7RYZCL.mjs";export{h as buildReports,d as checkReports,f as checkSelectedReports,b as exportFailures,k as exportReports,p as failureSummary,e as handInBlockers,l as notesByKind,m as notesOf,j as offlineReports,o as printFailures,c as quickFailures,a as repeatedIdFailures,q as reportFailures,n as reportNotes,i as withExportPolicy,g as writeSharedAssets};
@@ -0,0 +1,3 @@
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 v,b as j}from"./chunk-2RKIHJI2.mjs";import l from"node:fs";import p from"node:path";import V from"node:zlib";import{escapeAttribute as $,escapeMarkup as _}from"../browser/shared/escape.mjs";import{componentOf as b,instancesOf as L,partOf as O}from"../browser/shared/components/index.mjs";import{ICON_COLOR_VALUES as I,TAB_ICON as N,glyphOf as B,iconKind as u,iconUrl as T,iconValueOf as S,tabIconValue as R}from"../browser/shared/emoji/icon-value.mjs";import{lineIconSvg as z}from"../browser/shared/emoji/line-icons.mjs";import{mediaTypeOf as A,mediaUrl as J}from"../browser/shared/media.mjs";import{emojiDataDirectory as P,reportsDirectory as E}from"../browser/shared/paths.mjs";import{slugPattern as G}from"../browser/shared/reports.mjs";import{documentDirectory as D}from"../browser/shared/workspace.mjs";var g=P,k=String.fromCodePoint(65039),C=null,x=null;function H(){return C??={positions:JSON.parse(l.readFileSync(p.join(g,"positions.json"),"utf8")),index:JSON.parse(l.readFileSync(p.join(g,"twemoji-index.json"),"utf8")),svg:V.gunzipSync(l.readFileSync(p.join(g,"twemoji-svg.bin")))},C}function F(e){let{positions:t,index:r,svg:o}=H(),n=[e,e.replaceAll(k,""),`${e}${k}`].find(c=>t[c]),i=n&&r[t[n][0]];return i?o.subarray(i[0],i[0]+i[1]):null}function U(e){let t=F(e);return t?`data:image/svg+xml;base64,${t.toString("base64")}`:null}function ue(e){return d(""),[...x.keys()].filter(t=>t.startsWith(`${e}/`)).map(t=>t.slice(e.length+1))}function d(e,t="currentColor"){x??=new Map(JSON.parse(l.readFileSync(p.join(g,"icons.json"),"utf8")).icons.flatMap(([,n,i,c,a])=>[[`mingcute/${n}`,c],[`tabler/${i}`,a]].filter(([,s])=>s)));let r=B(e),o=r&&x.get(`${r.set}/${r.name}`);return o?o.split("#COLOR").join(t).replace("<svg ",'<svg aria-hidden="true" '):null}function K(e){let[t,r]=I[B(e)?.color]??I.gray,o=d(e);return o&&o.replace(/<svg\b[^>]*>/,n=>`${n.replace(/ aria-hidden="true"/,"").replace(/^<svg /,'<svg xmlns="http://www.w3.org/2000/svg" ').replace(/ xmlns="http:\/\/www\.w3\.org\/2000\/svg"(?=.* xmlns=)/,"")}<style>svg{color:${t}}@media (prefers-color-scheme:dark){svg{color:${r}}}</style>`)}var W=e=>`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 36 36"><text x="18" y="18" text-anchor="middle" dominant-baseline="central" font-size="30" font-family="'Apple Color Emoji','Segoe UI Emoji','Noto Color Emoji',sans-serif">${_(e)}</text></svg>`;function q({value:e,slug:t=null,tab:r=!1,reportsDirectory:o=E}){let n=z(e,{color:"#000",tab:r});if(n)return{type:"image/svg+xml",body:Buffer.from(n)};let i=u(e);if(i==="emoji")return{type:"image/svg+xml",body:F(e)??Buffer.from(W(e))};if(i==="glyph"){let a=r?K(e):d(e,"#000");return a&&{type:"image/svg+xml",body:Buffer.from(a)}}if(i!=="image"||!t||!G.test(t))return null;let c=p.join(D(t,o),e);return l.existsSync(c)?{type:A(e),body:l.readFileSync(c)}:null}var M=/(<div\b[^>]*\bclass="doc-icon"[^>]*>)([\s\S]*?)(<\/div>)/g;function de(e,{slug:t,mode:r="export",reportsDirectory:o=E}){return te(X(e,{mode:r}).replace(M,(n,i,c,a)=>{let s=S(n),y=u(s);if(!y)return n;let f=null;if(y==="emoji"){let m=U(s);f=m&&`<img alt="${$(s)}" src="${m}">`}else if(y==="glyph")f=d(s);else if(r==="preview")f=`<img src="${J("asset",t,s)}" alt="">`;else{let m=p.join(D(t,o),s),w=l.existsSync(m)?l.readFileSync(m):null;f=w&&`<img src="data:${A(s)};base64,${w.toString("base64")}" alt="">`}let h=r==="preview"?i.replace(/>$/,` data-ge-icon="${$(s)}">`):i;return f?`${h}${f}${a}`:`${h}${c}${a}`}),ee(Z(e),{slug:t,mode:r,reportsDirectory:o}))}var ye=e=>[...e.matchAll(M)].flatMap(t=>{let r=u(S(t[0]))==="image"?/<img\b[^>]*\bsrc="/.exec(t[2]):null;return r?[t.index+t[1].length+r.index]:[]}),Q=/<button\b[^>]*\bdata-tab-icon="([^"]*)"[^>]*>/g;function X(e,{mode:t="export"}={}){return e.replace(Q,(r,o)=>{if(u(o)!=="emoji"||r.includes(N))return r;let n=t==="preview"?T(o):U(o);if(!n)return r;let i=`${N}: ${R(n)}`;return/\sstyle="/.test(r)?r.replace(/\sstyle="([^"]*)"/,(c,a)=>` style="${a.replace(/;?\s*$/,"; ")}${i}"`):r.replace(/>$/,` style="${i}">`)})}function Y(e){let t=O(e,b("page").header)[0];return{all:L(e,b("icon")),own:t?O(t,b("icon").match):[]}}function Z(e){let[t]=Y(v(e)).own;return t?S(j(e,t)):null}function ee(e,{slug:t,mode:r,reportsDirectory:o}){if(!e)return null;if(r==="preview")return T(e,t,{tab:!0});let n=q({value:e,slug:t,tab:!0,reportsDirectory:o});return n&&`data:${n.type};base64,${Buffer.from(n.body).toString("base64")}`}var te=(e,t)=>t&&/<\/head>/i.test(e)&&!e.includes("data-doc-tab-icon")?e.replace(/<\/head>/i,()=>` <link rel="icon" href="${$(t)}" data-doc-tab-icon>
3
+ </head>`):e;export{U as a,ue as b,d as c,q as d,de as e,ye as f,Y as g,Z as h};
@@ -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{a as m,b as u,c as f,d}from"./chunk-BPL64HGA.mjs";import{b as p}from"./chunk-OUUP3WKT.mjs";import{j as n}from"./chunk-4OZWXZE5.mjs";import{l as i,t as a,w as c}from"./chunk-HMYTM3GT.mjs";import{reportsDirectory as g}from"../browser/shared/paths.mjs";import{documentDirectory as $,documentFiles as y}from"../browser/shared/workspace.mjs";var k=()=>`No documents in ${g} yet: gallery new <slug> "<title>" makes one.`;async function A(w){let{slugs:e,options:h}=await n({options:["--allow-failures"],argv:w,noneIsAll:!0});e.length===0&&(console.error(k()),process.exit(1)),await p(e),await f(e),await d(e);let{reports:r,failures:t}=await i(e,{prepare:m()}),s=r.filter(o=>!t.has(o.slug));for(let o of s)console.log(`OK ${o.slug}`);for(let o of e)y($(o,g)).both&&console.log(`note ${o}: both doc.html and report.html: report.html is not read`);a(r),u(r);let l=s.length+t.size;console.log(`Checked ${l} document${l===1?"":"s"}: ${s.length} passed, ${t.size} failed.`),await c(t,{allow:h.has("--allow-failures")})}export{k as a,A as b};
2
+ import{a as m,b as u,c as f,d}from"./chunk-3A5I2GJK.mjs";import{b as p}from"./chunk-XQRUG4G3.mjs";import{j as n}from"./chunk-4OZWXZE5.mjs";import{l as i,t as a,w as c}from"./chunk-XMKHCUI6.mjs";import{reportsDirectory as g}from"../browser/shared/paths.mjs";import{documentDirectory as $,documentFiles as y}from"../browser/shared/workspace.mjs";var k=()=>`No documents in ${g} yet: gallery new <slug> "<title>" makes one.`;async function A(w){let{slugs:e,options:h}=await n({options:["--allow-failures"],argv:w,noneIsAll:!0});e.length===0&&(console.error(k()),process.exit(1)),await p(e),await f(e),await d(e);let{reports:r,failures:t}=await i(e,{prepare:m()}),s=r.filter(o=>!t.has(o.slug));for(let o of s)console.log(`OK ${o.slug}`);for(let o of e)y($(o,g)).both&&console.log(`note ${o}: both doc.html and report.html: report.html is not read`);a(r),u(r);let l=s.length+t.size;console.log(`Checked ${l} document${l===1?"":"s"}: ${s.length} passed, ${t.size} failed.`),await c(t,{allow:h.has("--allow-failures")})}export{k as a,A as b};
@@ -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}from"./chunk-AEMVZYZQ.mjs";import"./chunk-DR73Y2UJ.mjs";import"./chunk-CG3UHDKH.mjs";import"./chunk-4AMTKWDO.mjs";import"./chunk-QXVNUASA.mjs";import"./chunk-FCK6NXON.mjs";import"./chunk-OU3S466R.mjs";import"./chunk-CZ5KJSGK.mjs";import"./chunk-UGO5N3EI.mjs";import"./chunk-5IIH335D.mjs";import"./chunk-QK3VISCA.mjs";import"./chunk-2OHANJ6Q.mjs";import"./chunk-F4ZA6JRZ.mjs";import"./chunk-7M2BQQGZ.mjs";import"./chunk-TOE6DPLH.mjs";import"./chunk-WTEGUPFG.mjs";import"./chunk-VKSRM7EY.mjs";import"./chunk-LE44MD3O.mjs";import"./chunk-XMKHCUI6.mjs";import"./chunk-SAHS56QM.mjs";import"./chunk-KH24LWAT.mjs";import"./chunk-YFJU3O7G.mjs";import"./chunk-NWRZXELO.mjs";import"./chunk-G4YP7GVC.mjs";import"./chunk-DHB7UZ7F.mjs";import"./chunk-2RKIHJI2.mjs";import"./chunk-JXLSHVJ2.mjs";import"./chunk-XKOHV4H6.mjs";import"./chunk-KFZBYDIS.mjs";import"./chunk-7XDYK3UC.mjs";import"./chunk-VG5JEIUQ.mjs";import"./chunk-N3DSBH5S.mjs";import"./chunk-5L7RYZCL.mjs";export{a as startProductionServer};
@@ -1,3 +1,3 @@
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{c as L,d as _,e as D,g as N}from"./chunk-35NQ4PLQ.mjs";import{createHash as q,randomUUID as Q}from"node:crypto";import f from"node:fs/promises";import g from"node:path";import{refusal as V,said as T,saying as X}from"../browser/shared/i18n/index.mjs";import{extensionOf as Y,imageExtension as Z,imageFile as M,mediaTypeOf as tt,UPLOAD_LIMITS as y}from"../browser/shared/media.mjs";import{slugPattern as F}from"../browser/shared/reports.mjs";import{documentDirectory as U,documentFiles as et,layoutOf as nt}from"../browser/shared/workspace.mjs";var z=i=>Y(String(i??"").replace(/[?#].*$/,"")),it=i=>{let e=String(i??"").replace(/[?#].*$/,"");e=e.slice(e.lastIndexOf("/")+1);try{e=decodeURIComponent(e)}catch{}return e.replace(/[\u0000-\u001f<>:"/\\|?*]/g,"").trim().slice(0,120)||"file"};function rt(i){let e=i.subarray(0,16);return e[0]===137&&e.toString("latin1",1,4)==="PNG"?"image/png":e[0]===0&&e[1]===0&&e[2]===1&&e[3]===0?"image/x-icon":e[0]===255&&e[1]===216?"image/jpeg":e.toString("latin1",0,4)==="GIF8"?"image/gif":e.toString("latin1",0,4)==="RIFF"&&e.toString("latin1",8,12)==="WEBP"?"image/webp":e.toString("latin1",4,12)==="ftypavif"?"image/avif":/^\s*(<\?xml[^>]*>\s*)?(<!--[\s\S]*?-->\s*)*<svg\b/i.test(i.subarray(0,512).toString("utf8"))?"image/svg+xml":null}var w=(i,e)=>V(e,{reason:i}),S=(i,e)=>{let l=rt(i);if(!l)throw w("type","\u4EC5\u652F\u6301\u56FE\u7247");return Z(l)},at=(i,e)=>z(e),ot=(i,e)=>{let l=z(e);if(!["html","htm","pdf"].includes(l)||l==="pdf"&&i.subarray(0,5).toString("latin1")!=="%PDF-")throw w("type","\u53EA\u80FD\u5D4C\u5165 HTML \u6216 PDF \u6587\u4EF6");return l},j={big:i=>T("\u56FE\u7247\u592A\u5927\uFF08\u6700\u591A {0} MB\uFF09",i),unreachable:"\u4E0B\u8F7D\u4E0D\u4E86\u8FD9\u5F20\u56FE\u7247"},B={big:i=>T("\u6587\u4EF6\u592A\u5927\uFF08\u6700\u591A {0} MB\uFF09",i),unreachable:"\u4E0B\u8F7D\u4E0D\u4E86\u8FD9\u4E2A\u6587\u4EF6"},k={icon:{limit:y.icon,words:j,extension:S},image:{limit:y.image,words:j,extension:S},file:{limit:y.file,words:B,extension:at,named:!0},embed:{limit:y.embed,words:B,extension:ot,named:!0}};function wt(i,e,l,b){let s=k[i].extension(l,b);return`${i}-${e.slice(0,12)}${s?`.${s}`:""}`}function bt({reportsDirectory:i}){let e=nt(i).emojiLibrary,l=async t=>{let n=U(t,i);return await f.stat(et(n).html).catch(()=>null)?n:null},b=g.join(e,"library.json"),s=(t,n,r)=>[t,{ok:!1,reason:n,...X(r)}];async function O(t,n,{stem:r,limit:a,words:c=j,extension:o=S,given:m}){let u=o(n,m);if(n.length>a)throw w("size",c.big(a/1024/1024));let p=`${r}-${q("sha256").update(n).digest("hex").slice(0,12)}${u?`.${u}`:""}`;await f.mkdir(t,{recursive:!0});let h=g.join(t,p);return await f.stat(h).catch(()=>null)||await f.writeFile(h,n),p}let E=(t,n,r,a=y.icon)=>O(t,n,{stem:r,limit:a});async function I(t,n,r=j){let a=await L(t,{unreachable:r.unreachable});if(!a.ok)throw w("download",r.unreachable);let c=await _(a,n);if(!c)throw w("size",r.big(n/1024/1024));return c}async function $(){try{let t=JSON.parse(await f.readFile(b,"utf8"));return Array.isArray(t)?t:[]}catch{return[]}}let v=t=>({id:t.id,name:t.name,url:`/__gallery/edit/emoji-library/${t.file}`,created_time:t.created,alive:!0});async function A(t){let{slug:n,data:r,url:a,library:c}=t??{},o=Object.hasOwn(k,t?.kind)?t.kind:"icon";if(typeof n!="string"||!F.test(n))return s(400,"body");let m=await l(n);if(!m)return s(404,"missing");let{limit:u,words:p,extension:h,named:J}=k[o];try{let d,x;if(typeof r=="string")d=Buffer.from(r,"base64"),x=t.name;else if(typeof a=="string")d=await I(a,u,p),x=a;else if(typeof c=="string"){let P=(await $()).find(K=>K.id===c);if(!P)return s(404,"library","\u8FD9\u4E2A\u81EA\u5B9A\u4E49\u8868\u60C5\u5DF2\u4E0D\u5728\u8868\u60C5\u5E93\u91CC");d=await f.readFile(g.join(e,P.file))}else return s(400,"body");return[200,{ok:!0,path:`assets/${await O(g.join(m,"assets"),d,{stem:o,limit:u,words:p,extension:h,given:x})}`,...J?{name:it(x),size:d.length}:{}}]}catch(d){return s(422,d.reason??"write",d)}}async function R(t){let{slug:n,url:r,parts:a="all"}=t??{};if(typeof n!="string"||!F.test(n)||typeof r!="string"||!["all","icon","title"].includes(a))return s(400,"body");let c=await l(n);if(!c)return s(404,"missing");try{return[200,{ok:!0,...await N(r,async(m,u)=>`assets/${await E(g.join(c,"assets"),m,u,y.image)}`,{icon:a!=="title",cover:a==="all"})}]}catch(o){return s(422,o.reason??"download",o)}}async function W(t){return typeof t?.url!="string"?s(400,"body"):[200,{ok:!0,...await D(t.url)}]}async function C(t){let{slug:n,name:r,url:a}=t??{};if(typeof r!="string"||!/^[\p{Ll}\p{Lo}\d_-]{1,49}$/u.test(r)||typeof a!="string")return s(400,"body");let c=await $();if(c.some(o=>o.name===r))return s(409,"name","\u540D\u79F0\u5DF2\u88AB\u5360\u7528");try{let o;M(a)&&typeof n=="string"&&F.test(n)?o=await f.readFile(g.join(U(n,i),a)):o=await I(a,y.icon);let m=await E(e,o,"emoji"),u={id:Q(),name:r,file:m,created:Date.now()};return await f.writeFile(b,`${JSON.stringify([...c,u],null,2)}
2
+ import{c as L,d as _,e as D,h as N}from"./chunk-7M2BQQGZ.mjs";import{createHash as q,randomUUID as Q}from"node:crypto";import f from"node:fs/promises";import g from"node:path";import{refusal as V,said as T,saying as X}from"../browser/shared/i18n/index.mjs";import{extensionOf as Y,imageExtension as Z,imageFile as M,mediaTypeOf as tt,UPLOAD_LIMITS as y}from"../browser/shared/media.mjs";import{slugPattern as F}from"../browser/shared/reports.mjs";import{documentDirectory as U,documentFiles as et,layoutOf as nt}from"../browser/shared/workspace.mjs";var z=i=>Y(String(i??"").replace(/[?#].*$/,"")),it=i=>{let e=String(i??"").replace(/[?#].*$/,"");e=e.slice(e.lastIndexOf("/")+1);try{e=decodeURIComponent(e)}catch{}return e.replace(/[\u0000-\u001f<>:"/\\|?*]/g,"").trim().slice(0,120)||"file"};function rt(i){let e=i.subarray(0,16);return e[0]===137&&e.toString("latin1",1,4)==="PNG"?"image/png":e[0]===0&&e[1]===0&&e[2]===1&&e[3]===0?"image/x-icon":e[0]===255&&e[1]===216?"image/jpeg":e.toString("latin1",0,4)==="GIF8"?"image/gif":e.toString("latin1",0,4)==="RIFF"&&e.toString("latin1",8,12)==="WEBP"?"image/webp":e.toString("latin1",4,12)==="ftypavif"?"image/avif":/^\s*(<\?xml[^>]*>\s*)?(<!--[\s\S]*?-->\s*)*<svg\b/i.test(i.subarray(0,512).toString("utf8"))?"image/svg+xml":null}var w=(i,e)=>V(e,{reason:i}),S=(i,e)=>{let l=rt(i);if(!l)throw w("type","\u4EC5\u652F\u6301\u56FE\u7247");return Z(l)},at=(i,e)=>z(e),ot=(i,e)=>{let l=z(e);if(!["html","htm","pdf"].includes(l)||l==="pdf"&&i.subarray(0,5).toString("latin1")!=="%PDF-")throw w("type","\u53EA\u80FD\u5D4C\u5165 HTML \u6216 PDF \u6587\u4EF6");return l},j={big:i=>T("\u56FE\u7247\u592A\u5927\uFF08\u6700\u591A {0} MB\uFF09",i),unreachable:"\u4E0B\u8F7D\u4E0D\u4E86\u8FD9\u5F20\u56FE\u7247"},B={big:i=>T("\u6587\u4EF6\u592A\u5927\uFF08\u6700\u591A {0} MB\uFF09",i),unreachable:"\u4E0B\u8F7D\u4E0D\u4E86\u8FD9\u4E2A\u6587\u4EF6"},k={icon:{limit:y.icon,words:j,extension:S},image:{limit:y.image,words:j,extension:S},file:{limit:y.file,words:B,extension:at,named:!0},embed:{limit:y.embed,words:B,extension:ot,named:!0}};function wt(i,e,l,b){let s=k[i].extension(l,b);return`${i}-${e.slice(0,12)}${s?`.${s}`:""}`}function bt({reportsDirectory:i}){let e=nt(i).emojiLibrary,l=async t=>{let n=U(t,i);return await f.stat(et(n).html).catch(()=>null)?n:null},b=g.join(e,"library.json"),s=(t,n,r)=>[t,{ok:!1,reason:n,...X(r)}];async function O(t,n,{stem:r,limit:a,words:c=j,extension:o=S,given:m}){let u=o(n,m);if(n.length>a)throw w("size",c.big(a/1024/1024));let p=`${r}-${q("sha256").update(n).digest("hex").slice(0,12)}${u?`.${u}`:""}`;await f.mkdir(t,{recursive:!0});let h=g.join(t,p);return await f.stat(h).catch(()=>null)||await f.writeFile(h,n),p}let E=(t,n,r,a=y.icon)=>O(t,n,{stem:r,limit:a});async function I(t,n,r=j){let a=await L(t,{unreachable:r.unreachable});if(!a.ok)throw w("download",r.unreachable);let c=await _(a,n);if(!c)throw w("size",r.big(n/1024/1024));return c}async function $(){try{let t=JSON.parse(await f.readFile(b,"utf8"));return Array.isArray(t)?t:[]}catch{return[]}}let v=t=>({id:t.id,name:t.name,url:`/__gallery/edit/emoji-library/${t.file}`,created_time:t.created,alive:!0});async function A(t){let{slug:n,data:r,url:a,library:c}=t??{},o=Object.hasOwn(k,t?.kind)?t.kind:"icon";if(typeof n!="string"||!F.test(n))return s(400,"body");let m=await l(n);if(!m)return s(404,"missing");let{limit:u,words:p,extension:h,named:J}=k[o];try{let d,x;if(typeof r=="string")d=Buffer.from(r,"base64"),x=t.name;else if(typeof a=="string")d=await I(a,u,p),x=a;else if(typeof c=="string"){let P=(await $()).find(K=>K.id===c);if(!P)return s(404,"library","\u8FD9\u4E2A\u81EA\u5B9A\u4E49\u8868\u60C5\u5DF2\u4E0D\u5728\u8868\u60C5\u5E93\u91CC");d=await f.readFile(g.join(e,P.file))}else return s(400,"body");return[200,{ok:!0,path:`assets/${await O(g.join(m,"assets"),d,{stem:o,limit:u,words:p,extension:h,given:x})}`,...J?{name:it(x),size:d.length}:{}}]}catch(d){return s(422,d.reason??"write",d)}}async function R(t){let{slug:n,url:r,parts:a="all"}=t??{};if(typeof n!="string"||!F.test(n)||typeof r!="string"||!["all","icon","title"].includes(a))return s(400,"body");let c=await l(n);if(!c)return s(404,"missing");try{return[200,{ok:!0,...await N(r,async(m,u)=>`assets/${await E(g.join(c,"assets"),m,u,y.image)}`,{icon:a!=="title",cover:a==="all"})}]}catch(o){return s(422,o.reason??"download",o)}}async function W(t){return typeof t?.url!="string"?s(400,"body"):[200,{ok:!0,...await D(t.url)}]}async function C(t){let{slug:n,name:r,url:a}=t??{};if(typeof r!="string"||!/^[\p{Ll}\p{Lo}\d_-]{1,49}$/u.test(r)||typeof a!="string")return s(400,"body");let c=await $();if(c.some(o=>o.name===r))return s(409,"name","\u540D\u79F0\u5DF2\u88AB\u5360\u7528");try{let o;M(a)&&typeof n=="string"&&F.test(n)?o=await f.readFile(g.join(U(n,i),a)):o=await I(a,y.icon);let m=await E(e,o,"emoji"),u={id:Q(),name:r,file:m,created:Date.now()};return await f.writeFile(b,`${JSON.stringify([...c,u],null,2)}
3
3
  `),[200,{ok:!0,entry:v(u)}]}catch(o){return s(422,o.reason??"write",o)}}let G=async()=>[200,{ok:!0,list:(await $()).map(v)}];async function H(t){if(!M(`assets/${t}`))return null;let n=await f.readFile(g.join(e,t)).catch(()=>null);return n&&{type:tt(t),body:n}}return{upload:A,unfurl:R,frameable:W,addEmoji:C,listEmojis:G,readEmoji:H}}export{wt as a,bt as b};
@@ -1,3 +1,3 @@
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{b as E}from"./chunk-SXHBYZST.mjs";import{g as M}from"./chunk-OW5NWPOJ.mjs";import{a as O}from"./chunk-HYMEEXKN.mjs";import{e as I,j as S}from"./chunk-FJYN7RTH.mjs";import d from"node:fs/promises";import b from"node:path";import{isInstance as T}from"../browser/shared/components/index.mjs";import{ATTRIBUTE as _}from"../browser/shared/components/installed.mjs";import{exportSourceOf as q}from"../browser/shared/export-wrap.mjs";import{sha256 as w}from"../browser/shared/files.mjs";import{attr as g,hasClass as y}from"../browser/shared/html-tree.mjs";import{editStateDirectory as F,exportsDirectory as z,qaDirectory as G,reportsDirectory as H}from"../browser/shared/paths.mjs";import{documentDirectory as K,documentFiles as Q}from"../browser/shared/workspace.mjs";function V(t,e=null){return t.tagName==="figure"&&y(t,"doc-figure")||t.tagName==="div"&&(y(t,"doc-code")||y(t,"doc-diff"))||e===D||T(t)||y(t,"doc-flow")||y(t,"doc-sheet-shell")||g(t,"data-doc-sheets")!==void 0?0:t.tagName==="figure"||y(t,"doc-columns")?1:y(t,"doc-table-wrap")?2:3}function X(t){let e=new Map,n=new Map;for(let i of I(t).units)i.blockId&&!n.has(i.blockId)&&n.set(i.blockId,i.kind);let a=new Map,r=new Map,o=new Map,f=i=>!!i.tagName&&g(i,"data-block-id")!==void 0,u=(i,c)=>{if(i.nodeName==="#text")return i.value;if(!i.tagName||i.tagName==="template")return"";let s=g(i,"data-doc-chart-data")?.trim();s&&a.get(c).push(s);let l=g(i,"data-doc-chart-source")?.trim();l&&!r.has(l)&&r.set(l,c);let h=i.attrs.map(({name:k,value:N})=>`${k}="${N}"`).sort().join(" ");return`<${i.tagName} ${h}>${(i.childNodes??[]).map(k=>f(k)?"":u(k,c)).join("")}</${i.tagName}>`},m=(i,c)=>{for(let s of i.childNodes??[]){if(!s.tagName||s.tagName==="template")continue;let l=g(s,"data-block-id"),h=c;if(l!==void 0&&!e.has(l)){let k=[s.tagName,...(g(s,"class")??"").split(/\s+/).filter(Boolean).slice(0,1)].join("."),N=o.get(c)??0;o.set(c,N+1),a.set(l,[]);let v=V(s,n.get(l)),x=s.sourceCodeLocation,U=x?(x.endOffset??x.startTag?.endOffset??x.startOffset)-x.startOffset:0,B=u(s,l).replace(R," ");e.set(l,{hash:w(B).slice(0,16),bare:w(B.replace(`data-block-id="${l}"`,"")).slice(0,16),rank:v,card:v<3,whole:n.get(l)===D,figure:n.get(l)===tt,tag:k,parent:c,at:N,size:U,package:T(s)?g(s,_)??null:null}),h=l}m(s,h)}};m(O(t),null);let p=new Map([...e].map(([i,{hash:c,bare:s}])=>[i,{hash:c,bare:s}]));for(let[i,c]of a){let s=c.map(l=>p.get(r.get(l))).filter(Boolean);s.length&&(e.get(i).hash=w([p.get(i).hash,...s.map(({hash:l})=>l)].join("|")).slice(0,16),e.get(i).bare=w([p.get(i).bare,...s.map(({bare:l})=>l)].join("|")).slice(0,16))}return e}function Y(t){let e=[],n=a=>{for(let r of a.childNodes??[])if(!(!r.tagName||r.tagName==="template"||g(r,"data-block-id")!==void 0))if(r.tagName==="script"||r.tagName==="style"){let o=r.attrs.map(({name:f,value:u})=>`${f}="${u}"`).sort().join(" ");e.push(`<${r.tagName} ${o}>${(r.childNodes??[]).map(f=>f.value??"").join("")}`.replace(R," "))}else n(r)};return n(O(t)),e.length?w(e.join("|")).slice(0,16):""}var Z=t=>Object.fromEntries(M(t).map(({id:e,stamp:n})=>[e,n])),D="block",tt="figure",R=/[ \t\n\f\r]+/g,et=["export","preview"];function st(t){if(t==null)return null;try{let{blocks:e,places:n,moved:a,unseen:r,from:o,time:f,idless:u,page:m,packages:p}=JSON.parse(t)??{};if(!e||typeof e!="object"||Array.isArray(e))return null;let i=n&&typeof n=="object"&&!Array.isArray(n)?n:{},c=s=>Array.isArray(s)?s.filter(l=>typeof l=="string"):[];return{blocks:Object.fromEntries(Object.entries(e).filter(([,s])=>typeof s=="string")),places:Object.fromEntries(Object.entries(i).filter(([,s])=>Array.isArray(s)&&s.length===2&&(s[0]===null||typeof s[0]=="string")&&Number.isInteger(s[1]))),moved:c(a),unseen:c(r),...et.includes(o)?{from:o,time:Number.isFinite(f)?f:null}:{},...c(u).length?{idless:c(u)}:{},...typeof m=="string"?{page:m}:{},...p&&typeof p=="object"&&!Array.isArray(p)?{packages:Object.fromEntries(Object.entries(p).filter(([,s])=>typeof s=="string"))}:{}}}catch{return null}}var $="ge-idless-";function nt(t,{from:e,time:n}){let a=0,{text:r}=S(E(t).text,()=>`${$}${a++}`),o=Z(r),f={blocks:{},places:{},moved:[],unseen:[],from:e,time:n,page:Y(r),...Object.keys(o).length?{packages:o}:{}},u=[];for(let[m,{hash:p,bare:i,card:c,parent:s,at:l}]of X(r)){if(m.startsWith($)){u.push(i);continue}f.blocks[m]=p,s?.startsWith($)||(f.places[m]=[s,l]),c&&f.unseen.push(m)}return u.length?{...f,idless:u}:f}function yt(t,e){if(!e?.idless?.length)return e;let n=new Map;for(let o of e.idless)n.set(o,(n.get(o)??0)+1);let a={...e,blocks:{...e.blocks},unseen:[...e.unseen]};for(let[o,{hash:f,bare:u,card:m}]of t)Object.hasOwn(e.blocks,o)||!n.get(u)||(n.set(u,n.get(u)-1),a.blocks[o]=f,m&&a.unseen.push(o));let r=[...n].flatMap(([o,f])=>Array(f).fill(o));return r.length?a.idless=r:delete a.idless,a}var at=/<[^>]*\sdata-doc-placeholder\b/,j=t=>b.join(G,t),L=t=>b.join(j(t),"blocks.json"),P=t=>b.join(j(t),"exported.html");async function W(t){return st(await d.readFile(L(t),"utf8").catch(()=>null))!==null}async function C(t,e,n){let a=async c=>d.readFile(c).then(s=>({bytes:s,file:c}),()=>null),r=await a(P(t)),o=[r];if(e){let c=e.slice(0,16),s=b.join(F,"history",t),l=await d.readdir(s).catch(()=>[]);o.push(...await Promise.all(l.filter(h=>h.endsWith(`-${c}.html`)).map(h=>a(b.join(s,h))))),o.push(await a(b.join(F,"snapshots",`${c}.html`)))}let f=r?(await d.stat(r.file).catch(()=>null))?.mtimeMs??null:null,m=!(r&&e&&n!==null&&f!==null&&f>n&&w(r.bytes)!==e)&&e&&o.find(c=>c&&w(c.bytes)===e),p=m||r;if(!p)return null;let i=m&&n!==null?n:p===r?f??n:(await d.stat(p.file).catch(()=>null))?.mtimeMs??n;return{text:p.bytes.toString("utf8"),time:i??null}}async function A(t){let e=b.join(z,`${t}.html`),[n,a]=await Promise.all([d.readFile(e,"utf8").catch(()=>null),d.stat(e).catch(()=>null)]);return n===null||!a?null:{said:q(n),time:a.mtimeMs}}async function J(t,e,n){if(at.test(e))return!1;let a=nt(e,n);return!Object.keys(a.blocks).length&&!a.idless?!1:(await d.mkdir(j(t),{recursive:!0}),await d.writeFile(L(t),`${JSON.stringify(a)}
2
+ import{b as E}from"./chunk-WTEGUPFG.mjs";import{g as M}from"./chunk-SAHS56QM.mjs";import{a as O}from"./chunk-2RKIHJI2.mjs";import{e as I,j as S}from"./chunk-KFZBYDIS.mjs";import d from"node:fs/promises";import b from"node:path";import{isInstance as T}from"../browser/shared/components/index.mjs";import{ATTRIBUTE as _}from"../browser/shared/components/installed.mjs";import{exportSourceOf as q}from"../browser/shared/export-wrap.mjs";import{sha256 as w}from"../browser/shared/files.mjs";import{attr as g,hasClass as y}from"../browser/shared/html-tree.mjs";import{editStateDirectory as F,exportsDirectory as z,qaDirectory as G,reportsDirectory as H}from"../browser/shared/paths.mjs";import{documentDirectory as K,documentFiles as Q}from"../browser/shared/workspace.mjs";function V(t,e=null){return t.tagName==="figure"&&y(t,"doc-figure")||t.tagName==="div"&&(y(t,"doc-code")||y(t,"doc-diff"))||e===D||T(t)||y(t,"doc-flow")||y(t,"doc-sheet-shell")||g(t,"data-doc-sheets")!==void 0?0:t.tagName==="figure"||y(t,"doc-columns")?1:y(t,"doc-table-wrap")?2:3}function X(t){let e=new Map,n=new Map;for(let i of I(t).units)i.blockId&&!n.has(i.blockId)&&n.set(i.blockId,i.kind);let a=new Map,r=new Map,o=new Map,f=i=>!!i.tagName&&g(i,"data-block-id")!==void 0,u=(i,c)=>{if(i.nodeName==="#text")return i.value;if(!i.tagName||i.tagName==="template")return"";let s=g(i,"data-doc-chart-data")?.trim();s&&a.get(c).push(s);let l=g(i,"data-doc-chart-source")?.trim();l&&!r.has(l)&&r.set(l,c);let h=i.attrs.map(({name:k,value:N})=>`${k}="${N}"`).sort().join(" ");return`<${i.tagName} ${h}>${(i.childNodes??[]).map(k=>f(k)?"":u(k,c)).join("")}</${i.tagName}>`},m=(i,c)=>{for(let s of i.childNodes??[]){if(!s.tagName||s.tagName==="template")continue;let l=g(s,"data-block-id"),h=c;if(l!==void 0&&!e.has(l)){let k=[s.tagName,...(g(s,"class")??"").split(/\s+/).filter(Boolean).slice(0,1)].join("."),N=o.get(c)??0;o.set(c,N+1),a.set(l,[]);let v=V(s,n.get(l)),x=s.sourceCodeLocation,U=x?(x.endOffset??x.startTag?.endOffset??x.startOffset)-x.startOffset:0,B=u(s,l).replace(R," ");e.set(l,{hash:w(B).slice(0,16),bare:w(B.replace(`data-block-id="${l}"`,"")).slice(0,16),rank:v,card:v<3,whole:n.get(l)===D,figure:n.get(l)===tt,tag:k,parent:c,at:N,size:U,package:T(s)?g(s,_)??null:null}),h=l}m(s,h)}};m(O(t),null);let p=new Map([...e].map(([i,{hash:c,bare:s}])=>[i,{hash:c,bare:s}]));for(let[i,c]of a){let s=c.map(l=>p.get(r.get(l))).filter(Boolean);s.length&&(e.get(i).hash=w([p.get(i).hash,...s.map(({hash:l})=>l)].join("|")).slice(0,16),e.get(i).bare=w([p.get(i).bare,...s.map(({bare:l})=>l)].join("|")).slice(0,16))}return e}function Y(t){let e=[],n=a=>{for(let r of a.childNodes??[])if(!(!r.tagName||r.tagName==="template"||g(r,"data-block-id")!==void 0))if(r.tagName==="script"||r.tagName==="style"){let o=r.attrs.map(({name:f,value:u})=>`${f}="${u}"`).sort().join(" ");e.push(`<${r.tagName} ${o}>${(r.childNodes??[]).map(f=>f.value??"").join("")}`.replace(R," "))}else n(r)};return n(O(t)),e.length?w(e.join("|")).slice(0,16):""}var Z=t=>Object.fromEntries(M(t).map(({id:e,stamp:n})=>[e,n])),D="block",tt="figure",R=/[ \t\n\f\r]+/g,et=["export","preview"];function st(t){if(t==null)return null;try{let{blocks:e,places:n,moved:a,unseen:r,from:o,time:f,idless:u,page:m,packages:p}=JSON.parse(t)??{};if(!e||typeof e!="object"||Array.isArray(e))return null;let i=n&&typeof n=="object"&&!Array.isArray(n)?n:{},c=s=>Array.isArray(s)?s.filter(l=>typeof l=="string"):[];return{blocks:Object.fromEntries(Object.entries(e).filter(([,s])=>typeof s=="string")),places:Object.fromEntries(Object.entries(i).filter(([,s])=>Array.isArray(s)&&s.length===2&&(s[0]===null||typeof s[0]=="string")&&Number.isInteger(s[1]))),moved:c(a),unseen:c(r),...et.includes(o)?{from:o,time:Number.isFinite(f)?f:null}:{},...c(u).length?{idless:c(u)}:{},...typeof m=="string"?{page:m}:{},...p&&typeof p=="object"&&!Array.isArray(p)?{packages:Object.fromEntries(Object.entries(p).filter(([,s])=>typeof s=="string"))}:{}}}catch{return null}}var $="ge-idless-";function nt(t,{from:e,time:n}){let a=0,{text:r}=S(E(t).text,()=>`${$}${a++}`),o=Z(r),f={blocks:{},places:{},moved:[],unseen:[],from:e,time:n,page:Y(r),...Object.keys(o).length?{packages:o}:{}},u=[];for(let[m,{hash:p,bare:i,card:c,parent:s,at:l}]of X(r)){if(m.startsWith($)){u.push(i);continue}f.blocks[m]=p,s?.startsWith($)||(f.places[m]=[s,l]),c&&f.unseen.push(m)}return u.length?{...f,idless:u}:f}function yt(t,e){if(!e?.idless?.length)return e;let n=new Map;for(let o of e.idless)n.set(o,(n.get(o)??0)+1);let a={...e,blocks:{...e.blocks},unseen:[...e.unseen]};for(let[o,{hash:f,bare:u,card:m}]of t)Object.hasOwn(e.blocks,o)||!n.get(u)||(n.set(u,n.get(u)-1),a.blocks[o]=f,m&&a.unseen.push(o));let r=[...n].flatMap(([o,f])=>Array(f).fill(o));return r.length?a.idless=r:delete a.idless,a}var at=/<[^>]*\sdata-doc-placeholder\b/,j=t=>b.join(G,t),L=t=>b.join(j(t),"blocks.json"),P=t=>b.join(j(t),"exported.html");async function W(t){return st(await d.readFile(L(t),"utf8").catch(()=>null))!==null}async function C(t,e,n){let a=async c=>d.readFile(c).then(s=>({bytes:s,file:c}),()=>null),r=await a(P(t)),o=[r];if(e){let c=e.slice(0,16),s=b.join(F,"history",t),l=await d.readdir(s).catch(()=>[]);o.push(...await Promise.all(l.filter(h=>h.endsWith(`-${c}.html`)).map(h=>a(b.join(s,h))))),o.push(await a(b.join(F,"snapshots",`${c}.html`)))}let f=r?(await d.stat(r.file).catch(()=>null))?.mtimeMs??null:null,m=!(r&&e&&n!==null&&f!==null&&f>n&&w(r.bytes)!==e)&&e&&o.find(c=>c&&w(c.bytes)===e),p=m||r;if(!p)return null;let i=m&&n!==null?n:p===r?f??n:(await d.stat(p.file).catch(()=>null))?.mtimeMs??n;return{text:p.bytes.toString("utf8"),time:i??null}}async function A(t){let e=b.join(z,`${t}.html`),[n,a]=await Promise.all([d.readFile(e,"utf8").catch(()=>null),d.stat(e).catch(()=>null)]);return n===null||!a?null:{said:q(n),time:a.mtimeMs}}async function J(t,e,n){if(at.test(e))return!1;let a=nt(e,n);return!Object.keys(a.blocks).length&&!a.idless?!1:(await d.mkdir(j(t),{recursive:!0}),await d.writeFile(L(t),`${JSON.stringify(a)}
3
3
  `),!0)}async function bt(t){let e=new Map(await Promise.all(t.map(async a=>[a,await A(a).catch(()=>null)])));return{keep:async(a,r=null)=>{for(let o of a)try{if(!await W(o)){let m=e.get(o),p=await C(o,m?.said??null,m?.time??null);p&&await J(o,p.text,{from:"export",time:p.time})}let[f,u]=await Promise.all([d.readFile(Q(K(o,H)).html),r?{said:r.get(o)??null}:A(o)]);u?.said&&w(f)===u.said&&(await d.mkdir(j(o),{recursive:!0}),await d.writeFile(P(o),f))}catch{}}}}async function kt(t,e){try{if(await W(t))return!1;let n=await A(t),a=await C(t,n?.said??null,n?.time??null);return await J(t,a?.text??e,a?{from:"export",time:a.time}:{from:"preview",time:Date.now()})}catch{return!1}}export{V as a,X as b,Y as c,Z as d,et as e,st as f,nt as g,yt as h,W as i,C as j,bt as k,kt 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{c as i,d as u}from"./chunk-RKPWLGZ3.mjs";import{j as c,k as f}from"./chunk-UFNYFFKO.mjs";import{t as p}from"./chunk-D4EURAX4.mjs";import{b as d,f as h}from"./chunk-4OZWXZE5.mjs";import w from"node:fs/promises";import y from"node:path";import{reportsDirectory as b}from"../browser/shared/paths.mjs";import{sameDirectory as x}from"../browser/shared/preview-server.mjs";import{copyOldDocuments as j,ensureWorkspace as v,layoutOf as D}from"../browser/shared/workspace.mjs";import{nameProblem as G,writeWorkspaceName as N}from"../browser/shared/workspace-name.mjs";import{registerQuietly as O}from"../browser/shared/workspace-registry.mjs";var g=(o,t)=>`${o} ${t}${o===1?"":"s"}`;function C(o,t,r){let{preferences:s}=D(r);return[o.copied.length?`Copied ${g(o.copied.length,"document")} from ${t}: ${o.copied.join(", ")}`:`Copied no documents from ${t}.`,...o.skipped.length?[`Skipped (the slug is taken here, or the folder's name is no slug): ${o.skipped.join(", ")}`]:[],...o.kept.length?[`Left behind (a name a workspace keeps for itself, for its custom blocks here, which no new document takes): ${o.kept.join(", ")}`]:[],...o.preferences==="copied"?[`\u5199\u4F5C\u504F\u597D\uFF1Acopied (${s})`]:o.preferences==="kept"?[`\u5199\u4F5C\u504F\u597D\uFF1Akept the workspace's (${s}); the old one was not copied`]:[],...o.outline?[`Sidebar order: ${o.outline}`]:[],...o.page?[`\u5199\u4F5C\u504F\u597D's page: ${o.page==="copied"?"copied":"kept the workspace's"}`]:[],...o.emoji?[`Emoji library: ${o.emoji} added`]:[],...o.history?[`Recent versions: ${g(o.history,"document")}`]:[],...o.packages.length?[`Custom blocks: ${o.packages.join(", ")}`]:[]]}async function U(o){let{values:t}=h({values:["--from","--name"],argv:o}),r=b,s=t.get("--name"),l=s===void 0?null:G(s);if(l)throw new d(l);let m;try{let{made:e,ours:n,reads:k}=await v(r);n||(console.error(u(r,k)),process.exit(1)),m=e}catch(e){if(!e.code)throw e;console.error(i(r,e.code)),process.exit(1)}if(console.log(`\u5DE5\u4F5C\u533A\uFF1A${r}\uFF08${m?"\u65B0\u5EFA":"\u5DF2\u6709"}\uFF09`),s!==void 0)try{let e=await N(r,s);console.log(`\u540D\u5B57\uFF1A${e.name}${e.before&&e.before!==e.name?` (it was "${e.before}")`:""}`)}catch(e){console.error(e.code?i(r,e.code):e.message),process.exit(1)}if(await O(r),t.has("--from")){let e=y.resolve(t.get("--from"));await w.stat(e).then(n=>n.isDirectory(),()=>!1)||(console.error(`No such folder: ${e} (--from names an older Gallery's reports/ folder).`),process.exit(1)),x(e,r)&&(console.error(`${e} is this workspace: --from names another folder (an older Gallery's reports/).`),process.exit(1));for(let n of C(await j({from:e,to:r}),e,r))console.log(n)}let $=await p(r);for(let e of $.packs)e.failed?console.warn(`\u5757\u5305\uFF1AGallery's pack ${e.id} was not installed (${e.failed}); a later start tries again.`):e.first&&console.log(`\u5757\u5305\uFF1A${e.name.zh} (${e.id} ${e.version}, ${e.added.length+e.same.length+e.updated.length} blocks)${e.id==="gallery-soft"?", switched off: \u8BBE\u7F6E \u203A \u7EC4\u4EF6\u5217\u8868 turns it on":""}`);let a=await c(r);a.did==="made"?console.log(`\u9996\u9875\uFF1A${a.file} (the home page, its cards Gallery's today and note; the workbench opens it first)`):a.did==="failed"&&console.warn(`\u9996\u9875\uFF1A${f(a)}`),console.log('Next: gallery new <slug> "<title>" makes a document; gallery open opens the workbench.')}export{C as a,U as b};
2
+ import{c as i,d as u}from"./chunk-KUILYI7H.mjs";import{j as f,k as p}from"./chunk-VKSRM7EY.mjs";import{u as c}from"./chunk-LE44MD3O.mjs";import{b as d,f as h}from"./chunk-4OZWXZE5.mjs";import w from"node:fs/promises";import y from"node:path";import{reportsDirectory as b}from"../browser/shared/paths.mjs";import{sameDirectory as x}from"../browser/shared/preview-server.mjs";import{copyOldDocuments as j,ensureWorkspace as v,layoutOf as D}from"../browser/shared/workspace.mjs";import{nameProblem as G,writeWorkspaceName as N}from"../browser/shared/workspace-name.mjs";import{registerQuietly as O}from"../browser/shared/workspace-registry.mjs";var g=(o,t)=>`${o} ${t}${o===1?"":"s"}`;function C(o,t,r){let{preferences:s}=D(r);return[o.copied.length?`Copied ${g(o.copied.length,"document")} from ${t}: ${o.copied.join(", ")}`:`Copied no documents from ${t}.`,...o.skipped.length?[`Skipped (the slug is taken here, or the folder's name is no slug): ${o.skipped.join(", ")}`]:[],...o.kept.length?[`Left behind (a name a workspace keeps for itself, for its custom blocks here, which no new document takes): ${o.kept.join(", ")}`]:[],...o.preferences==="copied"?[`\u5199\u4F5C\u504F\u597D\uFF1Acopied (${s})`]:o.preferences==="kept"?[`\u5199\u4F5C\u504F\u597D\uFF1Akept the workspace's (${s}); the old one was not copied`]:[],...o.outline?[`Sidebar order: ${o.outline}`]:[],...o.page?[`\u5199\u4F5C\u504F\u597D's page: ${o.page==="copied"?"copied":"kept the workspace's"}`]:[],...o.emoji?[`Emoji library: ${o.emoji} added`]:[],...o.history?[`Recent versions: ${g(o.history,"document")}`]:[],...o.packages.length?[`Custom blocks: ${o.packages.join(", ")}`]:[]]}async function U(o){let{values:t}=h({values:["--from","--name"],argv:o}),r=b,s=t.get("--name"),l=s===void 0?null:G(s);if(l)throw new d(l);let m;try{let{made:e,ours:n,reads:k}=await v(r);n||(console.error(u(r,k)),process.exit(1)),m=e}catch(e){if(!e.code)throw e;console.error(i(r,e.code)),process.exit(1)}if(console.log(`\u5DE5\u4F5C\u533A\uFF1A${r}\uFF08${m?"\u65B0\u5EFA":"\u5DF2\u6709"}\uFF09`),s!==void 0)try{let e=await N(r,s);console.log(`\u540D\u5B57\uFF1A${e.name}${e.before&&e.before!==e.name?` (it was "${e.before}")`:""}`)}catch(e){console.error(e.code?i(r,e.code):e.message),process.exit(1)}if(await O(r),t.has("--from")){let e=y.resolve(t.get("--from"));await w.stat(e).then(n=>n.isDirectory(),()=>!1)||(console.error(`No such folder: ${e} (--from names an older Gallery's reports/ folder).`),process.exit(1)),x(e,r)&&(console.error(`${e} is this workspace: --from names another folder (an older Gallery's reports/).`),process.exit(1));for(let n of C(await j({from:e,to:r}),e,r))console.log(n)}let $=await c(r);for(let e of $.packs)e.failed?console.warn(`\u5757\u5305\uFF1AGallery's pack ${e.id} was not installed (${e.failed}); a later start tries again.`):e.first&&console.log(`\u5757\u5305\uFF1A${e.name.zh} (${e.id} ${e.version}, ${e.added.length+e.same.length+e.updated.length} blocks)${e.id==="gallery-soft"?", switched off: \u8BBE\u7F6E \u203A \u7EC4\u4EF6\u5217\u8868 turns it on":""}`);let a=await f(r);a.did==="made"?console.log(`\u9996\u9875\uFF1A${a.file} (the home page, its cards Gallery's today and note; the workbench opens it first)`):a.did==="failed"&&console.warn(`\u9996\u9875\uFF1A${p(a)}`),console.log('Next: gallery new <slug> "<title>" makes a document; gallery open opens the workbench.')}export{C as a,U as b};