@i14ks/ccv 0.22.0 → 0.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundle/ccv.mjs +323 -13
- package/package.json +1 -1
- package/web/assets/{codemirror-BVRIW86g.js → codemirror-BdKpW4CC.js} +1 -1
- package/web/assets/{index-BOTbHjsh.js → index-B2BGvdag.js} +1 -1
- package/web/assets/index-BCLbqlhA.js +134 -0
- package/web/assets/{index-B54sB01B.js → index-BrkwvvWk.js} +1 -1
- package/web/assets/{index-DcOycRyY.js → index-BroMLvyS.js} +1 -1
- package/web/assets/{index-DqNX5AfU.js → index-C59b0_Vk.js} +1 -1
- package/web/assets/index-C6Y6TadO.css +1 -0
- package/web/assets/{index-BRDMJVs_.js → index-CRsndRFc.js} +1 -1
- package/web/assets/{index-A6KnUhy4.js → index-CWTFMuFd.js} +1 -1
- package/web/assets/{index-B5EnmuL9.js → index-CZuUjzhP.js} +1 -1
- package/web/assets/{index-5z-WKiE2.js → index-ChyP1fTD.js} +1 -1
- package/web/assets/{index-BSbB9pNN.js → index-D6DYiY6f.js} +1 -1
- package/web/assets/{index-DiFzORZa.js → index-D83he8x-.js} +1 -1
- package/web/assets/{index-BUtKkXYx.js → index-DPrfFlZq.js} +1 -1
- package/web/assets/{index-C4RL1RRN.js → index-DXHZO0ym.js} +1 -1
- package/web/assets/{index-CwbKEdO4.js → index-Dd7rh20x.js} +1 -1
- package/web/assets/{index-CftAsWDp.js → index-DqnCWDLh.js} +1 -1
- package/web/assets/{index-Cj3tIh2i.js → index-Si6no75_.js} +1 -1
- package/web/assets/{index-iBO43oLF.js → index-UxKgaDrj.js} +1 -1
- package/web/assets/{index-CEtwcv2R.js → index-YCUybqa_.js} +1 -1
- package/web/assets/{index-BTHa3RWC.js → index-wsSNo9PM.js} +1 -1
- package/web/assets/{index-CHk-wT2e.js → index-yXtesgZ4.js} +1 -1
- package/web/index.html +2 -2
- package/web/assets/index-L8M_w2e-.js +0 -134
- package/web/assets/index-xoxa8R94.css +0 -1
package/bundle/ccv.mjs
CHANGED
|
@@ -223,7 +223,7 @@ function workspaceIdRemap(paths, sessionsOf) {
|
|
|
223
223
|
}
|
|
224
224
|
|
|
225
225
|
// ../host/dist/session.js
|
|
226
|
-
import { EventEmitter } from "node:events";
|
|
226
|
+
import { EventEmitter as EventEmitter2 } from "node:events";
|
|
227
227
|
import { randomUUID } from "node:crypto";
|
|
228
228
|
import path5 from "node:path";
|
|
229
229
|
import { query, renameSession } from "@anthropic-ai/claude-agent-sdk";
|
|
@@ -787,6 +787,173 @@ var Journal = class {
|
|
|
787
787
|
}
|
|
788
788
|
};
|
|
789
789
|
|
|
790
|
+
// ../host/dist/network-guard.js
|
|
791
|
+
import { EventEmitter } from "node:events";
|
|
792
|
+
import { request } from "node:https";
|
|
793
|
+
import { networkInterfaces } from "node:os";
|
|
794
|
+
var TRACE_URL = "https://api.anthropic.com/cdn-cgi/trace";
|
|
795
|
+
var NETWORK_CHECK_MS = 5e3;
|
|
796
|
+
var INTERFACES_POLL_MS = 1e3;
|
|
797
|
+
var CHECK_TIMEOUT_MS = 4e3;
|
|
798
|
+
var RETRY_DELAY_MS = 1e3;
|
|
799
|
+
var NETWORK_FRESH_MS = 3e3;
|
|
800
|
+
var UNCHECKED_REASON = "\u041C\u0430\u0440\u0448\u0440\u0443\u0442 \u0434\u043E Anthropic \u0435\u0449\u0451 \u043D\u0435 \u043F\u0440\u043E\u0432\u0435\u0440\u0435\u043D";
|
|
801
|
+
var NetworkGuard = class extends EventEmitter {
|
|
802
|
+
#enabled = false;
|
|
803
|
+
#blocked = /* @__PURE__ */ new Set();
|
|
804
|
+
#state = {
|
|
805
|
+
status: "ok",
|
|
806
|
+
country: null,
|
|
807
|
+
reason: null,
|
|
808
|
+
checkedAt: null,
|
|
809
|
+
enabled: false
|
|
810
|
+
};
|
|
811
|
+
#checkTimer = null;
|
|
812
|
+
#interfacesTimer = null;
|
|
813
|
+
#interfaces = "";
|
|
814
|
+
#inFlight = null;
|
|
815
|
+
/** Растёт при каждой смене настроек: ответ проверки, начатой до неё, не применяется. */
|
|
816
|
+
#generation = 0;
|
|
817
|
+
get state() {
|
|
818
|
+
return { ...this.#state };
|
|
819
|
+
}
|
|
820
|
+
/** Почему агентам сейчас нельзя в сеть; `null` — можно. */
|
|
821
|
+
blockedReason() {
|
|
822
|
+
return this.#state.status === "blocked" ? this.#state.reason ?? UNCHECKED_REASON : null;
|
|
823
|
+
}
|
|
824
|
+
/**
|
|
825
|
+
* Применить настройки. Включение начинает с блока до первой проверки,
|
|
826
|
+
* выключение снимает блок сразу.
|
|
827
|
+
*/
|
|
828
|
+
configure(enabled, blockedCountries) {
|
|
829
|
+
const countries = new Set(blockedCountries);
|
|
830
|
+
const same = enabled === this.#enabled && countries.size === this.#blocked.size && [...countries].every((c) => this.#blocked.has(c));
|
|
831
|
+
if (same)
|
|
832
|
+
return;
|
|
833
|
+
this.#generation += 1;
|
|
834
|
+
this.#blocked = countries;
|
|
835
|
+
const wasEnabled = this.#enabled;
|
|
836
|
+
this.#enabled = enabled;
|
|
837
|
+
if (!enabled) {
|
|
838
|
+
this.#stopTimers();
|
|
839
|
+
this.#apply({ status: "ok", country: this.#state.country, reason: null, checkedAt: null });
|
|
840
|
+
return;
|
|
841
|
+
}
|
|
842
|
+
if (!wasEnabled) {
|
|
843
|
+
this.#apply({ status: "blocked", country: null, reason: UNCHECKED_REASON, checkedAt: null });
|
|
844
|
+
this.#startTimers();
|
|
845
|
+
}
|
|
846
|
+
void this.check();
|
|
847
|
+
}
|
|
848
|
+
stop() {
|
|
849
|
+
this.#stopTimers();
|
|
850
|
+
}
|
|
851
|
+
/** Проверить сейчас. Параллельные вызовы делят одну проверку. */
|
|
852
|
+
check() {
|
|
853
|
+
if (!this.#enabled)
|
|
854
|
+
return Promise.resolve(this.state);
|
|
855
|
+
this.#inFlight ??= this.#runCheck().finally(() => {
|
|
856
|
+
this.#inFlight = null;
|
|
857
|
+
});
|
|
858
|
+
return this.#inFlight;
|
|
859
|
+
}
|
|
860
|
+
/** Проверить, если последняя проверка старше `NETWORK_FRESH_MS`. */
|
|
861
|
+
async ensureFresh() {
|
|
862
|
+
if (!this.#enabled)
|
|
863
|
+
return this.state;
|
|
864
|
+
const at = this.#state.checkedAt;
|
|
865
|
+
if (at !== null && Date.now() - at < NETWORK_FRESH_MS && !this.#inFlight)
|
|
866
|
+
return this.state;
|
|
867
|
+
return this.check();
|
|
868
|
+
}
|
|
869
|
+
async #runCheck() {
|
|
870
|
+
const generation = this.#generation;
|
|
871
|
+
let result = await traceCountry();
|
|
872
|
+
if (!result.ok && generation === this.#generation) {
|
|
873
|
+
await new Promise((resolve) => setTimeout(resolve, RETRY_DELAY_MS));
|
|
874
|
+
result = await traceCountry();
|
|
875
|
+
}
|
|
876
|
+
if (generation !== this.#generation || !this.#enabled)
|
|
877
|
+
return this.state;
|
|
878
|
+
const checkedAt = Date.now();
|
|
879
|
+
if (!result.ok) {
|
|
880
|
+
this.#apply({
|
|
881
|
+
status: "blocked",
|
|
882
|
+
country: null,
|
|
883
|
+
reason: `\u041D\u0435 \u0443\u0434\u0430\u043B\u043E\u0441\u044C \u043F\u0440\u043E\u0432\u0435\u0440\u0438\u0442\u044C \u043C\u0430\u0440\u0448\u0440\u0443\u0442 \u0434\u043E Anthropic: ${result.error}`,
|
|
884
|
+
checkedAt
|
|
885
|
+
});
|
|
886
|
+
} else if (this.#blocked.has(result.country)) {
|
|
887
|
+
this.#apply({
|
|
888
|
+
status: "blocked",
|
|
889
|
+
country: result.country,
|
|
890
|
+
reason: `\u0417\u0430\u043F\u0440\u043E\u0441\u044B \u043A Anthropic \u0438\u0434\u0443\u0442 \u0438\u0437 ${result.country} \u2014 \u043F\u043E\u0445\u043E\u0436\u0435, VPN \u043D\u0435 \u0440\u0430\u0431\u043E\u0442\u0430\u0435\u0442`,
|
|
891
|
+
checkedAt
|
|
892
|
+
});
|
|
893
|
+
} else {
|
|
894
|
+
this.#apply({ status: "ok", country: result.country, reason: null, checkedAt });
|
|
895
|
+
}
|
|
896
|
+
return this.state;
|
|
897
|
+
}
|
|
898
|
+
#apply(next) {
|
|
899
|
+
const previous = this.#state;
|
|
900
|
+
this.#state = { ...next, enabled: this.#enabled };
|
|
901
|
+
const changed = previous.status !== next.status || previous.country !== next.country || previous.reason !== next.reason || previous.enabled !== this.#enabled;
|
|
902
|
+
if (changed)
|
|
903
|
+
this.emit("change", this.state);
|
|
904
|
+
}
|
|
905
|
+
#startTimers() {
|
|
906
|
+
this.#stopTimers();
|
|
907
|
+
this.#interfaces = interfacesSignature();
|
|
908
|
+
this.#checkTimer = setInterval(() => void this.check(), NETWORK_CHECK_MS);
|
|
909
|
+
this.#checkTimer.unref();
|
|
910
|
+
this.#interfacesTimer = setInterval(() => {
|
|
911
|
+
const signature = interfacesSignature();
|
|
912
|
+
if (signature === this.#interfaces)
|
|
913
|
+
return;
|
|
914
|
+
this.#interfaces = signature;
|
|
915
|
+
void this.check();
|
|
916
|
+
}, INTERFACES_POLL_MS);
|
|
917
|
+
this.#interfacesTimer.unref();
|
|
918
|
+
}
|
|
919
|
+
#stopTimers() {
|
|
920
|
+
if (this.#checkTimer)
|
|
921
|
+
clearInterval(this.#checkTimer);
|
|
922
|
+
if (this.#interfacesTimer)
|
|
923
|
+
clearInterval(this.#interfacesTimer);
|
|
924
|
+
this.#checkTimer = null;
|
|
925
|
+
this.#interfacesTimer = null;
|
|
926
|
+
}
|
|
927
|
+
};
|
|
928
|
+
var networkGuard = new NetworkGuard();
|
|
929
|
+
function traceCountry() {
|
|
930
|
+
return new Promise((resolve) => {
|
|
931
|
+
const req = request(TRACE_URL, { method: "GET", agent: false, timeout: CHECK_TIMEOUT_MS, headers: { "cache-control": "no-store" } }, (res) => {
|
|
932
|
+
let body = "";
|
|
933
|
+
res.setEncoding("utf8");
|
|
934
|
+
res.on("data", (chunk) => {
|
|
935
|
+
body += chunk;
|
|
936
|
+
if (body.length > 16e3)
|
|
937
|
+
req.destroy(new Error("\u0441\u043B\u0438\u0448\u043A\u043E\u043C \u0434\u043B\u0438\u043D\u043D\u044B\u0439 \u043E\u0442\u0432\u0435\u0442"));
|
|
938
|
+
});
|
|
939
|
+
res.on("end", () => {
|
|
940
|
+
const country = /^loc=([A-Z]{2})$/m.exec(body)?.[1];
|
|
941
|
+
if (res.statusCode === 200 && country)
|
|
942
|
+
resolve({ ok: true, country });
|
|
943
|
+
else
|
|
944
|
+
resolve({ ok: false, error: `\u043D\u0435\u043E\u0436\u0438\u0434\u0430\u043D\u043D\u044B\u0439 \u043E\u0442\u0432\u0435\u0442 (HTTP ${res.statusCode ?? "\u2014"})` });
|
|
945
|
+
});
|
|
946
|
+
res.on("error", (error) => resolve({ ok: false, error: error.message }));
|
|
947
|
+
});
|
|
948
|
+
req.on("timeout", () => req.destroy(new Error("\u043D\u0435\u0442 \u043E\u0442\u0432\u0435\u0442\u0430")));
|
|
949
|
+
req.on("error", (error) => resolve({ ok: false, error: error.message }));
|
|
950
|
+
req.end();
|
|
951
|
+
});
|
|
952
|
+
}
|
|
953
|
+
function interfacesSignature() {
|
|
954
|
+
return Object.entries(networkInterfaces()).map(([name, addresses]) => `${name}:${(addresses ?? []).map((a) => a.address).sort().join(",")}`).sort().join("|");
|
|
955
|
+
}
|
|
956
|
+
|
|
790
957
|
// ../host/dist/settings.js
|
|
791
958
|
import { readFile as readFile3 } from "node:fs/promises";
|
|
792
959
|
import { homedir as homedir2 } from "node:os";
|
|
@@ -1176,7 +1343,7 @@ var INTERRUPT_SETTLE_MS = 15e3;
|
|
|
1176
1343
|
var TASK_STOP_TIMEOUT_MS = 5e3;
|
|
1177
1344
|
var TASK_WAKE_MS = 5e3;
|
|
1178
1345
|
var CONTEXT_MIN_INTERVAL_MS = 5e3;
|
|
1179
|
-
var ClaudeSession = class extends
|
|
1346
|
+
var ClaudeSession = class extends EventEmitter2 {
|
|
1180
1347
|
id;
|
|
1181
1348
|
workspaceId;
|
|
1182
1349
|
cwd;
|
|
@@ -1484,6 +1651,8 @@ var ClaudeSession = class extends EventEmitter {
|
|
|
1484
1651
|
* умолчанию) — обычное поведение, ничего не меняется.
|
|
1485
1652
|
*/
|
|
1486
1653
|
#spawn(restarted, resumeAt) {
|
|
1654
|
+
if (this.#refuseOffRoute())
|
|
1655
|
+
return;
|
|
1487
1656
|
const options2 = {
|
|
1488
1657
|
cwd: this.cwd,
|
|
1489
1658
|
// Без этого SDK не читает с диска ничего: ни CLAUDE.md, ни кастомные
|
|
@@ -1668,6 +1837,56 @@ var ClaudeSession = class extends EventEmitter {
|
|
|
1668
1837
|
this.#query = null;
|
|
1669
1838
|
this.#resetTasks();
|
|
1670
1839
|
}
|
|
1840
|
+
/**
|
|
1841
|
+
* Погасить процесс CLI, не закрывая сессию: упал VPN (см. network-guard.ts).
|
|
1842
|
+
*
|
|
1843
|
+
* Идущий ход обрывается вместе с процессом, отложенное переподключение
|
|
1844
|
+
* отменяется, накопленные для повтора промпты забываются — повторить их сам
|
|
1845
|
+
* хост не вправе, решать человеку. Разговор цел: следующий промпт после
|
|
1846
|
+
* возвращения VPN поднимет процесс, продолжающий ту же сессию.
|
|
1847
|
+
*/
|
|
1848
|
+
suspend(reason) {
|
|
1849
|
+
if (this.#closing || this.#state === "closed")
|
|
1850
|
+
return;
|
|
1851
|
+
if (this.#reconnectTimer) {
|
|
1852
|
+
clearTimeout(this.#reconnectTimer);
|
|
1853
|
+
this.#reconnectTimer = null;
|
|
1854
|
+
}
|
|
1855
|
+
this.#pendingRetry = [];
|
|
1856
|
+
if (!this.#query) {
|
|
1857
|
+
if (this.#state === "reconnecting")
|
|
1858
|
+
this.#setState("error");
|
|
1859
|
+
return;
|
|
1860
|
+
}
|
|
1861
|
+
const busy = this.#state !== "idle";
|
|
1862
|
+
this.#teardown(reason);
|
|
1863
|
+
this.#inbox = new AsyncQueue();
|
|
1864
|
+
this.#streamMessageId = null;
|
|
1865
|
+
this.#blockCounts.clear();
|
|
1866
|
+
if (busy)
|
|
1867
|
+
this.#lastTurn = "interrupted";
|
|
1868
|
+
this.#record({
|
|
1869
|
+
kind: "error",
|
|
1870
|
+
message: `${reason}. \u041F\u0440\u043E\u0446\u0435\u0441\u0441 Claude \u043E\u0441\u0442\u0430\u043D\u043E\u0432\u043B\u0435\u043D${busy ? ", \u0445\u043E\u0434 \u043F\u0440\u0435\u0440\u0432\u0430\u043D" : ""}. \u0420\u0430\u0437\u0433\u043E\u0432\u043E\u0440 \u0441\u043E\u0445\u0440\u0430\u043D\u0451\u043D \u2014 \u043A\u043E\u0433\u0434\u0430 VPN \u0432\u0435\u0440\u043D\u0451\u0442\u0441\u044F, \u043E\u0442\u043F\u0440\u0430\u0432\u044C\u0442\u0435 \u043F\u0440\u043E\u043C\u043F\u0442, \u0438 \u0441\u0435\u0441\u0441\u0438\u044F \u043F\u0440\u043E\u0434\u043E\u043B\u0436\u0438\u0442.`
|
|
1871
|
+
});
|
|
1872
|
+
this.#setState("error");
|
|
1873
|
+
}
|
|
1874
|
+
/**
|
|
1875
|
+
* Нет VPN — процесс не поднимаем: пишем об этом в ленту и оставляем сессию
|
|
1876
|
+
* без процесса. Следующий промпт попробует снова.
|
|
1877
|
+
*/
|
|
1878
|
+
#refuseOffRoute() {
|
|
1879
|
+
const blocked = networkGuard.blockedReason();
|
|
1880
|
+
if (!blocked)
|
|
1881
|
+
return false;
|
|
1882
|
+
this.#pendingRetry = [];
|
|
1883
|
+
this.#record({
|
|
1884
|
+
kind: "error",
|
|
1885
|
+
message: `${blocked}. \u041F\u0440\u043E\u0446\u0435\u0441\u0441 Claude \u043D\u0435 \u0437\u0430\u043F\u0443\u0449\u0435\u043D \u2014 \u043E\u0442\u043F\u0440\u0430\u0432\u044C\u0442\u0435 \u043F\u0440\u043E\u043C\u043F\u0442, \u043A\u043E\u0433\u0434\u0430 VPN \u0432\u0435\u0440\u043D\u0451\u0442\u0441\u044F.`
|
|
1886
|
+
});
|
|
1887
|
+
this.#setState("error");
|
|
1888
|
+
return true;
|
|
1889
|
+
}
|
|
1671
1890
|
// -------------------------------------------------------------------------
|
|
1672
1891
|
// Переподключение
|
|
1673
1892
|
// -------------------------------------------------------------------------
|
|
@@ -1697,6 +1916,8 @@ var ClaudeSession = class extends EventEmitter {
|
|
|
1697
1916
|
clearTimeout(this.#reconnectTimer);
|
|
1698
1917
|
this.#reconnectTimer = null;
|
|
1699
1918
|
}
|
|
1919
|
+
if (this.#refuseOffRoute())
|
|
1920
|
+
return;
|
|
1700
1921
|
this.#setState("reconnecting");
|
|
1701
1922
|
this.#teardown("\u043F\u0435\u0440\u0435\u043F\u043E\u0434\u043A\u043B\u044E\u0447\u0435\u043D\u0438\u0435");
|
|
1702
1923
|
this.#inbox = new AsyncQueue();
|
|
@@ -1751,6 +1972,9 @@ var ClaudeSession = class extends EventEmitter {
|
|
|
1751
1972
|
sendPrompt(text, images, service = false) {
|
|
1752
1973
|
if (this.#closing)
|
|
1753
1974
|
throw new Error("session is closed");
|
|
1975
|
+
const blocked = networkGuard.blockedReason();
|
|
1976
|
+
if (blocked)
|
|
1977
|
+
throw new Error(`${blocked}. \u041F\u0440\u043E\u043C\u043F\u0442 \u043D\u0435 \u043E\u0442\u043F\u0440\u0430\u0432\u043B\u0435\u043D.`);
|
|
1754
1978
|
this.#record({ kind: "user.message", text, images });
|
|
1755
1979
|
if (!service && (!this.#title || this.#titleIsDefault)) {
|
|
1756
1980
|
this.#title = text.slice(0, 80);
|
|
@@ -1788,6 +2012,9 @@ var ClaudeSession = class extends EventEmitter {
|
|
|
1788
2012
|
async editPrompt(userIndex, text, images) {
|
|
1789
2013
|
if (this.#closing)
|
|
1790
2014
|
throw new Error("session is closed");
|
|
2015
|
+
const blocked = networkGuard.blockedReason();
|
|
2016
|
+
if (blocked)
|
|
2017
|
+
throw new Error(`${blocked}. \u041F\u0440\u0430\u0432\u043A\u0430 \u043D\u0435 \u043E\u0442\u043F\u0440\u0430\u0432\u043B\u0435\u043D\u0430.`);
|
|
1791
2018
|
if (this.#state === "running")
|
|
1792
2019
|
await this.interrupt();
|
|
1793
2020
|
const source = this.#claudeSessionId ?? this.#options.resume;
|
|
@@ -2905,7 +3132,7 @@ function contentToText2(content) {
|
|
|
2905
3132
|
}
|
|
2906
3133
|
|
|
2907
3134
|
// ../host/dist/antigravity-session.js
|
|
2908
|
-
import { EventEmitter as
|
|
3135
|
+
import { EventEmitter as EventEmitter3 } from "node:events";
|
|
2909
3136
|
import { spawn as spawn2, execFile as execFile3 } from "node:child_process";
|
|
2910
3137
|
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
2911
3138
|
import { mkdir as mkdir2, writeFile as writeFile2 } from "node:fs/promises";
|
|
@@ -3125,7 +3352,7 @@ function agyContextWindow(model) {
|
|
|
3125
3352
|
|
|
3126
3353
|
// ../host/dist/antigravity-session.js
|
|
3127
3354
|
var TRANSIENT = /* @__PURE__ */ new Set(["assistant.delta", "thinking.delta", "state"]);
|
|
3128
|
-
var AntigravitySession = class extends
|
|
3355
|
+
var AntigravitySession = class extends EventEmitter3 {
|
|
3129
3356
|
id;
|
|
3130
3357
|
workspaceId;
|
|
3131
3358
|
cwd;
|
|
@@ -3265,6 +3492,8 @@ var AntigravitySession = class extends EventEmitter2 {
|
|
|
3265
3492
|
}
|
|
3266
3493
|
this.#capabilities = this.#baseCapabilities();
|
|
3267
3494
|
this.emit("capabilities");
|
|
3495
|
+
if (this.#refuseOffRoute())
|
|
3496
|
+
return;
|
|
3268
3497
|
void agyModels(this.#executable).then((models) => {
|
|
3269
3498
|
if (!this.#capabilities || models.length === 0)
|
|
3270
3499
|
return;
|
|
@@ -3323,6 +3552,8 @@ var AntigravitySession = class extends EventEmitter2 {
|
|
|
3323
3552
|
#spawn() {
|
|
3324
3553
|
if (!this.#executable || this.#closing)
|
|
3325
3554
|
return;
|
|
3555
|
+
if (this.#refuseOffRoute())
|
|
3556
|
+
return;
|
|
3326
3557
|
let child;
|
|
3327
3558
|
try {
|
|
3328
3559
|
child = spawn2(this.#executable, this.#args(), {
|
|
@@ -3420,12 +3651,48 @@ var AntigravitySession = class extends EventEmitter2 {
|
|
|
3420
3651
|
reconnect(_reason) {
|
|
3421
3652
|
this.#restart();
|
|
3422
3653
|
}
|
|
3654
|
+
/**
|
|
3655
|
+
* Погасить процесс `agy`, не закрывая сессию: упал VPN (см.
|
|
3656
|
+
* network-guard.ts). Следующий промпт после его возвращения поднимет
|
|
3657
|
+
* процесс на том же разговоре.
|
|
3658
|
+
*/
|
|
3659
|
+
suspend(reason) {
|
|
3660
|
+
if (this.#closing || this.#state === "closed" || !this.#child)
|
|
3661
|
+
return;
|
|
3662
|
+
const busy = this.#pendingTurns > 0;
|
|
3663
|
+
this.#restartPending = false;
|
|
3664
|
+
this.#kill();
|
|
3665
|
+
this.#closeOpenSteps();
|
|
3666
|
+
this.#pendingTurns = 0;
|
|
3667
|
+
if (busy)
|
|
3668
|
+
this.#lastTurn = "interrupted";
|
|
3669
|
+
this.#record_({
|
|
3670
|
+
kind: "error",
|
|
3671
|
+
message: `${reason}. \u041F\u0440\u043E\u0446\u0435\u0441\u0441 Antigravity \u043E\u0441\u0442\u0430\u043D\u043E\u0432\u043B\u0435\u043D${busy ? ", \u0445\u043E\u0434 \u043F\u0440\u0435\u0440\u0432\u0430\u043D" : ""}. \u0420\u0430\u0437\u0433\u043E\u0432\u043E\u0440 \u0441\u043E\u0445\u0440\u0430\u043D\u0451\u043D \u2014 \u043A\u043E\u0433\u0434\u0430 VPN \u0432\u0435\u0440\u043D\u0451\u0442\u0441\u044F, \u043E\u0442\u043F\u0440\u0430\u0432\u044C\u0442\u0435 \u043F\u0440\u043E\u043C\u043F\u0442, \u0438 \u0441\u0435\u0441\u0441\u0438\u044F \u043F\u0440\u043E\u0434\u043E\u043B\u0436\u0438\u0442.`
|
|
3672
|
+
});
|
|
3673
|
+
this.#setState("error");
|
|
3674
|
+
}
|
|
3675
|
+
/** Нет VPN — процесс не поднимаем, пишем об этом в ленту. */
|
|
3676
|
+
#refuseOffRoute() {
|
|
3677
|
+
const blocked = networkGuard.blockedReason();
|
|
3678
|
+
if (!blocked)
|
|
3679
|
+
return false;
|
|
3680
|
+
this.#record_({
|
|
3681
|
+
kind: "error",
|
|
3682
|
+
message: `${blocked}. \u041F\u0440\u043E\u0446\u0435\u0441\u0441 Antigravity \u043D\u0435 \u0437\u0430\u043F\u0443\u0449\u0435\u043D \u2014 \u043E\u0442\u043F\u0440\u0430\u0432\u044C\u0442\u0435 \u043F\u0440\u043E\u043C\u043F\u0442, \u043A\u043E\u0433\u0434\u0430 VPN \u0432\u0435\u0440\u043D\u0451\u0442\u0441\u044F.`
|
|
3683
|
+
});
|
|
3684
|
+
this.#setState("error");
|
|
3685
|
+
return true;
|
|
3686
|
+
}
|
|
3423
3687
|
// -------------------------------------------------------------------------
|
|
3424
3688
|
// Ввод
|
|
3425
3689
|
// -------------------------------------------------------------------------
|
|
3426
3690
|
sendPrompt(text, images) {
|
|
3427
3691
|
if (this.#closing)
|
|
3428
3692
|
throw new Error("session is closed");
|
|
3693
|
+
const blocked = networkGuard.blockedReason();
|
|
3694
|
+
if (blocked)
|
|
3695
|
+
throw new Error(`${blocked}. \u041F\u0440\u043E\u043C\u043F\u0442 \u043D\u0435 \u043E\u0442\u043F\u0440\u0430\u0432\u043B\u0435\u043D.`);
|
|
3429
3696
|
const command = /^\/([\w-]+)(?:\s+([\s\S]*))?$/.exec(text.trim());
|
|
3430
3697
|
if (command && AGY_CLI_COMMANDS.has(command[1]) && (!images || images.length === 0)) {
|
|
3431
3698
|
void this.#runCliCommand(text, command[1], command[2]?.trim() ?? "");
|
|
@@ -3642,7 +3909,7 @@ Attached image${paths.length > 1 ? "s" : ""} (view them with your file viewing t
|
|
|
3642
3909
|
}
|
|
3643
3910
|
/** Квота `agy` (`/usage`) — общая на аккаунт, кэш один на хост. */
|
|
3644
3911
|
async refreshUsage(force = false) {
|
|
3645
|
-
if (!this.#executable)
|
|
3912
|
+
if (!this.#executable || networkGuard.blockedReason())
|
|
3646
3913
|
return;
|
|
3647
3914
|
const usage = await agyUsage(this.#executable, force);
|
|
3648
3915
|
if (!usage)
|
|
@@ -6155,6 +6422,7 @@ var MIN_AUTO_ARCHIVE_AFTER_MS = 60 * 60 * 1e3;
|
|
|
6155
6422
|
var DEFAULT_AUTO_STOP_AFTER_MS = 10 * 60 * 1e3;
|
|
6156
6423
|
var MIN_AUTO_STOP_AFTER_MS = 60 * 1e3;
|
|
6157
6424
|
var MIN_AUTO_SAVE_AFTER_PAUSE_MS = 500;
|
|
6425
|
+
var DEFAULT_BLOCKED_COUNTRIES = ["RU", "BY", "CN", "IR", "KP", "SY", "CU"];
|
|
6158
6426
|
var FOLDER_ACCESS = ["all", "projects", "project"];
|
|
6159
6427
|
var PROVIDERS = ["claude", "antigravity"];
|
|
6160
6428
|
var PERMISSION_MODES = [
|
|
@@ -6191,7 +6459,11 @@ var DEFAULT_APP_SETTINGS = {
|
|
|
6191
6459
|
limitStopFiveHourPct: 95,
|
|
6192
6460
|
limitStopSevenDayPct: 99,
|
|
6193
6461
|
// Оба: до появления настройки приложение предлагало обоих агентов.
|
|
6194
|
-
enabledProviders: ["claude", "antigravity"]
|
|
6462
|
+
enabledProviders: ["claude", "antigravity"],
|
|
6463
|
+
// Включено: запрос без VPN может стоить аккаунта, а тому, у кого маршрут и
|
|
6464
|
+
// так из разрешённой страны, защита ничем не мешает.
|
|
6465
|
+
networkGuardEnabled: true,
|
|
6466
|
+
networkGuardBlockedCountries: DEFAULT_BLOCKED_COUNTRIES
|
|
6195
6467
|
};
|
|
6196
6468
|
var AppSettingsStore = class {
|
|
6197
6469
|
#settings = { ...DEFAULT_APP_SETTINGS };
|
|
@@ -6276,6 +6548,15 @@ function sanitize2(value, fallback) {
|
|
|
6276
6548
|
if (picked.length > 0)
|
|
6277
6549
|
result.enabledProviders = picked;
|
|
6278
6550
|
}
|
|
6551
|
+
if (typeof record.networkGuardEnabled === "boolean") {
|
|
6552
|
+
result.networkGuardEnabled = record.networkGuardEnabled;
|
|
6553
|
+
}
|
|
6554
|
+
const countries = record.networkGuardBlockedCountries;
|
|
6555
|
+
if (Array.isArray(countries)) {
|
|
6556
|
+
result.networkGuardBlockedCountries = [
|
|
6557
|
+
...new Set(countries.filter((c) => typeof c === "string").map((c) => c.trim().toUpperCase()).filter((c) => /^[A-Z]{2}$/.test(c)))
|
|
6558
|
+
];
|
|
6559
|
+
}
|
|
6279
6560
|
return result;
|
|
6280
6561
|
}
|
|
6281
6562
|
function claudeHome() {
|
|
@@ -6635,7 +6916,7 @@ function authorName(raw) {
|
|
|
6635
6916
|
}
|
|
6636
6917
|
|
|
6637
6918
|
// ../host/dist/auth.js
|
|
6638
|
-
import { EventEmitter as
|
|
6919
|
+
import { EventEmitter as EventEmitter4 } from "node:events";
|
|
6639
6920
|
var QUICK_TIMEOUT_MS = 3e4;
|
|
6640
6921
|
var LOGIN_TIMEOUT_MS = 10 * 6e4;
|
|
6641
6922
|
var URL_RE = /https:\/\/\S*\/oauth\/authorize\S*/;
|
|
@@ -6647,7 +6928,7 @@ var IDLE = {
|
|
|
6647
6928
|
output: "",
|
|
6648
6929
|
error: null
|
|
6649
6930
|
};
|
|
6650
|
-
var AuthCli = class extends
|
|
6931
|
+
var AuthCli = class extends EventEmitter4 {
|
|
6651
6932
|
#child = null;
|
|
6652
6933
|
#state = IDLE;
|
|
6653
6934
|
#timer = null;
|
|
@@ -6832,7 +7113,7 @@ function describe5(error) {
|
|
|
6832
7113
|
}
|
|
6833
7114
|
|
|
6834
7115
|
// ../host/dist/relay-link.js
|
|
6835
|
-
import { EventEmitter as
|
|
7116
|
+
import { EventEmitter as EventEmitter5 } from "node:events";
|
|
6836
7117
|
import { readFile as readFile15, writeFile as writeFile13, rm as rm5, mkdir as mkdir12 } from "node:fs/promises";
|
|
6837
7118
|
import path20 from "node:path";
|
|
6838
7119
|
import { hostname } from "node:os";
|
|
@@ -6851,7 +7132,7 @@ var SILENCE_TIMEOUT_MS = 95e3;
|
|
|
6851
7132
|
function jitter(delay2) {
|
|
6852
7133
|
return Math.round(delay2 * (0.8 + Math.random() * 0.4));
|
|
6853
7134
|
}
|
|
6854
|
-
var RelayLink = class extends
|
|
7135
|
+
var RelayLink = class extends EventEmitter5 {
|
|
6855
7136
|
#credentials = null;
|
|
6856
7137
|
#socket = null;
|
|
6857
7138
|
#retry = RETRY_MIN_MS;
|
|
@@ -7239,14 +7520,14 @@ function humanize(error) {
|
|
|
7239
7520
|
}
|
|
7240
7521
|
|
|
7241
7522
|
// ../host/dist/terminal.js
|
|
7242
|
-
import { EventEmitter as
|
|
7523
|
+
import { EventEmitter as EventEmitter6 } from "node:events";
|
|
7243
7524
|
import { access as access2, constants as constants2 } from "node:fs/promises";
|
|
7244
7525
|
import path21 from "node:path";
|
|
7245
7526
|
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
7246
7527
|
var SCROLLBACK_BYTES = 256 * 1024;
|
|
7247
7528
|
var FLUSH_MS = 12;
|
|
7248
7529
|
var MAX_TERMINALS = 24;
|
|
7249
|
-
var TerminalHub = class extends
|
|
7530
|
+
var TerminalHub = class extends EventEmitter6 {
|
|
7250
7531
|
#terminals = /* @__PURE__ */ new Map();
|
|
7251
7532
|
#module = null;
|
|
7252
7533
|
list(workspaceId) {
|
|
@@ -7680,6 +7961,7 @@ var HostServer = class {
|
|
|
7680
7961
|
await this.#folders.load();
|
|
7681
7962
|
await this.#carryOverWorkspaceIds();
|
|
7682
7963
|
await this.#settings.load();
|
|
7964
|
+
this.#wireNetworkGuard();
|
|
7683
7965
|
await this.#limitStop.load();
|
|
7684
7966
|
await this.#github.load();
|
|
7685
7967
|
await warmClaudeLauncher();
|
|
@@ -7708,7 +7990,25 @@ var HostServer = class {
|
|
|
7708
7990
|
this.#limitTimer = setInterval(() => this.#sweepUsage(), LIMIT_SWEEP_MS);
|
|
7709
7991
|
this.#limitTimer.unref();
|
|
7710
7992
|
}
|
|
7993
|
+
/**
|
|
7994
|
+
* Защита от запросов без VPN (см. network-guard.ts): при блоке гасим
|
|
7995
|
+
* процессы всех живых сессий — идущий ход шлёт запрос за запросом, и
|
|
7996
|
+
* дожидаться его конца нельзя.
|
|
7997
|
+
*/
|
|
7998
|
+
#wireNetworkGuard() {
|
|
7999
|
+
networkGuard.on("change", (state) => {
|
|
8000
|
+
this.#broadcast({ type: "network.state", state });
|
|
8001
|
+
if (state.status !== "blocked")
|
|
8002
|
+
return;
|
|
8003
|
+
const reason = state.reason ?? "VPN \u043D\u0435 \u0440\u0430\u0431\u043E\u0442\u0430\u0435\u0442";
|
|
8004
|
+
for (const session of this.#sessions.values())
|
|
8005
|
+
session.suspend(reason);
|
|
8006
|
+
});
|
|
8007
|
+
const { networkGuardEnabled, networkGuardBlockedCountries } = this.#settings.current;
|
|
8008
|
+
networkGuard.configure(networkGuardEnabled, networkGuardBlockedCountries);
|
|
8009
|
+
}
|
|
7711
8010
|
async shutdown() {
|
|
8011
|
+
networkGuard.stop();
|
|
7712
8012
|
if (this.#autoStopTimer)
|
|
7713
8013
|
clearInterval(this.#autoStopTimer);
|
|
7714
8014
|
this.#autoStopTimer = null;
|
|
@@ -7876,6 +8176,7 @@ var HostServer = class {
|
|
|
7876
8176
|
this.#sendLive(socket);
|
|
7877
8177
|
this.#auth.status().then((status) => this.#send(socket, { type: "auth.status", status })).catch(() => void 0);
|
|
7878
8178
|
this.#send(socket, { type: "relay.state", state: this.#relay.state });
|
|
8179
|
+
this.#send(socket, { type: "network.state", state: networkGuard.state });
|
|
7879
8180
|
return;
|
|
7880
8181
|
case "ping":
|
|
7881
8182
|
this.#send(socket, { type: "pong", nonce: frame.nonce });
|
|
@@ -7921,6 +8222,7 @@ var HostServer = class {
|
|
|
7921
8222
|
return;
|
|
7922
8223
|
}
|
|
7923
8224
|
case "workspace.find.agent":
|
|
8225
|
+
await networkGuard.ensureFresh();
|
|
7924
8226
|
this.#findWithAgent(frame.query);
|
|
7925
8227
|
return;
|
|
7926
8228
|
case "workspace.roots":
|
|
@@ -8135,10 +8437,12 @@ var HostServer = class {
|
|
|
8135
8437
|
return;
|
|
8136
8438
|
}
|
|
8137
8439
|
case "prompt.send":
|
|
8440
|
+
await networkGuard.ensureFresh();
|
|
8138
8441
|
this.#approveAfterLimit(frame.sessionId);
|
|
8139
8442
|
this.#requireSession(frame.sessionId).sendPrompt(frame.text, frame.images);
|
|
8140
8443
|
return;
|
|
8141
8444
|
case "prompt.edit":
|
|
8445
|
+
await networkGuard.ensureFresh();
|
|
8142
8446
|
this.#approveAfterLimit(frame.sessionId);
|
|
8143
8447
|
await this.#requireSession(frame.sessionId).editPrompt(frame.userIndex, frame.text, frame.images);
|
|
8144
8448
|
return;
|
|
@@ -8146,6 +8450,7 @@ var HostServer = class {
|
|
|
8146
8450
|
this.#requireSession(frame.sessionId).respondPermission(frame.requestId, frame.decision, frame.reason, frame.answers, frame.annotations, frame.plan);
|
|
8147
8451
|
return;
|
|
8148
8452
|
case "side.ask":
|
|
8453
|
+
await networkGuard.ensureFresh();
|
|
8149
8454
|
this.#ensureSide(this.#requireSession(frame.sessionId)).sendPrompt(frame.text);
|
|
8150
8455
|
return;
|
|
8151
8456
|
// Поднять форк, ничего не спрашивая: клиенту нужен его id, чтобы
|
|
@@ -8560,6 +8865,7 @@ var HostServer = class {
|
|
|
8560
8865
|
await this.#sendSessionList(workspace.id);
|
|
8561
8866
|
}
|
|
8562
8867
|
}
|
|
8868
|
+
networkGuard.configure(settings.networkGuardEnabled, settings.networkGuardBlockedCountries);
|
|
8563
8869
|
if (before.terminalEnabled && !settings.terminalEnabled) {
|
|
8564
8870
|
for (const terminal of this.#terminals.list()) {
|
|
8565
8871
|
this.#terminals.close(terminal.id);
|
|
@@ -8572,9 +8878,13 @@ var HostServer = class {
|
|
|
8572
8878
|
this.#send(socket, { type: "auth.status", status: await this.#auth.status() });
|
|
8573
8879
|
this.#send(socket, { type: "auth.login", state: this.#auth.loginState });
|
|
8574
8880
|
return;
|
|
8575
|
-
case "auth.login":
|
|
8881
|
+
case "auth.login": {
|
|
8882
|
+
const blocked = (await networkGuard.ensureFresh()).status === "blocked";
|
|
8883
|
+
if (blocked)
|
|
8884
|
+
throw new Error(`${networkGuard.blockedReason()}. \u0412\u0445\u043E\u0434 \u043E\u0442\u043B\u043E\u0436\u0435\u043D.`);
|
|
8576
8885
|
await this.#auth.login(frame.mode, frame.switchAccount === true);
|
|
8577
8886
|
return;
|
|
8887
|
+
}
|
|
8578
8888
|
case "auth.code":
|
|
8579
8889
|
this.#auth.submitCode(frame.code);
|
|
8580
8890
|
return;
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{s as r,H as a}from"./index-
|
|
1
|
+
import{s as r,H as a}from"./index-wsSNo9PM.js";import{E as e}from"./index-891wE-Rj.js";import{t as o}from"./index-BCLbqlhA.js";import"./index-BHot-lnj.js";const m=e.theme({"&":{height:"100%",color:"var(--text)",backgroundColor:"var(--bg)",fontSize:"13px"},".cm-scroller":{fontFamily:"var(--mono)",lineHeight:"1.6"},".cm-content":{caretColor:"var(--accent)"},".cm-cursor, .cm-dropCursor":{borderLeftColor:"var(--accent)"},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:"var(--cm-selection)"},".cm-gutters":{backgroundColor:"var(--bg)",color:"var(--muted)",borderRight:"1px solid var(--border-soft)"},".cm-activeLineGutter":{backgroundColor:"var(--surface-2)",color:"var(--text-2)"},".cm-activeLine":{backgroundColor:"var(--cm-active)"},".cm-selectionMatch":{backgroundColor:"var(--cm-match)"},"&.cm-focused .cm-matchingBracket":{backgroundColor:"var(--cm-match)",outline:"1px solid var(--accent-line)"},".cm-foldPlaceholder":{backgroundColor:"var(--surface-2)",border:"1px solid var(--border)",color:"var(--muted)"},".cm-panels":{backgroundColor:"var(--surface)",color:"var(--text)",border:"1px solid var(--border)"},".cm-panels input, .cm-panels button, .cm-panels select":{fontFamily:"var(--sans)",fontSize:"12px",background:"var(--surface-2)",color:"var(--text)",border:"1px solid var(--border)",borderRadius:"6px",padding:"3px 6px"},".cm-searchMatch":{backgroundColor:"var(--cm-match)"},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:"var(--accent-soft)"},".cm-tooltip":{background:"var(--surface)",border:"1px solid var(--border)",borderRadius:"8px",boxShadow:"var(--shadow-md)",color:"var(--text)"},".cm-tooltip-autocomplete ul li[aria-selected]":{background:"var(--surface-2)",color:"var(--text)"}}),i=r(a.define([{tag:[o.keyword,o.modifier,o.controlKeyword,o.moduleKeyword],color:"var(--cm-key)"},{tag:[o.name,o.deleted,o.character,o.macroName],color:"var(--text)"},{tag:[o.propertyName],color:"var(--cm-prop)"},{tag:[o.function(o.variableName),o.labelName],color:"var(--cm-fn)"},{tag:[o.color,o.constant(o.name),o.standard(o.name),o.bool],color:"var(--cm-const)"},{tag:[o.definition(o.name),o.separator],color:"var(--text)"},{tag:[o.typeName,o.className,o.changed,o.annotation,o.self,o.namespace],color:"var(--cm-type)"},{tag:[o.number,o.integer,o.float],color:"var(--cm-num)"},{tag:[o.string,o.special(o.string),o.regexp],color:"var(--cm-str)"},{tag:[o.operator,o.operatorKeyword,o.escape],color:"var(--cm-op)"},{tag:[o.meta,o.comment],color:"var(--cm-comment)",fontStyle:"italic"},{tag:o.strong,fontWeight:"650"},{tag:o.emphasis,fontStyle:"italic"},{tag:o.strikethrough,textDecoration:"line-through"},{tag:o.link,color:"var(--cm-str)",textDecoration:"underline"},{tag:o.heading,fontWeight:"650",color:"var(--cm-key)"},{tag:o.invalid,color:"var(--danger)"}]));export{i as editorHighlight,m as editorTheme};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{Prec as st,EditorSelection as P,countColumn as z,EditorState as it}from"./index-BHot-lnj.js";import{n as ot,E as at}from"./index-891wE-Rj.js";import{L as fe,q as lt,e as X,r as ht,j as ft,t as ut,o as Ee,l as dt,u as pt,v as ue,P as ct}from"./index-BTHa3RWC.js";import{C as mt}from"./index-CwbKEdO4.js";import{P as gt,a as Q,N as v,T as kt,b as Ie,s as Me,c as H,p as Lt,t as m}from"./index-L8M_w2e-.js";import{html as bt,htmlCompletionSource as wt}from"./index-BUtKkXYx.js";import"./index-BSbB9pNN.js";import"./index-C4RL1RRN.js";import"./index-B5EnmuL9.js";class U{static create(e,r,n,s,i){let o=s+(s<<8)+e+(r<<4)|0;return new U(e,r,n,o,i,[],[])}constructor(e,r,n,s,i,o,a){this.type=e,this.value=r,this.from=n,this.hash=s,this.end=i,this.children=o,this.positions=a,this.hashProp=[[v.contextHash,s]]}addChild(e,r){e.prop(v.contextHash)!=this.hash&&(e=new H(e.type,e.children,e.positions,e.length,this.hashProp)),this.children.push(e),this.positions.push(r)}toTree(e,r=this.end){let n=this.children.length-1;return n>=0&&(r=Math.max(r,this.positions[n]+this.children[n].length+this.from)),new H(e.types[this.type],this.children,this.positions,r-this.from).balance({makeTree:(s,i,o)=>new H(Q.none,s,i,o,this.hashProp)})}}var u;(function(t){t[t.Document=1]="Document",t[t.CodeBlock=2]="CodeBlock",t[t.FencedCode=3]="FencedCode",t[t.Blockquote=4]="Blockquote",t[t.HorizontalRule=5]="HorizontalRule",t[t.BulletList=6]="BulletList",t[t.OrderedList=7]="OrderedList",t[t.ListItem=8]="ListItem",t[t.ATXHeading1=9]="ATXHeading1",t[t.ATXHeading2=10]="ATXHeading2",t[t.ATXHeading3=11]="ATXHeading3",t[t.ATXHeading4=12]="ATXHeading4",t[t.ATXHeading5=13]="ATXHeading5",t[t.ATXHeading6=14]="ATXHeading6",t[t.SetextHeading1=15]="SetextHeading1",t[t.SetextHeading2=16]="SetextHeading2",t[t.HTMLBlock=17]="HTMLBlock",t[t.LinkReference=18]="LinkReference",t[t.Paragraph=19]="Paragraph",t[t.CommentBlock=20]="CommentBlock",t[t.ProcessingInstructionBlock=21]="ProcessingInstructionBlock",t[t.Escape=22]="Escape",t[t.Entity=23]="Entity",t[t.HardBreak=24]="HardBreak",t[t.Emphasis=25]="Emphasis",t[t.StrongEmphasis=26]="StrongEmphasis",t[t.Link=27]="Link",t[t.Image=28]="Image",t[t.InlineCode=29]="InlineCode",t[t.HTMLTag=30]="HTMLTag",t[t.Comment=31]="Comment",t[t.ProcessingInstruction=32]="ProcessingInstruction",t[t.Autolink=33]="Autolink",t[t.HeaderMark=34]="HeaderMark",t[t.QuoteMark=35]="QuoteMark",t[t.ListMark=36]="ListMark",t[t.LinkMark=37]="LinkMark",t[t.EmphasisMark=38]="EmphasisMark",t[t.CodeMark=39]="CodeMark",t[t.CodeText=40]="CodeText",t[t.CodeInfo=41]="CodeInfo",t[t.LinkTitle=42]="LinkTitle",t[t.LinkLabel=43]="LinkLabel",t[t.URL=44]="URL"})(u||(u={}));class St{constructor(e,r){this.start=e,this.content=r,this.marks=[],this.parsers=[]}}class Ct{constructor(){this.text="",this.baseIndent=0,this.basePos=0,this.depth=0,this.markers=[],this.pos=0,this.indent=0,this.next=-1}forward(){this.basePos>this.pos&&this.forwardInner()}forwardInner(){let e=this.skipSpace(this.basePos);this.indent=this.countIndent(e,this.pos,this.indent),this.pos=e,this.next=e==this.text.length?-1:this.text.charCodeAt(e)}skipSpace(e){return O(this.text,e)}reset(e){for(this.text=e,this.baseIndent=this.basePos=this.pos=this.indent=0,this.forwardInner(),this.depth=1;this.markers.length;)this.markers.pop()}moveBase(e){this.basePos=e,this.baseIndent=this.countIndent(e,this.pos,this.indent)}moveBaseColumn(e){this.baseIndent=e,this.basePos=this.findColumn(e)}addMarker(e){this.markers.push(e)}countIndent(e,r=0,n=0){for(let s=r;s<e;s++)n+=this.text.charCodeAt(s)==9?4-n%4:1;return n}findColumn(e){let r=0;for(let n=0;r<this.text.length&&n<e;r++)n+=this.text.charCodeAt(r)==9?4-n%4:1;return r}scrub(){if(!this.baseIndent)return this.text;let e="";for(let r=0;r<this.basePos;r++)e+=" ";return e+this.text.slice(this.basePos)}}function de(t,e,r){if(r.pos==r.text.length||t!=e.block&&r.indent>=e.stack[r.depth+1].value+r.baseIndent)return!0;if(r.indent>=r.baseIndent+4)return!1;let n=(t.type==u.OrderedList?oe:ie)(r,e,!1);return n>0&&(t.type!=u.BulletList||se(r,e,!1)<0)&&r.text.charCodeAt(r.pos+n-1)==t.value}const He={[u.Blockquote](t,e,r){return r.next!=62?!1:(r.markers.push(k(u.QuoteMark,e.lineStart+r.pos,e.lineStart+r.pos+1)),r.moveBase(r.pos+(x(r.text.charCodeAt(r.pos+1))?2:1)),t.end=e.lineStart+r.text.length,!0)},[u.ListItem](t,e,r){return r.indent<r.baseIndent+t.value&&r.next>-1?!1:(r.moveBaseColumn(r.baseIndent+t.value),!0)},[u.OrderedList]:de,[u.BulletList]:de,[u.Document](){return!0}};function x(t){return t==32||t==9||t==10||t==13}function O(t,e=0){for(;e<t.length&&x(t.charCodeAt(e));)e++;return e}function pe(t,e,r){for(;e>r&&x(t.charCodeAt(e-1));)e--;return e}function Pe(t){if(t.next!=96&&t.next!=126)return-1;let e=t.pos+1;for(;e<t.text.length&&t.text.charCodeAt(e)==t.next;)e++;if(e<t.pos+3)return-1;if(t.next==96){for(let r=e;r<t.text.length;r++)if(t.text.charCodeAt(r)==96)return-1}return e}function ve(t){return t.next!=62?-1:t.text.charCodeAt(t.pos+1)==32?2:1}function se(t,e,r){if(t.next!=42&&t.next!=45&&t.next!=95)return-1;let n=1;for(let s=t.pos+1;s<t.text.length;s++){let i=t.text.charCodeAt(s);if(i==t.next)n++;else if(!x(i))return-1}return r&&t.next==45&&Re(t)>-1&&t.depth==e.stack.length&&e.parser.leafBlockParsers.indexOf(De.SetextHeading)>-1||n<3?-1:1}function Ne(t,e){for(let r=t.stack.length-1;r>=0;r--)if(t.stack[r].type==e)return!0;return!1}function ie(t,e,r){return(t.next==45||t.next==43||t.next==42)&&(t.pos==t.text.length-1||x(t.text.charCodeAt(t.pos+1)))&&(!r||Ne(e,u.BulletList)||t.skipSpace(t.pos+2)<t.text.length)?1:-1}function oe(t,e,r){let n=t.pos,s=t.next;for(;s>=48&&s<=57;){n++;if(n==t.text.length)return-1;s=t.text.charCodeAt(n)}return n==t.pos||n>t.pos+9||s!=46&&s!=41||n<t.text.length-1&&!x(t.text.charCodeAt(n+1))||r&&!Ne(e,u.OrderedList)&&(t.skipSpace(n+1)==t.text.length||n>t.pos+1||t.next!=49)?-1:n+1-t.pos}function ye(t){if(t.next!=35)return-1;let e=t.pos+1;for(;e<t.text.length&&t.text.charCodeAt(e)==35;)e++;if(e<t.text.length&&t.text.charCodeAt(e)!=32)return-1;let r=e-t.pos;return r>6?-1:r}function Re(t){if(t.next!=45&&t.next!=61||t.indent>=t.baseIndent+4)return-1;let e=t.pos+1;for(;e<t.text.length&&t.text.charCodeAt(e)==t.next;)e++;let r=e;for(;e<t.text.length&&x(t.text.charCodeAt(e));)e++;return e==t.text.length?r:-1}const W=/^[ \t]*$/,Oe=/-->/,Te=/\?>/,ee=[[/^<(?:script|pre|style)(?:\s|>|$)/i,/<\/(?:script|pre|style)>/i],[/^\s*<!--/,Oe],[/^\s*<\?/,Te],[/^\s*<![A-Z]/,/>/],[/^\s*<!\[CDATA\[/,/\]\]>/],[/^\s*<\/?(?:address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h1|h2|h3|h4|h5|h6|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul)(?:\s|\/?>|$)/i,W],[/^\s*(?:<\/[a-z][\w-]*\s*>|<[a-z][\w-]*(\s+[a-z:_][\w-.]*(?:\s*=\s*(?:[^\s"'=<>`]+|'[^']*'|"[^"]*"))?)*\s*>)\s*$/i,W]];function ze(t,e,r){if(t.next!=60)return-1;let n=t.text.slice(t.pos);for(let s=0,i=ee.length-(r?1:0);s<i;s++)if(ee[s][0].test(n))return s;return-1}function ce(t,e){let r=t.countIndent(e,t.pos,t.indent),n=t.skipSpace(e),s=t.countIndent(n,e,r);return s>=r+5||n==t.text.length?r+1:s}function A(t,e,r){let n=t.length-1;n>=0&&t[n].to==e&&t[n].type==u.CodeText?t[n].to=r:t.push(k(u.CodeText,e,r))}const $={LinkReference:void 0,IndentedCode(t,e){let r=e.baseIndent+4;if(e.indent<r)return!1;let n=e.findColumn(r),s=t.lineStart+n,i=t.lineStart+e.text.length,o=[],a=[];for(A(o,s,i);t.nextLine()&&e.depth>=t.stack.length;)if(e.pos==e.text.length){A(a,t.lineStart-1,t.lineStart);for(let l of e.markers)a.push(l)}else{if(e.indent<r)break;{if(a.length){for(let h of a)h.type==u.CodeText?A(o,h.from,h.to):o.push(h);a=[]}A(o,t.lineStart-1,t.lineStart);for(let h of e.markers)o.push(h);i=t.lineStart+e.text.length;let l=t.lineStart+e.findColumn(e.baseIndent+4);l<i&&A(o,l,i)}}return a.length&&(a=a.filter(l=>l.type!=u.CodeText),a.length&&(e.markers=a.concat(e.markers))),t.addNode(t.buffer.writeElements(o,-s).finish(u.CodeBlock,i-s),s),!0},FencedCode(t,e){let r=Pe(e);if(r<0)return!1;let n=t.lineStart+e.pos,s=e.next,i=r-e.pos,o=e.skipSpace(r),a=pe(e.text,e.text.length,o),l=[k(u.CodeMark,n,n+i)];o<a&&l.push(k(u.CodeInfo,t.lineStart+o,t.lineStart+a));for(let h=!0,f=!0,p=!1;t.nextLine()&&e.depth>=t.stack.length;h=!1){let d=e.pos;if(e.indent-e.baseIndent<4)for(;d<e.text.length&&e.text.charCodeAt(d)==s;)d++;if(d-e.pos>=i&&e.skipSpace(d)==e.text.length){for(let c of e.markers)l.push(c);f&&p&&A(l,t.lineStart-1,t.lineStart),l.push(k(u.CodeMark,t.lineStart+e.pos,t.lineStart+d)),t.nextLine();break}else{p=!0,h||(A(l,t.lineStart-1,t.lineStart),f=!1);for(let g of e.markers)l.push(g);let c=t.lineStart+e.basePos,L=t.lineStart+e.text.length;c<L&&(A(l,c,L),f=!1)}}return t.addNode(t.buffer.writeElements(l,-n).finish(u.FencedCode,t.prevLineEnd()-n),n),!0},Blockquote(t,e){let r=ve(e);return r<0?!1:(t.startContext(u.Blockquote,e.pos),t.addNode(u.QuoteMark,t.lineStart+e.pos,t.lineStart+e.pos+1),e.moveBase(e.pos+r),null)},HorizontalRule(t,e){if(se(e,t,!1)<0)return!1;let r=t.lineStart+e.pos;return t.nextLine(),t.addNode(u.HorizontalRule,r),!0},BulletList(t,e){let r=ie(e,t,!1);if(r<0)return!1;t.block.type!=u.BulletList&&t.startContext(u.BulletList,e.basePos,e.next);let n=ce(e,e.pos+1);return t.startContext(u.ListItem,e.basePos,n-e.baseIndent),t.addNode(u.ListMark,t.lineStart+e.pos,t.lineStart+e.pos+r),e.moveBaseColumn(n),null},OrderedList(t,e){let r=oe(e,t,!1);if(r<0)return!1;t.block.type!=u.OrderedList&&t.startContext(u.OrderedList,e.basePos,e.text.charCodeAt(e.pos+r-1));let n=ce(e,e.pos+r);return t.startContext(u.ListItem,e.basePos,n-e.baseIndent),t.addNode(u.ListMark,t.lineStart+e.pos,t.lineStart+e.pos+r),e.moveBaseColumn(n),null},ATXHeading(t,e){let r=ye(e);if(r<0)return!1;let n=e.pos,s=t.lineStart+n,i=pe(e.text,e.text.length,n),o=i;for(;o>n&&e.text.charCodeAt(o-1)==e.next;)o--;(o==i||o==n||!x(e.text.charCodeAt(o-1)))&&(o=e.text.length);let a=t.buffer.write(u.HeaderMark,0,r).writeElements(t.parser.parseInline(e.text.slice(n+r+1,o),s+r+1),-s);o<e.text.length&&a.write(u.HeaderMark,o-n,i-n);let l=a.finish(u.ATXHeading1-1+r,e.text.length-n);return t.nextLine(),t.addNode(l,s),!0},HTMLBlock(t,e){let r=ze(e,t,!1);if(r<0)return!1;let n=t.lineStart+e.pos,s=ee[r][1],i=[],o=s!=W;for(;!s.test(e.text)&&t.nextLine();){if(e.depth<t.stack.length){o=!1;break}for(let h of e.markers)i.push(h)}o&&t.nextLine();let a=s==Oe?u.CommentBlock:s==Te?u.ProcessingInstructionBlock:u.HTMLBlock,l=t.prevLineEnd();return t.addNode(t.buffer.writeElements(i,-n).finish(a,l-n),n),!0},SetextHeading:void 0};class xt{constructor(e){this.stage=0,this.elts=[],this.pos=0,this.start=e.start,this.advance(e.content)}nextLine(e,r,n){if(this.stage==-1)return!1;let s=n.content+`
|
|
1
|
+
import{Prec as st,EditorSelection as P,countColumn as z,EditorState as it}from"./index-BHot-lnj.js";import{n as ot,E as at}from"./index-891wE-Rj.js";import{L as fe,q as lt,e as X,r as ht,j as ft,t as ut,o as Ee,l as dt,u as pt,v as ue,P as ct}from"./index-wsSNo9PM.js";import{C as mt}from"./index-Dd7rh20x.js";import{P as gt,a as Q,N as v,T as kt,b as Ie,s as Me,c as H,p as Lt,t as m}from"./index-BCLbqlhA.js";import{html as bt,htmlCompletionSource as wt}from"./index-DPrfFlZq.js";import"./index-D6DYiY6f.js";import"./index-DXHZO0ym.js";import"./index-CZuUjzhP.js";class U{static create(e,r,n,s,i){let o=s+(s<<8)+e+(r<<4)|0;return new U(e,r,n,o,i,[],[])}constructor(e,r,n,s,i,o,a){this.type=e,this.value=r,this.from=n,this.hash=s,this.end=i,this.children=o,this.positions=a,this.hashProp=[[v.contextHash,s]]}addChild(e,r){e.prop(v.contextHash)!=this.hash&&(e=new H(e.type,e.children,e.positions,e.length,this.hashProp)),this.children.push(e),this.positions.push(r)}toTree(e,r=this.end){let n=this.children.length-1;return n>=0&&(r=Math.max(r,this.positions[n]+this.children[n].length+this.from)),new H(e.types[this.type],this.children,this.positions,r-this.from).balance({makeTree:(s,i,o)=>new H(Q.none,s,i,o,this.hashProp)})}}var u;(function(t){t[t.Document=1]="Document",t[t.CodeBlock=2]="CodeBlock",t[t.FencedCode=3]="FencedCode",t[t.Blockquote=4]="Blockquote",t[t.HorizontalRule=5]="HorizontalRule",t[t.BulletList=6]="BulletList",t[t.OrderedList=7]="OrderedList",t[t.ListItem=8]="ListItem",t[t.ATXHeading1=9]="ATXHeading1",t[t.ATXHeading2=10]="ATXHeading2",t[t.ATXHeading3=11]="ATXHeading3",t[t.ATXHeading4=12]="ATXHeading4",t[t.ATXHeading5=13]="ATXHeading5",t[t.ATXHeading6=14]="ATXHeading6",t[t.SetextHeading1=15]="SetextHeading1",t[t.SetextHeading2=16]="SetextHeading2",t[t.HTMLBlock=17]="HTMLBlock",t[t.LinkReference=18]="LinkReference",t[t.Paragraph=19]="Paragraph",t[t.CommentBlock=20]="CommentBlock",t[t.ProcessingInstructionBlock=21]="ProcessingInstructionBlock",t[t.Escape=22]="Escape",t[t.Entity=23]="Entity",t[t.HardBreak=24]="HardBreak",t[t.Emphasis=25]="Emphasis",t[t.StrongEmphasis=26]="StrongEmphasis",t[t.Link=27]="Link",t[t.Image=28]="Image",t[t.InlineCode=29]="InlineCode",t[t.HTMLTag=30]="HTMLTag",t[t.Comment=31]="Comment",t[t.ProcessingInstruction=32]="ProcessingInstruction",t[t.Autolink=33]="Autolink",t[t.HeaderMark=34]="HeaderMark",t[t.QuoteMark=35]="QuoteMark",t[t.ListMark=36]="ListMark",t[t.LinkMark=37]="LinkMark",t[t.EmphasisMark=38]="EmphasisMark",t[t.CodeMark=39]="CodeMark",t[t.CodeText=40]="CodeText",t[t.CodeInfo=41]="CodeInfo",t[t.LinkTitle=42]="LinkTitle",t[t.LinkLabel=43]="LinkLabel",t[t.URL=44]="URL"})(u||(u={}));class St{constructor(e,r){this.start=e,this.content=r,this.marks=[],this.parsers=[]}}class Ct{constructor(){this.text="",this.baseIndent=0,this.basePos=0,this.depth=0,this.markers=[],this.pos=0,this.indent=0,this.next=-1}forward(){this.basePos>this.pos&&this.forwardInner()}forwardInner(){let e=this.skipSpace(this.basePos);this.indent=this.countIndent(e,this.pos,this.indent),this.pos=e,this.next=e==this.text.length?-1:this.text.charCodeAt(e)}skipSpace(e){return O(this.text,e)}reset(e){for(this.text=e,this.baseIndent=this.basePos=this.pos=this.indent=0,this.forwardInner(),this.depth=1;this.markers.length;)this.markers.pop()}moveBase(e){this.basePos=e,this.baseIndent=this.countIndent(e,this.pos,this.indent)}moveBaseColumn(e){this.baseIndent=e,this.basePos=this.findColumn(e)}addMarker(e){this.markers.push(e)}countIndent(e,r=0,n=0){for(let s=r;s<e;s++)n+=this.text.charCodeAt(s)==9?4-n%4:1;return n}findColumn(e){let r=0;for(let n=0;r<this.text.length&&n<e;r++)n+=this.text.charCodeAt(r)==9?4-n%4:1;return r}scrub(){if(!this.baseIndent)return this.text;let e="";for(let r=0;r<this.basePos;r++)e+=" ";return e+this.text.slice(this.basePos)}}function de(t,e,r){if(r.pos==r.text.length||t!=e.block&&r.indent>=e.stack[r.depth+1].value+r.baseIndent)return!0;if(r.indent>=r.baseIndent+4)return!1;let n=(t.type==u.OrderedList?oe:ie)(r,e,!1);return n>0&&(t.type!=u.BulletList||se(r,e,!1)<0)&&r.text.charCodeAt(r.pos+n-1)==t.value}const He={[u.Blockquote](t,e,r){return r.next!=62?!1:(r.markers.push(k(u.QuoteMark,e.lineStart+r.pos,e.lineStart+r.pos+1)),r.moveBase(r.pos+(x(r.text.charCodeAt(r.pos+1))?2:1)),t.end=e.lineStart+r.text.length,!0)},[u.ListItem](t,e,r){return r.indent<r.baseIndent+t.value&&r.next>-1?!1:(r.moveBaseColumn(r.baseIndent+t.value),!0)},[u.OrderedList]:de,[u.BulletList]:de,[u.Document](){return!0}};function x(t){return t==32||t==9||t==10||t==13}function O(t,e=0){for(;e<t.length&&x(t.charCodeAt(e));)e++;return e}function pe(t,e,r){for(;e>r&&x(t.charCodeAt(e-1));)e--;return e}function Pe(t){if(t.next!=96&&t.next!=126)return-1;let e=t.pos+1;for(;e<t.text.length&&t.text.charCodeAt(e)==t.next;)e++;if(e<t.pos+3)return-1;if(t.next==96){for(let r=e;r<t.text.length;r++)if(t.text.charCodeAt(r)==96)return-1}return e}function ve(t){return t.next!=62?-1:t.text.charCodeAt(t.pos+1)==32?2:1}function se(t,e,r){if(t.next!=42&&t.next!=45&&t.next!=95)return-1;let n=1;for(let s=t.pos+1;s<t.text.length;s++){let i=t.text.charCodeAt(s);if(i==t.next)n++;else if(!x(i))return-1}return r&&t.next==45&&Re(t)>-1&&t.depth==e.stack.length&&e.parser.leafBlockParsers.indexOf(De.SetextHeading)>-1||n<3?-1:1}function Ne(t,e){for(let r=t.stack.length-1;r>=0;r--)if(t.stack[r].type==e)return!0;return!1}function ie(t,e,r){return(t.next==45||t.next==43||t.next==42)&&(t.pos==t.text.length-1||x(t.text.charCodeAt(t.pos+1)))&&(!r||Ne(e,u.BulletList)||t.skipSpace(t.pos+2)<t.text.length)?1:-1}function oe(t,e,r){let n=t.pos,s=t.next;for(;s>=48&&s<=57;){n++;if(n==t.text.length)return-1;s=t.text.charCodeAt(n)}return n==t.pos||n>t.pos+9||s!=46&&s!=41||n<t.text.length-1&&!x(t.text.charCodeAt(n+1))||r&&!Ne(e,u.OrderedList)&&(t.skipSpace(n+1)==t.text.length||n>t.pos+1||t.next!=49)?-1:n+1-t.pos}function ye(t){if(t.next!=35)return-1;let e=t.pos+1;for(;e<t.text.length&&t.text.charCodeAt(e)==35;)e++;if(e<t.text.length&&t.text.charCodeAt(e)!=32)return-1;let r=e-t.pos;return r>6?-1:r}function Re(t){if(t.next!=45&&t.next!=61||t.indent>=t.baseIndent+4)return-1;let e=t.pos+1;for(;e<t.text.length&&t.text.charCodeAt(e)==t.next;)e++;let r=e;for(;e<t.text.length&&x(t.text.charCodeAt(e));)e++;return e==t.text.length?r:-1}const W=/^[ \t]*$/,Oe=/-->/,Te=/\?>/,ee=[[/^<(?:script|pre|style)(?:\s|>|$)/i,/<\/(?:script|pre|style)>/i],[/^\s*<!--/,Oe],[/^\s*<\?/,Te],[/^\s*<![A-Z]/,/>/],[/^\s*<!\[CDATA\[/,/\]\]>/],[/^\s*<\/?(?:address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h1|h2|h3|h4|h5|h6|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul)(?:\s|\/?>|$)/i,W],[/^\s*(?:<\/[a-z][\w-]*\s*>|<[a-z][\w-]*(\s+[a-z:_][\w-.]*(?:\s*=\s*(?:[^\s"'=<>`]+|'[^']*'|"[^"]*"))?)*\s*>)\s*$/i,W]];function ze(t,e,r){if(t.next!=60)return-1;let n=t.text.slice(t.pos);for(let s=0,i=ee.length-(r?1:0);s<i;s++)if(ee[s][0].test(n))return s;return-1}function ce(t,e){let r=t.countIndent(e,t.pos,t.indent),n=t.skipSpace(e),s=t.countIndent(n,e,r);return s>=r+5||n==t.text.length?r+1:s}function A(t,e,r){let n=t.length-1;n>=0&&t[n].to==e&&t[n].type==u.CodeText?t[n].to=r:t.push(k(u.CodeText,e,r))}const $={LinkReference:void 0,IndentedCode(t,e){let r=e.baseIndent+4;if(e.indent<r)return!1;let n=e.findColumn(r),s=t.lineStart+n,i=t.lineStart+e.text.length,o=[],a=[];for(A(o,s,i);t.nextLine()&&e.depth>=t.stack.length;)if(e.pos==e.text.length){A(a,t.lineStart-1,t.lineStart);for(let l of e.markers)a.push(l)}else{if(e.indent<r)break;{if(a.length){for(let h of a)h.type==u.CodeText?A(o,h.from,h.to):o.push(h);a=[]}A(o,t.lineStart-1,t.lineStart);for(let h of e.markers)o.push(h);i=t.lineStart+e.text.length;let l=t.lineStart+e.findColumn(e.baseIndent+4);l<i&&A(o,l,i)}}return a.length&&(a=a.filter(l=>l.type!=u.CodeText),a.length&&(e.markers=a.concat(e.markers))),t.addNode(t.buffer.writeElements(o,-s).finish(u.CodeBlock,i-s),s),!0},FencedCode(t,e){let r=Pe(e);if(r<0)return!1;let n=t.lineStart+e.pos,s=e.next,i=r-e.pos,o=e.skipSpace(r),a=pe(e.text,e.text.length,o),l=[k(u.CodeMark,n,n+i)];o<a&&l.push(k(u.CodeInfo,t.lineStart+o,t.lineStart+a));for(let h=!0,f=!0,p=!1;t.nextLine()&&e.depth>=t.stack.length;h=!1){let d=e.pos;if(e.indent-e.baseIndent<4)for(;d<e.text.length&&e.text.charCodeAt(d)==s;)d++;if(d-e.pos>=i&&e.skipSpace(d)==e.text.length){for(let c of e.markers)l.push(c);f&&p&&A(l,t.lineStart-1,t.lineStart),l.push(k(u.CodeMark,t.lineStart+e.pos,t.lineStart+d)),t.nextLine();break}else{p=!0,h||(A(l,t.lineStart-1,t.lineStart),f=!1);for(let g of e.markers)l.push(g);let c=t.lineStart+e.basePos,L=t.lineStart+e.text.length;c<L&&(A(l,c,L),f=!1)}}return t.addNode(t.buffer.writeElements(l,-n).finish(u.FencedCode,t.prevLineEnd()-n),n),!0},Blockquote(t,e){let r=ve(e);return r<0?!1:(t.startContext(u.Blockquote,e.pos),t.addNode(u.QuoteMark,t.lineStart+e.pos,t.lineStart+e.pos+1),e.moveBase(e.pos+r),null)},HorizontalRule(t,e){if(se(e,t,!1)<0)return!1;let r=t.lineStart+e.pos;return t.nextLine(),t.addNode(u.HorizontalRule,r),!0},BulletList(t,e){let r=ie(e,t,!1);if(r<0)return!1;t.block.type!=u.BulletList&&t.startContext(u.BulletList,e.basePos,e.next);let n=ce(e,e.pos+1);return t.startContext(u.ListItem,e.basePos,n-e.baseIndent),t.addNode(u.ListMark,t.lineStart+e.pos,t.lineStart+e.pos+r),e.moveBaseColumn(n),null},OrderedList(t,e){let r=oe(e,t,!1);if(r<0)return!1;t.block.type!=u.OrderedList&&t.startContext(u.OrderedList,e.basePos,e.text.charCodeAt(e.pos+r-1));let n=ce(e,e.pos+r);return t.startContext(u.ListItem,e.basePos,n-e.baseIndent),t.addNode(u.ListMark,t.lineStart+e.pos,t.lineStart+e.pos+r),e.moveBaseColumn(n),null},ATXHeading(t,e){let r=ye(e);if(r<0)return!1;let n=e.pos,s=t.lineStart+n,i=pe(e.text,e.text.length,n),o=i;for(;o>n&&e.text.charCodeAt(o-1)==e.next;)o--;(o==i||o==n||!x(e.text.charCodeAt(o-1)))&&(o=e.text.length);let a=t.buffer.write(u.HeaderMark,0,r).writeElements(t.parser.parseInline(e.text.slice(n+r+1,o),s+r+1),-s);o<e.text.length&&a.write(u.HeaderMark,o-n,i-n);let l=a.finish(u.ATXHeading1-1+r,e.text.length-n);return t.nextLine(),t.addNode(l,s),!0},HTMLBlock(t,e){let r=ze(e,t,!1);if(r<0)return!1;let n=t.lineStart+e.pos,s=ee[r][1],i=[],o=s!=W;for(;!s.test(e.text)&&t.nextLine();){if(e.depth<t.stack.length){o=!1;break}for(let h of e.markers)i.push(h)}o&&t.nextLine();let a=s==Oe?u.CommentBlock:s==Te?u.ProcessingInstructionBlock:u.HTMLBlock,l=t.prevLineEnd();return t.addNode(t.buffer.writeElements(i,-n).finish(a,l-n),n),!0},SetextHeading:void 0};class xt{constructor(e){this.stage=0,this.elts=[],this.pos=0,this.start=e.start,this.advance(e.content)}nextLine(e,r,n){if(this.stage==-1)return!1;let s=n.content+`
|
|
2
2
|
`+r.scrub(),i=this.advance(s);return i>-1&&i<s.length?this.complete(e,n,i):!1}finish(e,r){return(this.stage==2||this.stage==3)&&O(r.content,this.pos)==r.content.length?this.complete(e,r,r.content.length):!1}complete(e,r,n){return e.addLeafElement(r,k(u.LinkReference,this.start,this.start+n,this.elts)),!0}nextStage(e){return e?(this.pos=e.to-this.start,this.elts.push(e),this.stage++,!0):(e===!1&&(this.stage=-1),!1)}advance(e){for(;;){if(this.stage==-1)return-1;if(this.stage==0){if(!this.nextStage(Ze(e,this.pos,this.start,!0)))return-1;if(e.charCodeAt(this.pos)!=58)return this.stage=-1;this.elts.push(k(u.LinkMark,this.pos+this.start,this.pos+this.start+1)),this.pos++}else if(this.stage==1){if(!this.nextStage(qe(e,O(e,this.pos),this.start)))return-1}else if(this.stage==2){let r=O(e,this.pos),n=0;if(r>this.pos){let s=Qe(e,r,this.start);if(s){let i=V(e,s.to-this.start);i>0&&(this.nextStage(s),n=i)}}return n||(n=V(e,this.pos)),n>0&&n<e.length?n:-1}else return V(e,this.pos)}}}function V(t,e){for(;e<t.length;e++){let r=t.charCodeAt(e);if(r==10)break;if(!x(r))return-1}return e}class At{nextLine(e,r,n){let s=r.depth<e.stack.length?-1:Re(r),i=r.next;if(s<0)return!1;let o=k(u.HeaderMark,e.lineStart+r.pos,e.lineStart+s);return e.nextLine(),e.addLeafElement(n,k(i==61?u.SetextHeading1:u.SetextHeading2,n.start,e.prevLineEnd(),[...e.parser.parseInline(n.content,n.start),o])),!0}finish(){return!1}}const De={LinkReference(t,e){return e.content.charCodeAt(0)==91?new xt(e):null},SetextHeading(){return new At}},Bt=[(t,e)=>ye(e)>=0,(t,e)=>Pe(e)>=0,(t,e)=>ve(e)>=0,(t,e)=>ie(e,t,!0)>=0,(t,e)=>oe(e,t,!0)>=0,(t,e)=>se(e,t,!0)>=0,(t,e)=>ze(e,t,!0)>=0],Et={text:"",end:0};class It{constructor(e,r,n,s){this.parser=e,this.input=r,this.ranges=s,this.line=new Ct,this.atEnd=!1,this.reusePlaceholders=new Map,this.stoppedAt=null,this.rangeI=0,this.to=s[s.length-1].to,this.lineStart=this.absoluteLineStart=this.absoluteLineEnd=s[0].from,this.block=U.create(u.Document,0,this.lineStart,0,0),this.stack=[this.block],this.fragments=n.length?new Pt(n,r):null,this.readLine()}get parsedPos(){return this.absoluteLineStart}advance(){if(this.stoppedAt!=null&&this.absoluteLineStart>this.stoppedAt)return this.finish();let{line:e}=this;for(;;){for(let n=0;;){let s=e.depth<this.stack.length?this.stack[this.stack.length-1]:null;for(;n<e.markers.length&&(!s||e.markers[n].from<s.end);){let i=e.markers[n++];this.addNode(i.type,i.from,i.to)}if(!s)break;this.finishContext()}if(e.pos<e.text.length)break;if(!this.nextLine())return this.finish()}if(this.fragments&&this.reuseFragment(e.basePos))return null;e:for(;;){for(let n of this.parser.blockParsers)if(n){let s=n(this,e);if(s!=!1){if(s==!0)return null;e.forward();continue e}}break}if(e.pos==e.text.length)return this.nextLine()?null:this.finish();let r=new St(this.lineStart+e.pos,e.text.slice(e.pos));for(let n of this.parser.leafBlockParsers)if(n){let s=n(this,r);s&&r.parsers.push(s)}e:for(;this.nextLine()&&e.pos!=e.text.length;){if(e.indent<e.baseIndent+4){for(let n of this.parser.endLeafBlock)if(n(this,e,r))break e}for(let n of r.parsers)if(n.nextLine(this,e,r))return null;r.content+=`
|
|
3
3
|
`+e.scrub();for(let n of e.markers)r.marks.push(n)}return this.finishLeaf(r),null}stopAt(e){if(this.stoppedAt!=null&&this.stoppedAt<e)throw new RangeError("Can't move stoppedAt forward");this.stoppedAt=e}reuseFragment(e){if(!this.fragments.moveTo(this.absoluteLineStart+e,this.absoluteLineStart)||!this.fragments.matches(this.block.hash))return!1;let r=this.fragments.takeNodes(this);return r?(this.absoluteLineStart+=r,this.lineStart=Ve(this.absoluteLineStart,this.ranges),this.moveRangeI(),this.absoluteLineStart<this.to?(this.lineStart++,this.absoluteLineStart++,this.readLine()):(this.atEnd=!0,this.readLine()),!0):!1}get depth(){return this.stack.length}parentType(e=this.depth-1){return this.parser.nodeSet.types[this.stack[e].type]}nextLine(){return this.lineStart+=this.line.text.length,this.absoluteLineEnd>=this.to?(this.absoluteLineStart=this.absoluteLineEnd,this.atEnd=!0,this.readLine(),!1):(this.lineStart++,this.absoluteLineStart=this.absoluteLineEnd+1,this.moveRangeI(),this.readLine(),!0)}peekLine(){return this.scanLine(this.absoluteLineEnd+1).text}moveRangeI(){for(;this.rangeI<this.ranges.length-1&&this.absoluteLineStart>=this.ranges[this.rangeI].to;)this.rangeI++,this.absoluteLineStart=Math.max(this.absoluteLineStart,this.ranges[this.rangeI].from)}scanLine(e){let r=Et;if(r.end=e,e>=this.to)r.text="";else if(r.text=this.lineChunkAt(e),r.end+=r.text.length,this.ranges.length>1){let n=this.absoluteLineStart,s=this.rangeI;for(;this.ranges[s].to<r.end;){s++;let i=this.ranges[s].from,o=this.lineChunkAt(i);r.end=i+o.length,r.text=r.text.slice(0,this.ranges[s-1].to-n)+o,n=r.end-r.text.length}}return r}readLine(){let{line:e}=this,{text:r,end:n}=this.scanLine(this.absoluteLineStart);for(this.absoluteLineEnd=n,e.reset(r);e.depth<this.stack.length;e.depth++){let s=this.stack[e.depth],i=this.parser.skipContextMarkup[s.type];if(!i)throw new Error("Unhandled block context "+u[s.type]);let o=this.line.markers.length;if(!i(s,this,e)){this.line.markers.length>o&&(s.end=this.line.markers[this.line.markers.length-1].to),e.forward();break}e.forward()}}lineChunkAt(e){let r=this.input.chunk(e),n;if(this.input.lineChunks)n=r==`
|
|
4
4
|
`?"":r;else{let s=r.indexOf(`
|