@evandu/super-pi 0.1.146 → 0.1.147
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.
- package/agents/super-pi-task/core.ts +60 -1
- package/agents/super-pi-task/index.ts +4 -0
- package/dist/.super-pi-check-inputs.json +2 -2
- package/dist/client/.super-pi-client-sources.json +8 -8
- package/dist/client/assets/{CodeMirrorEditor-CEwBCVM6.js → CodeMirrorEditor-DQCjEnxG.js} +2 -2
- package/dist/client/assets/{dist-DC1IocrS.js → dist-1Innu17E.js} +1 -1
- package/dist/client/assets/{dist-CSCUT1PQ.js → dist-1lynFOc5.js} +1 -1
- package/dist/client/assets/{dist-Do52MRwm.js → dist-B1qLZVMK.js} +1 -1
- package/dist/client/assets/{dist-CAOcjKAQ.js → dist-B4pz_xdd.js} +1 -1
- package/dist/client/assets/{dist-B0RXZeXQ.js → dist-B6KwDpeI.js} +1 -1
- package/dist/client/assets/{dist-DFMtP3wG.js → dist-BJVI1Unv.js} +1 -1
- package/dist/client/assets/{dist-oLq6HXLG.js → dist-BWvzD8Pe.js} +1 -1
- package/dist/client/assets/{dist-9F1wL-T5.js → dist-BayWssd0.js} +1 -1
- package/dist/client/assets/{dist-DBUqwiWG.js → dist-Bk_pkBVH.js} +1 -1
- package/dist/client/assets/{dist-CbVf2Cjn.js → dist-BpeClAv0.js} +1 -1
- package/dist/client/assets/{dist-DftD4ibj.js → dist-BsmJg5PX.js} +1 -1
- package/dist/client/assets/{dist-CUB_Chdh.js → dist-Bx7s4rni.js} +1 -1
- package/dist/client/assets/{dist-Bh8Q7Y_n.js → dist-CDBKM9tL.js} +1 -1
- package/dist/client/assets/{dist-BoyICDlL.js → dist-CGzXCzCG.js} +1 -1
- package/dist/client/assets/{dist-BCNaDgNW.js → dist-CRxCwn-Z.js} +1 -1
- package/dist/client/assets/{dist-76ArZ5M4.js → dist-CTDgUnBG.js} +1 -1
- package/dist/client/assets/{dist-BXBSIuTD.js → dist-D1VfMWmf.js} +1 -1
- package/dist/client/assets/{dist-DN0GlnnZ.js → dist-DTZLNEci.js} +1 -1
- package/dist/client/assets/{dist-JvQIIdqB.js → dist-DuUi29km.js} +1 -1
- package/dist/client/assets/{dist-CHt8PX8R.js → dist-F3S0t1oM.js} +1 -1
- package/dist/client/assets/{dist-BuR5Iagd.js → dist-QZ-FAVJV.js} +1 -1
- package/dist/client/assets/{dist-Bx6ZWYUW.js → dist-u0nBg0fZ.js} +1 -1
- package/dist/client/assets/index-BMpqviwU.css +1 -0
- package/dist/client/assets/{index-E7yaLa2C.js → index-Dzyp_7sf.js} +43 -43
- package/dist/client/index.html +2 -2
- package/dist/server/active-memory.d.ts +17 -0
- package/dist/server/active-memory.js +39 -0
- package/dist/server/application/conversation-service.js +6 -0
- package/dist/server/application/run-service.d.ts +16 -0
- package/dist/server/application/run-service.js +175 -26
- package/dist/server/application/session-orchestrator-service.d.ts +103 -1
- package/dist/server/application/session-orchestrator-service.js +303 -8
- package/dist/server/application/session-watchdog.d.ts +159 -0
- package/dist/server/application/session-watchdog.js +244 -0
- package/dist/server/http-server.js +136 -76
- package/dist/server/index.js +3 -0
- package/dist/server/knowledge-vectors.d.ts +15 -0
- package/dist/server/knowledge-vectors.js +118 -37
- package/dist/server/knowledge.d.ts +7 -8
- package/dist/server/knowledge.js +133 -55
- package/dist/server/length-continuation.d.ts +50 -0
- package/dist/server/length-continuation.js +55 -0
- package/dist/server/pi-session-events.js +5 -1
- package/dist/server/pi-session-pool.d.ts +2 -0
- package/dist/server/pi-session-pool.js +16 -0
- package/dist/server/runtime.js +2 -1
- package/dist/server/session-tree-scope.d.ts +125 -0
- package/dist/server/session-tree-scope.js +337 -0
- package/dist/server/store.d.ts +13 -0
- package/dist/server/store.js +37 -4
- package/dist/server/task-tool.d.ts +1 -1
- package/dist/server/task-tool.js +2 -1
- package/dist/server/turn-failure.d.ts +26 -0
- package/dist/server/turn-failure.js +51 -0
- package/dist/server/types.d.ts +15 -1
- package/package.json +19 -3
- package/dist/client/assets/index-D-OxlUxN.css +0 -1
|
@@ -1163,7 +1163,8 @@ Usage notes:
|
|
|
1163
1163
|
2. The initial task should provide clear context and goals since the new session starts with a fresh conversation history.
|
|
1164
1164
|
3. Use session_status with the returned conversationId to check progress, or session_dispatch to send further messages.
|
|
1165
1165
|
4. The new session reports completion to its DIRECT parent automatically. 'parentConversationId' optionally selects that parent; by default it is the calling session.
|
|
1166
|
-
5. The new session always belongs to the calling session's workspace. Pass 'cwd' as a workspace-relative subdirectory (for example, 'packages/a') when it should work below the workspace root; absolute paths and traversal are rejected
|
|
1166
|
+
5. The new session always belongs to the calling session's workspace. Pass 'cwd' as a workspace-relative subdirectory (for example, 'packages/a') when it should work below the workspace root; absolute paths and traversal are rejected.
|
|
1167
|
+
6. Optionally pass 'model' to choose which model the NEW session runs on: {"provider":"...","modelId":"..."} - the same "provider/modelId" pair the model picker shows, and BOTH halves are required. Leave 'model' out and the new session starts on the workspace default model.`;
|
|
1167
1168
|
|
|
1168
1169
|
/** Model-facing description for session_status. */
|
|
1169
1170
|
export const SESSION_STATUS_DESCRIPTION = `Inspect the progress, run state, and latest activity of sibling conversations created by the orchestrator.
|
|
@@ -1259,6 +1260,13 @@ export type SessionSpawnParams = {
|
|
|
1259
1260
|
parentConversationId?: string;
|
|
1260
1261
|
title?: string;
|
|
1261
1262
|
agentId?: string;
|
|
1263
|
+
/**
|
|
1264
|
+
* The model the NEW session runs on, as the "provider/modelId" pair the model picker shows.
|
|
1265
|
+
*
|
|
1266
|
+
* Both halves are required when this is present, and the server looks the pair up in Pi's
|
|
1267
|
+
* catalog: a pair Pi does not offer is REFUSED there, not quietly replaced by the default.
|
|
1268
|
+
*/
|
|
1269
|
+
model?: { provider: string; modelId: string };
|
|
1262
1270
|
thinkingLevel?: string;
|
|
1263
1271
|
wait?: boolean;
|
|
1264
1272
|
/** Optional subdirectory (relative to the resolved workspace root) the new session's cwd should be rooted in. */
|
|
@@ -1283,6 +1291,46 @@ export type SessionStopParams = {
|
|
|
1283
1291
|
messageId?: string;
|
|
1284
1292
|
};
|
|
1285
1293
|
|
|
1294
|
+
/**
|
|
1295
|
+
* THE FORMAT THE MODEL IS TOLD TO USE. The client hands its model picker a single
|
|
1296
|
+
* "provider/modelId" string, so this is the shape the model already knows how to read.
|
|
1297
|
+
*/
|
|
1298
|
+
const SPAWN_MODEL_FORMAT = 'the "provider/modelId" pair the model picker shows, e.g. {"provider":"anthropic","modelId":"claude-..."}';
|
|
1299
|
+
|
|
1300
|
+
const SPAWN_MODEL_SHAPE_REFUSAL = `session_spawn's \`model\` parameter must be an object carrying BOTH \`provider\` and \`modelId\` - ${SPAWN_MODEL_FORMAT}. Provide both, or leave \`model\` out entirely to use the workspace default model.`;
|
|
1301
|
+
|
|
1302
|
+
const SPAWN_MODEL_MISSING_PROVIDER_REFUSAL = `session_spawn's \`model\` parameter is missing \`provider\`. It needs BOTH \`provider\` and \`modelId\` - ${SPAWN_MODEL_FORMAT}. Provide both, or leave \`model\` out entirely to use the workspace default model.`;
|
|
1303
|
+
|
|
1304
|
+
const SPAWN_MODEL_MISSING_MODEL_ID_REFUSAL = `session_spawn's \`model\` parameter is missing \`modelId\`. It needs BOTH \`provider\` and \`modelId\` - ${SPAWN_MODEL_FORMAT}. Provide both, or leave \`model\` out entirely to use the workspace default model.`;
|
|
1305
|
+
|
|
1306
|
+
/**
|
|
1307
|
+
* The model selection the model asked for, or the reason it cannot be used.
|
|
1308
|
+
*
|
|
1309
|
+
* THE MODEL IS A PAIR OR IT IS NOTHING. The server's `setModel` looks the pair up in Pi's catalog:
|
|
1310
|
+
* half a pair is looked up with an empty string, is not found, and comes back as a catalog error
|
|
1311
|
+
* that does not say WHICH half was missing. So the pair is checked here, where the model can be
|
|
1312
|
+
* told exactly what to fix.
|
|
1313
|
+
*
|
|
1314
|
+
* A HALF-SPECIFIED MODEL IS REFUSED, NOT DROPPED. A dropped `model` is indistinguishable from a
|
|
1315
|
+
* deliberate "use the workspace default": the new session would run on a model nobody asked for,
|
|
1316
|
+
* and the mistake would not surface until the session behaved differently from what was expected.
|
|
1317
|
+
* That is why an empty object and a blank string are refusals too, rather than "no model at all".
|
|
1318
|
+
*
|
|
1319
|
+
* An ABSENT `model` is not a case here. It means "the workspace default", which is what the server
|
|
1320
|
+
* has always done, and the body then carries no model field at all.
|
|
1321
|
+
*/
|
|
1322
|
+
function readSpawnModel(raw: unknown): { model?: { provider: string; modelId: string }; error?: string } {
|
|
1323
|
+
if (raw === undefined || raw === null) return {};
|
|
1324
|
+
const pair = (typeof raw === "object" && !Array.isArray(raw)) ? raw as { provider?: unknown; modelId?: unknown } : undefined;
|
|
1325
|
+
if (!pair) return { error: SPAWN_MODEL_SHAPE_REFUSAL };
|
|
1326
|
+
const provider = typeof pair.provider === "string" ? pair.provider.trim() : "";
|
|
1327
|
+
const modelId = typeof pair.modelId === "string" ? pair.modelId.trim() : "";
|
|
1328
|
+
if (!provider && !modelId) return { error: SPAWN_MODEL_SHAPE_REFUSAL };
|
|
1329
|
+
if (!provider) return { error: SPAWN_MODEL_MISSING_PROVIDER_REFUSAL };
|
|
1330
|
+
if (!modelId) return { error: SPAWN_MODEL_MISSING_MODEL_ID_REFUSAL };
|
|
1331
|
+
return { model: { provider, modelId } };
|
|
1332
|
+
}
|
|
1333
|
+
|
|
1286
1334
|
/** Execute session_spawn: creates a new sibling conversation and queues initial prompt. */
|
|
1287
1335
|
export async function executeSessionSpawn(
|
|
1288
1336
|
params: SessionSpawnParams,
|
|
@@ -1304,6 +1352,13 @@ export async function executeSessionSpawn(
|
|
|
1304
1352
|
if (!params.task || !params.task.trim()) {
|
|
1305
1353
|
return text("session_spawn requires a non-empty `task` parameter describing what the sibling session should do.", true);
|
|
1306
1354
|
}
|
|
1355
|
+
// THE MODEL IS CHECKED BEFORE THE CALL, not after it. A half-specified pair would reach the server
|
|
1356
|
+
// as a catalog lookup with an empty half, and the answer would be an error about a model nobody
|
|
1357
|
+
// could name. Refused here, the model is told which half is missing and can fix it in one call.
|
|
1358
|
+
const selection = readSpawnModel(params.model);
|
|
1359
|
+
if (selection.error) {
|
|
1360
|
+
return text(selection.error, true);
|
|
1361
|
+
}
|
|
1307
1362
|
|
|
1308
1363
|
const send = deps.fetch ?? (globalFetch as unknown as TaskFetch);
|
|
1309
1364
|
try {
|
|
@@ -1319,6 +1374,10 @@ export async function executeSessionSpawn(
|
|
|
1319
1374
|
task: params.task.trim(),
|
|
1320
1375
|
title: params.title?.trim() || undefined,
|
|
1321
1376
|
agentId: params.agentId?.trim() || undefined,
|
|
1377
|
+
// ONLY WHEN A PAIR WAS GIVEN. An absent `model` leaves the field out of the body entirely,
|
|
1378
|
+
// and the server then applies the workspace default - which is what a spawn without a model
|
|
1379
|
+
// has always done, and what an explicit model must not quietly replace.
|
|
1380
|
+
...(selection.model ? { model: selection.model } : {}),
|
|
1322
1381
|
thinkingLevel: params.thinkingLevel?.trim() || undefined,
|
|
1323
1382
|
wait: Boolean(params.wait),
|
|
1324
1383
|
cwd: params.cwd?.trim() || undefined,
|
|
@@ -458,6 +458,10 @@ const extension = (pi: ExtensionApi): void => {
|
|
|
458
458
|
agentId: Type.Optional(Type.String({
|
|
459
459
|
description: "Optional agent definition to assign to the new session (e.g. 'coder', 'planner'). Defaults to the workspace default.",
|
|
460
460
|
})),
|
|
461
|
+
model: Type.Optional(Type.Object({
|
|
462
|
+
provider: Type.String({ description: "The provider half of the \"provider/modelId\" pair, e.g. \"anthropic\"." }),
|
|
463
|
+
modelId: Type.String({ description: "The model half of the \"provider/modelId\" pair, e.g. \"claude-...\"." }),
|
|
464
|
+
}, { description: "The model the NEW session runs on. BOTH halves are required - it is one \"provider/modelId\" pair, exactly as the model picker shows it. Leave it out to use the workspace default model." })),
|
|
461
465
|
thinkingLevel: Type.Optional(Type.String({
|
|
462
466
|
description: "Optional thinking level override ('off', 'low', 'medium', 'high'). Defaults to workspace setting.",
|
|
463
467
|
})),
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
{
|
|
2
|
-
"hash": "
|
|
2
|
+
"hash": "32e49d6e2012d538c105b4faff8416b2d9963d87a41e18c1e5b7a85d686e9084",
|
|
3
3
|
"files": {
|
|
4
|
-
"src/client/App.tsx": "
|
|
4
|
+
"src/client/App.tsx": "ecd95b1f6b5491092e0a639ebd9446e8050b9a5add3e995696e13f76a65c4264",
|
|
5
5
|
"src/client/CodeMirrorEditor.tsx": "b6b6479effa1482eda710f04a26f3af843515526e129ca5bc70692cca9074b09",
|
|
6
6
|
"src/client/ErrorBoundary.tsx": "d16376f9f6c7cc1fab8590c65a66438127642f7d6bb8023cec53d8a6cc9f3964",
|
|
7
7
|
"src/client/FeishuPanel.tsx": "52f116eba265bfde683338f5893107ad5559fd2f7d4a9e0df935507a46862a3b",
|
|
8
8
|
"src/client/FilesPanel.tsx": "820a8685729ab03d22917bc56b7831f5cd8c6534dde4ba2a8d145f4dab5a9293",
|
|
9
|
-
"src/client/GitPanel.tsx": "
|
|
9
|
+
"src/client/GitPanel.tsx": "101cd8dd4549ddedb4c75bc48cebf4d06e9229cc4daf48196d3de07a51cb6538",
|
|
10
10
|
"src/client/HelpWindow.tsx": "a52005240894911eb8a35efab78aa6ddcda9fef6dca976aafc4255a4f635ca76",
|
|
11
11
|
"src/client/KnowledgeFilePicker.tsx": "8f7eb7e9f70265aed09cc0892b091827976757d8f2a2d736d6ca170fcdd871e7",
|
|
12
12
|
"src/client/KnowledgePanel.tsx": "4f7230cfe610cd86d63aa143c82f6195b3c4208ef0bea703f92104ef27237704",
|
|
13
13
|
"src/client/MarkdownView.tsx": "4f04a8f3c9381946e5d2f957ac4fb74a6b16272e90375fb4dc6bd3a43d7c744d",
|
|
14
14
|
"src/client/MemoryPanel.tsx": "2cc1f4ee709f6d56ede8b0ceced228ea4c935cfd1cc803275558dbbd5f5244fb",
|
|
15
|
-
"src/client/ScheduledTasksPanel.tsx": "
|
|
15
|
+
"src/client/ScheduledTasksPanel.tsx": "ad8d929b73c7d332730fd41a8594e3d79930161121d5727b94d39a089d36d9c8",
|
|
16
16
|
"src/client/SlashCommandMenu.tsx": "69cd0a9d5e35f41f703e91a845e5bd750c952d2957be03b5528e156e60bf6ecb",
|
|
17
|
-
"src/client/Tabs.tsx": "
|
|
17
|
+
"src/client/Tabs.tsx": "4b29ddad2451a039f2bd7de99011683949307846667f0f0aa554a1d591fd7f18",
|
|
18
18
|
"src/client/TerminalPanel.tsx": "89db360a96c47e4afa7d84bbeada7ab765794a6a28b8c1260f15a71fbf948201",
|
|
19
19
|
"src/client/WorkflowCard.tsx": "8ce5458537a3b02dcbb9bbb4c7afacb07e0f41857ed250aa4cde0cbc8d4bde6c",
|
|
20
20
|
"src/client/editor-blame.ts": "d03669f945aca09ff77d100ef0d4f0129af4f8ccef81963c3ce00f8f6fb034c2",
|
|
@@ -27,13 +27,13 @@
|
|
|
27
27
|
"src/client/pending-operations.ts": "8a5f9e9711c0f875c8ed194196c218162de5270298dad4091351d41294c859d7",
|
|
28
28
|
"src/client/session-tree.ts": "affc00d2264926d615a38e458a89d3a8c651b74135bbfe004d0a9be9b14a0c86",
|
|
29
29
|
"src/client/slash-commands.ts": "b792018fb67bd9e6f777397b0720b8b3aa565a4d8f7a76f94fec097ddf749480",
|
|
30
|
-
"src/client/styles.css": "
|
|
30
|
+
"src/client/styles.css": "e75703da5ef20811ff70bd882729bb1b7228fb6667542181d61bdf85d2505c1e",
|
|
31
31
|
"src/client/terminal-emulator.ts": "ffcc4f5fbddaf25cebcc9e03dbe5d7d0ad2c21586f5d169e57c04c82e2308b3b",
|
|
32
32
|
"src/client/theme.tsx": "5892479a802f41e7d45adeb5170efbf555b240f8581528bcde7bf2d99c635010",
|
|
33
33
|
"src/client/tool-sharing.ts": "679c97f6d40be466964f2f1076aa7ea55f4a585c3deff8214675070220921059",
|
|
34
34
|
"src/client/tools.ts": "58fe41f0edbd490e3fab7f12f258b1dbc2163b653553b03ac61caf1543618e50",
|
|
35
|
-
"src/client/types.ts": "
|
|
35
|
+
"src/client/types.ts": "7c06189b32890009d28a371a64d9f29161c14a349a5b399d51d1314d38fa27ac",
|
|
36
36
|
"src/client/vite-env.d.ts": "65996936fbb042915f7b74a200fcdde7e410f32a669b1ab9597cfaa4b0faddb5"
|
|
37
37
|
},
|
|
38
|
-
"recordedAt": "2026-
|
|
38
|
+
"recordedAt": "2026-11-01T06:41:55.741Z"
|
|
39
39
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/dist-
|
|
2
|
-
import{a as e,i as t,n,r,s as i,t as a}from"./index-E7yaLa2C.js";var o=i(e(),1);async function s(e,t){let[{StreamLanguage:n},i]=await Promise.all([r(()=>import(`./dist-Do52MRwm.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-BoyICDlL.js`).then(e=>e.cpp()),__vite__mapDeps([6,5,2,3,0,1,4,7])),cc:()=>r(()=>import(`./dist-BoyICDlL.js`).then(e=>e.cpp()),__vite__mapDeps([6,5,2,3,0,1,4,7])),cxx:()=>r(()=>import(`./dist-BoyICDlL.js`).then(e=>e.cpp()),__vite__mapDeps([6,5,2,3,0,1,4,7])),hpp:()=>r(()=>import(`./dist-BoyICDlL.js`).then(e=>e.cpp()),__vite__mapDeps([6,5,2,3,0,1,4,7])),hh:()=>r(()=>import(`./dist-BoyICDlL.js`).then(e=>e.cpp()),__vite__mapDeps([6,5,2,3,0,1,4,7])),hxx:()=>r(()=>import(`./dist-BoyICDlL.js`).then(e=>e.cpp()),__vite__mapDeps([6,5,2,3,0,1,4,7])),c:()=>r(()=>import(`./dist-BoyICDlL.js`).then(e=>e.cpp()),__vite__mapDeps([6,5,2,3,0,1,4,7])),h:()=>r(()=>import(`./dist-BoyICDlL.js`).then(e=>e.cpp()),__vite__mapDeps([6,5,2,3,0,1,4,7])),cu:()=>r(()=>import(`./dist-BoyICDlL.js`).then(e=>e.cpp()),__vite__mapDeps([6,5,2,3,0,1,4,7])),cuh:()=>r(()=>import(`./dist-BoyICDlL.js`).then(e=>e.cpp()),__vite__mapDeps([6,5,2,3,0,1,4,7])),js:()=>r(()=>import(`./dist-CUB_Chdh.js`).then(e=>e.t).then(e=>e.javascript()),__vite__mapDeps([8,2,3,1,4,5,0,7,9])),jsx:()=>r(()=>import(`./dist-CUB_Chdh.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-CUB_Chdh.js`).then(e=>e.t).then(e=>e.javascript()),__vite__mapDeps([8,2,3,1,4,5,0,7,9])),cjs:()=>r(()=>import(`./dist-CUB_Chdh.js`).then(e=>e.t).then(e=>e.javascript()),__vite__mapDeps([8,2,3,1,4,5,0,7,9])),ts:()=>r(()=>import(`./dist-CUB_Chdh.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-CUB_Chdh.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-CUB_Chdh.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-CUB_Chdh.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-Bh8Q7Y_n.js`).then(e=>e.python()),__vite__mapDeps([10,5,2,3,0,1,4,7,9])),pyi:()=>r(()=>import(`./dist-Bh8Q7Y_n.js`).then(e=>e.python()),__vite__mapDeps([10,5,2,3,0,1,4,7,9])),java:()=>r(()=>import(`./dist-CbVf2Cjn.js`).then(e=>e.java()),__vite__mapDeps([11,5,2,3,0,1,4,7])),php:()=>r(()=>import(`./dist-DftD4ibj.js`).then(e=>e.php()),__vite__mapDeps([12,5,2,3,0,1,4,7,13,14,8,9])),sql:()=>r(()=>import(`./dist-CHt8PX8R.js`).then(e=>e.sql()),__vite__mapDeps([15,5,2,3,0,1,4,7,9])),yaml:()=>r(()=>import(`./dist-DN0GlnnZ.js`).then(e=>e.yaml()),__vite__mapDeps([16,5,2,3,0,1,4,7])),yml:()=>r(()=>import(`./dist-DN0GlnnZ.js`).then(e=>e.yaml()),__vite__mapDeps([16,5,2,3,0,1,4,7])),xml:()=>r(()=>import(`./dist-76ArZ5M4.js`).then(e=>e.xml()),__vite__mapDeps([17,1,2,3,4,5,0,7])),json:()=>r(()=>import(`./dist-B0RXZeXQ.js`).then(e=>e.json()),__vite__mapDeps([18,5,2,3,0,1,4,7])),jsonc:()=>r(()=>import(`./dist-B0RXZeXQ.js`).then(e=>e.json()),__vite__mapDeps([18,5,2,3,0,1,4,7])),json5:()=>r(()=>import(`./dist-B0RXZeXQ.js`).then(e=>e.json()),__vite__mapDeps([18,5,2,3,0,1,4,7])),html:()=>r(()=>import(`./dist-JvQIIdqB.js`).then(e=>e.html()),__vite__mapDeps([13,1,2,3,4,5,0,7,14,8,9])),htm:()=>r(()=>import(`./dist-JvQIIdqB.js`).then(e=>e.html()),__vite__mapDeps([13,1,2,3,4,5,0,7,14,8,9])),vue:()=>r(()=>import(`./dist-JvQIIdqB.js`).then(e=>e.html()),__vite__mapDeps([13,1,2,3,4,5,0,7,14,8,9])),svelte:()=>r(()=>import(`./dist-JvQIIdqB.js`).then(e=>e.html()),__vite__mapDeps([13,1,2,3,4,5,0,7,14,8,9])),css:()=>r(()=>import(`./dist-BXBSIuTD.js`).then(e=>e.r).then(e=>e.css()),__vite__mapDeps([14,2,3,5,0,1,4,7])),md:()=>r(()=>import(`./dist-oLq6HXLG.js`).then(e=>e.markdown()),__vite__mapDeps([19,1,2,3,4,5,0,9,13,7,14,8])),markdown:()=>r(()=>import(`./dist-oLq6HXLG.js`).then(e=>e.markdown()),__vite__mapDeps([19,1,2,3,4,5,0,9,13,7,14,8])),mdx:()=>r(()=>import(`./dist-oLq6HXLG.js`).then(e=>e.markdown()),__vite__mapDeps([19,1,2,3,4,5,0,9,13,7,14,8])),rs:()=>r(()=>import(`./dist-CAOcjKAQ.js`).then(e=>e.rust()),__vite__mapDeps([20,5,2,3,0,1,4,7])),go:()=>r(()=>import(`./dist-BuR5Iagd.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-DBUqwiWG.js`).then(e=>e.x),__vite__mapDeps([1,2,3])),r(()=>import(`./dist-BCNaDgNW.js`).then(e=>e.s),__vite__mapDeps([4,2,3,1])),r(()=>import(`./dist-CSCUT1PQ.js`),__vite__mapDeps([22,1,2,3,4,5,0])),r(()=>import(`./dist-9F1wL-T5.js`),__vite__mapDeps([23,1,2,3,4])),r(()=>import(`./dist-Do52MRwm.js`),__vite__mapDeps([0,1,2,3,4,5])),r(()=>import(`./dist-Bx6ZWYUW.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-B1qLZVMK.js","assets/dist-Bk_pkBVH.js","assets/index-Dzyp_7sf.js","assets/index-BMpqviwU.css","assets/dist-CRxCwn-Z.js","assets/dist-u0nBg0fZ.js","assets/dist-CGzXCzCG.js","assets/dist-BJVI1Unv.js","assets/dist-Bx7s4rni.js","assets/dist-1Innu17E.js","assets/dist-CDBKM9tL.js","assets/dist-BpeClAv0.js","assets/dist-BsmJg5PX.js","assets/dist-DuUi29km.js","assets/dist-D1VfMWmf.js","assets/dist-F3S0t1oM.js","assets/dist-DTZLNEci.js","assets/dist-CTDgUnBG.js","assets/dist-B6KwDpeI.js","assets/dist-BWvzD8Pe.js","assets/dist-B4pz_xdd.js","assets/dist-QZ-FAVJV.js","assets/dist-1lynFOc5.js","assets/dist-BayWssd0.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{a as e,i as t,n,r,s as i,t as a}from"./index-Dzyp_7sf.js";var o=i(e(),1);async function s(e,t){let[{StreamLanguage:n},i]=await Promise.all([r(()=>import(`./dist-B1qLZVMK.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-CGzXCzCG.js`).then(e=>e.cpp()),__vite__mapDeps([6,5,2,3,0,1,4,7])),cc:()=>r(()=>import(`./dist-CGzXCzCG.js`).then(e=>e.cpp()),__vite__mapDeps([6,5,2,3,0,1,4,7])),cxx:()=>r(()=>import(`./dist-CGzXCzCG.js`).then(e=>e.cpp()),__vite__mapDeps([6,5,2,3,0,1,4,7])),hpp:()=>r(()=>import(`./dist-CGzXCzCG.js`).then(e=>e.cpp()),__vite__mapDeps([6,5,2,3,0,1,4,7])),hh:()=>r(()=>import(`./dist-CGzXCzCG.js`).then(e=>e.cpp()),__vite__mapDeps([6,5,2,3,0,1,4,7])),hxx:()=>r(()=>import(`./dist-CGzXCzCG.js`).then(e=>e.cpp()),__vite__mapDeps([6,5,2,3,0,1,4,7])),c:()=>r(()=>import(`./dist-CGzXCzCG.js`).then(e=>e.cpp()),__vite__mapDeps([6,5,2,3,0,1,4,7])),h:()=>r(()=>import(`./dist-CGzXCzCG.js`).then(e=>e.cpp()),__vite__mapDeps([6,5,2,3,0,1,4,7])),cu:()=>r(()=>import(`./dist-CGzXCzCG.js`).then(e=>e.cpp()),__vite__mapDeps([6,5,2,3,0,1,4,7])),cuh:()=>r(()=>import(`./dist-CGzXCzCG.js`).then(e=>e.cpp()),__vite__mapDeps([6,5,2,3,0,1,4,7])),js:()=>r(()=>import(`./dist-Bx7s4rni.js`).then(e=>e.t).then(e=>e.javascript()),__vite__mapDeps([8,2,3,1,4,5,0,7,9])),jsx:()=>r(()=>import(`./dist-Bx7s4rni.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-Bx7s4rni.js`).then(e=>e.t).then(e=>e.javascript()),__vite__mapDeps([8,2,3,1,4,5,0,7,9])),cjs:()=>r(()=>import(`./dist-Bx7s4rni.js`).then(e=>e.t).then(e=>e.javascript()),__vite__mapDeps([8,2,3,1,4,5,0,7,9])),ts:()=>r(()=>import(`./dist-Bx7s4rni.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-Bx7s4rni.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-Bx7s4rni.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-Bx7s4rni.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-CDBKM9tL.js`).then(e=>e.python()),__vite__mapDeps([10,5,2,3,0,1,4,7,9])),pyi:()=>r(()=>import(`./dist-CDBKM9tL.js`).then(e=>e.python()),__vite__mapDeps([10,5,2,3,0,1,4,7,9])),java:()=>r(()=>import(`./dist-BpeClAv0.js`).then(e=>e.java()),__vite__mapDeps([11,5,2,3,0,1,4,7])),php:()=>r(()=>import(`./dist-BsmJg5PX.js`).then(e=>e.php()),__vite__mapDeps([12,5,2,3,0,1,4,7,13,14,8,9])),sql:()=>r(()=>import(`./dist-F3S0t1oM.js`).then(e=>e.sql()),__vite__mapDeps([15,5,2,3,0,1,4,7,9])),yaml:()=>r(()=>import(`./dist-DTZLNEci.js`).then(e=>e.yaml()),__vite__mapDeps([16,5,2,3,0,1,4,7])),yml:()=>r(()=>import(`./dist-DTZLNEci.js`).then(e=>e.yaml()),__vite__mapDeps([16,5,2,3,0,1,4,7])),xml:()=>r(()=>import(`./dist-CTDgUnBG.js`).then(e=>e.xml()),__vite__mapDeps([17,1,2,3,4,5,0,7])),json:()=>r(()=>import(`./dist-B6KwDpeI.js`).then(e=>e.json()),__vite__mapDeps([18,5,2,3,0,1,4,7])),jsonc:()=>r(()=>import(`./dist-B6KwDpeI.js`).then(e=>e.json()),__vite__mapDeps([18,5,2,3,0,1,4,7])),json5:()=>r(()=>import(`./dist-B6KwDpeI.js`).then(e=>e.json()),__vite__mapDeps([18,5,2,3,0,1,4,7])),html:()=>r(()=>import(`./dist-DuUi29km.js`).then(e=>e.html()),__vite__mapDeps([13,1,2,3,4,5,0,7,14,8,9])),htm:()=>r(()=>import(`./dist-DuUi29km.js`).then(e=>e.html()),__vite__mapDeps([13,1,2,3,4,5,0,7,14,8,9])),vue:()=>r(()=>import(`./dist-DuUi29km.js`).then(e=>e.html()),__vite__mapDeps([13,1,2,3,4,5,0,7,14,8,9])),svelte:()=>r(()=>import(`./dist-DuUi29km.js`).then(e=>e.html()),__vite__mapDeps([13,1,2,3,4,5,0,7,14,8,9])),css:()=>r(()=>import(`./dist-D1VfMWmf.js`).then(e=>e.r).then(e=>e.css()),__vite__mapDeps([14,2,3,5,0,1,4,7])),md:()=>r(()=>import(`./dist-BWvzD8Pe.js`).then(e=>e.markdown()),__vite__mapDeps([19,1,2,3,4,5,0,9,13,7,14,8])),markdown:()=>r(()=>import(`./dist-BWvzD8Pe.js`).then(e=>e.markdown()),__vite__mapDeps([19,1,2,3,4,5,0,9,13,7,14,8])),mdx:()=>r(()=>import(`./dist-BWvzD8Pe.js`).then(e=>e.markdown()),__vite__mapDeps([19,1,2,3,4,5,0,9,13,7,14,8])),rs:()=>r(()=>import(`./dist-B4pz_xdd.js`).then(e=>e.rust()),__vite__mapDeps([20,5,2,3,0,1,4,7])),go:()=>r(()=>import(`./dist-QZ-FAVJV.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-Bk_pkBVH.js`).then(e=>e.x),__vite__mapDeps([1,2,3])),r(()=>import(`./dist-CRxCwn-Z.js`).then(e=>e.s),__vite__mapDeps([4,2,3,1])),r(()=>import(`./dist-1lynFOc5.js`),__vite__mapDeps([22,1,2,3,4,5,0])),r(()=>import(`./dist-BayWssd0.js`),__vite__mapDeps([23,1,2,3,4])),r(()=>import(`./dist-B1qLZVMK.js`),__vite__mapDeps([0,1,2,3,4,5])),r(()=>import(`./dist-u0nBg0fZ.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 +1 @@
|
|
|
1
|
-
import{a as e,c as t,f as n,g as r,h as i,l as a,m as o,p as s,s as c,t as l}from"./dist-
|
|
1
|
+
import{a as e,c as t,f as n,g as r,h as i,l as a,m as o,p as s,s as c,t as l}from"./dist-Bk_pkBVH.js";import{d as u,o as d,r as f,t as p}from"./dist-CRxCwn-Z.js";import{indentUnit as m,syntaxTree as h}from"./dist-B1qLZVMK.js";var g=class{constructor(e,t,n,r){this.state=e,this.pos=t,this.explicit=n,this.view=r,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(e){let t=h(this.state).resolveInner(this.pos,-1);for(;t&&e.indexOf(t.name)<0;)t=t.parent;return t?{from:t.from,to:this.pos,text:this.state.sliceDoc(t.from,this.pos),type:t.type}:null}matchBefore(e){let t=this.state.doc.lineAt(this.pos),n=Math.max(t.from,this.pos-250),r=t.text.slice(n-t.from,this.pos-t.from),i=r.search(x(e,!1));return i<0?null:{from:n+i,to:this.pos,text:r.slice(i)}}get aborted(){return this.abortListeners==null}addEventListener(e,t,n){e==`abort`&&this.abortListeners&&(this.abortListeners.push(t),n&&n.onDocChange&&(this.abortOnDocChange=!0))}};function _(e){let t=Object.keys(e).join(``),n=/\w/.test(t);return n&&(t=t.replace(/\w/g,``)),`[${n?`\\w`:``}${t.replace(/[^\w\s]/g,`\\$&`)}]`}function v(e){let t=Object.create(null),n=Object.create(null);for(let{label:r}of e){t[r[0]]=!0;for(let e=1;e<r.length;e++)n[r[e]]=!0}let r=_(t)+_(n)+`*$`;return[RegExp(`^`+r),new RegExp(r)]}function y(e){let t=e.map(e=>typeof e==`string`?{label:e}:e),[n,r]=t.every(e=>/^\w+$/.test(e.label))?[/\w*$/,/\w+$/]:v(t);return e=>{let i=e.matchBefore(r);return i||e.explicit?{from:i?i.from:e.pos,options:t,validFor:n}:null}}function b(e,t){return n=>{for(let t=h(n.state).resolveInner(n.pos,-1);t;t=t.parent){if(e.indexOf(t.name)>-1)return null;if(t.type.isTop)break}return t(n)}}function x(e,t){let{source:n}=e,r=t&&n[0]!=`^`,i=n[n.length-1]!=`$`;return!r&&!i?e:RegExp(`${r?`^`:``}(?:${n})${i?`$`:``}`,e.flags??(e.ignoreCase?`i`:``))}var S=l.define();typeof navigator==`object`&&navigator.platform;var C=f.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:`monospace`,whiteSpace:`nowrap`,overflow:`hidden auto`,maxWidth_fallback:`700px`,maxWidth:`min(700px, 95vw)`,minWidth:`250px`,maxHeight:`10em`,height:`100%`,listStyle:`none`,margin:0,padding:0,"& > li, & > completion-section":{padding:`1px 3px`,lineHeight:1.2},"& > li":{overflowX:`hidden`,textOverflow:`ellipsis`,cursor:`pointer`},"& > completion-section":{display:`list-item`,borderBottom:`1px solid silver`,paddingLeft:`0.5em`,opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:`#17c`,color:`white`},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:`#777`},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:`#347`,color:`white`},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:`#444`},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:`"···"`,opacity:.5,display:`block`,textAlign:`center`,cursor:`pointer`},".cm-tooltip.cm-completionInfo":{position:`absolute`,padding:`3px 9px`,width:`max-content`,maxWidth:`400px`,boxSizing:`border-box`,whiteSpace:`pre-line`},".cm-completionInfo.cm-completionInfo-left":{right:`100%`},".cm-completionInfo.cm-completionInfo-right":{left:`100%`},".cm-completionInfo.cm-completionInfo-left-narrow":{right:`30px`},".cm-completionInfo.cm-completionInfo-right-narrow":{left:`30px`},"&light .cm-snippetField":{backgroundColor:`#00000022`},"&dark .cm-snippetField":{backgroundColor:`#ffffff22`},".cm-snippetFieldPosition":{verticalAlign:`text-top`,width:0,height:`1.15em`,display:`inline-block`,margin:`0 -0.7px -.7em`,borderLeft:`1.4px dotted #888`},".cm-completionMatchedText":{textDecoration:`underline`},".cm-completionDetail":{marginLeft:`0.5em`,fontStyle:`italic`},".cm-completionIcon":{fontSize:`90%`,width:`.8em`,display:`inline-block`,textAlign:`center`,paddingRight:`.6em`,opacity:`0.6`,boxSizing:`content-box`},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:`'ƒ'`}},".cm-completionIcon-class":{"&:after":{content:`'○'`}},".cm-completionIcon-interface":{"&:after":{content:`'◌'`}},".cm-completionIcon-variable":{"&:after":{content:`'𝑥'`}},".cm-completionIcon-constant":{"&:after":{content:`'𝐶'`}},".cm-completionIcon-type":{"&:after":{content:`'𝑡'`}},".cm-completionIcon-enum":{"&:after":{content:`'∪'`}},".cm-completionIcon-property":{"&:after":{content:`'□'`}},".cm-completionIcon-keyword":{"&:after":{content:`'🔑︎'`}},".cm-completionIcon-namespace":{"&:after":{content:`'▢'`}},".cm-completionIcon-text":{"&:after":{content:`'abc'`,fontSize:`50%`,verticalAlign:`middle`}}}),w=class{constructor(e,t,n,r){this.field=e,this.line=t,this.from=n,this.to=r}},T=class e{constructor(e,t,n){this.field=e,this.from=t,this.to=n}map(n){let r=n.mapPos(this.from,-1,t.TrackDel),i=n.mapPos(this.to,1,t.TrackDel);return r==null||i==null?null:new e(this.field,r,i)}},E=class e{constructor(e,t){this.lines=e,this.fieldPositions=t}instantiate(e,t){let n=[],r=[t],i=e.doc.lineAt(t),a=/^\s*/.exec(i.text)[0];for(let i of this.lines){if(n.length){let n=a,o=/^\t*/.exec(i)[0].length;for(let t=0;t<o;t++)n+=e.facet(m);r.push(t+n.length-o),i=n+i.slice(o)}n.push(i),t+=i.length+1}return{text:n,ranges:this.fieldPositions.map(e=>new T(e.field,r[e.line]+e.from,r[e.line]+e.to))}}static parse(t){let n=[],r=[],i=[],a;for(let e of t.split(/\r\n?|\n/)){for(;a=/[#$]\{(?:(\d+)(?::([^{}]*))?|((?:\\[{}]|[^{}])*))\}/.exec(e);){let t=a[1]?+a[1]:null,o=a[2]||a[3]||``,s=-1;t===0&&(t=1e9);let c=o.replace(/\\[{}]/g,e=>e[1]);for(let e=0;e<n.length;e++)(t==null?c&&n[e].name==c:n[e].seq==t)&&(s=e);if(s<0){let e=0;for(;e<n.length&&(t==null||n[e].seq!=null&&n[e].seq<t);)e++;n.splice(e,0,{seq:t,name:c}),s=e;for(let e of i)e.field>=s&&e.field++}for(let e of i)if(e.line==r.length&&e.from>a.index){let t=a[2]?3+(a[1]||``).length:2;e.from-=t,e.to-=t}i.push(new w(s,r.length,a.index,a.index+c.length)),e=e.slice(0,a.index)+o+e.slice(a.index+a[0].length)}e=e.replace(/\\([{}])/g,(e,t,n)=>{for(let e of i)e.line==r.length&&e.from>n&&(e.from--,e.to--);return t}),r.push(e)}return new e(r,i)}},D=p.widget({widget:new class extends d{toDOM(){let e=document.createElement(`span`);return e.className=`cm-snippetFieldPosition`,e}ignoreEvent(){return!1}}}),O=p.mark({class:`cm-snippetField`}),k=class e{constructor(e,t){this.ranges=e,this.active=t,this.deco=p.set(e.map(e=>(e.from==e.to?D:O).range(e.from,e.to)),!0)}map(t){let n=[];for(let e of this.ranges){let r=e.map(t);if(!r)return null;n.push(r)}return new e(n,this.active)}selectionInsideField(e){return e.ranges.every(e=>this.ranges.some(t=>t.field==this.active&&t.from<=e.from&&t.to>=e.to))}},A=s.define({map(e,t){return e&&e.map(t)}}),j=s.define(),M=o.define({create(){return null},update(e,t){for(let n of t.effects){if(n.is(A))return n.value;if(n.is(j)&&e)return new k(e.ranges,n.value)}return e&&t.docChanged&&(e=e.map(t.changes)),e&&t.selection&&!e.selectionInsideField(t.selection)&&(e=null),e},provide:e=>f.decorations.from(e,e=>e?e.deco:p.none)});function N(t,n){return e.create(t.filter(e=>e.field==n).map(t=>e.range(t.from,t.to)))}function P(e){let t=E.parse(e);return(e,n,a,o)=>{let{text:c,ranges:l}=t.instantiate(e.state,a),{main:u}=e.state.selection,d={changes:{from:a,to:o==u.from?u.to:o,insert:i.of(c)},scrollIntoView:!0,annotations:n?[S.of(n),r.userEvent.of(`input.complete`)]:void 0};if(l.length&&(d.selection=N(l,0)),l.some(e=>e.field>0)){let t=new k(l,0),n=d.effects=[A.of(t)];e.state.field(M,!1)===void 0&&n.push(s.appendConfig.of([M,R,B,C]))}e.dispatch(e.state.update(d))}}function F(e){return({state:t,dispatch:n})=>{let r=t.field(M,!1);if(!r||e<0&&r.active==0)return!1;let i=r.active+e,a=e>0&&!r.ranges.some(t=>t.field==i+e);return n(t.update({selection:N(r.ranges,i),effects:A.of(a?null:new k(r.ranges,i)),scrollIntoView:!0})),!0}}var I=[{key:`Tab`,run:F(1),shift:F(-1)},{key:`Escape`,run:({state:e,dispatch:t})=>e.field(M,!1)?(t(e.update({effects:A.of(null)})),!0):!1}],L=c.define({combine(e){return e.length?e[0]:I}}),R=a.highest(u.compute([L],e=>e.facet(L)));function z(e,t){return{...t,apply:P(e)}}var B=f.domEventHandlers({mousedown(e,t){let n=t.state.field(M,!1),r;if(!n||(r=t.posAtCoords({x:e.clientX,y:e.clientY}))==null)return!1;let i=n.ranges.find(e=>e.from<=r&&e.to>=r);return!i||i.field==n.active?!1:(t.dispatch({selection:N(n.ranges,i.field),effects:A.of(n.ranges.some(e=>e.field>i.field)?new k(n.ranges,i.field):null),scrollIntoView:!0}),!0)}}),V=new class extends n{};V.startSide=1,V.endSide=-1,typeof navigator==`object`&&navigator.userAgent;export{z as i,y as n,b as r,g as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{S as e,a as t,b as n,g as r,h as i,i as a,m as o,n as s,p as c,r as l,s as u,t as d,y as f}from"./dist-DBUqwiWG.js";import{n as p,r as m}from"./dist-BCNaDgNW.js";import{l as ee}from"./dist-Bx6ZWYUW.js";import{IndentContext as te,getIndentUnit as ne,getIndentation as re,indentString as h,indentUnit as ie,matchBrackets as g,syntaxTree as _}from"./dist-Do52MRwm.js";var ae=e=>{let{state:t}=e,n=t.doc.lineAt(t.selection.main.from),r=y(e.state,n.from);return r.line?oe(e):r.block?fe(e):!1};function v(e,t){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let i=e(t,n);return i?(r(n.update(i)),!0):!1}}var oe=v(S,0),se=v(S,1),ce=v(S,2),le=v(x,0),ue=v(x,1),de=v(x,2),fe=v((e,t)=>x(e,t,me(t)),0);function y(e,t){let n=e.languageDataAt(`commentTokens`,t,1);return n.length?n[0]:{}}var b=50;function pe(e,{open:t,close:n},r,i){let a=e.sliceDoc(r-b,r),o=e.sliceDoc(i,i+b),s=/\s*$/.exec(a)[0].length,c=/^\s*/.exec(o)[0].length,l=a.length-s;if(a.slice(l-t.length,l)==t&&o.slice(c,c+n.length)==n)return{open:{pos:r-s,margin:s&&1},close:{pos:i+c,margin:c&&1}};let u,d;i-r<=100?u=d=e.sliceDoc(r,i):(u=e.sliceDoc(r,r+b),d=e.sliceDoc(i-b,i));let f=/^\s*/.exec(u)[0].length,p=/\s*$/.exec(d)[0].length,m=d.length-p-n.length;return u.slice(f,f+t.length)==t&&d.slice(m,m+n.length)==n?{open:{pos:r+f+t.length,margin:+!!/\s/.test(u.charAt(f+t.length))},close:{pos:i-p-n.length,margin:+!!/\s/.test(d.charAt(m-1))}}:null}function me(e){let t=[];for(let n of e.selection.ranges){let r=e.doc.lineAt(n.from),i=n.to<=r.to?r:e.doc.lineAt(n.to);i.from>r.from&&i.from==n.to&&(i=n.to==r.to+1?r:e.doc.lineAt(n.to-1));let a=t.length-1;a>=0&&t[a].to>r.from?t[a].to=i.to:t.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:i.to})}return t}function x(e,t,n=t.selection.ranges){let r=n.map(e=>y(t,e.from).block);if(!r.every(e=>e))return null;let i=n.map((e,n)=>pe(t,r[n],e.from,e.to));if(e!=2&&!i.every(e=>e))return{changes:t.changes(n.map((e,t)=>i[t]?[]:[{from:e.from,insert:r[t].open+` `},{from:e.to,insert:` `+r[t].close}]))};if(e!=1&&i.some(e=>e)){let e=[];for(let t=0,n;t<i.length;t++)if(n=i[t]){let i=r[t],{open:a,close:o}=n;e.push({from:a.pos-i.open.length,to:a.pos+a.margin},{from:o.pos-o.margin,to:o.pos+i.close.length})}return{changes:e}}return null}function S(e,t,n=t.selection.ranges){let r=[],i=-1;ranges:for(let{from:e,to:a}of n){let n=r.length,o=1e9,s;for(let n=e;n<=a;){let c=t.doc.lineAt(n);if(s==null&&(s=y(t,c.from).line,!s))continue ranges;if(c.from>i&&(e==a||a>c.from)){i=c.from;let e=/^\s*/.exec(c.text)[0].length,t=e==c.length,n=c.text.slice(e,e+s.length)==s?e:-1;e<c.text.length&&e<o&&(o=e),r.push({line:c,comment:n,token:s,indent:e,empty:t,single:!1})}n=c.to+1}if(o<1e9)for(let e=n;e<r.length;e++)r[e].indent<r[e].line.text.length&&(r[e].indent=o);r.length==n+1&&(r[n].single=!0)}if(e!=2&&r.some(e=>e.comment<0&&(!e.empty||e.single))){let e=[];for(let{line:t,token:n,indent:i,empty:a,single:o}of r)(o||!a)&&e.push({from:t.from+i,insert:n+` `});let n=t.changes(e);return{changes:n,selection:t.selection.map(n,1)}}if(e!=1&&r.some(e=>e.comment>=0)){let e=[];for(let{line:t,comment:n,token:i}of r)if(n>=0){let r=t.from+n,a=r+i.length;t.text[a-t.from]==` `&&a++,e.push({from:r,to:a})}return{changes:e}}return null}var C=d.define(),he=d.define(),ge=u.define(),_e=u.define({combine(e){return f(e,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(n,r)=>e(n,r)||t(n,r)})}}),w=o.define({create(){return A.empty},update(e,t){let n=t.state.facet(_e),i=t.annotation(C);if(i){let r=D.fromTransaction(t,i.selection),a=i.side,o=a==0?e.undone:e.done;return o=r?O(o,o.length,n.minDepth,r):Ne(o,t.startState.selection),new A(a==0?i.rest:o,a==0?o:i.rest)}let a=t.annotation(he);if((a==`full`||a==`before`)&&(e=e.isolate()),t.annotation(r.addToHistory)===!1)return t.changes.empty?e:e.addMapping(t.changes.desc);let o=D.fromTransaction(t),s=t.annotation(r.time),c=t.annotation(r.userEvent);return o?e=e.addChanges(o,s,c,n,t):t.selection&&(e=e.addSelection(t.startState.selection,s,c,n.newGroupDelay)),(a==`full`||a==`after`)&&(e=e.isolate()),e},toJSON(e){return{done:e.done.map(e=>e.toJSON()),undone:e.undone.map(e=>e.toJSON())}},fromJSON(e){return new A(e.done.map(D.fromJSON),e.undone.map(D.fromJSON))}});function ve(e={}){return[w,_e.of(e),m.domEventHandlers({beforeinput(e,t){let n=e.inputType==`historyUndo`?be:e.inputType==`historyRedo`?E:null;return n?(e.preventDefault(),n(t)):!1}})]}var ye=w;function T(e,t){return function({state:n,dispatch:r}){if(!t&&n.readOnly)return!1;let i=n.field(w,!1);if(!i)return!1;let a=i.pop(e,n,t);return a?(r(a),!0):!1}}var be=T(0,!1),E=T(1,!1),xe=T(0,!0),Se=T(1,!0);function Ce(e){return function(t){let n=t.field(w,!1);if(!n)return 0;let r=e==0?n.done:n.undone;return r.length-(r.length&&!r[0].changes?1:0)}}var we=Ce(0),Te=Ce(1);function Ee(e){return function(t){let n=t.field(w,!1);if(!n)return!1;let r=e==0?n.done:n.undone;return r.length>0&&r[0].selectionsAfter.length>0}}var De=Ee(0),Oe=Ee(0),D=class e{constructor(e,t,n,r,i){this.changes=e,this.effects=t,this.mapped=n,this.startSelection=r,this.selectionsAfter=i}setSelAfter(t){return new e(this.changes,this.effects,this.mapped,this.startSelection,t)}toJSON(){return{changes:this.changes?.toJSON(),mapped:this.mapped?.toJSON(),startSelection:this.startSelection?.toJSON(),selectionsAfter:this.selectionsAfter.map(e=>e.toJSON())}}static fromJSON(n){return new e(n.changes&&l.fromJSON(n.changes),[],n.mapped&&s.fromJSON(n.mapped),n.startSelection&&t.fromJSON(n.startSelection),n.selectionsAfter.map(t.fromJSON))}static fromTransaction(t,n){let r=k;for(let e of t.startState.facet(ge)){let n=e(t);n.length&&(r=r.concat(n))}return!r.length&&t.changes.empty?null:new e(t.changes.invert(t.startState.doc),r,void 0,n||t.startState.selection,k)}static selection(t){return new e(void 0,k,void 0,void 0,t)}};function O(e,t,n,r){let i=t+1>n+20?t-n-1:0,a=e.slice(i,t);return a.push(r),a}function ke(e,t){let n=[],r=!1;return e.iterChangedRanges((e,t)=>n.push(e,t)),t.iterChangedRanges((e,t,i,a)=>{for(let e=0;e<n.length;){let t=n[e++],o=n[e++];a>=t&&i<=o&&(r=!0)}}),r}function Ae(e,t){return e.ranges.length==t.ranges.length&&e.ranges.filter((e,n)=>e.empty!=t.ranges[n].empty).length===0}function je(e,t){return e.length?t.length?e.concat(t):e:t}var k=[],Me=200;function Ne(e,t){if(e.length){let n=e[e.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-Me));return r.length&&r[r.length-1].eq(t)?e:(r.push(t),O(e,e.length-1,1e9,n.setSelAfter(r)))}return[D.selection([t])]}function Pe(e){let t=e[e.length-1],n=e.slice();return n[e.length-1]=t.setSelAfter(t.selectionsAfter.slice(0,t.selectionsAfter.length-1)),n}function Fe(e,t){if(!e.length)return e;let n=e.length,r=k;for(;n;){let i=Ie(e[n-1],t,r);if(i.changes&&!i.changes.empty||i.effects.length){let t=e.slice(0,n);return t[n-1]=i,t}t=i.mapped,n--,r=i.selectionsAfter}return r.length?[D.selection(r)]:k}function Ie(e,t,n){let r=je(e.selectionsAfter.length?e.selectionsAfter.map(e=>e.map(t)):k,n);if(!e.changes)return D.selection(r);let i=e.changes.map(t),a=t.mapDesc(e.changes,!0),o=e.mapped?e.mapped.composeDesc(a):a;return new D(i,c.mapEffects(e.effects,t),o,e.startSelection.map(a),r)}var Le=/^(input\.type|delete)($|\.)/,A=class e{constructor(e,t,n=0,r=void 0){this.done=e,this.undone=t,this.prevTime=n,this.prevUserEvent=r}isolate(){return this.prevTime?new e(this.done,this.undone):this}addChanges(t,n,r,i,a){let o=this.done,s=o[o.length-1];return o=s&&s.changes&&!s.changes.empty&&t.changes&&(!r||Le.test(r))&&(!s.selectionsAfter.length&&n-this.prevTime<i.newGroupDelay&&i.joinToEvent(a,ke(s.changes,t.changes))||r==`input.type.compose`)?O(o,o.length-1,i.minDepth,new D(t.changes.compose(s.changes),je(c.mapEffects(t.effects,s.changes),s.effects),s.mapped,s.startSelection,k)):O(o,o.length,i.minDepth,t),new e(o,k,n,r)}addSelection(t,n,r,i){let a=this.done.length?this.done[this.done.length-1].selectionsAfter:k;return a.length>0&&n-this.prevTime<i&&r==this.prevUserEvent&&r&&/^select($|\.)/.test(r)&&Ae(a[a.length-1],t)?this:new e(Ne(this.done,t),this.undone,n,r)}addMapping(t){return new e(Fe(this.done,t),Fe(this.undone,t),this.prevTime,this.prevUserEvent)}pop(e,t,n){let r=e==0?this.done:this.undone;if(r.length==0)return null;let i=r[r.length-1],a=i.selectionsAfter[0]||(i.startSelection?i.startSelection.map(i.changes.invertedDesc,1):t.selection);if(n&&i.selectionsAfter.length)return t.update({selection:i.selectionsAfter[i.selectionsAfter.length-1],annotations:C.of({side:e,rest:Pe(r),selection:a}),userEvent:e==0?`select.undo`:`select.redo`,scrollIntoView:!0});if(i.changes){let n=r.length==1?k:r.slice(0,r.length-1);return i.mapped&&(n=Fe(n,i.mapped)),t.update({changes:i.changes,selection:i.startSelection,effects:i.effects,annotations:C.of({side:e,rest:n,selection:a}),filter:!1,userEvent:e==0?`undo`:`redo`,scrollIntoView:!0})}return null}};A.empty=new A(k,k);var Re=[{key:`Mod-z`,run:be,preventDefault:!0},{key:`Mod-y`,mac:`Mod-Shift-z`,run:E,preventDefault:!0},{linux:`Ctrl-Shift-z`,run:E,preventDefault:!0},{key:`Mod-u`,run:xe,preventDefault:!0},{key:`Alt-u`,mac:`Mod-Shift-u`,run:Se,preventDefault:!0}];function j(e,n){return t.create(e.ranges.map(n),e.mainIndex)}function M(e,t){return e.update({selection:t,scrollIntoView:!0,userEvent:`select`})}function N({state:e,dispatch:t},n){let r=j(e.selection,n);return!r.eq(e.selection,!0)&&(t(M(e,r)),!0)}function P(e,n){return t.cursor(n?e.to:e.from)}function F(e,t){return N(e,n=>n.empty?e.moveByChar(n,t):P(n,t))}function I(e){return e.textDirectionAt(e.state.selection.main.head)==p.LTR}var L=e=>F(e,!I(e)),ze=e=>F(e,I(e)),Be=e=>F(e,!0),Ve=e=>F(e,!1);function He(n,r,i){let a=r.head,o=n.doc.lineAt(a);return a=a==(i?o.to:o.from)?i?Math.min(n.doc.length,o.to+1):Math.max(0,o.from-1):o.from+e(o.text,a-o.from,i),t.cursor(a,i?-1:1)}function Ue(e,t){return N(e,n=>n.empty?He(e.state,n,t):P(n,t))}var We=e=>Ue(e,!0),Ge=e=>Ue(e,!1);function R(e,t){return N(e,n=>n.empty?e.moveByGroup(n,t):P(n,t))}var Ke=e=>R(e,!I(e)),qe=e=>R(e,I(e)),Je=e=>R(e,!0),Ye=e=>R(e,!1);function Xe(e,t,n){let r=e.state.charCategorizer(t),i=r(n),o=i!=a.Space;return e=>{let t=r(e);return t==a.Space?(o=!1,!0):o&&t==i}}var Ze=e=>N(e,t=>t.empty?e.moveByChar(t,!0,n=>Xe(e,t.head,n)):P(t,!0)),Qe=typeof Intl<`u`&&Intl.Segmenter?new Intl.Segmenter(void 0,{granularity:`word`}):null;function $e(e,n,r){let i=e.state.charCategorizer(n.from),o=a.Space,s=n.from,c=0,l=!1,u=!1,d=!1,f=t=>{if(l)return!1;s+=r?t.length:-t.length;let n=i(t),f;if(n==a.Word&&t.charCodeAt(0)<128&&/[\W_]/.test(t)&&(n=-1),o==a.Space&&(o=n),o!=n)return!1;if(o==a.Word){if(t.toLowerCase()==t){if(!r&&u)return!1;d=!0}else if(d){if(r)return!1;l=!0}else{if(u&&r&&i(f=e.state.sliceDoc(s,s+1))==a.Word&&f.toLowerCase()==f)return!1;u=!0}}return c++,!0},p=e.moveByChar(n,r,e=>(f(e),f));if(Qe&&o==a.Word&&p.from==n.from+c*(r?1:-1)){let i=Math.min(n.head,p.head),a=Math.max(n.head,p.head),o=e.state.sliceDoc(i,a);if(o.length>1&&/[\u4E00-\uffff]/.test(o)){let e=Array.from(Qe.segment(o));if(e.length>1)return r?t.cursor(n.head+e[1].index,-1):t.cursor(p.head+e[e.length-1].index,1)}}return p}function et(e,t){return N(e,n=>n.empty?$e(e,n,t):P(n,t))}var tt=e=>et(e,!0),nt=e=>et(e,!1);function rt(e,t,n){if(t.type.prop(n))return!0;let r=t.to-t.from;return r&&(r>2||/[^\s,.;:]/.test(e.sliceDoc(t.from,t.to)))||t.firstChild}function z(e,n,r){let i=_(e).resolveInner(n.head),a=r?ee.closedBy:ee.openedBy;for(let t=n.head;;){let n=r?i.childAfter(t):i.childBefore(t);if(!n)break;rt(e,n,a)?i=n:t=r?n.to:n.from}let o=i.type.prop(a),s,c;return c=o&&(s=r?g(e,i.from,1):g(e,i.to,-1))&&s.matched?r?s.end.to:s.end.from:r?i.to:i.from,t.cursor(c,r?-1:1)}var it=e=>N(e,t=>z(e.state,t,!I(e))),at=e=>N(e,t=>z(e.state,t,I(e)));function ot(e,t){return N(e,n=>{if(!n.empty)return P(n,t);let r=e.moveVertically(n,t);return r.head==n.head?e.moveToLineBoundary(n,t):r})}var B=e=>ot(e,!1),V=e=>ot(e,!0);function st(e){let t=e.scrollDOM.clientHeight<e.scrollDOM.scrollHeight-2,n=0,r=0,i;if(t){for(let t of e.state.facet(m.scrollMargins)){let i=t(e);i?.top&&(n=Math.max(i?.top,n)),i?.bottom&&(r=Math.max(i?.bottom,r))}i=e.scrollDOM.clientHeight-n-r}else i=(e.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:n,marginBottom:r,selfScroll:t,height:Math.max(e.defaultLineHeight,i-5)}}function ct(e,t){let n=st(e),{state:r}=e,i=j(r.selection,r=>r.empty?e.moveVertically(r,t,n.height):P(r,t));if(i.eq(r.selection))return!1;let a;if(n.selfScroll){let t=e.coordsAtPos(r.selection.main.head),o=e.scrollDOM.getBoundingClientRect(),s=o.top+n.marginTop,c=o.bottom-n.marginBottom;t&&t.top>s&&t.bottom<c&&(a=m.scrollIntoView(i.main.head,{y:`start`,yMargin:t.top-s}))}return e.dispatch(M(r,i),{effects:a}),!0}var H=e=>ct(e,!1),U=e=>ct(e,!0);function W(e,n,r){let i=e.lineBlockAt(n.head),a=e.moveToLineBoundary(n,r);if(a.head==n.head&&a.head!=(r?i.to:i.from)&&(a=e.moveToLineBoundary(n,r,!1)),!r&&a.head==i.from&&i.length){let r=/^\s*/.exec(e.state.sliceDoc(i.from,Math.min(i.from+100,i.to)))[0].length;r&&n.head!=i.from+r&&(a=t.cursor(i.from+r))}return a}var lt=e=>N(e,t=>W(e,t,!0)),ut=e=>N(e,t=>W(e,t,!1)),dt=e=>N(e,t=>W(e,t,!I(e))),ft=e=>N(e,t=>W(e,t,I(e))),pt=e=>N(e,t=>e.moveToLineBoundary(t,!1,!1)),mt=e=>N(e,t=>e.moveToLineBoundary(t,!0,!1));function ht(e,n,r){let i=!1,a=j(e.selection,n=>{let a=g(e,n.head,-1)||g(e,n.head,1)||n.head>0&&g(e,n.head-1,1)||n.head<e.doc.length&&g(e,n.head+1,-1);if(!a||!a.end)return n;i=!0;let o=a.start.from==n.head?a.end.to:a.end.from;return r?t.range(n.anchor,o):t.cursor(o)});return i?(n(M(e,a)),!0):!1}var gt=({state:e,dispatch:t})=>ht(e,t,!1),_t=({state:e,dispatch:t})=>ht(e,t,!0);function G(e,n,r){let i=j(e.state.selection,e=>{e.undirectional&&e.head>=e.anchor!=n&&(e=t.range(e.head,e.anchor));let i=r(e);return t.range(e.anchor,i.head,i.goalColumn,i.bidiLevel||void 0,i.assoc)});return!i.eq(e.state.selection)&&(e.dispatch(M(e.state,i)),!0)}function K(e,t){return G(e,t,n=>e.moveByChar(n,t))}var q=e=>K(e,!I(e)),vt=e=>K(e,I(e)),yt=e=>K(e,!0),bt=e=>K(e,!1),xt=e=>G(e,!0,t=>He(e.state,t,!0)),St=e=>G(e,!1,t=>He(e.state,t,!1));function J(e,t){return G(e,t,n=>e.moveByGroup(n,t))}var Ct=e=>J(e,!I(e)),wt=e=>J(e,I(e)),Tt=e=>J(e,!0),Et=e=>J(e,!1),Dt=e=>G(e,!0,t=>e.moveByChar(t,!0,n=>Xe(e,t.head,n)));function Ot(e,t){return G(e,t,n=>$e(e,n,t))}var kt=e=>Ot(e,!0),At=e=>Ot(e,!1),jt=e=>{let t=!I(e);return G(e,t,n=>z(e.state,n,t))},Mt=e=>{let t=I(e);return G(e,t,n=>z(e.state,n,t))};function Nt(e,t){return G(e,t,n=>e.moveVertically(n,t))}var Pt=e=>Nt(e,!1),Ft=e=>Nt(e,!0);function It(e,t){return G(e,t,n=>e.moveVertically(n,t,st(e).height))}var Lt=e=>It(e,!1),Rt=e=>It(e,!0),zt=e=>G(e,!0,t=>W(e,t,!0)),Bt=e=>G(e,!1,t=>W(e,t,!1)),Vt=e=>{let t=!I(e);return G(e,t,n=>W(e,n,t))},Ht=e=>{let t=I(e);return G(e,t,n=>W(e,n,t))},Ut=e=>G(e,!1,n=>t.cursor(e.lineBlockAt(n.head).from)),Wt=e=>G(e,!0,n=>t.cursor(e.lineBlockAt(n.head).to)),Gt=({state:e,dispatch:t})=>(t(M(e,{anchor:0})),!0),Kt=({state:e,dispatch:t})=>(t(M(e,{anchor:e.doc.length})),!0),qt=({state:e,dispatch:t})=>(t(M(e,{anchor:e.selection.main.anchor,head:0})),!0),Jt=({state:e,dispatch:t})=>(t(M(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0),Yt=({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:`select`})),!0),Xt=({state:e,dispatch:n})=>{let r=Q(e).map(({from:n,to:r})=>t.undirectionalRange(n,Math.min(r+1,e.doc.length)));return n(e.update({selection:t.create(r),userEvent:`select`})),!0},Zt=({state:e,dispatch:n})=>{let r=j(e.selection,n=>{let r=_(e),i=r.resolveStack(n.from,1);if(n.empty){let e=r.resolveStack(n.from,-1);e.node.from>=i.node.from&&e.node.to<=i.node.to&&(i=e)}for(let e=i;e;e=e.next){let{node:r}=e;if((r.from<n.from&&r.to>=n.to||r.to>n.to&&r.from<=n.from)&&e.next)return t.undirectionalRange(r.from,r.to)}return n});return!r.eq(e.selection)&&(n(M(e,r)),!0)};function Qt(e,n){let{state:r}=e,i=r.selection,a=r.selection.ranges.slice();for(let t of r.selection.ranges){let i=r.doc.lineAt(t.head);if(n?i.to<e.state.doc.length:i.from>0)for(let r=t;;){let t=e.moveVertically(r,n);if(t.head<i.from||t.head>i.to){a.some(e=>e.head==t.head)||a.push(t);break}if(t.head==r.head)break;r=t}}return a.length!=i.ranges.length&&(e.dispatch(M(r,t.create(a,a.length-1))),!0)}var $t=e=>Qt(e,!1),en=e=>Qt(e,!0),tn=({state:e,dispatch:n})=>{let r=e.selection,i=null;return r.ranges.length>1?i=t.create([r.main]):r.main.empty||(i=t.create([t.cursor(r.main.head)])),i?(n(M(e,i)),!0):!1};function Y(e,n){if(e.state.readOnly)return!1;let r=`delete.selection`,{state:i}=e,a=i.changeByRange(i=>{let{from:a,to:o}=i;if(a==o){let t=n(i);t<a?(r=`delete.backward`,t=X(e,t,!1)):t>a&&(r=`delete.forward`,t=X(e,t,!0)),a=Math.min(a,t),o=Math.max(o,t)}else a=X(e,a,!1),o=X(e,o,!0);return a==o?{range:i}:{changes:{from:a,to:o},range:t.cursor(a,a<i.head?-1:1)}});return!a.changes.empty&&(e.dispatch(i.update(a,{scrollIntoView:!0,userEvent:r,effects:r==`delete.selection`?m.announce.of(i.phrase(`Selection deleted`)):void 0})),!0)}function X(e,t,n){if(e instanceof m)for(let r of e.state.facet(m.atomicRanges).map(t=>t(e)))r.between(t,t,(e,r)=>{e<t&&r>t&&(t=n?r:e)});return t}var nn=(t,r,i)=>Y(t,a=>{let o=a.from,{state:s}=t,c=s.doc.lineAt(o),l,u;if(i&&!r&&o>c.from&&o<c.from+200&&!/[^ \t]/.test(l=c.text.slice(0,o-c.from))){if(l[l.length-1]==` `)return o-1;let e=n(l,s.tabSize)%ne(s)||ne(s);for(let t=0;t<e&&l[l.length-1-t]==` `;t++)o--;u=o}else u=e(c.text,o-c.from,r,r)+c.from,u==o&&c.number!=(r?s.doc.lines:1)?u+=r?1:-1:!r&&/[\ufe00-\ufe0f]/.test(c.text.slice(u-c.from,o-c.from))&&(u=e(c.text,u-c.from,!1,!1)+c.from);return u}),Z=e=>nn(e,!1,!0),rn=e=>nn(e,!1,!1),an=e=>nn(e,!0,!1),on=(t,n)=>Y(t,r=>{let i=r.head,{state:a}=t,o=a.doc.lineAt(i),s=a.charCategorizer(i);for(let t=null;;){if(i==(n?o.to:o.from)){i==r.head&&o.number!=(n?a.doc.lines:1)&&(i+=n?1:-1);break}let c=e(o.text,i-o.from,n)+o.from,l=o.text.slice(Math.min(i,c)-o.from,Math.max(i,c)-o.from),u=s(l);if(t!=null&&u!=t)break;(l!=` `||i!=r.head)&&(t=u),i=c}return i}),sn=e=>on(e,!1),cn=e=>on(e,!0),ln=e=>Y(e,t=>e.moveByChar(t,!0,n=>Xe(e,t.head,n)).head),un=e=>Y(e,t=>{let n=e.lineBlockAt(t.head).to;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),dn=e=>Y(e,t=>{let n=e.lineBlockAt(t.head).from;return t.head>n?n:Math.max(0,t.head-1)}),fn=e=>Y(e,t=>{let n=e.moveToLineBoundary(t,!1).head;return t.head>n?n:Math.max(0,t.head-1)}),pn=e=>Y(e,t=>{let n=e.moveToLineBoundary(t,!0).head;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),mn=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=[];for(let t=0,r=``,i=e.doc.iter();;){if(i.next(),i.lineBreak||i.done){let e=r.search(/\s+$/);if(e>-1&&n.push({from:t-(r.length-e),to:t}),i.done)break;r=``}else r=i.value;t+=i.value.length}return n.length?(t(e.update({changes:n,userEvent:`delete`})),!0):!1},hn=({state:e,dispatch:n})=>{if(e.readOnly)return!1;let r=e.changeByRange(e=>({changes:{from:e.from,to:e.to,insert:i.of([``,``])},range:t.cursor(e.from)}));return n(e.update(r,{scrollIntoView:!0,userEvent:`input`})),!0},gn=({state:n,dispatch:r})=>{if(n.readOnly)return!1;let i=n.changeByRange(r=>{if(!r.empty||r.from==0||r.from==n.doc.length)return{range:r};let i=r.from,a=n.doc.lineAt(i),o=i==a.from?i-1:e(a.text,i-a.from,!1)+a.from,s=i==a.to?i+1:e(a.text,i-a.from,!0)+a.from;return{changes:{from:o,to:s,insert:n.doc.slice(i,s).append(n.doc.slice(o,i))},range:t.cursor(s)}});return!i.changes.empty&&(r(n.update(i,{scrollIntoView:!0,userEvent:`move.character`})),!0)};function Q(e){let t=[],n=-1;for(let r of e.selection.ranges){let i=e.doc.lineAt(r.from),a=e.doc.lineAt(r.to);if(!r.empty&&r.to==a.from&&(a=e.doc.lineAt(r.to-1)),n>=i.number){let e=t[t.length-1];e.to=a.to,e.ranges.push(r)}else t.push({from:i.from,to:a.to,ranges:[r]});n=a.number+1}return t}function _n(e,n,r){if(e.readOnly)return!1;let i=[],a=[];for(let n of Q(e)){if(r?n.to==e.doc.length:n.from==0)continue;let o=e.doc.lineAt(r?n.to+1:n.from-1),s=o.length+1;if(r){i.push({from:n.to,to:o.to},{from:n.from,insert:o.text+e.lineBreak});for(let r of n.ranges)a.push(t.range(Math.min(e.doc.length,r.anchor+s),Math.min(e.doc.length,r.head+s)))}else{i.push({from:o.from,to:n.from},{from:n.to,insert:e.lineBreak+o.text});for(let e of n.ranges)a.push(t.range(e.anchor-s,e.head-s))}}return i.length?(n(e.update({changes:i,scrollIntoView:!0,selection:t.create(a,e.selection.mainIndex),userEvent:`move.line`})),!0):!1}var vn=({state:e,dispatch:t})=>_n(e,t,!1),yn=({state:e,dispatch:t})=>_n(e,t,!0);function bn(e,t,n){if(e.readOnly)return!1;let r=[];for(let t of Q(e))n?r.push({from:t.from,insert:e.doc.slice(t.from,t.to)+e.lineBreak}):r.push({from:t.to,insert:e.lineBreak+e.doc.slice(t.from,t.to)});let i=e.changes(r);return t(e.update({changes:i,selection:e.selection.map(i,n?1:-1),scrollIntoView:!0,userEvent:`input.copyline`})),!0}var xn=({state:e,dispatch:t})=>bn(e,t,!1),Sn=({state:e,dispatch:t})=>bn(e,t,!0),Cn=e=>{if(e.state.readOnly)return!1;let{state:t}=e,n=t.changes(Q(t).map(({from:e,to:n})=>(e>0?e--:n<t.doc.length&&n++,{from:e,to:n}))),r=j(t.selection,t=>{let n;if(e.lineWrapping){let r=e.lineBlockAt(t.head),i=e.coordsAtPos(t.head,t.assoc||1);i&&(n=r.bottom+e.documentTop-i.bottom+e.defaultLineHeight/2)}return e.moveVertically(t,!0,n)}).map(n);return e.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:`delete.line`}),!0},wn=({state:e,dispatch:t})=>(t(e.update(e.replaceSelection(e.lineBreak),{scrollIntoView:!0,userEvent:`input`})),!0),Tn=({state:e,dispatch:n})=>(n(e.update(e.changeByRange(n=>{let r=/^\s*/.exec(e.doc.lineAt(n.from).text)[0];return{changes:{from:n.from,to:n.to,insert:e.lineBreak+r},range:t.cursor(n.from+r.length+1)}}),{scrollIntoView:!0,userEvent:`input`})),!0);function En(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let n=_(e).resolveInner(t),r=n.childBefore(t),i=n.childAfter(t),a;return r&&i&&r.to<=t&&i.from>=t&&(a=r.type.prop(ee.closedBy))&&a.indexOf(i.name)>-1&&e.doc.lineAt(r.to).from==e.doc.lineAt(i.from).from&&!/\S/.test(e.sliceDoc(r.to,i.from))?{from:r.to,to:i.from}:null}var Dn=kn(!1),On=kn(!0);function kn(e){return({state:r,dispatch:a})=>{if(r.readOnly)return!1;let o=r.changeByRange(a=>{let{from:o,to:s}=a,c=r.doc.lineAt(o),l=!e&&o==s&&En(r,o);e&&(o=s=(s<=c.to?c:r.doc.lineAt(s)).to);let u=new te(r,{simulateBreak:o,simulateDoubleBreak:!!l}),d=re(u,o);for(d??=n(/^\s*/.exec(r.doc.lineAt(o).text)[0],r.tabSize);s<c.to&&/\s/.test(c.text[s-c.from]);)s++;l?{from:o,to:s}=l:o>c.from&&o<c.from+100&&!/\S/.test(c.text.slice(0,o))&&(o=c.from);let f=[``,h(r,d)];return l&&f.push(h(r,u.lineIndent(c.from,-1))),{changes:{from:o,to:s,insert:i.of(f)},range:t.cursor(o+1+f[1].length)}});return a(r.update(o,{scrollIntoView:!0,userEvent:`input`})),!0}}function An(e,n){let r=-1;return e.changeByRange(i=>{let a=[];for(let t=i.from;t<=i.to;){let o=e.doc.lineAt(t);o.number>r&&(i.empty||i.to>o.from)&&(n(o,a,i),r=o.number),t=o.to+1}let o=e.changes(a);return{changes:a,range:t.range(o.mapPos(i.anchor,1),o.mapPos(i.head,1))}})}var jn=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=Object.create(null),r=new te(e,{overrideIndentation:e=>n[e]??-1}),i=An(e,(t,i,a)=>{let o=re(r,t.from);if(o==null)return;/\S/.test(t.text)||(o=0);let s=/^\s*/.exec(t.text)[0],c=h(e,o);(s!=c||a.from<t.from+s.length)&&(n[t.from]=o,i.push({from:t.from,to:t.from+s.length,insert:c}))});return i.changes.empty||t(e.update(i,{userEvent:`indent`})),!0},$=({state:e,dispatch:t})=>!e.readOnly&&(t(e.update(An(e,(t,n)=>{n.push({from:t.from,insert:e.facet(ie)})}),{userEvent:`input.indent`})),!0),Mn=({state:e,dispatch:t})=>!e.readOnly&&(t(e.update(An(e,(t,r)=>{let i=/^\s*/.exec(t.text)[0];if(!i)return;let a=n(i,e.tabSize),o=0,s=h(e,Math.max(0,a-ne(e)));for(;o<i.length&&o<s.length&&i.charCodeAt(o)==s.charCodeAt(o);)o++;r.push({from:t.from+o,to:t.from+i.length,insert:s.slice(o)})}),{userEvent:`delete.dedent`})),!0),Nn=e=>(e.setTabFocusMode(),!0),Pn=e=>(e.setTabFocusMode(2e3),!0),Fn=({state:e,dispatch:t})=>e.selection.ranges.some(e=>!e.empty)?$({state:e,dispatch:t}):(t(e.update(e.replaceSelection(` `),{scrollIntoView:!0,userEvent:`input`})),!0),In=[{key:`Ctrl-b`,run:L,shift:q,preventDefault:!0},{key:`Ctrl-f`,run:ze,shift:vt},{key:`Ctrl-p`,run:B,shift:Pt},{key:`Ctrl-n`,run:V,shift:Ft},{key:`Ctrl-a`,run:pt,shift:Ut},{key:`Ctrl-e`,run:mt,shift:Wt},{key:`Ctrl-d`,run:an},{key:`Ctrl-h`,run:Z},{key:`Ctrl-k`,run:un},{key:`Ctrl-Alt-h`,run:sn},{key:`Ctrl-o`,run:hn},{key:`Ctrl-t`,run:gn},{key:`Ctrl-v`,run:U}],Ln=[{key:`ArrowLeft`,run:L,shift:q,preventDefault:!0},{key:`Mod-ArrowLeft`,mac:`Alt-ArrowLeft`,run:Ke,shift:Ct,preventDefault:!0},{mac:`Cmd-ArrowLeft`,run:dt,shift:Vt,preventDefault:!0},{key:`ArrowRight`,run:ze,shift:vt,preventDefault:!0},{key:`Mod-ArrowRight`,mac:`Alt-ArrowRight`,run:qe,shift:wt,preventDefault:!0},{mac:`Cmd-ArrowRight`,run:ft,shift:Ht,preventDefault:!0},{key:`ArrowUp`,run:B,shift:Pt,preventDefault:!0},{mac:`Cmd-ArrowUp`,run:Gt,shift:qt},{mac:`Ctrl-ArrowUp`,run:H,shift:Lt},{key:`ArrowDown`,run:V,shift:Ft,preventDefault:!0},{mac:`Cmd-ArrowDown`,run:Kt,shift:Jt},{mac:`Ctrl-ArrowDown`,run:U,shift:Rt},{key:`PageUp`,run:H,shift:Lt},{key:`PageDown`,run:U,shift:Rt},{key:`Home`,run:ut,shift:Bt,preventDefault:!0},{key:`Mod-Home`,run:Gt,shift:qt},{key:`End`,run:lt,shift:zt,preventDefault:!0},{key:`Mod-End`,run:Kt,shift:Jt},{key:`Enter`,run:Dn,shift:Dn},{key:`Mod-a`,run:Yt},{key:`Backspace`,run:Z,shift:Z,preventDefault:!0},{key:`Delete`,run:an,preventDefault:!0},{key:`Mod-Backspace`,mac:`Alt-Backspace`,run:sn,preventDefault:!0},{key:`Mod-Delete`,mac:`Alt-Delete`,run:cn,preventDefault:!0},{mac:`Mod-Backspace`,run:fn,preventDefault:!0},{mac:`Mod-Delete`,run:pn,preventDefault:!0}].concat(In.map(e=>({mac:e.key,run:e.run,shift:e.shift}))),Rn=[{key:`Alt-ArrowLeft`,mac:`Ctrl-ArrowLeft`,run:it,shift:jt},{key:`Alt-ArrowRight`,mac:`Ctrl-ArrowRight`,run:at,shift:Mt},{key:`Alt-ArrowUp`,run:vn},{key:`Shift-Alt-ArrowUp`,run:xn},{key:`Alt-ArrowDown`,run:yn},{key:`Shift-Alt-ArrowDown`,run:Sn},{key:`Mod-Alt-ArrowUp`,run:$t},{key:`Mod-Alt-ArrowDown`,run:en},{key:`Escape`,run:tn},{key:`Mod-Enter`,run:On},{key:`Alt-l`,mac:`Ctrl-l`,run:Xt},{key:`Mod-i`,run:Zt,preventDefault:!0},{key:`Mod-[`,run:Mn},{key:`Mod-]`,run:$},{key:`Mod-Alt-\\`,run:jn},{key:`Shift-Mod-k`,run:Cn},{key:`Shift-Mod-\\`,run:gt},{key:`Mod-/`,run:ae},{key:`Alt-A`,mac:`Ctrl-A`,run:le},{key:`Ctrl-m`,mac:`Shift-Alt-m`,run:Nn}].concat(Ln),zn={key:`Tab`,run:$,shift:Mn};export{$t as addCursorAbove,en as addCursorBelow,ue as blockComment,de as blockUncomment,Oe as canRedoSelection,De as canUndoSelection,Sn as copyLineDown,xn as copyLineUp,Ve as cursorCharBackward,Ge as cursorCharBackwardLogical,Be as cursorCharForward,We as cursorCharForwardLogical,L as cursorCharLeft,ze as cursorCharRight,Kt as cursorDocEnd,Gt as cursorDocStart,Ye as cursorGroupBackward,Je as cursorGroupForward,Ze as cursorGroupForwardWin,Ke as cursorGroupLeft,qe as cursorGroupRight,ut as cursorLineBoundaryBackward,lt as cursorLineBoundaryForward,dt as cursorLineBoundaryLeft,ft as cursorLineBoundaryRight,V as cursorLineDown,mt as cursorLineEnd,pt as cursorLineStart,B as cursorLineUp,gt as cursorMatchingBracket,U as cursorPageDown,H as cursorPageUp,nt as cursorSubwordBackward,tt as cursorSubwordForward,it as cursorSyntaxLeft,at as cursorSyntaxRight,Rn as defaultKeymap,Z as deleteCharBackward,rn as deleteCharBackwardStrict,an as deleteCharForward,sn as deleteGroupBackward,cn as deleteGroupForward,ln as deleteGroupForwardWin,Cn as deleteLine,fn as deleteLineBoundaryBackward,pn as deleteLineBoundaryForward,un as deleteToLineEnd,dn as deleteToLineStart,mn as deleteTrailingWhitespace,In as emacsStyleKeymap,ve as history,ye as historyField,Re as historyKeymap,Mn as indentLess,$ as indentMore,jn as indentSelection,zn as indentWithTab,On as insertBlankLine,wn as insertNewline,Dn as insertNewlineAndIndent,Tn as insertNewlineKeepIndent,Fn as insertTab,ge as invertedEffects,he as isolateHistory,se as lineComment,ce as lineUncomment,yn as moveLineDown,vn as moveLineUp,E as redo,Te as redoDepth,Se as redoSelection,Yt as selectAll,bt as selectCharBackward,St as selectCharBackwardLogical,yt as selectCharForward,xt as selectCharForwardLogical,q as selectCharLeft,vt as selectCharRight,Jt as selectDocEnd,qt as selectDocStart,Et as selectGroupBackward,Tt as selectGroupForward,Dt as selectGroupForwardWin,Ct as selectGroupLeft,wt as selectGroupRight,Xt as selectLine,Bt as selectLineBoundaryBackward,zt as selectLineBoundaryForward,Vt as selectLineBoundaryLeft,Ht as selectLineBoundaryRight,Ft as selectLineDown,Wt as selectLineEnd,Ut as selectLineStart,Pt as selectLineUp,_t as selectMatchingBracket,Rt as selectPageDown,Lt as selectPageUp,Zt as selectParentSyntax,At as selectSubwordBackward,kt as selectSubwordForward,jt as selectSyntaxLeft,Mt as selectSyntaxRight,tn as simplifySelection,hn as splitLine,Ln as standardKeymap,Pn as temporarilySetTabFocusMode,le as toggleBlockComment,fe as toggleBlockCommentByLine,ae as toggleComment,oe as toggleLineComment,Nn as toggleTabFocusMode,gn as transposeChars,be as undo,we as undoDepth,xe as undoSelection};
|
|
1
|
+
import{S as e,a as t,b as n,g as r,h as i,i as a,m as o,n as s,p as c,r as l,s as u,t as d,y as f}from"./dist-Bk_pkBVH.js";import{n as p,r as m}from"./dist-CRxCwn-Z.js";import{l as ee}from"./dist-u0nBg0fZ.js";import{IndentContext as te,getIndentUnit as ne,getIndentation as re,indentString as h,indentUnit as ie,matchBrackets as g,syntaxTree as _}from"./dist-B1qLZVMK.js";var ae=e=>{let{state:t}=e,n=t.doc.lineAt(t.selection.main.from),r=y(e.state,n.from);return r.line?oe(e):r.block?fe(e):!1};function v(e,t){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let i=e(t,n);return i?(r(n.update(i)),!0):!1}}var oe=v(S,0),se=v(S,1),ce=v(S,2),le=v(x,0),ue=v(x,1),de=v(x,2),fe=v((e,t)=>x(e,t,me(t)),0);function y(e,t){let n=e.languageDataAt(`commentTokens`,t,1);return n.length?n[0]:{}}var b=50;function pe(e,{open:t,close:n},r,i){let a=e.sliceDoc(r-b,r),o=e.sliceDoc(i,i+b),s=/\s*$/.exec(a)[0].length,c=/^\s*/.exec(o)[0].length,l=a.length-s;if(a.slice(l-t.length,l)==t&&o.slice(c,c+n.length)==n)return{open:{pos:r-s,margin:s&&1},close:{pos:i+c,margin:c&&1}};let u,d;i-r<=100?u=d=e.sliceDoc(r,i):(u=e.sliceDoc(r,r+b),d=e.sliceDoc(i-b,i));let f=/^\s*/.exec(u)[0].length,p=/\s*$/.exec(d)[0].length,m=d.length-p-n.length;return u.slice(f,f+t.length)==t&&d.slice(m,m+n.length)==n?{open:{pos:r+f+t.length,margin:+!!/\s/.test(u.charAt(f+t.length))},close:{pos:i-p-n.length,margin:+!!/\s/.test(d.charAt(m-1))}}:null}function me(e){let t=[];for(let n of e.selection.ranges){let r=e.doc.lineAt(n.from),i=n.to<=r.to?r:e.doc.lineAt(n.to);i.from>r.from&&i.from==n.to&&(i=n.to==r.to+1?r:e.doc.lineAt(n.to-1));let a=t.length-1;a>=0&&t[a].to>r.from?t[a].to=i.to:t.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:i.to})}return t}function x(e,t,n=t.selection.ranges){let r=n.map(e=>y(t,e.from).block);if(!r.every(e=>e))return null;let i=n.map((e,n)=>pe(t,r[n],e.from,e.to));if(e!=2&&!i.every(e=>e))return{changes:t.changes(n.map((e,t)=>i[t]?[]:[{from:e.from,insert:r[t].open+` `},{from:e.to,insert:` `+r[t].close}]))};if(e!=1&&i.some(e=>e)){let e=[];for(let t=0,n;t<i.length;t++)if(n=i[t]){let i=r[t],{open:a,close:o}=n;e.push({from:a.pos-i.open.length,to:a.pos+a.margin},{from:o.pos-o.margin,to:o.pos+i.close.length})}return{changes:e}}return null}function S(e,t,n=t.selection.ranges){let r=[],i=-1;ranges:for(let{from:e,to:a}of n){let n=r.length,o=1e9,s;for(let n=e;n<=a;){let c=t.doc.lineAt(n);if(s==null&&(s=y(t,c.from).line,!s))continue ranges;if(c.from>i&&(e==a||a>c.from)){i=c.from;let e=/^\s*/.exec(c.text)[0].length,t=e==c.length,n=c.text.slice(e,e+s.length)==s?e:-1;e<c.text.length&&e<o&&(o=e),r.push({line:c,comment:n,token:s,indent:e,empty:t,single:!1})}n=c.to+1}if(o<1e9)for(let e=n;e<r.length;e++)r[e].indent<r[e].line.text.length&&(r[e].indent=o);r.length==n+1&&(r[n].single=!0)}if(e!=2&&r.some(e=>e.comment<0&&(!e.empty||e.single))){let e=[];for(let{line:t,token:n,indent:i,empty:a,single:o}of r)(o||!a)&&e.push({from:t.from+i,insert:n+` `});let n=t.changes(e);return{changes:n,selection:t.selection.map(n,1)}}if(e!=1&&r.some(e=>e.comment>=0)){let e=[];for(let{line:t,comment:n,token:i}of r)if(n>=0){let r=t.from+n,a=r+i.length;t.text[a-t.from]==` `&&a++,e.push({from:r,to:a})}return{changes:e}}return null}var C=d.define(),he=d.define(),ge=u.define(),_e=u.define({combine(e){return f(e,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(n,r)=>e(n,r)||t(n,r)})}}),w=o.define({create(){return A.empty},update(e,t){let n=t.state.facet(_e),i=t.annotation(C);if(i){let r=D.fromTransaction(t,i.selection),a=i.side,o=a==0?e.undone:e.done;return o=r?O(o,o.length,n.minDepth,r):Ne(o,t.startState.selection),new A(a==0?i.rest:o,a==0?o:i.rest)}let a=t.annotation(he);if((a==`full`||a==`before`)&&(e=e.isolate()),t.annotation(r.addToHistory)===!1)return t.changes.empty?e:e.addMapping(t.changes.desc);let o=D.fromTransaction(t),s=t.annotation(r.time),c=t.annotation(r.userEvent);return o?e=e.addChanges(o,s,c,n,t):t.selection&&(e=e.addSelection(t.startState.selection,s,c,n.newGroupDelay)),(a==`full`||a==`after`)&&(e=e.isolate()),e},toJSON(e){return{done:e.done.map(e=>e.toJSON()),undone:e.undone.map(e=>e.toJSON())}},fromJSON(e){return new A(e.done.map(D.fromJSON),e.undone.map(D.fromJSON))}});function ve(e={}){return[w,_e.of(e),m.domEventHandlers({beforeinput(e,t){let n=e.inputType==`historyUndo`?be:e.inputType==`historyRedo`?E:null;return n?(e.preventDefault(),n(t)):!1}})]}var ye=w;function T(e,t){return function({state:n,dispatch:r}){if(!t&&n.readOnly)return!1;let i=n.field(w,!1);if(!i)return!1;let a=i.pop(e,n,t);return a?(r(a),!0):!1}}var be=T(0,!1),E=T(1,!1),xe=T(0,!0),Se=T(1,!0);function Ce(e){return function(t){let n=t.field(w,!1);if(!n)return 0;let r=e==0?n.done:n.undone;return r.length-(r.length&&!r[0].changes?1:0)}}var we=Ce(0),Te=Ce(1);function Ee(e){return function(t){let n=t.field(w,!1);if(!n)return!1;let r=e==0?n.done:n.undone;return r.length>0&&r[0].selectionsAfter.length>0}}var De=Ee(0),Oe=Ee(0),D=class e{constructor(e,t,n,r,i){this.changes=e,this.effects=t,this.mapped=n,this.startSelection=r,this.selectionsAfter=i}setSelAfter(t){return new e(this.changes,this.effects,this.mapped,this.startSelection,t)}toJSON(){return{changes:this.changes?.toJSON(),mapped:this.mapped?.toJSON(),startSelection:this.startSelection?.toJSON(),selectionsAfter:this.selectionsAfter.map(e=>e.toJSON())}}static fromJSON(n){return new e(n.changes&&l.fromJSON(n.changes),[],n.mapped&&s.fromJSON(n.mapped),n.startSelection&&t.fromJSON(n.startSelection),n.selectionsAfter.map(t.fromJSON))}static fromTransaction(t,n){let r=k;for(let e of t.startState.facet(ge)){let n=e(t);n.length&&(r=r.concat(n))}return!r.length&&t.changes.empty?null:new e(t.changes.invert(t.startState.doc),r,void 0,n||t.startState.selection,k)}static selection(t){return new e(void 0,k,void 0,void 0,t)}};function O(e,t,n,r){let i=t+1>n+20?t-n-1:0,a=e.slice(i,t);return a.push(r),a}function ke(e,t){let n=[],r=!1;return e.iterChangedRanges((e,t)=>n.push(e,t)),t.iterChangedRanges((e,t,i,a)=>{for(let e=0;e<n.length;){let t=n[e++],o=n[e++];a>=t&&i<=o&&(r=!0)}}),r}function Ae(e,t){return e.ranges.length==t.ranges.length&&e.ranges.filter((e,n)=>e.empty!=t.ranges[n].empty).length===0}function je(e,t){return e.length?t.length?e.concat(t):e:t}var k=[],Me=200;function Ne(e,t){if(e.length){let n=e[e.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-Me));return r.length&&r[r.length-1].eq(t)?e:(r.push(t),O(e,e.length-1,1e9,n.setSelAfter(r)))}return[D.selection([t])]}function Pe(e){let t=e[e.length-1],n=e.slice();return n[e.length-1]=t.setSelAfter(t.selectionsAfter.slice(0,t.selectionsAfter.length-1)),n}function Fe(e,t){if(!e.length)return e;let n=e.length,r=k;for(;n;){let i=Ie(e[n-1],t,r);if(i.changes&&!i.changes.empty||i.effects.length){let t=e.slice(0,n);return t[n-1]=i,t}t=i.mapped,n--,r=i.selectionsAfter}return r.length?[D.selection(r)]:k}function Ie(e,t,n){let r=je(e.selectionsAfter.length?e.selectionsAfter.map(e=>e.map(t)):k,n);if(!e.changes)return D.selection(r);let i=e.changes.map(t),a=t.mapDesc(e.changes,!0),o=e.mapped?e.mapped.composeDesc(a):a;return new D(i,c.mapEffects(e.effects,t),o,e.startSelection.map(a),r)}var Le=/^(input\.type|delete)($|\.)/,A=class e{constructor(e,t,n=0,r=void 0){this.done=e,this.undone=t,this.prevTime=n,this.prevUserEvent=r}isolate(){return this.prevTime?new e(this.done,this.undone):this}addChanges(t,n,r,i,a){let o=this.done,s=o[o.length-1];return o=s&&s.changes&&!s.changes.empty&&t.changes&&(!r||Le.test(r))&&(!s.selectionsAfter.length&&n-this.prevTime<i.newGroupDelay&&i.joinToEvent(a,ke(s.changes,t.changes))||r==`input.type.compose`)?O(o,o.length-1,i.minDepth,new D(t.changes.compose(s.changes),je(c.mapEffects(t.effects,s.changes),s.effects),s.mapped,s.startSelection,k)):O(o,o.length,i.minDepth,t),new e(o,k,n,r)}addSelection(t,n,r,i){let a=this.done.length?this.done[this.done.length-1].selectionsAfter:k;return a.length>0&&n-this.prevTime<i&&r==this.prevUserEvent&&r&&/^select($|\.)/.test(r)&&Ae(a[a.length-1],t)?this:new e(Ne(this.done,t),this.undone,n,r)}addMapping(t){return new e(Fe(this.done,t),Fe(this.undone,t),this.prevTime,this.prevUserEvent)}pop(e,t,n){let r=e==0?this.done:this.undone;if(r.length==0)return null;let i=r[r.length-1],a=i.selectionsAfter[0]||(i.startSelection?i.startSelection.map(i.changes.invertedDesc,1):t.selection);if(n&&i.selectionsAfter.length)return t.update({selection:i.selectionsAfter[i.selectionsAfter.length-1],annotations:C.of({side:e,rest:Pe(r),selection:a}),userEvent:e==0?`select.undo`:`select.redo`,scrollIntoView:!0});if(i.changes){let n=r.length==1?k:r.slice(0,r.length-1);return i.mapped&&(n=Fe(n,i.mapped)),t.update({changes:i.changes,selection:i.startSelection,effects:i.effects,annotations:C.of({side:e,rest:n,selection:a}),filter:!1,userEvent:e==0?`undo`:`redo`,scrollIntoView:!0})}return null}};A.empty=new A(k,k);var Re=[{key:`Mod-z`,run:be,preventDefault:!0},{key:`Mod-y`,mac:`Mod-Shift-z`,run:E,preventDefault:!0},{linux:`Ctrl-Shift-z`,run:E,preventDefault:!0},{key:`Mod-u`,run:xe,preventDefault:!0},{key:`Alt-u`,mac:`Mod-Shift-u`,run:Se,preventDefault:!0}];function j(e,n){return t.create(e.ranges.map(n),e.mainIndex)}function M(e,t){return e.update({selection:t,scrollIntoView:!0,userEvent:`select`})}function N({state:e,dispatch:t},n){let r=j(e.selection,n);return!r.eq(e.selection,!0)&&(t(M(e,r)),!0)}function P(e,n){return t.cursor(n?e.to:e.from)}function F(e,t){return N(e,n=>n.empty?e.moveByChar(n,t):P(n,t))}function I(e){return e.textDirectionAt(e.state.selection.main.head)==p.LTR}var L=e=>F(e,!I(e)),ze=e=>F(e,I(e)),Be=e=>F(e,!0),Ve=e=>F(e,!1);function He(n,r,i){let a=r.head,o=n.doc.lineAt(a);return a=a==(i?o.to:o.from)?i?Math.min(n.doc.length,o.to+1):Math.max(0,o.from-1):o.from+e(o.text,a-o.from,i),t.cursor(a,i?-1:1)}function Ue(e,t){return N(e,n=>n.empty?He(e.state,n,t):P(n,t))}var We=e=>Ue(e,!0),Ge=e=>Ue(e,!1);function R(e,t){return N(e,n=>n.empty?e.moveByGroup(n,t):P(n,t))}var Ke=e=>R(e,!I(e)),qe=e=>R(e,I(e)),Je=e=>R(e,!0),Ye=e=>R(e,!1);function Xe(e,t,n){let r=e.state.charCategorizer(t),i=r(n),o=i!=a.Space;return e=>{let t=r(e);return t==a.Space?(o=!1,!0):o&&t==i}}var Ze=e=>N(e,t=>t.empty?e.moveByChar(t,!0,n=>Xe(e,t.head,n)):P(t,!0)),Qe=typeof Intl<`u`&&Intl.Segmenter?new Intl.Segmenter(void 0,{granularity:`word`}):null;function $e(e,n,r){let i=e.state.charCategorizer(n.from),o=a.Space,s=n.from,c=0,l=!1,u=!1,d=!1,f=t=>{if(l)return!1;s+=r?t.length:-t.length;let n=i(t),f;if(n==a.Word&&t.charCodeAt(0)<128&&/[\W_]/.test(t)&&(n=-1),o==a.Space&&(o=n),o!=n)return!1;if(o==a.Word){if(t.toLowerCase()==t){if(!r&&u)return!1;d=!0}else if(d){if(r)return!1;l=!0}else{if(u&&r&&i(f=e.state.sliceDoc(s,s+1))==a.Word&&f.toLowerCase()==f)return!1;u=!0}}return c++,!0},p=e.moveByChar(n,r,e=>(f(e),f));if(Qe&&o==a.Word&&p.from==n.from+c*(r?1:-1)){let i=Math.min(n.head,p.head),a=Math.max(n.head,p.head),o=e.state.sliceDoc(i,a);if(o.length>1&&/[\u4E00-\uffff]/.test(o)){let e=Array.from(Qe.segment(o));if(e.length>1)return r?t.cursor(n.head+e[1].index,-1):t.cursor(p.head+e[e.length-1].index,1)}}return p}function et(e,t){return N(e,n=>n.empty?$e(e,n,t):P(n,t))}var tt=e=>et(e,!0),nt=e=>et(e,!1);function rt(e,t,n){if(t.type.prop(n))return!0;let r=t.to-t.from;return r&&(r>2||/[^\s,.;:]/.test(e.sliceDoc(t.from,t.to)))||t.firstChild}function z(e,n,r){let i=_(e).resolveInner(n.head),a=r?ee.closedBy:ee.openedBy;for(let t=n.head;;){let n=r?i.childAfter(t):i.childBefore(t);if(!n)break;rt(e,n,a)?i=n:t=r?n.to:n.from}let o=i.type.prop(a),s,c;return c=o&&(s=r?g(e,i.from,1):g(e,i.to,-1))&&s.matched?r?s.end.to:s.end.from:r?i.to:i.from,t.cursor(c,r?-1:1)}var it=e=>N(e,t=>z(e.state,t,!I(e))),at=e=>N(e,t=>z(e.state,t,I(e)));function ot(e,t){return N(e,n=>{if(!n.empty)return P(n,t);let r=e.moveVertically(n,t);return r.head==n.head?e.moveToLineBoundary(n,t):r})}var B=e=>ot(e,!1),V=e=>ot(e,!0);function st(e){let t=e.scrollDOM.clientHeight<e.scrollDOM.scrollHeight-2,n=0,r=0,i;if(t){for(let t of e.state.facet(m.scrollMargins)){let i=t(e);i?.top&&(n=Math.max(i?.top,n)),i?.bottom&&(r=Math.max(i?.bottom,r))}i=e.scrollDOM.clientHeight-n-r}else i=(e.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:n,marginBottom:r,selfScroll:t,height:Math.max(e.defaultLineHeight,i-5)}}function ct(e,t){let n=st(e),{state:r}=e,i=j(r.selection,r=>r.empty?e.moveVertically(r,t,n.height):P(r,t));if(i.eq(r.selection))return!1;let a;if(n.selfScroll){let t=e.coordsAtPos(r.selection.main.head),o=e.scrollDOM.getBoundingClientRect(),s=o.top+n.marginTop,c=o.bottom-n.marginBottom;t&&t.top>s&&t.bottom<c&&(a=m.scrollIntoView(i.main.head,{y:`start`,yMargin:t.top-s}))}return e.dispatch(M(r,i),{effects:a}),!0}var H=e=>ct(e,!1),U=e=>ct(e,!0);function W(e,n,r){let i=e.lineBlockAt(n.head),a=e.moveToLineBoundary(n,r);if(a.head==n.head&&a.head!=(r?i.to:i.from)&&(a=e.moveToLineBoundary(n,r,!1)),!r&&a.head==i.from&&i.length){let r=/^\s*/.exec(e.state.sliceDoc(i.from,Math.min(i.from+100,i.to)))[0].length;r&&n.head!=i.from+r&&(a=t.cursor(i.from+r))}return a}var lt=e=>N(e,t=>W(e,t,!0)),ut=e=>N(e,t=>W(e,t,!1)),dt=e=>N(e,t=>W(e,t,!I(e))),ft=e=>N(e,t=>W(e,t,I(e))),pt=e=>N(e,t=>e.moveToLineBoundary(t,!1,!1)),mt=e=>N(e,t=>e.moveToLineBoundary(t,!0,!1));function ht(e,n,r){let i=!1,a=j(e.selection,n=>{let a=g(e,n.head,-1)||g(e,n.head,1)||n.head>0&&g(e,n.head-1,1)||n.head<e.doc.length&&g(e,n.head+1,-1);if(!a||!a.end)return n;i=!0;let o=a.start.from==n.head?a.end.to:a.end.from;return r?t.range(n.anchor,o):t.cursor(o)});return i?(n(M(e,a)),!0):!1}var gt=({state:e,dispatch:t})=>ht(e,t,!1),_t=({state:e,dispatch:t})=>ht(e,t,!0);function G(e,n,r){let i=j(e.state.selection,e=>{e.undirectional&&e.head>=e.anchor!=n&&(e=t.range(e.head,e.anchor));let i=r(e);return t.range(e.anchor,i.head,i.goalColumn,i.bidiLevel||void 0,i.assoc)});return!i.eq(e.state.selection)&&(e.dispatch(M(e.state,i)),!0)}function K(e,t){return G(e,t,n=>e.moveByChar(n,t))}var q=e=>K(e,!I(e)),vt=e=>K(e,I(e)),yt=e=>K(e,!0),bt=e=>K(e,!1),xt=e=>G(e,!0,t=>He(e.state,t,!0)),St=e=>G(e,!1,t=>He(e.state,t,!1));function J(e,t){return G(e,t,n=>e.moveByGroup(n,t))}var Ct=e=>J(e,!I(e)),wt=e=>J(e,I(e)),Tt=e=>J(e,!0),Et=e=>J(e,!1),Dt=e=>G(e,!0,t=>e.moveByChar(t,!0,n=>Xe(e,t.head,n)));function Ot(e,t){return G(e,t,n=>$e(e,n,t))}var kt=e=>Ot(e,!0),At=e=>Ot(e,!1),jt=e=>{let t=!I(e);return G(e,t,n=>z(e.state,n,t))},Mt=e=>{let t=I(e);return G(e,t,n=>z(e.state,n,t))};function Nt(e,t){return G(e,t,n=>e.moveVertically(n,t))}var Pt=e=>Nt(e,!1),Ft=e=>Nt(e,!0);function It(e,t){return G(e,t,n=>e.moveVertically(n,t,st(e).height))}var Lt=e=>It(e,!1),Rt=e=>It(e,!0),zt=e=>G(e,!0,t=>W(e,t,!0)),Bt=e=>G(e,!1,t=>W(e,t,!1)),Vt=e=>{let t=!I(e);return G(e,t,n=>W(e,n,t))},Ht=e=>{let t=I(e);return G(e,t,n=>W(e,n,t))},Ut=e=>G(e,!1,n=>t.cursor(e.lineBlockAt(n.head).from)),Wt=e=>G(e,!0,n=>t.cursor(e.lineBlockAt(n.head).to)),Gt=({state:e,dispatch:t})=>(t(M(e,{anchor:0})),!0),Kt=({state:e,dispatch:t})=>(t(M(e,{anchor:e.doc.length})),!0),qt=({state:e,dispatch:t})=>(t(M(e,{anchor:e.selection.main.anchor,head:0})),!0),Jt=({state:e,dispatch:t})=>(t(M(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0),Yt=({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:`select`})),!0),Xt=({state:e,dispatch:n})=>{let r=Q(e).map(({from:n,to:r})=>t.undirectionalRange(n,Math.min(r+1,e.doc.length)));return n(e.update({selection:t.create(r),userEvent:`select`})),!0},Zt=({state:e,dispatch:n})=>{let r=j(e.selection,n=>{let r=_(e),i=r.resolveStack(n.from,1);if(n.empty){let e=r.resolveStack(n.from,-1);e.node.from>=i.node.from&&e.node.to<=i.node.to&&(i=e)}for(let e=i;e;e=e.next){let{node:r}=e;if((r.from<n.from&&r.to>=n.to||r.to>n.to&&r.from<=n.from)&&e.next)return t.undirectionalRange(r.from,r.to)}return n});return!r.eq(e.selection)&&(n(M(e,r)),!0)};function Qt(e,n){let{state:r}=e,i=r.selection,a=r.selection.ranges.slice();for(let t of r.selection.ranges){let i=r.doc.lineAt(t.head);if(n?i.to<e.state.doc.length:i.from>0)for(let r=t;;){let t=e.moveVertically(r,n);if(t.head<i.from||t.head>i.to){a.some(e=>e.head==t.head)||a.push(t);break}if(t.head==r.head)break;r=t}}return a.length!=i.ranges.length&&(e.dispatch(M(r,t.create(a,a.length-1))),!0)}var $t=e=>Qt(e,!1),en=e=>Qt(e,!0),tn=({state:e,dispatch:n})=>{let r=e.selection,i=null;return r.ranges.length>1?i=t.create([r.main]):r.main.empty||(i=t.create([t.cursor(r.main.head)])),i?(n(M(e,i)),!0):!1};function Y(e,n){if(e.state.readOnly)return!1;let r=`delete.selection`,{state:i}=e,a=i.changeByRange(i=>{let{from:a,to:o}=i;if(a==o){let t=n(i);t<a?(r=`delete.backward`,t=X(e,t,!1)):t>a&&(r=`delete.forward`,t=X(e,t,!0)),a=Math.min(a,t),o=Math.max(o,t)}else a=X(e,a,!1),o=X(e,o,!0);return a==o?{range:i}:{changes:{from:a,to:o},range:t.cursor(a,a<i.head?-1:1)}});return!a.changes.empty&&(e.dispatch(i.update(a,{scrollIntoView:!0,userEvent:r,effects:r==`delete.selection`?m.announce.of(i.phrase(`Selection deleted`)):void 0})),!0)}function X(e,t,n){if(e instanceof m)for(let r of e.state.facet(m.atomicRanges).map(t=>t(e)))r.between(t,t,(e,r)=>{e<t&&r>t&&(t=n?r:e)});return t}var nn=(t,r,i)=>Y(t,a=>{let o=a.from,{state:s}=t,c=s.doc.lineAt(o),l,u;if(i&&!r&&o>c.from&&o<c.from+200&&!/[^ \t]/.test(l=c.text.slice(0,o-c.from))){if(l[l.length-1]==` `)return o-1;let e=n(l,s.tabSize)%ne(s)||ne(s);for(let t=0;t<e&&l[l.length-1-t]==` `;t++)o--;u=o}else u=e(c.text,o-c.from,r,r)+c.from,u==o&&c.number!=(r?s.doc.lines:1)?u+=r?1:-1:!r&&/[\ufe00-\ufe0f]/.test(c.text.slice(u-c.from,o-c.from))&&(u=e(c.text,u-c.from,!1,!1)+c.from);return u}),Z=e=>nn(e,!1,!0),rn=e=>nn(e,!1,!1),an=e=>nn(e,!0,!1),on=(t,n)=>Y(t,r=>{let i=r.head,{state:a}=t,o=a.doc.lineAt(i),s=a.charCategorizer(i);for(let t=null;;){if(i==(n?o.to:o.from)){i==r.head&&o.number!=(n?a.doc.lines:1)&&(i+=n?1:-1);break}let c=e(o.text,i-o.from,n)+o.from,l=o.text.slice(Math.min(i,c)-o.from,Math.max(i,c)-o.from),u=s(l);if(t!=null&&u!=t)break;(l!=` `||i!=r.head)&&(t=u),i=c}return i}),sn=e=>on(e,!1),cn=e=>on(e,!0),ln=e=>Y(e,t=>e.moveByChar(t,!0,n=>Xe(e,t.head,n)).head),un=e=>Y(e,t=>{let n=e.lineBlockAt(t.head).to;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),dn=e=>Y(e,t=>{let n=e.lineBlockAt(t.head).from;return t.head>n?n:Math.max(0,t.head-1)}),fn=e=>Y(e,t=>{let n=e.moveToLineBoundary(t,!1).head;return t.head>n?n:Math.max(0,t.head-1)}),pn=e=>Y(e,t=>{let n=e.moveToLineBoundary(t,!0).head;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),mn=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=[];for(let t=0,r=``,i=e.doc.iter();;){if(i.next(),i.lineBreak||i.done){let e=r.search(/\s+$/);if(e>-1&&n.push({from:t-(r.length-e),to:t}),i.done)break;r=``}else r=i.value;t+=i.value.length}return n.length?(t(e.update({changes:n,userEvent:`delete`})),!0):!1},hn=({state:e,dispatch:n})=>{if(e.readOnly)return!1;let r=e.changeByRange(e=>({changes:{from:e.from,to:e.to,insert:i.of([``,``])},range:t.cursor(e.from)}));return n(e.update(r,{scrollIntoView:!0,userEvent:`input`})),!0},gn=({state:n,dispatch:r})=>{if(n.readOnly)return!1;let i=n.changeByRange(r=>{if(!r.empty||r.from==0||r.from==n.doc.length)return{range:r};let i=r.from,a=n.doc.lineAt(i),o=i==a.from?i-1:e(a.text,i-a.from,!1)+a.from,s=i==a.to?i+1:e(a.text,i-a.from,!0)+a.from;return{changes:{from:o,to:s,insert:n.doc.slice(i,s).append(n.doc.slice(o,i))},range:t.cursor(s)}});return!i.changes.empty&&(r(n.update(i,{scrollIntoView:!0,userEvent:`move.character`})),!0)};function Q(e){let t=[],n=-1;for(let r of e.selection.ranges){let i=e.doc.lineAt(r.from),a=e.doc.lineAt(r.to);if(!r.empty&&r.to==a.from&&(a=e.doc.lineAt(r.to-1)),n>=i.number){let e=t[t.length-1];e.to=a.to,e.ranges.push(r)}else t.push({from:i.from,to:a.to,ranges:[r]});n=a.number+1}return t}function _n(e,n,r){if(e.readOnly)return!1;let i=[],a=[];for(let n of Q(e)){if(r?n.to==e.doc.length:n.from==0)continue;let o=e.doc.lineAt(r?n.to+1:n.from-1),s=o.length+1;if(r){i.push({from:n.to,to:o.to},{from:n.from,insert:o.text+e.lineBreak});for(let r of n.ranges)a.push(t.range(Math.min(e.doc.length,r.anchor+s),Math.min(e.doc.length,r.head+s)))}else{i.push({from:o.from,to:n.from},{from:n.to,insert:e.lineBreak+o.text});for(let e of n.ranges)a.push(t.range(e.anchor-s,e.head-s))}}return i.length?(n(e.update({changes:i,scrollIntoView:!0,selection:t.create(a,e.selection.mainIndex),userEvent:`move.line`})),!0):!1}var vn=({state:e,dispatch:t})=>_n(e,t,!1),yn=({state:e,dispatch:t})=>_n(e,t,!0);function bn(e,t,n){if(e.readOnly)return!1;let r=[];for(let t of Q(e))n?r.push({from:t.from,insert:e.doc.slice(t.from,t.to)+e.lineBreak}):r.push({from:t.to,insert:e.lineBreak+e.doc.slice(t.from,t.to)});let i=e.changes(r);return t(e.update({changes:i,selection:e.selection.map(i,n?1:-1),scrollIntoView:!0,userEvent:`input.copyline`})),!0}var xn=({state:e,dispatch:t})=>bn(e,t,!1),Sn=({state:e,dispatch:t})=>bn(e,t,!0),Cn=e=>{if(e.state.readOnly)return!1;let{state:t}=e,n=t.changes(Q(t).map(({from:e,to:n})=>(e>0?e--:n<t.doc.length&&n++,{from:e,to:n}))),r=j(t.selection,t=>{let n;if(e.lineWrapping){let r=e.lineBlockAt(t.head),i=e.coordsAtPos(t.head,t.assoc||1);i&&(n=r.bottom+e.documentTop-i.bottom+e.defaultLineHeight/2)}return e.moveVertically(t,!0,n)}).map(n);return e.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:`delete.line`}),!0},wn=({state:e,dispatch:t})=>(t(e.update(e.replaceSelection(e.lineBreak),{scrollIntoView:!0,userEvent:`input`})),!0),Tn=({state:e,dispatch:n})=>(n(e.update(e.changeByRange(n=>{let r=/^\s*/.exec(e.doc.lineAt(n.from).text)[0];return{changes:{from:n.from,to:n.to,insert:e.lineBreak+r},range:t.cursor(n.from+r.length+1)}}),{scrollIntoView:!0,userEvent:`input`})),!0);function En(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let n=_(e).resolveInner(t),r=n.childBefore(t),i=n.childAfter(t),a;return r&&i&&r.to<=t&&i.from>=t&&(a=r.type.prop(ee.closedBy))&&a.indexOf(i.name)>-1&&e.doc.lineAt(r.to).from==e.doc.lineAt(i.from).from&&!/\S/.test(e.sliceDoc(r.to,i.from))?{from:r.to,to:i.from}:null}var Dn=kn(!1),On=kn(!0);function kn(e){return({state:r,dispatch:a})=>{if(r.readOnly)return!1;let o=r.changeByRange(a=>{let{from:o,to:s}=a,c=r.doc.lineAt(o),l=!e&&o==s&&En(r,o);e&&(o=s=(s<=c.to?c:r.doc.lineAt(s)).to);let u=new te(r,{simulateBreak:o,simulateDoubleBreak:!!l}),d=re(u,o);for(d??=n(/^\s*/.exec(r.doc.lineAt(o).text)[0],r.tabSize);s<c.to&&/\s/.test(c.text[s-c.from]);)s++;l?{from:o,to:s}=l:o>c.from&&o<c.from+100&&!/\S/.test(c.text.slice(0,o))&&(o=c.from);let f=[``,h(r,d)];return l&&f.push(h(r,u.lineIndent(c.from,-1))),{changes:{from:o,to:s,insert:i.of(f)},range:t.cursor(o+1+f[1].length)}});return a(r.update(o,{scrollIntoView:!0,userEvent:`input`})),!0}}function An(e,n){let r=-1;return e.changeByRange(i=>{let a=[];for(let t=i.from;t<=i.to;){let o=e.doc.lineAt(t);o.number>r&&(i.empty||i.to>o.from)&&(n(o,a,i),r=o.number),t=o.to+1}let o=e.changes(a);return{changes:a,range:t.range(o.mapPos(i.anchor,1),o.mapPos(i.head,1))}})}var jn=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=Object.create(null),r=new te(e,{overrideIndentation:e=>n[e]??-1}),i=An(e,(t,i,a)=>{let o=re(r,t.from);if(o==null)return;/\S/.test(t.text)||(o=0);let s=/^\s*/.exec(t.text)[0],c=h(e,o);(s!=c||a.from<t.from+s.length)&&(n[t.from]=o,i.push({from:t.from,to:t.from+s.length,insert:c}))});return i.changes.empty||t(e.update(i,{userEvent:`indent`})),!0},$=({state:e,dispatch:t})=>!e.readOnly&&(t(e.update(An(e,(t,n)=>{n.push({from:t.from,insert:e.facet(ie)})}),{userEvent:`input.indent`})),!0),Mn=({state:e,dispatch:t})=>!e.readOnly&&(t(e.update(An(e,(t,r)=>{let i=/^\s*/.exec(t.text)[0];if(!i)return;let a=n(i,e.tabSize),o=0,s=h(e,Math.max(0,a-ne(e)));for(;o<i.length&&o<s.length&&i.charCodeAt(o)==s.charCodeAt(o);)o++;r.push({from:t.from+o,to:t.from+i.length,insert:s.slice(o)})}),{userEvent:`delete.dedent`})),!0),Nn=e=>(e.setTabFocusMode(),!0),Pn=e=>(e.setTabFocusMode(2e3),!0),Fn=({state:e,dispatch:t})=>e.selection.ranges.some(e=>!e.empty)?$({state:e,dispatch:t}):(t(e.update(e.replaceSelection(` `),{scrollIntoView:!0,userEvent:`input`})),!0),In=[{key:`Ctrl-b`,run:L,shift:q,preventDefault:!0},{key:`Ctrl-f`,run:ze,shift:vt},{key:`Ctrl-p`,run:B,shift:Pt},{key:`Ctrl-n`,run:V,shift:Ft},{key:`Ctrl-a`,run:pt,shift:Ut},{key:`Ctrl-e`,run:mt,shift:Wt},{key:`Ctrl-d`,run:an},{key:`Ctrl-h`,run:Z},{key:`Ctrl-k`,run:un},{key:`Ctrl-Alt-h`,run:sn},{key:`Ctrl-o`,run:hn},{key:`Ctrl-t`,run:gn},{key:`Ctrl-v`,run:U}],Ln=[{key:`ArrowLeft`,run:L,shift:q,preventDefault:!0},{key:`Mod-ArrowLeft`,mac:`Alt-ArrowLeft`,run:Ke,shift:Ct,preventDefault:!0},{mac:`Cmd-ArrowLeft`,run:dt,shift:Vt,preventDefault:!0},{key:`ArrowRight`,run:ze,shift:vt,preventDefault:!0},{key:`Mod-ArrowRight`,mac:`Alt-ArrowRight`,run:qe,shift:wt,preventDefault:!0},{mac:`Cmd-ArrowRight`,run:ft,shift:Ht,preventDefault:!0},{key:`ArrowUp`,run:B,shift:Pt,preventDefault:!0},{mac:`Cmd-ArrowUp`,run:Gt,shift:qt},{mac:`Ctrl-ArrowUp`,run:H,shift:Lt},{key:`ArrowDown`,run:V,shift:Ft,preventDefault:!0},{mac:`Cmd-ArrowDown`,run:Kt,shift:Jt},{mac:`Ctrl-ArrowDown`,run:U,shift:Rt},{key:`PageUp`,run:H,shift:Lt},{key:`PageDown`,run:U,shift:Rt},{key:`Home`,run:ut,shift:Bt,preventDefault:!0},{key:`Mod-Home`,run:Gt,shift:qt},{key:`End`,run:lt,shift:zt,preventDefault:!0},{key:`Mod-End`,run:Kt,shift:Jt},{key:`Enter`,run:Dn,shift:Dn},{key:`Mod-a`,run:Yt},{key:`Backspace`,run:Z,shift:Z,preventDefault:!0},{key:`Delete`,run:an,preventDefault:!0},{key:`Mod-Backspace`,mac:`Alt-Backspace`,run:sn,preventDefault:!0},{key:`Mod-Delete`,mac:`Alt-Delete`,run:cn,preventDefault:!0},{mac:`Mod-Backspace`,run:fn,preventDefault:!0},{mac:`Mod-Delete`,run:pn,preventDefault:!0}].concat(In.map(e=>({mac:e.key,run:e.run,shift:e.shift}))),Rn=[{key:`Alt-ArrowLeft`,mac:`Ctrl-ArrowLeft`,run:it,shift:jt},{key:`Alt-ArrowRight`,mac:`Ctrl-ArrowRight`,run:at,shift:Mt},{key:`Alt-ArrowUp`,run:vn},{key:`Shift-Alt-ArrowUp`,run:xn},{key:`Alt-ArrowDown`,run:yn},{key:`Shift-Alt-ArrowDown`,run:Sn},{key:`Mod-Alt-ArrowUp`,run:$t},{key:`Mod-Alt-ArrowDown`,run:en},{key:`Escape`,run:tn},{key:`Mod-Enter`,run:On},{key:`Alt-l`,mac:`Ctrl-l`,run:Xt},{key:`Mod-i`,run:Zt,preventDefault:!0},{key:`Mod-[`,run:Mn},{key:`Mod-]`,run:$},{key:`Mod-Alt-\\`,run:jn},{key:`Shift-Mod-k`,run:Cn},{key:`Shift-Mod-\\`,run:gt},{key:`Mod-/`,run:ae},{key:`Alt-A`,mac:`Ctrl-A`,run:le},{key:`Ctrl-m`,mac:`Shift-Alt-m`,run:Nn}].concat(Ln),zn={key:`Tab`,run:$,shift:Mn};export{$t as addCursorAbove,en as addCursorBelow,ue as blockComment,de as blockUncomment,Oe as canRedoSelection,De as canUndoSelection,Sn as copyLineDown,xn as copyLineUp,Ve as cursorCharBackward,Ge as cursorCharBackwardLogical,Be as cursorCharForward,We as cursorCharForwardLogical,L as cursorCharLeft,ze as cursorCharRight,Kt as cursorDocEnd,Gt as cursorDocStart,Ye as cursorGroupBackward,Je as cursorGroupForward,Ze as cursorGroupForwardWin,Ke as cursorGroupLeft,qe as cursorGroupRight,ut as cursorLineBoundaryBackward,lt as cursorLineBoundaryForward,dt as cursorLineBoundaryLeft,ft as cursorLineBoundaryRight,V as cursorLineDown,mt as cursorLineEnd,pt as cursorLineStart,B as cursorLineUp,gt as cursorMatchingBracket,U as cursorPageDown,H as cursorPageUp,nt as cursorSubwordBackward,tt as cursorSubwordForward,it as cursorSyntaxLeft,at as cursorSyntaxRight,Rn as defaultKeymap,Z as deleteCharBackward,rn as deleteCharBackwardStrict,an as deleteCharForward,sn as deleteGroupBackward,cn as deleteGroupForward,ln as deleteGroupForwardWin,Cn as deleteLine,fn as deleteLineBoundaryBackward,pn as deleteLineBoundaryForward,un as deleteToLineEnd,dn as deleteToLineStart,mn as deleteTrailingWhitespace,In as emacsStyleKeymap,ve as history,ye as historyField,Re as historyKeymap,Mn as indentLess,$ as indentMore,jn as indentSelection,zn as indentWithTab,On as insertBlankLine,wn as insertNewline,Dn as insertNewlineAndIndent,Tn as insertNewlineKeepIndent,Fn as insertTab,ge as invertedEffects,he as isolateHistory,se as lineComment,ce as lineUncomment,yn as moveLineDown,vn as moveLineUp,E as redo,Te as redoDepth,Se as redoSelection,Yt as selectAll,bt as selectCharBackward,St as selectCharBackwardLogical,yt as selectCharForward,xt as selectCharForwardLogical,q as selectCharLeft,vt as selectCharRight,Jt as selectDocEnd,qt as selectDocStart,Et as selectGroupBackward,Tt as selectGroupForward,Dt as selectGroupForwardWin,Ct as selectGroupLeft,wt as selectGroupRight,Xt as selectLine,Bt as selectLineBoundaryBackward,zt as selectLineBoundaryForward,Vt as selectLineBoundaryLeft,Ht as selectLineBoundaryRight,Ft as selectLineDown,Wt as selectLineEnd,Ut as selectLineStart,Pt as selectLineUp,_t as selectMatchingBracket,Rt as selectPageDown,Lt as selectPageUp,Zt as selectParentSyntax,At as selectSubwordBackward,kt as selectSubwordForward,jt as selectSyntaxLeft,Mt as selectSyntaxRight,tn as simplifySelection,hn as splitLine,Ln as standardKeymap,Pn as temporarilySetTabFocusMode,le as toggleBlockComment,fe as toggleBlockCommentByLine,ae as toggleComment,oe as toggleLineComment,Nn as toggleTabFocusMode,gn as transposeChars,be as undo,we as undoDepth,xe as undoSelection};
|
|
@@ -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-DBUqwiWG.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-BCNaDgNW.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-Bx6ZWYUW.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-Bk_pkBVH.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-CRxCwn-Z.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-u0nBg0fZ.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};
|