@thevinci/web 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (337) hide show
  1. package/README.md +197 -0
  2. package/bin/cli-entry.js +55 -0
  3. package/bin/cli-output.js +145 -0
  4. package/bin/cli.js +4887 -0
  5. package/bin/cli.test.js +64 -0
  6. package/dist/apple-touch-icon-120x120.png +0 -0
  7. package/dist/apple-touch-icon-152x152.png +0 -0
  8. package/dist/apple-touch-icon-167x167.png +0 -0
  9. package/dist/apple-touch-icon-180x180.png +0 -0
  10. package/dist/apple-touch-icon.png +0 -0
  11. package/dist/apple-touch-icon.svg +528 -0
  12. package/dist/assets/JsonTreeView-CSm9OzXG.js +1 -0
  13. package/dist/assets/KaTeX_AMS-Regular-BQhdFMY1.woff2 +0 -0
  14. package/dist/assets/KaTeX_AMS-Regular-DMm9YOAa.woff +0 -0
  15. package/dist/assets/KaTeX_AMS-Regular-DRggAlZN.ttf +0 -0
  16. package/dist/assets/KaTeX_Caligraphic-Bold-ATXxdsX0.ttf +0 -0
  17. package/dist/assets/KaTeX_Caligraphic-Bold-BEiXGLvX.woff +0 -0
  18. package/dist/assets/KaTeX_Caligraphic-Bold-Dq_IR9rO.woff2 +0 -0
  19. package/dist/assets/KaTeX_Caligraphic-Regular-CTRA-rTL.woff +0 -0
  20. package/dist/assets/KaTeX_Caligraphic-Regular-Di6jR-x-.woff2 +0 -0
  21. package/dist/assets/KaTeX_Caligraphic-Regular-wX97UBjC.ttf +0 -0
  22. package/dist/assets/KaTeX_Fraktur-Bold-BdnERNNW.ttf +0 -0
  23. package/dist/assets/KaTeX_Fraktur-Bold-BsDP51OF.woff +0 -0
  24. package/dist/assets/KaTeX_Fraktur-Bold-CL6g_b3V.woff2 +0 -0
  25. package/dist/assets/KaTeX_Fraktur-Regular-CB_wures.ttf +0 -0
  26. package/dist/assets/KaTeX_Fraktur-Regular-CTYiF6lA.woff2 +0 -0
  27. package/dist/assets/KaTeX_Fraktur-Regular-Dxdc4cR9.woff +0 -0
  28. package/dist/assets/KaTeX_Main-Bold-Cx986IdX.woff2 +0 -0
  29. package/dist/assets/KaTeX_Main-Bold-Jm3AIy58.woff +0 -0
  30. package/dist/assets/KaTeX_Main-Bold-waoOVXN0.ttf +0 -0
  31. package/dist/assets/KaTeX_Main-BoldItalic-DxDJ3AOS.woff2 +0 -0
  32. package/dist/assets/KaTeX_Main-BoldItalic-DzxPMmG6.ttf +0 -0
  33. package/dist/assets/KaTeX_Main-BoldItalic-SpSLRI95.woff +0 -0
  34. package/dist/assets/KaTeX_Main-Italic-3WenGoN9.ttf +0 -0
  35. package/dist/assets/KaTeX_Main-Italic-BMLOBm91.woff +0 -0
  36. package/dist/assets/KaTeX_Main-Italic-NWA7e6Wa.woff2 +0 -0
  37. package/dist/assets/KaTeX_Main-Regular-B22Nviop.woff2 +0 -0
  38. package/dist/assets/KaTeX_Main-Regular-Dr94JaBh.woff +0 -0
  39. package/dist/assets/KaTeX_Main-Regular-ypZvNtVU.ttf +0 -0
  40. package/dist/assets/KaTeX_Math-BoldItalic-B3XSjfu4.ttf +0 -0
  41. package/dist/assets/KaTeX_Math-BoldItalic-CZnvNsCZ.woff2 +0 -0
  42. package/dist/assets/KaTeX_Math-BoldItalic-iY-2wyZ7.woff +0 -0
  43. package/dist/assets/KaTeX_Math-Italic-DA0__PXp.woff +0 -0
  44. package/dist/assets/KaTeX_Math-Italic-flOr_0UB.ttf +0 -0
  45. package/dist/assets/KaTeX_Math-Italic-t53AETM-.woff2 +0 -0
  46. package/dist/assets/KaTeX_SansSerif-Bold-CFMepnvq.ttf +0 -0
  47. package/dist/assets/KaTeX_SansSerif-Bold-D1sUS0GD.woff2 +0 -0
  48. package/dist/assets/KaTeX_SansSerif-Bold-DbIhKOiC.woff +0 -0
  49. package/dist/assets/KaTeX_SansSerif-Italic-C3H0VqGB.woff2 +0 -0
  50. package/dist/assets/KaTeX_SansSerif-Italic-DN2j7dab.woff +0 -0
  51. package/dist/assets/KaTeX_SansSerif-Italic-YYjJ1zSn.ttf +0 -0
  52. package/dist/assets/KaTeX_SansSerif-Regular-BNo7hRIc.ttf +0 -0
  53. package/dist/assets/KaTeX_SansSerif-Regular-CS6fqUqJ.woff +0 -0
  54. package/dist/assets/KaTeX_SansSerif-Regular-DDBCnlJ7.woff2 +0 -0
  55. package/dist/assets/KaTeX_Script-Regular-C5JkGWo-.ttf +0 -0
  56. package/dist/assets/KaTeX_Script-Regular-D3wIWfF6.woff2 +0 -0
  57. package/dist/assets/KaTeX_Script-Regular-D5yQViql.woff +0 -0
  58. package/dist/assets/KaTeX_Size1-Regular-C195tn64.woff +0 -0
  59. package/dist/assets/KaTeX_Size1-Regular-Dbsnue_I.ttf +0 -0
  60. package/dist/assets/KaTeX_Size1-Regular-mCD8mA8B.woff2 +0 -0
  61. package/dist/assets/KaTeX_Size2-Regular-B7gKUWhC.ttf +0 -0
  62. package/dist/assets/KaTeX_Size2-Regular-Dy4dx90m.woff2 +0 -0
  63. package/dist/assets/KaTeX_Size2-Regular-oD1tc_U0.woff +0 -0
  64. package/dist/assets/KaTeX_Size3-Regular-CTq5MqoE.woff +0 -0
  65. package/dist/assets/KaTeX_Size3-Regular-DgpXs0kz.ttf +0 -0
  66. package/dist/assets/KaTeX_Size4-Regular-BF-4gkZK.woff +0 -0
  67. package/dist/assets/KaTeX_Size4-Regular-DWFBv043.ttf +0 -0
  68. package/dist/assets/KaTeX_Size4-Regular-Dl5lxZxV.woff2 +0 -0
  69. package/dist/assets/KaTeX_Typewriter-Regular-C0xS9mPB.woff +0 -0
  70. package/dist/assets/KaTeX_Typewriter-Regular-CO6r4hn1.woff2 +0 -0
  71. package/dist/assets/KaTeX_Typewriter-Regular-D3Ib7_Hf.ttf +0 -0
  72. package/dist/assets/MarkdownRendererImpl-DensKOLc.js +6 -0
  73. package/dist/assets/MultiRunWindow-Bo7THayo.js +1 -0
  74. package/dist/assets/OnboardingScreen-BDqmzTVR.js +2 -0
  75. package/dist/assets/SettingsWindow-coz__Ykw.js +1 -0
  76. package/dist/assets/TerminalView-DrZ-i3Dr.js +1 -0
  77. package/dist/assets/ToolOutputDialog-Eglzslt3.js +16 -0
  78. package/dist/assets/es-4o9ciP61.js +15 -0
  79. package/dist/assets/ibm-plex-mono-latin-400-normal-CvHOgSBP.woff +0 -0
  80. package/dist/assets/ibm-plex-mono-latin-400-normal-DMJ8VG8y.woff2 +0 -0
  81. package/dist/assets/ibm-plex-mono-latin-500-normal-CB9ihrfo.woff +0 -0
  82. package/dist/assets/ibm-plex-mono-latin-500-normal-DSY6xOcd.woff2 +0 -0
  83. package/dist/assets/ibm-plex-mono-latin-600-normal-BgSNZQsw.woff2 +0 -0
  84. package/dist/assets/ibm-plex-mono-latin-600-normal-DWFSQ4vo.woff +0 -0
  85. package/dist/assets/ibm-plex-sans-latin-400-normal-CDDApCn2.woff2 +0 -0
  86. package/dist/assets/ibm-plex-sans-latin-400-normal-CYLoc0-x.woff +0 -0
  87. package/dist/assets/ibm-plex-sans-latin-500-normal-6ng42L7E.woff2 +0 -0
  88. package/dist/assets/ibm-plex-sans-latin-500-normal-BgVn5rGT.woff +0 -0
  89. package/dist/assets/ibm-plex-sans-latin-600-normal-Cu4Hd6ag.woff +0 -0
  90. package/dist/assets/ibm-plex-sans-latin-600-normal-CuJfVYMP.woff2 +0 -0
  91. package/dist/assets/index-DLTDToSP.css +1 -0
  92. package/dist/assets/index-DgiFEKGN.js +1 -0
  93. package/dist/assets/ko-B20imCHE.js +15 -0
  94. package/dist/assets/main-BV3KOtdA.css +1 -0
  95. package/dist/assets/main-CDKJj0sH.js +226 -0
  96. package/dist/assets/main-LC-PSNVM.js +2 -0
  97. package/dist/assets/miniChat-CQUiG_cr.js +2 -0
  98. package/dist/assets/modelPrefsAutoSave-Dm799vzR.js +6986 -0
  99. package/dist/assets/pl-DQJ7LSzj.js +15 -0
  100. package/dist/assets/pt-BR-OmjHUz9y.js +15 -0
  101. package/dist/assets/renderElectronMiniChatApp-CARbeW0G.js +2 -0
  102. package/dist/assets/uk-BNFxOlO4.js +15 -0
  103. package/dist/assets/vendor--DBfsbEis.css +1 -0
  104. package/dist/assets/vendor-.bun-B9l0ZNi2.js +4094 -0
  105. package/dist/assets/wasm-CG6Dc4jp.js +1 -0
  106. package/dist/assets/wasmSttWorker-Dtlxac_K.js +1 -0
  107. package/dist/assets/wasmSttWorker-oo7Dm_jy.js +1806 -0
  108. package/dist/assets/worker-CbT6TVo7.js +155 -0
  109. package/dist/assets/zh-CN-C6T-Ac7F.js +15 -0
  110. package/dist/favicon-16.png +0 -0
  111. package/dist/favicon-32.png +0 -0
  112. package/dist/favicon.png +0 -0
  113. package/dist/favicon.svg +528 -0
  114. package/dist/index.html +607 -0
  115. package/dist/logo-dark-192x192.png +0 -0
  116. package/dist/logo-dark-512x512.png +0 -0
  117. package/dist/logo-dark-512x512.svg +528 -0
  118. package/dist/logo-light-192x192.png +0 -0
  119. package/dist/logo-light-512x512.png +0 -0
  120. package/dist/logo-light-512x512.svg +528 -0
  121. package/dist/mini-chat.html +16 -0
  122. package/dist/pwa-192.png +0 -0
  123. package/dist/pwa-512.png +0 -0
  124. package/dist/pwa-maskable-192.png +0 -0
  125. package/dist/pwa-maskable-512.png +0 -0
  126. package/dist/site.webmanifest +21 -0
  127. package/dist/sw.js +1 -0
  128. package/package.json +118 -0
  129. package/public/apple-touch-icon-120x120.png +0 -0
  130. package/public/apple-touch-icon-152x152.png +0 -0
  131. package/public/apple-touch-icon-167x167.png +0 -0
  132. package/public/apple-touch-icon-180x180.png +0 -0
  133. package/public/apple-touch-icon.png +0 -0
  134. package/public/apple-touch-icon.svg +528 -0
  135. package/public/favicon-16.png +0 -0
  136. package/public/favicon-32.png +0 -0
  137. package/public/favicon.png +0 -0
  138. package/public/favicon.svg +528 -0
  139. package/public/logo-dark-192x192.png +0 -0
  140. package/public/logo-dark-512x512.png +0 -0
  141. package/public/logo-dark-512x512.svg +528 -0
  142. package/public/logo-light-192x192.png +0 -0
  143. package/public/logo-light-512x512.png +0 -0
  144. package/public/logo-light-512x512.svg +528 -0
  145. package/public/pwa-192.png +0 -0
  146. package/public/pwa-512.png +0 -0
  147. package/public/pwa-maskable-192.png +0 -0
  148. package/public/pwa-maskable-512.png +0 -0
  149. package/public/site.webmanifest +21 -0
  150. package/server/TERMINAL_WS_PROTOCOL.md +48 -0
  151. package/server/index.d.ts +39 -0
  152. package/server/index.js +1311 -0
  153. package/server/lib/cloudflare-tunnel.js +650 -0
  154. package/server/lib/event-stream/DOCUMENTATION.md +61 -0
  155. package/server/lib/event-stream/directory-ws-bridge.js +185 -0
  156. package/server/lib/event-stream/global-hub.js +158 -0
  157. package/server/lib/event-stream/global-hub.test.js +140 -0
  158. package/server/lib/event-stream/global-ws-bridge.js +206 -0
  159. package/server/lib/event-stream/index.js +25 -0
  160. package/server/lib/event-stream/protocol.js +131 -0
  161. package/server/lib/event-stream/protocol.test.js +182 -0
  162. package/server/lib/event-stream/runtime.js +180 -0
  163. package/server/lib/event-stream/runtime.test.js +512 -0
  164. package/server/lib/event-stream/upstream-reader.js +226 -0
  165. package/server/lib/event-stream/upstream-reader.test.js +276 -0
  166. package/server/lib/fs/DOCUMENTATION.md +36 -0
  167. package/server/lib/fs/routes.js +1040 -0
  168. package/server/lib/fs/search.js +238 -0
  169. package/server/lib/git/DOCUMENTATION.md +152 -0
  170. package/server/lib/git/credentials.js +74 -0
  171. package/server/lib/git/identity-storage.js +112 -0
  172. package/server/lib/git/index.js +6 -0
  173. package/server/lib/git/routes.js +972 -0
  174. package/server/lib/git/service.js +3432 -0
  175. package/server/lib/git/service.test.js +39 -0
  176. package/server/lib/github/DOCUMENTATION.md +171 -0
  177. package/server/lib/github/auth.js +307 -0
  178. package/server/lib/github/device-flow.js +50 -0
  179. package/server/lib/github/index.js +24 -0
  180. package/server/lib/github/octokit.js +10 -0
  181. package/server/lib/github/pr-status.js +519 -0
  182. package/server/lib/github/repo/fork-detection.js +102 -0
  183. package/server/lib/github/repo/index.js +55 -0
  184. package/server/lib/github/routes.js +1560 -0
  185. package/server/lib/magic-prompts/routes.js +63 -0
  186. package/server/lib/magic-prompts/runtime.js +119 -0
  187. package/server/lib/notifications/DOCUMENTATION.md +122 -0
  188. package/server/lib/notifications/emitter-runtime.js +102 -0
  189. package/server/lib/notifications/index.js +4 -0
  190. package/server/lib/notifications/message.js +52 -0
  191. package/server/lib/notifications/message.test.js +34 -0
  192. package/server/lib/notifications/push-runtime.js +304 -0
  193. package/server/lib/notifications/routes.js +315 -0
  194. package/server/lib/notifications/runtime.js +566 -0
  195. package/server/lib/notifications/template-runtime.js +349 -0
  196. package/server/lib/notifications/template-runtime.test.js +26 -0
  197. package/server/lib/opencode/DOCUMENTATION.md +362 -0
  198. package/server/lib/opencode/agents.js +634 -0
  199. package/server/lib/opencode/auth-state-runtime.js +88 -0
  200. package/server/lib/opencode/auth.js +83 -0
  201. package/server/lib/opencode/bootstrap-runtime.js +131 -0
  202. package/server/lib/opencode/cli-entry-runtime.js +43 -0
  203. package/server/lib/opencode/cli-options.js +128 -0
  204. package/server/lib/opencode/commands.js +339 -0
  205. package/server/lib/opencode/config-entity-routes.js +370 -0
  206. package/server/lib/opencode/core-routes.js +500 -0
  207. package/server/lib/opencode/core-routes.test.js +26 -0
  208. package/server/lib/opencode/env-config.js +74 -0
  209. package/server/lib/opencode/env-keys.js +68 -0
  210. package/server/lib/opencode/env-runtime.js +1162 -0
  211. package/server/lib/opencode/env-runtime.test.js +116 -0
  212. package/server/lib/opencode/feature-routes-runtime.js +244 -0
  213. package/server/lib/opencode/hmr-state-runtime.js +85 -0
  214. package/server/lib/opencode/index.js +66 -0
  215. package/server/lib/opencode/lifecycle.js +1019 -0
  216. package/server/lib/opencode/lifecycle.test.js +240 -0
  217. package/server/lib/opencode/mcp.js +278 -0
  218. package/server/lib/opencode/network-runtime.js +104 -0
  219. package/server/lib/opencode/network-runtime.test.js +37 -0
  220. package/server/lib/opencode/opencode-resolution-runtime.js +71 -0
  221. package/server/lib/opencode/path-utils.js +100 -0
  222. package/server/lib/opencode/path-utils.test.js +71 -0
  223. package/server/lib/opencode/project-directory-runtime.js +124 -0
  224. package/server/lib/opencode/project-icon-routes.js +399 -0
  225. package/server/lib/opencode/project-icon-routes.test.js +107 -0
  226. package/server/lib/opencode/providers.js +96 -0
  227. package/server/lib/opencode/proxy.js +445 -0
  228. package/server/lib/opencode/pwa-manifest-routes.js +257 -0
  229. package/server/lib/opencode/pwa-manifest-routes.test.js +133 -0
  230. package/server/lib/opencode/routes.js +541 -0
  231. package/server/lib/opencode/server-startup-runtime.js +156 -0
  232. package/server/lib/opencode/server-utils-runtime.js +168 -0
  233. package/server/lib/opencode/server-utils-runtime.test.js +135 -0
  234. package/server/lib/opencode/session-runtime.js +356 -0
  235. package/server/lib/opencode/session-runtime.test.js +151 -0
  236. package/server/lib/opencode/settings-helpers.js +770 -0
  237. package/server/lib/opencode/settings-helpers.test.js +109 -0
  238. package/server/lib/opencode/settings-normalization-runtime.js +428 -0
  239. package/server/lib/opencode/settings-runtime.js +826 -0
  240. package/server/lib/opencode/settings-runtime.test.js +85 -0
  241. package/server/lib/opencode/shared.js +615 -0
  242. package/server/lib/opencode/shutdown-runtime.js +139 -0
  243. package/server/lib/opencode/shutdown-runtime.test.js +58 -0
  244. package/server/lib/opencode/skill-routes.js +701 -0
  245. package/server/lib/opencode/skills.js +548 -0
  246. package/server/lib/opencode/startup-pipeline-runtime.js +130 -0
  247. package/server/lib/opencode/static-routes-runtime.js +65 -0
  248. package/server/lib/opencode/theme-runtime.js +167 -0
  249. package/server/lib/opencode/tunnel-auth.js +591 -0
  250. package/server/lib/opencode/tunnel-wiring-runtime.js +94 -0
  251. package/server/lib/opencode/vinci-routes.js +76 -0
  252. package/server/lib/opencode/watcher.js +115 -0
  253. package/server/lib/opencode/watcher.test.js +239 -0
  254. package/server/lib/preview/proxy-runtime.js +1333 -0
  255. package/server/lib/preview/proxy-runtime.test.js +144 -0
  256. package/server/lib/projects/project-config.js +567 -0
  257. package/server/lib/projects/project-config.test.js +175 -0
  258. package/server/lib/projects/project-id.js +13 -0
  259. package/server/lib/quota/DOCUMENTATION.md +58 -0
  260. package/server/lib/quota/index.js +25 -0
  261. package/server/lib/quota/providers/claude.js +107 -0
  262. package/server/lib/quota/providers/codex.js +113 -0
  263. package/server/lib/quota/providers/copilot.js +165 -0
  264. package/server/lib/quota/providers/google/api.js +92 -0
  265. package/server/lib/quota/providers/google/auth.js +108 -0
  266. package/server/lib/quota/providers/google/index.js +124 -0
  267. package/server/lib/quota/providers/google/transforms.js +109 -0
  268. package/server/lib/quota/providers/index.js +168 -0
  269. package/server/lib/quota/providers/interface.js +55 -0
  270. package/server/lib/quota/providers/kimi.js +108 -0
  271. package/server/lib/quota/providers/minimax-cn-coding-plan.js +140 -0
  272. package/server/lib/quota/providers/minimax-coding-plan.js +139 -0
  273. package/server/lib/quota/providers/nanogpt.js +124 -0
  274. package/server/lib/quota/providers/ollama-cloud.js +112 -0
  275. package/server/lib/quota/providers/openai.js +91 -0
  276. package/server/lib/quota/providers/openrouter.js +92 -0
  277. package/server/lib/quota/providers/zai.js +91 -0
  278. package/server/lib/quota/providers/zhipuai-coding-plan.js +133 -0
  279. package/server/lib/quota/providers/zhipuai.js +114 -0
  280. package/server/lib/quota/routes.js +27 -0
  281. package/server/lib/quota/utils/auth.js +50 -0
  282. package/server/lib/quota/utils/formatters.js +85 -0
  283. package/server/lib/quota/utils/formatters.test.js +54 -0
  284. package/server/lib/quota/utils/index.js +10 -0
  285. package/server/lib/quota/utils/transformers.js +55 -0
  286. package/server/lib/scheduled-tasks/DOCUMENTATION.md +44 -0
  287. package/server/lib/scheduled-tasks/routes.js +235 -0
  288. package/server/lib/scheduled-tasks/runtime.js +773 -0
  289. package/server/lib/scheduled-tasks/runtime.test.js +100 -0
  290. package/server/lib/security/request-security.js +115 -0
  291. package/server/lib/session-folders/routes.js +63 -0
  292. package/server/lib/session-folders/routes.test.js +102 -0
  293. package/server/lib/skills-catalog/DOCUMENTATION.md +178 -0
  294. package/server/lib/skills-catalog/cache.js +29 -0
  295. package/server/lib/skills-catalog/clawdhub/api.js +158 -0
  296. package/server/lib/skills-catalog/clawdhub/index.js +30 -0
  297. package/server/lib/skills-catalog/clawdhub/install.js +238 -0
  298. package/server/lib/skills-catalog/clawdhub/scan.js +113 -0
  299. package/server/lib/skills-catalog/curated-sources.js +21 -0
  300. package/server/lib/skills-catalog/git.js +77 -0
  301. package/server/lib/skills-catalog/index.js +42 -0
  302. package/server/lib/skills-catalog/install.js +294 -0
  303. package/server/lib/skills-catalog/scan.js +221 -0
  304. package/server/lib/skills-catalog/source.js +87 -0
  305. package/server/lib/terminal/DOCUMENTATION.md +76 -0
  306. package/server/lib/terminal/index.js +31 -0
  307. package/server/lib/terminal/output-replay-buffer.js +78 -0
  308. package/server/lib/terminal/output-replay-buffer.test.js +75 -0
  309. package/server/lib/terminal/runtime.js +850 -0
  310. package/server/lib/terminal/runtime.test.js +96 -0
  311. package/server/lib/terminal/terminal-ws-protocol.js +68 -0
  312. package/server/lib/terminal/terminal-ws-protocol.test.js +145 -0
  313. package/server/lib/text/DOCUMENTATION.md +35 -0
  314. package/server/lib/text/summarization.js +138 -0
  315. package/server/lib/text/summarization.test.js +34 -0
  316. package/server/lib/tts/DOCUMENTATION.md +146 -0
  317. package/server/lib/tts/base-url.js +62 -0
  318. package/server/lib/tts/capability-runtime.js +31 -0
  319. package/server/lib/tts/index.js +19 -0
  320. package/server/lib/tts/routes.js +261 -0
  321. package/server/lib/tts/routes.test.js +53 -0
  322. package/server/lib/tts/service.js +178 -0
  323. package/server/lib/tts/stt.js +75 -0
  324. package/server/lib/tunnels/DOCUMENTATION.md +18 -0
  325. package/server/lib/tunnels/index.js +166 -0
  326. package/server/lib/tunnels/managed-config.js +201 -0
  327. package/server/lib/tunnels/providers/cloudflare.js +260 -0
  328. package/server/lib/tunnels/registry.js +51 -0
  329. package/server/lib/tunnels/routes.js +605 -0
  330. package/server/lib/tunnels/types.js +219 -0
  331. package/server/lib/ui-auth/DOCUMENTATION.md +38 -0
  332. package/server/lib/ui-auth/ui-auth.js +673 -0
  333. package/server/lib/ui-auth/ui-passkeys.js +545 -0
  334. package/server/opencode-proxy.test.js +151 -0
  335. package/server/proxy-headers.js +61 -0
  336. package/server/proxy-headers.test.js +58 -0
  337. package/server/sse-routes.test.js +152 -0
@@ -0,0 +1,155 @@
1
+ let G=class extends Error{constructor(e){super(e),this.name="ShikiError"}};function Ns(t){return on(t)}function on(t){return Array.isArray(t)?Ps(t):t instanceof RegExp?t:typeof t=="object"?$s(t):t}function Ps(t){let e=[];for(let n=0,r=t.length;n<r;n++)e[n]=on(t[n]);return e}function $s(t){let e={};for(let n in t)e[n]=on(t[n]);return e}function wr(t,...e){return e.forEach(n=>{for(let r in n)t[r]=n[r]}),t}function Cr(t){const e=~t.lastIndexOf("/")||~t.lastIndexOf("\\");return e===0?t:~e===t.length-1?Cr(t.substring(0,t.length-1)):t.substr(~e+1)}var St=/\$(\d+)|\${(\d+):\/(downcase|upcase)}/g,ze=class{static hasCaptures(t){return t===null?!1:(St.lastIndex=0,St.test(t))}static replaceCaptures(t,e,n){return t.replace(St,(r,s,o,i)=>{let a=n[parseInt(s||o,10)];if(a){let l=e.substring(a.start,a.end);for(;l[0]===".";)l=l.substring(1);switch(i){case"downcase":return l.toLowerCase();case"upcase":return l.toUpperCase();default:return l}}else return r})}};function _r(t,e){return t<e?-1:t>e?1:0}function Sr(t,e){if(t===null&&e===null)return 0;if(!t)return-1;if(!e)return 1;let n=t.length,r=e.length;if(n===r){for(let s=0;s<n;s++){let o=_r(t[s],e[s]);if(o!==0)return o}return 0}return n-r}function kn(t){return!!(/^#[0-9a-f]{6}$/i.test(t)||/^#[0-9a-f]{8}$/i.test(t)||/^#[0-9a-f]{3}$/i.test(t)||/^#[0-9a-f]{4}$/i.test(t))}function kr(t){return t.replace(/[\-\\\{\}\*\+\?\|\^\$\.\,\[\]\(\)\#\s]/g,"\\$&")}var xr=class{constructor(t){this.fn=t}cache=new Map;get(t){if(this.cache.has(t))return this.cache.get(t);const e=this.fn(t);return this.cache.set(t,e),e}},tt=class{constructor(t,e,n){this._colorMap=t,this._defaults=e,this._root=n}static createFromRawTheme(t,e){return this.createFromParsedTheme(Os(t),e)}static createFromParsedTheme(t,e){return Gs(t,e)}_cachedMatchRoot=new xr(t=>this._root.match(t));getColorMap(){return this._colorMap.getColorMap()}getDefaults(){return this._defaults}match(t){if(t===null)return this._defaults;const e=t.scopeName,r=this._cachedMatchRoot.get(e).find(s=>Ts(t.parent,s.parentScopes));return r?new vr(r.fontStyle,r.foreground,r.background):null}},kt=class Ye{constructor(e,n){this.parent=e,this.scopeName=n}static push(e,n){for(const r of n)e=new Ye(e,r);return e}static from(...e){let n=null;for(let r=0;r<e.length;r++)n=new Ye(n,e[r]);return n}push(e){return new Ye(this,e)}getSegments(){let e=this;const n=[];for(;e;)n.push(e.scopeName),e=e.parent;return n.reverse(),n}toString(){return this.getSegments().join(" ")}extends(e){return this===e?!0:this.parent===null?!1:this.parent.extends(e)}getExtensionIfDefined(e){const n=[];let r=this;for(;r&&r!==e;)n.push(r.scopeName),r=r.parent;return r===e?n.reverse():void 0}};function Ts(t,e){if(e.length===0)return!0;for(let n=0;n<e.length;n++){let r=e[n],s=!1;if(r===">"){if(n===e.length-1)return!1;r=e[++n],s=!0}for(;t&&!Ms(t.scopeName,r);){if(s)return!1;t=t.parent}if(!t)return!1;t=t.parent}return!0}function Ms(t,e){return e===t||t.startsWith(e)&&t[e.length]==="."}var vr=class{constructor(t,e,n){this.fontStyle=t,this.foregroundId=e,this.backgroundId=n}};function Os(t){if(!t)return[];if(!t.settings||!Array.isArray(t.settings))return[];let e=t.settings,n=[],r=0;for(let s=0,o=e.length;s<o;s++){let i=e[s];if(!i.settings)continue;let a;if(typeof i.scope=="string"){let f=i.scope;f=f.replace(/^[,]+/,""),f=f.replace(/[,]+$/,""),a=f.split(",")}else Array.isArray(i.scope)?a=i.scope:a=[""];let l=-1;if(typeof i.settings.fontStyle=="string"){l=0;let f=i.settings.fontStyle.split(" ");for(let h=0,d=f.length;h<d;h++)switch(f[h]){case"italic":l=l|1;break;case"bold":l=l|2;break;case"underline":l=l|4;break;case"strikethrough":l=l|8;break}}let c=null;typeof i.settings.foreground=="string"&&kn(i.settings.foreground)&&(c=i.settings.foreground);let u=null;typeof i.settings.background=="string"&&kn(i.settings.background)&&(u=i.settings.background);for(let f=0,h=a.length;f<h;f++){let p=a[f].trim().split(" "),b=p[p.length-1],w=null;p.length>1&&(w=p.slice(0,p.length-1),w.reverse()),n[r++]=new Ds(b,w,s,l,c,u)}}return n}var Ds=class{constructor(t,e,n,r,s,o){this.scope=t,this.parentScopes=e,this.index=n,this.fontStyle=r,this.foreground=s,this.background=o}},j=(t=>(t[t.NotSet=-1]="NotSet",t[t.None=0]="None",t[t.Italic=1]="Italic",t[t.Bold=2]="Bold",t[t.Underline=4]="Underline",t[t.Strikethrough=8]="Strikethrough",t))(j||{});function Gs(t,e){t.sort((l,c)=>{let u=_r(l.scope,c.scope);return u!==0||(u=Sr(l.parentScopes,c.parentScopes),u!==0)?u:l.index-c.index});let n=0,r="#000000",s="#ffffff";for(;t.length>=1&&t[0].scope==="";){let l=t.shift();l.fontStyle!==-1&&(n=l.fontStyle),l.foreground!==null&&(r=l.foreground),l.background!==null&&(s=l.background)}let o=new Bs(e),i=new vr(n,o.getId(r),o.getId(s)),a=new Us(new Bt(0,null,-1,0,0),[]);for(let l=0,c=t.length;l<c;l++){let u=t[l];a.insert(0,u.scope,u.parentScopes,u.fontStyle,o.getId(u.foreground),o.getId(u.background))}return new tt(o,i,a)}var Bs=class{_isFrozen;_lastColorId;_id2color;_color2id;constructor(t){if(this._lastColorId=0,this._id2color=[],this._color2id=Object.create(null),Array.isArray(t)){this._isFrozen=!0;for(let e=0,n=t.length;e<n;e++)this._color2id[t[e]]=e,this._id2color[e]=t[e]}else this._isFrozen=!1}getId(t){if(t===null)return 0;t=t.toUpperCase();let e=this._color2id[t];if(e)return e;if(this._isFrozen)throw new Error(`Missing color in color map - ${t}`);return e=++this._lastColorId,this._color2id[t]=e,this._id2color[e]=t,e}getColorMap(){return this._id2color.slice(0)}},Fs=Object.freeze([]),Bt=class Ir{scopeDepth;parentScopes;fontStyle;foreground;background;constructor(e,n,r,s,o){this.scopeDepth=e,this.parentScopes=n||Fs,this.fontStyle=r,this.foreground=s,this.background=o}clone(){return new Ir(this.scopeDepth,this.parentScopes,this.fontStyle,this.foreground,this.background)}static cloneArr(e){let n=[];for(let r=0,s=e.length;r<s;r++)n[r]=e[r].clone();return n}acceptOverwrite(e,n,r,s){this.scopeDepth>e?console.log("how did this happen?"):this.scopeDepth=e,n!==-1&&(this.fontStyle=n),r!==0&&(this.foreground=r),s!==0&&(this.background=s)}},Us=class Ft{constructor(e,n=[],r={}){this._mainRule=e,this._children=r,this._rulesWithParentScopes=n}_rulesWithParentScopes;static _cmpBySpecificity(e,n){if(e.scopeDepth!==n.scopeDepth)return n.scopeDepth-e.scopeDepth;let r=0,s=0;for(;e.parentScopes[r]===">"&&r++,n.parentScopes[s]===">"&&s++,!(r>=e.parentScopes.length||s>=n.parentScopes.length);){const o=n.parentScopes[s].length-e.parentScopes[r].length;if(o!==0)return o;r++,s++}return n.parentScopes.length-e.parentScopes.length}match(e){if(e!==""){let r=e.indexOf("."),s,o;if(r===-1?(s=e,o=""):(s=e.substring(0,r),o=e.substring(r+1)),this._children.hasOwnProperty(s))return this._children[s].match(o)}const n=this._rulesWithParentScopes.concat(this._mainRule);return n.sort(Ft._cmpBySpecificity),n}insert(e,n,r,s,o,i){if(n===""){this._doInsertHere(e,r,s,o,i);return}let a=n.indexOf("."),l,c;a===-1?(l=n,c=""):(l=n.substring(0,a),c=n.substring(a+1));let u;this._children.hasOwnProperty(l)?u=this._children[l]:(u=new Ft(this._mainRule.clone(),Bt.cloneArr(this._rulesWithParentScopes)),this._children[l]=u),u.insert(e+1,c,r,s,o,i)}_doInsertHere(e,n,r,s,o){if(n===null){this._mainRule.acceptOverwrite(e,r,s,o);return}for(let i=0,a=this._rulesWithParentScopes.length;i<a;i++){let l=this._rulesWithParentScopes[i];if(Sr(l.parentScopes,n)===0){l.acceptOverwrite(e,r,s,o);return}}r===-1&&(r=this._mainRule.fontStyle),s===0&&(s=this._mainRule.foreground),o===0&&(o=this._mainRule.background),this._rulesWithParentScopes.push(new Bt(e,n,r,s,o))}},ke=class q{static toBinaryStr(e){return e.toString(2).padStart(32,"0")}static print(e){const n=q.getLanguageId(e),r=q.getTokenType(e),s=q.getFontStyle(e),o=q.getForeground(e),i=q.getBackground(e);console.log({languageId:n,tokenType:r,fontStyle:s,foreground:o,background:i})}static getLanguageId(e){return(e&255)>>>0}static getTokenType(e){return(e&768)>>>8}static containsBalancedBrackets(e){return(e&1024)!==0}static getFontStyle(e){return(e&30720)>>>11}static getForeground(e){return(e&16744448)>>>15}static getBackground(e){return(e&4278190080)>>>24}static set(e,n,r,s,o,i,a){let l=q.getLanguageId(e),c=q.getTokenType(e),u=q.containsBalancedBrackets(e)?1:0,f=q.getFontStyle(e),h=q.getForeground(e),d=q.getBackground(e);return n!==0&&(l=n),r!==8&&(c=r),s!==null&&(u=s?1:0),o!==-1&&(f=o),i!==0&&(h=i),a!==0&&(d=a),(l<<0|c<<8|u<<10|f<<11|h<<15|d<<24)>>>0}};function nt(t,e){const n=[],r=js(t);let s=r.next();for(;s!==null;){let l=0;if(s.length===2&&s.charAt(1)===":"){switch(s.charAt(0)){case"R":l=1;break;case"L":l=-1;break;default:console.log(`Unknown priority ${s} in scope selector`)}s=r.next()}let c=i();if(n.push({matcher:c,priority:l}),s!==",")break;s=r.next()}return n;function o(){if(s==="-"){s=r.next();const l=o();return c=>!!l&&!l(c)}if(s==="("){s=r.next();const l=a();return s===")"&&(s=r.next()),l}if(xn(s)){const l=[];do l.push(s),s=r.next();while(xn(s));return c=>e(l,c)}return null}function i(){const l=[];let c=o();for(;c;)l.push(c),c=o();return u=>l.every(f=>f(u))}function a(){const l=[];let c=i();for(;c&&(l.push(c),s==="|"||s===",");){do s=r.next();while(s==="|"||s===",");c=i()}return u=>l.some(f=>f(u))}}function xn(t){return!!t&&!!t.match(/[\w\.:]+/)}function js(t){let e=/([LR]:|[\w\.:][\w\.:\-]*|[\,\|\-\(\)])/g,n=e.exec(t);return{next:()=>{if(!n)return null;const r=n[0];return n=e.exec(t),r}}}function Er(t){typeof t.dispose=="function"&&t.dispose()}var Te=class{constructor(t){this.scopeName=t}toKey(){return this.scopeName}},Ws=class{constructor(t,e){this.scopeName=t,this.ruleName=e}toKey(){return`${this.scopeName}#${this.ruleName}`}},zs=class{_references=[];_seenReferenceKeys=new Set;get references(){return this._references}visitedRule=new Set;add(t){const e=t.toKey();this._seenReferenceKeys.has(e)||(this._seenReferenceKeys.add(e),this._references.push(t))}},Hs=class{constructor(t,e){this.repo=t,this.initialScopeName=e,this.seenFullScopeRequests.add(this.initialScopeName),this.Q=[new Te(this.initialScopeName)]}seenFullScopeRequests=new Set;seenPartialScopeRequests=new Set;Q;processQueue(){const t=this.Q;this.Q=[];const e=new zs;for(const n of t)qs(n,this.initialScopeName,this.repo,e);for(const n of e.references)if(n instanceof Te){if(this.seenFullScopeRequests.has(n.scopeName))continue;this.seenFullScopeRequests.add(n.scopeName),this.Q.push(n)}else{if(this.seenFullScopeRequests.has(n.scopeName)||this.seenPartialScopeRequests.has(n.toKey()))continue;this.seenPartialScopeRequests.add(n.toKey()),this.Q.push(n)}}};function qs(t,e,n,r){const s=n.lookup(t.scopeName);if(!s){if(t.scopeName===e)throw new Error(`No grammar provided for <${e}>`);return}const o=n.lookup(e);t instanceof Te?Je({baseGrammar:o,selfGrammar:s},r):Ut(t.ruleName,{baseGrammar:o,selfGrammar:s,repository:s.repository},r);const i=n.injections(t.scopeName);if(i)for(const a of i)r.add(new Te(a))}function Ut(t,e,n){if(e.repository&&e.repository[t]){const r=e.repository[t];rt([r],e,n)}}function Je(t,e){t.selfGrammar.patterns&&Array.isArray(t.selfGrammar.patterns)&&rt(t.selfGrammar.patterns,{...t,repository:t.selfGrammar.repository},e),t.selfGrammar.injections&&rt(Object.values(t.selfGrammar.injections),{...t,repository:t.selfGrammar.repository},e)}function rt(t,e,n){for(const r of t){if(n.visitedRule.has(r))continue;n.visitedRule.add(r);const s=r.repository?wr({},e.repository,r.repository):e.repository;Array.isArray(r.patterns)&&rt(r.patterns,{...e,repository:s},n);const o=r.include;if(!o)continue;const i=Ar(o);switch(i.kind){case 0:Je({...e,selfGrammar:e.baseGrammar},n);break;case 1:Je(e,n);break;case 2:Ut(i.ruleName,{...e,repository:s},n);break;case 3:case 4:const a=i.scopeName===e.selfGrammar.scopeName?e.selfGrammar:i.scopeName===e.baseGrammar.scopeName?e.baseGrammar:void 0;if(a){const l={baseGrammar:e.baseGrammar,selfGrammar:a,repository:s};i.kind===4?Ut(i.ruleName,l,n):Je(l,n)}else i.kind===4?n.add(new Ws(i.scopeName,i.ruleName)):n.add(new Te(i.scopeName));break}}}var Vs=class{kind=0},Xs=class{kind=1},Ks=class{constructor(t){this.ruleName=t}kind=2},Zs=class{constructor(t){this.scopeName=t}kind=3},Qs=class{constructor(t,e){this.scopeName=t,this.ruleName=e}kind=4};function Ar(t){if(t==="$base")return new Vs;if(t==="$self")return new Xs;const e=t.indexOf("#");if(e===-1)return new Zs(t);if(e===0)return new Ks(t.substring(1));{const n=t.substring(0,e),r=t.substring(e+1);return new Qs(n,r)}}var Ys=/\\(\d+)/,vn=/\\(\d+)/g,Js=-1,Lr=-2;var Fe=class{$location;id;_nameIsCapturing;_name;_contentNameIsCapturing;_contentName;constructor(t,e,n,r){this.$location=t,this.id=e,this._name=n||null,this._nameIsCapturing=ze.hasCaptures(this._name),this._contentName=r||null,this._contentNameIsCapturing=ze.hasCaptures(this._contentName)}get debugName(){const t=this.$location?`${Cr(this.$location.filename)}:${this.$location.line}`:"unknown";return`${this.constructor.name}#${this.id} @ ${t}`}getName(t,e){return!this._nameIsCapturing||this._name===null||t===null||e===null?this._name:ze.replaceCaptures(this._name,t,e)}getContentName(t,e){return!this._contentNameIsCapturing||this._contentName===null?this._contentName:ze.replaceCaptures(this._contentName,t,e)}},eo=class extends Fe{retokenizeCapturedWithRuleId;constructor(t,e,n,r,s){super(t,e,n,r),this.retokenizeCapturedWithRuleId=s}dispose(){}collectPatterns(t,e){throw new Error("Not supported!")}compile(t,e){throw new Error("Not supported!")}compileAG(t,e,n,r){throw new Error("Not supported!")}},to=class extends Fe{_match;captures;_cachedCompiledPatterns;constructor(t,e,n,r,s){super(t,e,n,null),this._match=new Me(r,this.id),this.captures=s,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}get debugMatchRegExp(){return`${this._match.source}`}collectPatterns(t,e){e.push(this._match)}compile(t,e){return this._getCachedCompiledPatterns(t).compile(t)}compileAG(t,e,n,r){return this._getCachedCompiledPatterns(t).compileAG(t,n,r)}_getCachedCompiledPatterns(t){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new Oe,this.collectPatterns(t,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},In=class extends Fe{hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(t,e,n,r,s){super(t,e,n,r),this.patterns=s.patterns,this.hasMissingPatterns=s.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}collectPatterns(t,e){for(const n of this.patterns)t.getRule(n).collectPatterns(t,e)}compile(t,e){return this._getCachedCompiledPatterns(t).compile(t)}compileAG(t,e,n,r){return this._getCachedCompiledPatterns(t).compileAG(t,n,r)}_getCachedCompiledPatterns(t){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new Oe,this.collectPatterns(t,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},jt=class extends Fe{_begin;beginCaptures;_end;endHasBackReferences;endCaptures;applyEndPatternLast;hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(t,e,n,r,s,o,i,a,l,c){super(t,e,n,r),this._begin=new Me(s,this.id),this.beginCaptures=o,this._end=new Me(i||"￿",-1),this.endHasBackReferences=this._end.hasBackReferences,this.endCaptures=a,this.applyEndPatternLast=l||!1,this.patterns=c.patterns,this.hasMissingPatterns=c.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugEndRegExp(){return`${this._end.source}`}getEndWithResolvedBackReferences(t,e){return this._end.resolveBackReferences(t,e)}collectPatterns(t,e){e.push(this._begin)}compile(t,e){return this._getCachedCompiledPatterns(t,e).compile(t)}compileAG(t,e,n,r){return this._getCachedCompiledPatterns(t,e).compileAG(t,n,r)}_getCachedCompiledPatterns(t,e){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new Oe;for(const n of this.patterns)t.getRule(n).collectPatterns(t,this._cachedCompiledPatterns);this.applyEndPatternLast?this._cachedCompiledPatterns.push(this._end.hasBackReferences?this._end.clone():this._end):this._cachedCompiledPatterns.unshift(this._end.hasBackReferences?this._end.clone():this._end)}return this._end.hasBackReferences&&(this.applyEndPatternLast?this._cachedCompiledPatterns.setSource(this._cachedCompiledPatterns.length()-1,e):this._cachedCompiledPatterns.setSource(0,e)),this._cachedCompiledPatterns}},st=class extends Fe{_begin;beginCaptures;whileCaptures;_while;whileHasBackReferences;hasMissingPatterns;patterns;_cachedCompiledPatterns;_cachedCompiledWhilePatterns;constructor(t,e,n,r,s,o,i,a,l){super(t,e,n,r),this._begin=new Me(s,this.id),this.beginCaptures=o,this.whileCaptures=a,this._while=new Me(i,Lr),this.whileHasBackReferences=this._while.hasBackReferences,this.patterns=l.patterns,this.hasMissingPatterns=l.hasMissingPatterns,this._cachedCompiledPatterns=null,this._cachedCompiledWhilePatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null),this._cachedCompiledWhilePatterns&&(this._cachedCompiledWhilePatterns.dispose(),this._cachedCompiledWhilePatterns=null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugWhileRegExp(){return`${this._while.source}`}getWhileWithResolvedBackReferences(t,e){return this._while.resolveBackReferences(t,e)}collectPatterns(t,e){e.push(this._begin)}compile(t,e){return this._getCachedCompiledPatterns(t).compile(t)}compileAG(t,e,n,r){return this._getCachedCompiledPatterns(t).compileAG(t,n,r)}_getCachedCompiledPatterns(t){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new Oe;for(const e of this.patterns)t.getRule(e).collectPatterns(t,this._cachedCompiledPatterns)}return this._cachedCompiledPatterns}compileWhile(t,e){return this._getCachedCompiledWhilePatterns(t,e).compile(t)}compileWhileAG(t,e,n,r){return this._getCachedCompiledWhilePatterns(t,e).compileAG(t,n,r)}_getCachedCompiledWhilePatterns(t,e){return this._cachedCompiledWhilePatterns||(this._cachedCompiledWhilePatterns=new Oe,this._cachedCompiledWhilePatterns.push(this._while.hasBackReferences?this._while.clone():this._while)),this._while.hasBackReferences&&this._cachedCompiledWhilePatterns.setSource(0,e||"￿"),this._cachedCompiledWhilePatterns}},Rr=class U{static createCaptureRule(e,n,r,s,o){return e.registerRule(i=>new eo(n,i,r,s,o))}static getCompiledRuleId(e,n,r){return e.id||n.registerRule(s=>{if(e.id=s,e.match)return new to(e.$vscodeTextmateLocation,e.id,e.name,e.match,U._compileCaptures(e.captures,n,r));if(typeof e.begin>"u"){e.repository&&(r=wr({},r,e.repository));let o=e.patterns;return typeof o>"u"&&e.include&&(o=[{include:e.include}]),new In(e.$vscodeTextmateLocation,e.id,e.name,e.contentName,U._compilePatterns(o,n,r))}return e.while?new st(e.$vscodeTextmateLocation,e.id,e.name,e.contentName,e.begin,U._compileCaptures(e.beginCaptures||e.captures,n,r),e.while,U._compileCaptures(e.whileCaptures||e.captures,n,r),U._compilePatterns(e.patterns,n,r)):new jt(e.$vscodeTextmateLocation,e.id,e.name,e.contentName,e.begin,U._compileCaptures(e.beginCaptures||e.captures,n,r),e.end,U._compileCaptures(e.endCaptures||e.captures,n,r),e.applyEndPatternLast,U._compilePatterns(e.patterns,n,r))}),e.id}static _compileCaptures(e,n,r){let s=[];if(e){let o=0;for(const i in e){if(i==="$vscodeTextmateLocation")continue;const a=parseInt(i,10);a>o&&(o=a)}for(let i=0;i<=o;i++)s[i]=null;for(const i in e){if(i==="$vscodeTextmateLocation")continue;const a=parseInt(i,10);let l=0;e[i].patterns&&(l=U.getCompiledRuleId(e[i],n,r)),s[a]=U.createCaptureRule(n,e[i].$vscodeTextmateLocation,e[i].name,e[i].contentName,l)}}return s}static _compilePatterns(e,n,r){let s=[];if(e)for(let o=0,i=e.length;o<i;o++){const a=e[o];let l=-1;if(a.include){const c=Ar(a.include);switch(c.kind){case 0:case 1:l=U.getCompiledRuleId(r[a.include],n,r);break;case 2:let u=r[c.ruleName];u&&(l=U.getCompiledRuleId(u,n,r));break;case 3:case 4:const f=c.scopeName,h=c.kind===4?c.ruleName:null,d=n.getExternalGrammar(f,r);if(d)if(h){let p=d.repository[h];p&&(l=U.getCompiledRuleId(p,n,d.repository))}else l=U.getCompiledRuleId(d.repository.$self,n,d.repository);break}}else l=U.getCompiledRuleId(a,n,r);if(l!==-1){const c=n.getRule(l);let u=!1;if((c instanceof In||c instanceof jt||c instanceof st)&&c.hasMissingPatterns&&c.patterns.length===0&&(u=!0),u)continue;s.push(l)}}return{patterns:s,hasMissingPatterns:(e?e.length:0)!==s.length}}},Me=class Nr{source;ruleId;hasAnchor;hasBackReferences;_anchorCache;constructor(e,n){if(e&&typeof e=="string"){const r=e.length;let s=0,o=[],i=!1;for(let a=0;a<r;a++)if(e.charAt(a)==="\\"&&a+1<r){const c=e.charAt(a+1);c==="z"?(o.push(e.substring(s,a)),o.push("$(?!\\n)(?<!\\n)"),s=a+2):(c==="A"||c==="G")&&(i=!0),a++}this.hasAnchor=i,s===0?this.source=e:(o.push(e.substring(s,r)),this.source=o.join(""))}else this.hasAnchor=!1,this.source=e;this.hasAnchor?this._anchorCache=this._buildAnchorCache():this._anchorCache=null,this.ruleId=n,typeof this.source=="string"?this.hasBackReferences=Ys.test(this.source):this.hasBackReferences=!1}clone(){return new Nr(this.source,this.ruleId)}setSource(e){this.source!==e&&(this.source=e,this.hasAnchor&&(this._anchorCache=this._buildAnchorCache()))}resolveBackReferences(e,n){if(typeof this.source!="string")throw new Error("This method should only be called if the source is a string");let r=n.map(s=>e.substring(s.start,s.end));return vn.lastIndex=0,this.source.replace(vn,(s,o)=>kr(r[parseInt(o,10)]||""))}_buildAnchorCache(){if(typeof this.source!="string")throw new Error("This method should only be called if the source is a string");let e=[],n=[],r=[],s=[],o,i,a,l;for(o=0,i=this.source.length;o<i;o++)a=this.source.charAt(o),e[o]=a,n[o]=a,r[o]=a,s[o]=a,a==="\\"&&o+1<i&&(l=this.source.charAt(o+1),l==="A"?(e[o+1]="￿",n[o+1]="￿",r[o+1]="A",s[o+1]="A"):l==="G"?(e[o+1]="￿",n[o+1]="G",r[o+1]="￿",s[o+1]="G"):(e[o+1]=l,n[o+1]=l,r[o+1]=l,s[o+1]=l),o++);return{A0_G0:e.join(""),A0_G1:n.join(""),A1_G0:r.join(""),A1_G1:s.join("")}}resolveAnchors(e,n){return!this.hasAnchor||!this._anchorCache||typeof this.source!="string"?this.source:e?n?this._anchorCache.A1_G1:this._anchorCache.A1_G0:n?this._anchorCache.A0_G1:this._anchorCache.A0_G0}},Oe=class{_items;_hasAnchors;_cached;_anchorCache;constructor(){this._items=[],this._hasAnchors=!1,this._cached=null,this._anchorCache={A0_G0:null,A0_G1:null,A1_G0:null,A1_G1:null}}dispose(){this._disposeCaches()}_disposeCaches(){this._cached&&(this._cached.dispose(),this._cached=null),this._anchorCache.A0_G0&&(this._anchorCache.A0_G0.dispose(),this._anchorCache.A0_G0=null),this._anchorCache.A0_G1&&(this._anchorCache.A0_G1.dispose(),this._anchorCache.A0_G1=null),this._anchorCache.A1_G0&&(this._anchorCache.A1_G0.dispose(),this._anchorCache.A1_G0=null),this._anchorCache.A1_G1&&(this._anchorCache.A1_G1.dispose(),this._anchorCache.A1_G1=null)}push(t){this._items.push(t),this._hasAnchors=this._hasAnchors||t.hasAnchor}unshift(t){this._items.unshift(t),this._hasAnchors=this._hasAnchors||t.hasAnchor}length(){return this._items.length}setSource(t,e){this._items[t].source!==e&&(this._disposeCaches(),this._items[t].setSource(e))}compile(t){if(!this._cached){let e=this._items.map(n=>n.source);this._cached=new En(t,e,this._items.map(n=>n.ruleId))}return this._cached}compileAG(t,e,n){return this._hasAnchors?e?n?(this._anchorCache.A1_G1||(this._anchorCache.A1_G1=this._resolveAnchors(t,e,n)),this._anchorCache.A1_G1):(this._anchorCache.A1_G0||(this._anchorCache.A1_G0=this._resolveAnchors(t,e,n)),this._anchorCache.A1_G0):n?(this._anchorCache.A0_G1||(this._anchorCache.A0_G1=this._resolveAnchors(t,e,n)),this._anchorCache.A0_G1):(this._anchorCache.A0_G0||(this._anchorCache.A0_G0=this._resolveAnchors(t,e,n)),this._anchorCache.A0_G0):this.compile(t)}_resolveAnchors(t,e,n){let r=this._items.map(s=>s.resolveAnchors(e,n));return new En(t,r,this._items.map(s=>s.ruleId))}},En=class{constructor(t,e,n){this.regExps=e,this.rules=n,this.scanner=t.createOnigScanner(e)}scanner;dispose(){typeof this.scanner.dispose=="function"&&this.scanner.dispose()}toString(){const t=[];for(let e=0,n=this.rules.length;e<n;e++)t.push(" - "+this.rules[e]+": "+this.regExps[e]);return t.join(`
2
+ `)}findNextMatchSync(t,e,n){const r=this.scanner.findNextMatchSync(t,e,n);return r?{ruleId:this.rules[r.index],captureIndices:r.captureIndices}:null}},xt=class{constructor(t,e){this.languageId=t,this.tokenType=e}},no=class Wt{_defaultAttributes;_embeddedLanguagesMatcher;constructor(e,n){this._defaultAttributes=new xt(e,8),this._embeddedLanguagesMatcher=new ro(Object.entries(n||{}))}getDefaultAttributes(){return this._defaultAttributes}getBasicScopeAttributes(e){return e===null?Wt._NULL_SCOPE_METADATA:this._getBasicScopeAttributes.get(e)}static _NULL_SCOPE_METADATA=new xt(0,0);_getBasicScopeAttributes=new xr(e=>{const n=this._scopeToLanguage(e),r=this._toStandardTokenType(e);return new xt(n,r)});_scopeToLanguage(e){return this._embeddedLanguagesMatcher.match(e)||0}_toStandardTokenType(e){const n=e.match(Wt.STANDARD_TOKEN_TYPE_REGEXP);if(!n)return 8;switch(n[1]){case"comment":return 1;case"string":return 2;case"regex":return 3;case"meta.embedded":return 0}throw new Error("Unexpected match for standard token type!")}static STANDARD_TOKEN_TYPE_REGEXP=/\b(comment|string|regex|meta\.embedded)\b/},ro=class{values;scopesRegExp;constructor(t){if(t.length===0)this.values=null,this.scopesRegExp=null;else{this.values=new Map(t);const e=t.map(([n,r])=>kr(n));e.sort(),e.reverse(),this.scopesRegExp=new RegExp(`^((${e.join(")|(")}))($|\\.)`,"")}}match(t){if(!this.scopesRegExp)return;const e=t.match(this.scopesRegExp);if(e)return this.values.get(e[1])}},An=class{constructor(t,e){this.stack=t,this.stoppedEarly=e}};function Pr(t,e,n,r,s,o,i,a){const l=e.content.length;let c=!1,u=-1;if(i){const d=so(t,e,n,r,s,o);s=d.stack,r=d.linePos,n=d.isFirstLine,u=d.anchorPosition}const f=Date.now();for(;!c;){if(a!==0&&Date.now()-f>a)return new An(s,!0);h()}return new An(s,!1);function h(){const d=oo(t,e,n,r,s,u);if(!d){o.produce(s,l),c=!0;return}const p=d.captureIndices,b=d.matchedRuleId,w=p&&p.length>0?p[0].end>r:!1;if(b===Js){const y=s.getRule(t);o.produce(s,p[0].start),s=s.withContentNameScopesList(s.nameScopesList),Ne(t,e,n,s,o,y.endCaptures,p),o.produce(s,p[0].end);const m=s;if(s=s.parent,u=m.getAnchorPos(),!w&&m.getEnterPos()===r){s=m,o.produce(s,l),c=!0;return}}else{const y=t.getRule(b);o.produce(s,p[0].start);const m=s,g=y.getName(e.content,p),S=s.contentNameScopesList.pushAttributed(g,t);if(s=s.push(b,r,u,p[0].end===l,null,S,S),y instanceof jt){const k=y;Ne(t,e,n,s,o,k.beginCaptures,p),o.produce(s,p[0].end),u=p[0].end;const _=k.getContentName(e.content,p),x=S.pushAttributed(_,t);if(s=s.withContentNameScopesList(x),k.endHasBackReferences&&(s=s.withEndRule(k.getEndWithResolvedBackReferences(e.content,p))),!w&&m.hasSameRuleAs(s)){s=s.pop(),o.produce(s,l),c=!0;return}}else if(y instanceof st){const k=y;Ne(t,e,n,s,o,k.beginCaptures,p),o.produce(s,p[0].end),u=p[0].end;const _=k.getContentName(e.content,p),x=S.pushAttributed(_,t);if(s=s.withContentNameScopesList(x),k.whileHasBackReferences&&(s=s.withEndRule(k.getWhileWithResolvedBackReferences(e.content,p))),!w&&m.hasSameRuleAs(s)){s=s.pop(),o.produce(s,l),c=!0;return}}else if(Ne(t,e,n,s,o,y.captures,p),o.produce(s,p[0].end),s=s.pop(),!w){s=s.safePop(),o.produce(s,l),c=!0;return}}p[0].end>r&&(r=p[0].end,n=!1)}}function so(t,e,n,r,s,o){let i=s.beginRuleCapturedEOL?0:-1;const a=[];for(let l=s;l;l=l.pop()){const c=l.getRule(t);c instanceof st&&a.push({rule:c,stack:l})}for(let l=a.pop();l;l=a.pop()){const{ruleScanner:c,findOptions:u}=lo(l.rule,t,l.stack.endRule,n,r===i),f=c.findNextMatchSync(e,r,u);if(f){if(f.ruleId!==Lr){s=l.stack.pop();break}f.captureIndices&&f.captureIndices.length&&(o.produce(l.stack,f.captureIndices[0].start),Ne(t,e,n,l.stack,o,l.rule.whileCaptures,f.captureIndices),o.produce(l.stack,f.captureIndices[0].end),i=f.captureIndices[0].end,f.captureIndices[0].end>r&&(r=f.captureIndices[0].end,n=!1))}else{s=l.stack.pop();break}}return{stack:s,linePos:r,anchorPosition:i,isFirstLine:n}}function oo(t,e,n,r,s,o){const i=io(t,e,n,r,s,o),a=t.getInjections();if(a.length===0)return i;const l=ao(a,t,e,n,r,s,o);if(!l)return i;if(!i)return l;const c=i.captureIndices[0].start,u=l.captureIndices[0].start;return u<c||l.priorityMatch&&u===c?l:i}function io(t,e,n,r,s,o){const i=s.getRule(t),{ruleScanner:a,findOptions:l}=$r(i,t,s.endRule,n,r===o),c=a.findNextMatchSync(e,r,l);return c?{captureIndices:c.captureIndices,matchedRuleId:c.ruleId}:null}function ao(t,e,n,r,s,o,i){let a=Number.MAX_VALUE,l=null,c,u=0;const f=o.contentNameScopesList.getScopeNames();for(let h=0,d=t.length;h<d;h++){const p=t[h];if(!p.matcher(f))continue;const b=e.getRule(p.ruleId),{ruleScanner:w,findOptions:y}=$r(b,e,null,r,s===i),m=w.findNextMatchSync(n,s,y);if(!m)continue;const g=m.captureIndices[0].start;if(!(g>=a)&&(a=g,l=m.captureIndices,c=m.ruleId,u=p.priority,a===s))break}return l?{priorityMatch:u===-1,captureIndices:l,matchedRuleId:c}:null}function $r(t,e,n,r,s){return{ruleScanner:t.compileAG(e,n,r,s),findOptions:0}}function lo(t,e,n,r,s){return{ruleScanner:t.compileWhileAG(e,n,r,s),findOptions:0}}function Ne(t,e,n,r,s,o,i){if(o.length===0)return;const a=e.content,l=Math.min(o.length,i.length),c=[],u=i[0].end;for(let f=0;f<l;f++){const h=o[f];if(h===null)continue;const d=i[f];if(d.length===0)continue;if(d.start>u)break;for(;c.length>0&&c[c.length-1].endPos<=d.start;)s.produceFromScopes(c[c.length-1].scopes,c[c.length-1].endPos),c.pop();if(c.length>0?s.produceFromScopes(c[c.length-1].scopes,d.start):s.produce(r,d.start),h.retokenizeCapturedWithRuleId){const b=h.getName(a,i),w=r.contentNameScopesList.pushAttributed(b,t),y=h.getContentName(a,i),m=w.pushAttributed(y,t),g=r.push(h.retokenizeCapturedWithRuleId,d.start,-1,!1,null,w,m),S=t.createOnigString(a.substring(0,d.end));Pr(t,S,n&&d.start===0,d.start,g,s,!1,0),Er(S);continue}const p=h.getName(a,i);if(p!==null){const w=(c.length>0?c[c.length-1].scopes:r.contentNameScopesList).pushAttributed(p,t);c.push(new co(w,d.end))}}for(;c.length>0;)s.produceFromScopes(c[c.length-1].scopes,c[c.length-1].endPos),c.pop()}var co=class{scopes;endPos;constructor(t,e){this.scopes=t,this.endPos=e}};function uo(t,e,n,r,s,o,i,a){return new ho(t,e,n,r,s,o,i,a)}function Ln(t,e,n,r,s){const o=nt(e,ot),i=Rr.getCompiledRuleId(n,r,s.repository);for(const a of o)t.push({debugSelector:e,matcher:a.matcher,ruleId:i,grammar:s,priority:a.priority})}function ot(t,e){if(e.length<t.length)return!1;let n=0;return t.every(r=>{for(let s=n;s<e.length;s++)if(fo(e[s],r))return n=s+1,!0;return!1})}function fo(t,e){if(!t)return!1;if(t===e)return!0;const n=e.length;return t.length>n&&t.substr(0,n)===e&&t[n]==="."}var ho=class{constructor(t,e,n,r,s,o,i,a){if(this._rootScopeName=t,this.balancedBracketSelectors=o,this._onigLib=a,this._basicScopeAttributesProvider=new no(n,r),this._rootId=-1,this._lastRuleId=0,this._ruleId2desc=[null],this._includedGrammars={},this._grammarRepository=i,this._grammar=Rn(e,null),this._injections=null,this._tokenTypeMatchers=[],s)for(const l of Object.keys(s)){const c=nt(l,ot);for(const u of c)this._tokenTypeMatchers.push({matcher:u.matcher,type:s[l]})}}_rootId;_lastRuleId;_ruleId2desc;_includedGrammars;_grammarRepository;_grammar;_injections;_basicScopeAttributesProvider;_tokenTypeMatchers;get themeProvider(){return this._grammarRepository}dispose(){for(const t of this._ruleId2desc)t&&t.dispose()}createOnigScanner(t){return this._onigLib.createOnigScanner(t)}createOnigString(t){return this._onigLib.createOnigString(t)}getMetadataForScope(t){return this._basicScopeAttributesProvider.getBasicScopeAttributes(t)}_collectInjections(){const t={lookup:s=>s===this._rootScopeName?this._grammar:this.getExternalGrammar(s),injections:s=>this._grammarRepository.injections(s)},e=[],n=this._rootScopeName,r=t.lookup(n);if(r){const s=r.injections;if(s)for(let i in s)Ln(e,i,s[i],this,r);const o=this._grammarRepository.injections(n);o&&o.forEach(i=>{const a=this.getExternalGrammar(i);if(a){const l=a.injectionSelector;l&&Ln(e,l,a,this,a)}})}return e.sort((s,o)=>s.priority-o.priority),e}getInjections(){return this._injections===null&&(this._injections=this._collectInjections()),this._injections}registerRule(t){const e=++this._lastRuleId,n=t(e);return this._ruleId2desc[e]=n,n}getRule(t){return this._ruleId2desc[t]}getExternalGrammar(t,e){if(this._includedGrammars[t])return this._includedGrammars[t];if(this._grammarRepository){const n=this._grammarRepository.lookup(t);if(n)return this._includedGrammars[t]=Rn(n,e&&e.$base),this._includedGrammars[t]}}tokenizeLine(t,e,n=0){const r=this._tokenize(t,e,!1,n);return{tokens:r.lineTokens.getResult(r.ruleStack,r.lineLength),ruleStack:r.ruleStack,stoppedEarly:r.stoppedEarly}}tokenizeLine2(t,e,n=0){const r=this._tokenize(t,e,!0,n);return{tokens:r.lineTokens.getBinaryResult(r.ruleStack,r.lineLength),ruleStack:r.ruleStack,stoppedEarly:r.stoppedEarly}}_tokenize(t,e,n,r){this._rootId===-1&&(this._rootId=Rr.getCompiledRuleId(this._grammar.repository.$self,this,this._grammar.repository),this.getInjections());let s;if(!e||e===zt.NULL){s=!0;const c=this._basicScopeAttributesProvider.getDefaultAttributes(),u=this.themeProvider.getDefaults(),f=ke.set(0,c.languageId,c.tokenType,null,u.fontStyle,u.foregroundId,u.backgroundId),h=this.getRule(this._rootId).getName(null,null);let d;h?d=Pe.createRootAndLookUpScopeName(h,f,this):d=Pe.createRoot("unknown",f),e=new zt(null,this._rootId,-1,-1,!1,null,d,d)}else s=!1,e.reset();t=t+`
3
+ `;const o=this.createOnigString(t),i=o.content.length,a=new go(n,t,this._tokenTypeMatchers,this.balancedBracketSelectors),l=Pr(this,o,s,0,e,a,!0,r);return Er(o),{lineLength:i,lineTokens:a,ruleStack:l.stack,stoppedEarly:l.stoppedEarly}}};function Rn(t,e){return t=Ns(t),t.repository=t.repository||{},t.repository.$self={$vscodeTextmateLocation:t.$vscodeTextmateLocation,patterns:t.patterns,name:t.scopeName},t.repository.$base=e||t.repository.$self,t}var Pe=class Y{constructor(e,n,r){this.parent=e,this.scopePath=n,this.tokenAttributes=r}static fromExtension(e,n){let r=e,s=e?.scopePath??null;for(const o of n)s=kt.push(s,o.scopeNames),r=new Y(r,s,o.encodedTokenAttributes);return r}static createRoot(e,n){return new Y(null,new kt(null,e),n)}static createRootAndLookUpScopeName(e,n,r){const s=r.getMetadataForScope(e),o=new kt(null,e),i=r.themeProvider.themeMatch(o),a=Y.mergeAttributes(n,s,i);return new Y(null,o,a)}get scopeName(){return this.scopePath.scopeName}toString(){return this.getScopeNames().join(" ")}equals(e){return Y.equals(this,e)}static equals(e,n){do{if(e===n||!e&&!n)return!0;if(!e||!n||e.scopeName!==n.scopeName||e.tokenAttributes!==n.tokenAttributes)return!1;e=e.parent,n=n.parent}while(!0)}static mergeAttributes(e,n,r){let s=-1,o=0,i=0;return r!==null&&(s=r.fontStyle,o=r.foregroundId,i=r.backgroundId),ke.set(e,n.languageId,n.tokenType,null,s,o,i)}pushAttributed(e,n){if(e===null)return this;if(e.indexOf(" ")===-1)return Y._pushAttributed(this,e,n);const r=e.split(/ /g);let s=this;for(const o of r)s=Y._pushAttributed(s,o,n);return s}static _pushAttributed(e,n,r){const s=r.getMetadataForScope(n),o=e.scopePath.push(n),i=r.themeProvider.themeMatch(o),a=Y.mergeAttributes(e.tokenAttributes,s,i);return new Y(e,o,a)}getScopeNames(){return this.scopePath.getSegments()}getExtensionIfDefined(e){const n=[];let r=this;for(;r&&r!==e;)n.push({encodedTokenAttributes:r.tokenAttributes,scopeNames:r.scopePath.getExtensionIfDefined(r.parent?.scopePath??null)}),r=r.parent;return r===e?n.reverse():void 0}},zt=class le{constructor(e,n,r,s,o,i,a,l){this.parent=e,this.ruleId=n,this.beginRuleCapturedEOL=o,this.endRule=i,this.nameScopesList=a,this.contentNameScopesList=l,this.depth=this.parent?this.parent.depth+1:1,this._enterPos=r,this._anchorPos=s}_stackElementBrand=void 0;static NULL=new le(null,0,0,0,!1,null,null,null);_enterPos;_anchorPos;depth;equals(e){return e===null?!1:le._equals(this,e)}static _equals(e,n){return e===n?!0:this._structuralEquals(e,n)?Pe.equals(e.contentNameScopesList,n.contentNameScopesList):!1}static _structuralEquals(e,n){do{if(e===n||!e&&!n)return!0;if(!e||!n||e.depth!==n.depth||e.ruleId!==n.ruleId||e.endRule!==n.endRule)return!1;e=e.parent,n=n.parent}while(!0)}clone(){return this}static _reset(e){for(;e;)e._enterPos=-1,e._anchorPos=-1,e=e.parent}reset(){le._reset(this)}pop(){return this.parent}safePop(){return this.parent?this.parent:this}push(e,n,r,s,o,i,a){return new le(this,e,n,r,s,o,i,a)}getEnterPos(){return this._enterPos}getAnchorPos(){return this._anchorPos}getRule(e){return e.getRule(this.ruleId)}toString(){const e=[];return this._writeString(e,0),"["+e.join(",")+"]"}_writeString(e,n){return this.parent&&(n=this.parent._writeString(e,n)),e[n++]=`(${this.ruleId}, ${this.nameScopesList?.toString()}, ${this.contentNameScopesList?.toString()})`,n}withContentNameScopesList(e){return this.contentNameScopesList===e?this:this.parent.push(this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,this.endRule,this.nameScopesList,e)}withEndRule(e){return this.endRule===e?this:new le(this.parent,this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,e,this.nameScopesList,this.contentNameScopesList)}hasSameRuleAs(e){let n=this;for(;n&&n._enterPos===e._enterPos;){if(n.ruleId===e.ruleId)return!0;n=n.parent}return!1}toStateStackFrame(){return{ruleId:this.ruleId,beginRuleCapturedEOL:this.beginRuleCapturedEOL,endRule:this.endRule,nameScopesList:this.nameScopesList?.getExtensionIfDefined(this.parent?.nameScopesList??null)??[],contentNameScopesList:this.contentNameScopesList?.getExtensionIfDefined(this.nameScopesList)??[]}}static pushFrame(e,n){const r=Pe.fromExtension(e?.nameScopesList??null,n.nameScopesList);return new le(e,n.ruleId,n.enterPos??-1,n.anchorPos??-1,n.beginRuleCapturedEOL,n.endRule,r,Pe.fromExtension(r,n.contentNameScopesList))}},po=class{balancedBracketScopes;unbalancedBracketScopes;allowAny=!1;constructor(t,e){this.balancedBracketScopes=t.flatMap(n=>n==="*"?(this.allowAny=!0,[]):nt(n,ot).map(r=>r.matcher)),this.unbalancedBracketScopes=e.flatMap(n=>nt(n,ot).map(r=>r.matcher))}get matchesAlways(){return this.allowAny&&this.unbalancedBracketScopes.length===0}get matchesNever(){return this.balancedBracketScopes.length===0&&!this.allowAny}match(t){for(const e of this.unbalancedBracketScopes)if(e(t))return!1;for(const e of this.balancedBracketScopes)if(e(t))return!0;return this.allowAny}},go=class{constructor(t,e,n,r){this.balancedBracketSelectors=r,this._emitBinaryTokens=t,this._tokenTypeOverrides=n,this._lineText=null,this._tokens=[],this._binaryTokens=[],this._lastTokenEndIndex=0}_emitBinaryTokens;_lineText;_tokens;_binaryTokens;_lastTokenEndIndex;_tokenTypeOverrides;produce(t,e){this.produceFromScopes(t.contentNameScopesList,e)}produceFromScopes(t,e){if(this._lastTokenEndIndex>=e)return;if(this._emitBinaryTokens){let r=t?.tokenAttributes??0,s=!1;if(this.balancedBracketSelectors?.matchesAlways&&(s=!0),this._tokenTypeOverrides.length>0||this.balancedBracketSelectors&&!this.balancedBracketSelectors.matchesAlways&&!this.balancedBracketSelectors.matchesNever){const o=t?.getScopeNames()??[];for(const i of this._tokenTypeOverrides)i.matcher(o)&&(r=ke.set(r,0,i.type,null,-1,0,0));this.balancedBracketSelectors&&(s=this.balancedBracketSelectors.match(o))}if(s&&(r=ke.set(r,0,8,s,-1,0,0)),this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-1]===r){this._lastTokenEndIndex=e;return}this._binaryTokens.push(this._lastTokenEndIndex),this._binaryTokens.push(r),this._lastTokenEndIndex=e;return}const n=t?.getScopeNames()??[];this._tokens.push({startIndex:this._lastTokenEndIndex,endIndex:e,scopes:n}),this._lastTokenEndIndex=e}getResult(t,e){return this._tokens.length>0&&this._tokens[this._tokens.length-1].startIndex===e-1&&this._tokens.pop(),this._tokens.length===0&&(this._lastTokenEndIndex=-1,this.produce(t,e),this._tokens[this._tokens.length-1].startIndex=0),this._tokens}getBinaryResult(t,e){this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-2]===e-1&&(this._binaryTokens.pop(),this._binaryTokens.pop()),this._binaryTokens.length===0&&(this._lastTokenEndIndex=-1,this.produce(t,e),this._binaryTokens[this._binaryTokens.length-2]=0);const n=new Uint32Array(this._binaryTokens.length);for(let r=0,s=this._binaryTokens.length;r<s;r++)n[r]=this._binaryTokens[r];return n}},mo=class{constructor(t,e){this._onigLib=e,this._theme=t}_grammars=new Map;_rawGrammars=new Map;_injectionGrammars=new Map;_theme;dispose(){for(const t of this._grammars.values())t.dispose()}setTheme(t){this._theme=t}getColorMap(){return this._theme.getColorMap()}addGrammar(t,e){this._rawGrammars.set(t.scopeName,t),e&&this._injectionGrammars.set(t.scopeName,e)}lookup(t){return this._rawGrammars.get(t)}injections(t){return this._injectionGrammars.get(t)}getDefaults(){return this._theme.getDefaults()}themeMatch(t){return this._theme.match(t)}grammarForScopeName(t,e,n,r,s){if(!this._grammars.has(t)){let o=this._rawGrammars.get(t);if(!o)return null;this._grammars.set(t,uo(t,o,e,n,r,s,this,this._onigLib))}return this._grammars.get(t)}},yo=class{_options;_syncRegistry;_ensureGrammarCache;constructor(e){this._options=e,this._syncRegistry=new mo(tt.createFromRawTheme(e.theme,e.colorMap),e.onigLib),this._ensureGrammarCache=new Map}dispose(){this._syncRegistry.dispose()}setTheme(e,n){this._syncRegistry.setTheme(tt.createFromRawTheme(e,n))}getColorMap(){return this._syncRegistry.getColorMap()}loadGrammarWithEmbeddedLanguages(e,n,r){return this.loadGrammarWithConfiguration(e,n,{embeddedLanguages:r})}loadGrammarWithConfiguration(e,n,r){return this._loadGrammar(e,n,r.embeddedLanguages,r.tokenTypes,new po(r.balancedBracketSelectors||[],r.unbalancedBracketSelectors||[]))}loadGrammar(e){return this._loadGrammar(e,0,null,null,null)}_loadGrammar(e,n,r,s,o){const i=new Hs(this._syncRegistry,e);for(;i.Q.length>0;)i.Q.map(a=>this._loadSingleGrammar(a.scopeName)),i.processQueue();return this._grammarForScopeName(e,n,r,s,o)}_loadSingleGrammar(e){this._ensureGrammarCache.has(e)||(this._doLoadSingleGrammar(e),this._ensureGrammarCache.set(e,!0))}_doLoadSingleGrammar(e){const n=this._options.loadGrammar(e);if(n){const r=typeof this._options.getInjections=="function"?this._options.getInjections(e):void 0;this._syncRegistry.addGrammar(n,r)}}addGrammar(e,n=[],r=0,s=null){return this._syncRegistry.addGrammar(e,n),this._grammarForScopeName(e.scopeName,r,s)}_grammarForScopeName(e,n=0,r=null,s=null,o=null){return this._syncRegistry.grammarForScopeName(e,n,r,s,o)}},Ht=zt.NULL;const bo=["area","base","basefont","bgsound","br","col","command","embed","frame","hr","image","img","input","keygen","link","meta","param","source","track","wbr"];class Ue{constructor(e,n,r){this.normal=n,this.property=e,r&&(this.space=r)}}Ue.prototype.normal={};Ue.prototype.property={};Ue.prototype.space=void 0;function Tr(t,e){const n={},r={};for(const s of t)Object.assign(n,s.property),Object.assign(r,s.normal);return new Ue(n,r,e)}function qt(t){return t.toLowerCase()}class W{constructor(e,n){this.attribute=n,this.property=e}}W.prototype.attribute="";W.prototype.booleanish=!1;W.prototype.boolean=!1;W.prototype.commaOrSpaceSeparated=!1;W.prototype.commaSeparated=!1;W.prototype.defined=!1;W.prototype.mustUseProperty=!1;W.prototype.number=!1;W.prototype.overloadedBoolean=!1;W.prototype.property="";W.prototype.spaceSeparated=!1;W.prototype.space=void 0;let wo=0;const E=de(),$=de(),Vt=de(),C=de(),R=de(),_e=de(),z=de();function de(){return 2**++wo}var Xt=Object.freeze({__proto__:null,boolean:E,booleanish:$,commaOrSpaceSeparated:z,commaSeparated:_e,number:C,overloadedBoolean:Vt,spaceSeparated:R});const vt=Object.keys(Xt);class an extends W{constructor(e,n,r,s){let o=-1;if(super(e,n),Nn(this,"space",s),typeof r=="number")for(;++o<vt.length;){const i=vt[o];Nn(this,vt[o],(r&Xt[i])===Xt[i])}}}an.prototype.defined=!0;function Nn(t,e,n){n&&(t[e]=n)}function ve(t){const e={},n={};for(const[r,s]of Object.entries(t.properties)){const o=new an(r,t.transform(t.attributes||{},r),s,t.space);t.mustUseProperty&&t.mustUseProperty.includes(r)&&(o.mustUseProperty=!0),e[r]=o,n[qt(r)]=r,n[qt(o.attribute)]=r}return new Ue(e,n,t.space)}const Mr=ve({properties:{ariaActiveDescendant:null,ariaAtomic:$,ariaAutoComplete:null,ariaBusy:$,ariaChecked:$,ariaColCount:C,ariaColIndex:C,ariaColSpan:C,ariaControls:R,ariaCurrent:null,ariaDescribedBy:R,ariaDetails:null,ariaDisabled:$,ariaDropEffect:R,ariaErrorMessage:null,ariaExpanded:$,ariaFlowTo:R,ariaGrabbed:$,ariaHasPopup:null,ariaHidden:$,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:R,ariaLevel:C,ariaLive:null,ariaModal:$,ariaMultiLine:$,ariaMultiSelectable:$,ariaOrientation:null,ariaOwns:R,ariaPlaceholder:null,ariaPosInSet:C,ariaPressed:$,ariaReadOnly:$,ariaRelevant:null,ariaRequired:$,ariaRoleDescription:R,ariaRowCount:C,ariaRowIndex:C,ariaRowSpan:C,ariaSelected:$,ariaSetSize:C,ariaSort:null,ariaValueMax:C,ariaValueMin:C,ariaValueNow:C,ariaValueText:null,role:null},transform(t,e){return e==="role"?e:"aria-"+e.slice(4).toLowerCase()}});function Or(t,e){return e in t?t[e]:e}function Dr(t,e){return Or(t,e.toLowerCase())}const Co=ve({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:_e,acceptCharset:R,accessKey:R,action:null,allow:null,allowFullScreen:E,allowPaymentRequest:E,allowUserMedia:E,alt:null,as:null,async:E,autoCapitalize:null,autoComplete:R,autoFocus:E,autoPlay:E,blocking:R,capture:null,charSet:null,checked:E,cite:null,className:R,cols:C,colSpan:null,content:null,contentEditable:$,controls:E,controlsList:R,coords:C|_e,crossOrigin:null,data:null,dateTime:null,decoding:null,default:E,defer:E,dir:null,dirName:null,disabled:E,download:Vt,draggable:$,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:E,formTarget:null,headers:R,height:C,hidden:Vt,high:C,href:null,hrefLang:null,htmlFor:R,httpEquiv:R,id:null,imageSizes:null,imageSrcSet:null,inert:E,inputMode:null,integrity:null,is:null,isMap:E,itemId:null,itemProp:R,itemRef:R,itemScope:E,itemType:R,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:E,low:C,manifest:null,max:null,maxLength:C,media:null,method:null,min:null,minLength:C,multiple:E,muted:E,name:null,nonce:null,noModule:E,noValidate:E,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:E,optimum:C,pattern:null,ping:R,placeholder:null,playsInline:E,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:E,referrerPolicy:null,rel:R,required:E,reversed:E,rows:C,rowSpan:C,sandbox:R,scope:null,scoped:E,seamless:E,selected:E,shadowRootClonable:E,shadowRootDelegatesFocus:E,shadowRootMode:null,shape:null,size:C,sizes:null,slot:null,span:C,spellCheck:$,src:null,srcDoc:null,srcLang:null,srcSet:null,start:C,step:null,style:null,tabIndex:C,target:null,title:null,translate:null,type:null,typeMustMatch:E,useMap:null,value:$,width:C,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:R,axis:null,background:null,bgColor:null,border:C,borderColor:null,bottomMargin:C,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:E,declare:E,event:null,face:null,frame:null,frameBorder:null,hSpace:C,leftMargin:C,link:null,longDesc:null,lowSrc:null,marginHeight:C,marginWidth:C,noResize:E,noHref:E,noShade:E,noWrap:E,object:null,profile:null,prompt:null,rev:null,rightMargin:C,rules:null,scheme:null,scrolling:$,standby:null,summary:null,text:null,topMargin:C,valueType:null,version:null,vAlign:null,vLink:null,vSpace:C,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:E,disableRemotePlayback:E,prefix:null,property:null,results:C,security:null,unselectable:null},space:"html",transform:Dr}),_o=ve({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:z,accentHeight:C,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:C,amplitude:C,arabicForm:null,ascent:C,attributeName:null,attributeType:null,azimuth:C,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:C,by:null,calcMode:null,capHeight:C,className:R,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:C,diffuseConstant:C,direction:null,display:null,dur:null,divisor:C,dominantBaseline:null,download:E,dx:null,dy:null,edgeMode:null,editable:null,elevation:C,enableBackground:null,end:null,event:null,exponent:C,externalResourcesRequired:null,fill:null,fillOpacity:C,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:_e,g2:_e,glyphName:_e,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:C,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:C,horizOriginX:C,horizOriginY:C,id:null,ideographic:C,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:C,k:C,k1:C,k2:C,k3:C,k4:C,kernelMatrix:z,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:C,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:C,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:C,overlineThickness:C,paintOrder:null,panose1:null,path:null,pathLength:C,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:R,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:C,pointsAtY:C,pointsAtZ:C,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:z,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:z,rev:z,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:z,requiredFeatures:z,requiredFonts:z,requiredFormats:z,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:C,specularExponent:C,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:C,strikethroughThickness:C,string:null,stroke:null,strokeDashArray:z,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:C,strokeOpacity:C,strokeWidth:null,style:null,surfaceScale:C,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:z,tabIndex:C,tableValues:null,target:null,targetX:C,targetY:C,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:z,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:C,underlineThickness:C,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:C,values:null,vAlphabetic:C,vMathematical:C,vectorEffect:null,vHanging:C,vIdeographic:C,version:null,vertAdvY:C,vertOriginX:C,vertOriginY:C,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:C,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:Or}),Gr=ve({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(t,e){return"xlink:"+e.slice(5).toLowerCase()}}),Br=ve({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:Dr}),Fr=ve({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(t,e){return"xml:"+e.slice(3).toLowerCase()}}),So=/[A-Z]/g,Pn=/-[a-z]/g,ko=/^data[-\w.:]+$/i;function xo(t,e){const n=qt(e);let r=e,s=W;if(n in t.normal)return t.property[t.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&ko.test(e)){if(e.charAt(4)==="-"){const o=e.slice(5).replace(Pn,Io);r="data"+o.charAt(0).toUpperCase()+o.slice(1)}else{const o=e.slice(4);if(!Pn.test(o)){let i=o.replace(So,vo);i.charAt(0)!=="-"&&(i="-"+i),e="data"+i}}s=an}return new s(r,e)}function vo(t){return"-"+t.toLowerCase()}function Io(t){return t.charAt(1).toUpperCase()}const Eo=Tr([Mr,Co,Gr,Br,Fr],"html"),Ur=Tr([Mr,_o,Gr,Br,Fr],"svg"),$n={}.hasOwnProperty;function Ao(t,e){const n=e||{};function r(s,...o){let i=r.invalid;const a=r.handlers;if(s&&$n.call(s,t)){const l=String(s[t]);i=$n.call(a,l)?a[l]:r.unknown}if(i)return i.call(this,s,...o)}return r.handlers=n.handlers||{},r.invalid=n.invalid,r.unknown=n.unknown,r}const Lo=/["&'<>`]/g,Ro=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,No=/[\x01-\t\v\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g,Po=/[|\\{}()[\]^$+*?.]/g,Tn=new WeakMap;function $o(t,e){if(t=t.replace(e.subset?To(e.subset):Lo,r),e.subset||e.escapeOnly)return t;return t.replace(Ro,n).replace(No,r);function n(s,o,i){return e.format((s.charCodeAt(0)-55296)*1024+s.charCodeAt(1)-56320+65536,i.charCodeAt(o+2),e)}function r(s,o,i){return e.format(s.charCodeAt(0),i.charCodeAt(o+1),e)}}function To(t){let e=Tn.get(t);return e||(e=Mo(t),Tn.set(t,e)),e}function Mo(t){const e=[];let n=-1;for(;++n<t.length;)e.push(t[n].replace(Po,"\\$&"));return new RegExp("(?:"+e.join("|")+")","g")}const Oo=/[\dA-Fa-f]/;function Do(t,e,n){const r="&#x"+t.toString(16).toUpperCase();return n&&e&&!Oo.test(String.fromCharCode(e))?r:r+";"}const Go=/\d/;function Bo(t,e,n){const r="&#"+String(t);return n&&e&&!Go.test(String.fromCharCode(e))?r:r+";"}const Fo=["AElig","AMP","Aacute","Acirc","Agrave","Aring","Atilde","Auml","COPY","Ccedil","ETH","Eacute","Ecirc","Egrave","Euml","GT","Iacute","Icirc","Igrave","Iuml","LT","Ntilde","Oacute","Ocirc","Ograve","Oslash","Otilde","Ouml","QUOT","REG","THORN","Uacute","Ucirc","Ugrave","Uuml","Yacute","aacute","acirc","acute","aelig","agrave","amp","aring","atilde","auml","brvbar","ccedil","cedil","cent","copy","curren","deg","divide","eacute","ecirc","egrave","eth","euml","frac12","frac14","frac34","gt","iacute","icirc","iexcl","igrave","iquest","iuml","laquo","lt","macr","micro","middot","nbsp","not","ntilde","oacute","ocirc","ograve","ordf","ordm","oslash","otilde","ouml","para","plusmn","pound","quot","raquo","reg","sect","shy","sup1","sup2","sup3","szlig","thorn","times","uacute","ucirc","ugrave","uml","uuml","yacute","yen","yuml"],It={nbsp:" ",iexcl:"¡",cent:"¢",pound:"£",curren:"¤",yen:"¥",brvbar:"¦",sect:"§",uml:"¨",copy:"©",ordf:"ª",laquo:"«",not:"¬",shy:"­",reg:"®",macr:"¯",deg:"°",plusmn:"±",sup2:"²",sup3:"³",acute:"´",micro:"µ",para:"¶",middot:"·",cedil:"¸",sup1:"¹",ordm:"º",raquo:"»",frac14:"¼",frac12:"½",frac34:"¾",iquest:"¿",Agrave:"À",Aacute:"Á",Acirc:"Â",Atilde:"Ã",Auml:"Ä",Aring:"Å",AElig:"Æ",Ccedil:"Ç",Egrave:"È",Eacute:"É",Ecirc:"Ê",Euml:"Ë",Igrave:"Ì",Iacute:"Í",Icirc:"Î",Iuml:"Ï",ETH:"Ð",Ntilde:"Ñ",Ograve:"Ò",Oacute:"Ó",Ocirc:"Ô",Otilde:"Õ",Ouml:"Ö",times:"×",Oslash:"Ø",Ugrave:"Ù",Uacute:"Ú",Ucirc:"Û",Uuml:"Ü",Yacute:"Ý",THORN:"Þ",szlig:"ß",agrave:"à",aacute:"á",acirc:"â",atilde:"ã",auml:"ä",aring:"å",aelig:"æ",ccedil:"ç",egrave:"è",eacute:"é",ecirc:"ê",euml:"ë",igrave:"ì",iacute:"í",icirc:"î",iuml:"ï",eth:"ð",ntilde:"ñ",ograve:"ò",oacute:"ó",ocirc:"ô",otilde:"õ",ouml:"ö",divide:"÷",oslash:"ø",ugrave:"ù",uacute:"ú",ucirc:"û",uuml:"ü",yacute:"ý",thorn:"þ",yuml:"ÿ",fnof:"ƒ",Alpha:"Α",Beta:"Β",Gamma:"Γ",Delta:"Δ",Epsilon:"Ε",Zeta:"Ζ",Eta:"Η",Theta:"Θ",Iota:"Ι",Kappa:"Κ",Lambda:"Λ",Mu:"Μ",Nu:"Ν",Xi:"Ξ",Omicron:"Ο",Pi:"Π",Rho:"Ρ",Sigma:"Σ",Tau:"Τ",Upsilon:"Υ",Phi:"Φ",Chi:"Χ",Psi:"Ψ",Omega:"Ω",alpha:"α",beta:"β",gamma:"γ",delta:"δ",epsilon:"ε",zeta:"ζ",eta:"η",theta:"θ",iota:"ι",kappa:"κ",lambda:"λ",mu:"μ",nu:"ν",xi:"ξ",omicron:"ο",pi:"π",rho:"ρ",sigmaf:"ς",sigma:"σ",tau:"τ",upsilon:"υ",phi:"φ",chi:"χ",psi:"ψ",omega:"ω",thetasym:"ϑ",upsih:"ϒ",piv:"ϖ",bull:"•",hellip:"…",prime:"′",Prime:"″",oline:"‾",frasl:"⁄",weierp:"℘",image:"ℑ",real:"ℜ",trade:"™",alefsym:"ℵ",larr:"←",uarr:"↑",rarr:"→",darr:"↓",harr:"↔",crarr:"↵",lArr:"⇐",uArr:"⇑",rArr:"⇒",dArr:"⇓",hArr:"⇔",forall:"∀",part:"∂",exist:"∃",empty:"∅",nabla:"∇",isin:"∈",notin:"∉",ni:"∋",prod:"∏",sum:"∑",minus:"−",lowast:"∗",radic:"√",prop:"∝",infin:"∞",ang:"∠",and:"∧",or:"∨",cap:"∩",cup:"∪",int:"∫",there4:"∴",sim:"∼",cong:"≅",asymp:"≈",ne:"≠",equiv:"≡",le:"≤",ge:"≥",sub:"⊂",sup:"⊃",nsub:"⊄",sube:"⊆",supe:"⊇",oplus:"⊕",otimes:"⊗",perp:"⊥",sdot:"⋅",lceil:"⌈",rceil:"⌉",lfloor:"⌊",rfloor:"⌋",lang:"〈",rang:"〉",loz:"◊",spades:"♠",clubs:"♣",hearts:"♥",diams:"♦",quot:'"',amp:"&",lt:"<",gt:">",OElig:"Œ",oelig:"œ",Scaron:"Š",scaron:"š",Yuml:"Ÿ",circ:"ˆ",tilde:"˜",ensp:" ",emsp:" ",thinsp:" ",zwnj:"‌",zwj:"‍",lrm:"‎",rlm:"‏",ndash:"–",mdash:"—",lsquo:"‘",rsquo:"’",sbquo:"‚",ldquo:"“",rdquo:"”",bdquo:"„",dagger:"†",Dagger:"‡",permil:"‰",lsaquo:"‹",rsaquo:"›",euro:"€"},Uo=["cent","copy","divide","gt","lt","not","para","times"],jr={}.hasOwnProperty,Kt={};let He;for(He in It)jr.call(It,He)&&(Kt[It[He]]=He);const jo=/[^\dA-Za-z]/;function Wo(t,e,n,r){const s=String.fromCharCode(t);if(jr.call(Kt,s)){const o=Kt[s],i="&"+o;return n&&Fo.includes(o)&&!Uo.includes(o)&&(!r||e&&e!==61&&jo.test(String.fromCharCode(e)))?i:i+";"}return""}function zo(t,e,n){let r=Do(t,e,n.omitOptionalSemicolons),s;if((n.useNamedReferences||n.useShortestReferences)&&(s=Wo(t,e,n.omitOptionalSemicolons,n.attribute)),(n.useShortestReferences||!s)&&n.useShortestReferences){const o=Bo(t,e,n.omitOptionalSemicolons);o.length<r.length&&(r=o)}return s&&(!n.useShortestReferences||s.length<r.length)?s:r}function Se(t,e){return $o(t,Object.assign({format:zo},e))}const Ho=/^>|^->|<!--|-->|--!>|<!-$/g,qo=[">"],Vo=["<",">"];function Xo(t,e,n,r){return r.settings.bogusComments?"<?"+Se(t.value,Object.assign({},r.settings.characterReferences,{subset:qo}))+">":"<!--"+t.value.replace(Ho,s)+"-->";function s(o){return Se(o,Object.assign({},r.settings.characterReferences,{subset:Vo}))}}function Ko(t,e,n,r){return"<!"+(r.settings.upperDoctype?"DOCTYPE":"doctype")+(r.settings.tightDoctype?"":" ")+"html>"}function Mn(t,e){const n=String(t);if(typeof e!="string")throw new TypeError("Expected character");let r=0,s=n.indexOf(e);for(;s!==-1;)r++,s=n.indexOf(e,s+e.length);return r}function Zo(t,e){const n=e||{};return(t[t.length-1]===""?[...t,""]:t).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}function Qo(t){return t.join(" ").trim()}const Yo=/[ \t\n\f\r]/g;function ln(t){return typeof t=="object"?t.type==="text"?On(t.value):!1:On(t)}function On(t){return t.replace(Yo,"")===""}const O=zr(1),Wr=zr(-1),Jo=[];function zr(t){return e;function e(n,r,s){const o=n?n.children:Jo;let i=(r||0)+t,a=o[i];if(!s)for(;a&&ln(a);)i+=t,a=o[i];return a}}const ei={}.hasOwnProperty;function Hr(t){return e;function e(n,r,s){return ei.call(t,n.tagName)&&t[n.tagName](n,r,s)}}const cn=Hr({body:ni,caption:Et,colgroup:Et,dd:ii,dt:oi,head:Et,html:ti,li:si,optgroup:ai,option:li,p:ri,rp:Dn,rt:Dn,tbody:ui,td:Gn,tfoot:fi,th:Gn,thead:ci,tr:hi});function Et(t,e,n){const r=O(n,e,!0);return!r||r.type!=="comment"&&!(r.type==="text"&&ln(r.value.charAt(0)))}function ti(t,e,n){const r=O(n,e);return!r||r.type!=="comment"}function ni(t,e,n){const r=O(n,e);return!r||r.type!=="comment"}function ri(t,e,n){const r=O(n,e);return r?r.type==="element"&&(r.tagName==="address"||r.tagName==="article"||r.tagName==="aside"||r.tagName==="blockquote"||r.tagName==="details"||r.tagName==="div"||r.tagName==="dl"||r.tagName==="fieldset"||r.tagName==="figcaption"||r.tagName==="figure"||r.tagName==="footer"||r.tagName==="form"||r.tagName==="h1"||r.tagName==="h2"||r.tagName==="h3"||r.tagName==="h4"||r.tagName==="h5"||r.tagName==="h6"||r.tagName==="header"||r.tagName==="hgroup"||r.tagName==="hr"||r.tagName==="main"||r.tagName==="menu"||r.tagName==="nav"||r.tagName==="ol"||r.tagName==="p"||r.tagName==="pre"||r.tagName==="section"||r.tagName==="table"||r.tagName==="ul"):!n||!(n.type==="element"&&(n.tagName==="a"||n.tagName==="audio"||n.tagName==="del"||n.tagName==="ins"||n.tagName==="map"||n.tagName==="noscript"||n.tagName==="video"))}function si(t,e,n){const r=O(n,e);return!r||r.type==="element"&&r.tagName==="li"}function oi(t,e,n){const r=O(n,e);return!!(r&&r.type==="element"&&(r.tagName==="dt"||r.tagName==="dd"))}function ii(t,e,n){const r=O(n,e);return!r||r.type==="element"&&(r.tagName==="dt"||r.tagName==="dd")}function Dn(t,e,n){const r=O(n,e);return!r||r.type==="element"&&(r.tagName==="rp"||r.tagName==="rt")}function ai(t,e,n){const r=O(n,e);return!r||r.type==="element"&&r.tagName==="optgroup"}function li(t,e,n){const r=O(n,e);return!r||r.type==="element"&&(r.tagName==="option"||r.tagName==="optgroup")}function ci(t,e,n){const r=O(n,e);return!!(r&&r.type==="element"&&(r.tagName==="tbody"||r.tagName==="tfoot"))}function ui(t,e,n){const r=O(n,e);return!r||r.type==="element"&&(r.tagName==="tbody"||r.tagName==="tfoot")}function fi(t,e,n){return!O(n,e)}function hi(t,e,n){const r=O(n,e);return!r||r.type==="element"&&r.tagName==="tr"}function Gn(t,e,n){const r=O(n,e);return!r||r.type==="element"&&(r.tagName==="td"||r.tagName==="th")}const di=Hr({body:mi,colgroup:yi,head:gi,html:pi,tbody:bi});function pi(t){const e=O(t,-1);return!e||e.type!=="comment"}function gi(t){const e=new Set;for(const r of t.children)if(r.type==="element"&&(r.tagName==="base"||r.tagName==="title")){if(e.has(r.tagName))return!1;e.add(r.tagName)}const n=t.children[0];return!n||n.type==="element"}function mi(t){const e=O(t,-1,!0);return!e||e.type!=="comment"&&!(e.type==="text"&&ln(e.value.charAt(0)))&&!(e.type==="element"&&(e.tagName==="meta"||e.tagName==="link"||e.tagName==="script"||e.tagName==="style"||e.tagName==="template"))}function yi(t,e,n){const r=Wr(n,e),s=O(t,-1,!0);return n&&r&&r.type==="element"&&r.tagName==="colgroup"&&cn(r,n.children.indexOf(r),n)?!1:!!(s&&s.type==="element"&&s.tagName==="col")}function bi(t,e,n){const r=Wr(n,e),s=O(t,-1);return n&&r&&r.type==="element"&&(r.tagName==="thead"||r.tagName==="tbody")&&cn(r,n.children.indexOf(r),n)?!1:!!(s&&s.type==="element"&&s.tagName==="tr")}const qe={name:[[`
4
+ \f\r &/=>`.split(""),`
5
+ \f\r "&'/=>\``.split("")],[`\0
6
+ \f\r "&'/<=>`.split(""),`\0
7
+ \f\r "&'/<=>\``.split("")]],unquoted:[[`
8
+ \f\r &>`.split(""),`\0
9
+ \f\r "&'<=>\``.split("")],[`\0
10
+ \f\r "&'<=>\``.split(""),`\0
11
+ \f\r "&'<=>\``.split("")]],single:[["&'".split(""),"\"&'`".split("")],["\0&'".split(""),"\0\"&'`".split("")]],double:[['"&'.split(""),"\"&'`".split("")],['\0"&'.split(""),"\0\"&'`".split("")]]};function wi(t,e,n,r){const s=r.schema,o=s.space==="svg"?!1:r.settings.omitOptionalTags;let i=s.space==="svg"?r.settings.closeEmptyElements:r.settings.voids.includes(t.tagName.toLowerCase());const a=[];let l;s.space==="html"&&t.tagName==="svg"&&(r.schema=Ur);const c=Ci(r,t.properties),u=r.all(s.space==="html"&&t.tagName==="template"?t.content:t);return r.schema=s,u&&(i=!1),(c||!o||!di(t,e,n))&&(a.push("<",t.tagName,c?" "+c:""),i&&(s.space==="svg"||r.settings.closeSelfClosing)&&(l=c.charAt(c.length-1),(!r.settings.tightSelfClosing||l==="/"||l&&l!=='"'&&l!=="'")&&a.push(" "),a.push("/")),a.push(">")),a.push(u),!i&&(!o||!cn(t,e,n))&&a.push("</"+t.tagName+">"),a.join("")}function Ci(t,e){const n=[];let r=-1,s;if(e){for(s in e)if(e[s]!==null&&e[s]!==void 0){const o=_i(t,s,e[s]);o&&n.push(o)}}for(;++r<n.length;){const o=t.settings.tightAttributes?n[r].charAt(n[r].length-1):void 0;r!==n.length-1&&o!=='"'&&o!=="'"&&(n[r]+=" ")}return n.join("")}function _i(t,e,n){const r=xo(t.schema,e),s=t.settings.allowParseErrors&&t.schema.space==="html"?0:1,o=t.settings.allowDangerousCharacters?0:1;let i=t.quote,a;if(r.overloadedBoolean&&(n===r.attribute||n==="")?n=!0:(r.boolean||r.overloadedBoolean)&&(typeof n!="string"||n===r.attribute||n==="")&&(n=!!n),n==null||n===!1||typeof n=="number"&&Number.isNaN(n))return"";const l=Se(r.attribute,Object.assign({},t.settings.characterReferences,{subset:qe.name[s][o]}));return n===!0||(n=Array.isArray(n)?(r.commaSeparated?Zo:Qo)(n,{padLeft:!t.settings.tightCommaSeparatedLists}):String(n),t.settings.collapseEmptyAttributes&&!n)?l:(t.settings.preferUnquoted&&(a=Se(n,Object.assign({},t.settings.characterReferences,{attribute:!0,subset:qe.unquoted[s][o]}))),a!==n&&(t.settings.quoteSmart&&Mn(n,i)>Mn(n,t.alternative)&&(i=t.alternative),a=i+Se(n,Object.assign({},t.settings.characterReferences,{subset:(i==="'"?qe.single:qe.double)[s][o],attribute:!0}))+i),l+(a&&"="+a))}const Si=["<","&"];function qr(t,e,n,r){return n&&n.type==="element"&&(n.tagName==="script"||n.tagName==="style")?t.value:Se(t.value,Object.assign({},r.settings.characterReferences,{subset:Si}))}function ki(t,e,n,r){return r.settings.allowDangerousHtml?t.value:qr(t,e,n,r)}function xi(t,e,n,r){return r.all(t)}const vi=Ao("type",{invalid:Ii,unknown:Ei,handlers:{comment:Xo,doctype:Ko,element:wi,raw:ki,root:xi,text:qr}});function Ii(t){throw new Error("Expected node, not `"+t+"`")}function Ei(t){const e=t;throw new Error("Cannot compile unknown node `"+e.type+"`")}const Ai={},Li={},Ri=[];function Ni(t,e){const n=e||Ai,r=n.quote||'"',s=r==='"'?"'":'"';if(r!=='"'&&r!=="'")throw new Error("Invalid quote `"+r+"`, expected `'` or `\"`");return{one:Pi,all:$i,settings:{omitOptionalTags:n.omitOptionalTags||!1,allowParseErrors:n.allowParseErrors||!1,allowDangerousCharacters:n.allowDangerousCharacters||!1,quoteSmart:n.quoteSmart||!1,preferUnquoted:n.preferUnquoted||!1,tightAttributes:n.tightAttributes||!1,upperDoctype:n.upperDoctype||!1,tightDoctype:n.tightDoctype||!1,bogusComments:n.bogusComments||!1,tightCommaSeparatedLists:n.tightCommaSeparatedLists||!1,tightSelfClosing:n.tightSelfClosing||!1,collapseEmptyAttributes:n.collapseEmptyAttributes||!1,allowDangerousHtml:n.allowDangerousHtml||!1,voids:n.voids||bo,characterReferences:n.characterReferences||Li,closeSelfClosing:n.closeSelfClosing||!1,closeEmptyElements:n.closeEmptyElements||!1},schema:n.space==="svg"?Ur:Eo,quote:r,alternative:s}.one(Array.isArray(t)?{type:"root",children:t}:t,void 0,void 0)}function Pi(t,e,n){return vi(t,e,n,this)}function $i(t){const e=[],n=t&&t.children||Ri;let r=-1;for(;++r<n.length;)e[r]=this.one(n[r],r,t);return e.join("")}function it(t,e){const n=typeof t=="string"?{}:{...t.colorReplacements},r=typeof t=="string"?t:t.name;for(const[s,o]of Object.entries(e?.colorReplacements||{}))typeof o=="string"?n[s]=o:s===r&&Object.assign(n,o);return n}function ie(t,e){return t&&(e?.[t?.toLowerCase()]||t)}function Ti(t){return Array.isArray(t)?t:[t]}async function Vr(t){return Promise.resolve(typeof t=="function"?t():t).then(e=>e.default||e)}function un(t){return!t||["plaintext","txt","text","plain"].includes(t)}function Mi(t){return t==="ansi"||un(t)}function fn(t){return t==="none"}function Oi(t){return fn(t)}function Xr(t,e){if(!e)return t;t.properties||={},t.properties.class||=[],typeof t.properties.class=="string"&&(t.properties.class=t.properties.class.split(/\s+/g)),Array.isArray(t.properties.class)||(t.properties.class=[]);const n=Array.isArray(e)?e:e.split(/\s+/g);for(const r of n)r&&!t.properties.class.includes(r)&&t.properties.class.push(r);return t}function ht(t,e=!1){if(t.length===0)return[["",0]];const n=t.split(/(\r?\n)/g);let r=0;const s=[];for(let o=0;o<n.length;o+=2){const i=e?n[o]+(n[o+1]||""):n[o];s.push([i,r]),r+=n[o].length,r+=n[o+1]?.length||0}return s}function Di(t){const e=ht(t,!0).map(([s])=>s);function n(s){if(s===t.length)return{line:e.length-1,character:e[e.length-1].length};let o=s,i=0;for(const a of e){if(o<a.length)break;o-=a.length,i++}return{line:i,character:o}}function r(s,o){let i=0;for(let a=0;a<s;a++)i+=e[a].length;return i+=o,i}return{lines:e,indexToPos:n,posToIndex:r}}const hn="light-dark()",Gi=["color","background-color"];function Bi(t,e){let n=0;const r=[];for(const s of e)s>n&&r.push({...t,content:t.content.slice(n,s),offset:t.offset+n}),n=s;return n<t.content.length&&r.push({...t,content:t.content.slice(n),offset:t.offset+n}),r}function Fi(t,e){const n=Array.from(e instanceof Set?e:new Set(e)).sort((r,s)=>r-s);return n.length?t.map(r=>r.flatMap(s=>{const o=n.filter(i=>s.offset<i&&i<s.offset+s.content.length).map(i=>i-s.offset).sort((i,a)=>i-a);return o.length?Bi(s,o):s})):t}function Ui(t,e,n,r,s="css-vars"){const o={content:t.content,explanation:t.explanation,offset:t.offset},i=e.map(u=>at(t.variants[u])),a=new Set(i.flatMap(u=>Object.keys(u))),l={},c=(u,f)=>{const h=f==="color"?"":f==="background-color"?"-bg":`-${f}`;return n+e[u]+(f==="color"?"":h)};return i.forEach((u,f)=>{for(const h of a){const d=u[h]||"inherit";if(f===0&&r&&Gi.includes(h))if(r===hn&&i.length>1){const p=e.findIndex(m=>m==="light"),b=e.findIndex(m=>m==="dark");if(p===-1||b===-1)throw new G('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');const w=i[p][h]||"inherit",y=i[b][h]||"inherit";l[h]=`light-dark(${w}, ${y})`,s==="css-vars"&&(l[c(f,h)]=d)}else l[h]=d;else s==="css-vars"&&(l[c(f,h)]=d)}}),o.htmlStyle=l,o}function at(t){const e={};if(t.color&&(e.color=t.color),t.bgColor&&(e["background-color"]=t.bgColor),t.fontStyle){t.fontStyle&j.Italic&&(e["font-style"]="italic"),t.fontStyle&j.Bold&&(e["font-weight"]="bold");const n=[];t.fontStyle&j.Underline&&n.push("underline"),t.fontStyle&j.Strikethrough&&n.push("line-through"),n.length&&(e["text-decoration"]=n.join(" "))}return e}function Zt(t){return typeof t=="string"?t:Object.entries(t).map(([e,n])=>`${e}:${n}`).join(";")}const Kr=new WeakMap;function dt(t,e){Kr.set(t,e)}function De(t){return Kr.get(t)}class Ie{_stacks={};lang;get themes(){return Object.keys(this._stacks)}get theme(){return this.themes[0]}get _stack(){return this._stacks[this.theme]}static initial(e,n){return new Ie(Object.fromEntries(Ti(n).map(r=>[r,Ht])),e)}constructor(...e){if(e.length===2){const[n,r]=e;this.lang=r,this._stacks=n}else{const[n,r,s]=e;this.lang=r,this._stacks={[s]:n}}}getInternalStack(e=this.theme){return this._stacks[e]}getScopes(e=this.theme){return ji(this._stacks[e])}toJSON(){return{lang:this.lang,theme:this.theme,themes:this.themes,scopes:this.getScopes()}}}function ji(t){const e=[],n=new Set;function r(s){if(n.has(s))return;n.add(s);const o=s?.nameScopesList?.scopeName;o&&e.push(o),s.parent&&r(s.parent)}return r(t),e}function Wi(t,e){if(!(t instanceof Ie))throw new G("Invalid grammar state");return t.getInternalStack(e)}function zi(){const t=new WeakMap;function e(n){if(!t.has(n.meta)){let r=function(i){if(typeof i=="number"){if(i<0||i>n.source.length)throw new G(`Invalid decoration offset: ${i}. Code length: ${n.source.length}`);return{...s.indexToPos(i),offset:i}}else{const a=s.lines[i.line];if(a===void 0)throw new G(`Invalid decoration position ${JSON.stringify(i)}. Lines length: ${s.lines.length}`);let l=i.character;if(l<0&&(l=a.length+l),l<0||l>a.length)throw new G(`Invalid decoration position ${JSON.stringify(i)}. Line ${i.line} length: ${a.length}`);return{...i,character:l,offset:s.posToIndex(i.line,l)}}};const s=Di(n.source),o=(n.options.decorations||[]).map(i=>({...i,start:r(i.start),end:r(i.end)}));Hi(o),t.set(n.meta,{decorations:o,converter:s,source:n.source})}return t.get(n.meta)}return{name:"shiki:decorations",tokens(n){if(!this.options.decorations?.length)return;const s=e(this).decorations.flatMap(i=>[i.start.offset,i.end.offset]);return Fi(n,s)},code(n){if(!this.options.decorations?.length)return;const r=e(this),s=Array.from(n.children).filter(u=>u.type==="element"&&u.tagName==="span");if(s.length!==r.converter.lines.length)throw new G(`Number of lines in code element (${s.length}) does not match the number of lines in the source (${r.converter.lines.length}). Failed to apply decorations.`);function o(u,f,h,d){const p=s[u];let b="",w=-1,y=-1;if(f===0&&(w=0),h===0&&(y=0),h===Number.POSITIVE_INFINITY&&(y=p.children.length),w===-1||y===-1)for(let g=0;g<p.children.length;g++)b+=Zr(p.children[g]),w===-1&&b.length===f&&(w=g+1),y===-1&&b.length===h&&(y=g+1);if(w===-1)throw new G(`Failed to find start index for decoration ${JSON.stringify(d.start)}`);if(y===-1)throw new G(`Failed to find end index for decoration ${JSON.stringify(d.end)}`);const m=p.children.slice(w,y);if(!d.alwaysWrap&&m.length===p.children.length)a(p,d,"line");else if(!d.alwaysWrap&&m.length===1&&m[0].type==="element")a(m[0],d,"token");else{const g={type:"element",tagName:"span",properties:{},children:m};a(g,d,"wrapper"),p.children.splice(w,m.length,g)}}function i(u,f){s[u]=a(s[u],f,"line")}function a(u,f,h){const d=f.properties||{},p=f.transform||(b=>b);return u.tagName=f.tagName||"span",u.properties={...u.properties,...d,class:u.properties.class},f.properties?.class&&Xr(u,f.properties.class),u=p(u,h)||u,u}const l=[],c=r.decorations.sort((u,f)=>f.start.offset-u.start.offset||u.end.offset-f.end.offset);for(const u of c){const{start:f,end:h}=u;if(f.line===h.line)o(f.line,f.character,h.character,u);else if(f.line<h.line){o(f.line,f.character,Number.POSITIVE_INFINITY,u);for(let d=f.line+1;d<h.line;d++)l.unshift(()=>i(d,u));o(h.line,0,h.character,u)}}l.forEach(u=>u())}}}function Hi(t){for(let e=0;e<t.length;e++){const n=t[e];if(n.start.offset>n.end.offset)throw new G(`Invalid decoration range: ${JSON.stringify(n.start)} - ${JSON.stringify(n.end)}`);for(let r=e+1;r<t.length;r++){const s=t[r],o=n.start.offset<=s.start.offset&&s.start.offset<n.end.offset,i=n.start.offset<s.end.offset&&s.end.offset<=n.end.offset,a=s.start.offset<=n.start.offset&&n.start.offset<s.end.offset,l=s.start.offset<n.end.offset&&n.end.offset<=s.end.offset;if(o||i||a||l){if(o&&i||a&&l||a&&n.start.offset===n.end.offset||i&&s.start.offset===s.end.offset)continue;throw new G(`Decorations ${JSON.stringify(n.start)} and ${JSON.stringify(s.start)} intersect.`)}}}}function Zr(t){return t.type==="text"?t.value:t.type==="element"?t.children.map(Zr).join(""):""}const qi=[zi()];function lt(t){const e=Vi(t.transformers||[]);return[...e.pre,...e.normal,...e.post,...qi]}function Vi(t){const e=[],n=[],r=[];for(const s of t)switch(s.enforce){case"pre":e.push(s);break;case"post":n.push(s);break;default:r.push(s)}return{pre:e,post:n,normal:r}}var ue=["black","red","green","yellow","blue","magenta","cyan","white","brightBlack","brightRed","brightGreen","brightYellow","brightBlue","brightMagenta","brightCyan","brightWhite"],At={1:"bold",2:"dim",3:"italic",4:"underline",7:"reverse",8:"hidden",9:"strikethrough"};function Xi(t,e){const n=t.indexOf("\x1B",e);if(n!==-1&&t[n+1]==="["){const r=t.indexOf("m",n);if(r!==-1)return{sequence:t.substring(n+2,r).split(";"),startPosition:n,position:r+1}}return{position:t.length}}function Bn(t){const e=t.shift();if(e==="2"){const n=t.splice(0,3).map(r=>Number.parseInt(r));return n.length!==3||n.some(r=>Number.isNaN(r))?void 0:{type:"rgb",rgb:n}}else if(e==="5"){const n=t.shift();if(n)return{type:"table",index:Number(n)}}}function Ki(t){const e=[];for(;t.length>0;){const n=t.shift();if(!n)continue;const r=Number.parseInt(n);if(!Number.isNaN(r))if(r===0)e.push({type:"resetAll"});else if(r<=9)At[r]&&e.push({type:"setDecoration",value:At[r]});else if(r<=29){const s=At[r-20];s&&(e.push({type:"resetDecoration",value:s}),s==="dim"&&e.push({type:"resetDecoration",value:"bold"}))}else if(r<=37)e.push({type:"setForegroundColor",value:{type:"named",name:ue[r-30]}});else if(r===38){const s=Bn(t);s&&e.push({type:"setForegroundColor",value:s})}else if(r===39)e.push({type:"resetForegroundColor"});else if(r<=47)e.push({type:"setBackgroundColor",value:{type:"named",name:ue[r-40]}});else if(r===48){const s=Bn(t);s&&e.push({type:"setBackgroundColor",value:s})}else r===49?e.push({type:"resetBackgroundColor"}):r===53?e.push({type:"setDecoration",value:"overline"}):r===55?e.push({type:"resetDecoration",value:"overline"}):r>=90&&r<=97?e.push({type:"setForegroundColor",value:{type:"named",name:ue[r-90+8]}}):r>=100&&r<=107&&e.push({type:"setBackgroundColor",value:{type:"named",name:ue[r-100+8]}})}return e}function Zi(){let t=null,e=null,n=new Set;return{parse(r){const s=[];let o=0;do{const i=Xi(r,o),a=i.sequence?r.substring(o,i.startPosition):r.substring(o);if(a.length>0&&s.push({value:a,foreground:t,background:e,decorations:new Set(n)}),i.sequence){const l=Ki(i.sequence);for(const c of l)c.type==="resetAll"?(t=null,e=null,n.clear()):c.type==="resetForegroundColor"?t=null:c.type==="resetBackgroundColor"?e=null:c.type==="resetDecoration"&&n.delete(c.value);for(const c of l)c.type==="setForegroundColor"?t=c.value:c.type==="setBackgroundColor"?e=c.value:c.type==="setDecoration"&&n.add(c.value)}o=i.position}while(o<r.length);return s}}}var Qi={black:"#000000",red:"#bb0000",green:"#00bb00",yellow:"#bbbb00",blue:"#0000bb",magenta:"#ff00ff",cyan:"#00bbbb",white:"#eeeeee",brightBlack:"#555555",brightRed:"#ff5555",brightGreen:"#00ff00",brightYellow:"#ffff55",brightBlue:"#5555ff",brightMagenta:"#ff55ff",brightCyan:"#55ffff",brightWhite:"#ffffff"};function Yi(t=Qi){function e(a){return t[a]}function n(a){return`#${a.map(l=>Math.max(0,Math.min(l,255)).toString(16).padStart(2,"0")).join("")}`}let r;function s(){if(r)return r;r=[];for(let c=0;c<ue.length;c++)r.push(e(ue[c]));let a=[0,95,135,175,215,255];for(let c=0;c<6;c++)for(let u=0;u<6;u++)for(let f=0;f<6;f++)r.push(n([a[c],a[u],a[f]]));let l=8;for(let c=0;c<24;c++,l+=10)r.push(n([l,l,l]));return r}function o(a){return s()[a]}function i(a){switch(a.type){case"named":return e(a.name);case"rgb":return n(a.rgb);case"table":return o(a.index)}}return{value:i}}const Ji={black:"#000000",red:"#cd3131",green:"#0DBC79",yellow:"#E5E510",blue:"#2472C8",magenta:"#BC3FBC",cyan:"#11A8CD",white:"#E5E5E5",brightBlack:"#666666",brightRed:"#F14C4C",brightGreen:"#23D18B",brightYellow:"#F5F543",brightBlue:"#3B8EEA",brightMagenta:"#D670D6",brightCyan:"#29B8DB",brightWhite:"#FFFFFF"};function ea(t,e,n){const r=it(t,n),s=ht(e),o=Object.fromEntries(ue.map(l=>{const c=`terminal.ansi${l[0].toUpperCase()}${l.substring(1)}`,u=t.colors?.[c];return[l,u||Ji[l]]})),i=Yi(o),a=Zi();return s.map(l=>a.parse(l[0]).map(c=>{let u,f;c.decorations.has("reverse")?(u=c.background?i.value(c.background):t.bg,f=c.foreground?i.value(c.foreground):t.fg):(u=c.foreground?i.value(c.foreground):t.fg,f=c.background?i.value(c.background):void 0),u=ie(u,r),f=ie(f,r),c.decorations.has("dim")&&(u=ta(u));let h=j.None;return c.decorations.has("bold")&&(h|=j.Bold),c.decorations.has("italic")&&(h|=j.Italic),c.decorations.has("underline")&&(h|=j.Underline),c.decorations.has("strikethrough")&&(h|=j.Strikethrough),{content:c.value,offset:l[1],color:u,bgColor:f,fontStyle:h}}))}function ta(t){const e=t.match(/#([0-9a-f]{3,8})/i);if(e){const r=e[1];if(r.length===8){const s=Math.round(Number.parseInt(r.slice(6,8),16)/2).toString(16).padStart(2,"0");return`#${r.slice(0,6)}${s}`}else{if(r.length===6)return`#${r}80`;if(r.length===4){const s=r[0],o=r[1],i=r[2],a=r[3],l=Math.round(Number.parseInt(`${a}${a}`,16)/2).toString(16).padStart(2,"0");return`#${s}${s}${o}${o}${i}${i}${l}`}else if(r.length===3){const s=r[0],o=r[1],i=r[2];return`#${s}${s}${o}${o}${i}${i}80`}}}const n=t.match(/var\((--[\w-]+-ansi-[\w-]+)\)/);return n?`var(${n[1]}-dim)`:t}function dn(t,e,n={}){const{theme:r=t.getLoadedThemes()[0]}=n,s=t.resolveLangAlias(n.lang||"text");if(un(s)||fn(r))return ht(e).map(l=>[{content:l[0],offset:l[1]}]);const{theme:o,colorMap:i}=t.setTheme(r);if(s==="ansi")return ea(o,e,n);const a=t.getLanguage(n.lang||"text");if(n.grammarState){if(n.grammarState.lang!==a.name)throw new G(`Grammar state language "${n.grammarState.lang}" does not match highlight language "${a.name}"`);if(!n.grammarState.themes.includes(o.name))throw new G(`Grammar state themes "${n.grammarState.themes}" do not contain highlight theme "${o.name}"`)}return ra(e,a,o,i,n)}function na(...t){if(t.length===2)return De(t[1]);const[e,n,r={}]=t,{lang:s="text",theme:o=e.getLoadedThemes()[0]}=r;if(un(s)||fn(o))throw new G("Plain language does not have grammar state");if(s==="ansi")throw new G("ANSI language does not have grammar state");const{theme:i,colorMap:a}=e.setTheme(o),l=e.getLanguage(s);return new Ie(pn(n,l,i,a,r).stateStack,l.name,i.name)}function ra(t,e,n,r,s){const o=pn(t,e,n,r,s),i=new Ie(o.stateStack,e.name,n.name);return dt(o.tokens,i),o.tokens}function pn(t,e,n,r,s){const o=it(n,s),{tokenizeMaxLineLength:i=0,tokenizeTimeLimit:a=500}=s,l=ht(t);let c=s.grammarState?Wi(s.grammarState,n.name)??Ht:s.grammarContextCode!=null?pn(s.grammarContextCode,e,n,r,{...s,grammarState:void 0,grammarContextCode:void 0}).stateStack:Ht,u=[];const f=[];for(let h=0,d=l.length;h<d;h++){const[p,b]=l[h];if(p===""){u=[],f.push([]);continue}if(i>0&&p.length>=i){u=[],f.push([{content:p,offset:b,color:"",fontStyle:0}]);continue}let w,y,m;s.includeExplanation&&(w=e.tokenizeLine(p,c,a),y=w.tokens,m=0);const g=e.tokenizeLine2(p,c,a),S=g.tokens.length/2;for(let k=0;k<S;k++){const _=g.tokens[2*k],x=k+1<S?g.tokens[2*k+2]:p.length;if(_===x)continue;const v=g.tokens[2*k+1],N=ie(r[ke.getForeground(v)],o),L=ke.getFontStyle(v),F={content:p.substring(_,x),offset:b+_,color:N,fontStyle:L};if(s.includeExplanation){const A=[];if(s.includeExplanation!=="scopeName")for(const K of n.settings){let pe;switch(typeof K.scope){case"string":pe=K.scope.split(/,/).map(_t=>_t.trim());break;case"object":pe=K.scope;break;default:continue}A.push({settings:K,selectors:pe.map(_t=>_t.split(/ /))})}F.explanation=[];let re=0;for(;_+re<x;){const K=y[m],pe=p.substring(K.startIndex,K.endIndex);re+=pe.length,F.explanation.push({content:pe,scopes:s.includeExplanation==="scopeName"?sa(K.scopes):oa(A,K.scopes)}),m+=1}}u.push(F)}f.push(u),u=[],c=g.ruleStack}return{tokens:f,stateStack:c}}function sa(t){return t.map(e=>({scopeName:e}))}function oa(t,e){const n=[];for(let r=0,s=e.length;r<s;r++){const o=e[r];n[r]={scopeName:o,themeMatches:aa(t,o,e.slice(0,r))}}return n}function Fn(t,e){return t===e||e.substring(0,t.length)===t&&e[t.length]==="."}function ia(t,e,n){if(!Fn(t[t.length-1],e))return!1;let r=t.length-2,s=n.length-1;for(;r>=0&&s>=0;)Fn(t[r],n[s])&&(r-=1),s-=1;return r===-1}function aa(t,e,n){const r=[];for(const{selectors:s,settings:o}of t)for(const i of s)if(ia(i,e,n)){r.push(o);break}return r}function Qr(t,e,n){const r=Object.entries(n.themes).filter(l=>l[1]).map(l=>({color:l[0],theme:l[1]})),s=r.map(l=>{const c=dn(t,e,{...n,theme:l.theme}),u=De(c),f=typeof l.theme=="string"?l.theme:l.theme.name;return{tokens:c,state:u,theme:f}}),o=la(...s.map(l=>l.tokens)),i=o[0].map((l,c)=>l.map((u,f)=>{const h={content:u.content,variants:{},offset:u.offset};return"includeExplanation"in n&&n.includeExplanation&&(h.explanation=u.explanation),o.forEach((d,p)=>{const{content:b,explanation:w,offset:y,...m}=d[c][f];h.variants[r[p].color]=m}),h})),a=s[0].state?new Ie(Object.fromEntries(s.map(l=>[l.theme,l.state?.getInternalStack(l.theme)])),s[0].state.lang):void 0;return a&&dt(i,a),i}function la(...t){const e=t.map(()=>[]),n=t.length;for(let r=0;r<t[0].length;r++){const s=t.map(l=>l[r]),o=e.map(()=>[]);e.forEach((l,c)=>l.push(o[c]));const i=s.map(()=>0),a=s.map(l=>l[0]);for(;a.every(l=>l);){const l=Math.min(...a.map(c=>c.content.length));for(let c=0;c<n;c++){const u=a[c];u.content.length===l?(o[c].push(u),i[c]+=1,a[c]=s[c][i[c]]):(o[c].push({...u,content:u.content.slice(0,l)}),a[c]={...u,content:u.content.slice(l),offset:u.offset+l})}}}return e}function ct(t,e,n){let r,s,o,i,a,l;if("themes"in n){const{defaultColor:c="light",cssVariablePrefix:u="--shiki-",colorsRendering:f="css-vars"}=n,h=Object.entries(n.themes).filter(y=>y[1]).map(y=>({color:y[0],theme:y[1]})).sort((y,m)=>y.color===c?-1:m.color===c?1:0);if(h.length===0)throw new G("`themes` option must not be empty");const d=Qr(t,e,n);if(l=De(d),c&&hn!==c&&!h.find(y=>y.color===c))throw new G(`\`themes\` option must contain the defaultColor key \`${c}\``);const p=h.map(y=>t.getTheme(y.theme)),b=h.map(y=>y.color);o=d.map(y=>y.map(m=>Ui(m,b,u,c,f))),l&&dt(o,l);const w=h.map(y=>it(y.theme,n));s=Un(h,p,w,u,c,"fg",f),r=Un(h,p,w,u,c,"bg",f),i=`shiki-themes ${p.map(y=>y.name).join(" ")}`,a=c?void 0:[s,r].join(";")}else if("theme"in n){const c=it(n.theme,n);o=dn(t,e,n);const u=t.getTheme(n.theme);r=ie(u.bg,c),s=ie(u.fg,c),i=u.name,l=De(o)}else throw new G("Invalid options, either `theme` or `themes` must be provided");return{tokens:o,fg:s,bg:r,themeName:i,rootStyle:a,grammarState:l}}function Un(t,e,n,r,s,o,i){return t.map((a,l)=>{const c=ie(e[l][o],n[l])||"inherit",u=`${r+a.color}${o==="bg"?"-bg":""}:${c}`;if(l===0&&s){if(s===hn&&t.length>1){const f=t.findIndex(b=>b.color==="light"),h=t.findIndex(b=>b.color==="dark");if(f===-1||h===-1)throw new G('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');const d=ie(e[f][o],n[f])||"inherit",p=ie(e[h][o],n[h])||"inherit";return`light-dark(${d}, ${p});${u}`}return c}return i==="css-vars"?u:null}).filter(a=>!!a).join(";")}function ut(t,e,n,r={meta:{},options:n,codeToHast:(s,o)=>ut(t,s,o),codeToTokens:(s,o)=>ct(t,s,o)}){let s=e;for(const p of lt(n))s=p.preprocess?.call(r,s,n)||s;let{tokens:o,fg:i,bg:a,themeName:l,rootStyle:c,grammarState:u}=ct(t,s,n);const{mergeWhitespaces:f=!0,mergeSameStyleTokens:h=!1}=n;f===!0?o=ua(o):f==="never"&&(o=fa(o)),h&&(o=ha(o));const d={...r,get source(){return s}};for(const p of lt(n))o=p.tokens?.call(d,o)||o;return ca(o,{...n,fg:i,bg:a,themeName:l,rootStyle:n.rootStyle===!1?!1:n.rootStyle??c},d,u)}function ca(t,e,n,r=De(t)){const s=lt(e),o=[],i={type:"root",children:[]},{structure:a="classic",tabindex:l="0"}=e,c={class:`shiki ${e.themeName||""}`};e.rootStyle!==!1&&(e.rootStyle!=null?c.style=e.rootStyle:c.style=`background-color:${e.bg};color:${e.fg}`),l!==!1&&l!=null&&(c.tabindex=l.toString());for(const[b,w]of Object.entries(e.meta||{}))b.startsWith("_")||(c[b]=w);let u={type:"element",tagName:"pre",properties:c,children:[],data:e.data},f={type:"element",tagName:"code",properties:{},children:o};const h=[],d={...n,structure:a,addClassToHast:Xr,get source(){return n.source},get tokens(){return t},get options(){return e},get root(){return i},get pre(){return u},get code(){return f},get lines(){return h}};if(t.forEach((b,w)=>{w&&(a==="inline"?i.children.push({type:"element",tagName:"br",properties:{},children:[]}):a==="classic"&&o.push({type:"text",value:`
12
+ `}));let y={type:"element",tagName:"span",properties:{class:"line"},children:[]},m=0;for(const g of b){let S={type:"element",tagName:"span",properties:{...g.htmlAttrs},children:[{type:"text",value:g.content}]};const k=Zt(g.htmlStyle||at(g));k&&(S.properties.style=k);for(const _ of s)S=_?.span?.call(d,S,w+1,m,y,g)||S;a==="inline"?i.children.push(S):a==="classic"&&y.children.push(S),m+=g.content.length}if(a==="classic"){for(const g of s)y=g?.line?.call(d,y,w+1)||y;h.push(y),o.push(y)}else a==="inline"&&h.push(y)}),a==="classic"){for(const b of s)f=b?.code?.call(d,f)||f;u.children.push(f);for(const b of s)u=b?.pre?.call(d,u)||u;i.children.push(u)}else if(a==="inline"){const b=[];let w={type:"element",tagName:"span",properties:{class:"line"},children:[]};for(const g of i.children)g.type==="element"&&g.tagName==="br"?(b.push(w),w={type:"element",tagName:"span",properties:{class:"line"},children:[]}):(g.type==="element"||g.type==="text")&&w.children.push(g);b.push(w);let m={type:"element",tagName:"code",properties:{},children:b};for(const g of s)m=g?.code?.call(d,m)||m;i.children=[];for(let g=0;g<m.children.length;g++){g>0&&i.children.push({type:"element",tagName:"br",properties:{},children:[]});const S=m.children[g];S.type==="element"&&i.children.push(...S.children)}}let p=i;for(const b of s)p=b?.root?.call(d,p)||p;return r&&dt(p,r),p}function ua(t){return t.map(e=>{const n=[];let r="",s;return e.forEach((o,i)=>{const l=!(o.fontStyle&&(o.fontStyle&j.Underline||o.fontStyle&j.Strikethrough));l&&o.content.match(/^\s+$/)&&e[i+1]?(s===void 0&&(s=o.offset),r+=o.content):r?(l?n.push({...o,offset:s,content:r+o.content}):n.push({content:r,offset:s},o),s=void 0,r=""):n.push(o)}),n})}function fa(t){return t.map(e=>e.flatMap(n=>{if(n.content.match(/^\s+$/))return n;const r=n.content.match(/^(\s*)(.*?)(\s*)$/);if(!r)return n;const[,s,o,i]=r;if(!s&&!i)return n;const a=[{...n,offset:n.offset+s.length,content:o}];return s&&a.unshift({content:s,offset:n.offset}),i&&a.push({content:i,offset:n.offset+s.length+o.length}),a}))}function ha(t){return t.map(e=>{const n=[];for(const r of e){if(n.length===0){n.push({...r});continue}const s=n[n.length-1],o=Zt(s.htmlStyle||at(s)),i=Zt(r.htmlStyle||at(r)),a=s.fontStyle&&(s.fontStyle&j.Underline||s.fontStyle&j.Strikethrough),l=r.fontStyle&&(r.fontStyle&j.Underline||r.fontStyle&j.Strikethrough);!a&&!l&&o===i?s.content+=r.content:n.push({...r})}return n})}const da=Ni;function pa(t,e,n){const r={meta:{},options:n,codeToHast:(o,i)=>ut(t,o,i),codeToTokens:(o,i)=>ct(t,o,i)};let s=da(ut(t,e,n,r));for(const o of lt(n))s=o.postprocess?.call(r,s,n)||s;return s}const jn={light:"#333333",dark:"#bbbbbb"},Wn={light:"#fffffe",dark:"#1e1e1e"},zn="__shiki_resolved";function gn(t){if(t?.[zn])return t;const e={...t};e.tokenColors&&!e.settings&&(e.settings=e.tokenColors,delete e.tokenColors),e.type||="dark",e.colorReplacements={...e.colorReplacements},e.settings||=[];let{bg:n,fg:r}=e;if(!n||!r){const a=e.settings?e.settings.find(l=>!l.name&&!l.scope):void 0;a?.settings?.foreground&&(r=a.settings.foreground),a?.settings?.background&&(n=a.settings.background),!r&&e?.colors?.["editor.foreground"]&&(r=e.colors["editor.foreground"]),!n&&e?.colors?.["editor.background"]&&(n=e.colors["editor.background"]),r||(r=e.type==="light"?jn.light:jn.dark),n||(n=e.type==="light"?Wn.light:Wn.dark),e.fg=r,e.bg=n}e.settings[0]&&e.settings[0].settings&&!e.settings[0].scope||e.settings.unshift({settings:{foreground:e.fg,background:e.bg}});let s=0;const o=new Map;function i(a){if(o.has(a))return o.get(a);s+=1;const l=`#${s.toString(16).padStart(8,"0").toLowerCase()}`;return e.colorReplacements?.[`#${l}`]?i(a):(o.set(a,l),l)}e.settings=e.settings.map(a=>{const l=a.settings?.foreground&&!a.settings.foreground.startsWith("#"),c=a.settings?.background&&!a.settings.background.startsWith("#");if(!l&&!c)return a;const u={...a,settings:{...a.settings}};if(l){const f=i(a.settings.foreground);e.colorReplacements[f]=a.settings.foreground,u.settings.foreground=f}if(c){const f=i(a.settings.background);e.colorReplacements[f]=a.settings.background,u.settings.background=f}return u});for(const a of Object.keys(e.colors||{}))if((a==="editor.foreground"||a==="editor.background"||a.startsWith("terminal.ansi"))&&!e.colors[a]?.startsWith("#")){const l=i(e.colors[a]);e.colorReplacements[l]=e.colors[a],e.colors[a]=l}return Object.defineProperty(e,zn,{enumerable:!1,writable:!1,value:!0}),e}async function Yr(t){return Array.from(new Set((await Promise.all(t.filter(e=>!Mi(e)).map(async e=>await Vr(e).then(n=>Array.isArray(n)?n:[n])))).flat()))}async function Jr(t){return(await Promise.all(t.map(async n=>Oi(n)?null:gn(await Vr(n))))).filter(n=>!!n)}let ga=3;function ma(t,e=3){e>ga||console.trace(`[SHIKI DEPRECATE]: ${t}`)}let Ce=class extends Error{constructor(e){super(e),this.name="ShikiError"}};function es(t,e){if(!e)return t;if(e[t]){const n=new Set([t]);for(;e[t];){if(t=e[t],n.has(t))throw new Ce(`Circular alias \`${Array.from(n).join(" -> ")} -> ${t}\``);n.add(t)}}return t}class ya extends yo{constructor(e,n,r,s={}){super(e),this._resolver=e,this._themes=n,this._langs=r,this._alias=s,this._themes.map(o=>this.loadTheme(o)),this.loadLanguages(this._langs)}_resolvedThemes=new Map;_resolvedGrammars=new Map;_langMap=new Map;_langGraph=new Map;_textmateThemeCache=new WeakMap;_loadedThemesCache=null;_loadedLanguagesCache=null;getTheme(e){return typeof e=="string"?this._resolvedThemes.get(e):this.loadTheme(e)}loadTheme(e){const n=gn(e);return n.name&&(this._resolvedThemes.set(n.name,n),this._loadedThemesCache=null),n}getLoadedThemes(){return this._loadedThemesCache||(this._loadedThemesCache=[...this._resolvedThemes.keys()]),this._loadedThemesCache}setTheme(e){let n=this._textmateThemeCache.get(e);n||(n=tt.createFromRawTheme(e),this._textmateThemeCache.set(e,n)),this._syncRegistry.setTheme(n)}getGrammar(e){return e=es(e,this._alias),this._resolvedGrammars.get(e)}loadLanguage(e){if(this.getGrammar(e.name))return;const n=new Set([...this._langMap.values()].filter(o=>o.embeddedLangsLazy?.includes(e.name)));this._resolver.addLanguage(e);const r={balancedBracketSelectors:e.balancedBracketSelectors||["*"],unbalancedBracketSelectors:e.unbalancedBracketSelectors||[]};this._syncRegistry._rawGrammars.set(e.scopeName,e);const s=this.loadGrammarWithConfiguration(e.scopeName,1,r);if(s.name=e.name,this._resolvedGrammars.set(e.name,s),e.aliases&&e.aliases.forEach(o=>{this._alias[o]=e.name}),this._loadedLanguagesCache=null,n.size)for(const o of n)this._resolvedGrammars.delete(o.name),this._loadedLanguagesCache=null,this._syncRegistry?._injectionGrammars?.delete(o.scopeName),this._syncRegistry?._grammars?.delete(o.scopeName),this.loadLanguage(this._langMap.get(o.name))}dispose(){super.dispose(),this._resolvedThemes.clear(),this._resolvedGrammars.clear(),this._langMap.clear(),this._langGraph.clear(),this._loadedThemesCache=null}loadLanguages(e){for(const s of e)this.resolveEmbeddedLanguages(s);const n=Array.from(this._langGraph.entries()),r=n.filter(([s,o])=>!o);if(r.length){const s=n.filter(([o,i])=>i?(i.embeddedLanguages||i.embeddedLangs)?.some(l=>r.map(([c])=>c).includes(l)):!1).filter(o=>!r.includes(o));throw new Ce(`Missing languages ${r.map(([o])=>`\`${o}\``).join(", ")}, required by ${s.map(([o])=>`\`${o}\``).join(", ")}`)}for(const[s,o]of n)this._resolver.addLanguage(o);for(const[s,o]of n)this.loadLanguage(o)}getLoadedLanguages(){return this._loadedLanguagesCache||(this._loadedLanguagesCache=[...new Set([...this._resolvedGrammars.keys(),...Object.keys(this._alias)])]),this._loadedLanguagesCache}resolveEmbeddedLanguages(e){this._langMap.set(e.name,e),this._langGraph.set(e.name,e);const n=e.embeddedLanguages??e.embeddedLangs;if(n)for(const r of n)this._langGraph.set(r,this._langMap.get(r))}}class ba{_langs=new Map;_scopeToLang=new Map;_injections=new Map;_onigLib;constructor(e,n){this._onigLib={createOnigScanner:r=>e.createScanner(r),createOnigString:r=>e.createString(r)},n.forEach(r=>this.addLanguage(r))}get onigLib(){return this._onigLib}getLangRegistration(e){return this._langs.get(e)}loadGrammar(e){return this._scopeToLang.get(e)}addLanguage(e){this._langs.set(e.name,e),e.aliases&&e.aliases.forEach(n=>{this._langs.set(n,e)}),this._scopeToLang.set(e.scopeName,e),e.injectTo&&e.injectTo.forEach(n=>{this._injections.get(n)||this._injections.set(n,[]),this._injections.get(n).push(e.scopeName)})}getInjections(e){const n=e.split(".");let r=[];for(let s=1;s<=n.length;s++){const o=n.slice(0,s).join(".");r=[...r,...this._injections.get(o)||[]]}return r}}let Le=0;function wa(t){Le+=1,t.warnings!==!1&&Le>=10&&Le%10===0&&console.warn(`[Shiki] ${Le} instances have been created. Shiki is supposed to be used as a singleton, consider refactoring your code to cache your highlighter instance; Or call \`highlighter.dispose()\` to release unused instances.`);let e=!1;if(!t.engine)throw new Ce("`engine` option is required for synchronous mode");const n=(t.langs||[]).flat(1),r=(t.themes||[]).flat(1).map(gn),s=new ba(t.engine,n),o=new ya(s,r,n,t.langAlias);let i;function a(g){return es(g,t.langAlias)}function l(g){y();const S=o.getGrammar(typeof g=="string"?g:g.name);if(!S)throw new Ce(`Language \`${g}\` not found, you may need to load it first`);return S}function c(g){if(g==="none")return{bg:"",fg:"",name:"none",settings:[],type:"dark"};y();const S=o.getTheme(g);if(!S)throw new Ce(`Theme \`${g}\` not found, you may need to load it first`);return S}function u(g){y();const S=c(g);i!==g&&(o.setTheme(S),i=g);const k=o.getColorMap();return{theme:S,colorMap:k}}function f(){return y(),o.getLoadedThemes()}function h(){return y(),o.getLoadedLanguages()}function d(...g){y(),o.loadLanguages(g.flat(1))}async function p(...g){return d(await Yr(g))}function b(...g){y();for(const S of g.flat(1))o.loadTheme(S)}async function w(...g){return y(),b(await Jr(g))}function y(){if(e)throw new Ce("Shiki instance has been disposed")}function m(){e||(e=!0,o.dispose(),Le-=1)}return{setTheme:u,getTheme:c,getLanguage:l,getLoadedThemes:f,getLoadedLanguages:h,resolveLangAlias:a,loadLanguage:p,loadLanguageSync:d,loadTheme:w,loadThemeSync:b,dispose:m,[Symbol.dispose]:m}}async function Ca(t){t.engine||ma("`engine` option is required. Use `createOnigurumaEngine` or `createJavaScriptRegexEngine` to create an engine.");const[e,n,r]=await Promise.all([Jr(t.themes||[]),Yr(t.langs||[]),t.engine]);return wa({...t,themes:e,langs:n,engine:r})}async function _a(t){const e=await Ca(t);return{getLastGrammarState:(...n)=>na(e,...n),codeToTokensBase:(n,r)=>dn(e,n,r),codeToTokensWithThemes:(n,r)=>Qr(e,n,r),codeToTokens:(n,r)=>ct(e,n,r),codeToHast:(n,r)=>ut(e,n,r),codeToHtml:(n,r)=>pa(e,n,r),getBundledLanguages:()=>({}),getBundledThemes:()=>({}),...e,getInternalContext:()=>e}}function Ee(t){if([...t].length!==1)throw new Error(`Expected "${t}" to be a single code point`);return t.codePointAt(0)}function Sa(t,e,n){return t.has(e)||t.set(e,n),t.get(e)}const mn=new Set(["alnum","alpha","ascii","blank","cntrl","digit","graph","lower","print","punct","space","upper","word","xdigit"]),B=String.raw;function Ae(t,e){if(t==null)throw new Error(e??"Value expected");return t}const ts=B`\[\^?`,ns=`c.? | C(?:-.?)?|${B`[pP]\{(?:\^?[-\x20_]*[A-Za-z][-\x20\w]*\})?`}|${B`x[89A-Fa-f]\p{AHex}(?:\\x[89A-Fa-f]\p{AHex})*`}|${B`u(?:\p{AHex}{4})? | x\{[^\}]*\}? | x\p{AHex}{0,2}`}|${B`o\{[^\}]*\}?`}|${B`\d{1,3}`}`,yn=/[?*+][?+]?|\{(?:\d+(?:,\d*)?|,\d+)\}\??/,Ve=new RegExp(B`
13
+ \\ (?:
14
+ ${ns}
15
+ | [gk]<[^>]*>?
16
+ | [gk]'[^']*'?
17
+ | .
18
+ )
19
+ | \( (?:
20
+ \? (?:
21
+ [:=!>({]
22
+ | <[=!]
23
+ | <[^>]*>
24
+ | '[^']*'
25
+ | ~\|?
26
+ | #(?:[^)\\]|\\.?)*
27
+ | [^:)]*[:)]
28
+ )?
29
+ | \*[^\)]*\)?
30
+ )?
31
+ | (?:${yn.source})+
32
+ | ${ts}
33
+ | .
34
+ `.replace(/\s+/g,""),"gsu"),Lt=new RegExp(B`
35
+ \\ (?:
36
+ ${ns}
37
+ | .
38
+ )
39
+ | \[:(?:\^?\p{Alpha}+|\^):\]
40
+ | ${ts}
41
+ | &&
42
+ | .
43
+ `.replace(/\s+/g,""),"gsu");function ka(t,e={}){const n={flags:"",...e,rules:{captureGroup:!1,singleline:!1,...e.rules}};if(typeof t!="string")throw new Error("String expected as pattern");const r=ja(n.flags),s=[r.extended],o={captureGroup:n.rules.captureGroup,getCurrentModX(){return s.at(-1)},numOpenGroups:0,popModX(){s.pop()},pushModX(f){s.push(f)},replaceCurrentModX(f){s[s.length-1]=f},singleline:n.rules.singleline};let i=[],a;for(Ve.lastIndex=0;a=Ve.exec(t);){const f=xa(o,t,a[0],Ve.lastIndex);f.tokens?i.push(...f.tokens):f.token&&i.push(f.token),f.lastIndex!==void 0&&(Ve.lastIndex=f.lastIndex)}const l=[];let c=0;i.filter(f=>f.type==="GroupOpen").forEach(f=>{f.kind==="capturing"?f.number=++c:f.raw==="("&&l.push(f)}),c||l.forEach((f,h)=>{f.kind="capturing",f.number=h+1});const u=c||l.length;return{tokens:i.map(f=>f.type==="EscapedNumber"?za(f,u):f).flat(),flags:r}}function xa(t,e,n,r){const[s,o]=n;if(n==="["||n==="[^"){const i=va(e,n,r);return{tokens:i.tokens,lastIndex:i.lastIndex}}if(s==="\\"){if("AbBGyYzZ".includes(o))return{token:Hn(n,n)};if(/^\\g[<']/.test(n)){if(!/^\\g(?:<[^>]+>|'[^']+')$/.test(n))throw new Error(`Invalid group name "${n}"`);return{token:Ma(n)}}if(/^\\k[<']/.test(n)){if(!/^\\k(?:<[^>]+>|'[^']+')$/.test(n))throw new Error(`Invalid group name "${n}"`);return{token:ss(n)}}if(o==="K")return{token:os("keep",n)};if(o==="N"||o==="R")return{token:fe("newline",n,{negate:o==="N"})};if(o==="O")return{token:fe("any",n)};if(o==="X")return{token:fe("text_segment",n)};const i=rs(n,{inCharClass:!1});return Array.isArray(i)?{tokens:i}:{token:i}}if(s==="("){if(o==="*")return{token:Ba(n)};if(n==="(?{")throw new Error(`Unsupported callout "${n}"`);if(n.startsWith("(?#")){if(e[r]!==")")throw new Error('Unclosed comment group "(?#"');return{lastIndex:r+1}}if(/^\(\?[-imx]+[:)]$/.test(n))return{token:Ga(n,t)};if(t.pushModX(t.getCurrentModX()),t.numOpenGroups++,n==="("&&!t.captureGroup||n==="(?:")return{token:be("group",n)};if(n==="(?>")return{token:be("atomic",n)};if(n==="(?="||n==="(?!"||n==="(?<="||n==="(?<!")return{token:be(n[2]==="<"?"lookbehind":"lookahead",n,{negate:n.endsWith("!")})};if(n==="("&&t.captureGroup||n.startsWith("(?<")&&n.endsWith(">")||n.startsWith("(?'")&&n.endsWith("'"))return{token:be("capturing",n,{...n!=="("&&{name:n.slice(3,-1)}})};if(n.startsWith("(?~")){if(n==="(?~|")throw new Error(`Unsupported absence function kind "${n}"`);return{token:be("absence_repeater",n)}}throw n==="(?("?new Error(`Unsupported conditional "${n}"`):new Error(`Invalid or unsupported group option "${n}"`)}if(n===")"){if(t.popModX(),t.numOpenGroups--,t.numOpenGroups<0)throw new Error('Unmatched ")"');return{token:Pa(n)}}if(t.getCurrentModX()){if(n==="#"){const i=e.indexOf(`
44
+ `,r);return{lastIndex:i===-1?e.length:i}}if(/^\s$/.test(n)){const i=/\s+/y;return i.lastIndex=r,{lastIndex:i.exec(e)?i.lastIndex:r}}}if(n===".")return{token:fe("dot",n)};if(n==="^"||n==="$"){const i=t.singleline?{"^":B`\A`,$:B`\Z`}[n]:n;return{token:Hn(i,n)}}return n==="|"?{token:Ea(n)}:yn.test(n)?{tokens:Ha(n)}:{token:ne(Ee(n),n)}}function va(t,e,n){const r=[qn(e[1]==="^",e)];let s=1,o;for(Lt.lastIndex=n;o=Lt.exec(t);){const i=o[0];if(i[0]==="["&&i[1]!==":")s++,r.push(qn(i[1]==="^",i));else if(i==="]"){if(r.at(-1).type==="CharacterClassOpen")r.push(ne(93,i));else if(s--,r.push(Aa(i)),!s)break}else{const a=Ia(i);Array.isArray(a)?r.push(...a):r.push(a)}}return{tokens:r,lastIndex:Lt.lastIndex||t.length}}function Ia(t){if(t[0]==="\\")return rs(t,{inCharClass:!0});if(t[0]==="["){const e=/\[:(?<negate>\^?)(?<name>[a-z]+):\]/.exec(t);if(!e||!mn.has(e.groups.name))throw new Error(`Invalid POSIX class "${t}"`);return fe("posix",t,{value:e.groups.name,negate:!!e.groups.negate})}return t==="-"?La(t):t==="&&"?Ra(t):ne(Ee(t),t)}function rs(t,{inCharClass:e}){const n=t[1];if(n==="c"||n==="C")return Da(t);if("dDhHsSwW".includes(n))return Fa(t);if(t.startsWith(B`\o{`))throw new Error(`Incomplete, invalid, or unsupported octal code point "${t}"`);if(/^\\[pP]\{/.test(t)){if(t.length===3)throw new Error(`Incomplete or invalid Unicode property "${t}"`);return Ua(t)}if(new RegExp("^\\\\x[89A-Fa-f]\\p{AHex}","u").test(t))try{const r=t.split(/\\x/).slice(1).map(i=>parseInt(i,16)),s=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}).decode(new Uint8Array(r)),o=new TextEncoder;return[...s].map(i=>{const a=[...o.encode(i)].map(l=>`\\x${l.toString(16)}`).join("");return ne(Ee(i),a)})}catch{throw new Error(`Multibyte code "${t}" incomplete or invalid in Oniguruma`)}if(n==="u"||n==="x")return ne(Wa(t),t);if(Vn.has(n))return ne(Vn.get(n),t);if(/\d/.test(n))return Na(e,t);if(t==="\\")throw new Error(B`Incomplete escape "\"`);if(n==="M")throw new Error(`Unsupported meta "${t}"`);if([...t].length===2)return ne(t.codePointAt(1),t);throw new Error(`Unexpected escape "${t}"`)}function Ea(t){return{type:"Alternator",raw:t}}function Hn(t,e){return{type:"Assertion",kind:t,raw:e}}function ss(t){return{type:"Backreference",raw:t}}function ne(t,e){return{type:"Character",value:t,raw:e}}function Aa(t){return{type:"CharacterClassClose",raw:t}}function La(t){return{type:"CharacterClassHyphen",raw:t}}function Ra(t){return{type:"CharacterClassIntersector",raw:t}}function qn(t,e){return{type:"CharacterClassOpen",negate:t,raw:e}}function fe(t,e,n={}){return{type:"CharacterSet",kind:t,...n,raw:e}}function os(t,e,n={}){return t==="keep"?{type:"Directive",kind:t,raw:e}:{type:"Directive",kind:t,flags:Ae(n.flags),raw:e}}function Na(t,e){return{type:"EscapedNumber",inCharClass:t,raw:e}}function Pa(t){return{type:"GroupClose",raw:t}}function be(t,e,n={}){return{type:"GroupOpen",kind:t,...n,raw:e}}function $a(t,e,n,r){return{type:"NamedCallout",kind:t,tag:e,arguments:n,raw:r}}function Ta(t,e,n,r){return{type:"Quantifier",kind:t,min:e,max:n,raw:r}}function Ma(t){return{type:"Subroutine",raw:t}}const Oa=new Set(["COUNT","CMP","ERROR","FAIL","MAX","MISMATCH","SKIP","TOTAL_COUNT"]),Vn=new Map([["a",7],["b",8],["e",27],["f",12],["n",10],["r",13],["t",9],["v",11]]);function Da(t){const e=t[1]==="c"?t[2]:t[3];if(!e||!/[A-Za-z]/.test(e))throw new Error(`Unsupported control character "${t}"`);return ne(Ee(e.toUpperCase())-64,t)}function Ga(t,e){let{on:n,off:r}=/^\(\?(?<on>[imx]*)(?:-(?<off>[-imx]*))?/.exec(t).groups;r??="";const s=(e.getCurrentModX()||n.includes("x"))&&!r.includes("x"),o=Kn(n),i=Kn(r),a={};if(o&&(a.enable=o),i&&(a.disable=i),t.endsWith(")"))return e.replaceCurrentModX(s),os("flags",t,{flags:a});if(t.endsWith(":"))return e.pushModX(s),e.numOpenGroups++,be("group",t,{...(o||i)&&{flags:a}});throw new Error(`Unexpected flag modifier "${t}"`)}function Ba(t){const e=/\(\*(?<name>[A-Za-z_]\w*)?(?:\[(?<tag>(?:[A-Za-z_]\w*)?)\])?(?:\{(?<args>[^}]*)\})?\)/.exec(t);if(!e)throw new Error(`Incomplete or invalid named callout "${t}"`);const{name:n,tag:r,args:s}=e.groups;if(!n)throw new Error(`Invalid named callout "${t}"`);if(r==="")throw new Error(`Named callout tag with empty value not allowed "${t}"`);const o=s?s.split(",").filter(u=>u!=="").map(u=>/^[+-]?\d+$/.test(u)?+u:u):[],[i,a,l]=o,c=Oa.has(n)?n.toLowerCase():"custom";switch(c){case"fail":case"mismatch":case"skip":if(o.length>0)throw new Error(`Named callout arguments not allowed "${o}"`);break;case"error":if(o.length>1)throw new Error(`Named callout allows only one argument "${o}"`);if(typeof i=="string")throw new Error(`Named callout argument must be a number "${i}"`);break;case"max":if(!o.length||o.length>2)throw new Error(`Named callout must have one or two arguments "${o}"`);if(typeof i=="string"&&!/^[A-Za-z_]\w*$/.test(i))throw new Error(`Named callout argument one must be a tag or number "${i}"`);if(o.length===2&&(typeof a=="number"||!/^[<>X]$/.test(a)))throw new Error(`Named callout optional argument two must be '<', '>', or 'X' "${a}"`);break;case"count":case"total_count":if(o.length>1)throw new Error(`Named callout allows only one argument "${o}"`);if(o.length===1&&(typeof i=="number"||!/^[<>X]$/.test(i)))throw new Error(`Named callout optional argument must be '<', '>', or 'X' "${i}"`);break;case"cmp":if(o.length!==3)throw new Error(`Named callout must have three arguments "${o}"`);if(typeof i=="string"&&!/^[A-Za-z_]\w*$/.test(i))throw new Error(`Named callout argument one must be a tag or number "${i}"`);if(typeof a=="number"||!/^(?:[<>!=]=|[<>])$/.test(a))throw new Error(`Named callout argument two must be '==', '!=', '>', '<', '>=', or '<=' "${a}"`);if(typeof l=="string"&&!/^[A-Za-z_]\w*$/.test(l))throw new Error(`Named callout argument three must be a tag or number "${l}"`);break;case"custom":throw new Error(`Undefined callout name "${n}"`);default:throw new Error(`Unexpected named callout kind "${c}"`)}return $a(c,r??null,s?.split(",")??null,t)}function Xn(t){let e=null,n,r;if(t[0]==="{"){const{minStr:s,maxStr:o}=/^\{(?<minStr>\d*)(?:,(?<maxStr>\d*))?/.exec(t).groups,i=1e5;if(+s>i||o&&+o>i)throw new Error("Quantifier value unsupported in Oniguruma");if(n=+s,r=o===void 0?+s:o===""?1/0:+o,n>r&&(e="possessive",[n,r]=[r,n]),t.endsWith("?")){if(e==="possessive")throw new Error('Unsupported possessive interval quantifier chain with "?"');e="lazy"}else e||(e="greedy")}else n=t[0]==="+"?1:0,r=t[0]==="?"?1:1/0,e=t[1]==="+"?"possessive":t[1]==="?"?"lazy":"greedy";return Ta(e,n,r,t)}function Fa(t){const e=t[1].toLowerCase();return fe({d:"digit",h:"hex",s:"space",w:"word"}[e],t,{negate:t[1]!==e})}function Ua(t){const{p:e,neg:n,value:r}=/^\\(?<p>[pP])\{(?<neg>\^?)(?<value>[^}]+)/.exec(t).groups;return fe("property",t,{value:r,negate:e==="P"&&!n||e==="p"&&!!n})}function Kn(t){const e={};return t.includes("i")&&(e.ignoreCase=!0),t.includes("m")&&(e.dotAll=!0),t.includes("x")&&(e.extended=!0),Object.keys(e).length?e:null}function ja(t){const e={ignoreCase:!1,dotAll:!1,extended:!1,digitIsAscii:!1,posixIsAscii:!1,spaceIsAscii:!1,wordIsAscii:!1,textSegmentMode:null};for(let n=0;n<t.length;n++){const r=t[n];if(!"imxDPSWy".includes(r))throw new Error(`Invalid flag "${r}"`);if(r==="y"){if(!/^y{[gw]}/.test(t.slice(n)))throw new Error('Invalid or unspecified flag "y" mode');e.textSegmentMode=t[n+2]==="g"?"grapheme":"word",n+=3;continue}e[{i:"ignoreCase",m:"dotAll",x:"extended",D:"digitIsAscii",P:"posixIsAscii",S:"spaceIsAscii",W:"wordIsAscii"}[r]]=!0}return e}function Wa(t){if(new RegExp("^(?:\\\\u(?!\\p{AHex}{4})|\\\\x(?!\\p{AHex}{1,2}|\\{\\p{AHex}{1,8}\\}))","u").test(t))throw new Error(`Incomplete or invalid escape "${t}"`);const e=t[2]==="{"?new RegExp("^\\\\x\\{\\s*(?<hex>\\p{AHex}+)","u").exec(t).groups.hex:t.slice(2);return parseInt(e,16)}function za(t,e){const{raw:n,inCharClass:r}=t,s=n.slice(1);if(!r&&(s!=="0"&&s.length===1||s[0]!=="0"&&+s<=e))return[ss(n)];const o=[],i=s.match(/^[0-7]+|\d/g);for(let a=0;a<i.length;a++){const l=i[a];let c;if(a===0&&l!=="8"&&l!=="9"){if(c=parseInt(l,8),c>127)throw new Error(B`Octal encoded byte above 177 unsupported "${n}"`)}else c=Ee(l);o.push(ne(c,(a===0?"\\":"")+l))}return o}function Ha(t){const e=[],n=new RegExp(yn,"gy");let r;for(;r=n.exec(t);){const s=r[0];if(s[0]==="{"){const o=/^\{(?<min>\d+),(?<max>\d+)\}\??$/.exec(s);if(o){const{min:i,max:a}=o.groups;if(+i>+a&&s.endsWith("?")){n.lastIndex--,e.push(Xn(s.slice(0,-1)));continue}}}e.push(Xn(s))}return e}function is(t,e){if(!Array.isArray(t.body))throw new Error("Expected node with body array");if(t.body.length!==1)return!1;const n=t.body[0];return!e||Object.keys(e).every(r=>e[r]===n[r])}function qa(t){return Va.has(t.type)}const Va=new Set(["AbsenceFunction","Backreference","CapturingGroup","Character","CharacterClass","CharacterSet","Group","Quantifier","Subroutine"]);function as(t,e={}){const n={flags:"",normalizeUnknownPropertyNames:!1,skipBackrefValidation:!1,skipLookbehindValidation:!1,skipPropertyNameValidation:!1,unicodePropertyMap:null,...e,rules:{captureGroup:!1,singleline:!1,...e.rules}},r=ka(t,{flags:n.flags,rules:{captureGroup:n.rules.captureGroup,singleline:n.rules.singleline}}),s=(h,d)=>{const p=r.tokens[o.nextIndex];switch(o.parent=h,o.nextIndex++,p.type){case"Alternator":return he();case"Assertion":return Xa(p);case"Backreference":return Ka(p,o);case"Character":return pt(p.value,{useLastValid:!!d.isCheckingRangeEnd});case"CharacterClassHyphen":return Za(p,o,d);case"CharacterClassOpen":return Qa(p,o,d);case"CharacterSet":return Ya(p,o);case"Directive":return sl(p.kind,{flags:p.flags});case"GroupOpen":return Ja(p,o,d);case"NamedCallout":return il(p.kind,p.tag,p.arguments);case"Quantifier":return el(p,o);case"Subroutine":return tl(p,o);default:throw new Error(`Unexpected token type "${p.type}"`)}},o={capturingGroups:[],hasNumberedRef:!1,namedGroupsByName:new Map,nextIndex:0,normalizeUnknownPropertyNames:n.normalizeUnknownPropertyNames,parent:null,skipBackrefValidation:n.skipBackrefValidation,skipLookbehindValidation:n.skipLookbehindValidation,skipPropertyNameValidation:n.skipPropertyNameValidation,subroutines:[],tokens:r.tokens,unicodePropertyMap:n.unicodePropertyMap,walk:s},i=ll(ol(r.flags));let a=i.body[0];for(;o.nextIndex<r.tokens.length;){const h=s(a,{});h.type==="Alternative"?(i.body.push(h),a=h):a.body.push(h)}const{capturingGroups:l,hasNumberedRef:c,namedGroupsByName:u,subroutines:f}=o;if(c&&u.size&&!n.rules.captureGroup)throw new Error("Numbered backref/subroutine not allowed when using named capture");for(const{ref:h}of f)if(typeof h=="number"){if(h>l.length)throw new Error("Subroutine uses a group number that's not defined");h&&(l[h-1].isSubroutined=!0)}else if(u.has(h)){if(u.get(h).length>1)throw new Error(B`Subroutine uses a duplicate group name "\g<${h}>"`);u.get(h)[0].isSubroutined=!0}else throw new Error(B`Subroutine uses a group name that's not defined "\g<${h}>"`);return i}function Xa({kind:t}){return Qt(Ae({"^":"line_start",$:"line_end","\\A":"string_start","\\b":"word_boundary","\\B":"word_boundary","\\G":"search_start","\\y":"text_segment_boundary","\\Y":"text_segment_boundary","\\z":"string_end","\\Z":"string_end_newline"}[t],`Unexpected assertion kind "${t}"`),{negate:t===B`\B`||t===B`\Y`})}function Ka({raw:t},e){const n=/^\\k[<']/.test(t),r=n?t.slice(3,-1):t.slice(1),s=(o,i=!1)=>{const a=e.capturingGroups.length;let l=!1;if(o>a)if(e.skipBackrefValidation)l=!0;else throw new Error(`Not enough capturing groups defined to the left "${t}"`);return e.hasNumberedRef=!0,Yt(i?a+1-o:o,{orphan:l})};if(n){const o=/^(?<sign>-?)0*(?<num>[1-9]\d*)$/.exec(r);if(o)return s(+o.groups.num,!!o.groups.sign);if(/[-+]/.test(r))throw new Error(`Invalid backref name "${t}"`);if(!e.namedGroupsByName.has(r))throw new Error(`Group name not defined to the left "${t}"`);return Yt(r)}return s(+r)}function Za(t,e,n){const{tokens:r,walk:s}=e,o=e.parent,i=o.body.at(-1),a=r[e.nextIndex];if(!n.isCheckingRangeEnd&&i&&i.type!=="CharacterClass"&&i.type!=="CharacterClassRange"&&a&&a.type!=="CharacterClassOpen"&&a.type!=="CharacterClassClose"&&a.type!=="CharacterClassIntersector"){const l=s(o,{...n,isCheckingRangeEnd:!0});if(i.type==="Character"&&l.type==="Character")return o.body.pop(),rl(i,l);throw new Error("Invalid character class range")}return pt(Ee("-"))}function Qa({negate:t},e,n){const{tokens:r,walk:s}=e,o=[et()],i=r[e.nextIndex];let a=Yn(i);for(;a.type!=="CharacterClassClose";){if(a.type==="CharacterClassIntersector")o.push(et()),e.nextIndex++;else{const c=o.at(-1);c.body.push(s(c,n))}a=Yn(r[e.nextIndex],i)}const l=et({negate:t});return o.length===1?l.body=o[0].body:(l.kind="intersection",l.body=o.map(c=>c.body.length===1?c.body[0]:c)),e.nextIndex++,l}function Ya({kind:t,negate:e,value:n},r){const{normalizeUnknownPropertyNames:s,skipPropertyNameValidation:o,unicodePropertyMap:i}=r;if(t==="property"){const a=gt(n);if(mn.has(a)&&!i?.has(a))t="posix",n=a;else return we(n,{negate:e,normalizeUnknownPropertyNames:s,skipPropertyNameValidation:o,unicodePropertyMap:i})}return t==="posix"?al(n,{negate:e}):Jt(t,{negate:e})}function Ja(t,e,n){const{tokens:r,capturingGroups:s,namedGroupsByName:o,skipLookbehindValidation:i,walk:a}=e,l=cl(t),c=l.type==="AbsenceFunction",u=Qn(l),f=u&&l.negate;if(l.type==="CapturingGroup"&&(s.push(l),l.name&&Sa(o,l.name,[]).push(l)),c&&n.isInAbsenceFunction)throw new Error("Nested absence function not supported by Oniguruma");let h=Jn(r[e.nextIndex]);for(;h.type!=="GroupClose";){if(h.type==="Alternator")l.body.push(he()),e.nextIndex++;else{const d=l.body.at(-1),p=a(d,{...n,isInAbsenceFunction:n.isInAbsenceFunction||c,isInLookbehind:n.isInLookbehind||u,isInNegLookbehind:n.isInNegLookbehind||f});if(d.body.push(p),(u||n.isInLookbehind)&&!i){const b="Lookbehind includes a pattern not allowed by Oniguruma";if(f||n.isInNegLookbehind){if(Zn(p)||p.type==="CapturingGroup")throw new Error(b)}else if(Zn(p)||Qn(p)&&p.negate)throw new Error(b)}}h=Jn(r[e.nextIndex])}return e.nextIndex++,l}function el({kind:t,min:e,max:n},r){const s=r.parent,o=s.body.at(-1);if(!o||!qa(o))throw new Error("Quantifier requires a repeatable token");const i=cs(t,e,n,o);return s.body.pop(),i}function tl({raw:t},e){const{capturingGroups:n,subroutines:r}=e;let s=t.slice(3,-1);const o=/^(?<sign>[-+]?)0*(?<num>[1-9]\d*)$/.exec(s);if(o){const a=+o.groups.num,l=n.length;if(e.hasNumberedRef=!0,s={"":a,"+":l+a,"-":l+1-a}[o.groups.sign],s<1)throw new Error("Invalid subroutine number")}else s==="0"&&(s=0);const i=us(s);return r.push(i),i}function nl(t,e){return{type:"AbsenceFunction",kind:t,body:je(e?.body)}}function he(t){return{type:"Alternative",body:fs(t?.body)}}function Qt(t,e){const n={type:"Assertion",kind:t};return(t==="word_boundary"||t==="text_segment_boundary")&&(n.negate=!!e?.negate),n}function Yt(t,e){const n=!!e?.orphan;return{type:"Backreference",ref:t,...n&&{orphan:n}}}function ls(t,e){const n={name:void 0,isSubroutined:!1,...e};if(n.name!==void 0&&!ul(n.name))throw new Error(`Group name "${n.name}" invalid in Oniguruma`);return{type:"CapturingGroup",number:t,...n.name&&{name:n.name},...n.isSubroutined&&{isSubroutined:n.isSubroutined},body:je(e?.body)}}function pt(t,e){const n={useLastValid:!1,...e};if(t>1114111){const r=t.toString(16);if(n.useLastValid)t=1114111;else throw t>1310719?new Error(`Invalid code point out of range "\\x{${r}}"`):new Error(`Invalid code point out of range in JS "\\x{${r}}"`)}return{type:"Character",value:t}}function et(t){const e={kind:"union",negate:!1,...t};return{type:"CharacterClass",kind:e.kind,negate:e.negate,body:fs(t?.body)}}function rl(t,e){if(e.value<t.value)throw new Error("Character class range out of order");return{type:"CharacterClassRange",min:t,max:e}}function Jt(t,e){const n=!!e?.negate,r={type:"CharacterSet",kind:t};return(t==="digit"||t==="hex"||t==="newline"||t==="space"||t==="word")&&(r.negate=n),(t==="text_segment"||t==="newline"&&!n)&&(r.variableLength=!0),r}function sl(t,e={}){if(t==="keep")return{type:"Directive",kind:t};if(t==="flags")return{type:"Directive",kind:t,flags:Ae(e.flags)};throw new Error(`Unexpected directive kind "${t}"`)}function ol(t){return{type:"Flags",...t}}function Z(t){const e=t?.atomic,n=t?.flags;if(e&&n)throw new Error("Atomic group cannot have flags");return{type:"Group",...e&&{atomic:e},...n&&{flags:n},body:je(t?.body)}}function ce(t){const e={behind:!1,negate:!1,...t};return{type:"LookaroundAssertion",kind:e.behind?"lookbehind":"lookahead",negate:e.negate,body:je(t?.body)}}function il(t,e,n){return{type:"NamedCallout",kind:t,tag:e,arguments:n}}function al(t,e){const n=!!e?.negate;if(!mn.has(t))throw new Error(`Invalid POSIX class "${t}"`);return{type:"CharacterSet",kind:"posix",value:t,negate:n}}function cs(t,e,n,r){if(e>n)throw new Error("Invalid reversed quantifier range");return{type:"Quantifier",kind:t,min:e,max:n,body:r}}function ll(t,e){return{type:"Regex",body:je(e?.body),flags:t}}function us(t){return{type:"Subroutine",ref:t}}function we(t,e){const n={negate:!1,normalizeUnknownPropertyNames:!1,skipPropertyNameValidation:!1,unicodePropertyMap:null,...e};let r=n.unicodePropertyMap?.get(gt(t));if(!r){if(n.normalizeUnknownPropertyNames)r=fl(t);else if(n.unicodePropertyMap&&!n.skipPropertyNameValidation)throw new Error(B`Invalid Unicode property "\p{${t}}"`)}return{type:"CharacterSet",kind:"property",value:r??t,negate:n.negate}}function cl({flags:t,kind:e,name:n,negate:r,number:s}){switch(e){case"absence_repeater":return nl("repeater");case"atomic":return Z({atomic:!0});case"capturing":return ls(s,{name:n});case"group":return Z({flags:t});case"lookahead":case"lookbehind":return ce({behind:e==="lookbehind",negate:r});default:throw new Error(`Unexpected group kind "${e}"`)}}function je(t){if(t===void 0)t=[he()];else if(!Array.isArray(t)||!t.length||!t.every(e=>e.type==="Alternative"))throw new Error("Invalid body; expected array of one or more Alternative nodes");return t}function fs(t){if(t===void 0)t=[];else if(!Array.isArray(t)||!t.every(e=>!!e.type))throw new Error("Invalid body; expected array of nodes");return t}function Zn(t){return t.type==="LookaroundAssertion"&&t.kind==="lookahead"}function Qn(t){return t.type==="LookaroundAssertion"&&t.kind==="lookbehind"}function ul(t){return/^[\p{Alpha}\p{Pc}][^)]*$/u.test(t)}function fl(t){return t.trim().replace(/[- _]+/g,"_").replace(/[A-Z][a-z]+(?=[A-Z])/g,"$&_").replace(/[A-Za-z]+/g,e=>e[0].toUpperCase()+e.slice(1).toLowerCase())}function gt(t){return t.replace(/[- _]+/g,"").toLowerCase()}function Yn(t,e){const n=e;return Ae(t,`Unclosed character class${n?.type==="Character"&&n.value===93&&n.raw==="]"?' (started with "]")':""}`)}function Jn(t){return Ae(t,"Unclosed group")}function $e(t,e,n=null){function r(o,i){for(let a=0;a<o.length;a++){const l=s(o[a],i,a,o);a=Math.max(-1,a+l)}}function s(o,i=null,a=null,l=null){let c=0,u=!1;const f={node:o,parent:i,key:a,container:l,root:t,remove(){Xe(l).splice(Math.max(0,ge(a)+c),1),c--,u=!0},removeAllNextSiblings(){return Xe(l).splice(ge(a)+1)},removeAllPrevSiblings(){const y=ge(a)+c;return c-=y,Xe(l).splice(0,Math.max(0,y))},replaceWith(y,m={}){const g=!!m.traverse;l?l[Math.max(0,ge(a)+c)]=y:Ae(i,"Can't replace root node")[a]=y,g&&s(y,i,a,l),u=!0},replaceWithMultiple(y,m={}){const g=!!m.traverse;if(Xe(l).splice(Math.max(0,ge(a)+c),1,...y),c+=y.length-1,g){let S=0;for(let k=0;k<y.length;k++)S+=s(y[k],i,ge(a)+k+S,l)}u=!0},skip(){u=!0}},{type:h}=o,d=e["*"],p=e[h],b=typeof d=="function"?d:d?.enter,w=typeof p=="function"?p:p?.enter;if(b?.(f,n),w?.(f,n),!u)switch(h){case"AbsenceFunction":case"Alternative":case"CapturingGroup":case"CharacterClass":case"Group":case"LookaroundAssertion":r(o.body,o);break;case"Assertion":case"Backreference":case"Character":case"CharacterSet":case"Directive":case"Flags":case"NamedCallout":case"Subroutine":break;case"CharacterClassRange":s(o.min,o,"min"),s(o.max,o,"max");break;case"Quantifier":s(o.body,o,"body");break;case"Regex":r(o.body,o),s(o.flags,o,"flags");break;default:throw new Error(`Unexpected node type "${h}"`)}return p?.exit?.(f,n),d?.exit?.(f,n),c}return s(t),t}function Xe(t){if(!Array.isArray(t))throw new Error("Container expected");return t}function ge(t){if(typeof t!="number")throw new Error("Numeric key expected");return t}const hl=String.raw`\(\?(?:[:=!>A-Za-z\-]|<[=!]|\(DEFINE\))`;function dl(t,e){for(let n=0;n<t.length;n++)t[n]>=e&&t[n]++}function pl(t,e,n,r){return t.slice(0,e)+r+t.slice(e+n.length)}const X=Object.freeze({DEFAULT:"DEFAULT",CHAR_CLASS:"CHAR_CLASS"});function bn(t,e,n,r){const s=new RegExp(String.raw`${e}|(?<$skip>\[\^?|\\?.)`,"gsu"),o=[!1];let i=0,a="";for(const l of t.matchAll(s)){const{0:c,groups:{$skip:u}}=l;if(!u&&(!r||r===X.DEFAULT==!i)){n instanceof Function?a+=n(l,{context:i?X.CHAR_CLASS:X.DEFAULT,negated:o[o.length-1]}):a+=n;continue}c[0]==="["?(i++,o.push(c[1]==="^")):c==="]"&&i&&(i--,o.pop()),a+=c}return a}function hs(t,e,n,r){bn(t,e,n,r)}function gl(t,e,n=0,r){if(!new RegExp(e,"su").test(t))return null;const s=new RegExp(`${e}|(?<$skip>\\\\?.)`,"gsu");s.lastIndex=n;let o=0,i;for(;i=s.exec(t);){const{0:a,groups:{$skip:l}}=i;if(!l&&(!r||r===X.DEFAULT==!o))return i;a==="["?o++:a==="]"&&o&&o--,s.lastIndex==i.index&&s.lastIndex++}return null}function Ke(t,e,n){return!!gl(t,e,0,n)}function ml(t,e){const n=/\\?./gsu;n.lastIndex=e;let r=t.length,s=0,o=1,i;for(;i=n.exec(t);){const[a]=i;if(a==="[")s++;else if(s)a==="]"&&s--;else if(a==="(")o++;else if(a===")"&&(o--,!o)){r=i.index;break}}return t.slice(e,r)}const er=new RegExp(String.raw`(?<noncapturingStart>${hl})|(?<capturingStart>\((?:\?<[^>]+>)?)|\\?.`,"gsu");function yl(t,e){const n=e?.hiddenCaptures??[];let r=e?.captureTransfers??new Map;if(!/\(\?>/.test(t))return{pattern:t,captureTransfers:r,hiddenCaptures:n};const s="(?>",o="(?:(?=(",i=[0],a=[];let l=0,c=0,u=NaN,f;do{f=!1;let h=0,d=0,p=!1,b;for(er.lastIndex=Number.isNaN(u)?0:u+o.length;b=er.exec(t);){const{0:w,index:y,groups:{capturingStart:m,noncapturingStart:g}}=b;if(w==="[")h++;else if(h)w==="]"&&h--;else if(w===s&&!p)u=y,p=!0;else if(p&&g)d++;else if(m)p?d++:(l++,i.push(l+c));else if(w===")"&&p){if(!d){c++;const S=l+c;if(t=`${t.slice(0,u)}${o}${t.slice(u+s.length,y)}))<$$${S}>)${t.slice(y+1)}`,f=!0,a.push(S),dl(n,S),r.size){const k=new Map;r.forEach((_,x)=>{k.set(x>=S?x+1:x,_.map(v=>v>=S?v+1:v))}),r=k}break}d--}}}while(f);return n.push(...a),t=bn(t,String.raw`\\(?<backrefNum>[1-9]\d*)|<\$\$(?<wrappedBackrefNum>\d+)>`,({0:h,groups:{backrefNum:d,wrappedBackrefNum:p}})=>{if(d){const b=+d;if(b>i.length-1)throw new Error(`Backref "${h}" greater than number of captures`);return`\\${i[b]}`}return`\\${p}`},X.DEFAULT),{pattern:t,captureTransfers:r,hiddenCaptures:n}}const ds=String.raw`(?:[?*+]|\{\d+(?:,\d*)?\})`,Rt=new RegExp(String.raw`
45
+ \\(?: \d+
46
+ | c[A-Za-z]
47
+ | [gk]<[^>]+>
48
+ | [pPu]\{[^\}]+\}
49
+ | u[A-Fa-f\d]{4}
50
+ | x[A-Fa-f\d]{2}
51
+ )
52
+ | \((?: \? (?: [:=!>]
53
+ | <(?:[=!]|[^>]+>)
54
+ | [A-Za-z\-]+:
55
+ | \(DEFINE\)
56
+ ))?
57
+ | (?<qBase>${ds})(?<qMod>[?+]?)(?<invalidQ>[?*+\{]?)
58
+ | \\?.
59
+ `.replace(/\s+/g,""),"gsu");function bl(t){if(!new RegExp(`${ds}\\+`).test(t))return{pattern:t};const e=[];let n=null,r=null,s="",o=0,i;for(Rt.lastIndex=0;i=Rt.exec(t);){const{0:a,index:l,groups:{qBase:c,qMod:u,invalidQ:f}}=i;if(a==="[")o||(r=l),o++;else if(a==="]")o?o--:r=null;else if(!o)if(u==="+"&&s&&!s.startsWith("(")){if(f)throw new Error(`Invalid quantifier "${a}"`);let h=-1;if(/^\{\d+\}$/.test(c))t=pl(t,l+c.length,u,"");else{if(s===")"||s==="]"){const d=s===")"?n:r;if(d===null)throw new Error(`Invalid unmatched "${s}"`);t=`${t.slice(0,d)}(?>${t.slice(d,l)}${c})${t.slice(l+a.length)}`}else t=`${t.slice(0,l-s.length)}(?>${s}${c})${t.slice(l+a.length)}`;h+=4}Rt.lastIndex+=h}else a[0]==="("?e.push(l):a===")"&&(n=e.length?e.pop():null);s=a}return{pattern:t}}const V=String.raw,wl=V`\\g<(?<gRNameOrNum>[^>&]+)&R=(?<gRDepth>[^>]+)>`,en=V`\(\?R=(?<rDepth>[^\)]+)\)|${wl}`,mt=V`\(\?<(?![=!])(?<captureName>[^>]+)>`,ps=V`${mt}|(?<unnamed>\()(?!\?)`,ae=new RegExp(V`${mt}|${en}|\(\?|\\?.`,"gsu"),Nt="Cannot use multiple overlapping recursions";function Cl(t,e){const{hiddenCaptures:n,mode:r}={hiddenCaptures:[],mode:"plugin",...e};let s=e?.captureTransfers??new Map;if(!new RegExp(en,"su").test(t))return{pattern:t,captureTransfers:s,hiddenCaptures:n};if(r==="plugin"&&Ke(t,V`\(\?\(DEFINE\)`,X.DEFAULT))throw new Error("DEFINE groups cannot be used with recursion");const o=[],i=Ke(t,V`\\[1-9]`,X.DEFAULT),a=new Map,l=[];let c=!1,u=0,f=0,h;for(ae.lastIndex=0;h=ae.exec(t);){const{0:d,groups:{captureName:p,rDepth:b,gRNameOrNum:w,gRDepth:y}}=h;if(d==="[")u++;else if(u)d==="]"&&u--;else if(b){if(tr(b),c)throw new Error(Nt);if(i)throw new Error(`${r==="external"?"Backrefs":"Numbered backrefs"} cannot be used with global recursion`);const m=t.slice(0,h.index),g=t.slice(ae.lastIndex);if(Ke(g,en,X.DEFAULT))throw new Error(Nt);const S=+b-1;t=nr(m,g,S,!1,n,o,f),s=sr(s,m,S,o.length,0,f);break}else if(w){tr(y);let m=!1;for(const A of l)if(A.name===w||A.num===+w){if(m=!0,A.hasRecursedWithin)throw new Error(Nt);break}if(!m)throw new Error(V`Recursive \g cannot be used outside the referenced group "${r==="external"?w:V`\g<${w}&R=${y}>`}"`);const g=a.get(w),S=ml(t,g);if(i&&Ke(S,V`${mt}|\((?!\?)`,X.DEFAULT))throw new Error(`${r==="external"?"Backrefs":"Numbered backrefs"} cannot be used with recursion of capturing groups`);const k=t.slice(g,h.index),_=S.slice(k.length+d.length),x=o.length,v=+y-1,N=nr(k,_,v,!0,n,o,f);s=sr(s,k,v,o.length-x,x,f);const L=t.slice(0,g),F=t.slice(g+S.length);t=`${L}${N}${F}`,ae.lastIndex+=N.length-d.length-k.length-_.length,l.forEach(A=>A.hasRecursedWithin=!0),c=!0}else if(p)f++,a.set(String(f),ae.lastIndex),a.set(p,ae.lastIndex),l.push({num:f,name:p});else if(d[0]==="("){const m=d==="(";m&&(f++,a.set(String(f),ae.lastIndex)),l.push(m?{num:f}:{})}else d===")"&&l.pop()}return n.push(...o),{pattern:t,captureTransfers:s,hiddenCaptures:n}}function tr(t){const e=`Max depth must be integer between 2 and 100; used ${t}`;if(!/^[1-9]\d*$/.test(t))throw new Error(e);if(t=+t,t<2||t>100)throw new Error(e)}function nr(t,e,n,r,s,o,i){const a=new Set;r&&hs(t+e,mt,({groups:{captureName:c}})=>{a.add(c)},X.DEFAULT);const l=[n,r?a:null,s,o,i];return`${t}${rr(`(?:${t}`,"forward",...l)}(?:)${rr(`${e})`,"backward",...l)}${e}`}function rr(t,e,n,r,s,o,i){const l=u=>e==="forward"?u+2:n-u+2-1;let c="";for(let u=0;u<n;u++){const f=l(u);c+=bn(t,V`${ps}|\\k<(?<backref>[^>]+)>`,({0:h,groups:{captureName:d,unnamed:p,backref:b}})=>{if(b&&r&&!r.has(b))return h;const w=`_$${f}`;if(p||d){const y=i+o.length+1;return o.push(y),_l(s,y),p?h:`(?<${d}${w}>`}return V`\k<${b}${w}>`},X.DEFAULT)}return c}function _l(t,e){for(let n=0;n<t.length;n++)t[n]>=e&&t[n]++}function sr(t,e,n,r,s,o){if(t.size&&r){let i=0;hs(e,ps,()=>i++,X.DEFAULT);const a=o-i+s,l=new Map;return t.forEach((c,u)=>{const f=(r-i*n)/n,h=i*n,d=u>a+i?u+r:u,p=[];for(const b of c)if(b<=a)p.push(b);else if(b>a+i+f)p.push(b+r);else if(b<=a+i)for(let w=0;w<=n;w++)p.push(b+i*w);else for(let w=0;w<=n;w++)p.push(b+h+f*w);l.set(d,p)}),l}return t}var T=String.fromCodePoint,I=String.raw,Q={},yt=globalThis.RegExp;Q.flagGroups=(()=>{try{new yt("(?i:)")}catch{return!1}return!0})();Q.unicodeSets=(()=>{try{new yt("[[]]","v")}catch{return!1}return!0})();Q.bugFlagVLiteralHyphenIsRange=Q.unicodeSets?(()=>{try{new yt(I`[\d\-a]`,"v")}catch{return!0}return!1})():!1;Q.bugNestedClassIgnoresNegation=Q.unicodeSets&&new yt("[[^a]]","v").test("a");function ft(t,{enable:e,disable:n}){return{dotAll:!n?.dotAll&&!!(e?.dotAll||t.dotAll),ignoreCase:!n?.ignoreCase&&!!(e?.ignoreCase||t.ignoreCase)}}function Ge(t,e,n){return t.has(e)||t.set(e,n),t.get(e)}function tn(t,e){return or[t]>=or[e]}function Sl(t,e){if(t==null)throw new Error(e??"Value expected");return t}var or={ES2025:2025,ES2024:2024,ES2018:2018},kl={auto:"auto",ES2025:"ES2025",ES2024:"ES2024",ES2018:"ES2018"};function gs(t={}){if({}.toString.call(t)!=="[object Object]")throw new Error("Unexpected options");if(t.target!==void 0&&!kl[t.target])throw new Error(`Unexpected target "${t.target}"`);const e={accuracy:"default",avoidSubclass:!1,flags:"",global:!1,hasIndices:!1,lazyCompileLength:1/0,target:"auto",verbose:!1,...t,rules:{allowOrphanBackrefs:!1,asciiWordBoundaries:!1,captureGroup:!1,recursionLimit:20,singleline:!1,...t.rules}};return e.target==="auto"&&(e.target=Q.flagGroups?"ES2025":Q.unicodeSets?"ES2024":"ES2018"),e}var xl="[ -\r ]",vl=new Set([T(304),T(305)]),ee=I`[\p{L}\p{M}\p{N}\p{Pc}]`;function ms(t){if(vl.has(t))return[t];const e=new Set,n=t.toLowerCase(),r=n.toUpperCase(),s=Al.get(n),o=Il.get(n),i=El.get(n);return[...r].length===1&&e.add(r),i&&e.add(i),s&&e.add(s),e.add(n),o&&e.add(o),[...e]}var wn=new Map(`C Other
60
+ Cc Control cntrl
61
+ Cf Format
62
+ Cn Unassigned
63
+ Co Private_Use
64
+ Cs Surrogate
65
+ L Letter
66
+ LC Cased_Letter
67
+ Ll Lowercase_Letter
68
+ Lm Modifier_Letter
69
+ Lo Other_Letter
70
+ Lt Titlecase_Letter
71
+ Lu Uppercase_Letter
72
+ M Mark Combining_Mark
73
+ Mc Spacing_Mark
74
+ Me Enclosing_Mark
75
+ Mn Nonspacing_Mark
76
+ N Number
77
+ Nd Decimal_Number digit
78
+ Nl Letter_Number
79
+ No Other_Number
80
+ P Punctuation punct
81
+ Pc Connector_Punctuation
82
+ Pd Dash_Punctuation
83
+ Pe Close_Punctuation
84
+ Pf Final_Punctuation
85
+ Pi Initial_Punctuation
86
+ Po Other_Punctuation
87
+ Ps Open_Punctuation
88
+ S Symbol
89
+ Sc Currency_Symbol
90
+ Sk Modifier_Symbol
91
+ Sm Math_Symbol
92
+ So Other_Symbol
93
+ Z Separator
94
+ Zl Line_Separator
95
+ Zp Paragraph_Separator
96
+ Zs Space_Separator
97
+ ASCII
98
+ ASCII_Hex_Digit AHex
99
+ Alphabetic Alpha
100
+ Any
101
+ Assigned
102
+ Bidi_Control Bidi_C
103
+ Bidi_Mirrored Bidi_M
104
+ Case_Ignorable CI
105
+ Cased
106
+ Changes_When_Casefolded CWCF
107
+ Changes_When_Casemapped CWCM
108
+ Changes_When_Lowercased CWL
109
+ Changes_When_NFKC_Casefolded CWKCF
110
+ Changes_When_Titlecased CWT
111
+ Changes_When_Uppercased CWU
112
+ Dash
113
+ Default_Ignorable_Code_Point DI
114
+ Deprecated Dep
115
+ Diacritic Dia
116
+ Emoji
117
+ Emoji_Component EComp
118
+ Emoji_Modifier EMod
119
+ Emoji_Modifier_Base EBase
120
+ Emoji_Presentation EPres
121
+ Extended_Pictographic ExtPict
122
+ Extender Ext
123
+ Grapheme_Base Gr_Base
124
+ Grapheme_Extend Gr_Ext
125
+ Hex_Digit Hex
126
+ IDS_Binary_Operator IDSB
127
+ IDS_Trinary_Operator IDST
128
+ ID_Continue IDC
129
+ ID_Start IDS
130
+ Ideographic Ideo
131
+ Join_Control Join_C
132
+ Logical_Order_Exception LOE
133
+ Lowercase Lower
134
+ Math
135
+ Noncharacter_Code_Point NChar
136
+ Pattern_Syntax Pat_Syn
137
+ Pattern_White_Space Pat_WS
138
+ Quotation_Mark QMark
139
+ Radical
140
+ Regional_Indicator RI
141
+ Sentence_Terminal STerm
142
+ Soft_Dotted SD
143
+ Terminal_Punctuation Term
144
+ Unified_Ideograph UIdeo
145
+ Uppercase Upper
146
+ Variation_Selector VS
147
+ White_Space space
148
+ XID_Continue XIDC
149
+ XID_Start XIDS`.split(/\s/).map(t=>[gt(t),t])),Il=new Map([["s",T(383)],[T(383),"s"]]),El=new Map([[T(223),T(7838)],[T(107),T(8490)],[T(229),T(8491)],[T(969),T(8486)]]),Al=new Map([se(453),se(456),se(459),se(498),...Pt(8072,8079),...Pt(8088,8095),...Pt(8104,8111),se(8124),se(8140),se(8188)]),Ll=new Map([["alnum",I`[\p{Alpha}\p{Nd}]`],["alpha",I`\p{Alpha}`],["ascii",I`\p{ASCII}`],["blank",I`[\p{Zs}\t]`],["cntrl",I`\p{Cc}`],["digit",I`\p{Nd}`],["graph",I`[\P{space}&&\P{Cc}&&\P{Cn}&&\P{Cs}]`],["lower",I`\p{Lower}`],["print",I`[[\P{space}&&\P{Cc}&&\P{Cn}&&\P{Cs}]\p{Zs}]`],["punct",I`[\p{P}\p{S}]`],["space",I`\p{space}`],["upper",I`\p{Upper}`],["word",I`[\p{Alpha}\p{M}\p{Nd}\p{Pc}]`],["xdigit",I`\p{AHex}`]]);function Rl(t,e){const n=[];for(let r=t;r<=e;r++)n.push(r);return n}function se(t){const e=T(t);return[e.toLowerCase(),e]}function Pt(t,e){return Rl(t,e).map(n=>se(n))}var ys=new Set(["Lower","Lowercase","Upper","Uppercase","Ll","Lowercase_Letter","Lt","Titlecase_Letter","Lu","Uppercase_Letter"]);function Nl(t,e){const n={accuracy:"default",asciiWordBoundaries:!1,avoidSubclass:!1,bestEffortTarget:"ES2025",...e};bs(t);const r={accuracy:n.accuracy,asciiWordBoundaries:n.asciiWordBoundaries,avoidSubclass:n.avoidSubclass,flagDirectivesByAlt:new Map,jsGroupNameMap:new Map,minTargetEs2024:tn(n.bestEffortTarget,"ES2024"),passedLookbehind:!1,strategy:null,subroutineRefMap:new Map,supportedGNodes:new Set,digitIsAscii:t.flags.digitIsAscii,spaceIsAscii:t.flags.spaceIsAscii,wordIsAscii:t.flags.wordIsAscii};$e(t,Pl,r);const s={dotAll:t.flags.dotAll,ignoreCase:t.flags.ignoreCase},o={currentFlags:s,prevFlags:null,globalFlags:s,groupOriginByCopy:new Map,groupsByName:new Map,multiplexCapturesToLeftByRef:new Map,openRefs:new Map,reffedNodesByReferencer:new Map,subroutineRefMap:r.subroutineRefMap};$e(t,$l,o);const i={groupsByName:o.groupsByName,highestOrphanBackref:0,numCapturesToLeft:0,reffedNodesByReferencer:o.reffedNodesByReferencer};return $e(t,Tl,i),t._originMap=o.groupOriginByCopy,t._strategy=r.strategy,t}var Pl={AbsenceFunction({node:t,parent:e,replaceWith:n}){const{body:r,kind:s}=t;if(s==="repeater"){const o=Z();o.body[0].body.push(ce({negate:!0,body:r}),we("Any"));const i=Z();i.body[0].body.push(cs("greedy",0,1/0,o)),n(P(i,e),{traverse:!0})}else throw new Error('Unsupported absence function "(?~|"')},Alternative:{enter({node:t,parent:e,key:n},{flagDirectivesByAlt:r}){const s=t.body.filter(o=>o.kind==="flags");for(let o=n+1;o<e.body.length;o++){const i=e.body[o];Ge(r,i,[]).push(...s)}},exit({node:t},{flagDirectivesByAlt:e}){if(e.get(t)?.length){const n=Cs(e.get(t));if(n){const r=Z({flags:n});r.body[0].body=t.body,t.body=[P(r,t)]}}}},Assertion({node:t,parent:e,key:n,container:r,root:s,remove:o,replaceWith:i},a){const{kind:l,negate:c}=t,{asciiWordBoundaries:u,avoidSubclass:f,supportedGNodes:h,wordIsAscii:d}=a;if(l==="text_segment_boundary")throw new Error(`Unsupported text segment boundary "\\${c?"Y":"y"}"`);if(l==="line_end")i(P(ce({body:[he({body:[Qt("string_end")]}),he({body:[pt(10)]})]}),e));else if(l==="line_start")i(P(te(I`(?<=\A|\n(?!\z))`,{skipLookbehindValidation:!0}),e));else if(l==="search_start")if(h.has(t))s.flags.sticky=!0,o();else{const p=r[n-1];if(p&&Fl(p))i(P(ce({negate:!0}),e));else{if(f)throw new Error(I`Uses "\G" in a way that requires a subclass`);i(oe(Qt("string_start"),e)),a.strategy="clip_search"}}else if(!(l==="string_end"||l==="string_start"))if(l==="string_end_newline")i(P(te(I`(?=\n?\z)`),e));else if(l==="word_boundary"){if(!d&&!u){const p=`(?:(?<=${ee})(?!${ee})|(?<!${ee})(?=${ee}))`,b=`(?:(?<=${ee})(?=${ee})|(?<!${ee})(?!${ee}))`;i(P(te(c?b:p),e))}}else throw new Error(`Unexpected assertion kind "${l}"`)},Backreference({node:t},{jsGroupNameMap:e}){let{ref:n}=t;typeof n=="string"&&!Tt(n)&&(n=$t(n,e),t.ref=n)},CapturingGroup({node:t},{jsGroupNameMap:e,subroutineRefMap:n}){let{name:r}=t;r&&!Tt(r)&&(r=$t(r,e),t.name=r),n.set(t.number,t),r&&n.set(r,t)},CharacterClassRange({node:t,parent:e,replaceWith:n}){if(e.kind==="intersection"){const r=et({body:[t]});n(P(r,e),{traverse:!0})}},CharacterSet({node:t,parent:e,replaceWith:n},{accuracy:r,minTargetEs2024:s,digitIsAscii:o,spaceIsAscii:i,wordIsAscii:a}){const{kind:l,negate:c,value:u}=t;if(o&&(l==="digit"||u==="digit")){n(oe(Jt("digit",{negate:c}),e));return}if(i&&(l==="space"||u==="space")){n(P(Mt(te(xl),c),e));return}if(a&&(l==="word"||u==="word")){n(oe(Jt("word",{negate:c}),e));return}if(l==="any")n(oe(we("Any"),e));else if(l==="digit")n(oe(we("Nd",{negate:c}),e));else if(l!=="dot")if(l==="text_segment"){if(r==="strict")throw new Error(I`Use of "\X" requires non-strict accuracy`);const f="\\p{Emoji}(?:\\p{EMod}|\\uFE0F\\u20E3?|[\\x{E0020}-\\x{E007E}]+\\x{E007F})?",h=I`\p{RI}{2}|${f}(?:\u200D${f})*`;n(P(te(I`(?>\r\n|${s?I`\p{RGI_Emoji}`:h}|\P{M}\p{M}*)`,{skipPropertyNameValidation:!0}),e))}else if(l==="hex")n(oe(we("AHex",{negate:c}),e));else if(l==="newline")n(P(te(c?`[^
150
+ ]`:`(?>\r
151
+ ?|[
152
+ \v\f…\u2028\u2029])`),e));else if(l==="posix")if(!s&&(u==="graph"||u==="print")){if(r==="strict")throw new Error(`POSIX class "${u}" requires min target ES2024 or non-strict accuracy`);let f={graph:"!-~",print:" -~"}[u];c&&(f=`\0-${T(f.codePointAt(0)-1)}${T(f.codePointAt(2)+1)}-􏿿`),n(P(te(`[${f}]`),e))}else n(P(Mt(te(Ll.get(u)),c),e));else if(l==="property")wn.has(gt(u))||(t.key="sc");else if(l==="space")n(oe(we("space",{negate:c}),e));else if(l==="word")n(P(Mt(te(ee),c),e));else throw new Error(`Unexpected character set kind "${l}"`)},Directive({node:t,parent:e,root:n,remove:r,replaceWith:s,removeAllPrevSiblings:o,removeAllNextSiblings:i}){const{kind:a,flags:l}=t;if(a==="flags")if(!l.enable&&!l.disable)r();else{const c=Z({flags:l});c.body[0].body=i(),s(P(c,e),{traverse:!0})}else if(a==="keep"){const c=n.body[0],f=n.body.length===1&&is(c,{type:"Group"})&&c.body[0].body.length===1?c.body[0]:n;if(e.parent!==f||f.body.length>1)throw new Error(I`Uses "\K" in a way that's unsupported`);const h=ce({behind:!0});h.body[0].body=o(),s(P(h,e))}else throw new Error(`Unexpected directive kind "${a}"`)},Flags({node:t,parent:e}){if(t.posixIsAscii)throw new Error('Unsupported flag "P"');if(t.textSegmentMode==="word")throw new Error('Unsupported flag "y{w}"');["digitIsAscii","extended","posixIsAscii","spaceIsAscii","wordIsAscii","textSegmentMode"].forEach(n=>delete t[n]),Object.assign(t,{global:!1,hasIndices:!1,multiline:!1,sticky:t.sticky??!1}),e.options={disable:{x:!0,n:!0},force:{v:!0}}},Group({node:t}){if(!t.flags)return;const{enable:e,disable:n}=t.flags;e?.extended&&delete e.extended,n?.extended&&delete n.extended,e?.dotAll&&n?.dotAll&&delete e.dotAll,e?.ignoreCase&&n?.ignoreCase&&delete e.ignoreCase,e&&!Object.keys(e).length&&delete t.flags.enable,n&&!Object.keys(n).length&&delete t.flags.disable,!t.flags.enable&&!t.flags.disable&&delete t.flags},LookaroundAssertion({node:t},e){const{kind:n}=t;n==="lookbehind"&&(e.passedLookbehind=!0)},NamedCallout({node:t,parent:e,replaceWith:n}){const{kind:r}=t;if(r==="fail")n(P(ce({negate:!0}),e));else throw new Error(`Unsupported named callout "(*${r.toUpperCase()}"`)},Quantifier({node:t}){if(t.body.type==="Quantifier"){const e=Z();e.body[0].body.push(t.body),t.body=P(e,t)}},Regex:{enter({node:t},{supportedGNodes:e}){const n=[];let r=!1,s=!1;for(const o of t.body)if(o.body.length===1&&o.body[0].kind==="search_start")o.body.pop();else{const i=Ss(o.body);i?(r=!0,Array.isArray(i)?n.push(...i):n.push(i)):s=!0}r&&!s&&n.forEach(o=>e.add(o))},exit(t,{accuracy:e,passedLookbehind:n,strategy:r}){if(e==="strict"&&n&&r)throw new Error(I`Uses "\G" in a way that requires non-strict accuracy`)}},Subroutine({node:t},{jsGroupNameMap:e}){let{ref:n}=t;typeof n=="string"&&!Tt(n)&&(n=$t(n,e),t.ref=n)}},$l={Backreference({node:t},{multiplexCapturesToLeftByRef:e,reffedNodesByReferencer:n}){const{orphan:r,ref:s}=t;r||n.set(t,[...e.get(s).map(({node:o})=>o)])},CapturingGroup:{enter({node:t,parent:e,replaceWith:n,skip:r},{groupOriginByCopy:s,groupsByName:o,multiplexCapturesToLeftByRef:i,openRefs:a,reffedNodesByReferencer:l}){const c=s.get(t);if(c&&a.has(t.number)){const f=oe(ir(t.number),e);l.set(f,a.get(t.number)),n(f);return}a.set(t.number,t),i.set(t.number,[]),t.name&&Ge(i,t.name,[]);const u=i.get(t.name??t.number);for(let f=0;f<u.length;f++){const h=u[f];if(c===h.node||c&&c===h.origin||t===h.origin){u.splice(f,1);break}}if(i.get(t.number).push({node:t,origin:c}),t.name&&i.get(t.name).push({node:t,origin:c}),t.name){const f=Ge(o,t.name,new Map);let h=!1;if(c)h=!0;else for(const d of f.values())if(!d.hasDuplicateNameToRemove){h=!0;break}o.get(t.name).set(t,{node:t,hasDuplicateNameToRemove:h})}},exit({node:t},{openRefs:e}){e.get(t.number)===t&&e.delete(t.number)}},Group:{enter({node:t},e){e.prevFlags=e.currentFlags,t.flags&&(e.currentFlags=ft(e.currentFlags,t.flags))},exit(t,e){e.currentFlags=e.prevFlags}},Subroutine({node:t,parent:e,replaceWith:n},r){const{isRecursive:s,ref:o}=t;if(s){let u=e;for(;(u=u.parent)&&!(u.type==="CapturingGroup"&&(u.name===o||u.number===o)););r.reffedNodesByReferencer.set(t,u);return}const i=r.subroutineRefMap.get(o),a=o===0,l=a?ir(0):ws(i,r.groupOriginByCopy,null);let c=l;if(!a){const u=Cs(Dl(i,h=>h.type==="Group"&&!!h.flags)),f=u?ft(r.globalFlags,u):r.globalFlags;Ml(f,r.currentFlags)||(c=Z({flags:Gl(f)}),c.body[0].body.push(l))}n(P(c,e),{traverse:!a})}},Tl={Backreference({node:t,parent:e,replaceWith:n},r){if(t.orphan){r.highestOrphanBackref=Math.max(r.highestOrphanBackref,t.ref);return}const o=r.reffedNodesByReferencer.get(t).filter(i=>Ol(i,t));if(!o.length)n(P(ce({negate:!0}),e));else if(o.length>1){const i=Z({atomic:!0,body:o.reverse().map(a=>he({body:[Yt(a.number)]}))});n(P(i,e))}else t.ref=o[0].number},CapturingGroup({node:t},e){t.number=++e.numCapturesToLeft,t.name&&e.groupsByName.get(t.name).get(t).hasDuplicateNameToRemove&&delete t.name},Regex:{exit({node:t},e){const n=Math.max(e.highestOrphanBackref-e.numCapturesToLeft,0);for(let r=0;r<n;r++){const s=ls();t.body.at(-1).body.push(s)}}},Subroutine({node:t},e){!t.isRecursive||t.ref===0||(t.ref=e.reffedNodesByReferencer.get(t).number)}};function bs(t){$e(t,{"*"({node:e,parent:n}){e.parent=n}})}function Ml(t,e){return t.dotAll===e.dotAll&&t.ignoreCase===e.ignoreCase}function Ol(t,e){let n=e;do{if(n.type==="Regex")return!1;if(n.type==="Alternative")continue;if(n===t)return!1;const r=_s(n.parent);for(const s of r){if(s===n)break;if(s===t||ks(s,t))return!0}}while(n=n.parent);throw new Error("Unexpected path")}function ws(t,e,n,r){const s=Array.isArray(t)?[]:{};for(const[o,i]of Object.entries(t))o==="parent"?s.parent=Array.isArray(n)?r:n:i&&typeof i=="object"?s[o]=ws(i,e,s,n):(o==="type"&&i==="CapturingGroup"&&e.set(s,e.get(t)??t),s[o]=i);return s}function ir(t){const e=us(t);return e.isRecursive=!0,e}function Dl(t,e){const n=[];for(;t=t.parent;)(!e||e(t))&&n.push(t);return n}function $t(t,e){if(e.has(t))return e.get(t);const n=`$${e.size}_${t.replace(/^[^$_\p{IDS}]|[^$\u200C\u200D\p{IDC}]/ug,"_")}`;return e.set(t,n),n}function Cs(t){const e=["dotAll","ignoreCase"],n={enable:{},disable:{}};return t.forEach(({flags:r})=>{e.forEach(s=>{r.enable?.[s]&&(delete n.disable[s],n.enable[s]=!0),r.disable?.[s]&&(n.disable[s]=!0)})}),Object.keys(n.enable).length||delete n.enable,Object.keys(n.disable).length||delete n.disable,n.enable||n.disable?n:null}function Gl({dotAll:t,ignoreCase:e}){const n={};return(t||e)&&(n.enable={},t&&(n.enable.dotAll=!0),e&&(n.enable.ignoreCase=!0)),(!t||!e)&&(n.disable={},!t&&(n.disable.dotAll=!0),!e&&(n.disable.ignoreCase=!0)),n}function _s(t){if(!t)throw new Error("Node expected");const{body:e}=t;return Array.isArray(e)?e:e?[e]:null}function Ss(t){const e=t.find(n=>n.kind==="search_start"||Ul(n,{negate:!1})||!Bl(n));if(!e)return null;if(e.kind==="search_start")return e;if(e.type==="LookaroundAssertion")return e.body[0].body[0];if(e.type==="CapturingGroup"||e.type==="Group"){const n=[];for(const r of e.body){const s=Ss(r.body);if(!s)return null;Array.isArray(s)?n.push(...s):n.push(s)}return n}return null}function ks(t,e){const n=_s(t)??[];for(const r of n)if(r===e||ks(r,e))return!0;return!1}function Bl({type:t}){return t==="Assertion"||t==="Directive"||t==="LookaroundAssertion"}function Fl(t){const e=["Character","CharacterClass","CharacterSet"];return e.includes(t.type)||t.type==="Quantifier"&&t.min&&e.includes(t.body.type)}function Ul(t,e){const n={negate:null,...e};return t.type==="LookaroundAssertion"&&(n.negate===null||t.negate===n.negate)&&t.body.length===1&&is(t.body[0],{type:"Assertion",kind:"search_start"})}function Tt(t){return/^[$_\p{IDS}][$\u200C\u200D\p{IDC}]*$/u.test(t)}function te(t,e){const r=as(t,{...e,unicodePropertyMap:wn}).body;return r.length>1||r[0].body.length>1?Z({body:r}):r[0].body[0]}function Mt(t,e){return t.negate=e,t}function oe(t,e){return t.parent=e,t}function P(t,e){return bs(t),t.parent=e,t}function jl(t,e){const n=gs(e),r=tn(n.target,"ES2024"),s=tn(n.target,"ES2025"),o=n.rules.recursionLimit;if(!Number.isInteger(o)||o<2||o>20)throw new Error("Invalid recursionLimit; use 2-20");let i=null,a=null;if(!s){const d=[t.flags.ignoreCase];$e(t,Wl,{getCurrentModI:()=>d.at(-1),popModI(){d.pop()},pushModI(p){d.push(p)},setHasCasedChar(){d.at(-1)?i=!0:a=!0}})}const l={dotAll:t.flags.dotAll,ignoreCase:!!((t.flags.ignoreCase||i)&&!a)};let c=t;const u={accuracy:n.accuracy,appliedGlobalFlags:l,captureMap:new Map,currentFlags:{dotAll:t.flags.dotAll,ignoreCase:t.flags.ignoreCase},inCharClass:!1,lastNode:c,originMap:t._originMap,recursionLimit:o,useAppliedIgnoreCase:!!(!s&&i&&a),useFlagMods:s,useFlagV:r,verbose:n.verbose};function f(d){return u.lastNode=c,c=d,Sl(zl[d.type],`Unexpected node type "${d.type}"`)(d,u,f)}const h={pattern:t.body.map(f).join("|"),flags:f(t.flags),options:{...t.options}};return r||(delete h.options.force.v,h.options.disable.v=!0,h.options.unicodeSetsPlugin=null),h._captureTransfers=new Map,h._hiddenCaptures=[],u.captureMap.forEach((d,p)=>{d.hidden&&h._hiddenCaptures.push(p),d.transferTo&&Ge(h._captureTransfers,d.transferTo,[]).push(p)}),h}var Wl={"*":{enter({node:t},e){if(lr(t)){const n=e.getCurrentModI();e.pushModI(t.flags?ft({ignoreCase:n},t.flags).ignoreCase:n)}},exit({node:t},e){lr(t)&&e.popModI()}},Backreference(t,e){e.setHasCasedChar()},Character({node:t},e){Cn(T(t.value))&&e.setHasCasedChar()},CharacterClassRange({node:t,skip:e},n){e(),xs(t,{firstOnly:!0}).length&&n.setHasCasedChar()},CharacterSet({node:t},e){t.kind==="property"&&ys.has(t.value)&&e.setHasCasedChar()}},zl={Alternative({body:t},e,n){return t.map(n).join("")},Assertion({kind:t,negate:e}){if(t==="string_end")return"$";if(t==="string_start")return"^";if(t==="word_boundary")return e?I`\B`:I`\b`;throw new Error(`Unexpected assertion kind "${t}"`)},Backreference({ref:t},e){if(typeof t!="number")throw new Error("Unexpected named backref in transformed AST");if(!e.useFlagMods&&e.accuracy==="strict"&&e.currentFlags.ignoreCase&&!e.captureMap.get(t).ignoreCase)throw new Error("Use of case-insensitive backref to case-sensitive group requires target ES2025 or non-strict accuracy");return"\\"+t},CapturingGroup(t,e,n){const{body:r,name:s,number:o}=t,i={ignoreCase:e.currentFlags.ignoreCase},a=e.originMap.get(t);return a&&(i.hidden=!0,o>a.number&&(i.transferTo=a.number)),e.captureMap.set(o,i),`(${s?`?<${s}>`:""}${r.map(n).join("|")})`},Character({value:t},e){const n=T(t),r=me(t,{escDigit:e.lastNode.type==="Backreference",inCharClass:e.inCharClass,useFlagV:e.useFlagV});if(r!==n)return r;if(e.useAppliedIgnoreCase&&e.currentFlags.ignoreCase&&Cn(n)){const s=ms(n);return e.inCharClass?s.join(""):s.length>1?`[${s.join("")}]`:s[0]}return n},CharacterClass(t,e,n){const{kind:r,negate:s,parent:o}=t;let{body:i}=t;if(r==="intersection"&&!e.useFlagV)throw new Error("Use of character class intersection requires min target ES2024");Q.bugFlagVLiteralHyphenIsRange&&e.useFlagV&&i.some(cr)&&(i=[pt(45),...i.filter(c=>!cr(c))]);const a=()=>`[${s?"^":""}${i.map(n).join(r==="intersection"?"&&":"")}]`;if(!e.inCharClass){if((!e.useFlagV||Q.bugNestedClassIgnoresNegation)&&!s){const u=i.filter(f=>f.type==="CharacterClass"&&f.kind==="union"&&f.negate);if(u.length){const f=Z(),h=f.body[0];return f.parent=o,h.parent=f,i=i.filter(d=>!u.includes(d)),t.body=i,i.length?(t.parent=h,h.body.push(t)):f.body.pop(),u.forEach(d=>{const p=he({body:[d]});d.parent=p,p.parent=f,f.body.push(p)}),n(f)}}e.inCharClass=!0;const c=a();return e.inCharClass=!1,c}const l=i[0];if(r==="union"&&!s&&l&&((!e.useFlagV||!e.verbose)&&o.kind==="union"&&!(Q.bugFlagVLiteralHyphenIsRange&&e.useFlagV)||!e.verbose&&o.kind==="intersection"&&i.length===1&&l.type!=="CharacterClassRange"))return i.map(n).join("");if(!e.useFlagV&&o.type==="CharacterClass")throw new Error("Uses nested character class in a way that requires min target ES2024");return a()},CharacterClassRange(t,e){const n=t.min.value,r=t.max.value,s={escDigit:!1,inCharClass:!0,useFlagV:e.useFlagV},o=me(n,s),i=me(r,s),a=new Set;if(e.useAppliedIgnoreCase&&e.currentFlags.ignoreCase){const l=xs(t);Kl(l).forEach(u=>{a.add(Array.isArray(u)?`${me(u[0],s)}-${me(u[1],s)}`:me(u,s))})}return`${o}-${i}${[...a].join("")}`},CharacterSet({kind:t,negate:e,value:n,key:r},s){if(t==="dot")return s.currentFlags.dotAll?s.appliedGlobalFlags.dotAll||s.useFlagMods?".":"[^]":I`[^\n]`;if(t==="digit")return e?I`\D`:I`\d`;if(t==="property"){if(s.useAppliedIgnoreCase&&s.currentFlags.ignoreCase&&ys.has(n))throw new Error(`Unicode property "${n}" can't be case-insensitive when other chars have specific case`);return`${e?I`\P`:I`\p`}{${r?`${r}=`:""}${n}}`}if(t==="word")return e?I`\W`:I`\w`;throw new Error(`Unexpected character set kind "${t}"`)},Flags(t,e){return(e.appliedGlobalFlags.ignoreCase?"i":"")+(t.dotAll?"s":"")+(t.sticky?"y":"")},Group({atomic:t,body:e,flags:n,parent:r},s,o){const i=s.currentFlags;n&&(s.currentFlags=ft(i,n));const a=e.map(o).join("|"),l=!s.verbose&&e.length===1&&r.type!=="Quantifier"&&!t&&(!s.useFlagMods||!n)?a:`(?${Zl(t,n,s.useFlagMods)}${a})`;return s.currentFlags=i,l},LookaroundAssertion({body:t,kind:e,negate:n},r,s){return`(?${`${e==="lookahead"?"":"<"}${n?"!":"="}`}${t.map(s).join("|")})`},Quantifier(t,e,n){return n(t.body)+Ql(t)},Subroutine({isRecursive:t,ref:e},n){if(!t)throw new Error("Unexpected non-recursive subroutine in transformed AST");const r=n.recursionLimit;return e===0?`(?R=${r})`:I`\g<${e}&R=${r}>`}},Hl=new Set(["$","(",")","*","+",".","?","[","\\","]","^","{","|","}"]),ql=new Set(["-","\\","]","^","["]),Vl=new Set(["(",")","-","/","[","\\","]","^","{","|","}","!","#","$","%","&","*","+",",",".",":",";","<","=",">","?","@","`","~"]),ar=new Map([[9,I`\t`],[10,I`\n`],[11,I`\v`],[12,I`\f`],[13,I`\r`],[8232,I`\u2028`],[8233,I`\u2029`],[65279,I`\uFEFF`]]),Xl=new RegExp("^\\p{Cased}$","u");function Cn(t){return Xl.test(t)}function xs(t,e){const n=!!e?.firstOnly,r=t.min.value,s=t.max.value,o=[];if(r<65&&(s===65535||s>=131071)||r===65536&&s>=131071)return o;for(let i=r;i<=s;i++){const a=T(i);if(!Cn(a))continue;const l=ms(a).filter(c=>{const u=c.codePointAt(0);return u<r||u>s});if(l.length&&(o.push(...l),n))break}return o}function me(t,{escDigit:e,inCharClass:n,useFlagV:r}){if(ar.has(t))return ar.get(t);if(t<32||t>126&&t<160||t>262143||e&&Yl(t))return t>255?`\\u{${t.toString(16).toUpperCase()}}`:`\\x${t.toString(16).toUpperCase().padStart(2,"0")}`;const s=n?r?Vl:ql:Hl,o=T(t);return(s.has(o)?"\\":"")+o}function Kl(t){const e=t.map(s=>s.codePointAt(0)).sort((s,o)=>s-o),n=[];let r=null;for(let s=0;s<e.length;s++)e[s+1]===e[s]+1?r??=e[s]:r===null?n.push(e[s]):(n.push([r,e[s]]),r=null);return n}function Zl(t,e,n){if(t)return">";let r="";if(e&&n){const{enable:s,disable:o}=e;r=(s?.ignoreCase?"i":"")+(s?.dotAll?"s":"")+(o?"-":"")+(o?.ignoreCase?"i":"")+(o?.dotAll?"s":"")}return`${r}:`}function Ql({kind:t,max:e,min:n}){let r;return!n&&e===1?r="?":!n&&e===1/0?r="*":n===1&&e===1/0?r="+":n===e?r=`{${n}}`:r=`{${n},${e===1/0?"":e}}`,r+{greedy:"",lazy:"?",possessive:"+"}[t]}function lr({type:t}){return t==="CapturingGroup"||t==="Group"||t==="LookaroundAssertion"}function Yl(t){return t>47&&t<58}function cr({type:t,value:e}){return t==="Character"&&e===45}var Jl=class nn extends RegExp{#t=new Map;#e=null;#r;#n=null;#s=null;rawOptions={};get source(){return this.#r||"(?:)"}constructor(e,n,r){const s=!!r?.lazyCompile;if(e instanceof RegExp){if(r)throw new Error("Cannot provide options when copying a regexp");const o=e;super(o,n),this.#r=o.source,o instanceof nn&&(this.#t=o.#t,this.#n=o.#n,this.#s=o.#s,this.rawOptions=o.rawOptions)}else{const o={hiddenCaptures:[],strategy:null,transfers:[],...r};super(s?"":e,n),this.#r=e,this.#t=tc(o.hiddenCaptures,o.transfers),this.#s=o.strategy,this.rawOptions=r??{}}s||(this.#e=this)}exec(e){if(!this.#e){const{lazyCompile:s,...o}=this.rawOptions;this.#e=new nn(this.#r,this.flags,o)}const n=this.global||this.sticky,r=this.lastIndex;if(this.#s==="clip_search"&&n&&r){this.lastIndex=0;const s=this.#o(e.slice(r));return s&&(ec(s,r,e,this.hasIndices),this.lastIndex+=r),s}return this.#o(e)}#o(e){this.#e.lastIndex=this.lastIndex;const n=super.exec.call(this.#e,e);if(this.lastIndex=this.#e.lastIndex,!n||!this.#t.size)return n;const r=[...n];n.length=1;let s;this.hasIndices&&(s=[...n.indices],n.indices.length=1);const o=[0];for(let i=1;i<r.length;i++){const{hidden:a,transferTo:l}=this.#t.get(i)??{};if(a?o.push(null):(o.push(n.length),n.push(r[i]),this.hasIndices&&n.indices.push(s[i])),l&&r[i]!==void 0){const c=o[l];if(!c)throw new Error(`Invalid capture transfer to "${c}"`);if(n[c]=r[i],this.hasIndices&&(n.indices[c]=s[i]),n.groups){this.#n||(this.#n=nc(this.source));const u=this.#n.get(l);u&&(n.groups[u]=r[i],this.hasIndices&&(n.indices.groups[u]=s[i]))}}}return n}};function ec(t,e,n,r){if(t.index+=e,t.input=n,r){const s=t.indices;for(let i=0;i<s.length;i++){const a=s[i];a&&(s[i]=[a[0]+e,a[1]+e])}const o=s.groups;o&&Object.keys(o).forEach(i=>{const a=o[i];a&&(o[i]=[a[0]+e,a[1]+e])})}}function tc(t,e){const n=new Map;for(const r of t)n.set(r,{hidden:!0});for(const[r,s]of e)for(const o of s)Ge(n,o,{}).transferTo=r;return n}function nc(t){const e=/(?<capture>\((?:\?<(?![=!])(?<name>[^>]+)>|(?!\?)))|\\?./gsu,n=new Map;let r=0,s=0,o;for(;o=e.exec(t);){const{0:i,groups:{capture:a,name:l}}=o;i==="["?r++:r?i==="]"&&r--:a&&(s++,l&&n.set(s,l))}return n}function rc(t,e){const n=sc(t,e);return n.options?new Jl(n.pattern,n.flags,n.options):new RegExp(n.pattern,n.flags)}function sc(t,e){const n=gs(e),r=as(t,{flags:n.flags,normalizeUnknownPropertyNames:!0,rules:{captureGroup:n.rules.captureGroup,singleline:n.rules.singleline},skipBackrefValidation:n.rules.allowOrphanBackrefs,unicodePropertyMap:wn}),s=Nl(r,{accuracy:n.accuracy,asciiWordBoundaries:n.rules.asciiWordBoundaries,avoidSubclass:n.avoidSubclass,bestEffortTarget:n.target}),o=jl(s,n),i=Cl(o.pattern,{captureTransfers:o._captureTransfers,hiddenCaptures:o._hiddenCaptures,mode:"external"}),a=bl(i.pattern),l=yl(a.pattern,{captureTransfers:i.captureTransfers,hiddenCaptures:i.hiddenCaptures}),c={pattern:l.pattern,flags:`${n.hasIndices?"d":""}${n.global?"g":""}${o.flags}${o.options.disable.v?"u":"v"}`};if(n.avoidSubclass){if(n.lazyCompileLength!==1/0)throw new Error("Lazy compilation requires subclass")}else{const u=l.hiddenCaptures.sort((p,b)=>p-b),f=Array.from(l.captureTransfers),h=s._strategy,d=c.pattern.length>=n.lazyCompileLength;(u.length||f.length||h||d)&&(c.options={...u.length&&{hiddenCaptures:u},...f.length&&{transfers:f},...h&&{strategy:h},...d&&{lazyCompile:d}})}return c}const ur=4294967295;class oc{constructor(e,n={}){this.patterns=e,this.options=n;const{forgiving:r=!1,cache:s,regexConstructor:o}=n;if(!o)throw new Error("Option `regexConstructor` is not provided");this.regexps=e.map(i=>{if(typeof i!="string")return i;const a=s?.get(i);if(a){if(a instanceof RegExp)return a;if(r)return null;throw a}try{const l=o(i);return s?.set(i,l),l}catch(l){if(s?.set(i,l),r)return null;throw l}})}regexps;findNextMatchSync(e,n,r){const s=typeof e=="string"?e:e.content,o=[];function i(a,l,c=0){return{index:a,captureIndices:l.indices.map(u=>u==null?{start:ur,end:ur,length:0}:{start:u[0]+c,end:u[1]+c,length:u[1]-u[0]})}}for(let a=0;a<this.regexps.length;a++){const l=this.regexps[a];if(l)try{l.lastIndex=n;const c=l.exec(s);if(!c)continue;if(c.index===n)return i(a,c,0);o.push([a,c,0])}catch(c){if(this.options.forgiving)continue;throw c}}if(o.length){const a=Math.min(...o.map(l=>l[1].index));for(const[l,c,u]of o)if(c.index===a)return i(l,c,u)}return null}}function ic(t,e){return rc(t,{global:!0,hasIndices:!0,lazyCompileLength:3e3,rules:{allowOrphanBackrefs:!0,asciiWordBoundaries:!0,captureGroup:!0,recursionLimit:5,singleline:!0},...e})}function ac(t={}){const e=Object.assign({target:"auto",cache:new Map},t);return e.regexConstructor||=n=>ic(n,{target:e.target}),{createScanner(n){return new oc(n,e)},createString(n){return{content:n}}}}class _n extends Error{constructor(e){super(e),this.name="ShikiError"}}function lc(){return 2147483648}function cc(){return typeof performance<"u"?performance.now():Date.now()}const uc=(t,e)=>t+(e-t%e)%e;async function fc(t){let e,n;const r={};function s(d){n=d,r.HEAPU8=new Uint8Array(d),r.HEAPU32=new Uint32Array(d)}function o(d,p,b){r.HEAPU8.copyWithin(d,p,p+b)}function i(d){try{return e.grow(d-n.byteLength+65535>>>16),s(e.buffer),1}catch{}}function a(d){const p=r.HEAPU8.length;d=d>>>0;const b=lc();if(d>b)return!1;for(let w=1;w<=4;w*=2){let y=p*(1+.2/w);y=Math.min(y,d+100663296);const m=Math.min(b,uc(Math.max(d,y),65536));if(i(m))return!0}return!1}const l=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function c(d,p,b=1024){const w=p+b;let y=p;for(;d[y]&&!(y>=w);)++y;if(y-p>16&&d.buffer&&l)return l.decode(d.subarray(p,y));let m="";for(;p<y;){let g=d[p++];if(!(g&128)){m+=String.fromCharCode(g);continue}const S=d[p++]&63;if((g&224)===192){m+=String.fromCharCode((g&31)<<6|S);continue}const k=d[p++]&63;if((g&240)===224?g=(g&15)<<12|S<<6|k:g=(g&7)<<18|S<<12|k<<6|d[p++]&63,g<65536)m+=String.fromCharCode(g);else{const _=g-65536;m+=String.fromCharCode(55296|_>>10,56320|_&1023)}}return m}function u(d,p){return d?c(r.HEAPU8,d,p):""}const f={emscripten_get_now:cc,emscripten_memcpy_big:o,emscripten_resize_heap:a,fd_write:()=>0};async function h(){const p=await t({env:f,wasi_snapshot_preview1:f});e=p.memory,s(e.buffer),Object.assign(r,p),r.UTF8ToString=u}return await h(),r}var hc=Object.defineProperty,dc=(t,e,n)=>e in t?hc(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,M=(t,e,n)=>dc(t,typeof e!="symbol"?e+"":e,n);let D=null;function pc(t){throw new _n(t.UTF8ToString(t.getLastOnigError()))}class bt{constructor(e){M(this,"utf16Length"),M(this,"utf8Length"),M(this,"utf16Value"),M(this,"utf8Value"),M(this,"utf16OffsetToUtf8"),M(this,"utf8OffsetToUtf16");const n=e.length,r=bt._utf8ByteLength(e),s=r!==n,o=s?new Uint32Array(n+1):null;s&&(o[n]=r);const i=s?new Uint32Array(r+1):null;s&&(i[r]=n);const a=new Uint8Array(r);let l=0;for(let c=0;c<n;c++){const u=e.charCodeAt(c);let f=u,h=!1;if(u>=55296&&u<=56319&&c+1<n){const d=e.charCodeAt(c+1);d>=56320&&d<=57343&&(f=(u-55296<<10)+65536|d-56320,h=!0)}s&&(o[c]=l,h&&(o[c+1]=l),f<=127?i[l+0]=c:f<=2047?(i[l+0]=c,i[l+1]=c):f<=65535?(i[l+0]=c,i[l+1]=c,i[l+2]=c):(i[l+0]=c,i[l+1]=c,i[l+2]=c,i[l+3]=c)),f<=127?a[l++]=f:f<=2047?(a[l++]=192|(f&1984)>>>6,a[l++]=128|(f&63)>>>0):f<=65535?(a[l++]=224|(f&61440)>>>12,a[l++]=128|(f&4032)>>>6,a[l++]=128|(f&63)>>>0):(a[l++]=240|(f&1835008)>>>18,a[l++]=128|(f&258048)>>>12,a[l++]=128|(f&4032)>>>6,a[l++]=128|(f&63)>>>0),h&&c++}this.utf16Length=n,this.utf8Length=r,this.utf16Value=e,this.utf8Value=a,this.utf16OffsetToUtf8=o,this.utf8OffsetToUtf16=i}static _utf8ByteLength(e){let n=0;for(let r=0,s=e.length;r<s;r++){const o=e.charCodeAt(r);let i=o,a=!1;if(o>=55296&&o<=56319&&r+1<s){const l=e.charCodeAt(r+1);l>=56320&&l<=57343&&(i=(o-55296<<10)+65536|l-56320,a=!0)}i<=127?n+=1:i<=2047?n+=2:i<=65535?n+=3:n+=4,a&&r++}return n}createString(e){const n=e.omalloc(this.utf8Length);return e.HEAPU8.set(this.utf8Value,n),n}}const wt=class J{constructor(e){if(M(this,"id",++J.LAST_ID),M(this,"_onigBinding"),M(this,"content"),M(this,"utf16Length"),M(this,"utf8Length"),M(this,"utf16OffsetToUtf8"),M(this,"utf8OffsetToUtf16"),M(this,"ptr"),!D)throw new _n("Must invoke loadWasm first.");this._onigBinding=D,this.content=e;const n=new bt(e);this.utf16Length=n.utf16Length,this.utf8Length=n.utf8Length,this.utf16OffsetToUtf8=n.utf16OffsetToUtf8,this.utf8OffsetToUtf16=n.utf8OffsetToUtf16,this.utf8Length<1e4&&!J._sharedPtrInUse?(J._sharedPtr||(J._sharedPtr=D.omalloc(1e4)),J._sharedPtrInUse=!0,D.HEAPU8.set(n.utf8Value,J._sharedPtr),this.ptr=J._sharedPtr):this.ptr=n.createString(D)}convertUtf8OffsetToUtf16(e){return this.utf8OffsetToUtf16?e<0?0:e>this.utf8Length?this.utf16Length:this.utf8OffsetToUtf16[e]:e}convertUtf16OffsetToUtf8(e){return this.utf16OffsetToUtf8?e<0?0:e>this.utf16Length?this.utf8Length:this.utf16OffsetToUtf8[e]:e}dispose(){this.ptr===J._sharedPtr?J._sharedPtrInUse=!1:this._onigBinding.ofree(this.ptr)}};M(wt,"LAST_ID",0);M(wt,"_sharedPtr",0);M(wt,"_sharedPtrInUse",!1);let vs=wt;class gc{constructor(e){if(M(this,"_onigBinding"),M(this,"_ptr"),!D)throw new _n("Must invoke loadWasm first.");const n=[],r=[];for(let a=0,l=e.length;a<l;a++){const c=new bt(e[a]);n[a]=c.createString(D),r[a]=c.utf8Length}const s=D.omalloc(4*e.length);D.HEAPU32.set(n,s/4);const o=D.omalloc(4*e.length);D.HEAPU32.set(r,o/4);const i=D.createOnigScanner(s,o,e.length);for(let a=0,l=e.length;a<l;a++)D.ofree(n[a]);D.ofree(o),D.ofree(s),i===0&&pc(D),this._onigBinding=D,this._ptr=i}dispose(){this._onigBinding.freeOnigScanner(this._ptr)}findNextMatchSync(e,n,r){let s=0;if(typeof r=="number"&&(s=r),typeof e=="string"){e=new vs(e);const o=this._findNextMatchSync(e,n,!1,s);return e.dispose(),o}return this._findNextMatchSync(e,n,!1,s)}_findNextMatchSync(e,n,r,s){const o=this._onigBinding,i=o.findNextOnigScannerMatch(this._ptr,e.id,e.ptr,e.utf8Length,e.convertUtf16OffsetToUtf8(n),s);if(i===0)return null;const a=o.HEAPU32;let l=i/4;const c=a[l++],u=a[l++],f=[];for(let h=0;h<u;h++){const d=e.convertUtf8OffsetToUtf16(a[l++]),p=e.convertUtf8OffsetToUtf16(a[l++]);f[h]={start:d,end:p,length:p-d}}return{index:c,captureIndices:f}}}function mc(t){return typeof t.instantiator=="function"}function yc(t){return typeof t.default=="function"}function bc(t){return typeof t.data<"u"}function wc(t){return typeof Response<"u"&&t instanceof Response}function Cc(t){return typeof ArrayBuffer<"u"&&(t instanceof ArrayBuffer||ArrayBuffer.isView(t))||typeof Buffer<"u"&&Buffer.isBuffer?.(t)||typeof SharedArrayBuffer<"u"&&t instanceof SharedArrayBuffer||typeof Uint32Array<"u"&&t instanceof Uint32Array}let Ze;function _c(t){if(Ze)return Ze;async function e(){D=await fc(async n=>{let r=t;return r=await r,typeof r=="function"&&(r=await r(n)),typeof r=="function"&&(r=await r(n)),mc(r)?r=await r.instantiator(n):yc(r)?r=await r.default(n):(bc(r)&&(r=r.data),wc(r)?typeof WebAssembly.instantiateStreaming=="function"?r=await Sc(r)(n):r=await kc(r)(n):Cc(r)?r=await Ot(r)(n):r instanceof WebAssembly.Module?r=await Ot(r)(n):"default"in r&&r.default instanceof WebAssembly.Module&&(r=await Ot(r.default)(n))),"instance"in r&&(r=r.instance),"exports"in r&&(r=r.exports),r})}return Ze=e(),Ze}function Ot(t){return e=>WebAssembly.instantiate(t,e)}function Sc(t){return e=>WebAssembly.instantiateStreaming(t,e)}function kc(t){return async e=>{const n=await t.arrayBuffer();return WebAssembly.instantiate(n,e)}}async function xc(t){return t&&await _c(t),{createScanner(e){return new gc(e.map(n=>typeof n=="string"?n:n.source))},createString(e){return new vs(e)}}}class Is{diff(e,n,r={}){let s;typeof r=="function"?(s=r,r={}):"callback"in r&&(s=r.callback);const o=this.castInput(e,r),i=this.castInput(n,r),a=this.removeEmpty(this.tokenize(o,r)),l=this.removeEmpty(this.tokenize(i,r));return this.diffWithOptionsObj(a,l,r,s)}diffWithOptionsObj(e,n,r,s){var o;const i=m=>{if(m=this.postProcess(m,r),s){setTimeout(function(){s(m)},0);return}else return m},a=n.length,l=e.length;let c=1,u=a+l;r.maxEditLength!=null&&(u=Math.min(u,r.maxEditLength));const f=(o=r.timeout)!==null&&o!==void 0?o:1/0,h=Date.now()+f,d=[{oldPos:-1,lastComponent:void 0}];let p=this.extractCommon(d[0],n,e,0,r);if(d[0].oldPos+1>=l&&p+1>=a)return i(this.buildValues(d[0].lastComponent,n,e));let b=-1/0,w=1/0;const y=()=>{for(let m=Math.max(b,-c);m<=Math.min(w,c);m+=2){let g;const S=d[m-1],k=d[m+1];S&&(d[m-1]=void 0);let _=!1;if(k){const v=k.oldPos-m;_=k&&0<=v&&v<a}const x=S&&S.oldPos+1<l;if(!_&&!x){d[m]=void 0;continue}if(!x||_&&S.oldPos<k.oldPos?g=this.addToPath(k,!0,!1,0,r):g=this.addToPath(S,!1,!0,1,r),p=this.extractCommon(g,n,e,m,r),g.oldPos+1>=l&&p+1>=a)return i(this.buildValues(g.lastComponent,n,e))||!0;d[m]=g,g.oldPos+1>=l&&(w=Math.min(w,m-1)),p+1>=a&&(b=Math.max(b,m+1))}c++};if(s)(function m(){setTimeout(function(){if(c>u||Date.now()>h)return s(void 0);y()||m()},0)})();else for(;c<=u&&Date.now()<=h;){const m=y();if(m)return m}}addToPath(e,n,r,s,o){const i=e.lastComponent;return i&&!o.oneChangePerToken&&i.added===n&&i.removed===r?{oldPos:e.oldPos+s,lastComponent:{count:i.count+1,added:n,removed:r,previousComponent:i.previousComponent}}:{oldPos:e.oldPos+s,lastComponent:{count:1,added:n,removed:r,previousComponent:i}}}extractCommon(e,n,r,s,o){const i=n.length,a=r.length;let l=e.oldPos,c=l-s,u=0;for(;c+1<i&&l+1<a&&this.equals(r[l+1],n[c+1],o);)c++,l++,u++,o.oneChangePerToken&&(e.lastComponent={count:1,previousComponent:e.lastComponent,added:!1,removed:!1});return u&&!o.oneChangePerToken&&(e.lastComponent={count:u,previousComponent:e.lastComponent,added:!1,removed:!1}),e.oldPos=l,c}equals(e,n,r){return r.comparator?r.comparator(e,n):e===n||!!r.ignoreCase&&e.toLowerCase()===n.toLowerCase()}removeEmpty(e){const n=[];for(let r=0;r<e.length;r++)e[r]&&n.push(e[r]);return n}castInput(e,n){return e}tokenize(e,n){return Array.from(e)}join(e){return e.join("")}postProcess(e,n){return e}get useLongestToken(){return!1}buildValues(e,n,r){const s=[];let o;for(;e;)s.push(e),o=e.previousComponent,delete e.previousComponent,e=o;s.reverse();const i=s.length;let a=0,l=0,c=0;for(;a<i;a++){const u=s[a];if(u.removed)u.value=this.join(r.slice(c,c+u.count)),c+=u.count;else{if(!u.added&&this.useLongestToken){let f=n.slice(l,l+u.count);f=f.map(function(h,d){const p=r[c+d];return p.length>h.length?p:h}),u.value=this.join(f)}else u.value=this.join(n.slice(l,l+u.count));l+=u.count,u.added||(c+=u.count)}}return s}}class vc extends Is{}const Ic=new vc;function Ec(t,e,n){return Ic.diff(t,e,n)}const fr="a-zA-Z0-9_\\u{AD}\\u{C0}-\\u{D6}\\u{D8}-\\u{F6}\\u{F8}-\\u{2C6}\\u{2C8}-\\u{2D7}\\u{2DE}-\\u{2FF}\\u{1E00}-\\u{1EFF}";class Ac extends Is{tokenize(e){const n=new RegExp(`(\\r?\\n)|[${fr}]+|[^\\S\\n\\r]+|[^${fr}]`,"ug");return e.match(n)||[]}}const Lc=new Ac;function Rc(t,e,n){return Lc.diff(t,e,n)}function Nc(t={}){const{classPrefix:e="__shiki_",classSuffix:n="",classReplacer:r=a=>a}=t,s=new Map;function o(a){return Object.entries(a).map(([l,c])=>`${l}:${c}`).join(";")}function i(a){const l=typeof a=="string"?a:o(a);let c=e+Pc(l)+n;return c=r(c),s.has(c)||s.set(c,typeof a=="string"?a:{...a}),c}return{name:"@shikijs/transformers:style-to-class",pre(a){if(!a.properties.style)return;const l=i(a.properties.style);delete a.properties.style,this.addClassToHast(a,l)},tokens(a){for(const l of a)for(const c of l){if(!c.htmlStyle)continue;const u=i(c.htmlStyle);c.htmlStyle={},c.htmlAttrs||={},c.htmlAttrs.class?c.htmlAttrs.class+=` ${u}`:c.htmlAttrs.class=u}},getClassRegistry(){return s},getCSS(){let a="";for(const[l,c]of s.entries())a+=`.${l}{${typeof c=="string"?c:o(c)}}`;return a},clearRegistry(){s.clear()}}}function Pc(t,e=0){let n=3735928559^e,r=1103547991^e;for(let s=0,o;s<t.length;s++)o=t.charCodeAt(s),n=Math.imul(n^o,2654435761),r=Math.imul(r^o,1597334677);return n=Math.imul(n^n>>>16,2246822507),n^=Math.imul(r^r>>>13,3266489909),r=Math.imul(r^r>>>16,2246822507),r^=Math.imul(n^n>>>13,3266489909),(4294967296*(2097151&r)+(n>>>0)).toString(36).slice(0,6)}const $c=new RegExp("(?<=\\n)"),We={dark:"pierre-dark",light:"pierre-light"},Es=1,hr=new Map,dr=new Set;function Sn(t,e){t=Array.isArray(t)?t:[t];for(const n of t){if(dr.has(n.name))continue;let r=hr.get(n.name);r==null&&(r=n,hr.set(n.name,r)),dr.add(r.name),e.loadLanguageSync(r.data)}}const Dt=new Map,pr=new Set;function As(t,e){t=Array.isArray(t)?t:[t];for(let n of t){let r;if(typeof n=="string"){if(r=Dt.get(n),r==null)throw new Error(`loadResolvedThemes: ${n} is not resolved, you must resolve it before calling loadResolvedThemes`)}else r=n,n=n.name,Dt.has(n)||Dt.set(n,r);pr.has(n)||(pr.add(n),e.loadThemeSync(r))}}function Be(t){return t.replace(/\n$|\r\n$/,"")}function Tc(t){return{type:"text",value:t}}function Mc(t){let e=t.children[0];for(;e!=null;){if(e.type==="element"&&e.tagName==="code")return e;"children"in e?e=e.children[0]:e=null}}function Oc(t,e,n){const r=typeof n.lineInfo=="function"?n.lineInfo(e):n.lineInfo[e-1];if(r==null){const s=`processLine: line ${e}, contains no state.lineInfo`;throw console.error(s,{node:t,line:e,state:n}),new Error(s)}return t.tagName="div",t.properties["data-line"]=r.lineNumber,t.properties["data-alt-line"]=r.altLineNumber,t.properties["data-line-type"]=r.type,t.properties["data-line-index"]=r.lineIndex,t.children.length===0&&t.children.push(Tc(`
153
+ `)),t}function Ls(t=!1){const e={lineInfo:[]},n=[{line(r){return delete r.properties.class,r},pre(r){const s=Mc(r),o=[];if(s!=null){let i=1;for(const a of s.children)a.type==="element"&&(o.push(Oc(a,i,e)),i++);s.children=o}return r}}];return t&&n.push(Dc,gr),{state:e,transformers:n,toClass:gr}}const gr=Nc({classPrefix:"hl-"}),Dc={name:"token-style-normalizer",tokens(t){for(const e of t)for(const n of e){if(n.htmlStyle!=null)continue;const r={};n.color!=null&&(r.color=n.color),n.bgColor!=null&&(r["background-color"]=n.bgColor),n.fontStyle!=null&&n.fontStyle!==0&&((n.fontStyle&1)!==0&&(r["font-style"]="italic"),(n.fontStyle&2)!==0&&(r["font-weight"]="bold"),(n.fontStyle&4)!==0&&(r["text-decoration"]="underline")),Object.keys(r).length>0&&(n.htmlStyle=r)}}};function H(t){return`--${t==="token"?"diffs-token":"diffs"}-`}const ye=new Map,Re={"1c":"1c",abap:"abap",as:"actionscript-3",ada:"ada",adb:"ada",ads:"ada",adoc:"asciidoc",asciidoc:"asciidoc","component.html":"angular-html","component.ts":"angular-ts",conf:"nginx",htaccess:"apache",cls:"tex",trigger:"apex",apl:"apl",applescript:"applescript",scpt:"applescript",ara:"ara",asm:"asm",s:"riscv",astro:"astro",awk:"awk",bal:"ballerina",sh:"zsh",bash:"zsh",bat:"cmd",cmd:"cmd",be:"berry",beancount:"beancount",bib:"bibtex",bicep:"bicep","blade.php":"blade",bsl:"bsl",c:"c",h:"objective-cpp",cs:"csharp",cpp:"cpp",hpp:"cpp",cc:"cpp",cxx:"cpp",hh:"cpp",cdc:"cdc",cairo:"cairo",clar:"clarity",clj:"clojure",cljs:"clojure",cljc:"clojure",soy:"soy",cmake:"cmake","CMakeLists.txt":"cmake",cob:"cobol",cbl:"cobol",cobol:"cobol",CODEOWNERS:"codeowners",ql:"ql",coffee:"coffeescript",lisp:"lisp",cl:"lisp",lsp:"lisp",log:"log",v:"verilog",cql:"cql",cr:"crystal",css:"css",csv:"csv",cue:"cue",cypher:"cypher",cyp:"cypher",d:"d",dart:"dart",dax:"dax",desktop:"desktop",diff:"diff",patch:"diff",Dockerfile:"dockerfile",dockerfile:"dockerfile",env:"dotenv",dm:"dream-maker",edge:"edge",el:"emacs-lisp",ex:"elixir",exs:"elixir",elm:"elm",erb:"erb",erl:"erlang",hrl:"erlang",f:"fortran-fixed-form",for:"fortran-fixed-form",fs:"fsharp",fsi:"fsharp",fsx:"fsharp",f03:"f03",f08:"f08",f18:"f18",f77:"f77",f90:"fortran-free-form",f95:"fortran-free-form",fnl:"fennel",fish:"fish",ftl:"ftl",tres:"gdresource",res:"gdresource",gd:"gdscript",gdshader:"gdshader",gs:"genie",feature:"gherkin",COMMIT_EDITMSG:"git-commit","git-rebase-todo":"git-rebase",gjs:"glimmer-js",gleam:"gleam",gts:"glimmer-ts",glsl:"glsl",vert:"glsl",frag:"glsl",shader:"shaderlab",gp:"gnuplot",plt:"gnuplot",gnuplot:"gnuplot",go:"go",graphql:"graphql",gql:"graphql",groovy:"groovy",gvy:"groovy",hack:"hack",haml:"haml",hbs:"handlebars",handlebars:"handlebars",hs:"haskell",lhs:"haskell",hx:"haxe",hcl:"hcl",hjson:"hjson",hlsl:"hlsl",fx:"hlsl",html:"html",htm:"html",http:"http",rest:"http",hxml:"hxml",hy:"hy",imba:"imba",ini:"ini",cfg:"ini",jade:"pug",pug:"pug",java:"java",js:"javascript",mjs:"javascript",cjs:"javascript",jinja:"jinja",jinja2:"jinja",j2:"jinja",jison:"jison",jl:"julia",json:"json",json5:"json5",jsonc:"jsonc",jsonl:"jsonl",jsonnet:"jsonnet",libsonnet:"jsonnet",jssm:"jssm",jsx:"jsx",kt:"kotlin",kts:"kts",kql:"kusto",tex:"tex",ltx:"tex",lean:"lean4",less:"less",liquid:"liquid",lit:"lit",ll:"llvm",logo:"logo",lua:"lua",luau:"luau",Makefile:"makefile",mk:"makefile",makefile:"makefile",md:"markdown",markdown:"markdown",marko:"marko",m:"wolfram",mat:"matlab",mdc:"mdc",mdx:"mdx",wiki:"wikitext",mediawiki:"wikitext",mmd:"mermaid",mermaid:"mermaid",mips:"mipsasm",mojo:"mojo","🔥":"mojo",move:"move",nar:"narrat",nf:"nextflow",nim:"nim",nims:"nim",nimble:"nim",nix:"nix",nu:"nushell",mm:"objective-cpp",ml:"ocaml",mli:"ocaml",mll:"ocaml",mly:"ocaml",pas:"pascal",p:"pascal",pl:"prolog",pm:"perl",t:"perl",raku:"raku",p6:"raku",pl6:"raku",php:"php",phtml:"php",pls:"plsql",sql:"sql",po:"po",polar:"polar",pcss:"postcss",pot:"pot",potx:"potx",pq:"powerquery",pqm:"powerquery",ps1:"powershell",psm1:"powershell",psd1:"powershell",prisma:"prisma",pro:"prolog",P:"prolog",properties:"properties",proto:"protobuf",pp:"puppet",purs:"purescript",py:"python",pyw:"python",pyi:"python",qml:"qml",qmldir:"qmldir",qss:"qss",r:"r",R:"r",rkt:"racket",rktl:"racket",razor:"razor",cshtml:"razor",rb:"ruby",rbw:"ruby",reg:"reg",regex:"regexp",rel:"rel",rs:"rust",rst:"rst",rake:"ruby",gemspec:"ruby",sas:"sas",sass:"sass",scala:"scala",sc:"scala",scm:"scheme",ss:"scheme",sld:"scheme",scss:"scss",sdbl:"sdbl",shadergraph:"shader",st:"smalltalk",sol:"solidity",sparql:"sparql",rq:"sparql",spl:"splunk",config:"ssh-config",do:"stata",ado:"stata",dta:"stata",styl:"stylus",stylus:"stylus",svelte:"svelte",swift:"swift",sv:"system-verilog",svh:"system-verilog",service:"systemd",socket:"systemd",device:"systemd",timer:"systemd",talon:"talonscript",tasl:"tasl",tcl:"tcl",templ:"templ",tf:"tf",tfvars:"tfvars",toml:"toml",ts:"typescript",tsp:"typespec",tsv:"tsv",tsx:"tsx",ttl:"turtle",twig:"twig",typ:"typst",vv:"v",vala:"vala",vapi:"vala",vb:"vb",vbs:"vb",bas:"vb",vh:"verilog",vhd:"vhdl",vhdl:"vhdl",vim:"vimscript",vue:"vue","vine.ts":"vue-vine",vy:"vyper",wasm:"wasm",wat:"wasm",wy:"文言",wgsl:"wgsl",wit:"wit",wl:"wolfram",nb:"wolfram",xml:"xml",xsl:"xsl",xslt:"xsl",yaml:"yaml",yml:"yml",zs:"zenscript",zig:"zig",zsh:"zsh",sty:"tex"};function rn(t){if(ye.has(t))return ye.get(t)??"text";if(Re[t]!=null)return Re[t];const e=t.match(/\.([^/\\]+\.[^/\\]+)$/);if(e!=null){if(ye.has(e[1]))return ye.get(e[1])??"text";if(Re[e[1]]!=null)return Re[e[1]]??"text"}const n=t.match(/\.([^.]+)$/)?.[1]??"";return ye.has(n)?ye.get(n)??"text":Re[n]??"text"}function Rs({theme:t=We,highlighter:e,prefix:n}){let r="";if(typeof t=="string"){const s=e.getTheme(t);r+=`color:${s.fg};`,r+=`background-color:${s.bg};`,r+=`${H("global")}fg:${s.fg};`,r+=`${H("global")}bg:${s.bg};`,r+=Gt(s,n)}else{let s=e.getTheme(t.dark);r+=`${H("global")}dark:${s.fg};`,r+=`${H("global")}dark-bg:${s.bg};`,r+=Gt(s,"dark"),s=e.getTheme(t.light),r+=`${H("global")}light:${s.fg};`,r+=`${H("global")}light-bg:${s.bg};`,r+=Gt(s,"light")}return r}function Gt(t,e){e=e!=null?`${e}-`:"";let n="";const r=t.colors?.["gitDecoration.addedResourceForeground"]??t.colors?.["terminal.ansiGreen"];r!=null&&(n+=`${H("global")}${e}addition-color:${r};`);const s=t.colors?.["gitDecoration.deletedResourceForeground"]??t.colors?.["terminal.ansiRed"];s!=null&&(n+=`${H("global")}${e}deletion-color:${s};`);const o=t.colors?.["gitDecoration.modifiedResourceForeground"]??t.colors?.["terminal.ansiBlue"];return o!=null&&(n+=`${H("global")}${e}modified-color:${o};`),n}function sn(t){let e=t.children[0];for(;e!=null;){if(e.type==="element"&&e.tagName==="code")return e.children;"children"in e?e=e.children[0]:e=null}throw console.error(t),new Error("getLineNodes: Unable to find children")}function Gc({diff:t,diffStyle:e,startingLine:n=0,totalLines:r=1/0,expandedHunks:s,collapsedContextThreshold:o=Es,callback:i}){const a={finalHunk:t.hunks.at(-1),viewportStart:n,viewportEnd:n+r,isWindowedHighlight:n>0||r<1/0,splitCount:0,unifiedCount:0,shouldBreak(){if(!a.isWindowedHighlight)return!1;const l=a.unifiedCount>=n+r,c=a.splitCount>=n+r;return l&&c},shouldSkip(l,c){if(!a.isWindowedHighlight)return!1;const u=a.unifiedCount+l<n,f=a.splitCount+c<n;return u&&f},incrementCounts(l,c){a.unifiedCount+=l,a.splitCount+=c},isInWindow(l,c){if(!a.isWindowedHighlight)return!0;const u=a.isInUnifiedWindow(l),f=a.isInSplitWindow(c);return u||f},isInUnifiedWindow(l){return!a.isWindowedHighlight||a.unifiedCount>=n-l&&a.unifiedCount<n+r},isInSplitWindow(l){return!a.isWindowedHighlight||a.splitCount>=n-l&&a.splitCount<n+r},emit(l,c=!1){return c||a.incrementCounts(1,1),i(l)??!1}};e:for(const[l,c]of t.hunks.entries()){let u=function(_,x){return d==null||d.collapsedLines<=0||d.fromStart+d.fromEnd>0?0:x===c.splitLineStart+c.splitLineCount-1?d.collapsedLines:0},f=function(){if(h.collapsedLines===0)return 0;const _=h.collapsedLines;return h.collapsedLines=0,_};if(a.shouldBreak())break;const h=mr(t.isPartial,c.collapsedBefore,s,l,o),d=(()=>{if(c!==a.finalHunk||!Bc(t))return;const _=t.additionLines.length-(c.additionLineIndex+c.additionCount),x=t.deletionLines.length-(c.deletionLineIndex+c.deletionCount);if(_!==x)throw new Error(`iterateOverDiff: trailing context mismatch (additions=${_}, deletions=${x}) for ${t.name}`);const v=Math.min(_,x);return mr(t.isPartial,v,s,t.hunks.length,o)})(),p=h.fromStart+h.fromEnd;if(a.shouldSkip(p,p))a.incrementCounts(p,p),f();else{let _=c.unifiedLineStart-h.rangeSize,x=c.splitLineStart-h.rangeSize,v=c.deletionLineIndex-h.rangeSize,N=c.additionLineIndex-h.rangeSize,L=c.deletionStart-h.rangeSize,F=c.additionStart-h.rangeSize,A=0;for(;A<h.fromStart;){if(a.isInWindow(0,0)){if(a.emit({hunkIndex:l,hunk:c,collapsedBefore:0,collapsedAfter:0,type:"context-expanded",deletionLine:{lineNumber:L+A,lineIndex:v+A,noEOFCR:!1,unifiedLineIndex:_+A,splitLineIndex:x+A},additionLine:{unifiedLineIndex:_+A,splitLineIndex:x+A,lineIndex:N+A,lineNumber:F+A,noEOFCR:!1}}))break e}else a.incrementCounts(1,1);A++}for(_=c.unifiedLineStart-h.fromEnd,x=c.splitLineStart-h.fromEnd,v=c.deletionLineIndex-h.fromEnd,N=c.additionLineIndex-h.fromEnd,L=c.deletionStart-h.fromEnd,F=c.additionStart-h.fromEnd,A=0;A<h.fromEnd;){if(a.isInWindow(0,0)){if(a.emit({hunkIndex:l,hunk:c,collapsedBefore:f(),collapsedAfter:0,type:"context-expanded",deletionLine:{lineNumber:L+A,lineIndex:v+A,noEOFCR:!1,unifiedLineIndex:_+A,splitLineIndex:x+A},additionLine:{unifiedLineIndex:_+A,splitLineIndex:x+A,lineIndex:N+A,lineNumber:F+A,noEOFCR:!1}}))break e}else a.incrementCounts(1,1);A++}}let b=c.unifiedLineStart,w=c.splitLineStart,y=c.deletionLineIndex,m=c.additionLineIndex,g=c.deletionStart,S=c.additionStart;const k=c.hunkContent.at(-1);for(const _ of c.hunkContent){if(a.shouldBreak())break e;const x=_===k;if(_.type==="context"){if(a.shouldSkip(_.lines,_.lines))a.incrementCounts(_.lines,_.lines),f();else{let v=0;for(;v<_.lines;){if(a.isInWindow(0,0)){const N=x&&v===_.lines-1,L=b+v,F=w+v;if(a.emit({hunkIndex:l,hunk:c,collapsedBefore:f(),collapsedAfter:u(L,F),type:"context",deletionLine:{lineNumber:g+v,lineIndex:y+v,noEOFCR:N&&c.noEOFCRDeletions,unifiedLineIndex:L,splitLineIndex:F},additionLine:{unifiedLineIndex:L,splitLineIndex:F,lineIndex:m+v,lineNumber:S+v,noEOFCR:N&&c.noEOFCRAdditions}}))break e}else a.incrementCounts(1,1);v++}}b+=_.lines,w+=_.lines,y+=_.lines,m+=_.lines,g+=_.lines,S+=_.lines}else{const v=Math.max(_.deletions,_.additions),N=_.deletions+_.additions;if(!a.shouldSkip(N,v)){const L=Fc(a,_);for(const[F,A]of L)for(let re=F;re<A;re++){const K=u(b+re,w+re);if(a.emit(Uc({hunkIndex:l,hunk:c,collapsedBefore:f(),collapsedAfter:K,diffStyle:e,index:re,unifiedLineIndex:b,splitLineIndex:w,additionLineIndex:m,deletionLineIndex:y,additionLineNumber:S,deletionLineNumber:g,content:_,isLastContent:x,unifiedCount:N,splitCount:v}),!0))break e}}f(),a.incrementCounts(N,v),b+=N,w+=v,y+=_.deletions,m+=_.additions,g+=_.deletions,S+=_.additions}}if(d!=null){const{collapsedLines:_,fromStart:x,fromEnd:v}=d,N=x+v;let L=0;for(;L<N;){if(a.shouldBreak())break e;if(a.isInWindow(0,0)){const F=L===N-1;if(a.emit({hunkIndex:t.hunks.length,hunk:void 0,collapsedBefore:0,collapsedAfter:F?_:0,type:"context-expanded",deletionLine:{lineNumber:g+L,lineIndex:y+L,noEOFCR:!1,unifiedLineIndex:b+L,splitLineIndex:w+L},additionLine:{unifiedLineIndex:b+L,splitLineIndex:w+L,lineIndex:m+L,lineNumber:S+L,noEOFCR:!1}}))break e}else a.incrementCounts(1,1);L++}}}}function mr(t,e,n,r,s){if(e=Math.max(e,0),e===0||t)return{fromStart:0,fromEnd:0,rangeSize:e,collapsedLines:Math.max(e,0)};if(n===!0||e<=s)return{fromStart:e,fromEnd:0,rangeSize:e,collapsedLines:0};const o=n?.get(r),i=Math.min(Math.max(o?.fromStart??0,0),e),a=Math.min(Math.max(o?.fromEnd??0,0),e),l=i+a,c=l>=e;return{fromStart:c?e:i,fromEnd:c?0:a,rangeSize:e,collapsedLines:Math.max(e-l,0)}}function Bc(t){const e=t.hunks.at(-1);return e==null||t.isPartial||t.additionLines.length===0||t.deletionLines.length===0?!1:e.additionLineIndex+e.additionCount<t.additionLines.length||e.deletionLineIndex+e.deletionCount<t.deletionLines.length}function Fc(t,e,n){if(!t.isWindowedHighlight)return[[0,Math.max(e.deletions,e.additions)]];const r=[];function s(l,c){if(l+c<=t.viewportStart||l>=t.viewportEnd)return;const u=Math.max(0,t.viewportStart-l),f=Math.min(c,t.viewportEnd-l);return f>u?[u,f]:void 0}function o(l,c){return l}function i(l,c){if(l==null)return;const[u,f]=o(l);f>u&&r.push([u,f])}if(i(s(t.unifiedCount,e.deletions)),i(s(t.unifiedCount+e.deletions,e.additions)),i(s(t.splitCount,e.deletions)),i(s(t.splitCount,e.additions)),r.length===0)return r;r.sort((l,c)=>l[0]-c[0]);const a=[r[0]];for(const[l,c]of r.slice(1)){const u=a[a.length-1];l<=u[1]?u[1]=Math.max(u[1],c):a.push([l,c])}return a}function Uc({hunkIndex:t,hunk:e,collapsedAfter:n,collapsedBefore:r,diffStyle:s,index:o,unifiedLineIndex:i,splitLineIndex:a,additionLineIndex:l,deletionLineIndex:c,additionLineNumber:u,deletionLineNumber:f,content:h,isLastContent:d,unifiedCount:p,splitCount:b}){const w=o<h.deletions?i+o:void 0,y=o<h.additions?i+h.deletions+o:void 0,m=a+o,g=o<h.deletions?c+o:void 0,S=o<h.deletions?f+o:void 0,k=o<h.additions?l+o:void 0,_=o<h.additions?u+o:void 0,x=d&&o===b-1&&e.noEOFCRDeletions,v=d&&o===b-1&&e.noEOFCRAdditions,N=g!=null&&S!=null&&w!=null?{lineNumber:S,lineIndex:g,noEOFCR:x,unifiedLineIndex:w,splitLineIndex:m}:void 0,L=k!=null&&_!=null&&y!=null?{unifiedLineIndex:y,splitLineIndex:m,lineIndex:k,lineNumber:_,noEOFCR:v}:void 0;if(N==null&&L!=null)return{type:"change",hunkIndex:t,hunk:e,collapsedAfter:n,collapsedBefore:r,deletionLine:void 0,additionLine:L};if(N!=null&&L==null)return{type:"change",hunkIndex:t,hunk:e,collapsedAfter:n,collapsedBefore:r,deletionLine:N,additionLine:void 0};if(N==null||L==null)throw new Error("iterateOverDiff: missing change line data");return{type:"change",hunkIndex:t,hunk:e,collapsedAfter:n,collapsedBefore:r,deletionLine:N,additionLine:L}}function yr({line:t,spanStart:e,spanLength:n}){return{start:{line:t,character:e},end:{line:t,character:e+n},properties:{"data-diff-span":""},alwaysWrap:!0}}function Qe({item:t,arr:e,enableJoin:n,isNeutral:r=!1,isLastItem:s=!1}){const o=e[e.length-1];if(o==null||s||!n){e.push([r?0:1,t.value]);return}const i=o[0]===0;if(r===i||r&&t.value.length===1&&!i){o[1]+=t.value;return}e.push([r?0:1,t.value])}const jc={forcePlainText:!1};function Wc(t,e,n,{forcePlainText:r,startingLine:s,totalLines:o,expandedHunks:i,collapsedContextThreshold:a=Es}=jc){r?(s??=0,o??=1/0):(s=0,o=1/0);const l=s>0||o<1/0,c=(()=>{const m=n.theme??We;if(typeof m=="string")return e.getTheme(m).type})(),u=Rs({theme:n.theme,highlighter:e}),f=r&&!l&&(t.unifiedLineCount>1e3||t.splitLineCount>1e3)?"none":n.lineDiffType,h={deletionLines:[],additionLines:[]},d=!r&&!t.isPartial,p=r?i:void 0,b=new Map;function w(m){const g=d?0:m,S=b.get(g)??Hc();return b.set(g,S),S}function y(m,g,S,k){if(l){let _=S.at(-1);(_==null||_.targetIndex+_.count!==g)&&(_={targetIndex:g,originalOffset:k.length,count:0},S.push(_)),_.count++}k.push(m)}Gc({diff:t,diffStyle:"both",startingLine:s,totalLines:o,expandedHunks:l?p:!0,collapsedContextThreshold:a,callback:({hunkIndex:m,additionLine:g,deletionLine:S,type:k})=>{const _=w(m),x=g!=null?g.splitLineIndex:S.splitLineIndex;k==="change"&&g!=null&&S!=null&&zc({additionLine:t.additionLines[g.lineIndex],deletionLine:t.deletionLines[S.lineIndex],deletionLineIndex:_.deletionContent.length,additionLineIndex:_.additionContent.length,deletionDecorations:_.deletionDecorations,additionDecorations:_.additionDecorations,lineDiffType:f}),S!=null&&(y(t.deletionLines[S.lineIndex],S.lineIndex,_.deletionSegments,_.deletionContent),_.deletionInfo.push({type:k==="change"?"change-deletion":k,lineNumber:S.lineNumber,altLineNumber:k==="change"?void 0:g.lineNumber??void 0,lineIndex:`${S.unifiedLineIndex},${x}`})),g!=null&&(y(t.additionLines[g.lineIndex],g.lineIndex,_.additionSegments,_.additionContent),_.additionInfo.push({type:k==="change"?"change-addition":k,lineNumber:g.lineNumber,altLineNumber:k==="change"?void 0:S.lineNumber??void 0,lineIndex:`${g.unifiedLineIndex},${x}`}))}});for(const m of b.values()){if(m.deletionContent.length===0&&m.additionContent.length===0)continue;const g={name:t.prevName??t.name,contents:m.deletionContent.value},S={name:t.name,contents:m.additionContent.value},{deletionLines:k,additionLines:_}=qc({deletionFile:g,deletionInfo:m.deletionInfo,deletionDecorations:m.deletionDecorations,additionFile:S,additionInfo:m.additionInfo,additionDecorations:m.additionDecorations,highlighter:e,options:n,languageOverride:r?"text":t.lang});if(d){h.deletionLines=k,h.additionLines=_;continue}if(m.deletionSegments.length>0)for(const x of m.deletionSegments)for(let v=0;v<x.count;v++)h.deletionLines[x.targetIndex+v]=k[x.originalOffset+v];else h.deletionLines.push(...k);if(m.additionSegments.length>0)for(const x of m.additionSegments)for(let v=0;v<x.count;v++)h.additionLines[x.targetIndex+v]=_[x.originalOffset+v];else h.additionLines.push(..._)}return{code:h,themeStyles:u,baseThemeType:c}}function zc({deletionLine:t,additionLine:e,deletionLineIndex:n,additionLineIndex:r,deletionDecorations:s,additionDecorations:o,lineDiffType:i}){if(t==null||e==null||i==="none")return;t=Be(t),e=Be(e);const a=i==="char"?Ec(t,e):Rc(t,e),l=[],c=[],u=i==="word-alt",f=a.at(-1);for(const d of a){const p=d===f;!d.added&&!d.removed?(Qe({item:d,arr:l,enableJoin:u,isNeutral:!0,isLastItem:p}),Qe({item:d,arr:c,enableJoin:u,isNeutral:!0,isLastItem:p})):d.removed?Qe({item:d,arr:l,enableJoin:u,isLastItem:p}):Qe({item:d,arr:c,enableJoin:u,isLastItem:p})}let h=0;for(const d of l)d[0]===1&&s.push(yr({line:n,spanStart:h,spanLength:d[1].length})),h+=d[1].length;h=0;for(const d of c)d[0]===1&&o.push(yr({line:r,spanStart:h,spanLength:d[1].length})),h+=d[1].length}function Hc(){return{deletionContent:{push(t){this.value+=t,this.length++},value:"",length:0},additionContent:{push(t){this.value+=t,this.length++},value:"",length:0},deletionInfo:[],additionInfo:[],deletionDecorations:[],additionDecorations:[],deletionSegments:[],additionSegments:[]}}function qc({deletionFile:t,additionFile:e,deletionInfo:n,additionInfo:r,highlighter:s,deletionDecorations:o,additionDecorations:i,languageOverride:a,options:{theme:l=We,...c}}){const u=a??rn(t.name),f=a??rn(e.name),{state:h,transformers:d}=Ls(),p=typeof l=="string"?{...c,lang:"text",theme:l,transformers:d,decorations:void 0,defaultColor:!1,cssVariablePrefix:H("token")}:{...c,lang:"text",themes:l,transformers:d,decorations:void 0,defaultColor:!1,cssVariablePrefix:H("token")};return{deletionLines:t.contents===""?[]:(p.lang=u,h.lineInfo=n,p.decorations=o,sn(s.codeToHast(Be(t.contents),p))),additionLines:e.contents===""?[]:(p.lang=f,p.decorations=i,h.lineInfo=r,sn(s.codeToHast(Be(e.contents),p)))}}function Vc({lines:t,startingLine:e=0,totalLines:n=1/0,callback:r}){const s=Math.min(e+n,t.length),o=(()=>{const i=t.at(-1);return i===""||i===`
154
+ `||i===`\r
155
+ `||i==="\r"?Math.max(0,t.length-2):t.length-1})();for(let i=e;i<s;i++){const a=i===o;if(r({lineIndex:i,lineNumber:i+1,content:t[i],isLastLine:a})===!0||a)break}}function Xc(t){return t!==""?t.split($c):[]}const Kc={forcePlainText:!1};function Zc(t,e,{theme:n=We,tokenizeMaxLineLength:r},{forcePlainText:s,startingLine:o,totalLines:i,lines:a}=Kc){s?(o??=0,i??=1/0):(o=0,i=1/0);const l=o>0||i<1/0,{state:c,transformers:u}=Ls(),f=s?"text":t.lang??rn(t.name),h=(()=>{if(typeof n=="string")return e.getTheme(n).type})(),d=Rs({theme:n,highlighter:e});c.lineInfo=y=>({type:"context",lineIndex:y-1+o,lineNumber:y+o});const p=typeof n=="string"?{lang:f,theme:n,transformers:u,defaultColor:!1,cssVariablePrefix:H("token"),tokenizeMaxLineLength:r}:{lang:f,themes:n,transformers:u,defaultColor:!1,cssVariablePrefix:H("token"),tokenizeMaxLineLength:r},b=sn(e.codeToHast(l?Qc(a??Xc(t.contents),o,i):Be(t.contents),p)),w=l?new Array(o):b;return l&&w.push(...b),{code:w,themeStyles:d,baseThemeType:h}}function Qc(t,e,n){let r="";return Vc({lines:t,startingLine:e,totalLines:n,callback({content:s}){r+=s}}),r}let br,xe={theme:We,tokenizeMaxLineLength:1e3,lineDiffType:"word-alt"};self.addEventListener("error",t=>{console.error("[Shiki Worker] Unhandled error:",t.error)});self.addEventListener("message",t=>{Yc(t.data)});async function Yc(t){try{switch(t.type){case"initialize":await Jc(t);break;case"set-render-options":await eu(t);break;case"file":await tu(t);break;case"diff":await nu(t);break;default:throw new Error(`Unknown request type: ${t.type}`)}}catch(e){console.error("Worker error:",e),ou(t.id,e)}}async function Jc({id:t,renderOptions:e,preferredHighlighter:n,resolvedThemes:r,resolvedLanguages:s}){let o=Ct(n);"then"in o&&(o=await o),As(r,o),s!=null&&Sn(s,o),xe=e,postMessage({type:"success",id:t,requestType:"initialize",sentAt:Date.now()})}async function eu({id:t,renderOptions:e,resolvedThemes:n}){let r=Ct();"then"in r&&(r=await r),As(n,r),xe=e,postMessage({type:"success",id:t,requestType:"set-render-options",sentAt:Date.now()})}async function tu({id:t,file:e,resolvedLanguages:n}){let r=Ct();"then"in r&&(r=await r),n!=null&&Sn(n,r);const s={theme:xe.theme,tokenizeMaxLineLength:xe.tokenizeMaxLineLength};ru(t,Zc(e,r,s),s)}async function nu({id:t,diff:e,resolvedLanguages:n}){let r=Ct();"then"in r&&(r=await r),n!=null&&Sn(n,r),su(t,Wc(e,r,xe),xe)}function Ct(t="shiki-js"){return br??=_a({themes:[],langs:[],engine:t==="shiki-wasm"?xc(import("./wasm-CG6Dc4jp.js")):ac()}),br}function ru(t,e,n){postMessage({type:"success",requestType:"file",id:t,result:e,options:n,sentAt:Date.now()})}function su(t,e,n){postMessage({type:"success",requestType:"diff",id:t,result:e,options:n,sentAt:Date.now()})}function ou(t,e){const n={type:"error",id:t,error:e instanceof Error?e.message:String(e),stack:e instanceof Error?e.stack:void 0};postMessage(n)}