markstream-vue
Version:
Vue 3 Markdown renderer optimized for large docs: progressive Mermaid, streaming diff code blocks, and fast real-time preview.
861 lines (860 loc) • 36.1 kB
JavaScript
var gt = Object.defineProperty, pt = Object.defineProperties;
var wt = Object.getOwnPropertyDescriptors;
var He = Object.getOwnPropertySymbols;
var yt = Object.prototype.hasOwnProperty, xt = Object.prototype.propertyIsEnumerable;
var Te = (f, k, i) => k in f ? gt(f, k, { enumerable: !0, configurable: !0, writable: !0, value: i }) : f[k] = i, Oe = (f, k) => {
for (var i in k || (k = {}))
yt.call(k, i) && Te(f, i, k[i]);
if (He)
for (var i of He(k))
xt.call(k, i) && Te(f, i, k[i]);
return f;
}, Le = (f, k) => pt(f, wt(k));
var $ = (f, k, i) => new Promise((G, u) => {
var x = (v) => {
try {
N(i.next(v));
} catch (w) {
u(w);
}
}, j = (v) => {
try {
N(i.throw(v));
} catch (w) {
u(w);
}
}, N = (v) => v.done ? G(v.value) : Promise.resolve(v.value).then(x, j);
N((i = i.apply(f, k)).next());
});
import { defineComponent as kt, ref as B, watch as V, onBeforeUnmount as bt, computed as Y, nextTick as ve, onUnmounted as Ct, createBlock as Mt, createElementBlock as L, openBlock as H, unref as g, normalizeClass as Ne, normalizeStyle as De, createCommentVNode as U, withDirectives as Pe, createElementVNode as r, renderSlot as me, toDisplayString as ze, Fragment as Bt, vShow as $e } from "vue";
import { u as St, a as Et, g as Ft, s as te, l as Ht, b as Tt, _ as Ot, c as Ve, h as Lt, d as Nt } from "./exports-BreegGo9.js";
const Dt = {
key: 0,
class: "code-block-header flex justify-between items-center px-4 py-2.5 border-b border-gray-400/5",
style: { color: "var(--vscode-editor-foreground)", "background-color": "var(--vscode-editor-background)" }
}, Pt = { class: "flex items-center space-x-2 flex-1 overflow-hidden" }, zt = ["innerHTML"], $t = { class: "text-sm font-medium font-mono truncate" }, Vt = { class: "flex items-center space-x-2" }, Rt = ["aria-pressed"], It = ["disabled"], Yt = ["disabled"], At = ["disabled"], jt = ["aria-label"], qt = {
key: 0,
xmlns: "http://www.w3.org/2000/svg",
"xmlns:xlink": "http://www.w3.org/1999/xlink",
"aria-hidden": "true",
role: "img",
width: "1em",
height: "1em",
viewBox: "0 0 24 24",
class: "w-3 h-3"
}, Wt = {
key: 1,
xmlns: "http://www.w3.org/2000/svg",
"xmlns:xlink": "http://www.w3.org/1999/xlink",
"aria-hidden": "true",
role: "img",
width: "1em",
height: "1em",
viewBox: "0 0 24 24",
class: "w-3 h-3"
}, Xt = ["aria-pressed"], Ut = {
key: 0,
xmlns: "http://www.w3.org/2000/svg",
"xmlns:xlink": "http://www.w3.org/1999/xlink",
"aria-hidden": "true",
role: "img",
width: "1em",
height: "1em",
viewBox: "0 0 24 24",
class: "w-3 h-3"
}, Gt = {
key: 1,
xmlns: "http://www.w3.org/2000/svg",
"xmlns:xlink": "http://www.w3.org/1999/xlink",
"aria-hidden": "true",
role: "img",
width: "1em",
height: "1em",
viewBox: "0 0 24 24",
class: "w-3 h-3"
}, Jt = ["aria-label"], Kt = { class: "code-loading-placeholder" }, Qt = {
class: "sr-only",
"aria-live": "polite",
role: "status"
}, Re = 10, Ie = 36, Ye = 1, Ae = 0, je = 1.5, oe = 1, Zt = /* @__PURE__ */ kt({
__name: "CodeBlockNode",
props: {
node: {},
isDark: { type: Boolean },
loading: { type: Boolean, default: !0 },
stream: { type: Boolean, default: !0 },
darkTheme: { default: void 0 },
lightTheme: { default: void 0 },
isShowPreview: { type: Boolean, default: !0 },
monacoOptions: {},
enableFontSizeControl: { type: Boolean, default: !0 },
minWidth: { default: void 0 },
maxWidth: { default: void 0 },
themes: {},
showHeader: { type: Boolean, default: !0 },
showCopyButton: { type: Boolean, default: !0 },
showExpandButton: { type: Boolean, default: !0 },
showPreviewButton: { type: Boolean, default: !0 },
showFontSizeButtons: { type: Boolean, default: !0 },
customId: {}
},
emits: ["previewCode", "copy"],
setup(f, { emit: k }) {
var Be, Se;
const i = f, G = k, { t: u } = St(), x = B(null), j = B(null), N = B(!1), v = B(String((Be = i.node.language) != null ? Be : "")), w = B(!1), b = B(!1), J = B(!1), ge = B(!1), R = B(null);
let ne = 0;
const qe = Et(), q = B(null), P = B(typeof window == "undefined");
typeof window != "undefined" && V(
() => j.value,
(t) => {
var o;
if ((o = q.value) == null || o.destroy(), q.value = null, !t) {
P.value = !1;
return;
}
const e = qe(t, { rootMargin: "400px" });
q.value = e, P.value = e.isVisible.value, e.whenVisible.then(() => {
P.value = !0;
});
},
{ immediate: !0 }
), bt(() => {
var t;
(t = q.value) == null || t.destroy(), q.value = null;
});
let z = null, K = null, ie = () => {
}, le = () => {
}, Q = () => null, D = () => ({ getModel: () => ({ getLineCount: () => 1 }), getOption: () => 14, updateOptions: () => {
} }), T = () => ({ getModel: () => ({ getLineCount: () => 1 }), getOption: () => 14, updateOptions: () => {
} }), Z = () => {
}, ae = () => {
}, W = null, pe = () => {
var t;
return String((t = i.node.language) != null ? t : "plaintext");
}, re = () => $(null, null, function* () {
});
const S = Y(() => i.node.diff), se = B(!1);
typeof window != "undefined" && $(null, null, function* () {
try {
const t = yield Ft();
if (!t) {
se.value = !0;
return;
}
const e = t.useMonaco, o = t.detectLanguage;
if (typeof o == "function" && (pe = o), typeof e == "function") {
const n = Me();
if (n && i.themes && Array.isArray(i.themes) && !i.themes.includes(n))
throw new Error("Preferred theme not in provided themes array");
const l = e(Le(Oe({
wordWrap: "on",
wrappingIndent: "same",
themes: i.themes,
theme: n
}, i.monacoOptions || {}), {
onThemeChange() {
Ke();
}
}));
z = l.createEditor || z, K = l.createDiffEditor || K, ie = l.updateCode || ie, le = l.updateDiff || le, Q = l.getEditor || Q, D = l.getEditorView || D, T = l.getDiffEditorView || T, Z = l.cleanupEditor || Z, ae = l.safeClean || l.cleanupEditor || ae, re = l.setTheme || re, ge.value = !0, x.value && (yield de(x.value));
}
} catch (t) {
se.value = !0;
}
});
const E = B(
typeof ((Se = i.monacoOptions) == null ? void 0 : Se.fontSize) == "number" ? i.monacoOptions.fontSize : Number.NaN
), c = B(E.value), We = Y(() => {
const t = E.value, e = c.value;
return typeof t == "number" && Number.isFinite(t) && t > 0 && typeof e == "number" && Number.isFinite(e) && e > 0;
});
function Xe() {
try {
const t = x.value;
if (!t)
return null;
const e = t.querySelector(".view-lines .view-line");
if (e) {
const o = Math.ceil(e.getBoundingClientRect().height);
if (o > 0)
return o;
}
} catch (t) {
}
return null;
}
function we() {
var t, e, o, n, l;
try {
const a = S.value ? (o = (e = (t = T()) == null ? void 0 : t.getModifiedEditor) == null ? void 0 : e.call(t)) != null ? o : T() : D(), p = Q(), y = (n = p == null ? void 0 : p.EditorOption) == null ? void 0 : n.fontInfo;
if (a && y != null) {
const m = (l = a.getOption) == null ? void 0 : l.call(a, y), s = m == null ? void 0 : m.fontSize;
if (typeof s == "number" && Number.isFinite(s) && s > 0)
return s;
}
} catch (a) {
}
try {
const a = x.value;
if (a) {
const p = a.querySelector(".view-lines .view-line");
if (p)
try {
if (typeof window != "undefined" && typeof window.getComputedStyle == "function") {
const y = window.getComputedStyle(p).fontSize, m = y && y.match(/^(\d+(?:\.\d+)?)/);
if (m)
return Number.parseFloat(m[1]);
}
} catch (y) {
}
}
} catch (a) {
}
return null;
}
function ue(t) {
var n, l;
try {
const a = Q(), p = (n = a == null ? void 0 : a.EditorOption) == null ? void 0 : n.lineHeight;
if (p != null) {
const y = (l = t == null ? void 0 : t.getOption) == null ? void 0 : l.call(t, p);
if (typeof y == "number" && y > 0)
return y;
}
} catch (a) {
}
const e = Xe();
if (e && e > 0)
return e;
const o = Number.isFinite(c.value) && c.value > 0 ? c.value : 12;
return Math.max(12, Math.round(o * 1.35));
}
function ce() {
var e;
if (Number.isFinite(c.value) && c.value > 0 && Number.isFinite(E.value))
return c.value;
const t = we();
return typeof ((e = i.monacoOptions) == null ? void 0 : e.fontSize) == "number" ? (E.value = i.monacoOptions.fontSize, c.value = i.monacoOptions.fontSize, c.value) : t && t > 0 ? (E.value = t, c.value = t, t) : (E.value = 12, c.value = 12, 12);
}
function Ue() {
const t = ce(), e = Math.min(Ie, t + Ye);
c.value = e;
}
function Ge() {
const t = ce(), e = Math.max(Re, t - Ye);
c.value = e;
}
function Je() {
ce(), Number.isFinite(E.value) && (c.value = E.value);
}
function ye() {
var t, e, o, n, l, a, p, y, m, s, h;
try {
const d = S.value ? T() : D();
if (!d)
return null;
if (S.value && (d != null && d.getOriginalEditor) && (d != null && d.getModifiedEditor)) {
const M = (t = d.getOriginalEditor) == null ? void 0 : t.call(d), O = (e = d.getModifiedEditor) == null ? void 0 : e.call(d), ct = ((o = M == null ? void 0 : M.getContentHeight) == null ? void 0 : o.call(M)) || 0, dt = ((n = O == null ? void 0 : O.getContentHeight) == null ? void 0 : n.call(O)) || 0, Fe = Math.max(ct, dt);
if (Fe > 0)
return Math.ceil(Fe + oe);
const ft = ((p = (a = (l = M == null ? void 0 : M.getModel) == null ? void 0 : l.call(M)) == null ? void 0 : a.getLineCount) == null ? void 0 : p.call(a)) || 1, vt = ((s = (m = (y = O == null ? void 0 : O.getModel) == null ? void 0 : y.call(O)) == null ? void 0 : m.getLineCount) == null ? void 0 : s.call(m)) || 1, mt = Math.max(ft, vt), ht = Math.max(ue(M), ue(O));
return Math.ceil(mt * (ht + je) + Ae + oe);
} else if (d != null && d.getContentHeight) {
const M = d.getContentHeight();
if (M > 0)
return Math.ceil(M + oe);
}
const fe = (h = d == null ? void 0 : d.getModel) == null ? void 0 : h.call(d);
let Ee = 1;
fe && typeof fe.getLineCount == "function" && (Ee = fe.getLineCount());
const ut = ue(d);
return Math.ceil(Ee * (ut + je) + Ae + oe);
} catch (d) {
return null;
}
}
function Ke() {
var y, m, s;
const t = x.value, e = j.value;
if (!t || !e)
return;
const o = t.querySelector(".monaco-editor") || t;
let n = null;
try {
typeof window != "undefined" && typeof window.getComputedStyle == "function" && (n = window.getComputedStyle(o));
} catch (h) {
n = null;
}
const l = String((y = n == null ? void 0 : n.getPropertyValue("--vscode-editor-foreground")) != null ? y : ""), a = String((m = n == null ? void 0 : n.getPropertyValue("--vscode-editor-background")) != null ? m : ""), p = String((s = n == null ? void 0 : n.getPropertyValue("--vscode-editor-hoverHighlightBackground")) != null ? s : "");
if (l && a)
return e.style.setProperty("--vscode-editor-foreground", l.trim()), e.style.setProperty("--vscode-editor-background", a.trim()), e.style.setProperty("--vscode-editor-selectionBackground", p.trim()), !0;
}
function I() {
try {
const t = x.value;
if (!t)
return;
const e = t.getBoundingClientRect(), o = window.scrollY + e.top, n = ye();
if (n != null && n > 0) {
const l = e.height;
t.style.height = `${Math.ceil(n)}px`, t.style.maxHeight = "none";
const a = Math.ceil(n) - l;
a !== 0 && o < window.scrollY && window.scrollBy(0, a);
}
} catch (t) {
}
}
function A() {
var t;
try {
const e = x.value;
if (!e)
return;
const o = e.getBoundingClientRect(), n = window.scrollY + o.top, l = o.height, a = Qe();
if (ne > 0 && (ne--, R.value != null)) {
const s = Math.min(R.value, a);
e.style.height = `${Math.ceil(s)}px`, e.style.maxHeight = `${Math.ceil(a)}px`, e.style.overflow = "auto";
const h = Math.ceil(s) - l;
h !== 0 && n < window.scrollY && window.scrollBy(0, h);
return;
}
const p = ye();
if (p != null && p > 0) {
const s = Math.min(p, a);
e.style.height = `${Math.ceil(s)}px`, e.style.maxHeight = `${Math.ceil(a)}px`, e.style.overflow = "auto";
const h = Math.ceil(s) - l;
h !== 0 && n < window.scrollY && window.scrollBy(0, h);
return;
}
if (R.value != null) {
const s = Math.min(R.value, a);
e.style.height = `${Math.ceil(s)}px`, e.style.maxHeight = `${Math.ceil(a)}px`, e.style.overflow = "auto";
const h = Math.ceil(s) - l;
h !== 0 && n < window.scrollY && window.scrollBy(0, h);
return;
}
const y = Math.ceil(((t = e.getBoundingClientRect) == null ? void 0 : t.call(e).height) || 0);
if (y > 0) {
const s = Math.min(y, a);
e.style.height = `${Math.ceil(s)}px`, e.style.maxHeight = `${Math.ceil(a)}px`, e.style.overflow = "auto";
const h = Math.ceil(s) - l;
h !== 0 && n < window.scrollY && window.scrollBy(0, h);
return;
}
const m = Number.parseFloat(e.style.height);
if (!Number.isNaN(m) && m > 0) {
const s = Math.ceil(Math.min(m, a));
e.style.height = `${s}px`;
const h = s - l;
h !== 0 && n < window.scrollY && window.scrollBy(0, h);
} else {
const s = Math.ceil(a);
e.style.height = `${s}px`;
const h = s - l;
h !== 0 && n < window.scrollY && window.scrollBy(0, h);
}
e.style.maxHeight = `${Math.ceil(a)}px`, e.style.overflow = "auto";
} catch (e) {
}
}
function Qe() {
var o, n;
const t = (n = (o = i.monacoOptions) == null ? void 0 : o.MAX_HEIGHT) != null ? n : 500;
if (typeof t == "number")
return t;
const e = String(t).match(/^(\d+(?:\.\d+)?)/);
return e ? Number.parseFloat(e[1]) : 500;
}
const xe = Y(() => {
const t = v.value.trim().toLowerCase();
return i.isShowPreview && (t === "html" || t === "svg");
}), X = Y(
() => v.value.trim().toLowerCase() === "mermaid"
);
V(
() => i.node.language,
(t) => {
v.value = t;
}
), V(
() => i.node.code,
(t) => $(null, null, function* () {
var e, o;
if (i.stream !== !1) {
if (v.value || (v.value = pe(t)), z && !J.value && x.value)
try {
yield de(x.value);
} catch (n) {
}
S.value ? le(String((e = i.node.originalCode) != null ? e : ""), String((o = i.node.updatedCode) != null ? o : ""), v.value) : ie(t, v.value), w.value && te(() => I());
}
})
);
const Ze = Y(() => {
const t = v.value.trim().toLowerCase();
return Ht[t] || t.charAt(0).toUpperCase() + t.slice(1);
}), _e = Y(() => {
const t = v.value.trim().toLowerCase();
return Tt(t.split(":")[0]);
}), et = Y(() => {
const t = {}, e = (l) => {
if (l != null)
return typeof l == "number" ? `${l}px` : String(l);
}, o = e(i.minWidth), n = e(i.maxWidth);
return o && (t.minWidth = o), n && (t.maxWidth = n), t;
});
function tt() {
return $(this, null, function* () {
try {
typeof navigator != "undefined" && navigator.clipboard && typeof navigator.clipboard.writeText == "function" && (yield navigator.clipboard.writeText(i.node.code)), N.value = !0, G("copy", i.node.code), setTimeout(() => {
N.value = !1;
}, 1e3);
} catch (t) {
console.error("复制失败:", t);
}
});
}
function ke(t) {
const e = t;
return !e || e.disabled;
}
function F(t, e, o = "top") {
if (ke(t.currentTarget))
return;
const n = t, l = (n == null ? void 0 : n.clientX) != null && (n == null ? void 0 : n.clientY) != null ? { x: n.clientX, y: n.clientY } : void 0;
Ve(t.currentTarget, e, o, !1, l, i.isDark);
}
function C() {
Lt();
}
function be(t) {
if (ke(t.currentTarget))
return;
const e = N.value ? u("common.copied") || "Copied" : u("common.copy") || "Copy", o = t, n = (o == null ? void 0 : o.clientX) != null && (o == null ? void 0 : o.clientY) != null ? { x: o.clientX, y: o.clientY } : void 0;
Ve(t.currentTarget, e, "top", !1, n, i.isDark);
}
function ot() {
w.value = !w.value;
const t = S.value ? T() : D(), e = x.value;
!t || !e || (w.value ? (_(!0), e.style.maxHeight = "none", e.style.overflow = "visible", I()) : (_(!1), e.style.overflow = "auto", A()));
}
function nt() {
var t, e, o;
if (b.value = !b.value, b.value) {
if (x.value) {
const n = Math.ceil(((e = (t = x.value).getBoundingClientRect) == null ? void 0 : e.call(t).height) || 0);
n > 0 && (R.value = n);
}
_(!1);
} else {
w.value && _(!0), x.value && R.value != null && (x.value.style.height = `${R.value}px`);
const n = S.value ? T() : D();
try {
(o = n == null ? void 0 : n.layout) == null || o.call(n);
} catch (l) {
}
ne = 2, te(() => {
w.value ? I() : A();
});
}
}
V(
() => c.value,
(t, e) => {
const o = S.value ? T() : D();
o && typeof t == "number" && Number.isFinite(t) && t > 0 && (o.updateOptions({ fontSize: t }), w.value && !b.value && I());
},
{ flush: "post", immediate: !1 }
);
function it() {
if (!xe.value)
return;
const t = (v.value || i.node.language).toLowerCase(), e = t === "html" ? "text/html" : "image/svg+xml", o = t === "html" ? u("artifacts.htmlPreviewTitle") || "HTML Preview" : u("artifacts.svgPreviewTitle") || "SVG Preview";
G("previewCode", {
node: i.node,
artifactType: e,
artifactTitle: o,
id: `temp-${t}-${Date.now()}`
});
}
function _(t) {
var e, o;
try {
if (S.value) {
const n = T();
(e = n == null ? void 0 : n.updateOptions) == null || e.call(n, { automaticLayout: t });
} else {
const n = D();
(o = n == null ? void 0 : n.updateOptions) == null || o.call(n, { automaticLayout: t });
}
} catch (n) {
}
}
function lt(t) {
return $(this, null, function* () {
var o, n, l;
if (!z)
return;
S.value ? (ae(), K ? yield K(t, String((o = i.node.originalCode) != null ? o : ""), String((n = i.node.updatedCode) != null ? n : ""), v.value) : yield z(t, i.node.code, v.value)) : yield z(t, i.node.code, v.value);
const e = S.value ? T() : D();
if (typeof ((l = i.monacoOptions) == null ? void 0 : l.fontSize) == "number")
e == null || e.updateOptions({ fontSize: i.monacoOptions.fontSize, automaticLayout: !1 }), E.value = i.monacoOptions.fontSize, c.value = i.monacoOptions.fontSize;
else {
const a = we();
a && a > 0 ? (E.value = a, c.value = a) : (E.value = 12, c.value = 12);
}
!w.value && !b.value && A(), i.loading === !1 && (yield ve(), te(() => {
w.value && !b.value ? I() : b.value || A();
}));
});
}
function de(t) {
return z ? W || (J.value = !0, W = $(null, null, function* () {
yield lt(t);
}).finally(() => {
W = null;
}), W) : null;
}
const Ce = V(
() => [x.value, X.value, S.value, i.stream, i.loading, ge.value, P.value],
(y) => $(null, [y], function* ([t, e, o, n, l, a, p]) {
if (!t || !z || !p || n === !1 && l !== !1)
return;
if (X.value) {
Z(), Ce();
return;
}
const m = de(t);
m && (yield m, Ce());
})
), at = V(
() => [i.darkTheme, i.lightTheme, J.value, P.value],
() => {
if (!(!J.value || !P.value)) {
if (X.value)
return at();
rt();
}
}
);
function Me() {
return i.isDark ? i.darkTheme : i.lightTheme;
}
function rt() {
const t = Me();
t && re(t);
}
const st = V(
() => [i.monacoOptions, P.value],
() => {
var o, n;
if (!z || !P.value)
return;
if (X.value)
return st();
const t = S.value ? T() : D(), e = typeof ((o = i.monacoOptions) == null ? void 0 : o.fontSize) == "number" ? i.monacoOptions.fontSize : Number.isFinite(c.value) ? c.value : void 0;
typeof e == "number" && Number.isFinite(e) && e > 0 && ((n = t == null ? void 0 : t.updateOptions) == null || n.call(t, { fontSize: e })), w.value && !b.value ? I() : b.value || A();
},
{ deep: !0 }
), ee = V(
() => [i.loading, P.value],
(o) => $(null, [o], function* ([t, e]) {
if (e) {
if (X.value) {
ve(() => {
ee == null || ee();
});
return;
}
t || (yield ve(), te(() => {
b.value || (w.value ? I() : A()), ee();
}));
}
}),
{ immediate: !0, flush: "post" }
);
return Ct(() => {
Z();
}), (t, e) => se.value ? (H(), Mt(g(Ot), {
key: 0,
node: f.node,
loading: i.loading
}, null, 8, ["node", "loading"])) : (H(), L("div", {
key: 1,
ref_key: "container",
ref: j,
style: De(et.value),
class: Ne(["code-block-container my-4 rounded-lg border overflow-hidden shadow-sm", [
i.isDark ? "border-gray-700/30 bg-gray-900" : "border-gray-200 bg-white",
{ "is-rendering": i.loading, "is-dark": i.isDark }
]])
}, [
i.showHeader ? (H(), L("div", Dt, [
me(t.$slots, "header-left", {}, () => [
r("div", Pt, [
r("span", {
class: "icon-slot h-4 w-4 flex-shrink-0",
innerHTML: _e.value
}, null, 8, zt),
r("span", $t, ze(Ze.value), 1)
])
], !0),
me(t.$slots, "header-right", {}, () => [
r("div", Vt, [
r("button", {
type: "button",
class: "code-action-btn p-2 text-xs rounded-md transition-colors hover:bg-[var(--vscode-editor-selectionBackground)]",
"aria-pressed": b.value,
onClick: nt,
onMouseenter: e[0] || (e[0] = (o) => F(o, b.value ? g(u)("common.expand") || "Expand" : g(u)("common.collapse") || "Collapse")),
onFocus: e[1] || (e[1] = (o) => F(o, b.value ? g(u)("common.expand") || "Expand" : g(u)("common.collapse") || "Collapse")),
onMouseleave: C,
onBlur: C
}, [
(H(), L("svg", {
style: De({ rotate: b.value ? "0deg" : "90deg" }),
xmlns: "http://www.w3.org/2000/svg",
"xmlns:xlink": "http://www.w3.org/1999/xlink",
"aria-hidden": "true",
role: "img",
width: "1em",
height: "1em",
viewBox: "0 0 24 24",
class: "w-3 h-3"
}, [...e[17] || (e[17] = [
r("path", {
fill: "none",
stroke: "currentColor",
"stroke-linecap": "round",
"stroke-linejoin": "round",
"stroke-width": "2",
d: "m9 18l6-6l-6-6"
}, null, -1)
])], 4))
], 40, Rt),
i.showFontSizeButtons && i.enableFontSizeControl ? (H(), L(Bt, { key: 0 }, [
r("button", {
type: "button",
class: "code-action-btn p-2 text-xs rounded-md transition-colors hover:bg-[var(--vscode-editor-selectionBackground)]",
disabled: Number.isFinite(c.value) ? c.value <= Re : !1,
onClick: e[2] || (e[2] = (o) => Ge()),
onMouseenter: e[3] || (e[3] = (o) => F(o, g(u)("common.decrease") || "Decrease")),
onFocus: e[4] || (e[4] = (o) => F(o, g(u)("common.decrease") || "Decrease")),
onMouseleave: C,
onBlur: C
}, [...e[18] || (e[18] = [
r("svg", {
xmlns: "http://www.w3.org/2000/svg",
"xmlns:xlink": "http://www.w3.org/1999/xlink",
"aria-hidden": "true",
role: "img",
width: "1em",
height: "1em",
viewBox: "0 0 24 24",
class: "w-3 h-3"
}, [
r("path", {
fill: "none",
stroke: "currentColor",
"stroke-linecap": "round",
"stroke-linejoin": "round",
"stroke-width": "2",
d: "M5 12h14"
})
], -1)
])], 40, It),
r("button", {
type: "button",
class: "code-action-btn p-2 text-xs rounded-md transition-colors hover:bg-[var(--vscode-editor-selectionBackground)]",
disabled: !We.value || c.value === E.value,
onClick: e[5] || (e[5] = (o) => Je()),
onMouseenter: e[6] || (e[6] = (o) => F(o, g(u)("common.reset") || "Reset")),
onFocus: e[7] || (e[7] = (o) => F(o, g(u)("common.reset") || "Reset")),
onMouseleave: C,
onBlur: C
}, [...e[19] || (e[19] = [
r("svg", {
xmlns: "http://www.w3.org/2000/svg",
"xmlns:xlink": "http://www.w3.org/1999/xlink",
"aria-hidden": "true",
role: "img",
width: "1em",
height: "1em",
viewBox: "0 0 24 24",
class: "w-3 h-3"
}, [
r("g", {
fill: "none",
stroke: "currentColor",
"stroke-linecap": "round",
"stroke-linejoin": "round",
"stroke-width": "2"
}, [
r("path", { d: "M3 12a9 9 0 1 0 9-9a9.75 9.75 0 0 0-6.74 2.74L3 8" }),
r("path", { d: "M3 3v5h5" })
])
], -1)
])], 40, Yt),
r("button", {
type: "button",
class: "code-action-btn p-2 text-xs rounded-md transition-colors hover:bg-[var(--vscode-editor-selectionBackground)]",
disabled: Number.isFinite(c.value) ? c.value >= Ie : !1,
onClick: e[8] || (e[8] = (o) => Ue()),
onMouseenter: e[9] || (e[9] = (o) => F(o, g(u)("common.increase") || "Increase")),
onFocus: e[10] || (e[10] = (o) => F(o, g(u)("common.increase") || "Increase")),
onMouseleave: C,
onBlur: C
}, [...e[20] || (e[20] = [
r("svg", {
xmlns: "http://www.w3.org/2000/svg",
"xmlns:xlink": "http://www.w3.org/1999/xlink",
"aria-hidden": "true",
role: "img",
width: "1em",
height: "1em",
viewBox: "0 0 24 24",
class: "w-3 h-3"
}, [
r("path", {
fill: "none",
stroke: "currentColor",
"stroke-linecap": "round",
"stroke-linejoin": "round",
"stroke-width": "2",
d: "M5 12h14m-7-7v14"
})
], -1)
])], 40, At)
], 64)) : U("", !0),
i.showCopyButton ? (H(), L("button", {
key: 1,
type: "button",
class: "code-action-btn p-2 text-xs rounded-md transition-colors hover:bg-[var(--vscode-editor-selectionBackground)]",
"aria-label": N.value ? g(u)("common.copied") || "Copied" : g(u)("common.copy") || "Copy",
onClick: tt,
onMouseenter: e[11] || (e[11] = (o) => be(o)),
onFocus: e[12] || (e[12] = (o) => be(o)),
onMouseleave: C,
onBlur: C
}, [
N.value ? (H(), L("svg", Wt, [...e[22] || (e[22] = [
r("path", {
fill: "none",
stroke: "currentColor",
"stroke-linecap": "round",
"stroke-linejoin": "round",
"stroke-width": "2",
d: "M20 6L9 17l-5-5"
}, null, -1)
])])) : (H(), L("svg", qt, [...e[21] || (e[21] = [
r("g", {
fill: "none",
stroke: "currentColor",
"stroke-linecap": "round",
"stroke-linejoin": "round",
"stroke-width": "2"
}, [
r("rect", {
width: "14",
height: "14",
x: "8",
y: "8",
rx: "2",
ry: "2"
}),
r("path", { d: "M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2" })
], -1)
])]))
], 40, jt)) : U("", !0),
i.showExpandButton ? (H(), L("button", {
key: 2,
type: "button",
class: "code-action-btn p-2 text-xs rounded-md transition-colors hover:bg-[var(--vscode-editor-selectionBackground)]",
"aria-pressed": w.value,
onClick: ot,
onMouseenter: e[13] || (e[13] = (o) => F(o, w.value ? g(u)("common.collapse") || "Collapse" : g(u)("common.expand") || "Expand")),
onFocus: e[14] || (e[14] = (o) => F(o, w.value ? g(u)("common.collapse") || "Collapse" : g(u)("common.expand") || "Expand")),
onMouseleave: C,
onBlur: C
}, [
w.value ? (H(), L("svg", Ut, [...e[23] || (e[23] = [
r("path", {
fill: "none",
stroke: "currentColor",
"stroke-linecap": "round",
"stroke-linejoin": "round",
"stroke-width": "2",
d: "M15 3h6v6m0-6l-7 7M3 21l7-7m-1 7H3v-6"
}, null, -1)
])])) : (H(), L("svg", Gt, [...e[24] || (e[24] = [
r("path", {
fill: "none",
stroke: "currentColor",
"stroke-linecap": "round",
"stroke-linejoin": "round",
"stroke-width": "2",
d: "m14 10l7-7m-1 7h-6V4M3 21l7-7m-6 0h6v6"
}, null, -1)
])]))
], 40, Xt)) : U("", !0),
xe.value && i.showPreviewButton ? (H(), L("button", {
key: 3,
type: "button",
class: "code-action-btn p-2 text-xs rounded-md transition-colors hover:bg-[var(--vscode-editor-selectionBackground)]",
"aria-label": g(u)("common.preview") || "Preview",
onClick: it,
onMouseenter: e[15] || (e[15] = (o) => F(o, g(u)("common.preview") || "Preview")),
onFocus: e[16] || (e[16] = (o) => F(o, g(u)("common.preview") || "Preview")),
onMouseleave: C,
onBlur: C
}, [...e[25] || (e[25] = [
r("svg", {
xmlns: "http://www.w3.org/2000/svg",
width: "12",
height: "12",
viewBox: "0 0 24 24"
}, [
r("g", {
fill: "currentColor",
"fill-rule": "evenodd",
"clip-rule": "evenodd"
}, [
r("path", { d: "M23.628 7.41c-.12-1.172-.08-3.583-.9-4.233c-1.921-1.51-6.143-1.11-8.815-1.19c-3.481-.15-7.193.14-10.625.24a.34.34 0 0 0 0 .67c3.472-.05 7.074-.29 10.575-.09c2.471.15 6.653-.14 8.254 1.16c.4.33.41 2.732.49 3.582a42 42 0 0 1 .08 9.005a13.8 13.8 0 0 1-.45 3.001c-2.42 1.4-19.69 2.381-20.72.55a21 21 0 0 1-.65-4.632a41.5 41.5 0 0 1 .12-7.964c.08 0 7.334.33 12.586.24c2.331 0 4.682-.13 6.764-.21a.33.33 0 0 0 0-.66c-7.714-.16-12.897-.43-19.31.05c.11-1.38.48-3.922.38-4.002a.3.3 0 0 0-.42 0c-.37.41-.29 1.77-.36 2.251s-.14 1.07-.2 1.6a45 45 0 0 0-.36 8.645a21.8 21.8 0 0 0 .66 5.002c1.46 2.702 17.248 1.461 20.95.43c1.45-.4 1.69-.8 1.871-1.95c.575-3.809.602-7.68.08-11.496" }),
r("path", { d: "M4.528 5.237a.84.84 0 0 0-.21-1c-.77-.41-1.71.39-1 1.1a.83.83 0 0 0 1.21-.1m2.632-.25c.14-.14.19-.84-.2-1c-.77-.41-1.71.39-1 1.09a.82.82 0 0 0 1.2-.09m2.88 0a.83.83 0 0 0-.21-1c-.77-.41-1.71.39-1 1.09a.82.82 0 0 0 1.21-.09m-4.29 8.735c0 .08.23 2.471.31 2.561a.371.371 0 0 0 .63-.14c0-.09 0 0 .15-1.72a10 10 0 0 0-.11-2.232a5.3 5.3 0 0 1-.26-1.37a.3.3 0 0 0-.54-.24a6.8 6.8 0 0 0-.2 2.33c-1.281-.38-1.121.13-1.131-.42a15 15 0 0 0-.19-1.93c-.16-.17-.36-.17-.51.14a20 20 0 0 0-.43 3.471c.04.773.18 1.536.42 2.272c.26.4.7.22.7-.1c0-.09-.16-.09 0-1.862c.06-1.18-.23-.3 1.16-.76m5.033-2.552c.32-.07.41-.28.39-.37c0-.55-3.322-.34-3.462-.24s-.2.18-.18.28s0 .11 0 .16a3.8 3.8 0 0 0 1.591.361v.82a15 15 0 0 0-.13 3.132c0 .2-.09.94.17 1.16a.34.34 0 0 0 .48 0c.125-.35.196-.718.21-1.09a8 8 0 0 0 .14-3.232c0-.13.05-.7-.1-.89a8 8 0 0 0 .89-.09m5.544-.181a.69.69 0 0 0-.89-.44a2.8 2.8 0 0 0-1.252 1.001a2.3 2.3 0 0 0-.41-.83a1 1 0 0 0-1.6.27a7 7 0 0 0-.35 2.07c0 .571 0 2.642.06 2.762c.14 1.09 1 .51.63.13a17.6 17.6 0 0 1 .38-3.962c.32-1.18.32.2.39.51s.11 1.081.73 1.081s.48-.93 1.401-1.78q.075 1.345 0 2.69a15 15 0 0 0 0 1.811a.34.34 0 0 0 .68 0q.112-.861.11-1.73a16.7 16.7 0 0 0 .12-3.582m1.441-.201c-.05.16-.3 3.002-.31 3.202a6.3 6.3 0 0 0 .21 1.741c.33 1 1.21 1.07 2.291.82a3.7 3.7 0 0 0 1.14-.23c.21-.22.10-.59-.41-.64q-.817.096-1.64.07c-.44-.07-.34 0-.67-4.442q.015-.185 0-.37a.316.316 0 0 0-.23-.38a.316.316 0 0 0-.38.23" })
])
], -1)
])], 40, Jt)) : U("", !0)
])
], !0)
])) : U("", !0),
Pe(r("div", {
ref_key: "codeEditor",
ref: x,
class: Ne(["code-editor-container", [f.stream ? "" : "code-height-placeholder"]])
}, null, 2), [
[$e, !b.value && (f.stream ? !0 : !f.loading)]
]),
Pe(r("div", Kt, [
me(t.$slots, "loading", {
loading: f.loading,
stream: f.stream
}, () => [
e[26] || (e[26] = r("div", { class: "loading-skeleton" }, [
r("div", { class: "skeleton-line" }),
r("div", { class: "skeleton-line" }),
r("div", { class: "skeleton-line short" })
], -1))
], !0)
], 512), [
[$e, !f.stream && f.loading]
]),
r("span", Qt, ze(N.value ? g(u)("common.copied") || "Copied" : ""), 1)
], 6));
}
}), he = /* @__PURE__ */ Nt(Zt, [["__scopeId", "data-v-c3ca09d1"]]);
he.install = (f) => {
f.component(he.__name, he);
};
export {
he as default
};