@rho-workspace/rho 0.5.3 → 0.5.5

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 (277) hide show
  1. package/README.md +24 -5
  2. package/dist/browser-access.js +3 -2
  3. package/dist/capabilities.d.ts +29 -2
  4. package/dist/capabilities.js +79 -2
  5. package/dist/cli.js +237 -99
  6. package/dist/contract.generated.d.ts +441 -16
  7. package/dist/contract.generated.js +1 -1
  8. package/dist/contracts/owners.generated.js +459 -10
  9. package/dist/conversation-presentation.d.ts +3 -1
  10. package/dist/conversation-presentation.js +16 -6
  11. package/dist/conversations.d.ts +10 -6
  12. package/dist/conversations.js +17 -13
  13. package/dist/discovery.d.ts +1 -0
  14. package/dist/discovery.js +3 -3
  15. package/dist/extension-contract.d.ts +99 -0
  16. package/dist/extension-contract.js +52 -0
  17. package/dist/extension-directory.d.ts +9 -0
  18. package/dist/extension-directory.js +11 -0
  19. package/dist/extension-worker.d.ts +1 -0
  20. package/dist/extension-worker.js +36 -0
  21. package/dist/extensions.d.ts +157 -0
  22. package/dist/extensions.js +349 -0
  23. package/dist/installs.d.ts +11 -0
  24. package/dist/installs.js +179 -0
  25. package/dist/plugin-cli.d.ts +1 -0
  26. package/dist/plugin-cli.js +139 -0
  27. package/dist/plugin-inventory.json +18 -0
  28. package/dist/plugins.d.ts +3 -3
  29. package/dist/project-notes.js +2 -0
  30. package/dist/project-work.d.ts +3 -1
  31. package/dist/project-work.js +15 -2
  32. package/dist/protocol.d.ts +7 -0
  33. package/dist/protocol.js +11 -7
  34. package/dist/screen-check-skill.d.ts +2 -0
  35. package/dist/screen-check-skill.js +39 -0
  36. package/dist/server.d.ts +6 -1
  37. package/dist/server.js +105 -15
  38. package/dist/web/.vite/manifest.json +65 -65
  39. package/dist/web/assets/{canvas-BXhC8RDZ.js → canvas-D8rDdfDz.js} +1 -1
  40. package/dist/web/assets/choices-b0XhrGQV.js +1 -0
  41. package/dist/web/assets/{console-e1P5qYQ5.js → console-BSjLGe0T.js} +1 -1
  42. package/dist/web/assets/{dist-Dd3iAGFy.js → dist-Buk0lwzI.js} +2 -2
  43. package/dist/web/assets/dist-Cw8hRIlT.js +1 -0
  44. package/dist/web/assets/dist-Tzoe_zm-.js +3 -0
  45. package/dist/web/assets/{dist-DEorbOW0.js → dist-foH9IKc6.js} +1 -1
  46. package/dist/web/assets/explore-in-BVUy3ZW_.js +1 -0
  47. package/dist/web/assets/graph-1OdIJ9l7.js +2 -0
  48. package/dist/web/assets/index-CsC3sTRq.css +1 -0
  49. package/dist/web/assets/{index-BYuKpyoi.js → index-CxmItXqa.js} +220 -121
  50. package/dist/web/assets/{notes-meaning-B3HFbh84.js → notes-meaning-pVbbQUGP.js} +1 -1
  51. package/dist/web/assets/overview-B9UtVJ32.js +6 -0
  52. package/dist/web/assets/preview-CksD_5KS.js +1 -0
  53. package/dist/web/assets/{review-BVh9jWMB.js → review-CMxQlQ-C.js} +1 -1
  54. package/dist/web/assets/{skills-DPaEYkln.js → skills-BFNSyrnD.js} +1 -1
  55. package/dist/web/assets/{skills-work-dvjfy_tu.js → skills-work-BGPSnF_I.js} +1 -1
  56. package/dist/web/assets/{studio-process-BYm8mjRJ.js → studio-process-CsRoTHOh.js} +2 -2
  57. package/dist/web/assets/{timeline-events-CDZ7wiJX.js → timeline-events-BbuuFWHV.js} +1 -1
  58. package/dist/web/assets/{work-turns-BeCt303c.js → work-turns-BvJlIMmA.js} +1 -1
  59. package/dist/web/assets/workspace-CWlkjLNx.js +5 -0
  60. package/dist/web/composition.json +80 -80
  61. package/dist/web/index.html +3 -3
  62. package/dist/web/renderer.json +1 -1
  63. package/dist/web-assets.d.ts +2 -1
  64. package/dist/web-assets.js +3 -2
  65. package/dist/work-contract.js +2 -2
  66. package/docs/FRONTEND.md +30 -14
  67. package/docs/HEADLESS.md +60 -14
  68. package/docs/PLUGIN-AUTHORING.md +4 -0
  69. package/docs/THIRD-PARTY-PLUGINS.md +190 -0
  70. package/example/pa14-qs/.rho/rho/conversations/c-67f77cfebaba2cea.json +1 -1
  71. package/example/pa14-qs/.rho/rho/conversations/c-91aa2e46b1ac1a6c.json +1 -1
  72. package/example/pa14-qs/.rho/rho/conversations/c-fa24dfd80dfe4bcb.json +1 -1
  73. package/node_modules/@hono/node-server/dist/index.js +11 -0
  74. package/node_modules/@hono/node-server/dist/index.mjs +11 -0
  75. package/node_modules/@hono/node-server/dist/listener.js +11 -0
  76. package/node_modules/@hono/node-server/dist/listener.mjs +11 -0
  77. package/node_modules/@hono/node-server/dist/request.js +11 -0
  78. package/node_modules/@hono/node-server/dist/request.mjs +11 -0
  79. package/node_modules/@hono/node-server/dist/server.js +11 -0
  80. package/node_modules/@hono/node-server/dist/server.mjs +11 -0
  81. package/node_modules/@hono/node-server/dist/vercel.js +11 -0
  82. package/node_modules/@hono/node-server/dist/vercel.mjs +11 -0
  83. package/node_modules/@hono/node-server/package.json +1 -1
  84. package/node_modules/@rho-workspace/plugin-agent/README.md +42 -1
  85. package/node_modules/@rho-workspace/plugin-agent/dist/acp-conversation.js +14 -3
  86. package/node_modules/@rho-workspace/plugin-agent/dist/activity-normalize.d.ts +1 -0
  87. package/node_modules/@rho-workspace/plugin-agent/dist/activity-normalize.js +2 -2
  88. package/node_modules/@rho-workspace/plugin-agent/dist/conversation.d.ts +1 -0
  89. package/node_modules/@rho-workspace/plugin-agent/dist/conversation.js +1 -0
  90. package/node_modules/@rho-workspace/plugin-agent/dist/dsh-session.d.ts +6 -0
  91. package/node_modules/@rho-workspace/plugin-agent/dist/dsh-session.js +174 -0
  92. package/node_modules/@rho-workspace/plugin-agent/dist/external-session-contract.d.ts +82 -0
  93. package/node_modules/@rho-workspace/plugin-agent/dist/external-session-contract.js +15 -0
  94. package/node_modules/@rho-workspace/plugin-agent/dist/external-session.d.ts +73 -0
  95. package/node_modules/@rho-workspace/plugin-agent/dist/external-session.js +190 -0
  96. package/node_modules/@rho-workspace/plugin-agent/dist/generic-acp.d.ts +11 -0
  97. package/node_modules/@rho-workspace/plugin-agent/dist/generic-acp.js +7 -0
  98. package/node_modules/@rho-workspace/plugin-agent/dist/index.d.ts +373 -0
  99. package/node_modules/@rho-workspace/plugin-agent/dist/index.js +1 -0
  100. package/node_modules/@rho-workspace/plugin-agent/dist/mcp.js +5 -1
  101. package/node_modules/@rho-workspace/plugin-agent/dist/operations.d.ts +33 -0
  102. package/node_modules/@rho-workspace/plugin-agent/dist/operations.js +3 -0
  103. package/node_modules/@rho-workspace/plugin-agent/dist/presentation.d.ts +14 -0
  104. package/node_modules/@rho-workspace/plugin-agent/dist/presentation.js +2 -0
  105. package/node_modules/@rho-workspace/plugin-agent/dist/ui-external-session.d.ts +15 -0
  106. package/node_modules/@rho-workspace/plugin-agent/dist/ui-external-session.js +37 -0
  107. package/node_modules/@rho-workspace/plugin-agent/package.json +5 -1
  108. package/node_modules/@rho-workspace/plugin-annotations/package.json +1 -1
  109. package/node_modules/@rho-workspace/plugin-documents/README.md +4 -0
  110. package/node_modules/@rho-workspace/plugin-documents/dist/index.d.ts +3 -0
  111. package/node_modules/@rho-workspace/plugin-documents/dist/index.js +1 -1
  112. package/node_modules/@rho-workspace/plugin-documents/package.json +1 -1
  113. package/node_modules/@rho-workspace/plugin-kernel/README.md +71 -10
  114. package/node_modules/@rho-workspace/plugin-kernel/dist/code.d.ts +2 -0
  115. package/node_modules/@rho-workspace/plugin-kernel/dist/code.js +4 -1
  116. package/node_modules/@rho-workspace/plugin-kernel/dist/contract.js +5 -0
  117. package/node_modules/@rho-workspace/plugin-kernel/dist/index.d.ts +7 -0
  118. package/node_modules/@rho-workspace/plugin-kernel/dist/index.js +55 -8
  119. package/node_modules/@rho-workspace/plugin-kernel/dist/lineage.d.ts +9 -6
  120. package/node_modules/@rho-workspace/plugin-kernel/dist/lineage.js +18 -41
  121. package/node_modules/@rho-workspace/plugin-kernel/dist/operations.js +5 -2
  122. package/node_modules/@rho-workspace/plugin-kernel/dist/script-flow.d.ts +39 -0
  123. package/node_modules/@rho-workspace/plugin-kernel/dist/script-flow.js +661 -0
  124. package/node_modules/@rho-workspace/plugin-kernel/dist/ui-base.d.ts +3 -0
  125. package/node_modules/@rho-workspace/plugin-kernel/dist/ui-base.js +10 -0
  126. package/node_modules/@rho-workspace/plugin-kernel/dist/ui-flow.d.ts +38 -4
  127. package/node_modules/@rho-workspace/plugin-kernel/dist/ui-flow.js +194 -97
  128. package/node_modules/@rho-workspace/plugin-kernel/dist/ui-notebook-work.js +1 -2
  129. package/node_modules/@rho-workspace/plugin-kernel/dist/ui-notebook.d.ts +10 -2
  130. package/node_modules/@rho-workspace/plugin-kernel/dist/ui-notebook.js +79 -18
  131. package/node_modules/@rho-workspace/plugin-kernel/dist/ui-styles.js +115 -45
  132. package/node_modules/@rho-workspace/plugin-kernel/dist/ui.d.ts +1 -1
  133. package/node_modules/@rho-workspace/plugin-kernel/dist/ui.js +1 -1
  134. package/node_modules/@rho-workspace/plugin-kernel/dist/value-graph.d.ts +63 -0
  135. package/node_modules/@rho-workspace/plugin-kernel/dist/value-graph.js +344 -0
  136. package/node_modules/@rho-workspace/plugin-kernel/package.json +1 -1
  137. package/node_modules/@rho-workspace/plugin-kernel/runners/runner.R +6 -3
  138. package/node_modules/@rho-workspace/plugin-kernel/runners/runner.py +6 -3
  139. package/node_modules/express-rate-limit/dist/index.cjs +1 -1
  140. package/node_modules/express-rate-limit/dist/index.mjs +1 -1
  141. package/node_modules/express-rate-limit/package.json +1 -1
  142. package/node_modules/ip-address/dist/ipv6.js +1 -1
  143. package/node_modules/ip-address/package.json +1 -1
  144. package/node_modules/playwright-core/LICENSE +202 -0
  145. package/node_modules/playwright-core/NOTICE +5 -0
  146. package/node_modules/playwright-core/ThirdPartyNotices.txt +13 -0
  147. package/node_modules/playwright-core/bin/install_media_pack.ps1 +5 -0
  148. package/node_modules/playwright-core/bin/install_webkit_wsl.ps1 +33 -0
  149. package/node_modules/playwright-core/bin/reinstall_chrome_beta_linux.sh +42 -0
  150. package/node_modules/playwright-core/bin/reinstall_chrome_beta_mac.sh +13 -0
  151. package/node_modules/playwright-core/bin/reinstall_chrome_beta_win.ps1 +24 -0
  152. package/node_modules/playwright-core/bin/reinstall_chrome_stable_linux.sh +42 -0
  153. package/node_modules/playwright-core/bin/reinstall_chrome_stable_mac.sh +12 -0
  154. package/node_modules/playwright-core/bin/reinstall_chrome_stable_win.ps1 +24 -0
  155. package/node_modules/playwright-core/bin/reinstall_msedge_beta_linux.sh +48 -0
  156. package/node_modules/playwright-core/bin/reinstall_msedge_beta_mac.sh +11 -0
  157. package/node_modules/playwright-core/bin/reinstall_msedge_beta_win.ps1 +23 -0
  158. package/node_modules/playwright-core/bin/reinstall_msedge_dev_linux.sh +48 -0
  159. package/node_modules/playwright-core/bin/reinstall_msedge_dev_mac.sh +11 -0
  160. package/node_modules/playwright-core/bin/reinstall_msedge_dev_win.ps1 +23 -0
  161. package/node_modules/playwright-core/bin/reinstall_msedge_stable_linux.sh +48 -0
  162. package/node_modules/playwright-core/bin/reinstall_msedge_stable_mac.sh +11 -0
  163. package/node_modules/playwright-core/bin/reinstall_msedge_stable_win.ps1 +24 -0
  164. package/node_modules/playwright-core/browsers.json +52 -0
  165. package/node_modules/playwright-core/cli.js +22 -0
  166. package/node_modules/playwright-core/index.js +17 -0
  167. package/node_modules/playwright-core/index.mjs +28 -0
  168. package/node_modules/playwright-core/lib/bootstrap.js +149 -0
  169. package/node_modules/playwright-core/lib/coreBundle.js +78041 -0
  170. package/node_modules/playwright-core/lib/entry/cliDaemon.js +5 -0
  171. package/node_modules/playwright-core/lib/entry/dashboardApp.js +3 -0
  172. package/node_modules/playwright-core/lib/entry/mcp.js +10 -0
  173. package/node_modules/playwright-core/lib/entry/oopBrowserDownload.js +3 -0
  174. package/node_modules/playwright-core/lib/package.js +50 -0
  175. package/node_modules/playwright-core/lib/server/chromium/appIcon.png +0 -0
  176. package/node_modules/playwright-core/lib/server/electron/loader.js +123 -0
  177. package/node_modules/playwright-core/lib/serverRegistry.js +1939 -0
  178. package/node_modules/playwright-core/lib/serverRegistry.js.LICENSE +65 -0
  179. package/node_modules/playwright-core/lib/tools/cli-client/channelSessions.js +141 -0
  180. package/node_modules/playwright-core/lib/tools/cli-client/cli.js +7 -0
  181. package/node_modules/playwright-core/lib/tools/cli-client/help.json +808 -0
  182. package/node_modules/playwright-core/lib/tools/cli-client/minimist.js +128 -0
  183. package/node_modules/playwright-core/lib/tools/cli-client/output.js +352 -0
  184. package/node_modules/playwright-core/lib/tools/cli-client/program.js +422 -0
  185. package/node_modules/playwright-core/lib/tools/cli-client/registry.js +180 -0
  186. package/node_modules/playwright-core/lib/tools/cli-client/session.js +261 -0
  187. package/node_modules/playwright-core/lib/tools/dashboard/appIcon.png +0 -0
  188. package/node_modules/playwright-core/lib/tools/utils/extension.js +112 -0
  189. package/node_modules/playwright-core/lib/tools/utils/socketConnection.js +108 -0
  190. package/node_modules/playwright-core/lib/utilsBundle.js +86078 -0
  191. package/node_modules/playwright-core/lib/utilsBundle.js.LICENSE +1890 -0
  192. package/node_modules/playwright-core/lib/vite/dashboard/assets/codeMirrorModule--QdMvsKi.css +1 -0
  193. package/node_modules/playwright-core/lib/vite/dashboard/assets/codeMirrorModule-CQ8RZGBm.js +32 -0
  194. package/node_modules/playwright-core/lib/vite/dashboard/assets/codicon-DCmgc-ay.ttf +0 -0
  195. package/node_modules/playwright-core/lib/vite/dashboard/assets/firefox-1bWoP6pv.svg +1 -0
  196. package/node_modules/playwright-core/lib/vite/dashboard/assets/firefox-beta-k3eOH_eK.svg +1 -0
  197. package/node_modules/playwright-core/lib/vite/dashboard/assets/firefox-nightly-Cp5nfeDT.svg +1 -0
  198. package/node_modules/playwright-core/lib/vite/dashboard/assets/index-AwgwcYie.css +1 -0
  199. package/node_modules/playwright-core/lib/vite/dashboard/assets/index-hRvO4yU2.js +12 -0
  200. package/node_modules/playwright-core/lib/vite/dashboard/assets/safari-na3_-uQk.svg +1 -0
  201. package/node_modules/playwright-core/lib/vite/dashboard/index.html +29 -0
  202. package/node_modules/playwright-core/lib/vite/dashboard/playwright-logo.svg +24 -0
  203. package/node_modules/playwright-core/lib/vite/htmlReport/index.html +16 -0
  204. package/node_modules/playwright-core/lib/vite/htmlReport/report.css +2 -0
  205. package/node_modules/playwright-core/lib/vite/htmlReport/report.js +32 -0
  206. package/node_modules/playwright-core/lib/vite/recorder/assets/codeMirrorModule--QdMvsKi.css +1 -0
  207. package/node_modules/playwright-core/lib/vite/recorder/assets/codeMirrorModule-DK72OMRi.js +32 -0
  208. package/node_modules/playwright-core/lib/vite/recorder/assets/codicon-DCmgc-ay.ttf +0 -0
  209. package/node_modules/playwright-core/lib/vite/recorder/assets/index-BZpYJZ-P.css +1 -0
  210. package/node_modules/playwright-core/lib/vite/recorder/assets/index-Cn0mmDuv.js +129 -0
  211. package/node_modules/playwright-core/lib/vite/recorder/index.html +29 -0
  212. package/node_modules/playwright-core/lib/vite/recorder/playwright-logo.svg +9 -0
  213. package/node_modules/playwright-core/lib/vite/traceViewer/assets/codeMirrorModule-BEB2e8M3.js +32 -0
  214. package/node_modules/playwright-core/lib/vite/traceViewer/assets/defaultSettingsView-D-g2vrvf.js +184 -0
  215. package/node_modules/playwright-core/lib/vite/traceViewer/assets/urlMatch-L3liM589.js +1 -0
  216. package/node_modules/playwright-core/lib/vite/traceViewer/assets/xtermModule-B794rD2Z.js +7 -0
  217. package/node_modules/playwright-core/lib/vite/traceViewer/codeMirrorModule.-QdMvsKi.css +1 -0
  218. package/node_modules/playwright-core/lib/vite/traceViewer/codicon.DCmgc-ay.ttf +0 -0
  219. package/node_modules/playwright-core/lib/vite/traceViewer/defaultSettingsView.C8BeHuxd.css +1 -0
  220. package/node_modules/playwright-core/lib/vite/traceViewer/index.B_TqY17P.css +1 -0
  221. package/node_modules/playwright-core/lib/vite/traceViewer/index.html +44 -0
  222. package/node_modules/playwright-core/lib/vite/traceViewer/index.oNry3Hjv.js +1 -0
  223. package/node_modules/playwright-core/lib/vite/traceViewer/manifest.webmanifest +16 -0
  224. package/node_modules/playwright-core/lib/vite/traceViewer/playwright-logo.svg +9 -0
  225. package/node_modules/playwright-core/lib/vite/traceViewer/snapshot.B_Jk1wbt.js +1 -0
  226. package/node_modules/playwright-core/lib/vite/traceViewer/snapshot.html +10 -0
  227. package/node_modules/playwright-core/lib/vite/traceViewer/sw.bundle.js +4 -0
  228. package/node_modules/playwright-core/lib/vite/traceViewer/uiMode.CYwC_gH1.js +5 -0
  229. package/node_modules/playwright-core/lib/vite/traceViewer/uiMode.CyMfwkXJ.css +1 -0
  230. package/node_modules/playwright-core/lib/vite/traceViewer/uiMode.html +18 -0
  231. package/node_modules/playwright-core/lib/vite/traceViewer/xtermModule.kHJ-D0s7.css +1 -0
  232. package/node_modules/playwright-core/lib/webp_codec.LICENSE +173 -0
  233. package/node_modules/playwright-core/lib/webp_codec.wasm +0 -0
  234. package/node_modules/playwright-core/lib/xdg-open +1267 -0
  235. package/node_modules/playwright-core/package.json +34 -0
  236. package/package.json +13 -7
  237. package/protocol/index.json +75 -21
  238. package/protocol/operations/agent.sessions.list.json +100 -0
  239. package/protocol/operations/agent.sessions.read.json +266 -0
  240. package/protocol/operations/conversation.settings.check.json +147 -4
  241. package/protocol/operations/conversation.settings.read.json +145 -3
  242. package/protocol/operations/conversation.settings.update.json +166 -4
  243. package/protocol/operations/conversation.start.json +2 -1
  244. package/protocol/operations/extension.call.json +132 -0
  245. package/protocol/operations/extension.content.json +78 -0
  246. package/protocol/operations/extension.describe.json +195 -0
  247. package/protocol/operations/extension.install.json +198 -0
  248. package/protocol/operations/extension.list.json +123 -0
  249. package/protocol/operations/extension.manage.json +55 -0
  250. package/protocol/operations/extension.read.json +112 -0
  251. package/protocol/operations/kernel.interrupt.json +20 -0
  252. package/protocol/operations/kernel.read.json +30 -0
  253. package/protocol/operations/kernel.run.json +36 -1
  254. package/protocol/operations/kernel.stop.json +10 -0
  255. package/protocol/operations/project.work.read.json +3 -2
  256. package/protocol/operations/session.grant.json +9 -0
  257. package/scripts/browser-checks.mjs +53 -0
  258. package/scripts/screen-check.mjs +193 -0
  259. package/scripts/third-party-acceptance.mjs +77 -0
  260. package/vendor/composition.json +111 -111
  261. package/vendor/rho-workspace-plugin-agent-0.4.29.tgz +0 -0
  262. package/vendor/rho-workspace-plugin-annotations-0.5.2.tgz +0 -0
  263. package/vendor/rho-workspace-plugin-documents-0.4.11.tgz +0 -0
  264. package/vendor/rho-workspace-plugin-kernel-0.5.5.tgz +0 -0
  265. package/web/theme.css +17 -2
  266. package/dist/web/assets/choices-B-y2OYvE.js +0 -1
  267. package/dist/web/assets/dist-CBM2oq6g.js +0 -1
  268. package/dist/web/assets/dist-CH56yNDn.js +0 -3
  269. package/dist/web/assets/explore-in-muWXOGOY.js +0 -1
  270. package/dist/web/assets/graph-CK-df5lh.js +0 -2
  271. package/dist/web/assets/index-DBd77u4a.css +0 -1
  272. package/dist/web/assets/overview-D1Ev2OC_.js +0 -6
  273. package/dist/web/assets/preview-HbmQKUGY.js +0 -1
  274. package/dist/web/assets/workspace-d5Hw_ClZ.js +0 -5
  275. package/vendor/rho-workspace-plugin-agent-0.4.27.tgz +0 -0
  276. package/vendor/rho-workspace-plugin-documents-0.4.10.tgz +0 -0
  277. package/vendor/rho-workspace-plugin-kernel-0.5.2.tgz +0 -0
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{t}from"./react-Dss-ouuy.js";import{c as n}from"./home-CCbP6kS-.js";var r=e(t(),1),i=new Map(Object.entries({data:`csv.tsv.tab.xlsx.xls.json.parquet.feather.arrow.rds.rda.rdata.h5.h5ad.hdf5.loom.mtx.sav.dta.sas7bdat.fasta.fa.fastq.fq.bam.sam.vcf.bed.gtf.gff.gff3.nwk.tre.newick`.split(`.`),code:`r.rmd.qmd.py.ipynb.sh.bash.zsh.jl.sql.js.mjs.ts.stan.smk.nf.wdl.cpp.c.h.rs.go.java.pl.awk.sas.do.m`.split(`.`),figures:[`png`,`jpg`,`jpeg`,`svg`,`pdf`,`gif`,`tif`,`tiff`,`webp`,`eps`],notes:[`md`,`markdown`,`txt`,`rst`,`org`,`tex`,`bib`,`docx`,`html`]}).flatMap(([e,t])=>t.map(t=>[t,e]))),a=new Set([`results`,`result`,`output`,`outputs`,`out`,`figures`,`figs`,`plots`,`reports`]);function o(e){let t=e.split(`/`),n=t.at(-1).toLowerCase().split(`.`);n.length>2&&[`gz`,`bz2`,`xz`,`zst`].includes(n.at(-1))&&n.pop();let r=n.length>1?i.get(n.at(-1))??null:null;return r===`data`&&t.slice(0,-1).some(e=>a.has(e.toLowerCase()))?`results`:r}var s=e=>/\.(csv|png|jpe?g|svg)$/i.test(e),c=new Set([`node_modules`,`renv`,`packrat`,`__pycache__`,`venv`,`.venv`,`site-library`,`.ipynb_checkpoints`,`.Rproj.user`,`.snakemake`,`.nextflow`]),l={maxFolders:48,maxDepth:5,maxFiles:4e3};async function u(e,t,n){let r=[],i=[{path:``,depth:0}],a=0,s=!1;for(;i.length;){if(n.aborted)throw new DOMException(`aborted`,`AbortError`);if(a>=l.maxFolders){s=!0;break}let u=i.shift();a++;let d=await e.call(`project.entries`,{projectId:t,...u.path?{path:u.path}:{}},n);d.truncated&&(s=!0);for(let e of d.entries)if(!e.hidden){if(e.kind===`folder`){if(c.has(e.name))continue;if(u.depth+1>l.maxDepth){s=!0;continue}i.push({path:e.path,depth:u.depth+1})}else{if(r.length>=l.maxFiles){s=!0;break}r.push({...e,category:o(e.path)})}}}return{files:r,truncated:s}}function d(e,t,n){let[i,a]=(0,r.useState)({files:[],truncated:!1,reading:!1,problem:``,readAt:0}),[o,s]=(0,r.useState)(0),c=(0,r.useRef)(0),l=(0,r.useRef)(void 0),[d,f]=(0,r.useState)(0);return(0,r.useEffect)(()=>{a({files:[],truncated:!1,reading:!1,problem:``,readAt:0}),c.current=0},[t]),(0,r.useEffect)(()=>{if(!t)return;let e=Math.max(0,c.current+5e3-Date.now());return clearTimeout(l.current),l.current=setTimeout(()=>f(e=>e+1),e),()=>clearTimeout(l.current)},[t,n,o]),(0,r.useEffect)(()=>{if(!t||!d)return;let n=new AbortController;return c.current=Date.now(),a(e=>({...e,reading:!0})),u(e,t,n.signal).then(e=>a({...e,reading:!1,problem:``,readAt:Date.now()}),e=>{n.signal.aborted||a(t=>({...t,reading:!1,problem:e instanceof Error?e.message:`The project folder could not be read.`}))}),()=>n.abort()},[e,t,d]),{...i,refresh:()=>{c.current=0,s(e=>e+1)}}}var f=[`data`,`code`,`results`,`notes`],p=[`data`,`code`,`workflows`,`results`,`reports`,`notes`,`references`,`environment`],ee=new Set([`renv.lock`,`description`,`environment.yml`,`environment.yaml`,`pyproject.toml`,`setup.py`,`setup.cfg`,`pipfile`,`pipfile.lock`,`poetry.lock`,`uv.lock`,`conda-lock.yml`,`dockerfile`,`containerfile`,`apptainer.def`,`singularity.def`,`install.r`,`project.toml`,`manifest.toml`]),te=new Set([`snakefile`,`makefile`,`gnumakefile`,`justfile`,`_targets.r`,`nextflow.config`,`dvc.yaml`]),ne=new Set([`refs`,`references`,`literature`,`papers`,`reading`,`bibliography`]),m=e=>e.toLowerCase().replace(/\.[^./]+$/,``),re=e=>new Set(e.filter(e=>/\.(rmd|qmd|rnw)$/i.test(e.path)).map(e=>m(e.path))),ie=e=>new Set(e.filter(e=>/\.html?$/i.test(e.path)).map(e=>e.path.toLowerCase().split(`/`).slice(0,-1).join(`/`))),ae=/^[a-z][\w.]*(-[a-z][\w.]*)*-\d+(\.\d+)+$/,oe=/^(lib|libs|site_libs|.+_files)$/;function se(e,t,n=new Set){let r=e.path.toLowerCase().split(`/`),i=r.at(-1),a=i.includes(`.`)?i.split(`.`).at(-1):``;return r.slice(0,-1).some((e,n)=>e.endsWith(`_files`)&&t.has([...r.slice(0,n),e.slice(0,-6)].join(`/`)))||r.slice(0,-1).some((e,t)=>t>0&&ae.test(e)&&oe.test(r[t-1])&&n.has(r.slice(0,t-1).join(`/`)))?null:ee.has(i)||/^requirements([-_.][^/]*)?\.txt$/.test(i)||a===`rproj`?`environment`:te.has(i)||[`smk`,`nf`,`wdl`,`cwl`].includes(a)?`workflows`:[`rmd`,`qmd`,`rnw`].includes(a)||[`html`,`pdf`,`docx`].includes(a)&&t.has(m(e.path))?`reports`:[`bib`,`ris`,`nbib`,`enw`].includes(a)||a===`pdf`&&r.slice(0,-1).some(e=>ne.has(e))?`references`:e.category===`figures`||e.category===`results`?`results`:e.category}var h=e=>e.split(`/`).filter(Boolean).at(-1)??e;function g(e,t){let n=e.split(`/`);if(n.pop(),!n.length)return t.name??h(t.root);let r=n[0].startsWith(`@`)?t.sources?.find(e=>`@`+e.id===n[0]):void 0;return[r?r.name:n[0],...n.slice(1)].join(`/`)}var _=e=>![`current-filesystem-observation`,`captured-observation`].includes(e.provenance?.source??``),v=new Intl.Collator(void 0,{numeric:!0,sensitivity:`base`});function y(e,t,n,r,i=[]){let a=new Map,o=new Map(i.map(e=>[e.operationId,e.acceptedAt])),s=e=>o.get(String(e.provenance?.operationId??``))??``,c=new Map;if(e===`results`)for(let e of n){let t=c.get(e.path);_(e)&&(!t||s(e).localeCompare(s(t))>0||s(e)===s(t)&&e.version.localeCompare(t.version)>0)&&c.set(e.path,e)}for(let e of c.values())a.set(e.path,{key:`result:`+e.path,path:e.path,name:h(e.path),folder:g(e.path,r),bytes:e.bytes??null,category:e.kind===`media`?`figures`:`results`,resource:{id:e.id,version:e.version,kind:e.kind,path:e.path}});let l=re(t),u=ie(t);for(let n of t)se(n,l,u)===e&&!a.has(n.path)&&a.set(n.path,{key:`file:`+n.path,path:n.path,name:n.name,folder:g(n.path,r),bytes:n.bytes,category:n.category});let d=e=>Number(e.path.includes(`/`));return[...a.values()].sort((e,t)=>d(e)-d(t)||v.compare(e.folder,t.folder)||v.compare(e.name,t.name))}function ce(e){let t=new Set(e.views.map(e=>e.id)),n=new Set,r=new Map((e.nodes??[]).map(e=>[e.id,e])),i=e=>{let n=r.get(e);return n?n.kind===`view`?t.has(n.id)?[n.id]:[]:n.children.flatMap(i):[]},a=e=>{let o=r.get(e);if(!o)return null;if(o.kind===`view`)return t.has(o.id)?(n.add(o.id),{kind:`tabs`,id:`tabs:`+o.id,views:[o.id]}):null;let s=o.presentation?.mode===`split`?o.presentation:null;if(s){let e=o.children.map((e,t)=>({region:a(e),weight:s.weights[t]??1})).filter(e=>e.region);return e.length?e.length===1?e[0].region:{kind:`split`,id:o.id,axis:s.axis,weights:e.map(e=>e.weight),children:e.map(e=>e.region)}:null}let c=i(o.id);return c.forEach(e=>n.add(e)),c.length?{kind:`tabs`,id:o.id,views:c}:null},o=e.rootId&&r.size?a(e.rootId):null,s=e.views.map(e=>e.id).filter(e=>!n.has(e));if(!s.length)return o;if(!o)return{kind:`tabs`,id:`tabs:root`,views:s};let c=b(o),l=c[c.length-1];return o=x(o,l.id,{...l,views:[...l.views,...s]}),o}function b(e){return e.kind===`tabs`?[e]:e.children.flatMap(b)}function le(e){return e?b(e).flatMap(e=>e.views):[]}function ue(e,t){return e?b(e).find(e=>e.views.includes(t))??null:null}function x(e,t,n){return e.id===t?n:e.kind===`split`?{...e,children:e.children.map(e=>x(e,t,n))}:e}function S(e,t,n,r=.12){let i=e.reduce((e,t)=>e+t,0),a=[...e],o=i*r,s=a[t]+a[t+1],c=Math.min(s-o,Math.max(o,a[t]+n*i));return a[t]=c,a[t+1]=s-c,a}function de(e){let t=e.bindings?.data,n=e=>e.replace(/[^A-Za-z0-9._-]/g,`_`).slice(0,40);return typeof t?.id==`string`&&typeof t.version==`string`?{kind:`shared`,id:`linked:${n(t.id)}@${n(t.version)}`}:{kind:`shared`,id:e.id}}var C=e=>e?.presentation?.mode===`split`,w=(e,t)=>e.find(e=>e.kind===`group`&&e.children?.includes(t));function T(e,t){let n=t;for(;;){let t=w(e,n);if(!t||C(t))return n;n=t.id}}function E(e,t){let n=e.find(e=>e.id===t);return n?n.kind===`view`?[t]:(n.children??[]).flatMap(t=>E(e,t)):[]}function D(e){let t=e.nodes,n=e.rootId;for(let e=!0;e;){e=!1;for(let r of t){if(r.kind!==`group`||r.id===n)continue;let i=w(t,r.id);if(!r.children?.length){let n=i.children.indexOf(r.id);i.children=i.children.filter(e=>e!==r.id),C(i)&&(i.presentation={...i.presentation,weights:(i.presentation.weights??[]).filter((e,t)=>t!==n)}),t=t.filter(e=>e.id!==r.id),e=!0;break}if(C(r)&&r.children.length===1){let n=r.children[0];i.children=i.children.map(e=>e===r.id?n:e),t=t.filter(e=>e.id!==r.id),e=!0;break}}let r=t.find(e=>e.id===n);if(r&&C(r)&&r.children?.length===1){let i=r.children[0];t.find(e=>e.id===i).kind===`group`&&(t=t.filter(e=>e.id!==n),n=i,e=!0)}}return{rootId:n,nodes:t}}var O=e=>({rootId:e.rootId,nodes:structuredClone(e.nodes)});function k(e,t){let n=w(e.nodes,t),r=n.children.indexOf(t);n.children=n.children.filter(e=>e!==t),C(n)&&(n.presentation={...n.presentation,weights:(n.presentation.weights??[]).filter((e,t)=>t!==r)})}function fe(e,t,n,r){if(!e.nodes.some(e=>e.id===t&&e.kind===`view`)||!w(e.nodes,t))return null;let i=T(e.nodes,t);if(i===t||E(e.nodes,i).length<2)return null;let a=O(e);k(a,t);let o={id:r(`group`),kind:`group`,children:[t]};a.nodes.push(o);let s=w(a.nodes,i);if(s&&C(s)&&s.presentation.axis===n){let e=s.children.indexOf(i),t=[...s.presentation.weights??s.children.map(()=>1)],n=(t[e]??1)/2;s.children.splice(e+1,0,o.id),t.splice(e,1,n,n),s.presentation={...s.presentation,weights:t}}else{let e={id:r(`split`),kind:`group`,children:[i,o.id],presentation:{mode:`split`,axis:n,weights:[1,1]}};a.nodes.push(e),s?s.children=s.children.map(t=>t===i?e.id:t):a.rootId=e.id}return D(a)}function A(e){let t=[],n=(r,i)=>{let a=e.nodes.find(e=>e.id===r);if(a){if(C(a))for(let e of a.children??[])n(e,!0);else(i||r===e.rootId)&&t.push(r)}};return n(e.rootId,!1),t}function j(e,t,n){let r=e.nodes.find(e=>e.id===t.id);if(r)return r.kind===`view`&&r.component===t.component&&r.version===t.version&&JSON.stringify(r.bindings)===JSON.stringify(t.bindings)?e:null;let i=O(e),a=A(i).at(-1),o=i.nodes.find(e=>e.id===a);if(!o)return null;if(i.nodes.push({id:t.id,kind:`view`,component:t.component,version:t.version,props:structuredClone(t.props),bindings:structuredClone(t.bindings)}),o.kind===`group`)o.children=[...o.children??[],t.id];else{let e={id:n(`group`),kind:`group`,children:[o.id,t.id]};i.nodes.push(e);let r=w(i.nodes,o.id);r?r.children=r.children.map(t=>t===o.id?e.id:t):i.rootId=e.id}return i}function pe(e,t,n,r){if(!w(e.nodes,t))return null;let i=A(e),a=T(e.nodes,t),o=i[i.indexOf(a)+n];if(!o||o===a)return null;let s=O(e);k(s,t);let c=s.nodes.find(e=>e.id===o);if(c.kind===`group`)c.children=[...c.children??[],t];else{let e={id:r(`group`),kind:`group`,children:[o,t]};s.nodes.push(e);let n=w(s.nodes,o);n.children=n.children.map(t=>t===o?e.id:t)}return D(s)}function me(e,t,n){if(!e.nodes.find(e=>e.id===t&&e.kind===`view`))return null;let r=O(e),i=r.nodes.find(e=>e.id===t);return i.props={...i.props,...n},r}function he(e,t){if(!w(e.nodes,t))return null;let n=O(e);return k(n,t),n.nodes=n.nodes.filter(e=>e.id!==t),D(n)}function M(e,t,n){let r=e.nodes.find(e=>e.id===t);if(!C(r)||r.children.length!==n.length)return null;let i=O(e),a=i.nodes.find(e=>e.id===t);return a.presentation={...a.presentation,weights:n.map(e=>Math.round(e*1e3)/1e3)},i}var N=e=>e.startsWith(`tabs:`)?e.slice(5):e;function P(e,t,n,r,i){let a=e.nodes.find(e=>e.id===n);if(!a||C(a)||n===t||!w(e.nodes,t))return null;if(T(e.nodes,t)===n){let i=E(e.nodes,n),a=i.filter(e=>e!==t),o=r&&a.includes(r)?a.indexOf(r):a.length;if(i.indexOf(t)===o)return null}let o=O(e);k(o,t);let s=o.nodes.find(e=>e.id===n);if(s.kind===`group`){let e=s.children??[],n=r?e.find(e=>e===r||E(o.nodes,e).includes(r)):void 0;e.splice(n?e.indexOf(n):e.length,0,t),s.children=e}else{let e={id:i(`group`),kind:`group`,children:r===n?[t,n]:[n,t]};o.nodes.push(e);let a=w(o.nodes,n);a?a.children=a.children.map(t=>t===n?e.id:t):o.rootId=e.id}return D(o)}function F(e,t,n,r,i){if(e.nodes.some(e=>e.id===t.id))return null;let a=n&&w(e.nodes,n)?n:E(e.nodes,A(e).at(-1)??e.rootId)[0]??null,o=j(e,t,i);return!o||!a?o:z(o,t.id,T(o.nodes,a),r,i)??o}function I(e,t,n,r,i=.4){if(e.nodes.some(e=>e.id===t.id))return null;let a=j(e,t,r);if(!a||E(a.nodes,a.rootId).length<2)return a;let o=O(a);k(o,t.id);let s={id:r(`group`),kind:`group`,children:[t.id]};return o.nodes.push(s),L(o,s.id,n,i,r),D(o)}function L(e,t,n,r,i){let a=n===`left`||n===`right`?`horizontal`:`vertical`,o=n===`right`||n===`bottom`,s=e.nodes.find(t=>t.id===e.rootId);if(C(s)&&s.presentation.axis===a){let e=[...s.presentation.weights??s.children.map(()=>1)],n=e.reduce((e,t)=>e+t,0)*r/(1-r);o?(s.children.push(t),e.push(n)):(s.children.unshift(t),e.unshift(n)),s.presentation={...s.presentation,weights:e}}else{let n={id:i(`split`),kind:`group`,children:o?[e.rootId,t]:[t,e.rootId],presentation:{mode:`split`,axis:a,weights:o?[1-r,r]:[r,1-r]}};e.nodes.push(n),e.rootId=n.id}}function R(e,t){let n=1;for(let r=T(e.nodes,t),i=w(e.nodes,r);i;r=i.id,i=w(e.nodes,r)){if(!C(i)||i.presentation.axis!==`horizontal`)continue;let e=i.presentation.weights??i.children.map(()=>1),t=e.reduce((e,t)=>e+t,0);n*=(e[i.children.indexOf(r)]??1)/(t||1)}return n}function ge(e,t,n,r,i,a){let o=T(e.nodes,n),s=w(e.nodes,o);if(r&&s&&R(e,n)*r<2*i){let n=s.children.indexOf(o),r=s.children[n+1]??s.children[n-1];for(let t=e.nodes.find(e=>e.id===r);t&&C(t);t=e.nodes.find(e=>e.id===r))r=t.children?.[0];let i=r?j(e,t,a):null;if(i)return P(i,t.id,r,null,a)??i}return F(e,t,n,`right`,a)}function z(e,t,n,r,i){let a=e.nodes.find(e=>e.id===n);if(!a||C(a)||n===t||!w(e.nodes,t)||T(e.nodes,t)===n&&E(e.nodes,n).length<2)return null;let o=O(e);k(o,t);let s={id:i(`group`),kind:`group`,children:[t]};return o.nodes.push(s),B(o,s.id,n,r,i),D(o)}function B(e,t,n,r,i){let a=r===`left`||r===`right`?`horizontal`:`vertical`,o=r===`right`||r===`bottom`,s=w(e.nodes,n);if(s&&C(s)&&s.presentation.axis===a){let e=s.children.indexOf(n),r=[...s.presentation.weights??s.children.map(()=>1)],i=(r[e]??1)/2;s.children.splice(o?e+1:e,0,t),r.splice(e,1,i,i),s.presentation={...s.presentation,weights:r}}else{let r={id:i(`split`),kind:`group`,children:o?[n,t]:[t,n],presentation:{mode:`split`,axis:a,weights:[1,1]}};e.nodes.push(r),s?s.children=s.children.map(e=>e===n?r.id:e):e.rootId=r.id}}function V(e,t){let n=(e,t)=>{let r=e.nodes.find(e=>e.id===t);return!r||r.kind===`view`?t:[t,r.presentation?.mode===`split`?r.presentation.axis:`tabs`,(r.children??[]).map(t=>n(e,t))]};return JSON.stringify(n(e,e.rootId))===JSON.stringify(n(t,t.rootId))}function _e(e,t,n,r,i,a){let o=A(e),s=e.nodes.find(e=>e.id===t);if(!s||t===n||t===e.rootId||!o.includes(t)||!o.includes(n))return null;if(s.kind===`view`)return r===`center`?P(e,t,n,i,a):z(e,t,n,r,a);let c=O(e);if(k(c,t),r!==`center`){B(c,t,n,r,a);let i=D(c);return V(e,i)?null:i}let l=E(c.nodes,t),u=new Set,d=e=>{let t=c.nodes.find(t=>t.id===e);t?.kind===`group`&&(u.add(e),t.children?.forEach(d))};d(t),c.nodes=c.nodes.filter(e=>!u.has(e.id));let f=c.nodes.find(e=>e.id===n);if(f.kind===`group`){let e=f.children??[],t=i?e.find(e=>e===i||E(c.nodes,e).includes(i)):void 0;e.splice(t?e.indexOf(t):e.length,0,...l),f.children=e}else{let e={id:a(`group`),kind:`group`,children:i===n?[...l,n]:[n,...l]};c.nodes.push(e);let t=w(c.nodes,n);t?t.children=t.children.map(t=>t===n?e.id:t):c.rootId=e.id}return D(c)}function H(e,t,n,r,i=1/3){let a=e.nodes.find(e=>e.id===t);if(!a||!w(e.nodes,t)||a.kind!==`view`&&!A(e).includes(t))return null;let o=T(e.nodes,t);if(o!==t&&E(e.nodes,o).length===1)return H(e,o,n,r,i);let s=O(e);k(s,t);let c=t;if(!A(e).includes(t)){let e={id:r(`group`),kind:`group`,children:[t]};s.nodes.push(e),c=e.id}L(s,c,n,i,r);let l=D(s);return V(e,l)?null:l}function U(e,t,n,r){if(e.nodes.some(e=>e.id===t.id))return null;let i=j(e,t,r);return i&&(P(i,t.id,n,null,r)??i)}var W=`workspace`,ve={workspace:`Workspace`,"agent-canvas":`Agent canvas`,"observed-outputs":`Observed outputs`};function ye(e){return ve[e]??(/^workspace-(\d+)$/.exec(e)?`Workspace `+e.slice(10):e)}var be=e=>`conversation-`+e,xe=e=>e.startsWith(`conversation-`)?e.slice(13):null;function G(e){let t=2166136261,n=16777619;for(let r of e){let e=r.codePointAt(0);t=Math.imul(t^e,16777619)>>>0,n=Math.imul(n^e,2166136261)>>>0}return`file-`+(t.toString(16).padStart(8,`0`)+n.toString(16).padStart(8,`0`)).slice(0,12)+`-`}var Se={maxViewsPerSide:6},K=`canvas-`,q=`markdown.reader`,J=`html.reader`,Ce=e=>e.kind===`view`?e.component===`rho.editor`||e.component===q||e.component===J?`code`:e.component===`rho.table`||e.component===`rho.media`?`data`:null:null,Y=/\.(png|jpe?g|svg|gif|pdf|tiff?|webp|xlsx?|rds|rda|rdata|parquet|feather|h5|h5ad|bam|zip|gz)$/i,we=e=>s(e)||!Y.test(e),Te=(e,t)=>e.catalog.operations.some(e=>e.method===t&&e.authorized&&e.state===`available`),X=(e,t)=>e.catalog.components.find(e=>e.id===t),Z=e=>Te(e,`agent.activity.capture`)&&!!X(e,`rho.table`)&&!!X(e,`rho.media`);async function Q(e,t,n){if(typeof n!=`string`){let e=X(t,n.kind===`table`?`rho.table`:`rho.media`);if(!e||![`table`,`media`].includes(n.kind))return null;let r=Object.keys(e.bindings)[0]??`data`;return{side:`data`,node:{id:`result-`+n.id.slice(0,12)+`-`+n.version.slice(0,12),kind:`view`,component:e.id,version:e.version,props:{title:n.path.split(`/`).at(-1)??n.path},bindings:{[r]:{id:n.id,version:n.version}}}}}let r=n,i=t.project.id,a=r.split(`/`).at(-1)??r;if(s(r)&&Z(t)){let n=await e.call(`agent.activity.capture`,{projectId:i,path:r}),o=X(t,n.kind===`table`?`rho.table`:`rho.media`),s=Object.keys(o.bindings)[0]??`data`;return{side:`data`,node:{id:G(r)+n.version.slice(0,12),kind:`view`,component:o.id,version:o.version,props:{title:a},bindings:{[s]:{id:n.id,version:n.version}}}}}if(Y.test(r))return null;let o=(/\.(md|markdown)$/i.test(r)?X(t,q):/\.html?$/i.test(r)?X(t,J):void 0)??X(t,`rho.editor`);if(!o)return null;let c=await e.call(`document.open`,{projectId:i,path:r});return{side:`code`,node:{id:`doc-`+c.id.slice(0,12),kind:`view`,component:o.id,version:o.version,props:{title:a},bindings:{document:{kind:`live-document`,documentId:c.id}}}}}function Ee(e,t,n,r){let i=structuredClone(e?.nodes??[]),a=e?.rootId??`root`;if(i.some(e=>e.id===t.id))return null;let o=e=>i.find(t=>t.id===e),s=e=>i.find(t=>t.kind===`group`&&t.children?.includes(e)),c=e=>!!e&&e.kind===`group`&&e.presentation?.mode!==`split`,l=t.id.startsWith(`file-`)?t.id.slice(0,18):``,u=l?i.find(e=>e.kind===`view`&&e.id.startsWith(l)):void 0;if(u){let e=s(u.id);if(e)return e.children=e.children.map(e=>e===u.id?t.id:e),{rootId:a,nodes:[...i.filter(e=>e.id!==u.id),t]}}if(r&&e?.rootId&&i.length)return U({rootId:a,nodes:i},t,r,e=>`${e}-${crypto.randomUUID().slice(0,8)}`);let d=o(a);d||(d={id:a,kind:`group`,children:[]},i.push(d));let f=new Map;for(let e of i)if(Ce(e)===n){let t=s(e.id);c(t)&&f.set(t,(f.get(t)??0)+1)}let p=i.find(e=>e.id===K+n&&e.kind===`group`)??[...f].sort((e,t)=>t[1]-e[1])[0]?.[0]??(d.children?.length?void 0:d);if(!p){p={id:K+n,kind:`group`,children:[]},i.push(p);let e=e=>n===`code`?0:e;if(d.presentation?.mode===`split`&&d.presentation.axis===`horizontal`){let t=d.presentation.weights?.length===d.children.length?[...d.presentation.weights]:d.children.map(()=>1),n=e(d.children.length);d.children.splice(n,0,p.id),t.splice(n,0,t.reduce((e,t)=>e+t,0)/t.length),d.presentation={...d.presentation,weights:t}}else{let t=`split`,n=1;for(;o(t);)t=`split-`+ ++n;let r=[a];r.splice(e(1),0,p.id),i.push({id:t,kind:`group`,children:r,presentation:{mode:`split`,axis:`horizontal`,weights:[1,1]}}),a=t}}if(p.children=[...p.children??[],t.id],i.push(t),p.id.startsWith(K))for(;p.children.length>Se.maxViewsPerSide;){let e=p.children.shift(),t=i.findIndex(t=>t.id===e);t>=0&&i.splice(t,1)}return{rootId:a,nodes:i}}var $=new Map;function De(e,t,r,i,a){let o=t.project.id+`/`+r,s=($.get(o)??Promise.resolve()).catch(()=>void 0).then(async()=>{let o=await Q(e,t,i);if(!o)return null;let s=t.project.id;for(let t=0;;t++){let i=await e.call(`composition.read`,{projectId:s,compositionId:r}).catch(e=>{if(e instanceof n&&e.error.kind===`not_found`)return null;throw e}),c=(i?.nodes)?.find(e=>e.id===o.node.id);if(c)return{compositionId:r,viewId:c.id};let l=Ee(i,o.node,o.side,a);if(!l)return{compositionId:r,viewId:o.node.id};try{return await e.call(`composition.apply`,{projectId:s,compositionId:r,expectedVersion:i?.version??0,changeId:`open-`+crypto.randomUUID(),operations:[{op:`replace`,rootId:l.rootId,nodes:l.nodes}]}),{compositionId:r,viewId:o.node.id}}catch(e){if(t===0&&e instanceof n&&e.error.kind===`stale`)continue;throw e}}});return $.set(o,s),s}export{le as A,ce as C,me as D,de as E,p as F,d as I,l as L,s as M,o as N,fe as O,y as P,j as S,M as T,ue as _,De as a,H as b,we as c,F as d,U as f,N as g,z as h,G as i,f as j,b as k,Q as l,he as m,ye as n,be as o,ge as p,W as r,xe as s,Z as t,I as u,_e as v,S as w,pe as x,P as y};
1
+ import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{t}from"./react-Dss-ouuy.js";import{c as n}from"./home-CCbP6kS-.js";var r=e(t(),1),i=new Map(Object.entries({data:`csv.tsv.tab.xlsx.xls.json.parquet.feather.arrow.rds.rda.rdata.h5.h5ad.hdf5.loom.mtx.sav.dta.sas7bdat.fasta.fa.fastq.fq.bam.sam.vcf.bed.gtf.gff.gff3.nwk.tre.newick`.split(`.`),code:`r.rmd.qmd.py.ipynb.sh.bash.zsh.jl.sql.js.mjs.ts.stan.smk.nf.wdl.cpp.c.h.rs.go.java.pl.awk.sas.do.m`.split(`.`),figures:[`png`,`jpg`,`jpeg`,`svg`,`pdf`,`gif`,`tif`,`tiff`,`webp`,`eps`],notes:[`md`,`markdown`,`txt`,`rst`,`org`,`tex`,`bib`,`docx`,`html`]}).flatMap(([e,t])=>t.map(t=>[t,e]))),a=new Set([`results`,`result`,`output`,`outputs`,`out`,`figures`,`figs`,`plots`,`reports`]);function o(e){let t=e.split(`/`),n=t.at(-1).toLowerCase().split(`.`);n.length>2&&[`gz`,`bz2`,`xz`,`zst`].includes(n.at(-1))&&n.pop();let r=n.length>1?i.get(n.at(-1))??null:null;return r===`data`&&t.slice(0,-1).some(e=>a.has(e.toLowerCase()))?`results`:r}var s=e=>/\.(csv|png|jpe?g|svg)$/i.test(e),c=new Set([`node_modules`,`renv`,`packrat`,`__pycache__`,`venv`,`.venv`,`site-library`,`.ipynb_checkpoints`,`.Rproj.user`,`.snakemake`,`.nextflow`]),l={maxFolders:48,maxDepth:5,maxFiles:4e3};async function u(e,t,n){let r=[],i=[{path:``,depth:0}],a=0,s=!1;for(;i.length;){if(n.aborted)throw new DOMException(`aborted`,`AbortError`);if(a>=l.maxFolders){s=!0;break}let u=i.shift();a++;let d=await e.call(`project.entries`,{projectId:t,...u.path?{path:u.path}:{}},n);d.truncated&&(s=!0);for(let e of d.entries)if(!e.hidden){if(e.kind===`folder`){if(c.has(e.name))continue;if(u.depth+1>l.maxDepth){s=!0;continue}i.push({path:e.path,depth:u.depth+1})}else{if(r.length>=l.maxFiles){s=!0;break}r.push({...e,category:o(e.path)})}}}return{files:r,truncated:s}}function d(e,t,n){let[i,a]=(0,r.useState)({files:[],truncated:!1,reading:!1,problem:``,readAt:0}),[o,s]=(0,r.useState)(0),c=(0,r.useRef)(0),l=(0,r.useRef)(void 0),[d,f]=(0,r.useState)(0);return(0,r.useEffect)(()=>{a({files:[],truncated:!1,reading:!1,problem:``,readAt:0}),c.current=0},[t]),(0,r.useEffect)(()=>{if(!t)return;let e=Math.max(0,c.current+5e3-Date.now());return clearTimeout(l.current),l.current=setTimeout(()=>f(e=>e+1),e),()=>clearTimeout(l.current)},[t,n,o]),(0,r.useEffect)(()=>{if(!t||!d)return;let n=new AbortController;return c.current=Date.now(),a(e=>({...e,reading:!0})),u(e,t,n.signal).then(e=>a({...e,reading:!1,problem:``,readAt:Date.now()}),e=>{n.signal.aborted||a(t=>({...t,reading:!1,problem:e instanceof Error?e.message:`The project folder could not be read.`}))}),()=>n.abort()},[e,t,d]),{...i,refresh:()=>{c.current=0,s(e=>e+1)}}}var f=[`data`,`code`,`results`,`notes`],p=[`data`,`code`,`workflows`,`results`,`reports`,`notes`,`references`,`environment`],ee=new Set([`renv.lock`,`description`,`environment.yml`,`environment.yaml`,`pyproject.toml`,`setup.py`,`setup.cfg`,`pipfile`,`pipfile.lock`,`poetry.lock`,`uv.lock`,`conda-lock.yml`,`dockerfile`,`containerfile`,`apptainer.def`,`singularity.def`,`install.r`,`project.toml`,`manifest.toml`]),te=new Set([`snakefile`,`makefile`,`gnumakefile`,`justfile`,`_targets.r`,`nextflow.config`,`dvc.yaml`]),ne=new Set([`refs`,`references`,`literature`,`papers`,`reading`,`bibliography`]),m=e=>e.toLowerCase().replace(/\.[^./]+$/,``),re=e=>new Set(e.filter(e=>/\.(rmd|qmd|rnw)$/i.test(e.path)).map(e=>m(e.path))),ie=e=>new Set(e.filter(e=>/\.html?$/i.test(e.path)).map(e=>e.path.toLowerCase().split(`/`).slice(0,-1).join(`/`))),ae=/^[a-z][\w.]*(-[a-z][\w.]*)*-\d+(\.\d+)+$/,oe=/^(lib|libs|site_libs|.+_files)$/;function se(e,t,n=new Set){let r=e.path.toLowerCase().split(`/`),i=r.at(-1),a=i.includes(`.`)?i.split(`.`).at(-1):``;return r.slice(0,-1).some((e,n)=>e.endsWith(`_files`)&&t.has([...r.slice(0,n),e.slice(0,-6)].join(`/`)))||r.slice(0,-1).some((e,t)=>t>0&&ae.test(e)&&oe.test(r[t-1])&&n.has(r.slice(0,t-1).join(`/`)))?null:ee.has(i)||/^requirements([-_.][^/]*)?\.txt$/.test(i)||a===`rproj`?`environment`:te.has(i)||[`smk`,`nf`,`wdl`,`cwl`].includes(a)?`workflows`:[`rmd`,`qmd`,`rnw`].includes(a)||[`html`,`pdf`,`docx`].includes(a)&&t.has(m(e.path))?`reports`:[`bib`,`ris`,`nbib`,`enw`].includes(a)||a===`pdf`&&r.slice(0,-1).some(e=>ne.has(e))?`references`:e.category===`figures`||e.category===`results`?`results`:e.category}var h=e=>e.split(`/`).filter(Boolean).at(-1)??e;function g(e,t){let n=e.split(`/`);if(n.pop(),!n.length)return t.name??h(t.root);let r=n[0].startsWith(`@`)?t.sources?.find(e=>`@`+e.id===n[0]):void 0;return[r?r.name:n[0],...n.slice(1)].join(`/`)}var _=e=>![`current-filesystem-observation`,`captured-observation`].includes(e.provenance?.source??``),v=new Intl.Collator(void 0,{numeric:!0,sensitivity:`base`});function y(e,t,n,r,i=[]){let a=new Map,o=new Map(i.map(e=>[e.operationId,e.acceptedAt])),s=e=>o.get(String(e.provenance?.operationId??``))??``,c=new Map;if(e===`results`)for(let e of n){let t=c.get(e.path);_(e)&&(!t||s(e).localeCompare(s(t))>0||s(e)===s(t)&&e.version.localeCompare(t.version)>0)&&c.set(e.path,e)}for(let e of c.values())a.set(e.path,{key:`result:`+e.path,path:e.path,name:h(e.path),folder:g(e.path,r),bytes:e.bytes??null,category:e.kind===`media`?`figures`:`results`,resource:{id:e.id,version:e.version,kind:e.kind,path:e.path}});let l=re(t),u=ie(t);for(let n of t)se(n,l,u)===e&&!a.has(n.path)&&a.set(n.path,{key:`file:`+n.path,path:n.path,name:n.name,folder:g(n.path,r),bytes:n.bytes,category:n.category});let d=e=>Number(e.path.includes(`/`));return[...a.values()].sort((e,t)=>d(e)-d(t)||v.compare(e.folder,t.folder)||v.compare(e.name,t.name))}function ce(e){let t=new Set(e.views.map(e=>e.id)),n=new Set,r=new Map((e.nodes??[]).map(e=>[e.id,e])),i=e=>{let n=r.get(e);return n?n.kind===`view`?t.has(n.id)?[n.id]:[]:n.children.flatMap(i):[]},a=e=>{let o=r.get(e);if(!o)return null;if(o.kind===`view`)return t.has(o.id)?(n.add(o.id),{kind:`tabs`,id:`tabs:`+o.id,views:[o.id]}):null;let s=o.presentation?.mode===`split`?o.presentation:null;if(s){let e=o.children.map((e,t)=>({region:a(e),weight:s.weights[t]??1})).filter(e=>e.region);return e.length?e.length===1?e[0].region:{kind:`split`,id:o.id,axis:s.axis,weights:e.map(e=>e.weight),children:e.map(e=>e.region)}:null}let c=i(o.id);return c.forEach(e=>n.add(e)),c.length?{kind:`tabs`,id:o.id,views:c}:null},o=e.rootId&&r.size?a(e.rootId):null,s=e.views.map(e=>e.id).filter(e=>!n.has(e));if(!s.length)return o;if(!o)return{kind:`tabs`,id:`tabs:root`,views:s};let c=b(o),l=c[c.length-1];return o=x(o,l.id,{...l,views:[...l.views,...s]}),o}function b(e){return e.kind===`tabs`?[e]:e.children.flatMap(b)}function le(e){return e?b(e).flatMap(e=>e.views):[]}function ue(e,t){return e?b(e).find(e=>e.views.includes(t))??null:null}function x(e,t,n){return e.id===t?n:e.kind===`split`?{...e,children:e.children.map(e=>x(e,t,n))}:e}function S(e,t,n,r=.12){let i=e.reduce((e,t)=>e+t,0),a=[...e],o=i*r,s=a[t]+a[t+1],c=Math.min(s-o,Math.max(o,a[t]+n*i));return a[t]=c,a[t+1]=s-c,a}function de(e){let t=e.bindings?.data,n=e=>e.replace(/[^A-Za-z0-9._-]/g,`_`).slice(0,40);return typeof t?.id==`string`&&typeof t.version==`string`?{kind:`shared`,id:`linked:${n(t.id)}@${n(t.version)}`}:{kind:`shared`,id:e.id}}var C=e=>e?.presentation?.mode===`split`,w=(e,t)=>e.find(e=>e.kind===`group`&&e.children?.includes(t));function T(e,t){let n=t;for(;;){let t=w(e,n);if(!t||C(t))return n;n=t.id}}function E(e,t){let n=e.find(e=>e.id===t);return n?n.kind===`view`?[t]:(n.children??[]).flatMap(t=>E(e,t)):[]}function D(e){let t=e.nodes,n=e.rootId;for(let e=!0;e;){e=!1;for(let r of t){if(r.kind!==`group`||r.id===n)continue;let i=w(t,r.id);if(!r.children?.length){let n=i.children.indexOf(r.id);i.children=i.children.filter(e=>e!==r.id),C(i)&&(i.presentation={...i.presentation,weights:(i.presentation.weights??[]).filter((e,t)=>t!==n)}),t=t.filter(e=>e.id!==r.id),e=!0;break}if(C(r)&&r.children.length===1){let n=r.children[0];i.children=i.children.map(e=>e===r.id?n:e),t=t.filter(e=>e.id!==r.id),e=!0;break}}let r=t.find(e=>e.id===n);if(r&&C(r)&&r.children?.length===1){let i=r.children[0];t.find(e=>e.id===i).kind===`group`&&(t=t.filter(e=>e.id!==n),n=i,e=!0)}}return{rootId:n,nodes:t}}var O=e=>({rootId:e.rootId,nodes:structuredClone(e.nodes)});function k(e,t){let n=w(e.nodes,t),r=n.children.indexOf(t);n.children=n.children.filter(e=>e!==t),C(n)&&(n.presentation={...n.presentation,weights:(n.presentation.weights??[]).filter((e,t)=>t!==r)})}function fe(e,t,n,r){if(!e.nodes.some(e=>e.id===t&&e.kind===`view`)||!w(e.nodes,t))return null;let i=T(e.nodes,t);if(i===t||E(e.nodes,i).length<2)return null;let a=O(e);k(a,t);let o={id:r(`group`),kind:`group`,children:[t]};a.nodes.push(o);let s=w(a.nodes,i);if(s&&C(s)&&s.presentation.axis===n){let e=s.children.indexOf(i),t=[...s.presentation.weights??s.children.map(()=>1)],n=(t[e]??1)/2;s.children.splice(e+1,0,o.id),t.splice(e,1,n,n),s.presentation={...s.presentation,weights:t}}else{let e={id:r(`split`),kind:`group`,children:[i,o.id],presentation:{mode:`split`,axis:n,weights:[1,1]}};a.nodes.push(e),s?s.children=s.children.map(t=>t===i?e.id:t):a.rootId=e.id}return D(a)}function A(e){let t=[],n=(r,i)=>{let a=e.nodes.find(e=>e.id===r);if(a){if(C(a))for(let e of a.children??[])n(e,!0);else(i||r===e.rootId)&&t.push(r)}};return n(e.rootId,!1),t}function j(e,t,n){let r=e.nodes.find(e=>e.id===t.id);if(r)return r.kind===`view`&&r.component===t.component&&r.version===t.version&&JSON.stringify(r.bindings)===JSON.stringify(t.bindings)?e:null;let i=O(e),a=A(i).at(-1),o=i.nodes.find(e=>e.id===a);if(!o)return null;if(i.nodes.push({id:t.id,kind:`view`,component:t.component,version:t.version,props:structuredClone(t.props),bindings:structuredClone(t.bindings)}),o.kind===`group`)o.children=[...o.children??[],t.id];else{let e={id:n(`group`),kind:`group`,children:[o.id,t.id]};i.nodes.push(e);let r=w(i.nodes,o.id);r?r.children=r.children.map(t=>t===o.id?e.id:t):i.rootId=e.id}return i}function pe(e,t,n,r){if(!w(e.nodes,t))return null;let i=A(e),a=T(e.nodes,t),o=i[i.indexOf(a)+n];if(!o||o===a)return null;let s=O(e);k(s,t);let c=s.nodes.find(e=>e.id===o);if(c.kind===`group`)c.children=[...c.children??[],t];else{let e={id:r(`group`),kind:`group`,children:[o,t]};s.nodes.push(e);let n=w(s.nodes,o);n.children=n.children.map(t=>t===o?e.id:t)}return D(s)}function me(e,t,n){if(!e.nodes.find(e=>e.id===t&&e.kind===`view`))return null;let r=O(e),i=r.nodes.find(e=>e.id===t);return i.props={...i.props,...n},r}function he(e,t){if(!w(e.nodes,t))return null;let n=O(e);return k(n,t),n.nodes=n.nodes.filter(e=>e.id!==t),D(n)}function M(e,t,n){let r=e.nodes.find(e=>e.id===t);if(!C(r)||r.children.length!==n.length)return null;let i=O(e),a=i.nodes.find(e=>e.id===t);return a.presentation={...a.presentation,weights:n.map(e=>Math.round(e*1e3)/1e3)},i}var N=e=>e.startsWith(`tabs:`)?e.slice(5):e;function P(e,t,n,r,i){let a=e.nodes.find(e=>e.id===n);if(!a||C(a)||n===t||!w(e.nodes,t))return null;if(T(e.nodes,t)===n){let i=E(e.nodes,n),a=i.filter(e=>e!==t),o=r&&a.includes(r)?a.indexOf(r):a.length;if(i.indexOf(t)===o)return null}let o=O(e);k(o,t);let s=o.nodes.find(e=>e.id===n);if(s.kind===`group`){let e=s.children??[],n=r?e.find(e=>e===r||E(o.nodes,e).includes(r)):void 0;e.splice(n?e.indexOf(n):e.length,0,t),s.children=e}else{let e={id:i(`group`),kind:`group`,children:r===n?[t,n]:[n,t]};o.nodes.push(e);let a=w(o.nodes,n);a?a.children=a.children.map(t=>t===n?e.id:t):o.rootId=e.id}return D(o)}function F(e,t,n,r,i){if(e.nodes.some(e=>e.id===t.id))return null;let a=n&&w(e.nodes,n)?n:E(e.nodes,A(e).at(-1)??e.rootId)[0]??null,o=j(e,t,i);return!o||!a?o:z(o,t.id,T(o.nodes,a),r,i)??o}function I(e,t,n,r,i=.4){if(e.nodes.some(e=>e.id===t.id))return null;let a=j(e,t,r);if(!a||E(a.nodes,a.rootId).length<2)return a;let o=O(a);k(o,t.id);let s={id:r(`group`),kind:`group`,children:[t.id]};return o.nodes.push(s),L(o,s.id,n,i,r),D(o)}function L(e,t,n,r,i){let a=n===`left`||n===`right`?`horizontal`:`vertical`,o=n===`right`||n===`bottom`,s=e.nodes.find(t=>t.id===e.rootId);if(C(s)&&s.presentation.axis===a){let e=[...s.presentation.weights??s.children.map(()=>1)],n=e.reduce((e,t)=>e+t,0)*r/(1-r);o?(s.children.push(t),e.push(n)):(s.children.unshift(t),e.unshift(n)),s.presentation={...s.presentation,weights:e}}else{let n={id:i(`split`),kind:`group`,children:o?[e.rootId,t]:[t,e.rootId],presentation:{mode:`split`,axis:a,weights:o?[1-r,r]:[r,1-r]}};e.nodes.push(n),e.rootId=n.id}}function R(e,t){let n=1;for(let r=T(e.nodes,t),i=w(e.nodes,r);i;r=i.id,i=w(e.nodes,r)){if(!C(i)||i.presentation.axis!==`horizontal`)continue;let e=i.presentation.weights??i.children.map(()=>1),t=e.reduce((e,t)=>e+t,0);n*=(e[i.children.indexOf(r)]??1)/(t||1)}return n}function ge(e,t,n,r,i,a){let o=T(e.nodes,n),s=w(e.nodes,o);if(r&&s&&R(e,n)*r<2*i){let n=s.children.indexOf(o),r=s.children[n+1]??s.children[n-1];for(let t=e.nodes.find(e=>e.id===r);t&&C(t);t=e.nodes.find(e=>e.id===r))r=t.children?.[0];let i=r?j(e,t,a):null;if(i)return P(i,t.id,r,null,a)??i}return F(e,t,n,`right`,a)}function z(e,t,n,r,i){let a=e.nodes.find(e=>e.id===n);if(!a||C(a)||n===t||!w(e.nodes,t)||T(e.nodes,t)===n&&E(e.nodes,n).length<2)return null;let o=O(e);k(o,t);let s={id:i(`group`),kind:`group`,children:[t]};return o.nodes.push(s),B(o,s.id,n,r,i),D(o)}function B(e,t,n,r,i){let a=r===`left`||r===`right`?`horizontal`:`vertical`,o=r===`right`||r===`bottom`,s=w(e.nodes,n);if(s&&C(s)&&s.presentation.axis===a){let e=s.children.indexOf(n),r=[...s.presentation.weights??s.children.map(()=>1)],i=(r[e]??1)/2;s.children.splice(o?e+1:e,0,t),r.splice(e,1,i,i),s.presentation={...s.presentation,weights:r}}else{let r={id:i(`split`),kind:`group`,children:o?[n,t]:[t,n],presentation:{mode:`split`,axis:a,weights:[1,1]}};e.nodes.push(r),s?s.children=s.children.map(e=>e===n?r.id:e):e.rootId=r.id}}function V(e,t){let n=(e,t)=>{let r=e.nodes.find(e=>e.id===t);return!r||r.kind===`view`?t:[t,r.presentation?.mode===`split`?r.presentation.axis:`tabs`,(r.children??[]).map(t=>n(e,t))]};return JSON.stringify(n(e,e.rootId))===JSON.stringify(n(t,t.rootId))}function _e(e,t,n,r,i,a){let o=A(e),s=e.nodes.find(e=>e.id===t);if(!s||t===n||t===e.rootId||!o.includes(t)||!o.includes(n))return null;if(s.kind===`view`)return r===`center`?P(e,t,n,i,a):z(e,t,n,r,a);let c=O(e);if(k(c,t),r!==`center`){B(c,t,n,r,a);let i=D(c);return V(e,i)?null:i}let l=E(c.nodes,t),u=new Set,d=e=>{let t=c.nodes.find(t=>t.id===e);t?.kind===`group`&&(u.add(e),t.children?.forEach(d))};d(t),c.nodes=c.nodes.filter(e=>!u.has(e.id));let f=c.nodes.find(e=>e.id===n);if(f.kind===`group`){let e=f.children??[],t=i?e.find(e=>e===i||E(c.nodes,e).includes(i)):void 0;e.splice(t?e.indexOf(t):e.length,0,...l),f.children=e}else{let e={id:a(`group`),kind:`group`,children:i===n?[...l,n]:[n,...l]};c.nodes.push(e);let t=w(c.nodes,n);t?t.children=t.children.map(t=>t===n?e.id:t):c.rootId=e.id}return D(c)}function H(e,t,n,r,i=1/3){let a=e.nodes.find(e=>e.id===t);if(!a||!w(e.nodes,t)||a.kind!==`view`&&!A(e).includes(t))return null;let o=T(e.nodes,t);if(o!==t&&E(e.nodes,o).length===1)return H(e,o,n,r,i);let s=O(e);k(s,t);let c=t;if(!A(e).includes(t)){let e={id:r(`group`),kind:`group`,children:[t]};s.nodes.push(e),c=e.id}L(s,c,n,i,r);let l=D(s);return V(e,l)?null:l}function U(e,t,n,r){if(e.nodes.some(e=>e.id===t.id))return null;let i=j(e,t,r);return i&&(P(i,t.id,n,null,r)??i)}var W=`workspace`,ve={workspace:`Workspace`,"agent-canvas":`Agent canvas`,"observed-outputs":`Observed outputs`,"external-results":`External results`};function ye(e){return ve[e]??(/^workspace-(\d+)$/.exec(e)?`Workspace `+e.slice(10):e)}var be=e=>`conversation-`+e,xe=e=>e.startsWith(`conversation-`)?e.slice(13):null;function G(e){let t=2166136261,n=16777619;for(let r of e){let e=r.codePointAt(0);t=Math.imul(t^e,16777619)>>>0,n=Math.imul(n^e,2166136261)>>>0}return`file-`+(t.toString(16).padStart(8,`0`)+n.toString(16).padStart(8,`0`)).slice(0,12)+`-`}var Se={maxViewsPerSide:6},K=`canvas-`,q=`markdown.reader`,J=`html.reader`,Ce=e=>e.kind===`view`?e.component===`rho.editor`||e.component===q||e.component===J?`code`:e.component===`rho.table`||e.component===`rho.media`?`data`:null:null,Y=/\.(png|jpe?g|svg|gif|pdf|tiff?|webp|xlsx?|rds|rda|rdata|parquet|feather|h5|h5ad|bam|zip|gz)$/i,we=e=>s(e)||!Y.test(e),Te=(e,t)=>e.catalog.operations.some(e=>e.method===t&&e.authorized&&e.state===`available`),X=(e,t)=>e.catalog.components.find(e=>e.id===t),Z=e=>Te(e,`agent.activity.capture`)&&!!X(e,`rho.table`)&&!!X(e,`rho.media`);async function Q(e,t,n){if(typeof n!=`string`){let e=X(t,n.kind===`table`?`rho.table`:`rho.media`);if(!e||![`table`,`media`].includes(n.kind))return null;let r=Object.keys(e.bindings)[0]??`data`;return{side:`data`,node:{id:`result-`+n.id.slice(0,12)+`-`+n.version.slice(0,12),kind:`view`,component:e.id,version:e.version,props:{title:n.path.split(`/`).at(-1)??n.path},bindings:{[r]:{id:n.id,version:n.version}}}}}let r=n,i=t.project.id,a=r.split(`/`).at(-1)??r;if(s(r)&&Z(t)){let n=await e.call(`agent.activity.capture`,{projectId:i,path:r}),o=X(t,n.kind===`table`?`rho.table`:`rho.media`),s=Object.keys(o.bindings)[0]??`data`;return{side:`data`,node:{id:G(r)+n.version.slice(0,12),kind:`view`,component:o.id,version:o.version,props:{title:a},bindings:{[s]:{id:n.id,version:n.version}}}}}if(Y.test(r))return null;let o=(/\.(md|markdown)$/i.test(r)?X(t,q):/\.html?$/i.test(r)?X(t,J):void 0)??X(t,`rho.editor`);if(!o)return null;let c=await e.call(`document.open`,{projectId:i,path:r});return{side:`code`,node:{id:`doc-`+c.id.slice(0,12),kind:`view`,component:o.id,version:o.version,props:{title:a},bindings:{document:{kind:`live-document`,documentId:c.id}}}}}function Ee(e,t,n,r){let i=structuredClone(e?.nodes??[]),a=e?.rootId??`root`;if(i.some(e=>e.id===t.id))return null;let o=e=>i.find(t=>t.id===e),s=e=>i.find(t=>t.kind===`group`&&t.children?.includes(e)),c=e=>!!e&&e.kind===`group`&&e.presentation?.mode!==`split`,l=t.id.startsWith(`file-`)?t.id.slice(0,18):``,u=l?i.find(e=>e.kind===`view`&&e.id.startsWith(l)):void 0;if(u){let e=s(u.id);if(e)return e.children=e.children.map(e=>e===u.id?t.id:e),{rootId:a,nodes:[...i.filter(e=>e.id!==u.id),t]}}if(r&&e?.rootId&&i.length)return U({rootId:a,nodes:i},t,r,e=>`${e}-${crypto.randomUUID().slice(0,8)}`);let d=o(a);d||(d={id:a,kind:`group`,children:[]},i.push(d));let f=new Map;for(let e of i)if(Ce(e)===n){let t=s(e.id);c(t)&&f.set(t,(f.get(t)??0)+1)}let p=i.find(e=>e.id===K+n&&e.kind===`group`)??[...f].sort((e,t)=>t[1]-e[1])[0]?.[0]??(d.children?.length?void 0:d);if(!p){p={id:K+n,kind:`group`,children:[]},i.push(p);let e=e=>n===`code`?0:e;if(d.presentation?.mode===`split`&&d.presentation.axis===`horizontal`){let t=d.presentation.weights?.length===d.children.length?[...d.presentation.weights]:d.children.map(()=>1),n=e(d.children.length);d.children.splice(n,0,p.id),t.splice(n,0,t.reduce((e,t)=>e+t,0)/t.length),d.presentation={...d.presentation,weights:t}}else{let t=`split`,n=1;for(;o(t);)t=`split-`+ ++n;let r=[a];r.splice(e(1),0,p.id),i.push({id:t,kind:`group`,children:r,presentation:{mode:`split`,axis:`horizontal`,weights:[1,1]}}),a=t}}if(p.children=[...p.children??[],t.id],i.push(t),p.id.startsWith(K))for(;p.children.length>Se.maxViewsPerSide;){let e=p.children.shift(),t=i.findIndex(t=>t.id===e);t>=0&&i.splice(t,1)}return{rootId:a,nodes:i}}var $=new Map;function De(e,t,r,i,a){let o=t.project.id+`/`+r,s=($.get(o)??Promise.resolve()).catch(()=>void 0).then(async()=>{let o=await Q(e,t,i);if(!o)return null;let s=t.project.id;for(let t=0;;t++){let i=await e.call(`composition.read`,{projectId:s,compositionId:r}).catch(e=>{if(e instanceof n&&e.error.kind===`not_found`)return null;throw e}),c=(i?.nodes)?.find(e=>e.id===o.node.id);if(c)return{compositionId:r,viewId:c.id};let l=Ee(i,o.node,o.side,a);if(!l)return{compositionId:r,viewId:o.node.id};try{return await e.call(`composition.apply`,{projectId:s,compositionId:r,expectedVersion:i?.version??0,changeId:`open-`+crypto.randomUUID(),operations:[{op:`replace`,rootId:l.rootId,nodes:l.nodes}]}),{compositionId:r,viewId:o.node.id}}catch(e){if(t===0&&e instanceof n&&e.error.kind===`stale`)continue;throw e}}});return $.set(o,s),s}export{le as A,ce as C,me as D,de as E,p as F,d as I,l as L,s as M,o as N,fe as O,y as P,j as S,M as T,ue as _,De as a,H as b,we as c,F as d,U as f,N as g,z as h,G as i,f as j,b as k,Q as l,he as m,ye as n,be as o,ge as p,W as r,xe as s,Z as t,I as u,_e as v,S as w,pe as x,P as y};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{n as t,t as n}from"./react-Dss-ouuy.js";import{r}from"./markdown-0ngRuTpW.js";import{N as i}from"./canvas-D8rDdfDz.js";import{J as a,K as o,_t as s,mt as c,pt as l}from"./index-CxmItXqa.js";import{a as u,i as d,n as f,o as p,r as m,t as h}from"./notes-meaning-pVbbQUGP.js";var g=e(n(),1),_=(e,t)=>e.length>t?e.slice(0,t-1).trimEnd()+`…`:e;function v(e){let{process:t,meanings:n,traces:r}=e,i=new Map(e.files.map(e=>[e.path,e])),o=f(n),s=e.described??new Map,l=new Map,u=new Map,d=new Map,p=[],m=(e,t,n,r,i,a,o)=>{let s=t+`>`+n+`:`+r;e.has(s)||e.set(s,{id:s,from:t,to:n,label:r,basis:i,at:a,turn:o})},h=e=>t.nodes.filter(t=>t.kind===`file`&&t.path===e).flatMap(e=>e.versions??(e.resource?[{resource:e.resource,capturedAt:e.capturedAt??e.at}]:[])).sort((e,t)=>e.capturedAt-t.capturedAt),g=(e,n)=>t.nodes.find(t=>t.kind===`file`&&t.path===e&&(!n||t.resource?.version===n||t.versions?.some(e=>e.resource.version===n))),v=(t,n,a,u)=>{let d=`m:f:`+t,f=l.get(d);if(!f){let p=i.get(t),m=u?.files.find(e=>e.path===t)?.kept??null,g=h(t).at(-1),_=m??(g?{resource:g.resource,at:g.capturedAt}:null),v=c(t,o,s),y=o.get(t);f={id:d,kind:`file`,title:t.split(`/`).at(-1)??t,path:t,at:a,category:p?.category??e.kindOf(t),exists:!!p,bytes:p?.bytes,modifiedAt:p?.modifiedAt,..._?{resource:_.resource,capturedAt:_.at}:{gap:`No version of this file was kept in the Agent's record.`},events:[{key:d,at:a,node:d,turn:n,action:`write`,label:`Named in the notes`}],meaning:{session:``,conversationId:null,...v?{description:{...v,...v.source===`notes`&&y?{trace:r.get(y.statement)}:{}}}:{}}},l.set(d,f)}return f};n.forEach(n=>{let a=n.statements;if(!a.length)return;let o=`m:`+(n.conversationId??`notes-`+n.line),s=t.turns.find(e=>e.conversationId===n.conversationId),c=a.map(e=>r.get(e)?.written?.at).filter(e=>e!==void 0),f=c.length?Math.min(...c):s?.start??0;p.push({id:o,conversationId:n.conversationId??``,title:n.title,agent:s?.agent??`Notes`,start:f,end:Math.max(f,...c),running:!1});let h=e=>r.get(e)?.written?.at??f,g=e=>({session:n.title,conversationId:n.conversationId,...e?{statement:e,trace:r.get(e)}:{}}),y=a.filter(e=>e.kind===`todo`),b=a.find(e=>e.kind===`question`),C={id:`q:`+o,kind:`question`,title:_(b?.text||n.title,160),text:b?.text||n.title,at:b?h(b):f,turn:o,conversationId:n.conversationId??void 0,agent:s?.agent,events:[],meaning:{...g(b),...y.length?{todos:{done:y.filter(e=>e.done).length,total:y.length}}:{}}};l.set(C.id,C);let w=new Map;a.forEach((e,i)=>{if(e.kind!==`finding`&&e.kind!==`choice`)return;let a={id:`m:s:`+o+`:`+e.line,kind:e.kind,title:_(e.text,220),text:e.text,at:h(e),turn:o,conversationId:n.conversationId??void 0,events:[{key:`m:s:`+o+`:`+e.line,at:h(e),node:`m:s:`+o+`:`+e.line,turn:o,action:`write`,label:`Written in the notes`}],meaning:g(e)};l.set(a.id,a),w.set(i,a),m(u,C.id,a.id,e.kind===`finding`?`found`:`chose`,`declared`,h(e),o);for(let t of e.links)m(u,a.id,v(t,o,h(e),r.get(e)).id,e.kind===`finding`?`rests on`:`gives`,`declared`,h(e),o);for(let t of e.alternatives??[])for(let n of t.links)m(u,a.id,v(n,o,h(e),r.get(e)).id,`instead gives`,`declared`,h(e),o);let s=r.get(e)?.written;s&&t.nodes.some(e=>e.id===`q:`+s.turn)&&m(d,a.id,`q:`+s.turn,`written in`,`observed`,s.at,o)}),a.forEach(e=>{if(e.kind!==`figure`)return;let t=e.of===void 0?void 0:w.get(e.of);for(let n of e.links)m(u,(t??C).id,v(n,o,h(e),r.get(e)).id,t?`shown in`:`shows`,`declared`,h(e),o)});let T=()=>new Set([...u.values()].map(e=>e.to));for(let e of a)if(e.kind===`file`)for(let t of e.links){let n=v(t,o,h(e),r.get(e));!T().has(n.id)&&n.category!==`code`&&n.category!==`data`&&m(u,C.id,n.id,`made`,`declared`,h(e),o)}let E=a.filter(e=>e.kind===`method`||e.kind===`file`);for(let t of E){let n=t.links.filter(t=>(i.get(t)?.category??e.kindOf(t))===`code`),a=t.links.filter(t=>(i.get(t)?.category??e.kindOf(t))===`data`);for(let e of n)for(let n of a)m(u,v(e,o,h(t),r.get(t)).id,v(n,o,h(t),r.get(t)).id,`reads`,`declared`,h(t),o)}n.conversationId&&x(o,C,n.conversationId),S(o,n.conversationId);for(let e of E)for(let t of e.links){let n=v(t,o,h(e),r.get(e));T().has(n.id)||m(u,C.id,n.id,n.category===`data`?`uses data`:`uses`,`declared`,h(e),o)}});let y=new Set(n.map(e=>e.conversationId));for(let e of new Set([...s.values()].map(e=>e.conversationId))){if(y.has(e)||!b(e).length)continue;let n=`m:`+e,r=t.turns.find(t=>t.conversationId===e),i=t.nodes.find(t=>t.kind===`question`&&t.conversationId===e),a=b(e).map(e=>Date.parse(e.observedAt)),o=r?.start??Math.min(...a);p.push({id:n,conversationId:e,title:r?.title??`Conversation`,agent:r?.agent??`Agent`,start:o,end:Math.max(o,...a),running:!1});let s={id:`q:`+n,kind:`question`,title:_(i?.text??r?.title??`Conversation`,160),text:i?.text??r?.title??``,at:o,turn:n,conversationId:e,agent:r?.agent,events:[],meaning:{session:r?.title??`Conversation`,conversationId:e,...i?{message:{id:i.id,at:i.at}}:{}}};l.set(s.id,s),x(n,s,e),S(n,e)}function b(t){return[...s.values()].filter(n=>n.conversationId===t&&[`results`,`figures`].includes(i.get(n.path)?.category??e.kindOf(n.path)??``))}function x(e,t,n){for(let r of b(n)){if(l.has(`m:f:`+r.path))continue;let n=Date.parse(r.observedAt),i=v(r.path,e,n);m(u,t.id,i.id,`made`,`observed`,n,e)}}function S(e,n){let r=e=>!n||e.turn.startsWith(n+`/`),i=new Map(t.nodes.map(e=>[e.id,e])),a=!0;for(;a;){a=!1;for(let n of[...l.values()])if(n.kind===`file`&&n.path&&n.events[0]?.turn===e){for(let o of t.edges.filter(e=>r(e)&&i.get(e.to)?.path===n.path)){let r=i.get(o.from);if(r?.kind===`run`)for(let s of t.edges.filter(e=>e.to===r.id&&(e.label===`runs`||e.label===`named`))){let t=i.get(s.from);if(!t?.path||t.path===n.path)continue;let r=l.size,c=v(t.path,e,s.at);m(u,n.id,c.id,s.label===`runs`?`made by`:`named with`,o.basis,o.at,e),l.size>r&&(a=!0)}}if(n.category===`code`)for(let o of t.edges.filter(e=>r(e)&&e.label===`runs`&&i.get(e.from)?.path===n.path))for(let r of t.edges.filter(e=>e.to===o.to&&e.label===`named`)){let t=i.get(r.from);if(!t?.path||t.path===n.path)continue;let o=l.size;m(u,n.id,v(t.path,e,r.at).id,`reads`,`named`,r.at,e),l.size>o&&(a=!0)}}}}for(let e of l.values()){if(e.kind!==`file`||!e.path)continue;let t=g(e.path,e.resource?.version)??g(e.path);t&&m(d,e.id,t.id,`kept as`,`observed`,e.capturedAt??e.at,e.events[0].turn)}let C=`m:f:`+a,w=e=>e.from!==C&&e.to!==C;return{nodes:[...l.values()].filter(e=>e.id!==C),edges:[...u.values()].filter(w),turns:p,traces:[...d.values()].filter(w)}}function y(e,t,n){return n===`process`||!t||!t.nodes.length?e:n===`meaning`?{...e,nodes:t.nodes,edges:t.edges,turns:t.turns,events:[],live:null,omittedNodes:0}:{...e,nodes:[...t.nodes,...e.nodes],edges:[...t.edges,...t.traces,...e.edges],turns:[...t.turns,...e.turns]}}var b={versions:24},x=new Map;function S(e,t,n,r,a,d=[]){let p=t.project.id,h=(0,g.useMemo)(()=>n.nodes.filter(e=>e.kind===`file`&&e.path===`project-notes.md`).flatMap(e=>(e.versions??(e.resource?[{resource:e.resource,capturedAt:e.capturedAt??e.at}]:[])).map(t=>({...t,turn:e.events.find(e=>e.action===`capture`&&e.key.endsWith(`:`+t.resource.id))?.turn??e.events[0]?.turn??``}))).sort((e,t)=>e.capturedAt-t.capturedAt).slice(-b.versions),[n]),_=h.map(e=>e.resource.version).join(`,`),[y,S]=(0,g.useState)([]);return(0,g.useEffect)(()=>{let t=!0;return Promise.all(h.map(t=>{let n=p+`:`+t.resource.id+`@`+t.resource.version;return x.has(n)||x.set(n,s(e,p,t.resource,o.maxTitleBytes).then(e=>new TextDecoder().decode(e)).catch(()=>(x.delete(n),``))),x.get(n).then(e=>({text:e,at:t.capturedAt,turn:t.turn,conversationId:t.turn.split(`/`)[0]??``,resource:t.resource}))})).then(e=>{t&&S(e.filter(e=>e.text))}),()=>{t=!1}},[e,p,_]),(0,g.useMemo)(()=>{let e=m(a.length>o.maxTitleBytes?``:a),t=e=>n.nodes.filter(t=>t.kind===`file`&&t.path===e).flatMap(e=>e.versions??(e.resource?[{resource:e.resource,capturedAt:e.capturedAt??e.at}]:[])).map(e=>({at:e.capturedAt,resource:e.resource})),s=e=>{let t=r.find(t=>t.path===e);return t?.modifiedAt?Date.parse(t.modifiedAt):null},p=new Map;for(let n of e)for(let e of n.statements)p.set(e,u(e,y,t,s));let g=l(d),_=f(e);return{meanings:e,traces:p,layer:v({process:n,meanings:e,traces:p,files:r,kindOf:e=>i(e),described:g}),descriptions:_,versions:{read:y.length,kept:h.length},holds:e=>c(e,_,g)}},[a,y,n,r,d])}var C=t();function w({statement:e,trace:t,conversationId:n,client:i,projectId:a,onPath:o,onSent:s}){let[c,l]=(0,g.useState)(null),u=e=>t?.files.find(t=>t.path===e)?.later,f=e=>e.map(e=>(0,C.jsxs)(`button`,{className:`work-file`,title:e+(u(e)===`kept`?` · a newer version was kept since this was written`:u(e)===`written`?` · written again since this was written`:``),onClick:()=>o(e),children:[(0,C.jsx)(r,{name:/\.(png|jpe?g|svg)$/i.test(e)?`image`:/\.(csv|tsv)$/i.test(e)?`table`:`file`,size:13}),(0,C.jsx)(`span`,{children:e.split(`/`).at(-1)}),u(e)&&(0,C.jsx)(`small`,{children:`changed since`})]},e)),{topic:m,rest:_}=d(p(e.text,e.links)),v=e.alternatives??[];return(0,C.jsx)(`div`,{className:`choice`+(m?``:` untitled`),children:(0,C.jsxs)(`div`,{className:`choice-grid`,children:[m&&(0,C.jsx)(`p`,{className:`choice-topic`,children:m}),(0,C.jsxs)(`div`,{className:`choice-body`,children:[(0,C.jsx)(`p`,{className:`choice-taken`,children:_}),e.links.length>0&&(0,C.jsx)(`div`,{className:`choice-foot`,children:f(e.links)}),v.map((t,r)=>(0,C.jsxs)(`div`,{className:`choice-other`,children:[(0,C.jsxs)(`p`,{children:[(0,C.jsx)(`span`,{className:`choice-other-label`,children:`Other option`}),h(p(t.text,t.links))]}),t.links.length>0&&(0,C.jsx)(`div`,{className:`choice-foot`,children:f(t.links)}),n&&c!==r&&(0,C.jsx)(`button`,{className:`text-button choice-instead`,onClick:()=>l(r),children:`Use this instead…`}),n&&c===r&&(0,C.jsx)(T,{conversationId:n,client:i,projectId:a,taken:e.text,option:t.text,onCancel:()=>l(null),onSent:e=>{l(null),s?.(e)}})]},r))]})]})})}function T({conversationId:e,client:t,projectId:n,taken:r,option:i,onCancel:a,onSent:o}){let[s,c]=(0,g.useState)(`Use this option instead: “${i}” (in place of “${r}”). Redo what depends on it and update the notes.`),[l,u]=(0,g.useState)(!1),[d,f]=(0,g.useState)(``),p=(0,g.useRef)(null);async function m(){if(s.trim()&&!l){p.current?.text!==s&&(p.current={text:s,changeId:`choice-`+crypto.randomUUID()}),u(!0),f(``);try{await t.call(`conversation.send`,{projectId:n,conversationId:e,changeId:p.current.changeId,text:s}),p.current=null,o(e)}catch(e){f(e instanceof Error?e.message:`The message could not be sent.`)}finally{u(!1)}}}return(0,C.jsxs)(`form`,{className:`choice-send`,onSubmit:e=>{e.preventDefault(),m()},onKeyDown:e=>{e.key===`Escape`&&a()},children:[(0,C.jsx)(`textarea`,{rows:3,value:s,"aria-label":`Message to the Agent`,onChange:e=>c(e.target.value),autoFocus:!0}),d&&(0,C.jsx)(`p`,{className:`inline-error`,role:`alert`,children:d}),(0,C.jsxs)(`div`,{className:`choice-send-actions`,children:[(0,C.jsx)(`button`,{type:`button`,onClick:a,children:`Cancel`}),(0,C.jsx)(`button`,{type:`submit`,className:`primary`,disabled:l||!s.trim(),children:l?`Sending…`:`Send to the Agent`})]})]})}export{S as n,y as r,w as t};
@@ -1,4 +1,4 @@
1
- import{n as e,r as t}from"./rolldown-runtime-XKyaHtl9.js";import{n,t as r}from"./react-Dss-ouuy.js";import{a as i}from"./home-CCbP6kS-.js";import{r as a}from"./markdown-0ngRuTpW.js";import{N as o,i as s}from"./canvas-BXhC8RDZ.js";import{At as c,Gt as l,Ht as u,Nt as d,Ut as f,Wt as p,kt as m}from"./index-BYuKpyoi.js";import{c as h,l as g,t as _}from"./facts-BMO6V3-3.js";import{t as v}from"./work-turns-BeCt303c.js";var y=n(),b=t(r(),1),x={shownBytes:262144,pollMs:700,listed:50},S=e=>e instanceof Error?e.message:`The Console could not be reached.`,C=e=>[`unavailable`,`unauthorized`].includes(e?.error?.kind??``),w=e=>new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hourCycle:`h23`});function T(e){if(e<1e4)return(Math.max(e,100)/1e3).toFixed(1)+` s`;if(e<6e4)return Math.round(e/1e3)+` s`;let t=Math.floor(e/6e4),n=Math.round(e%6e4/1e3);return t+` min`+(n?` `+n+` s`:``)}function E(e,t,n){N();let[r,i]=(0,b.useState)(null),[a,o]=(0,b.useState)({off:!1,problem:``}),s=(0,b.useCallback)(()=>e.call(`console.list`,{projectId:t,limit:x.listed}).then(e=>{i(e.commands),o({off:!1,problem:``})},e=>o({off:C(e),problem:S(e)})),[e,t]);return(0,b.useEffect)(()=>{s()},[s,n]),{commands:r,...a,read:s}}function D(e,t,{onRan:n,center:r=!1}={}){let[i,a]=(0,b.useState)(``),[o,s]=(0,b.useState)(``),[c,l]=(0,b.useState)(!1),[u,d]=(0,b.useState)(``),f=(0,b.useRef)(null),p=(0,b.useRef)(null);async function m(r){if(r.trim()&&!c){f.current?.command!==r&&(f.current={command:r,changeId:`console-`+crypto.randomUUID()}),l(!0),d(``);try{await e.call(`console.run`,{projectId:t,command:r,changeId:f.current.changeId}),f.current=null,a(``),s(``),n?.()}catch(e){d(S(e))}finally{l(!1)}}}async function h(r){try{await e.call(`console.stop`,{projectId:t,commandId:r.commandId,changeId:`stop-`+r.commandId}),n?.()}catch(e){d(S(e))}}function g(e,t){a(e),s(`From `+t+`. Check it, then press Run.`),d(``),r&&p.current?.scrollIntoView({block:`center`}),p.current?.focus()}return{draft:i,setDraft:e=>{a(e),e||s(``)},note:o,busy:c,problem:u,input:p,start:m,stop:h,prepare:g}}function O({folder:e,line:t,problem:n}){N();let{draft:r,setDraft:i,note:a,busy:o,input:s}=t,c=Math.min(8,r.split(`
1
+ import{n as e,r as t}from"./rolldown-runtime-XKyaHtl9.js";import{n,t as r}from"./react-Dss-ouuy.js";import{a as i}from"./home-CCbP6kS-.js";import{r as a}from"./markdown-0ngRuTpW.js";import{N as o,i as s}from"./canvas-D8rDdfDz.js";import{At as c,Gt as l,Ht as u,Nt as d,Ut as f,Wt as p,kt as m}from"./index-CxmItXqa.js";import{c as h,l as g,t as _}from"./facts-BMO6V3-3.js";import{t as v}from"./work-turns-BvJlIMmA.js";var y=n(),b=t(r(),1),x={shownBytes:262144,pollMs:700,listed:50},S=e=>e instanceof Error?e.message:`The Console could not be reached.`,C=e=>[`unavailable`,`unauthorized`].includes(e?.error?.kind??``),w=e=>new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hourCycle:`h23`});function T(e){if(e<1e4)return(Math.max(e,100)/1e3).toFixed(1)+` s`;if(e<6e4)return Math.round(e/1e3)+` s`;let t=Math.floor(e/6e4),n=Math.round(e%6e4/1e3);return t+` min`+(n?` `+n+` s`:``)}function E(e,t,n){N();let[r,i]=(0,b.useState)(null),[a,o]=(0,b.useState)({off:!1,problem:``}),s=(0,b.useCallback)(()=>e.call(`console.list`,{projectId:t,limit:x.listed}).then(e=>{i(e.commands),o({off:!1,problem:``})},e=>o({off:C(e),problem:S(e)})),[e,t]);return(0,b.useEffect)(()=>{s()},[s,n]),{commands:r,...a,read:s}}function D(e,t,{onRan:n,center:r=!1}={}){let[i,a]=(0,b.useState)(``),[o,s]=(0,b.useState)(``),[c,l]=(0,b.useState)(!1),[u,d]=(0,b.useState)(``),f=(0,b.useRef)(null),p=(0,b.useRef)(null);async function m(r){if(r.trim()&&!c){f.current?.command!==r&&(f.current={command:r,changeId:`console-`+crypto.randomUUID()}),l(!0),d(``);try{await e.call(`console.run`,{projectId:t,command:r,changeId:f.current.changeId}),f.current=null,a(``),s(``),n?.()}catch(e){d(S(e))}finally{l(!1)}}}async function h(r){try{await e.call(`console.stop`,{projectId:t,commandId:r.commandId,changeId:`stop-`+r.commandId}),n?.()}catch(e){d(S(e))}}function g(e,t){a(e),s(`From `+t+`. Check it, then press Run.`),d(``),r&&p.current?.scrollIntoView({block:`center`}),p.current?.focus()}return{draft:i,setDraft:e=>{a(e),e||s(``)},note:o,busy:c,problem:u,input:p,start:m,stop:h,prepare:g}}function O({folder:e,line:t,problem:n}){N();let{draft:r,setDraft:i,note:a,busy:o,input:s}=t,c=Math.min(8,r.split(`
2
2
  `).length),l=(0,b.useId)(),u=t.problem||n;return(0,y.jsxs)(`form`,{className:`console-prompt`,onSubmit:e=>{e.preventDefault(),t.start(r)},children:[(0,y.jsxs)(`label`,{htmlFor:l,className:`console-prompt-label`,children:[`Run a command in `,(0,y.jsx)(`strong`,{children:e})]}),(0,y.jsxs)(`div`,{className:`console-line`,children:[(0,y.jsx)(`span`,{"aria-hidden":`true`,children:`$`}),(0,y.jsx)(`textarea`,{id:l,ref:s,rows:c,value:r,spellCheck:!1,autoComplete:`off`,autoCapitalize:`off`,placeholder:`python3 analysis.py`,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing&&(e.preventDefault(),t.start(r))}}),(0,y.jsx)(`button`,{type:`submit`,className:`primary`,disabled:o||!r.trim(),children:o?`Starting…`:`Run`})]}),a&&(0,y.jsx)(`p`,{className:`console-note`,children:a}),u&&(0,y.jsx)(`p`,{className:`inline-error`,role:`alert`,children:u})]})}function k(e,t,n,r){let[i,a]=(0,b.useState)({text:``,more:!1,problem:``}),o=(0,b.useRef)(0);return(0,b.useEffect)(()=>{if(!r)return;let i=!0,s,c=async()=>{try{for(;;){if(o.current>=x.shownBytes){a(e=>({...e,more:!0}));return}let r=await e.call(`console.output`,{projectId:t,commandId:n.commandId,offset:o.current,maxBytes:65536});if(!i)return;if(o.current=r.nextOffset,a(e=>({text:e.text+r.text,more:!1,problem:``})),!r.more)break}}catch(e){i&&a(t=>({...t,problem:S(e)}))}i&&n.state===`running`&&(s=setTimeout(c,x.pollMs))};return c(),()=>{i=!1,clearTimeout(s)}},[e,t,n.commandId,n.state,r]),i}var A=e=>e.state===`running`?`Running`:e.state===`stopped`?`Stopped`:e.state===`continuing`?`Still running outside Rho`:e.state===`unknown`?`Outcome unknown`:e.state===`not-started`?`Did not start`:e.exit?.signal?`Ended by `+e.exit.signal:`Exit `+(e.exit?.code??`?`);function j({record:e,client:t,projectId:n,made:r,after:i,onRunAgain:a,onStop:o}){N();let[s,c]=(0,b.useState)(e.state===`running`),[l,u]=(0,b.useState)(Date.now()),d=k(t,n,e,s),f=e.state===`running`;(0,b.useEffect)(()=>{if(!f)return;let e=setInterval(()=>u(Date.now()),1e3);return()=>clearInterval(e)},[f]);let p=(e.endedAt?Date.parse(e.endedAt):l)-Date.parse(e.startedAt),m=e.state===`exited`&&e.exit?.code===0,h=[m?``:A(e),p>=1e3?T(p):``].filter(Boolean).join(` · `);return(0,y.jsxs)(`li`,{className:`console-command mine`+(r||f?` made`:``)+(!m&&!f?` problem`:``),children:[(0,y.jsxs)(`details`,{open:s,onToggle:e=>c(e.currentTarget.open),children:[(0,y.jsxs)(`summary`,{children:[(0,y.jsx)(`span`,{className:`console-time`,children:w(Date.parse(e.startedAt))}),(0,y.jsx)(`span`,{className:`console-what`,title:e.command,children:(0,y.jsx)(`code`,{className:`alone`,children:e.command})}),(0,y.jsx)(`span`,{className:`console-end`+(f?` running`:m?``:` problem`),children:h})]}),(0,y.jsxs)(`div`,{className:`console-detail`,children:[e.cwd&&(0,y.jsxs)(`p`,{className:`console-note`,children:[`In `,e.cwd,`/`]}),d.text?(0,y.jsx)(`pre`,{className:`console-output`,ref:e=>{e&&f&&(e.scrollTop=e.scrollHeight)},children:d.text}):(0,y.jsx)(`p`,{className:`console-note`,children:f?`Waiting for output…`:d.problem?``:`It printed nothing.`}),d.more&&(0,y.jsxs)(`p`,{className:`console-note`,children:[`Showing the first `,(x.shownBytes/1024).toFixed(0),` KiB of `,e.kept.toLocaleString(`en-US`),` kept bytes.`]}),e.cut&&!f&&(0,y.jsxs)(`p`,{className:`console-note`,children:[`It printed `,e.bytes.toLocaleString(`en-US`),` bytes; the middle was not kept.`]}),e.problem&&(0,y.jsx)(`p`,{className:`console-note`,children:e.problem}),d.problem&&(0,y.jsx)(`p`,{className:`inline-error`,role:`alert`,children:d.problem}),!f&&e.state!==`continuing`&&(0,y.jsx)(`div`,{className:`console-actions`,children:(0,y.jsx)(`button`,{className:`text-button console-again`,onClick:()=>a(e),children:`Run again`})})]})]}),i,f&&(0,y.jsx)(`div`,{className:`console-actions`,children:(0,y.jsx)(`button`,{className:`text-button console-again`,disabled:!!e.stop,onClick:()=>o(e),children:e.stop?`Stopping…`:`Stop`})})]})}var M=`.console-command { border-top: 1px solid var(--color-divider); }
3
3
  .console-command summary { display: grid; grid-template-columns: 4.6em minmax(0, 1fr) auto; gap: 12px; align-items: baseline; padding: 8px 6px; margin: 0 -6px; border-radius: 6px; cursor: pointer; list-style: none; }
4
4
  .console-command summary:hover { background: var(--color-hover); }
@@ -1,4 +1,4 @@
1
- import{B as e,D as t,I as n,L as r,M as i,Y as a}from"./index-BYuKpyoi.js";import{c as o,d as s,f as c,g as l,i as u,l as d,m as f,o as p,p as m,t as h,u as g}from"./dist-DCtcCJPs.js";import{LRLanguage as ee,Language as te,LanguageDescription as ne,LanguageSupport as _,ParseContext as re,bracketMatchingHandle as ie,continuedIndent as v,defineLanguageFacet as ae,delimitedIndent as oe,flatIndent as se,foldInside as ce,foldNodeProp as y,foldService as le,indentNodeProp as b,indentUnit as ue,languageDataProp as de,sublanguageProp as fe,syntaxTree as x}from"./dist-CH56yNDn.js";import{a as pe,c as S,i as me,n as C,o as he,r as ge,s as _e,t as ve}from"./dist-CBM2oq6g.js";var ye=class e{static create(t,n,r,i,a){let o=i+(i<<8)+t+(n<<4)|0;return new e(t,n,r,o,a,[],[])}constructor(e,t,n,r,i,a,o){this.type=e,this.value=t,this.from=n,this.hash=r,this.end=i,this.children=a,this.positions=o,this.hashProp=[[d.contextHash,r]]}addChild(e,t){e.prop(d.contextHash)!=this.hash&&(e=new f(e.type,e.children,e.positions,e.length,this.hashProp)),this.children.push(e),this.positions.push(t)}toTree(e,t=this.end){let n=this.children.length-1;return n>=0&&(t=Math.max(t,this.positions[n]+this.children[n].length+this.from)),new f(e.types[this.type],this.children,this.positions,t-this.from).balance({makeTree:(e,t,n)=>new f(s.none,e,t,n,this.hashProp)})}},w;(function(e){e[e.Document=1]=`Document`,e[e.CodeBlock=2]=`CodeBlock`,e[e.FencedCode=3]=`FencedCode`,e[e.Blockquote=4]=`Blockquote`,e[e.HorizontalRule=5]=`HorizontalRule`,e[e.BulletList=6]=`BulletList`,e[e.OrderedList=7]=`OrderedList`,e[e.ListItem=8]=`ListItem`,e[e.ATXHeading1=9]=`ATXHeading1`,e[e.ATXHeading2=10]=`ATXHeading2`,e[e.ATXHeading3=11]=`ATXHeading3`,e[e.ATXHeading4=12]=`ATXHeading4`,e[e.ATXHeading5=13]=`ATXHeading5`,e[e.ATXHeading6=14]=`ATXHeading6`,e[e.SetextHeading1=15]=`SetextHeading1`,e[e.SetextHeading2=16]=`SetextHeading2`,e[e.HTMLBlock=17]=`HTMLBlock`,e[e.LinkReference=18]=`LinkReference`,e[e.Paragraph=19]=`Paragraph`,e[e.CommentBlock=20]=`CommentBlock`,e[e.ProcessingInstructionBlock=21]=`ProcessingInstructionBlock`,e[e.Escape=22]=`Escape`,e[e.Entity=23]=`Entity`,e[e.HardBreak=24]=`HardBreak`,e[e.Emphasis=25]=`Emphasis`,e[e.StrongEmphasis=26]=`StrongEmphasis`,e[e.Link=27]=`Link`,e[e.Image=28]=`Image`,e[e.InlineCode=29]=`InlineCode`,e[e.HTMLTag=30]=`HTMLTag`,e[e.Comment=31]=`Comment`,e[e.ProcessingInstruction=32]=`ProcessingInstruction`,e[e.Autolink=33]=`Autolink`,e[e.HeaderMark=34]=`HeaderMark`,e[e.QuoteMark=35]=`QuoteMark`,e[e.ListMark=36]=`ListMark`,e[e.LinkMark=37]=`LinkMark`,e[e.EmphasisMark=38]=`EmphasisMark`,e[e.CodeMark=39]=`CodeMark`,e[e.CodeText=40]=`CodeText`,e[e.CodeInfo=41]=`CodeInfo`,e[e.LinkTitle=42]=`LinkTitle`,e[e.LinkLabel=43]=`LinkLabel`,e[e.URL=44]=`URL`})(w||={});var be=class{constructor(e,t){this.start=e,this.content=t,this.marks=[],this.parsers=[]}},xe=class{constructor(){this.text=``,this.baseIndent=0,this.basePos=0,this.depth=0,this.markers=[],this.pos=0,this.indent=0,this.next=-1}forward(){this.basePos>this.pos&&this.forwardInner()}forwardInner(){let e=this.skipSpace(this.basePos);this.indent=this.countIndent(e,this.pos,this.indent),this.pos=e,this.next=e==this.text.length?-1:this.text.charCodeAt(e)}skipSpace(e){return E(this.text,e)}reset(e){for(this.text=e,this.baseIndent=this.basePos=this.pos=this.indent=0,this.forwardInner(),this.depth=1;this.markers.length;)this.markers.pop()}moveBase(e){this.basePos=e,this.baseIndent=this.countIndent(e,this.pos,this.indent)}moveBaseColumn(e){this.baseIndent=e,this.basePos=this.findColumn(e)}addMarker(e){this.markers.push(e)}countIndent(e,t=0,n=0){for(let r=t;r<e;r++)n+=this.text.charCodeAt(r)==9?4-n%4:1;return n}findColumn(e){let t=0;for(let n=0;t<this.text.length&&n<e;t++)n+=this.text.charCodeAt(t)==9?4-n%4:1;return t}scrub(){if(!this.baseIndent)return this.text;let e=``;for(let t=0;t<this.basePos;t++)e+=` `;return e+this.text.slice(this.basePos)}};function Se(e,t,n){if(n.pos==n.text.length||e!=t.block&&n.indent>=t.stack[n.depth+1].value+n.baseIndent)return!0;if(n.indent>=n.baseIndent+4)return!1;let r=(e.type==w.OrderedList?Ae:ke)(n,t,!1);return r>0&&(e.type!=w.BulletList||De(n,t,!1)<0)&&n.text.charCodeAt(n.pos+r-1)==e.value}var Ce={[w.Blockquote](e,t,n){return n.next==62&&(n.markers.push(N(w.QuoteMark,t.lineStart+n.pos,t.lineStart+n.pos+1)),n.moveBase(n.pos+(T(n.text.charCodeAt(n.pos+1))?2:1)),e.end=t.lineStart+n.text.length,!0)},[w.ListItem](e,t,n){return n.indent<n.baseIndent+e.value&&n.next>-1?!1:(n.moveBaseColumn(n.baseIndent+e.value),!0)},[w.OrderedList]:Se,[w.BulletList]:Se,[w.Document](){return!0}};function T(e){return e==32||e==9||e==10||e==13}function E(e,t=0){for(;t<e.length&&T(e.charCodeAt(t));)t++;return t}function we(e,t,n){for(;t>n&&T(e.charCodeAt(t-1));)t--;return t}function Te(e){if(e.next!=96&&e.next!=126)return-1;let t=e.pos+1;for(;t<e.text.length&&e.text.charCodeAt(t)==e.next;)t++;if(t<e.pos+3)return-1;if(e.next==96){for(let n=t;n<e.text.length;n++)if(e.text.charCodeAt(n)==96)return-1}return t}function Ee(e){return e.next==62?e.text.charCodeAt(e.pos+1)==32?2:1:-1}function De(e,t,n){if(e.next!=42&&e.next!=45&&e.next!=95)return-1;let r=1;for(let t=e.pos+1;t<e.text.length;t++){let n=e.text.charCodeAt(t);if(n==e.next)r++;else if(!T(n))return-1}return n&&e.next==45&&Me(e)>-1&&e.depth==t.stack.length&&t.parser.leafBlockParsers.indexOf(He.SetextHeading)>-1||r<3?-1:1}function Oe(e,t){for(let n=e.stack.length-1;n>=0;n--)if(e.stack[n].type==t)return!0;return!1}function ke(e,t,n){return(e.next==45||e.next==43||e.next==42)&&(e.pos==e.text.length-1||T(e.text.charCodeAt(e.pos+1)))&&(!n||Oe(t,w.BulletList)||e.skipSpace(e.pos+2)<e.text.length)?1:-1}function Ae(e,t,n){let r=e.pos,i=e.next;for(;i>=48&&i<=57;){if(r++,r==e.text.length)return-1;i=e.text.charCodeAt(r)}return r==e.pos||r>e.pos+9||i!=46&&i!=41||r<e.text.length-1&&!T(e.text.charCodeAt(r+1))||n&&!Oe(t,w.OrderedList)&&(e.skipSpace(r+1)==e.text.length||r>e.pos+1||e.next!=49)?-1:r+1-e.pos}function je(e){if(e.next!=35)return-1;let t=e.pos+1;for(;t<e.text.length&&e.text.charCodeAt(t)==35;)t++;if(t<e.text.length&&e.text.charCodeAt(t)!=32)return-1;let n=t-e.pos;return n>6?-1:n}function Me(e){if(e.next!=45&&e.next!=61||e.indent>=e.baseIndent+4)return-1;let t=e.pos+1;for(;t<e.text.length&&e.text.charCodeAt(t)==e.next;)t++;let n=t;for(;t<e.text.length&&T(e.text.charCodeAt(t));)t++;return t==e.text.length?n:-1}var Ne=/^[ \t]*$/,Pe=/-->/,Fe=/\?>/,Ie=[[/^<(?:script|pre|style)(?:\s|>|$)/i,/<\/(?:script|pre|style)>/i],[/^\s*<!--/,Pe],[/^\s*<\?/,Fe],[/^\s*<![A-Z]/,/>/],[/^\s*<!\[CDATA\[/,/\]\]>/],[/^\s*<\/?(?:address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h1|h2|h3|h4|h5|h6|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul)(?:\s|\/?>|$)/i,Ne],[/^\s*(?:<\/[a-z][\w-]*\s*>|<[a-z][\w-]*(\s+[a-z:_][\w-.]*(?:\s*=\s*(?:[^\s"'=<>`]+|'[^']*'|"[^"]*"))?)*\s*>)\s*$/i,Ne]];function Le(e,t,n){if(e.next!=60)return-1;let r=e.text.slice(e.pos);for(let e=0,t=Ie.length-+!!n;e<t;e++)if(Ie[e][0].test(r))return e;return-1}function Re(e,t){let n=e.countIndent(t,e.pos,e.indent),r=e.skipSpace(t),i=e.countIndent(r,t,n);return i>=n+5||r==e.text.length?n+1:i}function D(e,t,n){let r=e.length-1;r>=0&&e[r].to==t&&e[r].type==w.CodeText?e[r].to=n:e.push(N(w.CodeText,t,n))}var O={LinkReference:void 0,IndentedCode(e,t){let n=t.baseIndent+4;if(t.indent<n)return!1;let r=t.findColumn(n),i=e.lineStart+r,a=e.lineStart+t.text.length,o=[],s=[];for(D(o,i,a);e.nextLine()&&t.depth>=e.stack.length;)if(t.pos==t.text.length){D(s,e.lineStart-1,e.lineStart);for(let e of t.markers)s.push(e)}else if(t.indent<n)break;else{if(s.length){for(let e of s)e.type==w.CodeText?D(o,e.from,e.to):o.push(e);s=[]}D(o,e.lineStart-1,e.lineStart);for(let e of t.markers)o.push(e);a=e.lineStart+t.text.length;let n=e.lineStart+t.findColumn(t.baseIndent+4);n<a&&D(o,n,a)}return s.length&&(s=s.filter(e=>e.type!=w.CodeText),s.length&&(t.markers=s.concat(t.markers))),e.addNode(e.buffer.writeElements(o,-i).finish(w.CodeBlock,a-i),i),!0},FencedCode(e,t){let n=Te(t);if(n<0)return!1;let r=e.lineStart+t.pos,i=t.next,a=n-t.pos,o=t.skipSpace(n),s=we(t.text,t.text.length,o),c=[N(w.CodeMark,r,r+a)];o<s&&c.push(N(w.CodeInfo,e.lineStart+o,e.lineStart+s));for(let n=!0,r=!0,o=!1;e.nextLine()&&t.depth>=e.stack.length;n=!1){let s=t.pos;if(t.indent-t.baseIndent<4)for(;s<t.text.length&&t.text.charCodeAt(s)==i;)s++;if(s-t.pos>=a&&t.skipSpace(s)==t.text.length){for(let e of t.markers)c.push(e);r&&o&&D(c,e.lineStart-1,e.lineStart),c.push(N(w.CodeMark,e.lineStart+t.pos,e.lineStart+s)),e.nextLine();break}{o=!0,n||(D(c,e.lineStart-1,e.lineStart),r=!1);for(let e of t.markers)c.push(e);let i=e.lineStart+t.basePos,a=e.lineStart+t.text.length;i<a&&(D(c,i,a),r=!1)}}return e.addNode(e.buffer.writeElements(c,-r).finish(w.FencedCode,e.prevLineEnd()-r),r),!0},Blockquote(e,t){let n=Ee(t);return n<0?!1:(e.startContext(w.Blockquote,t.pos),e.addNode(w.QuoteMark,e.lineStart+t.pos,e.lineStart+t.pos+1),t.moveBase(t.pos+n),null)},HorizontalRule(e,t){if(De(t,e,!1)<0)return!1;let n=e.lineStart+t.pos;return e.nextLine(),e.addNode(w.HorizontalRule,n),!0},BulletList(e,t){let n=ke(t,e,!1);if(n<0)return!1;e.block.type!=w.BulletList&&e.startContext(w.BulletList,t.basePos,t.next);let r=Re(t,t.pos+1);return e.startContext(w.ListItem,t.basePos,r-t.baseIndent),e.addNode(w.ListMark,e.lineStart+t.pos,e.lineStart+t.pos+n),t.moveBaseColumn(r),null},OrderedList(e,t){let n=Ae(t,e,!1);if(n<0)return!1;e.block.type!=w.OrderedList&&e.startContext(w.OrderedList,t.basePos,t.text.charCodeAt(t.pos+n-1));let r=Re(t,t.pos+n);return e.startContext(w.ListItem,t.basePos,r-t.baseIndent),e.addNode(w.ListMark,e.lineStart+t.pos,e.lineStart+t.pos+n),t.moveBaseColumn(r),null},ATXHeading(e,t){let n=je(t);if(n<0)return!1;let r=t.pos,i=e.lineStart+r,a=we(t.text,t.text.length,r),o=a;for(;o>r&&t.text.charCodeAt(o-1)==t.next;)o--;(o==a||o==r||!T(t.text.charCodeAt(o-1)))&&(o=t.text.length);let s=e.buffer.write(w.HeaderMark,0,n).writeElements(e.parser.parseInline(t.text.slice(r+n+1,o),i+n+1),-i);o<t.text.length&&s.write(w.HeaderMark,o-r,a-r);let c=s.finish(w.ATXHeading1-1+n,t.text.length-r);return e.nextLine(),e.addNode(c,i),!0},HTMLBlock(e,t){let n=Le(t,e,!1);if(n<0)return!1;let r=e.lineStart+t.pos,i=Ie[n][1],a=[],o=i!=Ne;for(;!i.test(t.text)&&e.nextLine();){if(t.depth<e.stack.length){o=!1;break}for(let e of t.markers)a.push(e)}o&&e.nextLine();let s=i==Pe?w.CommentBlock:i==Fe?w.ProcessingInstructionBlock:w.HTMLBlock,c=e.prevLineEnd();return e.addNode(e.buffer.writeElements(a,-r).finish(s,c-r),r),!0},SetextHeading:void 0},ze=class{constructor(e){this.stage=0,this.elts=[],this.pos=0,this.start=e.start,this.advance(e.content)}nextLine(e,t,n){if(this.stage==-1)return!1;let r=n.content+`
1
+ import{C as e,G as t,I as n,M as r,N as i,O as a}from"./index-CxmItXqa.js";import{c as o,d as s,f as c,g as l,i as u,l as d,m as f,o as p,p as m,t as h,u as g}from"./dist-DCtcCJPs.js";import{LRLanguage as ee,Language as te,LanguageDescription as ne,LanguageSupport as _,ParseContext as re,bracketMatchingHandle as ie,continuedIndent as v,defineLanguageFacet as ae,delimitedIndent as oe,flatIndent as se,foldInside as ce,foldNodeProp as y,foldService as le,indentNodeProp as b,indentUnit as ue,languageDataProp as de,sublanguageProp as fe,syntaxTree as x}from"./dist-Tzoe_zm-.js";import{a as pe,c as S,i as me,n as C,o as he,r as ge,s as _e,t as ve}from"./dist-Cw8hRIlT.js";var ye=class e{static create(t,n,r,i,a){let o=i+(i<<8)+t+(n<<4)|0;return new e(t,n,r,o,a,[],[])}constructor(e,t,n,r,i,a,o){this.type=e,this.value=t,this.from=n,this.hash=r,this.end=i,this.children=a,this.positions=o,this.hashProp=[[d.contextHash,r]]}addChild(e,t){e.prop(d.contextHash)!=this.hash&&(e=new f(e.type,e.children,e.positions,e.length,this.hashProp)),this.children.push(e),this.positions.push(t)}toTree(e,t=this.end){let n=this.children.length-1;return n>=0&&(t=Math.max(t,this.positions[n]+this.children[n].length+this.from)),new f(e.types[this.type],this.children,this.positions,t-this.from).balance({makeTree:(e,t,n)=>new f(s.none,e,t,n,this.hashProp)})}},w;(function(e){e[e.Document=1]=`Document`,e[e.CodeBlock=2]=`CodeBlock`,e[e.FencedCode=3]=`FencedCode`,e[e.Blockquote=4]=`Blockquote`,e[e.HorizontalRule=5]=`HorizontalRule`,e[e.BulletList=6]=`BulletList`,e[e.OrderedList=7]=`OrderedList`,e[e.ListItem=8]=`ListItem`,e[e.ATXHeading1=9]=`ATXHeading1`,e[e.ATXHeading2=10]=`ATXHeading2`,e[e.ATXHeading3=11]=`ATXHeading3`,e[e.ATXHeading4=12]=`ATXHeading4`,e[e.ATXHeading5=13]=`ATXHeading5`,e[e.ATXHeading6=14]=`ATXHeading6`,e[e.SetextHeading1=15]=`SetextHeading1`,e[e.SetextHeading2=16]=`SetextHeading2`,e[e.HTMLBlock=17]=`HTMLBlock`,e[e.LinkReference=18]=`LinkReference`,e[e.Paragraph=19]=`Paragraph`,e[e.CommentBlock=20]=`CommentBlock`,e[e.ProcessingInstructionBlock=21]=`ProcessingInstructionBlock`,e[e.Escape=22]=`Escape`,e[e.Entity=23]=`Entity`,e[e.HardBreak=24]=`HardBreak`,e[e.Emphasis=25]=`Emphasis`,e[e.StrongEmphasis=26]=`StrongEmphasis`,e[e.Link=27]=`Link`,e[e.Image=28]=`Image`,e[e.InlineCode=29]=`InlineCode`,e[e.HTMLTag=30]=`HTMLTag`,e[e.Comment=31]=`Comment`,e[e.ProcessingInstruction=32]=`ProcessingInstruction`,e[e.Autolink=33]=`Autolink`,e[e.HeaderMark=34]=`HeaderMark`,e[e.QuoteMark=35]=`QuoteMark`,e[e.ListMark=36]=`ListMark`,e[e.LinkMark=37]=`LinkMark`,e[e.EmphasisMark=38]=`EmphasisMark`,e[e.CodeMark=39]=`CodeMark`,e[e.CodeText=40]=`CodeText`,e[e.CodeInfo=41]=`CodeInfo`,e[e.LinkTitle=42]=`LinkTitle`,e[e.LinkLabel=43]=`LinkLabel`,e[e.URL=44]=`URL`})(w||={});var be=class{constructor(e,t){this.start=e,this.content=t,this.marks=[],this.parsers=[]}},xe=class{constructor(){this.text=``,this.baseIndent=0,this.basePos=0,this.depth=0,this.markers=[],this.pos=0,this.indent=0,this.next=-1}forward(){this.basePos>this.pos&&this.forwardInner()}forwardInner(){let e=this.skipSpace(this.basePos);this.indent=this.countIndent(e,this.pos,this.indent),this.pos=e,this.next=e==this.text.length?-1:this.text.charCodeAt(e)}skipSpace(e){return E(this.text,e)}reset(e){for(this.text=e,this.baseIndent=this.basePos=this.pos=this.indent=0,this.forwardInner(),this.depth=1;this.markers.length;)this.markers.pop()}moveBase(e){this.basePos=e,this.baseIndent=this.countIndent(e,this.pos,this.indent)}moveBaseColumn(e){this.baseIndent=e,this.basePos=this.findColumn(e)}addMarker(e){this.markers.push(e)}countIndent(e,t=0,n=0){for(let r=t;r<e;r++)n+=this.text.charCodeAt(r)==9?4-n%4:1;return n}findColumn(e){let t=0;for(let n=0;t<this.text.length&&n<e;t++)n+=this.text.charCodeAt(t)==9?4-n%4:1;return t}scrub(){if(!this.baseIndent)return this.text;let e=``;for(let t=0;t<this.basePos;t++)e+=` `;return e+this.text.slice(this.basePos)}};function Se(e,t,n){if(n.pos==n.text.length||e!=t.block&&n.indent>=t.stack[n.depth+1].value+n.baseIndent)return!0;if(n.indent>=n.baseIndent+4)return!1;let r=(e.type==w.OrderedList?Ae:ke)(n,t,!1);return r>0&&(e.type!=w.BulletList||De(n,t,!1)<0)&&n.text.charCodeAt(n.pos+r-1)==e.value}var Ce={[w.Blockquote](e,t,n){return n.next==62&&(n.markers.push(N(w.QuoteMark,t.lineStart+n.pos,t.lineStart+n.pos+1)),n.moveBase(n.pos+(T(n.text.charCodeAt(n.pos+1))?2:1)),e.end=t.lineStart+n.text.length,!0)},[w.ListItem](e,t,n){return n.indent<n.baseIndent+e.value&&n.next>-1?!1:(n.moveBaseColumn(n.baseIndent+e.value),!0)},[w.OrderedList]:Se,[w.BulletList]:Se,[w.Document](){return!0}};function T(e){return e==32||e==9||e==10||e==13}function E(e,t=0){for(;t<e.length&&T(e.charCodeAt(t));)t++;return t}function we(e,t,n){for(;t>n&&T(e.charCodeAt(t-1));)t--;return t}function Te(e){if(e.next!=96&&e.next!=126)return-1;let t=e.pos+1;for(;t<e.text.length&&e.text.charCodeAt(t)==e.next;)t++;if(t<e.pos+3)return-1;if(e.next==96){for(let n=t;n<e.text.length;n++)if(e.text.charCodeAt(n)==96)return-1}return t}function Ee(e){return e.next==62?e.text.charCodeAt(e.pos+1)==32?2:1:-1}function De(e,t,n){if(e.next!=42&&e.next!=45&&e.next!=95)return-1;let r=1;for(let t=e.pos+1;t<e.text.length;t++){let n=e.text.charCodeAt(t);if(n==e.next)r++;else if(!T(n))return-1}return n&&e.next==45&&Me(e)>-1&&e.depth==t.stack.length&&t.parser.leafBlockParsers.indexOf(He.SetextHeading)>-1||r<3?-1:1}function Oe(e,t){for(let n=e.stack.length-1;n>=0;n--)if(e.stack[n].type==t)return!0;return!1}function ke(e,t,n){return(e.next==45||e.next==43||e.next==42)&&(e.pos==e.text.length-1||T(e.text.charCodeAt(e.pos+1)))&&(!n||Oe(t,w.BulletList)||e.skipSpace(e.pos+2)<e.text.length)?1:-1}function Ae(e,t,n){let r=e.pos,i=e.next;for(;i>=48&&i<=57;){if(r++,r==e.text.length)return-1;i=e.text.charCodeAt(r)}return r==e.pos||r>e.pos+9||i!=46&&i!=41||r<e.text.length-1&&!T(e.text.charCodeAt(r+1))||n&&!Oe(t,w.OrderedList)&&(e.skipSpace(r+1)==e.text.length||r>e.pos+1||e.next!=49)?-1:r+1-e.pos}function je(e){if(e.next!=35)return-1;let t=e.pos+1;for(;t<e.text.length&&e.text.charCodeAt(t)==35;)t++;if(t<e.text.length&&e.text.charCodeAt(t)!=32)return-1;let n=t-e.pos;return n>6?-1:n}function Me(e){if(e.next!=45&&e.next!=61||e.indent>=e.baseIndent+4)return-1;let t=e.pos+1;for(;t<e.text.length&&e.text.charCodeAt(t)==e.next;)t++;let n=t;for(;t<e.text.length&&T(e.text.charCodeAt(t));)t++;return t==e.text.length?n:-1}var Ne=/^[ \t]*$/,Pe=/-->/,Fe=/\?>/,Ie=[[/^<(?:script|pre|style)(?:\s|>|$)/i,/<\/(?:script|pre|style)>/i],[/^\s*<!--/,Pe],[/^\s*<\?/,Fe],[/^\s*<![A-Z]/,/>/],[/^\s*<!\[CDATA\[/,/\]\]>/],[/^\s*<\/?(?:address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h1|h2|h3|h4|h5|h6|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul)(?:\s|\/?>|$)/i,Ne],[/^\s*(?:<\/[a-z][\w-]*\s*>|<[a-z][\w-]*(\s+[a-z:_][\w-.]*(?:\s*=\s*(?:[^\s"'=<>`]+|'[^']*'|"[^"]*"))?)*\s*>)\s*$/i,Ne]];function Le(e,t,n){if(e.next!=60)return-1;let r=e.text.slice(e.pos);for(let e=0,t=Ie.length-+!!n;e<t;e++)if(Ie[e][0].test(r))return e;return-1}function Re(e,t){let n=e.countIndent(t,e.pos,e.indent),r=e.skipSpace(t),i=e.countIndent(r,t,n);return i>=n+5||r==e.text.length?n+1:i}function D(e,t,n){let r=e.length-1;r>=0&&e[r].to==t&&e[r].type==w.CodeText?e[r].to=n:e.push(N(w.CodeText,t,n))}var O={LinkReference:void 0,IndentedCode(e,t){let n=t.baseIndent+4;if(t.indent<n)return!1;let r=t.findColumn(n),i=e.lineStart+r,a=e.lineStart+t.text.length,o=[],s=[];for(D(o,i,a);e.nextLine()&&t.depth>=e.stack.length;)if(t.pos==t.text.length){D(s,e.lineStart-1,e.lineStart);for(let e of t.markers)s.push(e)}else if(t.indent<n)break;else{if(s.length){for(let e of s)e.type==w.CodeText?D(o,e.from,e.to):o.push(e);s=[]}D(o,e.lineStart-1,e.lineStart);for(let e of t.markers)o.push(e);a=e.lineStart+t.text.length;let n=e.lineStart+t.findColumn(t.baseIndent+4);n<a&&D(o,n,a)}return s.length&&(s=s.filter(e=>e.type!=w.CodeText),s.length&&(t.markers=s.concat(t.markers))),e.addNode(e.buffer.writeElements(o,-i).finish(w.CodeBlock,a-i),i),!0},FencedCode(e,t){let n=Te(t);if(n<0)return!1;let r=e.lineStart+t.pos,i=t.next,a=n-t.pos,o=t.skipSpace(n),s=we(t.text,t.text.length,o),c=[N(w.CodeMark,r,r+a)];o<s&&c.push(N(w.CodeInfo,e.lineStart+o,e.lineStart+s));for(let n=!0,r=!0,o=!1;e.nextLine()&&t.depth>=e.stack.length;n=!1){let s=t.pos;if(t.indent-t.baseIndent<4)for(;s<t.text.length&&t.text.charCodeAt(s)==i;)s++;if(s-t.pos>=a&&t.skipSpace(s)==t.text.length){for(let e of t.markers)c.push(e);r&&o&&D(c,e.lineStart-1,e.lineStart),c.push(N(w.CodeMark,e.lineStart+t.pos,e.lineStart+s)),e.nextLine();break}{o=!0,n||(D(c,e.lineStart-1,e.lineStart),r=!1);for(let e of t.markers)c.push(e);let i=e.lineStart+t.basePos,a=e.lineStart+t.text.length;i<a&&(D(c,i,a),r=!1)}}return e.addNode(e.buffer.writeElements(c,-r).finish(w.FencedCode,e.prevLineEnd()-r),r),!0},Blockquote(e,t){let n=Ee(t);return n<0?!1:(e.startContext(w.Blockquote,t.pos),e.addNode(w.QuoteMark,e.lineStart+t.pos,e.lineStart+t.pos+1),t.moveBase(t.pos+n),null)},HorizontalRule(e,t){if(De(t,e,!1)<0)return!1;let n=e.lineStart+t.pos;return e.nextLine(),e.addNode(w.HorizontalRule,n),!0},BulletList(e,t){let n=ke(t,e,!1);if(n<0)return!1;e.block.type!=w.BulletList&&e.startContext(w.BulletList,t.basePos,t.next);let r=Re(t,t.pos+1);return e.startContext(w.ListItem,t.basePos,r-t.baseIndent),e.addNode(w.ListMark,e.lineStart+t.pos,e.lineStart+t.pos+n),t.moveBaseColumn(r),null},OrderedList(e,t){let n=Ae(t,e,!1);if(n<0)return!1;e.block.type!=w.OrderedList&&e.startContext(w.OrderedList,t.basePos,t.text.charCodeAt(t.pos+n-1));let r=Re(t,t.pos+n);return e.startContext(w.ListItem,t.basePos,r-t.baseIndent),e.addNode(w.ListMark,e.lineStart+t.pos,e.lineStart+t.pos+n),t.moveBaseColumn(r),null},ATXHeading(e,t){let n=je(t);if(n<0)return!1;let r=t.pos,i=e.lineStart+r,a=we(t.text,t.text.length,r),o=a;for(;o>r&&t.text.charCodeAt(o-1)==t.next;)o--;(o==a||o==r||!T(t.text.charCodeAt(o-1)))&&(o=t.text.length);let s=e.buffer.write(w.HeaderMark,0,n).writeElements(e.parser.parseInline(t.text.slice(r+n+1,o),i+n+1),-i);o<t.text.length&&s.write(w.HeaderMark,o-r,a-r);let c=s.finish(w.ATXHeading1-1+n,t.text.length-r);return e.nextLine(),e.addNode(c,i),!0},HTMLBlock(e,t){let n=Le(t,e,!1);if(n<0)return!1;let r=e.lineStart+t.pos,i=Ie[n][1],a=[],o=i!=Ne;for(;!i.test(t.text)&&e.nextLine();){if(t.depth<e.stack.length){o=!1;break}for(let e of t.markers)a.push(e)}o&&e.nextLine();let s=i==Pe?w.CommentBlock:i==Fe?w.ProcessingInstructionBlock:w.HTMLBlock,c=e.prevLineEnd();return e.addNode(e.buffer.writeElements(a,-r).finish(s,c-r),r),!0},SetextHeading:void 0},ze=class{constructor(e){this.stage=0,this.elts=[],this.pos=0,this.start=e.start,this.advance(e.content)}nextLine(e,t,n){if(this.stage==-1)return!1;let r=n.content+`
2
2
  `+t.scrub(),i=this.advance(r);return i>-1&&i<r.length&&this.complete(e,n,i)}finish(e,t){return(this.stage==2||this.stage==3)&&E(t.content,this.pos)==t.content.length&&this.complete(e,t,t.content.length)}complete(e,t,n){return e.addLeafElement(t,N(w.LinkReference,this.start,this.start+n,this.elts)),!0}nextStage(e){return e?(this.pos=e.to-this.start,this.elts.push(e),this.stage++,!0):(e===!1&&(this.stage=-1),!1)}advance(e){for(;;)if(this.stage==-1)return-1;else if(this.stage==0){if(!this.nextStage(at(e,this.pos,this.start,!0)))return-1;if(e.charCodeAt(this.pos)!=58)return this.stage=-1;this.elts.push(N(w.LinkMark,this.pos+this.start,this.pos+this.start+1)),this.pos++}else if(this.stage==1){if(!this.nextStage(rt(e,E(e,this.pos),this.start)))return-1}else if(this.stage==2){let t=E(e,this.pos),n=0;if(t>this.pos){let r=it(e,t,this.start);if(r){let t=Be(e,r.to-this.start);t>0&&(this.nextStage(r),n=t)}}return n||=Be(e,this.pos),n>0&&n<e.length?n:-1}else return Be(e,this.pos)}};function Be(e,t){for(;t<e.length;t++){let n=e.charCodeAt(t);if(n==10)break;if(!T(n))return-1}return t}var Ve=class{nextLine(e,t,n){let r=t.depth<e.stack.length?-1:Me(t),i=t.next;if(r<0)return!1;let a=N(w.HeaderMark,e.lineStart+t.pos,e.lineStart+r);return e.nextLine(),e.addLeafElement(n,N(i==61?w.SetextHeading1:w.SetextHeading2,n.start,e.prevLineEnd(),[...e.parser.parseInline(n.content,n.start),a])),!0}finish(){return!1}},He={LinkReference(e,t){return t.content.charCodeAt(0)==91?new ze(t):null},SetextHeading(){return new Ve}},Ue=[(e,t)=>je(t)>=0,(e,t)=>Te(t)>=0,(e,t)=>Ee(t)>=0,(e,t)=>ke(t,e,!0)>=0,(e,t)=>Ae(t,e,!0)>=0,(e,t)=>De(t,e,!0)>=0,(e,t)=>Le(t,e,!0)>=0],We={text:``,end:0},Ge=class{constructor(e,t,n,r){this.parser=e,this.input=t,this.ranges=r,this.line=new xe,this.atEnd=!1,this.reusePlaceholders=new Map,this.stoppedAt=null,this.rangeI=0,this.to=r[r.length-1].to,this.lineStart=this.absoluteLineStart=this.absoluteLineEnd=r[0].from,this.block=ye.create(w.Document,0,this.lineStart,0,0),this.stack=[this.block],this.fragments=n.length?new ct(n,t):null,this.readLine()}get parsedPos(){return this.absoluteLineStart}advance(){if(this.stoppedAt!=null&&this.absoluteLineStart>this.stoppedAt)return this.finish();let{line:e}=this;for(;;){for(let t=0;;){let n=e.depth<this.stack.length?this.stack[this.stack.length-1]:null;for(;t<e.markers.length&&(!n||e.markers[t].from<n.end);){let n=e.markers[t++];this.addNode(n.type,n.from,n.to)}if(!n)break;this.finishContext()}if(e.pos<e.text.length)break;if(!this.nextLine())return this.finish()}if(this.fragments&&this.reuseFragment(e.basePos))return null;start:for(;;){for(let t of this.parser.blockParsers)if(t){let n=t(this,e);if(n!=0){if(n==1)return null;e.forward();continue start}}break}if(e.pos==e.text.length)return this.nextLine()?null:this.finish();let t=new be(this.lineStart+e.pos,e.text.slice(e.pos));for(let e of this.parser.leafBlockParsers)if(e){let n=e(this,t);n&&t.parsers.push(n)}lines:for(;this.nextLine()&&e.pos!=e.text.length;){if(e.indent<e.baseIndent+4){for(let n of this.parser.endLeafBlock)if(n(this,e,t))break lines}for(let n of t.parsers)if(n.nextLine(this,e,t))return null;t.content+=`
3
3
  `+e.scrub();for(let n of e.markers)t.marks.push(n)}return this.finishLeaf(t),null}stopAt(e){if(this.stoppedAt!=null&&this.stoppedAt<e)throw RangeError(`Can't move stoppedAt forward`);this.stoppedAt=e}reuseFragment(e){if(!this.fragments.moveTo(this.absoluteLineStart+e,this.absoluteLineStart)||!this.fragments.matches(this.block.hash))return!1;let t=this.fragments.takeNodes(this);return t?(this.absoluteLineStart+=t,this.lineStart=lt(this.absoluteLineStart,this.ranges),this.moveRangeI(),this.absoluteLineStart<this.to?(this.lineStart++,this.absoluteLineStart++,this.readLine()):(this.atEnd=!0,this.readLine()),!0):!1}get depth(){return this.stack.length}parentType(e=this.depth-1){return this.parser.nodeSet.types[this.stack[e].type]}nextLine(){return this.lineStart+=this.line.text.length,this.absoluteLineEnd>=this.to?(this.absoluteLineStart=this.absoluteLineEnd,this.atEnd=!0,this.readLine(),!1):(this.lineStart++,this.absoluteLineStart=this.absoluteLineEnd+1,this.moveRangeI(),this.readLine(),!0)}peekLine(){return this.scanLine(this.absoluteLineEnd+1).text}moveRangeI(){for(;this.rangeI<this.ranges.length-1&&this.absoluteLineStart>=this.ranges[this.rangeI].to;)this.rangeI++,this.absoluteLineStart=Math.max(this.absoluteLineStart,this.ranges[this.rangeI].from)}scanLine(e){let t=We;if(t.end=e,e>=this.to)t.text=``;else if(t.text=this.lineChunkAt(e),t.end+=t.text.length,this.ranges.length>1){let e=this.absoluteLineStart,n=this.rangeI;for(;this.ranges[n].to<t.end;){n++;let r=this.ranges[n].from,i=this.lineChunkAt(r);t.end=r+i.length,t.text=t.text.slice(0,this.ranges[n-1].to-e)+i,e=t.end-t.text.length}}return t}readLine(){let{line:e}=this,{text:t,end:n}=this.scanLine(this.absoluteLineStart);for(this.absoluteLineEnd=n,e.reset(t);e.depth<this.stack.length;e.depth++){let t=this.stack[e.depth],n=this.parser.skipContextMarkup[t.type];if(!n)throw Error(`Unhandled block context `+w[t.type]);let r=this.line.markers.length;if(!n(t,this,e)){this.line.markers.length>r&&(t.end=this.line.markers[this.line.markers.length-1].to),e.forward();break}e.forward()}}lineChunkAt(e){let t=this.input.chunk(e),n;if(this.input.lineChunks)n=t==`
4
4
  `?``:t;else{let e=t.indexOf(`
@@ -25,4 +25,4 @@ import{B as e,D as t,I as n,L as r,M as i,Y as a}from"./index-BYuKpyoi.js";impor
25
25
  \${}
26
26
  }`,{label:`interface`,detail:`definition`,type:`keyword`}),S("type ${name} = ${type}",{label:`type`,detail:`definition`,type:`keyword`}),S(`enum \${name} {
27
27
  \${}
28
- }`,{label:`enum`,detail:`definition`,type:`keyword`})]),Ti=new c,Ei=new Set([`Script`,`Block`,`FunctionExpression`,`FunctionDeclaration`,`ArrowFunction`,`MethodDeclaration`,`ForStatement`]);function G(e){return(t,n)=>{let r=t.node.getChild(`VariableDefinition`);return r&&n(r,e),!0}}var Di=[`FunctionDeclaration`],Oi={FunctionDeclaration:G(`function`),ClassDeclaration:G(`class`),ClassExpression:()=>!0,EnumDeclaration:G(`constant`),TypeAliasDeclaration:G(`type`),NamespaceDeclaration:G(`namespace`),VariableDefinition(e,t){e.matchContext(Di)||t(e,`variable`)},TypeDefinition(e,t){t(e,`type`)},__proto__:null};function ki(e,t){let n=Ti.get(t);if(n)return n;let r=[],i=!0;function a(t,n){let i=e.sliceString(t.from,t.to);r.push({label:i,type:n})}return t.cursor(o.IncludeAnonymous).iterate(t=>{if(i)i=!1;else if(t.name){let e=Oi[t.name];if(e&&e(t,a)||Ei.has(t.name))return!1}else if(t.to-t.from>8192){for(let n of ki(e,t.node))r.push(n);return!1}}),Ti.set(t,r),r}var Ai=/^[\w$\xa1-\uffff][\w$\d\xa1-\uffff]*$/,ji=[`TemplateString`,`String`,`RegExp`,`LineComment`,`BlockComment`,`VariableDefinition`,`TypeDefinition`,`Label`,`PropertyDefinition`,`PropertyName`,`PrivatePropertyDefinition`,`PrivatePropertyName`,`JSXText`,`JSXAttributeValue`,`JSXOpenTag`,`JSXCloseTag`,`JSXSelfClosingTag`,`.`,`?.`];function Mi(e){let t=x(e.state).resolveInner(e.pos,-1);if(ji.indexOf(t.name)>-1)return null;let n=t.name==`VariableName`||t.to-t.from<20&&Ai.test(e.state.sliceDoc(t.from,t.to));if(!n&&!e.explicit)return null;let r=[];for(let n=t;n;n=n.parent)Ei.has(n.name)&&(r=r.concat(ki(e.state.doc,n)));return{options:r,from:n?t.from:e.pos,validFor:Ai}}var K=ee.define({name:`javascript`,parser:Si.configure({props:[b.add({IfStatement:v({except:/^\s*({|else\b)/}),TryStatement:v({except:/^\s*({|catch\b|finally\b)/}),LabeledStatement:se,SwitchBody:e=>{let t=e.textAfter,n=/^\s*\}/.test(t),r=/^\s*(case|default)\b/.test(t);return e.baseIndent+(n?0:r?1:2)*e.unit},Block:oe({closing:`}`}),ArrowFunction:e=>e.baseIndent+e.unit,"TemplateString BlockComment":()=>null,"Statement Property":v({except:/^\s*{/}),JSXElement(e){let t=/^\s*<\//.test(e.textAfter);return e.lineIndent(e.node.from)+(t?0:e.unit)},JSXEscape(e){let t=/\s*\}/.test(e.textAfter);return e.lineIndent(e.node.from)+(t?0:e.unit)},"JSXOpenTag JSXSelfClosingTag"(e){return e.column(e.node.from)+e.unit}}),y.add({"Block ClassBody SwitchBody EnumBody ObjectExpression ArrayExpression ObjectType":ce,BlockComment(e){return{from:e.from+2,to:e.to-2}},JSXElement(e){let t=e.firstChild;if(!t||t.name==`JSXSelfClosingTag`)return null;let n=e.lastChild;return{from:t.to,to:n.type.isError?e.to:n.from}},"JSXSelfClosingTag JSXOpenTag"(e){let t=e.firstChild?.nextSibling,n=e.lastChild;return!t||t.type.isError?null:{from:t.to,to:n.type.isError?e.to:n.from}}})]}),languageData:{closeBrackets:{brackets:[`(`,`[`,`{`,`'`,`"`,"`"]},commentTokens:{line:`//`,block:{open:`/*`,close:`*/`}},indentOnInput:/^\s*(?:case |default:|\{|\}|<\/)$/,wordChars:`$`}}),Ni={test:e=>/^JSX/.test(e.name),facet:ae({commentTokens:{block:{open:`{/*`,close:`*/}`}}})},Pi=K.configure({dialect:`ts`},`typescript`),Fi=K.configure({dialect:`jsx`,props:[fe.add(e=>e.isTop?[Ni]:void 0)]}),Ii=K.configure({dialect:`jsx ts`,props:[fe.add(e=>e.isTop?[Ni]:void 0)]},`typescript`),Li=e=>({label:e,type:`keyword`}),Ri=`break case const continue default delete export extends false finally in instanceof let new return static super switch this throw true typeof var yield`.split(` `).map(Li),zi=Ri.concat([`declare`,`implements`,`private`,`protected`,`public`].map(Li));function Bi(e={}){let t=e.jsx?e.typescript?Ii:Fi:e.typescript?Pi:K,n=e.typescript?wi.concat(zi):Ci.concat(Ri);return new _(t,[K.data.of({autocomplete:_e(ji,he(n))}),K.data.of({autocomplete:Mi}),e.jsx?Wi:[]])}function Vi(e){for(;;){if(e.name==`JSXOpenTag`||e.name==`JSXSelfClosingTag`||e.name==`JSXFragmentTag`)return e;if(e.name==`JSXEscape`||!e.parent)return null;e=e.parent}}function Hi(e,t,n=e.length){for(let r=t?.firstChild;r;r=r.nextSibling)if(r.name==`JSXIdentifier`||r.name==`JSXBuiltin`||r.name==`JSXNamespacedName`||r.name==`JSXMemberExpression`)return e.sliceString(r.from,Math.min(r.to,n));return``}var Ui=typeof navigator==`object`&&/Android\b/.test(navigator.userAgent),Wi=t.inputHandler.of((e,t,r,i,a)=>{if((Ui?e.composing:e.compositionStarted)||e.state.readOnly||t!=r||i!=`>`&&i!=`/`||!K.isActiveAt(e.state,t,-1))return!1;let o=a(),{state:s}=o,c=s.changeByRange(e=>{let{head:t}=e,r=x(s).resolveInner(t-1,-1),a;if(r.name==`JSXStartTag`&&(r=r.parent),!(s.doc.sliceString(t-1,t)!=i||r.name==`JSXAttributeValue`&&r.to>t)){if(i==`>`&&r.name==`JSXFragmentTag`)return{range:e,changes:{from:t,insert:`</>`}};if(i==`/`&&r.name==`JSXStartCloseTag`){let e=r.parent,i=e.parent;if(i&&e.from==t-2&&((a=Hi(s.doc,i.firstChild,t))||i.firstChild?.name==`JSXFragmentTag`)){let e=`${a}>`;return{range:n.cursor(t+e.length,-1),changes:{from:t,insert:e}}}}else if(i==`>`){let n=Vi(r);if(n&&n.name==`JSXOpenTag`&&!/^\/?>|^<\//.test(s.doc.sliceString(t,t+2))&&(a=Hi(s.doc,n,t)))return{range:e,changes:{from:t,insert:`</${a}>`}}}}return{range:e}});return!c.changes.empty&&(e.dispatch([o,s.update(c,{userEvent:`input.complete`,scrollIntoView:!0})]),!0)}),q=[`_blank`,`_self`,`_top`,`_parent`],Gi=[`ascii`,`utf-8`,`utf-16`,`latin1`,`latin1`],Ki=[`get`,`post`,`put`,`delete`],qi=[`application/x-www-form-urlencoded`,`multipart/form-data`,`text/plain`],J=[`true`,`false`],Y={},Ji={a:{attrs:{href:null,ping:null,type:null,media:null,target:q,hreflang:null}},abbr:Y,address:Y,area:{attrs:{alt:null,coords:null,href:null,target:null,ping:null,media:null,hreflang:null,type:null,shape:[`default`,`rect`,`circle`,`poly`]}},article:Y,aside:Y,audio:{attrs:{src:null,mediagroup:null,crossorigin:[`anonymous`,`use-credentials`],preload:[`none`,`metadata`,`auto`],autoplay:[`autoplay`],loop:[`loop`],controls:[`controls`]}},b:Y,base:{attrs:{href:null,target:q}},bdi:Y,bdo:Y,blockquote:{attrs:{cite:null}},body:Y,br:Y,button:{attrs:{form:null,formaction:null,name:null,value:null,autofocus:[`autofocus`],disabled:[`autofocus`],formenctype:qi,formmethod:Ki,formnovalidate:[`novalidate`],formtarget:q,type:[`submit`,`reset`,`button`]}},canvas:{attrs:{width:null,height:null}},caption:Y,center:Y,cite:Y,code:Y,col:{attrs:{span:null}},colgroup:{attrs:{span:null}},command:{attrs:{type:[`command`,`checkbox`,`radio`],label:null,icon:null,radiogroup:null,command:null,title:null,disabled:[`disabled`],checked:[`checked`]}},data:{attrs:{value:null}},datagrid:{attrs:{disabled:[`disabled`],multiple:[`multiple`]}},datalist:{attrs:{data:null}},dd:Y,del:{attrs:{cite:null,datetime:null}},details:{attrs:{open:[`open`]}},dfn:Y,div:Y,dl:Y,dt:Y,em:Y,embed:{attrs:{src:null,type:null,width:null,height:null}},eventsource:{attrs:{src:null}},fieldset:{attrs:{disabled:[`disabled`],form:null,name:null}},figcaption:Y,figure:Y,footer:Y,form:{attrs:{action:null,name:null,"accept-charset":Gi,autocomplete:[`on`,`off`],enctype:qi,method:Ki,novalidate:[`novalidate`],target:q}},h1:Y,h2:Y,h3:Y,h4:Y,h5:Y,h6:Y,head:{children:[`title`,`base`,`link`,`style`,`meta`,`script`,`noscript`,`command`]},header:Y,hgroup:Y,hr:Y,html:{attrs:{manifest:null}},i:Y,iframe:{attrs:{src:null,srcdoc:null,name:null,width:null,height:null,sandbox:[`allow-top-navigation`,`allow-same-origin`,`allow-forms`,`allow-scripts`],seamless:[`seamless`]}},img:{attrs:{alt:null,src:null,ismap:null,usemap:null,width:null,height:null,crossorigin:[`anonymous`,`use-credentials`]}},input:{attrs:{alt:null,dirname:null,form:null,formaction:null,height:null,list:null,max:null,maxlength:null,min:null,name:null,pattern:null,placeholder:null,size:null,src:null,step:null,value:null,width:null,accept:[`audio/*`,`video/*`,`image/*`],autocomplete:[`on`,`off`],autofocus:[`autofocus`],checked:[`checked`],disabled:[`disabled`],formenctype:qi,formmethod:Ki,formnovalidate:[`novalidate`],formtarget:q,multiple:[`multiple`],readonly:[`readonly`],required:[`required`],type:[`hidden`,`text`,`search`,`tel`,`url`,`email`,`password`,`datetime`,`date`,`month`,`week`,`time`,`datetime-local`,`number`,`range`,`color`,`checkbox`,`radio`,`file`,`submit`,`image`,`reset`,`button`]}},ins:{attrs:{cite:null,datetime:null}},kbd:Y,keygen:{attrs:{challenge:null,form:null,name:null,autofocus:[`autofocus`],disabled:[`disabled`],keytype:[`RSA`]}},label:{attrs:{for:null,form:null}},legend:Y,li:{attrs:{value:null}},link:{attrs:{href:null,type:null,hreflang:null,media:null,sizes:[`all`,`16x16`,`16x16 32x32`,`16x16 32x32 64x64`]}},map:{attrs:{name:null}},mark:Y,menu:{attrs:{label:null,type:[`list`,`context`,`toolbar`]}},meta:{attrs:{content:null,charset:Gi,name:[`viewport`,`application-name`,`author`,`description`,`generator`,`keywords`],"http-equiv":[`content-language`,`content-type`,`default-style`,`refresh`]}},meter:{attrs:{value:null,min:null,low:null,high:null,max:null,optimum:null}},nav:Y,noscript:Y,object:{attrs:{data:null,type:null,name:null,usemap:null,form:null,width:null,height:null,typemustmatch:[`typemustmatch`]}},ol:{attrs:{reversed:[`reversed`],start:null,type:[`1`,`a`,`A`,`i`,`I`]},children:[`li`,`script`,`template`,`ul`,`ol`]},optgroup:{attrs:{disabled:[`disabled`],label:null}},option:{attrs:{disabled:[`disabled`],label:null,selected:[`selected`],value:null}},output:{attrs:{for:null,form:null,name:null}},p:Y,param:{attrs:{name:null,value:null}},pre:Y,progress:{attrs:{value:null,max:null}},q:{attrs:{cite:null}},rp:Y,rt:Y,ruby:Y,samp:Y,script:{attrs:{type:[`text/javascript`],src:null,async:[`async`],defer:[`defer`],charset:Gi}},section:Y,select:{attrs:{form:null,name:null,size:null,autofocus:[`autofocus`],disabled:[`disabled`],multiple:[`multiple`]}},slot:{attrs:{name:null}},small:Y,source:{attrs:{src:null,type:null,media:null}},span:Y,strong:Y,style:{attrs:{type:[`text/css`],media:null,scoped:null}},sub:Y,summary:Y,sup:Y,table:Y,tbody:Y,td:{attrs:{colspan:null,rowspan:null,headers:null}},template:Y,textarea:{attrs:{dirname:null,form:null,maxlength:null,name:null,placeholder:null,rows:null,cols:null,autofocus:[`autofocus`],disabled:[`disabled`],readonly:[`readonly`],required:[`required`],wrap:[`soft`,`hard`]}},tfoot:Y,th:{attrs:{colspan:null,rowspan:null,headers:null,scope:[`row`,`col`,`rowgroup`,`colgroup`]}},thead:Y,time:{attrs:{datetime:null}},title:Y,tr:Y,track:{attrs:{src:null,label:null,default:null,kind:[`subtitles`,`captions`,`descriptions`,`chapters`,`metadata`],srclang:null}},ul:{children:[`li`,`script`,`template`,`ul`,`ol`]},var:Y,video:{attrs:{src:null,poster:null,width:null,height:null,crossorigin:[`anonymous`,`use-credentials`],preload:[`auto`,`metadata`,`none`],autoplay:[`autoplay`],mediagroup:[`movie`],muted:[`muted`],controls:[`controls`]}},wbr:Y},Yi={accesskey:null,class:null,contenteditable:J,contextmenu:null,dir:[`ltr`,`rtl`,`auto`],draggable:[`true`,`false`,`auto`],dropzone:[`copy`,`move`,`link`,`string:`,`file:`],hidden:[`hidden`],id:null,inert:[`inert`],itemid:null,itemprop:null,itemref:null,itemscope:[`itemscope`],itemtype:null,lang:[`ar`,`bn`,`de`,`en-GB`,`en-US`,`es`,`fr`,`hi`,`id`,`ja`,`pa`,`pt`,`ru`,`tr`,`zh`],spellcheck:J,autocorrect:J,autocapitalize:J,style:null,tabindex:null,title:null,translate:[`yes`,`no`],rel:[`stylesheet`,`alternate`,`author`,`bookmark`,`help`,`license`,`next`,`nofollow`,`noreferrer`,`prefetch`,`prev`,`search`,`tag`],role:`alert application article banner button cell checkbox complementary contentinfo dialog document feed figure form grid gridcell heading img list listbox listitem main navigation region row rowgroup search switch tab table tabpanel textbox timer`.split(` `),"aria-activedescendant":null,"aria-atomic":J,"aria-autocomplete":[`inline`,`list`,`both`,`none`],"aria-busy":J,"aria-checked":[`true`,`false`,`mixed`,`undefined`],"aria-controls":null,"aria-describedby":null,"aria-disabled":J,"aria-dropeffect":null,"aria-expanded":[`true`,`false`,`undefined`],"aria-flowto":null,"aria-grabbed":[`true`,`false`,`undefined`],"aria-haspopup":J,"aria-hidden":J,"aria-invalid":[`true`,`false`,`grammar`,`spelling`],"aria-label":null,"aria-labelledby":null,"aria-level":null,"aria-live":[`off`,`polite`,`assertive`],"aria-multiline":J,"aria-multiselectable":J,"aria-owns":null,"aria-posinset":null,"aria-pressed":[`true`,`false`,`mixed`,`undefined`],"aria-readonly":J,"aria-relevant":null,"aria-required":J,"aria-selected":[`true`,`false`,`undefined`],"aria-setsize":null,"aria-sort":[`ascending`,`descending`,`none`,`other`],"aria-valuemax":null,"aria-valuemin":null,"aria-valuenow":null,"aria-valuetext":null},Xi=`beforeunload copy cut dragstart dragover dragleave dragenter dragend drag paste focus blur change click load mousedown mouseenter mouseleave mouseup keydown keyup resize scroll unload`.split(` `).map(e=>`on`+e);for(let e of Xi)Yi[e]=null;var X=class{constructor(e,t){this.tags={...Ji,...e},this.globalAttrs={...Yi,...t},this.allTags=Object.keys(this.tags),this.globalAttrNames=Object.keys(this.globalAttrs)}};X.default=new X;function Z(e,t,n=e.length){if(!t)return``;let r=t.firstChild,i=r&&r.getChild(`TagName`);return i?e.sliceString(i.from,Math.min(i.to,n)):``}function Q(e,t=!1){for(;e;e=e.parent)if(e.name==`Element`){if(t)t=!1;else return e}return null}function Zi(e,t,n){return n.tags[Z(e,Q(t))]?.children||n.allTags}function Qi(e,t){let n=[];for(let r=Q(t);r&&!r.type.isTop;r=Q(r.parent)){let i=Z(e,r);if(i&&r.lastChild.name==`CloseTag`)break;i&&n.indexOf(i)<0&&(t.name==`EndTag`||t.from>=r.firstChild.to)&&n.push(i)}return n}var $i=/^[:\-\.\w\u00b7-\uffff]*$/;function ea(e,t,n,r,i){let a=/\s*>/.test(e.sliceDoc(i,i+5))?``:`>`,o=Q(n,n.name==`StartTag`||n.name==`TagName`);return{from:r,to:i,options:Zi(e.doc,o,t).map(e=>({label:e,type:`type`})).concat(Qi(e.doc,n).map((e,t)=>({label:`/`+e,apply:`/`+e+a,type:`type`,boost:99-t}))),validFor:/^\/?[:\-\.\w\u00b7-\uffff]*$/}}function ta(e,t,n,r){let i=/\s*>/.test(e.sliceDoc(r,r+5))?``:`>`;return{from:n,to:r,options:Qi(e.doc,t).map((e,t)=>({label:e,apply:e+i,type:`type`,boost:99-t})),validFor:$i}}function na(e,t,n,r){let i=[],a=0;for(let r of Zi(e.doc,n,t))i.push({label:`<`+r,type:`type`});for(let t of Qi(e.doc,n))i.push({label:`</`+t+`>`,type:`type`,boost:99-a++});return{from:r,to:r,options:i,validFor:/^<\/?[:\-\.\w\u00b7-\uffff]*$/}}function ra(e,t,n,r,i){let a=Q(n),o=a?t.tags[Z(e.doc,a)]:null,s=o&&o.attrs?Object.keys(o.attrs):[];return{from:r,to:i,options:(o&&o.globalAttrs===!1?s:s.length?s.concat(t.globalAttrNames):t.globalAttrNames).map(e=>({label:e,type:`property`})),validFor:$i}}function ia(e,t,n,r,i){let a=n.parent?.getChild(`AttributeName`),o=[],s;if(a){let c=e.sliceDoc(a.from,a.to),l=t.globalAttrs[c];if(!l){let r=Q(n),i=r?t.tags[Z(e.doc,r)]:null;l=i?.attrs&&i.attrs[c]}if(l){let t=e.sliceDoc(r,i).toLowerCase(),n=`"`,a=`"`;/^['"]/.test(t)?(s=t[0]==`"`?/^[^"]*$/:/^[^']*$/,n=``,a=e.sliceDoc(i,i+1)==t[0]?``:t[0],t=t.slice(1),r++):s=/^[^\s<>='"]*$/;for(let e of l)o.push({label:e,apply:n+e+a,type:`constant`})}}return{from:r,to:i,options:o,validFor:s}}function aa(e,t){let{state:n,pos:r}=t,i=x(n).resolveInner(r,-1),a=i.resolve(r);for(let e=r,t;a==i&&(t=i.childBefore(e));){let n=t.lastChild;if(!n||!n.type.isError||n.from<n.to)break;a=i=t,e=n.from}return i.name==`TagName`?i.parent&&/CloseTag$/.test(i.parent.name)?ta(n,i,i.from,r):ea(n,e,i,i.from,r):i.name==`StartTag`||i.name==`IncompleteTag`?ea(n,e,i,r,r):i.name==`StartCloseTag`||i.name==`IncompleteCloseTag`?ta(n,i,r,r):i.name==`OpenTag`||i.name==`SelfClosingTag`||i.name==`AttributeName`?ra(n,e,i,i.name==`AttributeName`?i.from:r,r):i.name==`Is`||i.name==`AttributeValue`||i.name==`UnquotedAttributeValue`?ia(n,e,i,i.name==`Is`?r:i.from,r):t.explicit&&(a.name==`Element`||a.name==`Text`||a.name==`Document`)?na(n,e,i,r):null}function oa(e){return aa(X.default,e)}function sa(e){let{extraTags:t,extraGlobalAttributes:n}=e,r=n||t?new X(t,n):X.default;return e=>aa(r,e)}var ca=K.parser.configure({top:`SingleExpression`}),la=[{tag:`script`,attrs:e=>e.type==`text/typescript`||e.lang==`ts`,parser:Pi.parser},{tag:`script`,attrs:e=>e.type==`text/babel`||e.type==`text/jsx`,parser:Fi.parser},{tag:`script`,attrs:e=>e.type==`text/typescript-jsx`,parser:Ii.parser},{tag:`script`,attrs(e){return/^(importmap|speculationrules|application\/(.+\+)?json)$/i.test(e.type)},parser:ca},{tag:`script`,attrs(e){return!e.type||/^(?:text|application)\/(?:x-)?(?:java|ecma)script$|^module$|^$/i.test(e.type)},parser:K.parser},{tag:`style`,attrs(e){return(!e.lang||e.lang==`css`)&&(!e.type||/^(text\/)?(x-)?(stylesheet|css)$/i.test(e.type))},parser:W.parser}],ua=[{name:`style`,parser:W.parser.configure({top:`Styles`})}].concat(Xi.map(e=>({name:e,parser:K.parser}))),da=ee.define({name:`html`,parser:Bn.configure({props:[b.add({Element(e){let t=/^(\s*)(<\/)?/.exec(e.textAfter);return e.node.to<=e.pos+t[0].length?e.continue():e.lineIndent(e.node.from)+(t[2]?0:e.unit)},"OpenTag CloseTag SelfClosingTag"(e){return e.column(e.node.from)+e.unit},Document(e){if(e.pos+/\s*/.exec(e.textAfter)[0].length<e.node.to)return e.continue();let t=null,n;for(let n=e.node;;){let e=n.lastChild;if(!e||e.name!=`Element`||e.to!=n.to)break;t=n=e}return t&&!((n=t.lastChild)&&(n.name==`CloseTag`||n.name==`SelfClosingTag`))?e.lineIndent(t.from)+e.unit:null}}),y.add({Element(e){let t=e.firstChild,n=e.lastChild;return!t||t.name!=`OpenTag`?null:{from:t.to,to:n.name==`CloseTag`?n.from:e.to}}}),ie.add({"OpenTag CloseTag":e=>e.getChild(`TagName`)})]}),languageData:{commentTokens:{block:{open:`<!--`,close:`-->`}},indentOnInput:/^\s*<\/\w+\W$/,wordChars:`-_`}}),fa=da.configure({wrap:Wn(la,ua)});function pa(e={}){let t=``,n;e.matchClosingTags===!1&&(t=`noMatch`),e.selfClosingTags===!0&&(t=(t?t+` `:``)+`selfClosing`),(e.nestedLanguages&&e.nestedLanguages.length||e.nestedAttributes&&e.nestedAttributes.length)&&(n=Wn((e.nestedLanguages||[]).concat(la),(e.nestedAttributes||[]).concat(ua)));let r=n?da.configure({wrap:n,dialect:t}):t?fa.configure({dialect:t}):fa;return new _(r,[fa.data.of({autocomplete:sa(e)}),e.autoCloseTags===!1?[]:ga,Bi().support,Br().support])}var ma=new Set(`area base br col command embed frame hr img input keygen link meta param source track wbr menuitem`.split(` `));function ha(e,t,n){for(;;){if(t.lastChild?.name!=`CloseTag`)return!1;let r=t.parent;if(!r||Z(e,r)!=n)return!0;t=r}}var ga=t.inputHandler.of((e,t,r,i,a)=>{if(e.composing||e.state.readOnly||t!=r||i!=`>`&&i!=`/`||!fa.isActiveAt(e.state,t,-1))return!1;let o=a(),{state:s}=o,c=s.changeByRange(e=>{let t=s.doc.sliceString(e.from-1,e.to)==i,{head:r}=e,a=x(s).resolveInner(r,-1),o;if(t&&i==`>`&&a.name==`EndTag`){let t=a.parent;if((o=Z(s.doc,t.parent,r))&&!ma.has(o)&&!ha(s.doc,t.parent,o))return{range:e,changes:{from:r,to:r+ +(s.doc.sliceString(r,r+1)===`>`),insert:`</${o}>`}}}else if(t&&i==`/`&&a.name==`IncompleteCloseTag`){let e=a.parent;if(a.from==r-2&&e.lastChild?.name!=`CloseTag`&&(o=Z(s.doc,e,r))&&!ma.has(o)){let e=r+ +(s.doc.sliceString(r,r+1)===`>`),t=`${o}>`;return{range:n.cursor(r+t.length,-1),changes:{from:r,to:e,insert:t}}}}return{range:e}});return!c.changes.empty&&(e.dispatch([o,s.update(c,{userEvent:`input.complete`,scrollIntoView:!0})]),!0)}),_a=ae({commentTokens:{block:{open:`<!--`,close:`-->`}}}),va=new d,ya=dt.configure({props:[y.add(e=>!e.is(`Block`)||e.is(`Document`)||ba(e)!=null||xa(e)?void 0:(e,t)=>({from:t.doc.lineAt(e.from).to,to:e.to})),va.add(ba),b.add({Document:()=>null}),de.add({Document:_a})]});function ba(e){let t=/^(?:ATX|Setext)Heading(\d)$/.exec(e.name);return t?+t[1]:void 0}function xa(e){return e.name==`OrderedList`||e.name==`BulletList`}function Sa(e,t){let n=e;for(;;){let e=n.nextSibling,r;if(!e||(r=ba(e.type))!=null&&r<=t)break;n=e}return n.to}var Ca=le.of((e,t,n)=>{for(let r=x(e).resolveInner(n,-1);r&&!(r.from<t);r=r.parent){let e=r.type.prop(va);if(e==null)continue;let t=Sa(r,e);if(t>n)return{from:n,to:t}}return null});function wa(e){return new te(_a,e,[],`markdown`)}var Ta=wa(ya),$=wa(ya.configure([At,Nt,Mt,Pt,{props:[y.add({Table:(e,t)=>({from:t.doc.lineAt(e.from).to,to:e.to})})]}]));function Ea(e,t){return n=>{if(n&&e){let t=null;if(n=/\S*/.exec(n)[0],t=typeof e==`function`?e(n):ne.matchLanguageName(e,n,!0),t instanceof ne)return t.support?t.support.language.parser:re.getSkippingParser(t.load());if(t)return t.parser}return t?t.parser:null}}var Da=class{constructor(e,t,n,r,i,a,o){this.node=e,this.from=t,this.to=n,this.spaceBefore=r,this.spaceAfter=i,this.type=a,this.item=o}blank(e,t=!0){let n=this.spaceBefore+(this.node.name==`Blockquote`?`>`:``);if(e!=null){for(;n.length<e;)n+=` `;return n}for(let e=this.to-this.from-n.length-this.spaceAfter.length;e>0;e--)n+=` `;return n+(t?this.spaceAfter:``)}marker(e,t){let n=this.node.name==`OrderedList`?String(+ka(this.item,e)[2]+t):``;return this.spaceBefore+n+this.type+this.spaceAfter}};function Oa(e,t){let n=[],r=[];for(let t=e;t;t=t.parent){if(t.name==`FencedCode`)return r;(t.name==`ListItem`||t.name==`Blockquote`)&&n.push(t)}for(let e=n.length-1;e>=0;e--){let i=n[e],a,o=t.lineAt(i.from),s=i.from-o.from;if(i.name==`Blockquote`&&(a=/^ *>( ?)/.exec(o.text.slice(s))))r.push(new Da(i,s,s+a[0].length,``,a[1],`>`,null));else if(i.name==`ListItem`&&i.parent.name==`OrderedList`&&(a=/^( *)\d+([.)])( *)/.exec(o.text.slice(s)))){let e=a[3],t=a[0].length;e.length>=4&&(e=e.slice(0,e.length-4),t-=4),r.push(new Da(i.parent,s,s+t,a[1],e,a[2],i))}else if(i.name==`ListItem`&&i.parent.name==`BulletList`&&(a=/^( *)([-+*])( {1,4}\[[ xX]\])?( +)/.exec(o.text.slice(s)))){let e=a[4],t=a[0].length;e.length>4&&(e=e.slice(0,e.length-4),t-=4);let n=a[2];a[3]&&(n+=a[3].replace(/[xX]/,` `)),r.push(new Da(i.parent,s,s+t,a[1],e,n,i))}}return r}function ka(e,t){return/^(\s*)(\d+)(?=[.)])/.exec(t.sliceString(e.from,e.from+10))}function Aa(e,t,n,r=0){for(let i=-1,a=e;;){if(a.name==`ListItem`){let e=ka(a,t),o=+e[2];if(i>=0){if(o!=i+1)return;n.push({from:a.from+e[1].length,to:a.from+e[0].length,insert:String(i+2+r)})}i=o}let e=a.nextSibling;if(!e)break;a=e}}function ja(e,t){let n=/^[ \t]*/.exec(e)[0].length;if(!n||t.facet(ue)!=` `)return e;let r=a(e,4,n),i=``;for(let e=r;e>0;)e>=4?(i+=` `,e-=4):(i+=` `,e--);return i+e.slice(n)}var Ma=((e={})=>({state:t,dispatch:r})=>{let i=x(t),{doc:o}=t,s=null,c=t.changeByRange(r=>{if(!r.empty||!$.isActiveAt(t,r.from,-1)&&!$.isActiveAt(t,r.from,1))return s={range:r};let c=r.from,l=o.lineAt(c),u=Oa(i.resolveInner(c,-1),o);for(;u.length&&u[u.length-1].from>c-l.from;)u.pop();if(!u.length)return s={range:r};let d=u[u.length-1];if(d.to-d.spaceAfter.length>c-l.from)return s={range:r};let f=c>=d.to-d.spaceAfter.length&&!/\S/.test(l.text.slice(d.to));if(d.item&&f){if(d.item.from<l.from&&!/^[\s>]*$/.test(l.text.slice(0,d.to)))return s={range:r};let i=d.node.firstChild,a=d.node.getChild(`ListItem`,`ListItem`);if(i.to>=c||a&&a.to<c||l.from>0&&!/[^\s>]/.test(o.lineAt(l.from-1).text)||e.nonTightLists===!1){let e=u.length>1?u[u.length-2]:null,t,r=``;e&&e.item?(t=l.from+e.from,r=e.marker(o,1)):t=l.from+(e?e.to:0);let i=[{from:t,to:c,insert:r}];return d.node.name==`OrderedList`&&Aa(d.item,o,i,-2),e&&e.node.name==`OrderedList`&&Aa(e.item,o,i),{range:n.cursor(t+r.length),changes:i}}{let e=Fa(u,t,l);return{range:n.cursor(c+e.length+1),changes:{from:l.from,insert:e+t.lineBreak}}}}if(d.node.name==`Blockquote`&&f&&l.from){let e=o.lineAt(l.from-1),n=/>\s*$/.exec(e.text);if(n&&n.index==d.from){let i=t.changes([{from:e.from+n.index,to:e.to},{from:l.from+d.from,to:l.to}]);return{range:r.map(i),changes:i}}}let p=[];d.node.name==`OrderedList`&&Aa(d.item,o,p);let m=d.item&&d.item.from<l.from,h=``;if(!m||/^[\s\d.)\-+*>]*/.exec(l.text)[0].length>=d.to)for(let e=0,t=u.length-1;e<=t;e++)h+=e==t&&!m?u[e].marker(o,1):u[e].blank(e<t?a(l.text,4,u[e+1].from)-h.length:null);let g=c;for(;g>l.from&&/\s/.test(l.text.charAt(g-l.from-1));)g--;return h=ja(h,t),Pa(d.node,t.doc)&&(h=Fa(u,t,l)+t.lineBreak+h),p.push({from:g,to:c,insert:t.lineBreak+h}),{range:n.cursor(g+h.length+1),changes:p}});return!s&&(r(t.update(c,{scrollIntoView:!0,userEvent:`input`})),!0)})();function Na(e){return e.name==`QuoteMark`||e.name==`ListMark`}function Pa(e,t){if(e.name!=`OrderedList`&&e.name!=`BulletList`)return!1;let n=e.firstChild,r=e.getChild(`ListItem`,`ListItem`);if(!r)return!1;let i=t.lineAt(n.to),a=t.lineAt(r.from),o=/^[\s>]*$/.test(i.text);return i.number+ +!o<a.number}function Fa(e,t,n){let r=``;for(let t=0,i=e.length-2;t<=i;t++)r+=e[t].blank(t<i?a(n.text,4,e[t+1].from)-r.length:null,t<i);return ja(r,t)}function Ia(e,t){let n=e.resolveInner(t,-1),r=t;Na(n)&&(r=n.from,n=n.parent);for(let e;e=n.childBefore(r);)if(Na(e))r=e.from;else if(e.name==`OrderedList`||e.name==`BulletList`)n=e.lastChild,r=n.to;else break;return n}var La=[{key:`Enter`,run:Ma},{key:`Backspace`,run:({state:e,dispatch:t})=>{let r=x(e),i=null,o=e.changeByRange(t=>{let o=t.from,{doc:s}=e;if(t.empty&&$.isActiveAt(e,t.from)){let t=s.lineAt(o),i=Oa(Ia(r,o),s);if(i.length){let r=i[i.length-1],s=r.to-r.spaceAfter.length+ +!!r.spaceAfter;if(o-t.from>s&&!/\S/.test(t.text.slice(s,o-t.from)))return{range:n.cursor(t.from+s),changes:{from:t.from+s,to:o}};if(o-t.from==s&&(r.item&&t.from<=r.item.from||/^[\s>]*$/.test(t.text.slice(0,r.to)))){let i=t.from+r.from;if(r.item&&r.node.from<r.item.from&&/\S/.test(t.text.slice(r.from,r.to))){let o=r.blank(a(t.text,4,r.to)-a(t.text,4,r.from));return i==t.from&&(o=ja(o,e)),{range:n.cursor(i+o.length),changes:{from:i,to:t.from+r.to,insert:o}}}if(i<o)return{range:n.cursor(i),changes:{from:i,to:o}}}}}return i={range:t}});return!i&&(t(e.update(o,{scrollIntoView:!0,userEvent:`delete`})),!0)}}],Ra=pa({matchClosingTags:!1});function za(t={}){let{codeLanguages:n,defaultCodeLanguage:r,addKeymap:a=!0,base:{parser:o}=Ta,completeHTMLTags:s=!0,pasteURLAsLink:c=!0,htmlTagLanguage:l=Ra}=t;if(!(o instanceof qe))throw RangeError("Base parser provided to `markdown` should be a Markdown parser");let u=t.extensions?[t.extensions]:[],d=[l.support,Ca],f;c&&d.push(Wa),r instanceof _?(d.push(r.support),f=r.language):r&&(f=r);let p=n||f?Ea(n,f):void 0;u.push(pt({codeParser:p,htmlParser:l.language.parser})),a&&d.push(e.high(i.of(La)));let m=wa(o.configure(u));return s&&d.push(m.data.of({autocomplete:Ba})),new _(m,d)}function Ba(e){let{state:t,pos:n}=e,r=/<[:\-\.\w\u00b7-\uffff]*$/.exec(t.sliceDoc(n-25,n));if(!r)return null;let i=x(t).resolveInner(n,-1);for(;i&&!i.type.isTop;){if(i.name==`CodeBlock`||i.name==`FencedCode`||i.name==`ProcessingInstructionBlock`||i.name==`CommentBlock`||i.name==`Link`||i.name==`Image`)return null;i=i.parent}return{from:n-r[0].length,to:n,options:Ha(),validFor:/^<[:\-\.\w\u00b7-\uffff]*$/}}var Va=null;function Ha(){if(Va)return Va;let e=oa(new pe(r.create({extensions:Ra}),0,!0));return Va=e?e.options:[]}var Ua=/code|horizontalrule|html|link|comment|processing|escape|entity|image|mark|url/i,Wa=t.domEventHandlers({paste:(e,t)=>{let{main:n}=t.state.selection;if(n.empty)return!1;let r=e.clipboardData?.getData(`text/plain`);if(!r||!/^(https?:\/\/|mailto:|xmpp:|www\.)/.test(r)||(/^www\./.test(r)&&(r=`https://`+r),!$.isActiveAt(t.state,n.from,1)))return!1;let i=x(t.state),a=!1;return i.iterate({from:n.from,to:n.to,enter:e=>{(e.from>n.from||Ua.test(e.name))&&(a=!0)},leave:e=>{e.to<n.to&&(a=!0)}}),!a&&(t.dispatch({changes:[{from:n.from,insert:`[`},{from:n.to,insert:`](${r})`}],userEvent:`input.paste`,scrollIntoView:!0}),!0)}});export{za as markdown,$ as markdownLanguage};
28
+ }`,{label:`enum`,detail:`definition`,type:`keyword`})]),Ti=new c,Ei=new Set([`Script`,`Block`,`FunctionExpression`,`FunctionDeclaration`,`ArrowFunction`,`MethodDeclaration`,`ForStatement`]);function G(e){return(t,n)=>{let r=t.node.getChild(`VariableDefinition`);return r&&n(r,e),!0}}var Di=[`FunctionDeclaration`],Oi={FunctionDeclaration:G(`function`),ClassDeclaration:G(`class`),ClassExpression:()=>!0,EnumDeclaration:G(`constant`),TypeAliasDeclaration:G(`type`),NamespaceDeclaration:G(`namespace`),VariableDefinition(e,t){e.matchContext(Di)||t(e,`variable`)},TypeDefinition(e,t){t(e,`type`)},__proto__:null};function ki(e,t){let n=Ti.get(t);if(n)return n;let r=[],i=!0;function a(t,n){let i=e.sliceString(t.from,t.to);r.push({label:i,type:n})}return t.cursor(o.IncludeAnonymous).iterate(t=>{if(i)i=!1;else if(t.name){let e=Oi[t.name];if(e&&e(t,a)||Ei.has(t.name))return!1}else if(t.to-t.from>8192){for(let n of ki(e,t.node))r.push(n);return!1}}),Ti.set(t,r),r}var Ai=/^[\w$\xa1-\uffff][\w$\d\xa1-\uffff]*$/,ji=[`TemplateString`,`String`,`RegExp`,`LineComment`,`BlockComment`,`VariableDefinition`,`TypeDefinition`,`Label`,`PropertyDefinition`,`PropertyName`,`PrivatePropertyDefinition`,`PrivatePropertyName`,`JSXText`,`JSXAttributeValue`,`JSXOpenTag`,`JSXCloseTag`,`JSXSelfClosingTag`,`.`,`?.`];function Mi(e){let t=x(e.state).resolveInner(e.pos,-1);if(ji.indexOf(t.name)>-1)return null;let n=t.name==`VariableName`||t.to-t.from<20&&Ai.test(e.state.sliceDoc(t.from,t.to));if(!n&&!e.explicit)return null;let r=[];for(let n=t;n;n=n.parent)Ei.has(n.name)&&(r=r.concat(ki(e.state.doc,n)));return{options:r,from:n?t.from:e.pos,validFor:Ai}}var K=ee.define({name:`javascript`,parser:Si.configure({props:[b.add({IfStatement:v({except:/^\s*({|else\b)/}),TryStatement:v({except:/^\s*({|catch\b|finally\b)/}),LabeledStatement:se,SwitchBody:e=>{let t=e.textAfter,n=/^\s*\}/.test(t),r=/^\s*(case|default)\b/.test(t);return e.baseIndent+(n?0:r?1:2)*e.unit},Block:oe({closing:`}`}),ArrowFunction:e=>e.baseIndent+e.unit,"TemplateString BlockComment":()=>null,"Statement Property":v({except:/^\s*{/}),JSXElement(e){let t=/^\s*<\//.test(e.textAfter);return e.lineIndent(e.node.from)+(t?0:e.unit)},JSXEscape(e){let t=/\s*\}/.test(e.textAfter);return e.lineIndent(e.node.from)+(t?0:e.unit)},"JSXOpenTag JSXSelfClosingTag"(e){return e.column(e.node.from)+e.unit}}),y.add({"Block ClassBody SwitchBody EnumBody ObjectExpression ArrayExpression ObjectType":ce,BlockComment(e){return{from:e.from+2,to:e.to-2}},JSXElement(e){let t=e.firstChild;if(!t||t.name==`JSXSelfClosingTag`)return null;let n=e.lastChild;return{from:t.to,to:n.type.isError?e.to:n.from}},"JSXSelfClosingTag JSXOpenTag"(e){let t=e.firstChild?.nextSibling,n=e.lastChild;return!t||t.type.isError?null:{from:t.to,to:n.type.isError?e.to:n.from}}})]}),languageData:{closeBrackets:{brackets:[`(`,`[`,`{`,`'`,`"`,"`"]},commentTokens:{line:`//`,block:{open:`/*`,close:`*/`}},indentOnInput:/^\s*(?:case |default:|\{|\}|<\/)$/,wordChars:`$`}}),Ni={test:e=>/^JSX/.test(e.name),facet:ae({commentTokens:{block:{open:`{/*`,close:`*/}`}}})},Pi=K.configure({dialect:`ts`},`typescript`),Fi=K.configure({dialect:`jsx`,props:[fe.add(e=>e.isTop?[Ni]:void 0)]}),Ii=K.configure({dialect:`jsx ts`,props:[fe.add(e=>e.isTop?[Ni]:void 0)]},`typescript`),Li=e=>({label:e,type:`keyword`}),Ri=`break case const continue default delete export extends false finally in instanceof let new return static super switch this throw true typeof var yield`.split(` `).map(Li),zi=Ri.concat([`declare`,`implements`,`private`,`protected`,`public`].map(Li));function Bi(e={}){let t=e.jsx?e.typescript?Ii:Fi:e.typescript?Pi:K,n=e.typescript?wi.concat(zi):Ci.concat(Ri);return new _(t,[K.data.of({autocomplete:_e(ji,he(n))}),K.data.of({autocomplete:Mi}),e.jsx?Wi:[]])}function Vi(e){for(;;){if(e.name==`JSXOpenTag`||e.name==`JSXSelfClosingTag`||e.name==`JSXFragmentTag`)return e;if(e.name==`JSXEscape`||!e.parent)return null;e=e.parent}}function Hi(e,t,n=e.length){for(let r=t?.firstChild;r;r=r.nextSibling)if(r.name==`JSXIdentifier`||r.name==`JSXBuiltin`||r.name==`JSXNamespacedName`||r.name==`JSXMemberExpression`)return e.sliceString(r.from,Math.min(r.to,n));return``}var Ui=typeof navigator==`object`&&/Android\b/.test(navigator.userAgent),Wi=e.inputHandler.of((e,t,n,i,a)=>{if((Ui?e.composing:e.compositionStarted)||e.state.readOnly||t!=n||i!=`>`&&i!=`/`||!K.isActiveAt(e.state,t,-1))return!1;let o=a(),{state:s}=o,c=s.changeByRange(e=>{let{head:t}=e,n=x(s).resolveInner(t-1,-1),a;if(n.name==`JSXStartTag`&&(n=n.parent),!(s.doc.sliceString(t-1,t)!=i||n.name==`JSXAttributeValue`&&n.to>t)){if(i==`>`&&n.name==`JSXFragmentTag`)return{range:e,changes:{from:t,insert:`</>`}};if(i==`/`&&n.name==`JSXStartCloseTag`){let e=n.parent,i=e.parent;if(i&&e.from==t-2&&((a=Hi(s.doc,i.firstChild,t))||i.firstChild?.name==`JSXFragmentTag`)){let e=`${a}>`;return{range:r.cursor(t+e.length,-1),changes:{from:t,insert:e}}}}else if(i==`>`){let r=Vi(n);if(r&&r.name==`JSXOpenTag`&&!/^\/?>|^<\//.test(s.doc.sliceString(t,t+2))&&(a=Hi(s.doc,r,t)))return{range:e,changes:{from:t,insert:`</${a}>`}}}}return{range:e}});return!c.changes.empty&&(e.dispatch([o,s.update(c,{userEvent:`input.complete`,scrollIntoView:!0})]),!0)}),q=[`_blank`,`_self`,`_top`,`_parent`],Gi=[`ascii`,`utf-8`,`utf-16`,`latin1`,`latin1`],Ki=[`get`,`post`,`put`,`delete`],qi=[`application/x-www-form-urlencoded`,`multipart/form-data`,`text/plain`],J=[`true`,`false`],Y={},Ji={a:{attrs:{href:null,ping:null,type:null,media:null,target:q,hreflang:null}},abbr:Y,address:Y,area:{attrs:{alt:null,coords:null,href:null,target:null,ping:null,media:null,hreflang:null,type:null,shape:[`default`,`rect`,`circle`,`poly`]}},article:Y,aside:Y,audio:{attrs:{src:null,mediagroup:null,crossorigin:[`anonymous`,`use-credentials`],preload:[`none`,`metadata`,`auto`],autoplay:[`autoplay`],loop:[`loop`],controls:[`controls`]}},b:Y,base:{attrs:{href:null,target:q}},bdi:Y,bdo:Y,blockquote:{attrs:{cite:null}},body:Y,br:Y,button:{attrs:{form:null,formaction:null,name:null,value:null,autofocus:[`autofocus`],disabled:[`autofocus`],formenctype:qi,formmethod:Ki,formnovalidate:[`novalidate`],formtarget:q,type:[`submit`,`reset`,`button`]}},canvas:{attrs:{width:null,height:null}},caption:Y,center:Y,cite:Y,code:Y,col:{attrs:{span:null}},colgroup:{attrs:{span:null}},command:{attrs:{type:[`command`,`checkbox`,`radio`],label:null,icon:null,radiogroup:null,command:null,title:null,disabled:[`disabled`],checked:[`checked`]}},data:{attrs:{value:null}},datagrid:{attrs:{disabled:[`disabled`],multiple:[`multiple`]}},datalist:{attrs:{data:null}},dd:Y,del:{attrs:{cite:null,datetime:null}},details:{attrs:{open:[`open`]}},dfn:Y,div:Y,dl:Y,dt:Y,em:Y,embed:{attrs:{src:null,type:null,width:null,height:null}},eventsource:{attrs:{src:null}},fieldset:{attrs:{disabled:[`disabled`],form:null,name:null}},figcaption:Y,figure:Y,footer:Y,form:{attrs:{action:null,name:null,"accept-charset":Gi,autocomplete:[`on`,`off`],enctype:qi,method:Ki,novalidate:[`novalidate`],target:q}},h1:Y,h2:Y,h3:Y,h4:Y,h5:Y,h6:Y,head:{children:[`title`,`base`,`link`,`style`,`meta`,`script`,`noscript`,`command`]},header:Y,hgroup:Y,hr:Y,html:{attrs:{manifest:null}},i:Y,iframe:{attrs:{src:null,srcdoc:null,name:null,width:null,height:null,sandbox:[`allow-top-navigation`,`allow-same-origin`,`allow-forms`,`allow-scripts`],seamless:[`seamless`]}},img:{attrs:{alt:null,src:null,ismap:null,usemap:null,width:null,height:null,crossorigin:[`anonymous`,`use-credentials`]}},input:{attrs:{alt:null,dirname:null,form:null,formaction:null,height:null,list:null,max:null,maxlength:null,min:null,name:null,pattern:null,placeholder:null,size:null,src:null,step:null,value:null,width:null,accept:[`audio/*`,`video/*`,`image/*`],autocomplete:[`on`,`off`],autofocus:[`autofocus`],checked:[`checked`],disabled:[`disabled`],formenctype:qi,formmethod:Ki,formnovalidate:[`novalidate`],formtarget:q,multiple:[`multiple`],readonly:[`readonly`],required:[`required`],type:[`hidden`,`text`,`search`,`tel`,`url`,`email`,`password`,`datetime`,`date`,`month`,`week`,`time`,`datetime-local`,`number`,`range`,`color`,`checkbox`,`radio`,`file`,`submit`,`image`,`reset`,`button`]}},ins:{attrs:{cite:null,datetime:null}},kbd:Y,keygen:{attrs:{challenge:null,form:null,name:null,autofocus:[`autofocus`],disabled:[`disabled`],keytype:[`RSA`]}},label:{attrs:{for:null,form:null}},legend:Y,li:{attrs:{value:null}},link:{attrs:{href:null,type:null,hreflang:null,media:null,sizes:[`all`,`16x16`,`16x16 32x32`,`16x16 32x32 64x64`]}},map:{attrs:{name:null}},mark:Y,menu:{attrs:{label:null,type:[`list`,`context`,`toolbar`]}},meta:{attrs:{content:null,charset:Gi,name:[`viewport`,`application-name`,`author`,`description`,`generator`,`keywords`],"http-equiv":[`content-language`,`content-type`,`default-style`,`refresh`]}},meter:{attrs:{value:null,min:null,low:null,high:null,max:null,optimum:null}},nav:Y,noscript:Y,object:{attrs:{data:null,type:null,name:null,usemap:null,form:null,width:null,height:null,typemustmatch:[`typemustmatch`]}},ol:{attrs:{reversed:[`reversed`],start:null,type:[`1`,`a`,`A`,`i`,`I`]},children:[`li`,`script`,`template`,`ul`,`ol`]},optgroup:{attrs:{disabled:[`disabled`],label:null}},option:{attrs:{disabled:[`disabled`],label:null,selected:[`selected`],value:null}},output:{attrs:{for:null,form:null,name:null}},p:Y,param:{attrs:{name:null,value:null}},pre:Y,progress:{attrs:{value:null,max:null}},q:{attrs:{cite:null}},rp:Y,rt:Y,ruby:Y,samp:Y,script:{attrs:{type:[`text/javascript`],src:null,async:[`async`],defer:[`defer`],charset:Gi}},section:Y,select:{attrs:{form:null,name:null,size:null,autofocus:[`autofocus`],disabled:[`disabled`],multiple:[`multiple`]}},slot:{attrs:{name:null}},small:Y,source:{attrs:{src:null,type:null,media:null}},span:Y,strong:Y,style:{attrs:{type:[`text/css`],media:null,scoped:null}},sub:Y,summary:Y,sup:Y,table:Y,tbody:Y,td:{attrs:{colspan:null,rowspan:null,headers:null}},template:Y,textarea:{attrs:{dirname:null,form:null,maxlength:null,name:null,placeholder:null,rows:null,cols:null,autofocus:[`autofocus`],disabled:[`disabled`],readonly:[`readonly`],required:[`required`],wrap:[`soft`,`hard`]}},tfoot:Y,th:{attrs:{colspan:null,rowspan:null,headers:null,scope:[`row`,`col`,`rowgroup`,`colgroup`]}},thead:Y,time:{attrs:{datetime:null}},title:Y,tr:Y,track:{attrs:{src:null,label:null,default:null,kind:[`subtitles`,`captions`,`descriptions`,`chapters`,`metadata`],srclang:null}},ul:{children:[`li`,`script`,`template`,`ul`,`ol`]},var:Y,video:{attrs:{src:null,poster:null,width:null,height:null,crossorigin:[`anonymous`,`use-credentials`],preload:[`auto`,`metadata`,`none`],autoplay:[`autoplay`],mediagroup:[`movie`],muted:[`muted`],controls:[`controls`]}},wbr:Y},Yi={accesskey:null,class:null,contenteditable:J,contextmenu:null,dir:[`ltr`,`rtl`,`auto`],draggable:[`true`,`false`,`auto`],dropzone:[`copy`,`move`,`link`,`string:`,`file:`],hidden:[`hidden`],id:null,inert:[`inert`],itemid:null,itemprop:null,itemref:null,itemscope:[`itemscope`],itemtype:null,lang:[`ar`,`bn`,`de`,`en-GB`,`en-US`,`es`,`fr`,`hi`,`id`,`ja`,`pa`,`pt`,`ru`,`tr`,`zh`],spellcheck:J,autocorrect:J,autocapitalize:J,style:null,tabindex:null,title:null,translate:[`yes`,`no`],rel:[`stylesheet`,`alternate`,`author`,`bookmark`,`help`,`license`,`next`,`nofollow`,`noreferrer`,`prefetch`,`prev`,`search`,`tag`],role:`alert application article banner button cell checkbox complementary contentinfo dialog document feed figure form grid gridcell heading img list listbox listitem main navigation region row rowgroup search switch tab table tabpanel textbox timer`.split(` `),"aria-activedescendant":null,"aria-atomic":J,"aria-autocomplete":[`inline`,`list`,`both`,`none`],"aria-busy":J,"aria-checked":[`true`,`false`,`mixed`,`undefined`],"aria-controls":null,"aria-describedby":null,"aria-disabled":J,"aria-dropeffect":null,"aria-expanded":[`true`,`false`,`undefined`],"aria-flowto":null,"aria-grabbed":[`true`,`false`,`undefined`],"aria-haspopup":J,"aria-hidden":J,"aria-invalid":[`true`,`false`,`grammar`,`spelling`],"aria-label":null,"aria-labelledby":null,"aria-level":null,"aria-live":[`off`,`polite`,`assertive`],"aria-multiline":J,"aria-multiselectable":J,"aria-owns":null,"aria-posinset":null,"aria-pressed":[`true`,`false`,`mixed`,`undefined`],"aria-readonly":J,"aria-relevant":null,"aria-required":J,"aria-selected":[`true`,`false`,`undefined`],"aria-setsize":null,"aria-sort":[`ascending`,`descending`,`none`,`other`],"aria-valuemax":null,"aria-valuemin":null,"aria-valuenow":null,"aria-valuetext":null},Xi=`beforeunload copy cut dragstart dragover dragleave dragenter dragend drag paste focus blur change click load mousedown mouseenter mouseleave mouseup keydown keyup resize scroll unload`.split(` `).map(e=>`on`+e);for(let e of Xi)Yi[e]=null;var X=class{constructor(e,t){this.tags={...Ji,...e},this.globalAttrs={...Yi,...t},this.allTags=Object.keys(this.tags),this.globalAttrNames=Object.keys(this.globalAttrs)}};X.default=new X;function Z(e,t,n=e.length){if(!t)return``;let r=t.firstChild,i=r&&r.getChild(`TagName`);return i?e.sliceString(i.from,Math.min(i.to,n)):``}function Q(e,t=!1){for(;e;e=e.parent)if(e.name==`Element`){if(t)t=!1;else return e}return null}function Zi(e,t,n){return n.tags[Z(e,Q(t))]?.children||n.allTags}function Qi(e,t){let n=[];for(let r=Q(t);r&&!r.type.isTop;r=Q(r.parent)){let i=Z(e,r);if(i&&r.lastChild.name==`CloseTag`)break;i&&n.indexOf(i)<0&&(t.name==`EndTag`||t.from>=r.firstChild.to)&&n.push(i)}return n}var $i=/^[:\-\.\w\u00b7-\uffff]*$/;function ea(e,t,n,r,i){let a=/\s*>/.test(e.sliceDoc(i,i+5))?``:`>`,o=Q(n,n.name==`StartTag`||n.name==`TagName`);return{from:r,to:i,options:Zi(e.doc,o,t).map(e=>({label:e,type:`type`})).concat(Qi(e.doc,n).map((e,t)=>({label:`/`+e,apply:`/`+e+a,type:`type`,boost:99-t}))),validFor:/^\/?[:\-\.\w\u00b7-\uffff]*$/}}function ta(e,t,n,r){let i=/\s*>/.test(e.sliceDoc(r,r+5))?``:`>`;return{from:n,to:r,options:Qi(e.doc,t).map((e,t)=>({label:e,apply:e+i,type:`type`,boost:99-t})),validFor:$i}}function na(e,t,n,r){let i=[],a=0;for(let r of Zi(e.doc,n,t))i.push({label:`<`+r,type:`type`});for(let t of Qi(e.doc,n))i.push({label:`</`+t+`>`,type:`type`,boost:99-a++});return{from:r,to:r,options:i,validFor:/^<\/?[:\-\.\w\u00b7-\uffff]*$/}}function ra(e,t,n,r,i){let a=Q(n),o=a?t.tags[Z(e.doc,a)]:null,s=o&&o.attrs?Object.keys(o.attrs):[];return{from:r,to:i,options:(o&&o.globalAttrs===!1?s:s.length?s.concat(t.globalAttrNames):t.globalAttrNames).map(e=>({label:e,type:`property`})),validFor:$i}}function ia(e,t,n,r,i){let a=n.parent?.getChild(`AttributeName`),o=[],s;if(a){let c=e.sliceDoc(a.from,a.to),l=t.globalAttrs[c];if(!l){let r=Q(n),i=r?t.tags[Z(e.doc,r)]:null;l=i?.attrs&&i.attrs[c]}if(l){let t=e.sliceDoc(r,i).toLowerCase(),n=`"`,a=`"`;/^['"]/.test(t)?(s=t[0]==`"`?/^[^"]*$/:/^[^']*$/,n=``,a=e.sliceDoc(i,i+1)==t[0]?``:t[0],t=t.slice(1),r++):s=/^[^\s<>='"]*$/;for(let e of l)o.push({label:e,apply:n+e+a,type:`constant`})}}return{from:r,to:i,options:o,validFor:s}}function aa(e,t){let{state:n,pos:r}=t,i=x(n).resolveInner(r,-1),a=i.resolve(r);for(let e=r,t;a==i&&(t=i.childBefore(e));){let n=t.lastChild;if(!n||!n.type.isError||n.from<n.to)break;a=i=t,e=n.from}return i.name==`TagName`?i.parent&&/CloseTag$/.test(i.parent.name)?ta(n,i,i.from,r):ea(n,e,i,i.from,r):i.name==`StartTag`||i.name==`IncompleteTag`?ea(n,e,i,r,r):i.name==`StartCloseTag`||i.name==`IncompleteCloseTag`?ta(n,i,r,r):i.name==`OpenTag`||i.name==`SelfClosingTag`||i.name==`AttributeName`?ra(n,e,i,i.name==`AttributeName`?i.from:r,r):i.name==`Is`||i.name==`AttributeValue`||i.name==`UnquotedAttributeValue`?ia(n,e,i,i.name==`Is`?r:i.from,r):t.explicit&&(a.name==`Element`||a.name==`Text`||a.name==`Document`)?na(n,e,i,r):null}function oa(e){return aa(X.default,e)}function sa(e){let{extraTags:t,extraGlobalAttributes:n}=e,r=n||t?new X(t,n):X.default;return e=>aa(r,e)}var ca=K.parser.configure({top:`SingleExpression`}),la=[{tag:`script`,attrs:e=>e.type==`text/typescript`||e.lang==`ts`,parser:Pi.parser},{tag:`script`,attrs:e=>e.type==`text/babel`||e.type==`text/jsx`,parser:Fi.parser},{tag:`script`,attrs:e=>e.type==`text/typescript-jsx`,parser:Ii.parser},{tag:`script`,attrs(e){return/^(importmap|speculationrules|application\/(.+\+)?json)$/i.test(e.type)},parser:ca},{tag:`script`,attrs(e){return!e.type||/^(?:text|application)\/(?:x-)?(?:java|ecma)script$|^module$|^$/i.test(e.type)},parser:K.parser},{tag:`style`,attrs(e){return(!e.lang||e.lang==`css`)&&(!e.type||/^(text\/)?(x-)?(stylesheet|css)$/i.test(e.type))},parser:W.parser}],ua=[{name:`style`,parser:W.parser.configure({top:`Styles`})}].concat(Xi.map(e=>({name:e,parser:K.parser}))),da=ee.define({name:`html`,parser:Bn.configure({props:[b.add({Element(e){let t=/^(\s*)(<\/)?/.exec(e.textAfter);return e.node.to<=e.pos+t[0].length?e.continue():e.lineIndent(e.node.from)+(t[2]?0:e.unit)},"OpenTag CloseTag SelfClosingTag"(e){return e.column(e.node.from)+e.unit},Document(e){if(e.pos+/\s*/.exec(e.textAfter)[0].length<e.node.to)return e.continue();let t=null,n;for(let n=e.node;;){let e=n.lastChild;if(!e||e.name!=`Element`||e.to!=n.to)break;t=n=e}return t&&!((n=t.lastChild)&&(n.name==`CloseTag`||n.name==`SelfClosingTag`))?e.lineIndent(t.from)+e.unit:null}}),y.add({Element(e){let t=e.firstChild,n=e.lastChild;return!t||t.name!=`OpenTag`?null:{from:t.to,to:n.name==`CloseTag`?n.from:e.to}}}),ie.add({"OpenTag CloseTag":e=>e.getChild(`TagName`)})]}),languageData:{commentTokens:{block:{open:`<!--`,close:`-->`}},indentOnInput:/^\s*<\/\w+\W$/,wordChars:`-_`}}),fa=da.configure({wrap:Wn(la,ua)});function pa(e={}){let t=``,n;e.matchClosingTags===!1&&(t=`noMatch`),e.selfClosingTags===!0&&(t=(t?t+` `:``)+`selfClosing`),(e.nestedLanguages&&e.nestedLanguages.length||e.nestedAttributes&&e.nestedAttributes.length)&&(n=Wn((e.nestedLanguages||[]).concat(la),(e.nestedAttributes||[]).concat(ua)));let r=n?da.configure({wrap:n,dialect:t}):t?fa.configure({dialect:t}):fa;return new _(r,[fa.data.of({autocomplete:sa(e)}),e.autoCloseTags===!1?[]:ga,Bi().support,Br().support])}var ma=new Set(`area base br col command embed frame hr img input keygen link meta param source track wbr menuitem`.split(` `));function ha(e,t,n){for(;;){if(t.lastChild?.name!=`CloseTag`)return!1;let r=t.parent;if(!r||Z(e,r)!=n)return!0;t=r}}var ga=e.inputHandler.of((e,t,n,i,a)=>{if(e.composing||e.state.readOnly||t!=n||i!=`>`&&i!=`/`||!fa.isActiveAt(e.state,t,-1))return!1;let o=a(),{state:s}=o,c=s.changeByRange(e=>{let t=s.doc.sliceString(e.from-1,e.to)==i,{head:n}=e,a=x(s).resolveInner(n,-1),o;if(t&&i==`>`&&a.name==`EndTag`){let t=a.parent;if((o=Z(s.doc,t.parent,n))&&!ma.has(o)&&!ha(s.doc,t.parent,o))return{range:e,changes:{from:n,to:n+ +(s.doc.sliceString(n,n+1)===`>`),insert:`</${o}>`}}}else if(t&&i==`/`&&a.name==`IncompleteCloseTag`){let e=a.parent;if(a.from==n-2&&e.lastChild?.name!=`CloseTag`&&(o=Z(s.doc,e,n))&&!ma.has(o)){let e=n+ +(s.doc.sliceString(n,n+1)===`>`),t=`${o}>`;return{range:r.cursor(n+t.length,-1),changes:{from:n,to:e,insert:t}}}}return{range:e}});return!c.changes.empty&&(e.dispatch([o,s.update(c,{userEvent:`input.complete`,scrollIntoView:!0})]),!0)}),_a=ae({commentTokens:{block:{open:`<!--`,close:`-->`}}}),va=new d,ya=dt.configure({props:[y.add(e=>!e.is(`Block`)||e.is(`Document`)||ba(e)!=null||xa(e)?void 0:(e,t)=>({from:t.doc.lineAt(e.from).to,to:e.to})),va.add(ba),b.add({Document:()=>null}),de.add({Document:_a})]});function ba(e){let t=/^(?:ATX|Setext)Heading(\d)$/.exec(e.name);return t?+t[1]:void 0}function xa(e){return e.name==`OrderedList`||e.name==`BulletList`}function Sa(e,t){let n=e;for(;;){let e=n.nextSibling,r;if(!e||(r=ba(e.type))!=null&&r<=t)break;n=e}return n.to}var Ca=le.of((e,t,n)=>{for(let r=x(e).resolveInner(n,-1);r&&!(r.from<t);r=r.parent){let e=r.type.prop(va);if(e==null)continue;let t=Sa(r,e);if(t>n)return{from:n,to:t}}return null});function wa(e){return new te(_a,e,[],`markdown`)}var Ta=wa(ya),$=wa(ya.configure([At,Nt,Mt,Pt,{props:[y.add({Table:(e,t)=>({from:t.doc.lineAt(e.from).to,to:e.to})})]}]));function Ea(e,t){return n=>{if(n&&e){let t=null;if(n=/\S*/.exec(n)[0],t=typeof e==`function`?e(n):ne.matchLanguageName(e,n,!0),t instanceof ne)return t.support?t.support.language.parser:re.getSkippingParser(t.load());if(t)return t.parser}return t?t.parser:null}}var Da=class{constructor(e,t,n,r,i,a,o){this.node=e,this.from=t,this.to=n,this.spaceBefore=r,this.spaceAfter=i,this.type=a,this.item=o}blank(e,t=!0){let n=this.spaceBefore+(this.node.name==`Blockquote`?`>`:``);if(e!=null){for(;n.length<e;)n+=` `;return n}for(let e=this.to-this.from-n.length-this.spaceAfter.length;e>0;e--)n+=` `;return n+(t?this.spaceAfter:``)}marker(e,t){let n=this.node.name==`OrderedList`?String(+ka(this.item,e)[2]+t):``;return this.spaceBefore+n+this.type+this.spaceAfter}};function Oa(e,t){let n=[],r=[];for(let t=e;t;t=t.parent){if(t.name==`FencedCode`)return r;(t.name==`ListItem`||t.name==`Blockquote`)&&n.push(t)}for(let e=n.length-1;e>=0;e--){let i=n[e],a,o=t.lineAt(i.from),s=i.from-o.from;if(i.name==`Blockquote`&&(a=/^ *>( ?)/.exec(o.text.slice(s))))r.push(new Da(i,s,s+a[0].length,``,a[1],`>`,null));else if(i.name==`ListItem`&&i.parent.name==`OrderedList`&&(a=/^( *)\d+([.)])( *)/.exec(o.text.slice(s)))){let e=a[3],t=a[0].length;e.length>=4&&(e=e.slice(0,e.length-4),t-=4),r.push(new Da(i.parent,s,s+t,a[1],e,a[2],i))}else if(i.name==`ListItem`&&i.parent.name==`BulletList`&&(a=/^( *)([-+*])( {1,4}\[[ xX]\])?( +)/.exec(o.text.slice(s)))){let e=a[4],t=a[0].length;e.length>4&&(e=e.slice(0,e.length-4),t-=4);let n=a[2];a[3]&&(n+=a[3].replace(/[xX]/,` `)),r.push(new Da(i.parent,s,s+t,a[1],e,n,i))}}return r}function ka(e,t){return/^(\s*)(\d+)(?=[.)])/.exec(t.sliceString(e.from,e.from+10))}function Aa(e,t,n,r=0){for(let i=-1,a=e;;){if(a.name==`ListItem`){let e=ka(a,t),o=+e[2];if(i>=0){if(o!=i+1)return;n.push({from:a.from+e[1].length,to:a.from+e[0].length,insert:String(i+2+r)})}i=o}let e=a.nextSibling;if(!e)break;a=e}}function ja(e,n){let r=/^[ \t]*/.exec(e)[0].length;if(!r||n.facet(ue)!=` `)return e;let i=t(e,4,r),a=``;for(let e=i;e>0;)e>=4?(a+=` `,e-=4):(a+=` `,e--);return a+e.slice(r)}var Ma=((e={})=>({state:n,dispatch:i})=>{let a=x(n),{doc:o}=n,s=null,c=n.changeByRange(i=>{if(!i.empty||!$.isActiveAt(n,i.from,-1)&&!$.isActiveAt(n,i.from,1))return s={range:i};let c=i.from,l=o.lineAt(c),u=Oa(a.resolveInner(c,-1),o);for(;u.length&&u[u.length-1].from>c-l.from;)u.pop();if(!u.length)return s={range:i};let d=u[u.length-1];if(d.to-d.spaceAfter.length>c-l.from)return s={range:i};let f=c>=d.to-d.spaceAfter.length&&!/\S/.test(l.text.slice(d.to));if(d.item&&f){if(d.item.from<l.from&&!/^[\s>]*$/.test(l.text.slice(0,d.to)))return s={range:i};let t=d.node.firstChild,a=d.node.getChild(`ListItem`,`ListItem`);if(t.to>=c||a&&a.to<c||l.from>0&&!/[^\s>]/.test(o.lineAt(l.from-1).text)||e.nonTightLists===!1){let e=u.length>1?u[u.length-2]:null,t,n=``;e&&e.item?(t=l.from+e.from,n=e.marker(o,1)):t=l.from+(e?e.to:0);let i=[{from:t,to:c,insert:n}];return d.node.name==`OrderedList`&&Aa(d.item,o,i,-2),e&&e.node.name==`OrderedList`&&Aa(e.item,o,i),{range:r.cursor(t+n.length),changes:i}}{let e=Fa(u,n,l);return{range:r.cursor(c+e.length+1),changes:{from:l.from,insert:e+n.lineBreak}}}}if(d.node.name==`Blockquote`&&f&&l.from){let e=o.lineAt(l.from-1),t=/>\s*$/.exec(e.text);if(t&&t.index==d.from){let r=n.changes([{from:e.from+t.index,to:e.to},{from:l.from+d.from,to:l.to}]);return{range:i.map(r),changes:r}}}let p=[];d.node.name==`OrderedList`&&Aa(d.item,o,p);let m=d.item&&d.item.from<l.from,h=``;if(!m||/^[\s\d.)\-+*>]*/.exec(l.text)[0].length>=d.to)for(let e=0,n=u.length-1;e<=n;e++)h+=e==n&&!m?u[e].marker(o,1):u[e].blank(e<n?t(l.text,4,u[e+1].from)-h.length:null);let g=c;for(;g>l.from&&/\s/.test(l.text.charAt(g-l.from-1));)g--;return h=ja(h,n),Pa(d.node,n.doc)&&(h=Fa(u,n,l)+n.lineBreak+h),p.push({from:g,to:c,insert:n.lineBreak+h}),{range:r.cursor(g+h.length+1),changes:p}});return!s&&(i(n.update(c,{scrollIntoView:!0,userEvent:`input`})),!0)})();function Na(e){return e.name==`QuoteMark`||e.name==`ListMark`}function Pa(e,t){if(e.name!=`OrderedList`&&e.name!=`BulletList`)return!1;let n=e.firstChild,r=e.getChild(`ListItem`,`ListItem`);if(!r)return!1;let i=t.lineAt(n.to),a=t.lineAt(r.from),o=/^[\s>]*$/.test(i.text);return i.number+ +!o<a.number}function Fa(e,n,r){let i=``;for(let n=0,a=e.length-2;n<=a;n++)i+=e[n].blank(n<a?t(r.text,4,e[n+1].from)-i.length:null,n<a);return ja(i,n)}function Ia(e,t){let n=e.resolveInner(t,-1),r=t;Na(n)&&(r=n.from,n=n.parent);for(let e;e=n.childBefore(r);)if(Na(e))r=e.from;else if(e.name==`OrderedList`||e.name==`BulletList`)n=e.lastChild,r=n.to;else break;return n}var La=[{key:`Enter`,run:Ma},{key:`Backspace`,run:({state:e,dispatch:n})=>{let i=x(e),a=null,o=e.changeByRange(n=>{let o=n.from,{doc:s}=e;if(n.empty&&$.isActiveAt(e,n.from)){let n=s.lineAt(o),a=Oa(Ia(i,o),s);if(a.length){let i=a[a.length-1],s=i.to-i.spaceAfter.length+ +!!i.spaceAfter;if(o-n.from>s&&!/\S/.test(n.text.slice(s,o-n.from)))return{range:r.cursor(n.from+s),changes:{from:n.from+s,to:o}};if(o-n.from==s&&(i.item&&n.from<=i.item.from||/^[\s>]*$/.test(n.text.slice(0,i.to)))){let a=n.from+i.from;if(i.item&&i.node.from<i.item.from&&/\S/.test(n.text.slice(i.from,i.to))){let o=i.blank(t(n.text,4,i.to)-t(n.text,4,i.from));return a==n.from&&(o=ja(o,e)),{range:r.cursor(a+o.length),changes:{from:a,to:n.from+i.to,insert:o}}}if(a<o)return{range:r.cursor(a),changes:{from:a,to:o}}}}}return a={range:n}});return!a&&(n(e.update(o,{scrollIntoView:!0,userEvent:`delete`})),!0)}}],Ra=pa({matchClosingTags:!1});function za(e={}){let{codeLanguages:t,defaultCodeLanguage:r,addKeymap:i=!0,base:{parser:o}=Ta,completeHTMLTags:s=!0,pasteURLAsLink:c=!0,htmlTagLanguage:l=Ra}=e;if(!(o instanceof qe))throw RangeError("Base parser provided to `markdown` should be a Markdown parser");let u=e.extensions?[e.extensions]:[],d=[l.support,Ca],f;c&&d.push(Wa),r instanceof _?(d.push(r.support),f=r.language):r&&(f=r);let p=t||f?Ea(t,f):void 0;u.push(pt({codeParser:p,htmlParser:l.language.parser})),i&&d.push(n.high(a.of(La)));let m=wa(o.configure(u));return s&&d.push(m.data.of({autocomplete:Ba})),new _(m,d)}function Ba(e){let{state:t,pos:n}=e,r=/<[:\-\.\w\u00b7-\uffff]*$/.exec(t.sliceDoc(n-25,n));if(!r)return null;let i=x(t).resolveInner(n,-1);for(;i&&!i.type.isTop;){if(i.name==`CodeBlock`||i.name==`FencedCode`||i.name==`ProcessingInstructionBlock`||i.name==`CommentBlock`||i.name==`Link`||i.name==`Image`)return null;i=i.parent}return{from:n-r[0].length,to:n,options:Ha(),validFor:/^<[:\-\.\w\u00b7-\uffff]*$/}}var Va=null;function Ha(){if(Va)return Va;let e=oa(new pe(i.create({extensions:Ra}),0,!0));return Va=e?e.options:[]}var Ua=/code|horizontalrule|html|link|comment|processing|escape|entity|image|mark|url/i,Wa=e.domEventHandlers({paste:(e,t)=>{let{main:n}=t.state.selection;if(n.empty)return!1;let r=e.clipboardData?.getData(`text/plain`);if(!r||!/^(https?:\/\/|mailto:|xmpp:|www\.)/.test(r)||(/^www\./.test(r)&&(r=`https://`+r),!$.isActiveAt(t.state,n.from,1)))return!1;let i=x(t.state),a=!1;return i.iterate({from:n.from,to:n.to,enter:e=>{(e.from>n.from||Ua.test(e.name))&&(a=!0)},leave:e=>{e.to<n.to&&(a=!0)}}),!a&&(t.dispatch({changes:[{from:n.from,insert:`[`},{from:n.to,insert:`](${r})`}],userEvent:`input.paste`,scrollIntoView:!0}),!0)}});export{za as markdown,$ as markdownLanguage};
@@ -0,0 +1 @@
1
+ import{B as e,C as t,E as n,F as r,H as i,I as a,M as o,O as s,P as c,U as l,V as u,j as d,x as f,z as p}from"./index-CxmItXqa.js";import{c as ee,d as te,l as m,m as h,p as g,s as ne,u as re}from"./dist-DCtcCJPs.js";import{indentUnit as ie,syntaxTree as _}from"./dist-Tzoe_zm-.js";var v=class{constructor(e,t,n,r){this.state=e,this.pos=t,this.explicit=n,this.view=r,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(e){let t=_(this.state).resolveInner(this.pos,-1);for(;t&&e.indexOf(t.name)<0;)t=t.parent;return t?{from:t.from,to:this.pos,text:this.state.sliceDoc(t.from,this.pos),type:t.type}:null}matchBefore(e){let t=this.state.doc.lineAt(this.pos),n=Math.max(t.from,this.pos-250),r=t.text.slice(n-t.from,this.pos-t.from),i=r.search(se(e,!1));return i<0?null:{from:n+i,to:this.pos,text:r.slice(i)}}get aborted(){return this.abortListeners==null}addEventListener(e,t,n){e==`abort`&&this.abortListeners&&(this.abortListeners.push(t),n&&n.onDocChange&&(this.abortOnDocChange=!0))}};function y(e){let t=Object.keys(e).join(``),n=/\w/.test(t);return n&&(t=t.replace(/\w/g,``)),`[${n?`\\w`:``}${t.replace(/[^\w\s]/g,`\\$&`)}]`}function ae(e){let t=Object.create(null),n=Object.create(null);for(let{label:r}of e){t[r[0]]=!0;for(let e=1;e<r.length;e++)n[r[e]]=!0}let r=y(t)+y(n)+`*$`;return[RegExp(`^`+r),new RegExp(r)]}function b(e){let t=e.map(e=>typeof e==`string`?{label:e}:e),[n,r]=t.every(e=>/^\w+$/.test(e.label))?[/\w*$/,/\w+$/]:ae(t);return e=>{let i=e.matchBefore(r);return i||e.explicit?{from:i?i.from:e.pos,options:t,validFor:n}:null}}function oe(e,t){return n=>{for(let t=_(n.state).resolveInner(n.pos,-1);t;t=t.parent){if(e.indexOf(t.name)>-1)return null;if(t.type.isTop)break}return t(n)}}function se(e,t){let{source:n}=e,r=t&&n[0]!=`^`,i=n[n.length-1]!=`$`;return!r&&!i?e:RegExp(`${r?`^`:``}(?:${n})${i?`$`:``}`,e.flags??(e.ignoreCase?`i`:``))}var ce=d.define();typeof navigator==`object`&&navigator.platform;var x=t.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:`monospace`,whiteSpace:`nowrap`,overflow:`hidden auto`,maxWidth_fallback:`700px`,maxWidth:`min(700px, 95vw)`,minWidth:`250px`,maxHeight:`10em`,height:`100%`,listStyle:`none`,margin:0,padding:0,"& > li, & > completion-section":{padding:`1px 3px`,lineHeight:1.2},"& > li":{overflowX:`hidden`,textOverflow:`ellipsis`,cursor:`pointer`},"& > completion-section":{display:`list-item`,borderBottom:`1px solid silver`,paddingLeft:`0.5em`,opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:`#17c`,color:`white`},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:`#777`},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:`#347`,color:`white`},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:`#444`},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:`"···"`,opacity:.5,display:`block`,textAlign:`center`,cursor:`pointer`},".cm-tooltip.cm-completionInfo":{position:`absolute`,padding:`3px 9px`,width:`max-content`,maxWidth:`400px`,boxSizing:`border-box`,whiteSpace:`pre-line`},".cm-completionInfo.cm-completionInfo-left":{right:`100%`},".cm-completionInfo.cm-completionInfo-right":{left:`100%`},".cm-completionInfo.cm-completionInfo-left-narrow":{right:`30px`},".cm-completionInfo.cm-completionInfo-right-narrow":{left:`30px`},"&light .cm-snippetField":{backgroundColor:`#00000022`},"&dark .cm-snippetField":{backgroundColor:`#ffffff22`},".cm-snippetFieldPosition":{verticalAlign:`text-top`,width:0,height:`1.15em`,display:`inline-block`,margin:`0 -0.7px -.7em`,borderLeft:`1.4px dotted #888`},".cm-completionMatchedText":{textDecoration:`underline`},".cm-completionDetail":{marginLeft:`0.5em`,fontStyle:`italic`},".cm-completionIcon":{fontSize:`90%`,width:`.8em`,display:`inline-block`,textAlign:`center`,paddingRight:`.6em`,opacity:`0.6`,boxSizing:`content-box`},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:`'ƒ'`}},".cm-completionIcon-class":{"&:after":{content:`'○'`}},".cm-completionIcon-interface":{"&:after":{content:`'◌'`}},".cm-completionIcon-variable":{"&:after":{content:`'𝑥'`}},".cm-completionIcon-constant":{"&:after":{content:`'𝐶'`}},".cm-completionIcon-type":{"&:after":{content:`'𝑡'`}},".cm-completionIcon-enum":{"&:after":{content:`'∪'`}},".cm-completionIcon-property":{"&:after":{content:`'□'`}},".cm-completionIcon-keyword":{"&:after":{content:`'🔑︎'`}},".cm-completionIcon-namespace":{"&:after":{content:`'▢'`}},".cm-completionIcon-text":{"&:after":{content:`'abc'`,fontSize:`50%`,verticalAlign:`middle`}}}),S=class{constructor(e,t,n,r){this.field=e,this.line=t,this.from=n,this.to=r}},C=class e{constructor(e,t,n){this.field=e,this.from=t,this.to=n}map(t){let n=t.mapPos(this.from,-1,r.TrackDel),i=t.mapPos(this.to,1,r.TrackDel);return n==null||i==null?null:new e(this.field,n,i)}},w=class e{constructor(e,t){this.lines=e,this.fieldPositions=t}instantiate(e,t){let n=[],r=[t],i=e.doc.lineAt(t),a=/^\s*/.exec(i.text)[0];for(let i of this.lines){if(n.length){let n=a,o=/^\t*/.exec(i)[0].length;for(let t=0;t<o;t++)n+=e.facet(ie);r.push(t+n.length-o),i=n+i.slice(o)}n.push(i),t+=i.length+1}return{text:n,ranges:this.fieldPositions.map(e=>new C(e.field,r[e.line]+e.from,r[e.line]+e.to))}}static parse(t){let n=[],r=[],i=[],a;for(let e of t.split(/\r\n?|\n/)){for(;a=/[#$]\{(?:(\d+)(?::([^{}]*))?|((?:\\[{}]|[^{}])*))\}/.exec(e);){let t=a[1]?+a[1]:null,o=a[2]||a[3]||``,s=-1;t===0&&(t=1e9);let c=o.replace(/\\[{}]/g,e=>e[1]);for(let e=0;e<n.length;e++)(t==null?c&&n[e].name==c:n[e].seq==t)&&(s=e);if(s<0){let e=0;for(;e<n.length&&(t==null||n[e].seq!=null&&n[e].seq<t);)e++;n.splice(e,0,{seq:t,name:c}),s=e;for(let e of i)e.field>=s&&e.field++}for(let e of i)if(e.line==r.length&&e.from>a.index){let t=a[2]?3+(a[1]||``).length:2;e.from-=t,e.to-=t}i.push(new S(s,r.length,a.index,a.index+c.length)),e=e.slice(0,a.index)+o+e.slice(a.index+a[0].length)}e=e.replace(/\\([{}])/g,(e,t,n)=>{for(let e of i)e.line==r.length&&e.from>n&&(e.from--,e.to--);return t}),r.push(e)}return new e(r,i)}},le=f.widget({widget:new class extends n{toDOM(){let e=document.createElement(`span`);return e.className=`cm-snippetFieldPosition`,e}ignoreEvent(){return!1}}}),ue=f.mark({class:`cm-snippetField`}),T=class e{constructor(e,t){this.ranges=e,this.active=t,this.deco=f.set(e.map(e=>(e.from==e.to?le:ue).range(e.from,e.to)),!0)}map(t){let n=[];for(let e of this.ranges){let r=e.map(t);if(!r)return null;n.push(r)}return new e(n,this.active)}selectionInsideField(e){return e.ranges.every(e=>this.ranges.some(t=>t.field==this.active&&t.from<=e.from&&t.to>=e.to))}},E=e.define({map(e,t){return e&&e.map(t)}}),de=e.define(),D=u.define({create(){return null},update(e,t){for(let n of t.effects){if(n.is(E))return n.value;if(n.is(de)&&e)return new T(e.ranges,n.value)}return e&&t.docChanged&&(e=e.map(t.changes)),e&&t.selection&&!e.selectionInsideField(t.selection)&&(e=null),e},provide:e=>t.decorations.from(e,e=>e?e.deco:f.none)});function O(e,t){return o.create(e.filter(e=>e.field==t).map(e=>o.range(e.from,e.to)))}function fe(t){let n=w.parse(t);return(t,r,a,o)=>{let{text:s,ranges:c}=n.instantiate(t.state,a),{main:u}=t.state.selection,d={changes:{from:a,to:o==u.from?u.to:o,insert:i.of(s)},scrollIntoView:!0,annotations:r?[ce.of(r),l.userEvent.of(`input.complete`)]:void 0};if(c.length&&(d.selection=O(c,0)),c.some(e=>e.field>0)){let n=new T(c,0),r=d.effects=[E.of(n)];t.state.field(D,!1)===void 0&&r.push(e.appendConfig.of([D,M,P,x]))}t.dispatch(t.state.update(d))}}function k(e){return({state:t,dispatch:n})=>{let r=t.field(D,!1);if(!r||e<0&&r.active==0)return!1;let i=r.active+e,a=e>0&&!r.ranges.some(t=>t.field==i+e);return n(t.update({selection:O(r.ranges,i),effects:E.of(a?null:new T(r.ranges,i)),scrollIntoView:!0})),!0}}var A=[{key:`Tab`,run:k(1),shift:k(-1)},{key:`Escape`,run:({state:e,dispatch:t})=>e.field(D,!1)?(t(e.update({effects:E.of(null)})),!0):!1}],j=c.define({combine(e){return e.length?e[0]:A}}),M=a.highest(s.compute([j],e=>e.facet(j)));function N(e,t){return{...t,apply:fe(e)}}var P=t.domEventHandlers({mousedown(e,t){let n=t.state.field(D,!1),r;if(!n||(r=t.posAtCoords({x:e.clientX,y:e.clientY}))==null)return!1;let i=n.ranges.find(e=>e.from<=r&&e.to>=r);return!i||i.field==n.active?!1:(t.dispatch({selection:O(n.ranges,i.field),effects:E.of(n.ranges.some(e=>e.field>i.field)?new T(n.ranges,i.field):null),scrollIntoView:!0}),!0)}}),F=new class extends p{};F.startSide=1,F.endSide=-1,typeof navigator==`object`&&navigator.userAgent;var I=class e{constructor(e,t,n,r,i,a,o,s,c,l=0,u){this.p=e,this.stack=t,this.state=n,this.reducePos=r,this.pos=i,this.score=a,this.buffer=o,this.bufferBase=s,this.curContext=c,this.lookAhead=l,this.parent=u}toString(){return`[${this.stack.filter((e,t)=>t%3==0).concat(this.state)}]@${this.pos}${this.score?`!`+this.score:``}`}static start(t,n,r=0){let i=t.parser.context;return new e(t,[],n,r,r,0,[],0,i?new L(i,i.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(e,t){this.stack.push(this.state,t,this.bufferBase+this.buffer.length),this.state=e}reduce(e){let t=e>>19,n=e&65535,{parser:r}=this.p,i=this.reducePos<this.pos-25&&this.setLookAhead(this.pos),a=r.dynamicPrecedence(n);if(a&&(this.score+=a),t==0){n<r.minRepeatTerm&&this.reducePos<this.pos&&(this.reducePos=this.pos),this.pushState(r.getGoto(this.state,n,!0),this.reducePos),n<r.minRepeatTerm&&this.storeNode(n,this.reducePos,this.reducePos,i?8:4,!0),this.reduceContext(n,this.reducePos);return}let o=this.stack.length-(t-1)*3-(e&262144?6:0),s=o?this.stack[o-2]:this.p.ranges[0].from;n<r.minRepeatTerm&&s==this.reducePos&&this.reducePos<this.pos&&(this.reducePos=this.pos);let c=this.reducePos-s;c>=2e3&&!this.p.parser.nodeSet.types[n]?.isAnonymous&&(s==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=c):this.p.lastBigReductionSize<c&&(this.p.bigReductionCount=1,this.p.lastBigReductionStart=s,this.p.lastBigReductionSize=c));let l=o?this.stack[o-1]:0,u=this.bufferBase+this.buffer.length-l;if(n<r.minRepeatTerm||e&131072){let e=r.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(n,s,e,u+4,!0)}if(e&262144)this.state=this.stack[o];else{let e=this.stack[o-3];this.state=r.getGoto(e,n,!0)}for(;this.stack.length>o;)this.stack.pop();this.reduceContext(n,s)}storeNode(e,t,n,r=4,i=!1){if(e==0&&(!this.stack.length||this.stack[this.stack.length-1]<this.buffer.length+this.bufferBase)){let e=this.buffer.length;if(e>0&&this.buffer[e-4]==0&&this.buffer[e-1]>-1){if(t==n)return;if(this.buffer[e-2]>=t){this.buffer[e-2]=n;return}}}if(!i||this.pos==n)this.buffer.push(e,t,n,r);else{let i=this.buffer.length;if(i>0&&(this.buffer[i-4]!=0||this.buffer[i-1]<0)){let e=!1;for(let t=i;t>0&&this.buffer[t-2]>n;t-=4)if(this.buffer[t-1]>=0){e=!0;break}if(e)for(;i>0&&this.buffer[i-2]>n;)this.buffer[i]=this.buffer[i-4],this.buffer[i+1]=this.buffer[i-3],this.buffer[i+2]=this.buffer[i-2],this.buffer[i+3]=this.buffer[i-1],i-=4,r>4&&(r-=4)}this.buffer[i]=e,this.buffer[i+1]=t,this.buffer[i+2]=n,this.buffer[i+3]=r}}shift(e,t,n,r){if(e&131072)this.pushState(e&65535,this.pos);else if(e&262144)this.pos=r,this.shiftContext(t,n),t<=this.p.parser.maxNode&&this.buffer.push(t,n,r,4);else{let i=e,{parser:a}=this.p;this.pos=r;let o=a.stateFlag(i,1);!o&&(r>n||t<=a.maxNode)&&(this.reducePos=r),this.pushState(i,o?n:Math.min(n,this.reducePos)),this.shiftContext(t,n),t<=a.maxNode&&this.buffer.push(t,n,r,4)}}apply(e,t,n,r){e&65536?this.reduce(e):this.shift(e,t,n,r)}useNode(e,t,n){let r=this.p.reused.length-1;(r<0||this.p.reused[r]!=e)&&(this.p.reused.push(e),r++);let i=this.reducePos=this.pos=n+e.length;this.pushState(t,n),this.buffer.push(r,n,i,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,e,this,this.p.stream.reset(this.pos-e.length)))}split(){let t=this,n=t.buffer.length;for(n&&t.buffer[n-4]==0&&(n-=4);n>0&&t.buffer[n-2]>t.reducePos;)n-=4;let r=t.buffer.slice(n),i=t.bufferBase+n;for(;t&&i==t.bufferBase;)t=t.parent;return new e(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,r,i,this.curContext,this.lookAhead,t)}recoverByDelete(e,t){let n=e<=this.p.parser.maxNode;n&&this.storeNode(e,this.pos,t,4),this.storeNode(0,this.pos,t,n?8:4),this.pos=this.reducePos=t,this.score-=190}canShift(e){for(let t=new R(this);;){let n=this.p.parser.stateSlot(t.state,4)||this.p.parser.hasAction(t.state,e);if(n==0)return!1;if(!(n&65536))return!0;t.reduce(n)}}recoverByInsert(e){if(this.stack.length>=300)return[];let t=this.p.parser.nextStates(this.state);if(t.length>8||this.stack.length>=120){let n=[];for(let r=0,i;r<t.length;r+=2)(i=t[r+1])!=this.state&&this.p.parser.hasAction(i,e)&&n.push(t[r],i);if(this.stack.length<120)for(let e=0;n.length<8&&e<t.length;e+=2){let r=t[e+1];n.some((e,t)=>t&1&&e==r)||n.push(t[e],r)}t=n}let n=[];for(let e=0;e<t.length&&n.length<4;e+=2){let r=t[e+1];if(r==this.state)continue;let i=this.split();i.pushState(r,this.pos),i.storeNode(0,i.pos,i.pos,4,!0),i.shiftContext(t[e],this.pos),i.reducePos=this.pos,i.score-=200,n.push(i)}return n}forceReduce(){let{parser:e}=this.p,t=e.stateSlot(this.state,5);if(!(t&65536))return!1;if(!e.validAction(this.state,t)){let n=t>>19,r=t&65535,i=this.stack.length-n*3;if(i<0||e.getGoto(this.stack[i],r,!1)<0){let e=this.findForcedReduction();if(e==null)return!1;t=e}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(t),!0}findForcedReduction(){let{parser:e}=this.p,t=[],n=(r,i)=>{if(!t.includes(r))return t.push(r),e.allActions(r,t=>{if(!(t&393216)){if(t&65536){let n=(t>>19)-i;if(n>1){let r=t&65535,i=this.stack.length-n*3;if(i>=0&&e.getGoto(this.stack[i],r,!1)>=0)return n<<19|65536|r}}else{let e=n(t,i+1);if(e!=null)return e}}})};return n(this.state,0)}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(this.stack.length!=3)return!1;let{parser:e}=this.p;return e.data[e.stateSlot(this.state,1)]==65535&&!e.stateSlot(this.state,4)}restart(){this.storeNode(0,this.pos,this.pos,4,!0),this.state=this.stack[0],this.stack.length=0}sameState(e){if(this.state!=e.state||this.stack.length!=e.stack.length)return!1;for(let t=0;t<this.stack.length;t+=3)if(this.stack[t]!=e.stack[t])return!1;return!0}get parser(){return this.p.parser}dialectEnabled(e){return this.p.parser.dialect.flags[e]}shiftContext(e,t){this.curContext&&this.updateContext(this.curContext.tracker.shift(this.curContext.context,e,this,this.p.stream.reset(t)))}reduceContext(e,t){this.curContext&&this.updateContext(this.curContext.tracker.reduce(this.curContext.context,e,this,this.p.stream.reset(t)))}emitContext(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-3)&&this.storeNode(this.curContext.hash,this.reducePos,this.reducePos,-3,!0)}emitLookAhead(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-4)&&this.buffer.push(this.lookAhead,this.pos,this.pos,-4)}updateContext(e){if(e!=this.curContext.context){let t=new L(this.curContext.tracker,e);t.hash!=this.curContext.hash&&this.emitContext(),this.curContext=t}}setLookAhead(e){return e<=this.lookAhead?!1:(this.emitLookAhead(),this.lookAhead=e,!0)}close(){this.curContext&&this.curContext.tracker.strict&&this.emitContext(),this.lookAhead>0&&this.emitLookAhead()}},L=class{constructor(e,t){this.tracker=e,this.context=t,this.hash=e.strict?e.hash(t):0}},R=class{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let t=e&65535,n=e>>19;n==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(n-1)*3;let r=this.start.p.parser.getGoto(this.stack[this.base-3],t,!0);this.state=r}},z=class e{constructor(e,t,n){this.stack=e,this.pos=t,this.index=n,this.buffer=e.buffer,this.index==0&&this.maybeNext()}static create(t,n=t.bufferBase+t.buffer.length){return new e(t,n,n-t.bufferBase)}maybeNext(){let e=this.stack.parent;e!=null&&(this.index=this.stack.bufferBase-e.bufferBase,this.stack=e,this.buffer=e.buffer)}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}next(){this.index-=4,this.pos-=4,this.index==0&&this.maybeNext()}fork(){return new e(this.stack,this.pos,this.index)}};function B(e,t=Uint16Array){if(typeof e!=`string`)return e;let n=null;for(let r=0,i=0;r<e.length;){let a=0;for(;;){let t=e.charCodeAt(r++),n=!1;if(t==126){a=65535;break}t>=92&&t--,t>=34&&t--;let i=t-32;if(i>=46&&(i-=46,n=!0),a+=i,n)break;a*=46}n?n[i++]=a:n=new t(a)}return n}var V=class{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}},H=new V,pe=class{constructor(e,t){this.input=e,this.ranges=t,this.chunk=``,this.chunkOff=0,this.chunk2=``,this.chunk2Pos=0,this.next=-1,this.token=H,this.rangeIndex=0,this.pos=this.chunkPos=t[0].from,this.range=t[0],this.end=t[t.length-1].to,this.readNext()}resolveOffset(e,t){let n=this.range,r=this.rangeIndex,i=this.pos+e;for(;i<n.from;){if(!r)return null;let e=this.ranges[--r];i-=n.from-e.to,n=e}for(;t<0?i>n.to:i>=n.to;){if(r==this.ranges.length-1)return null;let e=this.ranges[++r];i+=e.from-n.to,n=e}return i}clipPos(e){if(e>=this.range.from&&e<this.range.to)return e;for(let t of this.ranges)if(t.to>e)return Math.max(e,t.from);return this.end}peek(e){let t=this.chunkOff+e,n,r;if(t>=0&&t<this.chunk.length)n=this.pos+e,r=this.chunk.charCodeAt(t);else{let t=this.resolveOffset(e,1);if(t==null)return-1;if(n=t,n>=this.chunk2Pos&&n<this.chunk2Pos+this.chunk2.length)r=this.chunk2.charCodeAt(n-this.chunk2Pos);else{let e=this.rangeIndex,t=this.range;for(;t.to<=n;)t=this.ranges[++e];this.chunk2=this.input.chunk(this.chunk2Pos=n),n+this.chunk2.length>t.to&&(this.chunk2=this.chunk2.slice(0,t.to-n)),r=this.chunk2.charCodeAt(0)}}return n>=this.token.lookAhead&&(this.token.lookAhead=n+1),r}acceptToken(e,t=0){let n=t?this.resolveOffset(t,-1):this.pos;if(n==null||n<this.token.start)throw RangeError(`Token end out of bounds`);this.token.value=e,this.token.end=n}acceptTokenTo(e,t){this.token.value=e,this.token.end=t}getChunk(){if(this.pos>=this.chunk2Pos&&this.pos<this.chunk2Pos+this.chunk2.length){let{chunk:e,chunkPos:t}=this;this.chunk=this.chunk2,this.chunkPos=this.chunk2Pos,this.chunk2=e,this.chunk2Pos=t,this.chunkOff=this.pos-this.chunkPos}else{this.chunk2=this.chunk,this.chunk2Pos=this.chunkPos;let e=this.input.chunk(this.pos),t=this.pos+e.length;this.chunk=t>this.range.to?e.slice(0,this.range.to-this.pos):e,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.next=this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?-1:this.chunk.charCodeAt(this.chunkOff)}advance(e=1){for(this.chunkOff+=e;this.pos+e>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();e-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=e,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk=``,this.next=-1}reset(e,t){if(t?(this.token=t,t.start=e,t.lookAhead=e+1,t.value=t.extended=-1):this.token=H,this.pos!=e){if(this.pos=e,e==this.end)return this.setDone(),this;for(;e<this.range.from;)this.range=this.ranges[--this.rangeIndex];for(;e>=this.range.to;)this.range=this.ranges[++this.rangeIndex];e>=this.chunkPos&&e<this.chunkPos+this.chunk.length?this.chunkOff=e-this.chunkPos:(this.chunk=``,this.chunkOff=0),this.readNext()}return this}read(e,t){if(e>=this.chunkPos&&t<=this.chunkPos+this.chunk.length)return this.chunk.slice(e-this.chunkPos,t-this.chunkPos);if(e>=this.chunk2Pos&&t<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(e-this.chunk2Pos,t-this.chunk2Pos);if(e>=this.range.from&&t<=this.range.to)return this.input.read(e,t);let n=``;for(let r of this.ranges){if(r.from>=t)break;r.to>e&&(n+=this.input.read(Math.max(r.from,e),Math.min(r.to,t)))}return n}},U=class{constructor(e,t){this.data=e,this.id=t}token(e,t){let{parser:n}=t.p;G(this.data,e,t,this.id,n.data,n.tokenPrecTable)}};U.prototype.contextual=U.prototype.fallback=U.prototype.extend=!1;var W=class{constructor(e,t,n){this.precTable=t,this.elseToken=n,this.data=typeof e==`string`?B(e):e}token(e,t){let n=e.pos,r=0;for(;;){let n=e.next<0,i=e.resolveOffset(1,1);if(G(this.data,e,t,0,this.data,this.precTable),e.token.value>-1)break;if(this.elseToken==null)return;if(n||r++,i==null)break;e.reset(i,e.token)}r&&(e.reset(n,e.token),e.acceptToken(this.elseToken,r))}};W.prototype.contextual=U.prototype.fallback=U.prototype.extend=!1;var me=class{constructor(e,t={}){this.token=e,this.contextual=!!t.contextual,this.fallback=!!t.fallback,this.extend=!!t.extend}};function G(e,t,n,r,i,a){let o=0,s=1<<r,{dialect:c}=n.p.parser;scan:for(;(s&e[o])!=0;){let n=e[o+1];for(let r=o+3;r<n;r+=2)if((e[r+1]&s)>0){let n=e[r];if(c.allows(n)&&(t.token.value==-1||t.token.value==n||he(n,t.token.value,i,a))){t.acceptToken(n);break}}let r=t.next,l=0,u=e[o+2];if(t.next<0&&u>l&&e[n+u*3-3]==65535){o=e[n+u*3-1];continue scan}for(;l<u;){let i=l+u>>1,a=n+i+(i<<1),s=e[a],c=e[a+1]||65536;if(r<s)u=i;else if(r>=c)l=i+1;else{o=e[a+2],t.advance();continue scan}}break}}function K(e,t,n){for(let r=t,i;(i=e[r])!=65535;r++)if(i==n)return r-t;return-1}function he(e,t,n,r){let i=K(n,r,t);return i<0||K(n,r,e)<i}var q=typeof process<`u`&&/\bparse\b/.test({}.LOG),J=null;function Y(e,t,n){let r=e.cursor(ee.IncludeAnonymous);for(r.moveTo(t);;)if(!(n<0?r.childBefore(t):r.childAfter(t)))for(;;){if((n<0?r.to<t:r.from>t)&&!r.type.isError)return n<0?Math.max(0,Math.min(r.to-1,t-25)):Math.min(e.length,Math.max(r.from+1,t+25));if(n<0?r.prevSibling():r.nextSibling())break;if(!r.parent())return n<0?0:e.length}}var ge=class{constructor(e,t){this.fragments=e,this.minRepeat=t,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.lastRepeat=null,this.lastRepeatPos=-1,this.nextFragment()}nextFragment(){let e=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(e){for(this.safeFrom=e.openStart?Y(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?Y(e.tree,e.to+e.offset,-1)-e.offset:e.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(e.tree),this.start.push(-e.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(e){if(e<this.nextStart)return null;for(;this.fragment&&this.safeTo<=e;)this.nextFragment();if(!this.fragment)return null;for(;;){let t=this.trees.length-1;if(t<0)return this.nextFragment(),null;let n=this.trees[t],r=this.index[t];if(r==n.children.length){this.trees.pop(),this.start.pop(),this.index.pop();continue}let i=n.children[r],a=this.start[t]+n.positions[r];if(a>e)return this.nextStart=a,null;if(i instanceof h){let n=a>this.lastRepeatPos&&i.type.id>=this.minRepeat;if(a==e||n){let t=a+i.length,r;if(a>=this.safeFrom&&t<=this.safeTo&&(!(r=i.prop(m.lookAhead))||t+r<this.fragment.to)){if(n&&(this.lastRepeat=i,this.lastRepeatPos=a),a==e)return i}else if(a==e)return null}this.index[t]++,a+i.length>=Math.max(this.safeFrom,e)&&(this.trees.push(i),this.start.push(a),this.index.push(0))}else this.index[t]++,this.nextStart=a+i.length}}},_e=class{constructor(e,t){this.stream=t,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(e=>new V)}getActions(e){let t=0,n=null,{parser:r}=e.p,{tokenizers:i}=r,a=r.stateSlot(e.state,3),o=e.curContext?e.curContext.hash:0,s=0;for(let r=0;r<i.length;r++){if(!(1<<r&a))continue;let c=i[r],l=this.tokens[r];if((!n||c.fallback)&&((c.contextual||l.start!=e.pos||l.mask!=a||l.context!=o)&&(this.updateCachedToken(l,c,e),l.mask=a,l.context=o),l.lookAhead>l.end+25&&(s=Math.max(l.lookAhead,s)),l.value!=0)){let r=t;if(l.extended>-1&&(t=this.addActions(e,l.extended,l.end,t)),t=this.addActions(e,l.value,l.end,t),!c.extend&&(n=l,t>r))break}}for(;this.actions.length>t;)this.actions.pop();return s&&e.setLookAhead(s),!n&&e.pos==this.stream.end&&(n=new V,n.value=e.p.parser.eofTerm,n.start=n.end=e.pos,t=this.addActions(e,n.value,n.end,t)),this.mainToken=n,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let t=new V,{pos:n,p:r}=e;return t.start=n,t.end=Math.min(n+1,r.stream.end),t.value=n==r.stream.end?r.parser.eofTerm:0,t}updateCachedToken(e,t,n){let r=this.stream.clipPos(n.pos);if(t.token(this.stream.reset(r,e),n),e.value>-1){let{parser:t}=n.p;for(let r=0;r<t.specialized.length;r++)if(t.specialized[r]==e.value){let i=t.specializers[r](this.stream.read(e.start,e.end),n);if(i>=0&&n.p.parser.dialect.allows(i>>1)){i&1?e.extended=i>>1:e.value=i>>1;break}}}else e.value=0,e.end=this.stream.clipPos(r+1)}putAction(e,t,n,r){for(let t=0;t<r;t+=3)if(this.actions[t]==e)return r;return this.actions[r++]=e,this.actions[r++]=t,this.actions[r++]=n,r}addActions(e,t,n,r){let{state:i}=e,{parser:a}=e.p,{data:o}=a;for(let e=0;e<2;e++)for(let s=a.stateSlot(i,e?2:1);;s+=3){if(o[s]==65535){if(o[s+1]==1)s=Q(o,s+2);else{r==0&&o[s+1]==2&&(r=this.putAction(Q(o,s+2),t,n,r));break}}o[s]==t&&(r=this.putAction(Q(o,s+1),t,n,r))}return r}},ve=class{constructor(e,t,n,r){this.parser=e,this.input=t,this.ranges=r,this.recovering=0,this.nextStackID=9812,this.minStackPos=0,this.reused=[],this.stoppedAt=null,this.lastBigReductionStart=-1,this.lastBigReductionSize=0,this.bigReductionCount=0,this.stream=new pe(t,r),this.tokens=new _e(e,this.stream),this.topTerm=e.top[1];let{from:i}=r[0];this.stacks=[I.start(this,e.top[0],i)],this.fragments=n.length&&this.stream.end-i>e.bufferLength*4?new ge(n,e.minRepeatTerm):null}get parsedPos(){return this.minStackPos}advance(){let e=this.stacks,t=this.minStackPos,n=this.stacks=[],r,i;if(this.bigReductionCount>300&&e.length==1){let[t]=e;for(;t.forceReduce()&&t.stack.length&&t.stack[t.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let a=0;a<e.length;a++){let o=e[a];for(;;){if(this.tokens.mainToken=null,o.pos>t)n.push(o);else if(this.advanceStack(o,n,e))continue;else{r||(r=[],i=[]),r.push(o);let e=this.tokens.getMainToken(o);i.push(e.value,e.end)}break}}if(!n.length){let e=r&&Se(r);if(e)return q&&console.log(`Finish with `+this.stackID(e)),this.stackToTree(e);if(this.parser.strict)throw q&&r&&console.log(`Stuck with token `+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):`none`)),SyntaxError(`No parse at `+t);this.recovering||=5}if(this.recovering&&r){let e=this.stoppedAt!=null&&r[0].pos>this.stoppedAt?r[0]:this.runRecovery(r,i,n);if(e)return q&&console.log(`Force-finish `+this.stackID(e)),this.stackToTree(e.forceAll())}if(this.recovering){let e=this.recovering==1?1:this.recovering*3;if(n.length>e)for(n.sort((e,t)=>t.score-e.score);n.length>e;)n.pop();n.some(e=>e.reducePos>t)&&this.recovering--}else if(n.length>1){outer:for(let e=0;e<n.length-1;e++){let t=n[e];for(let r=e+1;r<n.length;r++){let i=n[r];if(t.sameState(i)||t.buffer.length>500&&i.buffer.length>500){if((t.score-i.score||t.buffer.length-i.buffer.length)>0)n.splice(r--,1);else{n.splice(e--,1);continue outer}}}}n.length>12&&(n.sort((e,t)=>t.score-e.score),n.splice(12,n.length-12))}this.minStackPos=n[0].pos;for(let e=1;e<n.length;e++)n[e].pos<this.minStackPos&&(this.minStackPos=n[e].pos);return null}stopAt(e){if(this.stoppedAt!=null&&this.stoppedAt<e)throw RangeError(`Can't move stoppedAt forward`);this.stoppedAt=e}tryReuse(e,t,n,r){if(!n)return null;let i=e.curContext&&e.curContext.tracker.strict,a=i?e.curContext.hash:0;for(;n;){let o=this.parser.nodeSet.types[n.type.id]==n.type?this.parser.getGoto(e.state,n.type.id):-1;if(o>-1&&n.length&&(!i||(n.prop(m.contextHash)||0)==a))return e.useNode(n,o,t),n;if(n.children.length==0||n.positions[0]>0)break;let s=n.children[0];if(s instanceof h&&(!r||s.type.id>=this.parser.minRepeatTerm))n=s;else break}return null}advanceStack(e,t,n){let r=e.pos,{parser:i}=this,a=q?this.stackID(e)+` -> `:``;if(this.stoppedAt!=null&&r>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let t=e.reducePos<r&&e.buffer.length&&e.buffer[e.buffer.length-2]<=e.reducePos&&this.fragments.lastRepeatPos==e.reducePos&&this.tryReuse(e,e.reducePos,this.fragments.lastRepeat,!0)||this.tryReuse(e,r,this.fragments.nodeAt(r),!1);if(t)return q&&console.log(a+this.stackID(e)+` (via reuse of ${i.getName(t.type.id)})`),!0}let o=i.stateSlot(e.state,4);if(o>0)return e.reduce(o),q&&console.log(a+this.stackID(e)+` (via always-reduce ${i.getName(o&65535)})`),!0;if(e.stack.length>=8400)for(;e.stack.length>6e3&&e.forceReduce(););let s=this.tokens.getActions(e);for(let o=0;o<s.length;){let c=s[o++],l=s[o++],u=s[o++],d=o==s.length||!n,f=d?e:e.split(),p=this.tokens.mainToken;if(f.apply(c,l,p?p.start:f.pos,u),q&&console.log(a+this.stackID(f)+` (via ${c&65536?`reduce of ${i.getName(c&65535)}`:`shift`} for ${i.getName(l)} @ ${r}${f==e?``:`, split`})`),d)return!0;f.pos>r?t.push(f):n.push(f)}return!1}advanceFully(e,t){let n=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>n)return X(e,t),!0}}runRecovery(e,t,n){let r=null,i=!1;for(let a=0;a<e.length;a++){let o=e[a],s=t[a<<1],c=t[(a<<1)+1],l=q?this.stackID(o)+` -> `:``;if(o.deadEnd&&(i||(i=!0,o.restart(),q&&console.log(l+this.stackID(o)+` (restarted)`),this.advanceFully(o,n))))continue;let u=o.split(),d=l;for(let e=0;e<10&&u.forceReduce()&&(q&&console.log(d+this.stackID(u)+` (via force-reduce)`),!this.advanceFully(u,n));e++)q&&(d=this.stackID(u)+` -> `);for(let e of o.recoverByInsert(s))q&&console.log(l+this.stackID(e)+` (via recover-insert)`),this.advanceFully(e,n);this.stream.end>o.pos?(c==o.pos&&(c++,s=0),o.recoverByDelete(s,c),q&&console.log(l+this.stackID(o)+` (via recover-delete ${this.parser.getName(s)})`),X(o,n)):(!r||r.score<u.score)&&(r=u)}return r}stackToTree(e){return e.close(),h.build({buffer:z.create(e),nodeSet:this.parser.nodeSet,topID:this.topTerm,maxBufferLength:this.parser.bufferLength,reused:this.reused,start:this.ranges[0].from,length:e.pos-this.ranges[0].from,minRepeatType:this.parser.minRepeatTerm})}stackID(e){let t=(J||=new WeakMap).get(e);return t||J.set(e,t=String.fromCodePoint(this.nextStackID++)),t+e}};function X(e,t){for(let n=0;n<t.length;n++){let r=t[n];if(r.pos==e.pos&&r.sameState(e)){t[n].score<e.score&&(t[n]=e);return}}t.push(e)}var ye=class{constructor(e,t,n){this.source=e,this.flags=t,this.disabled=n}allows(e){return!this.disabled||this.disabled[e]==0}},Z=e=>e,be=class{constructor(e){this.start=e.start,this.shift=e.shift||Z,this.reduce=e.reduce||Z,this.reuse=e.reuse||Z,this.hash=e.hash||(()=>0),this.strict=e.strict!==!1}},xe=class e extends g{constructor(e){if(super(),this.wrappers=[],e.version!=14)throw RangeError(`Parser version (${e.version}) doesn't match runtime version (14)`);let t=e.nodeNames.split(` `);this.minRepeatTerm=t.length;for(let n=0;n<e.repeatNodeCount;n++)t.push(``);let n=Object.keys(e.topRules).map(t=>e.topRules[t][1]),r=[];for(let e=0;e<t.length;e++)r.push([]);function i(e,t,n){r[e].push([t,t.deserialize(String(n))])}if(e.nodeProps)for(let t of e.nodeProps){let e=t[0];typeof e==`string`&&(e=m[e]);for(let n=1;n<t.length;){let r=t[n++];if(r>=0)i(r,e,t[n++]);else{let a=t[n+-r];for(let o=-r;o>0;o--)i(t[n++],e,a);n++}}}this.nodeSet=new re(t.map((t,i)=>te.define({name:i>=this.minRepeatTerm?void 0:t,id:i,props:r[i],top:n.indexOf(i)>-1,error:i==0,skipped:e.skippedNodes&&e.skippedNodes.indexOf(i)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=ne;let a=B(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let e=0;e<this.specializerSpecs.length;e++)this.specialized[e]=this.specializerSpecs[e].term;this.specializers=this.specializerSpecs.map($),this.states=B(e.states,Uint32Array),this.data=B(e.stateData),this.goto=B(e.goto),this.maxTerm=e.maxTerm,this.tokenizers=e.tokenizers.map(e=>typeof e==`number`?new U(a,e):e),this.topRules=e.topRules,this.dialects=e.dialects||{},this.dynamicPrecedences=e.dynamicPrecedences||null,this.tokenPrecTable=e.tokenPrec,this.termNames=e.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(e,t,n){let r=new ve(this,e,t,n);for(let i of this.wrappers)r=i(r,e,t,n);return r}getGoto(e,t,n=!1){let r=this.goto;if(t>=r[0])return-1;for(let i=r[t+1];;){let t=r[i++],a=t&1,o=r[i++];if(a&&n)return o;for(let n=i+(t>>1);i<n;i++)if(r[i]==e)return o;if(a)return-1}}hasAction(e,t){let n=this.data;for(let r=0;r<2;r++)for(let i=this.stateSlot(e,r?2:1),a;;i+=3){if((a=n[i])==65535){if(n[i+1]==1)a=n[i=Q(n,i+2)];else if(n[i+1]==2)return Q(n,i+2);else break}if(a==t||a==0)return Q(n,i+1)}return 0}stateSlot(e,t){return this.states[e*6+t]}stateFlag(e,t){return(this.stateSlot(e,0)&t)>0}validAction(e,t){return!!this.allActions(e,e=>e==t||null)}allActions(e,t){let n=this.stateSlot(e,4),r=n?t(n):void 0;for(let n=this.stateSlot(e,1);r==null;n+=3){if(this.data[n]==65535){if(this.data[n+1]==1)n=Q(this.data,n+2);else break}r=t(Q(this.data,n+1))}return r}nextStates(e){let t=[];for(let n=this.stateSlot(e,1);;n+=3){if(this.data[n]==65535){if(this.data[n+1]==1)n=Q(this.data,n+2);else break}if(!(this.data[n+2]&1)){let e=this.data[n+1];t.some((t,n)=>n&1&&t==e)||t.push(this.data[n],e)}}return t}configure(t){let n=Object.assign(Object.create(e.prototype),this);if(t.props&&(n.nodeSet=this.nodeSet.extend(...t.props)),t.top){let e=this.topRules[t.top];if(!e)throw RangeError(`Invalid top rule name ${t.top}`);n.top=e}return t.tokenizers&&(n.tokenizers=this.tokenizers.map(e=>{let n=t.tokenizers.find(t=>t.from==e);return n?n.to:e})),t.specializers&&(n.specializers=this.specializers.slice(),n.specializerSpecs=this.specializerSpecs.map((e,r)=>{let i=t.specializers.find(t=>t.from==e.external);if(!i)return e;let a=Object.assign(Object.assign({},e),{external:i.to});return n.specializers[r]=$(a),a})),t.contextTracker&&(n.context=t.contextTracker),t.dialect&&(n.dialect=this.parseDialect(t.dialect)),t.strict!=null&&(n.strict=t.strict),t.wrap&&(n.wrappers=n.wrappers.concat(t.wrap)),t.bufferLength!=null&&(n.bufferLength=t.bufferLength),n}hasWrappers(){return this.wrappers.length>0}getName(e){return this.termNames?this.termNames[e]:String(e<=this.maxNode&&this.nodeSet.types[e].name||e)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(e){let t=this.dynamicPrecedences;return t==null?0:t[e]||0}parseDialect(e){let t=Object.keys(this.dialects),n=t.map(()=>!1);if(e)for(let r of e.split(` `)){let e=t.indexOf(r);e>=0&&(n[e]=!0)}let r=null;for(let e=0;e<t.length;e++)if(!n[e])for(let n=this.dialects[t[e]],i;(i=this.data[n++])!=65535;)(r||=new Uint8Array(this.maxTerm+1))[i]=1;return new ye(e,n,r)}static deserialize(t){return new e(t)}};function Q(e,t){return e[t]|e[t+1]<<16}function Se(e){let t=null;for(let n of e){let e=n.p.stoppedAt;(n.pos==n.p.stream.end||e!=null&&n.pos>e)&&n.p.parser.stateFlag(n.state,2)&&(!t||t.score<n.score)&&(t=n)}return t}function $(e){if(e.external){let t=+!!e.extend;return(n,r)=>e.external(n,r)<<1|t}return e.get}export{v as a,N as c,W as i,me as n,b as o,xe as r,oe as s,be as t};
@@ -0,0 +1,3 @@
1
+ import{A as e,B as t,C as n,D as r,E as i,G as a,I as o,L as s,N as c,P as l,R as u,S as d,T as f,V as ee,W as te,k as ne,w as re,x as p}from"./index-CxmItXqa.js";import{a as ie,c as ae,d as m,h,i as oe,l as g,m as _,o as v,p as se,r as ce,u as le}from"./dist-DCtcCJPs.js";function ue(e,t,n,r=0,i=0){t??(t=e.search(/[^\s\u00a0]/),t==-1&&(t=e.length));let a=i;for(let i=r;i<t;i++)e.charCodeAt(i)==9?a+=n-a%n:a++;return a}var y=class{constructor(e,t,n,r){this.string=e,this.tabSize=t,this.indentUnit=n,this.overrideIndent=r,this.pos=0,this.start=0,this.lastColumnPos=0,this.lastColumnValue=0}eol(){return this.pos>=this.string.length}sol(){return this.pos==0}peek(){return this.string.charAt(this.pos)||void 0}next(){if(this.pos<this.string.length)return this.string.charAt(this.pos++)}eat(e){let t=this.string.charAt(this.pos),n;if(n=typeof e==`string`?t==e:t&&(e instanceof RegExp?e.test(t):e(t)),n)return++this.pos,t}eatWhile(e){let t=this.pos;for(;this.eat(e););return this.pos>t}eatSpace(){let e=this.pos;for(;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>e}skipToEnd(){this.pos=this.string.length}skipTo(e){let t=this.string.indexOf(e,this.pos);if(t>-1)return this.pos=t,!0}backUp(e){this.pos-=e}column(){return this.lastColumnPos<this.start&&(this.lastColumnValue=ue(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start),this.lastColumnValue}indentation(){return this.overrideIndent??ue(this.string,null,this.tabSize)}match(e,t,n){if(typeof e==`string`){let r=e=>n?e.toLowerCase():e;return r(this.string.substr(this.pos,e.length))==r(e)?(t!==!1&&(this.pos+=e.length),!0):null}{let n=this.string.slice(this.pos).match(e);return n&&n.index>0?null:(n&&t!==!1&&(this.pos+=n[0].length),n)}}current(){return this.string.slice(this.start,this.pos)}},b=new g;function x(e){return l.define({combine:e?t=>t.concat(e):void 0})}var de=new g,S=class{constructor(e,t,n=[],r=``){this.data=e,this.name=r,c.prototype.hasOwnProperty(`tree`)||Object.defineProperty(c.prototype,"tree",{get(){return C(this)}}),this.parser=t,this.extension=[O.of(this),c.languageData.of((e,t,n)=>{let r=fe(e,t,n),i=r.type.prop(b);if(!i)return[];let a=e.facet(i),o=r.type.prop(de);if(o){let i=r.resolve(t-r.from,n);for(let t of o)if(t.test(i,e)){let n=e.facet(t.facet);return t.type==`replace`?n:n.concat(a)}}return a})].concat(n)}isActiveAt(e,t,n=-1){return fe(e,t,n).type.prop(b)==this.data}findRegions(e){let t=e.facet(O);if(t?.data==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let n=[],r=(e,t)=>{if(e.prop(b)==this.data){n.push({from:t,to:t+e.length});return}let i=e.prop(g.mounted);if(i){if(i.tree.prop(b)==this.data){if(i.overlay)for(let e of i.overlay)n.push({from:e.from+t,to:e.to+t});else n.push({from:t,to:t+e.length});return}if(i.overlay){let e=n.length;if(r(i.tree,i.overlay[0].from+t),n.length>e)return}}for(let n=0;n<e.children.length;n++){let i=e.children[n];i instanceof _&&r(i,e.positions[n]+t)}};return r(C(e),0),n}get allowsNesting(){return!0}};S.setState=t.define();function fe(e,t,n){let r=e.facet(O),i=C(e).topNode;if(!r||r.allowsNesting)for(let e=i;e;e=e.enter(t,n,ae.ExcludeBuffers|ae.EnterBracketed))e.type.isTop&&(i=e);return i}var pe=class e extends S{constructor(e,t,n){super(e,t,[],n),this.parser=t}static define(t){let n=x(t.languageData);return new e(n,t.parser.configure({props:[b.add(e=>e.isTop?n:void 0)]}),t.name)}configure(t,n){return new e(this.data,this.parser.configure(t),n||this.name)}get allowsNesting(){return this.parser.hasWrappers()}};function C(e){let t=e.field(S.state,!1);return t?t.tree:_.empty}function me(e,t,n=50){let r=e.field(S.state,!1)?.context;if(!r)return null;let i=r.viewport;r.updateViewport({from:0,to:t});let a=r.isDone(t)||r.work(n,t)?r.tree:null;return r.updateViewport(i),a}function he(e,t=e.doc.length){return e.field(S.state,!1)?.context.isDone(t)||!1}function ge(e,t=e.viewport.to,n=100){let r=me(e.state,t,n);return r!=C(e.state)&&e.dispatch({}),!!r}function _e(e){return e.plugin(xe)?.isWorking()||!1}var ve=class{constructor(e){this.doc=e,this.cursorPos=0,this.string=``,this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,t){let n=this.cursorPos-this.string.length;return e<n||t>=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-n,t-n)}},w=null,T=class e{constructor(e,t,n=[],r,i,a,o,s){this.parser=e,this.state=t,this.fragments=n,this.tree=r,this.treeLen=i,this.viewport=a,this.skipped=o,this.scheduleOn=s,this.parse=null,this.tempSkipped=[]}static create(t,n,r){return new e(t,n,[],_.empty,0,r,[],null)}startParse(){return this.parser.startParse(new ve(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=_.empty&&this.isDone(t??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{if(typeof e==`number`){let t=Date.now()+e;e=()=>Date.now()>t}for(this.parse||=this.startParse(),t!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&t<this.state.doc.length&&this.parse.stopAt(t);;){let n=this.parse.advance();if(n){if(this.fragments=this.withoutTempSkipped(h.addTree(n,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=this.parse.stoppedAt??this.state.doc.length,this.tree=n,this.parse=null,this.treeLen<(t??this.state.doc.length))this.parse=this.startParse();else return!0}if(e())return!1}})}takeTree(){let e,t;this.parse&&(e=this.parse.parsedPos)>=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(t=this.parse.advance()););}),this.treeLen=e,this.tree=t,this.fragments=this.withoutTempSkipped(h.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=w;w=this;try{return e()}finally{w=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=ye(e,t.from,t.to);return e}changes(t,n){let{fragments:r,tree:i,treeLen:a,viewport:o,skipped:s}=this;if(this.takeTree(),!t.empty){let e=[];if(t.iterChangedRanges((t,n,r,i)=>e.push({fromA:t,toA:n,fromB:r,toB:i})),r=h.applyChanges(r,e),i=_.empty,a=0,o={from:t.mapPos(o.from,-1),to:t.mapPos(o.to,1)},this.skipped.length){s=[];for(let e of this.skipped){let n=t.mapPos(e.from,1),r=t.mapPos(e.to,-1);n<r&&s.push({from:n,to:r})}}}return new e(this.parser,n,r,i,a,o,s,this.scheduleOn)}updateViewport(e){if(this.viewport.from==e.from&&this.viewport.to==e.to)return!1;this.viewport=e;let t=this.skipped.length;for(let t=0;t<this.skipped.length;t++){let{from:n,to:r}=this.skipped[t];n<e.to&&r>e.from&&(this.fragments=ye(this.fragments,n,r),this.skipped.splice(t--,1))}return this.skipped.length>=t?!1:(this.reset(),!0)}reset(){this.parse&&=(this.takeTree(),null)}skipUntilInView(e,t){this.skipped.push({from:e,to:t})}static getSkippingParser(e){return new class extends se{createParse(t,n,r){let i=r[0].from,a=r[r.length-1].to;return{parsedPos:i,advance(){let t=w;if(t){for(let e of r)t.tempSkipped.push(e);e&&(t.scheduleOn=t.scheduleOn?Promise.all([t.scheduleOn,e]):e)}return this.parsedPos=a,new _(m.none,[],[],a-i)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&t[0].from==0&&t[0].to>=e}static get(){return w}};function ye(e,t,n){return h.applyChanges(e,[{fromA:t,toA:n,fromB:t,toB:n}])}var E=class e{constructor(e){this.context=e,this.tree=e.tree}apply(t){if(!t.docChanged&&this.tree==this.context.tree)return this;let n=this.context.changes(t.changes,t.state),r=this.context.treeLen==t.startState.doc.length?void 0:Math.max(t.changes.mapPos(this.context.treeLen),n.viewport.to);return n.work(20,r)||n.takeTree(),new e(n)}static init(t){let n=Math.min(3e3,t.doc.length),r=T.create(t.facet(O).parser,t,{from:0,to:n});return r.work(20,n)||r.takeTree(),new e(r)}};S.state=ee.define({create:E.init,update(e,t){for(let e of t.effects)if(e.is(S.setState))return e.value;return t.startState.facet(O)==t.state.facet(O)?e.apply(t):E.init(t.state)}});var be=e=>{let t=setTimeout(()=>e(),500);return()=>clearTimeout(t)};typeof requestIdleCallback<`u`&&(be=e=>{let t=-1,n=setTimeout(()=>{t=requestIdleCallback(e,{timeout:400})},100);return()=>t<0?clearTimeout(n):cancelIdleCallback(t)});var D=typeof navigator<`u`&&navigator.scheduling?.isInputPending?()=>navigator.scheduling.isInputPending():null,xe=f.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let t=this.view.state.field(S.state).context;(t.updateViewport(e.view.viewport)||this.view.viewport.to>t.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(t)}scheduleWork(){if(this.working)return;let{state:e}=this.view,t=e.field(S.state);(t.tree!=t.context.tree||!t.context.isDone(e.doc.length))&&(this.working=be(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEnd<t&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=t+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:n,viewport:{to:r}}=this.view,i=n.field(S.state);if(i.tree==i.context.tree&&i.context.isDone(r+1e5))return;let a=Date.now()+Math.min(this.chunkBudget,100,e&&!D?Math.max(25,e.timeRemaining()-5):1e9),o=i.context.treeLen<r&&n.doc.length>r+1e3,s=i.context.work(()=>D&&D()||Date.now()>a,r+(o?0:1e5));this.chunkBudget-=Date.now()-t,(s||this.chunkBudget<=0)&&(i.context.takeTree(),this.view.dispatch({effects:S.setState.of(new E(i.context))})),this.chunkBudget>0&&(!s||o)&&this.scheduleWork(),this.checkAsyncSchedule(i.context)}checkAsyncSchedule(e){e.scheduleOn&&=(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(e=>ne(this.view.state,e)).then(()=>this.workScheduled--),null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),O=l.define({combine(e){return e.length?e[0]:null},enables:e=>[S.state,xe,n.contentAttributes.compute([e],t=>{let n=t.facet(e);return n&&n.name?{"data-language":n.name}:{}})]}),Se=class{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}},Ce=class e{constructor(e,t,n,r,i,a=void 0){this.name=e,this.alias=t,this.extensions=n,this.filename=r,this.loadFunc=i,this.support=a,this.loading=null}load(){return this.loading||=this.loadFunc().then(e=>this.support=e,e=>{throw this.loading=null,e})}static of(t){let{load:n,support:r}=t;if(!n){if(!r)throw RangeError(`Must pass either 'load' or 'support' to LanguageDescription.of`);n=()=>Promise.resolve(r)}return new e(t.name,(t.alias||[]).concat(t.name).map(e=>e.toLowerCase()),t.extensions||[],t.filename,n,r)}static matchFilename(e,t){for(let n of e)if(n.filename&&n.filename.test(t))return n;let n=/\.([^.]+)$/.exec(t);if(n){for(let t of e)if(t.extensions.indexOf(n[1])>-1)return t}return null}static matchLanguageName(e,t,n=!0){t=t.toLowerCase();for(let n of e)if(n.alias.some(e=>e==t))return n;if(n)for(let n of e)for(let e of n.alias){let r=t.indexOf(e);if(r>-1&&(e.length>2||!/\w/.test(t[r-1])&&!/\w/.test(t[r+e.length])))return n}return null}},we=l.define(),k=l.define({combine:e=>{if(!e.length)return` `;let t=e[0];if(!t||/\S/.test(t)||Array.from(t).some(e=>e!=t[0]))throw Error(`Invalid indent unit: `+JSON.stringify(e[0]));return t}});function A(e){let t=e.facet(k);return t.charCodeAt(0)==9?e.tabSize*t.length:t.length}function j(e,t){let n=``,r=e.tabSize,i=e.facet(k)[0];if(i==` `){for(;t>=r;)n+=` `,t-=r;i=` `}for(let e=0;e<t;e++)n+=i;return n}function M(e,t){e instanceof c&&(e=new N(e));for(let n of e.state.facet(we)){let r=n(e,t);if(r!==void 0)return r}let n=C(e.state);return n.length>=t?Ee(e,n,t):null}function Te(e,t,n){let r=Object.create(null),i=new N(e,{overrideIndentation:e=>r[e]??-1}),a=[];for(let o=t;o<=n;){let t=e.doc.lineAt(o);o=t.to+1;let n=M(i,t.from);if(n==null)continue;/\S/.test(t.text)||(n=0);let s=/^\s*/.exec(t.text)[0],c=j(e,n);s!=c&&(r[t.from]=n,a.push({from:t.from,to:t.from+s.length,insert:c}))}return e.changes(a)}var N=class{constructor(e,t={}){this.state=e,this.options=t,this.unit=A(e)}lineAt(e,t=1){let n=this.state.doc.lineAt(e),{simulateBreak:r,simulateDoubleBreak:i}=this.options;return r!=null&&r>=n.from&&r<=n.to?i&&r==e?{text:``,from:e}:(t<0?r<e:r<=e)?{text:n.text.slice(r-n.from),from:r}:{text:n.text.slice(0,r-n.from),from:n.from}:n}textAfterPos(e,t=1){if(this.options.simulateDoubleBreak&&e==this.options.simulateBreak)return``;let{text:n,from:r}=this.lineAt(e,t);return n.slice(e-r,Math.min(n.length,e+100-r))}column(e,t=1){let{text:n,from:r}=this.lineAt(e,t),i=this.countColumn(n,e-r),a=this.options.overrideIndentation?this.options.overrideIndentation(r):-1;return a>-1&&(i+=a-this.countColumn(n,n.search(/\S|$/))),i}countColumn(e,t=e.length){return a(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:n,from:r}=this.lineAt(e,t),i=this.options.overrideIndentation;if(i){let e=i(r);if(e>-1)return e}return this.countColumn(n,n.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}},P=new g;function Ee(e,t,n){let r=t.resolveStack(n),i=t.resolveInner(n,-1).resolve(n,0).enterUnfinishedNodesBefore(n);if(i!=r.node){let e=[];for(let t=i;t&&!(t.from<r.node.from||t.to>r.node.to||t.from==r.node.from&&t.type==r.node.type);t=t.parent)e.push(t);for(let t=e.length-1;t>=0;t--)r={node:e[t],next:r}}return De(r,e,n)}function De(e,t,n){for(let r=e;r;r=r.next){let e=ke(r.node);if(e)return e(je.create(t,n,r))}return 0}function Oe(e){return e.pos==e.options.simulateBreak&&e.options.simulateDoubleBreak}function ke(e){let t=e.type.prop(P);if(t)return t;let n=e.firstChild,r;if(n&&(r=n.type.prop(g.closedBy))){let t=e.lastChild,n=t&&r.indexOf(t.name)>-1;return e=>Fe(e,!0,1,void 0,n&&!Oe(e)?t.from:void 0)}return e.parent==null?Ae:null}function Ae(){return 0}var je=class e extends N{constructor(e,t,n){super(e.state,e.options),this.base=e,this.pos=t,this.context=n}get node(){return this.context.node}static create(t,n,r){return new e(t,n,r)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let t=this.state.doc.lineAt(e.from);for(;;){let n=e.resolve(t.from);for(;n.parent&&n.parent.from==n.from;)n=n.parent;if(Me(n,e))break;t=this.state.doc.lineAt(n.from)}return this.lineIndent(t.from)}continue(){return De(this.context.next,this.base,this.pos)}};function Me(e,t){for(let n=t;n;n=n.parent)if(e==n)return!0;return!1}function Ne(e){let t=e.node,n=t.childAfter(t.from),r=t.lastChild;if(!n)return null;let i=e.options.simulateBreak,a=e.state.doc.lineAt(n.from),o=i==null||i<=a.from?a.to:Math.min(a.to,i);for(let e=n.to;;){let i=t.childAfter(e);if(!i||i==r)return null;if(!i.type.isSkipped){if(i.from>=o)return null;let e=/^ */.exec(a.text.slice(n.to-a.from))[0].length;return{from:n.from,to:n.to+e}}e=i.to}}function Pe({closing:e,align:t=!0,units:n=1}){return r=>Fe(r,t,n,e)}function Fe(e,t,n,r,i){let a=e.textAfter,o=a.match(/^\s*/)[0].length,s=r&&a.slice(o,o+r.length)==r||i==e.pos+o,c=t?Ne(e):null;return c?s?e.column(c.from):e.column(c.to):e.baseIndent+(s?0:e.unit*n)}var Ie=e=>e.baseIndent;function Le({except:e,units:t=1}={}){return n=>{let r=e&&e.test(n.textAfter);return n.baseIndent+(r?0:t*n.unit)}}var Re=200;function ze(){return c.transactionFilter.of(e=>{if(!e.docChanged||!e.isUserEvent(`input.type`)&&!e.isUserEvent(`input.complete`))return e;let t=e.startState.languageDataAt(`indentOnInput`,e.startState.selection.main.head);if(!t.length)return e;let n=e.newDoc,{head:r}=e.newSelection.main,i=n.lineAt(r);if(r>i.from+Re)return e;let a=n.sliceString(i.from,r);if(!t.some(e=>e.test(a)))return e;let{state:o}=e,s=-1,c=[];for(let{head:e}of o.selection.ranges){let t=o.doc.lineAt(e);if(t.from==s)continue;s=t.from;let n=M(o,t.from);if(n==null)continue;let r=/^\s*/.exec(t.text)[0],i=j(o,n);r!=i&&c.push({from:t.from,to:t.from+r.length,insert:i})}return c.length?[e,{changes:c,sequential:!0}]:e})}var Be=l.define(),Ve=new g;function He(e){let t=e.firstChild,n=e.lastChild;return t&&t.to<n.from?{from:t.to,to:n.type.isError?e.to:n.from}:null}function Ue(e,t,n){let r=C(e);if(r.length<n)return null;let i=r.resolveStack(n,1),a=null;for(let o=i;o;o=o.next){let i=o.node;if(i.to<=n||i.from>n)continue;if(a&&i.from<t)break;let s=i.type.prop(Ve);if(s&&(i.to<r.length-50||r.length==e.doc.length||!We(i))){let r=s(i,e);r&&r.from<=n&&r.from>=t&&r.to>n&&(a=r)}}return a}function We(e){let t=e.lastChild;return t&&t.to==e.to&&t.type.isError}function F(e,t,n){for(let r of e.facet(Be)){let i=r(e,t,n);if(i)return i}return Ue(e,t,n)}function Ge(e,t){let n=t.mapPos(e.from,1),r=t.mapPos(e.to,-1);return n>=r?void 0:{from:n,to:r}}var I=t.define({map:Ge}),L=t.define({map:Ge});function R(e){let t=[];for(let{head:n}of e.state.selection.ranges)t.some(e=>e.from<=n&&e.to>=n)||t.push(e.lineBlockAt(n));return t}var z=ee.define({create(){return p.none},update(e,t){t.isUserEvent(`delete`)&&t.changes.iterChangedRanges((t,n)=>e=Ke(e,t,n)),e=e.map(t.changes);let n=[];for(let r of t.effects)r.is(I)&&!Je(e,r.value.from,r.value.to)?n.push(r.value):r.is(L)&&(e=e.update({filter:(e,t)=>r.value.from!=e||r.value.to!=t,filterFrom:r.value.from,filterTo:r.value.to}));if(n.length){let{preparePlaceholder:r}=t.state.facet(U),i=n.map(e=>(r?p.replace({widget:new at(r(t.state,e))}):it).range(e.from,e.to));e=e.update({add:i})}return t.selection&&(e=Ke(e,t.selection.main.head)),e},provide:e=>n.decorations.from(e),toJSON(e,t){let n=[];return e.between(0,t.doc.length,(e,t)=>{n.push(e,t)}),n},fromJSON(e){if(!Array.isArray(e)||e.length%2)throw RangeError(`Invalid JSON for fold state`);let t=[];for(let n=0;n<e.length;){let r=e[n++],i=e[n++];if(typeof r!=`number`||typeof i!=`number`)throw RangeError(`Invalid JSON for fold state`);t.push(it.range(r,i))}return p.set(t,!0)}});function Ke(e,t,n=t){let r=!1;return e.between(t,n,(e,i)=>{e<n&&i>t&&(r=!0)}),r?e.update({filterFrom:t,filterTo:n,filter:(e,r)=>e>=n||r<=t}):e}function qe(e){return e.field(z,!1)||s.empty}function B(e,t,n){var r;let i=null;return(r=e.field(z,!1))==null||r.between(t,n,(e,t)=>{(!i||i.from>e)&&(i={from:e,to:t})}),i}function Je(e,t,n){let r=!1;return e.between(t,t,(e,i)=>{e==t&&i==n&&(r=!0)}),r}function V(e,n){return e.field(z,!1)?n:n.concat(t.appendConfig.of(W()))}var Ye=e=>{for(let t of R(e)){let n=F(e.state,t.from,t.to);if(n)return e.dispatch({effects:V(e.state,[I.of(n),H(e,n)])}),!0}return!1},Xe=e=>{if(!e.state.field(z,!1))return!1;let t=[];for(let n of R(e)){let r=B(e.state,n.from,n.to);r&&t.push(L.of(r),H(e,r,!1))}return t.length&&e.dispatch({effects:t}),t.length>0};function H(e,t,r=!0){let i=e.state.doc.lineAt(t.from).number,a=e.state.doc.lineAt(t.to).number;return n.announce.of(`${e.state.phrase(r?`Folded lines`:`Unfolded lines`)} ${i} ${e.state.phrase(`to`)} ${a}.`)}var Ze=e=>{let{state:t}=e,n=[];for(let r=0;r<t.doc.length;){let i=e.lineBlockAt(r),a=F(t,i.from,i.to);a&&n.push(I.of(a)),r=(a?e.lineBlockAt(a.to):i).to+1}return n.length&&e.dispatch({effects:V(e.state,n)}),!!n.length},Qe=e=>{let t=e.state.field(z,!1);if(!t||!t.size)return!1;let n=[];return t.between(0,e.state.doc.length,(e,t)=>{n.push(L.of({from:e,to:t}))}),e.dispatch({effects:n}),!0};function $e(e,t){for(let n=t;;){let r=F(e.state,n.from,n.to);if(r&&r.to>t.from)return r;if(!n.from)return null;n=e.lineBlockAt(n.from-1)}}var et=e=>{let t=[];for(let n of R(e)){let r=B(e.state,n.from,n.to);if(r)t.push(L.of(r),H(e,r,!1));else{let r=$e(e,n);r&&t.push(I.of(r),H(e,r))}}return t.length>0&&e.dispatch({effects:V(e.state,t)}),!!t.length},tt=[{key:`Ctrl-Shift-[`,mac:`Cmd-Alt-[`,run:Ye},{key:`Ctrl-Shift-]`,mac:`Cmd-Alt-]`,run:Xe},{key:`Ctrl-Alt-[`,run:Ze},{key:`Ctrl-Alt-]`,run:Qe}],nt={placeholderDOM:null,preparePlaceholder:null,placeholderText:`…`},U=l.define({combine(e){return te(e,nt)}});function W(e){let t=[z,ct];return e&&t.push(U.of(e)),t}function rt(e,t){let{state:n}=e,r=n.facet(U),i=t=>{let n=e.lineBlockAt(e.posAtDOM(t.target)),r=B(e.state,n.from,n.to);r&&e.dispatch({effects:L.of(r)}),t.preventDefault()};if(r.placeholderDOM)return r.placeholderDOM(e,i,t);let a=document.createElement(`span`);return a.textContent=r.placeholderText,a.setAttribute(`aria-label`,n.phrase(`folded code`)),a.title=n.phrase(`unfold`),a.className=`cm-foldPlaceholder`,a.onclick=i,a}var it=p.replace({widget:new class extends i{toDOM(e){return rt(e,null)}}}),at=class extends i{constructor(e){super(),this.value=e}eq(e){return this.value==e.value}toDOM(e){return rt(e,this.value)}},ot={openText:`⌄`,closedText:`›`,markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1},G=class extends re{constructor(e,t){super(),this.config=e,this.open=t}eq(e){return this.config==e.config&&this.open==e.open}toDOM(e){if(this.config.markerDOM)return this.config.markerDOM(this.open);let t=document.createElement(`span`);return t.textContent=this.open?this.config.openText:this.config.closedText,t.title=e.state.phrase(this.open?`Fold line`:`Unfold line`),t}};function st(e={}){let t={...ot,...e},n=new G(t,!0),i=new G(t,!1),a=f.fromClass(class{constructor(e){this.from=e.viewport.from,this.markers=this.buildMarkers(e)}update(e){(e.docChanged||e.viewportChanged||e.startState.facet(O)!=e.state.facet(O)||e.startState.field(z,!1)!=e.state.field(z,!1)||C(e.startState)!=C(e.state)||t.foldingChanged(e))&&(this.markers=this.buildMarkers(e.view))}buildMarkers(e){let t=new u;for(let r of e.viewportLineBlocks){let a=B(e.state,r.from,r.to)?i:F(e.state,r.from,r.to)?n:null;a&&t.add(r.from,r.from,a)}return t.finish()}}),{domEventHandlers:o}=t;return[a,r({class:`cm-foldGutter`,markers(e){return e.plugin(a)?.markers||s.empty},initialSpacer(){return new G(t,!1)},domEventHandlers:{...o,click:(e,t,n)=>{if(o.click&&o.click(e,t,n))return!0;let r=B(e.state,t.from,t.to);if(r)return e.dispatch({effects:L.of(r)}),!0;let i=F(e.state,t.from,t.to);return i?(e.dispatch({effects:I.of(i)}),!0):!1}}}),W()]}var ct=n.baseTheme({".cm-foldPlaceholder":{backgroundColor:`#eee`,border:`1px solid #ddd`,color:`#888`,borderRadius:`.2em`,margin:`0 1px`,padding:`0 1px`,cursor:`pointer`},".cm-foldGutter span":{padding:`0 1px`,cursor:`pointer`}}),K=class t{constructor(t,n){this.specs=t;let r;function i(t){let n=e.newName();return(r||=Object.create(null))[`.`+n]=t,n}let a=typeof n.all==`string`?n.all:n.all?i(n.all):void 0,o=n.scope;this.scope=o instanceof S?e=>e.prop(b)==o.data:o?e=>e==o:void 0,this.style=ie(t.map(e=>({tag:e.tag,class:e.class||i(Object.assign({},e,{tag:null}))})),{all:a}).style,this.module=r?new e(r):null,this.themeType=n.themeType}static define(e,n){return new t(e,n||{})}},q=l.define(),lt=l.define({combine(e){return e.length?[e[0]]:null}});function J(e){let t=e.facet(q);return t.length?t:e.facet(lt)}function ut(e,t){let r=[pt],i;return e instanceof K&&(e.module&&r.push(n.styleModule.of(e.module)),i=e.themeType),t?.fallback?r.push(lt.of(e)):i?r.push(q.computeN([n.darkTheme],t=>t.facet(n.darkTheme)==(i==`dark`)?[e]:[])):r.push(q.of(e)),r}function dt(e,t,n){let r=J(e),i=null;if(r){for(let e of r)if(!e.scope||n&&e.scope(n)){let n=e.style(t);n&&(i=i?i+` `+n:n)}}return i}var ft=class{constructor(e){this.markCache=Object.create(null),this.tree=C(e.state),this.decorations=this.buildDeco(e,J(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=C(e.state),n=J(e.state),r=n!=J(e.startState),{viewport:i}=e.view,a=e.changes.mapPos(this.decoratedTo,1);t.length<i.to&&!r&&t.type==this.tree.type&&a>=i.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=a):(t!=this.tree||e.viewportChanged||r)&&(this.tree=t,this.decorations=this.buildDeco(e.view,n),this.decoratedTo=i.to)}buildDeco(e,t){if(!t||!this.tree.length)return p.none;let n=new u;for(let{from:r,to:i}of e.visibleRanges)ce(this.tree,t,(e,t,r)=>{n.add(e,t,this.markCache[r]||(this.markCache[r]=p.mark({class:r})))},r,i);return n.finish()}},pt=o.high(f.fromClass(ft,{decorations:e=>e.decorations})),mt=K.define([{tag:v.meta,color:`#404740`},{tag:v.link,textDecoration:`underline`},{tag:v.heading,textDecoration:`underline`,fontWeight:`bold`},{tag:v.emphasis,fontStyle:`italic`},{tag:v.strong,fontWeight:`bold`},{tag:v.strikethrough,textDecoration:`line-through`},{tag:v.keyword,color:`#708`},{tag:[v.atom,v.bool,v.url,v.contentSeparator,v.labelName],color:`#219`},{tag:[v.literal,v.inserted],color:`#164`},{tag:[v.string,v.deleted],color:`#a11`},{tag:[v.regexp,v.escape,v.special(v.string)],color:`#e40`},{tag:v.definition(v.variableName),color:`#00f`},{tag:v.local(v.variableName),color:`#30a`},{tag:[v.typeName,v.namespace],color:`#085`},{tag:v.className,color:`#167`},{tag:[v.special(v.variableName),v.macroName],color:`#256`},{tag:v.definition(v.propertyName),color:`#00c`},{tag:v.comment,color:`#940`},{tag:v.invalid,color:`#f00`}]),ht=n.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:`#328c8252`},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:`#bb555544`}}),gt=1e4,_t=`()[]{}`,vt=l.define({combine(e){return te(e,{afterCursor:!0,brackets:_t,maxScanDistance:gt,renderMatch:xt})}}),yt=p.mark({class:`cm-matchingBracket`}),bt=p.mark({class:`cm-nonmatchingBracket`});function xt(e){let t=[],n=e.matched?yt:bt;return t.push(n.range(e.start.from,e.start.to)),e.end&&t.push(n.range(e.end.from,e.end.to)),t}function St(e){let t=[],n=e.facet(vt);for(let r of e.selection.ranges){if(!r.empty)continue;let i=Z(e,r.head,-1,n)||r.head>0&&Z(e,r.head-1,1,n)||n.afterCursor&&(Z(e,r.head,1,n)||r.head<e.doc.length&&Z(e,r.head+1,-1,n));i&&(t=t.concat(n.renderMatch(i,e)))}return p.set(t,!0)}var Ct=[f.fromClass(class{constructor(e){this.paused=!1,this.decorations=St(e.state)}update(e){(e.docChanged||e.selectionSet||this.paused)&&(e.view.composing?(this.decorations=this.decorations.map(e.changes),this.paused=!0):(this.decorations=St(e.state),this.paused=!1))}},{decorations:e=>e.decorations}),ht];function wt(e={}){return[vt.of(e),Ct]}var Tt=new g;function Y(e,t,n){let r=e.prop(t<0?g.openedBy:g.closedBy);if(r)return r;if(e.name.length==1){let r=n.indexOf(e.name);if(r>-1&&r%2==+(t<0))return[n[r+t]]}return null}function X(e){let t=e.type.prop(Tt);return t?t(e.node):e}function Z(e,t,n,r={}){let i=r.maxScanDistance||gt,a=r.brackets||_t,o=C(e),s=o.resolveInner(t,n);for(let r=s;r;r=r.parent){let i=Y(r.type,n,a);if(i&&r.from<r.to){let o=X(r);if(o&&(n>0?t>=o.from&&t<o.to:t>o.from&&t<=o.to))return Et(e,t,n,r,o,i,a)}}return Dt(e,t,n,o,s.type,i,a)}function Et(e,t,n,r,i,a,o){let s=r.parent,c={from:i.from,to:i.to},l=0,u=s?.cursor();if(u&&(n<0?u.childBefore(r.from):u.childAfter(r.to)))do if(n<0?u.to<=r.from:u.from>=r.to){if(l==0&&a.indexOf(u.type.name)>-1&&u.from<u.to){let e=X(u);return{start:c,end:e?{from:e.from,to:e.to}:void 0,matched:!0}}if(Y(u.type,n,o))l++;else if(Y(u.type,-n,o)){if(l==0){let e=X(u);return{start:c,end:e&&e.from<e.to?{from:e.from,to:e.to}:void 0,matched:!1}}l--}}while(n<0?u.prevSibling():u.nextSibling());return{start:c,matched:!1}}function Dt(e,t,n,r,i,a,o){if(n<0?!t:t==e.doc.length)return null;let s=n<0?e.sliceDoc(t-1,t):e.sliceDoc(t,t+1),c=o.indexOf(s);if(c<0||c%2==0!=n>0)return null;let l={from:n<0?t-1:t,to:n>0?t+1:t},u=e.doc.iterRange(t,n>0?e.doc.length:0),d=0;for(let e=0;!u.next().done&&e<=a;){let a=u.value;n<0&&(e+=a.length);let s=t+e*n;for(let e=n>0?0:a.length-1,t=n>0?a.length:-1;e!=t;e+=n){let t=o.indexOf(a[e]);if(!(t<0||r.resolveInner(s+e,1).type!=i)){if(t%2==0==n>0)d++;else if(d==1)return{start:l,end:{from:s+e,to:s+e+1},matched:t>>1==c>>1};else d--}}n>0&&(e+=a.length)}return u.done?{start:l,matched:!1}:null}function Ot(e){return{name:e.name||``,token:e.token,blankLine:e.blankLine||(()=>{}),startState:e.startState||(()=>!0),copyState:e.copyState||kt,indent:e.indent||(()=>null),languageData:e.languageData||{},tokenTable:e.tokenTable||Lt,mergeTokens:e.mergeTokens!==!1}}function kt(e){if(typeof e!=`object`)return e;let t={};for(let n in e){let r=e[n];t[n]=r instanceof Array?r.slice():r}return t}var At=new WeakMap,jt=class e extends S{constructor(e){let t=x(e.languageData),n=Ot(e),r,i=new class extends se{createParse(e,t,n){return new Ft(r,e,t,n)}};super(t,i,[],e.name),this.topNode=Kt(t,this),r=this,this.streamParser=n,this.stateAfter=new g({perNode:!0}),this.tokenTable=e.tokenTable?new Ht(n.tokenTable):Ut}static define(t){return new e(t)}getIndent(e){let t,{overrideIndentation:n}=e.options;n&&(t=At.get(e.state),t!=null&&t<e.pos-1e4&&(t=void 0));let r=Mt(this,e.node.tree,e.node.from,e.node.from,t??e.pos),i,a;if(r?(a=r.state,i=r.pos+1):(a=this.streamParser.startState(e.unit),i=e.node.from),e.pos-i>1e4)return null;for(;i<e.pos;){let t=e.state.doc.lineAt(i),r=Math.min(e.pos,t.to);if(t.length){let i=n?n(t.from):-1,o=new y(t.text,e.state.tabSize,e.unit,i<0?void 0:i);for(;o.pos<r-t.from;)It(this.streamParser.token,o,a)}else this.streamParser.blankLine(a,e.unit);if(r==e.pos)break;i=t.to+1}let o=e.lineAt(e.pos);return n&&t==null&&At.set(e.state,o.from),this.streamParser.indent(a,/^\s*(.*)/.exec(o.text)[1],e)}get allowsNesting(){return!1}};function Mt(e,t,n,r,i){let a=n>=r&&n+t.length<=i&&t.prop(e.stateAfter);if(a)return{state:e.streamParser.copyState(a),pos:n+t.length};for(let a=t.children.length-1;a>=0;a--){let o=t.children[a],s=n+t.positions[a],c=o instanceof _&&s<i&&Mt(e,o,s,r,i);if(c)return c}return null}function Nt(e,t,n,r,i){if(i&&n<=0&&r>=t.length)return t;!i&&n==0&&t.type==e.topNode&&(i=!0);for(let a=t.children.length-1;a>=0;a--){let o=t.positions[a],s=t.children[a],c;if(o<r&&s instanceof _){if(!(c=Nt(e,s,n-o,r-o,i)))break;return i?new _(t.type,t.children.slice(0,a).concat(c),t.positions.slice(0,a+1),o+c.length):c}}return null}function Pt(e,t,n,r,i){for(let i of t){let t=i.from+(i.openStart?25:0),a=i.to-(i.openEnd?25:0),o=t<=n&&a>n&&Mt(e,i.tree,0-i.offset,n,a),s;if(o&&o.pos<=r&&(s=Nt(e,i.tree,n+i.offset,o.pos+i.offset,!1)))return{state:o.state,tree:s}}return{state:e.streamParser.startState(i?A(i):4),tree:_.empty}}var Ft=class{constructor(e,t,n,r){this.lang=e,this.input=t,this.fragments=n,this.ranges=r,this.stoppedAt=null,this.chunks=[],this.chunkPos=[],this.chunk=[],this.chunkReused=void 0,this.rangeIndex=0,this.to=r[r.length-1].to;let i=T.get(),a=r[0].from,{state:o,tree:s}=Pt(e,n,a,this.to,i?.state);this.state=o,this.parsedPos=this.chunkStart=a+s.length;for(let e=0;e<s.children.length;e++)this.chunks.push(s.children[e]),this.chunkPos.push(s.positions[e]);i&&this.parsedPos<i.viewport.from-1e5&&r.some(e=>e.from<=i.viewport.from&&e.to>=i.viewport.from)&&(this.state=this.lang.streamParser.startState(A(i.state)),i.skipUntilInView(this.parsedPos,i.viewport.from),this.parsedPos=i.viewport.from),this.moveRangeIndex()}advance(){let e=T.get(),t=this.stoppedAt==null?this.to:Math.min(this.to,this.stoppedAt),n=Math.min(t,this.chunkStart+512);for(e&&(n=Math.min(n,e.viewport.to));this.parsedPos<n;)this.parseLine(e);return this.chunkStart<this.parsedPos&&this.finishChunk(),this.parsedPos>=t?this.finish():e&&this.parsedPos>=e.viewport.to?(e.skipUntilInView(this.parsedPos,t),this.finish()):null}stopAt(e){this.stoppedAt=e}lineAfter(e){let t=this.input.chunk(e);if(this.input.lineChunks)t==`
2
+ `&&(t=``);else{let e=t.indexOf(`
3
+ `);e>-1&&(t=t.slice(0,e))}return e+t.length<=this.to?t:t.slice(0,this.to-e)}nextLine(){let e=this.parsedPos,t=this.lineAfter(e),n=e+t.length;for(let e=this.rangeIndex;;){let r=this.ranges[e].to;if(r>=n||(t=t.slice(0,r-(n-t.length)),e++,e==this.ranges.length))break;let i=this.ranges[e].from,a=this.lineAfter(i);t+=a,n=i+a.length}return{line:t,end:n}}skipGapsTo(e,t,n){for(;;){let r=this.ranges[this.rangeIndex].to,i=e+t;if(n>0?r>i:r>=i)break;let a=this.ranges[++this.rangeIndex].from;t+=a-r}return t}moveRangeIndex(){for(;this.ranges[this.rangeIndex].to<this.parsedPos;)this.rangeIndex++}emitToken(e,t,n,r){let i=4;if(this.ranges.length>1){r=this.skipGapsTo(t,r,1),t+=r;let e=this.chunk.length;r=this.skipGapsTo(n,r,-1),n+=r,i+=this.chunk.length-e}let a=this.chunk.length-4;return this.lang.streamParser.mergeTokens&&i==4&&a>=0&&this.chunk[a]==e&&this.chunk[a+2]==t?this.chunk[a+2]=n:this.chunk.push(e,t,n,i),r}parseLine(e){let{line:t,end:n}=this.nextLine(),r=0,{streamParser:i}=this.lang,a=new y(t,e?e.state.tabSize:4,e?A(e.state):2);if(a.eol())i.blankLine(this.state,a.indentUnit);else for(;!a.eol();){let e=It(i.token,a,this.state);if(e&&(r=this.emitToken(this.lang.tokenTable.resolve(e),this.parsedPos+a.start,this.parsedPos+a.pos,r)),a.start>1e4)break}this.parsedPos=n,this.moveRangeIndex(),this.parsedPos<this.to&&this.parsedPos++}finishChunk(){let e=_.build({buffer:this.chunk,start:this.chunkStart,length:this.parsedPos-this.chunkStart,nodeSet:Rt,topID:0,maxBufferLength:512,reused:this.chunkReused});e=new _(e.type,e.children,e.positions,e.length,[[this.lang.stateAfter,this.lang.streamParser.copyState(this.state)]]),this.chunks.push(e),this.chunkPos.push(this.chunkStart-this.ranges[0].from),this.chunk=[],this.chunkReused=void 0,this.chunkStart=this.parsedPos}finish(){return new _(this.lang.topNode,this.chunks,this.chunkPos,this.parsedPos-this.ranges[0].from).balance()}};function It(e,t,n){t.start=t.pos;for(let r=0;r<10;r++){let r=e(t,n);if(t.pos>t.start)return r}throw Error(`Stream parser failed to advance stream.`)}var Lt=Object.create(null),Q=[m.none],Rt=new le(Q),zt=[],Bt=Object.create(null),Vt=Object.create(null);for(let[e,t]of[[`variable`,`variableName`],[`variable-2`,`variableName.special`],[`string-2`,`string.special`],[`def`,`variableName.definition`],[`tag`,`tagName`],[`attribute`,`attributeName`],[`type`,`typeName`],[`builtin`,`variableName.standard`],[`qualifier`,`modifier`],[`error`,`invalid`],[`header`,`heading`],[`property`,`propertyName`]])Vt[e]=Gt(Lt,t);var Ht=class{constructor(e){this.extra=e,this.table=Object.assign(Object.create(null),Vt)}resolve(e){return e?this.table[e]||(this.table[e]=Gt(this.extra,e)):0}},Ut=new Ht(Lt);function Wt(e,t){zt.indexOf(e)>-1||(zt.push(e),console.warn(t))}function Gt(e,t){let n=[];for(let r of t.split(` `)){let t=[];for(let n of r.split(`.`)){let r=e[n]||v[n];r?typeof r==`function`?t.length?t=t.map(r):Wt(n,`Modifier ${n} used at start of tag`):t.length?Wt(n,`Tag ${n} used as modifier`):t=Array.isArray(r)?r:[r]:Wt(n,`Unknown highlighting tag ${n}`)}for(let e of t)n.push(e)}if(!n.length)return 0;let r=t.replace(/ /g,`_`),i=r+` `+n.map(e=>e.id),a=Bt[i];if(a)return a.id;let o=Bt[i]=m.define({id:Q.length,name:r,props:[oe({[r]:n})]});return Q.push(o),o.id}function Kt(e,t){let n=m.define({id:Q.length,name:`Document`,props:[b.add(()=>e),P.add(()=>e=>t.getIndent(e))],top:!0});return Q.push(n),n}function qt(e){return e.length<=4096&&/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/.test(e)}function Jt(e){for(let t=e.iter();!t.next().done;)if(qt(t.value))return!0;return!1}function Yt(e){let t=!1;return e.iterChanges((e,n,r,i,a)=>{!t&&Jt(a)&&(t=!0)}),t}var $=l.define({combine:e=>e.some(e=>e)});function Xt(e={}){let t=[Zt];return e.alwaysIsolate&&t.push($.of(!0)),t}var Zt=f.fromClass(class{constructor(e){this.always=e.state.facet($)||e.textDirection!=d.LTR||e.state.facet(n.perLineTextDirection),this.hasRTL=!this.always&&Jt(e.state.doc),this.tree=C(e.state),this.decorations=this.always||this.hasRTL?Qt(e,this.tree,this.always):p.none}update(e){let t=e.state.facet($)||e.view.textDirection!=d.LTR||e.state.facet(n.perLineTextDirection);if(!t&&!this.hasRTL&&Yt(e.changes)&&(this.hasRTL=!0),!t&&!this.hasRTL)return;let r=C(e.state);(t!=this.always||r!=this.tree||e.docChanged||e.viewportChanged)&&(this.tree=r,this.always=t,this.decorations=Qt(e.view,r,t))}},{provide:e=>{function t(t){return t.plugin(e)?.decorations??p.none}return[n.outerDecorations.of(t),o.lowest(n.bidiIsolatedRanges.of(t))]}});function Qt(e,t,n){let r=new u,i=e.visibleRanges;n||(i=$t(i,e.state.doc));for(let{from:e,to:n}of i)t.iterate({enter:e=>{let t=e.type.prop(g.isolate);t&&r.add(e.from,e.to,en[t])},from:e,to:n});return r.finish()}function $t(e,t){let n=t.iter(),r=0,i=[],a=null;for(let{from:t,to:o}of e)if(!(a&&a.to>t&&(t=a.to,t>=o)))for(r+n.value.length<t&&(n.next(t-(r+n.value.length)),r=t);;){let e=r,t=r+n.value.length;if(!n.lineBreak&&qt(n.value)&&(a&&a.to>e-10?a.to=Math.min(o,t):i.push(a={from:e,to:Math.min(o,t)})),t>=o)break;r=t,n.next()}return i}var en={rtl:p.mark({class:`cm-iso`,inclusive:!0,attributes:{dir:`rtl`},bidiIsolate:d.RTL}),ltr:p.mark({class:`cm-iso`,inclusive:!0,attributes:{dir:`ltr`},bidiIsolate:d.LTR}),auto:p.mark({class:`cm-iso`,inclusive:!0,attributes:{dir:`auto`},bidiIsolate:null})};export{ve as DocInput,K as HighlightStyle,N as IndentContext,pe as LRLanguage,S as Language,Ce as LanguageDescription,Se as LanguageSupport,T as ParseContext,jt as StreamLanguage,y as StringStream,je as TreeIndentContext,Xt as bidiIsolates,wt as bracketMatching,Tt as bracketMatchingHandle,W as codeFolding,Le as continuedIndent,mt as defaultHighlightStyle,x as defineLanguageFacet,Pe as delimitedIndent,me as ensureSyntaxTree,Ie as flatIndent,Ze as foldAll,Ye as foldCode,I as foldEffect,st as foldGutter,He as foldInside,tt as foldKeymap,Ve as foldNodeProp,Be as foldService,z as foldState,F as foldable,qe as foldedRanges,ge as forceParsing,A as getIndentUnit,M as getIndentation,dt as highlightingFor,P as indentNodeProp,ze as indentOnInput,Te as indentRange,we as indentService,j as indentString,k as indentUnit,O as language,b as languageDataProp,Z as matchBrackets,de as sublanguageProp,ut as syntaxHighlighting,_e as syntaxParserRunning,C as syntaxTree,he as syntaxTreeAvailable,et as toggleFold,Qe as unfoldAll,Xe as unfoldCode,L as unfoldEffect};