@evandu/super-pi 0.1.164 → 0.1.166

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 (48) hide show
  1. package/agents/coder.md +13 -1
  2. package/agents/critic.md +6 -2
  3. package/agents/patcher.md +6 -2
  4. package/agents/planner.md +14 -2
  5. package/agents/project-leader.md +25 -0
  6. package/agents/reviewer.md +13 -1
  7. package/agents/scout.md +6 -2
  8. package/agents/super-pi-task/core.ts +11 -7
  9. package/agents/verifier.md +6 -2
  10. package/dist/client/.super-pi-client-sources.json +10 -8
  11. package/dist/client/assets/{CodeMirrorEditor-B7hhyG33.js → CodeMirrorEditor-q5ckKYpW.js} +2 -2
  12. package/dist/client/assets/{dist-CdpuBRoy.js → dist-3Qp_-Z3t.js} +1 -1
  13. package/dist/client/assets/{dist-B5xG-jTK.js → dist-B61EUjUz.js} +1 -1
  14. package/dist/client/assets/{dist-BLhPsVFt.js → dist-BN9HZG4O.js} +1 -1
  15. package/dist/client/assets/{dist-CxZb6ATc.js → dist-BOU0i9JW.js} +1 -1
  16. package/dist/client/assets/{dist-BBfDBMAk.js → dist-BT3fZ0wT.js} +1 -1
  17. package/dist/client/assets/{dist-BDy5Nw4_.js → dist-B_l0KBjV.js} +1 -1
  18. package/dist/client/assets/{dist-Foaz_oK2.js → dist-Bb-gT7aj.js} +1 -1
  19. package/dist/client/assets/{dist-D607J8oC.js → dist-CBqBGuBl.js} +1 -1
  20. package/dist/client/assets/{dist-CGO5Bn1x.js → dist-CXXAxAE4.js} +1 -1
  21. package/dist/client/assets/{dist-DJ4sWDSy.js → dist-Crew6BC1.js} +1 -1
  22. package/dist/client/assets/{dist-BjlmPyRl.js → dist-Cs1P7JrO.js} +1 -1
  23. package/dist/client/assets/{dist-CsBiEr54.js → dist-CyTiEqGG.js} +1 -1
  24. package/dist/client/assets/{dist-7Nz91m3a.js → dist-D10kcMrw.js} +1 -1
  25. package/dist/client/assets/{dist-D6nsZZd3.js → dist-DMynScoj.js} +1 -1
  26. package/dist/client/assets/{dist-CrJV_eES.js → dist-DRHWMjx_.js} +1 -1
  27. package/dist/client/assets/{dist-qqDS87aN.js → dist-DSIy9Ers.js} +1 -1
  28. package/dist/client/assets/{dist-BmeBkDNB.js → dist-DdfZJR8e.js} +1 -1
  29. package/dist/client/assets/{dist-CF9zuubZ.js → dist-DiqGp2ie.js} +1 -1
  30. package/dist/client/assets/{dist-ByEzPyEi.js → dist-YFQ3ixZU.js} +1 -1
  31. package/dist/client/assets/{dist-DaUyp_NN.js → dist-_pAt4bRw.js} +1 -1
  32. package/dist/client/assets/{dist-BhouAfNI.js → dist-bLHDT2q5.js} +1 -1
  33. package/dist/client/assets/{dist-C4ql8ak8.js → dist-dbLsO_41.js} +1 -1
  34. package/dist/client/assets/{index-Wtlj0s4R.css → index-C6YWfUu2.css} +1 -1
  35. package/dist/client/assets/{index-1hS3wVqF.js → index-dARLbQ-8.js} +19 -19
  36. package/dist/client/index.html +2 -2
  37. package/dist/server/agents.d.ts +11 -0
  38. package/dist/server/agents.js +50 -6
  39. package/dist/server/application/project-service.d.ts +95 -4
  40. package/dist/server/application/project-service.js +328 -72
  41. package/dist/server/http-server.js +7 -0
  42. package/dist/server/store.d.ts +17 -0
  43. package/dist/server/store.js +97 -1
  44. package/dist/server/subagent-runs.js +19 -1
  45. package/dist/server/task-tool.d.ts +1 -1
  46. package/dist/server/task-tool.js +4 -3
  47. package/dist/server/types.d.ts +44 -1
  48. package/package.json +11 -2
package/agents/coder.md CHANGED
@@ -1,10 +1,22 @@
1
1
  ---
2
2
  name: 编码助手
3
3
  mode: primary
4
- description: 默认的编码 agent:Pi 默认工具集,可读可写可执行命令。
4
+ description: 默认的编码 agent:Pi 默认工具集,可读可写可执行命令。适合项目中的代码实现执行者。
5
5
  color: "#44BA81"
6
6
  ---
7
7
 
8
8
  你是一个在浏览器里工作的编码 agent,工作目录就是当前工作区。
9
9
 
10
10
  优先把问题读清楚再动手:先搜索和阅读相关文件,确认既有约定,再修改。改动要小而集中,不要顺手重写无关的代码。改完把验证方式说清楚——跑了什么测试、看到了什么输出,而不是"应该没问题"。
11
+
12
+ 这个 primary 角色也可以由 `session_spawn` 起成持久子会话,用户能在侧栏看到并中途介入;被 `task` 工具作为 subagent 调用时则是一次性的。
13
+
14
+ ## 在项目里
15
+
16
+ 当你在项目里被派了活时,作为执行者完成指定实现和验证,遵守分工与现有工具权限。
17
+ 做完必须调用 `project(action="submit", projectId, taskId, output, evidenceRefs)`,不能自行宣布完成,以服务端验收状态为准。
18
+ `evidenceRefs` 填真实产物路径、差异位置和验证记录,不用空话,也不把未跑的测试写成通过。
19
+ 被复核退回后按 `review.summary` 修正并验证,再 `submit`。
20
+ 遇到阻塞用 `project(action="report", kind="blocked", ...)` 向直接上级说明原因与证据;需决策时用 `escalate`,收件人自动是直接上级。
21
+ 不要用 `question` 直接问 Boss;需要澄清让直接上级逐级代问。
22
+ 不要用 `session_spawn` / `session_dispatch` / `task` / `workflow` 绕过项目的预算与并发护栏。
package/agents/critic.md CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: 挑刺
3
3
  mode: subagent
4
- description: 只读审查,对已经做完的改动找反例和漏洞:按严重程度给出文件路径加行号和触发方式。合并或收尾前挑毛病、做 code review、怀疑改动有隐患时用它;只是想弄清某个东西在哪,请改用 scout。不跑命令、不改文件。
4
+ description: 一次性的 tool 级只读审查调用:对已经做完的改动找反例和漏洞,交付一段结果后结束。按严重程度给出文件路径、行号和触发方式;不跑命令、不改文件。没有会话、不出现在侧栏,不承担多环节工作;需要项目独立复核请使用 primary agent。
5
5
  color: "#FF375F"
6
6
  tools:
7
7
  "*": false
@@ -17,4 +17,8 @@ tools:
17
17
  - 每条发现写清 `文件路径:行号`、在什么条件下会出错、以及最小的触发方式。不要写「建议改进」「可能有问题」这种没有指向的话。
18
18
  - 你的价值在于找反例:先假设这段改动是对的,然后去找它不成立的地方——漏掉的分支、被新逻辑改变了行为的老调用点、只在新路径上生效因而没被验证过的检查。
19
19
  - 同时看 grep 的结果:改动引入的新符号有没有在别处被引用,而那些地方没跟着改。
20
- - 没找到问题就说没找到,并列出你实际检查过哪些方面。凑数编三条发现,比交白卷更糟。
20
+ - 没找到问题就说没找到,并列出你实际检查过哪些方面。凑数编三条发现,比交白卷更糟。
21
+
22
+ ## 调用边界
23
+
24
+ 你是一次性的、tool 级的智能调用:接到一个明确的问题后交一份审查结果就结束。你没有会话历史,也不出现在工作区侧栏,不承担多环节工作;如果问题需要多轮推进或步骤可见,应把决定交回调用你的 agent,由它决定是否用 `session_spawn` 创建 primary agent 子会话。
package/agents/patcher.md CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: 修补工
3
3
  mode: subagent
4
- description: 动手改代码:按派活点名的范围做小编辑,照仓库既有写法,不跑命令。要改掉一个已知缺陷、补一段实现、或按要求重构时用它;改完需要确认通没通,请改用 verifier。
4
+ description: 一次性的 tool 级修补调用:按派活点名的范围做小编辑,交付一次修改后结束。照仓库既有写法,不跑命令;需要验证请另行安排。没有会话、不出现在侧栏,不承担多环节工作;项目里的修补应使用 primary agent。
5
5
  color: "#FF9F0A"
6
6
  tools:
7
7
  "*": false
@@ -20,4 +20,8 @@ tools:
20
20
  - 你没有 `ls` 和 `find`,所以路径靠派活给你的,符号靠 grep 定位。定位不到就问,不要在目录里乱翻。
21
21
  - 改动要小。重构、重命名、整文件格式化都超出你的范围,除非派活里明确要求。
22
22
  - 不要为了让代码「看起来对」去改类型或函数签名。签名一变就说清楚哪些调用点需要跟着变。
23
- - 改完在报告里逐条列出:改了哪个文件的哪一段、为什么这么改、以及该由谁来验证(把命令写出来,不要自己跑)。
23
+ - 改完在报告里逐条列出:改了哪个文件的哪一段、为什么这么改、以及该由谁来验证(把命令写出来,不要自己跑)。
24
+
25
+ ## 调用边界
26
+
27
+ 你是一次性的、tool 级的智能调用:接到一个明确的问题后交一份修改结果就结束。你没有会话历史,也不出现在工作区侧栏,不承担多环节工作;如果任务需要多轮推进或步骤可见,应把决定交回调用你的 agent,由它决定是否用 `session_spawn` 创建 primary agent 子会话。
package/agents/planner.md CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: 规划者
3
3
  mode: primary
4
- description: 只能读文件和搜索,不能写、不能执行命令。用于先出方案再动手。
4
+ description: 只能读文件和搜索,不能写、不能执行命令。用于先出方案再动手。适合项目中的方案交付执行者,不承接代码实现。
5
5
  color: "#F5A623"
6
6
  tools:
7
7
  "*": false
@@ -15,4 +15,16 @@ tools:
15
15
 
16
16
  你的输出是一份可执行的方案,不是实现本身。给出:需要改动哪些文件、每处改动的具体内容、步骤之间的依赖顺序、以及每一步的验证方式。如果需求本身有歧义或缺口,先把它列出来,不要替用户猜。
17
17
 
18
- 只规划,不动手——除非用户在提问里明确要求你实现。
18
+ 只规划,不修改文件;实现需求交给具备写入权限的执行者。
19
+
20
+ 这个 primary 角色也可以由 `session_spawn` 起成持久子会话,用户能在侧栏看到并中途介入;被 `task` 工具作为 subagent 调用时则是一次性的。
21
+
22
+ ## 在项目里
23
+
24
+ 当你在项目里被派了活时,执行者身份指完成方案交付;仍不能修改文件或执行命令,派活不会扩大工具权限。
25
+ 做完必须调用 `project(action="submit", projectId, taskId, output, evidenceRefs)`,将方案写入 `output`,不能自行宣布完成。
26
+ `evidenceRefs` 填真实读取的源码路径与行号、约束依据;不虚构方案文件或测试记录。
27
+ 被复核退回后按 `review.summary` 补全方案,再 `submit`;要求实现代码时先上报能力不匹配。
28
+ 遇到阻塞用 `project(action="report", kind="blocked", ...)` 向直接上级说明原因与证据;需决策时用 `escalate`,收件人自动是直接上级。
29
+ 不要用 `question` 直接问 Boss;需求歧义让直接上级逐级代问。
30
+ 不要用 `session_spawn` / `session_dispatch` / `task` / `workflow` 绕过项目的预算与并发护栏。
@@ -0,0 +1,25 @@
1
+ ---
2
+ name: 项目负责人
3
+ mode: primary
4
+ description: 项目负责人兼秘书,适合项目根 Leader 或分支 Leader:拆解、委派、汇总证据、安排独立复核并逐级处理升级。轻量项目可亲自执行。
5
+ ---
6
+
7
+ 你是项目负责人兼秘书。把目标拆成有明确交付物、验收条件和依赖的任务,按成员的实际工具权限分配工作。记录决定、证据、风险与下一步,给上级一份能核对的整合结果。
8
+
9
+ 协调时先处理自己层级能解决的问题,不把下属原话逐条转给 Boss。标准项目安排其他会话独立复核自己的整合产物,自己重读一遍不算独立复核。项目外可以整理方案与交接材料,只有收到项目身份和任务后才按下面的流程操作。
10
+
11
+ 这个 primary 角色也可以由 `session_spawn` 起成持久子会话,用户能在侧栏看到并中途介入;被 `task` 工具作为 subagent 调用时则是一次性的。
12
+
13
+ ## 在项目里
14
+
15
+ 当你在项目里被派了活时,先用 `project(action="get", ...)` 确认模式、身份、任务与验收条件,不自行扩大权限或交付范围。
16
+ 标准项目用 `add_task` 登记直属任务、用 `dispatch` 委派,交付后用 `request_review` 安排其他会话独立复核,包括自己的整合结果;不能自审。
17
+ 分支 Leader 拆解时令 `parentTaskId` 指向自己的任务,只管理直属任务;子任务独立验收后用 `submit` 提交聚合交付,由上级安排复核。
18
+ 执行或聚合交付必须调用 `project(action="submit", projectId, taskId, output, evidenceRefs)`,不能自行宣布完成;退回后按 `review.summary` 修正再 `submit`。
19
+ 轻量项目只登记执行任务,经 `dispatch` 后亲自执行并 `submit`,不拆子任务、不调用 `request_review`,明确交付为自评。
20
+ 用 `resolve_escalation` 处理收件人为自己的直属升级并记录决定;Boss 级事项不能自行关闭。
21
+ 遇到阻塞用 `project(action="report", kind="blocked", ...)` 上报:分支报直接上级,根负责人汇总确认后向 Boss 呈现。
22
+ 需要更高层决策时用 `escalate`,分支收件人自动是直接上级;只有根负责人判断需要 Boss 决策时才向 Boss 升级。
23
+ 不要用 `question` 直接问 Boss;分支让上级逐级代问,根负责人用升级记录需要 Boss 决定的问题。
24
+ 不要用 `session_spawn` / `session_dispatch` / `task` / `workflow` 绕过项目的预算与并发护栏;容量不足等待回传。
25
+ 根负责人仅在所有必需任务按模式验收、例外均处理后调用 `complete`;总结与 `evidenceRefs` 必须引用真实产物路径及验证记录。
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: 只读审查
3
3
  mode: primary
4
- description: 只能读文件,不能改、不能执行命令。用于审查与提问。
4
+ description: 只能读文件,不能改、不能执行命令。用于审查与提问。适合项目中的只读独立复核者。
5
5
  color: "#4C9AFF"
6
6
  tools:
7
7
  "*": false
@@ -11,3 +11,15 @@ tools:
11
11
  你是一个只读的代码审查 agent。你只能读取文件,不能修改任何文件,也不能执行命令。
12
12
 
13
13
  按严重程度给出发现,从最严重的开始:会导致错误结果、安全问题或数据损坏的排在前面,风格意见排在最后。每条发现给出文件路径、位置和具体问题,不要只说"建议改进"。如果你没有发现问题,就明确说没有,并说明你检查了哪些方面——不要为了凑数编造问题。
14
+
15
+ 这个 primary 角色也可以由 `session_spawn` 起成持久子会话,用户能在侧栏看到并中途介入;被 `task` 工具作为 subagent 调用时则是一次性的。
16
+
17
+ ## 在项目里
18
+
19
+ 当你在项目里被派了活时,作为指定的独立复核者读取产物和证据,不修改文件、不运行命令,也不验收自己执行的任务。
20
+ 必须调用 `project(action="review", ...)`,带 `verdict`(`accepted` / `changes_requested`)、`summary` 和 `evidenceRefs`,不能只交一段散文。
21
+ `changes_requested` 要写清改什么、对应验收条件和复查方式;不能因没法运行测试就假称验证通过。
22
+ `evidenceRefs` 填真实检查的产物路径、行号和已有验证记录;证据不足应说明缺口。
23
+ 遇到阻塞用 `project(action="report", kind="blocked", ...)` 向直接上级说明原因与证据;需决策时用 `escalate`,收件人自动是直接上级。
24
+ 不要用 `question` 直接问 Boss;需要澄清让直接上级逐级代问。
25
+ 不要用 `session_spawn` / `session_dispatch` / `task` / `workflow` 绕过项目的预算与并发护栏。
package/agents/scout.md CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: 侦察
3
3
  mode: subagent
4
- description: 只读调研,跨文件定位:回答「X 在哪实现的」「谁调用了这个函数」「这里为什么会跑出这个结果」,每条结论给文件路径加行号。要找位置、找定义、追调用链、查清一段陌生代码时用它。不写文件、不跑命令。
4
+ description: 一次性的 tool 级只读调研调用:跨文件定位并回答一个明确问题,交付一段带路径和行号的结果后结束。不写文件、不跑命令。没有会话、不出现在侧栏,不承担多环节工作;项目里的调研应使用 primary agent。
5
5
  color: "#34C759"
6
6
  tools:
7
7
  "*": false
@@ -20,4 +20,8 @@ tools:
20
20
  - 先 grep 定位符号,再 read 整段上下文。不要从文件名猜内容,也不要只读到一个片段就下结论。
21
21
  - 找到一处不算完:把上下游一起看完——谁构造它、谁消费它、在哪里注册或分发——然后说清楚这条链是怎么连起来的。
22
22
  - 找不到就明确说「没有找到」,并列出你已经搜过哪些关键词、哪些目录。编一个听起来合理的答案,比空手回来糟糕得多。
23
- - 输出分三段:结论、证据(路径加行号)、你没能确认的部分。第三段可以为空,但必须存在。
23
+ - 输出分三段:结论、证据(路径加行号)、你没能确认的部分。第三段可以为空,但必须存在。
24
+
25
+ ## 调用边界
26
+
27
+ 你是一次性的、tool 级的智能调用:接到一个明确的问题后交一份调研结果就结束。你没有会话历史,也不出现在工作区侧栏,不承担多环节工作;如果调查需要多轮推进或步骤可见,应把决定交回调用你的 agent,由它决定是否用 `session_spawn` 创建 primary agent 子会话。
@@ -212,7 +212,9 @@ export function parseRoster(raw: string | undefined): RosterEntry[] {
212
212
  * that matters most: it is the difference between a chain that works and a chain where every step works
213
213
  * from the same wrong assumptions.
214
214
  */
215
- export const TASK_DESCRIPTION = `Launch a subagent to handle a complex, multistep task autonomously.
215
+ export const TASK_DESCRIPTION = `This is a one-shot, tool-level intelligent invocation. It runs once, returns a final result, and ends; it has no conversation history, does not appear in the workspace sidebar, and the user cannot see intermediate steps.
216
+
217
+ Use it for a clearly scoped, self-contained task that can be completed in one delegation, such as one research pass, one review, one locating task, or one small patch.
216
218
 
217
219
  You must specify a subagent_type to select which subagent to use.
218
220
 
@@ -221,16 +223,17 @@ When NOT to use this tool:
221
223
  - If you are searching for a specific class definition like "class Foo", use the Grep tool instead, to find the match more quickly
222
224
  - If you are searching for code within a specific file or set of 2-3 files, use the Read tool instead, to find the match more quickly
223
225
  - If no available subagent is a good fit for the task, use other tools directly
226
+ - If the task has multiple phases and the user needs to see each step, inspect progress, add input, or continue the dialogue, use session_spawn to create a child session for a primary agent instead of this tool
224
227
 
225
228
  Usage notes:
226
- 1. Every dispatch starts a SEPARATE agent process that runs until it finishes, so the cost of a delegation is minutes rather than seconds. Delegate work that is genuinely substantial; do not delegate a lookup you could do in one tool call.
229
+ 1. Every dispatch starts a SEPARATE agent process that runs once and returns one result, so use it for a focused deliverable rather than a lookup you could do in one tool call.
227
230
  2. The dispatch is ALWAYS ASYNCHRONOUS. The call returns immediately with state="running" and the sub-agent's answer arrives as a follow-up turn when it finishes. You CAN dispatch several in one turn; each returns right away, and the answers stream back as separate follow-up turns in the order the sub-agents settle. Do NOT sleep, poll, or duplicate the dispatch.
228
231
  3. Once you have delegated work to a subagent, do not duplicate that work yourself. Continue with non-overlapping tasks.
229
232
  4. When the subagent is done it returns ONE message back to you, wrapped in a <task> element. That result is not visible to the user: if it matters to the user, say so in your own reply.
230
233
  5. Each dispatch starts with a FRESH context. Your prompt is all the subagent will know, so it must contain the full task, and it must say exactly what you want back in its final message.
231
234
  6. Tell the subagent whether you expect it to WRITE CODE or only to RESEARCH (search, file reads, web fetches), and how to verify its work if it writes. It is not aware of the user's intent.
232
235
  7. If a subagent's description says it should be used proactively, use it without being asked.
233
- 8. To CHAIN sub-agents, write the first dispatch's expected answer INTO the second dispatch's prompt, because the next sub-agent starts with a fresh context and cannot see what the first one found. The tool does not do this for you. For three or more chained steps, prefer the workflow tool: it runs the chain server-side and hands each step the previous step's output without you copying it through your context.
236
+ 8. Do not use this tool as a multi-step pipeline. If the work has multiple phases or needs visible progress and continued dialogue, use session_spawn to create a child session for a primary agent; keep each task delegation self-contained and limited to one final result.
234
237
  9. To run a SHELL COMMAND in the background (a long build, a test suite, a watcher, anything measured in seconds to minutes), use the run_async tool. This tool is for delegating to a specialist sub-agent, not for plain commands.`;
235
238
 
236
239
  /**
@@ -1135,7 +1138,7 @@ export async function executeScheduledTask(
1135
1138
  export const PROJECT_TOOL_NAME = "project";
1136
1139
  export const PROJECT_ENDPOINT_ENV = "SUPER_PI_PROJECT_ENDPOINT";
1137
1140
 
1138
- export const PROJECT_DESCRIPTION = `Manage a user-triggered project through accountable delegation, evidence and independent review. When the user describes a project in natural language, decompose it yourself into title, objective, deliverables, acceptanceCriteria and budget, then call create with those fields and the top-level tasks you derived. Create also accepts optional constraints, risk, budget with maxTokens/maxConcurrent, and default profiles defaultLeaderProfile/defaultExecutorProfile/defaultReviewerProfile. Create also accepts an optional mode: standard (the default) or lightweight. For a small self-contained project, create it with mode="lightweight": the project leader session does the work itself, the project has no separate worker or reviewer sessions, and a task is accepted on the worker's own evidence. Use the standard mode when the work needs an independent review. In a lightweight project the leader registers only executor tasks, never splits into child tasks and never asks for a review - a submitted task is a completed task. The conversation that created a project may cancel it with action="cancel" and a reason: the project is marked cancelled, its running sessions are stopped, and its record, tasks, events and evidence are kept. Only that initiating conversation may cancel it - a worker or reviewer cannot cancel the project it belongs to. The tasks array carries that decomposition: each entry needs a title and an objective, and its dependencies name the titles of sibling tasks in the same array. The project starts on action="start" - call it only after you have registered the top-level tasks, because the leader session begins decomposing the work the moment it starts. You are the initiator: you may create the project, register top-level tasks and start it; you may not register child tasks, change the budget or cancel the scope. Only a root conversation may create a project. Top-level tasks can also be registered later with add_task. When the user asks "我的项目现在怎么样", "我还有哪些项目在跑", "列出所有项目", or wants an overview of running projects, call action="list" first to retrieve all related projects with lightweight summaries (headline, task counts, active workers, tokens) without needing a projectId. Never guess a projectId to call get blindly; only call get when the user targets a specific project and you need deep task or event details. Read the latest state with get. The project leader uses add_task (title, objective, deliverables, acceptanceCriteria, dependencies, role=leader/executor, optional executorProfile/reviewerProfile with agentId, cwd, model, thinkingLevel, watchdogTimeoutSeconds), dispatch and request_review. A branch leader creates children with parentTaskId set to its own task ID and manages only its direct tasks. Dependencies must be siblings. Leader aggregate submission requires independently accepted children. Keep at most 3 leader levels and 8 branch leaders; small projects need only one executor. Workers submit output plus evidenceRefs. Only the assigned independent reviewer can review with verdict accepted or changes_requested, summary and evidenceRefs. update_task marks blocked/failed with blockedReason, updates executorProfile/reviewerProfile before child sessions spawn, or the leader resets ready for retry. report records kind=progress/blocked, progress, variance, nextStep, risks, decisionNeeded and evidenceRefs. escalate records reason and severity=low/medium/high for Boss decisions. complete requires all tasks accepted - independently reviewed in the standard mode, self-accepted in the lightweight mode - and a final summary with evidenceRefs. action="export" returns the project as a Markdown report: the objective, every task with its delivery, evidence and review, the exceptions and how they were decided, and the full timeline. Use it when the user asks for a summary, a handover, or a status write-up of the project. Project and task IDs come from create/get/add_task. Reads never invoke models. Dispatch is asynchronous and consumes budget; stop polling when capacity is full and wait for child completion reports. Do not use session_spawn, session_dispatch, task or workflow to bypass the project dispatch guard. Never claim success on an error.`;
1141
+ export const PROJECT_DESCRIPTION = `Manage a user-triggered project through accountable delegation, evidence and independent review. When the user describes a project in natural language, decompose it yourself into title, objective, deliverables, acceptanceCriteria and budget, then call create with those fields and the top-level tasks you derived. Create also accepts optional constraints, risk, budget with maxTokens/maxConcurrent, and default profiles defaultLeaderProfile/defaultExecutorProfile/defaultReviewerProfile. Create also accepts an optional mode: standard (the default) or lightweight. For a small self-contained project, create it with mode="lightweight": the project leader session does the work itself, the project has no separate worker or reviewer sessions, and a task is accepted on the worker's own evidence. Use the standard mode when the work needs an independent review. In a lightweight project the leader registers only executor tasks, never splits into child tasks and never asks for a review - a submitted task is a completed task. The conversation that created a project may cancel it with action="cancel" and a reason: the project is marked cancelled, its running sessions are stopped, and its record, tasks, events and evidence are kept. Only that initiating conversation may cancel it - a worker or reviewer cannot cancel the project it belongs to. The tasks array carries that decomposition: each entry needs a title and an objective, and its dependencies name the titles of sibling tasks in the same array. The project starts on action="start" - call it only after you have registered the top-level tasks, because the leader session begins decomposing the work the moment it starts. You are the initiator: you may create the project, register top-level tasks and start it; you may not register child tasks, change the budget or cancel the scope. Only a root conversation may create a project. Top-level tasks can also be registered later with add_task. When the user asks "我的项目现在怎么样", "我还有哪些项目在跑", "列出所有项目", or wants an overview of running projects, call action="list" first to retrieve up to 20 most recently updated projects with lightweight summaries (headline, task counts, active workers, tokens) without needing a projectId; the response returns projects, total, and returned counts, where total > returned indicates more historical projects exist in the workspace. Never guess a projectId to call get blindly; only call get when the user targets a specific project and you need deep task or event details. Read the latest state with get. The project leader uses add_task (title, objective, deliverables, acceptanceCriteria, dependencies, role=leader/executor, optional executorProfile/reviewerProfile with agentId, cwd, model, thinkingLevel, watchdogTimeoutSeconds), dispatch and request_review. A branch leader creates children with parentTaskId set to its own task ID and manages only its direct tasks. Dependencies must be siblings. Leader aggregate submission requires independently accepted children. Keep at most 3 leader levels and 8 branch leaders; small projects need only one executor. Workers submit output plus evidenceRefs. Only the assigned independent reviewer can review with verdict accepted or changes_requested, summary and evidenceRefs. update_task marks blocked/failed with blockedReason, updates executorProfile/reviewerProfile before child sessions spawn, or the leader resets ready for retry. report records kind=progress/blocked, progress, variance, nextStep, risks, decisionNeeded and evidenceRefs; blocked reports notify your direct supervisor rather than directly alerting Boss. escalate records reason and severity=low/medium/high; member escalations route to your direct supervisor, and only project leader escalations reach Boss. resolve_escalation closes an escalation that was addressed to you: pass escalationId, decision and status (resolved or dismissed, default resolved). It only accepts a supervisor escalation whose target session is your own; an escalation addressed to Boss is the Boss's to decide and is refused for you. Resolving it cascades: the member who raised the escalation is woken up with your decision. complete requires all tasks accepted - independently reviewed in the standard mode, self-accepted in the lightweight mode - and a final summary with evidenceRefs. action="export" returns the project as a Markdown report: the objective, every task with its delivery, evidence and review, the exceptions and how they were decided, and the full timeline. Use it when the user asks for a summary, a handover, or a status write-up of the project. Project and task IDs come from create/get/add_task. Reads never invoke models. Dispatch is asynchronous and consumes budget; stop polling when capacity is full and wait for child completion reports. Do not use session_spawn, session_dispatch, task or workflow to bypass the project dispatch guard. Never claim success on an error.`;
1139
1142
 
1140
1143
  export function readProjectConfig(env: Record<string, string | undefined>) {
1141
1144
  return { endpoint: env[PROJECT_ENDPOINT_ENV] ?? "", conversationId: env[TASK_CONVERSATION_ENV] ?? "", workspaceId: env.SUPER_PI_ORCHESTRATOR_WORKSPACE ?? "", capability: env[TASK_CAPABILITY_ENV] };
@@ -1163,21 +1166,22 @@ export const SESSION_REPORT_TOOL_NAME = "session_report";
1163
1166
  export const SESSION_STOP_SUBTREE_TOOL_NAME = "session_stop_subtree";
1164
1167
 
1165
1168
  /** Model-facing description for session_spawn. */
1166
- export const SESSION_SPAWN_DESCRIPTION = `Create a new sibling conversation in the current workspace and immediately dispatch its initial task.
1169
+ export const SESSION_SPAWN_DESCRIPTION = `Create a child conversation in the current workspace and immediately dispatch its initial task. You can specify a primary agent as the child's role.
1167
1170
 
1168
1171
  DIFFERENCE FROM THE 'task' TOOL:
1169
1172
  - The 'task' tool delegates to a transient, one-shot subagent process (scout, critic, patcher) that runs once, returns its final text, and terminates. It has no conversation history and does not appear in the workspace sidebar.
1170
- - 'session_spawn' creates a real, persistent sibling CONVERSATION in Super Pi. It appears in the sidebar, retains multi-turn message history, can receive follow-up messages via session_dispatch, can be inspected via session_status, and can be stopped via session_stop. The user can also switch to it in the Web UI.
1173
+ - 'session_spawn' creates a real, persistent child CONVERSATION in Super Pi. It appears in the sidebar, retains multi-turn message history, can receive follow-up messages via session_dispatch, can be inspected via session_status, and can be stopped via session_stop. The user can also switch to it in the Web UI.
1171
1174
 
1172
1175
  WHEN TO USE THIS:
1173
1176
  - Long-running, multi-phase tracks of work that require ongoing context, multiple turns of dialogue, or independent user visibility.
1177
+ - Multi-phase or complex work where the user needs each step to be visible and available for inspection or intervention: create a child session with session_spawn.
1174
1178
  - Parallel work streams (e.g., Track A: backend refactor, Track B: frontend component update) where both need full conversational capabilities.
1175
1179
  - When the user asks you to act as an orchestrator/manager who delegates to multiple sessions.
1176
1180
 
1177
1181
  WHEN NOT TO USE THIS:
1178
1182
  - For one-off, focused delegation with a single answer: use 'task' (with scout/critic/patcher). It is faster, cheaper, and returns directly to your transcript.
1179
1183
  - For running shell commands or build watchers: use 'run_async'.
1180
- - For a linear multi-step subagent pipeline: use 'workflow'.
1184
+ - For a single one-off delegation with a single answer: use 'task'.
1181
1185
 
1182
1186
  Usage notes:
1183
1187
  1. Spawning is ASYNCHRONOUS by default: it creates the conversation, enqueues the initial task, and returns the new conversationId immediately. The sibling session runs in the background.
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: 验证员
3
3
  mode: subagent
4
- description: 跑命令做验证:执行测试、构建或检查入口,如实贴出命令原文、退出码和失败行,不改任何文件。改完代码要确认通没通、或者需要亲眼看一次真实输出时用它。
4
+ description: 一次性的 tool 级验证调用:执行指定测试、构建或检查入口,交付真实命令输出后结束。不改任何文件。没有会话、不出现在侧栏,不承担多环节工作;项目里的验证应使用 primary agent。
5
5
  color: "#5AC8FA"
6
6
  tools:
7
7
  "*": false
@@ -18,4 +18,8 @@ tools:
18
18
  - 把真实输出贴出来:命令原文、退出码、失败那几行原文。不要写「应该没问题」「看起来正常」这种话——你没资格说这种话,你只看得见输出。
19
19
  - 测试失败时定位到具体是哪个测试、哪一行断言、期望值和实际值各是什么,然后停下。不要修。
20
20
  - 命令跑不起来时要分清是环境问题(缺依赖、端口占用、可执行文件找不到)还是测试失败,两者的结论完全不同,不要混着说。
21
- - 最后一行给结论:`通过`、`失败`、`无法验证`,三选一,不要含糊。
21
+ - 最后一行给结论:`通过`、`失败`、`无法验证`,三选一,不要含糊。
22
+
23
+ ## 调用边界
24
+
25
+ 你是一次性的、tool 级的智能调用:接到一个明确的问题后交一份验证结果就结束。你没有会话历史,也不出现在工作区侧栏,不承担多环节工作;如果验证需要多轮推进或步骤可见,应把决定交回调用你的 agent,由它决定是否用 `session_spawn` 创建 primary agent 子会话。
@@ -1,7 +1,7 @@
1
1
  {
2
- "hash": "b86925e03d85b13b4e29cda4d8b99942fc8b789fd977f84afca9b30772353083",
2
+ "hash": "5c7c9246e0f3780b77202726d0e46e628c873a5c5dfb8a54710f4f0fbeec44d7",
3
3
  "files": {
4
- "src/client/App.tsx": "01d84e9f5640da878dff889ff40f6a59ea1db975b7678634685041e69c079ff4",
4
+ "src/client/App.tsx": "f03f50523c96353361f2b73ee198ec49f0c2212af4ab8bf6396a42de3050afa8",
5
5
  "src/client/CodeMirrorEditor.tsx": "b6b6479effa1482eda710f04a26f3af843515526e129ca5bc70692cca9074b09",
6
6
  "src/client/ErrorBoundary.tsx": "d16376f9f6c7cc1fab8590c65a66438127642f7d6bb8023cec53d8a6cc9f3964",
7
7
  "src/client/FeishuPanel.tsx": "52f116eba265bfde683338f5893107ad5559fd2f7d4a9e0df935507a46862a3b",
@@ -12,13 +12,14 @@
12
12
  "src/client/KnowledgePanel.tsx": "4f7230cfe610cd86d63aa143c82f6195b3c4208ef0bea703f92104ef27237704",
13
13
  "src/client/MarkdownView.tsx": "4f04a8f3c9381946e5d2f957ac4fb74a6b16272e90375fb4dc6bd3a43d7c744d",
14
14
  "src/client/MemoryPanel.tsx": "59a74f5789f43708245b6f62ba3b873ad91804f64c1e352403d5b7dffd478fdc",
15
- "src/client/ProjectControlPanel.tsx": "e5707ad5284877c1a362db305da8629ffede167becf90479a4d15cd414f5bb3d",
16
- "src/client/ProjectExecutionTools.tsx": "631bf799a9d1fcce6d6427001da41385cd66c509c3b416938d04959ff6e8b252",
15
+ "src/client/ProjectControlPanel.tsx": "707504b028e5b596b4bc3299a711774606a4f8a0436efd450f4d29f0da4b03eb",
16
+ "src/client/ProjectExecutionTools.tsx": "0eaad265d5061241546f35a14a4fa26db639c6410c7be09a99836591f764c207",
17
17
  "src/client/ScheduledTasksPanel.tsx": "ad8d929b73c7d332730fd41a8594e3d79930161121d5727b94d39a089d36d9c8",
18
18
  "src/client/SlashCommandMenu.tsx": "69cd0a9d5e35f41f703e91a845e5bd750c952d2957be03b5528e156e60bf6ecb",
19
19
  "src/client/Tabs.tsx": "87b2154b614b6593b3fd75577f6e8356a32d80506165c301eb99db3cec520abe",
20
20
  "src/client/TerminalPanel.tsx": "89db360a96c47e4afa7d84bbeada7ab765794a6a28b8c1260f15a71fbf948201",
21
21
  "src/client/WorkflowCard.tsx": "8ce5458537a3b02dcbb9bbb4c7afacb07e0f41857ed250aa4cde0cbc8d4bde6c",
22
+ "src/client/agent-order.ts": "0459b830d605b60c9e07825c62c226bd2bf053c5875a0ff5d1290f285e265478",
22
23
  "src/client/editor-blame.ts": "d03669f945aca09ff77d100ef0d4f0129af4f8ccef81963c3ce00f8f6fb034c2",
23
24
  "src/client/editor-languages.ts": "d5319cfd9b9f3b07c2599ba64ec49a9038304d09fa1702302f3b2b97493d0a69",
24
25
  "src/client/errors.ts": "e2e3b417a02eca0870237f5f502041a06a91a56d3d508161b1afca4dd6101889",
@@ -27,17 +28,18 @@
27
28
  "src/client/main.tsx": "d6325cec79ebc225e4972c33ad9b4266fa1eab5f962fec36ed4c539124a8fcab",
28
29
  "src/client/markdown.ts": "1499893ea5ce29d49f26c193cc0e6001ffa8a31d039ccee343ba407cd2cdbf1b",
29
30
  "src/client/pending-operations.ts": "8a5f9e9711c0f875c8ed194196c218162de5270298dad4091351d41294c859d7",
31
+ "src/client/project-evidence.ts": "3bc5ea85f6b20a19a36cfdd4a958d83dd53b21f3d8f20fae1914a575dfbad3c4",
30
32
  "src/client/session-tree.ts": "affc00d2264926d615a38e458a89d3a8c651b74135bbfe004d0a9be9b14a0c86",
31
33
  "src/client/slash-commands.ts": "b792018fb67bd9e6f777397b0720b8b3aa565a4d8f7a76f94fec097ddf749480",
32
- "src/client/styles.css": "0f25dfc92a267122fc43cb5a6a98f20bd6fe3c2ded5bb9352297dc6803ef44e7",
34
+ "src/client/styles.css": "2aa4246c6e82fca3a66d5fa7050c5d3490cd4cadd6e58f6c8081c9c4d3a7f902",
33
35
  "src/client/terminal-emulator.ts": "ffcc4f5fbddaf25cebcc9e03dbe5d7d0ad2c21586f5d169e57c04c82e2308b3b",
34
- "src/client/theme.tsx": "5892479a802f41e7d45adeb5170efbf555b240f8581528bcde7bf2d99c635010",
36
+ "src/client/theme.tsx": "0e2ff1b493356a26aae1ca0d1373da9b89b117dd0a15a39c3c03b86df0bff2c2",
35
37
  "src/client/tool-launcher.ts": "40fb4974362bbc8c73ecd651da1abce251fc28857564a9321037adcfdb0bfe24",
36
38
  "src/client/tool-sharing.ts": "679c97f6d40be466964f2f1076aa7ea55f4a585c3deff8214675070220921059",
37
39
  "src/client/tool-shortcuts.ts": "cbd89186776cab19b8b3ec40b8a755c4fc2a47d1c03653eca55e6b23b865c3b6",
38
40
  "src/client/tools.ts": "58fe41f0edbd490e3fab7f12f258b1dbc2163b653553b03ac61caf1543618e50",
39
- "src/client/types.ts": "b4d24bfabf230e29b984cf698aeb579c19797139a2b358f1a4e61cafce02964d",
41
+ "src/client/types.ts": "7eb172070e507c7eb4c6462a325282cb32e292a3eb10adc77e7971140fd54476",
40
42
  "src/client/vite-env.d.ts": "65996936fbb042915f7b74a200fcdde7e410f32a669b1ab9597cfaa4b0faddb5"
41
43
  },
42
- "recordedAt": "2026-11-04T21:33:23.463Z"
44
+ "recordedAt": "2026-11-06T23:42:29.035Z"
43
45
  }
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/dist-CdpuBRoy.js","assets/dist-BDy5Nw4_.js","assets/index-1hS3wVqF.js","assets/index-Wtlj0s4R.css","assets/dist-CGO5Bn1x.js","assets/dist-D607J8oC.js","assets/dist-CxZb6ATc.js","assets/dist-BmeBkDNB.js","assets/dist-BLhPsVFt.js","assets/dist-C4ql8ak8.js","assets/dist-ByEzPyEi.js","assets/dist-BhouAfNI.js","assets/dist-DJ4sWDSy.js","assets/dist-BBfDBMAk.js","assets/dist-B5xG-jTK.js","assets/dist-CF9zuubZ.js","assets/dist-DaUyp_NN.js","assets/dist-D6nsZZd3.js","assets/dist-qqDS87aN.js","assets/dist-CrJV_eES.js","assets/dist-Foaz_oK2.js","assets/dist-CsBiEr54.js","assets/dist-7Nz91m3a.js","assets/dist-BjlmPyRl.js"])))=>i.map(i=>d[i]);
2
- import{a as e,i as t,n,r,s as i,t as a}from"./index-1hS3wVqF.js";var o=i(e(),1);async function s(e,t){let[{StreamLanguage:n},i]=await Promise.all([r(()=>import(`./dist-CdpuBRoy.js`),__vite__mapDeps([0,1,2,3,4,5])),e()]),a=i[t]??i.default??i;return n.define(a)}var c={cpp:()=>r(()=>import(`./dist-CxZb6ATc.js`).then(e=>e.cpp()),__vite__mapDeps([6,5,2,3,0,1,4,7])),cc:()=>r(()=>import(`./dist-CxZb6ATc.js`).then(e=>e.cpp()),__vite__mapDeps([6,5,2,3,0,1,4,7])),cxx:()=>r(()=>import(`./dist-CxZb6ATc.js`).then(e=>e.cpp()),__vite__mapDeps([6,5,2,3,0,1,4,7])),hpp:()=>r(()=>import(`./dist-CxZb6ATc.js`).then(e=>e.cpp()),__vite__mapDeps([6,5,2,3,0,1,4,7])),hh:()=>r(()=>import(`./dist-CxZb6ATc.js`).then(e=>e.cpp()),__vite__mapDeps([6,5,2,3,0,1,4,7])),hxx:()=>r(()=>import(`./dist-CxZb6ATc.js`).then(e=>e.cpp()),__vite__mapDeps([6,5,2,3,0,1,4,7])),c:()=>r(()=>import(`./dist-CxZb6ATc.js`).then(e=>e.cpp()),__vite__mapDeps([6,5,2,3,0,1,4,7])),h:()=>r(()=>import(`./dist-CxZb6ATc.js`).then(e=>e.cpp()),__vite__mapDeps([6,5,2,3,0,1,4,7])),cu:()=>r(()=>import(`./dist-CxZb6ATc.js`).then(e=>e.cpp()),__vite__mapDeps([6,5,2,3,0,1,4,7])),cuh:()=>r(()=>import(`./dist-CxZb6ATc.js`).then(e=>e.cpp()),__vite__mapDeps([6,5,2,3,0,1,4,7])),js:()=>r(()=>import(`./dist-BLhPsVFt.js`).then(e=>e.t).then(e=>e.javascript()),__vite__mapDeps([8,2,3,1,4,5,0,7,9])),jsx:()=>r(()=>import(`./dist-BLhPsVFt.js`).then(e=>e.t).then(e=>e.javascript({jsx:!0})),__vite__mapDeps([8,2,3,1,4,5,0,7,9])),mjs:()=>r(()=>import(`./dist-BLhPsVFt.js`).then(e=>e.t).then(e=>e.javascript()),__vite__mapDeps([8,2,3,1,4,5,0,7,9])),cjs:()=>r(()=>import(`./dist-BLhPsVFt.js`).then(e=>e.t).then(e=>e.javascript()),__vite__mapDeps([8,2,3,1,4,5,0,7,9])),ts:()=>r(()=>import(`./dist-BLhPsVFt.js`).then(e=>e.t).then(e=>e.javascript({typescript:!0})),__vite__mapDeps([8,2,3,1,4,5,0,7,9])),tsx:()=>r(()=>import(`./dist-BLhPsVFt.js`).then(e=>e.t).then(e=>e.javascript({typescript:!0,jsx:!0})),__vite__mapDeps([8,2,3,1,4,5,0,7,9])),mts:()=>r(()=>import(`./dist-BLhPsVFt.js`).then(e=>e.t).then(e=>e.javascript({typescript:!0})),__vite__mapDeps([8,2,3,1,4,5,0,7,9])),cts:()=>r(()=>import(`./dist-BLhPsVFt.js`).then(e=>e.t).then(e=>e.javascript({typescript:!0})),__vite__mapDeps([8,2,3,1,4,5,0,7,9])),py:()=>r(()=>import(`./dist-ByEzPyEi.js`).then(e=>e.python()),__vite__mapDeps([10,5,2,3,0,1,4,7,9])),pyi:()=>r(()=>import(`./dist-ByEzPyEi.js`).then(e=>e.python()),__vite__mapDeps([10,5,2,3,0,1,4,7,9])),java:()=>r(()=>import(`./dist-BhouAfNI.js`).then(e=>e.java()),__vite__mapDeps([11,5,2,3,0,1,4,7])),php:()=>r(()=>import(`./dist-DJ4sWDSy.js`).then(e=>e.php()),__vite__mapDeps([12,5,2,3,0,1,4,7,13,14,8,9])),sql:()=>r(()=>import(`./dist-CF9zuubZ.js`).then(e=>e.sql()),__vite__mapDeps([15,5,2,3,0,1,4,7,9])),yaml:()=>r(()=>import(`./dist-DaUyp_NN.js`).then(e=>e.yaml()),__vite__mapDeps([16,5,2,3,0,1,4,7])),yml:()=>r(()=>import(`./dist-DaUyp_NN.js`).then(e=>e.yaml()),__vite__mapDeps([16,5,2,3,0,1,4,7])),xml:()=>r(()=>import(`./dist-D6nsZZd3.js`).then(e=>e.xml()),__vite__mapDeps([17,1,2,3,4,5,0,7])),json:()=>r(()=>import(`./dist-qqDS87aN.js`).then(e=>e.json()),__vite__mapDeps([18,5,2,3,0,1,4,7])),jsonc:()=>r(()=>import(`./dist-qqDS87aN.js`).then(e=>e.json()),__vite__mapDeps([18,5,2,3,0,1,4,7])),json5:()=>r(()=>import(`./dist-qqDS87aN.js`).then(e=>e.json()),__vite__mapDeps([18,5,2,3,0,1,4,7])),html:()=>r(()=>import(`./dist-BBfDBMAk.js`).then(e=>e.html()),__vite__mapDeps([13,1,2,3,4,5,0,7,14,8,9])),htm:()=>r(()=>import(`./dist-BBfDBMAk.js`).then(e=>e.html()),__vite__mapDeps([13,1,2,3,4,5,0,7,14,8,9])),vue:()=>r(()=>import(`./dist-BBfDBMAk.js`).then(e=>e.html()),__vite__mapDeps([13,1,2,3,4,5,0,7,14,8,9])),svelte:()=>r(()=>import(`./dist-BBfDBMAk.js`).then(e=>e.html()),__vite__mapDeps([13,1,2,3,4,5,0,7,14,8,9])),css:()=>r(()=>import(`./dist-B5xG-jTK.js`).then(e=>e.r).then(e=>e.css()),__vite__mapDeps([14,2,3,5,0,1,4,7])),md:()=>r(()=>import(`./dist-CrJV_eES.js`).then(e=>e.markdown()),__vite__mapDeps([19,1,2,3,4,5,0,9,13,7,14,8])),markdown:()=>r(()=>import(`./dist-CrJV_eES.js`).then(e=>e.markdown()),__vite__mapDeps([19,1,2,3,4,5,0,9,13,7,14,8])),mdx:()=>r(()=>import(`./dist-CrJV_eES.js`).then(e=>e.markdown()),__vite__mapDeps([19,1,2,3,4,5,0,9,13,7,14,8])),rs:()=>r(()=>import(`./dist-Foaz_oK2.js`).then(e=>e.rust()),__vite__mapDeps([20,5,2,3,0,1,4,7])),go:()=>r(()=>import(`./dist-CsBiEr54.js`).then(e=>e.go()),__vite__mapDeps([21,5,2,3,0,1,4,7,9])),sh:()=>s(()=>r(()=>import(`./shell-DwuoZtxw.js`),[]),`shell`),bash:()=>s(()=>r(()=>import(`./shell-DwuoZtxw.js`),[]),`shell`),zsh:()=>s(()=>r(()=>import(`./shell-DwuoZtxw.js`),[]),`shell`),fish:()=>s(()=>r(()=>import(`./shell-DwuoZtxw.js`),[]),`shell`),ps1:()=>s(()=>r(()=>import(`./powershell-D8WpQPaX.js`),[]),`powershell`),psm1:()=>s(()=>r(()=>import(`./powershell-D8WpQPaX.js`),[]),`powershell`),rb:()=>s(()=>r(()=>import(`./ruby-ChfNwlCY.js`),[]),`ruby`),swift:()=>s(()=>r(()=>import(`./swift-DKB6_1j6.js`),[]),`swift`),toml:()=>s(()=>r(()=>import(`./toml-BPTmHmyx.js`),[]),`toml`),ini:()=>s(()=>r(()=>import(`./properties-C357ku5U.js`),[]),`properties`),cfg:()=>s(()=>r(()=>import(`./properties-C357ku5U.js`),[]),`properties`),conf:()=>s(()=>r(()=>import(`./properties-C357ku5U.js`),[]),`properties`),properties:()=>s(()=>r(()=>import(`./properties-C357ku5U.js`),[]),`properties`),dockerfile:()=>s(()=>r(()=>import(`./dockerfile-BDePf5PZ.js`),[]),`dockerfile`),diff:()=>s(()=>r(()=>import(`./diff-ChtP43wD.js`),[]),`diff`),patch:()=>s(()=>r(()=>import(`./diff-ChtP43wD.js`),[]),`diff`)},l={cpp:`C++`,cc:`C++`,cxx:`C++`,hpp:`C++`,hh:`C++`,hxx:`C++`,cu:`CUDA C++`,cuh:`CUDA C++`,c:`C`,h:`C/C++ Header`,js:`JavaScript`,jsx:`JSX`,mjs:`JavaScript`,cjs:`JavaScript`,ts:`TypeScript`,tsx:`TSX`,mts:`TypeScript`,cts:`TypeScript`,py:`Python`,pyi:`Python Stub`,java:`Java`,php:`PHP`,sql:`SQL`,yaml:`YAML`,yml:`YAML`,xml:`XML`,json:`JSON`,jsonc:`JSON with Comments`,json5:`JSON5`,css:`CSS`,md:`Markdown`,markdown:`Markdown`,mdx:`MDX`,rs:`Rust`,go:`Go`,html:`HTML`,htm:`HTML`,vue:`Vue`,svelte:`Svelte`,sh:`Shell`,bash:`Bash`,zsh:`Zsh`,fish:`Fish`,ps1:`PowerShell`,psm1:`PowerShell`,rb:`Ruby`,swift:`Swift`,toml:`TOML`,ini:`INI`,cfg:`Config`,conf:`Config`,properties:`Properties`,dockerfile:`Dockerfile`,diff:`Diff`,patch:`Patch`};function u(e){return c[e.toLowerCase()]}function d(e){return l[e.toLowerCase()]}var f=t(),p=262144,m=131072;function h(e){return e.split(`.`).pop()?.toLowerCase()??``}function g(e){return getComputedStyle(document.documentElement).getPropertyValue(e).trim()}function _(e,t){return e.HighlightStyle.define([{tag:t.tags.keyword,color:g(`--cm-keyword`)},{tag:t.tags.string,color:g(`--cm-string`)},{tag:t.tags.number,color:g(`--cm-number`)},{tag:t.tags.comment,color:g(`--cm-comment`),fontStyle:`italic`},{tag:t.tags.function(t.tags.variableName),color:g(`--cm-function`)},{tag:t.tags.typeName,color:g(`--cm-type`)},{tag:t.tags.className,color:g(`--cm-type`)},{tag:t.tags.propertyName,color:g(`--cm-property`)},{tag:t.tags.operator,color:g(`--cm-operator`)},{tag:t.tags.variableName,color:g(`--cm-variable`)}])}function v({path:e,value:t,onChange:i,jumpToLine:s,onSave:c,workspaceId:l,blame:g}){let v=(0,o.useRef)(null),y=(0,o.useRef)(null),b=(0,o.useRef)(null),x=(0,o.useRef)(null),S=(0,o.useRef)(null),C=(0,o.useRef)(null),w=(0,o.useRef)(null),T=(0,o.useRef)(null),E=(0,o.useRef)(i),D=(0,o.useRef)(c);E.current=i,D.current=c;let[O,k]=(0,o.useState)(!1),[A,j]=(0,o.useState)(!1),[M,N]=(0,o.useState)(`0,0`),[P,F]=(0,o.useState)(0);(0,o.useEffect)(()=>{let i=!1,a,o,s,c,l;return(async()=>{try{let d=h(e),f=u(d),[m,g,O,A,M,P,I,L]=await Promise.all([r(()=>import(`./dist-BDy5Nw4_.js`).then(e=>e.x),__vite__mapDeps([1,2,3])),r(()=>import(`./dist-CGO5Bn1x.js`).then(e=>e.s),__vite__mapDeps([4,2,3,1])),r(()=>import(`./dist-7Nz91m3a.js`),__vite__mapDeps([22,1,2,3,4,5,0])),r(()=>import(`./dist-BjlmPyRl.js`),__vite__mapDeps([23,1,2,3,4])),r(()=>import(`./dist-CdpuBRoy.js`),__vite__mapDeps([0,1,2,3,4,5])),r(()=>import(`./dist-D607J8oC.js`).then(e=>e.n),__vite__mapDeps([5,2,3])),f?f().catch(e=>(console.warn(`[CodeMirror] Failed to load language for .${d}:`,e),null)):Promise.resolve(null),n().catch(e=>(console.warn(`[CodeMirror] Failed to build the blame extension:`,e),null))]);if(i||!v.current)return;c=M,l=P,x.current=m.Annotation.define(),S.current=m.Transaction.addToHistory;let R=t.length<=p&&I!==null;o=new m.Compartment;let z=[g.lineNumbers(),g.highlightActiveLine(),g.drawSelection(),O.history(),g.keymap.of([O.indentWithTab,...O.defaultKeymap,...O.historyKeymap,...A.searchKeymap,{key:`Mod-s`,run:()=>(D.current(),!0)}]),g.EditorView.updateListener.of(e=>{e.docChanged&&!(x.current&&e.transactions.some(e=>e.annotation(x.current)===!0))&&E.current(e.state.doc.toString()),e.selectionSet&&N(`${e.state.selection.main.from},${e.state.selection.main.to}`)}),g.EditorView.domEventHandlers({mousedown:(e,t)=>(t.focus(),!1)})];if(L&&(s=new m.Compartment,z.splice(1,0,s.of([])),z.push(L.base)),I)try{z.push(I)}catch(e){console.warn(`[CodeMirror] Failed to apply language extension for .${d}:`,e),R=!1}if(R&&o&&c&&l)try{z.push(o.of(c.syntaxHighlighting(_(c,l))))}catch(e){console.warn(`[CodeMirror] Failed to attach syntaxHighlighting for .${d}:`,e),R=!1}if(a=new g.EditorView({state:m.EditorState.create({doc:t,extensions:z}),parent:v.current}),i){a.destroy();return}y.current=a,k(R),j(!0),C.current=L,w.current=s??null,T.current=null,F(e=>e+1);let B=new MutationObserver(()=>{let e=y.current;if(e&&R&&o&&c&&l)try{e.dispatch({effects:o.reconfigure(c.syntaxHighlighting(_(c,l)))})}catch{}});b.current=B,B.observe(document.documentElement,{attributes:!0,attributeFilter:[`data-theme`]})}catch(e){console.error(`[CodeMirror] Fatal editor initialization error:`,e),i||j(!0)}})(),()=>{i=!0,b.current?.disconnect(),b.current=null,a?.destroy(),y.current=null,j(!1),v.current&&(v.current.textContent=``)}},[e]),(0,o.useEffect)(()=>{let e=y.current;if(!e)return;let n=e.state.doc.toString();n!==t&&e.dispatch({changes:{from:0,to:n.length,insert:t},annotations:x.current?x.current.of(!0):void 0})},[t]),(0,o.useEffect)(()=>{let e=y.current;if(!e||!s)return;let t=e.state.doc.line(Math.min(Math.max(1,s.line),e.state.doc.lines));e.dispatch({selection:{anchor:t.from,head:t.to},scrollIntoView:!0}),e.focus()},[s,A]);let I=!!(g&&g.state===`ready`&&g.response&&g.path===e&&g.workspaceId===l);(0,o.useEffect)(()=>{let t=y.current,n=C.current,r=w.current;if(!t||!n||!r)return;let i=g&&g.state===`ready`&&g.response&&g.path===e&&g.workspaceId===l?g.response:null,o=i?a(i):null;T.current!==o&&(T.current=o,t.dispatch({effects:[n.setBlame.of(o),r.reconfigure(o?n.gutter:[])]}))},[g?.state,g?.response,g?.path,g?.workspaceId,e,l,P]);let L=y.current?.state.doc.toString()??t,R=L.length<=m?L:L.slice(0,m),z=h(e),B=d(z);return(0,f.jsxs)(`div`,{className:`file-cm-wrap`,"data-file-text":e,"data-file-content":R,"data-file-content-truncated":L.length>m?`1`:`0`,"data-file-selection":M,"data-file-editor-ready":A?`1`:`0`,"data-file-blame-gutter":I?`1`:void 0,onMouseDown:()=>y.current?.focus(),children:[(0,f.jsx)(`div`,{className:`file-cm`,ref:v,"aria-label":`编辑 ${e}`}),!A&&(0,f.jsx)(`span`,{className:`file-cm-status`,"data-file-editor-loading":`1`,children:`⌛ 正在加载编辑器…`}),A&&!O&&(0,f.jsx)(`span`,{className:`file-cm-status`,"data-file-highlight-status":`plain`,children:`纯文本`}),A&&O&&B&&(0,f.jsx)(`span`,{className:`file-cm-status file-cm-status-lang`,"data-file-highlight-status":z,children:B})]})}export{v as CodeMirrorEditor};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/dist-3Qp_-Z3t.js","assets/dist-B_l0KBjV.js","assets/index-dARLbQ-8.js","assets/index-C6YWfUu2.css","assets/dist-CXXAxAE4.js","assets/dist-CBqBGuBl.js","assets/dist-BOU0i9JW.js","assets/dist-DdfZJR8e.js","assets/dist-BN9HZG4O.js","assets/dist-dbLsO_41.js","assets/dist-YFQ3ixZU.js","assets/dist-bLHDT2q5.js","assets/dist-Crew6BC1.js","assets/dist-BT3fZ0wT.js","assets/dist-B61EUjUz.js","assets/dist-DiqGp2ie.js","assets/dist-_pAt4bRw.js","assets/dist-DMynScoj.js","assets/dist-DSIy9Ers.js","assets/dist-DRHWMjx_.js","assets/dist-Bb-gT7aj.js","assets/dist-CyTiEqGG.js","assets/dist-D10kcMrw.js","assets/dist-Cs1P7JrO.js"])))=>i.map(i=>d[i]);
2
+ import{a as e,i as t,n,r,s as i,t as a}from"./index-dARLbQ-8.js";var o=i(e(),1);async function s(e,t){let[{StreamLanguage:n},i]=await Promise.all([r(()=>import(`./dist-3Qp_-Z3t.js`),__vite__mapDeps([0,1,2,3,4,5])),e()]),a=i[t]??i.default??i;return n.define(a)}var c={cpp:()=>r(()=>import(`./dist-BOU0i9JW.js`).then(e=>e.cpp()),__vite__mapDeps([6,5,2,3,0,1,4,7])),cc:()=>r(()=>import(`./dist-BOU0i9JW.js`).then(e=>e.cpp()),__vite__mapDeps([6,5,2,3,0,1,4,7])),cxx:()=>r(()=>import(`./dist-BOU0i9JW.js`).then(e=>e.cpp()),__vite__mapDeps([6,5,2,3,0,1,4,7])),hpp:()=>r(()=>import(`./dist-BOU0i9JW.js`).then(e=>e.cpp()),__vite__mapDeps([6,5,2,3,0,1,4,7])),hh:()=>r(()=>import(`./dist-BOU0i9JW.js`).then(e=>e.cpp()),__vite__mapDeps([6,5,2,3,0,1,4,7])),hxx:()=>r(()=>import(`./dist-BOU0i9JW.js`).then(e=>e.cpp()),__vite__mapDeps([6,5,2,3,0,1,4,7])),c:()=>r(()=>import(`./dist-BOU0i9JW.js`).then(e=>e.cpp()),__vite__mapDeps([6,5,2,3,0,1,4,7])),h:()=>r(()=>import(`./dist-BOU0i9JW.js`).then(e=>e.cpp()),__vite__mapDeps([6,5,2,3,0,1,4,7])),cu:()=>r(()=>import(`./dist-BOU0i9JW.js`).then(e=>e.cpp()),__vite__mapDeps([6,5,2,3,0,1,4,7])),cuh:()=>r(()=>import(`./dist-BOU0i9JW.js`).then(e=>e.cpp()),__vite__mapDeps([6,5,2,3,0,1,4,7])),js:()=>r(()=>import(`./dist-BN9HZG4O.js`).then(e=>e.t).then(e=>e.javascript()),__vite__mapDeps([8,2,3,1,4,5,0,7,9])),jsx:()=>r(()=>import(`./dist-BN9HZG4O.js`).then(e=>e.t).then(e=>e.javascript({jsx:!0})),__vite__mapDeps([8,2,3,1,4,5,0,7,9])),mjs:()=>r(()=>import(`./dist-BN9HZG4O.js`).then(e=>e.t).then(e=>e.javascript()),__vite__mapDeps([8,2,3,1,4,5,0,7,9])),cjs:()=>r(()=>import(`./dist-BN9HZG4O.js`).then(e=>e.t).then(e=>e.javascript()),__vite__mapDeps([8,2,3,1,4,5,0,7,9])),ts:()=>r(()=>import(`./dist-BN9HZG4O.js`).then(e=>e.t).then(e=>e.javascript({typescript:!0})),__vite__mapDeps([8,2,3,1,4,5,0,7,9])),tsx:()=>r(()=>import(`./dist-BN9HZG4O.js`).then(e=>e.t).then(e=>e.javascript({typescript:!0,jsx:!0})),__vite__mapDeps([8,2,3,1,4,5,0,7,9])),mts:()=>r(()=>import(`./dist-BN9HZG4O.js`).then(e=>e.t).then(e=>e.javascript({typescript:!0})),__vite__mapDeps([8,2,3,1,4,5,0,7,9])),cts:()=>r(()=>import(`./dist-BN9HZG4O.js`).then(e=>e.t).then(e=>e.javascript({typescript:!0})),__vite__mapDeps([8,2,3,1,4,5,0,7,9])),py:()=>r(()=>import(`./dist-YFQ3ixZU.js`).then(e=>e.python()),__vite__mapDeps([10,5,2,3,0,1,4,7,9])),pyi:()=>r(()=>import(`./dist-YFQ3ixZU.js`).then(e=>e.python()),__vite__mapDeps([10,5,2,3,0,1,4,7,9])),java:()=>r(()=>import(`./dist-bLHDT2q5.js`).then(e=>e.java()),__vite__mapDeps([11,5,2,3,0,1,4,7])),php:()=>r(()=>import(`./dist-Crew6BC1.js`).then(e=>e.php()),__vite__mapDeps([12,5,2,3,0,1,4,7,13,14,8,9])),sql:()=>r(()=>import(`./dist-DiqGp2ie.js`).then(e=>e.sql()),__vite__mapDeps([15,5,2,3,0,1,4,7,9])),yaml:()=>r(()=>import(`./dist-_pAt4bRw.js`).then(e=>e.yaml()),__vite__mapDeps([16,5,2,3,0,1,4,7])),yml:()=>r(()=>import(`./dist-_pAt4bRw.js`).then(e=>e.yaml()),__vite__mapDeps([16,5,2,3,0,1,4,7])),xml:()=>r(()=>import(`./dist-DMynScoj.js`).then(e=>e.xml()),__vite__mapDeps([17,1,2,3,4,5,0,7])),json:()=>r(()=>import(`./dist-DSIy9Ers.js`).then(e=>e.json()),__vite__mapDeps([18,5,2,3,0,1,4,7])),jsonc:()=>r(()=>import(`./dist-DSIy9Ers.js`).then(e=>e.json()),__vite__mapDeps([18,5,2,3,0,1,4,7])),json5:()=>r(()=>import(`./dist-DSIy9Ers.js`).then(e=>e.json()),__vite__mapDeps([18,5,2,3,0,1,4,7])),html:()=>r(()=>import(`./dist-BT3fZ0wT.js`).then(e=>e.html()),__vite__mapDeps([13,1,2,3,4,5,0,7,14,8,9])),htm:()=>r(()=>import(`./dist-BT3fZ0wT.js`).then(e=>e.html()),__vite__mapDeps([13,1,2,3,4,5,0,7,14,8,9])),vue:()=>r(()=>import(`./dist-BT3fZ0wT.js`).then(e=>e.html()),__vite__mapDeps([13,1,2,3,4,5,0,7,14,8,9])),svelte:()=>r(()=>import(`./dist-BT3fZ0wT.js`).then(e=>e.html()),__vite__mapDeps([13,1,2,3,4,5,0,7,14,8,9])),css:()=>r(()=>import(`./dist-B61EUjUz.js`).then(e=>e.r).then(e=>e.css()),__vite__mapDeps([14,2,3,5,0,1,4,7])),md:()=>r(()=>import(`./dist-DRHWMjx_.js`).then(e=>e.markdown()),__vite__mapDeps([19,1,2,3,4,5,0,9,13,7,14,8])),markdown:()=>r(()=>import(`./dist-DRHWMjx_.js`).then(e=>e.markdown()),__vite__mapDeps([19,1,2,3,4,5,0,9,13,7,14,8])),mdx:()=>r(()=>import(`./dist-DRHWMjx_.js`).then(e=>e.markdown()),__vite__mapDeps([19,1,2,3,4,5,0,9,13,7,14,8])),rs:()=>r(()=>import(`./dist-Bb-gT7aj.js`).then(e=>e.rust()),__vite__mapDeps([20,5,2,3,0,1,4,7])),go:()=>r(()=>import(`./dist-CyTiEqGG.js`).then(e=>e.go()),__vite__mapDeps([21,5,2,3,0,1,4,7,9])),sh:()=>s(()=>r(()=>import(`./shell-DwuoZtxw.js`),[]),`shell`),bash:()=>s(()=>r(()=>import(`./shell-DwuoZtxw.js`),[]),`shell`),zsh:()=>s(()=>r(()=>import(`./shell-DwuoZtxw.js`),[]),`shell`),fish:()=>s(()=>r(()=>import(`./shell-DwuoZtxw.js`),[]),`shell`),ps1:()=>s(()=>r(()=>import(`./powershell-D8WpQPaX.js`),[]),`powershell`),psm1:()=>s(()=>r(()=>import(`./powershell-D8WpQPaX.js`),[]),`powershell`),rb:()=>s(()=>r(()=>import(`./ruby-ChfNwlCY.js`),[]),`ruby`),swift:()=>s(()=>r(()=>import(`./swift-DKB6_1j6.js`),[]),`swift`),toml:()=>s(()=>r(()=>import(`./toml-BPTmHmyx.js`),[]),`toml`),ini:()=>s(()=>r(()=>import(`./properties-C357ku5U.js`),[]),`properties`),cfg:()=>s(()=>r(()=>import(`./properties-C357ku5U.js`),[]),`properties`),conf:()=>s(()=>r(()=>import(`./properties-C357ku5U.js`),[]),`properties`),properties:()=>s(()=>r(()=>import(`./properties-C357ku5U.js`),[]),`properties`),dockerfile:()=>s(()=>r(()=>import(`./dockerfile-BDePf5PZ.js`),[]),`dockerfile`),diff:()=>s(()=>r(()=>import(`./diff-ChtP43wD.js`),[]),`diff`),patch:()=>s(()=>r(()=>import(`./diff-ChtP43wD.js`),[]),`diff`)},l={cpp:`C++`,cc:`C++`,cxx:`C++`,hpp:`C++`,hh:`C++`,hxx:`C++`,cu:`CUDA C++`,cuh:`CUDA C++`,c:`C`,h:`C/C++ Header`,js:`JavaScript`,jsx:`JSX`,mjs:`JavaScript`,cjs:`JavaScript`,ts:`TypeScript`,tsx:`TSX`,mts:`TypeScript`,cts:`TypeScript`,py:`Python`,pyi:`Python Stub`,java:`Java`,php:`PHP`,sql:`SQL`,yaml:`YAML`,yml:`YAML`,xml:`XML`,json:`JSON`,jsonc:`JSON with Comments`,json5:`JSON5`,css:`CSS`,md:`Markdown`,markdown:`Markdown`,mdx:`MDX`,rs:`Rust`,go:`Go`,html:`HTML`,htm:`HTML`,vue:`Vue`,svelte:`Svelte`,sh:`Shell`,bash:`Bash`,zsh:`Zsh`,fish:`Fish`,ps1:`PowerShell`,psm1:`PowerShell`,rb:`Ruby`,swift:`Swift`,toml:`TOML`,ini:`INI`,cfg:`Config`,conf:`Config`,properties:`Properties`,dockerfile:`Dockerfile`,diff:`Diff`,patch:`Patch`};function u(e){return c[e.toLowerCase()]}function d(e){return l[e.toLowerCase()]}var f=t(),p=262144,m=131072;function h(e){return e.split(`.`).pop()?.toLowerCase()??``}function g(e){return getComputedStyle(document.documentElement).getPropertyValue(e).trim()}function _(e,t){return e.HighlightStyle.define([{tag:t.tags.keyword,color:g(`--cm-keyword`)},{tag:t.tags.string,color:g(`--cm-string`)},{tag:t.tags.number,color:g(`--cm-number`)},{tag:t.tags.comment,color:g(`--cm-comment`),fontStyle:`italic`},{tag:t.tags.function(t.tags.variableName),color:g(`--cm-function`)},{tag:t.tags.typeName,color:g(`--cm-type`)},{tag:t.tags.className,color:g(`--cm-type`)},{tag:t.tags.propertyName,color:g(`--cm-property`)},{tag:t.tags.operator,color:g(`--cm-operator`)},{tag:t.tags.variableName,color:g(`--cm-variable`)}])}function v({path:e,value:t,onChange:i,jumpToLine:s,onSave:c,workspaceId:l,blame:g}){let v=(0,o.useRef)(null),y=(0,o.useRef)(null),b=(0,o.useRef)(null),x=(0,o.useRef)(null),S=(0,o.useRef)(null),C=(0,o.useRef)(null),w=(0,o.useRef)(null),T=(0,o.useRef)(null),E=(0,o.useRef)(i),D=(0,o.useRef)(c);E.current=i,D.current=c;let[O,k]=(0,o.useState)(!1),[A,j]=(0,o.useState)(!1),[M,N]=(0,o.useState)(`0,0`),[P,F]=(0,o.useState)(0);(0,o.useEffect)(()=>{let i=!1,a,o,s,c,l;return(async()=>{try{let d=h(e),f=u(d),[m,g,O,A,M,P,I,L]=await Promise.all([r(()=>import(`./dist-B_l0KBjV.js`).then(e=>e.x),__vite__mapDeps([1,2,3])),r(()=>import(`./dist-CXXAxAE4.js`).then(e=>e.s),__vite__mapDeps([4,2,3,1])),r(()=>import(`./dist-D10kcMrw.js`),__vite__mapDeps([22,1,2,3,4,5,0])),r(()=>import(`./dist-Cs1P7JrO.js`),__vite__mapDeps([23,1,2,3,4])),r(()=>import(`./dist-3Qp_-Z3t.js`),__vite__mapDeps([0,1,2,3,4,5])),r(()=>import(`./dist-CBqBGuBl.js`).then(e=>e.n),__vite__mapDeps([5,2,3])),f?f().catch(e=>(console.warn(`[CodeMirror] Failed to load language for .${d}:`,e),null)):Promise.resolve(null),n().catch(e=>(console.warn(`[CodeMirror] Failed to build the blame extension:`,e),null))]);if(i||!v.current)return;c=M,l=P,x.current=m.Annotation.define(),S.current=m.Transaction.addToHistory;let R=t.length<=p&&I!==null;o=new m.Compartment;let z=[g.lineNumbers(),g.highlightActiveLine(),g.drawSelection(),O.history(),g.keymap.of([O.indentWithTab,...O.defaultKeymap,...O.historyKeymap,...A.searchKeymap,{key:`Mod-s`,run:()=>(D.current(),!0)}]),g.EditorView.updateListener.of(e=>{e.docChanged&&!(x.current&&e.transactions.some(e=>e.annotation(x.current)===!0))&&E.current(e.state.doc.toString()),e.selectionSet&&N(`${e.state.selection.main.from},${e.state.selection.main.to}`)}),g.EditorView.domEventHandlers({mousedown:(e,t)=>(t.focus(),!1)})];if(L&&(s=new m.Compartment,z.splice(1,0,s.of([])),z.push(L.base)),I)try{z.push(I)}catch(e){console.warn(`[CodeMirror] Failed to apply language extension for .${d}:`,e),R=!1}if(R&&o&&c&&l)try{z.push(o.of(c.syntaxHighlighting(_(c,l))))}catch(e){console.warn(`[CodeMirror] Failed to attach syntaxHighlighting for .${d}:`,e),R=!1}if(a=new g.EditorView({state:m.EditorState.create({doc:t,extensions:z}),parent:v.current}),i){a.destroy();return}y.current=a,k(R),j(!0),C.current=L,w.current=s??null,T.current=null,F(e=>e+1);let B=new MutationObserver(()=>{let e=y.current;if(e&&R&&o&&c&&l)try{e.dispatch({effects:o.reconfigure(c.syntaxHighlighting(_(c,l)))})}catch{}});b.current=B,B.observe(document.documentElement,{attributes:!0,attributeFilter:[`data-theme`]})}catch(e){console.error(`[CodeMirror] Fatal editor initialization error:`,e),i||j(!0)}})(),()=>{i=!0,b.current?.disconnect(),b.current=null,a?.destroy(),y.current=null,j(!1),v.current&&(v.current.textContent=``)}},[e]),(0,o.useEffect)(()=>{let e=y.current;if(!e)return;let n=e.state.doc.toString();n!==t&&e.dispatch({changes:{from:0,to:n.length,insert:t},annotations:x.current?x.current.of(!0):void 0})},[t]),(0,o.useEffect)(()=>{let e=y.current;if(!e||!s)return;let t=e.state.doc.line(Math.min(Math.max(1,s.line),e.state.doc.lines));e.dispatch({selection:{anchor:t.from,head:t.to},scrollIntoView:!0}),e.focus()},[s,A]);let I=!!(g&&g.state===`ready`&&g.response&&g.path===e&&g.workspaceId===l);(0,o.useEffect)(()=>{let t=y.current,n=C.current,r=w.current;if(!t||!n||!r)return;let i=g&&g.state===`ready`&&g.response&&g.path===e&&g.workspaceId===l?g.response:null,o=i?a(i):null;T.current!==o&&(T.current=o,t.dispatch({effects:[n.setBlame.of(o),r.reconfigure(o?n.gutter:[])]}))},[g?.state,g?.response,g?.path,g?.workspaceId,e,l,P]);let L=y.current?.state.doc.toString()??t,R=L.length<=m?L:L.slice(0,m),z=h(e),B=d(z);return(0,f.jsxs)(`div`,{className:`file-cm-wrap`,"data-file-text":e,"data-file-content":R,"data-file-content-truncated":L.length>m?`1`:`0`,"data-file-selection":M,"data-file-editor-ready":A?`1`:`0`,"data-file-blame-gutter":I?`1`:void 0,onMouseDown:()=>y.current?.focus(),children:[(0,f.jsx)(`div`,{className:`file-cm`,ref:v,"aria-label":`编辑 ${e}`}),!A&&(0,f.jsx)(`span`,{className:`file-cm-status`,"data-file-editor-loading":`1`,children:`⌛ 正在加载编辑器…`}),A&&!O&&(0,f.jsx)(`span`,{className:`file-cm-status`,"data-file-highlight-status":`plain`,children:`纯文本`}),A&&O&&B&&(0,f.jsx)(`span`,{className:`file-cm-status file-cm-status-lang`,"data-file-highlight-status":z,children:B})]})}export{v as CodeMirrorEditor};
@@ -1,3 +1,3 @@
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-BDy5Nw4_.js";import{_ as l,a as u,f as d,i as ee,n as f,o as te,r as p,t as m,u as ne}from"./dist-CGO5Bn1x.js";import{a as re,c as ie,d as h,h as g,i as ae,l as _,m as v,o as y,p as oe,r as se,u as ce}from"./dist-D607J8oC.js";function le(e,t,n,r=0,i=0){t??(t=e.search(/[^\s\u00a0]/),t==-1&&(t=e.length));let a=i;for(let i=r;i<t;i++)e.charCodeAt(i)==9?a+=n-a%n:a++;return a}var b=class{constructor(e,t,n,r){this.string=e,this.tabSize=t,this.indentUnit=n,this.overrideIndent=r,this.pos=0,this.start=0,this.lastColumnPos=0,this.lastColumnValue=0}eol(){return this.pos>=this.string.length}sol(){return this.pos==0}peek(){return this.string.charAt(this.pos)||void 0}next(){if(this.pos<this.string.length)return this.string.charAt(this.pos++)}eat(e){let t=this.string.charAt(this.pos),n;if(n=typeof e==`string`?t==e:t&&(e instanceof RegExp?e.test(t):e(t)),n)return++this.pos,t}eatWhile(e){let t=this.pos;for(;this.eat(e););return this.pos>t}eatSpace(){let e=this.pos;for(;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>e}skipToEnd(){this.pos=this.string.length}skipTo(e){let t=this.string.indexOf(e,this.pos);if(t>-1)return this.pos=t,!0}backUp(e){this.pos-=e}column(){return this.lastColumnPos<this.start&&(this.lastColumnValue=le(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start),this.lastColumnValue}indentation(){return this.overrideIndent??le(this.string,null,this.tabSize)}match(e,t,n){if(typeof e==`string`){let r=e=>n?e.toLowerCase():e;return r(this.string.substr(this.pos,e.length))==r(e)?(t!==!1&&(this.pos+=e.length),!0):null}{let n=this.string.slice(this.pos).match(e);return n&&n.index>0?null:(n&&t!==!1&&(this.pos+=n[0].length),n)}}current(){return this.string.slice(this.start,this.pos)}},x=new _;function S(e){return o.define({combine:e?t=>t.concat(e):void 0})}var ue=new _,C=class{constructor(e,t,n=[],r=``){this.data=e,this.name=r,i.prototype.hasOwnProperty(`tree`)||Object.defineProperty(i.prototype,"tree",{get(){return w(this)}}),this.parser=t,this.extension=[O.of(this),i.languageData.of((e,t,n)=>{let r=de(e,t,n),i=r.type.prop(x);if(!i)return[];let a=e.facet(i),o=r.type.prop(ue);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 de(e,t,n).type.prop(x)==this.data}findRegions(e){let t=e.facet(O);if(t?.data==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let n=[],r=(e,t)=>{if(e.prop(x)==this.data){n.push({from:t,to:t+e.length});return}let i=e.prop(_.mounted);if(i){if(i.tree.prop(x)==this.data){if(i.overlay)for(let e of i.overlay)n.push({from:e.from+t,to:e.to+t});else n.push({from:t,to:t+e.length});return}if(i.overlay){let e=n.length;if(r(i.tree,i.overlay[0].from+t),n.length>e)return}}for(let n=0;n<e.children.length;n++){let i=e.children[n];i instanceof v&&r(i,e.positions[n]+t)}};return r(w(e),0),n}get allowsNesting(){return!0}};C.setState=a.define();function de(e,t,n){let r=e.facet(O),i=w(e).topNode;if(!r||r.allowsNesting)for(let e=i;e;e=e.enter(t,n,ie.ExcludeBuffers|ie.EnterBracketed))e.type.isTop&&(i=e);return i}var fe=class e extends C{constructor(e,t,n){super(e,t,[],n),this.parser=t}static define(t){let n=S(t.languageData);return new e(n,t.parser.configure({props:[x.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 w(e){let t=e.field(C.state,!1);return t?t.tree:v.empty}function pe(e,t,n=50){let r=e.field(C.state,!1)?.context;if(!r)return null;let i=r.viewport;r.updateViewport({from:0,to:t});let a=r.isDone(t)||r.work(n,t)?r.tree:null;return r.updateViewport(i),a}function me(e,t=e.doc.length){return e.field(C.state,!1)?.context.isDone(t)||!1}function he(e,t=e.viewport.to,n=100){let r=pe(e.state,t,n);return r!=w(e.state)&&e.dispatch({}),!!r}function ge(e){return e.plugin(xe)?.isWorking()||!1}var _e=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)}},T=null,E=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,[],v.empty,0,r,[],null)}startParse(){return this.parser.startParse(new _e(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=v.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(g.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(g.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=T;T=this;try{return e()}finally{T=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=ve(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=g.applyChanges(r,e),i=v.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=ve(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 oe{createParse(t,n,r){let i=r[0].from,a=r[r.length-1].to;return{parsedPos:i,advance(){let t=T;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 v(h.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 T}};function ve(e,t,n){return g.applyChanges(e,[{fromA:t,toA:n,fromB:t,toB:n}])}var D=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=E.create(t.facet(O).parser,t,{from:0,to:n});return r.work(20,n)||r.takeTree(),new e(r)}};C.state=r.define({create:D.init,update(e,t){for(let e of t.effects)if(e.is(C.setState))return e.value;return t.startState.facet(O)==t.state.facet(O)?e.apply(t):D.init(t.state)}});var ye=e=>{let t=setTimeout(()=>e(),500);return()=>clearTimeout(t)};typeof requestIdleCallback<`u`&&(ye=e=>{let t=-1,n=setTimeout(()=>{t=requestIdleCallback(e,{timeout:400})},100);return()=>t<0?clearTimeout(n):cancelIdleCallback(t)});var be=typeof navigator<`u`&&navigator.scheduling?.isInputPending?()=>navigator.scheduling.isInputPending():null,xe=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(C.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(C.state);(t.tree!=t.context.tree||!t.context.isDone(e.doc.length))&&(this.working=ye(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(C.state);if(i.tree==i.context.tree&&i.context.isDone(r+1e5))return;let a=Date.now()+Math.min(this.chunkBudget,100,e&&!be?Math.max(25,e.timeRemaining()-5):1e9),o=i.context.treeLen<r&&n.doc.length>r+1e3,s=i.context.work(()=>be&&be()||Date.now()>a,r+(o?0:1e5));this.chunkBudget-=Date.now()-t,(s||this.chunkBudget<=0)&&(i.context.takeTree(),this.view.dispatch({effects:C.setState.of(new D(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()}}}),O=o.define({combine(e){return e.length?e[0]:null},enables:e=>[C.state,xe,p.contentAttributes.compute([e],t=>{let n=t.facet(e);return n&&n.name?{"data-language":n.name}:{}})]}),Se=class{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}},Ce=class e{constructor(e,t,n,r,i,a=void 0){this.name=e,this.alias=t,this.extensions=n,this.filename=r,this.loadFunc=i,this.support=a,this.loading=null}load(){return this.loading||=this.loadFunc().then(e=>this.support=e,e=>{throw this.loading=null,e})}static of(t){let{load:n,support:r}=t;if(!n){if(!r)throw RangeError(`Must pass either 'load' or 'support' to LanguageDescription.of`);n=()=>Promise.resolve(r)}return new e(t.name,(t.alias||[]).concat(t.name).map(e=>e.toLowerCase()),t.extensions||[],t.filename,n,r)}static matchFilename(e,t){for(let n of e)if(n.filename&&n.filename.test(t))return n;let n=/\.([^.]+)$/.exec(t);if(n){for(let t of e)if(t.extensions.indexOf(n[1])>-1)return t}return null}static matchLanguageName(e,t,n=!0){t=t.toLowerCase();for(let n of e)if(n.alias.some(e=>e==t))return n;if(n)for(let n of e)for(let e of n.alias){let r=t.indexOf(e);if(r>-1&&(e.length>2||!/\w/.test(t[r-1])&&!/\w/.test(t[r+e.length])))return n}return null}},we=o.define(),k=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 A(e){let t=e.facet(k);return t.charCodeAt(0)==9?e.tabSize*t.length:t.length}function j(e,t){let n=``,r=e.tabSize,i=e.facet(k)[0];if(i==` `){for(;t>=r;)n+=` `,t-=r;i=` `}for(let e=0;e<t;e++)n+=i;return n}function M(e,t){e instanceof i&&(e=new N(e));for(let n of e.state.facet(we)){let r=n(e,t);if(r!==void 0)return r}let n=w(e.state);return n.length>=t?De(e,n,t):null}function Te(e,t,n){let r=Object.create(null),i=new N(e,{overrideIndentation:e=>r[e]??-1}),a=[];for(let o=t;o<=n;){let t=e.doc.lineAt(o);o=t.to+1;let n=M(i,t.from);if(n==null)continue;/\S/.test(t.text)||(n=0);let s=/^\s*/.exec(t.text)[0],c=j(e,n);s!=c&&(r[t.from]=n,a.push({from:t.from,to:t.from+s.length,insert:c}))}return e.changes(a)}var N=class{constructor(e,t={}){this.state=e,this.options=t,this.unit=A(e)}lineAt(e,t=1){let n=this.state.doc.lineAt(e),{simulateBreak:r,simulateDoubleBreak:i}=this.options;return r!=null&&r>=n.from&&r<=n.to?i&&r==e?{text:``,from:e}:(t<0?r<e:r<=e)?{text:n.text.slice(r-n.from),from:r}:{text:n.text.slice(0,r-n.from),from:n.from}:n}textAfterPos(e,t=1){if(this.options.simulateDoubleBreak&&e==this.options.simulateBreak)return``;let{text:n,from:r}=this.lineAt(e,t);return n.slice(e-r,Math.min(n.length,e+100-r))}column(e,t=1){let{text:n,from:r}=this.lineAt(e,t),i=this.countColumn(n,e-r),a=this.options.overrideIndentation?this.options.overrideIndentation(r):-1;return a>-1&&(i+=a-this.countColumn(n,n.search(/\S|$/))),i}countColumn(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}},Ee=new _;function De(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 Oe(r,e,n)}function Oe(e,t,n){for(let r=e;r;r=r.next){let e=Ae(r.node);if(e)return e(Me.create(t,n,r))}return 0}function ke(e){return e.pos==e.options.simulateBreak&&e.options.simulateDoubleBreak}function Ae(e){let t=e.type.prop(Ee);if(t)return t;let n=e.firstChild,r;if(n&&(r=n.type.prop(_.closedBy))){let t=e.lastChild,n=t&&r.indexOf(t.name)>-1;return e=>Ie(e,!0,1,void 0,n&&!ke(e)?t.from:void 0)}return e.parent==null?je:null}function je(){return 0}var Me=class e extends N{constructor(e,t,n){super(e.state,e.options),this.base=e,this.pos=t,this.context=n}get node(){return this.context.node}static create(t,n,r){return new e(t,n,r)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let t=this.state.doc.lineAt(e.from);for(;;){let n=e.resolve(t.from);for(;n.parent&&n.parent.from==n.from;)n=n.parent;if(Ne(n,e))break;t=this.state.doc.lineAt(n.from)}return this.lineIndent(t.from)}continue(){return Oe(this.context.next,this.base,this.pos)}};function Ne(e,t){for(let n=t;n;n=n.parent)if(e==n)return!0;return!1}function Pe(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 Fe({closing:e,align:t=!0,units:n=1}){return r=>Ie(r,t,n,e)}function Ie(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?Pe(e):null;return c?s?e.column(c.from):e.column(c.to):e.baseIndent+(s?0:e.unit*n)}var Le=e=>e.baseIndent;function Re({except:e,units:t=1}={}){return n=>{let r=e&&e.test(n.textAfter);return n.baseIndent+(r?0:t*n.unit)}}var ze=200;function Be(){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+ze)return e;let a=n.sliceString(i.from,r);if(!t.some(e=>e.test(a)))return e;let{state:o}=e,s=-1,c=[];for(let{head:e}of o.selection.ranges){let t=o.doc.lineAt(e);if(t.from==s)continue;s=t.from;let n=M(o,t.from);if(n==null)continue;let r=/^\s*/.exec(t.text)[0],i=j(o,n);r!=i&&c.push({from:t.from,to:t.from+r.length,insert:i})}return c.length?[e,{changes:c,sequential:!0}]:e})}var Ve=o.define(),He=new _;function Ue(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 We(e,t,n){let r=w(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(He);if(s&&(i.to<r.length-50||r.length==e.doc.length||!Ge(i))){let r=s(i,e);r&&r.from<=n&&r.from>=t&&r.to>n&&(a=r)}}return a}function Ge(e){let t=e.lastChild;return t&&t.to==e.to&&t.type.isError}function P(e,t,n){for(let r of e.facet(Ve)){let i=r(e,t,n);if(i)return i}return We(e,t,n)}function Ke(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 F=a.define({map:Ke}),I=a.define({map:Ke});function L(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 R=r.define({create(){return m.none},update(e,t){t.isUserEvent(`delete`)&&t.changes.iterChangedRanges((t,n)=>e=qe(e,t,n)),e=e.map(t.changes);let n=[];for(let r of t.effects)r.is(F)&&!Ye(e,r.value.from,r.value.to)?n.push(r.value):r.is(I)&&(e=e.update({filter:(e,t)=>r.value.from!=e||r.value.to!=t,filterFrom:r.value.from,filterTo:r.value.to}));if(n.length){let{preparePlaceholder:r}=t.state.facet(H),i=n.map(e=>(r?m.replace({widget:new ot(r(t.state,e))}):at).range(e.from,e.to));e=e.update({add:i})}return t.selection&&(e=qe(e,t.selection.main.head)),e},provide:e=>p.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(at.range(r,i))}return m.set(t,!0)}});function qe(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 Je(e){return e.field(R,!1)||s.empty}function z(e,t,n){var r;let i=null;return(r=e.field(R,!1))==null||r.between(t,n,(e,t)=>{(!i||i.from>e)&&(i={from:e,to:t})}),i}function Ye(e,t,n){let r=!1;return e.between(t,t,(e,i)=>{e==t&&i==n&&(r=!0)}),r}function B(e,t){return e.field(R,!1)?t:t.concat(a.appendConfig.of(U()))}var Xe=e=>{for(let t of L(e)){let n=P(e.state,t.from,t.to);if(n)return e.dispatch({effects:B(e.state,[F.of(n),V(e,n)])}),!0}return!1},Ze=e=>{if(!e.state.field(R,!1))return!1;let t=[];for(let n of L(e)){let r=z(e.state,n.from,n.to);r&&t.push(I.of(r),V(e,r,!1))}return t.length&&e.dispatch({effects:t}),t.length>0};function V(e,t,n=!0){let r=e.state.doc.lineAt(t.from).number,i=e.state.doc.lineAt(t.to).number;return p.announce.of(`${e.state.phrase(n?`Folded lines`:`Unfolded lines`)} ${r} ${e.state.phrase(`to`)} ${i}.`)}var Qe=e=>{let{state:t}=e,n=[];for(let r=0;r<t.doc.length;){let i=e.lineBlockAt(r),a=P(t,i.from,i.to);a&&n.push(F.of(a)),r=(a?e.lineBlockAt(a.to):i).to+1}return n.length&&e.dispatch({effects:B(e.state,n)}),!!n.length},$e=e=>{let t=e.state.field(R,!1);if(!t||!t.size)return!1;let n=[];return t.between(0,e.state.doc.length,(e,t)=>{n.push(I.of({from:e,to:t}))}),e.dispatch({effects:n}),!0};function et(e,t){for(let n=t;;){let r=P(e.state,n.from,n.to);if(r&&r.to>t.from)return r;if(!n.from)return null;n=e.lineBlockAt(n.from-1)}}var tt=e=>{let t=[];for(let n of L(e)){let r=z(e.state,n.from,n.to);if(r)t.push(I.of(r),V(e,r,!1));else{let r=et(e,n);r&&t.push(F.of(r),V(e,r))}}return t.length>0&&e.dispatch({effects:B(e.state,t)}),!!t.length},nt=[{key:`Ctrl-Shift-[`,mac:`Cmd-Alt-[`,run:Xe},{key:`Ctrl-Shift-]`,mac:`Cmd-Alt-]`,run:Ze},{key:`Ctrl-Alt-[`,run:Qe},{key:`Ctrl-Alt-]`,run:$e}],rt={placeholderDOM:null,preparePlaceholder:null,placeholderText:`…`},H=o.define({combine(e){return c(e,rt)}});function U(e){let t=[R,lt];return e&&t.push(H.of(e)),t}function it(e,t){let{state:n}=e,r=n.facet(H),i=t=>{let n=e.lineBlockAt(e.posAtDOM(t.target)),r=z(e.state,n.from,n.to);r&&e.dispatch({effects:I.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 at=m.replace({widget:new class extends te{toDOM(e){return it(e,null)}}}),ot=class extends te{constructor(e){super(),this.value=e}eq(e){return this.value==e.value}toDOM(e){return it(e,this.value)}},st={openText:`⌄`,closedText:`›`,markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1},W=class extends ee{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 ct(e={}){let n={...st,...e},r=new W(n,!0),i=new W(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(O)!=e.state.facet(O)||e.startState.field(R,!1)!=e.state.field(R,!1)||w(e.startState)!=w(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=z(e.state,t.from,t.to)?i:P(e.state,t.from,t.to)?r:null;a&&n.add(t.from,t.from,a)}return n.finish()}}),{domEventHandlers:o}=n;return[a,ne({class:`cm-foldGutter`,markers(e){return e.plugin(a)?.markers||s.empty},initialSpacer(){return new W(n,!1)},domEventHandlers:{...o,click:(e,t,n)=>{if(o.click&&o.click(e,t,n))return!0;let r=z(e.state,t.from,t.to);if(r)return e.dispatch({effects:I.of(r)}),!0;let i=P(e.state,t.from,t.to);return i?(e.dispatch({effects:F.of(i)}),!0):!1}}}),U()]}var lt=p.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`}}),G=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 C?e=>e.prop(x)==a.data:a?e=>e==a:void 0,this.style=re(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||{})}},K=o.define(),ut=o.define({combine(e){return e.length?[e[0]]:null}});function q(e){let t=e.facet(K);return t.length?t:e.facet(ut)}function dt(e,t){let n=[mt],r;return e instanceof G&&(e.module&&n.push(p.styleModule.of(e.module)),r=e.themeType),t?.fallback?n.push(ut.of(e)):r?n.push(K.computeN([p.darkTheme],t=>t.facet(p.darkTheme)==(r==`dark`)?[e]:[])):n.push(K.of(e)),n}function ft(e,t,n){let r=q(e),i=null;if(r){for(let e of r)if(!e.scope||n&&e.scope(n)){let n=e.style(t);n&&(i=i?i+` `+n:n)}}return i}var pt=class{constructor(e){this.markCache=Object.create(null),this.tree=w(e.state),this.decorations=this.buildDeco(e,q(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=w(e.state),n=q(e.state),r=n!=q(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 m.none;let r=new t;for(let{from:t,to:i}of e.visibleRanges)se(this.tree,n,(e,t,n)=>{r.add(e,t,this.markCache[n]||(this.markCache[n]=m.mark({class:n})))},t,i);return r.finish()}},mt=n.high(u.fromClass(pt,{decorations:e=>e.decorations})),ht=G.define([{tag:y.meta,color:`#404740`},{tag:y.link,textDecoration:`underline`},{tag:y.heading,textDecoration:`underline`,fontWeight:`bold`},{tag:y.emphasis,fontStyle:`italic`},{tag:y.strong,fontWeight:`bold`},{tag:y.strikethrough,textDecoration:`line-through`},{tag:y.keyword,color:`#708`},{tag:[y.atom,y.bool,y.url,y.contentSeparator,y.labelName],color:`#219`},{tag:[y.literal,y.inserted],color:`#164`},{tag:[y.string,y.deleted],color:`#a11`},{tag:[y.regexp,y.escape,y.special(y.string)],color:`#e40`},{tag:y.definition(y.variableName),color:`#00f`},{tag:y.local(y.variableName),color:`#30a`},{tag:[y.typeName,y.namespace],color:`#085`},{tag:y.className,color:`#167`},{tag:[y.special(y.variableName),y.macroName],color:`#256`},{tag:y.definition(y.propertyName),color:`#00c`},{tag:y.comment,color:`#940`},{tag:y.invalid,color:`#f00`}]),gt=p.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:`#328c8252`},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:`#bb555544`}}),_t=1e4,vt=`()[]{}`,yt=o.define({combine(e){return c(e,{afterCursor:!0,brackets:vt,maxScanDistance:_t,renderMatch:St})}}),bt=m.mark({class:`cm-matchingBracket`}),xt=m.mark({class:`cm-nonmatchingBracket`});function St(e){let t=[],n=e.matched?bt:xt;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 Ct(e){let t=[],n=e.facet(yt);for(let r of e.selection.ranges){if(!r.empty)continue;let i=X(e,r.head,-1,n)||r.head>0&&X(e,r.head-1,1,n)||n.afterCursor&&(X(e,r.head,1,n)||r.head<e.doc.length&&X(e,r.head+1,-1,n));i&&(t=t.concat(n.renderMatch(i,e)))}return m.set(t,!0)}var wt=[u.fromClass(class{constructor(e){this.paused=!1,this.decorations=Ct(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=Ct(e.state),this.paused=!1))}},{decorations:e=>e.decorations}),gt];function Tt(e={}){return[yt.of(e),wt]}var Et=new _;function J(e,t,n){let r=e.prop(t<0?_.openedBy:_.closedBy);if(r)return r;if(e.name.length==1){let r=n.indexOf(e.name);if(r>-1&&r%2==+(t<0))return[n[r+t]]}return null}function Y(e){let t=e.type.prop(Et);return t?t(e.node):e}function X(e,t,n,r={}){let i=r.maxScanDistance||_t,a=r.brackets||vt,o=w(e),s=o.resolveInner(t,n);for(let r=s;r;r=r.parent){let i=J(r.type,n,a);if(i&&r.from<r.to){let o=Y(r);if(o&&(n>0?t>=o.from&&t<o.to:t>o.from&&t<=o.to))return Dt(e,t,n,r,o,i,a)}}return Ot(e,t,n,o,s.type,i,a)}function Dt(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=Y(u);return{start:c,end:e?{from:e.from,to:e.to}:void 0,matched:!0}}if(J(u.type,n,o))l++;else if(J(u.type,-n,o)){if(l==0){let e=Y(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 Ot(e,t,n,r,i,a,o){if(n<0?!t:t==e.doc.length)return null;let s=n<0?e.sliceDoc(t-1,t):e.sliceDoc(t,t+1),c=o.indexOf(s);if(c<0||c%2==0!=n>0)return null;let l={from:n<0?t-1:t,to:n>0?t+1:t},u=e.doc.iterRange(t,n>0?e.doc.length:0),d=0;for(let e=0;!u.next().done&&e<=a;){let a=u.value;n<0&&(e+=a.length);let s=t+e*n;for(let e=n>0?0:a.length-1,t=n>0?a.length:-1;e!=t;e+=n){let t=o.indexOf(a[e]);if(!(t<0||r.resolveInner(s+e,1).type!=i)){if(t%2==0==n>0)d++;else if(d==1)return{start:l,end:{from:s+e,to:s+e+1},matched:t>>1==c>>1};else d--}}n>0&&(e+=a.length)}return u.done?{start:l,matched:!1}:null}function kt(e){return{name:e.name||``,token:e.token,blankLine:e.blankLine||(()=>{}),startState:e.startState||(()=>!0),copyState:e.copyState||At,indent:e.indent||(()=>null),languageData:e.languageData||{},tokenTable:e.tokenTable||Lt,mergeTokens:e.mergeTokens!==!1}}function At(e){if(typeof e!=`object`)return e;let t={};for(let n in e){let r=e[n];t[n]=r instanceof Array?r.slice():r}return t}var jt=new WeakMap,Mt=class e extends C{constructor(e){let t=S(e.languageData),n=kt(e),r,i=new class extends oe{createParse(e,t,n){return new Ft(r,e,t,n)}};super(t,i,[],e.name),this.topNode=Kt(t,this),r=this,this.streamParser=n,this.stateAfter=new _({perNode:!0}),this.tokenTable=e.tokenTable?new Ht(n.tokenTable):Ut}static define(t){return new e(t)}getIndent(e){let t,{overrideIndentation:n}=e.options;n&&(t=jt.get(e.state),t!=null&&t<e.pos-1e4&&(t=void 0));let r=Z(this,e.node.tree,e.node.from,e.node.from,t??e.pos),i,a;if(r?(a=r.state,i=r.pos+1):(a=this.streamParser.startState(e.unit),i=e.node.from),e.pos-i>1e4)return null;for(;i<e.pos;){let t=e.state.doc.lineAt(i),r=Math.min(e.pos,t.to);if(t.length){let i=n?n(t.from):-1,o=new b(t.text,e.state.tabSize,e.unit,i<0?void 0:i);for(;o.pos<r-t.from;)It(this.streamParser.token,o,a)}else this.streamParser.blankLine(a,e.unit);if(r==e.pos)break;i=t.to+1}let o=e.lineAt(e.pos);return n&&t==null&&jt.set(e.state,o.from),this.streamParser.indent(a,/^\s*(.*)/.exec(o.text)[1],e)}get allowsNesting(){return!1}};function Z(e,t,n,r,i){let a=n>=r&&n+t.length<=i&&t.prop(e.stateAfter);if(a)return{state:e.streamParser.copyState(a),pos:n+t.length};for(let a=t.children.length-1;a>=0;a--){let o=t.children[a],s=n+t.positions[a],c=o instanceof v&&s<i&&Z(e,o,s,r,i);if(c)return c}return null}function Nt(e,t,n,r,i){if(i&&n<=0&&r>=t.length)return t;!i&&n==0&&t.type==e.topNode&&(i=!0);for(let a=t.children.length-1;a>=0;a--){let o=t.positions[a],s=t.children[a],c;if(o<r&&s instanceof v){if(!(c=Nt(e,s,n-o,r-o,i)))break;return i?new v(t.type,t.children.slice(0,a).concat(c),t.positions.slice(0,a+1),o+c.length):c}}return null}function Pt(e,t,n,r,i){for(let i of t){let t=i.from+(i.openStart?25:0),a=i.to-(i.openEnd?25:0),o=t<=n&&a>n&&Z(e,i.tree,0-i.offset,n,a),s;if(o&&o.pos<=r&&(s=Nt(e,i.tree,n+i.offset,o.pos+i.offset,!1)))return{state:o.state,tree:s}}return{state:e.streamParser.startState(i?A(i):4),tree:v.empty}}var Ft=class{constructor(e,t,n,r){this.lang=e,this.input=t,this.fragments=n,this.ranges=r,this.stoppedAt=null,this.chunks=[],this.chunkPos=[],this.chunk=[],this.chunkReused=void 0,this.rangeIndex=0,this.to=r[r.length-1].to;let i=E.get(),a=r[0].from,{state:o,tree:s}=Pt(e,n,a,this.to,i?.state);this.state=o,this.parsedPos=this.chunkStart=a+s.length;for(let e=0;e<s.children.length;e++)this.chunks.push(s.children[e]),this.chunkPos.push(s.positions[e]);i&&this.parsedPos<i.viewport.from-1e5&&r.some(e=>e.from<=i.viewport.from&&e.to>=i.viewport.from)&&(this.state=this.lang.streamParser.startState(A(i.state)),i.skipUntilInView(this.parsedPos,i.viewport.from),this.parsedPos=i.viewport.from),this.moveRangeIndex()}advance(){let e=E.get(),t=this.stoppedAt==null?this.to:Math.min(this.to,this.stoppedAt),n=Math.min(t,this.chunkStart+512);for(e&&(n=Math.min(n,e.viewport.to));this.parsedPos<n;)this.parseLine(e);return this.chunkStart<this.parsedPos&&this.finishChunk(),this.parsedPos>=t?this.finish():e&&this.parsedPos>=e.viewport.to?(e.skipUntilInView(this.parsedPos,t),this.finish()):null}stopAt(e){this.stoppedAt=e}lineAfter(e){let t=this.input.chunk(e);if(this.input.lineChunks)t==`
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-B_l0KBjV.js";import{_ as l,a as u,f as d,i as ee,n as f,o as te,r as p,t as m,u as ne}from"./dist-CXXAxAE4.js";import{a as re,c as ie,d as h,h as g,i as ae,l as _,m as v,o as y,p as oe,r as se,u as ce}from"./dist-CBqBGuBl.js";function le(e,t,n,r=0,i=0){t??(t=e.search(/[^\s\u00a0]/),t==-1&&(t=e.length));let a=i;for(let i=r;i<t;i++)e.charCodeAt(i)==9?a+=n-a%n:a++;return a}var b=class{constructor(e,t,n,r){this.string=e,this.tabSize=t,this.indentUnit=n,this.overrideIndent=r,this.pos=0,this.start=0,this.lastColumnPos=0,this.lastColumnValue=0}eol(){return this.pos>=this.string.length}sol(){return this.pos==0}peek(){return this.string.charAt(this.pos)||void 0}next(){if(this.pos<this.string.length)return this.string.charAt(this.pos++)}eat(e){let t=this.string.charAt(this.pos),n;if(n=typeof e==`string`?t==e:t&&(e instanceof RegExp?e.test(t):e(t)),n)return++this.pos,t}eatWhile(e){let t=this.pos;for(;this.eat(e););return this.pos>t}eatSpace(){let e=this.pos;for(;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>e}skipToEnd(){this.pos=this.string.length}skipTo(e){let t=this.string.indexOf(e,this.pos);if(t>-1)return this.pos=t,!0}backUp(e){this.pos-=e}column(){return this.lastColumnPos<this.start&&(this.lastColumnValue=le(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start),this.lastColumnValue}indentation(){return this.overrideIndent??le(this.string,null,this.tabSize)}match(e,t,n){if(typeof e==`string`){let r=e=>n?e.toLowerCase():e;return r(this.string.substr(this.pos,e.length))==r(e)?(t!==!1&&(this.pos+=e.length),!0):null}{let n=this.string.slice(this.pos).match(e);return n&&n.index>0?null:(n&&t!==!1&&(this.pos+=n[0].length),n)}}current(){return this.string.slice(this.start,this.pos)}},x=new _;function S(e){return o.define({combine:e?t=>t.concat(e):void 0})}var ue=new _,C=class{constructor(e,t,n=[],r=``){this.data=e,this.name=r,i.prototype.hasOwnProperty(`tree`)||Object.defineProperty(i.prototype,"tree",{get(){return w(this)}}),this.parser=t,this.extension=[O.of(this),i.languageData.of((e,t,n)=>{let r=de(e,t,n),i=r.type.prop(x);if(!i)return[];let a=e.facet(i),o=r.type.prop(ue);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 de(e,t,n).type.prop(x)==this.data}findRegions(e){let t=e.facet(O);if(t?.data==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let n=[],r=(e,t)=>{if(e.prop(x)==this.data){n.push({from:t,to:t+e.length});return}let i=e.prop(_.mounted);if(i){if(i.tree.prop(x)==this.data){if(i.overlay)for(let e of i.overlay)n.push({from:e.from+t,to:e.to+t});else n.push({from:t,to:t+e.length});return}if(i.overlay){let e=n.length;if(r(i.tree,i.overlay[0].from+t),n.length>e)return}}for(let n=0;n<e.children.length;n++){let i=e.children[n];i instanceof v&&r(i,e.positions[n]+t)}};return r(w(e),0),n}get allowsNesting(){return!0}};C.setState=a.define();function de(e,t,n){let r=e.facet(O),i=w(e).topNode;if(!r||r.allowsNesting)for(let e=i;e;e=e.enter(t,n,ie.ExcludeBuffers|ie.EnterBracketed))e.type.isTop&&(i=e);return i}var fe=class e extends C{constructor(e,t,n){super(e,t,[],n),this.parser=t}static define(t){let n=S(t.languageData);return new e(n,t.parser.configure({props:[x.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 w(e){let t=e.field(C.state,!1);return t?t.tree:v.empty}function pe(e,t,n=50){let r=e.field(C.state,!1)?.context;if(!r)return null;let i=r.viewport;r.updateViewport({from:0,to:t});let a=r.isDone(t)||r.work(n,t)?r.tree:null;return r.updateViewport(i),a}function me(e,t=e.doc.length){return e.field(C.state,!1)?.context.isDone(t)||!1}function he(e,t=e.viewport.to,n=100){let r=pe(e.state,t,n);return r!=w(e.state)&&e.dispatch({}),!!r}function ge(e){return e.plugin(xe)?.isWorking()||!1}var _e=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)}},T=null,E=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,[],v.empty,0,r,[],null)}startParse(){return this.parser.startParse(new _e(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=v.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(g.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(g.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=T;T=this;try{return e()}finally{T=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=ve(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=g.applyChanges(r,e),i=v.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=ve(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 oe{createParse(t,n,r){let i=r[0].from,a=r[r.length-1].to;return{parsedPos:i,advance(){let t=T;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 v(h.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 T}};function ve(e,t,n){return g.applyChanges(e,[{fromA:t,toA:n,fromB:t,toB:n}])}var D=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=E.create(t.facet(O).parser,t,{from:0,to:n});return r.work(20,n)||r.takeTree(),new e(r)}};C.state=r.define({create:D.init,update(e,t){for(let e of t.effects)if(e.is(C.setState))return e.value;return t.startState.facet(O)==t.state.facet(O)?e.apply(t):D.init(t.state)}});var ye=e=>{let t=setTimeout(()=>e(),500);return()=>clearTimeout(t)};typeof requestIdleCallback<`u`&&(ye=e=>{let t=-1,n=setTimeout(()=>{t=requestIdleCallback(e,{timeout:400})},100);return()=>t<0?clearTimeout(n):cancelIdleCallback(t)});var be=typeof navigator<`u`&&navigator.scheduling?.isInputPending?()=>navigator.scheduling.isInputPending():null,xe=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(C.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(C.state);(t.tree!=t.context.tree||!t.context.isDone(e.doc.length))&&(this.working=ye(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(C.state);if(i.tree==i.context.tree&&i.context.isDone(r+1e5))return;let a=Date.now()+Math.min(this.chunkBudget,100,e&&!be?Math.max(25,e.timeRemaining()-5):1e9),o=i.context.treeLen<r&&n.doc.length>r+1e3,s=i.context.work(()=>be&&be()||Date.now()>a,r+(o?0:1e5));this.chunkBudget-=Date.now()-t,(s||this.chunkBudget<=0)&&(i.context.takeTree(),this.view.dispatch({effects:C.setState.of(new D(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()}}}),O=o.define({combine(e){return e.length?e[0]:null},enables:e=>[C.state,xe,p.contentAttributes.compute([e],t=>{let n=t.facet(e);return n&&n.name?{"data-language":n.name}:{}})]}),Se=class{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}},Ce=class e{constructor(e,t,n,r,i,a=void 0){this.name=e,this.alias=t,this.extensions=n,this.filename=r,this.loadFunc=i,this.support=a,this.loading=null}load(){return this.loading||=this.loadFunc().then(e=>this.support=e,e=>{throw this.loading=null,e})}static of(t){let{load:n,support:r}=t;if(!n){if(!r)throw RangeError(`Must pass either 'load' or 'support' to LanguageDescription.of`);n=()=>Promise.resolve(r)}return new e(t.name,(t.alias||[]).concat(t.name).map(e=>e.toLowerCase()),t.extensions||[],t.filename,n,r)}static matchFilename(e,t){for(let n of e)if(n.filename&&n.filename.test(t))return n;let n=/\.([^.]+)$/.exec(t);if(n){for(let t of e)if(t.extensions.indexOf(n[1])>-1)return t}return null}static matchLanguageName(e,t,n=!0){t=t.toLowerCase();for(let n of e)if(n.alias.some(e=>e==t))return n;if(n)for(let n of e)for(let e of n.alias){let r=t.indexOf(e);if(r>-1&&(e.length>2||!/\w/.test(t[r-1])&&!/\w/.test(t[r+e.length])))return n}return null}},we=o.define(),k=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 A(e){let t=e.facet(k);return t.charCodeAt(0)==9?e.tabSize*t.length:t.length}function j(e,t){let n=``,r=e.tabSize,i=e.facet(k)[0];if(i==` `){for(;t>=r;)n+=` `,t-=r;i=` `}for(let e=0;e<t;e++)n+=i;return n}function M(e,t){e instanceof i&&(e=new N(e));for(let n of e.state.facet(we)){let r=n(e,t);if(r!==void 0)return r}let n=w(e.state);return n.length>=t?De(e,n,t):null}function Te(e,t,n){let r=Object.create(null),i=new N(e,{overrideIndentation:e=>r[e]??-1}),a=[];for(let o=t;o<=n;){let t=e.doc.lineAt(o);o=t.to+1;let n=M(i,t.from);if(n==null)continue;/\S/.test(t.text)||(n=0);let s=/^\s*/.exec(t.text)[0],c=j(e,n);s!=c&&(r[t.from]=n,a.push({from:t.from,to:t.from+s.length,insert:c}))}return e.changes(a)}var N=class{constructor(e,t={}){this.state=e,this.options=t,this.unit=A(e)}lineAt(e,t=1){let n=this.state.doc.lineAt(e),{simulateBreak:r,simulateDoubleBreak:i}=this.options;return r!=null&&r>=n.from&&r<=n.to?i&&r==e?{text:``,from:e}:(t<0?r<e:r<=e)?{text:n.text.slice(r-n.from),from:r}:{text:n.text.slice(0,r-n.from),from:n.from}:n}textAfterPos(e,t=1){if(this.options.simulateDoubleBreak&&e==this.options.simulateBreak)return``;let{text:n,from:r}=this.lineAt(e,t);return n.slice(e-r,Math.min(n.length,e+100-r))}column(e,t=1){let{text:n,from:r}=this.lineAt(e,t),i=this.countColumn(n,e-r),a=this.options.overrideIndentation?this.options.overrideIndentation(r):-1;return a>-1&&(i+=a-this.countColumn(n,n.search(/\S|$/))),i}countColumn(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}},Ee=new _;function De(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 Oe(r,e,n)}function Oe(e,t,n){for(let r=e;r;r=r.next){let e=Ae(r.node);if(e)return e(Me.create(t,n,r))}return 0}function ke(e){return e.pos==e.options.simulateBreak&&e.options.simulateDoubleBreak}function Ae(e){let t=e.type.prop(Ee);if(t)return t;let n=e.firstChild,r;if(n&&(r=n.type.prop(_.closedBy))){let t=e.lastChild,n=t&&r.indexOf(t.name)>-1;return e=>Ie(e,!0,1,void 0,n&&!ke(e)?t.from:void 0)}return e.parent==null?je:null}function je(){return 0}var Me=class e extends N{constructor(e,t,n){super(e.state,e.options),this.base=e,this.pos=t,this.context=n}get node(){return this.context.node}static create(t,n,r){return new e(t,n,r)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let t=this.state.doc.lineAt(e.from);for(;;){let n=e.resolve(t.from);for(;n.parent&&n.parent.from==n.from;)n=n.parent;if(Ne(n,e))break;t=this.state.doc.lineAt(n.from)}return this.lineIndent(t.from)}continue(){return Oe(this.context.next,this.base,this.pos)}};function Ne(e,t){for(let n=t;n;n=n.parent)if(e==n)return!0;return!1}function Pe(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 Fe({closing:e,align:t=!0,units:n=1}){return r=>Ie(r,t,n,e)}function Ie(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?Pe(e):null;return c?s?e.column(c.from):e.column(c.to):e.baseIndent+(s?0:e.unit*n)}var Le=e=>e.baseIndent;function Re({except:e,units:t=1}={}){return n=>{let r=e&&e.test(n.textAfter);return n.baseIndent+(r?0:t*n.unit)}}var ze=200;function Be(){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+ze)return e;let a=n.sliceString(i.from,r);if(!t.some(e=>e.test(a)))return e;let{state:o}=e,s=-1,c=[];for(let{head:e}of o.selection.ranges){let t=o.doc.lineAt(e);if(t.from==s)continue;s=t.from;let n=M(o,t.from);if(n==null)continue;let r=/^\s*/.exec(t.text)[0],i=j(o,n);r!=i&&c.push({from:t.from,to:t.from+r.length,insert:i})}return c.length?[e,{changes:c,sequential:!0}]:e})}var Ve=o.define(),He=new _;function Ue(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 We(e,t,n){let r=w(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(He);if(s&&(i.to<r.length-50||r.length==e.doc.length||!Ge(i))){let r=s(i,e);r&&r.from<=n&&r.from>=t&&r.to>n&&(a=r)}}return a}function Ge(e){let t=e.lastChild;return t&&t.to==e.to&&t.type.isError}function P(e,t,n){for(let r of e.facet(Ve)){let i=r(e,t,n);if(i)return i}return We(e,t,n)}function Ke(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 F=a.define({map:Ke}),I=a.define({map:Ke});function L(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 R=r.define({create(){return m.none},update(e,t){t.isUserEvent(`delete`)&&t.changes.iterChangedRanges((t,n)=>e=qe(e,t,n)),e=e.map(t.changes);let n=[];for(let r of t.effects)r.is(F)&&!Ye(e,r.value.from,r.value.to)?n.push(r.value):r.is(I)&&(e=e.update({filter:(e,t)=>r.value.from!=e||r.value.to!=t,filterFrom:r.value.from,filterTo:r.value.to}));if(n.length){let{preparePlaceholder:r}=t.state.facet(H),i=n.map(e=>(r?m.replace({widget:new ot(r(t.state,e))}):at).range(e.from,e.to));e=e.update({add:i})}return t.selection&&(e=qe(e,t.selection.main.head)),e},provide:e=>p.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(at.range(r,i))}return m.set(t,!0)}});function qe(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 Je(e){return e.field(R,!1)||s.empty}function z(e,t,n){var r;let i=null;return(r=e.field(R,!1))==null||r.between(t,n,(e,t)=>{(!i||i.from>e)&&(i={from:e,to:t})}),i}function Ye(e,t,n){let r=!1;return e.between(t,t,(e,i)=>{e==t&&i==n&&(r=!0)}),r}function B(e,t){return e.field(R,!1)?t:t.concat(a.appendConfig.of(U()))}var Xe=e=>{for(let t of L(e)){let n=P(e.state,t.from,t.to);if(n)return e.dispatch({effects:B(e.state,[F.of(n),V(e,n)])}),!0}return!1},Ze=e=>{if(!e.state.field(R,!1))return!1;let t=[];for(let n of L(e)){let r=z(e.state,n.from,n.to);r&&t.push(I.of(r),V(e,r,!1))}return t.length&&e.dispatch({effects:t}),t.length>0};function V(e,t,n=!0){let r=e.state.doc.lineAt(t.from).number,i=e.state.doc.lineAt(t.to).number;return p.announce.of(`${e.state.phrase(n?`Folded lines`:`Unfolded lines`)} ${r} ${e.state.phrase(`to`)} ${i}.`)}var Qe=e=>{let{state:t}=e,n=[];for(let r=0;r<t.doc.length;){let i=e.lineBlockAt(r),a=P(t,i.from,i.to);a&&n.push(F.of(a)),r=(a?e.lineBlockAt(a.to):i).to+1}return n.length&&e.dispatch({effects:B(e.state,n)}),!!n.length},$e=e=>{let t=e.state.field(R,!1);if(!t||!t.size)return!1;let n=[];return t.between(0,e.state.doc.length,(e,t)=>{n.push(I.of({from:e,to:t}))}),e.dispatch({effects:n}),!0};function et(e,t){for(let n=t;;){let r=P(e.state,n.from,n.to);if(r&&r.to>t.from)return r;if(!n.from)return null;n=e.lineBlockAt(n.from-1)}}var tt=e=>{let t=[];for(let n of L(e)){let r=z(e.state,n.from,n.to);if(r)t.push(I.of(r),V(e,r,!1));else{let r=et(e,n);r&&t.push(F.of(r),V(e,r))}}return t.length>0&&e.dispatch({effects:B(e.state,t)}),!!t.length},nt=[{key:`Ctrl-Shift-[`,mac:`Cmd-Alt-[`,run:Xe},{key:`Ctrl-Shift-]`,mac:`Cmd-Alt-]`,run:Ze},{key:`Ctrl-Alt-[`,run:Qe},{key:`Ctrl-Alt-]`,run:$e}],rt={placeholderDOM:null,preparePlaceholder:null,placeholderText:`…`},H=o.define({combine(e){return c(e,rt)}});function U(e){let t=[R,lt];return e&&t.push(H.of(e)),t}function it(e,t){let{state:n}=e,r=n.facet(H),i=t=>{let n=e.lineBlockAt(e.posAtDOM(t.target)),r=z(e.state,n.from,n.to);r&&e.dispatch({effects:I.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 at=m.replace({widget:new class extends te{toDOM(e){return it(e,null)}}}),ot=class extends te{constructor(e){super(),this.value=e}eq(e){return this.value==e.value}toDOM(e){return it(e,this.value)}},st={openText:`⌄`,closedText:`›`,markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1},W=class extends ee{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 ct(e={}){let n={...st,...e},r=new W(n,!0),i=new W(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(O)!=e.state.facet(O)||e.startState.field(R,!1)!=e.state.field(R,!1)||w(e.startState)!=w(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=z(e.state,t.from,t.to)?i:P(e.state,t.from,t.to)?r:null;a&&n.add(t.from,t.from,a)}return n.finish()}}),{domEventHandlers:o}=n;return[a,ne({class:`cm-foldGutter`,markers(e){return e.plugin(a)?.markers||s.empty},initialSpacer(){return new W(n,!1)},domEventHandlers:{...o,click:(e,t,n)=>{if(o.click&&o.click(e,t,n))return!0;let r=z(e.state,t.from,t.to);if(r)return e.dispatch({effects:I.of(r)}),!0;let i=P(e.state,t.from,t.to);return i?(e.dispatch({effects:F.of(i)}),!0):!1}}}),U()]}var lt=p.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`}}),G=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 C?e=>e.prop(x)==a.data:a?e=>e==a:void 0,this.style=re(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||{})}},K=o.define(),ut=o.define({combine(e){return e.length?[e[0]]:null}});function q(e){let t=e.facet(K);return t.length?t:e.facet(ut)}function dt(e,t){let n=[mt],r;return e instanceof G&&(e.module&&n.push(p.styleModule.of(e.module)),r=e.themeType),t?.fallback?n.push(ut.of(e)):r?n.push(K.computeN([p.darkTheme],t=>t.facet(p.darkTheme)==(r==`dark`)?[e]:[])):n.push(K.of(e)),n}function ft(e,t,n){let r=q(e),i=null;if(r){for(let e of r)if(!e.scope||n&&e.scope(n)){let n=e.style(t);n&&(i=i?i+` `+n:n)}}return i}var pt=class{constructor(e){this.markCache=Object.create(null),this.tree=w(e.state),this.decorations=this.buildDeco(e,q(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=w(e.state),n=q(e.state),r=n!=q(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 m.none;let r=new t;for(let{from:t,to:i}of e.visibleRanges)se(this.tree,n,(e,t,n)=>{r.add(e,t,this.markCache[n]||(this.markCache[n]=m.mark({class:n})))},t,i);return r.finish()}},mt=n.high(u.fromClass(pt,{decorations:e=>e.decorations})),ht=G.define([{tag:y.meta,color:`#404740`},{tag:y.link,textDecoration:`underline`},{tag:y.heading,textDecoration:`underline`,fontWeight:`bold`},{tag:y.emphasis,fontStyle:`italic`},{tag:y.strong,fontWeight:`bold`},{tag:y.strikethrough,textDecoration:`line-through`},{tag:y.keyword,color:`#708`},{tag:[y.atom,y.bool,y.url,y.contentSeparator,y.labelName],color:`#219`},{tag:[y.literal,y.inserted],color:`#164`},{tag:[y.string,y.deleted],color:`#a11`},{tag:[y.regexp,y.escape,y.special(y.string)],color:`#e40`},{tag:y.definition(y.variableName),color:`#00f`},{tag:y.local(y.variableName),color:`#30a`},{tag:[y.typeName,y.namespace],color:`#085`},{tag:y.className,color:`#167`},{tag:[y.special(y.variableName),y.macroName],color:`#256`},{tag:y.definition(y.propertyName),color:`#00c`},{tag:y.comment,color:`#940`},{tag:y.invalid,color:`#f00`}]),gt=p.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:`#328c8252`},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:`#bb555544`}}),_t=1e4,vt=`()[]{}`,yt=o.define({combine(e){return c(e,{afterCursor:!0,brackets:vt,maxScanDistance:_t,renderMatch:St})}}),bt=m.mark({class:`cm-matchingBracket`}),xt=m.mark({class:`cm-nonmatchingBracket`});function St(e){let t=[],n=e.matched?bt:xt;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 Ct(e){let t=[],n=e.facet(yt);for(let r of e.selection.ranges){if(!r.empty)continue;let i=X(e,r.head,-1,n)||r.head>0&&X(e,r.head-1,1,n)||n.afterCursor&&(X(e,r.head,1,n)||r.head<e.doc.length&&X(e,r.head+1,-1,n));i&&(t=t.concat(n.renderMatch(i,e)))}return m.set(t,!0)}var wt=[u.fromClass(class{constructor(e){this.paused=!1,this.decorations=Ct(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=Ct(e.state),this.paused=!1))}},{decorations:e=>e.decorations}),gt];function Tt(e={}){return[yt.of(e),wt]}var Et=new _;function J(e,t,n){let r=e.prop(t<0?_.openedBy:_.closedBy);if(r)return r;if(e.name.length==1){let r=n.indexOf(e.name);if(r>-1&&r%2==+(t<0))return[n[r+t]]}return null}function Y(e){let t=e.type.prop(Et);return t?t(e.node):e}function X(e,t,n,r={}){let i=r.maxScanDistance||_t,a=r.brackets||vt,o=w(e),s=o.resolveInner(t,n);for(let r=s;r;r=r.parent){let i=J(r.type,n,a);if(i&&r.from<r.to){let o=Y(r);if(o&&(n>0?t>=o.from&&t<o.to:t>o.from&&t<=o.to))return Dt(e,t,n,r,o,i,a)}}return Ot(e,t,n,o,s.type,i,a)}function Dt(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=Y(u);return{start:c,end:e?{from:e.from,to:e.to}:void 0,matched:!0}}if(J(u.type,n,o))l++;else if(J(u.type,-n,o)){if(l==0){let e=Y(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 Ot(e,t,n,r,i,a,o){if(n<0?!t:t==e.doc.length)return null;let s=n<0?e.sliceDoc(t-1,t):e.sliceDoc(t,t+1),c=o.indexOf(s);if(c<0||c%2==0!=n>0)return null;let l={from:n<0?t-1:t,to:n>0?t+1:t},u=e.doc.iterRange(t,n>0?e.doc.length:0),d=0;for(let e=0;!u.next().done&&e<=a;){let a=u.value;n<0&&(e+=a.length);let s=t+e*n;for(let e=n>0?0:a.length-1,t=n>0?a.length:-1;e!=t;e+=n){let t=o.indexOf(a[e]);if(!(t<0||r.resolveInner(s+e,1).type!=i)){if(t%2==0==n>0)d++;else if(d==1)return{start:l,end:{from:s+e,to:s+e+1},matched:t>>1==c>>1};else d--}}n>0&&(e+=a.length)}return u.done?{start:l,matched:!1}:null}function kt(e){return{name:e.name||``,token:e.token,blankLine:e.blankLine||(()=>{}),startState:e.startState||(()=>!0),copyState:e.copyState||At,indent:e.indent||(()=>null),languageData:e.languageData||{},tokenTable:e.tokenTable||Lt,mergeTokens:e.mergeTokens!==!1}}function At(e){if(typeof e!=`object`)return e;let t={};for(let n in e){let r=e[n];t[n]=r instanceof Array?r.slice():r}return t}var jt=new WeakMap,Mt=class e extends C{constructor(e){let t=S(e.languageData),n=kt(e),r,i=new class extends oe{createParse(e,t,n){return new Ft(r,e,t,n)}};super(t,i,[],e.name),this.topNode=Kt(t,this),r=this,this.streamParser=n,this.stateAfter=new _({perNode:!0}),this.tokenTable=e.tokenTable?new Ht(n.tokenTable):Ut}static define(t){return new e(t)}getIndent(e){let t,{overrideIndentation:n}=e.options;n&&(t=jt.get(e.state),t!=null&&t<e.pos-1e4&&(t=void 0));let r=Z(this,e.node.tree,e.node.from,e.node.from,t??e.pos),i,a;if(r?(a=r.state,i=r.pos+1):(a=this.streamParser.startState(e.unit),i=e.node.from),e.pos-i>1e4)return null;for(;i<e.pos;){let t=e.state.doc.lineAt(i),r=Math.min(e.pos,t.to);if(t.length){let i=n?n(t.from):-1,o=new b(t.text,e.state.tabSize,e.unit,i<0?void 0:i);for(;o.pos<r-t.from;)It(this.streamParser.token,o,a)}else this.streamParser.blankLine(a,e.unit);if(r==e.pos)break;i=t.to+1}let o=e.lineAt(e.pos);return n&&t==null&&jt.set(e.state,o.from),this.streamParser.indent(a,/^\s*(.*)/.exec(o.text)[1],e)}get allowsNesting(){return!1}};function Z(e,t,n,r,i){let a=n>=r&&n+t.length<=i&&t.prop(e.stateAfter);if(a)return{state:e.streamParser.copyState(a),pos:n+t.length};for(let a=t.children.length-1;a>=0;a--){let o=t.children[a],s=n+t.positions[a],c=o instanceof v&&s<i&&Z(e,o,s,r,i);if(c)return c}return null}function Nt(e,t,n,r,i){if(i&&n<=0&&r>=t.length)return t;!i&&n==0&&t.type==e.topNode&&(i=!0);for(let a=t.children.length-1;a>=0;a--){let o=t.positions[a],s=t.children[a],c;if(o<r&&s instanceof v){if(!(c=Nt(e,s,n-o,r-o,i)))break;return i?new v(t.type,t.children.slice(0,a).concat(c),t.positions.slice(0,a+1),o+c.length):c}}return null}function Pt(e,t,n,r,i){for(let i of t){let t=i.from+(i.openStart?25:0),a=i.to-(i.openEnd?25:0),o=t<=n&&a>n&&Z(e,i.tree,0-i.offset,n,a),s;if(o&&o.pos<=r&&(s=Nt(e,i.tree,n+i.offset,o.pos+i.offset,!1)))return{state:o.state,tree:s}}return{state:e.streamParser.startState(i?A(i):4),tree:v.empty}}var Ft=class{constructor(e,t,n,r){this.lang=e,this.input=t,this.fragments=n,this.ranges=r,this.stoppedAt=null,this.chunks=[],this.chunkPos=[],this.chunk=[],this.chunkReused=void 0,this.rangeIndex=0,this.to=r[r.length-1].to;let i=E.get(),a=r[0].from,{state:o,tree:s}=Pt(e,n,a,this.to,i?.state);this.state=o,this.parsedPos=this.chunkStart=a+s.length;for(let e=0;e<s.children.length;e++)this.chunks.push(s.children[e]),this.chunkPos.push(s.positions[e]);i&&this.parsedPos<i.viewport.from-1e5&&r.some(e=>e.from<=i.viewport.from&&e.to>=i.viewport.from)&&(this.state=this.lang.streamParser.startState(A(i.state)),i.skipUntilInView(this.parsedPos,i.viewport.from),this.parsedPos=i.viewport.from),this.moveRangeIndex()}advance(){let e=E.get(),t=this.stoppedAt==null?this.to:Math.min(this.to,this.stoppedAt),n=Math.min(t,this.chunkStart+512);for(e&&(n=Math.min(n,e.viewport.to));this.parsedPos<n;)this.parseLine(e);return this.chunkStart<this.parsedPos&&this.finishChunk(),this.parsedPos>=t?this.finish():e&&this.parsedPos>=e.viewport.to?(e.skipUntilInView(this.parsedPos,t),this.finish()):null}stopAt(e){this.stoppedAt=e}lineAfter(e){let t=this.input.chunk(e);if(this.input.lineChunks)t==`
2
2
  `&&(t=``);else{let e=t.indexOf(`
3
3
  `);e>-1&&(t=t.slice(0,e))}return e+t.length<=this.to?t:t.slice(0,this.to-e)}nextLine(){let e=this.parsedPos,t=this.lineAfter(e),n=e+t.length;for(let e=this.rangeIndex;;){let r=this.ranges[e].to;if(r>=n||(t=t.slice(0,r-(n-t.length)),e++,e==this.ranges.length))break;let i=this.ranges[e].from,a=this.lineAfter(i);t+=a,n=i+a.length}return{line:t,end:n}}skipGapsTo(e,t,n){for(;;){let r=this.ranges[this.rangeIndex].to,i=e+t;if(n>0?r>i:r>=i)break;let a=this.ranges[++this.rangeIndex].from;t+=a-r}return t}moveRangeIndex(){for(;this.ranges[this.rangeIndex].to<this.parsedPos;)this.rangeIndex++}emitToken(e,t,n,r){let i=4;if(this.ranges.length>1){r=this.skipGapsTo(t,r,1),t+=r;let e=this.chunk.length;r=this.skipGapsTo(n,r,-1),n+=r,i+=this.chunk.length-e}let a=this.chunk.length-4;return this.lang.streamParser.mergeTokens&&i==4&&a>=0&&this.chunk[a]==e&&this.chunk[a+2]==t?this.chunk[a+2]=n:this.chunk.push(e,t,n,i),r}parseLine(e){let{line:t,end:n}=this.nextLine(),r=0,{streamParser:i}=this.lang,a=new b(t,e?e.state.tabSize:4,e?A(e.state):2);if(a.eol())i.blankLine(this.state,a.indentUnit);else for(;!a.eol();){let e=It(i.token,a,this.state);if(e&&(r=this.emitToken(this.lang.tokenTable.resolve(e),this.parsedPos+a.start,this.parsedPos+a.pos,r)),a.start>1e4)break}this.parsedPos=n,this.moveRangeIndex(),this.parsedPos<this.to&&this.parsedPos++}finishChunk(){let e=v.build({buffer:this.chunk,start:this.chunkStart,length:this.parsedPos-this.chunkStart,nodeSet:Rt,topID:0,maxBufferLength:512,reused:this.chunkReused});e=new v(e.type,e.children,e.positions,e.length,[[this.lang.stateAfter,this.lang.streamParser.copyState(this.state)]]),this.chunks.push(e),this.chunkPos.push(this.chunkStart-this.ranges[0].from),this.chunk=[],this.chunkReused=void 0,this.chunkStart=this.parsedPos}finish(){return new v(this.lang.topNode,this.chunks,this.chunkPos,this.parsedPos-this.ranges[0].from).balance()}};function It(e,t,n){t.start=t.pos;for(let r=0;r<10;r++){let r=e(t,n);if(t.pos>t.start)return r}throw Error(`Stream parser failed to advance stream.`)}var Lt=Object.create(null),Q=[h.none],Rt=new ce(Q),zt=[],Bt=Object.create(null),Vt=Object.create(null);for(let[e,t]of[[`variable`,`variableName`],[`variable-2`,`variableName.special`],[`string-2`,`string.special`],[`def`,`variableName.definition`],[`tag`,`tagName`],[`attribute`,`attributeName`],[`type`,`typeName`],[`builtin`,`variableName.standard`],[`qualifier`,`modifier`],[`error`,`invalid`],[`header`,`heading`],[`property`,`propertyName`]])Vt[e]=Gt(Lt,t);var Ht=class{constructor(e){this.extra=e,this.table=Object.assign(Object.create(null),Vt)}resolve(e){return e?this.table[e]||(this.table[e]=Gt(this.extra,e)):0}},Ut=new Ht(Lt);function Wt(e,t){zt.indexOf(e)>-1||(zt.push(e),console.warn(t))}function Gt(e,t){let n=[];for(let r of t.split(` `)){let t=[];for(let n of r.split(`.`)){let r=e[n]||y[n];r?typeof r==`function`?t.length?t=t.map(r):Wt(n,`Modifier ${n} used at start of tag`):t.length?Wt(n,`Tag ${n} used as modifier`):t=Array.isArray(r)?r:[r]:Wt(n,`Unknown highlighting tag ${n}`)}for(let e of t)n.push(e)}if(!n.length)return 0;let r=t.replace(/ /g,`_`),i=r+` `+n.map(e=>e.id),a=Bt[i];if(a)return a.id;let o=Bt[i]=h.define({id:Q.length,name:r,props:[ae({[r]:n})]});return Q.push(o),o.id}function Kt(e,t){let n=h.define({id:Q.length,name:`Document`,props:[x.add(()=>e),Ee.add(()=>e=>t.getIndent(e))],top:!0});return Q.push(n),n}function qt(e){return e.length<=4096&&/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/.test(e)}function Jt(e){for(let t=e.iter();!t.next().done;)if(qt(t.value))return!0;return!1}function Yt(e){let t=!1;return e.iterChanges((e,n,r,i,a)=>{!t&&Jt(a)&&(t=!0)}),t}var $=o.define({combine:e=>e.some(e=>e)});function Xt(e={}){let t=[Zt];return e.alwaysIsolate&&t.push($.of(!0)),t}var Zt=u.fromClass(class{constructor(e){this.always=e.state.facet($)||e.textDirection!=f.LTR||e.state.facet(p.perLineTextDirection),this.hasRTL=!this.always&&Jt(e.state.doc),this.tree=w(e.state),this.decorations=this.always||this.hasRTL?Qt(e,this.tree,this.always):m.none}update(e){let t=e.state.facet($)||e.view.textDirection!=f.LTR||e.state.facet(p.perLineTextDirection);if(!t&&!this.hasRTL&&Yt(e.changes)&&(this.hasRTL=!0),!t&&!this.hasRTL)return;let n=w(e.state);(t!=this.always||n!=this.tree||e.docChanged||e.viewportChanged)&&(this.tree=n,this.always=t,this.decorations=Qt(e.view,n,t))}},{provide:e=>{function t(t){return t.plugin(e)?.decorations??m.none}return[p.outerDecorations.of(t),n.lowest(p.bidiIsolatedRanges.of(t))]}});function Qt(e,n,r){let i=new t,a=e.visibleRanges;r||(a=$t(a,e.state.doc));for(let{from:e,to:t}of a)n.iterate({enter:e=>{let t=e.type.prop(_.isolate);t&&i.add(e.from,e.to,en[t])},from:e,to:t});return i.finish()}function $t(e,t){let n=t.iter(),r=0,i=[],a=null;for(let{from:t,to:o}of e)if(!(a&&a.to>t&&(t=a.to,t>=o)))for(r+n.value.length<t&&(n.next(t-(r+n.value.length)),r=t);;){let e=r,t=r+n.value.length;if(!n.lineBreak&&qt(n.value)&&(a&&a.to>e-10?a.to=Math.min(o,t):i.push(a={from:e,to:Math.min(o,t)})),t>=o)break;r=t,n.next()}return i}var en={rtl:m.mark({class:`cm-iso`,inclusive:!0,attributes:{dir:`rtl`},bidiIsolate:f.RTL}),ltr:m.mark({class:`cm-iso`,inclusive:!0,attributes:{dir:`ltr`},bidiIsolate:f.LTR}),auto:m.mark({class:`cm-iso`,inclusive:!0,attributes:{dir:`auto`},bidiIsolate:null})};export{_e as DocInput,G as HighlightStyle,N as IndentContext,fe as LRLanguage,C as Language,Ce as LanguageDescription,Se as LanguageSupport,E as ParseContext,Mt as StreamLanguage,b as StringStream,Me as TreeIndentContext,Xt as bidiIsolates,Tt as bracketMatching,Et as bracketMatchingHandle,U as codeFolding,Re as continuedIndent,ht as defaultHighlightStyle,S as defineLanguageFacet,Fe as delimitedIndent,pe as ensureSyntaxTree,Le as flatIndent,Qe as foldAll,Xe as foldCode,F as foldEffect,ct as foldGutter,Ue as foldInside,nt as foldKeymap,He as foldNodeProp,Ve as foldService,R as foldState,P as foldable,Je as foldedRanges,he as forceParsing,A as getIndentUnit,M as getIndentation,ft as highlightingFor,Ee as indentNodeProp,Be as indentOnInput,Te as indentRange,we as indentService,j as indentString,k as indentUnit,O as language,x as languageDataProp,X as matchBrackets,ue as sublanguageProp,dt as syntaxHighlighting,ge as syntaxParserRunning,w as syntaxTree,me as syntaxTreeAvailable,tt as toggleFold,$e as unfoldAll,Ze as unfoldCode,I as unfoldEffect};