@republicroad/seal-editor 1.32.0 → 1.33.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bash-Dfpezy65.js +2 -0
- package/dist/c-BdHHW7PX.js +5 -0
- package/dist/c-BdHHW7PX.js.map +1 -0
- package/dist/c-lfOsiBpu.js +2 -0
- package/dist/core-CAYwPm3F.js +4984 -0
- package/dist/core-CAYwPm3F.js.map +1 -0
- package/dist/cpp-BGootNWJ.js +15 -0
- package/dist/cpp-BGootNWJ.js.map +1 -0
- package/dist/cpp-DvjZUDSj.js +2 -0
- package/dist/csharp-RRkgh3c4.js +5 -0
- package/dist/csharp-RRkgh3c4.js.map +1 -0
- package/dist/css-BbwcBM_4.js +2 -0
- package/dist/css-HuzvwXs-.js +5 -0
- package/dist/css-HuzvwXs-.js.map +1 -0
- package/dist/diff-D0WgTNQn.js +5 -0
- package/dist/diff-D0WgTNQn.js.map +1 -0
- package/dist/docker-DMpUQ2UE.js +5 -0
- package/dist/docker-DMpUQ2UE.js.map +1 -0
- package/dist/engine-javascript-DkCwfYjr.js +2393 -0
- package/dist/engine-javascript-DkCwfYjr.js.map +1 -0
- package/dist/github-dark-C85MA6EW.js +6 -0
- package/dist/github-dark-C85MA6EW.js.map +1 -0
- package/dist/github-light-Dzg0sEwI.js +6 -0
- package/dist/github-light-Dzg0sEwI.js.map +1 -0
- package/dist/go-BEdBk4fh.js +5 -0
- package/dist/go-BEdBk4fh.js.map +1 -0
- package/dist/graphql-C4UuinIq.js +2 -0
- package/dist/graphql-DcYBXWWL.js +16 -0
- package/dist/graphql-DcYBXWWL.js.map +1 -0
- package/dist/html-BH9giSUA.js +2 -0
- package/dist/html-Ctxsat8s.js +12 -0
- package/dist/html-Ctxsat8s.js.map +1 -0
- package/dist/i18n-Cgv8cs-o.js +665 -0
- package/dist/i18n-Cgv8cs-o.js.map +1 -0
- package/dist/index.d.ts +66 -6
- package/dist/index.js +5947 -6525
- package/dist/index.js.map +1 -1
- package/dist/java-CNN5-pjU.js +5 -0
- package/dist/java-CNN5-pjU.js.map +1 -0
- package/dist/java-CaG1IqbK.js +2 -0
- package/dist/javascript--0qAxhnA.js +2 -0
- package/dist/javascript-Bk0bJ4nQ.js +5 -0
- package/dist/javascript-Bk0bJ4nQ.js.map +1 -0
- package/dist/json-DFt_0dbD.js +5 -0
- package/dist/json-DFt_0dbD.js.map +1 -0
- package/dist/json-DVwBUiza.js +2 -0
- package/dist/jsx-DkJfxbAs.js +5 -0
- package/dist/jsx-DkJfxbAs.js.map +1 -0
- package/dist/jsx-cVAJ0Z2c.js +2 -0
- package/dist/kotlin-CQsNEM2o.js +5 -0
- package/dist/kotlin-CQsNEM2o.js.map +1 -0
- package/dist/markdown-nUtTZkU8.js +5 -0
- package/dist/markdown-nUtTZkU8.js.map +1 -0
- package/dist/php-CQpsnvwU.js +20 -0
- package/dist/php-CQpsnvwU.js.map +1 -0
- package/dist/python-D0AaDoWC.js +5 -0
- package/dist/python-D0AaDoWC.js.map +1 -0
- package/dist/rolldown-runtime-B0aSnxlc.js +20 -0
- package/dist/ruby-lBDztqPf.js +34 -0
- package/dist/ruby-lBDztqPf.js.map +1 -0
- package/dist/rust-BrRMzTsN.js +5 -0
- package/dist/rust-BrRMzTsN.js.map +1 -0
- package/dist/schema.d.ts +6 -6
- package/dist/scss-CoGT9c_3.js +7 -0
- package/dist/scss-CoGT9c_3.js.map +1 -0
- package/dist/shellscript-B2AvTo4A.js +5 -0
- package/dist/shellscript-B2AvTo4A.js.map +1 -0
- package/dist/shellscript-Dfpezy65.js +2 -0
- package/dist/simulate-run-detail-CxwpdDne.js +1013 -0
- package/dist/simulate-run-detail-CxwpdDne.js.map +1 -0
- package/dist/sql-D_W5grEC.js +2 -0
- package/dist/sql-q7LBKUMn.js +5 -0
- package/dist/sql-q7LBKUMn.js.map +1 -0
- package/dist/style.css +1 -1
- package/dist/swift-B7Z-rXzN.js +5 -0
- package/dist/swift-B7Z-rXzN.js.map +1 -0
- package/dist/toml-CIQJnU5u.js +5 -0
- package/dist/toml-CIQJnU5u.js.map +1 -0
- package/dist/tsx-BqSm8fWw.js +5 -0
- package/dist/tsx-BqSm8fWw.js.map +1 -0
- package/dist/tsx-DiMnnori.js +2 -0
- package/dist/typescript-C4BXhs_3.js +5 -0
- package/dist/typescript-C4BXhs_3.js.map +1 -0
- package/dist/typescript-DFf19o_s.js +2 -0
- package/dist/vue-DnpuW72P.js +23 -0
- package/dist/vue-DnpuW72P.js.map +1 -0
- package/dist/xml-C-8BjZCy.js +7 -0
- package/dist/xml-C-8BjZCy.js.map +1 -0
- package/dist/yaml-BZ3x6E3N.js +5 -0
- package/dist/yaml-BZ3x6E3N.js.map +1 -0
- package/dist/yaml-BswqmnDe.js +2 -0
- package/package.json +2 -1
|
@@ -0,0 +1,1013 @@
|
|
|
1
|
+
import { t as e } from "./utils-CX-Pz5p6.js";
|
|
2
|
+
import { i as t, r as n } from "./i18n-Cgv8cs-o.js";
|
|
3
|
+
import { Children as r, createContext as i, isValidElement as a, memo as o, useCallback as s, useContext as c, useDeferredValue as l, useEffect as u, useId as d, useLayoutEffect as f, useMemo as p, useRef as m, useState as h } from "react";
|
|
4
|
+
import { Fragment as g, jsx as _, jsxs as v } from "react/jsx-runtime";
|
|
5
|
+
import y from "json5";
|
|
6
|
+
//#region src/reui/code-block/code-block-highlight.tsx
|
|
7
|
+
var b = {
|
|
8
|
+
bash: () => import("./bash-Dfpezy65.js"),
|
|
9
|
+
c: () => import("./c-lfOsiBpu.js"),
|
|
10
|
+
cpp: () => import("./cpp-DvjZUDSj.js"),
|
|
11
|
+
csharp: () => import("./csharp-RRkgh3c4.js"),
|
|
12
|
+
css: () => import("./css-BbwcBM_4.js"),
|
|
13
|
+
diff: () => import("./diff-D0WgTNQn.js"),
|
|
14
|
+
docker: () => import("./docker-DMpUQ2UE.js"),
|
|
15
|
+
go: () => import("./go-BEdBk4fh.js"),
|
|
16
|
+
graphql: () => import("./graphql-C4UuinIq.js"),
|
|
17
|
+
html: () => import("./html-BH9giSUA.js"),
|
|
18
|
+
java: () => import("./java-CaG1IqbK.js"),
|
|
19
|
+
javascript: () => import("./javascript--0qAxhnA.js"),
|
|
20
|
+
json: () => import("./json-DVwBUiza.js"),
|
|
21
|
+
jsx: () => import("./jsx-cVAJ0Z2c.js"),
|
|
22
|
+
kotlin: () => import("./kotlin-CQsNEM2o.js"),
|
|
23
|
+
markdown: () => import("./markdown-nUtTZkU8.js"),
|
|
24
|
+
php: () => import("./php-CQpsnvwU.js"),
|
|
25
|
+
python: () => import("./python-D0AaDoWC.js"),
|
|
26
|
+
ruby: () => import("./ruby-lBDztqPf.js"),
|
|
27
|
+
rust: () => import("./rust-BrRMzTsN.js"),
|
|
28
|
+
scss: () => import("./scss-CoGT9c_3.js"),
|
|
29
|
+
shell: () => import("./shellscript-Dfpezy65.js"),
|
|
30
|
+
sql: () => import("./sql-D_W5grEC.js"),
|
|
31
|
+
swift: () => import("./swift-B7Z-rXzN.js"),
|
|
32
|
+
toml: () => import("./toml-CIQJnU5u.js"),
|
|
33
|
+
tsx: () => import("./tsx-DiMnnori.js"),
|
|
34
|
+
typescript: () => import("./typescript-DFf19o_s.js"),
|
|
35
|
+
vue: () => import("./vue-DnpuW72P.js"),
|
|
36
|
+
yaml: () => import("./yaml-BswqmnDe.js")
|
|
37
|
+
}, x = {
|
|
38
|
+
"c++": "cpp",
|
|
39
|
+
"c#": "csharp",
|
|
40
|
+
cs: "csharp",
|
|
41
|
+
dockerfile: "docker",
|
|
42
|
+
htm: "html",
|
|
43
|
+
js: "javascript",
|
|
44
|
+
jsonc: "json",
|
|
45
|
+
md: "markdown",
|
|
46
|
+
mdx: "markdown",
|
|
47
|
+
py: "python",
|
|
48
|
+
rb: "ruby",
|
|
49
|
+
rs: "rust",
|
|
50
|
+
sh: "shell",
|
|
51
|
+
shellscript: "shell",
|
|
52
|
+
ts: "typescript",
|
|
53
|
+
yml: "yaml",
|
|
54
|
+
zsh: "shell"
|
|
55
|
+
}, S = {
|
|
56
|
+
"github-light": () => import("./github-light-Dzg0sEwI.js"),
|
|
57
|
+
"github-dark": () => import("./github-dark-C85MA6EW.js"),
|
|
58
|
+
"css-variables": async () => {
|
|
59
|
+
let { createCssVariablesTheme: e } = await import("./core-CAYwPm3F.js");
|
|
60
|
+
return e({
|
|
61
|
+
name: "css-variables",
|
|
62
|
+
variablePrefix: "--code-",
|
|
63
|
+
fontStyle: !0
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
}, C = {
|
|
67
|
+
light: "github-light",
|
|
68
|
+
dark: "github-dark"
|
|
69
|
+
};
|
|
70
|
+
function w(e) {
|
|
71
|
+
if (!e) return;
|
|
72
|
+
let t = e.trim().toLowerCase(), n = x[t] ?? t;
|
|
73
|
+
return n in b ? n : void 0;
|
|
74
|
+
}
|
|
75
|
+
function T(e) {
|
|
76
|
+
let t = /* @__PURE__ */ new Set();
|
|
77
|
+
if (!e) return t;
|
|
78
|
+
if (Array.isArray(e)) {
|
|
79
|
+
for (let n of e) Number.isInteger(n) && n > 0 && t.add(n);
|
|
80
|
+
return t;
|
|
81
|
+
}
|
|
82
|
+
for (let n of e.split(",")) {
|
|
83
|
+
let e = n.trim();
|
|
84
|
+
if (!e) continue;
|
|
85
|
+
let r = e.match(/^(\d+)\s*-\s*(\d+)$/);
|
|
86
|
+
if (r) {
|
|
87
|
+
let e = Number(r[1]), n = Number(r[2]);
|
|
88
|
+
if (e > 0 && n >= e) for (let r = e; r <= n; r += 1) t.add(r);
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
if (/^\d+$/.test(e)) {
|
|
92
|
+
let n = Number(e);
|
|
93
|
+
n > 0 && t.add(n);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return t;
|
|
97
|
+
}
|
|
98
|
+
function E(e) {
|
|
99
|
+
return e.replace(/\r\n?/g, "\n");
|
|
100
|
+
}
|
|
101
|
+
function D(e, t) {
|
|
102
|
+
if (!t?.length) return [];
|
|
103
|
+
let n = [0];
|
|
104
|
+
for (let t = 0; t < e.length; t += 1) e[t] === "\n" && n.push(t + 1);
|
|
105
|
+
let r = (e) => {
|
|
106
|
+
let t = 0, r = n.length - 1;
|
|
107
|
+
for (; t < r;) {
|
|
108
|
+
let i = Math.ceil((t + r) / 2);
|
|
109
|
+
n[i] <= e ? t = i : r = i - 1;
|
|
110
|
+
}
|
|
111
|
+
return t + 1;
|
|
112
|
+
}, i = [], a = [];
|
|
113
|
+
for (let n of t) {
|
|
114
|
+
let t = typeof n == "string" ? n : n.word;
|
|
115
|
+
if (!t) continue;
|
|
116
|
+
let o = typeof n == "string" ? void 0 : T(n.lines), s = e.indexOf(t);
|
|
117
|
+
for (; s !== -1;) {
|
|
118
|
+
let n = s + t.length, c = !o || o.size === 0 || o.has(r(s)), l = i.some((e) => s < e.end && n > e.start);
|
|
119
|
+
c && !l && (i.push({
|
|
120
|
+
start: s,
|
|
121
|
+
end: n
|
|
122
|
+
}), a.push({
|
|
123
|
+
start: s,
|
|
124
|
+
end: n,
|
|
125
|
+
properties: { class: "cb-word" }
|
|
126
|
+
})), s = e.indexOf(t, s + t.length);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return a.sort((e, t) => e.start - t.start);
|
|
130
|
+
}
|
|
131
|
+
function ee(e) {
|
|
132
|
+
return e.split("\n").map((e) => e.replace(/\s*(?:\/\/|#|--|;|%|<!--|\/\*)\s*\[!code[^\]]*\]\s*(?:-->|\*\/)?\s*$/, "")).join("\n");
|
|
133
|
+
}
|
|
134
|
+
function O(e, t = 1) {
|
|
135
|
+
return E(e).split("\n").map((e, n) => ({
|
|
136
|
+
tokens: e ? [{ content: e }] : [],
|
|
137
|
+
number: t + n,
|
|
138
|
+
text: e
|
|
139
|
+
}));
|
|
140
|
+
}
|
|
141
|
+
var k = null, A = /* @__PURE__ */ new Set(), j = /* @__PURE__ */ new Set();
|
|
142
|
+
async function M() {
|
|
143
|
+
return k ||= (async () => {
|
|
144
|
+
let [{ createHighlighterCore: e }, { createJavaScriptRegexEngine: t }] = await Promise.all([import("./core-CAYwPm3F.js"), import("./engine-javascript-DkCwfYjr.js")]);
|
|
145
|
+
return await e({
|
|
146
|
+
themes: [],
|
|
147
|
+
langs: [],
|
|
148
|
+
engine: t({ forgiving: !0 })
|
|
149
|
+
});
|
|
150
|
+
})(), k;
|
|
151
|
+
}
|
|
152
|
+
var N = /* @__PURE__ */ new Set();
|
|
153
|
+
async function P(e, t, n = "light") {
|
|
154
|
+
let r = t in S ? t : C[n];
|
|
155
|
+
return r !== t && process.env.NODE_ENV !== "production" && !N.has(t) && (N.add(t), console.warn(`[code-block] Unknown theme "${t}" - falling back to "${r}". Register it in codeBlockThemes to use it.`)), j.has(r) ? r : (await e.loadTheme(await S[r]()), j.add(r), r);
|
|
156
|
+
}
|
|
157
|
+
async function te(e, t) {
|
|
158
|
+
if (A.has(t)) return;
|
|
159
|
+
let n = b[t];
|
|
160
|
+
n && (await e.loadLanguage(await n()), A.add(t));
|
|
161
|
+
}
|
|
162
|
+
var F = {
|
|
163
|
+
"font-style:italic": "italic",
|
|
164
|
+
"font-weight:bold": "bold",
|
|
165
|
+
"text-decoration:underline": "underline"
|
|
166
|
+
};
|
|
167
|
+
function ne(e) {
|
|
168
|
+
if (typeof e != "string") return {};
|
|
169
|
+
let t = {};
|
|
170
|
+
for (let n of e.split(";")) {
|
|
171
|
+
let e = n.trim();
|
|
172
|
+
if (!e) continue;
|
|
173
|
+
let r = e.indexOf(":");
|
|
174
|
+
if (r === -1) continue;
|
|
175
|
+
let i = e.slice(0, r).trim(), a = e.slice(r + 1).trim();
|
|
176
|
+
if (i === "color") t.color = a;
|
|
177
|
+
else if (i === "--shiki-dark") t.colorDark = a;
|
|
178
|
+
else {
|
|
179
|
+
let e = F[`${i}:${a}`];
|
|
180
|
+
e && (t.fontStyle = e);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
return t;
|
|
184
|
+
}
|
|
185
|
+
function I(e) {
|
|
186
|
+
let t = e.properties?.class ?? e.properties?.className;
|
|
187
|
+
return Array.isArray(t) ? t.map(String) : typeof t == "string" ? t.split(/\s+/).filter(Boolean) : [];
|
|
188
|
+
}
|
|
189
|
+
function L(e) {
|
|
190
|
+
let t = {};
|
|
191
|
+
e.includes("highlighted") && (t.highlighted = !0), e.includes("focused") && (t.focused = !0), e.includes("diff") && (e.includes("add") ? t.diff = "add" : e.includes("remove") && (t.diff = "remove"));
|
|
192
|
+
for (let n of [
|
|
193
|
+
"error",
|
|
194
|
+
"warning",
|
|
195
|
+
"info"
|
|
196
|
+
]) e.includes(n) && (t.level = n);
|
|
197
|
+
return Object.keys(t).length ? t : void 0;
|
|
198
|
+
}
|
|
199
|
+
function R(e, t, n) {
|
|
200
|
+
for (let r of e.children ?? []) {
|
|
201
|
+
if (r.type === "text") {
|
|
202
|
+
if (!r.value) continue;
|
|
203
|
+
t.push(n ? {
|
|
204
|
+
content: r.value,
|
|
205
|
+
word: !0
|
|
206
|
+
} : { content: r.value });
|
|
207
|
+
continue;
|
|
208
|
+
}
|
|
209
|
+
if (r.type !== "element") continue;
|
|
210
|
+
let e = I(r), i = n || e.includes("cb-word"), a = ne(r.properties?.style), o = !!(a.color || a.colorDark || a.fontStyle), s = (r.children ?? []).every((e) => e.type === "text");
|
|
211
|
+
if (o && s) {
|
|
212
|
+
let e = (r.children ?? []).map((e) => e.value ?? "").join("");
|
|
213
|
+
if (!e) continue;
|
|
214
|
+
t.push({
|
|
215
|
+
content: e,
|
|
216
|
+
...a,
|
|
217
|
+
...i ? { word: !0 } : {}
|
|
218
|
+
});
|
|
219
|
+
continue;
|
|
220
|
+
}
|
|
221
|
+
R(r, t, i);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
function z(e) {
|
|
225
|
+
if (e.type === "element" && e.tagName === "code") return e;
|
|
226
|
+
for (let t of e.children ?? []) {
|
|
227
|
+
let e = z(t);
|
|
228
|
+
if (e) return e;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
var B = 24, V = /* @__PURE__ */ new Map();
|
|
232
|
+
function re(e, t) {
|
|
233
|
+
if (e.number !== t.number || e.text !== t.text || e.tokens.length !== t.tokens.length || JSON.stringify(e.state ?? null) !== JSON.stringify(t.state ?? null)) return !1;
|
|
234
|
+
for (let n = 0; n < e.tokens.length; n += 1) {
|
|
235
|
+
let r = e.tokens[n], i = t.tokens[n];
|
|
236
|
+
if (r.content !== i.content || r.color !== i.color || r.colorDark !== i.colorDark || r.fontStyle !== i.fontStyle || r.word !== i.word) return !1;
|
|
237
|
+
}
|
|
238
|
+
return !0;
|
|
239
|
+
}
|
|
240
|
+
function H(e, t) {
|
|
241
|
+
let n = V.get(e);
|
|
242
|
+
if (n) for (let e = 0; e < t.length; e += 1) {
|
|
243
|
+
let r = n[e];
|
|
244
|
+
r && re(r, t[e]) && (t[e] = r);
|
|
245
|
+
}
|
|
246
|
+
if (V.set(e, t), V.size > B) {
|
|
247
|
+
let e = V.keys().next().value;
|
|
248
|
+
e !== void 0 && V.delete(e);
|
|
249
|
+
}
|
|
250
|
+
return t;
|
|
251
|
+
}
|
|
252
|
+
function ie(e, t) {
|
|
253
|
+
let n = T(t.highlightedLines), r = T(t.focusedLines), i = T(t.diff?.added), a = T(t.diff?.removed), o = {
|
|
254
|
+
error: T(t.lineLevels?.error),
|
|
255
|
+
warning: T(t.lineLevels?.warning),
|
|
256
|
+
info: T(t.lineLevels?.info)
|
|
257
|
+
};
|
|
258
|
+
e.forEach((e, t) => {
|
|
259
|
+
let s = t + 1, c = { ...e.state };
|
|
260
|
+
n.has(s) && (c.highlighted = !0), r.has(s) && (c.focused = !0), i.has(s) ? c.diff = "add" : a.has(s) && (c.diff = "remove");
|
|
261
|
+
for (let e of [
|
|
262
|
+
"error",
|
|
263
|
+
"warning",
|
|
264
|
+
"info"
|
|
265
|
+
]) o[e].has(s) && (c.level = e);
|
|
266
|
+
e.state = Object.keys(c).length ? c : void 0;
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
async function ae(e, t = {}) {
|
|
270
|
+
let n = E(e), r = t.startLine ?? 1, i = w(t.language);
|
|
271
|
+
if (!i) return O(n, r);
|
|
272
|
+
let a = t.themes ?? C, o = JSON.stringify([
|
|
273
|
+
t.instanceKey ?? null,
|
|
274
|
+
i,
|
|
275
|
+
a,
|
|
276
|
+
r,
|
|
277
|
+
t.highlightedLines ?? null,
|
|
278
|
+
t.highlightedWords ?? null,
|
|
279
|
+
t.focusedLines ?? null,
|
|
280
|
+
t.diff ?? null,
|
|
281
|
+
t.lineLevels ?? null,
|
|
282
|
+
(t.transformers ?? []).length
|
|
283
|
+
]), s;
|
|
284
|
+
try {
|
|
285
|
+
let e = await M(), [r, o] = await Promise.all([P(e, a.light), P(e, a.dark)]);
|
|
286
|
+
await te(e, i), s = e.codeToHast(n, {
|
|
287
|
+
lang: i,
|
|
288
|
+
themes: {
|
|
289
|
+
light: r,
|
|
290
|
+
dark: o
|
|
291
|
+
},
|
|
292
|
+
defaultColor: "light",
|
|
293
|
+
cssVariablePrefix: "--shiki-",
|
|
294
|
+
decorations: D(n, t.highlightedWords),
|
|
295
|
+
...t.transformers?.length ? { transformers: t.transformers } : {}
|
|
296
|
+
});
|
|
297
|
+
} catch {
|
|
298
|
+
return O(n, r);
|
|
299
|
+
}
|
|
300
|
+
let c = z(s);
|
|
301
|
+
if (!c) return O(n, r);
|
|
302
|
+
let l = [];
|
|
303
|
+
for (let e of c.children ?? []) {
|
|
304
|
+
if (e.type !== "element") continue;
|
|
305
|
+
let t = [];
|
|
306
|
+
R(e, t, !1), l.push({
|
|
307
|
+
tokens: t,
|
|
308
|
+
number: r + l.length,
|
|
309
|
+
text: t.map((e) => e.content).join(""),
|
|
310
|
+
state: L(I(e))
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
return l.length ? (ie(l, t), H(o, l)) : O(n, r);
|
|
314
|
+
}
|
|
315
|
+
//#endregion
|
|
316
|
+
//#region src/reui/code-block/code-block.tsx
|
|
317
|
+
var oe = i(null), se = i(null), U = i(!1), ce = i(null), le = i(null), W = typeof window < "u" ? f : u;
|
|
318
|
+
function ue(e) {
|
|
319
|
+
let t = c(oe);
|
|
320
|
+
if (!t) throw Error(`${e} must be used within a CodeBlock`);
|
|
321
|
+
return t;
|
|
322
|
+
}
|
|
323
|
+
var de = "[--code-block-bg:transparent]", fe = "[--code-block-radius:var(--radius-lg)]", pe = (/* @__PURE__ */ "[--code-block-padding:--spacing(3)] [--code-block-gutter-width:--spacing(9)] [--code-block-gutter-gap:--spacing(2.5)] [--code-block-fold-width:--spacing(4.5)] [--code-block-number-pad:var(--code-block-gutter-gap)] data-[gutter-channel]:[--code-block-number-pad:calc(var(--code-block-gutter-gap)+var(--code-block-fold-width))] data-[has-diff]:[--code-block-gutter-gap:--spacing(4)] [--code-block-line-height:1.5rem] [--code-block-font-size:0.8125rem] [--code-block-copy-inset:--spacing(2)] [--code-block-header-height:--spacing(9)] [--code-block-copy-top:var(--code-block-copy-inset)] data-[has-header]:[--code-block-copy-top:calc(var(--code-block-header-height)+1px+var(--code-block-copy-inset))] [--code-block-expand-clearance:--spacing(9)] [--code-block-bg:var(--card)] [--code-block-highlight-bg:color-mix(in_oklch,var(--primary)_6%,transparent)] dark:[--code-block-highlight-bg:color-mix(in_oklch,var(--primary)_12%,transparent)] [--code-block-highlight-bar:color-mix(in_oklch,var(--primary)_60%,transparent)] [--code-block-diff-add-bg:color-mix(in_oklch,var(--success)_8%,transparent)] dark:[--code-block-diff-add-bg:color-mix(in_oklch,var(--success)_12%,transparent)] [--code-block-diff-remove-bg:color-mix(in_oklch,var(--destructive)_8%,transparent)] dark:[--code-block-diff-remove-bg:color-mix(in_oklch,var(--destructive)_12%,transparent)] [--code-block-error-bg:color-mix(in_oklch,var(--destructive)_8%,transparent)] dark:[--code-block-error-bg:color-mix(in_oklch,var(--destructive)_12%,transparent)] [--code-block-warning-bg:color-mix(in_oklch,var(--warning)_10%,transparent)] dark:[--code-block-warning-bg:color-mix(in_oklch,var(--warning)_14%,transparent)] [--code-block-info-bg:color-mix(in_oklch,var(--info)_8%,transparent)] dark:[--code-block-info-bg:color-mix(in_oklch,var(--info)_12%,transparent)] [--code-block-caret-color:var(--primary)]".split(" ")).join(" "), me = "group/code-block relative flex min-w-0 flex-col rounded-(--code-block-radius) text-left", he = "border border-border bg-card text-card-foreground bg-clip-padding", G = "[&_[data-slot=code-block-token]]:text-[color:var(--cb-c,currentColor)] dark:[&_[data-slot=code-block-token]]:text-[color:var(--cb-cd,currentColor)]", K = [
|
|
324
|
+
"[[data-code-line-numbers]_&]:before:pointer-events-none",
|
|
325
|
+
"[[data-code-line-numbers]_&]:before:sticky",
|
|
326
|
+
"[[data-code-line-numbers]_&]:before:left-0",
|
|
327
|
+
"[[data-code-line-numbers]_&]:before:z-10",
|
|
328
|
+
"[[data-code-line-numbers]_&]:before:-ml-(--code-block-gutter-width)",
|
|
329
|
+
"[[data-code-line-numbers]_&]:before:inline-block",
|
|
330
|
+
"[[data-code-line-numbers]_&]:before:w-(--code-block-gutter-width)",
|
|
331
|
+
"[[data-code-line-numbers]_&]:before:pl-(--code-block-padding)",
|
|
332
|
+
"[[data-code-line-numbers]_&]:before:pr-(--code-block-number-pad)",
|
|
333
|
+
"[[data-code-line-numbers]_&]:before:bg-(--code-block-bg)",
|
|
334
|
+
"[[data-code-line-numbers]_&]:before:text-right",
|
|
335
|
+
"[[data-code-line-numbers]_&]:before:tabular-nums",
|
|
336
|
+
"[[data-code-line-numbers]_&]:before:text-muted-foreground/50",
|
|
337
|
+
"[[data-code-line-numbers]_&]:before:select-none",
|
|
338
|
+
"[[data-code-line-numbers]_&]:before:[counter-increment:cb-line]",
|
|
339
|
+
"[[data-code-line-numbers]_&]:before:content-[counter(cb-line)]",
|
|
340
|
+
"[[data-code-line-numbers]_&[data-gutter]]:before:content-[attr(data-gutter)]",
|
|
341
|
+
"[[data-code-line-numbers]_&[data-gutter]]:before:whitespace-pre"
|
|
342
|
+
].join(" "), q = [
|
|
343
|
+
"data-[diff]:after:absolute",
|
|
344
|
+
"data-[diff]:after:z-20",
|
|
345
|
+
"data-[diff]:after:left-0",
|
|
346
|
+
"data-[diff]:after:w-(--code-block-padding)",
|
|
347
|
+
"data-[diff]:after:text-center",
|
|
348
|
+
"[[data-code-line-numbers]_&]:data-[diff]:after:-left-(--code-block-gutter-gap)",
|
|
349
|
+
"[[data-code-line-numbers]_&]:data-[diff]:after:w-(--code-block-gutter-gap)",
|
|
350
|
+
"data-[diff]:after:select-none",
|
|
351
|
+
"data-[diff=add]:after:text-success",
|
|
352
|
+
"data-[diff=remove]:after:text-destructive",
|
|
353
|
+
"data-[diff=add]:after:content-['+']",
|
|
354
|
+
"data-[diff=remove]:after:content-['-']"
|
|
355
|
+
].join(" "), ge = [
|
|
356
|
+
"data-[highlighted]:bg-(--code-block-highlight-bg)",
|
|
357
|
+
"data-[highlighted]:shadow-[inset_2px_0_0_0_var(--code-block-highlight-bar)]",
|
|
358
|
+
"data-[diff=add]:bg-(--code-block-diff-add-bg)",
|
|
359
|
+
"data-[diff=remove]:bg-(--code-block-diff-remove-bg)",
|
|
360
|
+
"data-[level=error]:bg-(--code-block-error-bg)",
|
|
361
|
+
"data-[level=warning]:bg-(--code-block-warning-bg)",
|
|
362
|
+
"data-[level=info]:bg-(--code-block-info-bg)",
|
|
363
|
+
"data-[selected]:bg-accent",
|
|
364
|
+
"[[data-selectable]_&]:data-[active]:bg-muted/40"
|
|
365
|
+
].join(" "), J = "[[data-streaming]_&]:animate-in [[data-streaming]_&]:fade-in-0 [[data-streaming]_&]:slide-in-from-bottom-1 [[data-streaming]_&]:duration-150 [[data-streaming]_&]:ease-out motion-reduce:animate-none", Y = "", _e = "data-[blurred]:opacity-40 data-[blurred]:blur-[1.5px] data-[blurred]:transition-[opacity,filter] group-hover/code-block:data-[blurred]:opacity-100 group-hover/code-block:data-[blurred]:blur-none", ve = e("relative block min-h-(--code-block-line-height) w-full px-(--code-block-padding) leading-(--code-block-line-height)", "[[data-code-line-numbers]_&]:pl-0"), X = /^[ \t]*/;
|
|
366
|
+
function ye(e) {
|
|
367
|
+
let t = (e) => (X.exec(e)?.[0] ?? "").replace(/\t/g, " ").length, n = (e) => e.trim().length === 0, r = [], i = [], a = null;
|
|
368
|
+
for (let o of e) {
|
|
369
|
+
if (n(o.text)) continue;
|
|
370
|
+
let e = t(o.text);
|
|
371
|
+
for (; i.length && e <= i[i.length - 1].indent;) {
|
|
372
|
+
let e = i.pop();
|
|
373
|
+
e.last > e.start && r.push({
|
|
374
|
+
start: e.start,
|
|
375
|
+
end: e.last
|
|
376
|
+
});
|
|
377
|
+
}
|
|
378
|
+
for (let e of i) e.last = o.number;
|
|
379
|
+
a && e > a.indent && i.push({
|
|
380
|
+
start: a.number,
|
|
381
|
+
indent: a.indent,
|
|
382
|
+
last: o.number
|
|
383
|
+
}), a = {
|
|
384
|
+
number: o.number,
|
|
385
|
+
indent: e
|
|
386
|
+
};
|
|
387
|
+
}
|
|
388
|
+
for (; i.length;) {
|
|
389
|
+
let e = i.pop();
|
|
390
|
+
e.last > e.start && r.push({
|
|
391
|
+
start: e.start,
|
|
392
|
+
end: e.last
|
|
393
|
+
});
|
|
394
|
+
}
|
|
395
|
+
return r.sort((e, t) => e.start - t.start);
|
|
396
|
+
}
|
|
397
|
+
var be = [];
|
|
398
|
+
function xe(e) {
|
|
399
|
+
if (!e.color && !e.colorDark && !e.fontStyle) return;
|
|
400
|
+
let t = {};
|
|
401
|
+
return e.color && (t["--cb-c"] = e.color), e.colorDark && (t["--cb-cd"] = e.colorDark), e.fontStyle === "italic" && (t.fontStyle = "italic"), e.fontStyle === "bold" && (t.fontWeight = 700), e.fontStyle === "underline" && (t.textDecoration = "underline"), t;
|
|
402
|
+
}
|
|
403
|
+
function Se({ tokens: t }) {
|
|
404
|
+
return /* @__PURE__ */ _(g, { children: t.map((t, n) => {
|
|
405
|
+
let r = xe(t);
|
|
406
|
+
return !r && !t.word ? /* @__PURE__ */ _("span", { children: t.content }, n) : /* @__PURE__ */ _("span", {
|
|
407
|
+
"data-slot": "code-block-token",
|
|
408
|
+
"data-word": t.word || void 0,
|
|
409
|
+
className: e(t.word && "bg-primary/10 ring-primary/20 rounded-sm px-0.5 py-px ring-1 ring-inset"),
|
|
410
|
+
style: r,
|
|
411
|
+
children: t.content
|
|
412
|
+
}, n);
|
|
413
|
+
}) });
|
|
414
|
+
}
|
|
415
|
+
var Ce = o(function({ line: t, selectable: n, selected: r, focusMode: i, active: a, caret: o, actions: s, actionsSide: c = "end", domIdBase: l, startLine: u = 1, onSelect: d, foldable: f, foldRegion: p, folded: m, onToggleFold: h }) {
|
|
416
|
+
let g = t.state, y = i && !g?.focused, b = l ? `${l}-L${t.number}` : void 0, x = p ? p.end - p.start : 0, S = c === "gutter" && !p;
|
|
417
|
+
return /* @__PURE__ */ v("span", {
|
|
418
|
+
"data-slot": "code-block-line",
|
|
419
|
+
"data-code-line": t.number,
|
|
420
|
+
"data-gutter": t.gutter,
|
|
421
|
+
id: b,
|
|
422
|
+
"data-active": a || void 0,
|
|
423
|
+
"data-highlighted": g?.highlighted || void 0,
|
|
424
|
+
"data-diff": g?.diff,
|
|
425
|
+
"data-focused": g?.focused || void 0,
|
|
426
|
+
"data-blurred": y || void 0,
|
|
427
|
+
"data-level": g?.level,
|
|
428
|
+
"data-selected": r || void 0,
|
|
429
|
+
role: n ? "option" : void 0,
|
|
430
|
+
"aria-selected": n ? r : void 0,
|
|
431
|
+
tabIndex: n ? -1 : void 0,
|
|
432
|
+
onMouseDown: n ? (e) => {
|
|
433
|
+
e.shiftKey && e.preventDefault();
|
|
434
|
+
} : void 0,
|
|
435
|
+
onClick: n && d ? (e) => d(t.number, e.shiftKey) : void 0,
|
|
436
|
+
className: e(ve, K, ge, q, _e, J, n && "cursor-pointer"),
|
|
437
|
+
style: { counterReset: `cb-line ${t.number - 1}` },
|
|
438
|
+
children: [
|
|
439
|
+
p && h ? /* @__PURE__ */ _("button", {
|
|
440
|
+
type: "button",
|
|
441
|
+
tabIndex: n ? -1 : void 0,
|
|
442
|
+
"data-slot": "code-block-fold-toggle",
|
|
443
|
+
"data-state": m ? "folded" : "unfolded",
|
|
444
|
+
"aria-expanded": !m,
|
|
445
|
+
"aria-label": m ? `Unfold lines ${p.start + u - 1} to ${p.end + u - 1}` : `Fold lines ${p.start + u - 1} to ${p.end + u - 1}`,
|
|
446
|
+
onClick: (e) => {
|
|
447
|
+
e.stopPropagation(), h(p.start);
|
|
448
|
+
},
|
|
449
|
+
className: e("text-muted-foreground hover:bg-muted hover:text-foreground focus-visible:ring-ring/50 sticky z-20 inline-flex size-(--code-block-fold-width) shrink-0 translate-y-[calc((var(--code-block-line-height)-var(--code-block-fold-width))/2)] cursor-pointer items-center justify-center rounded-[4px] align-top outline-none focus-visible:ring-2", "-ml-[calc(var(--code-block-fold-width)+0.25rem)]", "mr-[0.25rem]", "left-[calc(var(--code-block-gutter-width)-var(--code-block-fold-width)-0.25rem)]", m && "text-muted-foreground/60"),
|
|
450
|
+
children: /* @__PURE__ */ _("svg", {
|
|
451
|
+
"aria-hidden": "true",
|
|
452
|
+
viewBox: "0 0 24 24",
|
|
453
|
+
fill: "none",
|
|
454
|
+
stroke: "currentColor",
|
|
455
|
+
strokeWidth: "2.5",
|
|
456
|
+
strokeLinecap: "round",
|
|
457
|
+
strokeLinejoin: "round",
|
|
458
|
+
className: "size-3",
|
|
459
|
+
children: /* @__PURE__ */ _("path", { d: m ? "m9 18 6-6-6-6" : "m6 9 6 6 6-6" })
|
|
460
|
+
})
|
|
461
|
+
}) : null,
|
|
462
|
+
s && a ? /* @__PURE__ */ _("span", {
|
|
463
|
+
"data-slot": "code-block-line-actions",
|
|
464
|
+
"data-side": S ? "gutter" : "end",
|
|
465
|
+
contentEditable: !1,
|
|
466
|
+
onClick: (e) => e.stopPropagation(),
|
|
467
|
+
className: e("text-foreground z-20 items-center gap-1 font-sans whitespace-normal select-none", !S && "absolute end-2 top-0 flex h-(--code-block-line-height)", S && "absolute top-1/2 left-0 flex -translate-x-1/2 -translate-y-1/2 items-center justify-center"),
|
|
468
|
+
children: s({
|
|
469
|
+
line: t.number,
|
|
470
|
+
text: t.text,
|
|
471
|
+
state: g
|
|
472
|
+
})
|
|
473
|
+
}) : null,
|
|
474
|
+
/* @__PURE__ */ v("span", {
|
|
475
|
+
"data-slot": "code-block-line-content",
|
|
476
|
+
children: [
|
|
477
|
+
t.tokens.length === 0 ? /* @__PURE__ */ _("br", {}) : null,
|
|
478
|
+
/* @__PURE__ */ _(Se, { tokens: t.tokens }),
|
|
479
|
+
m && x > 0 ? /* @__PURE__ */ _("button", {
|
|
480
|
+
type: "button",
|
|
481
|
+
tabIndex: n ? -1 : void 0,
|
|
482
|
+
"data-slot": "code-block-fold-marker",
|
|
483
|
+
"aria-label": `Unfold ${x} hidden lines`,
|
|
484
|
+
onClick: (e) => {
|
|
485
|
+
e.stopPropagation(), h?.(t.number);
|
|
486
|
+
},
|
|
487
|
+
className: "bg-muted/80 text-muted-foreground hover:bg-muted ml-2 inline-flex h-(--code-block-fold-width) translate-y-[calc((var(--code-block-line-height)-var(--code-block-fold-width))/2)] cursor-pointer items-center rounded-sm px-1.5 align-top text-[0.8em] leading-none select-none",
|
|
488
|
+
children: `... ${x} lines`
|
|
489
|
+
}) : null,
|
|
490
|
+
o ? /* @__PURE__ */ _("span", {
|
|
491
|
+
"data-slot": "code-block-caret",
|
|
492
|
+
"aria-hidden": "true",
|
|
493
|
+
className: "ml-0.5 inline-block h-[0.12em] w-[0.55em] translate-y-[0.02em] animate-pulse rounded-[1px] bg-(--code-block-caret-color) motion-reduce:animate-none"
|
|
494
|
+
}) : null
|
|
495
|
+
]
|
|
496
|
+
})
|
|
497
|
+
]
|
|
498
|
+
});
|
|
499
|
+
});
|
|
500
|
+
function we({ code: t, language: n, lines: r, themes: i, highlight: a = !0, showLineNumbers: o = !1, startLine: c = 1, wrap: f, defaultWrap: g = !1, onWrapChange: y, maxLines: b, variant: x = "default", label: S, highlightedLines: C, highlightedWords: T, focusedLines: E, diff: D, lineLevels: ee, transformers: k, streaming: A = !1, selectable: j = !1, selectedLines: M, defaultSelectedLines: N, onSelectedLinesChange: P, completeAnnouncement: te, expanded: F, defaultExpanded: ne = !1, onExpandedChange: I, foldable: L = !1, foldRegions: R, folded: z, defaultFolded: B, onFoldedChange: V, className: re, children: H, ...ie }) {
|
|
501
|
+
let U = d(), W = t ?? "", ue = w(n), G = l(W), K = p(() => O(G, c), [G, c]), [q, ge] = h(null), J = !r && a && !!ue && W.length > 0, Y = JSON.stringify([
|
|
502
|
+
i ?? null,
|
|
503
|
+
c,
|
|
504
|
+
C ?? null,
|
|
505
|
+
T ?? null,
|
|
506
|
+
E ?? null,
|
|
507
|
+
D ?? null,
|
|
508
|
+
ee ?? null
|
|
509
|
+
]), _e = m(!1), ve = m(k);
|
|
510
|
+
u(() => {
|
|
511
|
+
process.env.NODE_ENV !== "production" && A && ve.current !== k && !_e.current && (_e.current = !0, console.warn("[code-block] `transformers` changed identity during a stream, which re-tokenizes the whole document per chunk. Hoist the array to module scope or memoize it.")), ve.current = k;
|
|
512
|
+
}, [k, A]), u(() => {
|
|
513
|
+
if (!J) {
|
|
514
|
+
ge(null);
|
|
515
|
+
return;
|
|
516
|
+
}
|
|
517
|
+
let [e, t, r, i, a, o, s] = JSON.parse(Y), c = !0;
|
|
518
|
+
return ae(G, {
|
|
519
|
+
language: n,
|
|
520
|
+
instanceKey: U,
|
|
521
|
+
themes: e ?? void 0,
|
|
522
|
+
transformers: k,
|
|
523
|
+
startLine: t,
|
|
524
|
+
highlightedLines: r ?? void 0,
|
|
525
|
+
highlightedWords: i ?? void 0,
|
|
526
|
+
focusedLines: a ?? void 0,
|
|
527
|
+
diff: o ?? void 0,
|
|
528
|
+
lineLevels: s ?? void 0
|
|
529
|
+
}).then((e) => {
|
|
530
|
+
c && ge({
|
|
531
|
+
source: G,
|
|
532
|
+
spec: Y,
|
|
533
|
+
lines: e
|
|
534
|
+
});
|
|
535
|
+
}), () => {
|
|
536
|
+
c = !1;
|
|
537
|
+
};
|
|
538
|
+
}, [
|
|
539
|
+
J,
|
|
540
|
+
G,
|
|
541
|
+
n,
|
|
542
|
+
k,
|
|
543
|
+
Y
|
|
544
|
+
]);
|
|
545
|
+
let X = p(() => r || (!J || !q || q.spec !== Y || !G.startsWith(q.source) ? K : q.lines.length >= K.length ? q.lines : [...q.lines, ...K.slice(q.lines.length)]), [
|
|
546
|
+
r,
|
|
547
|
+
J,
|
|
548
|
+
q,
|
|
549
|
+
K,
|
|
550
|
+
G,
|
|
551
|
+
Y
|
|
552
|
+
]), xe = p(() => X.some((e) => e.state?.focused), [X]), Se = p(() => X.some((e) => e.state?.diff), [X]), [Ce, we] = h(g), ke = f ?? Ce, Ae = s((e) => {
|
|
553
|
+
f === void 0 && we(e), y?.(e);
|
|
554
|
+
}, [f, y]), Z = typeof b == "number" && X.length > b, [je, Me] = h(ne), Ne = F ?? je, Pe = s((e) => {
|
|
555
|
+
F === void 0 && Me(e), I?.(e);
|
|
556
|
+
}, [F, I]), Fe = !Z || Ne, [Ie, Le] = h(N ?? []), Re = M ?? Ie, Q = p(() => new Set(Re), [Re]), ze = m(null), Be = m({
|
|
557
|
+
selection: Re,
|
|
558
|
+
selectedSet: Q,
|
|
559
|
+
controlled: M !== void 0,
|
|
560
|
+
onSelectedLinesChange: P
|
|
561
|
+
});
|
|
562
|
+
Be.current = {
|
|
563
|
+
selection: Re,
|
|
564
|
+
selectedSet: Q,
|
|
565
|
+
controlled: M !== void 0,
|
|
566
|
+
onSelectedLinesChange: P
|
|
567
|
+
};
|
|
568
|
+
let Ve = s((e) => {
|
|
569
|
+
Be.current.controlled || Le(e), Be.current.onSelectedLinesChange?.(e);
|
|
570
|
+
}, []), He = s((e, t) => {
|
|
571
|
+
let n = ze.current, { selection: r, selectedSet: i } = Be.current;
|
|
572
|
+
if (t && n !== null) {
|
|
573
|
+
let t = Math.min(n, e), r = Math.max(n, e), i = [];
|
|
574
|
+
for (let e = t; e <= r; e += 1) i.push(e);
|
|
575
|
+
Ve(i);
|
|
576
|
+
return;
|
|
577
|
+
}
|
|
578
|
+
ze.current = e, Ve(i.has(e) ? r.filter((t) => t !== e) : [...r, e].sort((e, t) => e - t));
|
|
579
|
+
}, [Ve]), Ue = p(() => L ? R || ye(X).map((e) => ({
|
|
580
|
+
start: e.start - c + 1,
|
|
581
|
+
end: e.end - c + 1
|
|
582
|
+
})) : be, [
|
|
583
|
+
L,
|
|
584
|
+
R,
|
|
585
|
+
X,
|
|
586
|
+
c
|
|
587
|
+
]), We = p(() => new Map(Ue.map((e) => [e.start, e])), [Ue]), [Ge, Ke] = h(B ?? []), qe = z ?? Ge, $ = p(() => new Set(qe), [qe]), Je = m({
|
|
588
|
+
foldedValue: qe,
|
|
589
|
+
foldedSet: $,
|
|
590
|
+
controlled: z !== void 0,
|
|
591
|
+
onFoldedChange: V
|
|
592
|
+
});
|
|
593
|
+
Je.current = {
|
|
594
|
+
foldedValue: qe,
|
|
595
|
+
foldedSet: $,
|
|
596
|
+
controlled: z !== void 0,
|
|
597
|
+
onFoldedChange: V
|
|
598
|
+
};
|
|
599
|
+
let Ye = s((e) => {
|
|
600
|
+
Je.current.controlled || Ke(e), Je.current.onFoldedChange?.(e);
|
|
601
|
+
}, []), Xe = s((e) => {
|
|
602
|
+
let { foldedValue: t, foldedSet: n } = Je.current;
|
|
603
|
+
Ye(n.has(e) ? t.filter((t) => t !== e) : [...t, e].sort((e, t) => e - t));
|
|
604
|
+
}, [Ye]), Ze = p(() => {
|
|
605
|
+
if (!L || $.size === 0) return X;
|
|
606
|
+
let e = /* @__PURE__ */ new Set();
|
|
607
|
+
for (let t of $) {
|
|
608
|
+
let n = We.get(t);
|
|
609
|
+
if (n) for (let t = n.start + 1; t <= n.end; t += 1) e.add(t + c - 1);
|
|
610
|
+
}
|
|
611
|
+
return X.filter((t) => !e.has(t.number));
|
|
612
|
+
}, [
|
|
613
|
+
L,
|
|
614
|
+
$,
|
|
615
|
+
We,
|
|
616
|
+
X,
|
|
617
|
+
c
|
|
618
|
+
]), Qe = p(() => ({
|
|
619
|
+
language: n,
|
|
620
|
+
resolvedLanguage: ue,
|
|
621
|
+
showLineNumbers: o,
|
|
622
|
+
wrap: ke,
|
|
623
|
+
setWrap: Ae,
|
|
624
|
+
wrapControlled: f !== void 0,
|
|
625
|
+
expanded: Fe,
|
|
626
|
+
setExpanded: Pe,
|
|
627
|
+
collapsible: Z,
|
|
628
|
+
streaming: A,
|
|
629
|
+
contentId: U
|
|
630
|
+
}), [
|
|
631
|
+
n,
|
|
632
|
+
ue,
|
|
633
|
+
o,
|
|
634
|
+
ke,
|
|
635
|
+
Ae,
|
|
636
|
+
f,
|
|
637
|
+
Fe,
|
|
638
|
+
Z,
|
|
639
|
+
A,
|
|
640
|
+
U
|
|
641
|
+
]), $e = s(() => Ve([]), [Ve]), et = p(() => ({
|
|
642
|
+
code: W,
|
|
643
|
+
lines: X,
|
|
644
|
+
selected: Q,
|
|
645
|
+
selectable: j,
|
|
646
|
+
toggleLine: He,
|
|
647
|
+
clearSelection: $e,
|
|
648
|
+
foldable: L,
|
|
649
|
+
foldRegions: Ue,
|
|
650
|
+
folded: $,
|
|
651
|
+
toggleFold: Xe,
|
|
652
|
+
setFolded: Ye
|
|
653
|
+
}), [
|
|
654
|
+
W,
|
|
655
|
+
X,
|
|
656
|
+
Q,
|
|
657
|
+
j,
|
|
658
|
+
He,
|
|
659
|
+
$e,
|
|
660
|
+
L,
|
|
661
|
+
Ue,
|
|
662
|
+
$,
|
|
663
|
+
Xe,
|
|
664
|
+
Ye
|
|
665
|
+
]), tt = Z && !Fe ? b : void 0, nt = Ee(H, Oe), [rt, it] = h(null), [at, ot] = h("end"), st = m(null), ct = p(() => ({ register: (e, t, n = "end") => {
|
|
666
|
+
if (t) process.env.NODE_ENV !== "production" && st.current && st.current !== e && console.warn("[code-block] Two CodeBlockLineActions are mounted; the block renders ONE action group and the later mount replaces the earlier one."), st.current = e;
|
|
667
|
+
else if (st.current !== e) return;
|
|
668
|
+
else st.current = null;
|
|
669
|
+
it(() => t), ot(n);
|
|
670
|
+
} }), []), lt = L, ut = Ee(H, Te), dt = {
|
|
671
|
+
lines: Ze,
|
|
672
|
+
gutterMax: X[X.length - 1]?.number ?? c,
|
|
673
|
+
foldable: L,
|
|
674
|
+
gutterChannel: lt,
|
|
675
|
+
actionsSide: at,
|
|
676
|
+
foldStarts: We,
|
|
677
|
+
foldedSet: $,
|
|
678
|
+
onToggleFold: Xe,
|
|
679
|
+
expandClearance: Z && Fe,
|
|
680
|
+
wrap: ke,
|
|
681
|
+
startLine: c,
|
|
682
|
+
showLineNumbers: o,
|
|
683
|
+
focusMode: xe,
|
|
684
|
+
selectable: j,
|
|
685
|
+
selectedSet: Q,
|
|
686
|
+
toggleLine: He,
|
|
687
|
+
visibleLines: tt,
|
|
688
|
+
streaming: A,
|
|
689
|
+
label: S ?? (n ? `${n} code` : "Code"),
|
|
690
|
+
contentId: U,
|
|
691
|
+
actions: rt,
|
|
692
|
+
completeAnnouncement: te,
|
|
693
|
+
builtInSurfaceRendered: !ut
|
|
694
|
+
};
|
|
695
|
+
return /* @__PURE__ */ _(oe.Provider, {
|
|
696
|
+
value: Qe,
|
|
697
|
+
children: /* @__PURE__ */ _(se.Provider, {
|
|
698
|
+
value: et,
|
|
699
|
+
children: /* @__PURE__ */ _(le.Provider, {
|
|
700
|
+
value: ct,
|
|
701
|
+
children: /* @__PURE__ */ _("div", {
|
|
702
|
+
"data-slot": "code-block",
|
|
703
|
+
"data-variant": x,
|
|
704
|
+
"data-streaming": A || void 0,
|
|
705
|
+
"data-has-diff": Se || void 0,
|
|
706
|
+
"data-foldable": L || void 0,
|
|
707
|
+
"data-gutter-channel": lt || void 0,
|
|
708
|
+
"data-has-header": nt || void 0,
|
|
709
|
+
className: e(me, fe, pe, x === "default" && he, x === "ghost" && de, re),
|
|
710
|
+
...ie,
|
|
711
|
+
children: /* @__PURE__ */ v(ce.Provider, {
|
|
712
|
+
value: dt,
|
|
713
|
+
children: [H, !ut && /* @__PURE__ */ _(De, { ...dt })]
|
|
714
|
+
})
|
|
715
|
+
})
|
|
716
|
+
})
|
|
717
|
+
})
|
|
718
|
+
});
|
|
719
|
+
}
|
|
720
|
+
function Te({ className: e }) {
|
|
721
|
+
let t = c(ce);
|
|
722
|
+
if (!t) throw Error("CodeBlockContent must be used within a CodeBlock");
|
|
723
|
+
return u(() => {
|
|
724
|
+
process.env.NODE_ENV !== "production" && t.builtInSurfaceRendered && console.error("CodeBlockContent is hidden behind a component boundary, so CodeBlock also rendered its built-in surface and the code appears twice. Compose <CodeBlockContent /> directly in the CodeBlock's children (plain wrappers like a ScrollArea are fine).");
|
|
725
|
+
}, [t.builtInSurfaceRendered]), /* @__PURE__ */ _(De, {
|
|
726
|
+
...t,
|
|
727
|
+
scroll: !1,
|
|
728
|
+
className: e
|
|
729
|
+
});
|
|
730
|
+
}
|
|
731
|
+
function Ee(e, t) {
|
|
732
|
+
for (let n of r.toArray(e)) {
|
|
733
|
+
if (!a(n)) continue;
|
|
734
|
+
if (n.type === t) return !0;
|
|
735
|
+
let e = n.props.children;
|
|
736
|
+
if (e && Ee(e, t)) return !0;
|
|
737
|
+
}
|
|
738
|
+
return !1;
|
|
739
|
+
}
|
|
740
|
+
function De({ lines: t, wrap: n, startLine: r, showLineNumbers: i, focusMode: a, selectable: o, selectedSet: c, toggleLine: l, visibleLines: d, gutterMax: f, foldable: p, gutterChannel: g, actionsSide: y, foldStarts: b, foldedSet: x, onToggleFold: S, expandClearance: C, streaming: w, label: T, contentId: E, actions: D, completeAnnouncement: ee, scroll: O = !0, className: k }) {
|
|
741
|
+
let A = m(null), j = m(null), [M, N] = h(null), P = m(!0), [te, F] = h(""), ne = m(w);
|
|
742
|
+
u(() => {
|
|
743
|
+
ne.current && !w && F(ee ?? `Code generation complete, ${t.length} lines.`), ne.current = w;
|
|
744
|
+
}, [
|
|
745
|
+
w,
|
|
746
|
+
t.length,
|
|
747
|
+
ee
|
|
748
|
+
]);
|
|
749
|
+
let I = s(() => {
|
|
750
|
+
let e = A.current;
|
|
751
|
+
if (!e) return null;
|
|
752
|
+
if (e.scrollHeight > e.clientHeight + 1) return e;
|
|
753
|
+
let t = e.parentElement;
|
|
754
|
+
for (; t && t !== document.body;) {
|
|
755
|
+
let e = getComputedStyle(t).overflowY;
|
|
756
|
+
if ((e === "auto" || e === "scroll" || e === "overlay") && t.scrollHeight > t.clientHeight + 1) return t;
|
|
757
|
+
t = t.parentElement;
|
|
758
|
+
}
|
|
759
|
+
let n = document.scrollingElement;
|
|
760
|
+
return n && n.scrollHeight > n.clientHeight + 1 ? n : e;
|
|
761
|
+
}, []), L = s(() => {
|
|
762
|
+
let e = A.current;
|
|
763
|
+
if (!e) return;
|
|
764
|
+
let t = e.scrollHeight - e.scrollTop - e.clientHeight;
|
|
765
|
+
P.current = t < 24;
|
|
766
|
+
}, []);
|
|
767
|
+
u(() => {
|
|
768
|
+
if (!w) return;
|
|
769
|
+
let e = I();
|
|
770
|
+
if (!e || e === A.current) return;
|
|
771
|
+
let t = () => {
|
|
772
|
+
let t = e.scrollHeight - e.scrollTop - e.clientHeight;
|
|
773
|
+
P.current = t < 24;
|
|
774
|
+
}, n = e === document.scrollingElement ? window : e;
|
|
775
|
+
return n.addEventListener("scroll", t, { passive: !0 }), () => n.removeEventListener("scroll", t);
|
|
776
|
+
}, [
|
|
777
|
+
w,
|
|
778
|
+
t.length,
|
|
779
|
+
I
|
|
780
|
+
]), W(() => {
|
|
781
|
+
if (!w || !P.current) return;
|
|
782
|
+
let e = I();
|
|
783
|
+
e && (e.scrollTop = e.scrollHeight);
|
|
784
|
+
}, [
|
|
785
|
+
t,
|
|
786
|
+
w,
|
|
787
|
+
I
|
|
788
|
+
]);
|
|
789
|
+
let R = s((e) => {
|
|
790
|
+
if (!D && !o) return;
|
|
791
|
+
let t = (e.target?.closest?.("[data-code-line]"))?.getAttribute("data-code-line");
|
|
792
|
+
t && N(Number(t));
|
|
793
|
+
}, [D, o]), z = s(() => N(null), []), B = s((e, t) => l(e - r + 1, t), [l, r]), V = s((e) => {
|
|
794
|
+
if (!o) return;
|
|
795
|
+
if (e.key === "Escape") {
|
|
796
|
+
N(null);
|
|
797
|
+
return;
|
|
798
|
+
}
|
|
799
|
+
if ((e.key === "Enter" || e.key === " ") && M !== null) {
|
|
800
|
+
e.preventDefault(), B(M, e.shiftKey);
|
|
801
|
+
return;
|
|
802
|
+
}
|
|
803
|
+
let n = e.key === "ArrowDown" || e.key === "ArrowUp";
|
|
804
|
+
if (!n && e.key !== "Home" && e.key !== "End") return;
|
|
805
|
+
e.preventDefault();
|
|
806
|
+
let i;
|
|
807
|
+
if (e.key === "Home") i = t[0]?.number ?? r;
|
|
808
|
+
else if (e.key === "End") i = t[t.length - 1]?.number ?? r;
|
|
809
|
+
else {
|
|
810
|
+
let n = e.key === "ArrowDown" ? 1 : -1, a = t.findIndex((e) => e.number === M);
|
|
811
|
+
i = t[a === -1 ? n === 1 ? 0 : t.length - 1 : Math.min(t.length - 1, Math.max(0, a + n))]?.number ?? r;
|
|
812
|
+
}
|
|
813
|
+
N(i), (j.current?.querySelector(`[data-code-line="${i}"]`))?.scrollIntoView({ block: "nearest" }), n && e.shiftKey && B(i, !0);
|
|
814
|
+
}, [
|
|
815
|
+
o,
|
|
816
|
+
t,
|
|
817
|
+
r,
|
|
818
|
+
M,
|
|
819
|
+
B
|
|
820
|
+
]), re = t[t.length - 1]?.number, H = Math.max(2, String(f ?? r).length, ...t.map((e) => e.gutter?.length ?? 0)), ie = {
|
|
821
|
+
"--code-block-gutter-width": g ? `calc(${H}ch + var(--code-block-fold-width) + var(--code-block-gutter-gap) + var(--code-block-padding))` : `calc(${H}ch + var(--code-block-gutter-gap) + var(--code-block-padding))`,
|
|
822
|
+
counterReset: `cb-line ${r - 1}`
|
|
823
|
+
};
|
|
824
|
+
return /* @__PURE__ */ v("div", {
|
|
825
|
+
"data-slot": "code-block-content",
|
|
826
|
+
className: e("relative min-w-0 rounded-[inherit]", O && "flex-1 overflow-hidden"),
|
|
827
|
+
children: [/* @__PURE__ */ _("span", {
|
|
828
|
+
role: "status",
|
|
829
|
+
"aria-live": "polite",
|
|
830
|
+
className: "sr-only",
|
|
831
|
+
children: te
|
|
832
|
+
}), /* @__PURE__ */ _("div", {
|
|
833
|
+
ref: A,
|
|
834
|
+
"data-slot": "code-block-viewport",
|
|
835
|
+
id: E,
|
|
836
|
+
role: "region",
|
|
837
|
+
"aria-label": T,
|
|
838
|
+
"aria-busy": w || void 0,
|
|
839
|
+
"aria-activedescendant": o && M !== null ? `${E}-L${M}` : void 0,
|
|
840
|
+
tabIndex: 0,
|
|
841
|
+
onScroll: L,
|
|
842
|
+
onKeyDown: V,
|
|
843
|
+
className: e("focus-visible:ring-ring/50 relative min-w-0 rounded-[inherit] outline-none focus-visible:ring-[3px]", O && "[scrollbar-width:thin] overflow-auto", O && d && "max-h-(--cb-max-height)", k),
|
|
844
|
+
style: O && d ? { "--cb-max-height": `calc(${d} * var(--code-block-line-height) + 2 * var(--code-block-padding))` } : void 0,
|
|
845
|
+
children: /* @__PURE__ */ _("pre", {
|
|
846
|
+
ref: j,
|
|
847
|
+
dir: "ltr",
|
|
848
|
+
"data-code-line-numbers": i || void 0,
|
|
849
|
+
"data-wrap": n || void 0,
|
|
850
|
+
role: o ? "listbox" : void 0,
|
|
851
|
+
"data-selectable": o || void 0,
|
|
852
|
+
"aria-multiselectable": o || void 0,
|
|
853
|
+
"aria-label": o ? `${T} lines` : void 0,
|
|
854
|
+
onPointerOver: R,
|
|
855
|
+
onPointerLeave: z,
|
|
856
|
+
onFocus: R,
|
|
857
|
+
className: e("w-max min-w-full py-(--code-block-padding) font-mono text-(length:--code-block-font-size)", G, Y, n && "w-full max-w-full min-w-0 break-words whitespace-pre-wrap", i && "pl-(--code-block-gutter-width)", C && "pb-(--code-block-expand-clearance)"),
|
|
858
|
+
style: ie,
|
|
859
|
+
children: /* @__PURE__ */ _("code", {
|
|
860
|
+
"data-slot": "code-block-code",
|
|
861
|
+
role: o ? "presentation" : void 0,
|
|
862
|
+
children: t.map((e) => /* @__PURE__ */ _(Ce, {
|
|
863
|
+
line: e,
|
|
864
|
+
selectable: o,
|
|
865
|
+
selected: c.has(e.number - r + 1),
|
|
866
|
+
focusMode: a,
|
|
867
|
+
active: M === e.number,
|
|
868
|
+
caret: w && e.number === re,
|
|
869
|
+
actions: M === e.number ? D : null,
|
|
870
|
+
actionsSide: y,
|
|
871
|
+
domIdBase: E,
|
|
872
|
+
startLine: r,
|
|
873
|
+
onSelect: B,
|
|
874
|
+
foldable: p,
|
|
875
|
+
foldRegion: b.get(e.number - r + 1),
|
|
876
|
+
folded: x.has(e.number - r + 1),
|
|
877
|
+
onToggleFold: S
|
|
878
|
+
}, e.number))
|
|
879
|
+
})
|
|
880
|
+
})
|
|
881
|
+
})]
|
|
882
|
+
});
|
|
883
|
+
}
|
|
884
|
+
function Oe({ className: t, ...n }) {
|
|
885
|
+
return /* @__PURE__ */ _(U.Provider, {
|
|
886
|
+
value: !0,
|
|
887
|
+
children: /* @__PURE__ */ _("div", {
|
|
888
|
+
"data-slot": "code-block-header",
|
|
889
|
+
className: e("border-border flex min-h-9 shrink-0 items-center gap-2 border-b px-3 py-0 text-sm", t),
|
|
890
|
+
...n
|
|
891
|
+
})
|
|
892
|
+
});
|
|
893
|
+
}
|
|
894
|
+
function ke({ copied: e }) {
|
|
895
|
+
return e ? /* @__PURE__ */ _("svg", {
|
|
896
|
+
viewBox: "0 0 24 24",
|
|
897
|
+
fill: "none",
|
|
898
|
+
stroke: "currentColor",
|
|
899
|
+
strokeWidth: "2",
|
|
900
|
+
strokeLinecap: "round",
|
|
901
|
+
strokeLinejoin: "round",
|
|
902
|
+
"aria-hidden": "true",
|
|
903
|
+
children: /* @__PURE__ */ _("path", { d: "M20 6 9 17l-5-5" })
|
|
904
|
+
}) : /* @__PURE__ */ v("svg", {
|
|
905
|
+
viewBox: "0 0 24 24",
|
|
906
|
+
fill: "none",
|
|
907
|
+
stroke: "currentColor",
|
|
908
|
+
strokeWidth: "2",
|
|
909
|
+
strokeLinecap: "round",
|
|
910
|
+
strokeLinejoin: "round",
|
|
911
|
+
"aria-hidden": "true",
|
|
912
|
+
children: [/* @__PURE__ */ _("rect", {
|
|
913
|
+
width: "14",
|
|
914
|
+
height: "14",
|
|
915
|
+
x: "8",
|
|
916
|
+
y: "8",
|
|
917
|
+
rx: "2",
|
|
918
|
+
ry: "2"
|
|
919
|
+
}), /* @__PURE__ */ _("path", { d: "M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2" })]
|
|
920
|
+
});
|
|
921
|
+
}
|
|
922
|
+
function Ae({ value: n, timeout: r = 2e3, onCopy: i, onCopyError: a, labels: o, position: l = "auto", alwaysVisible: d = !1, className: f, variant: p = "ghost", size: m, children: g, ...v }) {
|
|
923
|
+
let y = c(oe), b = c(U), [x, S] = h(!1), [C, w] = h(!1), T = l === "auto" ? b ? "inline" : "pinned" : l, E = m ?? (T === "inline" ? "icon-sm" : "icon");
|
|
924
|
+
u(() => {
|
|
925
|
+
if (!x || r === 0) return;
|
|
926
|
+
let e = window.setTimeout(() => S(!1), r);
|
|
927
|
+
return () => window.clearTimeout(e);
|
|
928
|
+
}, [x, r]), u(() => {
|
|
929
|
+
if (!C) return;
|
|
930
|
+
let e = window.setTimeout(() => w(!1), 2e3);
|
|
931
|
+
return () => window.clearTimeout(e);
|
|
932
|
+
}, [C]);
|
|
933
|
+
let D = c(se), O = s(() => {
|
|
934
|
+
let e = D?.code || D?.lines.map((e) => e.text).join("\n"), t = ee(n ?? e ?? "");
|
|
935
|
+
t && typeof navigator < "u" && navigator.clipboard?.writeText && navigator.clipboard.writeText(t).then(() => {
|
|
936
|
+
S(!0), i?.(t);
|
|
937
|
+
}, (e) => {
|
|
938
|
+
w(!0), a?.(e);
|
|
939
|
+
});
|
|
940
|
+
}, [
|
|
941
|
+
n,
|
|
942
|
+
y,
|
|
943
|
+
D,
|
|
944
|
+
i,
|
|
945
|
+
a
|
|
946
|
+
]);
|
|
947
|
+
return /* @__PURE__ */ _(t, {
|
|
948
|
+
type: "button",
|
|
949
|
+
"data-slot": "code-block-copy",
|
|
950
|
+
"data-copied": x || void 0,
|
|
951
|
+
"data-copy-failed": C || void 0,
|
|
952
|
+
"data-position": T,
|
|
953
|
+
"aria-label": x ? o?.copied ?? "Copied" : o?.copy ?? "Copy code",
|
|
954
|
+
variant: p,
|
|
955
|
+
size: E,
|
|
956
|
+
onClick: O,
|
|
957
|
+
className: e("shrink-0 [&_svg]:size-3.5", T === "pinned" && "absolute top-(--code-block-copy-top) right-(--code-block-copy-inset) z-20", T === "pinned" && !d && "opacity-0 transition-opacity group-hover/code-block:opacity-100 focus-visible:opacity-100", f),
|
|
958
|
+
...v,
|
|
959
|
+
children: g ?? /* @__PURE__ */ _(ke, { copied: x })
|
|
960
|
+
});
|
|
961
|
+
}
|
|
962
|
+
function Z({ className: n, children: r, variant: i = "ghost", size: a = "sm", onClick: o, ...s }) {
|
|
963
|
+
let { expanded: c, setExpanded: l, collapsible: u, contentId: d } = ue("CodeBlockExpandButton");
|
|
964
|
+
return u ? /* @__PURE__ */ _("div", {
|
|
965
|
+
"data-slot": "code-block-expand",
|
|
966
|
+
"data-state": c ? "expanded" : "collapsed",
|
|
967
|
+
className: e("absolute inset-x-0 bottom-0 z-10 order-last flex items-end justify-center pt-10 pb-2", !c && "from-card via-card/85 bg-gradient-to-t to-transparent", n),
|
|
968
|
+
children: /* @__PURE__ */ _(t, {
|
|
969
|
+
type: "button",
|
|
970
|
+
"aria-expanded": c,
|
|
971
|
+
"aria-controls": d,
|
|
972
|
+
variant: i,
|
|
973
|
+
size: a,
|
|
974
|
+
onClick: (e) => {
|
|
975
|
+
o?.(e), e.defaultPrevented || l(!c);
|
|
976
|
+
},
|
|
977
|
+
...s,
|
|
978
|
+
children: r ?? (c ? "Show less" : "Show more")
|
|
979
|
+
})
|
|
980
|
+
}) : null;
|
|
981
|
+
}
|
|
982
|
+
//#endregion
|
|
983
|
+
//#region src/components/decision-graph/simulator/simulate-run-detail.tsx
|
|
984
|
+
var je = ({ detail: e }) => {
|
|
985
|
+
let t = n(), r = y.stringify(e, void 0, 2) ?? "null";
|
|
986
|
+
return /* @__PURE__ */ v("div", {
|
|
987
|
+
className: "relative",
|
|
988
|
+
"data-testid": "simulate-run-detail",
|
|
989
|
+
children: [/* @__PURE__ */ _(we, {
|
|
990
|
+
code: r,
|
|
991
|
+
language: "json",
|
|
992
|
+
variant: "ghost",
|
|
993
|
+
foldable: !0,
|
|
994
|
+
maxLines: 16,
|
|
995
|
+
showLineNumbers: !1,
|
|
996
|
+
className: "max-h-64 rounded-md bg-muted/60 font-mono text-[10px] leading-relaxed",
|
|
997
|
+
children: /* @__PURE__ */ _(Z, { className: "text-[10px]" })
|
|
998
|
+
}), /* @__PURE__ */ _(Ae, {
|
|
999
|
+
value: r,
|
|
1000
|
+
position: "pinned",
|
|
1001
|
+
alwaysVisible: !0,
|
|
1002
|
+
className: "absolute right-1.5 top-1.5 size-5 text-muted-foreground opacity-60 hover:opacity-100",
|
|
1003
|
+
labels: {
|
|
1004
|
+
copy: t("dg.simulation.copy"),
|
|
1005
|
+
copied: t("dg.simulation.copied")
|
|
1006
|
+
}
|
|
1007
|
+
})]
|
|
1008
|
+
});
|
|
1009
|
+
};
|
|
1010
|
+
//#endregion
|
|
1011
|
+
export { je as SimulateRunDetail };
|
|
1012
|
+
|
|
1013
|
+
//# sourceMappingURL=simulate-run-detail-CxwpdDne.js.map
|