@linkshell/gateway 0.6.62 → 0.6.64
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/dist/gateway/src/subscription.d.ts +8 -1
- package/dist/gateway/src/subscription.js +46 -7
- package/dist/gateway/src/subscription.js.map +1 -1
- package/dist/gateway/tsconfig.tsbuildinfo +1 -1
- package/dist/wire/src/index.d.ts +1 -0
- package/dist/wire/src/index.js +1 -0
- package/dist/wire/src/index.js.map +1 -1
- package/dist/wire/src/live-activity.d.ts +59 -2
- package/dist/wire/src/live-activity.js +26 -0
- package/dist/wire/src/live-activity.js.map +1 -1
- package/dist/wire/src/lsa.d.ts +308 -0
- package/dist/wire/src/lsa.js +144 -0
- package/dist/wire/src/lsa.js.map +1 -0
- package/dist/wire/src/model.d.ts +66 -0
- package/dist/wire/src/model.js +19 -0
- package/dist/wire/src/model.js.map +1 -1
- package/dist/wire/src/rpc.d.ts +233 -3
- package/dist/wire/src/rpc.js +95 -5
- package/dist/wire/src/rpc.js.map +1 -1
- package/dist/wire/src/usage.d.ts +32 -0
- package/dist/wire/src/usage.js +93 -5
- package/dist/wire/src/usage.js.map +1 -1
- package/dist/wire/src/watch.d.ts +4 -4
- package/package.json +2 -2
- package/src/subscription.ts +42 -7
- package/web-client/assets/{highlight-engine-CVPbtAaa.js → highlight-engine-O1eAlGCP.js} +1 -1
- package/web-client/assets/{index-BOUajjjs.js → index-CaTd0eIv.js} +2 -2
- package/web-client/assets/index-K63Wd-HY.css +1 -0
- package/web-client/assets/{qr-scanner.min-D4ETRllz.js → qr-scanner.min-DQPqSwkk.js} +1 -1
- package/web-client/assets/render-BXnR4aOI.js +894 -0
- package/web-client/index.html +2 -2
- package/web-client/preview/bridge.js +2 -2
- package/web-client/preview/worker.js +53 -1
- package/web-client/assets/index-hJVa0Yva.css +0 -1
- package/web-client/assets/render-GjZ5l-D0.js +0 -842
package/dist/wire/src/usage.d.ts
CHANGED
|
@@ -11,6 +11,11 @@ export declare const usageTotalsSchema: z.ZodObject<{
|
|
|
11
11
|
cacheReadTokens: z.ZodNumber;
|
|
12
12
|
cacheWriteTokens: z.ZodNumber;
|
|
13
13
|
totalTokens: z.ZodNumber;
|
|
14
|
+
estimatedCostUsd: z.ZodOptional<z.ZodNumber>;
|
|
15
|
+
}, z.core.$strip>;
|
|
16
|
+
export declare const usageRemoteStatsSchema: z.ZodObject<{
|
|
17
|
+
remoteTurns: z.ZodNumber;
|
|
18
|
+
remoteApprovals: z.ZodNumber;
|
|
14
19
|
}, z.core.$strip>;
|
|
15
20
|
export declare const usageReportSchema: z.ZodObject<{
|
|
16
21
|
generatedAt: z.ZodNumber;
|
|
@@ -25,6 +30,7 @@ export declare const usageReportSchema: z.ZodObject<{
|
|
|
25
30
|
cacheReadTokens: z.ZodNumber;
|
|
26
31
|
cacheWriteTokens: z.ZodNumber;
|
|
27
32
|
totalTokens: z.ZodNumber;
|
|
33
|
+
estimatedCostUsd: z.ZodOptional<z.ZodNumber>;
|
|
28
34
|
}, z.core.$strip>;
|
|
29
35
|
daily: z.ZodArray<z.ZodObject<{
|
|
30
36
|
records: z.ZodNumber;
|
|
@@ -34,6 +40,7 @@ export declare const usageReportSchema: z.ZodObject<{
|
|
|
34
40
|
cacheReadTokens: z.ZodNumber;
|
|
35
41
|
cacheWriteTokens: z.ZodNumber;
|
|
36
42
|
totalTokens: z.ZodNumber;
|
|
43
|
+
estimatedCostUsd: z.ZodOptional<z.ZodNumber>;
|
|
37
44
|
date: z.ZodString;
|
|
38
45
|
}, z.core.$strip>>;
|
|
39
46
|
models: z.ZodArray<z.ZodObject<{
|
|
@@ -44,6 +51,7 @@ export declare const usageReportSchema: z.ZodObject<{
|
|
|
44
51
|
cacheReadTokens: z.ZodNumber;
|
|
45
52
|
cacheWriteTokens: z.ZodNumber;
|
|
46
53
|
totalTokens: z.ZodNumber;
|
|
54
|
+
estimatedCostUsd: z.ZodOptional<z.ZodNumber>;
|
|
47
55
|
agent: z.ZodString;
|
|
48
56
|
model: z.ZodString;
|
|
49
57
|
}, z.core.$strip>>;
|
|
@@ -61,9 +69,33 @@ export declare const usageReportSchema: z.ZodObject<{
|
|
|
61
69
|
records: z.ZodNumber;
|
|
62
70
|
totalTokens: z.ZodNumber;
|
|
63
71
|
note: z.ZodString;
|
|
72
|
+
estimatedCostUsd: z.ZodOptional<z.ZodNumber>;
|
|
64
73
|
}, z.core.$strip>>>;
|
|
74
|
+
estimatedCostUsd: z.ZodOptional<z.ZodNumber>;
|
|
75
|
+
remoteStats: z.ZodOptional<z.ZodObject<{
|
|
76
|
+
remoteTurns: z.ZodNumber;
|
|
77
|
+
remoteApprovals: z.ZodNumber;
|
|
78
|
+
}, z.core.$strip>>;
|
|
65
79
|
warnings: z.ZodArray<z.ZodString>;
|
|
66
80
|
}, z.core.$strip>;
|
|
67
81
|
export type UsageQuery = z.infer<typeof usageQuerySchema>;
|
|
68
82
|
export type UsageTotals = z.infer<typeof usageTotalsSchema>;
|
|
83
|
+
export type UsageRemoteStats = z.infer<typeof usageRemoteStatsSchema>;
|
|
69
84
|
export type UsageReport = z.infer<typeof usageReportSchema>;
|
|
85
|
+
export interface ModelPricingPerMillion {
|
|
86
|
+
input: number;
|
|
87
|
+
output: number;
|
|
88
|
+
cacheRead: number;
|
|
89
|
+
cacheWrite: number;
|
|
90
|
+
}
|
|
91
|
+
export interface TokenCostInput {
|
|
92
|
+
inputTokens: number;
|
|
93
|
+
outputTokens: number;
|
|
94
|
+
cacheReadTokens?: number;
|
|
95
|
+
cacheWriteTokens?: number;
|
|
96
|
+
}
|
|
97
|
+
export declare function modelPricingPerMillionUsd(model: string): ModelPricingPerMillion;
|
|
98
|
+
/**
|
|
99
|
+
* Pure reference cost estimator (in USD) for a model and non-overlapping token bucket totals.
|
|
100
|
+
*/
|
|
101
|
+
export declare function estimateModelCostUsd(model: string, totals: TokenCostInput): number;
|
package/dist/wire/src/usage.js
CHANGED
|
@@ -4,18 +4,106 @@ export const usageQuerySchema = z.object({
|
|
|
4
4
|
agent: z.string().min(1).max(128).default("all"),
|
|
5
5
|
});
|
|
6
6
|
export const usageTotalsSchema = z.object({
|
|
7
|
-
records: z.number(),
|
|
8
|
-
|
|
7
|
+
records: z.number(),
|
|
8
|
+
sessions: z.number(),
|
|
9
|
+
inputTokens: z.number(),
|
|
10
|
+
outputTokens: z.number(),
|
|
11
|
+
cacheReadTokens: z.number(),
|
|
12
|
+
cacheWriteTokens: z.number(),
|
|
13
|
+
totalTokens: z.number(),
|
|
14
|
+
estimatedCostUsd: z.number().nonnegative().optional(),
|
|
15
|
+
});
|
|
16
|
+
export const usageRemoteStatsSchema = z.object({
|
|
17
|
+
remoteTurns: z.number().int().nonnegative(),
|
|
18
|
+
remoteApprovals: z.number().int().nonnegative(),
|
|
9
19
|
});
|
|
10
20
|
export const usageReportSchema = z.object({
|
|
11
|
-
generatedAt: z.number(),
|
|
21
|
+
generatedAt: z.number(),
|
|
22
|
+
days: z.number(),
|
|
23
|
+
agent: z.string(),
|
|
24
|
+
timezone: z.string(),
|
|
12
25
|
totals: usageTotalsSchema,
|
|
13
26
|
daily: z.array(usageTotalsSchema.extend({ date: z.string() })),
|
|
14
27
|
models: z.array(usageTotalsSchema.extend({ agent: z.string(), model: z.string() })),
|
|
15
28
|
agents: z.array(z.object({
|
|
16
|
-
id: z.string(),
|
|
17
|
-
|
|
29
|
+
id: z.string(),
|
|
30
|
+
label: z.string(),
|
|
31
|
+
source: z.enum(["native", "acp"]),
|
|
32
|
+
status: z.enum(["available", "no_data"]),
|
|
33
|
+
records: z.number(),
|
|
34
|
+
totalTokens: z.number(),
|
|
35
|
+
note: z.string(),
|
|
36
|
+
estimatedCostUsd: z.number().nonnegative().optional(),
|
|
18
37
|
})).optional(),
|
|
38
|
+
estimatedCostUsd: z.number().nonnegative().optional(),
|
|
39
|
+
remoteStats: usageRemoteStatsSchema.optional(),
|
|
19
40
|
warnings: z.array(z.string()),
|
|
20
41
|
});
|
|
42
|
+
/**
|
|
43
|
+
* Reference public API pricing (USD per 1M tokens), ordered most-specific first.
|
|
44
|
+
* Subscription users (ChatGPT Plus/Pro, Claude Pro/Max) pay flat fees; this
|
|
45
|
+
* estimates the equivalent API value of work orchestrated through LinkShell.
|
|
46
|
+
*/
|
|
47
|
+
const MODEL_PRICING_RULES = [
|
|
48
|
+
// Anthropic Claude
|
|
49
|
+
{ match: /claude[-_.]?opus[-_.]?(?:4[._][56]|5)/i, pricing: { input: 5, output: 25, cacheRead: 0.5, cacheWrite: 6.25 } },
|
|
50
|
+
{ match: /opus/i, pricing: { input: 15, output: 75, cacheRead: 1.5, cacheWrite: 18.75 } },
|
|
51
|
+
{ match: /sonnet/i, pricing: { input: 3, output: 15, cacheRead: 0.3, cacheWrite: 3.75 } },
|
|
52
|
+
{ match: /claude[-_.]?haiku[-_.]?4[._]5/i, pricing: { input: 1, output: 5, cacheRead: 0.1, cacheWrite: 1.25 } },
|
|
53
|
+
{ match: /haiku/i, pricing: { input: 0.8, output: 4, cacheRead: 0.08, cacheWrite: 1 } },
|
|
54
|
+
// OpenAI / Codex
|
|
55
|
+
{ match: /(?:gpt-5|o1|o3)[-_]pro/i, pricing: { input: 15, output: 60, cacheRead: 3.75, cacheWrite: 15 } },
|
|
56
|
+
{ match: /gpt-5[-_.]?mini/i, pricing: { input: 0.25, output: 2, cacheRead: 0.025, cacheWrite: 0.25 } },
|
|
57
|
+
{ match: /gpt-5[-_.]?nano/i, pricing: { input: 0.05, output: 0.4, cacheRead: 0.005, cacheWrite: 0.05 } },
|
|
58
|
+
{ match: /codex[-_.]?mini/i, pricing: { input: 1.5, output: 6, cacheRead: 0.375, cacheWrite: 1.5 } },
|
|
59
|
+
{ match: /gpt-5|codex/i, pricing: { input: 1.25, output: 10, cacheRead: 0.125, cacheWrite: 1.25 } },
|
|
60
|
+
{ match: /gpt-4\.1[-_.]?mini/i, pricing: { input: 0.4, output: 1.6, cacheRead: 0.1, cacheWrite: 0.4 } },
|
|
61
|
+
{ match: /gpt-4\.1[-_.]?nano/i, pricing: { input: 0.1, output: 0.4, cacheRead: 0.025, cacheWrite: 0.1 } },
|
|
62
|
+
{ match: /gpt-4\.1/i, pricing: { input: 2, output: 8, cacheRead: 0.5, cacheWrite: 2 } },
|
|
63
|
+
{ match: /gpt-4o[-_.]?mini/i, pricing: { input: 0.15, output: 0.6, cacheRead: 0.075, cacheWrite: 0.15 } },
|
|
64
|
+
{ match: /gpt-4o/i, pricing: { input: 2.5, output: 10, cacheRead: 1.25, cacheWrite: 2.5 } },
|
|
65
|
+
{ match: /o[34][-_.]?mini/i, pricing: { input: 1.1, output: 4.4, cacheRead: 0.275, cacheWrite: 1.1 } },
|
|
66
|
+
{ match: /\bo3\b|\bo1\b/i, pricing: { input: 2, output: 8, cacheRead: 0.5, cacheWrite: 2 } },
|
|
67
|
+
// Google Gemini
|
|
68
|
+
{ match: /gemini.*flash/i, pricing: { input: 0.3, output: 2.5, cacheRead: 0.075, cacheWrite: 0.3 } },
|
|
69
|
+
{ match: /gemini/i, pricing: { input: 1.25, output: 10, cacheRead: 0.3125, cacheWrite: 1.25 } },
|
|
70
|
+
// xAI Grok & DeepSeek
|
|
71
|
+
{ match: /grok/i, pricing: { input: 3, output: 15, cacheRead: 0.75, cacheWrite: 3 } },
|
|
72
|
+
{ match: /deepseek/i, pricing: { input: 0.27, output: 1.1, cacheRead: 0.07, cacheWrite: 0.27 } },
|
|
73
|
+
];
|
|
74
|
+
const DEFAULT_PRICING_PER_MILLION = {
|
|
75
|
+
input: 2,
|
|
76
|
+
output: 8,
|
|
77
|
+
cacheRead: 0.2,
|
|
78
|
+
cacheWrite: 2,
|
|
79
|
+
};
|
|
80
|
+
export function modelPricingPerMillionUsd(model) {
|
|
81
|
+
const normalized = model.trim();
|
|
82
|
+
for (const rule of MODEL_PRICING_RULES) {
|
|
83
|
+
if (rule.match.test(normalized))
|
|
84
|
+
return rule.pricing;
|
|
85
|
+
}
|
|
86
|
+
return DEFAULT_PRICING_PER_MILLION;
|
|
87
|
+
}
|
|
88
|
+
function safeTokenCount(value) {
|
|
89
|
+
return typeof value === "number" && Number.isFinite(value) && value > 0 ? value : 0;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Pure reference cost estimator (in USD) for a model and non-overlapping token bucket totals.
|
|
93
|
+
*/
|
|
94
|
+
export function estimateModelCostUsd(model, totals) {
|
|
95
|
+
const input = safeTokenCount(totals.inputTokens);
|
|
96
|
+
const output = safeTokenCount(totals.outputTokens);
|
|
97
|
+
const cacheRead = safeTokenCount(totals.cacheReadTokens);
|
|
98
|
+
const cacheWrite = safeTokenCount(totals.cacheWriteTokens);
|
|
99
|
+
if (input === 0 && output === 0 && cacheRead === 0 && cacheWrite === 0)
|
|
100
|
+
return 0;
|
|
101
|
+
const rate = modelPricingPerMillionUsd(model);
|
|
102
|
+
const rawUsd = (input * rate.input +
|
|
103
|
+
output * rate.output +
|
|
104
|
+
cacheRead * rate.cacheRead +
|
|
105
|
+
cacheWrite * rate.cacheWrite) /
|
|
106
|
+
1_000_000;
|
|
107
|
+
return Math.round(rawUsd * 1_000_000) / 1_000_000;
|
|
108
|
+
}
|
|
21
109
|
//# sourceMappingURL=usage.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usage.js","sourceRoot":"","sources":["../../../../wire/src/usage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC;IACvC,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;IACrE,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC;CACjD,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"usage.js","sourceRoot":"","sources":["../../../../wire/src/usage.ts"],"names":[],"mappings":"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"}
|
package/dist/wire/src/watch.d.ts
CHANGED
|
@@ -50,9 +50,9 @@ export declare const watchActionSchema: z.ZodObject<{
|
|
|
50
50
|
role: z.ZodEnum<{
|
|
51
51
|
stop: "stop";
|
|
52
52
|
choice: "choice";
|
|
53
|
+
always: "always";
|
|
53
54
|
reject: "reject";
|
|
54
55
|
allow: "allow";
|
|
55
|
-
always: "always";
|
|
56
56
|
}>;
|
|
57
57
|
kind: z.ZodEnum<{
|
|
58
58
|
answer: "answer";
|
|
@@ -164,9 +164,9 @@ export declare const watchSessionSchema: z.ZodObject<{
|
|
|
164
164
|
role: z.ZodEnum<{
|
|
165
165
|
stop: "stop";
|
|
166
166
|
choice: "choice";
|
|
167
|
+
always: "always";
|
|
167
168
|
reject: "reject";
|
|
168
169
|
allow: "allow";
|
|
169
|
-
always: "always";
|
|
170
170
|
}>;
|
|
171
171
|
kind: z.ZodEnum<{
|
|
172
172
|
answer: "answer";
|
|
@@ -330,9 +330,9 @@ export declare const watchSnapshotSchema: z.ZodObject<{
|
|
|
330
330
|
role: z.ZodEnum<{
|
|
331
331
|
stop: "stop";
|
|
332
332
|
choice: "choice";
|
|
333
|
+
always: "always";
|
|
333
334
|
reject: "reject";
|
|
334
335
|
allow: "allow";
|
|
335
|
-
always: "always";
|
|
336
336
|
}>;
|
|
337
337
|
kind: z.ZodEnum<{
|
|
338
338
|
answer: "answer";
|
|
@@ -429,9 +429,9 @@ export declare const watchCommandSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
429
429
|
role: z.ZodEnum<{
|
|
430
430
|
stop: "stop";
|
|
431
431
|
choice: "choice";
|
|
432
|
+
always: "always";
|
|
432
433
|
reject: "reject";
|
|
433
434
|
allow: "allow";
|
|
434
|
-
always: "always";
|
|
435
435
|
}>;
|
|
436
436
|
kind: z.ZodEnum<{
|
|
437
437
|
answer: "answer";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@linkshell/gateway",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.64",
|
|
4
4
|
"description": "LinkShell gateway: relays end-to-end encrypted frames between computers and devices, and brokers pairing.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"ws": "^8.21.0",
|
|
35
|
-
"@linkshell/wire": "0.2.
|
|
35
|
+
"@linkshell/wire": "0.2.31"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@types/ws": "^8.5.14",
|
package/src/subscription.ts
CHANGED
|
@@ -4,8 +4,41 @@ import type { GatewayOptions } from "./relay.js";
|
|
|
4
4
|
// has LinkShell. The gateway asks iTool's `itool_entitlement_for(uid, 'linkshell')` with the
|
|
5
5
|
// service-role key, on its own behalf, not with the user's token.
|
|
6
6
|
|
|
7
|
-
// www
|
|
8
|
-
export const MEMBERSHIP_URL = "https://www.itool.tech/
|
|
7
|
+
// Locale-neutral www URL: itool.tech routes /pro to /zh/pro or /en/pro from the browser's locale.
|
|
8
|
+
export const MEMBERSHIP_URL = "https://www.itool.tech/pro?from=linkshell";
|
|
9
|
+
|
|
10
|
+
export type GatewayLocale = "zh" | "en" | "ja";
|
|
11
|
+
export type AdmissionDenialCode = "login_required" | "membership_required" | "temporarily_unavailable";
|
|
12
|
+
|
|
13
|
+
export const LOGIN_REQUIRED_CODE: AdmissionDenialCode = "login_required";
|
|
14
|
+
export const MEMBERSHIP_REQUIRED_CODE: AdmissionDenialCode = "membership_required";
|
|
15
|
+
|
|
16
|
+
export function membershipUrl(locale?: GatewayLocale): string {
|
|
17
|
+
if (locale === "zh") return "https://www.itool.tech/zh/pro?from=linkshell";
|
|
18
|
+
if (locale === "en" || locale === "ja") return "https://www.itool.tech/en/pro?from=linkshell";
|
|
19
|
+
return MEMBERSHIP_URL;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function admissionDenialMessage(code: AdmissionDenialCode, locale?: GatewayLocale): string {
|
|
23
|
+
const url = membershipUrl(locale);
|
|
24
|
+
switch (code) {
|
|
25
|
+
case "login_required":
|
|
26
|
+
if (locale === "zh") return "官方网关需要登录账号(新账号注册享 7 天免费试用):在电脑上运行 linkshell login";
|
|
27
|
+
if (locale === "en") return "Official gateway requires sign-in (new accounts include a 7-day free trial): run linkshell login";
|
|
28
|
+
if (locale === "ja") return "公式ゲートウェイの利用にはログインが必要です(新規登録で 7 日間無料トライアル):PC で linkshell login を実行してください";
|
|
29
|
+
return "官方网关需要登录账号(新账号注册享 7 天免费试用):在电脑上运行 linkshell login · Official gateway requires sign-in (new accounts include a 7-day free trial): run linkshell login";
|
|
30
|
+
case "membership_required":
|
|
31
|
+
if (locale === "zh") return `官方网关需要 iTool 会员(新账号注册享 7 天免费试用):${url}`;
|
|
32
|
+
if (locale === "en") return `Official gateway requires an iTool membership (new accounts include a 7-day free trial): ${url}`;
|
|
33
|
+
if (locale === "ja") return `公式ゲートウェイには iTool メンバーシップが必要です(新規アカウントは 7 日間無料トライアル付き):${url}`;
|
|
34
|
+
return `官方网关需要 iTool 会员(新账号注册享 7 天免费试用):${url} · Official gateway requires an iTool membership (7-day free trial on new accounts)`;
|
|
35
|
+
case "temporarily_unavailable":
|
|
36
|
+
if (locale === "zh") return "暂时无法验证 iTool 会员,请稍后重试";
|
|
37
|
+
if (locale === "en") return "Unable to verify iTool membership right now; please try again shortly";
|
|
38
|
+
if (locale === "ja") return "現在 iTool メンバーシップを確認できません。しばらくしてから再度お試しください";
|
|
39
|
+
return "暂时无法验证 iTool 会员,请稍后重试 · Unable to verify iTool membership right now; please try again shortly";
|
|
40
|
+
}
|
|
41
|
+
}
|
|
9
42
|
|
|
10
43
|
export interface SubscriptionCheck {
|
|
11
44
|
/** "unknown": the lookup itself failed, which says nothing about the account. */
|
|
@@ -51,7 +84,7 @@ export function supabaseSubscriptions(supabase: { url: string; anonKey: string;
|
|
|
51
84
|
export function requirePro(
|
|
52
85
|
check: CheckSubscription,
|
|
53
86
|
warn: (message: string) => void,
|
|
54
|
-
options: { enforceGrace?: boolean; cacheMs?: number; graceMs?: number; now?: () => number } = {},
|
|
87
|
+
options: { enforceGrace?: boolean; cacheMs?: number; graceMs?: number; now?: () => number; locale?: GatewayLocale } = {},
|
|
55
88
|
): NonNullable<GatewayOptions["admit"]> {
|
|
56
89
|
const now = options.now ?? Date.now;
|
|
57
90
|
const cacheMs = options.cacheMs ?? 60_000;
|
|
@@ -67,12 +100,12 @@ export function requirePro(
|
|
|
67
100
|
}>();
|
|
68
101
|
return async ({ role, userId }) => {
|
|
69
102
|
if (role !== "machine") return undefined;
|
|
70
|
-
if (!userId) return
|
|
103
|
+
if (!userId) return admissionDenialMessage(LOGIN_REQUIRED_CODE, options.locale);
|
|
71
104
|
// Roll out revalidation explicitly; a code upgrade alone must preserve the
|
|
72
105
|
// existing admission behavior during a Supabase/network incident.
|
|
73
106
|
if (!options.enforceGrace) {
|
|
74
107
|
const subscription = await check(userId);
|
|
75
|
-
if (subscription.status === "inactive") return
|
|
108
|
+
if (subscription.status === "inactive") return admissionDenialMessage(MEMBERSHIP_REQUIRED_CODE, options.locale);
|
|
76
109
|
if (subscription.status === "unknown") warn(`subscription check unavailable (${subscription.reason}); admitting ${userId}`);
|
|
77
110
|
return undefined;
|
|
78
111
|
}
|
|
@@ -111,8 +144,10 @@ export function requirePro(
|
|
|
111
144
|
await entry.pending;
|
|
112
145
|
}
|
|
113
146
|
if (account.result?.status === "active") return undefined;
|
|
114
|
-
if (account.result?.status === "inactive" || account.lastKnown === "inactive")
|
|
147
|
+
if (account.result?.status === "inactive" || account.lastKnown === "inactive") {
|
|
148
|
+
return admissionDenialMessage(MEMBERSHIP_REQUIRED_CODE, options.locale);
|
|
149
|
+
}
|
|
115
150
|
if (account.graceFrom !== undefined && now() - account.graceFrom < graceMs) return undefined;
|
|
116
|
-
return "
|
|
151
|
+
return admissionDenialMessage("temporarily_unavailable", options.locale);
|
|
117
152
|
};
|
|
118
153
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/astro-DOly5024.js","assets/json-Cp-IABpG.js","assets/javascript-wDzz0qaB.js","assets/typescript-BPQ3VLAy.js","assets/css-Z72CF80r.js","assets/postcss-DnzrXTVv.js","assets/tsx-COt5Ahok.js","assets/cpp-DddhVWhK.js","assets/c-BIGW1oBm.js","assets/elixir-DkJLSxtU.js","assets/html-BlS82ilI.js","assets/graphql-ChdNCCLP.js","assets/jsx-g9-lgVsj.js","assets/latex-BK3a6r9z.js","assets/r-Cf5RLm7j.js","assets/lua-BaeVxFsk.js","assets/nginx-BpAMiNFr.js","assets/perl-5klg-GXX.js","assets/xml-sdJ4AIDG.js","assets/java-CylS5w8V.js","assets/sql-DkvoVjww.js","assets/php-DoruYMF0.js","assets/ruby-KQScI-mG.js","assets/bash-Yzrsuije.js","assets/yaml-Buea-lGh.js","assets/scss-Cw6XMfVs.js","assets/svelte-DoIXUgJc.js","assets/vue-CwSeJimo.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{_ as b}from"./index-BOUajjjs.js";import{t as dr}from"./markdown-gsWh3zpl.js";var E=class extends Error{constructor(e){super(e),this.name="ShikiError"}};function pr(e){return kt(e)}function kt(e){return Array.isArray(e)?gr(e):e instanceof RegExp?e:typeof e=="object"?mr(e):e}function gr(e){let t=[];for(let n=0,r=e.length;n<r;n++)t[n]=kt(e[n]);return t}function mr(e){let t={};for(let n in e)t[n]=kt(e[n]);return t}function mn(e,...t){return t.forEach(n=>{for(let r in n)e[r]=n[r]}),e}function _n(e){const t=~e.lastIndexOf("/")||~e.lastIndexOf("\\");return t===0?e:~t===e.length-1?_n(e.substring(0,e.length-1)):e.substr(~t+1)}var Qe=/\$(\d+)|\${(\d+):\/(downcase|upcase)}/g,we=class{static hasCaptures(e){return e===null?!1:(Qe.lastIndex=0,Qe.test(e))}static replaceCaptures(e,t,n){return e.replace(Qe,(r,s,o,i)=>{let a=n[parseInt(s||o,10)];if(a){let c=t.substring(a.start,a.end);for(;c[0]===".";)c=c.substring(1);switch(i){case"downcase":return c.toLowerCase();case"upcase":return c.toUpperCase();default:return c}}else return r})}};function yn(e,t){return e<t?-1:e>t?1:0}function wn(e,t){if(e===null&&t===null)return 0;if(!e)return-1;if(!t)return 1;let n=e.length,r=t.length;if(n===r){for(let s=0;s<n;s++){let o=yn(e[s],t[s]);if(o!==0)return o}return 0}return n-r}function Nt(e){return!!(/^#[0-9a-f]{6}$/i.test(e)||/^#[0-9a-f]{8}$/i.test(e)||/^#[0-9a-f]{3}$/i.test(e)||/^#[0-9a-f]{4}$/i.test(e))}function bn(e){return e.replace(/[\-\\\{\}\*\+\?\|\^\$\.\,\[\]\(\)\#\s]/g,"\\$&")}var Cn=class{constructor(e){this.fn=e}fn;cache=new Map;get(e){if(this.cache.has(e))return this.cache.get(e);const t=this.fn(e);return this.cache.set(e,t),t}},ve=class{constructor(e,t,n){this._colorMap=e,this._defaults=t,this._root=n}_colorMap;_defaults;_root;static createFromRawTheme(e,t){return this.createFromParsedTheme(wr(e),t)}static createFromParsedTheme(e,t){return Cr(e,t)}_cachedMatchRoot=new Cn(e=>this._root.match(e));getColorMap(){return this._colorMap.getColorMap()}getDefaults(){return this._defaults}match(e){if(e===null)return this._defaults;const t=e.scopeName,r=this._cachedMatchRoot.get(t).find(s=>_r(e.parent,s.parentScopes));return r?new kn(r.fontStyle,r.foreground,r.background):null}},Ke=class Se{constructor(t,n){this.parent=t,this.scopeName=n}parent;scopeName;static push(t,n){for(const r of n)t=new Se(t,r);return t}static from(...t){let n=null;for(let r=0;r<t.length;r++)n=new Se(n,t[r]);return n}push(t){return new Se(this,t)}getSegments(){let t=this;const n=[];for(;t;)n.push(t.scopeName),t=t.parent;return n.reverse(),n}toString(){return this.getSegments().join(" ")}extends(t){return this===t?!0:this.parent===null?!1:this.parent.extends(t)}getExtensionIfDefined(t){const n=[];let r=this;for(;r&&r!==t;)n.push(r.scopeName),r=r.parent;return r===t?n.reverse():void 0}};function _r(e,t){if(t.length===0)return!0;for(let n=0;n<t.length;n++){let r=t[n],s=!1;if(r===">"){if(n===t.length-1)return!1;r=t[++n],s=!0}for(;e&&!yr(e.scopeName,r);){if(s)return!1;e=e.parent}if(!e)return!1;e=e.parent}return!0}function yr(e,t){return t===e||e.startsWith(t)&&e[t.length]==="."}var kn=class{constructor(e,t,n){this.fontStyle=e,this.foregroundId=t,this.backgroundId=n}fontStyle;foregroundId;backgroundId};function wr(e){if(!e)return[];if(!e.settings||!Array.isArray(e.settings))return[];let t=e.settings,n=[],r=0;for(let s=0,o=t.length;s<o;s++){let i=t[s];if(!i.settings)continue;let a;if(typeof i.scope=="string"){let h=i.scope;h=h.replace(/^[,]+/,""),h=h.replace(/[,]+$/,""),a=h.split(",")}else Array.isArray(i.scope)?a=i.scope:a=[""];let c=-1;if(typeof i.settings.fontStyle=="string"){c=0;let h=i.settings.fontStyle.split(" ");for(let f=0,d=h.length;f<d;f++)switch(h[f]){case"italic":c=c|1;break;case"bold":c=c|2;break;case"underline":c=c|4;break;case"strikethrough":c=c|8;break}}let l=null;typeof i.settings.foreground=="string"&&Nt(i.settings.foreground)&&(l=i.settings.foreground);let u=null;typeof i.settings.background=="string"&&Nt(i.settings.background)&&(u=i.settings.background);for(let h=0,f=a.length;h<f;h++){let p=a[h].trim().split(" "),_=p[p.length-1],y=null;p.length>1&&(y=p.slice(0,p.length-1),y.reverse()),n[r++]=new br(_,y,s,c,l,u)}}return n}var br=class{constructor(e,t,n,r,s,o){this.scope=e,this.parentScopes=t,this.index=n,this.fontStyle=r,this.foreground=s,this.background=o}scope;parentScopes;index;fontStyle;foreground;background},$=(e=>(e[e.NotSet=-1]="NotSet",e[e.None=0]="None",e[e.Italic=1]="Italic",e[e.Bold=2]="Bold",e[e.Underline=4]="Underline",e[e.Strikethrough=8]="Strikethrough",e))($||{});function Cr(e,t){e.sort((c,l)=>{let u=yn(c.scope,l.scope);return u!==0||(u=wn(c.parentScopes,l.parentScopes),u!==0)?u:c.index-l.index});let n=0,r="#000000",s="#ffffff";for(;e.length>=1&&e[0].scope==="";){let c=e.shift();c.fontStyle!==-1&&(n=c.fontStyle),c.foreground!==null&&(r=c.foreground),c.background!==null&&(s=c.background)}let o=new kr(t),i=new kn(n,o.getId(r),o.getId(s)),a=new Er(new at(0,null,-1,0,0),[]);for(let c=0,l=e.length;c<l;c++){let u=e[c];a.insert(0,u.scope,u.parentScopes,u.fontStyle,o.getId(u.foreground),o.getId(u.background))}return new ve(o,i,a)}var kr=class{_isFrozen;_lastColorId;_id2color;_color2id;constructor(e){if(this._lastColorId=0,this._id2color=[],this._color2id=Object.create(null),Array.isArray(e)){this._isFrozen=!0;for(let t=0,n=e.length;t<n;t++)this._color2id[e[t]]=t,this._id2color[t]=e[t]}else this._isFrozen=!1}getId(e){if(e===null)return 0;e=e.toUpperCase();let t=this._color2id[e];if(t)return t;if(this._isFrozen)throw new Error(`Missing color in color map - ${e}`);return t=++this._lastColorId,this._color2id[e]=t,this._id2color[t]=e,t}getColorMap(){return this._id2color.slice(0)}},Sr=Object.freeze([]),at=class Sn{scopeDepth;parentScopes;fontStyle;foreground;background;constructor(t,n,r,s,o){this.scopeDepth=t,this.parentScopes=n||Sr,this.fontStyle=r,this.foreground=s,this.background=o}clone(){return new Sn(this.scopeDepth,this.parentScopes,this.fontStyle,this.foreground,this.background)}static cloneArr(t){let n=[];for(let r=0,s=t.length;r<s;r++)n[r]=t[r].clone();return n}acceptOverwrite(t,n,r,s){this.scopeDepth>t?console.log("how did this happen?"):this.scopeDepth=t,n!==-1&&(this.fontStyle=n),r!==0&&(this.foreground=r),s!==0&&(this.background=s)}},Er=class ct{constructor(t,n=[],r={}){this._mainRule=t,this._children=r,this._rulesWithParentScopes=n}_mainRule;_children;_rulesWithParentScopes;static _cmpBySpecificity(t,n){if(t.scopeDepth!==n.scopeDepth)return n.scopeDepth-t.scopeDepth;let r=0,s=0;for(;t.parentScopes[r]===">"&&r++,n.parentScopes[s]===">"&&s++,!(r>=t.parentScopes.length||s>=n.parentScopes.length);){const o=n.parentScopes[s].length-t.parentScopes[r].length;if(o!==0)return o;r++,s++}return n.parentScopes.length-t.parentScopes.length}match(t){if(t!==""){let r=t.indexOf("."),s,o;if(r===-1?(s=t,o=""):(s=t.substring(0,r),o=t.substring(r+1)),this._children.hasOwnProperty(s))return this._children[s].match(o)}const n=this._rulesWithParentScopes.concat(this._mainRule);return n.sort(ct._cmpBySpecificity),n}insert(t,n,r,s,o,i){if(n===""){this._doInsertHere(t,r,s,o,i);return}let a=n.indexOf("."),c,l;a===-1?(c=n,l=""):(c=n.substring(0,a),l=n.substring(a+1));let u;this._children.hasOwnProperty(c)?u=this._children[c]:(u=new ct(this._mainRule.clone(),at.cloneArr(this._rulesWithParentScopes)),this._children[c]=u),u.insert(t+1,l,r,s,o,i)}_doInsertHere(t,n,r,s,o){if(n===null){this._mainRule.acceptOverwrite(t,r,s,o);return}for(let i=0,a=this._rulesWithParentScopes.length;i<a;i++){let c=this._rulesWithParentScopes[i];if(wn(c.parentScopes,n)===0){c.acceptOverwrite(t,r,s,o);return}}r===-1&&(r=this._mainRule.fontStyle),s===0&&(s=this._mainRule.foreground),o===0&&(o=this._mainRule.background),this._rulesWithParentScopes.push(new at(t,n,r,s,o))}},J=class N{static toBinaryStr(t){return t.toString(2).padStart(32,"0")}static print(t){const n=N.getLanguageId(t),r=N.getTokenType(t),s=N.getFontStyle(t),o=N.getForeground(t),i=N.getBackground(t);console.log({languageId:n,tokenType:r,fontStyle:s,foreground:o,background:i})}static getLanguageId(t){return(t&255)>>>0}static getTokenType(t){return(t&768)>>>8}static containsBalancedBrackets(t){return(t&1024)!==0}static getFontStyle(t){return(t&30720)>>>11}static getForeground(t){return(t&16744448)>>>15}static getBackground(t){return(t&4278190080)>>>24}static set(t,n,r,s,o,i,a){let c=N.getLanguageId(t),l=N.getTokenType(t),u=N.containsBalancedBrackets(t)?1:0,h=N.getFontStyle(t),f=N.getForeground(t),d=N.getBackground(t);return n!==0&&(c=n),r!==8&&(l=r),s!==null&&(u=s?1:0),o!==-1&&(h=o),i!==0&&(f=i),a!==0&&(d=a),(c<<0|l<<8|u<<10|h<<11|f<<15|d<<24)>>>0}};function Ae(e,t){const n=[],r=Ir(e);let s=r.next();for(;s!==null;){let c=0;if(s.length===2&&s.charAt(1)===":"){switch(s.charAt(0)){case"R":c=1;break;case"L":c=-1;break;default:console.log(`Unknown priority ${s} in scope selector`)}s=r.next()}let l=i();if(n.push({matcher:l,priority:c}),s!==",")break;s=r.next()}return n;function o(){if(s==="-"){s=r.next();const c=o();return l=>!!c&&!c(l)}if(s==="("){s=r.next();const c=a();return s===")"&&(s=r.next()),c}if(Pt(s)){const c=[];do c.push(s),s=r.next();while(Pt(s));return l=>t(c,l)}return null}function i(){const c=[];let l=o();for(;l;)c.push(l),l=o();return u=>c.every(h=>h(u))}function a(){const c=[];let l=i();for(;l&&(c.push(l),s==="|"||s===",");){do s=r.next();while(s==="|"||s===",");l=i()}return u=>c.some(h=>h(u))}}function Pt(e){return!!e&&!!e.match(/[\w\.:]+/)}function Ir(e){let t=/([LR]:|[\w\.:][\w\.:\-]*|[\,\|\-\(\)])/g,n=t.exec(e);return{next:()=>{if(!n)return null;const r=n[0];return n=t.exec(e),r}}}function En(e){typeof e.dispose=="function"&&e.dispose()}var fe=class{constructor(e){this.scopeName=e}scopeName;toKey(){return this.scopeName}},vr=class{constructor(e,t){this.scopeName=e,this.ruleName=t}scopeName;ruleName;toKey(){return`${this.scopeName}#${this.ruleName}`}},Ar=class{_references=[];_seenReferenceKeys=new Set;get references(){return this._references}visitedRule=new Set;add(e){const t=e.toKey();this._seenReferenceKeys.has(t)||(this._seenReferenceKeys.add(t),this._references.push(e))}},xr=class{constructor(e,t){this.repo=e,this.initialScopeName=t,this.seenFullScopeRequests.add(this.initialScopeName),this.Q=[new fe(this.initialScopeName)]}repo;initialScopeName;seenFullScopeRequests=new Set;seenPartialScopeRequests=new Set;Q;processQueue(){const e=this.Q;this.Q=[];const t=new Ar;for(const n of e)Rr(n,this.initialScopeName,this.repo,t);for(const n of t.references)if(n instanceof fe){if(this.seenFullScopeRequests.has(n.scopeName))continue;this.seenFullScopeRequests.add(n.scopeName),this.Q.push(n)}else{if(this.seenFullScopeRequests.has(n.scopeName)||this.seenPartialScopeRequests.has(n.toKey()))continue;this.seenPartialScopeRequests.add(n.toKey()),this.Q.push(n)}}};function Rr(e,t,n,r){const s=n.lookup(e.scopeName);if(!s){if(e.scopeName===t)throw new Error(`No grammar provided for <${t}>`);return}const o=n.lookup(t);e instanceof fe?Ee({baseGrammar:o,selfGrammar:s},r):lt(e.ruleName,{baseGrammar:o,selfGrammar:s,repository:s.repository},r);const i=n.injections(e.scopeName);if(i)for(const a of i)r.add(new fe(a))}function lt(e,t,n){if(t.repository&&t.repository[e]){const r=t.repository[e];xe([r],t,n)}}function Ee(e,t){e.selfGrammar.patterns&&Array.isArray(e.selfGrammar.patterns)&&xe(e.selfGrammar.patterns,{...e,repository:e.selfGrammar.repository},t),e.selfGrammar.injections&&xe(Object.values(e.selfGrammar.injections),{...e,repository:e.selfGrammar.repository},t)}function xe(e,t,n){for(const r of e){if(n.visitedRule.has(r))continue;n.visitedRule.add(r);const s=r.repository?mn({},t.repository,r.repository):t.repository;Array.isArray(r.patterns)&&xe(r.patterns,{...t,repository:s},n);const o=r.include;if(!o)continue;const i=In(o);switch(i.kind){case 0:Ee({...t,selfGrammar:t.baseGrammar},n);break;case 1:Ee(t,n);break;case 2:lt(i.ruleName,{...t,repository:s},n);break;case 3:case 4:const a=i.scopeName===t.selfGrammar.scopeName?t.selfGrammar:i.scopeName===t.baseGrammar.scopeName?t.baseGrammar:void 0;if(a){const c={baseGrammar:t.baseGrammar,selfGrammar:a,repository:s};i.kind===4?lt(i.ruleName,c,n):Ee(c,n)}else i.kind===4?n.add(new vr(i.scopeName,i.ruleName)):n.add(new fe(i.scopeName));break}}}var $r=class{kind=0},Lr=class{kind=1},Nr=class{constructor(e){this.ruleName=e}ruleName;kind=2},Pr=class{constructor(e){this.scopeName=e}scopeName;kind=3},Tr=class{constructor(e,t){this.scopeName=e,this.ruleName=t}scopeName;ruleName;kind=4};function In(e){if(e==="$base")return new $r;if(e==="$self")return new Lr;const t=e.indexOf("#");if(t===-1)return new Pr(e);if(t===0)return new Nr(e.substring(1));{const n=e.substring(0,t),r=e.substring(t+1);return new Tr(n,r)}}var Gr=/\\(\d+)/,Tt=/\\(\d+)/g,Mr=-1,vn=-2;var _e=class{$location;id;_nameIsCapturing;_name;_contentNameIsCapturing;_contentName;constructor(e,t,n,r){this.$location=e,this.id=t,this._name=n||null,this._nameIsCapturing=we.hasCaptures(this._name),this._contentName=r||null,this._contentNameIsCapturing=we.hasCaptures(this._contentName)}get debugName(){const e=this.$location?`${_n(this.$location.filename)}:${this.$location.line}`:"unknown";return`${this.constructor.name}#${this.id} @ ${e}`}getName(e,t){return!this._nameIsCapturing||this._name===null||e===null||t===null?this._name:we.replaceCaptures(this._name,e,t)}getContentName(e,t){return!this._contentNameIsCapturing||this._contentName===null?this._contentName:we.replaceCaptures(this._contentName,e,t)}},Or=class extends _e{retokenizeCapturedWithRuleId;constructor(e,t,n,r,s){super(e,t,n,r),this.retokenizeCapturedWithRuleId=s}dispose(){}collectPatterns(e,t){throw new Error("Not supported!")}compile(e,t){throw new Error("Not supported!")}compileAG(e,t,n,r){throw new Error("Not supported!")}},Br=class extends _e{_match;captures;_cachedCompiledPatterns;constructor(e,t,n,r,s){super(e,t,n,null),this._match=new de(r,this.id),this.captures=s,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}get debugMatchRegExp(){return`${this._match.source}`}collectPatterns(e,t){t.push(this._match)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e).compileAG(e,n,r)}_getCachedCompiledPatterns(e){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new pe,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},Gt=class extends _e{hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(e,t,n,r,s){super(e,t,n,r),this.patterns=s.patterns,this.hasMissingPatterns=s.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}collectPatterns(e,t){for(const n of this.patterns)e.getRule(n).collectPatterns(e,t)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e).compileAG(e,n,r)}_getCachedCompiledPatterns(e){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new pe,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},ut=class extends _e{_begin;beginCaptures;_end;endHasBackReferences;endCaptures;applyEndPatternLast;hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(e,t,n,r,s,o,i,a,c,l){super(e,t,n,r),this._begin=new de(s,this.id),this.beginCaptures=o,this._end=new de(i||"",-1),this.endHasBackReferences=this._end.hasBackReferences,this.endCaptures=a,this.applyEndPatternLast=c||!1,this.patterns=l.patterns,this.hasMissingPatterns=l.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugEndRegExp(){return`${this._end.source}`}getEndWithResolvedBackReferences(e,t){return this._end.resolveBackReferences(e,t)}collectPatterns(e,t){t.push(this._begin)}compile(e,t){return this._getCachedCompiledPatterns(e,t).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e,t).compileAG(e,n,r)}_getCachedCompiledPatterns(e,t){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new pe;for(const n of this.patterns)e.getRule(n).collectPatterns(e,this._cachedCompiledPatterns);this.applyEndPatternLast?this._cachedCompiledPatterns.push(this._end.hasBackReferences?this._end.clone():this._end):this._cachedCompiledPatterns.unshift(this._end.hasBackReferences?this._end.clone():this._end)}return this._end.hasBackReferences&&(this.applyEndPatternLast?this._cachedCompiledPatterns.setSource(this._cachedCompiledPatterns.length()-1,t):this._cachedCompiledPatterns.setSource(0,t)),this._cachedCompiledPatterns}},Re=class extends _e{_begin;beginCaptures;whileCaptures;_while;whileHasBackReferences;hasMissingPatterns;patterns;_cachedCompiledPatterns;_cachedCompiledWhilePatterns;constructor(e,t,n,r,s,o,i,a,c){super(e,t,n,r),this._begin=new de(s,this.id),this.beginCaptures=o,this.whileCaptures=a,this._while=new de(i,vn),this.whileHasBackReferences=this._while.hasBackReferences,this.patterns=c.patterns,this.hasMissingPatterns=c.hasMissingPatterns,this._cachedCompiledPatterns=null,this._cachedCompiledWhilePatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null),this._cachedCompiledWhilePatterns&&(this._cachedCompiledWhilePatterns.dispose(),this._cachedCompiledWhilePatterns=null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugWhileRegExp(){return`${this._while.source}`}getWhileWithResolvedBackReferences(e,t){return this._while.resolveBackReferences(e,t)}collectPatterns(e,t){t.push(this._begin)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e).compileAG(e,n,r)}_getCachedCompiledPatterns(e){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new pe;for(const t of this.patterns)e.getRule(t).collectPatterns(e,this._cachedCompiledPatterns)}return this._cachedCompiledPatterns}compileWhile(e,t){return this._getCachedCompiledWhilePatterns(e,t).compile(e)}compileWhileAG(e,t,n,r){return this._getCachedCompiledWhilePatterns(e,t).compileAG(e,n,r)}_getCachedCompiledWhilePatterns(e,t){return this._cachedCompiledWhilePatterns||(this._cachedCompiledWhilePatterns=new pe,this._cachedCompiledWhilePatterns.push(this._while.hasBackReferences?this._while.clone():this._while)),this._while.hasBackReferences&&this._cachedCompiledWhilePatterns.setSource(0,t||""),this._cachedCompiledWhilePatterns}},An=class R{static createCaptureRule(t,n,r,s,o){return t.registerRule(i=>new Or(n,i,r,s,o))}static getCompiledRuleId(t,n,r){return t.id||n.registerRule(s=>{if(t.id=s,t.match)return new Br(t.$vscodeTextmateLocation,t.id,t.name,t.match,R._compileCaptures(t.captures,n,r));if(typeof t.begin>"u"){t.repository&&(r=mn({},r,t.repository));let o=t.patterns;return typeof o>"u"&&t.include&&(o=[{include:t.include}]),new Gt(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,R._compilePatterns(o,n,r))}return t.while?new Re(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,R._compileCaptures(t.beginCaptures||t.captures,n,r),t.while,R._compileCaptures(t.whileCaptures||t.captures,n,r),R._compilePatterns(t.patterns,n,r)):new ut(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,R._compileCaptures(t.beginCaptures||t.captures,n,r),t.end,R._compileCaptures(t.endCaptures||t.captures,n,r),t.applyEndPatternLast,R._compilePatterns(t.patterns,n,r))}),t.id}static _compileCaptures(t,n,r){let s=[];if(t){let o=0;for(const i in t){if(i==="$vscodeTextmateLocation")continue;const a=parseInt(i,10);a>o&&(o=a)}for(let i=0;i<=o;i++)s[i]=null;for(const i in t){if(i==="$vscodeTextmateLocation")continue;const a=parseInt(i,10);let c=0;t[i].patterns&&(c=R.getCompiledRuleId(t[i],n,r)),s[a]=R.createCaptureRule(n,t[i].$vscodeTextmateLocation,t[i].name,t[i].contentName,c)}}return s}static _compilePatterns(t,n,r){let s=[];if(t)for(let o=0,i=t.length;o<i;o++){const a=t[o];let c=-1;if(a.include){const l=In(a.include);switch(l.kind){case 0:case 1:c=R.getCompiledRuleId(r[a.include],n,r);break;case 2:let u=r[l.ruleName];u&&(c=R.getCompiledRuleId(u,n,r));break;case 3:case 4:const h=l.scopeName,f=l.kind===4?l.ruleName:null,d=n.getExternalGrammar(h,r);if(d)if(f){let p=d.repository[f];p&&(c=R.getCompiledRuleId(p,n,d.repository))}else c=R.getCompiledRuleId(d.repository.$self,n,d.repository);break}}else c=R.getCompiledRuleId(a,n,r);if(c!==-1){const l=n.getRule(c);let u=!1;if((l instanceof Gt||l instanceof ut||l instanceof Re)&&l.hasMissingPatterns&&l.patterns.length===0&&(u=!0),u)continue;s.push(c)}}return{patterns:s,hasMissingPatterns:(t?t.length:0)!==s.length}}},de=class xn{source;ruleId;hasAnchor;hasBackReferences;_anchorCache;constructor(t,n){if(t&&typeof t=="string"){const r=t.length;let s=0,o=[],i=!1;for(let a=0;a<r;a++)if(t.charAt(a)==="\\"&&a+1<r){const l=t.charAt(a+1);l==="z"?(o.push(t.substring(s,a)),o.push("$(?!\\n)(?<!\\n)"),s=a+2):(l==="A"||l==="G")&&(i=!0),a++}this.hasAnchor=i,s===0?this.source=t:(o.push(t.substring(s,r)),this.source=o.join(""))}else this.hasAnchor=!1,this.source=t;this.hasAnchor?this._anchorCache=this._buildAnchorCache():this._anchorCache=null,this.ruleId=n,typeof this.source=="string"?this.hasBackReferences=Gr.test(this.source):this.hasBackReferences=!1}clone(){return new xn(this.source,this.ruleId)}setSource(t){this.source!==t&&(this.source=t,this.hasAnchor&&(this._anchorCache=this._buildAnchorCache()))}resolveBackReferences(t,n){if(typeof this.source!="string")throw new Error("This method should only be called if the source is a string");let r=n.map(s=>t.substring(s.start,s.end));return Tt.lastIndex=0,this.source.replace(Tt,(s,o)=>bn(r[parseInt(o,10)]||""))}_buildAnchorCache(){if(typeof this.source!="string")throw new Error("This method should only be called if the source is a string");let t=[],n=[],r=[],s=[],o,i,a,c;for(o=0,i=this.source.length;o<i;o++)a=this.source.charAt(o),t[o]=a,n[o]=a,r[o]=a,s[o]=a,a==="\\"&&o+1<i&&(c=this.source.charAt(o+1),c==="A"?(t[o+1]="",n[o+1]="",r[o+1]="A",s[o+1]="A"):c==="G"?(t[o+1]="",n[o+1]="G",r[o+1]="",s[o+1]="G"):(t[o+1]=c,n[o+1]=c,r[o+1]=c,s[o+1]=c),o++);return{A0_G0:t.join(""),A0_G1:n.join(""),A1_G0:r.join(""),A1_G1:s.join("")}}resolveAnchors(t,n){return!this.hasAnchor||!this._anchorCache||typeof this.source!="string"?this.source:t?n?this._anchorCache.A1_G1:this._anchorCache.A1_G0:n?this._anchorCache.A0_G1:this._anchorCache.A0_G0}},pe=class{_items;_hasAnchors;_cached;_anchorCache;constructor(){this._items=[],this._hasAnchors=!1,this._cached=null,this._anchorCache={A0_G0:null,A0_G1:null,A1_G0:null,A1_G1:null}}dispose(){this._disposeCaches()}_disposeCaches(){this._cached&&(this._cached.dispose(),this._cached=null),this._anchorCache.A0_G0&&(this._anchorCache.A0_G0.dispose(),this._anchorCache.A0_G0=null),this._anchorCache.A0_G1&&(this._anchorCache.A0_G1.dispose(),this._anchorCache.A0_G1=null),this._anchorCache.A1_G0&&(this._anchorCache.A1_G0.dispose(),this._anchorCache.A1_G0=null),this._anchorCache.A1_G1&&(this._anchorCache.A1_G1.dispose(),this._anchorCache.A1_G1=null)}push(e){this._items.push(e),this._hasAnchors=this._hasAnchors||e.hasAnchor}unshift(e){this._items.unshift(e),this._hasAnchors=this._hasAnchors||e.hasAnchor}length(){return this._items.length}setSource(e,t){this._items[e].source!==t&&(this._disposeCaches(),this._items[e].setSource(t))}compile(e){if(!this._cached){let t=this._items.map(n=>n.source);this._cached=new Mt(e,t,this._items.map(n=>n.ruleId))}return this._cached}compileAG(e,t,n){return this._hasAnchors?t?n?(this._anchorCache.A1_G1||(this._anchorCache.A1_G1=this._resolveAnchors(e,t,n)),this._anchorCache.A1_G1):(this._anchorCache.A1_G0||(this._anchorCache.A1_G0=this._resolveAnchors(e,t,n)),this._anchorCache.A1_G0):n?(this._anchorCache.A0_G1||(this._anchorCache.A0_G1=this._resolveAnchors(e,t,n)),this._anchorCache.A0_G1):(this._anchorCache.A0_G0||(this._anchorCache.A0_G0=this._resolveAnchors(e,t,n)),this._anchorCache.A0_G0):this.compile(e)}_resolveAnchors(e,t,n){let r=this._items.map(s=>s.resolveAnchors(t,n));return new Mt(e,r,this._items.map(s=>s.ruleId))}},Mt=class{constructor(e,t,n){this.regExps=t,this.rules=n,this.scanner=e.createOnigScanner(t)}regExps;rules;scanner;dispose(){typeof this.scanner.dispose=="function"&&this.scanner.dispose()}toString(){const e=[];for(let t=0,n=this.rules.length;t<n;t++)e.push(" - "+this.rules[t]+": "+this.regExps[t]);return e.join(`
|
|
2
|
+
import{_ as b}from"./index-CaTd0eIv.js";import{t as dr}from"./markdown-gsWh3zpl.js";var E=class extends Error{constructor(e){super(e),this.name="ShikiError"}};function pr(e){return kt(e)}function kt(e){return Array.isArray(e)?gr(e):e instanceof RegExp?e:typeof e=="object"?mr(e):e}function gr(e){let t=[];for(let n=0,r=e.length;n<r;n++)t[n]=kt(e[n]);return t}function mr(e){let t={};for(let n in e)t[n]=kt(e[n]);return t}function mn(e,...t){return t.forEach(n=>{for(let r in n)e[r]=n[r]}),e}function _n(e){const t=~e.lastIndexOf("/")||~e.lastIndexOf("\\");return t===0?e:~t===e.length-1?_n(e.substring(0,e.length-1)):e.substr(~t+1)}var Qe=/\$(\d+)|\${(\d+):\/(downcase|upcase)}/g,we=class{static hasCaptures(e){return e===null?!1:(Qe.lastIndex=0,Qe.test(e))}static replaceCaptures(e,t,n){return e.replace(Qe,(r,s,o,i)=>{let a=n[parseInt(s||o,10)];if(a){let c=t.substring(a.start,a.end);for(;c[0]===".";)c=c.substring(1);switch(i){case"downcase":return c.toLowerCase();case"upcase":return c.toUpperCase();default:return c}}else return r})}};function yn(e,t){return e<t?-1:e>t?1:0}function wn(e,t){if(e===null&&t===null)return 0;if(!e)return-1;if(!t)return 1;let n=e.length,r=t.length;if(n===r){for(let s=0;s<n;s++){let o=yn(e[s],t[s]);if(o!==0)return o}return 0}return n-r}function Nt(e){return!!(/^#[0-9a-f]{6}$/i.test(e)||/^#[0-9a-f]{8}$/i.test(e)||/^#[0-9a-f]{3}$/i.test(e)||/^#[0-9a-f]{4}$/i.test(e))}function bn(e){return e.replace(/[\-\\\{\}\*\+\?\|\^\$\.\,\[\]\(\)\#\s]/g,"\\$&")}var Cn=class{constructor(e){this.fn=e}fn;cache=new Map;get(e){if(this.cache.has(e))return this.cache.get(e);const t=this.fn(e);return this.cache.set(e,t),t}},ve=class{constructor(e,t,n){this._colorMap=e,this._defaults=t,this._root=n}_colorMap;_defaults;_root;static createFromRawTheme(e,t){return this.createFromParsedTheme(wr(e),t)}static createFromParsedTheme(e,t){return Cr(e,t)}_cachedMatchRoot=new Cn(e=>this._root.match(e));getColorMap(){return this._colorMap.getColorMap()}getDefaults(){return this._defaults}match(e){if(e===null)return this._defaults;const t=e.scopeName,r=this._cachedMatchRoot.get(t).find(s=>_r(e.parent,s.parentScopes));return r?new kn(r.fontStyle,r.foreground,r.background):null}},Ke=class Se{constructor(t,n){this.parent=t,this.scopeName=n}parent;scopeName;static push(t,n){for(const r of n)t=new Se(t,r);return t}static from(...t){let n=null;for(let r=0;r<t.length;r++)n=new Se(n,t[r]);return n}push(t){return new Se(this,t)}getSegments(){let t=this;const n=[];for(;t;)n.push(t.scopeName),t=t.parent;return n.reverse(),n}toString(){return this.getSegments().join(" ")}extends(t){return this===t?!0:this.parent===null?!1:this.parent.extends(t)}getExtensionIfDefined(t){const n=[];let r=this;for(;r&&r!==t;)n.push(r.scopeName),r=r.parent;return r===t?n.reverse():void 0}};function _r(e,t){if(t.length===0)return!0;for(let n=0;n<t.length;n++){let r=t[n],s=!1;if(r===">"){if(n===t.length-1)return!1;r=t[++n],s=!0}for(;e&&!yr(e.scopeName,r);){if(s)return!1;e=e.parent}if(!e)return!1;e=e.parent}return!0}function yr(e,t){return t===e||e.startsWith(t)&&e[t.length]==="."}var kn=class{constructor(e,t,n){this.fontStyle=e,this.foregroundId=t,this.backgroundId=n}fontStyle;foregroundId;backgroundId};function wr(e){if(!e)return[];if(!e.settings||!Array.isArray(e.settings))return[];let t=e.settings,n=[],r=0;for(let s=0,o=t.length;s<o;s++){let i=t[s];if(!i.settings)continue;let a;if(typeof i.scope=="string"){let h=i.scope;h=h.replace(/^[,]+/,""),h=h.replace(/[,]+$/,""),a=h.split(",")}else Array.isArray(i.scope)?a=i.scope:a=[""];let c=-1;if(typeof i.settings.fontStyle=="string"){c=0;let h=i.settings.fontStyle.split(" ");for(let f=0,d=h.length;f<d;f++)switch(h[f]){case"italic":c=c|1;break;case"bold":c=c|2;break;case"underline":c=c|4;break;case"strikethrough":c=c|8;break}}let l=null;typeof i.settings.foreground=="string"&&Nt(i.settings.foreground)&&(l=i.settings.foreground);let u=null;typeof i.settings.background=="string"&&Nt(i.settings.background)&&(u=i.settings.background);for(let h=0,f=a.length;h<f;h++){let p=a[h].trim().split(" "),_=p[p.length-1],y=null;p.length>1&&(y=p.slice(0,p.length-1),y.reverse()),n[r++]=new br(_,y,s,c,l,u)}}return n}var br=class{constructor(e,t,n,r,s,o){this.scope=e,this.parentScopes=t,this.index=n,this.fontStyle=r,this.foreground=s,this.background=o}scope;parentScopes;index;fontStyle;foreground;background},$=(e=>(e[e.NotSet=-1]="NotSet",e[e.None=0]="None",e[e.Italic=1]="Italic",e[e.Bold=2]="Bold",e[e.Underline=4]="Underline",e[e.Strikethrough=8]="Strikethrough",e))($||{});function Cr(e,t){e.sort((c,l)=>{let u=yn(c.scope,l.scope);return u!==0||(u=wn(c.parentScopes,l.parentScopes),u!==0)?u:c.index-l.index});let n=0,r="#000000",s="#ffffff";for(;e.length>=1&&e[0].scope==="";){let c=e.shift();c.fontStyle!==-1&&(n=c.fontStyle),c.foreground!==null&&(r=c.foreground),c.background!==null&&(s=c.background)}let o=new kr(t),i=new kn(n,o.getId(r),o.getId(s)),a=new Er(new at(0,null,-1,0,0),[]);for(let c=0,l=e.length;c<l;c++){let u=e[c];a.insert(0,u.scope,u.parentScopes,u.fontStyle,o.getId(u.foreground),o.getId(u.background))}return new ve(o,i,a)}var kr=class{_isFrozen;_lastColorId;_id2color;_color2id;constructor(e){if(this._lastColorId=0,this._id2color=[],this._color2id=Object.create(null),Array.isArray(e)){this._isFrozen=!0;for(let t=0,n=e.length;t<n;t++)this._color2id[e[t]]=t,this._id2color[t]=e[t]}else this._isFrozen=!1}getId(e){if(e===null)return 0;e=e.toUpperCase();let t=this._color2id[e];if(t)return t;if(this._isFrozen)throw new Error(`Missing color in color map - ${e}`);return t=++this._lastColorId,this._color2id[e]=t,this._id2color[t]=e,t}getColorMap(){return this._id2color.slice(0)}},Sr=Object.freeze([]),at=class Sn{scopeDepth;parentScopes;fontStyle;foreground;background;constructor(t,n,r,s,o){this.scopeDepth=t,this.parentScopes=n||Sr,this.fontStyle=r,this.foreground=s,this.background=o}clone(){return new Sn(this.scopeDepth,this.parentScopes,this.fontStyle,this.foreground,this.background)}static cloneArr(t){let n=[];for(let r=0,s=t.length;r<s;r++)n[r]=t[r].clone();return n}acceptOverwrite(t,n,r,s){this.scopeDepth>t?console.log("how did this happen?"):this.scopeDepth=t,n!==-1&&(this.fontStyle=n),r!==0&&(this.foreground=r),s!==0&&(this.background=s)}},Er=class ct{constructor(t,n=[],r={}){this._mainRule=t,this._children=r,this._rulesWithParentScopes=n}_mainRule;_children;_rulesWithParentScopes;static _cmpBySpecificity(t,n){if(t.scopeDepth!==n.scopeDepth)return n.scopeDepth-t.scopeDepth;let r=0,s=0;for(;t.parentScopes[r]===">"&&r++,n.parentScopes[s]===">"&&s++,!(r>=t.parentScopes.length||s>=n.parentScopes.length);){const o=n.parentScopes[s].length-t.parentScopes[r].length;if(o!==0)return o;r++,s++}return n.parentScopes.length-t.parentScopes.length}match(t){if(t!==""){let r=t.indexOf("."),s,o;if(r===-1?(s=t,o=""):(s=t.substring(0,r),o=t.substring(r+1)),this._children.hasOwnProperty(s))return this._children[s].match(o)}const n=this._rulesWithParentScopes.concat(this._mainRule);return n.sort(ct._cmpBySpecificity),n}insert(t,n,r,s,o,i){if(n===""){this._doInsertHere(t,r,s,o,i);return}let a=n.indexOf("."),c,l;a===-1?(c=n,l=""):(c=n.substring(0,a),l=n.substring(a+1));let u;this._children.hasOwnProperty(c)?u=this._children[c]:(u=new ct(this._mainRule.clone(),at.cloneArr(this._rulesWithParentScopes)),this._children[c]=u),u.insert(t+1,l,r,s,o,i)}_doInsertHere(t,n,r,s,o){if(n===null){this._mainRule.acceptOverwrite(t,r,s,o);return}for(let i=0,a=this._rulesWithParentScopes.length;i<a;i++){let c=this._rulesWithParentScopes[i];if(wn(c.parentScopes,n)===0){c.acceptOverwrite(t,r,s,o);return}}r===-1&&(r=this._mainRule.fontStyle),s===0&&(s=this._mainRule.foreground),o===0&&(o=this._mainRule.background),this._rulesWithParentScopes.push(new at(t,n,r,s,o))}},J=class N{static toBinaryStr(t){return t.toString(2).padStart(32,"0")}static print(t){const n=N.getLanguageId(t),r=N.getTokenType(t),s=N.getFontStyle(t),o=N.getForeground(t),i=N.getBackground(t);console.log({languageId:n,tokenType:r,fontStyle:s,foreground:o,background:i})}static getLanguageId(t){return(t&255)>>>0}static getTokenType(t){return(t&768)>>>8}static containsBalancedBrackets(t){return(t&1024)!==0}static getFontStyle(t){return(t&30720)>>>11}static getForeground(t){return(t&16744448)>>>15}static getBackground(t){return(t&4278190080)>>>24}static set(t,n,r,s,o,i,a){let c=N.getLanguageId(t),l=N.getTokenType(t),u=N.containsBalancedBrackets(t)?1:0,h=N.getFontStyle(t),f=N.getForeground(t),d=N.getBackground(t);return n!==0&&(c=n),r!==8&&(l=r),s!==null&&(u=s?1:0),o!==-1&&(h=o),i!==0&&(f=i),a!==0&&(d=a),(c<<0|l<<8|u<<10|h<<11|f<<15|d<<24)>>>0}};function Ae(e,t){const n=[],r=Ir(e);let s=r.next();for(;s!==null;){let c=0;if(s.length===2&&s.charAt(1)===":"){switch(s.charAt(0)){case"R":c=1;break;case"L":c=-1;break;default:console.log(`Unknown priority ${s} in scope selector`)}s=r.next()}let l=i();if(n.push({matcher:l,priority:c}),s!==",")break;s=r.next()}return n;function o(){if(s==="-"){s=r.next();const c=o();return l=>!!c&&!c(l)}if(s==="("){s=r.next();const c=a();return s===")"&&(s=r.next()),c}if(Pt(s)){const c=[];do c.push(s),s=r.next();while(Pt(s));return l=>t(c,l)}return null}function i(){const c=[];let l=o();for(;l;)c.push(l),l=o();return u=>c.every(h=>h(u))}function a(){const c=[];let l=i();for(;l&&(c.push(l),s==="|"||s===",");){do s=r.next();while(s==="|"||s===",");l=i()}return u=>c.some(h=>h(u))}}function Pt(e){return!!e&&!!e.match(/[\w\.:]+/)}function Ir(e){let t=/([LR]:|[\w\.:][\w\.:\-]*|[\,\|\-\(\)])/g,n=t.exec(e);return{next:()=>{if(!n)return null;const r=n[0];return n=t.exec(e),r}}}function En(e){typeof e.dispose=="function"&&e.dispose()}var fe=class{constructor(e){this.scopeName=e}scopeName;toKey(){return this.scopeName}},vr=class{constructor(e,t){this.scopeName=e,this.ruleName=t}scopeName;ruleName;toKey(){return`${this.scopeName}#${this.ruleName}`}},Ar=class{_references=[];_seenReferenceKeys=new Set;get references(){return this._references}visitedRule=new Set;add(e){const t=e.toKey();this._seenReferenceKeys.has(t)||(this._seenReferenceKeys.add(t),this._references.push(e))}},xr=class{constructor(e,t){this.repo=e,this.initialScopeName=t,this.seenFullScopeRequests.add(this.initialScopeName),this.Q=[new fe(this.initialScopeName)]}repo;initialScopeName;seenFullScopeRequests=new Set;seenPartialScopeRequests=new Set;Q;processQueue(){const e=this.Q;this.Q=[];const t=new Ar;for(const n of e)Rr(n,this.initialScopeName,this.repo,t);for(const n of t.references)if(n instanceof fe){if(this.seenFullScopeRequests.has(n.scopeName))continue;this.seenFullScopeRequests.add(n.scopeName),this.Q.push(n)}else{if(this.seenFullScopeRequests.has(n.scopeName)||this.seenPartialScopeRequests.has(n.toKey()))continue;this.seenPartialScopeRequests.add(n.toKey()),this.Q.push(n)}}};function Rr(e,t,n,r){const s=n.lookup(e.scopeName);if(!s){if(e.scopeName===t)throw new Error(`No grammar provided for <${t}>`);return}const o=n.lookup(t);e instanceof fe?Ee({baseGrammar:o,selfGrammar:s},r):lt(e.ruleName,{baseGrammar:o,selfGrammar:s,repository:s.repository},r);const i=n.injections(e.scopeName);if(i)for(const a of i)r.add(new fe(a))}function lt(e,t,n){if(t.repository&&t.repository[e]){const r=t.repository[e];xe([r],t,n)}}function Ee(e,t){e.selfGrammar.patterns&&Array.isArray(e.selfGrammar.patterns)&&xe(e.selfGrammar.patterns,{...e,repository:e.selfGrammar.repository},t),e.selfGrammar.injections&&xe(Object.values(e.selfGrammar.injections),{...e,repository:e.selfGrammar.repository},t)}function xe(e,t,n){for(const r of e){if(n.visitedRule.has(r))continue;n.visitedRule.add(r);const s=r.repository?mn({},t.repository,r.repository):t.repository;Array.isArray(r.patterns)&&xe(r.patterns,{...t,repository:s},n);const o=r.include;if(!o)continue;const i=In(o);switch(i.kind){case 0:Ee({...t,selfGrammar:t.baseGrammar},n);break;case 1:Ee(t,n);break;case 2:lt(i.ruleName,{...t,repository:s},n);break;case 3:case 4:const a=i.scopeName===t.selfGrammar.scopeName?t.selfGrammar:i.scopeName===t.baseGrammar.scopeName?t.baseGrammar:void 0;if(a){const c={baseGrammar:t.baseGrammar,selfGrammar:a,repository:s};i.kind===4?lt(i.ruleName,c,n):Ee(c,n)}else i.kind===4?n.add(new vr(i.scopeName,i.ruleName)):n.add(new fe(i.scopeName));break}}}var $r=class{kind=0},Lr=class{kind=1},Nr=class{constructor(e){this.ruleName=e}ruleName;kind=2},Pr=class{constructor(e){this.scopeName=e}scopeName;kind=3},Tr=class{constructor(e,t){this.scopeName=e,this.ruleName=t}scopeName;ruleName;kind=4};function In(e){if(e==="$base")return new $r;if(e==="$self")return new Lr;const t=e.indexOf("#");if(t===-1)return new Pr(e);if(t===0)return new Nr(e.substring(1));{const n=e.substring(0,t),r=e.substring(t+1);return new Tr(n,r)}}var Gr=/\\(\d+)/,Tt=/\\(\d+)/g,Mr=-1,vn=-2;var _e=class{$location;id;_nameIsCapturing;_name;_contentNameIsCapturing;_contentName;constructor(e,t,n,r){this.$location=e,this.id=t,this._name=n||null,this._nameIsCapturing=we.hasCaptures(this._name),this._contentName=r||null,this._contentNameIsCapturing=we.hasCaptures(this._contentName)}get debugName(){const e=this.$location?`${_n(this.$location.filename)}:${this.$location.line}`:"unknown";return`${this.constructor.name}#${this.id} @ ${e}`}getName(e,t){return!this._nameIsCapturing||this._name===null||e===null||t===null?this._name:we.replaceCaptures(this._name,e,t)}getContentName(e,t){return!this._contentNameIsCapturing||this._contentName===null?this._contentName:we.replaceCaptures(this._contentName,e,t)}},Or=class extends _e{retokenizeCapturedWithRuleId;constructor(e,t,n,r,s){super(e,t,n,r),this.retokenizeCapturedWithRuleId=s}dispose(){}collectPatterns(e,t){throw new Error("Not supported!")}compile(e,t){throw new Error("Not supported!")}compileAG(e,t,n,r){throw new Error("Not supported!")}},Br=class extends _e{_match;captures;_cachedCompiledPatterns;constructor(e,t,n,r,s){super(e,t,n,null),this._match=new de(r,this.id),this.captures=s,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}get debugMatchRegExp(){return`${this._match.source}`}collectPatterns(e,t){t.push(this._match)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e).compileAG(e,n,r)}_getCachedCompiledPatterns(e){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new pe,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},Gt=class extends _e{hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(e,t,n,r,s){super(e,t,n,r),this.patterns=s.patterns,this.hasMissingPatterns=s.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}collectPatterns(e,t){for(const n of this.patterns)e.getRule(n).collectPatterns(e,t)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e).compileAG(e,n,r)}_getCachedCompiledPatterns(e){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new pe,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},ut=class extends _e{_begin;beginCaptures;_end;endHasBackReferences;endCaptures;applyEndPatternLast;hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(e,t,n,r,s,o,i,a,c,l){super(e,t,n,r),this._begin=new de(s,this.id),this.beginCaptures=o,this._end=new de(i||"",-1),this.endHasBackReferences=this._end.hasBackReferences,this.endCaptures=a,this.applyEndPatternLast=c||!1,this.patterns=l.patterns,this.hasMissingPatterns=l.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugEndRegExp(){return`${this._end.source}`}getEndWithResolvedBackReferences(e,t){return this._end.resolveBackReferences(e,t)}collectPatterns(e,t){t.push(this._begin)}compile(e,t){return this._getCachedCompiledPatterns(e,t).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e,t).compileAG(e,n,r)}_getCachedCompiledPatterns(e,t){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new pe;for(const n of this.patterns)e.getRule(n).collectPatterns(e,this._cachedCompiledPatterns);this.applyEndPatternLast?this._cachedCompiledPatterns.push(this._end.hasBackReferences?this._end.clone():this._end):this._cachedCompiledPatterns.unshift(this._end.hasBackReferences?this._end.clone():this._end)}return this._end.hasBackReferences&&(this.applyEndPatternLast?this._cachedCompiledPatterns.setSource(this._cachedCompiledPatterns.length()-1,t):this._cachedCompiledPatterns.setSource(0,t)),this._cachedCompiledPatterns}},Re=class extends _e{_begin;beginCaptures;whileCaptures;_while;whileHasBackReferences;hasMissingPatterns;patterns;_cachedCompiledPatterns;_cachedCompiledWhilePatterns;constructor(e,t,n,r,s,o,i,a,c){super(e,t,n,r),this._begin=new de(s,this.id),this.beginCaptures=o,this.whileCaptures=a,this._while=new de(i,vn),this.whileHasBackReferences=this._while.hasBackReferences,this.patterns=c.patterns,this.hasMissingPatterns=c.hasMissingPatterns,this._cachedCompiledPatterns=null,this._cachedCompiledWhilePatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null),this._cachedCompiledWhilePatterns&&(this._cachedCompiledWhilePatterns.dispose(),this._cachedCompiledWhilePatterns=null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugWhileRegExp(){return`${this._while.source}`}getWhileWithResolvedBackReferences(e,t){return this._while.resolveBackReferences(e,t)}collectPatterns(e,t){t.push(this._begin)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e).compileAG(e,n,r)}_getCachedCompiledPatterns(e){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new pe;for(const t of this.patterns)e.getRule(t).collectPatterns(e,this._cachedCompiledPatterns)}return this._cachedCompiledPatterns}compileWhile(e,t){return this._getCachedCompiledWhilePatterns(e,t).compile(e)}compileWhileAG(e,t,n,r){return this._getCachedCompiledWhilePatterns(e,t).compileAG(e,n,r)}_getCachedCompiledWhilePatterns(e,t){return this._cachedCompiledWhilePatterns||(this._cachedCompiledWhilePatterns=new pe,this._cachedCompiledWhilePatterns.push(this._while.hasBackReferences?this._while.clone():this._while)),this._while.hasBackReferences&&this._cachedCompiledWhilePatterns.setSource(0,t||""),this._cachedCompiledWhilePatterns}},An=class R{static createCaptureRule(t,n,r,s,o){return t.registerRule(i=>new Or(n,i,r,s,o))}static getCompiledRuleId(t,n,r){return t.id||n.registerRule(s=>{if(t.id=s,t.match)return new Br(t.$vscodeTextmateLocation,t.id,t.name,t.match,R._compileCaptures(t.captures,n,r));if(typeof t.begin>"u"){t.repository&&(r=mn({},r,t.repository));let o=t.patterns;return typeof o>"u"&&t.include&&(o=[{include:t.include}]),new Gt(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,R._compilePatterns(o,n,r))}return t.while?new Re(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,R._compileCaptures(t.beginCaptures||t.captures,n,r),t.while,R._compileCaptures(t.whileCaptures||t.captures,n,r),R._compilePatterns(t.patterns,n,r)):new ut(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,R._compileCaptures(t.beginCaptures||t.captures,n,r),t.end,R._compileCaptures(t.endCaptures||t.captures,n,r),t.applyEndPatternLast,R._compilePatterns(t.patterns,n,r))}),t.id}static _compileCaptures(t,n,r){let s=[];if(t){let o=0;for(const i in t){if(i==="$vscodeTextmateLocation")continue;const a=parseInt(i,10);a>o&&(o=a)}for(let i=0;i<=o;i++)s[i]=null;for(const i in t){if(i==="$vscodeTextmateLocation")continue;const a=parseInt(i,10);let c=0;t[i].patterns&&(c=R.getCompiledRuleId(t[i],n,r)),s[a]=R.createCaptureRule(n,t[i].$vscodeTextmateLocation,t[i].name,t[i].contentName,c)}}return s}static _compilePatterns(t,n,r){let s=[];if(t)for(let o=0,i=t.length;o<i;o++){const a=t[o];let c=-1;if(a.include){const l=In(a.include);switch(l.kind){case 0:case 1:c=R.getCompiledRuleId(r[a.include],n,r);break;case 2:let u=r[l.ruleName];u&&(c=R.getCompiledRuleId(u,n,r));break;case 3:case 4:const h=l.scopeName,f=l.kind===4?l.ruleName:null,d=n.getExternalGrammar(h,r);if(d)if(f){let p=d.repository[f];p&&(c=R.getCompiledRuleId(p,n,d.repository))}else c=R.getCompiledRuleId(d.repository.$self,n,d.repository);break}}else c=R.getCompiledRuleId(a,n,r);if(c!==-1){const l=n.getRule(c);let u=!1;if((l instanceof Gt||l instanceof ut||l instanceof Re)&&l.hasMissingPatterns&&l.patterns.length===0&&(u=!0),u)continue;s.push(c)}}return{patterns:s,hasMissingPatterns:(t?t.length:0)!==s.length}}},de=class xn{source;ruleId;hasAnchor;hasBackReferences;_anchorCache;constructor(t,n){if(t&&typeof t=="string"){const r=t.length;let s=0,o=[],i=!1;for(let a=0;a<r;a++)if(t.charAt(a)==="\\"&&a+1<r){const l=t.charAt(a+1);l==="z"?(o.push(t.substring(s,a)),o.push("$(?!\\n)(?<!\\n)"),s=a+2):(l==="A"||l==="G")&&(i=!0),a++}this.hasAnchor=i,s===0?this.source=t:(o.push(t.substring(s,r)),this.source=o.join(""))}else this.hasAnchor=!1,this.source=t;this.hasAnchor?this._anchorCache=this._buildAnchorCache():this._anchorCache=null,this.ruleId=n,typeof this.source=="string"?this.hasBackReferences=Gr.test(this.source):this.hasBackReferences=!1}clone(){return new xn(this.source,this.ruleId)}setSource(t){this.source!==t&&(this.source=t,this.hasAnchor&&(this._anchorCache=this._buildAnchorCache()))}resolveBackReferences(t,n){if(typeof this.source!="string")throw new Error("This method should only be called if the source is a string");let r=n.map(s=>t.substring(s.start,s.end));return Tt.lastIndex=0,this.source.replace(Tt,(s,o)=>bn(r[parseInt(o,10)]||""))}_buildAnchorCache(){if(typeof this.source!="string")throw new Error("This method should only be called if the source is a string");let t=[],n=[],r=[],s=[],o,i,a,c;for(o=0,i=this.source.length;o<i;o++)a=this.source.charAt(o),t[o]=a,n[o]=a,r[o]=a,s[o]=a,a==="\\"&&o+1<i&&(c=this.source.charAt(o+1),c==="A"?(t[o+1]="",n[o+1]="",r[o+1]="A",s[o+1]="A"):c==="G"?(t[o+1]="",n[o+1]="G",r[o+1]="",s[o+1]="G"):(t[o+1]=c,n[o+1]=c,r[o+1]=c,s[o+1]=c),o++);return{A0_G0:t.join(""),A0_G1:n.join(""),A1_G0:r.join(""),A1_G1:s.join("")}}resolveAnchors(t,n){return!this.hasAnchor||!this._anchorCache||typeof this.source!="string"?this.source:t?n?this._anchorCache.A1_G1:this._anchorCache.A1_G0:n?this._anchorCache.A0_G1:this._anchorCache.A0_G0}},pe=class{_items;_hasAnchors;_cached;_anchorCache;constructor(){this._items=[],this._hasAnchors=!1,this._cached=null,this._anchorCache={A0_G0:null,A0_G1:null,A1_G0:null,A1_G1:null}}dispose(){this._disposeCaches()}_disposeCaches(){this._cached&&(this._cached.dispose(),this._cached=null),this._anchorCache.A0_G0&&(this._anchorCache.A0_G0.dispose(),this._anchorCache.A0_G0=null),this._anchorCache.A0_G1&&(this._anchorCache.A0_G1.dispose(),this._anchorCache.A0_G1=null),this._anchorCache.A1_G0&&(this._anchorCache.A1_G0.dispose(),this._anchorCache.A1_G0=null),this._anchorCache.A1_G1&&(this._anchorCache.A1_G1.dispose(),this._anchorCache.A1_G1=null)}push(e){this._items.push(e),this._hasAnchors=this._hasAnchors||e.hasAnchor}unshift(e){this._items.unshift(e),this._hasAnchors=this._hasAnchors||e.hasAnchor}length(){return this._items.length}setSource(e,t){this._items[e].source!==t&&(this._disposeCaches(),this._items[e].setSource(t))}compile(e){if(!this._cached){let t=this._items.map(n=>n.source);this._cached=new Mt(e,t,this._items.map(n=>n.ruleId))}return this._cached}compileAG(e,t,n){return this._hasAnchors?t?n?(this._anchorCache.A1_G1||(this._anchorCache.A1_G1=this._resolveAnchors(e,t,n)),this._anchorCache.A1_G1):(this._anchorCache.A1_G0||(this._anchorCache.A1_G0=this._resolveAnchors(e,t,n)),this._anchorCache.A1_G0):n?(this._anchorCache.A0_G1||(this._anchorCache.A0_G1=this._resolveAnchors(e,t,n)),this._anchorCache.A0_G1):(this._anchorCache.A0_G0||(this._anchorCache.A0_G0=this._resolveAnchors(e,t,n)),this._anchorCache.A0_G0):this.compile(e)}_resolveAnchors(e,t,n){let r=this._items.map(s=>s.resolveAnchors(t,n));return new Mt(e,r,this._items.map(s=>s.ruleId))}},Mt=class{constructor(e,t,n){this.regExps=t,this.rules=n,this.scanner=e.createOnigScanner(t)}regExps;rules;scanner;dispose(){typeof this.scanner.dispose=="function"&&this.scanner.dispose()}toString(){const e=[];for(let t=0,n=this.rules.length;t<n;t++)e.push(" - "+this.rules[t]+": "+this.regExps[t]);return e.join(`
|
|
3
3
|
`)}findNextMatchSync(e,t,n){const r=this.scanner.findNextMatchSync(e,t,n);return r?{ruleId:this.rules[r.index],captureIndices:r.captureIndices}:null}},Ze=class{constructor(e,t){this.languageId=e,this.tokenType=t}languageId;tokenType},Dr=class ht{_defaultAttributes;_embeddedLanguagesMatcher;constructor(t,n){this._defaultAttributes=new Ze(t,8),this._embeddedLanguagesMatcher=new Fr(Object.entries(n||{}))}getDefaultAttributes(){return this._defaultAttributes}getBasicScopeAttributes(t){return t===null?ht._NULL_SCOPE_METADATA:this._getBasicScopeAttributes.get(t)}static _NULL_SCOPE_METADATA=new Ze(0,0);_getBasicScopeAttributes=new Cn(t=>{const n=this._scopeToLanguage(t),r=this._toStandardTokenType(t);return new Ze(n,r)});_scopeToLanguage(t){return this._embeddedLanguagesMatcher.match(t)||0}_toStandardTokenType(t){const n=t.match(ht.STANDARD_TOKEN_TYPE_REGEXP);if(!n)return 8;switch(n[1]){case"comment":return 1;case"string":return 2;case"regex":return 3;case"meta.embedded":return 0}throw new Error("Unexpected match for standard token type!")}static STANDARD_TOKEN_TYPE_REGEXP=/\b(comment|string|regex|meta\.embedded)\b/},Fr=class{values;scopesRegExp;constructor(e){if(e.length===0)this.values=null,this.scopesRegExp=null;else{this.values=new Map(e);const t=e.map(([n,r])=>bn(n));t.sort(),t.reverse(),this.scopesRegExp=new RegExp(`^((${t.join(")|(")}))($|\\.)`,"")}}match(e){if(!this.scopesRegExp)return;const t=e.match(this.scopesRegExp);if(t)return this.values.get(t[1])}},Ot=class{constructor(e,t){this.stack=e,this.stoppedEarly=t}stack;stoppedEarly};function Rn(e,t,n,r,s,o,i,a){const c=t.content.length;let l=!1,u=-1;if(i){const d=jr(e,t,n,r,s,o);s=d.stack,r=d.linePos,n=d.isFirstLine,u=d.anchorPosition}const h=Date.now();for(;!l;){if(a!==0&&Date.now()-h>a)return new Ot(s,!0);f()}return new Ot(s,!1);function f(){const d=Ur(e,t,n,r,s,u);if(!d){o.produce(s,c),l=!0;return}const p=d.captureIndices,_=d.matchedRuleId,y=p&&p.length>0?p[0].end>r:!1;if(_===Mr){const g=s.getRule(e);o.produce(s,p[0].start),s=s.withContentNameScopesList(s.nameScopesList),le(e,t,n,s,o,g.endCaptures,p),o.produce(s,p[0].end);const m=s;if(s=s.parent,u=m.getAnchorPos(),!y&&m.getEnterPos()===r){s=m,o.produce(s,c),l=!0;return}}else{const g=e.getRule(_);o.produce(s,p[0].start);const m=s,w=g.getName(t.content,p),k=s.contentNameScopesList.pushAttributed(w,e);if(s=s.push(_,r,u,p[0].end===c,null,k,k),g instanceof ut){const S=g;le(e,t,n,s,o,S.beginCaptures,p),o.produce(s,p[0].end),u=p[0].end;const x=S.getContentName(t.content,p),L=k.pushAttributed(x,e);if(s=s.withContentNameScopesList(L),S.endHasBackReferences&&(s=s.withEndRule(S.getEndWithResolvedBackReferences(t.content,p))),!y&&m.hasSameRuleAs(s)){s=s.pop(),o.produce(s,c),l=!0;return}}else if(g instanceof Re){const S=g;le(e,t,n,s,o,S.beginCaptures,p),o.produce(s,p[0].end),u=p[0].end;const x=S.getContentName(t.content,p),L=k.pushAttributed(x,e);if(s=s.withContentNameScopesList(L),S.whileHasBackReferences&&(s=s.withEndRule(S.getWhileWithResolvedBackReferences(t.content,p))),!y&&m.hasSameRuleAs(s)){s=s.pop(),o.produce(s,c),l=!0;return}}else if(le(e,t,n,s,o,g.captures,p),o.produce(s,p[0].end),s=s.pop(),!y){s=s.safePop(),o.produce(s,c),l=!0;return}}p[0].end>r&&(r=p[0].end,n=!1)}}function jr(e,t,n,r,s,o){let i=s.beginRuleCapturedEOL?0:-1;const a=[];for(let c=s;c;c=c.pop()){const l=c.getRule(e);l instanceof Re&&a.push({rule:l,stack:c})}for(let c=a.pop();c;c=a.pop()){const{ruleScanner:l,findOptions:u}=zr(c.rule,e,c.stack.endRule,n,r===i),h=l.findNextMatchSync(t,r,u);if(h){if(h.ruleId!==vn){s=c.stack.pop();break}h.captureIndices&&h.captureIndices.length&&(o.produce(c.stack,h.captureIndices[0].start),le(e,t,n,c.stack,o,c.rule.whileCaptures,h.captureIndices),o.produce(c.stack,h.captureIndices[0].end),i=h.captureIndices[0].end,h.captureIndices[0].end>r&&(r=h.captureIndices[0].end,n=!1))}else{s=c.stack.pop();break}}return{stack:s,linePos:r,anchorPosition:i,isFirstLine:n}}function Ur(e,t,n,r,s,o){const i=Vr(e,t,n,r,s,o),a=e.getInjections();if(a.length===0)return i;const c=Wr(a,e,t,n,r,s,o);if(!c)return i;if(!i)return c;const l=i.captureIndices[0].start,u=c.captureIndices[0].start;return u<l||c.priorityMatch&&u===l?c:i}function Vr(e,t,n,r,s,o){const i=s.getRule(e),{ruleScanner:a,findOptions:c}=$n(i,e,s.endRule,n,r===o),l=a.findNextMatchSync(t,r,c);return l?{captureIndices:l.captureIndices,matchedRuleId:l.ruleId}:null}function Wr(e,t,n,r,s,o,i){let a=Number.MAX_VALUE,c=null,l,u=0;const h=o.contentNameScopesList.getScopeNames();for(let f=0,d=e.length;f<d;f++){const p=e[f];if(!p.matcher(h))continue;const _=t.getRule(p.ruleId),{ruleScanner:y,findOptions:g}=$n(_,t,null,r,s===i),m=y.findNextMatchSync(n,s,g);if(!m)continue;const w=m.captureIndices[0].start;if(!(w>=a)&&(a=w,c=m.captureIndices,l=m.ruleId,u=p.priority,a===s))break}return c?{priorityMatch:u===-1,captureIndices:c,matchedRuleId:l}:null}function $n(e,t,n,r,s){return{ruleScanner:e.compileAG(t,n,r,s),findOptions:0}}function zr(e,t,n,r,s){return{ruleScanner:e.compileWhileAG(t,n,r,s),findOptions:0}}function le(e,t,n,r,s,o,i){if(o.length===0)return;const a=t.content,c=Math.min(o.length,i.length),l=[],u=i[0].end;for(let h=0;h<c;h++){const f=o[h];if(f===null)continue;const d=i[h];if(d.length===0)continue;if(d.start>u)break;for(;l.length>0&&l[l.length-1].endPos<=d.start;)s.produceFromScopes(l[l.length-1].scopes,l[l.length-1].endPos),l.pop();if(l.length>0?s.produceFromScopes(l[l.length-1].scopes,d.start):s.produce(r,d.start),f.retokenizeCapturedWithRuleId){const _=f.getName(a,i),y=r.contentNameScopesList.pushAttributed(_,e),g=f.getContentName(a,i),m=y.pushAttributed(g,e),w=r.push(f.retokenizeCapturedWithRuleId,d.start,-1,!1,null,y,m),k=e.createOnigString(a.substring(0,d.end));Rn(e,k,n&&d.start===0,d.start,w,s,!1,0),En(k);continue}const p=f.getName(a,i);if(p!==null){const y=(l.length>0?l[l.length-1].scopes:r.contentNameScopesList).pushAttributed(p,e);l.push(new Hr(y,d.end))}}for(;l.length>0;)s.produceFromScopes(l[l.length-1].scopes,l[l.length-1].endPos),l.pop()}var Hr=class{scopes;endPos;constructor(e,t){this.scopes=e,this.endPos=t}};function qr(e,t,n,r,s,o,i,a){return new Qr(e,t,n,r,s,o,i,a)}function Bt(e,t,n,r,s){const o=Ae(t,$e),i=An.getCompiledRuleId(n,r,s.repository);for(const a of o)e.push({debugSelector:t,matcher:a.matcher,ruleId:i,grammar:s,priority:a.priority})}function $e(e,t){if(t.length<e.length)return!1;let n=0;return e.every(r=>{for(let s=n;s<t.length;s++)if(Xr(t[s],r))return n=s+1,!0;return!1})}function Xr(e,t){if(!e)return!1;if(e===t)return!0;const n=t.length;return e.length>n&&e.substr(0,n)===t&&e[n]==="."}var Qr=class{constructor(e,t,n,r,s,o,i,a){if(this._rootScopeName=e,this.balancedBracketSelectors=o,this._onigLib=a,this._basicScopeAttributesProvider=new Dr(n,r),this._rootId=-1,this._lastRuleId=0,this._ruleId2desc=[null],this._includedGrammars={},this._grammarRepository=i,this._grammar=Dt(t,null),this._injections=null,this._tokenTypeMatchers=[],s)for(const c of Object.keys(s)){const l=Ae(c,$e);for(const u of l)this._tokenTypeMatchers.push({matcher:u.matcher,type:s[c]})}}_rootScopeName;balancedBracketSelectors;_onigLib;_rootId;_lastRuleId;_ruleId2desc;_includedGrammars;_grammarRepository;_grammar;_injections;_basicScopeAttributesProvider;_tokenTypeMatchers;get themeProvider(){return this._grammarRepository}dispose(){for(const e of this._ruleId2desc)e&&e.dispose()}createOnigScanner(e){return this._onigLib.createOnigScanner(e)}createOnigString(e){return this._onigLib.createOnigString(e)}getMetadataForScope(e){return this._basicScopeAttributesProvider.getBasicScopeAttributes(e)}_collectInjections(){const e={lookup:s=>s===this._rootScopeName?this._grammar:this.getExternalGrammar(s),injections:s=>this._grammarRepository.injections(s)},t=[],n=this._rootScopeName,r=e.lookup(n);if(r){const s=r.injections;if(s)for(let i in s)Bt(t,i,s[i],this,r);const o=this._grammarRepository.injections(n);o&&o.forEach(i=>{const a=this.getExternalGrammar(i);if(a){const c=a.injectionSelector;c&&Bt(t,c,a,this,a)}})}return t.sort((s,o)=>s.priority-o.priority),t}getInjections(){return this._injections===null&&(this._injections=this._collectInjections()),this._injections}registerRule(e){const t=++this._lastRuleId,n=e(t);return this._ruleId2desc[t]=n,n}getRule(e){return this._ruleId2desc[e]}getExternalGrammar(e,t){if(this._includedGrammars[e])return this._includedGrammars[e];if(this._grammarRepository){const n=this._grammarRepository.lookup(e);if(n)return this._includedGrammars[e]=Dt(n,t&&t.$base),this._includedGrammars[e]}}tokenizeLine(e,t,n=0){const r=this._tokenize(e,t,!1,n);return{tokens:r.lineTokens.getResult(r.ruleStack,r.lineLength),ruleStack:r.ruleStack,stoppedEarly:r.stoppedEarly}}tokenizeLine2(e,t,n=0){const r=this._tokenize(e,t,!0,n);return{tokens:r.lineTokens.getBinaryResult(r.ruleStack,r.lineLength),ruleStack:r.ruleStack,stoppedEarly:r.stoppedEarly}}_tokenize(e,t,n,r){this._rootId===-1&&(this._rootId=An.getCompiledRuleId(this._grammar.repository.$self,this,this._grammar.repository),this.getInjections());let s;if(!t||t===ft.NULL){s=!0;const l=this._basicScopeAttributesProvider.getDefaultAttributes(),u=this.themeProvider.getDefaults(),h=J.set(0,l.languageId,l.tokenType,null,u.fontStyle,u.foregroundId,u.backgroundId),f=this.getRule(this._rootId).getName(null,null);let d;f?d=ue.createRootAndLookUpScopeName(f,h,this):d=ue.createRoot("unknown",h),t=new ft(null,this._rootId,-1,-1,!1,null,d,d)}else s=!1,t.reset();e=e+`
|
|
4
4
|
`;const o=this.createOnigString(e),i=o.content.length,a=new Zr(n,e,this._tokenTypeMatchers,this.balancedBracketSelectors),c=Rn(this,o,s,0,t,a,!0,r);return En(o),{lineLength:i,lineTokens:a,ruleStack:c.stack,stoppedEarly:c.stoppedEarly}}};function Dt(e,t){return e=pr(e),e.repository=e.repository||{},e.repository.$self={$vscodeTextmateLocation:e.$vscodeTextmateLocation,patterns:e.patterns,name:e.scopeName},e.repository.$base=t||e.repository.$self,e}var ue=class D{constructor(t,n,r){this.parent=t,this.scopePath=n,this.tokenAttributes=r}parent;scopePath;tokenAttributes;static fromExtension(t,n){let r=t,s=t?.scopePath??null;for(const o of n)s=Ke.push(s,o.scopeNames),r=new D(r,s,o.encodedTokenAttributes);return r}static createRoot(t,n){return new D(null,new Ke(null,t),n)}static createRootAndLookUpScopeName(t,n,r){const s=r.getMetadataForScope(t),o=new Ke(null,t),i=r.themeProvider.themeMatch(o),a=D.mergeAttributes(n,s,i);return new D(null,o,a)}get scopeName(){return this.scopePath.scopeName}toString(){return this.getScopeNames().join(" ")}equals(t){return D.equals(this,t)}static equals(t,n){do{if(t===n||!t&&!n)return!0;if(!t||!n||t.scopeName!==n.scopeName||t.tokenAttributes!==n.tokenAttributes)return!1;t=t.parent,n=n.parent}while(!0)}static mergeAttributes(t,n,r){let s=-1,o=0,i=0;return r!==null&&(s=r.fontStyle,o=r.foregroundId,i=r.backgroundId),J.set(t,n.languageId,n.tokenType,null,s,o,i)}pushAttributed(t,n){if(t===null)return this;if(t.indexOf(" ")===-1)return D._pushAttributed(this,t,n);const r=t.split(/ /g);let s=this;for(const o of r)s=D._pushAttributed(s,o,n);return s}static _pushAttributed(t,n,r){const s=r.getMetadataForScope(n),o=t.scopePath.push(n),i=r.themeProvider.themeMatch(o),a=D.mergeAttributes(t.tokenAttributes,s,i);return new D(t,o,a)}getScopeNames(){return this.scopePath.getSegments()}getExtensionIfDefined(t){const n=[];let r=this;for(;r&&r!==t;)n.push({encodedTokenAttributes:r.tokenAttributes,scopeNames:r.scopePath.getExtensionIfDefined(r.parent?.scopePath??null)}),r=r.parent;return r===t?n.reverse():void 0}},ft=class X{constructor(t,n,r,s,o,i,a,c){this.parent=t,this.ruleId=n,this.beginRuleCapturedEOL=o,this.endRule=i,this.nameScopesList=a,this.contentNameScopesList=c,this.depth=this.parent?this.parent.depth+1:1,this._enterPos=r,this._anchorPos=s}parent;ruleId;beginRuleCapturedEOL;endRule;nameScopesList;contentNameScopesList;_stackElementBrand=void 0;static NULL=new X(null,0,0,0,!1,null,null,null);_enterPos;_anchorPos;depth;equals(t){return t===null?!1:X._equals(this,t)}static _equals(t,n){return t===n?!0:this._structuralEquals(t,n)?ue.equals(t.contentNameScopesList,n.contentNameScopesList):!1}static _structuralEquals(t,n){do{if(t===n||!t&&!n)return!0;if(!t||!n||t.depth!==n.depth||t.ruleId!==n.ruleId||t.endRule!==n.endRule)return!1;t=t.parent,n=n.parent}while(!0)}clone(){return this}static _reset(t){for(;t;)t._enterPos=-1,t._anchorPos=-1,t=t.parent}reset(){X._reset(this)}pop(){return this.parent}safePop(){return this.parent?this.parent:this}push(t,n,r,s,o,i,a){return new X(this,t,n,r,s,o,i,a)}getEnterPos(){return this._enterPos}getAnchorPos(){return this._anchorPos}getRule(t){return t.getRule(this.ruleId)}toString(){const t=[];return this._writeString(t,0),"["+t.join(",")+"]"}_writeString(t,n){return this.parent&&(n=this.parent._writeString(t,n)),t[n++]=`(${this.ruleId}, ${this.nameScopesList?.toString()}, ${this.contentNameScopesList?.toString()})`,n}withContentNameScopesList(t){return this.contentNameScopesList===t?this:this.parent.push(this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,this.endRule,this.nameScopesList,t)}withEndRule(t){return this.endRule===t?this:new X(this.parent,this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,t,this.nameScopesList,this.contentNameScopesList)}hasSameRuleAs(t){let n=this;for(;n&&n._enterPos===t._enterPos;){if(n.ruleId===t.ruleId)return!0;n=n.parent}return!1}toStateStackFrame(){return{ruleId:this.ruleId,beginRuleCapturedEOL:this.beginRuleCapturedEOL,endRule:this.endRule,nameScopesList:this.nameScopesList?.getExtensionIfDefined(this.parent?.nameScopesList??null)??[],contentNameScopesList:this.contentNameScopesList?.getExtensionIfDefined(this.nameScopesList)??[]}}static pushFrame(t,n){const r=ue.fromExtension(t?.nameScopesList??null,n.nameScopesList);return new X(t,n.ruleId,n.enterPos??-1,n.anchorPos??-1,n.beginRuleCapturedEOL,n.endRule,r,ue.fromExtension(r,n.contentNameScopesList))}},Kr=class{balancedBracketScopes;unbalancedBracketScopes;allowAny=!1;constructor(e,t){this.balancedBracketScopes=e.flatMap(n=>n==="*"?(this.allowAny=!0,[]):Ae(n,$e).map(r=>r.matcher)),this.unbalancedBracketScopes=t.flatMap(n=>Ae(n,$e).map(r=>r.matcher))}get matchesAlways(){return this.allowAny&&this.unbalancedBracketScopes.length===0}get matchesNever(){return this.balancedBracketScopes.length===0&&!this.allowAny}match(e){for(const t of this.unbalancedBracketScopes)if(t(e))return!1;for(const t of this.balancedBracketScopes)if(t(e))return!0;return this.allowAny}},Zr=class{constructor(e,t,n,r){this.balancedBracketSelectors=r,this._emitBinaryTokens=e,this._tokenTypeOverrides=n,this._lineText=null,this._tokens=[],this._binaryTokens=[],this._lastTokenEndIndex=0}balancedBracketSelectors;_emitBinaryTokens;_lineText;_tokens;_binaryTokens;_lastTokenEndIndex;_tokenTypeOverrides;produce(e,t){this.produceFromScopes(e.contentNameScopesList,t)}produceFromScopes(e,t){if(this._lastTokenEndIndex>=t)return;if(this._emitBinaryTokens){let r=e?.tokenAttributes??0,s=!1;if(this.balancedBracketSelectors?.matchesAlways&&(s=!0),this._tokenTypeOverrides.length>0||this.balancedBracketSelectors&&!this.balancedBracketSelectors.matchesAlways&&!this.balancedBracketSelectors.matchesNever){const o=e?.getScopeNames()??[];for(const i of this._tokenTypeOverrides)i.matcher(o)&&(r=J.set(r,0,i.type,null,-1,0,0));this.balancedBracketSelectors&&(s=this.balancedBracketSelectors.match(o))}if(s&&(r=J.set(r,0,8,s,-1,0,0)),this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-1]===r){this._lastTokenEndIndex=t;return}this._binaryTokens.push(this._lastTokenEndIndex),this._binaryTokens.push(r),this._lastTokenEndIndex=t;return}const n=e?.getScopeNames()??[];this._tokens.push({startIndex:this._lastTokenEndIndex,endIndex:t,scopes:n}),this._lastTokenEndIndex=t}getResult(e,t){return this._tokens.length>0&&this._tokens[this._tokens.length-1].startIndex===t-1&&this._tokens.pop(),this._tokens.length===0&&(this._lastTokenEndIndex=-1,this.produce(e,t),this._tokens[this._tokens.length-1].startIndex=0),this._tokens}getBinaryResult(e,t){this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-2]===t-1&&(this._binaryTokens.pop(),this._binaryTokens.pop()),this._binaryTokens.length===0&&(this._lastTokenEndIndex=-1,this.produce(e,t),this._binaryTokens[this._binaryTokens.length-2]=0);const n=new Uint32Array(this._binaryTokens.length);for(let r=0,s=this._binaryTokens.length;r<s;r++)n[r]=this._binaryTokens[r];return n}},Jr=class{constructor(e,t){this._onigLib=t,this._theme=e}_onigLib;_grammars=new Map;_rawGrammars=new Map;_injectionGrammars=new Map;_theme;dispose(){for(const e of this._grammars.values())e.dispose()}setTheme(e){this._theme=e}getColorMap(){return this._theme.getColorMap()}addGrammar(e,t){this._rawGrammars.set(e.scopeName,e),t&&this._injectionGrammars.set(e.scopeName,t)}lookup(e){return this._rawGrammars.get(e)}injections(e){return this._injectionGrammars.get(e)}getDefaults(){return this._theme.getDefaults()}themeMatch(e){return this._theme.match(e)}grammarForScopeName(e,t,n,r,s){if(!this._grammars.has(e)){let o=this._rawGrammars.get(e);if(!o)return null;this._grammars.set(e,qr(e,o,t,n,r,s,this,this._onigLib))}return this._grammars.get(e)}},Yr=class{_options;_syncRegistry;_ensureGrammarCache;constructor(t){this._options=t,this._syncRegistry=new Jr(ve.createFromRawTheme(t.theme,t.colorMap),t.onigLib),this._ensureGrammarCache=new Map}dispose(){this._syncRegistry.dispose()}setTheme(t,n){this._syncRegistry.setTheme(ve.createFromRawTheme(t,n))}getColorMap(){return this._syncRegistry.getColorMap()}loadGrammarWithEmbeddedLanguages(t,n,r){return this.loadGrammarWithConfiguration(t,n,{embeddedLanguages:r})}loadGrammarWithConfiguration(t,n,r){return this._loadGrammar(t,n,r.embeddedLanguages,r.tokenTypes,new Kr(r.balancedBracketSelectors||[],r.unbalancedBracketSelectors||[]))}loadGrammar(t){return this._loadGrammar(t,0,null,null,null)}_loadGrammar(t,n,r,s,o){const i=new xr(this._syncRegistry,t);for(;i.Q.length>0;)i.Q.map(a=>this._loadSingleGrammar(a.scopeName)),i.processQueue();return this._grammarForScopeName(t,n,r,s,o)}_loadSingleGrammar(t){this._ensureGrammarCache.has(t)||(this._doLoadSingleGrammar(t),this._ensureGrammarCache.set(t,!0))}_doLoadSingleGrammar(t){const n=this._options.loadGrammar(t);if(n){const r=typeof this._options.getInjections=="function"?this._options.getInjections(t):void 0;this._syncRegistry.addGrammar(n,r)}}addGrammar(t,n=[],r=0,s=null){return this._syncRegistry.addGrammar(t,n),this._grammarForScopeName(t.scopeName,r,s)}_grammarForScopeName(t,n=0,r=null,s=null,o=null){return this._syncRegistry.grammarForScopeName(t,n,r,s,o)}},dt=ft.NULL;function Le(e,t){const n=typeof e=="string"?{}:{...e.colorReplacements},r=typeof e=="string"?e:e.name;for(const[s,o]of Object.entries(t?.colorReplacements||{}))typeof o=="string"?n[s]=o:s===r&&Object.assign(n,o);return n}function H(e,t){return e&&(t?.[e?.toLowerCase()]||e)}function es(e){return Array.isArray(e)?e:[e]}async function Ln(e){return Promise.resolve(typeof e=="function"?e():e).then(t=>t.default||t)}function Oe(e){return!e||["plaintext","txt","text","plain"].includes(e)}function ts(e){return e==="ansi"||Oe(e)}function Be(e){return e==="none"}function ns(e){return Be(e)}const rs=/(\r?\n)/g;function De(e,t=!1){if(e.length===0)return[["",0]];const n=e.split(rs);let r=0;const s=[];for(let o=0;o<n.length;o+=2){const i=t?n[o]+(n[o+1]||""):n[o];s.push([i,r]),r+=n[o].length,r+=n[o+1]?.length||0}return s}const Ft={light:"#333333",dark:"#bbbbbb"},jt={light:"#fffffe",dark:"#1e1e1e"},Ut="__shiki_resolved";function St(e){if(e?.[Ut])return e;const t={...e};t.tokenColors&&!t.settings&&(t.settings=t.tokenColors,delete t.tokenColors),t.type||="dark",t.colorReplacements={...t.colorReplacements},t.settings||=[];let{bg:n,fg:r}=t;if(!n||!r){const a=t.settings?t.settings.find(c=>!c.name&&!c.scope):void 0;a?.settings?.foreground&&(r=a.settings.foreground),a?.settings?.background&&(n=a.settings.background),!r&&t?.colors?.["editor.foreground"]&&(r=t.colors["editor.foreground"]),!n&&t?.colors?.["editor.background"]&&(n=t.colors["editor.background"]),r||(r=t.type==="light"?Ft.light:Ft.dark),n||(n=t.type==="light"?jt.light:jt.dark),t.fg=r,t.bg=n}t.settings[0]&&t.settings[0].settings&&!t.settings[0].scope||t.settings.unshift({settings:{foreground:t.fg,background:t.bg}});let s=0;const o=new Map;function i(a){if(o.has(a))return o.get(a);s+=1;const c=`#${s.toString(16).padStart(8,"0").toLowerCase()}`;return t.colorReplacements?.[`#${c}`]?i(a):(o.set(a,c),c)}t.settings=t.settings.map(a=>{const c=a.settings?.foreground&&!a.settings.foreground.startsWith("#"),l=a.settings?.background&&!a.settings.background.startsWith("#");if(!c&&!l)return a;const u={...a,settings:{...a.settings}};if(c){const h=i(a.settings.foreground);t.colorReplacements[h]=a.settings.foreground,u.settings.foreground=h}if(l){const h=i(a.settings.background);t.colorReplacements[h]=a.settings.background,u.settings.background=h}return u});for(const a of Object.keys(t.colors||{}))if((a==="editor.foreground"||a==="editor.background"||a.startsWith("terminal.ansi"))&&!t.colors[a]?.startsWith("#")){const c=i(t.colors[a]);t.colorReplacements[c]=t.colors[a],t.colors[a]=c}return Object.defineProperty(t,Ut,{enumerable:!1,writable:!1,value:!0}),t}async function Nn(e){return[...new Set((await Promise.all(e.filter(t=>!ts(t)).map(async t=>await Ln(t).then(n=>Array.isArray(n)?n:[n])))).flat())]}async function Pn(e){return(await Promise.all(e.map(async t=>ns(t)?null:St(await Ln(t))))).filter(t=>!!t)}function Tn(e,t){if(!t)return e;if(t[e]){const n=new Set([e]);for(;t[e];){if(e=t[e],n.has(e))throw new E(`Circular alias \`${[...n].join(" -> ")} -> ${e}\``);n.add(e)}}return e}var ss=class extends Yr{_resolver;_themes;_langs;_alias;_resolvedThemes=new Map;_resolvedGrammars=new Map;_langMap=new Map;_langGraph=new Map;_textmateThemeCache=new WeakMap;_loadedThemesCache=null;_loadedLanguagesCache=null;constructor(e,t,n,r={}){super(e),this._resolver=e,this._themes=t,this._langs=n,this._alias=r,this._themes.map(s=>this.loadTheme(s)),this.loadLanguages(this._langs)}getTheme(e){return typeof e=="string"?this._resolvedThemes.get(e):this.loadTheme(e)}loadTheme(e){const t=St(e);return t.name&&(this._resolvedThemes.set(t.name,t),this._loadedThemesCache=null),t}getLoadedThemes(){return this._loadedThemesCache||(this._loadedThemesCache=[...this._resolvedThemes.keys()]),this._loadedThemesCache}setTheme(e){let t=this._textmateThemeCache.get(e);t||(t=ve.createFromRawTheme(e),this._textmateThemeCache.set(e,t)),this._syncRegistry.setTheme(t)}getGrammar(e){return e=Tn(e,this._alias),this._resolvedGrammars.get(e)}loadLanguage(e){if(this.getGrammar(e.name))return;const t=new Set([...this._langMap.values()].filter(s=>s.embeddedLangsLazy?.includes(e.name)));this._resolver.addLanguage(e);const n={balancedBracketSelectors:e.balancedBracketSelectors||["*"],unbalancedBracketSelectors:e.unbalancedBracketSelectors||[]};this._syncRegistry._rawGrammars.set(e.scopeName,e);const r=this.loadGrammarWithConfiguration(e.scopeName,1,n);if(r.name=e.name,this._resolvedGrammars.set(e.name,r),e.aliases&&e.aliases.forEach(s=>{this._alias[s]=e.name}),this._loadedLanguagesCache=null,t.size)for(const s of t)this._syncRegistry?._grammars?.get(s.scopeName)?.dispose(),this._resolvedGrammars.delete(s.name),this._loadedLanguagesCache=null,this._syncRegistry?._injectionGrammars?.delete(s.scopeName),this._syncRegistry?._grammars?.delete(s.scopeName),this.loadLanguage(this._langMap.get(s.name))}dispose(){super.dispose(),this._resolvedThemes.clear(),this._resolvedGrammars.clear(),this._langMap.clear(),this._langGraph.clear(),this._loadedThemesCache=null}loadLanguages(e){for(const r of e)this.resolveEmbeddedLanguages(r);const t=[...this._langGraph.entries()],n=t.filter(([r,s])=>!s);if(n.length){const r=t.filter(([s,o])=>o?(o.embeddedLanguages||o.embeddedLangs)?.some(i=>n.map(([a])=>a).includes(i)):!1).filter(s=>!n.includes(s));throw new E(`Missing languages ${n.map(([s])=>`\`${s}\``).join(", ")}, required by ${r.map(([s])=>`\`${s}\``).join(", ")}`)}for(const[r,s]of t)this._resolver.addLanguage(s);for(const[r,s]of t)this.loadLanguage(s)}getLoadedLanguages(){return this._loadedLanguagesCache||(this._loadedLanguagesCache=[...new Set([...this._resolvedGrammars.keys(),...Object.keys(this._alias)])]),this._loadedLanguagesCache}resolveEmbeddedLanguages(e){this._langMap.set(e.name,e),this._langGraph.set(e.name,e);const t=e.embeddedLanguages??e.embeddedLangs;if(t)for(const n of t)this._langGraph.set(n,this._langMap.get(n))}},os=class{_langs=new Map;_scopeToLang=new Map;_injections=new Map;_onigLib;constructor(e,t){this._onigLib={createOnigScanner:n=>e.createScanner(n),createOnigString:n=>e.createString(n)},t.forEach(n=>this.addLanguage(n))}get onigLib(){return this._onigLib}getLangRegistration(e){return this._langs.get(e)}loadGrammar(e){return this._scopeToLang.get(e)}addLanguage(e){this._langs.set(e.name,e),e.aliases&&e.aliases.forEach(t=>{this._langs.set(t,e)}),this._scopeToLang.set(e.scopeName,e),e.injectTo&&e.injectTo.forEach(t=>{this._injections.get(t)||this._injections.set(t,[]),this._injections.get(t).includes(e.scopeName)||this._injections.get(t).push(e.scopeName)})}getInjections(e){const t=e.split(".");let n=[];for(let r=1;r<=t.length;r++){const s=t.slice(0,r).join(".");n=[...n,...this._injections.get(s)||[]]}return n}};let ce=0;function is(e){ce+=1,e.warnings!==!1&&ce>=10&&ce%10===0&&console.warn(`[Shiki] ${ce} instances have been created. Shiki is supposed to be used as a singleton, consider refactoring your code to cache your highlighter instance; Or call \`highlighter.dispose()\` to release unused instances.`);let t=!1;if(!e.engine)throw new E("`engine` option is required for synchronous mode");const n=(e.langs||[]).flat(1),r=(e.themes||[]).flat(1).map(St),s=new ss(new os(e.engine,n),r,n,e.langAlias);let o;function i(m){return Tn(m,e.langAlias)}function a(m){y();const w=s.getGrammar(typeof m=="string"?m:m.name);if(!w)throw new E(`Language \`${m}\` not found, you may need to load it first`);return w}function c(m){if(m==="none")return{bg:"",fg:"",name:"none",settings:[],type:"dark"};y();const w=s.getTheme(m);if(!w)throw new E(`Theme \`${m}\` not found, you may need to load it first`);return w}function l(m){y();const w=c(m);return o!==m&&(s.setTheme(w),o=m),{theme:w,colorMap:s.getColorMap()}}function u(){return y(),s.getLoadedThemes()}function h(){return y(),s.getLoadedLanguages()}function f(...m){y(),s.loadLanguages(m.flat(1))}async function d(...m){return f(await Nn(m))}function p(...m){y();for(const w of m.flat(1))s.loadTheme(w)}async function _(...m){return y(),p(await Pn(m))}function y(){if(t)throw new E("Shiki instance has been disposed")}function g(){t||(t=!0,s.dispose(),ce-=1)}return{setTheme:l,getTheme:c,getLanguage:a,getLoadedThemes:u,getLoadedLanguages:h,resolveLangAlias:i,loadLanguage:d,loadLanguageSync:f,loadTheme:_,loadThemeSync:p,dispose:g,[Symbol.dispose]:g}}async function as(e){e.engine||console.warn("`engine` option is required. Use `createOnigurumaEngine` or `createJavaScriptRegexEngine` to create an engine.");const[t,n,r]=await Promise.all([Pn(e.themes||[]),Nn(e.langs||[]),e.engine]);return is({...e,themes:t,langs:n,engine:r})}const Gn=new WeakMap;function Fe(e,t){Gn.set(e,t)}function ge(e){return Gn.get(e)}var je=class Mn{_stacks={};lang;get themes(){return Object.keys(this._stacks)}get theme(){return this.themes[0]}get _stack(){return this._stacks[this.theme]}static initial(t,n){return new Mn(Object.fromEntries(es(n).map(r=>[r,dt])),t)}constructor(...t){if(t.length===2){const[n,r]=t;this.lang=r,this._stacks=n}else{const[n,r,s]=t;this.lang=r,this._stacks={[s]:n}}}getInternalStack(t=this.theme){return this._stacks[t]}getScopes(t=this.theme){return cs(this._stacks[t])}toJSON(){return{lang:this.lang,theme:this.theme,themes:this.themes,scopes:this.getScopes()}}};function cs(e){const t=[],n=new Set;function r(s){if(n.has(s))return;n.add(s);const o=s?.nameScopesList?.scopeName;o&&t.push(o),s.parent&&r(s.parent)}return r(e),t}function ls(e,t){if(!(e instanceof je))throw new E("Invalid grammar state");return e.getInternalStack(t)}const us=/,/,hs=/ /;function On(e,t,n={}){const{theme:r=e.getLoadedThemes()[0]}=n;if(Oe(e.resolveLangAlias(n.lang||"text"))||Be(r))return De(t).map(a=>[{content:a[0],offset:a[1]}]);const{theme:s,colorMap:o}=e.setTheme(r),i=e.getLanguage(n.lang||"text");if(n.grammarState){if(n.grammarState.lang!==i.name)throw new E(`Grammar state language "${n.grammarState.lang}" does not match highlight language "${i.name}"`);if(!n.grammarState.themes.includes(s.name))throw new E(`Grammar state themes "${n.grammarState.themes}" do not contain highlight theme "${s.name}"`)}return ds(t,i,s,o,n)}function fs(...e){if(e.length===2)return ge(e[1]);const[t,n,r={}]=e,{lang:s="text",theme:o=t.getLoadedThemes()[0]}=r;if(Oe(s)||Be(o))throw new E("Plain language does not have grammar state");if(s==="ansi")throw new E("ANSI language does not have grammar state");const{theme:i,colorMap:a}=t.setTheme(o),c=t.getLanguage(s);return new je(Et(n,c,i,a,r).stateStack,c.name,i.name)}function ds(e,t,n,r,s){const o=Et(e,t,n,r,s),i=new je(o.stateStack,t.name,n.name);return Fe(o.tokens,i),o.tokens}function Et(e,t,n,r,s){const o=Le(n,s),{tokenizeMaxLineLength:i=0,tokenizeTimeLimit:a=500,includeExplanation:c=!1}=s,l=De(e);let u=s.grammarState?ls(s.grammarState,n.name)??dt:s.grammarContextCode!=null?Et(s.grammarContextCode,t,n,r,{...s,grammarState:void 0,grammarContextCode:void 0}).stateStack:dt,h=[];const f=[];for(let d=0,p=l.length;d<p;d++){const[_,y]=l[d];if(_===""){h=[],f.push([]);continue}if(i>0&&_.length>=i){h=[],f.push([{content:_,offset:y,color:"",fontStyle:0}]);continue}let g,m,w;c&&c!=="tokenType"&&(g=t.tokenizeLine(_,u,a),m=g.tokens,w=0);const k=t.tokenizeLine2(_,u,a),S=k.tokens.length/2;for(let x=0;x<S;x++){const L=k.tokens[2*x],O=x+1<S?k.tokens[2*x+2]:_.length;if(L===O)continue;const ee=k.tokens[2*x+1],He=H(r[J.getForeground(ee)],o),qe=J.getFontStyle(ee),B={content:_.substring(L,O),offset:y+L,color:He,fontStyle:qe};if(c==="tokenType")B.type=J.getTokenType(ee);else if(c){const $t=[];if(c!=="scopeName")for(const F of n.settings){let te;switch(typeof F.scope){case"string":te=F.scope.split(us).map(Xe=>Xe.trim());break;case"object":te=F.scope;break;default:continue}$t.push({settings:F,selectors:te.map(Xe=>Xe.split(hs))})}B.explanation=[];let Lt=0;for(;L+Lt<O;){const F=m[w],te=_.substring(F.startIndex,F.endIndex);Lt+=te.length,B.explanation.push({content:te,scopes:c==="scopeName"?ps(F.scopes):gs($t,F.scopes)}),w+=1}}h.push(B)}f.push(h),h=[],u=k.ruleStack}return{tokens:f,stateStack:u}}function ps(e){return e.map(t=>({scopeName:t}))}function gs(e,t){const n=[];for(let r=0,s=t.length;r<s;r++){const o=t[r];n[r]={scopeName:o,themeMatches:_s(e,o,t.slice(0,r))}}return n}function Vt(e,t){return e===t||t.substring(0,e.length)===e&&t[e.length]==="."}function ms(e,t,n){if(!Vt(e.at(-1),t))return!1;let r=e.length-2,s=n.length-1;for(;r>=0&&s>=0;)Vt(e[r],n[s])&&(r-=1),s-=1;return r===-1}function _s(e,t,n){const r=[];for(const{selectors:s,settings:o}of e)for(const i of s)if(ms(i,t,n)){r.push(o);break}return r}function Bn(e,t,n,r=On){const s=Object.entries(n.themes).filter(l=>l[1]).map(l=>({color:l[0],theme:l[1]})),o=s.map(l=>{const u=r(e,t,{...n,theme:l.theme});return{tokens:u,state:ge(u),theme:typeof l.theme=="string"?l.theme:l.theme.name}}),i=ys(...o.map(l=>l.tokens)),a=i[0].map((l,u)=>l.map((h,f)=>{const d={content:h.content,variants:{},offset:h.offset};return"includeExplanation"in n&&n.includeExplanation&&(d.explanation=h.explanation),i.forEach((p,_)=>{const{content:y,explanation:g,offset:m,...w}=p[u][f];d.variants[s[_].color]=w}),d})),c=o[0].state?new je(Object.fromEntries(o.map(l=>[l.theme,l.state?.getInternalStack(l.theme)])),o[0].state.lang):void 0;return c&&Fe(a,c),a}function ys(...e){const t=e.map(()=>[]),n=e.length;for(let r=0;r<e[0].length;r++){const s=e.map(c=>c[r]),o=t.map(()=>[]);t.forEach((c,l)=>c.push(o[l]));const i=s.map(()=>0),a=s.map(c=>c[0]);for(;a.every(c=>c);){const c=Math.min(...a.map(l=>l.content.length));for(let l=0;l<n;l++){const u=a[l];u.content.length===c?(o[l].push(u),i[l]+=1,a[l]=s[l][i[l]]):(o[l].push({...u,content:u.content.slice(0,c)}),a[l]={...u,content:u.content.slice(c),offset:u.offset+c})}}}return t}const Wt=/\s+/g;function Dn(e,t){if(!t)return e;e.properties||={},e.properties.class||=[],typeof e.properties.class=="string"&&(e.properties.class=e.properties.class.split(Wt)),Array.isArray(e.properties.class)||(e.properties.class=[]);const n=Array.isArray(t)?t:t.split(Wt);for(const r of n)r&&!e.properties.class.includes(r)&&e.properties.class.push(r);return e}function ws(e){const t=De(e,!0).map(([s])=>s);function n(s){if(s===e.length)return{line:t.length-1,character:t.at(-1).length};let o=s,i=0;for(const a of t){if(o<a.length)break;o-=a.length,i++}return{line:i,character:o}}function r(s,o){let i=0;for(let a=0;a<s;a++)i+=t[a].length;return i+=o,i}return{lines:t,indexToPos:n,posToIndex:r}}const bs=["color","background-color"];function Cs(e,t){let n=0;const r=[];for(const s of t)s>n&&r.push({...e,content:e.content.slice(n,s),offset:e.offset+n}),n=s;return n<e.content.length&&r.push({...e,content:e.content.slice(n),offset:e.offset+n}),r}function ks(e,t){let n=0,r=e.length;for(;n<r;){const s=n+(r-n>>1);e[s]<=t?n=s+1:r=s}return n}function Ss(e,t){const n=[...t instanceof Set?t:new Set(t)].sort((r,s)=>r-s);return n.length?e.map(r=>r.flatMap(s=>{const o=s.offset+s.content.length,i=ks(n,s.offset);let a=i;for(;a<n.length&&n[a]<o;)a++;if(i===a)return s;const c=n.slice(i,a);for(let l=0;l<c.length;l++)c[l]-=s.offset;return Cs(s,c)})):e}function Es(e,t,n,r,s="css-vars"){const o={content:e.content,explanation:e.explanation,offset:e.offset},i=t.map(u=>Ne(e.variants[u])),a=new Set(i.flatMap(u=>Object.keys(u))),c={},l=(u,h)=>{const f=h==="color"?"":h==="background-color"?"-bg":`-${h}`;return n+t[u]+(h==="color"?"":f)};return i.forEach((u,h)=>{for(const f of a){const d=u[f]||"inherit";if(h===0&&r&&bs.includes(f))if(r==="light-dark()"&&i.length>1){const p=t.findIndex(m=>m==="light"),_=t.findIndex(m=>m==="dark");if(p===-1||_===-1)throw new E('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');const y=i[p][f]||"inherit",g=i[_][f]||"inherit";c[f]=`light-dark(${y}, ${g})`,s==="css-vars"&&(c[l(h,f)]=d)}else c[f]=d;else s==="css-vars"&&(c[l(h,f)]=d)}}),o.htmlStyle=c,o}function Ne(e){const t={};if(e.color&&(t.color=e.color),e.bgColor&&(t["background-color"]=e.bgColor),e.fontStyle){e.fontStyle&$.Italic&&(t["font-style"]="italic"),e.fontStyle&$.Bold&&(t["font-weight"]="bold");const n=[];e.fontStyle&$.Underline&&n.push("underline"),e.fontStyle&$.Strikethrough&&n.push("line-through"),n.length&&(t["text-decoration"]=n.join(" "))}return t}function pt(e){return typeof e=="string"?e:Object.entries(e).map(([t,n])=>`${t}:${n}`).join(";")}function Is(){const e=new WeakMap;function t(n){if(!e.has(n.meta)){let s=function(i){if(typeof i=="number"){if(i<0||i>n.source.length)throw new E(`Invalid decoration offset: ${i}. Code length: ${n.source.length}`);return{...r.indexToPos(i),offset:i}}else{const a=r.lines[i.line];if(a===void 0)throw new E(`Invalid decoration position ${JSON.stringify(i)}. Lines length: ${r.lines.length}`);let c=i.character;if(c<0&&(c=a.length+c),c<0||c>a.length)throw new E(`Invalid decoration position ${JSON.stringify(i)}. Line ${i.line} length: ${a.length}`);return{...i,character:c,offset:r.posToIndex(i.line,c)}}};const r=ws(n.source),o=(n.options.decorations||[]).map(i=>({...i,start:s(i.start),end:s(i.end)}));vs(o),e.set(n.meta,{decorations:o,converter:r,source:n.source})}return e.get(n.meta)}return{name:"shiki:decorations",tokens(n){if(this.options.decorations?.length)return Ss(n,t(this).decorations.flatMap(r=>[r.start.offset,r.end.offset]))},code(n){if(!this.options.decorations?.length)return;const r=t(this),s=[...n.children].filter(u=>u.type==="element"&&u.tagName==="span");if(s.length!==r.converter.lines.length)throw new E(`Number of lines in code element (${s.length}) does not match the number of lines in the source (${r.converter.lines.length}). Failed to apply decorations.`);function o(u,h,f,d){const p=s[u];let _="",y=-1,g=-1;if(h===0&&(y=0),f===0&&(g=0),f===Number.POSITIVE_INFINITY&&(g=p.children.length),y===-1||g===-1)for(let w=0;w<p.children.length;w++)_+=Fn(p.children[w]),y===-1&&_.length===h&&(y=w+1),g===-1&&_.length===f&&(g=w+1);if(y===-1)throw new E(`Failed to find start index for decoration ${JSON.stringify(d.start)}`);if(g===-1)throw new E(`Failed to find end index for decoration ${JSON.stringify(d.end)}`);const m=p.children.slice(y,g);if(!d.alwaysWrap&&m.length===p.children.length)a(p,d,"line");else if(!d.alwaysWrap&&m.length===1&&m[0].type==="element")a(m[0],d,"token");else{const w={type:"element",tagName:"span",properties:{},children:m};a(w,d,"wrapper"),p.children.splice(y,m.length,w)}}function i(u,h){s[u]=a(s[u],h,"line")}function a(u,h,f){const d=h.properties||{},p=h.transform||(_=>_);return u.tagName=h.tagName||"span",u.properties={...u.properties,...d,class:u.properties.class},h.properties?.class&&Dn(u,h.properties.class),u=p(u,f)||u,u}const c=[],l=r.decorations.sort((u,h)=>h.start.offset-u.start.offset||u.end.offset-h.end.offset);for(const u of l){const{start:h,end:f}=u;if(h.line===f.line)o(h.line,h.character,f.character,u);else if(h.line<f.line){o(h.line,h.character,Number.POSITIVE_INFINITY,u);for(let d=h.line+1;d<f.line;d++)c.unshift(()=>i(d,u));o(f.line,0,f.character,u)}}c.forEach(u=>u())}}}function vs(e){for(let t=0;t<e.length;t++){const n=e[t];if(n.start.offset>n.end.offset)throw new E(`Invalid decoration range: ${JSON.stringify(n.start)} - ${JSON.stringify(n.end)}`);for(let r=t+1;r<e.length;r++){const s=e[r],o=n.start.offset<=s.start.offset&&s.start.offset<n.end.offset,i=n.start.offset<s.end.offset&&s.end.offset<=n.end.offset,a=s.start.offset<=n.start.offset&&n.start.offset<s.end.offset,c=s.start.offset<n.end.offset&&n.end.offset<=s.end.offset;if(o||i||a||c){if(o&&i||a&&c||a&&n.start.offset===n.end.offset||i&&s.start.offset===s.end.offset)continue;throw new E(`Decorations ${JSON.stringify(n.start)} and ${JSON.stringify(s.start)} intersect.`)}}}}function Fn(e){return e.type==="text"?e.value:e.type==="element"?e.children.map(Fn).join(""):""}const As=[Is()];function Pe(e){const t=xs(e.transformers||[]);return[...t.pre,...t.normal,...t.post,...As]}function xs(e){const t=[],n=[],r=[];for(const s of e)switch(s.enforce){case"pre":t.push(s);break;case"post":n.push(s);break;default:r.push(s)}return{pre:t,post:n,normal:r}}var K=["black","red","green","yellow","blue","magenta","cyan","white","brightBlack","brightRed","brightGreen","brightYellow","brightBlue","brightMagenta","brightCyan","brightWhite"],Je={1:"bold",2:"dim",3:"italic",4:"underline",7:"reverse",8:"hidden",9:"strikethrough"};function Rs(e,t){const n=e.indexOf("\x1B",t);if(n!==-1&&e[n+1]==="["){const r=e.indexOf("m",n);if(r!==-1)return{sequence:e.substring(n+2,r).split(";"),startPosition:n,position:r+1}}return{position:e.length}}function zt(e){const t=e.shift();if(t==="2"){const n=e.splice(0,3).map(r=>Number.parseInt(r));return n.length!==3||n.some(r=>Number.isNaN(r))?void 0:{type:"rgb",rgb:n}}else if(t==="5"){const n=e.shift();if(n)return{type:"table",index:Number(n)}}}function $s(e){const t=[];for(;e.length>0;){const n=e.shift();if(!n)continue;const r=Number.parseInt(n);if(!Number.isNaN(r))if(r===0)t.push({type:"resetAll"});else if(r<=9)Je[r]&&t.push({type:"setDecoration",value:Je[r]});else if(r<=29){const s=Je[r-20];s&&(t.push({type:"resetDecoration",value:s}),s==="dim"&&t.push({type:"resetDecoration",value:"bold"}))}else if(r<=37)t.push({type:"setForegroundColor",value:{type:"named",name:K[r-30]}});else if(r===38){const s=zt(e);s&&t.push({type:"setForegroundColor",value:s})}else if(r===39)t.push({type:"resetForegroundColor"});else if(r<=47)t.push({type:"setBackgroundColor",value:{type:"named",name:K[r-40]}});else if(r===48){const s=zt(e);s&&t.push({type:"setBackgroundColor",value:s})}else r===49?t.push({type:"resetBackgroundColor"}):r===53?t.push({type:"setDecoration",value:"overline"}):r===55?t.push({type:"resetDecoration",value:"overline"}):r>=90&&r<=97?t.push({type:"setForegroundColor",value:{type:"named",name:K[r-90+8]}}):r>=100&&r<=107&&t.push({type:"setBackgroundColor",value:{type:"named",name:K[r-100+8]}})}return t}function Ls(){let e=null,t=null,n=new Set;return{parse(r){const s=[];let o=0;do{const i=Rs(r,o),a=i.sequence?r.substring(o,i.startPosition):r.substring(o);if(a.length>0&&s.push({value:a,foreground:e,background:t,decorations:new Set(n)}),i.sequence){const c=$s(i.sequence);for(const l of c)l.type==="resetAll"?(e=null,t=null,n.clear()):l.type==="resetForegroundColor"?e=null:l.type==="resetBackgroundColor"?t=null:l.type==="resetDecoration"&&n.delete(l.value);for(const l of c)l.type==="setForegroundColor"?e=l.value:l.type==="setBackgroundColor"?t=l.value:l.type==="setDecoration"&&n.add(l.value)}o=i.position}while(o<r.length);return s}}}var Ns={black:"#000000",red:"#bb0000",green:"#00bb00",yellow:"#bbbb00",blue:"#0000bb",magenta:"#ff00ff",cyan:"#00bbbb",white:"#eeeeee",brightBlack:"#555555",brightRed:"#ff5555",brightGreen:"#00ff00",brightYellow:"#ffff55",brightBlue:"#5555ff",brightMagenta:"#ff55ff",brightCyan:"#55ffff",brightWhite:"#ffffff"};function Ps(e=Ns){function t(a){return e[a]}function n(a){return`#${a.map(c=>Math.max(0,Math.min(c,255)).toString(16).padStart(2,"0")).join("")}`}let r;function s(){if(r)return r;r=[];for(let l=0;l<K.length;l++)r.push(t(K[l]));let a=[0,95,135,175,215,255];for(let l=0;l<6;l++)for(let u=0;u<6;u++)for(let h=0;h<6;h++)r.push(n([a[l],a[u],a[h]]));let c=8;for(let l=0;l<24;l++,c+=10)r.push(n([c,c,c]));return r}function o(a){return s()[a]}function i(a){switch(a.type){case"named":return t(a.name);case"rgb":return n(a.rgb);case"table":return o(a.index)}}return{value:i}}const Ts=/#([0-9a-f]{3,8})/i,Gs=/var\((--[\w-]+-ansi-[\w-]+)\)/,Ms={black:"#000000",red:"#cd3131",green:"#0DBC79",yellow:"#E5E510",blue:"#2472C8",magenta:"#BC3FBC",cyan:"#11A8CD",white:"#E5E5E5",brightBlack:"#666666",brightRed:"#F14C4C",brightGreen:"#23D18B",brightYellow:"#F5F543",brightBlue:"#3B8EEA",brightMagenta:"#D670D6",brightCyan:"#29B8DB",brightWhite:"#FFFFFF"};function Os(e,t,n){const r=Le(e,n),s=De(t),o=Ps(Object.fromEntries(K.map(a=>{const c=`terminal.ansi${a[0].toUpperCase()}${a.substring(1)}`;return[a,e.colors?.[c]||Ms[a]]}))),i=Ls();return s.map(a=>i.parse(a[0]).map(c=>{let l,u;c.decorations.has("reverse")?(l=c.background?o.value(c.background):e.bg,u=c.foreground?o.value(c.foreground):e.fg):(l=c.foreground?o.value(c.foreground):e.fg,u=c.background?o.value(c.background):void 0),l=H(l,r),u=H(u,r),c.decorations.has("dim")&&(l=Bs(l));let h=$.None;return c.decorations.has("bold")&&(h|=$.Bold),c.decorations.has("italic")&&(h|=$.Italic),c.decorations.has("underline")&&(h|=$.Underline),c.decorations.has("strikethrough")&&(h|=$.Strikethrough),{content:c.value,offset:a[1],color:l,bgColor:u,fontStyle:h}}))}function Bs(e){const t=e.match(Ts);if(t){const r=t[1];if(r.length===8){const s=Math.round(Number.parseInt(r.slice(6,8),16)/2).toString(16).padStart(2,"0");return`#${r.slice(0,6)}${s}`}else{if(r.length===6)return`#${r}80`;if(r.length===4){const s=r[0],o=r[1],i=r[2],a=r[3];return`#${s}${s}${o}${o}${i}${i}${Math.round(Number.parseInt(`${a}${a}`,16)/2).toString(16).padStart(2,"0")}`}else if(r.length===3){const s=r[0],o=r[1],i=r[2];return`#${s}${s}${o}${o}${i}${i}80`}}}const n=e.match(Gs);return n?`var(${n[1]}-dim)`:e}function gt(e,t,n={}){const r=e.resolveLangAlias(n.lang||"text"),{theme:s=e.getLoadedThemes()[0]}=n;if(!Oe(r)&&!Be(s)&&r==="ansi"){const{theme:o}=e.setTheme(s);return Os(o,t,n)}return On(e,t,n)}function Te(e,t,n){let r,s,o,i,a,c;if("themes"in n){const{defaultColor:l="light",cssVariablePrefix:u="--shiki-",colorsRendering:h="css-vars"}=n,f=Object.entries(n.themes).filter(g=>g[1]).map(g=>({color:g[0],theme:g[1]})).sort((g,m)=>g.color===l?-1:m.color===l?1:0);if(f.length===0)throw new E("`themes` option must not be empty");const d=Bn(e,t,n,gt);if(c=ge(d),l&&l!=="light-dark()"&&!f.some(g=>g.color===l))throw new E(`\`themes\` option must contain the defaultColor key \`${l}\``);const p=f.map(g=>e.getTheme(g.theme)),_=f.map(g=>g.color);o=d.map(g=>g.map(m=>Es(m,_,u,l,h))),c&&Fe(o,c);const y=f.map(g=>Le(g.theme,n));s=Ht(f,p,y,u,l,"fg",h),r=Ht(f,p,y,u,l,"bg",h),i=`shiki-themes ${p.map(g=>g.name).join(" ")}`,a=l?void 0:[s,r].join(";")}else if("theme"in n){const l=Le(n.theme,n);o=gt(e,t,n);const u=e.getTheme(n.theme);r=H(u.bg,l),s=H(u.fg,l),i=u.name,c=ge(o)}else throw new E("Invalid options, either `theme` or `themes` must be provided");return{tokens:o,fg:s,bg:r,themeName:i,rootStyle:a,grammarState:c}}function Ht(e,t,n,r,s,o,i){return e.map((a,c)=>{const l=H(t[c][o],n[c])||"inherit",u=`${r+a.color}${o==="bg"?"-bg":""}:${l}`;if(c===0&&s){if(s==="light-dark()"&&e.length>1){const h=e.findIndex(d=>d.color==="light"),f=e.findIndex(d=>d.color==="dark");if(h===-1||f===-1)throw new E('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');return`light-dark(${H(t[h][o],n[h])||"inherit"}, ${H(t[f][o],n[f])||"inherit"});${u}`}return l}return i==="css-vars"?u:null}).filter(a=>!!a).join(";")}const jn=/^\s+$/,Ds=/^(\s*)(.*?)(\s*)$/;function Ge(e,t,n,r={meta:{},options:n,codeToHast:(s,o)=>Ge(e,s,o),codeToTokens:(s,o)=>Te(e,s,o)}){let s=t;for(const p of Pe(n))s=p.preprocess?.call(r,s,n)||s;let{tokens:o,fg:i,bg:a,themeName:c,rootStyle:l,grammarState:u}=Te(e,s,n);const{mergeWhitespaces:h=!0,mergeSameStyleTokens:f=!1}=n;h===!0?o=js(o):h==="never"&&(o=Us(o)),f&&(o=Vs(o));const d={...r,get source(){return s}};for(const p of Pe(n))o=p.tokens?.call(d,o)||o;return Fs(o,{...n,fg:i,bg:a,themeName:c,rootStyle:n.rootStyle===!1?!1:n.rootStyle??l},d,u)}function Fs(e,t,n,r=ge(e)){const s=Pe(t),o=[],i={type:"root",children:[]},{structure:a="classic",tabindex:c="0"}=t,l={class:`shiki ${t.themeName||""}`};t.rootStyle!==!1&&(t.rootStyle!=null?l.style=t.rootStyle:l.style=`background-color:${t.bg};color:${t.fg}`),c!==!1&&c!=null&&(l.tabindex=c.toString());for(const[_,y]of Object.entries(t.meta||{}))_.startsWith("_")||(l[_]=y);let u={type:"element",tagName:"pre",properties:l,children:[],data:t.data},h={type:"element",tagName:"code",properties:{},children:o};const f=[],d={...n,structure:a,addClassToHast:Dn,get source(){return n.source},get tokens(){return e},get options(){return t},get root(){return i},get pre(){return u},get code(){return h},get lines(){return f}};if(e.forEach((_,y)=>{y&&(a==="inline"?i.children.push({type:"element",tagName:"br",properties:{},children:[]}):a==="classic"&&o.push({type:"text",value:`
|
|
5
5
|
`}));let g={type:"element",tagName:"span",properties:{class:"line"},children:[]},m=0;for(const w of _){let k={type:"element",tagName:"span",properties:{...w.htmlAttrs},children:[{type:"text",value:w.content}]};const S=pt(w.htmlStyle||Ne(w));S&&(k.properties.style=S);for(const x of s)k=x?.span?.call(d,k,y+1,m,g,w)||k;a==="inline"?i.children.push(k):a==="classic"&&g.children.push(k),m+=w.content.length}if(a==="classic"){for(const w of s)g=w?.line?.call(d,g,y+1)||g;f.push(g),o.push(g)}else a==="inline"&&f.push(g)}),a==="classic"){for(const _ of s)h=_?.code?.call(d,h)||h;u.children.push(h);for(const _ of s)u=_?.pre?.call(d,u)||u;i.children.push(u)}else if(a==="inline"){const _=[];let y={type:"element",tagName:"span",properties:{class:"line"},children:[]};for(const m of i.children)m.type==="element"&&m.tagName==="br"?(_.push(y),y={type:"element",tagName:"span",properties:{class:"line"},children:[]}):(m.type==="element"||m.type==="text")&&y.children.push(m);_.push(y);let g={type:"element",tagName:"code",properties:{},children:_};for(const m of s)g=m?.code?.call(d,g)||g;i.children=[];for(let m=0;m<g.children.length;m++){m>0&&i.children.push({type:"element",tagName:"br",properties:{},children:[]});const w=g.children[m];w.type==="element"&&i.children.push(...w.children)}}let p=i;for(const _ of s)p=_?.root?.call(d,p)||p;return r&&Fe(p,r),p}function js(e){return e.map(t=>{const n=[];let r="",s;return t.forEach((o,i)=>{const a=!(o.fontStyle&&(o.fontStyle&$.Underline||o.fontStyle&$.Strikethrough));a&&jn.test(o.content)&&t[i+1]?(s===void 0&&(s=o.offset),r+=o.content):r?(a?n.push({...o,offset:s,content:r+o.content}):n.push({content:r,offset:s},o),s=void 0,r=""):n.push(o)}),n})}function Us(e){return e.map(t=>t.flatMap(n=>{if(jn.test(n.content))return n;const r=n.content.match(Ds);if(!r)return n;const[,s,o,i]=r;if(!s&&!i)return n;const a=[{...n,offset:n.offset+s.length,content:o}];return s&&a.unshift({content:s,offset:n.offset}),i&&a.push({content:i,offset:n.offset+s.length+o.length}),a}))}function Vs(e){return e.map(t=>{const n=[];for(const r of t){if(n.length===0){n.push({...r});continue}const s=n.at(-1),o=pt(s.htmlStyle||Ne(s)),i=pt(r.htmlStyle||Ne(r)),a=s.fontStyle&&(s.fontStyle&$.Underline||s.fontStyle&$.Strikethrough),c=r.fontStyle&&(r.fontStyle&$.Underline||r.fontStyle&$.Strikethrough);!a&&!c&&o===i?s.content+=r.content:n.push({...r})}return n})}const Ws=dr;function zs(e,t,n){const r={meta:{},options:n,codeToHast:(o,i)=>Ge(e,o,i),codeToTokens:(o,i)=>Te(e,o,i)};let s=Ws(Ge(e,t,n,r));for(const o of Pe(n))s=o.postprocess?.call(r,s,n)||s;return s}async function Hs(e){const t=await as(e);return{getLastGrammarState:(...n)=>fs(t,...n),codeToTokensBase:(n,r)=>gt(t,n,r),codeToTokensWithThemes:(n,r)=>Bn(t,n,r),codeToTokens:(n,r)=>Te(t,n,r),codeToHast:(n,r)=>Ge(t,n,r),codeToHtml:(n,r)=>zs(t,n,r),getBundledLanguages:()=>({}),getBundledThemes:()=>({}),...t,getInternalContext:()=>t}}function qs(e={}){const{name:t="css-variables",variablePrefix:n="--shiki-",fontStyle:r=!0}=e,s=i=>e.variableDefaults?.[i]?`var(${n}${i}, ${e.variableDefaults[i]})`:`var(${n}${i})`,o={name:t,type:"dark",colors:{"editor.foreground":s("foreground"),"editor.background":s("background"),"terminal.ansiBlack":s("ansi-black"),"terminal.ansiRed":s("ansi-red"),"terminal.ansiGreen":s("ansi-green"),"terminal.ansiYellow":s("ansi-yellow"),"terminal.ansiBlue":s("ansi-blue"),"terminal.ansiMagenta":s("ansi-magenta"),"terminal.ansiCyan":s("ansi-cyan"),"terminal.ansiWhite":s("ansi-white"),"terminal.ansiBrightBlack":s("ansi-bright-black"),"terminal.ansiBrightRed":s("ansi-bright-red"),"terminal.ansiBrightGreen":s("ansi-bright-green"),"terminal.ansiBrightYellow":s("ansi-bright-yellow"),"terminal.ansiBrightBlue":s("ansi-bright-blue"),"terminal.ansiBrightMagenta":s("ansi-bright-magenta"),"terminal.ansiBrightCyan":s("ansi-bright-cyan"),"terminal.ansiBrightWhite":s("ansi-bright-white")},tokenColors:[{scope:["keyword.operator.accessor","meta.group.braces.round.function.arguments","meta.template.expression","markup.fenced_code meta.embedded.block"],settings:{foreground:s("foreground")}},{scope:"emphasis",settings:{fontStyle:"italic"}},{scope:["strong","markup.heading.markdown","markup.bold.markdown"],settings:{fontStyle:"bold"}},{scope:["markup.italic.markdown"],settings:{fontStyle:"italic"}},{scope:"meta.link.inline.markdown",settings:{fontStyle:"underline",foreground:s("token-link")}},{scope:["string","markup.fenced_code","markup.inline"],settings:{foreground:s("token-string")}},{scope:["comment","string.quoted.docstring.multi"],settings:{foreground:s("token-comment")}},{scope:["constant.numeric","constant.language","constant.other.placeholder","constant.character.format.placeholder","variable.language.this","variable.other.object","variable.other.class","variable.other.constant","meta.property-name","meta.property-value","support"],settings:{foreground:s("token-constant")}},{scope:["keyword","storage.modifier","storage.type","storage.control.clojure","entity.name.function.clojure","entity.name.tag.yaml","support.function.node","support.type.property-name.json","punctuation.separator.key-value","punctuation.definition.template-expression"],settings:{foreground:s("token-keyword")}},{scope:"variable.parameter.function",settings:{foreground:s("token-parameter")}},{scope:["support.function","entity.name.type","entity.other.inherited-class","meta.function-call","meta.instance.constructor","entity.other.attribute-name","entity.name.function","constant.keyword.clojure"],settings:{foreground:s("token-function")}},{scope:["entity.name.tag","string.quoted","string.regexp","string.interpolated","string.template","string.unquoted.plain.out.yaml","keyword.other.template"],settings:{foreground:s("token-string-expression")}},{scope:["punctuation.definition.arguments","punctuation.definition.dict","punctuation.separator","meta.function-call.arguments"],settings:{foreground:s("token-punctuation")}},{scope:["markup.underline.link","punctuation.definition.metadata.markdown"],settings:{foreground:s("token-link")}},{scope:["beginning.punctuation.definition.list.markdown"],settings:{foreground:s("token-string")}},{scope:["punctuation.definition.string.begin.markdown","punctuation.definition.string.end.markdown","string.other.link.title.markdown","string.other.link.description.markdown"],settings:{foreground:s("token-keyword")}},{scope:["markup.inserted","meta.diff.header.to-file","punctuation.definition.inserted"],settings:{foreground:s("token-inserted")}},{scope:["markup.deleted","meta.diff.header.from-file","punctuation.definition.deleted"],settings:{foreground:s("token-deleted")}},{scope:["markup.changed","punctuation.definition.changed"],settings:{foreground:s("token-changed")}}]};return r||(o.tokenColors=o.tokenColors?.map(i=>(i.settings?.fontStyle&&delete i.settings.fontStyle,i))),o}const qt=4294967295;function Xs(e){return!e.sticky&&!e.rawOptions?.strategy}function Xt(e,t){return{index:e,captureIndices:t.map(n=>n==null?{start:qt,end:qt,length:0}:{start:n[0],end:n[1],length:n[1]-n[0]})}}var Qs=class{patterns;options;regexps;lastSearches;constructor(e,t={}){this.patterns=e,this.options=t;const{forgiving:n=!1,cache:r,regexConstructor:s}=t;if(!s)throw new Error("Option `regexConstructor` is not provided");this.regexps=e.map(o=>{if(typeof o!="string")return o;const i=r?.get(o);if(i){if(i instanceof RegExp)return i;if(n)return null;throw i}try{const a=s(o);return r?.set(o,a),a}catch(a){if(r?.set(o,a),n)return null;throw a}}),this.lastSearches=this.regexps.map(o=>o&&Xs(o)?{strId:0,searchedFrom:0,matchIndex:-1,indices:null}:null)}findNextMatchSync(e,t,n){const r=typeof e=="string"?e:e.content,s=typeof e=="string"?0:e.id||0;let o=-1,i=0,a=null;for(let c=0;c<this.regexps.length;c++){const l=this.regexps[c];if(l)try{const u=s?this.lastSearches[c]:null;let h,f;if(u&&u.strId===s&&u.searchedFrom<=t&&(u.matchIndex===-1||u.matchIndex>=t))h=u.matchIndex,f=u.indices;else{l.lastIndex=t;const d=l.exec(r);h=d?d.index:-1,f=d?d.indices:null,u&&(u.strId=s,u.searchedFrom=t,u.matchIndex=h,u.indices=f)}if(h===-1)continue;if(h===t)return Xt(c,f);(o===-1||h<i)&&(o=c,i=h,a=f)}catch(u){if(this.options.forgiving)continue;throw u}}return o===-1?null:Xt(o,a)}};let Ks=0;function Zs(e){return{content:e,id:++Ks}}function ie(e){if([...e].length!==1)throw new Error(`Expected "${e}" to be a single code point`);return e.codePointAt(0)}function Js(e,t,n){return e.has(t)||e.set(t,n),e.get(t)}const It=new Set(["alnum","alpha","ascii","blank","cntrl","digit","graph","lower","print","punct","space","upper","word","xdigit"]),A=String.raw;function ae(e,t){if(e==null)throw new Error(t??"Value expected");return e}const Un=A`\[\^?`,Vn=`c.? | C(?:-.?)?|${A`[pP]\{(?:\^?[-\x20_]*[A-Za-z][-\x20\w]*\})?`}|${A`x[89A-Fa-f]\p{AHex}(?:\\x[89A-Fa-f]\p{AHex})*`}|${A`u(?:\p{AHex}{4})? | x\{[^\}]*\}? | x\p{AHex}{0,2}`}|${A`o\{[^\}]*\}?`}|${A`\d{1,3}`}`,vt=/[?*+][?+]?|\{(?:\d+(?:,\d*)?|,\d+)\}\??/,be=new RegExp(A`
|