@karmaniverous/jeeves-server 3.4.2 → 3.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (127) hide show
  1. package/.tsbuildinfo +1 -1
  2. package/CHANGELOG.md +38 -1
  3. package/README.md +18 -17
  4. package/client/package.json +19 -19
  5. package/client/src/components/SearchModal.tsx +11 -1
  6. package/client/src/components/layout/Header.tsx +3 -3
  7. package/client/src/lib/api.ts +10 -5
  8. package/dist/client/assets/CodeEditor-Brh86AGF.js +1 -0
  9. package/dist/client/assets/CodeViewer-Cegj3cEn.js +1 -0
  10. package/dist/client/assets/dist-2YqVIvgv.js +2 -0
  11. package/dist/client/assets/dist-5vamY028.js +1 -0
  12. package/dist/client/assets/dist-6_auAGci.js +1 -0
  13. package/dist/client/assets/dist-B0kq1DQG.js +1 -0
  14. package/dist/client/assets/dist-B2SZD_eN.js +1 -0
  15. package/dist/client/assets/dist-B2t4dYA2.js +1 -0
  16. package/dist/client/assets/dist-B5gFYAn7.js +1 -0
  17. package/dist/client/assets/dist-BPy6CnYN.js +1 -0
  18. package/dist/client/assets/dist-CL6VCrQn.js +9 -0
  19. package/dist/client/assets/dist-CWsHar9N.js +1 -0
  20. package/dist/client/assets/dist-CnFc5Ssx.js +1 -0
  21. package/dist/client/assets/dist-DSgLBuTS.js +1 -0
  22. package/dist/client/assets/dist-DUcac0X_.js +7 -0
  23. package/dist/client/assets/dist-DcTcc-BG.js +6 -0
  24. package/dist/client/assets/dist-DvfTyWk_.js +1 -0
  25. package/dist/client/assets/dist-Dz1Ulpqa.js +1 -0
  26. package/dist/client/assets/dist-Kr-mUYW1.js +5 -0
  27. package/dist/client/assets/dist-OX4k3MMG.js +2 -0
  28. package/dist/client/assets/dist-qiU0qoeK.js +1 -0
  29. package/dist/client/assets/dist-ui4J6fvl.js +23 -0
  30. package/dist/client/assets/index-Dk_myGs4.css +2 -0
  31. package/dist/client/assets/index-DrBXupPz.js +62 -0
  32. package/dist/client/assets/theme-CPpIxvB0.js +2 -0
  33. package/dist/client/index.html +3 -2
  34. package/dist/src/cli/commands/config.test.js +5 -40
  35. package/dist/src/cli/index.js +9 -15
  36. package/dist/src/cli/start-server.js +16 -0
  37. package/dist/src/config/index.js +48 -37
  38. package/dist/src/config/loadConfig.test.js +27 -25
  39. package/dist/src/config/migration.js +60 -0
  40. package/dist/src/config/schema.js +4 -3
  41. package/dist/src/descriptor.js +46 -0
  42. package/dist/src/routes/api/diagramExport.js +101 -0
  43. package/dist/src/routes/api/diagramExport.test.js +134 -0
  44. package/dist/src/routes/api/events.js +13 -0
  45. package/dist/src/routes/api/export.js +6 -82
  46. package/dist/src/routes/api/index.js +4 -0
  47. package/dist/src/routes/api/search.js +9 -50
  48. package/dist/src/routes/api/sharing.js +40 -23
  49. package/dist/src/routes/api/sharing.test.js +52 -0
  50. package/dist/src/routes/auth.js +1 -1
  51. package/dist/src/routes/config.js +8 -2
  52. package/dist/src/routes/keys.js +4 -4
  53. package/dist/src/routes/path/index.js +1 -1
  54. package/dist/src/routes/status.js +15 -16
  55. package/dist/src/routes/status.test.js +13 -8
  56. package/dist/src/server.js +21 -16
  57. package/dist/src/services/markdown.js +2 -1
  58. package/dist/src/services/markdown.test.js +22 -0
  59. package/dist/src/util/packageVersion.js +7 -16
  60. package/dist/src/util/packageVersion.test.js +7 -0
  61. package/guides/api-integration.md +4 -0
  62. package/guides/deployment.md +11 -10
  63. package/guides/event-gateway.md +4 -0
  64. package/guides/exports.md +4 -0
  65. package/guides/index.md +1 -1
  66. package/guides/setup.md +17 -16
  67. package/guides/sharing.md +4 -0
  68. package/package.json +3 -3
  69. package/scripts/download-plantuml.js +0 -1
  70. package/src/cli/commands/config.test.ts +5 -45
  71. package/src/cli/index.ts +9 -16
  72. package/src/cli/start-server.ts +21 -0
  73. package/src/config/index.ts +56 -43
  74. package/src/config/loadConfig.test.ts +27 -29
  75. package/src/config/migration.ts +76 -0
  76. package/src/config/schema.ts +5 -4
  77. package/src/descriptor.ts +55 -0
  78. package/src/routes/api/diagramExport.test.ts +200 -0
  79. package/src/routes/api/diagramExport.ts +170 -0
  80. package/src/routes/api/events.ts +22 -0
  81. package/src/routes/api/export.ts +6 -131
  82. package/src/routes/api/index.ts +4 -0
  83. package/src/routes/api/search.ts +9 -63
  84. package/src/routes/api/sharing.test.ts +66 -0
  85. package/src/routes/api/sharing.ts +47 -23
  86. package/src/routes/auth.ts +1 -1
  87. package/src/routes/config.ts +15 -2
  88. package/src/routes/keys.ts +4 -4
  89. package/src/routes/path/index.ts +1 -1
  90. package/src/routes/status.test.ts +14 -8
  91. package/src/routes/status.ts +56 -62
  92. package/src/server.ts +29 -17
  93. package/src/services/markdown.test.ts +26 -0
  94. package/src/services/markdown.ts +2 -1
  95. package/src/util/packageVersion.test.ts +9 -0
  96. package/src/util/packageVersion.ts +11 -18
  97. package/src/util/platform.ts +1 -1
  98. package/dist/client/assets/CodeEditor-DQZZL5Rq.js +0 -1
  99. package/dist/client/assets/CodeViewer-ofJVD1Vn.js +0 -1
  100. package/dist/client/assets/index--MBieNJA.js +0 -1
  101. package/dist/client/assets/index-BENeXQI_.js +0 -1
  102. package/dist/client/assets/index-BbBpoOxz.js +0 -1
  103. package/dist/client/assets/index-BdV9g5AM.js +0 -6
  104. package/dist/client/assets/index-BjAilRri.js +0 -2
  105. package/dist/client/assets/index-BqbhWo2I.js +0 -3
  106. package/dist/client/assets/index-CVbycZ0H.js +0 -1
  107. package/dist/client/assets/index-Cs5oz2oJ.js +0 -5
  108. package/dist/client/assets/index-D-RC7ZS6.css +0 -1
  109. package/dist/client/assets/index-D8KZVveX.js +0 -1
  110. package/dist/client/assets/index-DC4HMHxY.js +0 -13
  111. package/dist/client/assets/index-DcY2RXqX.js +0 -1
  112. package/dist/client/assets/index-Duy-tZYV.js +0 -1
  113. package/dist/client/assets/index-Dw7rDFmE.js +0 -7
  114. package/dist/client/assets/index-FlCUvrjv.js +0 -2
  115. package/dist/client/assets/index-K6OVmfhg.js +0 -1
  116. package/dist/client/assets/index-MLwyFRN0.js +0 -1
  117. package/dist/client/assets/index-OpqBpSjn.js +0 -1
  118. package/dist/client/assets/index-SsHei0HE.js +0 -1
  119. package/dist/client/assets/index-jSGuHSeS.js +0 -62
  120. package/dist/client/assets/index-uQa2yckk.js +0 -1
  121. package/dist/client/assets/index-udkXoIER.js +0 -1
  122. package/dist/src/cli/commands/config.js +0 -105
  123. package/dist/src/cli/commands/service.js +0 -93
  124. package/dist/src/cli/commands/start.js +0 -24
  125. package/src/cli/commands/config.ts +0 -117
  126. package/src/cli/commands/service.ts +0 -129
  127. package/src/cli/commands/start.ts +0 -27
package/CHANGELOG.md CHANGED
@@ -2,9 +2,46 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. Dates are displayed in UTC.
4
4
 
5
- #### [3.4.2](https://github.com/karmaniverous/jeeves-server/compare/service/3.4.1...3.4.2)
5
+ #### [3.5.0](https://github.com/karmaniverous/jeeves-server/compare/service/3.4.2...3.5.0)
6
+
7
+ - Fix config validate test assertion [`#136`](https://github.com/karmaniverous/jeeves-server/pull/136)
8
+ - [35] Component SDK adoption (core v0.4.4) + plugin/CLI factories [`#134`](https://github.com/karmaniverous/jeeves-server/pull/134)
9
+ - [35] refactor: replace hand-rolled package.json walk with packageDirectorySync [`#96`](https://github.com/karmaniverous/jeeves-server/pull/96)
10
+ - [35] fix: show user-friendly search error messages [`#98`](https://github.com/karmaniverous/jeeves-server/pull/98)
11
+ - [35] fix: decode HTML entities in TOC heading text [`#102`](https://github.com/karmaniverous/jeeves-server/pull/102)
12
+ - [35] refactor: remove Connected Services from TOOLS.md writer (closes #128) [`#128`](https://github.com/karmaniverous/jeeves-server/issues/128)
13
+ - [35] chore: update deps (peer-safe) [`c87c3a1`](https://github.com/karmaniverous/jeeves-server/commit/c87c3a1d10a15654ceac04c493d90abd65fe05d6)
14
+ - [35] refactor: migrate openclaw plugin to core v0.4.4 SDK [`e29773a`](https://github.com/karmaniverous/jeeves-server/commit/e29773a63dc0313a42c41d03289b5cc1f6a0e2bb)
15
+ - [35] refactor: SOLID/DRY cleanup [`78a0b2d`](https://github.com/karmaniverous/jeeves-server/commit/78a0b2d92391ae273d8c2b50fb855420a509ef30)
16
+ - [35] refactor: replace hand-rolled CLI with createServiceCli(descriptor) (#106) [`9b7517f`](https://github.com/karmaniverous/jeeves-server/commit/9b7517f58af9226088f034add21b9a58700d2e50)
17
+ - [35] refactor: adopt createPluginToolset, health-nested status, event endpoint (#87, #112, #118, #128) [`8ead7ae`](https://github.com/karmaniverous/jeeves-server/commit/8ead7aedbe5799f29ee21d0c6de49531ac174b9a)
18
+ - [35] test: add tests for diagramExport and sharing helpers [`1caaa1b`](https://github.com/karmaniverous/jeeves-server/commit/1caaa1ba28a978b8640bc06d3ba80ba62f5c375b)
19
+ - [35] feat: replace cosmiconfig with direct JSON config loading [`6f888c6`](https://github.com/karmaniverous/jeeves-server/commit/6f888c690e0a9711bd42f9f02e128bd70f0c62e4)
20
+ - [35] docs: sync documentation with SDK adoption changes [`aefbf73`](https://github.com/karmaniverous/jeeves-server/commit/aefbf73798c938dc449b20bbed81a20074aeaaed)
21
+ - [35] refactor: migrate GET /status to createStatusHandler factory [`3526b46`](https://github.com/karmaniverous/jeeves-server/commit/3526b4676f47460d094602dd8ffe66f52da8d3ad)
22
+ - npm audit fix [`a2db7c5`](https://github.com/karmaniverous/jeeves-server/commit/a2db7c5df23813bf1f1533f3bc8a1a8c733dda8a)
23
+ - chore: release @karmaniverous/jeeves-server-openclaw v0.5.1 [`3aa5827`](https://github.com/karmaniverous/jeeves-server/commit/3aa5827fd79b6236aea09439fa0e7d7dc14ccfbb)
24
+ - [35] fix: resolve lint errors from core v0.4.4 migration [`4b0c11d`](https://github.com/karmaniverous/jeeves-server/commit/4b0c11d89f22a00f0f86583e484551682bb57c06)
25
+ - [35] chore: bump @karmaniverous/jeeves to ^0.4.3, remove cosmiconfig dep [`8d3162b`](https://github.com/karmaniverous/jeeves-server/commit/8d3162b572167dcb5be5725956f37845d4518677)
26
+ - [35] feat: define JeevesComponentDescriptor for server component [`16c5b56`](https://github.com/karmaniverous/jeeves-server/commit/16c5b56ffa3600f613562b5a5e3a08629c5b1b5a)
27
+ - [35] feat: use getBindAddress from core, replace localhost with 127.0.0.1 [`1df9dc6`](https://github.com/karmaniverous/jeeves-server/commit/1df9dc60df3ba838bc692ada8143eb06723a3671)
28
+ - [35] docs: add title front matter to all guides [`840f9c7`](https://github.com/karmaniverous/jeeves-server/commit/840f9c77d0c746d13983931ec69185f935036ac6)
29
+ - [35] fix: encode browse path segments in API calls, add SPA catch-all (#50, #127) [`dce3f11`](https://github.com/karmaniverous/jeeves-server/commit/dce3f111018937535f4e614208312653e5ea5f18)
30
+ - [35] fix: use static bind default, bump openclaw core dep, remove local stub [`6420e8c`](https://github.com/karmaniverous/jeeves-server/commit/6420e8c96633138a1c176434e1fa662a4aec8445)
31
+ - ci: refactor linux-compat to use shared workflow + dedicated smoke-tests job [`e2f91f1`](https://github.com/karmaniverous/jeeves-server/commit/e2f91f1a53fd6df23e31dfda7ab4fcfb26abd499)
32
+ - [35] feat: add GET /api/events endpoint for event log queries [`c5e6505`](https://github.com/karmaniverous/jeeves-server/commit/c5e65058682f006efdd6ef604f6938b6f9f8d980)
33
+ - [35] feat: add POST /config/apply endpoint using createConfigApplyHandler [`d1281b8`](https://github.com/karmaniverous/jeeves-server/commit/d1281b87161b17547c0e9ff236db5bc38fc2d7b6)
34
+ - [35] fix: resolve startCommand path absolutely for CI compatibility [`25d23cd`](https://github.com/karmaniverous/jeeves-server/commit/25d23cd66b4e82d70f1b7b7295df826a7f1b34cd)
35
+ - [35] ci: add cloud-sync workflow (parity with watcher/runner) [`aed95e7`](https://github.com/karmaniverous/jeeves-server/commit/aed95e7daa7326ae193ab824d3b1bdf62fbc9b83)
36
+ - [35] fix: add missing dirs param to server_share plugin tool (#99, #87) [`359189a`](https://github.com/karmaniverous/jeeves-server/commit/359189a0f8e425e35be73e95e94136d60b04864f)
37
+ - fix: align config validate test assertion with core SDK output [`5c776ca`](https://github.com/karmaniverous/jeeves-server/commit/5c776ca69104056f3d1f51c0f85b0922ca08cdc2)
38
+
39
+ #### [service/3.4.2](https://github.com/karmaniverous/jeeves-server/compare/service/3.4.1...service/3.4.2)
40
+
41
+ > 25 March 2026
6
42
 
7
43
  - ci: replace bespoke docs workflow with shared version [`9521d00`](https://github.com/karmaniverous/jeeves-server/commit/9521d00c45901c20e81ad58627ad0d961c472973)
44
+ - chore: release @karmaniverous/jeeves-server v3.4.2 [`30e700c`](https://github.com/karmaniverous/jeeves-server/commit/30e700ca9ddaafc019cf1fc8f284f9b926e0b3e7)
8
45
  - chore: bump @karmaniverous/jeeves to 0.3.1 [`df78ac9`](https://github.com/karmaniverous/jeeves-server/commit/df78ac9a0e43b08adaac34f3476db8fe37ca78af)
9
46
 
10
47
  #### [service/3.4.1](https://github.com/karmaniverous/jeeves-server/compare/service/3.4.0...service/3.4.1)
package/README.md CHANGED
@@ -10,7 +10,7 @@ npm install -g @karmaniverous/jeeves-server
10
10
 
11
11
  ## Run
12
12
 
13
- Jeeves Server loads configuration via cosmiconfig. Create a config file such as `jeeves-server.config.json` and run:
13
+ Create a JSON config file at `<configDir>/jeeves-server/config.json` (or use `jeeves-server init`), then:
14
14
 
15
15
  ```bash
16
16
  jeeves-server start [--config <path>]
@@ -21,25 +21,26 @@ Default port: **1934**.
21
21
  ## CLI
22
22
 
23
23
  ```bash
24
- jeeves-server start
25
- jeeves-server config validate
26
- jeeves-server config show
27
- jeeves-server service install
28
- jeeves-server service uninstall
29
- jeeves-server service start|stop|restart
24
+ jeeves-server start # Start the server
25
+ jeeves-server status # Query running server status
26
+ jeeves-server config [jsonpath] # Query resolved configuration
27
+ jeeves-server config validate # Validate config file
28
+ jeeves-server config apply # Apply config patch to running server
29
+ jeeves-server init # Generate starter config
30
+ jeeves-server service install|uninstall # Register/remove system service
31
+ jeeves-server service start|stop|restart|status # Manage system service
30
32
  ```
31
33
 
32
34
  ## Docs
33
35
 
34
- - Setup & Configuration: ../../packages/service/guides/setup.md
35
- - Deployment: ../../packages/service/guides/deployment.md
36
- - Sharing: ../../packages/service/guides/sharing.md
37
- - Exports: ../../packages/service/guides/exports.md
38
- - Event Gateway: ../../packages/service/guides/event-gateway.md
39
- - API Integration: ../../packages/service/guides/api-integration.md
36
+ - [Setup & Configuration](guides/setup.md)
37
+ - [Deployment](guides/deployment.md)
38
+ - [Sharing](guides/sharing.md)
39
+ - [Exports](guides/exports.md)
40
+ - [Event Gateway](guides/event-gateway.md)
41
+ - [API Integration](guides/api-integration.md)
40
42
 
41
- ## Public endpoints
42
-
43
- - `GET /health` — health check
44
- - `GET /api/status` — server metadata (public; no auth)
43
+ ## Public Endpoints
45
44
 
45
+ - `GET /status` — server status (version, health, capabilities)
46
+ - `GET /config [?path=jsonpath]` — query resolved config (auth required)
@@ -16,7 +16,7 @@
16
16
  "@codemirror/lang-css": "^6.3.1",
17
17
  "@codemirror/lang-html": "^6.4.11",
18
18
  "@codemirror/lang-java": "^6.0.2",
19
- "@codemirror/lang-javascript": "^6.2.4",
19
+ "@codemirror/lang-javascript": "^6.2.5",
20
20
  "@codemirror/lang-json": "^6.0.2",
21
21
  "@codemirror/lang-markdown": "^6.5.0",
22
22
  "@codemirror/lang-php": "^6.0.2",
@@ -24,37 +24,37 @@
24
24
  "@codemirror/lang-rust": "^6.0.2",
25
25
  "@codemirror/lang-sql": "^6.10.0",
26
26
  "@codemirror/lang-xml": "^6.1.0",
27
- "@codemirror/lang-yaml": "^6.1.2",
28
- "@codemirror/state": "^6.5.2",
27
+ "@codemirror/lang-yaml": "^6.1.3",
28
+ "@codemirror/state": "^6.6.0",
29
29
  "@codemirror/theme-one-dark": "^6.1.3",
30
- "@codemirror/view": "^6.36.5",
31
- "@panzoom/panzoom": "^4.5.1",
30
+ "@codemirror/view": "^6.40.0",
31
+ "@panzoom/panzoom": "^4.6.1",
32
32
  "@radix-ui/react-alert-dialog": "^1.1.15",
33
33
  "@radix-ui/react-dropdown-menu": "^2.1.16",
34
34
  "@tailwindcss/typography": "^0.5.19",
35
- "@tailwindcss/vite": "^4.1.18",
35
+ "@tailwindcss/vite": "^4.2.2",
36
36
  "clsx": "^2.1.1",
37
37
  "codemirror": "^6.0.2",
38
- "lucide": "^0.575.0",
39
- "lucide-react": "^0.564.0",
40
- "react": "^19.2.0",
41
- "react-dom": "^19.2.0",
42
- "react-router-dom": "^7.13.0",
43
- "tailwind-merge": "^3.4.1",
38
+ "lucide": "^1.7.0",
39
+ "lucide-react": "^1.7.0",
40
+ "react": "^19.2.4",
41
+ "react-dom": "^19.2.4",
42
+ "react-router-dom": "^7.13.2",
43
+ "tailwind-merge": "^3.5.0",
44
44
  "tailwindcss": "^4.1.18"
45
45
  },
46
46
  "devDependencies": {
47
47
  "@eslint/js": "^9.39.1",
48
- "@types/node": "^24.10.1",
49
- "@types/react": "^19.2.7",
48
+ "@types/node": "^25.5.0",
49
+ "@types/react": "^19.2.14",
50
50
  "@types/react-dom": "^19.2.3",
51
- "@vitejs/plugin-react": "^5.1.1",
51
+ "@vitejs/plugin-react": "^6.0.1",
52
52
  "eslint": "^9.39.1",
53
53
  "eslint-plugin-react-hooks": "^7.0.1",
54
- "eslint-plugin-react-refresh": "^0.4.24",
55
- "globals": "^16.5.0",
54
+ "eslint-plugin-react-refresh": "^0.5.2",
55
+ "globals": "^17.4.0",
56
56
  "typescript": "~5.9.3",
57
- "typescript-eslint": "^8.48.0",
58
- "vite": "^7.3.1"
57
+ "typescript-eslint": "^8.57.2",
58
+ "vite": "^8.0.3"
59
59
  }
60
60
  }
@@ -491,7 +491,17 @@ export function SearchModal({ open, onClose }: SearchModalProps) {
491
491
  const res = await searchDocuments(q, 30, filter);
492
492
  setResults(res.results);
493
493
  } catch (err) {
494
- setError(String(err));
494
+ const raw = String(err);
495
+ if (raw.includes('502') || raw.includes('Watcher unreachable'))
496
+ setError('Search service is unavailable. Please try again later.');
497
+ else if (raw.includes('501') || raw.includes('not configured'))
498
+ setError('Search is not configured on this server.');
499
+ else if (raw.includes('403'))
500
+ setError('You do not have permission to search.');
501
+ else if (raw.includes('400'))
502
+ setError('Invalid search query. Please revise and try again.');
503
+ else
504
+ setError('Search failed. Please try again later.');
495
505
  } finally {
496
506
  setLoading(false);
497
507
  }
@@ -1,4 +1,4 @@
1
- import { Moon, Sun, BookOpen, KeyRound, Github, Search, Activity } from 'lucide-react';
1
+ import { Moon, Sun, BookOpen, KeyRound, GitBranch, Search, Activity } from 'lucide-react';
2
2
  import { useCallback, useEffect, useState } from 'react';
3
3
  import { Link } from 'react-router-dom';
4
4
 
@@ -133,7 +133,7 @@ export function Header({
133
133
  breakpoint: 'md',
134
134
  node: (
135
135
  <a href={GITHUB_URL} target="_blank" rel="noopener noreferrer" className={menuItemClass}>
136
- <Github className="h-4 w-4 shrink-0" />
136
+ <GitBranch className="h-4 w-4 shrink-0" />
137
137
  GitHub
138
138
  </a>
139
139
  ),
@@ -239,7 +239,7 @@ export function Header({
239
239
  {/* GitHub: visible md+ (768px) */}
240
240
  <a href={GITHUB_URL} target="_blank" rel="noopener noreferrer" title="GitHub" className="hidden md:inline-flex">
241
241
  <Button variant="ghost" size="icon" className="text-zinc-300 hover:text-white hover:bg-white/10 h-8 w-8">
242
- <Github className="h-4 w-4" />
242
+ <GitBranch className="h-4 w-4" />
243
243
  </Button>
244
244
  </a>
245
245
 
@@ -117,12 +117,17 @@ async function fetchJson<T>(url: string, init?: RequestInit): Promise<T> {
117
117
  return res.json() as Promise<T>;
118
118
  }
119
119
 
120
+ /** Encode each segment of a browse path for use in a URL. */
121
+ function encodeBrowsePath(p: string): string {
122
+ return p.split('/').map(encodeURIComponent).join('/');
123
+ }
124
+
120
125
  export async function getDrives(): Promise<DriveEntry[]> {
121
126
  return fetchJson<DriveEntry[]>(`${API_BASE}/drives`);
122
127
  }
123
128
 
124
129
  export async function getDirectory(path: string): Promise<DirectoryListing> {
125
- return fetchJson<DirectoryListing>(`${API_BASE}/path/${path}`);
130
+ return fetchJson<DirectoryListing>(`${API_BASE}/path/${encodeBrowsePath(path)}`);
126
131
  }
127
132
 
128
133
  export async function getFile(path: string): Promise<FileContent> {
@@ -130,11 +135,11 @@ export async function getFile(path: string): Promise<FileContent> {
130
135
  const pageParams = new URLSearchParams(window.location.search);
131
136
  const renderDiagrams = pageParams.get('render_diagrams');
132
137
  const qs = renderDiagrams ? `?render_diagrams=${renderDiagrams}` : '';
133
- return fetchJson<FileContent>(`${API_BASE}/file/${path}${qs}`);
138
+ return fetchJson<FileContent>(`${API_BASE}/file/${encodeBrowsePath(path)}${qs}`);
134
139
  }
135
140
 
136
141
  export async function getFileRaw(path: string): Promise<FileContent> {
137
- return fetchJson<FileContent>(`${API_BASE}/file/${path}?raw=1`);
142
+ return fetchJson<FileContent>(`${API_BASE}/file/${encodeBrowsePath(path)}?raw=1`);
138
143
  }
139
144
 
140
145
  export async function getAuthStatus(browsePath?: string): Promise<AuthStatus> {
@@ -164,7 +169,7 @@ export async function getShareLink(
164
169
  }
165
170
 
166
171
  export async function saveFile(path: string, content: string): Promise<{ ok: boolean; size: number }> {
167
- return fetchJson<{ ok: boolean; size: number }>(`${API_BASE}/file/${path}`, {
172
+ return fetchJson<{ ok: boolean; size: number }>(`${API_BASE}/file/${encodeBrowsePath(path)}`, {
168
173
  method: 'PUT',
169
174
  headers: { 'Content-Type': 'application/json' },
170
175
  body: JSON.stringify({ content }),
@@ -233,7 +238,7 @@ export async function fetchFacets(): Promise<FacetsResponse> {
233
238
 
234
239
  export async function clearCache(path: string): Promise<{ cleared: { exports: number; diagrams: number } }> {
235
240
  return fetchJson<{ cleared: { exports: number; diagrams: number } }>(
236
- `${API_BASE}/export-cache/${path}`,
241
+ `${API_BASE}/export-cache/${encodeBrowsePath(path)}`,
237
242
  { method: 'DELETE' },
238
243
  );
239
244
  }
@@ -0,0 +1 @@
1
+ import{i as e,l as t,n,o as r,r as i,t as a}from"./theme-CPpIxvB0.js";var o=t(r(),1),s=e();function c({content:e,fileName:t,onSave:r,onCancel:c}){let l=(0,o.useRef)(null),u=(0,o.useRef)(null),[d,f]=(0,o.useState)(!1),[p,m]=(0,o.useState)(!1),[h,g]=(0,o.useState)(!0),[_]=a(),v=(0,o.useRef)(e),y=(0,o.useCallback)(async()=>{if(!u.current)return;let e=u.current.state.doc.toString();m(!0);try{await r(e),v.current=e,f(!1)}finally{m(!1)}},[r]);return(0,o.useEffect)(()=>{if(!l.current)return;let r=!1;return(async()=>{let{EditorView:a,EditorState:o,basicSetup:s,keymap:c,oneDark:d}=await i();if(r)return;let p=await n(t.split(`.`).pop()??``);if(r)return;let m=[s,c.of([{key:`Mod-s`,run:()=>(y(),!0)}]),a.updateListener.of(e=>{e.docChanged&&f(e.state.doc.toString()!==v.current)}),a.theme({"&":{fontSize:`14px`,height:`100%`},".cm-scroller":{overflow:`auto`},".cm-content":{fontFamily:`'JetBrains Mono', 'Fira Code', 'Consolas', monospace`},".cm-gutters":{fontFamily:`'JetBrains Mono', 'Fira Code', 'Consolas', monospace`}})];_===`dark`&&m.push(d),p&&m.push(p),u.current=new a({state:o.create({doc:e,extensions:m}),parent:l.current}),g(!1)})(),()=>{r=!0,u.current&&=(u.current.destroy(),null)}},[]),(0,s.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,s.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 border-b border-border bg-muted/50`,children:[(0,s.jsx)(`span`,{className:`text-sm font-medium text-foreground`,children:`Editing`}),d&&(0,s.jsx)(`span`,{className:`text-xs px-1.5 py-0.5 bg-amber-500/20 text-amber-600 dark:text-amber-400 rounded`,children:`unsaved`}),(0,s.jsx)(`div`,{className:`flex-1`}),(0,s.jsx)(`button`,{onClick:c,className:`px-3 py-1 text-sm rounded border border-border text-muted-foreground hover:bg-accent transition-colors`,children:`Cancel`}),(0,s.jsx)(`button`,{onClick:y,disabled:p||!d,className:`px-3 py-1 text-sm rounded bg-blue-600 text-white hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed transition-colors`,children:p?`Saving…`:`Save`}),(0,s.jsx)(`span`,{className:`text-xs text-muted-foreground hidden sm:inline`,children:`Ctrl+S`})]}),(0,s.jsx)(`div`,{ref:l,className:`flex-1 overflow-hidden`,children:h&&(0,s.jsx)(`div`,{className:`flex items-center justify-center h-32 text-muted-foreground`,children:`Loading editor…`})})]})}export{c as CodeEditor};
@@ -0,0 +1 @@
1
+ import{i as e,l as t,n,o as r,r as i,t as a}from"./theme-CPpIxvB0.js";import{n as o,t as s}from"./index-DrBXupPz.js";var c=o(`copy`,[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]),l=t(r(),1),u=e();function d({content:e,fileName:t}){let r=(0,l.useRef)(null),o=(0,l.useRef)(null),[d,f]=(0,l.useState)(!0),[p,m]=(0,l.useState)(!1),[h]=a(),g=async()=>{await navigator.clipboard.writeText(e),m(!0),setTimeout(()=>m(!1),1500)};return(0,l.useEffect)(()=>{if(!r.current)return;let a=!1;return(async()=>{let{EditorView:s,EditorState:c,basicSetup:l,oneDark:u}=await i();if(a)return;let d=await n(t.split(`.`).pop()??``);if(a)return;let p=[l,c.readOnly.of(!0),s.editable.of(!1),s.theme({"&":{fontSize:`14px`},".cm-scroller":{overflow:`auto`},".cm-content":{fontFamily:`'JetBrains Mono', 'Fira Code', 'Consolas', monospace`},".cm-gutters":{fontFamily:`'JetBrains Mono', 'Fira Code', 'Consolas', monospace`},".cm-cursor":{display:`none`}})];h===`dark`&&p.push(u),d&&p.push(d),o.current=new s({state:c.create({doc:e,extensions:p}),parent:r.current}),f(!1)})(),()=>{a=!0,o.current&&=(o.current.destroy(),null)}},[e,t,h]),(0,u.jsxs)(`div`,{className:`relative group rounded-lg border border-border overflow-hidden`,children:[(0,u.jsx)(`div`,{className:`absolute top-2 right-2 z-10`,children:(0,u.jsx)(`button`,{onClick:()=>void g(),className:`p-1.5 rounded bg-accent hover:bg-accent/80 text-muted-foreground hover:text-foreground opacity-0 group-hover:opacity-100 transition-all`,title:`Copy to clipboard`,children:p?(0,u.jsx)(s,{className:`h-3.5 w-3.5 text-green-400`}):(0,u.jsx)(c,{className:`h-3.5 w-3.5`})})}),(0,u.jsx)(`div`,{ref:r,children:d&&(0,u.jsx)(`pre`,{className:`p-4 text-sm text-muted-foreground bg-muted`,children:(0,u.jsxs)(`code`,{children:[e.slice(0,200),`…`]})})})]})}export{d as CodeViewer};
@@ -0,0 +1,2 @@
1
+ import{A as e,C as t,D as n,I as r,T as i,_ as a,b as o,c as s,d as c,h as l,k as u,n as d,w as f,x as p}from"./dist-5vamY028.js";import{S as m,_ as ee,a as h,b as te,d as ne,g as re,h as ie,i as g,l as ae,m as oe,n as se,o as ce,p as _,r as le,s as v,t as ue,v as de,w as fe,y as pe}from"./dist-Kr-mUYW1.js";import{C as me,E as y,S as he,_ as ge,a as _e,d as ve,g as ye,h as be,l as xe,m as Se,n as Ce,o as we,r as b,s as Te,t as x,u as Ee,v as De,w as Oe,x as ke,y as Ae}from"./dist-DUcac0X_.js";import{i as je,n as Me,o as Ne,r as Pe}from"./dist-B2t4dYA2.js";var Fe=e=>{let{state:t}=e,n=t.doc.lineAt(t.selection.main.from),r=Be(e.state,n.from);return r.line?Le(e):r.block?ze(e):!1};function Ie(e,t){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let i=e(t,n);return i?(r(n.update(i)),!0):!1}}var Le=Ie(We,0),Re=Ie(Ue,0),ze=Ie((e,t)=>Ue(e,t,He(t)),0);function Be(e,t){let n=e.languageDataAt(`commentTokens`,t,1);return n.length?n[0]:{}}var S=50;function Ve(e,{open:t,close:n},r,i){let a=e.sliceDoc(r-S,r),o=e.sliceDoc(i,i+S),s=/\s*$/.exec(a)[0].length,c=/^\s*/.exec(o)[0].length,l=a.length-s;if(a.slice(l-t.length,l)==t&&o.slice(c,c+n.length)==n)return{open:{pos:r-s,margin:s&&1},close:{pos:i+c,margin:c&&1}};let u,d;i-r<=2*S?u=d=e.sliceDoc(r,i):(u=e.sliceDoc(r,r+S),d=e.sliceDoc(i-S,i));let f=/^\s*/.exec(u)[0].length,p=/\s*$/.exec(d)[0].length,m=d.length-p-n.length;return u.slice(f,f+t.length)==t&&d.slice(m,m+n.length)==n?{open:{pos:r+f+t.length,margin:/\s/.test(u.charAt(f+t.length))?1:0},close:{pos:i-p-n.length,margin:/\s/.test(d.charAt(m-1))?1:0}}:null}function He(e){let t=[];for(let n of e.selection.ranges){let r=e.doc.lineAt(n.from),i=n.to<=r.to?r:e.doc.lineAt(n.to);i.from>r.from&&i.from==n.to&&(i=n.to==r.to+1?r:e.doc.lineAt(n.to-1));let a=t.length-1;a>=0&&t[a].to>r.from?t[a].to=i.to:t.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:i.to})}return t}function Ue(e,t,n=t.selection.ranges){let r=n.map(e=>Be(t,e.from).block);if(!r.every(e=>e))return null;let i=n.map((e,n)=>Ve(t,r[n],e.from,e.to));if(e!=2&&!i.every(e=>e))return{changes:t.changes(n.map((e,t)=>i[t]?[]:[{from:e.from,insert:r[t].open+` `},{from:e.to,insert:` `+r[t].close}]))};if(e!=1&&i.some(e=>e)){let e=[];for(let t=0,n;t<i.length;t++)if(n=i[t]){let i=r[t],{open:a,close:o}=n;e.push({from:a.pos-i.open.length,to:a.pos+a.margin},{from:o.pos-o.margin,to:o.pos+i.close.length})}return{changes:e}}return null}function We(e,t,n=t.selection.ranges){let r=[],i=-1;ranges:for(let{from:e,to:a}of n){let n=r.length,o=1e9,s;for(let n=e;n<=a;){let c=t.doc.lineAt(n);if(s==null&&(s=Be(t,c.from).line,!s))continue ranges;if(c.from>i&&(e==a||a>c.from)){i=c.from;let e=/^\s*/.exec(c.text)[0].length,t=e==c.length,n=c.text.slice(e,e+s.length)==s?e:-1;e<c.text.length&&e<o&&(o=e),r.push({line:c,comment:n,token:s,indent:e,empty:t,single:!1})}n=c.to+1}if(o<1e9)for(let e=n;e<r.length;e++)r[e].indent<r[e].line.text.length&&(r[e].indent=o);r.length==n+1&&(r[n].single=!0)}if(e!=2&&r.some(e=>e.comment<0&&(!e.empty||e.single))){let e=[];for(let{line:t,token:n,indent:i,empty:a,single:o}of r)(o||!a)&&e.push({from:t.from+i,insert:n+` `});let n=t.changes(e);return{changes:n,selection:t.selection.map(n,1)}}else if(e!=1&&r.some(e=>e.comment>=0)){let e=[];for(let{line:t,comment:n,token:i}of r)if(n>=0){let r=t.from+n,a=r+i.length;t.text[a-t.from]==` `&&a++,e.push({from:r,to:a})}return{changes:e}}return null}var Ge=ue.define(),Ke=ue.define(),qe=v.define(),Je=v.define({combine(e){return pe(e,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(n,r)=>e(n,r)||t(n,r)})}}),Ye=oe.define({create(){return E.empty},update(e,t){let n=t.state.facet(Je),r=t.annotation(Ge);if(r){let i=w.fromTransaction(t,r.selection),a=r.side,o=a==0?e.undone:e.done;return o=i?tt(o,o.length,n.minDepth,i):ot(o,t.startState.selection),new E(a==0?r.rest:o,a==0?o:r.rest)}let i=t.annotation(Ke);if((i==`full`||i==`before`)&&(e=e.isolate()),t.annotation(re.addToHistory)===!1)return t.changes.empty?e:e.addMapping(t.changes.desc);let a=w.fromTransaction(t),o=t.annotation(re.time),s=t.annotation(re.userEvent);return a?e=e.addChanges(a,o,s,n,t):t.selection&&(e=e.addSelection(t.startState.selection,o,s,n.newGroupDelay)),(i==`full`||i==`after`)&&(e=e.isolate()),e},toJSON(e){return{done:e.done.map(e=>e.toJSON()),undone:e.undone.map(e=>e.toJSON())}},fromJSON(e){return new E(e.done.map(w.fromJSON),e.undone.map(w.fromJSON))}});function Xe(e={}){return[Ye,Je.of(e),b.domEventHandlers({beforeinput(e,t){let n=e.inputType==`historyUndo`?Ze:e.inputType==`historyRedo`?Qe:null;return n?(e.preventDefault(),n(t)):!1}})]}function C(e,t){return function({state:n,dispatch:r}){if(!t&&n.readOnly)return!1;let i=n.field(Ye,!1);if(!i)return!1;let a=i.pop(e,n,t);return a?(r(a),!0):!1}}var Ze=C(0,!1),Qe=C(1,!1),$e=C(0,!0),et=C(1,!0),w=class e{constructor(e,t,n,r,i){this.changes=e,this.effects=t,this.mapped=n,this.startSelection=r,this.selectionsAfter=i}setSelAfter(t){return new e(this.changes,this.effects,this.mapped,this.startSelection,t)}toJSON(){return{changes:this.changes?.toJSON(),mapped:this.mapped?.toJSON(),startSelection:this.startSelection?.toJSON(),selectionsAfter:this.selectionsAfter.map(e=>e.toJSON())}}static fromJSON(t){return new e(t.changes&&le.fromJSON(t.changes),[],t.mapped&&se.fromJSON(t.mapped),t.startSelection&&h.fromJSON(t.startSelection),t.selectionsAfter.map(h.fromJSON))}static fromTransaction(t,n){let r=T;for(let e of t.startState.facet(qe)){let n=e(t);n.length&&(r=r.concat(n))}return!r.length&&t.changes.empty?null:new e(t.changes.invert(t.startState.doc),r,void 0,n||t.startState.selection,T)}static selection(t){return new e(void 0,T,void 0,void 0,t)}};function tt(e,t,n,r){let i=t+1>n+20?t-n-1:0,a=e.slice(i,t);return a.push(r),a}function nt(e,t){let n=[],r=!1;return e.iterChangedRanges((e,t)=>n.push(e,t)),t.iterChangedRanges((e,t,i,a)=>{for(let e=0;e<n.length;){let t=n[e++],o=n[e++];a>=t&&i<=o&&(r=!0)}}),r}function rt(e,t){return e.ranges.length==t.ranges.length&&e.ranges.filter((e,n)=>e.empty!=t.ranges[n].empty).length===0}function it(e,t){return e.length?t.length?e.concat(t):e:t}var T=[],at=200;function ot(e,t){if(e.length){let n=e[e.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-at));return r.length&&r[r.length-1].eq(t)?e:(r.push(t),tt(e,e.length-1,1e9,n.setSelAfter(r)))}else return[w.selection([t])]}function st(e){let t=e[e.length-1],n=e.slice();return n[e.length-1]=t.setSelAfter(t.selectionsAfter.slice(0,t.selectionsAfter.length-1)),n}function ct(e,t){if(!e.length)return e;let n=e.length,r=T;for(;n;){let i=lt(e[n-1],t,r);if(i.changes&&!i.changes.empty||i.effects.length){let t=e.slice(0,n);return t[n-1]=i,t}else t=i.mapped,n--,r=i.selectionsAfter}return r.length?[w.selection(r)]:T}function lt(e,t,n){let r=it(e.selectionsAfter.length?e.selectionsAfter.map(e=>e.map(t)):T,n);if(!e.changes)return w.selection(r);let i=e.changes.map(t),a=t.mapDesc(e.changes,!0),o=e.mapped?e.mapped.composeDesc(a):a;return new w(i,_.mapEffects(e.effects,t),o,e.startSelection.map(a),r)}var ut=/^(input\.type|delete)($|\.)/,E=class e{constructor(e,t,n=0,r=void 0){this.done=e,this.undone=t,this.prevTime=n,this.prevUserEvent=r}isolate(){return this.prevTime?new e(this.done,this.undone):this}addChanges(t,n,r,i,a){let o=this.done,s=o[o.length-1];return o=s&&s.changes&&!s.changes.empty&&t.changes&&(!r||ut.test(r))&&(!s.selectionsAfter.length&&n-this.prevTime<i.newGroupDelay&&i.joinToEvent(a,nt(s.changes,t.changes))||r==`input.type.compose`)?tt(o,o.length-1,i.minDepth,new w(t.changes.compose(s.changes),it(_.mapEffects(t.effects,s.changes),s.effects),s.mapped,s.startSelection,T)):tt(o,o.length,i.minDepth,t),new e(o,T,n,r)}addSelection(t,n,r,i){let a=this.done.length?this.done[this.done.length-1].selectionsAfter:T;return a.length>0&&n-this.prevTime<i&&r==this.prevUserEvent&&r&&/^select($|\.)/.test(r)&&rt(a[a.length-1],t)?this:new e(ot(this.done,t),this.undone,n,r)}addMapping(t){return new e(ct(this.done,t),ct(this.undone,t),this.prevTime,this.prevUserEvent)}pop(e,t,n){let r=e==0?this.done:this.undone;if(r.length==0)return null;let i=r[r.length-1],a=i.selectionsAfter[0]||(i.startSelection?i.startSelection.map(i.changes.invertedDesc,1):t.selection);if(n&&i.selectionsAfter.length)return t.update({selection:i.selectionsAfter[i.selectionsAfter.length-1],annotations:Ge.of({side:e,rest:st(r),selection:a}),userEvent:e==0?`select.undo`:`select.redo`,scrollIntoView:!0});if(i.changes){let n=r.length==1?T:r.slice(0,r.length-1);return i.mapped&&(n=ct(n,i.mapped)),t.update({changes:i.changes,selection:i.startSelection,effects:i.effects,annotations:Ge.of({side:e,rest:n,selection:a}),filter:!1,userEvent:e==0?`undo`:`redo`,scrollIntoView:!0})}else return null}};E.empty=new E(T,T);var dt=[{key:`Mod-z`,run:Ze,preventDefault:!0},{key:`Mod-y`,mac:`Mod-Shift-z`,run:Qe,preventDefault:!0},{linux:`Ctrl-Shift-z`,run:Qe,preventDefault:!0},{key:`Mod-u`,run:$e,preventDefault:!0},{key:`Alt-u`,mac:`Mod-Shift-u`,run:et,preventDefault:!0}];function D(e,t){return h.create(e.ranges.map(t),e.mainIndex)}function O(e,t){return e.update({selection:t,scrollIntoView:!0,userEvent:`select`})}function k({state:e,dispatch:t},n){let r=D(e.selection,n);return r.eq(e.selection,!0)?!1:(t(O(e,r)),!0)}function ft(e,t){return h.cursor(t?e.to:e.from)}function pt(e,t){return k(e,n=>n.empty?e.moveByChar(n,t):ft(n,t))}function A(e){return e.textDirectionAt(e.state.selection.main.head)==Ce.LTR}var mt=e=>pt(e,!A(e)),ht=e=>pt(e,A(e));function gt(e,t){return k(e,n=>n.empty?e.moveByGroup(n,t):ft(n,t))}var _t=e=>gt(e,!A(e)),vt=e=>gt(e,A(e));typeof Intl<`u`&&Intl.Segmenter;function yt(e,t,n){if(t.type.prop(n))return!0;let r=t.to-t.from;return r&&(r>2||/[^\s,.;:]/.test(e.sliceDoc(t.from,t.to)))||t.firstChild}function j(t,i,a){let o=e(t).resolveInner(i.head),s=a?r.closedBy:r.openedBy;for(let e=i.head;;){let n=a?o.childAfter(e):o.childBefore(e);if(!n)break;yt(t,n,s)?o=n:e=a?n.to:n.from}let c=o.type.prop(s),l,u;return u=c&&(l=a?n(t,o.from,1):n(t,o.to,-1))&&l.matched?a?l.end.to:l.end.from:a?o.to:o.from,h.cursor(u,a?-1:1)}var bt=e=>k(e,t=>j(e.state,t,!A(e))),xt=e=>k(e,t=>j(e.state,t,A(e)));function St(e,t){return k(e,n=>{if(!n.empty)return ft(n,t);let r=e.moveVertically(n,t);return r.head==n.head?e.moveToLineBoundary(n,t):r})}var Ct=e=>St(e,!1),wt=e=>St(e,!0);function Tt(e){let t=e.scrollDOM.clientHeight<e.scrollDOM.scrollHeight-2,n=0,r=0,i;if(t){for(let t of e.state.facet(b.scrollMargins)){let i=t(e);i?.top&&(n=Math.max(i?.top,n)),i?.bottom&&(r=Math.max(i?.bottom,r))}i=e.scrollDOM.clientHeight-n-r}else i=(e.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:n,marginBottom:r,selfScroll:t,height:Math.max(e.defaultLineHeight,i-5)}}function Et(e,t){let n=Tt(e),{state:r}=e,i=D(r.selection,r=>r.empty?e.moveVertically(r,t,n.height):ft(r,t));if(i.eq(r.selection))return!1;let a;if(n.selfScroll){let t=e.coordsAtPos(r.selection.main.head),o=e.scrollDOM.getBoundingClientRect(),s=o.top+n.marginTop,c=o.bottom-n.marginBottom;t&&t.top>s&&t.bottom<c&&(a=b.scrollIntoView(i.main.head,{y:`start`,yMargin:t.top-s}))}return e.dispatch(O(r,i),{effects:a}),!0}var Dt=e=>Et(e,!1),Ot=e=>Et(e,!0);function M(e,t,n){let r=e.lineBlockAt(t.head),i=e.moveToLineBoundary(t,n);if(i.head==t.head&&i.head!=(n?r.to:r.from)&&(i=e.moveToLineBoundary(t,n,!1)),!n&&i.head==r.from&&r.length){let n=/^\s*/.exec(e.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;n&&t.head!=r.from+n&&(i=h.cursor(r.from+n))}return i}var kt=e=>k(e,t=>M(e,t,!0)),At=e=>k(e,t=>M(e,t,!1)),jt=e=>k(e,t=>M(e,t,!A(e))),Mt=e=>k(e,t=>M(e,t,A(e))),Nt=e=>k(e,t=>h.cursor(e.lineBlockAt(t.head).from,1)),Pt=e=>k(e,t=>h.cursor(e.lineBlockAt(t.head).to,-1));function Ft(e,t,r){let i=!1,a=D(e.selection,t=>{let a=n(e,t.head,-1)||n(e,t.head,1)||t.head>0&&n(e,t.head-1,1)||t.head<e.doc.length&&n(e,t.head+1,-1);if(!a||!a.end)return t;i=!0;let o=a.start.from==t.head?a.end.to:a.end.from;return r?h.range(t.anchor,o):h.cursor(o)});return i?(t(O(e,a)),!0):!1}var It=({state:e,dispatch:t})=>Ft(e,t,!1);function N(e,t){let n=D(e.state.selection,e=>{let n=t(e);return h.range(e.anchor,n.head,n.goalColumn,n.bidiLevel||void 0)});return n.eq(e.state.selection)?!1:(e.dispatch(O(e.state,n)),!0)}function Lt(e,t){return N(e,n=>e.moveByChar(n,t))}var Rt=e=>Lt(e,!A(e)),zt=e=>Lt(e,A(e));function Bt(e,t){return N(e,n=>e.moveByGroup(n,t))}var Vt=e=>Bt(e,!A(e)),Ht=e=>Bt(e,A(e)),Ut=e=>N(e,t=>j(e.state,t,!A(e))),Wt=e=>N(e,t=>j(e.state,t,A(e)));function Gt(e,t){return N(e,n=>e.moveVertically(n,t))}var Kt=e=>Gt(e,!1),qt=e=>Gt(e,!0);function Jt(e,t){return N(e,n=>e.moveVertically(n,t,Tt(e).height))}var Yt=e=>Jt(e,!1),Xt=e=>Jt(e,!0),Zt=e=>N(e,t=>M(e,t,!0)),Qt=e=>N(e,t=>M(e,t,!1)),$t=e=>N(e,t=>M(e,t,!A(e))),en=e=>N(e,t=>M(e,t,A(e))),tn=e=>N(e,t=>h.cursor(e.lineBlockAt(t.head).from)),nn=e=>N(e,t=>h.cursor(e.lineBlockAt(t.head).to)),rn=({state:e,dispatch:t})=>(t(O(e,{anchor:0})),!0),an=({state:e,dispatch:t})=>(t(O(e,{anchor:e.doc.length})),!0),on=({state:e,dispatch:t})=>(t(O(e,{anchor:e.selection.main.anchor,head:0})),!0),sn=({state:e,dispatch:t})=>(t(O(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0),cn=({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:`select`})),!0),ln=({state:e,dispatch:t})=>{let n=I(e).map(({from:t,to:n})=>h.range(t,Math.min(n+1,e.doc.length)));return t(e.update({selection:h.create(n),userEvent:`select`})),!0},un=({state:t,dispatch:n})=>{let r=D(t.selection,n=>{let r=e(t),i=r.resolveStack(n.from,1);if(n.empty){let e=r.resolveStack(n.from,-1);e.node.from>=i.node.from&&e.node.to<=i.node.to&&(i=e)}for(let e=i;e;e=e.next){let{node:t}=e;if((t.from<n.from&&t.to>=n.to||t.to>n.to&&t.from<=n.from)&&e.next)return h.range(t.to,t.from)}return n});return r.eq(t.selection)?!1:(n(O(t,r)),!0)};function dn(e,t){let{state:n}=e,r=n.selection,i=n.selection.ranges.slice();for(let r of n.selection.ranges){let a=n.doc.lineAt(r.head);if(t?a.to<e.state.doc.length:a.from>0)for(let n=r;;){let r=e.moveVertically(n,t);if(r.head<a.from||r.head>a.to){i.some(e=>e.head==r.head)||i.push(r);break}else if(r.head==n.head)break;else n=r}}return i.length==r.ranges.length?!1:(e.dispatch(O(n,h.create(i,i.length-1))),!0)}var fn=e=>dn(e,!1),pn=e=>dn(e,!0),mn=({state:e,dispatch:t})=>{let n=e.selection,r=null;return n.ranges.length>1?r=h.create([n.main]):n.main.empty||(r=h.create([h.cursor(n.main.head)])),r?(t(O(e,r)),!0):!1};function P(e,t){if(e.state.readOnly)return!1;let n=`delete.selection`,{state:r}=e,i=r.changeByRange(r=>{let{from:i,to:a}=r;if(i==a){let o=t(r);o<i?(n=`delete.backward`,o=F(e,o,!1)):o>i&&(n=`delete.forward`,o=F(e,o,!0)),i=Math.min(i,o),a=Math.max(a,o)}else i=F(e,i,!1),a=F(e,a,!0);return i==a?{range:r}:{changes:{from:i,to:a},range:h.cursor(i,i<r.head?-1:1)}});return i.changes.empty?!1:(e.dispatch(r.update(i,{scrollIntoView:!0,userEvent:n,effects:n==`delete.selection`?b.announce.of(r.phrase(`Selection deleted`)):void 0})),!0)}function F(e,t,n){if(e instanceof b)for(let r of e.state.facet(b.atomicRanges).map(t=>t(e)))r.between(t,t,(e,r)=>{e<t&&r>t&&(t=n?r:e)});return t}var hn=(e,t,n)=>P(e,r=>{let i=r.from,{state:a}=e,s=a.doc.lineAt(i),c,l;if(n&&!t&&i>s.from&&i<s.from+200&&!/[^ \t]/.test(c=s.text.slice(0,i-s.from))){if(c[c.length-1]==` `)return i-1;let e=te(c,a.tabSize)%o(a)||o(a);for(let t=0;t<e&&c[c.length-1-t]==` `;t++)i--;l=i}else l=m(s.text,i-s.from,t,t)+s.from,l==i&&s.number!=(t?a.doc.lines:1)?l+=t?1:-1:!t&&/[\ufe00-\ufe0f]/.test(s.text.slice(l-s.from,i-s.from))&&(l=m(s.text,l-s.from,!1,!1)+s.from);return l}),gn=e=>hn(e,!1,!0),_n=e=>hn(e,!0,!1),vn=(e,t)=>P(e,n=>{let r=n.head,{state:i}=e,a=i.doc.lineAt(r),o=i.charCategorizer(r);for(let e=null;;){if(r==(t?a.to:a.from)){r==n.head&&a.number!=(t?i.doc.lines:1)&&(r+=t?1:-1);break}let s=m(a.text,r-a.from,t)+a.from,c=a.text.slice(Math.min(r,s)-a.from,Math.max(r,s)-a.from),l=o(c);if(e!=null&&l!=e)break;(c!=` `||r!=n.head)&&(e=l),r=s}return r}),yn=e=>vn(e,!1),bn=e=>vn(e,!0),xn=e=>P(e,t=>{let n=e.lineBlockAt(t.head).to;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),Sn=e=>P(e,t=>{let n=e.moveToLineBoundary(t,!1).head;return t.head>n?n:Math.max(0,t.head-1)}),Cn=e=>P(e,t=>{let n=e.moveToLineBoundary(t,!0).head;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),wn=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(e=>({changes:{from:e.from,to:e.to,insert:ie.of([``,``])},range:h.cursor(e.from)}));return t(e.update(n,{scrollIntoView:!0,userEvent:`input`})),!0},Tn=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(t=>{if(!t.empty||t.from==0||t.from==e.doc.length)return{range:t};let n=t.from,r=e.doc.lineAt(n),i=n==r.from?n-1:m(r.text,n-r.from,!1)+r.from,a=n==r.to?n+1:m(r.text,n-r.from,!0)+r.from;return{changes:{from:i,to:a,insert:e.doc.slice(n,a).append(e.doc.slice(i,n))},range:h.cursor(a)}});return n.changes.empty?!1:(t(e.update(n,{scrollIntoView:!0,userEvent:`move.character`})),!0)};function I(e){let t=[],n=-1;for(let r of e.selection.ranges){let i=e.doc.lineAt(r.from),a=e.doc.lineAt(r.to);if(!r.empty&&r.to==a.from&&(a=e.doc.lineAt(r.to-1)),n>=i.number){let e=t[t.length-1];e.to=a.to,e.ranges.push(r)}else t.push({from:i.from,to:a.to,ranges:[r]});n=a.number+1}return t}function En(e,t,n){if(e.readOnly)return!1;let r=[],i=[];for(let t of I(e)){if(n?t.to==e.doc.length:t.from==0)continue;let a=e.doc.lineAt(n?t.to+1:t.from-1),o=a.length+1;if(n){r.push({from:t.to,to:a.to},{from:t.from,insert:a.text+e.lineBreak});for(let n of t.ranges)i.push(h.range(Math.min(e.doc.length,n.anchor+o),Math.min(e.doc.length,n.head+o)))}else{r.push({from:a.from,to:t.from},{from:t.to,insert:e.lineBreak+a.text});for(let e of t.ranges)i.push(h.range(e.anchor-o,e.head-o))}}return r.length?(t(e.update({changes:r,scrollIntoView:!0,selection:h.create(i,e.selection.mainIndex),userEvent:`move.line`})),!0):!1}var Dn=({state:e,dispatch:t})=>En(e,t,!1),On=({state:e,dispatch:t})=>En(e,t,!0);function kn(e,t,n){if(e.readOnly)return!1;let r=[];for(let t of I(e))n?r.push({from:t.from,insert:e.doc.slice(t.from,t.to)+e.lineBreak}):r.push({from:t.to,insert:e.lineBreak+e.doc.slice(t.from,t.to)});let i=e.changes(r);return t(e.update({changes:i,selection:e.selection.map(i,n?1:-1),scrollIntoView:!0,userEvent:`input.copyline`})),!0}var An=({state:e,dispatch:t})=>kn(e,t,!1),jn=({state:e,dispatch:t})=>kn(e,t,!0),Mn=e=>{if(e.state.readOnly)return!1;let{state:t}=e,n=t.changes(I(t).map(({from:e,to:n})=>(e>0?e--:n<t.doc.length&&n++,{from:e,to:n}))),r=D(t.selection,t=>{let n;if(e.lineWrapping){let r=e.lineBlockAt(t.head),i=e.coordsAtPos(t.head,t.assoc||1);i&&(n=r.bottom+e.documentTop-i.bottom+e.defaultLineHeight/2)}return e.moveVertically(t,!0,n)}).map(n);return e.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:`delete.line`}),!0};function Nn(t,n){if(/\(\)|\[\]|\{\}/.test(t.sliceDoc(n-1,n+1)))return{from:n,to:n};let i=e(t).resolveInner(n),a=i.childBefore(n),o=i.childAfter(n),s;return a&&o&&a.to<=n&&o.from>=n&&(s=a.type.prop(r.closedBy))&&s.indexOf(o.name)>-1&&t.doc.lineAt(a.to).from==t.doc.lineAt(o.from).from&&!/\S/.test(t.sliceDoc(a.to,o.from))?{from:a.to,to:o.from}:null}var Pn=In(!1),Fn=In(!0);function In(e){return({state:t,dispatch:n})=>{if(t.readOnly)return!1;let r=t.changeByRange(n=>{let{from:r,to:i}=n,a=t.doc.lineAt(r),o=!e&&r==i&&Nn(t,r);e&&(r=i=(i<=a.to?a:t.doc.lineAt(i)).to);let s=new d(t,{simulateBreak:r,simulateDoubleBreak:!!o}),c=p(s,r);for(c??=te(/^\s*/.exec(t.doc.lineAt(r).text)[0],t.tabSize);i<a.to&&/\s/.test(a.text[i-a.from]);)i++;o?{from:r,to:i}=o:r>a.from&&r<a.from+100&&!/\S/.test(a.text.slice(0,r))&&(r=a.from);let l=[``,f(t,c)];return o&&l.push(f(t,s.lineIndent(a.from,-1))),{changes:{from:r,to:i,insert:ie.of(l)},range:h.cursor(r+1+l[1].length)}});return n(t.update(r,{scrollIntoView:!0,userEvent:`input`})),!0}}function Ln(e,t){let n=-1;return e.changeByRange(r=>{let i=[];for(let a=r.from;a<=r.to;){let o=e.doc.lineAt(a);o.number>n&&(r.empty||r.to>o.from)&&(t(o,i,r),n=o.number),a=o.to+1}let a=e.changes(i);return{changes:i,range:h.range(a.mapPos(r.anchor,1),a.mapPos(r.head,1))}})}var Rn=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=Object.create(null),r=new d(e,{overrideIndentation:e=>n[e]??-1}),i=Ln(e,(t,i,a)=>{let o=p(r,t.from);if(o==null)return;/\S/.test(t.text)||(o=0);let s=/^\s*/.exec(t.text)[0],c=f(e,o);(s!=c||a.from<t.from+s.length)&&(n[t.from]=o,i.push({from:t.from,to:t.from+s.length,insert:c}))});return i.changes.empty||t(e.update(i,{userEvent:`indent`})),!0},zn=({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update(Ln(e,(t,n)=>{n.push({from:t.from,insert:e.facet(i)})}),{userEvent:`input.indent`})),!0),Bn=({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update(Ln(e,(t,n)=>{let r=/^\s*/.exec(t.text)[0];if(!r)return;let i=te(r,e.tabSize),a=0,s=f(e,Math.max(0,i-o(e)));for(;a<r.length&&a<s.length&&r.charCodeAt(a)==s.charCodeAt(a);)a++;n.push({from:t.from+a,to:t.from+r.length,insert:s.slice(a)})}),{userEvent:`delete.dedent`})),!0),Vn=e=>(e.setTabFocusMode(),!0),Hn=[{key:`Ctrl-b`,run:mt,shift:Rt,preventDefault:!0},{key:`Ctrl-f`,run:ht,shift:zt},{key:`Ctrl-p`,run:Ct,shift:Kt},{key:`Ctrl-n`,run:wt,shift:qt},{key:`Ctrl-a`,run:Nt,shift:tn},{key:`Ctrl-e`,run:Pt,shift:nn},{key:`Ctrl-d`,run:_n},{key:`Ctrl-h`,run:gn},{key:`Ctrl-k`,run:xn},{key:`Ctrl-Alt-h`,run:yn},{key:`Ctrl-o`,run:wn},{key:`Ctrl-t`,run:Tn},{key:`Ctrl-v`,run:Ot}],Un=[{key:`ArrowLeft`,run:mt,shift:Rt,preventDefault:!0},{key:`Mod-ArrowLeft`,mac:`Alt-ArrowLeft`,run:_t,shift:Vt,preventDefault:!0},{mac:`Cmd-ArrowLeft`,run:jt,shift:$t,preventDefault:!0},{key:`ArrowRight`,run:ht,shift:zt,preventDefault:!0},{key:`Mod-ArrowRight`,mac:`Alt-ArrowRight`,run:vt,shift:Ht,preventDefault:!0},{mac:`Cmd-ArrowRight`,run:Mt,shift:en,preventDefault:!0},{key:`ArrowUp`,run:Ct,shift:Kt,preventDefault:!0},{mac:`Cmd-ArrowUp`,run:rn,shift:on},{mac:`Ctrl-ArrowUp`,run:Dt,shift:Yt},{key:`ArrowDown`,run:wt,shift:qt,preventDefault:!0},{mac:`Cmd-ArrowDown`,run:an,shift:sn},{mac:`Ctrl-ArrowDown`,run:Ot,shift:Xt},{key:`PageUp`,run:Dt,shift:Yt},{key:`PageDown`,run:Ot,shift:Xt},{key:`Home`,run:At,shift:Qt,preventDefault:!0},{key:`Mod-Home`,run:rn,shift:on},{key:`End`,run:kt,shift:Zt,preventDefault:!0},{key:`Mod-End`,run:an,shift:sn},{key:`Enter`,run:Pn,shift:Pn},{key:`Mod-a`,run:cn},{key:`Backspace`,run:gn,shift:gn,preventDefault:!0},{key:`Delete`,run:_n,preventDefault:!0},{key:`Mod-Backspace`,mac:`Alt-Backspace`,run:yn,preventDefault:!0},{key:`Mod-Delete`,mac:`Alt-Delete`,run:bn,preventDefault:!0},{mac:`Mod-Backspace`,run:Sn,preventDefault:!0},{mac:`Mod-Delete`,run:Cn,preventDefault:!0}].concat(Hn.map(e=>({mac:e.key,run:e.run,shift:e.shift}))),Wn=[{key:`Alt-ArrowLeft`,mac:`Ctrl-ArrowLeft`,run:bt,shift:Ut},{key:`Alt-ArrowRight`,mac:`Ctrl-ArrowRight`,run:xt,shift:Wt},{key:`Alt-ArrowUp`,run:Dn},{key:`Shift-Alt-ArrowUp`,run:An},{key:`Alt-ArrowDown`,run:On},{key:`Shift-Alt-ArrowDown`,run:jn},{key:`Mod-Alt-ArrowUp`,run:fn},{key:`Mod-Alt-ArrowDown`,run:pn},{key:`Escape`,run:mn},{key:`Mod-Enter`,run:Fn},{key:`Alt-l`,mac:`Ctrl-l`,run:ln},{key:`Mod-i`,run:un,preventDefault:!0},{key:`Mod-[`,run:Bn},{key:`Mod-]`,run:zn},{key:`Mod-Alt-\\`,run:Rn},{key:`Shift-Mod-k`,run:Mn},{key:`Shift-Mod-\\`,run:It},{key:`Mod-/`,run:Fe},{key:`Alt-A`,run:Re},{key:`Ctrl-m`,mac:`Shift-Alt-m`,run:Vn}].concat(Un),Gn=typeof String.prototype.normalize==`function`?e=>e.normalize(`NFKD`):e=>e,L=class{constructor(e,t,n=0,r=e.length,i,a){this.test=a,this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer=``,this.bufferPos=0,this.iter=e.iterRange(n,r),this.bufferStart=n,this.normalize=i?e=>i(Gn(e)):Gn,this.query=this.normalize(t)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return ee(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let t=fe(e),n=this.bufferStart+this.bufferPos;this.bufferPos+=de(e);let r=this.normalize(t);if(r.length)for(let e=0,i=n;;e++){let a=r.charCodeAt(e),o=this.match(a,i,this.bufferPos+this.bufferStart);if(e==r.length-1){if(o)return this.value=o,this;break}i==n&&e<t.length&&t.charCodeAt(e)==a&&i++}}}match(e,t,n){let r=null;for(let t=0;t<this.matches.length;t+=2){let i=this.matches[t],a=!1;this.query.charCodeAt(i)==e&&(i==this.query.length-1?r={from:this.matches[t+1],to:n}:(this.matches[t]++,a=!0)),a||(this.matches.splice(t,2),t-=2)}return this.query.charCodeAt(0)==e&&(this.query.length==1?r={from:t,to:n}:this.matches.push(1,t)),r&&this.test&&!this.test(r.from,r.to,this.buffer,this.bufferStart)&&(r=null),r}};typeof Symbol<`u`&&(L.prototype[Symbol.iterator]=function(){return this});var Kn={from:-1,to:-1,match:/.*/.exec(``)},qn=`gm`+(/x/.unicode==null?``:`u`),Jn=class{constructor(e,t,n,r=0,i=e.length){if(this.text=e,this.to=i,this.curLine=``,this.done=!1,this.value=Kn,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new Zn(e,t,n,r,i);this.re=new RegExp(t,qn+(n?.ignoreCase?`i`:``)),this.test=n?.test,this.iter=e.iter(),this.curLineStart=e.lineAt(r).from,this.matchPos=R(e,r),this.getLine(this.curLineStart)}getLine(e){this.iter.next(e),this.iter.lineBreak?this.curLine=``:(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine=``:this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let n=this.curLineStart+t.index,r=n+t[0].length;if(this.matchPos=R(this.text,r+(n==r?1:0)),n==this.curLineStart+this.curLine.length&&this.nextLine(),(n<r||n>this.value.to)&&(!this.test||this.test(n,r,t)))return this.value={from:n,to:r,match:t},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length<this.to)this.nextLine(),e=0;else return this.done=!0,this}}},Yn=new WeakMap,Xn=class e{constructor(e,t){this.from=e,this.text=t}get to(){return this.from+this.text.length}static get(t,n,r){let i=Yn.get(t);if(!i||i.from>=r||i.to<=n){let i=new e(n,t.sliceString(n,r));return Yn.set(t,i),i}if(i.from==n&&i.to==r)return i;let{text:a,from:o}=i;return o>n&&(a=t.sliceString(n,o)+a,o=n),i.to<r&&(a+=t.sliceString(i.to,r)),Yn.set(t,new e(o,a)),new e(n,a.slice(n-o,r-o))}},Zn=class{constructor(e,t,n,r,i){this.text=e,this.to=i,this.done=!1,this.value=Kn,this.matchPos=R(e,r),this.re=new RegExp(t,qn+(n?.ignoreCase?`i`:``)),this.test=n?.test,this.flat=Xn.get(e,r,this.chunkEnd(r+5e3))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e&&(this.re.lastIndex=e+1,t=this.re.exec(this.flat.text)),t){let e=this.flat.from+t.index,n=e+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(e,n,t)))return this.value={from:e,to:n,match:t},this.matchPos=R(this.text,n+(e==n?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=Xn.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}};typeof Symbol<`u`&&(Jn.prototype[Symbol.iterator]=Zn.prototype[Symbol.iterator]=function(){return this});function Qn(e){try{return new RegExp(e,qn),!0}catch{return!1}}function R(e,t){if(t>=e.length)return t;let n=e.lineAt(t),r;for(;t<n.to&&(r=n.text.charCodeAt(t-n.from))>=56320&&r<57344;)t++;return t}var $n=e=>{let{state:t}=e,n=String(t.doc.lineAt(e.state.selection.main.head).number),{close:r,result:i}=me(e,{label:t.phrase(`Go to line`),input:{type:`text`,name:`line`,value:n},focus:!0,submitLabel:t.phrase(`go`)});return i.then(n=>{let i=n&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(n.elements.line.value);if(!i){e.dispatch({effects:r});return}let a=t.doc.lineAt(t.selection.main.head),[,o,s,c,l]=i,u=c?+c.slice(1):0,d=s?+s:a.number;if(s&&l){let e=d/100;o&&(e=e*(o==`-`?-1:1)+a.number/t.doc.lines),d=Math.round(t.doc.lines*e)}else s&&o&&(d=d*(o==`-`?-1:1)+a.number);let f=t.doc.line(Math.max(1,Math.min(t.doc.lines,d))),p=h.cursor(f.from+Math.max(0,Math.min(u,f.length)));e.dispatch({effects:[r,b.scrollIntoView(p.from,{y:`center`})],selection:p})}),!0},er={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},tr=v.define({combine(e){return pe(e,er,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})}});function nr(e){let t=[cr,sr];return e&&t.push(tr.of(e)),t}var rr=x.mark({class:`cm-selectionMatch`}),ir=x.mark({class:`cm-selectionMatch cm-selectionMatch-main`});function ar(e,t,n,r){return(n==0||e(t.sliceDoc(n-1,n))!=g.Word)&&(r==t.doc.length||e(t.sliceDoc(r,r+1))!=g.Word)}function or(e,t,n,r){return e(t.sliceDoc(n,n+1))==g.Word&&e(t.sliceDoc(r-1,r))==g.Word}var sr=_e.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.selectionSet||e.docChanged||e.viewportChanged)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=e.state.facet(tr),{state:n}=e,r=n.selection;if(r.ranges.length>1)return x.none;let i=r.main,a,o=null;if(i.empty){if(!t.highlightWordAroundCursor)return x.none;let e=n.wordAt(i.head);if(!e)return x.none;o=n.charCategorizer(i.head),a=n.sliceDoc(e.from,e.to)}else{let e=i.to-i.from;if(e<t.minSelectionLength||e>200)return x.none;if(t.wholeWords){if(a=n.sliceDoc(i.from,i.to),o=n.charCategorizer(i.head),!(ar(o,n,i.from,i.to)&&or(o,n,i.from,i.to)))return x.none}else if(a=n.sliceDoc(i.from,i.to),!a)return x.none}let s=[];for(let r of e.visibleRanges){let e=new L(n.doc,a,r.from,r.to);for(;!e.next().done;){let{from:r,to:a}=e.value;if((!o||ar(o,n,r,a))&&(i.empty&&r<=i.from&&a>=i.to?s.push(ir.range(r,a)):(r>=i.to||a<=i.from)&&s.push(rr.range(r,a)),s.length>t.maxMatches))return x.none}}return x.set(s)}},{decorations:e=>e.decorations}),cr=b.baseTheme({".cm-selectionMatch":{backgroundColor:`#99ff7780`},".cm-searchMatch .cm-selectionMatch":{backgroundColor:`transparent`}}),lr=({state:e,dispatch:t})=>{let{selection:n}=e,r=h.create(n.ranges.map(t=>e.wordAt(t.head)||h.cursor(t.head)),n.mainIndex);return r.eq(n)?!1:(t(e.update({selection:r})),!0)};function ur(e,t){let{main:n,ranges:r}=e.selection,i=e.wordAt(n.head),a=i&&i.from==n.from&&i.to==n.to;for(let n=!1,i=new L(e.doc,t,r[r.length-1].to);;)if(i.next(),i.done){if(n)return null;i=new L(e.doc,t,0,Math.max(0,r[r.length-1].from-1)),n=!0}else{if(n&&r.some(e=>e.from==i.value.from))continue;if(a){let t=e.wordAt(i.value.from);if(!t||t.from!=i.value.from||t.to!=i.value.to)continue}return i.value}}var dr=({state:e,dispatch:t})=>{let{ranges:n}=e.selection;if(n.some(e=>e.from===e.to))return lr({state:e,dispatch:t});let r=e.sliceDoc(n[0].from,n[0].to);if(e.selection.ranges.some(t=>e.sliceDoc(t.from,t.to)!=r))return!1;let i=ur(e,r);return i?(t(e.update({selection:e.selection.addRange(h.range(i.from,i.to),!1),effects:b.scrollIntoView(i.to)})),!0):!1},z=v.define({combine(e){return pe(e,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new Ir(e),scrollToMatch:e=>b.scrollIntoView(e)})}}),fr=class{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||``,this.valid=!!this.search&&(!this.regexp||Qn(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord,this.test=e.test}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(e,t)=>t==`n`?`
2
+ `:t==`r`?`\r`:t==`t`?` `:`\\`)}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord&&this.test==e.test}create(){return this.regexp?new yr(this):new gr(this)}getCursor(e,t=0,n){let r=e.doc?e:ce.create({doc:e});return n??=r.doc.length,this.regexp?V(this,r,t,n):B(this,r,t,n)}},pr=class{constructor(e){this.spec=e}};function mr(e,t,n){return(r,i,a,o)=>n&&!n(r,i,a,o)?!1:e(r>=o&&i<=o+a.length?a.slice(r-o,i-o):t.doc.sliceString(r,i),t,r,i)}function B(e,t,n,r){let i;return e.wholeWord&&(i=hr(t.doc,t.charCategorizer(t.selection.main.head))),e.test&&(i=mr(e.test,t,i)),new L(t.doc,e.unquoted,n,r,e.caseSensitive?void 0:e=>e.toLowerCase(),i)}function hr(e,t){return(n,r,i,a)=>((a>n||a+i.length<r)&&(a=Math.max(0,n-2),i=e.sliceString(a,Math.min(e.length,r+2))),(t(H(i,n-a))!=g.Word||t(U(i,n-a))!=g.Word)&&(t(U(i,r-a))!=g.Word||t(H(i,r-a))!=g.Word))}var gr=class extends pr{constructor(e){super(e)}nextMatch(e,t,n){let r=B(this.spec,e,n,e.doc.length).nextOverlapping();if(r.done){let n=Math.min(e.doc.length,t+this.spec.unquoted.length);r=B(this.spec,e,0,n).nextOverlapping()}return r.done||r.value.from==t&&r.value.to==n?null:r.value}prevMatchInRange(e,t,n){for(let r=n;;){let n=Math.max(t,r-1e4-this.spec.unquoted.length),i=B(this.spec,e,n,r),a=null;for(;!i.nextOverlapping().done;)a=i.value;if(a)return a;if(n==t)return null;r-=1e4}}prevMatch(e,t,n){let r=this.prevMatchInRange(e,0,t);return r||=this.prevMatchInRange(e,Math.max(0,n-this.spec.unquoted.length),e.doc.length),r&&(r.from!=t||r.to!=n)?r:null}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,t){let n=B(this.spec,e,0,e.doc.length),r=[];for(;!n.next().done;){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let i=B(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(n+this.spec.unquoted.length,e.doc.length));for(;!i.next().done;)r(i.value.from,i.value.to)}};function _r(e,t,n){return(r,i,a)=>(!n||n(r,i,a))&&e(a[0],t,r,i)}function V(e,t,n,r){let i;return e.wholeWord&&(i=vr(t.charCategorizer(t.selection.main.head))),e.test&&(i=_r(e.test,t,i)),new Jn(t.doc,e.search,{ignoreCase:!e.caseSensitive,test:i},n,r)}function H(e,t){return e.slice(m(e,t,!1),t)}function U(e,t){return e.slice(t,m(e,t))}function vr(e){return(t,n,r)=>!r[0].length||(e(H(r.input,r.index))!=g.Word||e(U(r.input,r.index))!=g.Word)&&(e(U(r.input,r.index+r[0].length))!=g.Word||e(H(r.input,r.index+r[0].length))!=g.Word)}var yr=class extends pr{nextMatch(e,t,n){let r=V(this.spec,e,n,e.doc.length).next();return r.done&&(r=V(this.spec,e,0,t).next()),r.done?null:r.value}prevMatchInRange(e,t,n){for(let r=1;;r++){let i=Math.max(t,n-r*1e4),a=V(this.spec,e,i,n),o=null;for(;!a.next().done;)o=a.value;if(o&&(i==t||o.from>i+10))return o;if(i==t)return null}}prevMatch(e,t,n){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,n,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(t,n)=>{if(n==`&`)return e.match[0];if(n==`$`)return`$`;for(let t=n.length;t>0;t--){let r=+n.slice(0,t);if(r>0&&r<e.match.length)return e.match[r]+n.slice(t)}return t})}matchAll(e,t){let n=V(this.spec,e,0,e.doc.length),r=[];for(;!n.next().done;){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let i=V(this.spec,e,Math.max(0,t-250),Math.min(n+250,e.doc.length));for(;!i.next().done;)r(i.value.from,i.value.to)}},W=_.define(),br=_.define(),G=oe.define({create(e){return new xr(Ar(e).create(),null)},update(e,t){for(let n of t.effects)n.is(W)?e=new xr(n.value.create(),e.panel):n.is(br)&&(e=new xr(e.query,n.value?kr:null));return e},provide:e=>Oe.from(e,e=>e.panel)}),xr=class{constructor(e,t){this.query=e,this.panel=t}},Sr=x.mark({class:`cm-searchMatch`}),Cr=x.mark({class:`cm-searchMatch cm-searchMatch-selected`}),wr=_e.fromClass(class{constructor(e){this.view=e,this.decorations=this.highlight(e.state.field(G))}update(e){let t=e.state.field(G);(t!=e.startState.field(G)||e.docChanged||e.selectionSet||e.viewportChanged)&&(this.decorations=this.highlight(t))}highlight({query:e,panel:t}){if(!t||!e.spec.valid)return x.none;let{view:n}=this,r=new ne;for(let t=0,i=n.visibleRanges,a=i.length;t<a;t++){let{from:o,to:s}=i[t];for(;t<a-1&&s>i[t+1].from-500;)s=i[++t].to;e.highlight(n.state,o,s,(e,t)=>{let i=n.state.selection.ranges.some(n=>n.from==e&&n.to==t);r.add(e,t,i?Cr:Sr)})}return r.finish()}},{decorations:e=>e.decorations});function K(e){return t=>{let n=t.state.field(G,!1);return n&&n.query.spec.valid?e(t,n):Nr(t)}}var q=K((e,{query:t})=>{let{to:n}=e.state.selection.main,r=t.nextMatch(e.state,n,n);if(!r)return!1;let i=h.single(r.from,r.to),a=e.state.facet(z);return e.dispatch({selection:i,effects:[zr(e,r),a.scrollToMatch(i.main,e)],userEvent:`select.search`}),Mr(e),!0}),J=K((e,{query:t})=>{let{state:n}=e,{from:r}=n.selection.main,i=t.prevMatch(n,r,r);if(!i)return!1;let a=h.single(i.from,i.to),o=e.state.facet(z);return e.dispatch({selection:a,effects:[zr(e,i),o.scrollToMatch(a.main,e)],userEvent:`select.search`}),Mr(e),!0}),Tr=K((e,{query:t})=>{let n=t.matchAll(e.state,1e3);return!n||!n.length?!1:(e.dispatch({selection:h.create(n.map(e=>h.range(e.from,e.to))),userEvent:`select.search.matches`}),!0)}),Er=({state:e,dispatch:t})=>{let n=e.selection;if(n.ranges.length>1||n.main.empty)return!1;let{from:r,to:i}=n.main,a=[],o=0;for(let t=new L(e.doc,e.sliceDoc(r,i));!t.next().done;){if(a.length>1e3)return!1;t.value.from==r&&(o=a.length),a.push(h.range(t.value.from,t.value.to))}return t(e.update({selection:h.create(a,o),userEvent:`select.search.matches`})),!0},Dr=K((e,{query:t})=>{let{state:n}=e,{from:r,to:i}=n.selection.main;if(n.readOnly)return!1;let a=t.nextMatch(n,r,r);if(!a)return!1;let o=a,s=[],c,l,u=[];o.from==r&&o.to==i&&(l=n.toText(t.getReplacement(o)),s.push({from:o.from,to:o.to,insert:l}),o=t.nextMatch(n,o.from,o.to),u.push(b.announce.of(n.phrase(`replaced match on line $`,n.doc.lineAt(r).number)+`.`)));let d=e.state.changes(s);return o&&(c=h.single(o.from,o.to).map(d),u.push(zr(e,o)),u.push(n.facet(z).scrollToMatch(c.main,e))),e.dispatch({changes:d,selection:c,effects:u,userEvent:`input.replace`}),!0}),Or=K((e,{query:t})=>{if(e.state.readOnly)return!1;let n=t.matchAll(e.state,1e9).map(e=>{let{from:n,to:r}=e;return{from:n,to:r,insert:t.getReplacement(e)}});if(!n.length)return!1;let r=e.state.phrase(`replaced $ matches`,n.length)+`.`;return e.dispatch({changes:n,effects:b.announce.of(r),userEvent:`input.replace.all`}),!0});function kr(e){return e.state.facet(z).createPanel(e)}function Ar(e,t){let n=e.selection.main,r=n.empty||n.to>n.from+100?``:e.sliceDoc(n.from,n.to);if(t&&!r)return t;let i=e.facet(z);return new fr({search:t?.literal??i.literal?r:r.replace(/\n/g,`\\n`),caseSensitive:t?.caseSensitive??i.caseSensitive,literal:t?.literal??i.literal,regexp:t?.regexp??i.regexp,wholeWord:t?.wholeWord??i.wholeWord})}function jr(e){let t=ve(e,kr);return t&&t.dom.querySelector(`[main-field]`)}function Mr(e){let t=jr(e);t&&t==e.root.activeElement&&t.select()}var Nr=e=>{let t=e.state.field(G,!1);if(t&&t.panel){let n=jr(e);if(n&&n!=e.root.activeElement){let r=Ar(e.state,t.query.spec);r.valid&&e.dispatch({effects:W.of(r)}),n.focus(),n.select()}}else e.dispatch({effects:[br.of(!0),t?W.of(Ar(e.state,t.query.spec)):_.appendConfig.of(Vr)]});return!0},Pr=e=>{let t=e.state.field(G,!1);if(!t||!t.panel)return!1;let n=ve(e,kr);return n&&n.dom.contains(e.root.activeElement)&&e.focus(),e.dispatch({effects:br.of(!1)}),!0},Fr=[{key:`Mod-f`,run:Nr,scope:`editor search-panel`},{key:`F3`,run:q,shift:J,scope:`editor search-panel`,preventDefault:!0},{key:`Mod-g`,run:q,shift:J,scope:`editor search-panel`,preventDefault:!0},{key:`Escape`,run:Pr,scope:`editor search-panel`},{key:`Mod-Shift-l`,run:Er},{key:`Mod-Alt-g`,run:$n},{key:`Mod-d`,run:dr,preventDefault:!0}],Ir=class{constructor(e){this.view=e;let t=this.query=e.state.field(G).query.spec;this.commit=this.commit.bind(this),this.searchField=y(`input`,{value:t.search,placeholder:Y(e,`Find`),"aria-label":Y(e,`Find`),class:`cm-textfield`,name:`search`,form:``,"main-field":`true`,onchange:this.commit,onkeyup:this.commit}),this.replaceField=y(`input`,{value:t.replace,placeholder:Y(e,`Replace`),"aria-label":Y(e,`Replace`),class:`cm-textfield`,name:`replace`,form:``,onchange:this.commit,onkeyup:this.commit}),this.caseField=y(`input`,{type:`checkbox`,name:`case`,form:``,checked:t.caseSensitive,onchange:this.commit}),this.reField=y(`input`,{type:`checkbox`,name:`re`,form:``,checked:t.regexp,onchange:this.commit}),this.wordField=y(`input`,{type:`checkbox`,name:`word`,form:``,checked:t.wholeWord,onchange:this.commit});function n(e,t,n){return y(`button`,{class:`cm-button`,name:e,onclick:t,type:`button`},n)}this.dom=y(`div`,{onkeydown:e=>this.keydown(e),class:`cm-search`},[this.searchField,n(`next`,()=>q(e),[Y(e,`next`)]),n(`prev`,()=>J(e),[Y(e,`previous`)]),n(`select`,()=>Tr(e),[Y(e,`all`)]),y(`label`,null,[this.caseField,Y(e,`match case`)]),y(`label`,null,[this.reField,Y(e,`regexp`)]),y(`label`,null,[this.wordField,Y(e,`by word`)]),...e.state.readOnly?[]:[y(`br`),this.replaceField,n(`replace`,()=>Dr(e),[Y(e,`replace`)]),n(`replaceAll`,()=>Or(e),[Y(e,`replace all`)])],y(`button`,{name:`close`,onclick:()=>Pr(e),"aria-label":Y(e,`close`),type:`button`},[`×`])])}commit(){let e=new fr({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:W.of(e)}))}keydown(e){he(this.view,e,`search-panel`)?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?J:q)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),Dr(this.view))}update(e){for(let t of e.transactions)for(let e of t.effects)e.is(W)&&!e.value.eq(this.query)&&this.setQuery(e.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(z).top}};function Y(e,t){return e.state.phrase(t)}var Lr=30,Rr=/[\s\.,:;?!]/;function zr(e,{from:t,to:n}){let r=e.state.doc.lineAt(t),i=e.state.doc.lineAt(n).to,a=Math.max(r.from,t-Lr),o=Math.min(i,n+Lr),s=e.state.sliceDoc(a,o);if(a!=r.from){for(let e=0;e<Lr;e++)if(!Rr.test(s[e+1])&&Rr.test(s[e])){s=s.slice(e);break}}if(o!=i){for(let e=s.length-1;e>s.length-Lr;e--)if(!Rr.test(s[e-1])&&Rr.test(s[e])){s=s.slice(0,e);break}}return b.announce.of(`${e.state.phrase(`current match`)}. ${s} ${e.state.phrase(`on line`)} ${r.number}.`)}var Br=b.baseTheme({".cm-panel.cm-search":{padding:`2px 6px 4px`,position:`relative`,"& [name=close]":{position:`absolute`,top:`0`,right:`4px`,backgroundColor:`inherit`,border:`none`,font:`inherit`,padding:0,margin:0},"& input, & button, & label":{margin:`.2em .6em .2em 0`},"& input[type=checkbox]":{marginRight:`.2em`},"& label":{fontSize:`80%`,whiteSpace:`pre`}},"&light .cm-searchMatch":{backgroundColor:`#ffff0054`},"&dark .cm-searchMatch":{backgroundColor:`#00ffff8a`},"&light .cm-searchMatch-selected":{backgroundColor:`#ff6a0054`},"&dark .cm-searchMatch-selected":{backgroundColor:`#ff00ff8a`}}),Vr=[G,ae.low(wr),Br],Hr=class{constructor(e,t,n){this.from=e,this.to=t,this.diagnostic=n}},X=class e{constructor(e,t,n){this.diagnostics=e,this.panel=t,this.selected=n}static init(t,n,r){let i=r.facet($).markerFilter;i&&(t=i(t,r));let a=t.slice().sort((e,t)=>e.from-t.from||e.to-t.to),o=new ne,s=[],c=0,l=r.doc.iter(),u=0,d=r.doc.length;for(let e=0;;){let t=e==a.length?null:a[e];if(!t&&!s.length)break;let n,r;if(s.length)n=c,r=s.reduce((e,t)=>Math.min(e,t.to),t&&t.from>n?t.from:1e8);else{if(n=t.from,n>d)break;r=t.to,s.push(t),e++}for(;e<a.length;){let t=a[e];if(t.from==n&&(t.to>t.from||t.to==n))s.push(t),e++,r=Math.min(t.to,r);else{r=Math.min(t.from,r);break}}r=Math.min(r,d);let i=!1;if(s.some(e=>e.from==n&&(e.to==r||r==d))&&(i=n==r,!i&&r-n<10)){let e=n-(u+l.value.length);e>0&&(l.next(e),u=n);for(let e=n;;){if(e>=r){i=!0;break}if(!l.lineBreak&&u+l.value.length>e)break;e=u+l.value.length,u+=l.value.length,l.next()}}let f=ui(s);if(i)o.add(n,n,x.widget({widget:new ri(f),diagnostics:s.slice()}));else{let e=s.reduce((e,t)=>t.markClass?e+` `+t.markClass:e,``);o.add(n,r,x.mark({class:`cm-lintRange cm-lintRange-`+f+e,diagnostics:s.slice(),inclusiveEnd:s.some(e=>e.to>r)}))}if(c=r,c==d)break;for(let e=0;e<s.length;e++)s[e].to<=c&&s.splice(e--,1)}let f=o.finish();return new e(f,n,Z(f))}};function Z(e,t=null,n=0){let r=null;return e.between(n,1e9,(e,n,{spec:i})=>{if(!(t&&i.diagnostics.indexOf(t)<0))if(!r)r=new Hr(e,n,t||i.diagnostics[0]);else if(i.diagnostics.indexOf(r.diagnostic)<0)return!1;else r=new Hr(r.from,n,r.diagnostic)}),r}function Ur(e,t){let n=t.pos,r=t.end||n,i=e.state.facet($).hideOn(e,n,r);if(i!=null)return i;let a=e.startState.doc.lineAt(t.pos);return!!(e.effects.some(e=>e.is(Gr))||e.changes.touchesRange(a.from,Math.max(a.to,r)))}function Wr(e,t){return e.field(Q,!1)?t:t.concat(_.appendConfig.of(di))}var Gr=_.define(),Kr=_.define(),qr=_.define(),Q=oe.define({create(){return new X(x.none,null,null)},update(e,t){if(t.docChanged&&e.diagnostics.size){let n=e.diagnostics.map(t.changes),r=null,i=e.panel;if(e.selected){let i=t.changes.mapPos(e.selected.from,1);r=Z(n,e.selected.diagnostic,i)||Z(n,null,i)}!n.size&&i&&t.state.facet($).autoPanel&&(i=null),e=new X(n,i,r)}for(let n of t.effects)if(n.is(Gr)){let r=t.state.facet($).autoPanel?n.value.length?ai.open:null:e.panel;e=X.init(n.value,r,t.state)}else n.is(Kr)?e=new X(e.diagnostics,n.value?ai.open:null,e.selected):n.is(qr)&&(e=new X(e.diagnostics,e.panel,n.value));return e},provide:e=>[Oe.from(e,e=>e.panel),b.decorations.from(e,e=>e.diagnostics)]}),Jr=x.mark({class:`cm-lintRange cm-lintRange-active`});function Yr(e,t,n){let{diagnostics:r}=e.state.field(Q),i,a=-1,o=-1;r.between(t-(n<0?1:0),t+(n>0?1:0),(e,r,{spec:s})=>{if(t>=e&&t<=r&&(e==r||(t>e||n>0)&&(t<r||n<0)))return i=s.diagnostics,a=e,o=r,!1});let s=e.state.facet($).tooltipFilter;return i&&s&&(i=s(i,e.state)),i?{pos:a,end:o,above:e.state.doc.lineAt(a).to<o,create(){return{dom:Xr(e,i)}}}:null}function Xr(e,t){return y(`ul`,{class:`cm-tooltip-lint`},t.map(t=>ni(e,t,!1)))}var Zr=e=>{let t=e.state.field(Q,!1);(!t||!t.panel)&&e.dispatch({effects:Wr(e.state,[Kr.of(!0)])});let n=ve(e,ai.open);return n&&n.dom.querySelector(`.cm-panel-lint ul`).focus(),!0},Qr=e=>{let t=e.state.field(Q,!1);return!t||!t.panel?!1:(e.dispatch({effects:Kr.of(!1)}),!0)},$r=[{key:`Mod-Shift-m`,run:Zr,preventDefault:!0},{key:`F8`,run:e=>{let t=e.state.field(Q,!1);if(!t)return!1;let n=e.state.selection.main,r=Z(t.diagnostics,null,n.to+1);return!r&&(r=Z(t.diagnostics,null,0),!r||r.from==n.from&&r.to==n.to)?!1:(e.dispatch({selection:{anchor:r.from,head:r.to},scrollIntoView:!0}),!0)}}],$=v.define({combine(e){return{sources:e.map(e=>e.source).filter(e=>e!=null),...pe(e.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:ei,tooltipFilter:ei,needsRefresh:(e,t)=>e?t?n=>e(n)||t(n):e:t,hideOn:(e,t)=>e?t?(n,r,i)=>e(n,r,i)||t(n,r,i):e:t,autoPanel:(e,t)=>e||t})}}});function ei(e,t){return e?t?(n,r)=>t(e(n,r),r):e:t}function ti(e){let t=[];if(e)actions:for(let{name:n}of e){for(let e=0;e<n.length;e++){let r=n[e];if(/[a-zA-Z]/.test(r)&&!t.some(e=>e.toLowerCase()==r.toLowerCase())){t.push(r);continue actions}}t.push(``)}return t}function ni(e,t,n){let r=n?ti(t.actions):[];return y(`li`,{class:`cm-diagnostic cm-diagnostic-`+t.severity},y(`span`,{class:`cm-diagnosticText`},t.renderMessage?t.renderMessage(e):t.message),t.actions?.map((n,i)=>{let a=!1,o=r=>{if(r.preventDefault(),a)return;a=!0;let i=Z(e.state.field(Q).diagnostics,t);i&&n.apply(e,i.from,i.to)},{name:s}=n,c=r[i]?s.indexOf(r[i]):-1,l=c<0?s:[s.slice(0,c),y(`u`,s.slice(c,c+1)),s.slice(c+1)];return y(`button`,{type:`button`,class:`cm-diagnosticAction`+(n.markClass?` `+n.markClass:``),onclick:o,onmousedown:o,"aria-label":` Action: ${s}${c<0?``:` (access key "${r[i]})"`}.`},l)}),t.source&&y(`div`,{class:`cm-diagnosticSource`},t.source))}var ri=class extends we{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return y(`span`,{class:`cm-lintPoint cm-lintPoint-`+this.sev})}},ii=class{constructor(e,t){this.diagnostic=t,this.id=`item_`+Math.floor(Math.random()*4294967295).toString(16),this.dom=ni(e,t,!0),this.dom.id=this.id,this.dom.setAttribute(`role`,`option`)}},ai=class e{constructor(e){this.view=e,this.items=[];let t=t=>{if(!(t.ctrlKey||t.altKey||t.metaKey)){if(t.keyCode==27)Qr(this.view),this.view.focus();else if(t.keyCode==38||t.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(t.keyCode==40||t.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(t.keyCode==36)this.moveSelection(0);else if(t.keyCode==35)this.moveSelection(this.items.length-1);else if(t.keyCode==13)this.view.focus();else if(t.keyCode>=65&&t.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:n}=this.items[this.selectedIndex],r=ti(n.actions);for(let i=0;i<r.length;i++)if(r[i].toUpperCase().charCodeAt(0)==t.keyCode){let t=Z(this.view.state.field(Q).diagnostics,n);t&&n.actions[i].apply(e,t.from,t.to)}}else return;t.preventDefault()}},n=e=>{for(let t=0;t<this.items.length;t++)this.items[t].dom.contains(e.target)&&this.moveSelection(t)};this.list=y(`ul`,{tabIndex:0,role:`listbox`,"aria-label":this.view.state.phrase(`Diagnostics`),onkeydown:t,onclick:n}),this.dom=y(`div`,{class:`cm-panel-lint`},this.list,y(`button`,{type:`button`,name:`close`,"aria-label":this.view.state.phrase(`close`),onclick:()=>Qr(this.view)},`×`)),this.update()}get selectedIndex(){let e=this.view.state.field(Q).selected;if(!e)return-1;for(let t=0;t<this.items.length;t++)if(this.items[t].diagnostic==e.diagnostic)return t;return-1}update(){let{diagnostics:e,selected:t}=this.view.state.field(Q),n=0,r=!1,i=null,a=new Set;for(e.between(0,this.view.state.doc.length,(e,o,{spec:s})=>{for(let e of s.diagnostics){if(a.has(e))continue;a.add(e);let o=-1,s;for(let t=n;t<this.items.length;t++)if(this.items[t].diagnostic==e){o=t;break}o<0?(s=new ii(this.view,e),this.items.splice(n,0,s),r=!0):(s=this.items[o],o>n&&(this.items.splice(n,o-n),r=!0)),t&&s.diagnostic==t.diagnostic?s.dom.hasAttribute(`aria-selected`)||(s.dom.setAttribute(`aria-selected`,`true`),i=s):s.dom.hasAttribute(`aria-selected`)&&s.dom.removeAttribute(`aria-selected`),n++}});n<this.items.length&&!(this.items.length==1&&this.items[0].diagnostic.from<0);)r=!0,this.items.pop();this.items.length==0&&(this.items.push(new ii(this.view,{from:-1,to:-1,severity:`info`,message:this.view.state.phrase(`No diagnostics`)})),r=!0),i?(this.list.setAttribute(`aria-activedescendant`,i.id),this.view.requestMeasure({key:this,read:()=>({sel:i.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:e,panel:t})=>{let n=t.height/this.list.offsetHeight;e.top<t.top?this.list.scrollTop-=(t.top-e.top)/n:e.bottom>t.bottom&&(this.list.scrollTop+=(e.bottom-t.bottom)/n)}})):this.selectedIndex<0&&this.list.removeAttribute(`aria-activedescendant`),r&&this.sync()}sync(){let e=this.list.firstChild;function t(){let t=e;e=t.nextSibling,t.remove()}for(let n of this.items)if(n.dom.parentNode==this.list){for(;e!=n.dom;)t();e=n.dom.nextSibling}else this.list.insertBefore(n.dom,e);for(;e;)t()}moveSelection(e){if(this.selectedIndex<0)return;let t=Z(this.view.state.field(Q).diagnostics,this.items[e].diagnostic);t&&this.view.dispatch({selection:{anchor:t.from,head:t.to},scrollIntoView:!0,effects:qr.of(t)})}static open(t){return new e(t)}};function oi(e,t=`viewBox="0 0 40 40"`){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${t}>${encodeURIComponent(e)}</svg>')`}function si(e){return oi(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${e}" fill="none" stroke-width=".7"/>`,`width="6" height="3"`)}var ci=b.baseTheme({".cm-diagnostic":{padding:`3px 6px 3px 8px`,marginLeft:`-1px`,display:`block`,whiteSpace:`pre-wrap`},".cm-diagnostic-error":{borderLeft:`5px solid #d11`},".cm-diagnostic-warning":{borderLeft:`5px solid orange`},".cm-diagnostic-info":{borderLeft:`5px solid #999`},".cm-diagnostic-hint":{borderLeft:`5px solid #66d`},".cm-diagnosticAction":{font:`inherit`,border:`none`,padding:`2px 4px`,backgroundColor:`#444`,color:`white`,borderRadius:`3px`,marginLeft:`8px`,cursor:`pointer`},".cm-diagnosticSource":{fontSize:`70%`,opacity:.7},".cm-lintRange":{backgroundPosition:`left bottom`,backgroundRepeat:`repeat-x`,paddingBottom:`0.7px`},".cm-lintRange-error":{backgroundImage:si(`#d11`)},".cm-lintRange-warning":{backgroundImage:si(`orange`)},".cm-lintRange-info":{backgroundImage:si(`#999`)},".cm-lintRange-hint":{backgroundImage:si(`#66d`)},".cm-lintRange-active":{backgroundColor:`#ffdd9980`},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:`relative`,"&:after":{content:`""`,position:`absolute`,bottom:0,left:`-2px`,borderLeft:`3px solid transparent`,borderRight:`3px solid transparent`,borderBottom:`4px solid #d11`}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:`orange`}},".cm-lintPoint-info":{"&:after":{borderBottomColor:`#999`}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:`#66d`}},".cm-panel.cm-panel-lint":{position:`relative`,"& ul":{maxHeight:`100px`,overflowY:`auto`,"& [aria-selected]":{backgroundColor:`#ddd`,"& u":{textDecoration:`underline`}},"&:focus [aria-selected]":{background_fallback:`#bdf`,backgroundColor:`Highlight`,color_fallback:`white`,color:`HighlightText`},"& u":{textDecoration:`none`},padding:0,margin:0},"& [name=close]":{position:`absolute`,top:`0`,right:`2px`,background:`inherit`,border:`none`,font:`inherit`,padding:0,margin:0}},"&dark .cm-lintRange-active":{backgroundColor:`#86714a80`},"&dark .cm-panel.cm-panel-lint ul":{"& [aria-selected]":{backgroundColor:`#2e343e`}}});function li(e){return e==`error`?4:e==`warning`?3:e==`info`?2:1}function ui(e){let t=`hint`,n=1;for(let r of e){let e=li(r.severity);e>n&&(n=e,t=r.severity)}return t}var di=[Q,b.decorations.compute([Q],e=>{let{selected:t,panel:n}=e.field(Q);return!t||!n||t.from==t.to?x.none:x.set([Jr.range(t.from,t.to)])}),ge(Yr,{hideOn:Ur}),ci],fi=[Ae(),be(),ye(),Xe(),l(),xe(),Ee(),ce.allowMultipleSelections.of(!0),t(),u(c,{fallback:!0}),s(),Pe(),Me(),ke(),Te(),Se(),nr(),De.of([...je,...Wn,...Fr,...dt,...a,...Ne,...$r])],pi=[ye(),Xe(),xe(),u(c,{fallback:!0}),De.of([...Wn,...dt])];export{b as EditorView,fi as basicSetup,pi as minimalSetup};
@@ -0,0 +1 @@
1
+ import{b as e,d as t,l as n,m as r,o as i,p as a,s as o,u as s,y as c}from"./dist-Kr-mUYW1.js";import{D as l,a as u,b as d,i as f,n as p,o as m,p as h,r as g,t as _}from"./dist-DUcac0X_.js";var ee=1024,v=0,y=class{constructor(e,t){this.from=e,this.to=t}},b=class{constructor(e={}){this.id=v++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw Error(`This node type doesn't define a deserialize function`)}),this.combine=e.combine||null}add(e){if(this.perNode)throw RangeError(`Can't add per-node props to node types`);return typeof e!=`function`&&(e=C.match(e)),t=>{let n=e(t);return n===void 0?null:[this,n]}}};b.closedBy=new b({deserialize:e=>e.split(` `)}),b.openedBy=new b({deserialize:e=>e.split(` `)}),b.group=new b({deserialize:e=>e.split(` `)}),b.isolate=new b({deserialize:e=>{if(e&&e!=`rtl`&&e!=`ltr`&&e!=`auto`)throw RangeError(`Invalid value for isolate: `+e);return e||`auto`}}),b.contextHash=new b({perNode:!0}),b.lookAhead=new b({perNode:!0}),b.mounted=new b({perNode:!0});var x=class{constructor(e,t,n,r=!1){this.tree=e,this.overlay=t,this.parser=n,this.bracketed=r}static get(e){return e&&e.props&&e.props[b.mounted.id]}},S=Object.create(null),C=class e{constructor(e,t,n,r=0){this.name=e,this.props=t,this.id=n,this.flags=r}static define(t){let n=t.props&&t.props.length?Object.create(null):S,r=(t.top?1:0)|(t.skipped?2:0)|(t.error?4:0)|(t.name==null?8:0),i=new e(t.name||``,n,t.id,r);if(t.props){for(let e of t.props)if(Array.isArray(e)||(e=e(i)),e){if(e[0].perNode)throw RangeError(`Can't store a per-node prop on a node type`);n[e[0].id]=e[1]}}return i}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e==`string`){if(this.name==e)return!0;let t=this.prop(b.group);return t?t.indexOf(e)>-1:!1}return this.id==e}static match(e){let t=Object.create(null);for(let n in e)for(let r of n.split(` `))t[r]=e[n];return e=>{for(let n=e.prop(b.group),r=-1;r<(n?n.length:0);r++){let i=t[r<0?e.name:n[r]];if(i)return i}}}};C.none=new C(``,Object.create(null),0,8);var te=class e{constructor(e){this.types=e;for(let t=0;t<e.length;t++)if(e[t].id!=t)throw RangeError(`Node type ids should correspond to array positions when creating a node set`)}extend(...t){let n=[];for(let e of this.types){let r=null;for(let n of t){let t=n(e);if(t){r||=Object.assign({},e.props);let n=t[1],i=t[0];i.combine&&i.id in r&&(n=i.combine(r[i.id],n)),r[i.id]=n}}n.push(r?new C(e.name,r,e.id,e.flags):e)}return new e(n)}},w=new WeakMap,T=new WeakMap,E;(function(e){e[e.ExcludeBuffers=1]=`ExcludeBuffers`,e[e.IncludeAnonymous=2]=`IncludeAnonymous`,e[e.IgnoreMounts=4]=`IgnoreMounts`,e[e.IgnoreOverlays=8]=`IgnoreOverlays`,e[e.EnterBracketed=16]=`EnterBracketed`})(E||={});var D=class e{constructor(e,t,n,r,i){if(this.type=e,this.children=t,this.positions=n,this.length=r,this.props=null,i&&i.length){this.props=Object.create(null);for(let[e,t]of i)this.props[typeof e==`number`?e:e.id]=t}}toString(){let e=x.get(this);if(e&&!e.overlay)return e.tree.toString();let t=``;for(let e of this.children){let n=e.toString();n&&(t&&(t+=`,`),t+=n)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(t.length?`(`+t+`)`:``):t}cursor(e=0){return new M(this.topNode,e)}cursorAt(e,t=0,n=0){let r=new M(w.get(this)||this.topNode);return r.moveTo(e,t),w.set(this,r._tree),r}get topNode(){return new A(this,0,0,null)}resolve(e,t=0){let n=k(w.get(this)||this.topNode,e,t,!1);return w.set(this,n),n}resolveInner(e,t=0){let n=k(T.get(this)||this.topNode,e,t,!0);return T.set(this,n),n}resolveStack(e,t=0){return ue(this,e,t)}iterate(e){let{enter:t,leave:n,from:r=0,to:i=this.length}=e,a=e.mode||0,o=(a&E.IncludeAnonymous)>0;for(let e=this.cursor(a|E.IncludeAnonymous);;){let a=!1;if(e.from<=i&&e.to>=r&&(!o&&e.type.isAnonymous||t(e)!==!1)){if(e.firstChild())continue;a=!0}for(;a&&n&&(o||!e.type.isAnonymous)&&n(e),!e.nextSibling();){if(!e.parent())return;a=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let t in this.props)e.push([+t,this.props[t]]);return e}balance(t={}){return this.children.length<=8?this:he(C.none,this.children,this.positions,0,this.children.length,0,this.length,(t,n,r)=>new e(this.type,t,n,r,this.propValues),t.makeTree||((t,n,r)=>new e(C.none,t,n,r)))}static build(e){return fe(e)}};D.empty=new D(C.none,[],[],0);var ne=class e{constructor(e,t){this.buffer=e,this.index=t}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new e(this.buffer,this.index)}},O=class e{constructor(e,t,n){this.buffer=e,this.length=t,this.set=n}get type(){return C.none}toString(){let e=[];for(let t=0;t<this.buffer.length;)e.push(this.childString(t)),t=this.buffer[t+3];return e.join(`,`)}childString(e){let t=this.buffer[e],n=this.buffer[e+3],r=this.set.types[t],i=r.name;if(/\W/.test(i)&&!r.isError&&(i=JSON.stringify(i)),e+=4,n==e)return i;let a=[];for(;e<n;)a.push(this.childString(e)),e=this.buffer[e+3];return i+`(`+a.join(`,`)+`)`}findChild(e,t,n,r,i){let{buffer:a}=this,o=-1;for(let s=e;s!=t&&!(re(i,r,a[s+1],a[s+2])&&(o=s,n>0));s=a[s+3]);return o}slice(t,n,r){let i=this.buffer,a=new Uint16Array(n-t),o=0;for(let e=t,s=0;e<n;){a[s++]=i[e++],a[s++]=i[e++]-r;let n=a[s++]=i[e++]-r;a[s++]=i[e++]-t,o=Math.max(o,n)}return new e(a,o,this.set)}};function re(e,t,n,r){switch(e){case-2:return n<t;case-1:return r>=t&&n<t;case 0:return n<t&&r>t;case 1:return n<=t&&r>t;case 2:return r>t;case 4:return!0}}function k(e,t,n,r){for(;e.from==e.to||(n<1?e.from>=t:e.from>t)||(n>-1?e.to<=t:e.to<t);){let t=!r&&e instanceof A&&e.index<0?null:e.parent;if(!t)return e;e=t}let i=r?0:E.IgnoreOverlays;if(r)for(let r=e,a=r.parent;a;r=a,a=r.parent)r instanceof A&&r.index<0&&a.enter(t,n,i)?.from!=r.from&&(e=a);for(;;){let r=e.enter(t,n,i);if(!r)return e;e=r}}var ie=class{cursor(e=0){return new M(this,e)}getChild(e,t=null,n=null){let r=ae(this,e,t,n);return r.length?r[0]:null}getChildren(e,t=null,n=null){return ae(this,e,t,n)}resolve(e,t=0){return k(this,e,t,!1)}resolveInner(e,t=0){return k(this,e,t,!0)}matchContext(e){return oe(this.parent,e)}enterUnfinishedNodesBefore(e){let t=this.childBefore(e),n=this;for(;t;){let e=t.lastChild;if(!e||e.to!=t.to)break;e.type.isError&&e.from==e.to?(n=t,t=e.prevSibling):t=e}return n}get node(){return this}get next(){return this.parent}},A=class e extends ie{constructor(e,t,n,r){super(),this._tree=e,this.from=t,this.index=n,this._parent=r}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(t,n,r,i,a=0){for(let o=this;;){for(let{children:s,positions:c}=o._tree,l=n>0?s.length:-1;t!=l;t+=n){let l=s[t],u=c[t]+o.from,d;if(!(!(a&E.EnterBracketed&&l instanceof D&&(d=x.get(l))&&!d.overlay&&d.bracketed&&r>=u&&r<=u+l.length)&&!re(i,r,u,u+l.length))){if(l instanceof O){if(a&E.ExcludeBuffers)continue;let e=l.findChild(0,l.buffer.length,n,r-u,i);if(e>-1)return new j(new se(o,l,t,u),null,e)}else if(a&E.IncludeAnonymous||!l.type.isAnonymous||de(l)){let s;if(!(a&E.IgnoreMounts)&&(s=x.get(l))&&!s.overlay)return new e(s.tree,u,t,o);let c=new e(l,u,t,o);return a&E.IncludeAnonymous||!c.type.isAnonymous?c:c.nextChild(n<0?l.children.length-1:0,n,r,i,a)}}}if(a&E.IncludeAnonymous||!o.type.isAnonymous||(t=o.index>=0?o.index+n:n<0?-1:o._parent._tree.children.length,o=o._parent,!o))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}prop(e){return this._tree.prop(e)}enter(t,n,r=0){let i;if(!(r&E.IgnoreOverlays)&&(i=x.get(this._tree))&&i.overlay){let a=t-this.from,o=r&E.EnterBracketed&&i.bracketed;for(let{from:t,to:r}of i.overlay)if((n>0||o?t<=a:t<a)&&(n<0||o?r>=a:r>a))return new e(i.tree,i.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,t,n,r)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}};function ae(e,t,n,r){let i=e.cursor(),a=[];if(!i.firstChild())return a;if(n!=null){for(let e=!1;!e;)if(e=i.type.is(n),!i.nextSibling())return a}for(;;){if(r!=null&&i.type.is(r))return a;if(i.type.is(t)&&a.push(i.node),!i.nextSibling())return r==null?a:[]}}function oe(e,t,n=t.length-1){for(let r=e;n>=0;r=r.parent){if(!r)return!1;if(!r.type.isAnonymous){if(t[n]&&t[n]!=r.name)return!1;n--}}return!0}var se=class{constructor(e,t,n,r){this.parent=e,this.buffer=t,this.index=n,this.start=r}},j=class e extends ie{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,t,n){super(),this.context=e,this._parent=t,this.index=n,this.type=e.buffer.set.types[e.buffer.buffer[n]]}child(t,n,r){let{buffer:i}=this.context,a=i.findChild(this.index+4,i.buffer[this.index+3],t,n-this.context.start,r);return a<0?null:new e(this.context,this,a)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}prop(e){return this.type.prop(e)}enter(t,n,r=0){if(r&E.ExcludeBuffers)return null;let{buffer:i}=this.context,a=i.findChild(this.index+4,i.buffer[this.index+3],n>0?1:-1,t-this.context.start,n);return a<0?null:new e(this.context,this,a)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:t}=this.context,n=t.buffer[this.index+3];return n<(this._parent?t.buffer[this._parent.index+3]:t.buffer.length)?new e(this.context,this._parent,n):this.externalSibling(1)}get prevSibling(){let{buffer:t}=this.context,n=this._parent?this._parent.index+4:0;return this.index==n?this.externalSibling(-1):new e(this.context,this._parent,t.findChild(n,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:n}=this.context,r=this.index+4,i=n.buffer[this.index+3];if(i>r){let a=n.buffer[this.index+1];e.push(n.slice(r,i,a)),t.push(0)}return new D(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}};function ce(e){if(!e.length)return null;let t=0,n=e[0];for(let r=1;r<e.length;r++){let i=e[r];(i.from>n.from||i.to<n.to)&&(n=i,t=r)}let r=n instanceof A&&n.index<0?null:n.parent,i=e.slice();return r?i[t]=r:i.splice(t,1),new le(i,n)}var le=class{constructor(e,t){this.heads=e,this.node=t}get next(){return ce(this.heads)}};function ue(e,t,n){let r=e.resolveInner(t,n),i=null;for(let e=r instanceof A?r:r.context.parent;e;e=e.parent)if(e.index<0){let a=e.parent;(i||=[r]).push(a.resolve(t,n)),e=a}else{let a=x.get(e.tree);if(a&&a.overlay&&a.overlay[0].from<=t&&a.overlay[a.overlay.length-1].to>=t){let o=new A(a.tree,a.overlay[0].from+e.from,-1,e);(i||=[r]).push(k(o,t,n,!1))}}return i?ce(i):r}var M=class{get name(){return this.type.name}constructor(e,t=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=t&~E.EnterBracketed,e instanceof A)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let t=e._parent;t;t=t._parent)this.stack.unshift(t.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,t){this.index=e;let{start:n,buffer:r}=this.buffer;return this.type=t||r.set.types[r.buffer[e]],this.from=n+r.buffer[e+1],this.to=n+r.buffer[e+2],!0}yield(e){return e?e instanceof A?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,n){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,n,this.mode));let{buffer:r}=this.buffer,i=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.buffer.start,n);return i<0?!1:(this.stack.push(this.index),this.yieldBuf(i))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,t,n=this.mode){return this.buffer?n&E.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,n))}parent(){if(!this.buffer)return this.yieldNode(this.mode&E.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&E.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode)):!1;let{buffer:t}=this.buffer,n=this.stack.length-1;if(e<0){let e=n<0?0:this.stack[n]+4;if(this.index!=e)return this.yieldBuf(t.findChild(e,this.index,-1,0,4))}else{let e=t.buffer[this.index+3];if(e<(n<0?t.buffer.length:t.buffer[this.stack[n]+3]))return this.yieldBuf(e)}return n<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,n,{buffer:r}=this;if(r){if(e>0){if(this.index<r.buffer.buffer.length)return!1}else for(let e=0;e<this.index;e++)if(r.buffer.buffer[e+3]<this.index)return!1;({index:t,parent:n}=r)}else ({index:t,_parent:n}=this._tree);for(;n;{index:t,_parent:n}=n)if(t>-1)for(let r=t+e,i=e<0?-1:n._tree.children.length;r!=i;r+=e){let e=n._tree.children[r];if(this.mode&E.IncludeAnonymous||e instanceof O||!e.type.isAnonymous||de(e))return!1}return!0}move(e,t){if(t&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,t=0){for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to<e))&&this.parent(););for(;this.enterChild(1,e,t););return this}get node(){if(!this.buffer)return this._tree;let e=this.bufferNode,t=null,n=0;if(e&&e.context==this.buffer)scan:for(let r=this.index,i=this.stack.length;i>=0;){for(let a=e;a;a=a._parent)if(a.index==r){if(r==this.index)return a;t=a,n=i+1;break scan}r=this.stack[--i]}for(let e=n;e<this.stack.length;e++)t=new j(this.buffer,t,this.stack[e]);return this.bufferNode=new j(this.buffer,t,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,t){for(let n=0;;){let r=!1;if(this.type.isAnonymous||e(this)!==!1){if(this.firstChild()){n++;continue}this.type.isAnonymous||(r=!0)}for(;;){if(r&&t&&t(this),r=this.type.isAnonymous,!n)return;if(this.nextSibling())break;this.parent(),n--,r=!0}}}matchContext(e){if(!this.buffer)return oe(this.node.parent,e);let{buffer:t}=this.buffer,{types:n}=t.set;for(let r=e.length-1,i=this.stack.length-1;r>=0;i--){if(i<0)return oe(this._tree,e,r);let a=n[t.buffer[this.stack[i]]];if(!a.isAnonymous){if(e[r]&&e[r]!=a.name)return!1;r--}}return!0}};function de(e){return e.children.some(e=>e instanceof O||!e.type.isAnonymous||de(e))}function fe(e){let{buffer:t,nodeSet:n,maxBufferLength:r=ee,reused:i=[],minRepeatType:a=n.types.length}=e,o=Array.isArray(t)?new ne(t,t.length):t,s=n.types,c=0,l=0;function u(e,t,_,ee,v,y){let{id:b,start:x,end:S,size:C}=o,te=l,w=c;if(C<0)if(o.next(),C==-1){let t=i[b];_.push(t),ee.push(x-e);return}else if(C==-3){c=b;return}else if(C==-4){l=b;return}else throw RangeError(`Unrecognized record size: ${C}`);let T=s[b],E,D,ne=x-e;if(S-x<=r&&(D=h(o.pos-t,v))){let t=new Uint16Array(D.size-D.skip),r=o.pos-D.size,i=t.length;for(;o.pos>r;)i=g(D.start,t,i);E=new O(t,S-D.start,n),ne=D.start-e}else{let e=o.pos-C;o.next();let t=[],n=[],i=b>=a?b:-1,s=0,c=S;for(;o.pos>e;)i>=0&&o.id==i&&o.size>=0?(o.end<=c-r&&(p(t,n,x,s,o.end,c,i,te,w),s=t.length,c=o.end),o.next()):y>2500?d(x,e,t,n):u(x,e,t,n,i,y+1);if(i>=0&&s>0&&s<t.length&&p(t,n,x,s,x,c,i,te,w),t.reverse(),n.reverse(),i>-1&&s>0){let e=f(T,w);E=he(T,t,n,0,t.length,0,S-x,e,e)}else E=m(T,t,n,S-x,te-S,w)}_.push(E),ee.push(ne)}function d(e,t,i,a){let s=[],c=0,l=-1;for(;o.pos>t;){let{id:e,start:t,end:n,size:i}=o;if(i>4)o.next();else if(l>-1&&t<l)break;else l<0&&(l=n-r),s.push(e,t,n),c++,o.next()}if(c){let t=new Uint16Array(c*4),r=s[s.length-2];for(let e=s.length-3,n=0;e>=0;e-=3)t[n++]=s[e],t[n++]=s[e+1]-r,t[n++]=s[e+2]-r,t[n++]=n;i.push(new O(t,s[2]-r,n)),a.push(r-e)}}function f(e,t){return(n,r,i)=>{let a=0,o=n.length-1,s,c;if(o>=0&&(s=n[o])instanceof D){if(!o&&s.type==e&&s.length==i)return s;(c=s.prop(b.lookAhead))&&(a=r[o]+s.length+c)}return m(e,n,r,i,a,t)}}function p(e,t,r,i,a,o,s,c,l){let u=[],d=[];for(;e.length>i;)u.push(e.pop()),d.push(t.pop()+r-a);e.push(m(n.types[s],u,d,o-a,c-o,l)),t.push(a-r)}function m(e,t,n,r,i,a,o){if(a){let e=[b.contextHash,a];o=o?[e].concat(o):[e]}if(i>25){let e=[b.lookAhead,i];o=o?[e].concat(o):[e]}return new D(e,t,n,r,o)}function h(e,t){let n=o.fork(),i=0,s=0,c=0,l=n.end-r,u={size:0,start:0,skip:0};scan:for(let r=n.pos-e;n.pos>r;){let e=n.size;if(n.id==t&&e>=0){u.size=i,u.start=s,u.skip=c,c+=4,i+=4,n.next();continue}let o=n.pos-e;if(e<0||o<r||n.start<l)break;let d=n.id>=a?4:0,f=n.start;for(n.next();n.pos>o;){if(n.size<0)if(n.size==-3||n.size==-4)d+=4;else break scan;else n.id>=a&&(d+=4);n.next()}s=f,i+=e,c+=d}return(t<0||i==e)&&(u.size=i,u.start=s,u.skip=c),u.size>4?u:void 0}function g(e,t,n){let{id:r,start:i,end:s,size:u}=o;if(o.next(),u>=0&&r<a){let a=n;if(u>4){let r=o.pos-(u-4);for(;o.pos>r;)n=g(e,t,n)}t[--n]=a,t[--n]=s-e,t[--n]=i-e,t[--n]=r}else u==-3?c=r:u==-4&&(l=r);return n}let _=[],v=[];for(;o.pos>0;)u(e.start||0,e.bufferStart||0,_,v,-1,0);let y=e.length??(_.length?v[0]+_[0].length:0);return new D(s[e.topID],_.reverse(),v.reverse(),y)}var pe=new WeakMap;function me(e,t){if(!e.isAnonymous||t instanceof O||t.type!=e)return 1;let n=pe.get(t);if(n==null){n=1;for(let r of t.children){if(r.type!=e||!(r instanceof D)){n=1;break}n+=me(e,r)}pe.set(t,n)}return n}function he(e,t,n,r,i,a,o,s,c){let l=0;for(let n=r;n<i;n++)l+=me(e,t[n]);let u=Math.ceil(l*1.5/8),d=[],f=[];function p(t,n,r,i,o){for(let s=r;s<i;){let r=s,l=n[s],m=me(e,t[s]);for(s++;s<i;s++){let n=me(e,t[s]);if(m+n>=u)break;m+=n}if(s==r+1){if(m>u){let e=t[r];p(e.children,e.positions,0,e.children.length,n[r]+o);continue}d.push(t[r])}else{let i=n[s-1]+t[s-1].length-l;d.push(he(e,t,n,r,s,l,i,null,c))}f.push(l+o-a)}}return p(t,n,r,i,0),(s||c)(d,f,o)}var ge=class{constructor(){this.map=new WeakMap}setBuffer(e,t,n){let r=this.map.get(e);r||this.map.set(e,r=new Map),r.set(t,n)}getBuffer(e,t){let n=this.map.get(e);return n&&n.get(t)}set(e,t){e instanceof j?this.setBuffer(e.context.buffer,e.index,t):e instanceof A&&this.map.set(e.tree,t)}get(e){return e instanceof j?this.getBuffer(e.context.buffer,e.index):e instanceof A?this.map.get(e.tree):void 0}cursorSet(e,t){e.buffer?this.setBuffer(e.buffer.buffer,e.index,t):this.map.set(e.tree,t)}cursorGet(e){return e.buffer?this.getBuffer(e.buffer.buffer,e.index):this.map.get(e.tree)}},N=class e{constructor(e,t,n,r,i=!1,a=!1){this.from=e,this.to=t,this.tree=n,this.offset=r,this.open=(i?1:0)|(a?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(t,n=[],r=!1){let i=[new e(0,t.length,t,0,!1,r)];for(let e of n)e.to>t.length&&i.push(e);return i}static applyChanges(t,n,r=128){if(!n.length)return t;let i=[],a=1,o=t.length?t[0]:null;for(let s=0,c=0,l=0;;s++){let u=s<n.length?n[s]:null,d=u?u.fromA:1e9;if(d-c>=r)for(;o&&o.from<d;){let n=o;if(c>=n.from||d<=n.to||l){let t=Math.max(n.from,c)-l,r=Math.min(n.to,d)-l;n=t>=r?null:new e(t,r,n.tree,n.offset+l,s>0,!!u)}if(n&&i.push(n),o.to>d)break;o=a<t.length?t[a++]:null}if(!u)break;c=u.toA,l=u.toA-u.toB}return i}},_e=class{startParse(e,t,n){return typeof e==`string`&&(e=new ve(e)),n=n?n.length?n.map(e=>new y(e.from,e.to)):[new y(0,0)]:[new y(0,e.length)],this.createParse(e,t||[],n)}parse(e,t,n){let r=this.startParse(e,t,n);for(;;){let e=r.advance();if(e)return e}}},ve=class{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}};function ye(e){return(t,n,r,i)=>new we(t,e,n,r,i)}var be=class{constructor(e,t,n,r,i,a){this.parser=e,this.parse=t,this.overlay=n,this.bracketed=r,this.target=i,this.from=a}};function xe(e){if(!e.length||e.some(e=>e.from>=e.to))throw RangeError(`Invalid inner parse ranges given: `+JSON.stringify(e))}var Se=class{constructor(e,t,n,r,i,a,o,s){this.parser=e,this.predicate=t,this.mounts=n,this.index=r,this.start=i,this.bracketed=a,this.target=o,this.prev=s,this.depth=0,this.ranges=[]}},Ce=new b({perNode:!0}),we=class{constructor(e,t,n,r,i){this.nest=t,this.input=n,this.fragments=r,this.ranges=i,this.inner=[],this.innerDone=0,this.baseTree=null,this.stoppedAt=null,this.baseParse=e}advance(){if(this.baseParse){let e=this.baseParse.advance();if(!e)return null;if(this.baseParse=null,this.baseTree=e,this.startInner(),this.stoppedAt!=null)for(let e of this.inner)e.parse.stopAt(this.stoppedAt)}if(this.innerDone==this.inner.length){let e=this.baseTree;return this.stoppedAt!=null&&(e=new D(e.type,e.children,e.positions,e.length,e.propValues.concat([[Ce,this.stoppedAt]]))),e}let e=this.inner[this.innerDone],t=e.parse.advance();if(t){this.innerDone++;let n=Object.assign(Object.create(null),e.target.props);n[b.mounted.id]=new x(t,e.overlay,e.parser,e.bracketed),e.target.props=n}return null}get parsedPos(){if(this.baseParse)return 0;let e=this.input.length;for(let t=this.innerDone;t<this.inner.length;t++)this.inner[t].from<e&&(e=Math.min(e,this.inner[t].parse.parsedPos));return e}stopAt(e){if(this.stoppedAt=e,this.baseParse)this.baseParse.stopAt(e);else for(let t=this.innerDone;t<this.inner.length;t++)this.inner[t].parse.stopAt(e)}startInner(){let e=new ke(this.fragments),t=null,n=null,r=new M(new A(this.baseTree,this.ranges[0].from,0,null),E.IncludeAnonymous|E.IgnoreMounts);scan:for(let i,a;;){let o=!0,s;if(this.stoppedAt!=null&&r.from>=this.stoppedAt)o=!1;else if(e.hasNode(r)){if(t){let e=t.mounts.find(e=>e.frag.from<=r.from&&e.frag.to>=r.to&&e.mount.overlay);if(e)for(let n of e.mount.overlay){let i=n.from+e.pos,a=n.to+e.pos;i>=r.from&&a<=r.to&&!t.ranges.some(e=>e.from<a&&e.to>i)&&t.ranges.push({from:i,to:a})}}o=!1}else if(n&&(a=Te(n.ranges,r.from,r.to)))o=a!=2;else if(!r.type.isAnonymous&&(i=this.nest(r,this.input))&&(r.from<r.to||!i.overlay)){r.tree||(De(r),t&&t.depth++,n&&n.depth++);let a=e.findMounts(r.from,i.parser);if(typeof i.overlay==`function`)t=new Se(i.parser,i.overlay,a,this.inner.length,r.from,!!i.bracketed,r.tree,t);else{let e=Ae(this.ranges,i.overlay||(r.from<r.to?[new y(r.from,r.to)]:[]));e.length&&xe(e),(e.length||!i.overlay)&&this.inner.push(new be(i.parser,e.length?i.parser.startParse(this.input,Me(a,e),e):i.parser.startParse(``),i.overlay?i.overlay.map(e=>new y(e.from-r.from,e.to-r.from)):null,!!i.bracketed,r.tree,e.length?e[0].from:r.from)),i.overlay?e.length&&(n={ranges:e,depth:0,prev:n}):o=!1}}else if(t&&(s=t.predicate(r))&&(s===!0&&(s=new y(r.from,r.to)),s.from<s.to)){let e=t.ranges.length-1;e>=0&&t.ranges[e].to==s.from?t.ranges[e]={from:t.ranges[e].from,to:s.to}:t.ranges.push(s)}if(o&&r.firstChild())t&&t.depth++,n&&n.depth++;else for(;!r.nextSibling();){if(!r.parent())break scan;if(t&&!--t.depth){let e=Ae(this.ranges,t.ranges);e.length&&(xe(e),this.inner.splice(t.index,0,new be(t.parser,t.parser.startParse(this.input,Me(t.mounts,e),e),t.ranges.map(e=>new y(e.from-t.start,e.to-t.start)),t.bracketed,t.target,e[0].from))),t=t.prev}n&&!--n.depth&&(n=n.prev)}}}};function Te(e,t,n){for(let r of e){if(r.from>=n)break;if(r.to>t)return r.from<=t&&r.to>=n?2:1}return 0}function Ee(e,t,n,r,i,a){if(t<n){let o=e.buffer[t+1];r.push(e.slice(t,n,o)),i.push(o-a)}}function De(e){let{node:t}=e,n=[],r=t.context.buffer;do n.push(e.index),e.parent();while(!e.tree);let i=e.tree,a=i.children.indexOf(r),o=i.children[a],s=o.buffer,c=[a];function l(e,r,i,a,u,d){let f=n[d],p=[],m=[];Ee(o,e,f,p,m,a);let h=s[f+1],g=s[f+2];c.push(p.length);let _=d?l(f+4,s[f+3],o.set.types[s[f]],h,g-h,d-1):t.toTree();return p.push(_),m.push(h-a),Ee(o,s[f+3],r,p,m,a),new D(i,p,m,u)}i.children[a]=l(0,s.length,C.none,0,o.length,n.length-1);for(let t of c){let n=e.tree.children[t],r=e.tree.positions[t];e.yield(new A(n,r+e.from,t,e._tree))}}var Oe=class{constructor(e,t){this.offset=t,this.done=!1,this.cursor=e.cursor(E.IncludeAnonymous|E.IgnoreMounts)}moveTo(e){let{cursor:t}=this,n=e-this.offset;for(;!this.done&&t.from<n;)t.to>=e&&t.enter(n,1,E.IgnoreOverlays|E.ExcludeBuffers)||t.next(!1)||(this.done=!0)}hasNode(e){if(this.moveTo(e.from),!this.done&&this.cursor.from+this.offset==e.from&&this.cursor.tree)for(let t=this.cursor.tree;;){if(t==e.tree)return!0;if(t.children.length&&t.positions[0]==0&&t.children[0]instanceof D)t=t.children[0];else break}return!1}},ke=class{constructor(e){if(this.fragments=e,this.curTo=0,this.fragI=0,e.length){let t=this.curFrag=e[0];this.curTo=t.tree.prop(Ce)??t.to,this.inner=new Oe(t.tree,-t.offset)}else this.curFrag=this.inner=null}hasNode(e){for(;this.curFrag&&e.from>=this.curTo;)this.nextFrag();return this.curFrag&&this.curFrag.from<=e.from&&this.curTo>=e.to&&this.inner.hasNode(e)}nextFrag(){if(this.fragI++,this.fragI==this.fragments.length)this.curFrag=this.inner=null;else{let e=this.curFrag=this.fragments[this.fragI];this.curTo=e.tree.prop(Ce)??e.to,this.inner=new Oe(e.tree,-e.offset)}}findMounts(e,t){let n=[];if(this.inner){this.inner.cursor.moveTo(e,1);for(let e=this.inner.cursor.node;e;e=e.parent){let r=e.tree?.prop(b.mounted);if(r&&r.parser==t)for(let t=this.fragI;t<this.fragments.length;t++){let i=this.fragments[t];if(i.from>=e.to)break;i.tree==this.curFrag.tree&&n.push({frag:i,pos:e.from-i.offset,mount:r})}}}return n}};function Ae(e,t){let n=null,r=t;for(let i=1,a=0;i<e.length;i++){let o=e[i-1].to,s=e[i].from;for(;a<r.length;a++){let e=r[a];if(e.from>=s)break;e.to<=o||(n||(r=n=t.slice()),e.from<o?(n[a]=new y(e.from,o),e.to>s&&n.splice(a+1,0,new y(s,e.to))):e.to>s?n[a--]=new y(s,e.to):n.splice(a--,1))}}return r}function je(e,t,n,r){let i=0,a=0,o=!1,s=!1,c=-1e9,l=[];for(;;){let u=i==e.length?1e9:o?e[i].to:e[i].from,d=a==t.length?1e9:s?t[a].to:t[a].from;if(o!=s){let e=Math.max(c,n),t=Math.min(u,d,r);e<t&&l.push(new y(e,t))}if(c=Math.min(u,d),c==1e9)break;u==c&&(o?(o=!1,i++):o=!0),d==c&&(s?(s=!1,a++):s=!0)}return l}function Me(e,t){let n=[];for(let{pos:r,mount:i,frag:a}of e){let e=r+(i.overlay?i.overlay[0].from:0),o=e+i.tree.length,s=Math.max(a.from,e),c=Math.min(a.to,o);if(i.overlay){let o=je(t,i.overlay.map(e=>new y(e.from+r,e.to+r)),s,c);for(let t=0,r=s;;t++){let s=t==o.length,l=s?c:o[t].from;if(l>r&&n.push(new N(r,l,i.tree,-e,a.from>=r||a.openStart,a.to<=l||a.openEnd)),s)break;r=o[t].to}}else n.push(new N(s,c,i.tree,-e,a.from>=e||a.openStart,a.to<=o||a.openEnd))}return n}var Ne=0,P=class e{constructor(e,t,n,r){this.name=e,this.set=t,this.base=n,this.modified=r,this.id=Ne++}toString(){let{name:e}=this;for(let t of this.modified)t.name&&(e=`${t.name}(${e})`);return e}static define(t,n){let r=typeof t==`string`?t:`?`;if(t instanceof e&&(n=t),n?.base)throw Error(`Can not derive from a modified tag`);let i=new e(r,[],null,[]);if(i.set.push(i),n)for(let e of n.set)i.set.push(e);return i}static defineModifier(e){let t=new Fe(e);return e=>e.modified.indexOf(t)>-1?e:Fe.get(e.base||e,e.modified.concat(t).sort((e,t)=>e.id-t.id))}},Pe=0,Fe=class e{constructor(e){this.name=e,this.instances=[],this.id=Pe++}static get(t,n){if(!n.length)return t;let r=n[0].instances.find(e=>e.base==t&&Ie(n,e.modified));if(r)return r;let i=[],a=new P(t.name,i,t,n);for(let e of n)e.instances.push(a);let o=Le(n);for(let n of t.set)if(!n.modified.length)for(let t of o)i.push(e.get(n,t));return a}};function Ie(e,t){return e.length==t.length&&e.every((e,n)=>e==t[n])}function Le(e){let t=[[]];for(let n=0;n<e.length;n++)for(let r=0,i=t.length;r<i;r++)t.push(t[r].concat(e[n]));return t.sort((e,t)=>t.length-e.length)}function Re(e){let t=Object.create(null);for(let n in e){let r=e[n];Array.isArray(r)||(r=[r]);for(let e of n.split(` `))if(e){let n=[],i=2,a=e;for(let t=0;;){if(a==`...`&&t>0&&t+3==e.length){i=1;break}let r=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(a);if(!r)throw RangeError(`Invalid path: `+e);if(n.push(r[0]==`*`?``:r[0][0]==`"`?JSON.parse(r[0]):r[0]),t+=r[0].length,t==e.length)break;let o=e[t++];if(t==e.length&&o==`!`){i=0;break}if(o!=`/`)throw RangeError(`Invalid path: `+e);a=e.slice(t)}let o=n.length-1,s=n[o];if(!s)throw RangeError(`Invalid path: `+e);t[s]=new F(r,i,o>0?n.slice(0,o):null).sort(t[s])}}return ze.add(t)}var ze=new b({combine(e,t){let n,r,i;for(;e||t;){if(!e||t&&e.depth>=t.depth?(i=t,t=t.next):(i=e,e=e.next),n&&n.mode==i.mode&&!i.context&&!n.context)continue;let a=new F(i.tags,i.mode,i.context);n?n.next=a:r=a,n=a}return r}}),F=class{constructor(e,t,n,r){this.tags=e,this.mode=t,this.context=n,this.next=r}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth<this.depth?(this.next=e,this):(e.next=this.sort(e.next),e)}get depth(){return this.context?this.context.length:0}};F.empty=new F([],2,null);function Be(e,t){let n=Object.create(null);for(let t of e)if(!Array.isArray(t.tag))n[t.tag.id]=t.class;else for(let e of t.tag)n[e.id]=t.class;let{scope:r,all:i=null}=t||{};return{style:e=>{let t=i;for(let r of e)for(let e of r.set){let r=n[e.id];if(r){t=t?t+` `+r:r;break}}return t},scope:r}}function Ve(e,t){let n=null;for(let r of e){let e=r.style(t);e&&(n=n?n+` `+e:e)}return n}function He(e,t,n,r=0,i=e.length){let a=new Ue(r,Array.isArray(t)?t:[t],n);a.highlightRange(e.cursor(),r,i,``,a.highlighters),a.flush(i)}var Ue=class{constructor(e,t,n){this.at=e,this.highlighters=t,this.span=n,this.class=``}startSpan(e,t){t!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=t)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,t,n,r,i){let{type:a,from:o,to:s}=e;if(o>=n||s<=t)return;a.isTop&&(i=this.highlighters.filter(e=>!e.scope||e.scope(a)));let c=r,l=We(e)||F.empty,u=Ve(i,l.tags);if(u&&(c&&(c+=` `),c+=u,l.mode==1&&(r+=(r?` `:``)+u)),this.startSpan(Math.max(t,o),c),l.opaque)return;let d=e.tree&&e.tree.prop(b.mounted);if(d&&d.overlay){let a=e.node.enter(d.overlay[0].from+o,1),l=this.highlighters.filter(e=>!e.scope||e.scope(d.tree.type)),u=e.firstChild();for(let f=0,p=o;;f++){let m=f<d.overlay.length?d.overlay[f]:null,h=m?m.from+o:s,g=Math.max(t,p),_=Math.min(n,h);if(g<_&&u)for(;e.from<_&&(this.highlightRange(e,g,_,r,i),this.startSpan(Math.min(_,e.to),c),!(e.to>=h||!e.nextSibling())););if(!m||h>n)break;p=m.to+o,p>t&&(this.highlightRange(a.cursor(),Math.max(t,m.from+o),Math.min(n,p),``,l),this.startSpan(Math.min(n,p),c))}u&&e.parent()}else if(e.firstChild()){d&&(r=``);do{if(e.to<=t)continue;if(e.from>=n)break;this.highlightRange(e,t,n,r,i),this.startSpan(Math.min(n,e.to),c)}while(e.nextSibling());e.parent()}}};function We(e){let t=e.type.prop(ze);for(;t&&t.context&&!e.matchContext(t.context);)t=t.next;return t||null}var I=P.define,L=I(),R=I(),Ge=I(R),Ke=I(R),z=I(),qe=I(z),Je=I(z),B=I(),V=I(B),H=I(),U=I(),Ye=I(),W=I(Ye),Xe=I(),G={comment:L,lineComment:I(L),blockComment:I(L),docComment:I(L),name:R,variableName:I(R),typeName:Ge,tagName:I(Ge),propertyName:Ke,attributeName:I(Ke),className:I(R),labelName:I(R),namespace:I(R),macroName:I(R),literal:z,string:qe,docString:I(qe),character:I(qe),attributeValue:I(qe),number:Je,integer:I(Je),float:I(Je),bool:I(z),regexp:I(z),escape:I(z),color:I(z),url:I(z),keyword:H,self:I(H),null:I(H),atom:I(H),unit:I(H),modifier:I(H),operatorKeyword:I(H),controlKeyword:I(H),definitionKeyword:I(H),moduleKeyword:I(H),operator:U,derefOperator:I(U),arithmeticOperator:I(U),logicOperator:I(U),bitwiseOperator:I(U),compareOperator:I(U),updateOperator:I(U),definitionOperator:I(U),typeOperator:I(U),controlOperator:I(U),punctuation:Ye,separator:I(Ye),bracket:W,angleBracket:I(W),squareBracket:I(W),paren:I(W),brace:I(W),content:B,heading:V,heading1:I(V),heading2:I(V),heading3:I(V),heading4:I(V),heading5:I(V),heading6:I(V),contentSeparator:I(B),list:I(B),quote:I(B),emphasis:I(B),strong:I(B),link:I(B),monospace:I(B),strikethrough:I(B),inserted:I(),deleted:I(),changed:I(),invalid:I(),meta:Xe,documentMeta:I(Xe),annotation:I(Xe),processingInstruction:I(Xe),definition:P.defineModifier(`definition`),constant:P.defineModifier(`constant`),function:P.defineModifier(`function`),standard:P.defineModifier(`standard`),local:P.defineModifier(`local`),special:P.defineModifier(`special`)};for(let e in G){let t=G[e];t instanceof P&&(t.name=e)}Be([{tag:G.link,class:`tok-link`},{tag:G.heading,class:`tok-heading`},{tag:G.emphasis,class:`tok-emphasis`},{tag:G.strong,class:`tok-strong`},{tag:G.keyword,class:`tok-keyword`},{tag:G.atom,class:`tok-atom`},{tag:G.bool,class:`tok-bool`},{tag:G.url,class:`tok-url`},{tag:G.labelName,class:`tok-labelName`},{tag:G.inserted,class:`tok-inserted`},{tag:G.deleted,class:`tok-deleted`},{tag:G.literal,class:`tok-literal`},{tag:G.string,class:`tok-string`},{tag:G.number,class:`tok-number`},{tag:[G.regexp,G.escape,G.special(G.string)],class:`tok-string2`},{tag:G.variableName,class:`tok-variableName`},{tag:G.local(G.variableName),class:`tok-variableName tok-local`},{tag:G.definition(G.variableName),class:`tok-variableName tok-definition`},{tag:G.special(G.variableName),class:`tok-variableName2`},{tag:G.definition(G.propertyName),class:`tok-propertyName tok-definition`},{tag:G.typeName,class:`tok-typeName`},{tag:G.namespace,class:`tok-namespace`},{tag:G.className,class:`tok-className`},{tag:G.macroName,class:`tok-macroName`},{tag:G.propertyName,class:`tok-propertyName`},{tag:G.operator,class:`tok-operator`},{tag:G.comment,class:`tok-comment`},{tag:G.meta,class:`tok-meta`},{tag:G.invalid,class:`tok-invalid`},{tag:G.punctuation,class:`tok-punctuation`}]);var K=new b;function Ze(e){return o.define({combine:e?t=>t.concat(e):void 0})}var Qe=new b,q=class{constructor(e,t,n=[],r=``){this.data=e,this.name=r,i.prototype.hasOwnProperty(`tree`)||Object.defineProperty(i.prototype,`tree`,{get(){return J(this)}}),this.parser=t,this.extension=[X.of(this),i.languageData.of((e,t,n)=>{let r=$e(e,t,n),i=r.type.prop(K);if(!i)return[];let a=e.facet(i),o=r.type.prop(Qe);if(o){let i=r.resolve(t-r.from,n);for(let t of o)if(t.test(i,e)){let n=e.facet(t.facet);return t.type==`replace`?n:n.concat(a)}}return a})].concat(n)}isActiveAt(e,t,n=-1){return $e(e,t,n).type.prop(K)==this.data}findRegions(e){let t=e.facet(X);if(t?.data==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let n=[],r=(e,t)=>{if(e.prop(K)==this.data){n.push({from:t,to:t+e.length});return}let i=e.prop(b.mounted);if(i){if(i.tree.prop(K)==this.data){if(i.overlay)for(let e of i.overlay)n.push({from:e.from+t,to:e.to+t});else n.push({from:t,to:t+e.length});return}else if(i.overlay){let e=n.length;if(r(i.tree,i.overlay[0].from+t),n.length>e)return}}for(let n=0;n<e.children.length;n++){let i=e.children[n];i instanceof D&&r(i,e.positions[n]+t)}};return r(J(e),0),n}get allowsNesting(){return!0}};q.setState=a.define();function $e(e,t,n){let r=e.facet(X),i=J(e).topNode;if(!r||r.allowsNesting)for(let e=i;e;e=e.enter(t,n,E.ExcludeBuffers|E.EnterBracketed))e.type.isTop&&(i=e);return i}var et=class e extends q{constructor(e,t,n){super(e,t,[],n),this.parser=t}static define(t){let n=Ze(t.languageData);return new e(n,t.parser.configure({props:[K.add(e=>e.isTop?n:void 0)]}),t.name)}configure(t,n){return new e(this.data,this.parser.configure(t),n||this.name)}get allowsNesting(){return this.parser.hasWrappers()}};function J(e){let t=e.field(q.state,!1);return t?t.tree:D.empty}var tt=class{constructor(e){this.doc=e,this.cursorPos=0,this.string=``,this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,t){let n=this.cursorPos-this.string.length;return e<n||t>=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-n,t-n)}},Y=null,nt=class e{constructor(e,t,n=[],r,i,a,o,s){this.parser=e,this.state=t,this.fragments=n,this.tree=r,this.treeLen=i,this.viewport=a,this.skipped=o,this.scheduleOn=s,this.parse=null,this.tempSkipped=[]}static create(t,n,r){return new e(t,n,[],D.empty,0,r,[],null)}startParse(){return this.parser.startParse(new tt(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=D.empty&&this.isDone(t??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{if(typeof e==`number`){let t=Date.now()+e;e=()=>Date.now()>t}for(this.parse||=this.startParse(),t!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&t<this.state.doc.length&&this.parse.stopAt(t);;){let n=this.parse.advance();if(n)if(this.fragments=this.withoutTempSkipped(N.addTree(n,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=this.parse.stoppedAt??this.state.doc.length,this.tree=n,this.parse=null,this.treeLen<(t??this.state.doc.length))this.parse=this.startParse();else return!0;if(e())return!1}})}takeTree(){let e,t;this.parse&&(e=this.parse.parsedPos)>=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(t=this.parse.advance()););}),this.treeLen=e,this.tree=t,this.fragments=this.withoutTempSkipped(N.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=Y;Y=this;try{return e()}finally{Y=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=rt(e,t.from,t.to);return e}changes(t,n){let{fragments:r,tree:i,treeLen:a,viewport:o,skipped:s}=this;if(this.takeTree(),!t.empty){let e=[];if(t.iterChangedRanges((t,n,r,i)=>e.push({fromA:t,toA:n,fromB:r,toB:i})),r=N.applyChanges(r,e),i=D.empty,a=0,o={from:t.mapPos(o.from,-1),to:t.mapPos(o.to,1)},this.skipped.length){s=[];for(let e of this.skipped){let n=t.mapPos(e.from,1),r=t.mapPos(e.to,-1);n<r&&s.push({from:n,to:r})}}}return new e(this.parser,n,r,i,a,o,s,this.scheduleOn)}updateViewport(e){if(this.viewport.from==e.from&&this.viewport.to==e.to)return!1;this.viewport=e;let t=this.skipped.length;for(let t=0;t<this.skipped.length;t++){let{from:n,to:r}=this.skipped[t];n<e.to&&r>e.from&&(this.fragments=rt(this.fragments,n,r),this.skipped.splice(t--,1))}return this.skipped.length>=t?!1:(this.reset(),!0)}reset(){this.parse&&=(this.takeTree(),null)}skipUntilInView(e,t){this.skipped.push({from:e,to:t})}static getSkippingParser(e){return new class extends _e{createParse(t,n,r){let i=r[0].from,a=r[r.length-1].to;return{parsedPos:i,advance(){let t=Y;if(t){for(let e of r)t.tempSkipped.push(e);e&&(t.scheduleOn=t.scheduleOn?Promise.all([t.scheduleOn,e]):e)}return this.parsedPos=a,new D(C.none,[],[],a-i)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&t[0].from==0&&t[0].to>=e}static get(){return Y}};function rt(e,t,n){return N.applyChanges(e,[{fromA:t,toA:n,fromB:t,toB:n}])}var it=class e{constructor(e){this.context=e,this.tree=e.tree}apply(t){if(!t.docChanged&&this.tree==this.context.tree)return this;let n=this.context.changes(t.changes,t.state),r=this.context.treeLen==t.startState.doc.length?void 0:Math.max(t.changes.mapPos(this.context.treeLen),n.viewport.to);return n.work(20,r)||n.takeTree(),new e(n)}static init(t){let n=Math.min(3e3,t.doc.length),r=nt.create(t.facet(X).parser,t,{from:0,to:n});return r.work(20,n)||r.takeTree(),new e(r)}};q.state=r.define({create:it.init,update(e,t){for(let e of t.effects)if(e.is(q.setState))return e.value;return t.startState.facet(X)==t.state.facet(X)?e.apply(t):it.init(t.state)}});var at=e=>{let t=setTimeout(()=>e(),500);return()=>clearTimeout(t)};typeof requestIdleCallback<`u`&&(at=e=>{let t=-1,n=setTimeout(()=>{t=requestIdleCallback(e,{timeout:400})},100);return()=>t<0?clearTimeout(n):cancelIdleCallback(t)});var ot=typeof navigator<`u`&&navigator.scheduling?.isInputPending?()=>navigator.scheduling.isInputPending():null,st=u.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let t=this.view.state.field(q.state).context;(t.updateViewport(e.view.viewport)||this.view.viewport.to>t.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(t)}scheduleWork(){if(this.working)return;let{state:e}=this.view,t=e.field(q.state);(t.tree!=t.context.tree||!t.context.isDone(e.doc.length))&&(this.working=at(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEnd<t&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=t+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:n,viewport:{to:r}}=this.view,i=n.field(q.state);if(i.tree==i.context.tree&&i.context.isDone(r+1e5))return;let a=Date.now()+Math.min(this.chunkBudget,100,e&&!ot?Math.max(25,e.timeRemaining()-5):1e9),o=i.context.treeLen<r&&n.doc.length>r+1e3,s=i.context.work(()=>ot&&ot()||Date.now()>a,r+(o?0:1e5));this.chunkBudget-=Date.now()-t,(s||this.chunkBudget<=0)&&(i.context.takeTree(),this.view.dispatch({effects:q.setState.of(new it(i.context))})),this.chunkBudget>0&&!(s&&!o)&&this.scheduleWork(),this.checkAsyncSchedule(i.context)}checkAsyncSchedule(e){e.scheduleOn&&=(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(e=>d(this.view.state,e)).then(()=>this.workScheduled--),null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),X=o.define({combine(e){return e.length?e[0]:null},enables:e=>[q.state,st,g.contentAttributes.compute([e],t=>{let n=t.facet(e);return n&&n.name?{"data-language":n.name}:{}})]}),ct=class{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}},lt=class e{constructor(e,t,n,r,i,a=void 0){this.name=e,this.alias=t,this.extensions=n,this.filename=r,this.loadFunc=i,this.support=a,this.loading=null}load(){return this.loading||=this.loadFunc().then(e=>this.support=e,e=>{throw this.loading=null,e})}static of(t){let{load:n,support:r}=t;if(!n){if(!r)throw RangeError(`Must pass either 'load' or 'support' to LanguageDescription.of`);n=()=>Promise.resolve(r)}return new e(t.name,(t.alias||[]).concat(t.name).map(e=>e.toLowerCase()),t.extensions||[],t.filename,n,r)}static matchFilename(e,t){for(let n of e)if(n.filename&&n.filename.test(t))return n;let n=/\.([^.]+)$/.exec(t);if(n){for(let t of e)if(t.extensions.indexOf(n[1])>-1)return t}return null}static matchLanguageName(e,t,n=!0){t=t.toLowerCase();for(let n of e)if(n.alias.some(e=>e==t))return n;if(n)for(let n of e)for(let e of n.alias){let r=t.indexOf(e);if(r>-1&&(e.length>2||!/\w/.test(t[r-1])&&!/\w/.test(t[r+e.length])))return n}return null}},ut=o.define(),dt=o.define({combine:e=>{if(!e.length)return` `;let t=e[0];if(!t||/\S/.test(t)||Array.from(t).some(e=>e!=t[0]))throw Error(`Invalid indent unit: `+JSON.stringify(e[0]));return t}});function ft(e){let t=e.facet(dt);return t.charCodeAt(0)==9?e.tabSize*t.length:t.length}function pt(e,t){let n=``,r=e.tabSize,i=e.facet(dt)[0];if(i==` `){for(;t>=r;)n+=` `,t-=r;i=` `}for(let e=0;e<t;e++)n+=i;return n}function mt(e,t){e instanceof i&&(e=new ht(e));for(let n of e.state.facet(ut)){let r=n(e,t);if(r!==void 0)return r}let n=J(e.state);return n.length>=t?_t(e,n,t):null}var ht=class{constructor(e,t={}){this.state=e,this.options=t,this.unit=ft(e)}lineAt(e,t=1){let n=this.state.doc.lineAt(e),{simulateBreak:r,simulateDoubleBreak:i}=this.options;return r!=null&&r>=n.from&&r<=n.to?i&&r==e?{text:``,from:e}:(t<0?r<e:r<=e)?{text:n.text.slice(r-n.from),from:r}:{text:n.text.slice(0,r-n.from),from:n.from}:n}textAfterPos(e,t=1){if(this.options.simulateDoubleBreak&&e==this.options.simulateBreak)return``;let{text:n,from:r}=this.lineAt(e,t);return n.slice(e-r,Math.min(n.length,e+100-r))}column(e,t=1){let{text:n,from:r}=this.lineAt(e,t),i=this.countColumn(n,e-r),a=this.options.overrideIndentation?this.options.overrideIndentation(r):-1;return a>-1&&(i+=a-this.countColumn(n,n.search(/\S|$/))),i}countColumn(t,n=t.length){return e(t,this.state.tabSize,n)}lineIndent(e,t=1){let{text:n,from:r}=this.lineAt(e,t),i=this.options.overrideIndentation;if(i){let e=i(r);if(e>-1)return e}return this.countColumn(n,n.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}},gt=new b;function _t(e,t,n){let r=t.resolveStack(n),i=t.resolveInner(n,-1).resolve(n,0).enterUnfinishedNodesBefore(n);if(i!=r.node){let e=[];for(let t=i;t&&!(t.from<r.node.from||t.to>r.node.to||t.from==r.node.from&&t.type==r.node.type);t=t.parent)e.push(t);for(let t=e.length-1;t>=0;t--)r={node:e[t],next:r}}return vt(r,e,n)}function vt(e,t,n){for(let r=e;r;r=r.next){let e=bt(r.node);if(e)return e(St.create(t,n,r))}return 0}function yt(e){return e.pos==e.options.simulateBreak&&e.options.simulateDoubleBreak}function bt(e){let t=e.type.prop(gt);if(t)return t;let n=e.firstChild,r;if(n&&(r=n.type.prop(b.closedBy))){let t=e.lastChild,n=t&&r.indexOf(t.name)>-1;return e=>Et(e,!0,1,void 0,n&&!yt(e)?t.from:void 0)}return e.parent==null?xt:null}function xt(){return 0}var St=class e extends ht{constructor(e,t,n){super(e.state,e.options),this.base=e,this.pos=t,this.context=n}get node(){return this.context.node}static create(t,n,r){return new e(t,n,r)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let t=this.state.doc.lineAt(e.from);for(;;){let n=e.resolve(t.from);for(;n.parent&&n.parent.from==n.from;)n=n.parent;if(Ct(n,e))break;t=this.state.doc.lineAt(n.from)}return this.lineIndent(t.from)}continue(){return vt(this.context.next,this.base,this.pos)}};function Ct(e,t){for(let n=t;n;n=n.parent)if(e==n)return!0;return!1}function wt(e){let t=e.node,n=t.childAfter(t.from),r=t.lastChild;if(!n)return null;let i=e.options.simulateBreak,a=e.state.doc.lineAt(n.from),o=i==null||i<=a.from?a.to:Math.min(a.to,i);for(let e=n.to;;){let i=t.childAfter(e);if(!i||i==r)return null;if(!i.type.isSkipped){if(i.from>=o)return null;let e=/^ */.exec(a.text.slice(n.to-a.from))[0].length;return{from:n.from,to:n.to+e}}e=i.to}}function Tt({closing:e,align:t=!0,units:n=1}){return r=>Et(r,t,n,e)}function Et(e,t,n,r,i){let a=e.textAfter,o=a.match(/^\s*/)[0].length,s=r&&a.slice(o,o+r.length)==r||i==e.pos+o,c=t?wt(e):null;return c?s?e.column(c.from):e.column(c.to):e.baseIndent+(s?0:e.unit*n)}var Dt=e=>e.baseIndent;function Ot({except:e,units:t=1}={}){return n=>{let r=e&&e.test(n.textAfter);return n.baseIndent+(r?0:t*n.unit)}}var kt=200;function At(){return i.transactionFilter.of(e=>{if(!e.docChanged||!e.isUserEvent(`input.type`)&&!e.isUserEvent(`input.complete`))return e;let t=e.startState.languageDataAt(`indentOnInput`,e.startState.selection.main.head);if(!t.length)return e;let n=e.newDoc,{head:r}=e.newSelection.main,i=n.lineAt(r);if(r>i.from+kt)return e;let a=n.sliceString(i.from,r);if(!t.some(e=>e.test(a)))return e;let{state:o}=e,s=-1,c=[];for(let{head:e}of o.selection.ranges){let t=o.doc.lineAt(e);if(t.from==s)continue;s=t.from;let n=mt(o,t.from);if(n==null)continue;let r=/^\s*/.exec(t.text)[0],i=pt(o,n);r!=i&&c.push({from:t.from,to:t.from+r.length,insert:i})}return c.length?[e,{changes:c,sequential:!0}]:e})}var jt=o.define(),Mt=new b;function Nt(e){let t=e.firstChild,n=e.lastChild;return t&&t.to<n.from?{from:t.to,to:n.type.isError?e.to:n.from}:null}function Pt(e,t,n){let r=J(e);if(r.length<n)return null;let i=r.resolveStack(n,1),a=null;for(let o=i;o;o=o.next){let i=o.node;if(i.to<=n||i.from>n)continue;if(a&&i.from<t)break;let s=i.type.prop(Mt);if(s&&(i.to<r.length-50||r.length==e.doc.length||!Ft(i))){let r=s(i,e);r&&r.from<=n&&r.from>=t&&r.to>n&&(a=r)}}return a}function Ft(e){let t=e.lastChild;return t&&t.to==e.to&&t.type.isError}function It(e,t,n){for(let r of e.facet(jt)){let i=r(e,t,n);if(i)return i}return Pt(e,t,n)}function Lt(e,t){let n=t.mapPos(e.from,1),r=t.mapPos(e.to,-1);return n>=r?void 0:{from:n,to:r}}var Rt=a.define({map:Lt}),Z=a.define({map:Lt});function zt(e){let t=[];for(let{head:n}of e.state.selection.ranges)t.some(e=>e.from<=n&&e.to>=n)||t.push(e.lineBlockAt(n));return t}var Q=r.define({create(){return _.none},update(e,t){t.isUserEvent(`delete`)&&t.changes.iterChangedRanges((t,n)=>e=Bt(e,t,n)),e=e.map(t.changes);for(let n of t.effects)if(n.is(Rt)&&!Ht(e,n.value.from,n.value.to)){let{preparePlaceholder:r}=t.state.facet(Yt),i=r?_.replace({widget:new $t(r(t.state,n.value))}):Qt;e=e.update({add:[i.range(n.value.from,n.value.to)]})}else n.is(Z)&&(e=e.update({filter:(e,t)=>n.value.from!=e||n.value.to!=t,filterFrom:n.value.from,filterTo:n.value.to}));return t.selection&&(e=Bt(e,t.selection.main.head)),e},provide:e=>g.decorations.from(e),toJSON(e,t){let n=[];return e.between(0,t.doc.length,(e,t)=>{n.push(e,t)}),n},fromJSON(e){if(!Array.isArray(e)||e.length%2)throw RangeError(`Invalid JSON for fold state`);let t=[];for(let n=0;n<e.length;){let r=e[n++],i=e[n++];if(typeof r!=`number`||typeof i!=`number`)throw RangeError(`Invalid JSON for fold state`);t.push(Qt.range(r,i))}return _.set(t,!0)}});function Bt(e,t,n=t){let r=!1;return e.between(t,n,(e,i)=>{e<n&&i>t&&(r=!0)}),r?e.update({filterFrom:t,filterTo:n,filter:(e,r)=>e>=n||r<=t}):e}function Vt(e,t,n){var r;let i=null;return(r=e.field(Q,!1))==null||r.between(t,n,(e,t)=>{(!i||i.from>e)&&(i={from:e,to:t})}),i}function Ht(e,t,n){let r=!1;return e.between(t,t,(e,i)=>{e==t&&i==n&&(r=!0)}),r}function Ut(e,t){return e.field(Q,!1)?t:t.concat(a.appendConfig.of(Xt()))}var Wt=e=>{for(let t of zt(e)){let n=It(e.state,t.from,t.to);if(n)return e.dispatch({effects:Ut(e.state,[Rt.of(n),Kt(e,n)])}),!0}return!1},Gt=e=>{if(!e.state.field(Q,!1))return!1;let t=[];for(let n of zt(e)){let r=Vt(e.state,n.from,n.to);r&&t.push(Z.of(r),Kt(e,r,!1))}return t.length&&e.dispatch({effects:t}),t.length>0};function Kt(e,t,n=!0){let r=e.state.doc.lineAt(t.from).number,i=e.state.doc.lineAt(t.to).number;return g.announce.of(`${e.state.phrase(n?`Folded lines`:`Unfolded lines`)} ${r} ${e.state.phrase(`to`)} ${i}.`)}var qt=[{key:`Ctrl-Shift-[`,mac:`Cmd-Alt-[`,run:Wt},{key:`Ctrl-Shift-]`,mac:`Cmd-Alt-]`,run:Gt},{key:`Ctrl-Alt-[`,run:e=>{let{state:t}=e,n=[];for(let r=0;r<t.doc.length;){let i=e.lineBlockAt(r),a=It(t,i.from,i.to);a&&n.push(Rt.of(a)),r=(a?e.lineBlockAt(a.to):i).to+1}return n.length&&e.dispatch({effects:Ut(e.state,n)}),!!n.length}},{key:`Ctrl-Alt-]`,run:e=>{let t=e.state.field(Q,!1);if(!t||!t.size)return!1;let n=[];return t.between(0,e.state.doc.length,(e,t)=>{n.push(Z.of({from:e,to:t}))}),e.dispatch({effects:n}),!0}}],Jt={placeholderDOM:null,preparePlaceholder:null,placeholderText:`…`},Yt=o.define({combine(e){return c(e,Jt)}});function Xt(e){let t=[Q,rn];return e&&t.push(Yt.of(e)),t}function Zt(e,t){let{state:n}=e,r=n.facet(Yt),i=t=>{let n=e.lineBlockAt(e.posAtDOM(t.target)),r=Vt(e.state,n.from,n.to);r&&e.dispatch({effects:Z.of(r)}),t.preventDefault()};if(r.placeholderDOM)return r.placeholderDOM(e,i,t);let a=document.createElement(`span`);return a.textContent=r.placeholderText,a.setAttribute(`aria-label`,n.phrase(`folded code`)),a.title=n.phrase(`unfold`),a.className=`cm-foldPlaceholder`,a.onclick=i,a}var Qt=_.replace({widget:new class extends m{toDOM(e){return Zt(e,null)}}}),$t=class extends m{constructor(e){super(),this.value=e}eq(e){return this.value==e.value}toDOM(e){return Zt(e,this.value)}},en={openText:`⌄`,closedText:`›`,markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1},tn=class extends f{constructor(e,t){super(),this.config=e,this.open=t}eq(e){return this.config==e.config&&this.open==e.open}toDOM(e){if(this.config.markerDOM)return this.config.markerDOM(this.open);let t=document.createElement(`span`);return t.textContent=this.open?this.config.openText:this.config.closedText,t.title=e.state.phrase(this.open?`Fold line`:`Unfold line`),t}};function nn(e={}){let n={...en,...e},r=new tn(n,!0),i=new tn(n,!1),a=u.fromClass(class{constructor(e){this.from=e.viewport.from,this.markers=this.buildMarkers(e)}update(e){(e.docChanged||e.viewportChanged||e.startState.facet(X)!=e.state.facet(X)||e.startState.field(Q,!1)!=e.state.field(Q,!1)||J(e.startState)!=J(e.state)||n.foldingChanged(e))&&(this.markers=this.buildMarkers(e.view))}buildMarkers(e){let n=new t;for(let t of e.viewportLineBlocks){let a=Vt(e.state,t.from,t.to)?i:It(e.state,t.from,t.to)?r:null;a&&n.add(t.from,t.from,a)}return n.finish()}}),{domEventHandlers:o}=n;return[a,h({class:`cm-foldGutter`,markers(e){return e.plugin(a)?.markers||s.empty},initialSpacer(){return new tn(n,!1)},domEventHandlers:{...o,click:(e,t,n)=>{if(o.click&&o.click(e,t,n))return!0;let r=Vt(e.state,t.from,t.to);if(r)return e.dispatch({effects:Z.of(r)}),!0;let i=It(e.state,t.from,t.to);return i?(e.dispatch({effects:Rt.of(i)}),!0):!1}}}),Xt()]}var rn=g.baseTheme({".cm-foldPlaceholder":{backgroundColor:`#eee`,border:`1px solid #ddd`,color:`#888`,borderRadius:`.2em`,margin:`0 1px`,padding:`0 1px`,cursor:`pointer`},".cm-foldGutter span":{padding:`0 1px`,cursor:`pointer`}}),an=class e{constructor(e,t){this.specs=e;let n;function r(e){let t=l.newName();return(n||=Object.create(null))[`.`+t]=e,t}let i=typeof t.all==`string`?t.all:t.all?r(t.all):void 0,a=t.scope;this.scope=a instanceof q?e=>e.prop(K)==a.data:a?e=>e==a:void 0,this.style=Be(e.map(e=>({tag:e.tag,class:e.class||r(Object.assign({},e,{tag:null}))})),{all:i}).style,this.module=n?new l(n):null,this.themeType=t.themeType}static define(t,n){return new e(t,n||{})}},on=o.define(),sn=o.define({combine(e){return e.length?[e[0]]:null}});function cn(e){let t=e.facet(on);return t.length?t:e.facet(sn)}function ln(e,t){let n=[dn],r;return e instanceof an&&(e.module&&n.push(g.styleModule.of(e.module)),r=e.themeType),t?.fallback?n.push(sn.of(e)):r?n.push(on.computeN([g.darkTheme],t=>t.facet(g.darkTheme)==(r==`dark`)?[e]:[])):n.push(on.of(e)),n}var un=class{constructor(e){this.markCache=Object.create(null),this.tree=J(e.state),this.decorations=this.buildDeco(e,cn(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=J(e.state),n=cn(e.state),r=n!=cn(e.startState),{viewport:i}=e.view,a=e.changes.mapPos(this.decoratedTo,1);t.length<i.to&&!r&&t.type==this.tree.type&&a>=i.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=a):(t!=this.tree||e.viewportChanged||r)&&(this.tree=t,this.decorations=this.buildDeco(e.view,n),this.decoratedTo=i.to)}buildDeco(e,n){if(!n||!this.tree.length)return _.none;let r=new t;for(let{from:t,to:i}of e.visibleRanges)He(this.tree,n,(e,t,n)=>{r.add(e,t,this.markCache[n]||(this.markCache[n]=_.mark({class:n})))},t,i);return r.finish()}},dn=n.high(u.fromClass(un,{decorations:e=>e.decorations})),fn=an.define([{tag:G.meta,color:`#404740`},{tag:G.link,textDecoration:`underline`},{tag:G.heading,textDecoration:`underline`,fontWeight:`bold`},{tag:G.emphasis,fontStyle:`italic`},{tag:G.strong,fontWeight:`bold`},{tag:G.strikethrough,textDecoration:`line-through`},{tag:G.keyword,color:`#708`},{tag:[G.atom,G.bool,G.url,G.contentSeparator,G.labelName],color:`#219`},{tag:[G.literal,G.inserted],color:`#164`},{tag:[G.string,G.deleted],color:`#a11`},{tag:[G.regexp,G.escape,G.special(G.string)],color:`#e40`},{tag:G.definition(G.variableName),color:`#00f`},{tag:G.local(G.variableName),color:`#30a`},{tag:[G.typeName,G.namespace],color:`#085`},{tag:G.className,color:`#167`},{tag:[G.special(G.variableName),G.macroName],color:`#256`},{tag:G.definition(G.propertyName),color:`#00c`},{tag:G.comment,color:`#940`},{tag:G.invalid,color:`#f00`}]),pn=g.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:`#328c8252`},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:`#bb555544`}}),mn=1e4,hn=`()[]{}`,gn=o.define({combine(e){return c(e,{afterCursor:!0,brackets:hn,maxScanDistance:mn,renderMatch:yn})}}),_n=_.mark({class:`cm-matchingBracket`}),vn=_.mark({class:`cm-nonmatchingBracket`});function yn(e){let t=[],n=e.matched?_n:vn;return t.push(n.range(e.start.from,e.start.to)),e.end&&t.push(n.range(e.end.from,e.end.to)),t}function bn(e){let t=[],n=e.facet(gn);for(let r of e.selection.ranges){if(!r.empty)continue;let i=$(e,r.head,-1,n)||r.head>0&&$(e,r.head-1,1,n)||n.afterCursor&&($(e,r.head,1,n)||r.head<e.doc.length&&$(e,r.head+1,-1,n));i&&(t=t.concat(n.renderMatch(i,e)))}return _.set(t,!0)}var xn=[u.fromClass(class{constructor(e){this.paused=!1,this.decorations=bn(e.state)}update(e){(e.docChanged||e.selectionSet||this.paused)&&(e.view.composing?(this.decorations=this.decorations.map(e.changes),this.paused=!0):(this.decorations=bn(e.state),this.paused=!1))}},{decorations:e=>e.decorations}),pn];function Sn(e={}){return[gn.of(e),xn]}var Cn=new b;function wn(e,t,n){let r=e.prop(t<0?b.openedBy:b.closedBy);if(r)return r;if(e.name.length==1){let r=n.indexOf(e.name);if(r>-1&&r%2==(t<0?1:0))return[n[r+t]]}return null}function Tn(e){let t=e.type.prop(Cn);return t?t(e.node):e}function $(e,t,n,r={}){let i=r.maxScanDistance||mn,a=r.brackets||hn,o=J(e),s=o.resolveInner(t,n);for(let r=s;r;r=r.parent){let i=wn(r.type,n,a);if(i&&r.from<r.to){let o=Tn(r);if(o&&(n>0?t>=o.from&&t<o.to:t>o.from&&t<=o.to))return En(e,t,n,r,o,i,a)}}return Dn(e,t,n,o,s.type,i,a)}function En(e,t,n,r,i,a,o){let s=r.parent,c={from:i.from,to:i.to},l=0,u=s?.cursor();if(u&&(n<0?u.childBefore(r.from):u.childAfter(r.to)))do if(n<0?u.to<=r.from:u.from>=r.to){if(l==0&&a.indexOf(u.type.name)>-1&&u.from<u.to){let e=Tn(u);return{start:c,end:e?{from:e.from,to:e.to}:void 0,matched:!0}}else if(wn(u.type,n,o))l++;else if(wn(u.type,-n,o)){if(l==0){let e=Tn(u);return{start:c,end:e&&e.from<e.to?{from:e.from,to:e.to}:void 0,matched:!1}}l--}}while(n<0?u.prevSibling():u.nextSibling());return{start:c,matched:!1}}function Dn(e,t,n,r,i,a,o){let s=n<0?e.sliceDoc(t-1,t):e.sliceDoc(t,t+1),c=o.indexOf(s);if(c<0||c%2==0!=n>0)return null;let l={from:n<0?t-1:t,to:n>0?t+1:t},u=e.doc.iterRange(t,n>0?e.doc.length:0),d=0;for(let e=0;!u.next().done&&e<=a;){let a=u.value;n<0&&(e+=a.length);let s=t+e*n;for(let e=n>0?0:a.length-1,t=n>0?a.length:-1;e!=t;e+=n){let t=o.indexOf(a[e]);if(!(t<0||r.resolveInner(s+e,1).type!=i))if(t%2==0==n>0)d++;else if(d==1)return{start:l,end:{from:s+e,to:s+e+1},matched:t>>1==c>>1};else d--}n>0&&(e+=a.length)}return u.done?{start:l,matched:!1}:null}var On=Object.create(null),kn=[C.none],An=[],jn=Object.create(null),Mn=Object.create(null);for(let[e,t]of[[`variable`,`variableName`],[`variable-2`,`variableName.special`],[`string-2`,`string.special`],[`def`,`variableName.definition`],[`tag`,`tagName`],[`attribute`,`attributeName`],[`type`,`typeName`],[`builtin`,`variableName.standard`],[`qualifier`,`modifier`],[`error`,`invalid`],[`header`,`heading`],[`property`,`propertyName`]])Mn[e]=Pn(On,t);function Nn(e,t){An.indexOf(e)>-1||(An.push(e),console.warn(t))}function Pn(e,t){let n=[];for(let r of t.split(` `)){let t=[];for(let n of r.split(`.`)){let r=e[n]||G[n];r?typeof r==`function`?t.length?t=t.map(r):Nn(n,`Modifier ${n} used at start of tag`):t.length?Nn(n,`Tag ${n} used as modifier`):t=Array.isArray(r)?r:[r]:Nn(n,`Unknown highlighting tag ${n}`)}for(let e of t)n.push(e)}if(!n.length)return 0;let r=t.replace(/ /g,`_`),i=r+` `+n.map(e=>e.id),a=jn[i];if(a)return a.id;let o=jn[i]=C.define({id:kn.length,name:r,props:[Re({[r]:n})]});return kn.push(o),o.id}p.RTL,p.LTR;export{J as A,_e as B,At as C,$ as D,K as E,E as F,ye as H,b as I,te as L,Re as M,G as N,Qe as O,ee as P,C as R,gt as S,dt as T,D as V,qt as _,lt as a,ft as b,Sn as c,fn as d,Ze as f,Nt as g,nn as h,q as i,P as j,ln as k,Cn as l,Dt as m,ht as n,ct as o,Tt as p,et as r,nt as s,an as t,Ot as u,Mt as v,pt as w,mt as x,jt as y,ge as z};