unleash-server 7.5.1 → 7.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (466) hide show
  1. package/dist/lib/addons/feature-event-formatter-md-events.d.ts.map +1 -1
  2. package/dist/lib/addons/feature-event-formatter-md-events.js +16 -1
  3. package/dist/lib/addons/feature-event-formatter-md-events.js.map +1 -1
  4. package/dist/lib/addons/slack-app-definition.d.ts.map +1 -1
  5. package/dist/lib/addons/slack-app-definition.js +4 -1
  6. package/dist/lib/addons/slack-app-definition.js.map +1 -1
  7. package/dist/lib/app.d.ts.map +1 -1
  8. package/dist/lib/app.js +11 -25
  9. package/dist/lib/app.js.map +1 -1
  10. package/dist/lib/create-config.d.ts.map +1 -1
  11. package/dist/lib/create-config.js +3 -0
  12. package/dist/lib/create-config.js.map +1 -1
  13. package/dist/lib/db/api-token-store.d.ts +4 -1
  14. package/dist/lib/db/api-token-store.d.ts.map +1 -1
  15. package/dist/lib/db/api-token-store.js +17 -3
  16. package/dist/lib/db/api-token-store.js.map +1 -1
  17. package/dist/lib/error/bad-gateway-error.d.ts +7 -0
  18. package/dist/lib/error/bad-gateway-error.d.ts.map +1 -0
  19. package/dist/lib/error/bad-gateway-error.js +9 -0
  20. package/dist/lib/error/bad-gateway-error.js.map +1 -0
  21. package/dist/lib/error/gateway-timeout-error.d.ts +7 -0
  22. package/dist/lib/error/gateway-timeout-error.d.ts.map +1 -0
  23. package/dist/lib/error/gateway-timeout-error.js +9 -0
  24. package/dist/lib/error/gateway-timeout-error.js.map +1 -0
  25. package/dist/lib/error/index.d.ts +3 -1
  26. package/dist/lib/error/index.d.ts.map +1 -1
  27. package/dist/lib/error/index.js +3 -1
  28. package/dist/lib/error/index.js.map +1 -1
  29. package/dist/lib/error/unleash-error.d.ts +1 -1
  30. package/dist/lib/error/unleash-error.d.ts.map +1 -1
  31. package/dist/lib/error/unleash-error.js +2 -0
  32. package/dist/lib/error/unleash-error.js.map +1 -1
  33. package/dist/lib/events/index.d.ts +4 -1
  34. package/dist/lib/events/index.d.ts.map +1 -1
  35. package/dist/lib/events/index.js +6 -0
  36. package/dist/lib/events/index.js.map +1 -1
  37. package/dist/lib/features/client-feature-toggles/client-feature-toggle-store.d.ts.map +1 -1
  38. package/dist/lib/features/client-feature-toggles/client-feature-toggle-store.js +5 -0
  39. package/dist/lib/features/client-feature-toggles/client-feature-toggle-store.js.map +1 -1
  40. package/dist/lib/features/client-feature-toggles/client-feature-toggle-store.test.d.ts +2 -0
  41. package/dist/lib/features/client-feature-toggles/client-feature-toggle-store.test.d.ts.map +1 -0
  42. package/dist/lib/features/client-feature-toggles/client-feature-toggle-store.test.js +53 -0
  43. package/dist/lib/features/client-feature-toggles/client-feature-toggle-store.test.js.map +1 -0
  44. package/dist/lib/features/client-feature-toggles/delta/client-feature-toggle-delta-read-model.d.ts.map +1 -1
  45. package/dist/lib/features/client-feature-toggles/delta/client-feature-toggle-delta-read-model.js +5 -0
  46. package/dist/lib/features/client-feature-toggles/delta/client-feature-toggle-delta-read-model.js.map +1 -1
  47. package/dist/lib/features/client-feature-toggles/delta/client-feature-toggle-delta-read-model.test.d.ts +2 -0
  48. package/dist/lib/features/client-feature-toggles/delta/client-feature-toggle-delta-read-model.test.d.ts.map +1 -0
  49. package/dist/lib/features/client-feature-toggles/delta/client-feature-toggle-delta-read-model.test.js +59 -0
  50. package/dist/lib/features/client-feature-toggles/delta/client-feature-toggle-delta-read-model.test.js.map +1 -0
  51. package/dist/lib/features/client-feature-toggles/delta/client-feature-toggle-delta.d.ts +9 -3
  52. package/dist/lib/features/client-feature-toggles/delta/client-feature-toggle-delta.d.ts.map +1 -1
  53. package/dist/lib/features/client-feature-toggles/delta/client-feature-toggle-delta.js +165 -92
  54. package/dist/lib/features/client-feature-toggles/delta/client-feature-toggle-delta.js.map +1 -1
  55. package/dist/lib/features/client-feature-toggles/delta/client-feature-toggle-delta.test.js +475 -1
  56. package/dist/lib/features/client-feature-toggles/delta/client-feature-toggle-delta.test.js.map +1 -1
  57. package/dist/lib/features/client-feature-toggles/delta/delta-cache.d.ts.map +1 -1
  58. package/dist/lib/features/client-feature-toggles/delta/delta-cache.js +3 -0
  59. package/dist/lib/features/client-feature-toggles/delta/delta-cache.js.map +1 -1
  60. package/dist/lib/features/client-feature-toggles/delta/delta-cache.test.js +15 -0
  61. package/dist/lib/features/client-feature-toggles/delta/delta-cache.test.js.map +1 -1
  62. package/dist/lib/features/client-feature-toggles/delta/visible-revision.d.ts +3 -0
  63. package/dist/lib/features/client-feature-toggles/delta/visible-revision.d.ts.map +1 -0
  64. package/dist/lib/features/client-feature-toggles/delta/visible-revision.js +16 -0
  65. package/dist/lib/features/client-feature-toggles/delta/visible-revision.js.map +1 -0
  66. package/dist/lib/features/client-feature-toggles/delta/visible-revision.test.d.ts +2 -0
  67. package/dist/lib/features/client-feature-toggles/delta/visible-revision.test.d.ts.map +1 -0
  68. package/dist/lib/features/client-feature-toggles/delta/visible-revision.test.js +25 -0
  69. package/dist/lib/features/client-feature-toggles/delta/visible-revision.test.js.map +1 -0
  70. package/dist/lib/features/context/context.d.ts +0 -1
  71. package/dist/lib/features/context/context.d.ts.map +1 -1
  72. package/dist/lib/features/context/context.js +7 -15
  73. package/dist/lib/features/context/context.js.map +1 -1
  74. package/dist/lib/features/edgetokens/edge-token-store.d.ts +2 -0
  75. package/dist/lib/features/edgetokens/edge-token-store.d.ts.map +1 -1
  76. package/dist/lib/features/edgetokens/edge-token-store.js +20 -0
  77. package/dist/lib/features/edgetokens/edge-token-store.js.map +1 -1
  78. package/dist/lib/features/edgetokens/fake-edge-token-store.d.ts +2 -0
  79. package/dist/lib/features/edgetokens/fake-edge-token-store.d.ts.map +1 -1
  80. package/dist/lib/features/edgetokens/fake-edge-token-store.js +6 -0
  81. package/dist/lib/features/edgetokens/fake-edge-token-store.js.map +1 -1
  82. package/dist/lib/features/events/event-store.d.ts +2 -4
  83. package/dist/lib/features/events/event-store.d.ts.map +1 -1
  84. package/dist/lib/features/events/event-store.js +1 -4
  85. package/dist/lib/features/events/event-store.js.map +1 -1
  86. package/dist/lib/features/feature-search/feature-search-controller.d.ts.map +1 -1
  87. package/dist/lib/features/feature-search/feature-search-controller.js +2 -1
  88. package/dist/lib/features/feature-search/feature-search-controller.js.map +1 -1
  89. package/dist/lib/features/feature-search/feature-search-service.d.ts.map +1 -1
  90. package/dist/lib/features/feature-search/feature-search-service.js +5 -0
  91. package/dist/lib/features/feature-search/feature-search-service.js.map +1 -1
  92. package/dist/lib/features/feature-search/feature-search-store.d.ts.map +1 -1
  93. package/dist/lib/features/feature-search/feature-search-store.js +17 -1
  94. package/dist/lib/features/feature-search/feature-search-store.js.map +1 -1
  95. package/dist/lib/features/feature-search/feature.search.e2e.test.js +56 -1
  96. package/dist/lib/features/feature-search/feature.search.e2e.test.js.map +1 -1
  97. package/dist/lib/features/feature-toggle/configuration-revision-service.d.ts +1 -2
  98. package/dist/lib/features/feature-toggle/configuration-revision-service.d.ts.map +1 -1
  99. package/dist/lib/features/feature-toggle/configuration-revision-service.js +2 -10
  100. package/dist/lib/features/feature-toggle/configuration-revision-service.js.map +1 -1
  101. package/dist/lib/features/feature-toggle/feature-toggle-strategies-store.d.ts.map +1 -1
  102. package/dist/lib/features/feature-toggle/feature-toggle-strategies-store.js +3 -2
  103. package/dist/lib/features/feature-toggle/feature-toggle-strategies-store.js.map +1 -1
  104. package/dist/lib/features/feature-toggle/types/feature-toggle-strategies-store-type.d.ts +1 -0
  105. package/dist/lib/features/feature-toggle/types/feature-toggle-strategies-store-type.d.ts.map +1 -1
  106. package/dist/lib/features/frontend-api/frontend-api-service.d.ts.map +1 -1
  107. package/dist/lib/features/frontend-api/frontend-api-service.js +8 -0
  108. package/dist/lib/features/frontend-api/frontend-api-service.js.map +1 -1
  109. package/dist/lib/features/frontend-api/frontend-api.e2e.test.js +43 -0
  110. package/dist/lib/features/frontend-api/frontend-api.e2e.test.js.map +1 -1
  111. package/dist/lib/features/frontend-api/frontend-api.middleware.e2e.test.d.ts +3 -0
  112. package/dist/lib/features/frontend-api/frontend-api.middleware.e2e.test.d.ts.map +1 -0
  113. package/dist/lib/features/frontend-api/frontend-api.middleware.e2e.test.js +1071 -0
  114. package/dist/lib/features/frontend-api/frontend-api.middleware.e2e.test.js.map +1 -0
  115. package/dist/lib/features/index.d.ts +1 -0
  116. package/dist/lib/features/index.d.ts.map +1 -1
  117. package/dist/lib/features/index.js +1 -0
  118. package/dist/lib/features/index.js.map +1 -1
  119. package/dist/lib/features/instance-stats/instance-stats-service.d.ts.map +1 -1
  120. package/dist/lib/features/instance-stats/instance-stats-service.js +1 -3
  121. package/dist/lib/features/instance-stats/instance-stats-service.js.map +1 -1
  122. package/dist/lib/features/metrics/impact/impact-metrics.e2e.test.js +12 -12
  123. package/dist/lib/features/metrics/impact/impact-metrics.e2e.test.js.map +1 -1
  124. package/dist/lib/features/metrics/impact/metrics-translator.d.ts +5 -2
  125. package/dist/lib/features/metrics/impact/metrics-translator.d.ts.map +1 -1
  126. package/dist/lib/features/metrics/impact/metrics-translator.js +86 -102
  127. package/dist/lib/features/metrics/impact/metrics-translator.js.map +1 -1
  128. package/dist/lib/features/metrics/impact/metrics-translator.test.js +70 -112
  129. package/dist/lib/features/metrics/impact/metrics-translator.test.js.map +1 -1
  130. package/dist/lib/features/project/createProjectService.d.ts.map +1 -1
  131. package/dist/lib/features/project/createProjectService.js +6 -0
  132. package/dist/lib/features/project/createProjectService.js.map +1 -1
  133. package/dist/lib/features/project/project-service.d.ts +2 -1
  134. package/dist/lib/features/project/project-service.d.ts.map +1 -1
  135. package/dist/lib/features/project/project-service.js +3 -1
  136. package/dist/lib/features/project/project-service.js.map +1 -1
  137. package/dist/lib/features/project-environments/project-environments.e2e.test.js +37 -0
  138. package/dist/lib/features/project-environments/project-environments.e2e.test.js.map +1 -1
  139. package/dist/lib/features/release-plans/release-plan-milestone-strategy-service.d.ts.map +1 -1
  140. package/dist/lib/features/release-plans/release-plan-milestone-strategy-service.js +2 -5
  141. package/dist/lib/features/release-plans/release-plan-milestone-strategy-service.js.map +1 -1
  142. package/dist/lib/features/release-plans/release-plan-milestone-strategy-service.test.js +2 -2
  143. package/dist/lib/features/release-plans/release-plan-milestone-strategy-service.test.js.map +1 -1
  144. package/dist/lib/features/release-plans/release-plan-milestone-strategy-store.d.ts +2 -1
  145. package/dist/lib/features/release-plans/release-plan-milestone-strategy-store.d.ts.map +1 -1
  146. package/dist/lib/features/release-plans/release-plan-milestone-strategy-store.js +20 -3
  147. package/dist/lib/features/release-plans/release-plan-milestone-strategy-store.js.map +1 -1
  148. package/dist/lib/features/release-plans/release-plan-milestone-strategy.d.ts +2 -0
  149. package/dist/lib/features/release-plans/release-plan-milestone-strategy.d.ts.map +1 -1
  150. package/dist/lib/features/release-plans/release-plan-store.d.ts.map +1 -1
  151. package/dist/lib/features/release-plans/release-plan-store.js +2 -0
  152. package/dist/lib/features/release-plans/release-plan-store.js.map +1 -1
  153. package/dist/lib/features/release-plans/release-plan-template-store.d.ts.map +1 -1
  154. package/dist/lib/features/release-plans/release-plan-template-store.js +4 -3
  155. package/dist/lib/features/release-plans/release-plan-template-store.js.map +1 -1
  156. package/dist/lib/features/release-plans/release-plan-template-store.test.d.ts +2 -0
  157. package/dist/lib/features/release-plans/release-plan-template-store.test.d.ts.map +1 -0
  158. package/dist/lib/features/release-plans/release-plan-template-store.test.js +47 -0
  159. package/dist/lib/features/release-plans/release-plan-template-store.test.js.map +1 -0
  160. package/dist/lib/metric-events.d.ts +3 -2
  161. package/dist/lib/metric-events.d.ts.map +1 -1
  162. package/dist/lib/metric-events.js +2 -1
  163. package/dist/lib/metric-events.js.map +1 -1
  164. package/dist/lib/middleware/api-token-middleware.d.ts.map +1 -1
  165. package/dist/lib/middleware/api-token-middleware.js +1 -5
  166. package/dist/lib/middleware/api-token-middleware.js.map +1 -1
  167. package/dist/lib/middleware/api-token-middleware.test.js +35 -25
  168. package/dist/lib/middleware/api-token-middleware.test.js.map +1 -1
  169. package/dist/lib/middleware/backend-token-middleware.d.ts +5 -0
  170. package/dist/lib/middleware/backend-token-middleware.d.ts.map +1 -0
  171. package/dist/lib/middleware/backend-token-middleware.js +61 -0
  172. package/dist/lib/middleware/backend-token-middleware.js.map +1 -0
  173. package/dist/lib/middleware/backend-token-middleware.test.d.ts +2 -0
  174. package/dist/lib/middleware/backend-token-middleware.test.d.ts.map +1 -0
  175. package/dist/lib/middleware/backend-token-middleware.test.js +73 -0
  176. package/dist/lib/middleware/backend-token-middleware.test.js.map +1 -0
  177. package/dist/lib/middleware/conditional-middleware.d.ts +20 -0
  178. package/dist/lib/middleware/conditional-middleware.d.ts.map +1 -1
  179. package/dist/lib/middleware/conditional-middleware.js +26 -0
  180. package/dist/lib/middleware/conditional-middleware.js.map +1 -1
  181. package/dist/lib/middleware/conditional-middleware.test.d.ts +2 -0
  182. package/dist/lib/middleware/conditional-middleware.test.d.ts.map +1 -0
  183. package/dist/lib/middleware/conditional-middleware.test.js +31 -0
  184. package/dist/lib/middleware/conditional-middleware.test.js.map +1 -0
  185. package/dist/lib/middleware/frontend-token-middleware.d.ts +5 -0
  186. package/dist/lib/middleware/frontend-token-middleware.d.ts.map +1 -0
  187. package/dist/lib/middleware/frontend-token-middleware.js +61 -0
  188. package/dist/lib/middleware/frontend-token-middleware.js.map +1 -0
  189. package/dist/lib/middleware/user-token-client-api-logger-middleware.js +1 -1
  190. package/dist/lib/middleware/user-token-client-api-logger-middleware.js.map +1 -1
  191. package/dist/lib/openapi/spec/event-schema.d.ts +1 -1
  192. package/dist/lib/openapi/spec/event-search-response-schema.d.ts +1 -1
  193. package/dist/lib/openapi/spec/events-schema.d.ts +1 -1
  194. package/dist/lib/openapi/spec/export-result-schema.d.ts +1018 -100
  195. package/dist/lib/openapi/spec/export-result-schema.d.ts.map +1 -1
  196. package/dist/lib/openapi/spec/export-result-schema.js +4 -2
  197. package/dist/lib/openapi/spec/export-result-schema.js.map +1 -1
  198. package/dist/lib/openapi/spec/feature-environment-safeguard-schema.d.ts +168 -0
  199. package/dist/lib/openapi/spec/feature-environment-safeguard-schema.d.ts.map +1 -0
  200. package/dist/lib/openapi/spec/feature-environment-safeguard-schema.js +66 -0
  201. package/dist/lib/openapi/spec/feature-environment-safeguard-schema.js.map +1 -0
  202. package/dist/lib/openapi/spec/feature-environment-schema.d.ts +265 -7
  203. package/dist/lib/openapi/spec/feature-environment-schema.d.ts.map +1 -1
  204. package/dist/lib/openapi/spec/feature-environment-schema.js +13 -0
  205. package/dist/lib/openapi/spec/feature-environment-schema.js.map +1 -1
  206. package/dist/lib/openapi/spec/feature-events-schema.d.ts +1 -1
  207. package/dist/lib/openapi/spec/feature-schema.d.ts +475 -16
  208. package/dist/lib/openapi/spec/feature-schema.d.ts.map +1 -1
  209. package/dist/lib/openapi/spec/feature-schema.js +4 -2
  210. package/dist/lib/openapi/spec/feature-schema.js.map +1 -1
  211. package/dist/lib/openapi/spec/feature-search-environment-schema.d.ts +688 -14
  212. package/dist/lib/openapi/spec/feature-search-environment-schema.d.ts.map +1 -1
  213. package/dist/lib/openapi/spec/feature-search-environment-schema.js +8 -0
  214. package/dist/lib/openapi/spec/feature-search-environment-schema.js.map +1 -1
  215. package/dist/lib/openapi/spec/feature-search-query-parameters.d.ts +10 -1
  216. package/dist/lib/openapi/spec/feature-search-query-parameters.d.ts.map +1 -1
  217. package/dist/lib/openapi/spec/feature-search-query-parameters.js +10 -0
  218. package/dist/lib/openapi/spec/feature-search-query-parameters.js.map +1 -1
  219. package/dist/lib/openapi/spec/feature-search-response-schema.d.ts +8097 -155
  220. package/dist/lib/openapi/spec/feature-search-response-schema.d.ts.map +1 -1
  221. package/dist/lib/openapi/spec/feature-search-response-schema.js +22 -0
  222. package/dist/lib/openapi/spec/feature-search-response-schema.js.map +1 -1
  223. package/dist/lib/openapi/spec/health-overview-schema.d.ts +1336 -210
  224. package/dist/lib/openapi/spec/health-overview-schema.d.ts.map +1 -1
  225. package/dist/lib/openapi/spec/health-overview-schema.js +8 -0
  226. package/dist/lib/openapi/spec/health-overview-schema.js.map +1 -1
  227. package/dist/lib/openapi/spec/health-report-schema.d.ts +1336 -210
  228. package/dist/lib/openapi/spec/health-report-schema.d.ts.map +1 -1
  229. package/dist/lib/openapi/spec/import-toggles-schema.d.ts +2 -2
  230. package/dist/lib/openapi/spec/import-toggles-schema.d.ts.map +1 -1
  231. package/dist/lib/openapi/spec/import-toggles-schema.js +4 -2
  232. package/dist/lib/openapi/spec/import-toggles-schema.js.map +1 -1
  233. package/dist/lib/openapi/spec/index.d.ts +4 -2
  234. package/dist/lib/openapi/spec/index.d.ts.map +1 -1
  235. package/dist/lib/openapi/spec/index.js +4 -2
  236. package/dist/lib/openapi/spec/index.js.map +1 -1
  237. package/dist/lib/openapi/spec/integration-event-schema.d.ts +1 -1
  238. package/dist/lib/openapi/spec/integration-events-schema.d.ts +2 -2
  239. package/dist/lib/openapi/spec/metric-query-schema.d.ts +6 -0
  240. package/dist/lib/openapi/spec/metric-query-schema.d.ts.map +1 -1
  241. package/dist/lib/openapi/spec/metric-query-schema.js +6 -0
  242. package/dist/lib/openapi/spec/metric-query-schema.js.map +1 -1
  243. package/dist/lib/openapi/spec/profile-schema.d.ts +475 -16
  244. package/dist/lib/openapi/spec/profile-schema.d.ts.map +1 -1
  245. package/dist/lib/openapi/spec/project-overview-schema.d.ts +1336 -210
  246. package/dist/lib/openapi/spec/project-overview-schema.d.ts.map +1 -1
  247. package/dist/lib/openapi/spec/project-overview-schema.js +8 -0
  248. package/dist/lib/openapi/spec/project-overview-schema.js.map +1 -1
  249. package/dist/lib/openapi/spec/release-plan-milestone-schema.d.ts +1 -1
  250. package/dist/lib/openapi/spec/release-plan-milestone-strategy-schema.d.ts +1 -1
  251. package/dist/lib/openapi/spec/release-plan-milestone-strategy-schema.js +1 -1
  252. package/dist/lib/openapi/spec/release-plan-milestone-strategy-schema.js.map +1 -1
  253. package/dist/lib/openapi/spec/{safeguard-schema.d.ts → release-plan-safeguard-schema.d.ts} +16 -4
  254. package/dist/lib/openapi/spec/release-plan-safeguard-schema.d.ts.map +1 -0
  255. package/dist/lib/openapi/spec/{safeguard-schema.js → release-plan-safeguard-schema.js} +3 -3
  256. package/dist/lib/openapi/spec/release-plan-safeguard-schema.js.map +1 -0
  257. package/dist/lib/openapi/spec/release-plan-schema.d.ts +23 -5
  258. package/dist/lib/openapi/spec/release-plan-schema.d.ts.map +1 -1
  259. package/dist/lib/openapi/spec/release-plan-schema.js +3 -3
  260. package/dist/lib/openapi/spec/release-plan-schema.js.map +1 -1
  261. package/dist/lib/openapi/spec/release-plan-template-schema.d.ts +2 -2
  262. package/dist/lib/openapi/spec/release-plan-templates-schema.d.ts +2897 -0
  263. package/dist/lib/openapi/spec/release-plan-templates-schema.d.ts.map +1 -0
  264. package/dist/lib/openapi/spec/release-plan-templates-schema.js +29 -0
  265. package/dist/lib/openapi/spec/release-plan-templates-schema.js.map +1 -0
  266. package/dist/lib/openapi/spec/release-plans-schema.d.ts +45 -9
  267. package/dist/lib/openapi/spec/release-plans-schema.d.ts.map +1 -1
  268. package/dist/lib/openapi/spec/release-plans-schema.js +2 -2
  269. package/dist/lib/openapi/spec/release-plans-schema.js.map +1 -1
  270. package/dist/lib/openapi/spec/search-features-schema.d.ts +13694 -5078
  271. package/dist/lib/openapi/spec/search-features-schema.d.ts.map +1 -1
  272. package/dist/lib/routes/admin-api/api-token.js +1 -1
  273. package/dist/lib/routes/admin-api/api-token.js.map +1 -1
  274. package/dist/lib/routes/admin-api/project/api-token.js +1 -1
  275. package/dist/lib/routes/admin-api/project/api-token.js.map +1 -1
  276. package/dist/lib/routes/logout.js +1 -1
  277. package/dist/lib/routes/logout.js.map +1 -1
  278. package/dist/lib/routes/logout.test.js +4 -4
  279. package/dist/lib/routes/logout.test.js.map +1 -1
  280. package/dist/lib/schema/api-token-schema.d.ts.map +1 -1
  281. package/dist/lib/schema/api-token-schema.js +1 -0
  282. package/dist/lib/schema/api-token-schema.js.map +1 -1
  283. package/dist/lib/server-impl.d.ts +5 -5
  284. package/dist/lib/server-impl.d.ts.map +1 -1
  285. package/dist/lib/server-impl.js +3 -3
  286. package/dist/lib/server-impl.js.map +1 -1
  287. package/dist/lib/services/api-token-service.d.ts +2 -2
  288. package/dist/lib/services/api-token-service.d.ts.map +1 -1
  289. package/dist/lib/services/api-token-service.js +5 -3
  290. package/dist/lib/services/api-token-service.js.map +1 -1
  291. package/dist/lib/services/api-token-service.test.js +5 -4
  292. package/dist/lib/services/api-token-service.test.js.map +1 -1
  293. package/dist/lib/services/edge-service.d.ts +1 -0
  294. package/dist/lib/services/edge-service.d.ts.map +1 -1
  295. package/dist/lib/services/edge-service.js +5 -2
  296. package/dist/lib/services/edge-service.js.map +1 -1
  297. package/dist/lib/services/user-service.d.ts.map +1 -1
  298. package/dist/lib/services/user-service.js +0 -4
  299. package/dist/lib/services/user-service.js.map +1 -1
  300. package/dist/lib/types/experimental.d.ts +1 -1
  301. package/dist/lib/types/experimental.d.ts.map +1 -1
  302. package/dist/lib/types/experimental.js +7 -8
  303. package/dist/lib/types/experimental.js.map +1 -1
  304. package/dist/lib/types/model.d.ts +2 -1
  305. package/dist/lib/types/model.d.ts.map +1 -1
  306. package/dist/lib/types/model.js.map +1 -1
  307. package/dist/lib/types/option.d.ts +2 -0
  308. package/dist/lib/types/option.d.ts.map +1 -1
  309. package/dist/lib/types/stores/api-token-store.d.ts +2 -1
  310. package/dist/lib/types/stores/api-token-store.d.ts.map +1 -1
  311. package/dist/lib/types/stores/edge-store.d.ts +2 -0
  312. package/dist/lib/types/stores/edge-store.d.ts.map +1 -1
  313. package/dist/lib/types/stores/event-store.d.ts +1 -1
  314. package/dist/lib/types/stores/event-store.d.ts.map +1 -1
  315. package/dist/lib/util/clone-db-config.d.ts +3 -0
  316. package/dist/lib/util/clone-db-config.d.ts.map +1 -0
  317. package/dist/lib/util/clone-db-config.js +18 -0
  318. package/dist/lib/util/clone-db-config.js.map +1 -0
  319. package/dist/lib/util/clone-db-config.test.d.ts +2 -0
  320. package/dist/lib/util/clone-db-config.test.d.ts.map +1 -0
  321. package/dist/lib/util/clone-db-config.test.js +40 -0
  322. package/dist/lib/util/clone-db-config.test.js.map +1 -0
  323. package/dist/lib/util/db-lock.d.ts.map +1 -1
  324. package/dist/lib/util/db-lock.js +2 -3
  325. package/dist/lib/util/db-lock.js.map +1 -1
  326. package/dist/lib/util/sortStrategies.d.ts +1 -1
  327. package/dist/lib/util/sortStrategies.d.ts.map +1 -1
  328. package/dist/lib/util/sortStrategies.js +6 -2
  329. package/dist/lib/util/sortStrategies.js.map +1 -1
  330. package/dist/lib/util/sortStrategies.test.js +21 -0
  331. package/dist/lib/util/sortStrategies.test.js.map +1 -1
  332. package/dist/migrations/20260309125735-drop-cascade-for-edge-api-token.d.ts +3 -0
  333. package/dist/migrations/20260309125735-drop-cascade-for-edge-api-token.d.ts.map +1 -0
  334. package/dist/migrations/20260309125735-drop-cascade-for-edge-api-token.js +15 -0
  335. package/dist/migrations/20260309125735-drop-cascade-for-edge-api-token.js.map +1 -0
  336. package/dist/migrations/20260310134100-split-safeguards-table.d.ts +3 -0
  337. package/dist/migrations/20260310134100-split-safeguards-table.d.ts.map +1 -0
  338. package/dist/migrations/20260310134100-split-safeguards-table.js +31 -0
  339. package/dist/migrations/20260310134100-split-safeguards-table.js.map +1 -0
  340. package/dist/migrations/20260311073041-migrate-safeguards-data.d.ts +3 -0
  341. package/dist/migrations/20260311073041-migrate-safeguards-data.d.ts.map +1 -0
  342. package/dist/migrations/20260311073041-migrate-safeguards-data.js +42 -0
  343. package/dist/migrations/20260311073041-migrate-safeguards-data.js.map +1 -0
  344. package/dist/migrations/20260312100000-release-plans-fix-cascade-on-env-disconnect.d.ts +3 -0
  345. package/dist/migrations/20260312100000-release-plans-fix-cascade-on-env-disconnect.d.ts.map +1 -0
  346. package/dist/migrations/20260312100000-release-plans-fix-cascade-on-env-disconnect.js +31 -0
  347. package/dist/migrations/20260312100000-release-plans-fix-cascade-on-env-disconnect.js.map +1 -0
  348. package/dist/migrations/20260316113111-update-memory-usage-to-big-int.d.ts +3 -0
  349. package/dist/migrations/20260316113111-update-memory-usage-to-big-int.d.ts.map +1 -0
  350. package/dist/migrations/20260316113111-update-memory-usage-to-big-int.js +8 -0
  351. package/dist/migrations/20260316113111-update-memory-usage-to-big-int.js.map +1 -0
  352. package/dist/migrations/20260316140000-safeguards-fix-cascade-on-env-disconnect.d.ts +3 -0
  353. package/dist/migrations/20260316140000-safeguards-fix-cascade-on-env-disconnect.d.ts.map +1 -0
  354. package/dist/migrations/20260316140000-safeguards-fix-cascade-on-env-disconnect.js +54 -0
  355. package/dist/migrations/20260316140000-safeguards-fix-cascade-on-env-disconnect.js.map +1 -0
  356. package/dist/migrations/20260317140000-safeguards-drop-project-not-null.d.ts +3 -0
  357. package/dist/migrations/20260317140000-safeguards-drop-project-not-null.d.ts.map +1 -0
  358. package/dist/migrations/20260317140000-safeguards-drop-project-not-null.js +21 -0
  359. package/dist/migrations/20260317140000-safeguards-drop-project-not-null.js.map +1 -0
  360. package/dist/migrations/20260318100000-safeguards-drop-project-column.d.ts +3 -0
  361. package/dist/migrations/20260318100000-safeguards-drop-project-column.d.ts.map +1 -0
  362. package/dist/migrations/20260318100000-safeguards-drop-project-column.js +14 -0
  363. package/dist/migrations/20260318100000-safeguards-drop-project-column.js.map +1 -0
  364. package/dist/migrations/20260406132537-user-access-requests.d.ts +3 -0
  365. package/dist/migrations/20260406132537-user-access-requests.d.ts.map +1 -0
  366. package/dist/migrations/20260406132537-user-access-requests.js +16 -0
  367. package/dist/migrations/20260406132537-user-access-requests.js.map +1 -0
  368. package/dist/migrations/20260406161629-user-access-requests-unique-email.d.ts +3 -0
  369. package/dist/migrations/20260406161629-user-access-requests-unique-email.d.ts.map +1 -0
  370. package/dist/migrations/20260406161629-user-access-requests-unique-email.js +14 -0
  371. package/dist/migrations/20260406161629-user-access-requests-unique-email.js.map +1 -0
  372. package/dist/migrator.d.ts.map +1 -1
  373. package/dist/migrator.js +4 -3
  374. package/dist/migrator.js.map +1 -1
  375. package/dist/server-dev.js +4 -7
  376. package/dist/server-dev.js.map +1 -1
  377. package/dist/test/e2e/api/admin/api-token.auth.e2e.test.js +5 -5
  378. package/dist/test/e2e/api/admin/api-token.auth.e2e.test.js.map +1 -1
  379. package/dist/test/e2e/api/admin/api-token.e2e.test.js +3 -2
  380. package/dist/test/e2e/api/admin/api-token.e2e.test.js.map +1 -1
  381. package/dist/test/e2e/api/admin/conditional-middleware.e2e.test.js +106 -38
  382. package/dist/test/e2e/api/admin/conditional-middleware.e2e.test.js.map +1 -1
  383. package/dist/test/e2e/api/admin/context-api-include-query-params.e2e.test.js +1 -7
  384. package/dist/test/e2e/api/admin/context-api-include-query-params.e2e.test.js.map +1 -1
  385. package/dist/test/e2e/api/admin/project/api-token.e2e.test.js +2 -1
  386. package/dist/test/e2e/api/admin/project/api-token.e2e.test.js.map +1 -1
  387. package/dist/test/e2e/api/admin/project/project.api.tokens.e2e.test.js +5 -5
  388. package/dist/test/e2e/api/admin/project/project.api.tokens.e2e.test.js.map +1 -1
  389. package/dist/test/e2e/api/admin/project-context.e2e.test.js +1 -7
  390. package/dist/test/e2e/api/admin/project-context.e2e.test.js.map +1 -1
  391. package/dist/test/e2e/api/client/feature.token.access.e2e.test.js +34 -1
  392. package/dist/test/e2e/api/client/feature.token.access.e2e.test.js.map +1 -1
  393. package/dist/test/e2e/services/api-token-service.e2e.test.js +21 -6
  394. package/dist/test/e2e/services/api-token-service.e2e.test.js.map +1 -1
  395. package/dist/test/e2e/services/edge-service.e2e.test.js +4 -3
  396. package/dist/test/e2e/services/edge-service.e2e.test.js.map +1 -1
  397. package/dist/test/e2e/stores/api-token-store.e2e.test.js +15 -14
  398. package/dist/test/e2e/stores/api-token-store.e2e.test.js.map +1 -1
  399. package/dist/test/e2e/stores/event-store.e2e.test.js +8 -9
  400. package/dist/test/e2e/stores/event-store.e2e.test.js.map +1 -1
  401. package/dist/test/fixtures/fake-api-token-store.d.ts +2 -1
  402. package/dist/test/fixtures/fake-api-token-store.d.ts.map +1 -1
  403. package/dist/test/fixtures/fake-api-token-store.js +4 -1
  404. package/dist/test/fixtures/fake-api-token-store.js.map +1 -1
  405. package/dist/test/fixtures/fake-event-store.d.ts +1 -1
  406. package/dist/test/fixtures/fake-event-store.d.ts.map +1 -1
  407. package/dist/test/fixtures/fake-event-store.js +1 -1
  408. package/dist/test/fixtures/fake-event-store.js.map +1 -1
  409. package/dist/test/fixtures/fake-release-plan-milestone-strategy-store.d.ts +2 -2
  410. package/dist/test/fixtures/fake-release-plan-milestone-strategy-store.d.ts.map +1 -1
  411. package/dist/test/fixtures/fake-release-plan-milestone-strategy-store.js +3 -2
  412. package/dist/test/fixtures/fake-release-plan-milestone-strategy-store.js.map +1 -1
  413. package/frontend/build/index.html +1 -1
  414. package/frontend/build/static/AdvancedPlayground-BTPrG6RW.js +3 -0
  415. package/frontend/build/static/BackendConnections-CRh8Vxoe.js +1 -0
  416. package/frontend/build/static/{CreateProject-DV-Ad8Sn.js → CreateProject-DEMalH1j.js} +1 -1
  417. package/frontend/build/static/EnterpriseEdge-Cp-pGMa0.js +6 -0
  418. package/frontend/build/static/FeatureMetricsChart-DQOE71LA.js +2 -0
  419. package/frontend/build/static/FeatureStaleDialog-B6BfnDiQ.js +689 -0
  420. package/frontend/build/static/{FeatureViewLazyExport-Bsw7-knb.js → FeatureViewLazyExport-BkNTNFqK.js} +4 -7
  421. package/frontend/build/static/FlagMetricsChart-zYDF9bet.js +2 -0
  422. package/frontend/build/static/FrontendNetworkTrafficUsage-CbxdFXH7.js +1 -0
  423. package/frontend/build/static/GridLayoutWrapper-Cq6Bzm36.js +3 -0
  424. package/frontend/build/static/ImpactMetricsPage-CFYXYXPb.js +1 -0
  425. package/frontend/build/static/LazyAdminExport-ByTh4iFa.js +38 -0
  426. package/frontend/build/static/LazyProjectExport-K12Xy3w9.js +46 -0
  427. package/frontend/build/static/{LifecycleChartComponent-cxR-TN3V.js → LifecycleChartComponent-DHvlFNd2.js} +3 -3
  428. package/frontend/build/static/LineChartComponent-BlhKm3cw.js +1 -0
  429. package/frontend/build/static/MarkCompletedDialogue-apmlFjVY.js +1 -0
  430. package/frontend/build/static/{NetworkOverview-DxaPXUzZ.js → NetworkOverview-BiLOuQ4c.js} +1 -1
  431. package/frontend/build/static/{NetworkPrometheusAPIWarning-ltyTlXFF.js → NetworkPrometheusAPIWarning-CYo3j2Tj.js} +1 -1
  432. package/frontend/build/static/{NetworkTraffic-Dhw4yIBs.js → NetworkTraffic-DONL5oIx.js} +1 -1
  433. package/frontend/build/static/NetworkTrafficUsage-DjQiYq0S.js +1 -0
  434. package/frontend/build/static/{PercentageDonut-JGNh2FVZ.js → PercentageDonut-CA9hYg3v.js} +1 -1
  435. package/frontend/build/static/{ReactJSONEditor-GHl7KvdS.js → ReactJSONEditor-9cJL1vJY.js} +31 -31
  436. package/frontend/build/static/{RoleCell-CjVCxBgl.js → RoleCell-ZzU5Oqy8.js} +1 -1
  437. package/frontend/build/static/Safeguard-DY1N4aPz.js +1 -0
  438. package/frontend/build/static/aggregateFeatureMetrics-D6bHft_C.js +1 -0
  439. package/frontend/build/static/{formatTickValue-BZb4ZIL9.js → formatTickValue-BcLsqREh.js} +2 -2
  440. package/frontend/build/static/{index-DcWBU_a4.js → index-B87DWXbl.js} +1 -1
  441. package/frontend/build/static/index-CoLhlfXP.js +565 -0
  442. package/frontend/build/static/loginBackground-CQx0IRYc.png +0 -0
  443. package/frontend/build/static/{networkTrafficUsageHighlightPlugin-BbfAyDiQ.js → networkTrafficUsageHighlightPlugin-CqEM-cK_.js} +1 -1
  444. package/frontend/build/static/passwordSuccess-fcvTEYOw.png +0 -0
  445. package/frontend/build/static/useApiTokens-ClWvohC9.js +1 -0
  446. package/frontend/package.json +50 -42
  447. package/package.json +11 -10
  448. package/dist/lib/openapi/spec/safeguard-schema.d.ts.map +0 -1
  449. package/dist/lib/openapi/spec/safeguard-schema.js.map +0 -1
  450. package/frontend/build/static/AdvancedPlayground-CF0hkpiE.js +0 -3
  451. package/frontend/build/static/BackendConnections-DhZczar-.js +0 -1
  452. package/frontend/build/static/EnterpriseEdge-D1To2ugP.js +0 -3
  453. package/frontend/build/static/FeatureMetricsChart-D8sRgx5P.js +0 -2
  454. package/frontend/build/static/FeatureStaleDialog-DOkhgvaj.js +0 -7
  455. package/frontend/build/static/FlagMetricsChart-CF_kEyQa.js +0 -2
  456. package/frontend/build/static/FrontendNetworkTrafficUsage-C8zJSvoc.js +0 -1
  457. package/frontend/build/static/GridLayoutWrapper-DpJcUbQB.js +0 -3
  458. package/frontend/build/static/ImpactMetricsPage-KLVv-tP4.js +0 -1
  459. package/frontend/build/static/LazyAdminExport-CWQiknO-.js +0 -38
  460. package/frontend/build/static/LazyProjectExport-DsMn4Yxm.js +0 -728
  461. package/frontend/build/static/LineChartComponent-_yZEp3dd.js +0 -1
  462. package/frontend/build/static/MarkCompletedDialogue-DFtLyDN0.js +0 -1
  463. package/frontend/build/static/NetworkTrafficUsage-deKWRhIS.js +0 -1
  464. package/frontend/build/static/aggregateFeatureMetrics-YEdZNNoV.js +0 -1
  465. package/frontend/build/static/index-DMSjiFEm.js +0 -583
  466. package/frontend/build/static/useApiTokens-DBB3NvXL.js +0 -1
@@ -1,7 +1,7 @@
1
1
  let Zs=[],va=[];(()=>{let n="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,t=0;e<n.length;e++)(e%2?va:Zs).push(t=t+n[e])})();function Cf(n){if(n<768)return!1;for(let e=0,t=Zs.length;;){let i=e+t>>1;if(n<Zs[i])t=i;else if(n>=va[i])e=i+1;else return!0;if(e==t)return!1}}function Lo(n){return n>=127462&&n<=127487}const Eo=8205;function Af(n,e,t=!0,i=!0){return(t?Sa:Mf)(n,e,i)}function Sa(n,e,t){if(e==n.length)return e;e&&Ca(n.charCodeAt(e))&&Aa(n.charCodeAt(e-1))&&e--;let i=Ss(n,e);for(e+=Io(i);e<n.length;){let s=Ss(n,e);if(i==Eo||s==Eo||t&&Cf(s))e+=Io(s),i=s;else if(Lo(s)){let r=0,o=e-2;for(;o>=0&&Lo(Ss(n,o));)r++,o-=2;if(r%2==0)break;e+=2}else break}return e}function Mf(n,e,t){for(;e>0;){let i=Sa(n,e-2,t);if(i<e)return i;e--}return 0}function Ss(n,e){let t=n.charCodeAt(e);if(!Aa(t)||e+1==n.length)return t;let i=n.charCodeAt(e+1);return Ca(i)?(t-55296<<10)+(i-56320)+65536:t}function Ca(n){return n>=56320&&n<57344}function Aa(n){return n>=55296&&n<56320}function Io(n){return n<65536?1:2}class F{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,i){[e,t]=ni(this,e,t);let s=[];return this.decompose(0,e,s,2),i.length&&i.decompose(0,i.length,s,3),this.decompose(t,this.length,s,1),Ye.from(s,this.length-(t-e)+i.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=ni(this,e,t);let i=[];return this.decompose(e,t,i,0),Ye.from(i,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),i=this.length-this.scanIdentical(e,-1),s=new xi(this),r=new xi(e);for(let o=t,l=t;;){if(s.next(o),r.next(o),o=0,s.lineBreak!=r.lineBreak||s.done!=r.done||s.value!=r.value)return!1;if(l+=s.value.length,s.done||l>=i)return!0}}iter(e=1){return new xi(this,e)}iterRange(e,t=this.length){return new Ma(this,e,t)}iterLines(e,t){let i;if(e==null)i=this.iter();else{t==null&&(t=this.lines+1);let s=this.line(e).from;i=this.iterRange(s,Math.max(s,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new Oa(i)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?F.empty:e.length<=32?new J(e):Ye.from(J.split(e,[]))}}class J extends F{constructor(e,t=Of(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,i,s){for(let r=0;;r++){let o=this.text[r],l=s+o.length;if((t?i:l)>=e)return new Tf(s,l,i,o);s=l+1,i++}}decompose(e,t,i,s){let r=e<=0&&t>=this.length?this:new J(No(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(s&1){let o=i.pop(),l=vn(r.text,o.text.slice(),0,r.length);if(l.length<=32)i.push(new J(l,o.length+r.length));else{let a=l.length>>1;i.push(new J(l.slice(0,a)),new J(l.slice(a)))}}else i.push(r)}replace(e,t,i){if(!(i instanceof J))return super.replace(e,t,i);[e,t]=ni(this,e,t);let s=vn(this.text,vn(i.text,No(this.text,0,e)),t),r=this.length+i.length-(t-e);return s.length<=32?new J(s,r):Ye.from(J.split(s,[]),r)}sliceString(e,t=this.length,i=`
2
2
  `){[e,t]=ni(this,e,t);let s="";for(let r=0,o=0;r<=t&&o<this.text.length;o++){let l=this.text[o],a=r+l.length;r>e&&o&&(s+=i),e<a&&t>r&&(s+=l.slice(Math.max(0,e-r),t-r)),r=a+1}return s}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(e,t){let i=[],s=-1;for(let r of e)i.push(r),s+=r.length+1,i.length==32&&(t.push(new J(i,s)),i=[],s=-1);return s>-1&&t.push(new J(i,s)),t}}class Ye extends F{constructor(e,t){super(),this.children=e,this.length=t,this.lines=0;for(let i of e)this.lines+=i.lines}lineInner(e,t,i,s){for(let r=0;;r++){let o=this.children[r],l=s+o.length,a=i+o.lines-1;if((t?a:l)>=e)return o.lineInner(e,t,i,s);s=l+1,i=a+1}}decompose(e,t,i,s){for(let r=0,o=0;o<=t&&r<this.children.length;r++){let l=this.children[r],a=o+l.length;if(e<=a&&t>=o){let h=s&((o<=e?1:0)|(a>=t?2:0));o>=e&&a<=t&&!h?i.push(l):l.decompose(e-o,t-o,i,h)}o=a+1}}replace(e,t,i){if([e,t]=ni(this,e,t),i.lines<this.lines)for(let s=0,r=0;s<this.children.length;s++){let o=this.children[s],l=r+o.length;if(e>=r&&t<=l){let a=o.replace(e-r,t-r,i),h=this.lines-o.lines+a.lines;if(a.lines<h>>4&&a.lines>h>>6){let c=this.children.slice();return c[s]=a,new Ye(c,this.length-(t-e)+i.length)}return super.replace(r,l,a)}r=l+1}return super.replace(e,t,i)}sliceString(e,t=this.length,i=`
3
3
  `){[e,t]=ni(this,e,t);let s="";for(let r=0,o=0;r<this.children.length&&o<=t;r++){let l=this.children[r],a=o+l.length;o>e&&r&&(s+=i),e<a&&t>o&&(s+=l.sliceString(e-o,t-o,i)),o=a+1}return s}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(e,t){if(!(e instanceof Ye))return 0;let i=0,[s,r,o,l]=t>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;s+=t,r+=t){if(s==o||r==l)return i;let a=this.children[s],h=e.children[r];if(a!=h)return i+a.scanIdentical(h,t);i+=a.length+1}}static from(e,t=e.reduce((i,s)=>i+s.length+1,-1)){let i=0;for(let d of e)i+=d.lines;if(i<32){let d=[];for(let p of e)p.flatten(d);return new J(d,t)}let s=Math.max(32,i>>5),r=s<<1,o=s>>1,l=[],a=0,h=-1,c=[];function f(d){let p;if(d.lines>r&&d instanceof Ye)for(let m of d.children)f(m);else d.lines>o&&(a>o||!a)?(u(),l.push(d)):d instanceof J&&a&&(p=c[c.length-1])instanceof J&&d.lines+p.lines<=32?(a+=d.lines,h+=d.length+1,c[c.length-1]=new J(p.text.concat(d.text),p.length+1+d.length)):(a+d.lines>s&&u(),a+=d.lines,h+=d.length+1,c.push(d))}function u(){a!=0&&(l.push(c.length==1?c[0]:Ye.from(c,h)),h=-1,a=c.length=0)}for(let d of e)f(d);return u(),l.length==1?l[0]:new Ye(l,t)}}F.empty=new J([""],0);function Of(n){let e=-1;for(let t of n)e+=t.length+1;return e}function vn(n,e,t=0,i=1e9){for(let s=0,r=0,o=!0;r<n.length&&s<=i;r++){let l=n[r],a=s+l.length;a>=t&&(a>i&&(l=l.slice(0,i-s)),s<t&&(l=l.slice(t-s)),o?(e[e.length-1]+=l,o=!1):e.push(l)),s=a+1}return e}function No(n,e,t){return vn(n,[""],e,t)}class xi{constructor(e,t=1){this.dir=t,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[e],this.offsets=[t>0?1:(e instanceof J?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let i=this.nodes.length-1,s=this.nodes[i],r=this.offsets[i],o=r>>1,l=s instanceof J?s.text.length:s.children.length;if(o==(t>0?l:0)){if(i==0)return this.done=!0,this.value="",this;t>0&&this.offsets[i-1]++,this.nodes.pop(),this.offsets.pop()}else if((r&1)==(t>0?0:1)){if(this.offsets[i]+=t,e==0)return this.lineBreak=!0,this.value=`
4
- `,this;e--}else if(s instanceof J){let a=s.text[o+(t<0?-1:0)];if(this.offsets[i]+=t,a.length>Math.max(0,e))return this.value=e==0?a:t>0?a.slice(e):a.slice(0,a.length-e),this;e-=a.length}else{let a=s.children[o+(t<0?-1:0)];e>a.length?(e-=a.length,this.offsets[i]+=t):(t<0&&this.offsets[i]--,this.nodes.push(a),this.offsets.push(t>0?1:(a instanceof J?a.text.length:a.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class Ma{constructor(e,t,i){this.value="",this.done=!1,this.cursor=new xi(e,t>i?-1:1),this.pos=t>i?e.length:0,this.from=Math.min(t,i),this.to=Math.max(t,i)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let i=t<0?this.pos-this.from:this.to-this.pos;e>i&&(e=i),i-=e;let{value:s}=this.cursor.next(e);return this.pos+=(s.length+e)*t,this.value=s.length<=i?s:t<0?s.slice(s.length-i):s.slice(0,i),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}}class Oa{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:t,lineBreak:i,value:s}=this.inner.next(e);return t&&this.afterBreak?(this.value="",this.afterBreak=!1):t?(this.done=!0,this.value=""):i?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=s,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(F.prototype[Symbol.iterator]=function(){return this.iter()},xi.prototype[Symbol.iterator]=Ma.prototype[Symbol.iterator]=Oa.prototype[Symbol.iterator]=function(){return this});class Tf{constructor(e,t,i,s){this.from=e,this.to=t,this.number=i,this.text=s}get length(){return this.to-this.from}}function ni(n,e,t){return e=Math.max(0,Math.min(n.length,e)),[e,Math.max(e,Math.min(n.length,t))]}function ne(n,e,t=!0,i=!0){return Af(n,e,t,i)}function Df(n){return n>=56320&&n<57344}function Bf(n){return n>=55296&&n<56320}function ye(n,e){let t=n.charCodeAt(e);if(!Bf(t)||e+1==n.length)return t;let i=n.charCodeAt(e+1);return Df(i)?(t-55296<<10)+(i-56320)+65536:t}function Gr(n){return n<=65535?String.fromCharCode(n):(n-=65536,String.fromCharCode((n>>10)+55296,(n&1023)+56320))}function _e(n){return n<65536?1:2}const er=/\r\n?|\n/;var pe=function(n){return n[n.Simple=0]="Simple",n[n.TrackDel=1]="TrackDel",n[n.TrackBefore=2]="TrackBefore",n[n.TrackAfter=3]="TrackAfter",n}(pe||(pe={}));class it{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;t<this.sections.length;t+=2)e+=this.sections[t];return e}get newLength(){let e=0;for(let t=0;t<this.sections.length;t+=2){let i=this.sections[t+1];e+=i<0?this.sections[t]:i}return e}get empty(){return this.sections.length==0||this.sections.length==2&&this.sections[1]<0}iterGaps(e){for(let t=0,i=0,s=0;t<this.sections.length;){let r=this.sections[t++],o=this.sections[t++];o<0?(e(i,s,r),s+=r):s+=o,i+=r}}iterChangedRanges(e,t=!1){tr(this,e,t)}get invertedDesc(){let e=[];for(let t=0;t<this.sections.length;){let i=this.sections[t++],s=this.sections[t++];s<0?e.push(i,s):e.push(s,i)}return new it(e)}composeDesc(e){return this.empty?e:e.empty?this:Ta(this,e)}mapDesc(e,t=!1){return e.empty?this:ir(this,e,t)}mapPos(e,t=-1,i=pe.Simple){let s=0,r=0;for(let o=0;o<this.sections.length;){let l=this.sections[o++],a=this.sections[o++],h=s+l;if(a<0){if(h>e)return r+(e-s);r+=l}else{if(i!=pe.Simple&&h>=e&&(i==pe.TrackDel&&s<e&&h>e||i==pe.TrackBefore&&s<e||i==pe.TrackAfter&&h>e))return null;if(h>e||h==e&&t<0&&!l)return e==s||t<0?r:r+a;r+=a}s=h}if(e>s)throw new RangeError(`Position ${e} is out of range for changeset of length ${s}`);return r}touchesRange(e,t=e){for(let i=0,s=0;i<this.sections.length&&s<=t;){let r=this.sections[i++],o=this.sections[i++],l=s+r;if(o>=0&&s<=t&&l>=e)return s<e&&l>t?"cover":!0;s=l}return!1}toString(){let e="";for(let t=0;t<this.sections.length;){let i=this.sections[t++],s=this.sections[t++];e+=(e?" ":"")+i+(s>=0?":"+s:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(t=>typeof t!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new it(e)}static create(e){return new it(e)}}class ee extends it{constructor(e,t){super(e),this.inserted=t}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return tr(this,(t,i,s,r,o)=>e=e.replace(s,s+(i-t),o),!1),e}mapDesc(e,t=!1){return ir(this,e,t,!0)}invert(e){let t=this.sections.slice(),i=[];for(let s=0,r=0;s<t.length;s+=2){let o=t[s],l=t[s+1];if(l>=0){t[s]=l,t[s+1]=o;let a=s>>1;for(;i.length<a;)i.push(F.empty);i.push(o?e.slice(r,r+o):F.empty)}r+=o}return new ee(t,i)}compose(e){return this.empty?e:e.empty?this:Ta(this,e,!0)}map(e,t=!1){return e.empty?this:ir(this,e,t,!0)}iterChanges(e,t=!1){tr(this,e,t)}get desc(){return it.create(this.sections)}filter(e){let t=[],i=[],s=[],r=new Oi(this);e:for(let o=0,l=0;;){let a=o==e.length?1e9:e[o++];for(;l<a||l==a&&r.len==0;){if(r.done)break e;let c=Math.min(r.len,a-l);he(s,c,-1);let f=r.ins==-1?-1:r.off==0?r.ins:0;he(t,c,f),f>0&&mt(i,t,r.text),r.forward(c),l+=c}let h=e[o++];for(;l<h;){if(r.done)break e;let c=Math.min(r.len,h-l);he(t,c,-1),he(s,c,r.ins==-1?-1:r.off==0?r.ins:0),r.forward(c),l+=c}}return{changes:new ee(t,i),filtered:it.create(s)}}toJSON(){let e=[];for(let t=0;t<this.sections.length;t+=2){let i=this.sections[t],s=this.sections[t+1];s<0?e.push(i):s==0?e.push([i]):e.push([i].concat(this.inserted[t>>1].toJSON()))}return e}static of(e,t,i){let s=[],r=[],o=0,l=null;function a(c=!1){if(!c&&!s.length)return;o<t&&he(s,t-o,-1);let f=new ee(s,r);l=l?l.compose(f.map(l)):f,s=[],r=[],o=0}function h(c){if(Array.isArray(c))for(let f of c)h(f);else if(c instanceof ee){if(c.length!=t)throw new RangeError(`Mismatched change set length (got ${c.length}, expected ${t})`);a(),l=l?l.compose(c.map(l)):c}else{let{from:f,to:u=f,insert:d}=c;if(f>u||f<0||u>t)throw new RangeError(`Invalid change range ${f} to ${u} (in doc of length ${t})`);let p=d?typeof d=="string"?F.of(d.split(i||er)):d:F.empty,m=p.length;if(f==u&&m==0)return;f<o&&a(),f>o&&he(s,f-o,-1),he(s,u-f,m),mt(r,s,p),o=u}}return h(e),a(!l),l}static empty(e){return new ee(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let t=[],i=[];for(let s=0;s<e.length;s++){let r=e[s];if(typeof r=="number")t.push(r,-1);else{if(!Array.isArray(r)||typeof r[0]!="number"||r.some((o,l)=>l&&typeof o!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(r.length==1)t.push(r[0],0);else{for(;i.length<s;)i.push(F.empty);i[s]=F.of(r.slice(1)),t.push(r[0],i[s].length)}}}return new ee(t,i)}static createSet(e,t){return new ee(e,t)}}function he(n,e,t,i=!1){if(e==0&&t<=0)return;let s=n.length-2;s>=0&&t<=0&&t==n[s+1]?n[s]+=e:s>=0&&e==0&&n[s]==0?n[s+1]+=t:i?(n[s]+=e,n[s+1]+=t):n.push(e,t)}function mt(n,e,t){if(t.length==0)return;let i=e.length-2>>1;if(i<n.length)n[n.length-1]=n[n.length-1].append(t);else{for(;n.length<i;)n.push(F.empty);n.push(t)}}function tr(n,e,t){let i=n.inserted;for(let s=0,r=0,o=0;o<n.sections.length;){let l=n.sections[o++],a=n.sections[o++];if(a<0)s+=l,r+=l;else{let h=s,c=r,f=F.empty;for(;h+=l,c+=a,a&&i&&(f=f.append(i[o-2>>1])),!(t||o==n.sections.length||n.sections[o+1]<0);)l=n.sections[o++],a=n.sections[o++];e(s,h,r,c,f),s=h,r=c}}}function ir(n,e,t,i=!1){let s=[],r=i?[]:null,o=new Oi(n),l=new Oi(e);for(let a=-1;;){if(o.done&&l.len||l.done&&o.len)throw new Error("Mismatched change set lengths");if(o.ins==-1&&l.ins==-1){let h=Math.min(o.len,l.len);he(s,h,-1),o.forward(h),l.forward(h)}else if(l.ins>=0&&(o.ins<0||a==o.i||o.off==0&&(l.len<o.len||l.len==o.len&&!t))){let h=l.len;for(he(s,l.ins,-1);h;){let c=Math.min(o.len,h);o.ins>=0&&a<o.i&&o.len<=c&&(he(s,0,o.ins),r&&mt(r,s,o.text),a=o.i),o.forward(c),h-=c}l.next()}else if(o.ins>=0){let h=0,c=o.len;for(;c;)if(l.ins==-1){let f=Math.min(c,l.len);h+=f,c-=f,l.forward(f)}else if(l.ins==0&&l.len<c)c-=l.len,l.next();else break;he(s,h,a<o.i?o.ins:0),r&&a<o.i&&mt(r,s,o.text),a=o.i,o.forward(o.len-c)}else{if(o.done&&l.done)return r?ee.createSet(s,r):it.create(s);throw new Error("Mismatched change set lengths")}}}function Ta(n,e,t=!1){let i=[],s=t?[]:null,r=new Oi(n),o=new Oi(e);for(let l=!1;;){if(r.done&&o.done)return s?ee.createSet(i,s):it.create(i);if(r.ins==0)he(i,r.len,0,l),r.next();else if(o.len==0&&!o.done)he(i,0,o.ins,l),s&&mt(s,i,o.text),o.next();else{if(r.done||o.done)throw new Error("Mismatched change set lengths");{let a=Math.min(r.len2,o.len),h=i.length;if(r.ins==-1){let c=o.ins==-1?-1:o.off?0:o.ins;he(i,a,c,l),s&&c&&mt(s,i,o.text)}else o.ins==-1?(he(i,r.off?0:r.len,a,l),s&&mt(s,i,r.textBit(a))):(he(i,r.off?0:r.len,o.off?0:o.ins,l),s&&!o.off&&mt(s,i,o.text));l=(r.ins>a||o.ins>=0&&o.len>a)&&(l||i.length>h),r.forward2(a),o.forward(a)}}}}class Oi{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i<e.length?(this.len=e[this.i++],this.ins=e[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return this.ins==-2}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:e}=this.set,t=this.i-2>>1;return t>=e.length?F.empty:e[t]}textBit(e){let{inserted:t}=this.set,i=this.i-2>>1;return i>=t.length&&!e?F.empty:t[i].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class Pt{constructor(e,t,i){this.from=e,this.to=t,this.flags=i}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}get goalColumn(){let e=this.flags>>6;return e==16777215?void 0:e}map(e,t=-1){let i,s;return this.empty?i=s=e.mapPos(this.from,t):(i=e.mapPos(this.from,1),s=e.mapPos(this.to,-1)),i==this.from&&s==this.to?this:new Pt(i,s,this.flags)}extend(e,t=e){if(e<=this.anchor&&t>=this.anchor)return b.range(e,t);let i=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return b.range(this.anchor,i)}eq(e,t=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!t||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return b.range(e.anchor,e.head)}static create(e,t,i){return new Pt(e,t,i)}}class b{constructor(e,t){this.ranges=e,this.mainIndex=t}map(e,t=-1){return e.empty?this:b.create(this.ranges.map(i=>i.map(e,t)),this.mainIndex)}eq(e,t=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let i=0;i<this.ranges.length;i++)if(!this.ranges[i].eq(e.ranges[i],t))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new b([this.main],0)}addRange(e,t=!0){return b.create([e].concat(this.ranges),t?0:this.mainIndex+1)}replaceRange(e,t=this.mainIndex){let i=this.ranges.slice();return i[t]=e,b.create(i,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(e=>e.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new b(e.ranges.map(t=>Pt.fromJSON(t)),e.main)}static single(e,t=e){return new b([b.range(e,t)],0)}static create(e,t=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let i=0,s=0;s<e.length;s++){let r=e[s];if(r.empty?r.from<=i:r.from<i)return b.normalized(e.slice(),t);i=r.to}return new b(e,t)}static cursor(e,t=0,i,s){return Pt.create(e,e,(t==0?0:t<0?8:16)|(i==null?7:Math.min(6,i))|(s??16777215)<<6)}static range(e,t,i,s){let r=(i??16777215)<<6|(s==null?7:Math.min(6,s));return t<e?Pt.create(t,e,48|r):Pt.create(e,t,(t>e?8:0)|r)}static normalized(e,t=0){let i=e[t];e.sort((s,r)=>s.from-r.from),t=e.indexOf(i);for(let s=1;s<e.length;s++){let r=e[s],o=e[s-1];if(r.empty?r.from<=o.to:r.from<o.to){let l=o.from,a=Math.max(r.to,o.to);s<=t&&t--,e.splice(--s,2,r.anchor>r.head?b.range(a,l):b.range(l,a))}}return new b(e,t)}}function Da(n,e){for(let t of n.ranges)if(t.to>e)throw new RangeError("Selection points outside of document")}let Qr=0;class M{constructor(e,t,i,s,r){this.combine=e,this.compareInput=t,this.compare=i,this.isStatic=s,this.id=Qr++,this.default=e([]),this.extensions=typeof r=="function"?r(this):r}get reader(){return this}static define(e={}){return new M(e.combine||(t=>t),e.compareInput||((t,i)=>t===i),e.compare||(e.combine?(t,i)=>t===i:Yr),!!e.static,e.enables)}of(e){return new Sn([],this,0,e)}compute(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new Sn(e,this,1,t)}computeN(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new Sn(e,this,2,t)}from(e,t){return t||(t=i=>i),this.compute([e],i=>t(i.field(e)))}}function Yr(n,e){return n==e||n.length==e.length&&n.every((t,i)=>t===e[i])}class Sn{constructor(e,t,i,s){this.dependencies=e,this.facet=t,this.type=i,this.value=s,this.id=Qr++}dynamicSlot(e){var t;let i=this.value,s=this.facet.compareInput,r=this.id,o=e[r]>>1,l=this.type==2,a=!1,h=!1,c=[];for(let f of this.dependencies)f=="doc"?a=!0:f=="selection"?h=!0:((t=e[f.id])!==null&&t!==void 0?t:1)&1||c.push(e[f.id]);return{create(f){return f.values[o]=i(f),1},update(f,u){if(a&&u.docChanged||h&&(u.docChanged||u.selection)||nr(f,c)){let d=i(f);if(l?!Wo(d,f.values[o],s):!s(d,f.values[o]))return f.values[o]=d,1}return 0},reconfigure:(f,u)=>{let d,p=u.config.address[r];if(p!=null){let m=Rn(u,p);if(this.dependencies.every(g=>g instanceof M?u.facet(g)===f.facet(g):g instanceof se?u.field(g,!1)==f.field(g,!1):!0)||(l?Wo(d=i(f),m,s):s(d=i(f),m)))return f.values[o]=m,0}else d=i(f);return f.values[o]=d,1}}}}function Wo(n,e,t){if(n.length!=e.length)return!1;for(let i=0;i<n.length;i++)if(!t(n[i],e[i]))return!1;return!0}function nr(n,e){let t=!1;for(let i of e)wi(n,i)&1&&(t=!0);return t}function Pf(n,e,t){let i=t.map(a=>n[a.id]),s=t.map(a=>a.type),r=i.filter(a=>!(a&1)),o=n[e.id]>>1;function l(a){let h=[];for(let c=0;c<i.length;c++){let f=Rn(a,i[c]);if(s[c]==2)for(let u of f)h.push(u);else h.push(f)}return e.combine(h)}return{create(a){for(let h of i)wi(a,h);return a.values[o]=l(a),1},update(a,h){if(!nr(a,r))return 0;let c=l(a);return e.compare(c,a.values[o])?0:(a.values[o]=c,1)},reconfigure(a,h){let c=nr(a,i),f=h.config.facets[e.id],u=h.facet(e);if(f&&!c&&Yr(t,f))return a.values[o]=u,0;let d=l(a);return e.compare(d,u)?(a.values[o]=u,0):(a.values[o]=d,1)}}}const Xi=M.define({static:!0});class se{constructor(e,t,i,s,r){this.id=e,this.createF=t,this.updateF=i,this.compareF=s,this.spec=r,this.provides=void 0}static define(e){let t=new se(Qr++,e.create,e.update,e.compare||((i,s)=>i===s),e);return e.provide&&(t.provides=e.provide(t)),t}create(e){let t=e.facet(Xi).find(i=>i.field==this);return((t==null?void 0:t.create)||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:i=>(i.values[t]=this.create(i),1),update:(i,s)=>{let r=i.values[t],o=this.updateF(r,s);return this.compareF(r,o)?0:(i.values[t]=o,1)},reconfigure:(i,s)=>{let r=i.facet(Xi),o=s.facet(Xi),l;return(l=r.find(a=>a.field==this))&&l!=o.find(a=>a.field==this)?(i.values[t]=l.create(i),1):s.config.address[this.id]!=null?(i.values[t]=s.field(this),0):(i.values[t]=this.create(i),1)}}}init(e){return[this,Xi.of({field:this,create:e})]}get extension(){return this}}const Dt={lowest:4,low:3,default:2,high:1,highest:0};function fi(n){return e=>new Ba(e,n)}const Vt={highest:fi(Dt.highest),high:fi(Dt.high),default:fi(Dt.default),low:fi(Dt.low),lowest:fi(Dt.lowest)};class Ba{constructor(e,t){this.inner=e,this.prec=t}}class rs{of(e){return new sr(this,e)}reconfigure(e){return rs.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class sr{constructor(e,t){this.compartment=e,this.inner=t}}class Pn{constructor(e,t,i,s,r,o){for(this.base=e,this.compartments=t,this.dynamicSlots=i,this.address=s,this.staticValues=r,this.facets=o,this.statusTemplate=[];this.statusTemplate.length<i.length;)this.statusTemplate.push(0)}staticFacet(e){let t=this.address[e.id];return t==null?e.default:this.staticValues[t>>1]}static resolve(e,t,i){let s=[],r=Object.create(null),o=new Map;for(let u of Rf(e,t,o))u instanceof se?s.push(u):(r[u.facet.id]||(r[u.facet.id]=[])).push(u);let l=Object.create(null),a=[],h=[];for(let u of s)l[u.id]=h.length<<1,h.push(d=>u.slot(d));let c=i==null?void 0:i.config.facets;for(let u in r){let d=r[u],p=d[0].facet,m=c&&c[u]||[];if(d.every(g=>g.type==0))if(l[p.id]=a.length<<1|1,Yr(m,d))a.push(i.facet(p));else{let g=p.combine(d.map(y=>y.value));a.push(i&&p.compare(g,i.facet(p))?i.facet(p):g)}else{for(let g of d)g.type==0?(l[g.id]=a.length<<1|1,a.push(g.value)):(l[g.id]=h.length<<1,h.push(y=>g.dynamicSlot(y)));l[p.id]=h.length<<1,h.push(g=>Pf(g,p,d))}}let f=h.map(u=>u(l));return new Pn(e,o,f,l,a,r)}}function Rf(n,e,t){let i=[[],[],[],[],[]],s=new Map;function r(o,l){let a=s.get(o);if(a!=null){if(a<=l)return;let h=i[a].indexOf(o);h>-1&&i[a].splice(h,1),o instanceof sr&&t.delete(o.compartment)}if(s.set(o,l),Array.isArray(o))for(let h of o)r(h,l);else if(o instanceof sr){if(t.has(o.compartment))throw new RangeError("Duplicate use of compartment in extensions");let h=e.get(o.compartment)||o.inner;t.set(o.compartment,h),r(h,l)}else if(o instanceof Ba)r(o.inner,o.prec);else if(o instanceof se)i[l].push(o),o.provides&&r(o.provides,l);else if(o instanceof Sn)i[l].push(o),o.facet.extensions&&r(o.facet.extensions,Dt.default);else{let h=o.extension;if(!h)throw new Error(`Unrecognized extension value in extension set (${o}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);r(h,l)}}return r(n,Dt.default),i.reduce((o,l)=>o.concat(l))}function wi(n,e){if(e&1)return 2;let t=e>>1,i=n.status[t];if(i==4)throw new Error("Cyclic dependency between fields and/or facets");if(i&2)return i;n.status[t]=4;let s=n.computeSlot(n,n.config.dynamicSlots[t]);return n.status[t]=2|s}function Rn(n,e){return e&1?n.config.staticValues[e>>1]:n.values[e>>1]}const Pa=M.define(),rr=M.define({combine:n=>n.some(e=>e),static:!0}),Ra=M.define({combine:n=>n.length?n[0]:void 0,static:!0}),La=M.define(),Ea=M.define(),Ia=M.define(),Na=M.define({combine:n=>n.length?n[0]:!1});class ft{constructor(e,t){this.type=e,this.value=t}static define(){return new Lf}}class Lf{of(e){return new ft(this,e)}}class Ef{constructor(e){this.map=e}of(e){return new R(this,e)}}class R{constructor(e,t){this.type=e,this.value=t}map(e){let t=this.type.map(this.value,e);return t===void 0?void 0:t==this.value?this:new R(this.type,t)}is(e){return this.type==e}static define(e={}){return new Ef(e.map||(t=>t))}static mapEffects(e,t){if(!e.length)return e;let i=[];for(let s of e){let r=s.map(t);r&&i.push(r)}return i}}R.reconfigure=R.define();R.appendConfig=R.define();class te{constructor(e,t,i,s,r,o){this.startState=e,this.changes=t,this.selection=i,this.effects=s,this.annotations=r,this.scrollIntoView=o,this._doc=null,this._state=null,i&&Da(i,t.newLength),r.some(l=>l.type==te.time)||(this.annotations=r.concat(te.time.of(Date.now())))}static create(e,t,i,s,r,o){return new te(e,t,i,s,r,o)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let t of this.annotations)if(t.type==e)return t.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let t=this.annotation(te.userEvent);return!!(t&&(t==e||t.length>e.length&&t.slice(0,e.length)==e&&t[e.length]=="."))}}te.time=ft.define();te.userEvent=ft.define();te.addToHistory=ft.define();te.remote=ft.define();function If(n,e){let t=[];for(let i=0,s=0;;){let r,o;if(i<n.length&&(s==e.length||e[s]>=n[i]))r=n[i++],o=n[i++];else if(s<e.length)r=e[s++],o=e[s++];else return t;!t.length||t[t.length-1]<r?t.push(r,o):t[t.length-1]<o&&(t[t.length-1]=o)}}function Wa(n,e,t){var i;let s,r,o;return t?(s=e.changes,r=ee.empty(e.changes.length),o=n.changes.compose(e.changes)):(s=e.changes.map(n.changes),r=n.changes.mapDesc(e.changes,!0),o=n.changes.compose(s)),{changes:o,selection:e.selection?e.selection.map(r):(i=n.selection)===null||i===void 0?void 0:i.map(s),effects:R.mapEffects(n.effects,s).concat(R.mapEffects(e.effects,r)),annotations:n.annotations.length?n.annotations.concat(e.annotations):e.annotations,scrollIntoView:n.scrollIntoView||e.scrollIntoView}}function or(n,e,t){let i=e.selection,s=_t(e.annotations);return e.userEvent&&(s=s.concat(te.userEvent.of(e.userEvent))),{changes:e.changes instanceof ee?e.changes:ee.of(e.changes||[],t,n.facet(Ra)),selection:i&&(i instanceof b?i:b.single(i.anchor,i.head)),effects:_t(e.effects),annotations:s,scrollIntoView:!!e.scrollIntoView}}function Fa(n,e,t){let i=or(n,e.length?e[0]:{},n.doc.length);e.length&&e[0].filter===!1&&(t=!1);for(let r=1;r<e.length;r++){e[r].filter===!1&&(t=!1);let o=!!e[r].sequential;i=Wa(i,or(n,e[r],o?i.changes.newLength:n.doc.length),o)}let s=te.create(n,i.changes,i.selection,i.effects,i.annotations,i.scrollIntoView);return Wf(t?Nf(s):s)}function Nf(n){let e=n.startState,t=!0;for(let s of e.facet(La)){let r=s(n);if(r===!1){t=!1;break}Array.isArray(r)&&(t=t===!0?r:If(t,r))}if(t!==!0){let s,r;if(t===!1)r=n.changes.invertedDesc,s=ee.empty(e.doc.length);else{let o=n.changes.filter(t);s=o.changes,r=o.filtered.mapDesc(o.changes).invertedDesc}n=te.create(e,s,n.selection&&n.selection.map(r),R.mapEffects(n.effects,r),n.annotations,n.scrollIntoView)}let i=e.facet(Ea);for(let s=i.length-1;s>=0;s--){let r=i[s](n);r instanceof te?n=r:Array.isArray(r)&&r.length==1&&r[0]instanceof te?n=r[0]:n=Fa(e,_t(r),!1)}return n}function Wf(n){let e=n.startState,t=e.facet(Ia),i=n;for(let s=t.length-1;s>=0;s--){let r=t[s](n);r&&Object.keys(r).length&&(i=Wa(i,or(e,r,n.changes.newLength),!0))}return i==n?n:te.create(e,n.changes,n.selection,i.effects,i.annotations,i.scrollIntoView)}const Ff=[];function _t(n){return n==null?Ff:Array.isArray(n)?n:[n]}var Q=function(n){return n[n.Word=0]="Word",n[n.Space=1]="Space",n[n.Other=2]="Other",n}(Q||(Q={}));const Hf=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let lr;try{lr=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function Vf(n){if(lr)return lr.test(n);for(let e=0;e<n.length;e++){let t=n[e];if(/\w/.test(t)||t>"€"&&(t.toUpperCase()!=t.toLowerCase()||Hf.test(t)))return!0}return!1}function zf(n){return e=>{if(!/\S/.test(e))return Q.Space;if(Vf(e))return Q.Word;for(let t=0;t<n.length;t++)if(e.indexOf(n[t])>-1)return Q.Word;return Q.Other}}class V{constructor(e,t,i,s,r,o){this.config=e,this.doc=t,this.selection=i,this.values=s,this.status=e.statusTemplate.slice(),this.computeSlot=r,o&&(o._state=this);for(let l=0;l<this.config.dynamicSlots.length;l++)wi(this,l<<1);this.computeSlot=null}field(e,t=!0){let i=this.config.address[e.id];if(i==null){if(t)throw new RangeError("Field is not present in this state");return}return wi(this,i),Rn(this,i)}update(...e){return Fa(this,e,!0)}applyTransaction(e){let t=this.config,{base:i,compartments:s}=t;for(let l of e.effects)l.is(rs.reconfigure)?(t&&(s=new Map,t.compartments.forEach((a,h)=>s.set(h,a)),t=null),s.set(l.value.compartment,l.value.extension)):l.is(R.reconfigure)?(t=null,i=l.value):l.is(R.appendConfig)&&(t=null,i=_t(i).concat(l.value));let r;t?r=e.startState.values.slice():(t=Pn.resolve(i,s,this),r=new V(t,this.doc,this.selection,t.dynamicSlots.map(()=>null),(a,h)=>h.reconfigure(a,this),null).values);let o=e.startState.facet(rr)?e.newSelection:e.newSelection.asSingle();new V(t,e.newDoc,o,r,(l,a)=>a.update(l,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:b.cursor(t.from+e.length)}))}changeByRange(e){let t=this.selection,i=e(t.ranges[0]),s=this.changes(i.changes),r=[i.range],o=_t(i.effects);for(let l=1;l<t.ranges.length;l++){let a=e(t.ranges[l]),h=this.changes(a.changes),c=h.map(s);for(let u=0;u<l;u++)r[u]=r[u].map(c);let f=s.mapDesc(h,!0);r.push(a.range.map(f)),s=s.compose(c),o=R.mapEffects(o,c).concat(R.mapEffects(_t(a.effects),f))}return{changes:s,selection:b.create(r,t.mainIndex),effects:o}}changes(e=[]){return e instanceof ee?e:ee.of(e,this.doc.length,this.facet(V.lineSeparator))}toText(e){return F.of(e.split(this.facet(V.lineSeparator)||er))}sliceDoc(e=0,t=this.doc.length){return this.doc.sliceString(e,t,this.lineBreak)}facet(e){let t=this.config.address[e.id];return t==null?e.default:(wi(this,t),Rn(this,t))}toJSON(e){let t={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let i in e){let s=e[i];s instanceof se&&this.config.address[s.id]!=null&&(t[i]=s.spec.toJSON(this.field(e[i]),this))}return t}static fromJSON(e,t={},i){if(!e||typeof e.doc!="string")throw new RangeError("Invalid JSON representation for EditorState");let s=[];if(i){for(let r in i)if(Object.prototype.hasOwnProperty.call(e,r)){let o=i[r],l=e[r];s.push(o.init(a=>o.spec.fromJSON(l,a)))}}return V.create({doc:e.doc,selection:b.fromJSON(e.selection),extensions:t.extensions?s.concat([t.extensions]):s})}static create(e={}){let t=Pn.resolve(e.extensions||[],new Map),i=e.doc instanceof F?e.doc:F.of((e.doc||"").split(t.staticFacet(V.lineSeparator)||er)),s=e.selection?e.selection instanceof b?e.selection:b.single(e.selection.anchor,e.selection.head):b.single(0);return Da(s,i.length),t.staticFacet(rr)||(s=s.asSingle()),new V(t,i,s,t.dynamicSlots.map(()=>null),(r,o)=>o.create(r),null)}get tabSize(){return this.facet(V.tabSize)}get lineBreak(){return this.facet(V.lineSeparator)||`
4
+ `,this;e--}else if(s instanceof J){let a=s.text[o+(t<0?-1:0)];if(this.offsets[i]+=t,a.length>Math.max(0,e))return this.value=e==0?a:t>0?a.slice(e):a.slice(0,a.length-e),this;e-=a.length}else{let a=s.children[o+(t<0?-1:0)];e>a.length?(e-=a.length,this.offsets[i]+=t):(t<0&&this.offsets[i]--,this.nodes.push(a),this.offsets.push(t>0?1:(a instanceof J?a.text.length:a.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class Ma{constructor(e,t,i){this.value="",this.done=!1,this.cursor=new xi(e,t>i?-1:1),this.pos=t>i?e.length:0,this.from=Math.min(t,i),this.to=Math.max(t,i)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let i=t<0?this.pos-this.from:this.to-this.pos;e>i&&(e=i),i-=e;let{value:s}=this.cursor.next(e);return this.pos+=(s.length+e)*t,this.value=s.length<=i?s:t<0?s.slice(s.length-i):s.slice(0,i),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}}class Oa{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:t,lineBreak:i,value:s}=this.inner.next(e);return t&&this.afterBreak?(this.value="",this.afterBreak=!1):t?(this.done=!0,this.value=""):i?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=s,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(F.prototype[Symbol.iterator]=function(){return this.iter()},xi.prototype[Symbol.iterator]=Ma.prototype[Symbol.iterator]=Oa.prototype[Symbol.iterator]=function(){return this});class Tf{constructor(e,t,i,s){this.from=e,this.to=t,this.number=i,this.text=s}get length(){return this.to-this.from}}function ni(n,e,t){return e=Math.max(0,Math.min(n.length,e)),[e,Math.max(e,Math.min(n.length,t))]}function ne(n,e,t=!0,i=!0){return Af(n,e,t,i)}function Df(n){return n>=56320&&n<57344}function Bf(n){return n>=55296&&n<56320}function ye(n,e){let t=n.charCodeAt(e);if(!Bf(t)||e+1==n.length)return t;let i=n.charCodeAt(e+1);return Df(i)?(t-55296<<10)+(i-56320)+65536:t}function Gr(n){return n<=65535?String.fromCharCode(n):(n-=65536,String.fromCharCode((n>>10)+55296,(n&1023)+56320))}function _e(n){return n<65536?1:2}const er=/\r\n?|\n/;var pe=function(n){return n[n.Simple=0]="Simple",n[n.TrackDel=1]="TrackDel",n[n.TrackBefore=2]="TrackBefore",n[n.TrackAfter=3]="TrackAfter",n}(pe||(pe={}));class it{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;t<this.sections.length;t+=2)e+=this.sections[t];return e}get newLength(){let e=0;for(let t=0;t<this.sections.length;t+=2){let i=this.sections[t+1];e+=i<0?this.sections[t]:i}return e}get empty(){return this.sections.length==0||this.sections.length==2&&this.sections[1]<0}iterGaps(e){for(let t=0,i=0,s=0;t<this.sections.length;){let r=this.sections[t++],o=this.sections[t++];o<0?(e(i,s,r),s+=r):s+=o,i+=r}}iterChangedRanges(e,t=!1){tr(this,e,t)}get invertedDesc(){let e=[];for(let t=0;t<this.sections.length;){let i=this.sections[t++],s=this.sections[t++];s<0?e.push(i,s):e.push(s,i)}return new it(e)}composeDesc(e){return this.empty?e:e.empty?this:Ta(this,e)}mapDesc(e,t=!1){return e.empty?this:ir(this,e,t)}mapPos(e,t=-1,i=pe.Simple){let s=0,r=0;for(let o=0;o<this.sections.length;){let l=this.sections[o++],a=this.sections[o++],h=s+l;if(a<0){if(h>e)return r+(e-s);r+=l}else{if(i!=pe.Simple&&h>=e&&(i==pe.TrackDel&&s<e&&h>e||i==pe.TrackBefore&&s<e||i==pe.TrackAfter&&h>e))return null;if(h>e||h==e&&t<0&&!l)return e==s||t<0?r:r+a;r+=a}s=h}if(e>s)throw new RangeError(`Position ${e} is out of range for changeset of length ${s}`);return r}touchesRange(e,t=e){for(let i=0,s=0;i<this.sections.length&&s<=t;){let r=this.sections[i++],o=this.sections[i++],l=s+r;if(o>=0&&s<=t&&l>=e)return s<e&&l>t?"cover":!0;s=l}return!1}toString(){let e="";for(let t=0;t<this.sections.length;){let i=this.sections[t++],s=this.sections[t++];e+=(e?" ":"")+i+(s>=0?":"+s:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(t=>typeof t!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new it(e)}static create(e){return new it(e)}}class ee extends it{constructor(e,t){super(e),this.inserted=t}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return tr(this,(t,i,s,r,o)=>e=e.replace(s,s+(i-t),o),!1),e}mapDesc(e,t=!1){return ir(this,e,t,!0)}invert(e){let t=this.sections.slice(),i=[];for(let s=0,r=0;s<t.length;s+=2){let o=t[s],l=t[s+1];if(l>=0){t[s]=l,t[s+1]=o;let a=s>>1;for(;i.length<a;)i.push(F.empty);i.push(o?e.slice(r,r+o):F.empty)}r+=o}return new ee(t,i)}compose(e){return this.empty?e:e.empty?this:Ta(this,e,!0)}map(e,t=!1){return e.empty?this:ir(this,e,t,!0)}iterChanges(e,t=!1){tr(this,e,t)}get desc(){return it.create(this.sections)}filter(e){let t=[],i=[],s=[],r=new Oi(this);e:for(let o=0,l=0;;){let a=o==e.length?1e9:e[o++];for(;l<a||l==a&&r.len==0;){if(r.done)break e;let c=Math.min(r.len,a-l);he(s,c,-1);let f=r.ins==-1?-1:r.off==0?r.ins:0;he(t,c,f),f>0&&mt(i,t,r.text),r.forward(c),l+=c}let h=e[o++];for(;l<h;){if(r.done)break e;let c=Math.min(r.len,h-l);he(t,c,-1),he(s,c,r.ins==-1?-1:r.off==0?r.ins:0),r.forward(c),l+=c}}return{changes:new ee(t,i),filtered:it.create(s)}}toJSON(){let e=[];for(let t=0;t<this.sections.length;t+=2){let i=this.sections[t],s=this.sections[t+1];s<0?e.push(i):s==0?e.push([i]):e.push([i].concat(this.inserted[t>>1].toJSON()))}return e}static of(e,t,i){let s=[],r=[],o=0,l=null;function a(c=!1){if(!c&&!s.length)return;o<t&&he(s,t-o,-1);let f=new ee(s,r);l=l?l.compose(f.map(l)):f,s=[],r=[],o=0}function h(c){if(Array.isArray(c))for(let f of c)h(f);else if(c instanceof ee){if(c.length!=t)throw new RangeError(`Mismatched change set length (got ${c.length}, expected ${t})`);a(),l=l?l.compose(c.map(l)):c}else{let{from:f,to:u=f,insert:d}=c;if(f>u||f<0||u>t)throw new RangeError(`Invalid change range ${f} to ${u} (in doc of length ${t})`);let p=d?typeof d=="string"?F.of(d.split(i||er)):d:F.empty,m=p.length;if(f==u&&m==0)return;f<o&&a(),f>o&&he(s,f-o,-1),he(s,u-f,m),mt(r,s,p),o=u}}return h(e),a(!l),l}static empty(e){return new ee(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let t=[],i=[];for(let s=0;s<e.length;s++){let r=e[s];if(typeof r=="number")t.push(r,-1);else{if(!Array.isArray(r)||typeof r[0]!="number"||r.some((o,l)=>l&&typeof o!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(r.length==1)t.push(r[0],0);else{for(;i.length<s;)i.push(F.empty);i[s]=F.of(r.slice(1)),t.push(r[0],i[s].length)}}}return new ee(t,i)}static createSet(e,t){return new ee(e,t)}}function he(n,e,t,i=!1){if(e==0&&t<=0)return;let s=n.length-2;s>=0&&t<=0&&t==n[s+1]?n[s]+=e:s>=0&&e==0&&n[s]==0?n[s+1]+=t:i?(n[s]+=e,n[s+1]+=t):n.push(e,t)}function mt(n,e,t){if(t.length==0)return;let i=e.length-2>>1;if(i<n.length)n[n.length-1]=n[n.length-1].append(t);else{for(;n.length<i;)n.push(F.empty);n.push(t)}}function tr(n,e,t){let i=n.inserted;for(let s=0,r=0,o=0;o<n.sections.length;){let l=n.sections[o++],a=n.sections[o++];if(a<0)s+=l,r+=l;else{let h=s,c=r,f=F.empty;for(;h+=l,c+=a,a&&i&&(f=f.append(i[o-2>>1])),!(t||o==n.sections.length||n.sections[o+1]<0);)l=n.sections[o++],a=n.sections[o++];e(s,h,r,c,f),s=h,r=c}}}function ir(n,e,t,i=!1){let s=[],r=i?[]:null,o=new Oi(n),l=new Oi(e);for(let a=-1;;){if(o.done&&l.len||l.done&&o.len)throw new Error("Mismatched change set lengths");if(o.ins==-1&&l.ins==-1){let h=Math.min(o.len,l.len);he(s,h,-1),o.forward(h),l.forward(h)}else if(l.ins>=0&&(o.ins<0||a==o.i||o.off==0&&(l.len<o.len||l.len==o.len&&!t))){let h=l.len;for(he(s,l.ins,-1);h;){let c=Math.min(o.len,h);o.ins>=0&&a<o.i&&o.len<=c&&(he(s,0,o.ins),r&&mt(r,s,o.text),a=o.i),o.forward(c),h-=c}l.next()}else if(o.ins>=0){let h=0,c=o.len;for(;c;)if(l.ins==-1){let f=Math.min(c,l.len);h+=f,c-=f,l.forward(f)}else if(l.ins==0&&l.len<c)c-=l.len,l.next();else break;he(s,h,a<o.i?o.ins:0),r&&a<o.i&&mt(r,s,o.text),a=o.i,o.forward(o.len-c)}else{if(o.done&&l.done)return r?ee.createSet(s,r):it.create(s);throw new Error("Mismatched change set lengths")}}}function Ta(n,e,t=!1){let i=[],s=t?[]:null,r=new Oi(n),o=new Oi(e);for(let l=!1;;){if(r.done&&o.done)return s?ee.createSet(i,s):it.create(i);if(r.ins==0)he(i,r.len,0,l),r.next();else if(o.len==0&&!o.done)he(i,0,o.ins,l),s&&mt(s,i,o.text),o.next();else{if(r.done||o.done)throw new Error("Mismatched change set lengths");{let a=Math.min(r.len2,o.len),h=i.length;if(r.ins==-1){let c=o.ins==-1?-1:o.off?0:o.ins;he(i,a,c,l),s&&c&&mt(s,i,o.text)}else o.ins==-1?(he(i,r.off?0:r.len,a,l),s&&mt(s,i,r.textBit(a))):(he(i,r.off?0:r.len,o.off?0:o.ins,l),s&&!o.off&&mt(s,i,o.text));l=(r.ins>a||o.ins>=0&&o.len>a)&&(l||i.length>h),r.forward2(a),o.forward(a)}}}}class Oi{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i<e.length?(this.len=e[this.i++],this.ins=e[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return this.ins==-2}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:e}=this.set,t=this.i-2>>1;return t>=e.length?F.empty:e[t]}textBit(e){let{inserted:t}=this.set,i=this.i-2>>1;return i>=t.length&&!e?F.empty:t[i].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class Pt{constructor(e,t,i){this.from=e,this.to=t,this.flags=i}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}get goalColumn(){let e=this.flags>>6;return e==16777215?void 0:e}map(e,t=-1){let i,s;return this.empty?i=s=e.mapPos(this.from,t):(i=e.mapPos(this.from,1),s=e.mapPos(this.to,-1)),i==this.from&&s==this.to?this:new Pt(i,s,this.flags)}extend(e,t=e,i=0){if(e<=this.anchor&&t>=this.anchor)return b.range(e,t,void 0,void 0,i);let s=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return b.range(this.anchor,s,void 0,void 0,i)}eq(e,t=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!t||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return b.range(e.anchor,e.head)}static create(e,t,i){return new Pt(e,t,i)}}class b{constructor(e,t){this.ranges=e,this.mainIndex=t}map(e,t=-1){return e.empty?this:b.create(this.ranges.map(i=>i.map(e,t)),this.mainIndex)}eq(e,t=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let i=0;i<this.ranges.length;i++)if(!this.ranges[i].eq(e.ranges[i],t))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new b([this.main],0)}addRange(e,t=!0){return b.create([e].concat(this.ranges),t?0:this.mainIndex+1)}replaceRange(e,t=this.mainIndex){let i=this.ranges.slice();return i[t]=e,b.create(i,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(e=>e.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new b(e.ranges.map(t=>Pt.fromJSON(t)),e.main)}static single(e,t=e){return new b([b.range(e,t)],0)}static create(e,t=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let i=0,s=0;s<e.length;s++){let r=e[s];if(r.empty?r.from<=i:r.from<i)return b.normalized(e.slice(),t);i=r.to}return new b(e,t)}static cursor(e,t=0,i,s){return Pt.create(e,e,(t==0?0:t<0?8:16)|(i==null?7:Math.min(6,i))|(s??16777215)<<6)}static range(e,t,i,s,r){let o=(i??16777215)<<6|(s==null?7:Math.min(6,s));return!r&&e!=t&&(r=t<e?1:-1),t<e?Pt.create(t,e,48|o):Pt.create(e,t,(r?r<0?8:16:0)|o)}static normalized(e,t=0){let i=e[t];e.sort((s,r)=>s.from-r.from),t=e.indexOf(i);for(let s=1;s<e.length;s++){let r=e[s],o=e[s-1];if(r.empty?r.from<=o.to:r.from<o.to){let l=o.from,a=Math.max(r.to,o.to);s<=t&&t--,e.splice(--s,2,r.anchor>r.head?b.range(a,l):b.range(l,a))}}return new b(e,t)}}function Da(n,e){for(let t of n.ranges)if(t.to>e)throw new RangeError("Selection points outside of document")}let Qr=0;class M{constructor(e,t,i,s,r){this.combine=e,this.compareInput=t,this.compare=i,this.isStatic=s,this.id=Qr++,this.default=e([]),this.extensions=typeof r=="function"?r(this):r}get reader(){return this}static define(e={}){return new M(e.combine||(t=>t),e.compareInput||((t,i)=>t===i),e.compare||(e.combine?(t,i)=>t===i:Yr),!!e.static,e.enables)}of(e){return new Sn([],this,0,e)}compute(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new Sn(e,this,1,t)}computeN(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new Sn(e,this,2,t)}from(e,t){return t||(t=i=>i),this.compute([e],i=>t(i.field(e)))}}function Yr(n,e){return n==e||n.length==e.length&&n.every((t,i)=>t===e[i])}class Sn{constructor(e,t,i,s){this.dependencies=e,this.facet=t,this.type=i,this.value=s,this.id=Qr++}dynamicSlot(e){var t;let i=this.value,s=this.facet.compareInput,r=this.id,o=e[r]>>1,l=this.type==2,a=!1,h=!1,c=[];for(let f of this.dependencies)f=="doc"?a=!0:f=="selection"?h=!0:((t=e[f.id])!==null&&t!==void 0?t:1)&1||c.push(e[f.id]);return{create(f){return f.values[o]=i(f),1},update(f,u){if(a&&u.docChanged||h&&(u.docChanged||u.selection)||nr(f,c)){let d=i(f);if(l?!Wo(d,f.values[o],s):!s(d,f.values[o]))return f.values[o]=d,1}return 0},reconfigure:(f,u)=>{let d,p=u.config.address[r];if(p!=null){let m=Rn(u,p);if(this.dependencies.every(g=>g instanceof M?u.facet(g)===f.facet(g):g instanceof se?u.field(g,!1)==f.field(g,!1):!0)||(l?Wo(d=i(f),m,s):s(d=i(f),m)))return f.values[o]=m,0}else d=i(f);return f.values[o]=d,1}}}}function Wo(n,e,t){if(n.length!=e.length)return!1;for(let i=0;i<n.length;i++)if(!t(n[i],e[i]))return!1;return!0}function nr(n,e){let t=!1;for(let i of e)wi(n,i)&1&&(t=!0);return t}function Pf(n,e,t){let i=t.map(a=>n[a.id]),s=t.map(a=>a.type),r=i.filter(a=>!(a&1)),o=n[e.id]>>1;function l(a){let h=[];for(let c=0;c<i.length;c++){let f=Rn(a,i[c]);if(s[c]==2)for(let u of f)h.push(u);else h.push(f)}return e.combine(h)}return{create(a){for(let h of i)wi(a,h);return a.values[o]=l(a),1},update(a,h){if(!nr(a,r))return 0;let c=l(a);return e.compare(c,a.values[o])?0:(a.values[o]=c,1)},reconfigure(a,h){let c=nr(a,i),f=h.config.facets[e.id],u=h.facet(e);if(f&&!c&&Yr(t,f))return a.values[o]=u,0;let d=l(a);return e.compare(d,u)?(a.values[o]=u,0):(a.values[o]=d,1)}}}const Xi=M.define({static:!0});class se{constructor(e,t,i,s,r){this.id=e,this.createF=t,this.updateF=i,this.compareF=s,this.spec=r,this.provides=void 0}static define(e){let t=new se(Qr++,e.create,e.update,e.compare||((i,s)=>i===s),e);return e.provide&&(t.provides=e.provide(t)),t}create(e){let t=e.facet(Xi).find(i=>i.field==this);return((t==null?void 0:t.create)||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:i=>(i.values[t]=this.create(i),1),update:(i,s)=>{let r=i.values[t],o=this.updateF(r,s);return this.compareF(r,o)?0:(i.values[t]=o,1)},reconfigure:(i,s)=>{let r=i.facet(Xi),o=s.facet(Xi),l;return(l=r.find(a=>a.field==this))&&l!=o.find(a=>a.field==this)?(i.values[t]=l.create(i),1):s.config.address[this.id]!=null?(i.values[t]=s.field(this),0):(i.values[t]=this.create(i),1)}}}init(e){return[this,Xi.of({field:this,create:e})]}get extension(){return this}}const Dt={lowest:4,low:3,default:2,high:1,highest:0};function fi(n){return e=>new Ba(e,n)}const Vt={highest:fi(Dt.highest),high:fi(Dt.high),default:fi(Dt.default),low:fi(Dt.low),lowest:fi(Dt.lowest)};class Ba{constructor(e,t){this.inner=e,this.prec=t}}class rs{of(e){return new sr(this,e)}reconfigure(e){return rs.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class sr{constructor(e,t){this.compartment=e,this.inner=t}}class Pn{constructor(e,t,i,s,r,o){for(this.base=e,this.compartments=t,this.dynamicSlots=i,this.address=s,this.staticValues=r,this.facets=o,this.statusTemplate=[];this.statusTemplate.length<i.length;)this.statusTemplate.push(0)}staticFacet(e){let t=this.address[e.id];return t==null?e.default:this.staticValues[t>>1]}static resolve(e,t,i){let s=[],r=Object.create(null),o=new Map;for(let u of Rf(e,t,o))u instanceof se?s.push(u):(r[u.facet.id]||(r[u.facet.id]=[])).push(u);let l=Object.create(null),a=[],h=[];for(let u of s)l[u.id]=h.length<<1,h.push(d=>u.slot(d));let c=i==null?void 0:i.config.facets;for(let u in r){let d=r[u],p=d[0].facet,m=c&&c[u]||[];if(d.every(g=>g.type==0))if(l[p.id]=a.length<<1|1,Yr(m,d))a.push(i.facet(p));else{let g=p.combine(d.map(y=>y.value));a.push(i&&p.compare(g,i.facet(p))?i.facet(p):g)}else{for(let g of d)g.type==0?(l[g.id]=a.length<<1|1,a.push(g.value)):(l[g.id]=h.length<<1,h.push(y=>g.dynamicSlot(y)));l[p.id]=h.length<<1,h.push(g=>Pf(g,p,d))}}let f=h.map(u=>u(l));return new Pn(e,o,f,l,a,r)}}function Rf(n,e,t){let i=[[],[],[],[],[]],s=new Map;function r(o,l){let a=s.get(o);if(a!=null){if(a<=l)return;let h=i[a].indexOf(o);h>-1&&i[a].splice(h,1),o instanceof sr&&t.delete(o.compartment)}if(s.set(o,l),Array.isArray(o))for(let h of o)r(h,l);else if(o instanceof sr){if(t.has(o.compartment))throw new RangeError("Duplicate use of compartment in extensions");let h=e.get(o.compartment)||o.inner;t.set(o.compartment,h),r(h,l)}else if(o instanceof Ba)r(o.inner,o.prec);else if(o instanceof se)i[l].push(o),o.provides&&r(o.provides,l);else if(o instanceof Sn)i[l].push(o),o.facet.extensions&&r(o.facet.extensions,Dt.default);else{let h=o.extension;if(!h)throw new Error(`Unrecognized extension value in extension set (${o}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);r(h,l)}}return r(n,Dt.default),i.reduce((o,l)=>o.concat(l))}function wi(n,e){if(e&1)return 2;let t=e>>1,i=n.status[t];if(i==4)throw new Error("Cyclic dependency between fields and/or facets");if(i&2)return i;n.status[t]=4;let s=n.computeSlot(n,n.config.dynamicSlots[t]);return n.status[t]=2|s}function Rn(n,e){return e&1?n.config.staticValues[e>>1]:n.values[e>>1]}const Pa=M.define(),rr=M.define({combine:n=>n.some(e=>e),static:!0}),Ra=M.define({combine:n=>n.length?n[0]:void 0,static:!0}),La=M.define(),Ea=M.define(),Ia=M.define(),Na=M.define({combine:n=>n.length?n[0]:!1});class ft{constructor(e,t){this.type=e,this.value=t}static define(){return new Lf}}class Lf{of(e){return new ft(this,e)}}class Ef{constructor(e){this.map=e}of(e){return new R(this,e)}}class R{constructor(e,t){this.type=e,this.value=t}map(e){let t=this.type.map(this.value,e);return t===void 0?void 0:t==this.value?this:new R(this.type,t)}is(e){return this.type==e}static define(e={}){return new Ef(e.map||(t=>t))}static mapEffects(e,t){if(!e.length)return e;let i=[];for(let s of e){let r=s.map(t);r&&i.push(r)}return i}}R.reconfigure=R.define();R.appendConfig=R.define();class te{constructor(e,t,i,s,r,o){this.startState=e,this.changes=t,this.selection=i,this.effects=s,this.annotations=r,this.scrollIntoView=o,this._doc=null,this._state=null,i&&Da(i,t.newLength),r.some(l=>l.type==te.time)||(this.annotations=r.concat(te.time.of(Date.now())))}static create(e,t,i,s,r,o){return new te(e,t,i,s,r,o)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let t of this.annotations)if(t.type==e)return t.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let t=this.annotation(te.userEvent);return!!(t&&(t==e||t.length>e.length&&t.slice(0,e.length)==e&&t[e.length]=="."))}}te.time=ft.define();te.userEvent=ft.define();te.addToHistory=ft.define();te.remote=ft.define();function If(n,e){let t=[];for(let i=0,s=0;;){let r,o;if(i<n.length&&(s==e.length||e[s]>=n[i]))r=n[i++],o=n[i++];else if(s<e.length)r=e[s++],o=e[s++];else return t;!t.length||t[t.length-1]<r?t.push(r,o):t[t.length-1]<o&&(t[t.length-1]=o)}}function Wa(n,e,t){var i;let s,r,o;return t?(s=e.changes,r=ee.empty(e.changes.length),o=n.changes.compose(e.changes)):(s=e.changes.map(n.changes),r=n.changes.mapDesc(e.changes,!0),o=n.changes.compose(s)),{changes:o,selection:e.selection?e.selection.map(r):(i=n.selection)===null||i===void 0?void 0:i.map(s),effects:R.mapEffects(n.effects,s).concat(R.mapEffects(e.effects,r)),annotations:n.annotations.length?n.annotations.concat(e.annotations):e.annotations,scrollIntoView:n.scrollIntoView||e.scrollIntoView}}function or(n,e,t){let i=e.selection,s=_t(e.annotations);return e.userEvent&&(s=s.concat(te.userEvent.of(e.userEvent))),{changes:e.changes instanceof ee?e.changes:ee.of(e.changes||[],t,n.facet(Ra)),selection:i&&(i instanceof b?i:b.single(i.anchor,i.head)),effects:_t(e.effects),annotations:s,scrollIntoView:!!e.scrollIntoView}}function Fa(n,e,t){let i=or(n,e.length?e[0]:{},n.doc.length);e.length&&e[0].filter===!1&&(t=!1);for(let r=1;r<e.length;r++){e[r].filter===!1&&(t=!1);let o=!!e[r].sequential;i=Wa(i,or(n,e[r],o?i.changes.newLength:n.doc.length),o)}let s=te.create(n,i.changes,i.selection,i.effects,i.annotations,i.scrollIntoView);return Wf(t?Nf(s):s)}function Nf(n){let e=n.startState,t=!0;for(let s of e.facet(La)){let r=s(n);if(r===!1){t=!1;break}Array.isArray(r)&&(t=t===!0?r:If(t,r))}if(t!==!0){let s,r;if(t===!1)r=n.changes.invertedDesc,s=ee.empty(e.doc.length);else{let o=n.changes.filter(t);s=o.changes,r=o.filtered.mapDesc(o.changes).invertedDesc}n=te.create(e,s,n.selection&&n.selection.map(r),R.mapEffects(n.effects,r),n.annotations,n.scrollIntoView)}let i=e.facet(Ea);for(let s=i.length-1;s>=0;s--){let r=i[s](n);r instanceof te?n=r:Array.isArray(r)&&r.length==1&&r[0]instanceof te?n=r[0]:n=Fa(e,_t(r),!1)}return n}function Wf(n){let e=n.startState,t=e.facet(Ia),i=n;for(let s=t.length-1;s>=0;s--){let r=t[s](n);r&&Object.keys(r).length&&(i=Wa(i,or(e,r,n.changes.newLength),!0))}return i==n?n:te.create(e,n.changes,n.selection,i.effects,i.annotations,i.scrollIntoView)}const Ff=[];function _t(n){return n==null?Ff:Array.isArray(n)?n:[n]}var Q=function(n){return n[n.Word=0]="Word",n[n.Space=1]="Space",n[n.Other=2]="Other",n}(Q||(Q={}));const Hf=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let lr;try{lr=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function Vf(n){if(lr)return lr.test(n);for(let e=0;e<n.length;e++){let t=n[e];if(/\w/.test(t)||t>"€"&&(t.toUpperCase()!=t.toLowerCase()||Hf.test(t)))return!0}return!1}function zf(n){return e=>{if(!/\S/.test(e))return Q.Space;if(Vf(e))return Q.Word;for(let t=0;t<n.length;t++)if(e.indexOf(n[t])>-1)return Q.Word;return Q.Other}}class V{constructor(e,t,i,s,r,o){this.config=e,this.doc=t,this.selection=i,this.values=s,this.status=e.statusTemplate.slice(),this.computeSlot=r,o&&(o._state=this);for(let l=0;l<this.config.dynamicSlots.length;l++)wi(this,l<<1);this.computeSlot=null}field(e,t=!0){let i=this.config.address[e.id];if(i==null){if(t)throw new RangeError("Field is not present in this state");return}return wi(this,i),Rn(this,i)}update(...e){return Fa(this,e,!0)}applyTransaction(e){let t=this.config,{base:i,compartments:s}=t;for(let l of e.effects)l.is(rs.reconfigure)?(t&&(s=new Map,t.compartments.forEach((a,h)=>s.set(h,a)),t=null),s.set(l.value.compartment,l.value.extension)):l.is(R.reconfigure)?(t=null,i=l.value):l.is(R.appendConfig)&&(t=null,i=_t(i).concat(l.value));let r;t?r=e.startState.values.slice():(t=Pn.resolve(i,s,this),r=new V(t,this.doc,this.selection,t.dynamicSlots.map(()=>null),(a,h)=>h.reconfigure(a,this),null).values);let o=e.startState.facet(rr)?e.newSelection:e.newSelection.asSingle();new V(t,e.newDoc,o,r,(l,a)=>a.update(l,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:b.cursor(t.from+e.length)}))}changeByRange(e){let t=this.selection,i=e(t.ranges[0]),s=this.changes(i.changes),r=[i.range],o=_t(i.effects);for(let l=1;l<t.ranges.length;l++){let a=e(t.ranges[l]),h=this.changes(a.changes),c=h.map(s);for(let u=0;u<l;u++)r[u]=r[u].map(c);let f=s.mapDesc(h,!0);r.push(a.range.map(f)),s=s.compose(c),o=R.mapEffects(o,c).concat(R.mapEffects(_t(a.effects),f))}return{changes:s,selection:b.create(r,t.mainIndex),effects:o}}changes(e=[]){return e instanceof ee?e:ee.of(e,this.doc.length,this.facet(V.lineSeparator))}toText(e){return F.of(e.split(this.facet(V.lineSeparator)||er))}sliceDoc(e=0,t=this.doc.length){return this.doc.sliceString(e,t,this.lineBreak)}facet(e){let t=this.config.address[e.id];return t==null?e.default:(wi(this,t),Rn(this,t))}toJSON(e){let t={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let i in e){let s=e[i];s instanceof se&&this.config.address[s.id]!=null&&(t[i]=s.spec.toJSON(this.field(e[i]),this))}return t}static fromJSON(e,t={},i){if(!e||typeof e.doc!="string")throw new RangeError("Invalid JSON representation for EditorState");let s=[];if(i){for(let r in i)if(Object.prototype.hasOwnProperty.call(e,r)){let o=i[r],l=e[r];s.push(o.init(a=>o.spec.fromJSON(l,a)))}}return V.create({doc:e.doc,selection:b.fromJSON(e.selection),extensions:t.extensions?s.concat([t.extensions]):s})}static create(e={}){let t=Pn.resolve(e.extensions||[],new Map),i=e.doc instanceof F?e.doc:F.of((e.doc||"").split(t.staticFacet(V.lineSeparator)||er)),s=e.selection?e.selection instanceof b?e.selection:b.single(e.selection.anchor,e.selection.head):b.single(0);return Da(s,i.length),t.staticFacet(rr)||(s=s.asSingle()),new V(t,i,s,t.dynamicSlots.map(()=>null),(r,o)=>o.create(r),null)}get tabSize(){return this.facet(V.tabSize)}get lineBreak(){return this.facet(V.lineSeparator)||`
5
5
  `}get readOnly(){return this.facet(Na)}phrase(e,...t){for(let i of this.facet(V.phrases))if(Object.prototype.hasOwnProperty.call(i,e)){e=i[e];break}return t.length&&(e=e.replace(/\$(\$|\d*)/g,(i,s)=>{if(s=="$")return"$";let r=+(s||1);return!r||r>t.length?i:t[r-1]})),e}languageDataAt(e,t,i=-1){let s=[];for(let r of this.facet(Pa))for(let o of r(this,t,i))Object.prototype.hasOwnProperty.call(o,e)&&s.push(o[e]);return s}charCategorizer(e){let t=this.languageDataAt("wordChars",e);return zf(t.length?t[0]:"")}wordAt(e){let{text:t,from:i,length:s}=this.doc.lineAt(e),r=this.charCategorizer(e),o=e-i,l=e-i;for(;o>0;){let a=ne(t,o,!1);if(r(t.slice(a,o))!=Q.Word)break;o=a}for(;l<s;){let a=ne(t,l);if(r(t.slice(l,a))!=Q.Word)break;l=a}return o==l?null:b.range(o+i,l+i)}}V.allowMultipleSelections=rr;V.tabSize=M.define({combine:n=>n.length?n[0]:4});V.lineSeparator=Ra;V.readOnly=Na;V.phrases=M.define({compare(n,e){let t=Object.keys(n),i=Object.keys(e);return t.length==i.length&&t.every(s=>n[s]==e[s])}});V.languageData=Pa;V.changeFilter=La;V.transactionFilter=Ea;V.transactionExtender=Ia;rs.reconfigure=R.define();function Ve(n,e,t={}){let i={};for(let s of n)for(let r of Object.keys(s)){let o=s[r],l=i[r];if(l===void 0)i[r]=o;else if(!(l===o||o===void 0))if(Object.hasOwnProperty.call(t,r))i[r]=t[r](l,o);else throw new Error("Config merge conflict for field "+r)}for(let s in e)i[s]===void 0&&(i[s]=e[s]);return i}class bt{eq(e){return this==e}range(e,t=e){return ar.create(e,t,this)}}bt.prototype.startSide=bt.prototype.endSide=0;bt.prototype.point=!1;bt.prototype.mapMode=pe.TrackDel;function _r(n,e){return n==e||n.constructor==e.constructor&&n.eq(e)}let ar=class Ha{constructor(e,t,i){this.from=e,this.to=t,this.value=i}static create(e,t,i){return new Ha(e,t,i)}};function hr(n,e){return n.from-e.from||n.value.startSide-e.value.startSide}class Xr{constructor(e,t,i,s){this.from=e,this.to=t,this.value=i,this.maxPoint=s}get length(){return this.to[this.to.length-1]}findIndex(e,t,i,s=0){let r=i?this.to:this.from;for(let o=s,l=r.length;;){if(o==l)return o;let a=o+l>>1,h=r[a]-e||(i?this.value[a].endSide:this.value[a].startSide)-t;if(a==o)return h>=0?o:l;h>=0?l=a:o=a+1}}between(e,t,i,s){for(let r=this.findIndex(t,-1e9,!0),o=this.findIndex(i,1e9,!1,r);r<o;r++)if(s(this.from[r]+e,this.to[r]+e,this.value[r])===!1)return!1}map(e,t){let i=[],s=[],r=[],o=-1,l=-1;for(let a=0;a<this.value.length;a++){let h=this.value[a],c=this.from[a]+e,f=this.to[a]+e,u,d;if(c==f){let p=t.mapPos(c,h.startSide,h.mapMode);if(p==null||(u=d=p,h.startSide!=h.endSide&&(d=t.mapPos(c,h.endSide),d<u)))continue}else if(u=t.mapPos(c,h.startSide),d=t.mapPos(f,h.endSide),u>d||u==d&&h.startSide>0&&h.endSide<=0)continue;(d-u||h.endSide-h.startSide)<0||(o<0&&(o=u),h.point&&(l=Math.max(l,d-u)),i.push(h),s.push(u-o),r.push(d-o))}return{mapped:i.length?new Xr(s,r,i,l):null,pos:o}}}class E{constructor(e,t,i,s){this.chunkPos=e,this.chunk=t,this.nextLayer=i,this.maxPoint=s}static create(e,t,i,s){return new E(e,t,i,s)}get length(){let e=this.chunk.length-1;return e<0?0:Math.max(this.chunkEnd(e),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let e=this.nextLayer.size;for(let t of this.chunk)e+=t.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:t=[],sort:i=!1,filterFrom:s=0,filterTo:r=this.length}=e,o=e.filter;if(t.length==0&&!o)return this;if(i&&(t=t.slice().sort(hr)),this.isEmpty)return t.length?E.of(t):this;let l=new Va(this,null,-1).goto(0),a=0,h=[],c=new ht;for(;l.value||a<t.length;)if(a<t.length&&(l.from-t[a].from||l.startSide-t[a].value.startSide)>=0){let f=t[a++];c.addInner(f.from,f.to,f.value)||h.push(f)}else l.rangeIndex==1&&l.chunkIndex<this.chunk.length&&(a==t.length||this.chunkEnd(l.chunkIndex)<t[a].from)&&(!o||s>this.chunkEnd(l.chunkIndex)||r<this.chunkPos[l.chunkIndex])&&c.addChunk(this.chunkPos[l.chunkIndex],this.chunk[l.chunkIndex])?l.nextChunk():((!o||s>l.to||r<l.from||o(l.from,l.to,l.value))&&(c.addInner(l.from,l.to,l.value)||h.push(ar.create(l.from,l.to,l.value))),l.next());return c.finishInner(this.nextLayer.isEmpty&&!h.length?E.empty:this.nextLayer.update({add:h,filter:o,filterFrom:s,filterTo:r}))}map(e){if(e.empty||this.isEmpty)return this;let t=[],i=[],s=-1;for(let o=0;o<this.chunk.length;o++){let l=this.chunkPos[o],a=this.chunk[o],h=e.touchesRange(l,l+a.length);if(h===!1)s=Math.max(s,a.maxPoint),t.push(a),i.push(e.mapPos(l));else if(h===!0){let{mapped:c,pos:f}=a.map(l,e);c&&(s=Math.max(s,c.maxPoint),t.push(c),i.push(f))}}let r=this.nextLayer.map(e);return t.length==0?r:new E(i,t,r||E.empty,s)}between(e,t,i){if(!this.isEmpty){for(let s=0;s<this.chunk.length;s++){let r=this.chunkPos[s],o=this.chunk[s];if(t>=r&&e<=r+o.length&&o.between(r,e-r,t-r,i)===!1)return}this.nextLayer.between(e,t,i)}}iter(e=0){return Ti.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,t=0){return Ti.from(e).goto(t)}static compare(e,t,i,s,r=-1){let o=e.filter(f=>f.maxPoint>0||!f.isEmpty&&f.maxPoint>=r),l=t.filter(f=>f.maxPoint>0||!f.isEmpty&&f.maxPoint>=r),a=Fo(o,l,i),h=new ui(o,a,r),c=new ui(l,a,r);i.iterGaps((f,u,d)=>Ho(h,f,c,u,d,s)),i.empty&&i.length==0&&Ho(h,0,c,0,0,s)}static eq(e,t,i=0,s){s==null&&(s=999999999);let r=e.filter(c=>!c.isEmpty&&t.indexOf(c)<0),o=t.filter(c=>!c.isEmpty&&e.indexOf(c)<0);if(r.length!=o.length)return!1;if(!r.length)return!0;let l=Fo(r,o),a=new ui(r,l,0).goto(i),h=new ui(o,l,0).goto(i);for(;;){if(a.to!=h.to||!cr(a.active,h.active)||a.point&&(!h.point||!_r(a.point,h.point)))return!1;if(a.to>s)return!0;a.next(),h.next()}}static spans(e,t,i,s,r=-1){let o=new ui(e,null,r).goto(t),l=t,a=o.openStart;for(;;){let h=Math.min(o.to,i);if(o.point){let c=o.activeForPoint(o.to),f=o.pointFrom<t?c.length+1:o.point.startSide<0?c.length:Math.min(c.length,a);s.point(l,h,o.point,c,f,o.pointRank),a=Math.min(o.openEnd(h),c.length)}else h>l&&(s.span(l,h,o.active,a),a=o.openEnd(h));if(o.to>i)return a+(o.point&&o.to>i?1:0);l=o.to,o.next()}}static of(e,t=!1){let i=new ht;for(let s of e instanceof ar?[e]:t?qf(e):e)i.add(s.from,s.to,s.value);return i.finish()}static join(e){if(!e.length)return E.empty;let t=e[e.length-1];for(let i=e.length-2;i>=0;i--)for(let s=e[i];s!=E.empty;s=s.nextLayer)t=new E(s.chunkPos,s.chunk,t,Math.max(s.maxPoint,t.maxPoint));return t}}E.empty=new E([],[],null,-1);function qf(n){if(n.length>1)for(let e=n[0],t=1;t<n.length;t++){let i=n[t];if(hr(e,i)>0)return n.slice().sort(hr);e=i}return n}E.empty.nextLayer=E.empty;class ht{finishChunk(e){this.chunks.push(new Xr(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,e&&(this.from=[],this.to=[],this.value=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(e,t,i){this.addInner(e,t,i)||(this.nextLayer||(this.nextLayer=new ht)).add(e,t,i)}addInner(e,t,i){let s=e-this.lastTo||i.startSide-this.last.endSide;if(s<=0&&(e-this.lastFrom||i.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return s<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(t-this.chunkStart),this.last=i,this.lastFrom=e,this.lastTo=t,this.value.push(i),i.point&&(this.maxPoint=Math.max(this.maxPoint,t-e)),!0)}addChunk(e,t){if((e-this.lastTo||t.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,t.maxPoint),this.chunks.push(t),this.chunkPos.push(e);let i=t.value.length-1;return this.last=t.value[i],this.lastFrom=t.from[i]+e,this.lastTo=t.to[i]+e,!0}finish(){return this.finishInner(E.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let t=E.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,t}}function Fo(n,e,t){let i=new Map;for(let r of n)for(let o=0;o<r.chunk.length;o++)r.chunk[o].maxPoint<=0&&i.set(r.chunk[o],r.chunkPos[o]);let s=new Set;for(let r of e)for(let o=0;o<r.chunk.length;o++){let l=i.get(r.chunk[o]);l!=null&&(t?t.mapPos(l):l)==r.chunkPos[o]&&!(t!=null&&t.touchesRange(l,l+r.chunk[o].length))&&s.add(r.chunk[o])}return s}class Va{constructor(e,t,i,s=0){this.layer=e,this.skip=t,this.minPoint=i,this.rank=s}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(e,t=-1e9){return this.chunkIndex=this.rangeIndex=0,this.gotoInner(e,t,!1),this}gotoInner(e,t,i){for(;this.chunkIndex<this.layer.chunk.length;){let s=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(s)||this.layer.chunkEnd(this.chunkIndex)<e||s.maxPoint<this.minPoint))break;this.chunkIndex++,i=!1}if(this.chunkIndex<this.layer.chunk.length){let s=this.layer.chunk[this.chunkIndex].findIndex(e-this.layer.chunkPos[this.chunkIndex],t,!0);(!i||this.rangeIndex<s)&&this.setRangeIndex(s)}this.next()}forward(e,t){(this.to-e||this.endSide-t)<0&&this.gotoInner(e,t,!0)}next(){for(;;)if(this.chunkIndex==this.layer.chunk.length){this.from=this.to=1e9,this.value=null;break}else{let e=this.layer.chunkPos[this.chunkIndex],t=this.layer.chunk[this.chunkIndex],i=e+t.from[this.rangeIndex];if(this.from=i,this.to=e+t.to[this.rangeIndex],this.value=t.value[this.rangeIndex],this.setRangeIndex(this.rangeIndex+1),this.minPoint<0||this.value.point&&this.to-this.from>=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex<this.layer.chunk.length&&this.skip.has(this.layer.chunk[this.chunkIndex]);)this.chunkIndex++;this.rangeIndex=0}else this.rangeIndex=e}nextChunk(){this.chunkIndex++,this.rangeIndex=0,this.next()}compare(e){return this.from-e.from||this.startSide-e.startSide||this.rank-e.rank||this.to-e.to||this.endSide-e.endSide}}class Ti{constructor(e){this.heap=e}static from(e,t=null,i=-1){let s=[];for(let r=0;r<e.length;r++)for(let o=e[r];!o.isEmpty;o=o.nextLayer)o.maxPoint>=i&&s.push(new Va(o,t,i,r));return s.length==1?s[0]:new Ti(s)}get startSide(){return this.value?this.value.startSide:0}goto(e,t=-1e9){for(let i of this.heap)i.goto(e,t);for(let i=this.heap.length>>1;i>=0;i--)Cs(this.heap,i);return this.next(),this}forward(e,t){for(let i of this.heap)i.forward(e,t);for(let i=this.heap.length>>1;i>=0;i--)Cs(this.heap,i);(this.to-e||this.value.endSide-t)<0&&this.next()}next(){if(this.heap.length==0)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let e=this.heap[0];this.from=e.from,this.to=e.to,this.value=e.value,this.rank=e.rank,e.value&&e.next(),Cs(this.heap,0)}}}function Cs(n,e){for(let t=n[e];;){let i=(e<<1)+1;if(i>=n.length)break;let s=n[i];if(i+1<n.length&&s.compare(n[i+1])>=0&&(s=n[i+1],i++),t.compare(s)<0)break;n[i]=t,n[e]=s,e=i}}class ui{constructor(e,t,i){this.minPoint=i,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=Ti.from(e,t,i)}goto(e,t=-1e9){return this.cursor.goto(e,t),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=t,this.openStart=-1,this.next(),this}forward(e,t){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-t)<0;)this.removeActive(this.minActive);this.cursor.forward(e,t)}removeActive(e){Ji(this.active,e),Ji(this.activeTo,e),Ji(this.activeRank,e),this.minActive=Vo(this.active,this.activeTo)}addActive(e){let t=0,{value:i,to:s,rank:r}=this.cursor;for(;t<this.activeRank.length&&(r-this.activeRank[t]||s-this.activeTo[t])>0;)t++;Zi(this.active,t,i),Zi(this.activeTo,t,s),Zi(this.activeRank,t,r),e&&Zi(e,t,this.cursor.from),this.minActive=Vo(this.active,this.activeTo)}next(){let e=this.to,t=this.point;this.point=null;let i=this.openStart<0?[]:null;for(;;){let s=this.minActive;if(s>-1&&(this.activeTo[s]-this.cursor.from||this.active[s].endSide-this.cursor.startSide)<0){if(this.activeTo[s]>e){this.to=this.activeTo[s],this.endSide=this.active[s].endSide;break}this.removeActive(s),i&&Ji(i,s)}else if(this.cursor.value)if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let r=this.cursor.value;if(!r.point)this.addActive(i),this.cursor.next();else if(t&&this.cursor.to==this.to&&this.cursor.from<this.cursor.to)this.cursor.next();else{this.point=r,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=r.endSide,this.cursor.next(),this.forward(this.to,this.endSide);break}}else{this.to=this.endSide=1e9;break}}if(i){this.openStart=0;for(let s=i.length-1;s>=0&&i[s]<e;s--)this.openStart++}}activeForPoint(e){if(!this.active.length)return this.active;let t=[];for(let i=this.active.length-1;i>=0&&!(this.activeRank[i]<this.pointRank);i--)(this.activeTo[i]>e||this.activeTo[i]==e&&this.active[i].endSide>=this.point.endSide)&&t.push(this.active[i]);return t.reverse()}openEnd(e){let t=0;for(let i=this.activeTo.length-1;i>=0&&this.activeTo[i]>e;i--)t++;return t}}function Ho(n,e,t,i,s,r){n.goto(e),t.goto(i);let o=i+s,l=i,a=i-e,h=!!r.boundChange;for(let c=!1;;){let f=n.to+a-t.to,u=f||n.endSide-t.endSide,d=u<0?n.to+a:t.to,p=Math.min(d,o);if(n.point||t.point?(n.point&&t.point&&_r(n.point,t.point)&&cr(n.activeForPoint(n.to),t.activeForPoint(t.to))||r.comparePoint(l,p,n.point,t.point),c=!1):(c&&r.boundChange(l),p>l&&!cr(n.active,t.active)&&r.compareRange(l,p,n.active,t.active),h&&p<o&&(f||n.openEnd(d)!=t.openEnd(d))&&(c=!0)),d>o)break;l=d,u<=0&&n.next(),u>=0&&t.next()}}function cr(n,e){if(n.length!=e.length)return!1;for(let t=0;t<n.length;t++)if(n[t]!=e[t]&&!_r(n[t],e[t]))return!1;return!0}function Ji(n,e){for(let t=e,i=n.length-1;t<i;t++)n[t]=n[t+1];n.pop()}function Zi(n,e,t){for(let i=n.length-1;i>=e;i--)n[i+1]=n[i];n[e]=t}function Vo(n,e){let t=-1,i=1e9;for(let s=0;s<e.length;s++)(e[s]-i||n[s].endSide-n[t].endSide)<0&&(t=s,i=e[s]);return t}function hi(n,e,t=n.length){let i=0;for(let s=0;s<t&&s<n.length;)n.charCodeAt(s)==9?(i+=e-i%e,s++):(i++,s=ne(n,s));return i}function fr(n,e,t,i){for(let s=0,r=0;;){if(r>=e)return s;if(s==n.length)break;r+=n.charCodeAt(s)==9?t-r%t:1,s=ne(n,s)}return i===!0?-1:n.length}const ur="ͼ",zo=typeof Symbol>"u"?"__"+ur:Symbol.for(ur),dr=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),qo=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};class xt{constructor(e,t){this.rules=[];let{finish:i}=t||{};function s(o){return/^@/.test(o)?[o]:o.split(/,\s*/)}function r(o,l,a,h){let c=[],f=/^@(\w+)\b/.exec(o[0]),u=f&&f[1]=="keyframes";if(f&&l==null)return a.push(o[0]+";");for(let d in l){let p=l[d];if(/&/.test(d))r(d.split(/,\s*/).map(m=>o.map(g=>m.replace(/&/,g))).reduce((m,g)=>m.concat(g)),p,a);else if(p&&typeof p=="object"){if(!f)throw new RangeError("The value of a property ("+d+") should be a primitive value.");r(s(d),p,c,u)}else p!=null&&c.push(d.replace(/_.*/,"").replace(/[A-Z]/g,m=>"-"+m.toLowerCase())+": "+p+";")}(c.length||u)&&a.push((i&&!f&&!h?o.map(i):o).join(", ")+" {"+c.join(" ")+"}")}for(let o in e)r(s(o),e[o],this.rules)}getRules(){return this.rules.join(`
6
6
  `)}static newName(){let e=qo[zo]||1;return qo[zo]=e+1,ur+e.toString(36)}static mount(e,t,i){let s=e[dr],r=i&&i.nonce;s?r&&s.setNonce(r):s=new $f(e,r),s.mount(Array.isArray(t)?t:[t],e)}}let $o=new Map;class $f{constructor(e,t){let i=e.ownerDocument||e,s=i.defaultView;if(!e.head&&e.adoptedStyleSheets&&s.CSSStyleSheet){let r=$o.get(i);if(r)return e[dr]=r;this.sheet=new s.CSSStyleSheet,$o.set(i,this)}else this.styleTag=i.createElement("style"),t&&this.styleTag.setAttribute("nonce",t);this.modules=[],e[dr]=this}mount(e,t){let i=this.sheet,s=0,r=0;for(let o=0;o<e.length;o++){let l=e[o],a=this.modules.indexOf(l);if(a<r&&a>-1&&(this.modules.splice(a,1),r--,a=-1),a==-1){if(this.modules.splice(r++,0,l),i)for(let h=0;h<l.rules.length;h++)i.insertRule(l.rules[h],s++)}else{for(;r<a;)s+=this.modules[r++].rules.length;s+=l.rules.length,r++}}if(i)t.adoptedStyleSheets.indexOf(this.sheet)<0&&(t.adoptedStyleSheets=[this.sheet,...t.adoptedStyleSheets]);else{let o="";for(let a=0;a<this.modules.length;a++)o+=this.modules[a].getRules()+`
7
7
  `;this.styleTag.textContent=o;let l=t.head||t;this.styleTag.parentNode!=l&&l.insertBefore(this.styleTag,l.firstChild)}}setNonce(e){this.styleTag&&this.styleTag.getAttribute("nonce")!=e&&this.styleTag.setAttribute("nonce",e)}}var wt={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},Di={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Kf=typeof navigator<"u"&&/Mac/.test(navigator.platform),jf=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var le=0;le<10;le++)wt[48+le]=wt[96+le]=String(le);for(var le=1;le<=24;le++)wt[le+111]="F"+le;for(var le=65;le<=90;le++)wt[le]=String.fromCharCode(le+32),Di[le]=String.fromCharCode(le);for(var As in wt)Di.hasOwnProperty(As)||(Di[As]=wt[As]);function Uf(n){var e=Kf&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||jf&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?Di:wt)[n.keyCode]||n.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}function q(){var n=arguments[0];typeof n=="string"&&(n=document.createElement(n));var e=1,t=arguments[1];if(t&&typeof t=="object"&&t.nodeType==null&&!Array.isArray(t)){for(var i in t)if(Object.prototype.hasOwnProperty.call(t,i)){var s=t[i];typeof s=="string"?n.setAttribute(i,s):s!=null&&(n[i]=s)}e++}for(;e<arguments.length;e++)za(n,arguments[e]);return n}function za(n,e){if(typeof e=="string")n.appendChild(document.createTextNode(e));else if(e!=null)if(e.nodeType!=null)n.appendChild(e);else if(Array.isArray(e))for(var t=0;t<e.length;t++)za(n,e[t]);else throw new RangeError("Unsupported child node: "+e)}let de=typeof navigator<"u"?navigator:{userAgent:"",vendor:"",platform:""},pr=typeof document<"u"?document:{documentElement:{style:{}}};const mr=/Edge\/(\d+)/.exec(de.userAgent),qa=/MSIE \d/.test(de.userAgent),gr=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(de.userAgent),os=!!(qa||gr||mr),Ko=!os&&/gecko\/(\d+)/i.test(de.userAgent),Ms=!os&&/Chrome\/(\d+)/.exec(de.userAgent),Gf="webkitFontSmoothing"in pr.documentElement.style,yr=!os&&/Apple Computer/.test(de.vendor),jo=yr&&(/Mobile\/\w+/.test(de.userAgent)||de.maxTouchPoints>2);var O={mac:jo||/Mac/.test(de.platform),windows:/Win/.test(de.platform),linux:/Linux|X11/.test(de.platform),ie:os,ie_version:qa?pr.documentMode||6:gr?+gr[1]:mr?+mr[1]:0,gecko:Ko,gecko_version:Ko?+(/Firefox\/(\d+)/.exec(de.userAgent)||[0,0])[1]:0,chrome:!!Ms,chrome_version:Ms?+Ms[1]:0,ios:jo,android:/Android\b/.test(de.userAgent),webkit_version:Gf?+(/\bAppleWebKit\/(\d+)/.exec(de.userAgent)||[0,0])[1]:0,safari:yr,safari_version:yr?+(/\bVersion\/(\d+(\.\d+)?)/.exec(de.userAgent)||[0,0])[1]:0,tabSize:pr.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};function Jr(n,e){for(let t in n)t=="class"&&e.class?e.class+=" "+n.class:t=="style"&&e.style?e.style+=";"+n.style:e[t]=n[t];return e}const Ln=Object.create(null);function Zr(n,e,t){if(n==e)return!0;n||(n=Ln),e||(e=Ln);let i=Object.keys(n),s=Object.keys(e);if(i.length-0!=s.length-0)return!1;for(let r of i)if(r!=t&&(s.indexOf(r)==-1||n[r]!==e[r]))return!1;return!0}function Qf(n,e){for(let t=n.attributes.length-1;t>=0;t--){let i=n.attributes[t].name;e[i]==null&&n.removeAttribute(i)}for(let t in e){let i=e[t];t=="style"?n.style.cssText=i:n.getAttribute(t)!=i&&n.setAttribute(t,i)}}function Uo(n,e,t){let i=!1;if(e)for(let s in e)t&&s in t||(i=!0,s=="style"?n.style.cssText="":n.removeAttribute(s));if(t)for(let s in t)e&&e[s]==t[s]||(i=!0,s=="style"?n.style.cssText=t[s]:n.setAttribute(s,t[s]));return i}function Yf(n){let e=Object.create(null);for(let t=0;t<n.attributes.length;t++){let i=n.attributes[t];e[i.name]=i.value}return e}class st{eq(e){return!1}updateDOM(e,t){return!1}compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}get estimatedHeight(){return-1}get lineBreaks(){return 0}ignoreEvent(e){return!0}coordsAt(e,t,i){return null}get isHidden(){return!1}get editable(){return!1}destroy(e){}}var ae=function(n){return n[n.Text=0]="Text",n[n.WidgetBefore=1]="WidgetBefore",n[n.WidgetAfter=2]="WidgetAfter",n[n.WidgetRange=3]="WidgetRange",n}(ae||(ae={}));class B extends bt{constructor(e,t,i,s){super(),this.startSide=e,this.endSide=t,this.widget=i,this.spec=s}get heightRelevant(){return!1}static mark(e){return new $i(e)}static widget(e){let t=Math.max(-1e4,Math.min(1e4,e.side||0)),i=!!e.block;return t+=i&&!e.inlineOrder?t>0?3e8:-4e8:t>0?1e8:-1e8,new Nt(e,t,t,i,e.widget||null,!1)}static replace(e){let t=!!e.block,i,s;if(e.isBlockGap)i=-5e8,s=4e8;else{let{start:r,end:o}=$a(e,t);i=(r?t?-3e8:-1:5e8)-1,s=(o?t?2e8:1:-6e8)+1}return new Nt(e,i,s,t,e.widget||null,!0)}static line(e){return new Ki(e)}static set(e,t=!1){return E.of(e,t)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}}B.none=E.empty;class $i extends B{constructor(e){let{start:t,end:i}=$a(e);super(t?-1:5e8,i?1:-6e8,null,e),this.tagName=e.tagName||"span",this.attrs=e.class&&e.attributes?Jr(e.attributes,{class:e.class}):e.class?{class:e.class}:e.attributes||Ln}eq(e){return this==e||e instanceof $i&&this.tagName==e.tagName&&Zr(this.attrs,e.attrs)}range(e,t=e){if(e>=t)throw new RangeError("Mark decorations may not be empty");return super.range(e,t)}}$i.prototype.point=!1;class Ki extends B{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof Ki&&this.spec.class==e.spec.class&&Zr(this.spec.attributes,e.spec.attributes)}range(e,t=e){if(t!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,t)}}Ki.prototype.mapMode=pe.TrackBefore;Ki.prototype.point=!0;class Nt extends B{constructor(e,t,i,s,r,o){super(t,i,r,e),this.block=s,this.isReplace=o,this.mapMode=s?t<=0?pe.TrackBefore:pe.TrackAfter:pe.TrackDel}get type(){return this.startSide!=this.endSide?ae.WidgetRange:this.startSide<=0?ae.WidgetBefore:ae.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof Nt&&_f(this.widget,e.widget)&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e,t=e){if(this.isReplace&&(e>t||e==t&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&t!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,t)}}Nt.prototype.point=!0;function $a(n,e=!1){let{inclusiveStart:t,inclusiveEnd:i}=n;return t==null&&(t=n.inclusive),i==null&&(i=n.inclusive),{start:t??e,end:i??e}}function _f(n,e){return n==e||!!(n&&e&&n.compare(e))}function Xt(n,e,t,i=0){let s=t.length-1;s>=0&&t[s]+i>=n?t[s]=Math.max(t[s],e):t.push(n,e)}class Bi extends bt{constructor(e,t){super(),this.tagName=e,this.attributes=t}eq(e){return e==this||e instanceof Bi&&this.tagName==e.tagName&&Zr(this.attributes,e.attributes)}static create(e){return new Bi(e.tagName,e.attributes||Ln)}static set(e,t=!1){return E.of(e,t)}}Bi.prototype.startSide=Bi.prototype.endSide=-1;function Pi(n){let e;return n.nodeType==11?e=n.getSelection?n:n.ownerDocument:e=n,e.getSelection()}function br(n,e){return e?n==e||n.contains(e.nodeType!=1?e.parentNode:e):!1}function ki(n,e){if(!e.anchorNode)return!1;try{return br(n,e.anchorNode)}catch{return!1}}function vi(n){return n.nodeType==3?Li(n,0,n.nodeValue.length).getClientRects():n.nodeType==1?n.getClientRects():[]}function Si(n,e,t,i){return t?Go(n,e,t,i,-1)||Go(n,e,t,i,1):!1}function kt(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e}function En(n){return n.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(n.nodeName)}function Go(n,e,t,i,s){for(;;){if(n==t&&e==i)return!0;if(e==(s<0?0:ct(n))){if(n.nodeName=="DIV")return!1;let r=n.parentNode;if(!r||r.nodeType!=1)return!1;e=kt(n)+(s<0?0:1),n=r}else if(n.nodeType==1){if(n=n.childNodes[e+(s<0?-1:0)],n.nodeType==1&&n.contentEditable=="false")return!1;e=s<0?ct(n):0}else return!1}}function ct(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Ri(n,e){let t=e?n.left:n.right;return{left:t,right:t,top:n.top,bottom:n.bottom}}function Xf(n){let e=n.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:n.innerWidth,top:0,bottom:n.innerHeight}}function Ka(n,e){let t=e.width/n.offsetWidth,i=e.height/n.offsetHeight;return(t>.995&&t<1.005||!isFinite(t)||Math.abs(e.width-n.offsetWidth)<1)&&(t=1),(i>.995&&i<1.005||!isFinite(i)||Math.abs(e.height-n.offsetHeight)<1)&&(i=1),{scaleX:t,scaleY:i}}function Jf(n,e,t,i,s,r,o,l){let a=n.ownerDocument,h=a.defaultView||window;for(let c=n,f=!1;c&&!f;)if(c.nodeType==1){let u,d=c==a.body,p=1,m=1;if(d)u=Xf(h);else{if(/^(fixed|sticky)$/.test(getComputedStyle(c).position)&&(f=!0),c.scrollHeight<=c.clientHeight&&c.scrollWidth<=c.clientWidth){c=c.assignedSlot||c.parentNode;continue}let w=c.getBoundingClientRect();({scaleX:p,scaleY:m}=Ka(c,w)),u={left:w.left,right:w.left+c.clientWidth*p,top:w.top,bottom:w.top+c.clientHeight*m}}let g=0,y=0;if(s=="nearest")e.top<u.top?(y=e.top-(u.top+o),t>0&&e.bottom>u.bottom+y&&(y=e.bottom-u.bottom+o)):e.bottom>u.bottom&&(y=e.bottom-u.bottom+o,t<0&&e.top-y<u.top&&(y=e.top-(u.top+o)));else{let w=e.bottom-e.top,x=u.bottom-u.top;y=(s=="center"&&w<=x?e.top+w/2-x/2:s=="start"||s=="center"&&t<0?e.top-o:e.bottom-x+o)-u.top}if(i=="nearest"?e.left<u.left?(g=e.left-(u.left+r),t>0&&e.right>u.right+g&&(g=e.right-u.right+r)):e.right>u.right&&(g=e.right-u.right+r,t<0&&e.left<u.left+g&&(g=e.left-(u.left+r))):g=(i=="center"?e.left+(e.right-e.left)/2-(u.right-u.left)/2:i=="start"==l?e.left-r:e.right-(u.right-u.left)+r)-u.left,g||y)if(d)h.scrollBy(g,y);else{let w=0,x=0;if(y){let D=c.scrollTop;c.scrollTop+=y/m,x=(c.scrollTop-D)*m}if(g){let D=c.scrollLeft;c.scrollLeft+=g/p,w=(c.scrollLeft-D)*p}e={left:e.left-w,top:e.top-x,right:e.right-w,bottom:e.bottom-x},w&&Math.abs(w-g)<1&&(i="nearest"),x&&Math.abs(x-y)<1&&(s="nearest")}if(d)break;(e.top<u.top||e.bottom>u.bottom||e.left<u.left||e.right>u.right)&&(e={left:Math.max(e.left,u.left),right:Math.min(e.right,u.right),top:Math.max(e.top,u.top),bottom:Math.min(e.bottom,u.bottom)}),c=c.assignedSlot||c.parentNode}else if(c.nodeType==11)c=c.host;else break}function ja(n,e=!0){let t=n.ownerDocument,i=null,s=null;for(let r=n.parentNode;r&&!(r==t.body||(!e||i)&&s);)if(r.nodeType==1)!s&&r.scrollHeight>r.clientHeight&&(s=r),e&&!i&&r.scrollWidth>r.clientWidth&&(i=r),r=r.assignedSlot||r.parentNode;else if(r.nodeType==11)r=r.host;else break;return{x:i,y:s}}class Zf{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(e){return this.anchorNode==e.anchorNode&&this.anchorOffset==e.anchorOffset&&this.focusNode==e.focusNode&&this.focusOffset==e.focusOffset}setRange(e){let{anchorNode:t,focusNode:i}=e;this.set(t,Math.min(e.anchorOffset,t?ct(t):0),i,Math.min(e.focusOffset,i?ct(i):0))}set(e,t,i,s){this.anchorNode=e,this.anchorOffset=t,this.focusNode=i,this.focusOffset=s}}let Tt=null;O.safari&&O.safari_version>=26&&(Tt=!1);function Ua(n){if(n.setActive)return n.setActive();if(Tt)return n.focus(Tt);let e=[];for(let t=n;t&&(e.push(t,t.scrollTop,t.scrollLeft),t!=t.ownerDocument);t=t.parentNode);if(n.focus(Tt==null?{get preventScroll(){return Tt={preventScroll:!0},!0}}:void 0),!Tt){Tt=!1;for(let t=0;t<e.length;){let i=e[t++],s=e[t++],r=e[t++];i.scrollTop!=s&&(i.scrollTop=s),i.scrollLeft!=r&&(i.scrollLeft=r)}}}let Qo;function Li(n,e,t=e){let i=Qo||(Qo=document.createRange());return i.setEnd(n,t),i.setStart(n,e),i}function Jt(n,e,t,i){let s={key:e,code:e,keyCode:t,which:t,cancelable:!0};i&&({altKey:s.altKey,ctrlKey:s.ctrlKey,shiftKey:s.shiftKey,metaKey:s.metaKey}=i);let r=new KeyboardEvent("keydown",s);r.synthetic=!0,n.dispatchEvent(r);let o=new KeyboardEvent("keyup",s);return o.synthetic=!0,n.dispatchEvent(o),r.defaultPrevented||o.defaultPrevented}function eu(n){for(;n;){if(n&&(n.nodeType==9||n.nodeType==11&&n.host))return n;n=n.assignedSlot||n.parentNode}return null}function tu(n,e){let t=e.focusNode,i=e.focusOffset;if(!t||e.anchorNode!=t||e.anchorOffset!=i)return!1;for(i=Math.min(i,ct(t));;)if(i){if(t.nodeType!=1)return!1;let s=t.childNodes[i-1];s.contentEditable=="false"?i--:(t=s,i=ct(t))}else{if(t==n)return!0;i=kt(t),t=t.parentNode}}function Ga(n){return n instanceof Window?n.pageYOffset>Math.max(0,n.document.documentElement.scrollHeight-n.innerHeight-4):n.scrollTop>Math.max(1,n.scrollHeight-n.clientHeight-4)}function Qa(n,e){for(let t=n,i=e;;){if(t.nodeType==3&&i>0)return{node:t,offset:i};if(t.nodeType==1&&i>0){if(t.contentEditable=="false")return null;t=t.childNodes[i-1],i=ct(t)}else if(t.parentNode&&!En(t))i=kt(t),t=t.parentNode;else return null}}function Ya(n,e){for(let t=n,i=e;;){if(t.nodeType==3&&i<t.nodeValue.length)return{node:t,offset:i};if(t.nodeType==1&&i<t.childNodes.length){if(t.contentEditable=="false")return null;t=t.childNodes[i],i=0}else if(t.parentNode&&!En(t))i=kt(t)+1,t=t.parentNode;else return null}}class Fe{constructor(e,t,i=!0){this.node=e,this.offset=t,this.precise=i}static before(e,t){return new Fe(e.parentNode,kt(e),t)}static after(e,t){return new Fe(e.parentNode,kt(e)+1,t)}}var j=function(n){return n[n.LTR=0]="LTR",n[n.RTL=1]="RTL",n}(j||(j={}));const Wt=j.LTR,eo=j.RTL;function _a(n){let e=[];for(let t=0;t<n.length;t++)e.push(1<<+n[t]);return e}const iu=_a("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),nu=_a("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),xr=Object.create(null),je=[];for(let n of["()","[]","{}"]){let e=n.charCodeAt(0),t=n.charCodeAt(1);xr[e]=t,xr[t]=-e}function Xa(n){return n<=247?iu[n]:1424<=n&&n<=1524?2:1536<=n&&n<=1785?nu[n-1536]:1774<=n&&n<=2220?4:8192<=n&&n<=8204?256:64336<=n&&n<=65023?4:1}const su=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/;class Je{get dir(){return this.level%2?eo:Wt}constructor(e,t,i){this.from=e,this.to=t,this.level=i}side(e,t){return this.dir==t==e?this.to:this.from}forward(e,t){return e==(this.dir==t)}static find(e,t,i,s){let r=-1;for(let o=0;o<e.length;o++){let l=e[o];if(l.from<=t&&l.to>=t){if(l.level==i)return o;(r<0||(s!=0?s<0?l.from<t:l.to>t:e[r].level>l.level))&&(r=o)}}if(r<0)throw new RangeError("Index out of range");return r}}function Ja(n,e){if(n.length!=e.length)return!1;for(let t=0;t<n.length;t++){let i=n[t],s=e[t];if(i.from!=s.from||i.to!=s.to||i.direction!=s.direction||!Ja(i.inner,s.inner))return!1}return!0}const K=[];function ru(n,e,t,i,s){for(let r=0;r<=i.length;r++){let o=r?i[r-1].to:e,l=r<i.length?i[r].from:t,a=r?256:s;for(let h=o,c=a,f=a;h<l;h++){let u=Xa(n.charCodeAt(h));u==512?u=c:u==8&&f==4&&(u=16),K[h]=u==4?2:u,u&7&&(f=u),c=u}for(let h=o,c=a,f=a;h<l;h++){let u=K[h];if(u==128)h<l-1&&c==K[h+1]&&c&24?u=K[h]=c:K[h]=256;else if(u==64){let d=h+1;for(;d<l&&K[d]==64;)d++;let p=h&&c==8||d<t&&K[d]==8?f==1?1:8:256;for(let m=h;m<d;m++)K[m]=p;h=d-1}else u==8&&f==1&&(K[h]=1);c=u,u&7&&(f=u)}}}function ou(n,e,t,i,s){let r=s==1?2:1;for(let o=0,l=0,a=0;o<=i.length;o++){let h=o?i[o-1].to:e,c=o<i.length?i[o].from:t;for(let f=h,u,d,p;f<c;f++)if(d=xr[u=n.charCodeAt(f)])if(d<0){for(let m=l-3;m>=0;m-=3)if(je[m+1]==-d){let g=je[m+2],y=g&2?s:g&4?g&1?r:s:0;y&&(K[f]=K[je[m]]=y),l=m;break}}else{if(je.length==189)break;je[l++]=f,je[l++]=u,je[l++]=a}else if((p=K[f])==2||p==1){let m=p==s;a=m?0:1;for(let g=l-3;g>=0;g-=3){let y=je[g+2];if(y&2)break;if(m)je[g+2]|=2;else{if(y&4)break;je[g+2]|=4}}}}}function lu(n,e,t,i){for(let s=0,r=i;s<=t.length;s++){let o=s?t[s-1].to:n,l=s<t.length?t[s].from:e;for(let a=o;a<l;){let h=K[a];if(h==256){let c=a+1;for(;;)if(c==l){if(s==t.length)break;c=t[s++].to,l=s<t.length?t[s].from:e}else if(K[c]==256)c++;else break;let f=r==1,u=(c<e?K[c]:i)==1,d=f==u?f?1:2:i;for(let p=c,m=s,g=m?t[m-1].to:n;p>a;)p==g&&(p=t[--m].from,g=m?t[m-1].to:n),K[--p]=d;a=c}else r=h,a++}}}function wr(n,e,t,i,s,r,o){let l=i%2?2:1;if(i%2==s%2)for(let a=e,h=0;a<t;){let c=!0,f=!1;if(h==r.length||a<r[h].from){let m=K[a];m!=l&&(c=!1,f=m==16)}let u=!c&&l==1?[]:null,d=c?i:i+1,p=a;e:for(;;)if(h<r.length&&p==r[h].from){if(f)break e;let m=r[h];if(!c)for(let g=m.to,y=h+1;;){if(g==t)break e;if(y<r.length&&r[y].from==g)g=r[y++].to;else{if(K[g]==l)break e;break}}if(h++,u)u.push(m);else{m.from>a&&o.push(new Je(a,m.from,d));let g=m.direction==Wt!=!(d%2);kr(n,g?i+1:i,s,m.inner,m.from,m.to,o),a=m.to}p=m.to}else{if(p==t||(c?K[p]!=l:K[p]==l))break;p++}u?wr(n,a,p,i+1,s,u,o):a<p&&o.push(new Je(a,p,d)),a=p}else for(let a=t,h=r.length;a>e;){let c=!0,f=!1;if(!h||a>r[h-1].to){let m=K[a-1];m!=l&&(c=!1,f=m==16)}let u=!c&&l==1?[]:null,d=c?i:i+1,p=a;e:for(;;)if(h&&p==r[h-1].to){if(f)break e;let m=r[--h];if(!c)for(let g=m.from,y=h;;){if(g==e)break e;if(y&&r[y-1].to==g)g=r[--y].from;else{if(K[g-1]==l)break e;break}}if(u)u.push(m);else{m.to<a&&o.push(new Je(m.to,a,d));let g=m.direction==Wt!=!(d%2);kr(n,g?i+1:i,s,m.inner,m.from,m.to,o),a=m.from}p=m.from}else{if(p==e||(c?K[p-1]!=l:K[p-1]==l))break;p--}u?wr(n,p,a,i+1,s,u,o):p<a&&o.push(new Je(p,a,d)),a=p}}function kr(n,e,t,i,s,r,o){let l=e%2?2:1;ru(n,s,r,i,l),ou(n,s,r,i,l),lu(s,r,i,l),wr(n,s,r,e,t,i,o)}function au(n,e,t){if(!n)return[new Je(0,0,e==eo?1:0)];if(e==Wt&&!t.length&&!su.test(n))return Za(n.length);if(t.length)for(;n.length>K.length;)K[K.length]=256;let i=[],s=e==Wt?0:1;return kr(n,s,s,t,0,n.length,i),i}function Za(n){return[new Je(0,n,0)]}let eh="";function hu(n,e,t,i,s){var r;let o=i.head-n.from,l=Je.find(e,o,(r=i.bidiLevel)!==null&&r!==void 0?r:-1,i.assoc),a=e[l],h=a.side(s,t);if(o==h){let u=l+=s?1:-1;if(u<0||u>=e.length)return null;a=e[l=u],o=a.side(!s,t),h=a.side(s,t)}let c=ne(n.text,o,a.forward(s,t));(c<a.from||c>a.to)&&(c=h),eh=n.text.slice(Math.min(o,c),Math.max(o,c));let f=l==(s?e.length-1:0)?null:e[l+(s?1:-1)];return f&&c==h&&f.level+(s?0:1)<a.level?b.cursor(f.side(!s,t)+n.from,f.forward(s,t)?1:-1,f.level):b.cursor(c+n.from,a.forward(s,t)?-1:1,a.level)}function cu(n,e,t){for(let i=e;i<t;i++){let s=Xa(n.charCodeAt(i));if(s==1)return Wt;if(s==2||s==4)return eo}return Wt}const th=M.define(),ih=M.define(),nh=M.define(),sh=M.define(),vr=M.define(),rh=M.define(),oh=M.define(),to=M.define(),io=M.define(),lh=M.define({combine:n=>n.some(e=>e)}),ah=M.define({combine:n=>n.some(e=>e)}),hh=M.define();class Zt{constructor(e,t="nearest",i="nearest",s=5,r=5,o=!1){this.range=e,this.y=t,this.x=i,this.yMargin=s,this.xMargin=r,this.isSnapshot=o}map(e){return e.empty?this:new Zt(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(e){return this.range.to<=e.doc.length?this:new Zt(b.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const en=R.define({map:(n,e)=>n.map(e)}),ch=R.define();function me(n,e,t){let i=n.facet(sh);i.length?i[0](e):window.onerror&&window.onerror(String(e),t,void 0,void 0,e)||(t?console.error(t+":",e):console.error(e))}const lt=M.define({combine:n=>n.length?n[0]:!0});let fu=0;const Ut=M.define({combine(n){return n.filter((e,t)=>{for(let i=0;i<t;i++)if(n[i].plugin==e.plugin)return!1;return!0})}});class Y{constructor(e,t,i,s,r){this.id=e,this.create=t,this.domEventHandlers=i,this.domEventObservers=s,this.baseExtensions=r(this),this.extension=this.baseExtensions.concat(Ut.of({plugin:this,arg:void 0}))}of(e){return this.baseExtensions.concat(Ut.of({plugin:this,arg:e}))}static define(e,t){const{eventHandlers:i,eventObservers:s,provide:r,decorations:o}=t||{};return new Y(fu++,e,i,s,l=>{let a=[];return o&&a.push(ls.of(h=>{let c=h.plugin(l);return c?o(c):B.none})),r&&a.push(r(l)),a})}static fromClass(e,t){return Y.define((i,s)=>new e(i,s),t)}}class Os{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}get plugin(){return this.spec&&this.spec.plugin}update(e){if(this.value){if(this.mustUpdate){let t=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(t)}catch(i){if(me(t.state,i,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(e,this.spec.arg)}catch(t){me(e.state,t,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var t;if(!((t=this.value)===null||t===void 0)&&t.destroy)try{this.value.destroy()}catch(i){me(e.state,i,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const fh=M.define(),no=M.define(),ls=M.define(),uh=M.define(),so=M.define(),ji=M.define(),dh=M.define();function Yo(n,e){let t=n.state.facet(dh);if(!t.length)return t;let i=t.map(r=>r instanceof Function?r(n):r),s=[];return E.spans(i,e.from,e.to,{point(){},span(r,o,l,a){let h=r-e.from,c=o-e.from,f=s;for(let u=l.length-1;u>=0;u--,a--){let d=l[u].spec.bidiIsolate,p;if(d==null&&(d=cu(e.text,h,c)),a>0&&f.length&&(p=f[f.length-1]).to==h&&p.direction==d)p.to=c,f=p.inner;else{let m={from:h,to:c,direction:d,inner:[]};f.push(m),f=m.inner}}}}),s}const ph=M.define();function ro(n){let e=0,t=0,i=0,s=0;for(let r of n.state.facet(ph)){let o=r(n);o&&(o.left!=null&&(e=Math.max(e,o.left)),o.right!=null&&(t=Math.max(t,o.right)),o.top!=null&&(i=Math.max(i,o.top)),o.bottom!=null&&(s=Math.max(s,o.bottom)))}return{left:e,right:t,top:i,bottom:s}}const gi=M.define();class Pe{constructor(e,t,i,s){this.fromA=e,this.toA=t,this.fromB=i,this.toB=s}join(e){return new Pe(Math.min(this.fromA,e.fromA),Math.max(this.toA,e.toA),Math.min(this.fromB,e.fromB),Math.max(this.toB,e.toB))}addToSet(e){let t=e.length,i=this;for(;t>0;t--){let s=e[t-1];if(!(s.fromA>i.toA)){if(s.toA<i.fromA)break;i=i.join(s),e.splice(t-1,1)}}return e.splice(t,0,i),e}static extendWithRanges(e,t){if(t.length==0)return e;let i=[];for(let s=0,r=0,o=0;;){let l=s<e.length?e[s].fromB:1e9,a=r<t.length?t[r]:1e9,h=Math.min(l,a);if(h==1e9)break;let c=h+o,f=h,u=c;for(;;)if(r<t.length&&t[r]<=f){let d=t[r+1];r+=2,f=Math.max(f,d);for(let p=s;p<e.length&&e[p].fromB<=f;p++)o=e[p].toA-e[p].toB;u=Math.max(u,d+o)}else if(s<e.length&&e[s].fromB<=f){let d=e[s++];f=Math.max(f,d.toB),u=Math.max(u,d.toA),o=d.toA-d.toB}else break;i.push(new Pe(c,u,h,f))}return i}}class In{constructor(e,t,i){this.view=e,this.state=t,this.transactions=i,this.flags=0,this.startState=e.state,this.changes=ee.empty(this.startState.doc.length);for(let r of i)this.changes=this.changes.compose(r.changes);let s=[];this.changes.iterChangedRanges((r,o,l,a)=>s.push(new Pe(r,o,l,a))),this.changedRanges=s}static create(e,t,i){return new In(e,t,i)}get viewportChanged(){return(this.flags&4)>0}get viewportMoved(){return(this.flags&8)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&18)>0}get focusChanged(){return(this.flags&1)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(e=>e.selection)}get empty(){return this.flags==0&&this.transactions.length==0}}const uu=[];class X{constructor(e,t,i=0){this.dom=e,this.length=t,this.flags=i,this.parent=null,e.cmTile=this}get breakAfter(){return this.flags&1}get children(){return uu}isWidget(){return!1}get isHidden(){return!1}isComposite(){return!1}isLine(){return!1}isText(){return!1}isBlock(){return!1}get domAttrs(){return null}sync(e){if(this.flags|=2,this.flags&4){this.flags&=-5;let t=this.domAttrs;t&&Qf(this.dom,t)}}toString(){return this.constructor.name+(this.children.length?`(${this.children})`:"")+(this.breakAfter?"#":"")}destroy(){this.parent=null}setDOM(e){this.dom=e,e.cmTile=this}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e,t=this.posAtStart){let i=t;for(let s of this.children){if(s==e)return i;i+=s.length+s.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}covers(e){return!0}coordsIn(e,t){return null}domPosFor(e,t){let i=kt(this.dom),s=this.length?e>0:t>0;return new Fe(this.parent.dom,i+(s?1:0),e==0||e==this.length)}markDirty(e){this.flags&=-3,e&&(this.flags|=4),this.parent&&this.parent.flags&2&&this.parent.markDirty(!1)}get overrideDOMText(){return null}get root(){for(let e=this;e;e=e.parent)if(e instanceof hs)return e;return null}static get(e){return e.cmTile}}class as extends X{constructor(e){super(e,0),this._children=[]}isComposite(){return!0}get children(){return this._children}get lastChild(){return this.children.length?this.children[this.children.length-1]:null}append(e){this.children.push(e),e.parent=this}sync(e){if(this.flags&2)return;super.sync(e);let t=this.dom,i=null,s,r=(e==null?void 0:e.node)==t?e:null,o=0;for(let l of this.children){if(l.sync(e),o+=l.length+l.breakAfter,s=i?i.nextSibling:t.firstChild,r&&s!=l.dom&&(r.written=!0),l.dom.parentNode==t)for(;s&&s!=l.dom;)s=_o(s);else t.insertBefore(l.dom,s);i=l.dom}for(s=i?i.nextSibling:t.firstChild,r&&s&&(r.written=!0);s;)s=_o(s);this.length=o}}function _o(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}class hs extends as{constructor(e,t){super(t),this.view=e}owns(e){for(;e;e=e.parent)if(e==this)return!0;return!1}isBlock(){return!0}nearest(e){for(;;){if(!e)return null;let t=X.get(e);if(t&&this.owns(t))return t;e=e.parentNode}}blockTiles(e){for(let t=[],i=this,s=0,r=0;;)if(s==i.children.length){if(!t.length)return;i=i.parent,i.breakAfter&&r++,s=t.pop()}else{let o=i.children[s++];if(o instanceof at)t.push(s),i=o,s=0;else{let l=r+o.length,a=e(o,r);if(a!==void 0)return a;r=l+o.breakAfter}}}resolveBlock(e,t){let i,s=-1,r,o=-1;if(this.blockTiles((l,a)=>{let h=a+l.length;if(e>=a&&e<=h){if(l.isWidget()&&t>=-1&&t<=1){if(l.flags&32)return!0;l.flags&16&&(i=void 0)}(a<e||e==h&&(t<-1?l.length:l.covers(1)))&&(!i||!l.isWidget()&&i.isWidget())&&(i=l,s=e-a),(h>e||e==a&&(t>1?l.length:l.covers(-1)))&&(!r||!l.isWidget()&&r.isWidget())&&(r=l,o=e-a)}}),!i&&!r)throw new Error("No tile at position "+e);return i&&t<0||!r?{tile:i,offset:s}:{tile:r,offset:o}}}class at extends as{constructor(e,t){super(e),this.wrapper=t}isBlock(){return!0}covers(e){return this.children.length?e<0?this.children[0].covers(-1):this.lastChild.covers(1):!1}get domAttrs(){return this.wrapper.attributes}static of(e,t){let i=new at(t||document.createElement(e.tagName),e);return t||(i.flags|=4),i}}class si extends as{constructor(e,t){super(e),this.attrs=t}isLine(){return!0}static start(e,t,i){let s=new si(t||document.createElement("div"),e);return(!t||!i)&&(s.flags|=4),s}get domAttrs(){return this.attrs}resolveInline(e,t,i){let s=null,r=-1,o=null,l=-1;function a(c,f){for(let u=0,d=0;u<c.children.length&&d<=f;u++){let p=c.children[u],m=d+p.length;m>=f&&(p.isComposite()?a(p,f-d):(!o||o.isHidden&&(t>0||i&&pu(o,p)))&&(m>f||p.flags&32)?(o=p,l=f-d):(d<f||p.flags&16&&!p.isHidden)&&(s=p,r=f-d)),d=m}}a(this,e);let h=(t<0?s:o)||s||o;return h?{tile:h,offset:h==s?r:l}:null}coordsIn(e,t){let i=this.resolveInline(e,t,!0);return i?i.tile.coordsIn(Math.max(0,i.offset),t):du(this)}domIn(e,t){let i=this.resolveInline(e,t);if(i){let{tile:s,offset:r}=i;if(this.dom.contains(s.dom))return s.isText()?new Fe(s.dom,Math.min(s.dom.nodeValue.length,r)):s.domPosFor(r,s.flags&16?1:s.flags&32?-1:t);let o=i.tile.parent,l=!1;for(let a of o.children){if(l)return new Fe(a.dom,0);a==i.tile&&(l=!0)}}return new Fe(this.dom,0)}}function du(n){let e=n.dom.lastChild;if(!e)return n.dom.getBoundingClientRect();let t=vi(e);return t[t.length-1]||null}function pu(n,e){let t=n.coordsIn(0,1),i=e.coordsIn(0,1);return t&&i&&i.top<t.bottom}class xe extends as{constructor(e,t){super(e),this.mark=t}get domAttrs(){return this.mark.attrs}static of(e,t){let i=new xe(t||document.createElement(e.tagName),e);return t||(i.flags|=4),i}}class Rt extends X{constructor(e,t){super(e,t.length),this.text=t}sync(e){this.flags&2||(super.sync(e),this.dom.nodeValue!=this.text&&(e&&e.node==this.dom&&(e.written=!0),this.dom.nodeValue=this.text))}isText(){return!0}toString(){return JSON.stringify(this.text)}coordsIn(e,t){let i=this.dom.nodeValue.length;e>i&&(e=i);let s=e,r=e,o=0;e==0&&t<0||e==i&&t>=0?O.chrome||O.gecko||(e?(s--,o=1):r<i&&(r++,o=-1)):t<0?s--:r<i&&r++;let l=Li(this.dom,s,r).getClientRects();if(!l.length)return null;let a=l[(o?o<0:t>=0)?0:l.length-1];return O.safari&&!o&&a.width==0&&(a=Array.prototype.find.call(l,h=>h.width)||a),o?Ri(a,o<0):a||null}static of(e,t){let i=new Rt(t||document.createTextNode(e),e);return t||(i.flags|=2),i}}class Ft extends X{constructor(e,t,i,s){super(e,t,s),this.widget=i}isWidget(){return!0}get isHidden(){return this.widget.isHidden}covers(e){return this.flags&48?!1:(this.flags&(e<0?64:128))>0}coordsIn(e,t){return this.coordsInWidget(e,t,!1)}coordsInWidget(e,t,i){let s=this.widget.coordsAt(this.dom,e,t);if(s)return s;if(i)return Ri(this.dom.getBoundingClientRect(),this.length?e==0:t<=0);{let r=this.dom.getClientRects(),o=null;if(!r.length)return null;let l=this.flags&16?!0:this.flags&32?!1:e>0;for(let a=l?r.length-1:0;o=r[a],!(e>0?a==0:a==r.length-1||o.top<o.bottom);a+=l?-1:1);return Ri(o,!l)}}get overrideDOMText(){if(!this.length)return F.empty;let{root:e}=this;if(!e)return F.empty;let t=this.posAtStart;return e.view.state.doc.slice(t,t+this.length)}destroy(){super.destroy(),this.widget.destroy(this.dom)}static of(e,t,i,s,r){return r||(r=e.toDOM(t),e.editable||(r.contentEditable="false")),new Ft(r,i,e,s)}}class Nn extends X{constructor(e){let t=document.createElement("img");t.className="cm-widgetBuffer",t.setAttribute("aria-hidden","true"),super(t,0,e)}get isHidden(){return!0}get overrideDOMText(){return F.empty}coordsIn(e){return this.dom.getBoundingClientRect()}}class mu{constructor(e){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=e}advance(e,t,i){let{tile:s,index:r,beforeBreak:o,parents:l}=this;for(;e||t>0;)if(s.isComposite())if(o){if(!e)break;i&&i.break(),e--,o=!1}else if(r==s.children.length){if(!e&&!l.length)break;i&&i.leave(s),o=!!s.breakAfter,{tile:s,index:r}=l.pop(),r++}else{let a=s.children[r],h=a.breakAfter;(t>0?a.length<=e:a.length<e)&&(!i||i.skip(a,0,a.length)!==!1||!a.isComposite)?(o=!!h,r++,e-=a.length):(l.push({tile:s,index:r}),s=a,r=0,i&&a.isComposite()&&i.enter(a))}else if(r==s.length)o=!!s.breakAfter,{tile:s,index:r}=l.pop(),r++;else if(e){let a=Math.min(e,s.length-r);i&&i.skip(s,r,r+a),e-=a,r+=a}else break;return this.tile=s,this.index=r,this.beforeBreak=o,this}get root(){return this.parents.length?this.parents[0].tile:this.tile}}class gu{constructor(e,t,i,s){this.from=e,this.to=t,this.wrapper=i,this.rank=s}}class yu{constructor(e,t,i){this.cache=e,this.root=t,this.blockWrappers=i,this.curLine=null,this.lastBlock=null,this.afterWidget=null,this.pos=0,this.wrappers=[],this.wrapperPos=0}addText(e,t,i,s){var r;this.flushBuffer();let o=this.ensureMarks(t,i),l=o.lastChild;if(l&&l.isText()&&!(l.flags&8)&&l.length+e.length<512){this.cache.reused.set(l,2);let a=o.children[o.children.length-1]=new Rt(l.dom,l.text+e);a.parent=o}else o.append(s||Rt.of(e,(r=this.cache.find(Rt))===null||r===void 0?void 0:r.dom));this.pos+=e.length,this.afterWidget=null}addComposition(e,t){let i=this.curLine;i.dom!=t.line.dom&&(i.setDOM(this.cache.reused.has(t.line)?Ts(t.line.dom):t.line.dom),this.cache.reused.set(t.line,2));let s=i;for(let l=t.marks.length-1;l>=0;l--){let a=t.marks[l],h=s.lastChild;if(h instanceof xe&&h.mark.eq(a.mark))h.dom!=a.dom&&h.setDOM(Ts(a.dom)),s=h;else{if(this.cache.reused.get(a)){let f=X.get(a.dom);f&&f.setDOM(Ts(a.dom))}let c=xe.of(a.mark,a.dom);s.append(c),s=c}this.cache.reused.set(a,2)}let r=X.get(e.text);r&&this.cache.reused.set(r,2);let o=new Rt(e.text,e.text.nodeValue);o.flags|=8,s.append(o)}addInlineWidget(e,t,i){let s=this.afterWidget&&e.flags&48&&(this.afterWidget.flags&48)==(e.flags&48);s||this.flushBuffer();let r=this.ensureMarks(t,i);!s&&!(e.flags&16)&&r.append(this.getBuffer(1)),r.append(e),this.pos+=e.length,this.afterWidget=e}addMark(e,t,i){this.flushBuffer(),this.ensureMarks(t,i).append(e),this.pos+=e.length,this.afterWidget=null}addBlockWidget(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}continueWidget(e){let t=this.afterWidget||this.lastBlock;t.length+=e,this.pos+=e}addLineStart(e,t){var i;e||(e=mh);let s=si.start(e,t||((i=this.cache.find(si))===null||i===void 0?void 0:i.dom),!!t);this.getBlockPos().append(this.lastBlock=this.curLine=s)}addLine(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}addBreak(){this.lastBlock.flags|=1,this.endLine(),this.pos++}addLineStartIfNotCovered(e){this.blockPosCovered()||this.addLineStart(e)}ensureLine(e){this.curLine||this.addLineStart(e)}ensureMarks(e,t){var i;let s=this.curLine;for(let r=e.length-1;r>=0;r--){let o=e[r],l;if(t>0&&(l=s.lastChild)&&l instanceof xe&&l.mark.eq(o))s=l,t--;else{let a=xe.of(o,(i=this.cache.find(xe,h=>h.mark.eq(o)))===null||i===void 0?void 0:i.dom);s.append(a),s=a,t=0}}return s}endLine(){if(this.curLine){this.flushBuffer();let e=this.curLine.lastChild;(!e||!Xo(this.curLine,!1)||e.dom.nodeName!="BR"&&e.isWidget()&&!(O.ios&&Xo(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(Ds,0,32)||new Ft(Ds.toDOM(),0,Ds,32)),this.curLine=this.afterWidget=null}}updateBlockWrappers(){this.wrapperPos>this.pos+1e4&&(this.blockWrappers.goto(this.pos),this.wrappers.length=0);for(let e=this.wrappers.length-1;e>=0;e--)this.wrappers[e].to<this.pos&&this.wrappers.splice(e,1);for(let e=this.blockWrappers;e.value&&e.from<=this.pos;e.next())if(e.to>=this.pos){let t=new gu(e.from,e.to,e.value,e.rank),i=this.wrappers.length;for(;i>0&&(this.wrappers[i-1].rank-t.rank||this.wrappers[i-1].to-t.to)<0;)i--;this.wrappers.splice(i,0,t)}this.wrapperPos=this.pos}getBlockPos(){var e;this.updateBlockWrappers();let t=this.root;for(let i of this.wrappers){let s=t.lastChild;if(i.from<this.pos&&s instanceof at&&s.wrapper.eq(i.wrapper))t=s;else{let r=at.of(i.wrapper,(e=this.cache.find(at,o=>o.wrapper.eq(i.wrapper)))===null||e===void 0?void 0:e.dom);t.append(r),t=r}}return t}blockPosCovered(){let e=this.lastBlock;return e!=null&&!e.breakAfter&&(!e.isWidget()||(e.flags&160)>0)}getBuffer(e){let t=2|(e<0?16:32),i=this.cache.find(Nn,void 0,1);return i&&(i.flags=t),i||new Nn(t)}flushBuffer(){this.afterWidget&&!(this.afterWidget.flags&32)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}}class bu{constructor(e){this.skipCount=0,this.text="",this.textOff=0,this.cursor=e.iter()}skip(e){this.textOff+e<=this.text.length?this.textOff+=e:(this.skipCount+=e-(this.text.length-this.textOff),this.text="",this.textOff=0)}next(e){if(this.textOff==this.text.length){let{value:s,lineBreak:r,done:o}=this.cursor.next(this.skipCount);if(this.skipCount=0,o)throw new Error("Ran out of text content when drawing inline views");this.text=s;let l=this.textOff=Math.min(e,s.length);return r?null:s.slice(0,l)}let t=Math.min(this.text.length,this.textOff+e),i=this.text.slice(this.textOff,t);return this.textOff=t,i}}const Wn=[Ft,si,Rt,xe,Nn,at,hs];for(let n=0;n<Wn.length;n++)Wn[n].bucket=n;class xu{constructor(e){this.view=e,this.buckets=Wn.map(()=>[]),this.index=Wn.map(()=>0),this.reused=new Map}add(e){let t=e.constructor.bucket,i=this.buckets[t];i.length<6?i.push(e):i[this.index[t]=(this.index[t]+1)%6]=e}find(e,t,i=2){let s=e.bucket,r=this.buckets[s],o=this.index[s];for(let l=r.length-1;l>=0;l--){let a=(l+o)%r.length,h=r[a];if((!t||t(h))&&!this.reused.has(h))return r.splice(a,1),a<o&&this.index[s]--,this.reused.set(h,i),h}return null}findWidget(e,t,i){let s=this.buckets[0];if(s.length)for(let r=0,o=0;;r++){if(r==s.length){if(o)return null;o=1,r=0}let l=s[r];if(!this.reused.has(l)&&(o==0?l.widget.compare(e):l.widget.constructor==e.constructor&&e.updateDOM(l.dom,this.view)))return s.splice(r,1),r<this.index[0]&&this.index[0]--,l.widget==e&&l.length==t&&(l.flags&497)==i?(this.reused.set(l,1),l):(this.reused.set(l,2),new Ft(l.dom,t,e,l.flags&-498|i))}}reuse(e){return this.reused.set(e,1),e}maybeReuse(e,t=2){if(!this.reused.has(e))return this.reused.set(e,t),e.dom}clear(){for(let e=0;e<this.buckets.length;e++)this.buckets[e].length=this.index[e]=0}}class wu{constructor(e,t,i,s,r){this.view=e,this.decorations=s,this.disallowBlockEffectsFor=r,this.openWidget=!1,this.openMarks=0,this.cache=new xu(e),this.text=new bu(e.state.doc),this.builder=new yu(this.cache,new hs(e,e.contentDOM),E.iter(i)),this.cache.reused.set(t,2),this.old=new mu(t),this.reuseWalker={skip:(o,l,a)=>{if(this.cache.add(o),o.isComposite())return!1},enter:o=>this.cache.add(o),leave:()=>{},break:()=>{}}}run(e,t){let i=t&&this.getCompositionContext(t.text);for(let s=0,r=0,o=0;;){let l=o<e.length?e[o++]:null,a=l?l.fromA:this.old.root.length;if(a>s){let h=a-s;this.preserve(h,!o,!l),s=a,r+=h}if(!l)break;t&&l.fromA<=t.range.fromA&&l.toA>=t.range.toA?(this.forward(l.fromA,t.range.fromA,t.range.fromA<t.range.toA?1:-1),this.emit(r,t.range.fromB),this.cache.clear(),this.builder.addComposition(t,i),this.text.skip(t.range.toB-t.range.fromB),this.forward(t.range.fromA,l.toA),this.emit(t.range.toB,l.toB)):(this.forward(l.fromA,l.toA),this.emit(r,l.toB)),r=l.toB,s=l.toA}return this.builder.curLine&&this.builder.endLine(),this.builder.root}preserve(e,t,i){let s=Su(this.old),r=this.openMarks;this.old.advance(e,i?1:-1,{skip:(o,l,a)=>{if(o.isWidget())if(this.openWidget)this.builder.continueWidget(a-l);else{let h=a>0||l<o.length?Ft.of(o.widget,this.view,a-l,o.flags&496,this.cache.maybeReuse(o)):this.cache.reuse(o);h.flags&256?(h.flags&=-2,this.builder.addBlockWidget(h)):(this.builder.ensureLine(null),this.builder.addInlineWidget(h,s,r),r=s.length)}else if(o.isText())this.builder.ensureLine(null),!l&&a==o.length&&!this.cache.reused.has(o)?this.builder.addText(o.text,s,r,this.cache.reuse(o)):(this.cache.add(o),this.builder.addText(o.text.slice(l,a),s,r)),r=s.length;else if(o.isLine())o.flags&=-2,this.cache.reused.set(o,1),this.builder.addLine(o);else if(o instanceof Nn)this.cache.add(o);else if(o instanceof xe)this.builder.ensureLine(null),this.builder.addMark(o,s,r),this.cache.reused.set(o,1),r=s.length;else return!1;this.openWidget=!1},enter:o=>{o.isLine()?this.builder.addLineStart(o.attrs,this.cache.maybeReuse(o)):(this.cache.add(o),o instanceof xe&&s.unshift(o.mark)),this.openWidget=!1},leave:o=>{o.isLine()?s.length&&(s.length=r=0):o instanceof xe&&(s.shift(),r=Math.min(r,s.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(e)}emit(e,t){let i=null,s=this.builder,r=0,o=E.spans(this.decorations,e,t,{point:(l,a,h,c,f,u)=>{if(h instanceof Nt){if(this.disallowBlockEffectsFor[u]){if(h.block)throw new RangeError("Block decorations may not be specified via plugins");if(a>this.view.state.doc.lineAt(l).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}if(r=c.length,f>c.length)s.continueWidget(a-l);else{let d=h.widget||(h.block?ri.block:ri.inline),p=ku(h),m=this.cache.findWidget(d,a-l,p)||Ft.of(d,this.view,a-l,p);h.block?(h.startSide>0&&s.addLineStartIfNotCovered(i),s.addBlockWidget(m)):(s.ensureLine(i),s.addInlineWidget(m,c,f))}i=null}else i=vu(i,h);a>l&&this.text.skip(a-l)},span:(l,a,h,c)=>{for(let f=l;f<a;){let u=this.text.next(Math.min(512,a-f));u==null?(s.addLineStartIfNotCovered(i),s.addBreak(),f++):(s.ensureLine(i),s.addText(u,h,f==l?c:h.length),f+=u.length),i=null}}});s.addLineStartIfNotCovered(i),this.openWidget=o>r,this.openMarks=o}forward(e,t,i=1){t-e<=10?this.old.advance(t-e,i,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(t-e-10,-1),this.old.advance(5,i,this.reuseWalker))}getCompositionContext(e){let t=[],i=null;for(let s=e.parentNode;;s=s.parentNode){let r=X.get(s);if(s==this.view.contentDOM)break;r instanceof xe?t.push(r):r!=null&&r.isLine()?i=r:r instanceof at||(s.nodeName=="DIV"&&!i&&s!=this.view.contentDOM?i=new si(s,mh):i||t.push(xe.of(new $i({tagName:s.nodeName.toLowerCase(),attributes:Yf(s)}),s)))}return{line:i,marks:t}}}function Xo(n,e){let t=i=>{for(let s of i.children)if((e?s.isText():s.length)||t(s))return!0;return!1};return t(n)}function ku(n){let e=n.isReplace?(n.startSide<0?64:0)|(n.endSide>0?128:0):n.startSide>0?32:16;return n.block&&(e|=256),e}const mh={class:"cm-line"};function vu(n,e){let t=e.spec.attributes,i=e.spec.class;return!t&&!i||(n||(n={class:"cm-line"}),t&&Jr(t,n),i&&(n.class+=" "+i)),n}function Su(n){let e=[];for(let t=n.parents.length;t>1;t--){let i=t==n.parents.length?n.tile:n.parents[t].tile;i instanceof xe&&e.push(i.mark)}return e}function Ts(n){let e=X.get(n);return e&&e.setDOM(n.cloneNode()),n}class ri extends st{constructor(e){super(),this.tag=e}eq(e){return e.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(e){return e.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}}ri.inline=new ri("span");ri.block=new ri("div");const Ds=new class extends st{toDOM(){return document.createElement("br")}get isHidden(){return!0}get editable(){return!0}};class Jo{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=B.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.updateDeco(),this.tile=new hs(e,e.contentDOM),this.updateInner([new Pe(0,0,0,e.state.doc.length)],null)}update(e){var t;let i=e.changedRanges;this.minWidth>0&&i.length&&(i.every(({fromA:c,toA:f})=>f<this.minWidthFrom||c>this.minWidthTo)?(this.minWidthFrom=e.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=e.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.updateEditContextFormatting(e);let s=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(!((t=this.domChanged)===null||t===void 0)&&t.newSel?s=this.domChanged.newSel.head:!Ru(e.changes,this.hasComposition)&&!e.selectionSet&&(s=e.state.selection.main.head));let r=s>-1?Au(this.view,e.changes,s):null;if(this.domChanged=null,this.hasComposition){let{from:c,to:f}=this.hasComposition;i=new Pe(c,f,e.changes.mapPos(c,-1),e.changes.mapPos(f,1)).addToSet(i.slice())}this.hasComposition=r?{from:r.range.fromB,to:r.range.toB}:null,(O.ie||O.chrome)&&!r&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let o=this.decorations,l=this.blockWrappers;this.updateDeco();let a=Tu(o,this.decorations,e.changes);a.length&&(i=Pe.extendWithRanges(i,a));let h=Bu(l,this.blockWrappers,e.changes);return h.length&&(i=Pe.extendWithRanges(i,h)),r&&!i.some(c=>c.fromA<=r.range.fromA&&c.toA>=r.range.toA)&&(i=r.range.addToSet(i.slice())),this.tile.flags&2&&i.length==0?!1:(this.updateInner(i,r),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,t){this.view.viewState.mustMeasureContent=!0;let{observer:i}=this.view;i.ignore(()=>{if(t||e.length){let o=this.tile,l=new wu(this.view,o,this.blockWrappers,this.decorations,this.dynamicDecorationMap);t&&X.get(t.text)&&l.cache.reused.set(X.get(t.text),2),this.tile=l.run(e,t),Sr(o,l.cache.reused)}this.tile.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.tile.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let r=O.chrome||O.ios?{node:i.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(r),r&&(r.written||i.selectionRange.focusNode!=r.node||!this.tile.dom.contains(r.node))&&(this.forceSelection=!0),this.tile.dom.style.height=""});let s=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let r of this.tile.children)r.isWidget()&&r.widget instanceof Bs&&s.push(r.dom);i.updateGaps(s)}updateEditContextFormatting(e){this.editContextFormatting=this.editContextFormatting.map(e.changes);for(let t of e.transactions)for(let i of t.effects)i.is(ch)&&(this.editContextFormatting=i.value)}updateSelection(e=!1,t=!1){(e||!this.view.observer.selectionRange.focusNode)&&this.view.observer.readSelectionRange();let{dom:i}=this.tile,s=this.view.root.activeElement,r=s==i,o=!r&&!(this.view.state.facet(lt)||i.tabIndex>-1)&&ki(i,this.view.observer.selectionRange)&&!(s&&i.contains(s));if(!(r||t||o))return;let l=this.forceSelection;this.forceSelection=!1;let a=this.view.state.selection.main,h,c;if(a.empty?c=h=this.inlineDOMNearPos(a.anchor,a.assoc||1):(c=this.inlineDOMNearPos(a.head,a.head==a.from?1:-1),h=this.inlineDOMNearPos(a.anchor,a.anchor==a.from?1:-1)),O.gecko&&a.empty&&!this.hasComposition&&Cu(h)){let u=document.createTextNode("");this.view.observer.ignore(()=>h.node.insertBefore(u,h.node.childNodes[h.offset]||null)),h=c=new Fe(u,0),l=!0}let f=this.view.observer.selectionRange;(l||!f.focusNode||(!Si(h.node,h.offset,f.anchorNode,f.anchorOffset)||!Si(c.node,c.offset,f.focusNode,f.focusOffset))&&!this.suppressWidgetCursorChange(f,a))&&(this.view.observer.ignore(()=>{O.android&&O.chrome&&i.contains(f.focusNode)&&Pu(f.focusNode,i)&&(i.blur(),i.focus({preventScroll:!0}));let u=Pi(this.view.root);if(u)if(a.empty){if(O.gecko){let d=Mu(h.node,h.offset);if(d&&d!=3){let p=(d==1?Qa:Ya)(h.node,h.offset);p&&(h=new Fe(p.node,p.offset))}}u.collapse(h.node,h.offset),a.bidiLevel!=null&&u.caretBidiLevel!==void 0&&(u.caretBidiLevel=a.bidiLevel)}else if(u.extend){u.collapse(h.node,h.offset);try{u.extend(c.node,c.offset)}catch{}}else{let d=document.createRange();a.anchor>a.head&&([h,c]=[c,h]),d.setEnd(c.node,c.offset),d.setStart(h.node,h.offset),u.removeAllRanges(),u.addRange(d)}o&&this.view.root.activeElement==i&&(i.blur(),s&&s.focus())}),this.view.observer.setSelectionRange(h,c)),this.impreciseAnchor=h.precise?null:new Fe(f.anchorNode,f.anchorOffset),this.impreciseHead=c.precise?null:new Fe(f.focusNode,f.focusOffset)}suppressWidgetCursorChange(e,t){return this.hasComposition&&t.empty&&Si(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==t.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,t=e.state.selection.main,i=Pi(e.root),{anchorNode:s,anchorOffset:r}=e.observer.selectionRange;if(!i||!t.empty||!t.assoc||!i.modify)return;let o=this.lineAt(t.head,t.assoc);if(!o)return;let l=o.posAtStart;if(t.head==l||t.head==l+o.length)return;let a=this.coordsAt(t.head,-1),h=this.coordsAt(t.head,1);if(!a||!h||a.bottom>h.top)return;let c=this.domAtPos(t.head+t.assoc,t.assoc);i.collapse(c.node,c.offset),i.modify("move",t.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let f=e.observer.selectionRange;e.docView.posFromDOM(f.anchorNode,f.anchorOffset)!=t.from&&i.collapse(s,r)}posFromDOM(e,t){let i=this.tile.nearest(e);if(!i)return this.tile.dom.compareDocumentPosition(e)&2?0:this.view.state.doc.length;let s=i.posAtStart;if(i.isComposite()){let r;if(e==i.dom)r=i.dom.childNodes[t];else{let o=ct(e)==0?0:t==0?-1:1;for(;;){let l=e.parentNode;if(l==i.dom)break;o==0&&l.firstChild!=l.lastChild&&(e==l.firstChild?o=-1:o=1),e=l}o<0?r=e:r=e.nextSibling}if(r==i.dom.firstChild)return s;for(;r&&!X.get(r);)r=r.nextSibling;if(!r)return s+i.length;for(let o=0,l=s;;o++){let a=i.children[o];if(a.dom==r)return l;l+=a.length+a.breakAfter}}else return i.isText()?e==i.dom?s+t:s+(t?i.length:0):s}domAtPos(e,t){let{tile:i,offset:s}=this.tile.resolveBlock(e,t);return i.isWidget()?i.domPosFor(e,t):i.domIn(s,t)}inlineDOMNearPos(e,t){let i,s=-1,r=!1,o,l=-1,a=!1;return this.tile.blockTiles((h,c)=>{if(h.isWidget()){if(h.flags&32&&c>=e)return!0;h.flags&16&&(r=!0)}else{let f=c+h.length;if(c<=e&&(i=h,s=e-c,r=f<e),f>=e&&!o&&(o=h,l=e-c,a=c>e),c>e&&o)return!0}}),!i&&!o?this.domAtPos(e,t):(r&&o?i=null:a&&i&&(o=null),i&&t<0||!o?i.domIn(s,t):o.domIn(l,t))}coordsAt(e,t){let{tile:i,offset:s}=this.tile.resolveBlock(e,t);return i.isWidget()?i.widget instanceof Bs?null:i.coordsInWidget(s,t,!0):i.coordsIn(s,t)}lineAt(e,t){let{tile:i}=this.tile.resolveBlock(e,t);return i.isLine()?i:null}coordsForChar(e){let{tile:t,offset:i}=this.tile.resolveBlock(e,1);if(!t.isLine())return null;function s(r,o){if(r.isComposite())for(let l of r.children){if(l.length>=o){let a=s(l,o);if(a)return a}if(o-=l.length,o<0)break}else if(r.isText()&&o<r.length){let l=ne(r.text,o);if(l==o)return null;let a=Li(r.dom,o,l).getClientRects();for(let h=0;h<a.length;h++){let c=a[h];if(h==a.length-1||c.top<c.bottom&&c.left<c.right)return c}}return null}return s(t,i)}measureVisibleLineHeights(e){let t=[],{from:i,to:s}=e,r=this.view.contentDOM.clientWidth,o=r>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,l=-1,a=this.view.textDirection==j.LTR,h=0,c=(f,u,d)=>{for(let p=0;p<f.children.length&&!(u>s);p++){let m=f.children[p],g=u+m.length,y=m.dom.getBoundingClientRect(),{height:w}=y;if(d&&!p&&(h+=y.top-d.top),m instanceof at)g>i&&c(m,u,y);else if(u>=i&&(h>0&&t.push(-h),t.push(w+h),h=0,o)){let x=m.dom.lastChild,D=x?vi(x):[];if(D.length){let k=D[D.length-1],v=a?k.right-y.left:y.right-k.left;v>l&&(l=v,this.minWidth=r,this.minWidthFrom=u,this.minWidthTo=g)}}d&&p==f.children.length-1&&(h+=d.bottom-y.bottom),u=g+m.breakAfter}};return c(this.tile,0,null),t}textDirectionAt(e){let{tile:t}=this.tile.resolveBlock(e,1);return getComputedStyle(t.dom).direction=="rtl"?j.RTL:j.LTR}measureTextSize(){let e=this.tile.blockTiles(o=>{if(o.isLine()&&o.children.length&&o.length<=20){let l=0,a;for(let h of o.children){if(!h.isText()||/[^ -~]/.test(h.text))return;let c=vi(h.dom);if(c.length!=1)return;l+=c[0].width,a=c[0].height}if(l)return{lineHeight:o.dom.getBoundingClientRect().height,charWidth:l/o.length,textHeight:a}}});if(e)return e;let t=document.createElement("div"),i,s,r;return t.className="cm-line",t.style.width="99999px",t.style.position="absolute",t.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.tile.dom.appendChild(t);let o=vi(t.firstChild)[0];i=t.getBoundingClientRect().height,s=o&&o.width?o.width/27:7,r=o&&o.height?o.height:i,t.remove()}),{lineHeight:i,charWidth:s,textHeight:r}}computeBlockGapDeco(){let e=[],t=this.view.viewState;for(let i=0,s=0;;s++){let r=s==t.viewports.length?null:t.viewports[s],o=r?r.from-1:this.view.state.doc.length;if(o>i){let l=(t.lineBlockAt(o).bottom-t.lineBlockAt(i).top)/this.view.scaleY;e.push(B.replace({widget:new Bs(l),block:!0,inclusive:!0,isBlockGap:!0}).range(i,o))}if(!r)break;i=r.to+1}return B.set(e)}updateDeco(){let e=1,t=this.view.state.facet(ls).map(r=>(this.dynamicDecorationMap[e++]=typeof r=="function")?r(this.view):r),i=!1,s=this.view.state.facet(so).map((r,o)=>{let l=typeof r=="function";return l&&(i=!0),l?r(this.view):r});for(s.length&&(this.dynamicDecorationMap[e++]=i,t.push(E.join(s))),this.decorations=[this.editContextFormatting,...t,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];e<this.decorations.length;)this.dynamicDecorationMap[e++]=!1;this.blockWrappers=this.view.state.facet(uh).map(r=>typeof r=="function"?r(this.view):r)}scrollIntoView(e){if(e.isSnapshot){let h=this.view.viewState.lineBlockAt(e.range.head);this.view.scrollDOM.scrollTop=h.top-e.yMargin,this.view.scrollDOM.scrollLeft=e.xMargin;return}for(let h of this.view.state.facet(hh))try{if(h(this.view,e.range,e))return!0}catch(c){me(this.view.state,c,"scroll handler")}let{range:t}=e,i=this.coordsAt(t.head,t.empty?t.assoc:t.head>t.anchor?-1:1),s;if(!i)return;!t.empty&&(s=this.coordsAt(t.anchor,t.anchor>t.head?-1:1))&&(i={left:Math.min(i.left,s.left),top:Math.min(i.top,s.top),right:Math.max(i.right,s.right),bottom:Math.max(i.bottom,s.bottom)});let r=ro(this.view),o={left:i.left-r.left,top:i.top-r.top,right:i.right+r.right,bottom:i.bottom+r.bottom},{offsetWidth:l,offsetHeight:a}=this.view.scrollDOM;if(Jf(this.view.scrollDOM,o,t.head<t.anchor?-1:1,e.x,e.y,Math.max(Math.min(e.xMargin,l),-l),Math.max(Math.min(e.yMargin,a),-a),this.view.textDirection==j.LTR),window.visualViewport&&window.innerHeight-window.visualViewport.height>1&&(i.top>window.pageYOffset+window.visualViewport.offsetTop+window.visualViewport.height||i.bottom<window.pageYOffset+window.visualViewport.offsetTop)){let h=this.view.docView.lineAt(t.head,1);h&&h.dom.scrollIntoView({block:"nearest"})}}lineHasWidget(e){let t=i=>i.isWidget()||i.children.some(t);return t(this.tile.resolveBlock(e,1).tile)}destroy(){Sr(this.tile)}}function Sr(n,e){let t=e==null?void 0:e.get(n);if(t!=1){t==null&&n.destroy();for(let i of n.children)Sr(i,e)}}function Cu(n){return n.node.nodeType==1&&n.node.firstChild&&(n.offset==0||n.node.childNodes[n.offset-1].contentEditable=="false")&&(n.offset==n.node.childNodes.length||n.node.childNodes[n.offset].contentEditable=="false")}function gh(n,e){let t=n.observer.selectionRange;if(!t.focusNode)return null;let i=Qa(t.focusNode,t.focusOffset),s=Ya(t.focusNode,t.focusOffset),r=i||s;if(s&&i&&s.node!=i.node){let l=X.get(s.node);if(!l||l.isText()&&l.text!=s.node.nodeValue)r=s;else if(n.docView.lastCompositionAfterCursor){let a=X.get(i.node);!a||a.isText()&&a.text!=i.node.nodeValue||(r=s)}}if(n.docView.lastCompositionAfterCursor=r!=i,!r)return null;let o=e-r.offset;return{from:o,to:o+r.node.nodeValue.length,node:r.node}}function Au(n,e,t){let i=gh(n,t);if(!i)return null;let{node:s,from:r,to:o}=i,l=s.nodeValue;if(/[\n\r]/.test(l)||n.state.doc.sliceString(i.from,i.to)!=l)return null;let a=e.invertedDesc;return{range:new Pe(a.mapPos(r),a.mapPos(o),r,o),text:s}}function Mu(n,e){return n.nodeType!=1?0:(e&&n.childNodes[e-1].contentEditable=="false"?1:0)|(e<n.childNodes.length&&n.childNodes[e].contentEditable=="false"?2:0)}let Ou=class{constructor(){this.changes=[]}compareRange(e,t){Xt(e,t,this.changes)}comparePoint(e,t){Xt(e,t,this.changes)}boundChange(e){Xt(e,e,this.changes)}};function Tu(n,e,t){let i=new Ou;return E.compare(n,e,t,i),i.changes}class Du{constructor(){this.changes=[]}compareRange(e,t){Xt(e,t,this.changes)}comparePoint(){}boundChange(e){Xt(e,e,this.changes)}}function Bu(n,e,t){let i=new Du;return E.compare(n,e,t,i),i.changes}function Pu(n,e){for(let t=n;t&&t!=e;t=t.assignedSlot||t.parentNode)if(t.nodeType==1&&t.contentEditable=="false")return!0;return!1}function Ru(n,e){let t=!1;return e&&n.iterChangedRanges((i,s)=>{i<e.to&&s>e.from&&(t=!0)}),t}class Bs extends st{constructor(e){super(),this.height=e}toDOM(){let e=document.createElement("div");return e.className="cm-gap",this.updateDOM(e),e}eq(e){return e.height==this.height}updateDOM(e){return e.style.height=this.height+"px",!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}}function Lu(n,e,t=1){let i=n.charCategorizer(e),s=n.doc.lineAt(e),r=e-s.from;if(s.length==0)return b.cursor(e);r==0?t=1:r==s.length&&(t=-1);let o=r,l=r;t<0?o=ne(s.text,r,!1):l=ne(s.text,r);let a=i(s.text.slice(o,l));for(;o>0;){let h=ne(s.text,o,!1);if(i(s.text.slice(h,o))!=a)break;o=h}for(;l<s.length;){let h=ne(s.text,l);if(i(s.text.slice(l,h))!=a)break;l=h}return b.range(o+s.from,l+s.from)}function Eu(n,e,t,i,s){let r=Math.round((i-e.left)*n.defaultCharacterWidth);if(n.lineWrapping&&t.height>n.defaultLineHeight*1.5){let l=n.viewState.heightOracle.textHeight,a=Math.floor((s-t.top-(n.defaultLineHeight-l)*.5)/l);r+=a*n.viewState.heightOracle.lineLength}let o=n.state.sliceDoc(t.from,t.to);return t.from+fr(o,r,n.state.tabSize)}function Cr(n,e,t){let i=n.lineBlockAt(e);if(Array.isArray(i.type)){let s;for(let r of i.type){if(r.from>e)break;if(!(r.to<e)){if(r.from<e&&r.to>e)return r;(!s||r.type==ae.Text&&(s.type!=r.type||(t<0?r.from<e:r.to>e)))&&(s=r)}}return s||i}return i}function Iu(n,e,t,i){let s=Cr(n,e.head,e.assoc||-1),r=!i||s.type!=ae.Text||!(n.lineWrapping||s.widgetLineBreaks)?null:n.coordsAtPos(e.assoc<0&&e.head>s.from?e.head-1:e.head);if(r){let o=n.dom.getBoundingClientRect(),l=n.textDirectionAt(s.from),a=n.posAtCoords({x:t==(l==j.LTR)?o.right-1:o.left+1,y:(r.top+r.bottom)/2});if(a!=null)return b.cursor(a,t?-1:1)}return b.cursor(t?s.to:s.from,t?-1:1)}function Zo(n,e,t,i){let s=n.state.doc.lineAt(e.head),r=n.bidiSpans(s),o=n.textDirectionAt(s.from);for(let l=e,a=null;;){let h=hu(s,r,o,l,t),c=eh;if(!h){if(s.number==(t?n.state.doc.lines:1))return l;c=`