import { a as e, c as t, d as n, f as r, l as i, n as a, r as o, s, t as c, u as l } from "./shiki-highlighter-BmQSSJpS.js";
import { t as u } from "./utils-Ct96Mtjw.js";
import { t as d } from "./use-toast-d9VPBjMn.js";
import { l as f, r as p, t as m, u as h } from "./dialog-DQ6nkP0y.js";
import * as g from "react";
import { Check as _, Copy as v, Download as y, ExternalLink as b, Maximize as ee, Minimize as x, RefreshCw as te, RotateCcw as ne, RotateCw as re, Search as ie, X as ae, ZoomIn as oe, ZoomOut as se } from "lucide-react";
import { Link as S, useParams as C } from "react-router-dom";
import { Fragment as w, jsx as T, jsxs as E } from "react/jsx-runtime";
import D from "remark-gfm";
import O from "remark-math";
import k from "react-markdown";
import A from "rehype-autolink-headings";
import j from "rehype-slug";
import M from "rehype-raw";
import ce from "rehype-katex";
import { SKIP as N, visit as P } from "unist-util-visit";
import F from "katex-physics";
//#region src/lib/rehype-component.ts
function I(e) {
	let t = /* @__PURE__ */ new Map();
	for (let [n] of Object.entries(e)) {
		let e = n.toLowerCase(), r = e.replace(/\./g, "-");
		t.set(e, n), t.set(r, n);
	}
	return () => (e) => {
		P(e, "element", (e) => {
			let n = e.tagName.toLowerCase(), r = t.get(n);
			r && (e.tagName = r, e.properties = e.properties || {}, e.properties.isComponent = !0);
		});
	};
}
//#endregion
//#region src/lib/image-viewer.ts
var L = {
	"zh-cn": {
		preview: "预览图片",
		zoomIn: "放大",
		zoomOut: "缩小",
		fit: "适配窗口",
		actualSize: "原始比例",
		reset: "重置",
		rotateLeft: "左旋",
		rotateRight: "右旋",
		fullscreen: "全屏",
		download: "下载",
		openInNewTab: "新标签打开",
		close: "关闭图片查看器",
		imageAltFallback: "文档图片",
		downloadSuccess: "图片下载已开始",
		downloadError: "当前图片无法直接下载，请尝试新标签打开。",
		fullscreenError: "当前浏览器不支持全屏，已保留对话框预览。",
		openInNewTabError: "无法在新标签页打开图片。",
		imageLoadError: "图片加载失败"
	},
	en: {
		preview: "Preview image",
		zoomIn: "Zoom in",
		zoomOut: "Zoom out",
		fit: "Fit to viewport",
		actualSize: "Actual size",
		reset: "Reset",
		rotateLeft: "Rotate left",
		rotateRight: "Rotate right",
		fullscreen: "Fullscreen",
		download: "Download",
		openInNewTab: "Open in new tab",
		close: "Close image viewer",
		imageAltFallback: "Documentation image",
		downloadSuccess: "Image download started",
		downloadError: "This image cannot be downloaded directly. Try opening it in a new tab.",
		fullscreenError: "Fullscreen is not available in this browser. Dialog preview is still available.",
		openInNewTabError: "Unable to open the image in a new tab.",
		imageLoadError: "Failed to load image"
	}
};
function le(e = "zh-cn", t) {
	return {
		...L[e === "en" ? "en" : "zh-cn"],
		...t
	};
}
//#endregion
//#region src/components/ImageViewer.tsx
var ue = .2, R = 5, de = .2;
function z(e) {
	return Math.min(R, Math.max(ue, Number(e.toFixed(2))));
}
function fe(e, t, n) {
	let r = (t || n || "image").trim().split("").map((e) => e.charCodeAt(0) < 32 || "<>:\"/\\|?*".includes(e) ? "-" : e).join("");
	return (e.split("?")[0]?.split("#")[0] ?? e).split("/").pop()?.trim() || r || "image";
}
function B(e, t) {
	let n = document.createElement("a");
	n.href = e, n.download = t, n.rel = "noopener noreferrer", document.body.appendChild(n), n.click(), document.body.removeChild(n);
}
function pe(e) {
	if (e.startsWith("blob:") || e.startsWith("data:")) return !0;
	try {
		return new URL(e, window.location.href).origin === window.location.origin;
	} catch {
		return !1;
	}
}
function V({ open: e, onOpenChange: a, src: o, alt: s, title: c, lang: _ = "zh-cn", labels: v }) {
	let S = g.useMemo(() => le(_, v), [_, v]), C = g.useRef(null), w = g.useRef(null), [D, O] = g.useState(1), [k, A] = g.useState(0), [j, M] = g.useState("fit"), [ce, N] = g.useState(!1), [P, F] = g.useState(!1), [I, L] = g.useState({
		x: 0,
		y: 0
	}), [V, H] = g.useState(!1), U = g.useRef(/* @__PURE__ */ new Map()), W = g.useRef(null), G = g.useRef(null), K = s?.trim() || c?.trim() || S.imageAltFallback, q = g.useCallback(() => {
		O(1), A(0), M("fit"), F(!1), L({
			x: 0,
			y: 0
		}), H(!1), U.current.clear(), W.current = null, G.current = null;
	}, []);
	g.useEffect(() => {
		if (e) {
			q();
			return;
		}
		N(!1);
	}, [e, q]), g.useEffect(() => {
		document.fullscreenElement || N(!1);
	}, [e]), g.useEffect(() => {
		let e = () => {
			N(!!document.fullscreenElement);
		};
		return document.addEventListener("fullscreenchange", e), () => {
			document.removeEventListener("fullscreenchange", e);
		};
	}, []);
	let me = g.useMemo(() => ({
		transform: `translate(${I.x}px, ${I.y}px) scale(${D}) rotate(${k}deg)`,
		transition: V ? "none" : "transform 160ms ease",
		cursor: P ? "default" : V ? "grabbing" : "grab"
	}), [
		V,
		P,
		k,
		D,
		I.x,
		I.y
	]), J = g.useCallback(() => {
		M("actual"), O((e) => z(e + de));
	}, []), Y = g.useCallback(() => {
		M("actual"), O((e) => z(e - de));
	}, []), he = g.useCallback(() => {
		M("fit"), O(1), L({
			x: 0,
			y: 0
		});
	}, []), ge = g.useCallback(() => {
		M("actual"), O(1), L({
			x: 0,
			y: 0
		});
	}, []), X = g.useCallback(() => {
		A((e) => e - 90);
	}, []), Z = g.useCallback(() => {
		A((e) => e + 90);
	}, []), _e = g.useCallback(async () => {
		let e = fe(o, c, s), t = null;
		try {
			if (pe(o)) {
				B(o, e), d({ description: S.downloadSuccess });
				return;
			}
		} catch {}
		try {
			let n = await fetch(o, { mode: "cors" });
			if (!n.ok) throw Error(`Failed to fetch image: ${n.status}`);
			let r = await n.blob();
			t = URL.createObjectURL(r), B(t, e), d({ description: S.downloadSuccess });
		} catch {
			d({
				variant: "destructive",
				description: S.downloadError
			});
		} finally {
			t && URL.revokeObjectURL(t);
		}
	}, [
		s,
		S.downloadError,
		S.downloadSuccess,
		o,
		c
	]), ve = g.useCallback(() => {
		try {
			window.open(o, "_blank", "noopener,noreferrer");
		} catch {
			d({
				variant: "destructive",
				description: S.openInNewTabError
			});
		}
	}, [S.openInNewTabError, o]), Q = g.useCallback(async () => {
		let e = C.current;
		if (!e?.requestFullscreen) {
			d({ description: S.fullscreenError });
			return;
		}
		try {
			document.fullscreenElement ? await document.exitFullscreen() : await e.requestFullscreen();
		} catch {
			d({ description: S.fullscreenError });
		}
	}, [S.fullscreenError]);
	g.useEffect(() => {
		if (!e) return;
		let t = (e) => {
			e.key === "+" ? (e.preventDefault(), J()) : e.key === "-" ? (e.preventDefault(), Y()) : e.key === "0" ? (e.preventDefault(), q()) : e.key === "f" || e.key === "F" ? (e.preventDefault(), Q()) : e.key === "[" ? (e.preventDefault(), X()) : e.key === "]" && (e.preventDefault(), Z());
		};
		return window.addEventListener("keydown", t), () => {
			window.removeEventListener("keydown", t);
		};
	}, [
		Q,
		e,
		q,
		X,
		Z,
		J,
		Y
	]);
	let $ = g.useCallback((e) => {
		e.preventDefault(), e.stopPropagation(), e.deltaY < 0 ? J() : Y();
	}, [J, Y]);
	g.useEffect(() => {
		if (!e) return;
		let t = C.current;
		if (t) return t.addEventListener("wheel", $, { passive: !1 }), () => {
			t.removeEventListener("wheel", $);
		};
	}, [$, e]);
	let ye = g.useCallback((e) => {
		U.current.set(e.pointerId, {
			x: e.clientX,
			y: e.clientY
		});
		let t = Array.from(U.current.values());
		if (t.length === 2 && G.current) {
			let [e, n] = t, r = Math.hypot(n.x - e.x, n.y - e.y), i = z(G.current.startScale * (r / G.current.startDistance));
			M("actual"), O(i);
			return;
		}
		let n = W.current;
		!n || n.pointerId !== e.pointerId || L({
			x: n.originX + (e.clientX - n.startX),
			y: n.originY + (e.clientY - n.startY)
		});
	}, []), be = g.useCallback((e) => {
		e && C.current?.hasPointerCapture(e.pointerId) && C.current.releasePointerCapture(e.pointerId), e && U.current.delete(e.pointerId), W.current = null, U.current.size < 2 && (G.current = null), H(!1);
	}, []), xe = g.useCallback((e) => {
		if (e.button !== 0 || P) return;
		e.preventDefault(), e.stopPropagation(), e.currentTarget.setPointerCapture(e.pointerId), U.current.set(e.pointerId, {
			x: e.clientX,
			y: e.clientY
		});
		let t = Array.from(U.current.values());
		if (t.length === 2) {
			let [e, n] = t;
			G.current = {
				startDistance: Math.max(1, Math.hypot(n.x - e.x, n.y - e.y)),
				startScale: D
			}, W.current = null, H(!1);
			return;
		}
		W.current = {
			pointerId: e.pointerId,
			startX: e.clientX,
			startY: e.clientY,
			originX: I.x,
			originY: I.y
		}, H(!0);
	}, [
		P,
		D,
		I.x,
		I.y
	]);
	g.useEffect(() => {
		if (!e) return;
		let t = (e) => {
			let t = C.current, n = e.target;
			!t || !(n instanceof Node) || !t.contains(n) || !e.ctrlKey || $(e);
		};
		return window.addEventListener("wheel", t, {
			passive: !1,
			capture: !0
		}), () => {
			window.removeEventListener("wheel", t, { capture: !0 });
		};
	}, [$, e]);
	let Se = g.useMemo(() => [
		{
			key: "zoom-in",
			label: S.zoomIn,
			icon: oe,
			onClick: J,
			disabled: P || D >= R
		},
		{
			key: "zoom-out",
			label: S.zoomOut,
			icon: se,
			onClick: Y,
			disabled: P || D <= ue
		},
		{
			key: "fit",
			label: S.fit,
			icon: x,
			onClick: he,
			disabled: P
		},
		{
			key: "actual-size",
			label: S.actualSize,
			icon: ie,
			onClick: ge,
			disabled: P
		},
		{
			key: "reset",
			label: S.reset,
			icon: te,
			onClick: q,
			disabled: P
		},
		{
			key: "rotate-left",
			label: S.rotateLeft,
			icon: ne,
			onClick: X,
			disabled: P
		},
		{
			key: "rotate-right",
			label: S.rotateRight,
			icon: re,
			onClick: Z,
			disabled: P
		},
		{
			key: "fullscreen",
			label: S.fullscreen,
			icon: ee,
			onClick: () => void Q(),
			disabled: !1
		},
		{
			key: "download",
			label: S.download,
			icon: y,
			onClick: _e,
			disabled: P
		},
		{
			key: "new-tab",
			label: S.openInNewTab,
			icon: b,
			onClick: ve,
			disabled: !1
		}
	], [
		_e,
		Q,
		ve,
		P,
		S.actualSize,
		S.download,
		S.fit,
		S.fullscreen,
		S.openInNewTab,
		S.reset,
		S.rotateLeft,
		S.rotateRight,
		S.zoomIn,
		S.zoomOut,
		q,
		X,
		Z,
		D,
		ge,
		he,
		J,
		Y
	]);
	return /* @__PURE__ */ T(m, {
		open: e,
		onOpenChange: a,
		children: /* @__PURE__ */ E(p, {
			showCloseButton: !1,
			className: "flex h-[min(94vh,980px)] w-[calc(100vw-0.75rem)] sm:w-[40rem] md:w-[52rem] lg:w-[64rem] xl:w-[74rem] 2xl:w-[86rem] max-w-[calc(100vw-0.75rem)] flex-col gap-3 border-zinc-800 bg-zinc-950 p-3 text-zinc-50 sm:max-w-[calc(100vw-2rem)] sm:p-4",
			children: [
				/* @__PURE__ */ T(h, { children: K }),
				/* @__PURE__ */ T(f, { children: S.close }),
				/* @__PURE__ */ E(l, {
					delayDuration: 100,
					children: [/* @__PURE__ */ E("div", {
						className: "flex items-center justify-between gap-3 rounded-lg border border-zinc-800 bg-zinc-900/80 px-3 py-2",
						children: [/* @__PURE__ */ E("div", {
							className: "min-w-0",
							children: [/* @__PURE__ */ T("p", {
								className: "truncate text-sm font-medium",
								children: K
							}), /* @__PURE__ */ E("p", {
								className: "text-xs text-zinc-400",
								children: [
									j === "fit" ? S.fit : `${Math.round(D * 100)}%`,
									k === 0 ? "" : ` · ${k}deg`,
									ce ? ` · ${S.fullscreen}` : ""
								]
							})]
						}), /* @__PURE__ */ T(r, {
							type: "button",
							size: "icon",
							variant: "ghost",
							className: "h-9 w-9 shrink-0 text-zinc-100 hover:bg-zinc-800 hover:text-white",
							onClick: () => a(!1),
							"aria-label": S.close,
							title: S.close,
							children: /* @__PURE__ */ T(ae, { className: "h-4 w-4" })
						})]
					}), /* @__PURE__ */ T("div", {
						className: "overflow-x-auto rounded-lg border border-zinc-800 bg-zinc-900/80 px-2 py-2",
						children: /* @__PURE__ */ T("div", {
							className: "flex min-w-max items-center gap-2",
							children: Se.map((e) => {
								let a = e.icon;
								return /* @__PURE__ */ E(t, { children: [/* @__PURE__ */ T(n, {
									asChild: !0,
									children: /* @__PURE__ */ T(r, {
										type: "button",
										size: "icon",
										variant: "secondary",
										className: "h-9 w-9 bg-zinc-800 text-zinc-100 hover:bg-zinc-700",
										onClick: e.onClick,
										disabled: e.disabled,
										"aria-label": e.label,
										title: e.label,
										children: /* @__PURE__ */ T(a, { className: "h-4 w-4" })
									})
								}), /* @__PURE__ */ T(i, { children: e.label })] }, e.key);
							})
						})
					})]
				}),
				/* @__PURE__ */ T("div", {
					ref: C,
					className: "relative flex min-h-0 flex-1 items-center justify-center overflow-hidden rounded-xl border border-zinc-800 bg-[radial-gradient(circle_at_top,_rgba(255,255,255,0.08),_transparent_40%),linear-gradient(180deg,_rgba(24,24,27,0.9),_rgba(9,9,11,1))] p-4 touch-none",
					onPointerDown: xe,
					onPointerMove: ye,
					onPointerUp: be,
					onPointerCancel: be,
					children: P ? /* @__PURE__ */ E("div", {
						className: "flex flex-col items-center gap-2 text-center",
						children: [
							/* @__PURE__ */ T("div", {
								className: "rounded-full border border-red-500/40 bg-red-500/10 p-3 text-red-300",
								children: /* @__PURE__ */ T(ie, { className: "h-5 w-5" })
							}),
							/* @__PURE__ */ T("p", {
								className: "text-sm font-medium",
								children: S.imageLoadError
							}),
							/* @__PURE__ */ T("p", {
								className: "max-w-md text-xs text-zinc-400",
								children: o
							})
						]
					}) : /* @__PURE__ */ T("img", {
						ref: w,
						src: o,
						alt: K,
						className: u("max-h-full max-w-full select-none rounded-lg object-contain shadow-2xl", j === "fit" ? "h-auto w-auto" : ""),
						style: me,
						onError: () => F(!0),
						draggable: !1
					})
				})
			]
		})
	});
}
//#endregion
//#region src/components/MdxContent.tsx
function H() {
	return (e) => {
		P(e, "element", (e, t, n) => {
			if (e.tagName === "p" && n && typeof t == "number" && e.children.some((e) => e.type === "element" && (U(e) || e.tagName === "pre"))) {
				let r = [], i = [], a = () => {
					i.length > 0 && (r.push({
						type: "element",
						tagName: "p",
						properties: {},
						children: i
					}), i = []);
				};
				for (let t of e.children) t.type === "element" && (U(t) || t.tagName === "pre") ? (a(), r.push(t)) : i.push(t);
				return a(), n.children.splice(t, 1, ...r), [N, t];
			}
		});
	};
}
function U(e) {
	if ((e.properties || {}).isComponent) return !0;
	let t = e.tagName;
	return t.charAt(0) === t.charAt(0).toUpperCase() && t.charAt(0) !== t.charAt(0).toLowerCase();
}
function W(e) {
	return e.replace(/<([A-Z][a-zA-Z0-9]*(?:\.[A-Z][a-zA-Z0-9]*)*)(\s+[^>]*)>([\s\S]*?)<\/\1>/g, (e, t, n, r) => {
		let i = G(n), a = t.toLowerCase().replace(/\./g, "-");
		return `<${a}${i}>${r}</${a}>`;
	}).replace(/<([A-Z][a-zA-Z0-9]*(?:\.[A-Z][a-zA-Z0-9]*)*)(\s+[^>]*?)\s*\/>/g, (e, t, n) => {
		let r = G(n), i = t.toLowerCase().replace(/\./g, "-");
		return `<${i}${r}></${i}>`;
	});
}
function G(e) {
	if (!e) return "";
	let t = [], n = /(\w+)=(?:{([^}]+)}|"([^"]*)"|'([^']*)')/g, r;
	for (; (r = n.exec(e)) !== null;) {
		let [, e, n, i, a] = r, o = n || i || a || "";
		t.push(`data-${e}="${o}"`);
	}
	return t.length > 0 ? " " + t.join(" ") : "";
}
function K(e) {
	let t = {};
	for (let [n, r] of Object.entries(e)) if (n.startsWith("data-")) {
		let e = n.slice(5);
		if (r === "true") t[e] = !0;
		else if (r === "false") t[e] = !1;
		else if (r === "null") t[e] = null;
		else if (r === "undefined") t[e] = void 0;
		else if (!isNaN(Number(r)) && r !== "") t[e] = Number(r);
		else if (r.startsWith("[") && r.endsWith("]")) try {
			t[e] = JSON.parse(r);
		} catch {
			t[e] = r;
		}
		else if (r.startsWith("{") && r.endsWith("}")) try {
			t[e] = JSON.parse(r);
		} catch {
			t[e] = r;
		}
		else t[e] = r;
	}
	return t;
}
var q = {
	js: "JavaScript",
	javascript: "JavaScript",
	ts: "TypeScript",
	typescript: "TypeScript",
	jsx: "JSX",
	tsx: "TSX",
	bash: "Bash",
	shell: "Shell",
	sh: "Shell",
	python: "Python",
	py: "Python",
	java: "Java",
	c: "C",
	cpp: "C++",
	csharp: "C#",
	go: "Go",
	rust: "Rust",
	ruby: "Ruby",
	php: "PHP",
	swift: "Swift",
	kotlin: "Kotlin",
	sql: "SQL",
	json: "JSON",
	yaml: "YAML",
	yml: "YAML",
	toml: "TOML",
	markdown: "Markdown",
	md: "Markdown",
	html: "HTML",
	css: "CSS",
	scss: "SCSS",
	less: "Less",
	vue: "Vue",
	svelte: "Svelte",
	docker: "Docker",
	dockerfile: "Dockerfile",
	nginx: "Nginx",
	xml: "XML",
	diff: "Diff",
	text: "Text"
};
function me({ className: t, children: n, meta: r, codeHighlight: i, shikiBundle: a }) {
	let [s, l] = g.useState(""), [u, d] = g.useState(!1), [f, p] = g.useState(!1), m = g.useMemo(() => r?.toLowerCase().includes("showlinenumbers") ?? !1, [r]), h = /language-(\w+)/.exec(t || ""), y = h ? h[1] : "text", b = e(y), ee = q[y.toLowerCase()] || y.toUpperCase(), x = g.useMemo(() => {
		let e = "";
		return e = typeof n == "string" ? n : g.Children.count(n) === 1 && typeof n == "string" ? String(n) : g.Children.toArray(n).map((e) => {
			if (typeof e == "string") return e;
			if (typeof e == "object" && e && "props" in e) {
				let t = e.props;
				if (t?.node?.type === "element") {
					let e = t.node.tagName || "span", n = t.children;
					return Array.isArray(n) && n.length === 0 ? `<${e} />` : `<${e}>${n.map((e) => typeof e == "string" ? e : e?.type === "text" && e.value || "").join("")}</${e}>`;
				}
			}
			return "";
		}).join(""), e.replace(/^\n+/, "").replace(/\n+$/, "");
	}, [n]);
	g.useEffect(() => {
		let e = () => {
			d(document.documentElement.classList.contains("dark"));
		};
		e();
		let t = new MutationObserver(() => e());
		return t.observe(document.documentElement, {
			attributes: !0,
			attributeFilter: ["class"]
		}), () => t.disconnect();
	}, []), g.useEffect(() => {
		o(x, {
			lang: b,
			theme: c(u, i, a),
			showLineNumbers: m
		}, i, a).then(l);
	}, [
		x,
		b,
		u,
		m,
		i,
		a
	]);
	let te = g.useCallback(async () => {
		let e = async (e) => {
			if (navigator.clipboard && window.isSecureContext) await navigator.clipboard.writeText(e);
			else {
				let t = document.createElement("textarea");
				t.value = e, t.style.position = "fixed", t.style.left = "-9999px", t.style.top = "-9999px", document.body.appendChild(t), t.focus(), t.select();
				try {
					document.execCommand("copy");
				} finally {
					document.body.removeChild(t);
				}
			}
		};
		try {
			await e(x), p(!0), setTimeout(() => p(!1), 2e3);
		} catch (e) {
			console.error("Failed to copy:", e);
		}
	}, [x]);
	return s ? /* @__PURE__ */ E("div", {
		className: "code-block-wrapper",
		children: [
			/* @__PURE__ */ T("span", {
				className: "code-lang-label",
				children: ee
			}),
			/* @__PURE__ */ T("button", {
				className: "code-copy-btn",
				onClick: te,
				title: f ? "已复制" : "复制代码",
				"aria-label": "复制代码",
				children: f ? /* @__PURE__ */ T(_, { className: "h-4 w-4 text-green-500" }) : /* @__PURE__ */ T(v, { className: "h-4 w-4" })
			}),
			/* @__PURE__ */ T("pre", {
				className: `shiki-code-block${m ? " show-line-numbers" : ""}`,
				dangerouslySetInnerHTML: { __html: s }
			})
		]
	}) : /* @__PURE__ */ T("div", {
		className: "code-block-wrapper",
		children: /* @__PURE__ */ T("pre", {
			className: "shiki-code-block",
			children: /* @__PURE__ */ T("code", { children: x })
		})
	});
}
function J({ lang: e, viewerConfig: t, src: n, alt: r, title: i, className: a, node: o, ...s }) {
	let [c, l] = g.useState(!1), u = g.useMemo(() => le(e, t?.labels), [e, t?.labels]);
	return n ? t?.enabled === !1 ? /* @__PURE__ */ T("img", {
		src: n,
		alt: r || u.imageAltFallback,
		title: i,
		className: a,
		...s
	}) : /* @__PURE__ */ E(w, { children: [/* @__PURE__ */ E("span", {
		className: "not-prose group relative my-6 block",
		children: [/* @__PURE__ */ T("button", {
			type: "button",
			className: "block w-full cursor-zoom-in overflow-hidden rounded-2xl border border-border/60 bg-muted/20 shadow-sm transition duration-200 hover:-translate-y-0.5 hover:shadow-xl focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
			onClick: () => l(!0),
			"aria-label": u.preview,
			title: u.preview,
			children: /* @__PURE__ */ T("img", {
				src: n,
				alt: r || u.imageAltFallback,
				title: i,
				className: a ?? "h-auto w-full rounded-2xl object-contain",
				...s
			})
		}), /* @__PURE__ */ E("button", {
			type: "button",
			className: "absolute right-3 top-3 inline-flex items-center gap-2 rounded-full border border-white/20 bg-black/65 px-3 py-1.5 text-xs font-medium text-white opacity-0 shadow-lg transition group-hover:opacity-100 group-focus-within:opacity-100 focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-white/70",
			onClick: () => l(!0),
			"aria-label": u.preview,
			children: [
				/* @__PURE__ */ T("span", {
					className: "sr-only",
					children: u.preview
				}),
				/* @__PURE__ */ E("svg", {
					"aria-hidden": "true",
					viewBox: "0 0 24 24",
					className: "h-3.5 w-3.5",
					fill: "none",
					stroke: "currentColor",
					strokeWidth: "2",
					strokeLinecap: "round",
					strokeLinejoin: "round",
					children: [/* @__PURE__ */ T("path", { d: "M2 12s3.5-6 10-6 10 6 10 6-3.5 6-10 6-10-6-10-6Z" }), /* @__PURE__ */ T("circle", {
						cx: "12",
						cy: "12",
						r: "3"
					})]
				}),
				/* @__PURE__ */ T("span", { children: u.preview })
			]
		})]
	}), /* @__PURE__ */ T(V, {
		open: c,
		onOpenChange: l,
		src: n,
		alt: r,
		title: i,
		lang: e,
		labels: t?.labels
	})] }) : null;
}
function Y({ source: e, skipFirstH1: t = !1, imageViewer: n, codeHighlight: r, shikiBundle: i }) {
	let o = C().lang || "zh-cn", c = s();
	g.useEffect(() => {
		a(r, i);
	}, [r, i]);
	let l = g.useMemo(() => {
		if (!t) return e;
		let n = e.split("\n"), r = !1;
		return n.filter((e) => !r && e.startsWith("# ") ? (r = !0, !1) : !0).join("\n");
	}, [e, t]), u = g.useMemo(() => W(l), [l]), d = g.useMemo(() => {
		let e = /* @__PURE__ */ new Map();
		return c && Object.entries(c).forEach(([t, n]) => {
			let r = g.memo(({ children: e, ...t }) => {
				let r = K(t);
				return g.createElement(n, r, e);
			});
			if (e.set(t, r), t.includes(".")) {
				let [n, i] = t.split("."), a = `${n.toLowerCase()}-${i.toLowerCase()}`;
				e.set(a, r);
			}
		}), e;
	}, [c]), f = g.useMemo(() => Object.fromEntries(d), [d]);
	return /* @__PURE__ */ T("div", {
		className: "prose dark:prose-invert max-w-none",
		children: /* @__PURE__ */ T(k, {
			remarkPlugins: [D, O],
			rehypePlugins: [
				j,
				M,
				I(f),
				H,
				[A, { behavior: "append" }],
				[ce, {
					strict: !1,
					trust: !0,
					macros: {
						"\\R": "\\mathbb{R}",
						"\\N": "\\mathbb{N}",
						"\\Z": "\\mathbb{Z}",
						"\\Q": "\\mathbb{Q}",
						"\\C": "\\mathbb{C}",
						...F
					}
				}]
			],
			components: {
				...f,
				table({ children: e, ...t }) {
					return /* @__PURE__ */ T("div", {
						className: "overflow-x-auto",
						children: /* @__PURE__ */ T("table", {
							...t,
							children: e
						})
					});
				},
				pre({ children: e, ...t }) {
					let n = g.Children.toArray(e).find((e) => e?.type === "code" || e?.props?.node?.tagName === "code");
					if (n) {
						let e = n.props, t = e?.className || "", a = e?.node, o = e?.children, s = e?.["data-raw-value"];
						return s && (o = s), /* @__PURE__ */ T(me, {
							className: t,
							meta: a?.data?.meta || "",
							codeHighlight: r,
							shikiBundle: i,
							children: o
						});
					}
					return /* @__PURE__ */ T("pre", {
						...t,
						children: e
					});
				},
				a({ href: e, children: t, ...n }) {
					return e ? e.startsWith("#") ? /* @__PURE__ */ T("a", {
						href: e,
						...n,
						children: t
					}) : /^(https?:)?\/\//i.test(e) || e.startsWith("mailto:") || e.startsWith("tel:") ? /* @__PURE__ */ T("a", {
						href: e,
						target: "_blank",
						rel: "noopener noreferrer",
						...n,
						children: t
					}) : /* @__PURE__ */ T(S, {
						to: `/${o}${e.startsWith("/") ? e : `/${e}`}`,
						...n,
						children: t
					}) : /* @__PURE__ */ T("a", {
						...n,
						children: t
					});
				},
				img({ src: e, alt: t, title: r, className: i, node: a, ...s }) {
					return /* @__PURE__ */ T(J, {
						lang: o,
						viewerConfig: n,
						src: e,
						alt: t,
						title: r,
						className: i,
						node: a,
						...s
					});
				}
			},
			children: u
		})
	});
}
//#endregion
export { V as n, Y as t };
