"use client";
import { SKIP as e, visitParents as t } from "../../unist-util-visit-parents/lib/index.js";
import { visit as n } from "../../unist-util-visit/lib/index.js";
import r from "../../remark-gfm/lib/index.js";
import { harden as i } from "../../rehype-harden/dist/index.js";
import a from "../../rehype-raw/lib/index.js";
import { defaultSchema as o } from "../../hast-util-sanitize/lib/schema.js";
import s from "../../rehype-sanitize/lib/index.js";
import { $e as c } from "../../remend/dist/index.js";
import { toJsxRuntime as l } from "../../hast-util-to-jsx-runtime/lib/index.js";
import { urlAttributes as u } from "../../html-url-attributes/lib/index.js";
import d from "../../remark-parse/lib/index.js";
import f from "../../remark-rehype/lib/index.js";
import { unified as p } from "../../unified/lib/index.js";
import { x as m } from "../node_modules/marked/lib/marked.esm.js";
import { Suspense as h, cloneElement as g, createContext as _, createElement as v, isValidElement as y, lazy as b, memo as x, useCallback as S, useContext as C, useEffect as w, useId as ee, useMemo as T, useRef as E, useState as D, useTransition as te } from "react";
import { Fragment as O, jsx as k, jsxs as A } from "react/jsx-runtime";
import { clsx as j } from "clsx";
import { twMerge as M } from "tailwind-merge";
import { createPortal as N } from "react-dom";
//#region ../../node_modules/streamdown/dist/chunk-BO2N2NFS.js
var P = 300, F = "300px", ne = 500;
function re(e = {}) {
	let { immediate: t = !1, debounceDelay: n = P, rootMargin: r = F, idleTimeout: i = ne } = e, [a, o] = D(!1), s = E(null), c = E(null), l = E(null), u = T(() => (e) => {
		let t = Date.now();
		return window.setTimeout(() => {
			e({
				didTimeout: !1,
				timeRemaining: () => Math.max(0, 50 - (Date.now() - t))
			});
		}, 1);
	}, []), d = T(() => typeof window < "u" && window.requestIdleCallback ? (e, t) => window.requestIdleCallback(e, t) : u, [u]), f = T(() => typeof window < "u" && window.cancelIdleCallback ? (e) => window.cancelIdleCallback(e) : (e) => {
		clearTimeout(e);
	}, []);
	return w(() => {
		if (t) {
			o(!0);
			return;
		}
		let e = s.current;
		if (!e) return;
		c.current &&= (clearTimeout(c.current), null), l.current &&= (f(l.current), null);
		let a = () => {
			c.current &&= (clearTimeout(c.current), null), l.current &&= (f(l.current), null);
		}, u = (e) => {
			l.current = d((t) => {
				t.timeRemaining() > 0 || t.didTimeout ? (o(!0), e.disconnect()) : l.current = d(() => {
					o(!0), e.disconnect();
				}, { timeout: i / 2 });
			}, { timeout: i });
		}, p = (e) => {
			a(), c.current = window.setTimeout(() => {
				var t;
				let n = e.takeRecords();
				(n.length === 0 || (t = n.at(-1)?.isIntersecting) != null && t) && u(e);
			}, n);
		}, m = (e, t) => {
			e.isIntersecting ? p(t) : a();
		}, h = new IntersectionObserver((e) => {
			for (let t of e) m(t, h);
		}, {
			rootMargin: r,
			threshold: 0
		});
		return h.observe(e), () => {
			c.current && clearTimeout(c.current), l.current && f(l.current), h.disconnect();
		};
	}, [
		t,
		n,
		r,
		i,
		f,
		d
	]), {
		shouldRender: a,
		containerRef: s
	};
}
var ie = /\s/, ae = /^\s+$/, oe = new Set([
	"code",
	"pre",
	"svg",
	"math",
	"annotation"
]), I = (e) => typeof e == "object" && !!e && "type" in e && e.type === "element", se = (e) => e.some((e) => I(e) && oe.has(e.tagName)), L = (e) => {
	let t = [], n = "", r = !1;
	for (let i of e) {
		let e = ie.test(i);
		e !== r && n && (t.push(n), n = ""), n += i, r = e;
	}
	return n && t.push(n), t;
}, ce = (e) => {
	let t = [], n = "";
	for (let r of e) ie.test(r) ? n += r : (n &&= (t.push(n), ""), t.push(r));
	return n && t.push(n), t;
}, R = (e, t, n, r, i, a) => {
	let o = `--sd-animation:sd-${t};--sd-duration:${i ? 0 : n}ms;--sd-easing:${r}`;
	return a && (o += `;--sd-delay:${a}ms`), {
		type: "element",
		tagName: "span",
		properties: {
			"data-sd-animate": !0,
			style: o
		},
		children: [{
			type: "text",
			value: e
		}]
	};
}, z = (t, n, r, i, a) => {
	let o = n.at(-1);
	if (!(o && "children" in o)) return;
	if (se(n)) return e;
	let s = o, c = s.children.indexOf(t);
	if (c === -1) return;
	let l = t.value;
	if (!l.trim()) {
		a.count += l.length;
		return;
	}
	let u = r.sep === "char" ? ce(l) : L(l), d = i.prevContentLength, f = u.map((e) => {
		let t = a.count;
		if (a.count += e.length, ae.test(e)) return {
			type: "text",
			value: e
		};
		let n = d > 0 && t < d, i = n ? 0 : a.newIndex++ * r.stagger;
		return R(e, r.animation, r.duration, r.easing, n, i);
	});
	return s.children.splice(c, 1, ...f), c + f.length;
}, B = 0;
function le(e) {
	let n = {
		animation: e?.animation ?? "fadeIn",
		duration: e?.duration ?? 150,
		easing: e?.easing ?? "ease",
		sep: e?.sep ?? "word",
		stagger: e?.stagger ?? 40
	}, r = {
		prevContentLength: 0,
		lastRenderCharCount: 0
	}, i = B++, a = () => (e) => {
		let i = {
			count: 0,
			newIndex: 0
		};
		t(e, "text", (e, t) => z(e, t, n, r, i)), r.lastRenderCharCount = i.count, r.prevContentLength = 0;
	};
	return Object.defineProperty(a, "name", { value: `rehypeAnimate$${i}` }), {
		name: "animate",
		type: "animate",
		rehypePlugin: a,
		setPrevContentLength(e) {
			r.prevContentLength = e;
		},
		getLastRenderCharCount() {
			let e = r.lastRenderCharCount;
			return r.lastRenderCharCount = 0, e;
		}
	};
}
le();
var ue = _(!1), de = () => C(ue), V = (...e) => M(j(e)), fe = (e, t) => {
	if (!e || !t) return t;
	let n = `${e}:`;
	return t.split(/\s+/).filter(Boolean).map((t) => t.startsWith(n) ? t : `${e}:${t}`).join(" ");
}, pe = (e) => e ? (...t) => fe(e, M(j(t))) : V, H = (e, t, n) => {
	let r = typeof t == "string" && n.startsWith("text/csv") ? "﻿" : "", i = typeof t == "string" ? new Blob([r + t], { type: n }) : t, a = URL.createObjectURL(i), o = document.createElement("a");
	o.href = a, o.download = e, document.body.appendChild(o), o.click(), document.body.removeChild(o), URL.revokeObjectURL(a);
}, me = _(V), U = () => C(me), W = V("block", "before:content-[counter(line)]", "before:inline-block", "before:[counter-increment:line]", "before:w-6", "before:mr-4", "before:text-[13px]", "before:text-right", "before:text-muted-foreground/50", "before:font-mono", "before:select-none"), he = (e) => {
	let t = {};
	for (let n of e.split(";")) {
		let e = n.indexOf(":");
		if (e > 0) {
			let r = n.slice(0, e).trim(), i = n.slice(e + 1).trim();
			r && i && (t[r] = i);
		}
	}
	return t;
}, G = x(({ children: e, result: t, language: n, className: r, startLine: i, lineNumbers: a = !0, ...o }) => {
	let s = U(), c = T(() => s(W), [s]), l = T(() => {
		let e = {};
		return t.bg && (e["--sdm-bg"] = t.bg), t.fg && (e["--sdm-fg"] = t.fg), t.rootStyle && Object.assign(e, he(t.rootStyle)), e;
	}, [
		t.bg,
		t.fg,
		t.rootStyle
	]);
	return k("div", {
		className: s(r, "overflow-x-auto rounded-md border border-border bg-background p-4 text-sm"),
		"data-language": n,
		"data-streamdown": "code-block-body",
		...o,
		children: k("pre", {
			className: s(r, "bg-[var(--sdm-bg,inherit]", "dark:bg-[var(--shiki-dark-bg,var(--sdm-bg,inherit)]"),
			style: l,
			children: k("code", {
				className: a ? s("[counter-increment:line_0] [counter-reset:line]") : void 0,
				style: a && i && i > 1 ? { counterReset: `line ${i - 1}` } : void 0,
				children: t.tokens.map((e, t) => k("span", {
					className: a ? c : void 0,
					children: e.length === 0 || e.length === 1 && e[0].content === "" ? "\n" : e.map((e, t) => {
						let n = {}, r = !!e.bgColor;
						if (e.color && (n["--sdm-c"] = e.color), e.bgColor && (n["--sdm-tbg"] = e.bgColor), e.htmlStyle) for (let [t, i] of Object.entries(e.htmlStyle)) t === "color" ? n["--sdm-c"] = i : t === "background-color" ? (n["--sdm-tbg"] = i, r = !0) : n[t] = i;
						return k("span", {
							className: s("text-[var(--sdm-c,inherit)]", "dark:text-[var(--shiki-dark,var(--sdm-c,inherit))]", r && "bg-[var(--sdm-tbg)]", r && "dark:bg-[var(--shiki-dark-bg,var(--sdm-tbg))]"),
							style: n,
							...e.htmlAttrs,
							children: e.content
						}, t);
					})
				}, t))
			})
		})
	});
}, (e, t) => e.result === t.result && e.language === t.language && e.className === t.className && e.startLine === t.startLine && e.lineNumbers === t.lineNumbers), K = ({ className: e, language: t, style: n, isIncomplete: r, ...i }) => k("div", {
	className: U()("my-4 flex w-full flex-col gap-2 rounded-xl border border-border bg-sidebar p-2", e),
	"data-incomplete": r || void 0,
	"data-language": t,
	"data-streamdown": "code-block",
	style: {
		contentVisibility: "auto",
		containIntrinsicSize: "auto 200px",
		...n
	},
	...i
}), ge = _({ code: "" }), _e = () => C(ge), q = ({ language: e }) => {
	let t = U();
	return k("div", {
		className: t("flex h-8 items-center text-muted-foreground text-xs"),
		"data-language": e,
		"data-streamdown": "code-block-header",
		children: k("span", {
			className: t("ml-1 font-mono lowercase"),
			children: e
		})
	});
}, ve = (e) => {
	let t = e.length;
	for (; t > 0 && e[t - 1] === "\n";) t--;
	return e.slice(0, t);
}, ye = b(() => import("./highlighted-body-OFNGDK62.js").then((e) => ({ default: e.HighlightedCodeBlockBody }))), be = ({ code: e, language: t, className: n, children: r, isIncomplete: i = !1, startLine: a, lineNumbers: o, ...s }) => {
	let c = U(), l = T(() => ve(e), [e]), u = T(() => ({
		bg: "transparent",
		fg: "inherit",
		tokens: l.split("\n").map((e) => [{
			content: e,
			color: "inherit",
			bgColor: "transparent",
			htmlStyle: {},
			offset: 0
		}])
	}), [l]);
	return k(ge.Provider, {
		value: { code: e },
		children: A(K, {
			isIncomplete: i,
			language: t,
			children: [
				k(q, { language: t }),
				r ? k("div", {
					className: c("pointer-events-none sticky top-2 z-10 -mt-10 flex h-8 items-center justify-end"),
					children: k("div", {
						className: c("pointer-events-auto flex shrink-0 items-center gap-2 rounded-md border border-sidebar bg-sidebar/80 px-1.5 py-1 supports-[backdrop-filter]:bg-sidebar/70 supports-[backdrop-filter]:backdrop-blur"),
						"data-streamdown": "code-block-actions",
						children: r
					})
				}) : null,
				k(h, {
					fallback: k(G, {
						className: n,
						language: t,
						lineNumbers: o,
						result: u,
						startLine: a,
						...s
					}),
					children: k(ye, {
						className: n,
						code: l,
						language: t,
						lineNumbers: o,
						raw: u,
						startLine: a,
						...s
					})
				})
			]
		})
	});
}, J = {
	CheckIcon: (e) => k("svg", {
		color: "currentColor",
		height: 16,
		strokeLinejoin: "round",
		viewBox: "0 0 16 16",
		width: 16,
		...e,
		children: k("path", {
			clipRule: "evenodd",
			d: "M15.5607 3.99999L15.0303 4.53032L6.23744 13.3232C5.55403 14.0066 4.44599 14.0066 3.76257 13.3232L4.2929 12.7929L3.76257 13.3232L0.969676 10.5303L0.439346 9.99999L1.50001 8.93933L2.03034 9.46966L4.82323 12.2626C4.92086 12.3602 5.07915 12.3602 5.17678 12.2626L13.9697 3.46966L14.5 2.93933L15.5607 3.99999Z",
			fill: "currentColor",
			fillRule: "evenodd"
		})
	}),
	CopyIcon: (e) => k("svg", {
		color: "currentColor",
		height: 16,
		strokeLinejoin: "round",
		viewBox: "0 0 16 16",
		width: 16,
		...e,
		children: k("path", {
			clipRule: "evenodd",
			d: "M2.75 0.5C1.7835 0.5 1 1.2835 1 2.25V9.75C1 10.7165 1.7835 11.5 2.75 11.5H3.75H4.5V10H3.75H2.75C2.61193 10 2.5 9.88807 2.5 9.75V2.25C2.5 2.11193 2.61193 2 2.75 2H8.25C8.38807 2 8.5 2.11193 8.5 2.25V3H10V2.25C10 1.2835 9.2165 0.5 8.25 0.5H2.75ZM7.75 4.5C6.7835 4.5 6 5.2835 6 6.25V13.75C6 14.7165 6.7835 15.5 7.75 15.5H13.25C14.2165 15.5 15 14.7165 15 13.75V6.25C15 5.2835 14.2165 4.5 13.25 4.5H7.75ZM7.5 6.25C7.5 6.11193 7.61193 6 7.75 6H13.25C13.3881 6 13.5 6.11193 13.5 6.25V13.75C13.5 13.8881 13.3881 14 13.25 14H7.75C7.61193 14 7.5 13.8881 7.5 13.75V6.25Z",
			fill: "currentColor",
			fillRule: "evenodd"
		})
	}),
	DownloadIcon: (e) => k("svg", {
		color: "currentColor",
		height: 16,
		strokeLinejoin: "round",
		viewBox: "0 0 16 16",
		width: 16,
		...e,
		children: k("path", {
			clipRule: "evenodd",
			d: "M8.75 1V1.75V8.68934L10.7197 6.71967L11.25 6.18934L12.3107 7.25L11.7803 7.78033L8.70711 10.8536C8.31658 11.2441 7.68342 11.2441 7.29289 10.8536L4.21967 7.78033L3.68934 7.25L4.75 6.18934L5.28033 6.71967L7.25 8.68934V1.75V1H8.75ZM13.5 9.25V13.5H2.5V9.25V8.5H1V9.25V14C1 14.5523 1.44771 15 2 15H14C14.5523 15 15 14.5523 15 14V9.25V8.5H13.5V9.25Z",
			fill: "currentColor",
			fillRule: "evenodd"
		})
	}),
	ExternalLinkIcon: (e) => k("svg", {
		color: "currentColor",
		height: 16,
		strokeLinejoin: "round",
		viewBox: "0 0 16 16",
		width: 16,
		...e,
		children: k("path", {
			clipRule: "evenodd",
			d: "M13.5 10.25V13.25C13.5 13.3881 13.3881 13.5 13.25 13.5H2.75C2.61193 13.5 2.5 13.3881 2.5 13.25L2.5 2.75C2.5 2.61193 2.61193 2.5 2.75 2.5H5.75H6.5V1H5.75H2.75C1.7835 1 1 1.7835 1 2.75V13.25C1 14.2165 1.7835 15 2.75 15H13.25C14.2165 15 15 14.2165 15 13.25V10.25V9.5H13.5V10.25ZM9 1H9.75H14.2495C14.6637 1 14.9995 1.33579 14.9995 1.75V6.25V7H13.4995V6.25V3.56066L8.53033 8.52978L8 9.06011L6.93934 7.99945L7.46967 7.46912L12.4388 2.5H9.75H9V1Z",
			fill: "currentColor",
			fillRule: "evenodd"
		})
	}),
	Loader2Icon: (e) => A("svg", {
		color: "currentColor",
		height: 16,
		strokeLinejoin: "round",
		viewBox: "0 0 16 16",
		width: 16,
		...e,
		children: [
			k("path", {
				d: "M8 0V4",
				stroke: "currentColor",
				strokeWidth: "1.5"
			}),
			k("path", {
				d: "M8 16V12",
				opacity: "0.5",
				stroke: "currentColor",
				strokeWidth: "1.5"
			}),
			k("path", {
				d: "M3.29773 1.52783L5.64887 4.7639",
				opacity: "0.9",
				stroke: "currentColor",
				strokeWidth: "1.5"
			}),
			k("path", {
				d: "M12.7023 1.52783L10.3511 4.7639",
				opacity: "0.1",
				stroke: "currentColor",
				strokeWidth: "1.5"
			}),
			k("path", {
				d: "M12.7023 14.472L10.3511 11.236",
				opacity: "0.4",
				stroke: "currentColor",
				strokeWidth: "1.5"
			}),
			k("path", {
				d: "M3.29773 14.472L5.64887 11.236",
				opacity: "0.6",
				stroke: "currentColor",
				strokeWidth: "1.5"
			}),
			k("path", {
				d: "M15.6085 5.52783L11.8043 6.7639",
				opacity: "0.2",
				stroke: "currentColor",
				strokeWidth: "1.5"
			}),
			k("path", {
				d: "M0.391602 10.472L4.19583 9.23598",
				opacity: "0.7",
				stroke: "currentColor",
				strokeWidth: "1.5"
			}),
			k("path", {
				d: "M15.6085 10.4722L11.8043 9.2361",
				opacity: "0.3",
				stroke: "currentColor",
				strokeWidth: "1.5"
			}),
			k("path", {
				d: "M0.391602 5.52783L4.19583 6.7639",
				opacity: "0.8",
				stroke: "currentColor",
				strokeWidth: "1.5"
			})
		]
	}),
	Maximize2Icon: (e) => k("svg", {
		color: "currentColor",
		height: 16,
		strokeLinejoin: "round",
		viewBox: "0 0 16 16",
		width: 16,
		...e,
		children: k("path", {
			clipRule: "evenodd",
			d: "M1 5.25V6H2.5V5.25V2.5H5.25H6V1H5.25H2C1.44772 1 1 1.44772 1 2V5.25ZM5.25 14.9994H6V13.4994H5.25H2.5V10.7494V9.99939H1V10.7494V13.9994C1 14.5517 1.44772 14.9994 2 14.9994H5.25ZM15 10V10.75V14C15 14.5523 14.5523 15 14 15H10.75H10V13.5H10.75H13.5V10.75V10H15ZM10.75 1H10V2.5H10.75H13.5V5.25V6H15V5.25V2C15 1.44772 14.5523 1 14 1H10.75Z",
			fill: "currentColor",
			fillRule: "evenodd"
		})
	}),
	RotateCcwIcon: (e) => k("svg", {
		color: "currentColor",
		height: 16,
		strokeLinejoin: "round",
		viewBox: "0 0 16 16",
		width: 16,
		...e,
		children: k("path", {
			clipRule: "evenodd",
			d: "M13.5 8C13.5 4.96643 11.0257 2.5 7.96452 2.5C5.42843 2.5 3.29365 4.19393 2.63724 6.5H5.25H6V8H5.25H0.75C0.335787 8 0 7.66421 0 7.25V2.75V2H1.5V2.75V5.23347C2.57851 2.74164 5.06835 1 7.96452 1C11.8461 1 15 4.13001 15 8C15 11.87 11.8461 15 7.96452 15C5.62368 15 3.54872 13.8617 2.27046 12.1122L1.828 11.5066L3.03915 10.6217L3.48161 11.2273C4.48831 12.6051 6.12055 13.5 7.96452 13.5C11.0257 13.5 13.5 11.0336 13.5 8Z",
			fill: "currentColor",
			fillRule: "evenodd"
		})
	}),
	XIcon: (e) => k("svg", {
		color: "currentColor",
		height: 16,
		strokeLinejoin: "round",
		viewBox: "0 0 16 16",
		width: 16,
		...e,
		children: k("path", {
			clipRule: "evenodd",
			d: "M12.4697 13.5303L13 14.0607L14.0607 13L13.5303 12.4697L9.06065 7.99999L13.5303 3.53032L14.0607 2.99999L13 1.93933L12.4697 2.46966L7.99999 6.93933L3.53032 2.46966L2.99999 1.93933L1.93933 2.99999L2.46966 3.53032L6.93933 7.99999L2.46966 12.4697L1.93933 13L2.99999 14.0607L3.53032 13.5303L7.99999 9.06065L12.4697 13.5303Z",
			fill: "currentColor",
			fillRule: "evenodd"
		})
	}),
	ZoomInIcon: (e) => k("svg", {
		color: "currentColor",
		height: 16,
		strokeLinejoin: "round",
		viewBox: "0 0 16 16",
		width: 16,
		...e,
		children: k("path", {
			clipRule: "evenodd",
			d: "M1.5 6.5C1.5 3.73858 3.73858 1.5 6.5 1.5C9.26142 1.5 11.5 3.73858 11.5 6.5C11.5 9.26142 9.26142 11.5 6.5 11.5C3.73858 11.5 1.5 9.26142 1.5 6.5ZM6.5 0C2.91015 0 0 2.91015 0 6.5C0 10.0899 2.91015 13 6.5 13C8.02469 13 9.42677 12.475 10.5353 11.596L13.9697 15.0303L14.5 15.5607L15.5607 14.5L15.0303 13.9697L11.596 10.5353C12.475 9.42677 13 8.02469 13 6.5C13 2.91015 10.0899 0 6.5 0ZM4.125 5.875H4.75H5.875V4.75V4.125H7.125V4.75V5.875H8.25H8.875V7.125H8.25H7.125V8.25V8.875H5.875V8.25V7.125H4.75H4.125V5.875Z",
			fill: "currentColor",
			fillRule: "evenodd"
		})
	}),
	ZoomOutIcon: (e) => k("svg", {
		color: "currentColor",
		height: 16,
		strokeLinejoin: "round",
		viewBox: "0 0 16 16",
		width: 16,
		...e,
		children: k("path", {
			clipRule: "evenodd",
			d: "M1.5 6.5C1.5 3.73858 3.73858 1.5 6.5 1.5C9.26142 1.5 11.5 3.73858 11.5 6.5C11.5 9.26142 9.26142 11.5 6.5 11.5C3.73858 11.5 1.5 9.26142 1.5 6.5ZM6.5 0C2.91015 0 0 2.91015 0 6.5C0 10.0899 2.91015 13 6.5 13C8.02469 13 9.42677 12.475 10.5353 11.596L13.9697 15.0303L14.5 15.5607L15.5607 14.5L15.0303 13.9697L11.596 10.5353C12.475 9.42677 13 8.02469 13 6.5C13 2.91015 10.0899 0 6.5 0ZM4.125 5.875H4.75H8.25H8.875V7.125H8.25H4.75H4.125V5.875Z",
			fill: "currentColor",
			fillRule: "evenodd"
		})
	})
}, xe = _(J), Se = (e, t) => {
	if (e === t) return !0;
	if (!(e && t)) return e === t;
	let n = Object.keys(e), r = Object.keys(t);
	return n.length === r.length ? n.every((n) => e[n] === t[n]) : !1;
}, Ce = ({ icons: e, children: t }) => {
	let n = E(e), r = E(e ? {
		...J,
		...e
	} : J);
	Se(n.current, e) || (n.current = e, r.current = e ? {
		...J,
		...e
	} : J);
	let i = r.current;
	return k(xe.Provider, {
		value: i,
		children: t
	});
}, Y = () => C(xe), we = {
	copyCode: "Copy Code",
	downloadFile: "Download file",
	downloadDiagram: "Download diagram",
	downloadDiagramAsSvg: "Download diagram as SVG",
	downloadDiagramAsPng: "Download diagram as PNG",
	downloadDiagramAsMmd: "Download diagram as MMD",
	viewFullscreen: "View fullscreen",
	exitFullscreen: "Exit fullscreen",
	mermaidFormatSvg: "SVG",
	mermaidFormatPng: "PNG",
	mermaidFormatMmd: "MMD",
	copyTable: "Copy table",
	copyTableAsMarkdown: "Copy table as Markdown",
	copyTableAsCsv: "Copy table as CSV",
	copyTableAsTsv: "Copy table as TSV",
	downloadTable: "Download table",
	downloadTableAsCsv: "Download table as CSV",
	downloadTableAsMarkdown: "Download table as Markdown",
	tableFormatMarkdown: "Markdown",
	tableFormatCsv: "CSV",
	tableFormatTsv: "TSV",
	imageNotAvailable: "Image not available",
	downloadImage: "Download image",
	openExternalLink: "Open external link?",
	externalLinkWarning: "You're about to visit an external website.",
	close: "Close",
	copyLink: "Copy link",
	copied: "Copied",
	openLink: "Open link"
}, Te = _(we), X = () => C(Te), Ee = ({ onCopy: e, onError: t, timeout: n = 2e3, children: r, className: i, code: a, ...o }) => {
	let s = U(), [c, l] = D(!1), u = E(0), { code: d } = _e(), { isAnimating: f } = C($), p = X(), m = a ?? d, h = async () => {
		var r;
		if (typeof window > "u" || !((r = navigator == null ? void 0 : navigator.clipboard) != null && r.writeText)) {
			t?.(/* @__PURE__ */ Error("Clipboard API not available"));
			return;
		}
		try {
			c || (await navigator.clipboard.writeText(m), l(!0), e?.(), u.current = window.setTimeout(() => l(!1), n));
		} catch (e) {
			t?.(e);
		}
	};
	w(() => () => {
		window.clearTimeout(u.current);
	}, []);
	let g = Y(), _ = c ? g.CheckIcon : g.CopyIcon;
	return k("button", {
		className: s("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50", i),
		"data-streamdown": "code-block-copy-button",
		disabled: f,
		onClick: h,
		title: p.copyCode,
		type: "button",
		...o,
		children: r ?? k(_, { size: 14 })
	});
}, De = {
	"1c": "1c",
	"1c-query": "1cq",
	abap: "abap",
	"actionscript-3": "as",
	ada: "ada",
	adoc: "adoc",
	"angular-html": "html",
	"angular-ts": "ts",
	apache: "conf",
	apex: "cls",
	apl: "apl",
	applescript: "applescript",
	ara: "ara",
	asciidoc: "adoc",
	asm: "asm",
	astro: "astro",
	awk: "awk",
	ballerina: "bal",
	bash: "sh",
	bat: "bat",
	batch: "bat",
	be: "be",
	beancount: "beancount",
	berry: "berry",
	bibtex: "bib",
	bicep: "bicep",
	blade: "blade.php",
	bsl: "bsl",
	c: "c",
	"c#": "cs",
	"c++": "cpp",
	cadence: "cdc",
	cairo: "cairo",
	cdc: "cdc",
	clarity: "clar",
	clj: "clj",
	clojure: "clj",
	"closure-templates": "soy",
	cmake: "cmake",
	cmd: "cmd",
	cobol: "cob",
	codeowners: "CODEOWNERS",
	codeql: "ql",
	coffee: "coffee",
	coffeescript: "coffee",
	"common-lisp": "lisp",
	console: "sh",
	coq: "v",
	cpp: "cpp",
	cql: "cql",
	crystal: "cr",
	cs: "cs",
	csharp: "cs",
	css: "css",
	csv: "csv",
	cue: "cue",
	cypher: "cql",
	d: "d",
	dart: "dart",
	dax: "dax",
	desktop: "desktop",
	diff: "diff",
	docker: "dockerfile",
	dockerfile: "dockerfile",
	dotenv: "env",
	"dream-maker": "dm",
	edge: "edge",
	elisp: "el",
	elixir: "ex",
	elm: "elm",
	"emacs-lisp": "el",
	erb: "erb",
	erl: "erl",
	erlang: "erl",
	f: "f",
	"f#": "fs",
	f03: "f03",
	f08: "f08",
	f18: "f18",
	f77: "f77",
	f90: "f90",
	f95: "f95",
	fennel: "fnl",
	fish: "fish",
	fluent: "ftl",
	for: "for",
	"fortran-fixed-form": "f",
	"fortran-free-form": "f90",
	fs: "fs",
	fsharp: "fs",
	fsl: "fsl",
	ftl: "ftl",
	gdresource: "tres",
	gdscript: "gd",
	gdshader: "gdshader",
	genie: "gs",
	gherkin: "feature",
	"git-commit": "gitcommit",
	"git-rebase": "gitrebase",
	gjs: "js",
	gleam: "gleam",
	"glimmer-js": "js",
	"glimmer-ts": "ts",
	glsl: "glsl",
	gnuplot: "plt",
	go: "go",
	gql: "gql",
	graphql: "graphql",
	groovy: "groovy",
	gts: "gts",
	hack: "hack",
	haml: "haml",
	handlebars: "hbs",
	haskell: "hs",
	haxe: "hx",
	hbs: "hbs",
	hcl: "hcl",
	hjson: "hjson",
	hlsl: "hlsl",
	hs: "hs",
	html: "html",
	"html-derivative": "html",
	http: "http",
	hxml: "hxml",
	hy: "hy",
	imba: "imba",
	ini: "ini",
	jade: "jade",
	java: "java",
	javascript: "js",
	jinja: "jinja",
	jison: "jison",
	jl: "jl",
	js: "js",
	json: "json",
	json5: "json5",
	jsonc: "jsonc",
	jsonl: "jsonl",
	jsonnet: "jsonnet",
	jssm: "jssm",
	jsx: "jsx",
	julia: "jl",
	kotlin: "kt",
	kql: "kql",
	kt: "kt",
	kts: "kts",
	kusto: "kql",
	latex: "tex",
	lean: "lean",
	lean4: "lean",
	less: "less",
	liquid: "liquid",
	lisp: "lisp",
	lit: "lit",
	llvm: "ll",
	log: "log",
	logo: "logo",
	lua: "lua",
	luau: "luau",
	make: "mak",
	makefile: "mak",
	markdown: "md",
	marko: "marko",
	matlab: "m",
	md: "md",
	mdc: "mdc",
	mdx: "mdx",
	mediawiki: "wiki",
	mermaid: "mmd",
	mips: "s",
	mipsasm: "s",
	mmd: "mmd",
	mojo: "mojo",
	move: "move",
	nar: "nar",
	narrat: "narrat",
	nextflow: "nf",
	nf: "nf",
	nginx: "conf",
	nim: "nim",
	nix: "nix",
	nu: "nu",
	nushell: "nu",
	objc: "m",
	"objective-c": "m",
	"objective-cpp": "mm",
	ocaml: "ml",
	pascal: "pas",
	perl: "pl",
	perl6: "p6",
	php: "php",
	plsql: "pls",
	po: "po",
	polar: "polar",
	postcss: "pcss",
	pot: "pot",
	potx: "potx",
	powerquery: "pq",
	powershell: "ps1",
	prisma: "prisma",
	prolog: "pl",
	properties: "properties",
	proto: "proto",
	protobuf: "proto",
	ps: "ps",
	ps1: "ps1",
	pug: "pug",
	puppet: "pp",
	purescript: "purs",
	py: "py",
	python: "py",
	ql: "ql",
	qml: "qml",
	qmldir: "qmldir",
	qss: "qss",
	r: "r",
	racket: "rkt",
	raku: "raku",
	razor: "cshtml",
	rb: "rb",
	reg: "reg",
	regex: "regex",
	regexp: "regexp",
	rel: "rel",
	riscv: "s",
	rs: "rs",
	rst: "rst",
	ruby: "rb",
	rust: "rs",
	sas: "sas",
	sass: "sass",
	scala: "scala",
	scheme: "scm",
	scss: "scss",
	sdbl: "sdbl",
	sh: "sh",
	shader: "shader",
	shaderlab: "shader",
	shell: "sh",
	shellscript: "sh",
	shellsession: "sh",
	smalltalk: "st",
	solidity: "sol",
	soy: "soy",
	sparql: "rq",
	spl: "spl",
	splunk: "spl",
	sql: "sql",
	"ssh-config": "config",
	stata: "do",
	styl: "styl",
	stylus: "styl",
	svelte: "svelte",
	swift: "swift",
	"system-verilog": "sv",
	systemd: "service",
	talon: "talon",
	talonscript: "talon",
	tasl: "tasl",
	tcl: "tcl",
	templ: "templ",
	terraform: "tf",
	tex: "tex",
	tf: "tf",
	tfvars: "tfvars",
	toml: "toml",
	ts: "ts",
	"ts-tags": "ts",
	tsp: "tsp",
	tsv: "tsv",
	tsx: "tsx",
	turtle: "ttl",
	twig: "twig",
	typ: "typ",
	typescript: "ts",
	typespec: "tsp",
	typst: "typ",
	v: "v",
	vala: "vala",
	vb: "vb",
	verilog: "v",
	vhdl: "vhdl",
	vim: "vim",
	viml: "vim",
	vimscript: "vim",
	vue: "vue",
	"vue-html": "html",
	"vue-vine": "vine",
	vy: "vy",
	vyper: "vy",
	wasm: "wasm",
	wenyan: "wy",
	wgsl: "wgsl",
	wiki: "wiki",
	wikitext: "wiki",
	wit: "wit",
	wl: "wl",
	wolfram: "wl",
	xml: "xml",
	xsl: "xsl",
	yaml: "yaml",
	yml: "yml",
	zenscript: "zs",
	zig: "zig",
	zsh: "zsh",
	文言: "wy"
}, Oe = ({ onDownload: e, onError: t, language: n, children: r, className: i, code: a, ...o }) => {
	let s = U(), { code: c } = _e(), { isAnimating: l } = C($), u = X(), d = Y(), f = a ?? c, p = `file.${n && n in De ? De[n] : "txt"}`;
	return k("button", {
		className: s("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50", i),
		"data-streamdown": "code-block-download-button",
		disabled: l,
		onClick: () => {
			try {
				H(p, f, "text/plain"), e?.();
			} catch (e) {
				t?.(e);
			}
		},
		title: u.downloadFile,
		type: "button",
		...o,
		children: r ?? k(d.DownloadIcon, { size: 14 })
	});
}, ke = () => {
	let { Loader2Icon: e } = Y(), t = U();
	return A("div", {
		className: t("w-full divide-y divide-border overflow-hidden rounded-xl border border-border"),
		children: [k("div", { className: t("h-[46px] w-full bg-muted/80") }), k("div", {
			className: t("flex w-full items-center justify-center p-4"),
			children: k(e, { className: t("size-4 animate-spin") })
		})]
	});
}, Ae = /\.[^/.]+$/, je = ({ node: e, className: t, src: n, alt: r, onLoad: i, onError: a, ...o }) => {
	let { DownloadIcon: s } = Y(), c = U(), l = E(null), [u, d] = D(!1), [f, p] = D(!1), m = X(), h = o.width != null || o.height != null, g = (u || h) && !f, _ = f && !h;
	w(() => {
		let e = l.current;
		if (e != null && e.complete) {
			let t = e.naturalWidth > 0;
			d(t), p(!t);
		}
	}, []);
	let v = S((e) => {
		d(!0), p(!1), i?.(e);
	}, [i]), y = S((e) => {
		d(!1), p(!0), a?.(e);
	}, [a]), b = async () => {
		if (n) try {
			let e = await (await fetch(n)).blob(), t = new URL(n, window.location.origin).pathname.split("/").pop() || "", i = t.split(".").pop(), a = t.includes(".") && i !== void 0 && i.length <= 4, o = "";
			if (a) o = t;
			else {
				let n = e.type, i = "png";
				n.includes("jpeg") || n.includes("jpg") ? i = "jpg" : n.includes("png") ? i = "png" : n.includes("svg") ? i = "svg" : n.includes("gif") ? i = "gif" : n.includes("webp") && (i = "webp"), o = `${(r || t || "image").replace(Ae, "")}.${i}`;
			}
			H(o, e, e.type);
		} catch {
			window.open(n, "_blank");
		}
	};
	return n ? A("div", {
		className: c("group relative my-4 inline-block"),
		"data-streamdown": "image-wrapper",
		children: [
			k("img", {
				alt: r,
				className: c("max-w-full rounded-lg", _ && "hidden", t),
				"data-streamdown": "image",
				onError: y,
				onLoad: v,
				ref: l,
				src: n,
				...o
			}),
			_ && k("span", {
				className: c("text-muted-foreground text-xs italic"),
				"data-streamdown": "image-fallback",
				children: m.imageNotAvailable
			}),
			k("div", { className: c("pointer-events-none absolute inset-0 hidden rounded-lg bg-black/10 group-hover:block") }),
			g && k("button", {
				className: c("absolute right-2 bottom-2 flex h-8 w-8 cursor-pointer items-center justify-center rounded-md border border-border bg-background/90 shadow-sm backdrop-blur-sm transition-all duration-200 hover:bg-background", "opacity-0 group-hover:opacity-100"),
				onClick: b,
				title: m.downloadImage,
				type: "button",
				children: k(s, { size: 14 })
			})
		]
	}) : null;
}, Z = 0, Me = () => {
	Z += 1, Z === 1 && (document.body.style.overflow = "hidden");
}, Ne = () => {
	Z = Math.max(0, Z - 1), Z === 0 && (document.body.style.overflow = "");
}, Pe = ({ url: e, isOpen: t, onClose: n, onConfirm: r }) => {
	let { CheckIcon: i, CopyIcon: a, ExternalLinkIcon: o, XIcon: s } = Y(), c = U(), [l, u] = D(!1), d = X(), f = S(async () => {
		try {
			await navigator.clipboard.writeText(e), u(!0), setTimeout(() => u(!1), 2e3);
		} catch {}
	}, [e]), p = S(() => {
		r(), n();
	}, [r, n]);
	return w(() => {
		if (t) {
			Me();
			let e = (e) => {
				e.key === "Escape" && n();
			};
			return document.addEventListener("keydown", e), () => {
				document.removeEventListener("keydown", e), Ne();
			};
		}
	}, [t, n]), t ? k("div", {
		className: c("fixed inset-0 z-50 flex items-center justify-center bg-background/50 backdrop-blur-sm"),
		"data-streamdown": "link-safety-modal",
		onClick: n,
		onKeyDown: (e) => {
			e.key === "Escape" && n();
		},
		role: "button",
		tabIndex: 0,
		children: A("div", {
			className: c("relative mx-4 flex w-full max-w-md flex-col gap-4 rounded-xl border bg-background p-6 shadow-lg"),
			onClick: (e) => e.stopPropagation(),
			onKeyDown: (e) => e.stopPropagation(),
			role: "presentation",
			children: [
				k("button", {
					className: c("absolute top-4 right-4 rounded-md p-1 text-muted-foreground transition-all hover:bg-muted hover:text-foreground"),
					onClick: n,
					title: d.close,
					type: "button",
					children: k(s, { size: 16 })
				}),
				A("div", {
					className: c("flex flex-col gap-2"),
					children: [A("div", {
						className: c("flex items-center gap-2 font-semibold text-lg"),
						children: [k(o, { size: 20 }), k("span", { children: d.openExternalLink })]
					}), k("p", {
						className: c("text-muted-foreground text-sm"),
						children: d.externalLinkWarning
					})]
				}),
				k("div", {
					className: c("break-all rounded-md bg-muted p-3 font-mono text-sm", e.length > 100 && "max-h-32 overflow-y-auto"),
					children: e
				}),
				A("div", {
					className: c("flex gap-2"),
					children: [k("button", {
						className: c("flex flex-1 items-center justify-center gap-2 rounded-md border bg-background px-4 py-2 font-medium text-sm transition-all hover:bg-muted"),
						onClick: f,
						type: "button",
						children: l ? A(O, { children: [k(i, { size: 14 }), k("span", { children: d.copied })] }) : A(O, { children: [k(a, { size: 14 }), k("span", { children: d.copyLink })] })
					}), A("button", {
						className: c("flex flex-1 items-center justify-center gap-2 rounded-md bg-primary px-4 py-2 font-medium text-primary-foreground text-sm transition-all hover:bg-primary/90"),
						onClick: p,
						type: "button",
						children: [k(o, { size: 14 }), k("span", { children: d.openLink })]
					})]
				})
			]
		})
	}) : null;
}, Fe = _(null), Ie = () => C(Fe), Le = () => Ie()?.code ?? null, Re = () => Ie()?.mermaid ?? null, ze = (e) => {
	var t;
	let n = Ie();
	return n != null && n.renderers && e && (t = n.renderers.find((t) => Array.isArray(t.language) ? t.language.includes(e) : t.language === e)) != null ? t : null;
}, Be = (e, t) => new Promise((t, n) => {
	let r = "data:image/svg+xml;base64," + btoa(unescape(encodeURIComponent(e))), i = new Image();
	i.crossOrigin = "anonymous", i.onload = () => {
		let e = document.createElement("canvas"), r = i.width * 5, a = i.height * 5;
		e.width = r, e.height = a;
		let o = e.getContext("2d");
		if (!o) {
			n(/* @__PURE__ */ Error("Failed to create 2D canvas context for PNG export"));
			return;
		}
		o.drawImage(i, 0, 0, r, a), e.toBlob((e) => {
			if (!e) {
				n(/* @__PURE__ */ Error("Failed to create PNG blob"));
				return;
			}
			t(e);
		}, "image/png");
	}, i.onerror = () => n(/* @__PURE__ */ Error("Failed to load SVG image")), i.src = r;
}), Ve = ({ chart: e, children: t, className: n, onDownload: r, config: i, onError: a }) => {
	let o = U(), [s, c] = D(!1), l = E(null), { isAnimating: u } = C($), d = Y(), f = Re(), p = X(), m = async (t) => {
		try {
			if (t === "mmd") {
				H("diagram.mmd", e, "text/plain"), c(!1), r?.(t);
				return;
			}
			if (!f) {
				a?.(/* @__PURE__ */ Error("Mermaid plugin not available"));
				return;
			}
			let n = f.getMermaid(i), o = e.split("").reduce((e, t) => (e << 5) - e + t.charCodeAt(0) | 0, 0), s = `mermaid-${Math.abs(o)}-${Date.now()}-${Math.random().toString(36).substring(2, 9)}`, { svg: l } = await n.render(s, e);
			if (!l) {
				a?.(/* @__PURE__ */ Error("SVG not found. Please wait for the diagram to render."));
				return;
			}
			if (t === "svg") {
				H("diagram.svg", l, "image/svg+xml"), c(!1), r?.(t);
				return;
			}
			if (t === "png") {
				H("diagram.png", await Be(l), "image/png"), r?.(t), c(!1);
				return;
			}
		} catch (e) {
			a?.(e);
		}
	};
	return w(() => {
		let e = (e) => {
			let t = e.composedPath();
			l.current && !t.includes(l.current) && c(!1);
		};
		return document.addEventListener("mousedown", e), () => {
			document.removeEventListener("mousedown", e);
		};
	}, []), A("div", {
		className: o("relative"),
		ref: l,
		children: [k("button", {
			className: o("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50", n),
			disabled: u,
			onClick: () => c(!s),
			title: p.downloadDiagram,
			type: "button",
			children: t ?? k(d.DownloadIcon, { size: 14 })
		}), s ? A("div", {
			className: o("absolute top-full right-0 z-10 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg"),
			children: [
				k("button", {
					className: o("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),
					onClick: () => m("svg"),
					title: p.downloadDiagramAsSvg,
					type: "button",
					children: p.mermaidFormatSvg
				}),
				k("button", {
					className: o("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),
					onClick: () => m("png"),
					title: p.downloadDiagramAsPng,
					type: "button",
					children: p.mermaidFormatPng
				}),
				k("button", {
					className: o("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),
					onClick: () => m("mmd"),
					title: p.downloadDiagramAsMmd,
					type: "button",
					children: p.mermaidFormatMmd
				})
			]
		}) : null]
	});
}, He = ({ chart: e, config: t, onFullscreen: n, onExit: r, className: i, ...a }) => {
	let { Maximize2Icon: o, XIcon: s } = Y(), c = U(), [l, u] = D(!1), { isAnimating: d, controls: f } = C($), p = X(), m = (() => {
		if (typeof f == "boolean") return f;
		let e = f.mermaid;
		return e === !1 ? !1 : e === !0 || e === void 0 ? !0 : e.panZoom !== !1;
	})(), h = () => {
		u(!l);
	};
	return w(() => {
		if (l) {
			Me();
			let e = (e) => {
				e.key === "Escape" && u(!1);
			};
			return document.addEventListener("keydown", e), () => {
				document.removeEventListener("keydown", e), Ne();
			};
		}
	}, [l]), w(() => {
		l ? n?.() : r && r();
	}, [
		l,
		n,
		r
	]), A(O, { children: [k("button", {
		className: c("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50", i),
		disabled: d,
		onClick: h,
		title: p.viewFullscreen,
		type: "button",
		...a,
		children: k(o, { size: 14 })
	}), l ? N(A("div", {
		className: c("fixed inset-0 z-50 flex items-center justify-center bg-background/95 backdrop-blur-sm"),
		onClick: h,
		onKeyDown: (e) => {
			e.key === "Escape" && h();
		},
		role: "button",
		tabIndex: 0,
		children: [k("button", {
			className: c("absolute top-4 right-4 z-10 rounded-md p-2 text-muted-foreground transition-all hover:bg-muted hover:text-foreground"),
			onClick: h,
			title: p.exitFullscreen,
			type: "button",
			children: k(s, { size: 20 })
		}), k("div", {
			className: c("flex size-full items-center justify-center p-4"),
			onClick: (e) => e.stopPropagation(),
			onKeyDown: (e) => e.stopPropagation(),
			role: "presentation",
			children: k(Pn, {
				chart: e,
				className: c("size-full [&_svg]:h-auto [&_svg]:w-auto"),
				config: t,
				fullscreen: !0,
				showControls: m
			})
		})]
	}), document.body) : null] });
}, Ue = (e) => {
	let t = [], n = [], r = e.querySelectorAll("thead th");
	for (let e of r) t.push(e.textContent?.trim() || "");
	let i = e.querySelectorAll("tbody tr");
	for (let e of i) {
		let t = [], r = e.querySelectorAll("td");
		for (let e of r) t.push(e.textContent?.trim() || "");
		n.push(t);
	}
	return {
		headers: t,
		rows: n
	};
}, We = (e) => {
	let { headers: t, rows: n } = e, r = (e) => {
		let t = !1, n = !1;
		for (let r of e) {
			if (r === "\"") {
				t = !0, n = !0;
				break;
			}
			(r === "," || r === "\n") && (t = !0);
		}
		return t ? n ? `"${e.replace(/"/g, "\"\"")}"` : `"${e}"` : e;
	}, i = t.length > 0 ? n.length + 1 : n.length, a = Array(i), o = 0;
	t.length > 0 && (a[o] = t.map(r).join(","), o += 1);
	for (let e of n) a[o] = e.map(r).join(","), o += 1;
	return a.join("\n");
}, Ge = (e) => {
	let { headers: t, rows: n } = e, r = (e) => {
		let t = !1;
		for (let n of e) if (n === "	" || n === "\n" || n === "\r") {
			t = !0;
			break;
		}
		if (!t) return e;
		let n = [];
		for (let t of e) t === "	" ? n.push("\\t") : t === "\n" ? n.push("\\n") : t === "\r" ? n.push("\\r") : n.push(t);
		return n.join("");
	}, i = t.length > 0 ? n.length + 1 : n.length, a = Array(i), o = 0;
	t.length > 0 && (a[o] = t.map(r).join("	"), o += 1);
	for (let e of n) a[o] = e.map(r).join("	"), o += 1;
	return a.join("\n");
}, Ke = (e) => {
	let t = !1;
	for (let n of e) if (n === "\\" || n === "|") {
		t = !0;
		break;
	}
	if (!t) return e;
	let n = [];
	for (let t of e) t === "\\" ? n.push("\\\\") : t === "|" ? n.push("\\|") : n.push(t);
	return n.join("");
}, qe = (e) => {
	let { headers: t, rows: n } = e;
	if (t.length === 0) return "";
	let r = Array(n.length + 2), i = 0;
	r[i] = `| ${t.map((e) => Ke(e)).join(" | ")} |`, i += 1;
	let a = Array(t.length);
	for (let e = 0; e < t.length; e += 1) a[e] = "---";
	r[i] = `| ${a.join(" | ")} |`, i += 1;
	for (let e of n) if (e.length < t.length) {
		let n = Array(t.length);
		for (let r = 0; r < t.length; r += 1) n[r] = r < e.length ? Ke(e[r]) : "";
		r[i] = `| ${n.join(" | ")} |`, i += 1;
	} else r[i] = `| ${e.map((e) => Ke(e)).join(" | ")} |`, i += 1;
	return r.join("\n");
}, Je = ({ children: e, className: t, onCopy: n, onError: r, timeout: i = 2e3 }) => {
	let a = U(), [o, s] = D(!1), [c, l] = D(!1), u = E(null), d = E(0), { isAnimating: f } = C($), p = X(), m = async (e) => {
		var t;
		if (typeof window > "u" || !((t = navigator == null ? void 0 : navigator.clipboard) != null && t.write)) {
			r?.(/* @__PURE__ */ Error("Clipboard API not available"));
			return;
		}
		try {
			let t = (u.current?.closest("[data-streamdown=\"table-wrapper\"]"))?.querySelector("table");
			if (!t) {
				r?.(/* @__PURE__ */ Error("Table not found"));
				return;
			}
			let a = Ue(t), o = ({
				csv: We,
				tsv: Ge,
				md: qe
			}[e] || qe)(a), c = new ClipboardItem({
				"text/plain": new Blob([o], { type: "text/plain" }),
				"text/html": new Blob([t.outerHTML], { type: "text/html" })
			});
			await navigator.clipboard.write([c]), l(!0), s(!1), n?.(e), d.current = window.setTimeout(() => l(!1), i);
		} catch (e) {
			r?.(e);
		}
	};
	w(() => {
		let e = (e) => {
			let t = e.composedPath();
			u.current && !t.includes(u.current) && s(!1);
		};
		return document.addEventListener("mousedown", e), () => {
			document.removeEventListener("mousedown", e), window.clearTimeout(d.current);
		};
	}, []);
	let h = Y(), g = c ? h.CheckIcon : h.CopyIcon;
	return A("div", {
		className: a("relative"),
		ref: u,
		children: [k("button", {
			className: a("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50", t),
			disabled: f,
			onClick: () => s(!o),
			title: p.copyTable,
			type: "button",
			children: e ?? k(g, {
				height: 14,
				width: 14
			})
		}), o ? A("div", {
			className: a("absolute top-full right-0 z-20 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg"),
			children: [
				k("button", {
					className: a("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),
					onClick: () => m("md"),
					title: p.copyTableAsMarkdown,
					type: "button",
					children: p.tableFormatMarkdown
				}),
				k("button", {
					className: a("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),
					onClick: () => m("csv"),
					title: p.copyTableAsCsv,
					type: "button",
					children: p.tableFormatCsv
				}),
				k("button", {
					className: a("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),
					onClick: () => m("tsv"),
					title: p.copyTableAsTsv,
					type: "button",
					children: p.tableFormatTsv
				})
			]
		}) : null]
	});
}, Ye = ({ children: e, className: t, onDownload: n, onError: r }) => {
	let i = U(), [a, o] = D(!1), s = E(null), { isAnimating: c } = C($), l = X(), u = Y(), d = (e) => {
		try {
			let t = (s.current?.closest("[data-streamdown=\"table-wrapper\"]"))?.querySelector("table");
			if (!t) {
				r?.(/* @__PURE__ */ Error("Table not found"));
				return;
			}
			let i = Ue(t), a = e === "csv" ? We(i) : qe(i);
			H(`table.${e === "csv" ? "csv" : "md"}`, a, e === "csv" ? "text/csv" : "text/markdown"), o(!1), n?.(e);
		} catch (e) {
			r?.(e);
		}
	};
	return w(() => {
		let e = (e) => {
			let t = e.composedPath();
			s.current && !t.includes(s.current) && o(!1);
		};
		return document.addEventListener("mousedown", e), () => {
			document.removeEventListener("mousedown", e);
		};
	}, []), A("div", {
		className: i("relative"),
		ref: s,
		children: [k("button", {
			className: i("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50", t),
			disabled: c,
			onClick: () => o(!a),
			title: l.downloadTable,
			type: "button",
			children: e ?? k(u.DownloadIcon, { size: 14 })
		}), a ? A("div", {
			className: i("absolute top-full right-0 z-20 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg"),
			children: [k("button", {
				className: i("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),
				onClick: () => d("csv"),
				title: l.downloadTableAsCsv,
				type: "button",
				children: l.tableFormatCsv
			}), k("button", {
				className: i("w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40"),
				onClick: () => d("markdown"),
				title: l.downloadTableAsMarkdown,
				type: "button",
				children: l.tableFormatMarkdown
			})]
		}) : null]
	});
}, Xe = ({ children: e, className: t, showCopy: n = !0, showDownload: r = !0 }) => {
	let { Maximize2Icon: i, XIcon: a } = Y(), o = U(), [s, c] = D(!1), { isAnimating: l } = C($), u = X(), d = () => {
		c(!0);
	}, f = () => {
		c(!1);
	};
	return w(() => {
		if (s) {
			Me();
			let e = (e) => {
				e.key === "Escape" && c(!1);
			};
			return document.addEventListener("keydown", e), () => {
				document.removeEventListener("keydown", e), Ne();
			};
		}
	}, [s]), A(O, { children: [k("button", {
		className: o("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50", t),
		disabled: l,
		onClick: d,
		title: u.viewFullscreen,
		type: "button",
		children: k(i, { size: 14 })
	}), s ? N(k("div", {
		"aria-label": u.viewFullscreen,
		"aria-modal": "true",
		className: o("fixed inset-0 z-50 flex flex-col bg-background"),
		"data-streamdown": "table-fullscreen",
		onClick: f,
		onKeyDown: (e) => {
			e.key === "Escape" && f();
		},
		role: "dialog",
		children: A("div", {
			className: o("flex h-full flex-col"),
			onClick: (e) => e.stopPropagation(),
			onKeyDown: (e) => e.stopPropagation(),
			role: "presentation",
			children: [A("div", {
				className: o("flex items-center justify-end gap-1 p-4"),
				children: [
					n ? k(Je, {}) : null,
					r ? k(Ye, {}) : null,
					k("button", {
						className: o("rounded-md p-1 text-muted-foreground transition-all hover:bg-muted hover:text-foreground"),
						onClick: f,
						title: u.exitFullscreen,
						type: "button",
						children: k(a, { size: 20 })
					})
				]
			}), k("div", {
				className: o("flex-1 overflow-auto p-4 pt-0 [&_thead]:sticky [&_thead]:top-0 [&_thead]:z-10"),
				children: k("table", {
					className: o("w-full border-collapse border border-border"),
					"data-streamdown": "table",
					children: e
				})
			})]
		})
	}), document.body) : null] });
}, Ze = ({ children: e, className: t, showControls: n, showCopy: r = !0, showDownload: i = !0, showFullscreen: a = !0, ...o }) => {
	let s = U(), c = n && r, l = n && i, u = n && a, d = c || l || u;
	return A("div", {
		className: s("my-4 flex flex-col gap-2 rounded-lg border border-border bg-sidebar p-2"),
		"data-streamdown": "table-wrapper",
		children: [d ? A("div", {
			className: s("flex items-center justify-end gap-1"),
			children: [
				c ? k(Je, {}) : null,
				l ? k(Ye, {}) : null,
				u ? k(Xe, {
					showCopy: c,
					showDownload: l,
					children: e
				}) : null
			]
		}) : null, k("div", {
			className: s("border-collapse overflow-x-auto overflow-y-auto rounded-md border border-border bg-background"),
			children: k("table", {
				className: s("w-full divide-y divide-border", t),
				"data-streamdown": "table",
				...o,
				children: e
			})
		})]
	});
}, Qe = /startLine=(\d+)/, $e = /\bnoLineNumbers\b/, et = b(() => import("./mermaid-GHXKKRXX.js").then((e) => ({ default: e.Mermaid }))), tt = /language-([^\s]+)/;
function nt(e, t) {
	if (!(e != null && e.position || t != null && t.position)) return !0;
	if (!(e != null && e.position && t != null && t.position)) return !1;
	let n = e.position.start, r = t.position.start, i = e.position.end, a = t.position.end;
	return n?.line === r?.line && n?.column === r?.column && i?.line === a?.line && i?.column === a?.column;
}
function Q(e, t) {
	return e.className === t.className && nt(e.node, t.node);
}
var rt = (e, t) => typeof e == "boolean" ? e : e[t] !== !1, it = (e, t) => {
	if (typeof e == "boolean") return e;
	let n = e.table;
	return n === !1 ? !1 : n === !0 || n === void 0 ? !0 : n[t] !== !1;
}, at = (e, t) => {
	if (typeof e == "boolean") return e;
	let n = e.code;
	return n === !1 ? !1 : n === !0 || n === void 0 ? !0 : n[t] !== !1;
}, ot = (e, t) => {
	if (typeof e == "boolean") return e;
	let n = e.mermaid;
	return n === !1 ? !1 : n === !0 || n === void 0 ? !0 : n[t] !== !1;
}, st = x(({ children: e, className: t, node: n, ...r }) => k("ol", {
	className: U()("list-inside list-decimal whitespace-normal [li_&]:pl-6", t),
	"data-streamdown": "ordered-list",
	...r,
	children: e
}), (e, t) => Q(e, t));
st.displayName = "MarkdownOl";
var ct = x(({ children: e, className: t, node: n, ...r }) => k("li", {
	className: U()("py-1 [&>p]:inline", t),
	"data-streamdown": "list-item",
	...r,
	children: e
}), (e, t) => e.className === t.className && nt(e.node, t.node));
ct.displayName = "MarkdownLi";
var lt = x(({ children: e, className: t, node: n, ...r }) => k("ul", {
	className: U()("list-inside list-disc whitespace-normal [li_&]:pl-6", t),
	"data-streamdown": "unordered-list",
	...r,
	children: e
}), (e, t) => Q(e, t));
lt.displayName = "MarkdownUl";
var ut = x(({ className: e, node: t, ...n }) => k("hr", {
	className: U()("my-6 border-border", e),
	"data-streamdown": "horizontal-rule",
	...n
}), (e, t) => Q(e, t));
ut.displayName = "MarkdownHr";
var dt = x(({ children: e, className: t, node: n, ...r }) => k("span", {
	className: U()("font-semibold", t),
	"data-streamdown": "strong",
	...r,
	children: e
}), (e, t) => Q(e, t));
dt.displayName = "MarkdownStrong";
var ft = x(({ children: e, className: t, href: n, node: r, ...i }) => {
	let a = U(), { linkSafety: o } = C($), [s, c] = D(!1), l = n === "streamdown:incomplete-link", u = S(async (e) => {
		if (!(!(o != null && o.enabled && n) || l)) {
			if (e.preventDefault(), o.onLinkCheck && await o.onLinkCheck(n)) {
				window.open(n, "_blank", "noreferrer");
				return;
			}
			c(!0);
		}
	}, [
		o,
		n,
		l
	]), d = S(() => {
		n && window.open(n, "_blank", "noreferrer");
	}, [n]), f = S(() => {
		c(!1);
	}, []), p = {
		url: n ?? "",
		isOpen: s,
		onClose: f,
		onConfirm: d
	};
	return o != null && o.enabled && n ? A(O, { children: [k("button", {
		className: a("wrap-anywhere appearance-none text-left font-medium text-primary underline", t),
		"data-incomplete": l,
		"data-streamdown": "link",
		onClick: u,
		type: "button",
		children: e
	}), o.renderModal ? o.renderModal(p) : k(Pe, { ...p })] }) : k("a", {
		className: a("wrap-anywhere font-medium text-primary underline", t),
		"data-incomplete": l,
		"data-streamdown": "link",
		href: n,
		rel: "noreferrer",
		target: "_blank",
		...i,
		children: e
	});
}, (e, t) => Q(e, t) && e.href === t.href);
ft.displayName = "MarkdownA";
var pt = x(({ children: e, className: t, node: n, ...r }) => k("h1", {
	className: U()("mt-6 mb-2 font-semibold text-3xl", t),
	"data-streamdown": "heading-1",
	...r,
	children: e
}), (e, t) => Q(e, t));
pt.displayName = "MarkdownH1";
var mt = x(({ children: e, className: t, node: n, ...r }) => k("h2", {
	className: U()("mt-6 mb-2 font-semibold text-2xl", t),
	"data-streamdown": "heading-2",
	...r,
	children: e
}), (e, t) => Q(e, t));
mt.displayName = "MarkdownH2";
var ht = x(({ children: e, className: t, node: n, ...r }) => k("h3", {
	className: U()("mt-6 mb-2 font-semibold text-xl", t),
	"data-streamdown": "heading-3",
	...r,
	children: e
}), (e, t) => Q(e, t));
ht.displayName = "MarkdownH3";
var gt = x(({ children: e, className: t, node: n, ...r }) => k("h4", {
	className: U()("mt-6 mb-2 font-semibold text-lg", t),
	"data-streamdown": "heading-4",
	...r,
	children: e
}), (e, t) => Q(e, t));
gt.displayName = "MarkdownH4";
var _t = x(({ children: e, className: t, node: n, ...r }) => k("h5", {
	className: U()("mt-6 mb-2 font-semibold text-base", t),
	"data-streamdown": "heading-5",
	...r,
	children: e
}), (e, t) => Q(e, t));
_t.displayName = "MarkdownH5";
var vt = x(({ children: e, className: t, node: n, ...r }) => k("h6", {
	className: U()("mt-6 mb-2 font-semibold text-sm", t),
	"data-streamdown": "heading-6",
	...r,
	children: e
}), (e, t) => Q(e, t));
vt.displayName = "MarkdownH6";
var yt = x(({ children: e, className: t, node: n, ...r }) => {
	let { controls: i } = C($);
	return k(Ze, {
		className: t,
		showControls: rt(i, "table"),
		showCopy: it(i, "copy"),
		showDownload: it(i, "download"),
		showFullscreen: it(i, "fullscreen"),
		...r,
		children: e
	});
}, (e, t) => Q(e, t));
yt.displayName = "MarkdownTable";
var bt = x(({ children: e, className: t, node: n, ...r }) => k("thead", {
	className: U()("bg-muted/80", t),
	"data-streamdown": "table-header",
	...r,
	children: e
}), (e, t) => Q(e, t));
bt.displayName = "MarkdownThead";
var xt = x(({ children: e, className: t, node: n, ...r }) => k("tbody", {
	className: U()("divide-y divide-border", t),
	"data-streamdown": "table-body",
	...r,
	children: e
}), (e, t) => Q(e, t));
xt.displayName = "MarkdownTbody";
var St = x(({ children: e, className: t, node: n, ...r }) => k("tr", {
	className: U()("border-border", t),
	"data-streamdown": "table-row",
	...r,
	children: e
}), (e, t) => Q(e, t));
St.displayName = "MarkdownTr";
var Ct = x(({ children: e, className: t, node: n, ...r }) => k("th", {
	className: U()("whitespace-nowrap px-4 py-2 text-left font-semibold text-sm", t),
	"data-streamdown": "table-header-cell",
	...r,
	children: e
}), (e, t) => Q(e, t));
Ct.displayName = "MarkdownTh";
var wt = x(({ children: e, className: t, node: n, ...r }) => k("td", {
	className: U()("px-4 py-2 text-sm", t),
	"data-streamdown": "table-cell",
	...r,
	children: e
}), (e, t) => Q(e, t));
wt.displayName = "MarkdownTd";
var Tt = x(({ children: e, className: t, node: n, ...r }) => k("blockquote", {
	className: U()("my-4 border-muted-foreground/30 border-l-4 pl-4 text-muted-foreground italic", t),
	"data-streamdown": "blockquote",
	...r,
	children: e
}), (e, t) => Q(e, t));
Tt.displayName = "MarkdownBlockquote";
var Et = x(({ children: e, className: t, node: n, ...r }) => k("sup", {
	className: U()("text-sm", t),
	"data-streamdown": "superscript",
	...r,
	children: e
}), (e, t) => Q(e, t));
Et.displayName = "MarkdownSup";
var Dt = x(({ children: e, className: t, node: n, ...r }) => k("sub", {
	className: U()("text-sm", t),
	"data-streamdown": "subscript",
	...r,
	children: e
}), (e, t) => Q(e, t));
Dt.displayName = "MarkdownSub";
var Ot = x(({ children: e, className: t, node: n, ...r }) => {
	if ("data-footnotes" in r) {
		let n = (e) => {
			if (!y(e)) return !1;
			let t = Array.isArray(e.props.children) ? e.props.children : [e.props.children], n = !1, r = !1;
			for (let e of t) if (e) {
				if (typeof e == "string") e.trim() !== "" && (n = !0);
				else if (y(e)) if (e.props?.["data-footnote-backref"] !== void 0) r = !0;
				else {
					let t = Array.isArray(e.props.children) ? e.props.children : [e.props.children];
					for (let e of t) {
						if (typeof e == "string" && e.trim() !== "") {
							n = !0;
							break;
						}
						if (y(e) && e.props?.["data-footnote-backref"] === void 0) {
							n = !0;
							break;
						}
					}
				}
			}
			return r && !n;
		}, i = Array.isArray(e) ? e.map((e) => {
			if (!y(e)) return e;
			if (e.type === st) {
				let t = (Array.isArray(e.props.children) ? e.props.children : [e.props.children]).filter((e) => !n(e));
				return t.length === 0 ? null : {
					...e,
					props: {
						...e.props,
						children: t
					}
				};
			}
			return e;
		}) : e;
		return (Array.isArray(i) ? i.some((e) => e !== null) : i !== null) ? k("section", {
			className: t,
			...r,
			children: i
		}) : null;
	}
	return k("section", {
		className: t,
		...r,
		children: e
	});
}, (e, t) => Q(e, t));
Ot.displayName = "MarkdownSection";
var kt = x(({ node: e, className: t, children: n, ...r }) => {
	let i = U(), a = !("data-block" in r), { mermaid: o, controls: s, lineNumbers: c } = C($), l = Re(), u = de(), d = (t?.match(tt))?.at(1) ?? "", f = ze(d);
	if (a) return k("code", {
		className: i("rounded bg-muted px-1.5 py-0.5 font-mono text-sm", t),
		"data-streamdown": "inline-code",
		...r,
		children: n
	});
	let p = e?.properties?.metastring, m = p?.match(Qe), g = m ? Number.parseInt(m[1], 10) : void 0, _ = g !== void 0 && g >= 1 ? g : void 0, v = !(p && $e.test(p)) && c !== !1, b = "";
	if (y(n) && n.props && typeof n.props == "object" && "children" in n.props && typeof n.props.children == "string" ? b = n.props.children : typeof n == "string" && (b = n), f) {
		let e = f.component;
		return k(h, {
			fallback: k(ke, {}),
			children: k(e, {
				code: b,
				isIncomplete: u,
				language: d,
				meta: p
			})
		});
	}
	if (d === "mermaid" && l) {
		let e = rt(s, "mermaid"), n = ot(s, "download"), r = ot(s, "copy"), a = ot(s, "fullscreen"), c = ot(s, "panZoom"), l = e && (n || r || a);
		return k(h, {
			fallback: k(ke, {}),
			children: A("div", {
				className: i("group relative my-4 flex w-full flex-col gap-2 rounded-xl border border-border bg-sidebar p-2", t),
				"data-streamdown": "mermaid-block",
				children: [
					k("div", {
						className: i("flex h-8 items-center text-muted-foreground text-xs"),
						children: k("span", {
							className: i("ml-1 font-mono lowercase"),
							children: "mermaid"
						})
					}),
					l ? k("div", {
						className: i("pointer-events-none sticky top-2 z-10 -mt-10 flex h-8 items-center justify-end"),
						children: A("div", {
							className: i("pointer-events-auto flex shrink-0 items-center gap-2 rounded-md border border-sidebar bg-sidebar/80 px-1.5 py-1 supports-[backdrop-filter]:bg-sidebar/70 supports-[backdrop-filter]:backdrop-blur"),
							"data-streamdown": "mermaid-block-actions",
							children: [
								n ? k(Ve, {
									chart: b,
									config: o?.config
								}) : null,
								r ? k(Ee, { code: b }) : null,
								a ? k(He, {
									chart: b,
									config: o?.config
								}) : null
							]
						})
					}) : null,
					k("div", {
						className: i("rounded-md border border-border bg-background"),
						children: k(et, {
							chart: b,
							config: o?.config,
							showControls: c
						})
					})
				]
			})
		});
	}
	let x = rt(s, "code"), S = at(s, "download"), w = at(s, "copy");
	return k(be, {
		className: t,
		code: b,
		isIncomplete: u,
		language: d,
		lineNumbers: v,
		startLine: _,
		children: x ? A(O, { children: [S ? k(Oe, {
			code: b,
			language: d
		}) : null, w ? k(Ee, {}) : null] }) : null
	});
}, (e, t) => e.className === t.className && nt(e.node, t.node));
kt.displayName = "MarkdownCode";
var At = x(je, (e, t) => e.className === t.className && nt(e.node, t.node));
At.displayName = "MarkdownImg";
var jt = x(({ children: e, node: t, ...n }) => {
	let r = (Array.isArray(e) ? e : [e]).filter((e) => e != null && e !== "");
	if (r.length === 1 && y(r[0])) {
		let t = r[0].props.node?.tagName;
		if (t === "img" || t === "code" && "data-block" in r[0].props) return k(O, { children: e });
	}
	return k("p", {
		...n,
		children: e
	});
}, (e, t) => Q(e, t));
jt.displayName = "MarkdownParagraph";
var Mt = {
	ol: st,
	li: ct,
	ul: lt,
	hr: ut,
	strong: dt,
	a: ft,
	h1: pt,
	h2: mt,
	h3: ht,
	h4: gt,
	h5: _t,
	h6: vt,
	table: yt,
	thead: bt,
	tbody: xt,
	tr: St,
	th: Ct,
	td: wt,
	blockquote: Tt,
	code: kt,
	img: At,
	pre: ({ children: e }) => y(e) ? g(e, { "data-block": "true" }) : e,
	sup: Et,
	sub: Dt,
	p: jt,
	section: Ot
}, Nt = /[\u0590-\u08FF\uFB1D-\uFDFF\uFE70-\uFEFF]/, Pt = /\p{L}/u;
function Ft(e) {
	let t = e.replace(/^#{1,6}\s+/gm, "").replace(/(\*{1,3}|_{1,3})/g, "").replace(/`[^`]*`/g, "").replace(/\[([^\]]*)\]\([^)]*\)/g, "$1").replace(/^[\s>*\-+\d.]+/gm, "");
	for (let e of t) {
		if (Nt.test(e)) return "rtl";
		if (Pt.test(e)) return "ltr";
	}
	return "ltr";
}
var It = /^[ \t]{0,3}(`{3,}|~{3,})/, Lt = /^\|?[ \t]*:?-{1,}:?[ \t]*(\|[ \t]*:?-{1,}:?[ \t]*)*\|?$/, Rt = (e) => {
	let t = e.split("\n"), n = null, r = 0;
	for (let e of t) {
		let t = It.exec(e);
		if (n === null) {
			if (t) {
				let e = t[1];
				n = e[0], r = e.length;
			}
		} else if (t) {
			let e = t[1], i = e[0], a = e.length;
			i === n && a >= r && (n = null, r = 0);
		}
	}
	return n !== null;
}, zt = (e) => {
	let t = e.split("\n");
	for (let e of t) {
		let t = e.trim();
		if (t.length > 0 && t.includes("|") && Lt.test(t)) return !0;
	}
	return !1;
}, Bt = () => (e) => {
	n(e, "html", (e, t, n) => {
		!n || typeof t != "number" || (n.children[t] = {
			type: "text",
			value: e.value
		});
	});
}, Vt = [], Ht = { allowDangerousHtml: !0 }, Ut = /* @__PURE__ */ new WeakMap(), Wt = new class {
	constructor() {
		this.cache = /* @__PURE__ */ new Map(), this.keyCache = /* @__PURE__ */ new WeakMap(), this.maxSize = 100;
	}
	generateCacheKey(e) {
		let t = this.keyCache.get(e);
		if (t) return t;
		let n = e.rehypePlugins, r = e.remarkPlugins, i = e.remarkRehypeOptions;
		if (!(n || r || i)) {
			let t = "default";
			return this.keyCache.set(e, t), t;
		}
		let a = (e) => {
			if (!e || e.length === 0) return "";
			let t = "";
			for (let n = 0; n < e.length; n += 1) {
				let r = e[n];
				if (n > 0 && (t += ","), Array.isArray(r)) {
					let [e, n] = r;
					if (typeof e == "function") {
						let n = Ut.get(e);
						n || (n = e.name, Ut.set(e, n)), t += n;
					} else t += String(e);
					t += ":", t += JSON.stringify(n);
				} else if (typeof r == "function") {
					let e = Ut.get(r);
					e || (e = r.name, Ut.set(r, e)), t += e;
				} else t += String(r);
			}
			return t;
		}, o = a(n), s = `${a(r)}::${o}::${i ? JSON.stringify(i) : ""}`;
		return this.keyCache.set(e, s), s;
	}
	get(e) {
		let t = this.generateCacheKey(e), n = this.cache.get(t);
		return n && (this.cache.delete(t), this.cache.set(t, n)), n;
	}
	set(e, t) {
		let n = this.generateCacheKey(e);
		if (this.cache.size >= this.maxSize) {
			let e = this.cache.keys().next().value;
			e && this.cache.delete(e);
		}
		this.cache.set(n, t);
	}
	clear() {
		this.cache.clear();
	}
}(), Gt = (e) => {
	let t = Kt(e), n = e.children || "";
	return $t(t.runSync(t.parse(n), n), e);
}, Kt = (e) => {
	let t = Wt.get(e);
	if (t) return t;
	let n = Jt(e);
	return Wt.set(e, n), n;
}, qt = (e) => e.some((e) => Array.isArray(e) ? e[0] === a : e === a), Jt = (e) => {
	let t = e.rehypePlugins || Vt, n = e.remarkPlugins || Vt, r = qt(t) ? n : [...n, Bt], i = e.remarkRehypeOptions ? {
		...Ht,
		...e.remarkRehypeOptions
	} : Ht;
	return p().use(d).use(r).use(f, i).use(t);
}, Yt = (e) => e, Xt = (e, t, n, r) => {
	n ? e.children.splice(t, 1) : e.children[t] = {
		type: "text",
		value: r
	};
}, Zt = (e, t) => {
	for (let n in u) if (Object.hasOwn(u, n) && Object.hasOwn(e.properties, n)) {
		let r = e.properties[n], i = u[n];
		(i === null || i.includes(e.tagName)) && (e.properties[n] = t(String(r || ""), n, e) ?? void 0);
	}
}, Qt = (e, t, n, r, i, a) => {
	let o = !1;
	return r ? o = !r.includes(e.tagName) : i && (o = i.includes(e.tagName)), !o && a && typeof t == "number" && (o = !a(e, t, n)), o;
}, $t = (e, t) => {
	let { allowElement: r, allowedElements: i, disallowedElements: a, skipHtml: o, unwrapDisallowed: s, urlTransform: c } = t;
	if (r || i || a || o || c) {
		let t = c || Yt;
		n(e, (e, n, c) => {
			if (e.type === "raw" && c && typeof n == "number") return Xt(c, n, o, e.value), n;
			if (e.type === "element" && (Zt(e, t), Qt(e, n, c, i, a, r) && c && typeof n == "number")) return s && e.children ? c.children.splice(n, 1, ...e.children) : c.children.splice(n, 1), n;
		});
	}
	return l(e, {
		Fragment: O,
		components: t.components,
		ignoreInvalidStyle: !0,
		jsx: k,
		jsxs: A,
		passKeys: !0,
		passNode: !0
	});
}, en = /\[\^[\w-]{1,200}\](?!:)/, tn = /\[\^[\w-]{1,200}\]:/, nn = /<(\w+)[\s>]/, rn = new Set([
	"area",
	"base",
	"br",
	"col",
	"embed",
	"hr",
	"img",
	"input",
	"link",
	"meta",
	"param",
	"source",
	"track",
	"wbr"
]), an = /* @__PURE__ */ new Map(), on = /* @__PURE__ */ new Map(), sn = (e) => {
	let t = e.toLowerCase(), n = an.get(t);
	if (n) return n;
	let r = RegExp(`<${t}(?=[\\s>/])[^>]*>`, "gi");
	return an.set(t, r), r;
}, cn = (e) => {
	let t = e.toLowerCase(), n = on.get(t);
	if (n) return n;
	let r = RegExp(`</${t}(?=[\\s>])[^>]*>`, "gi");
	return on.set(t, r), r;
}, ln = (e, t) => {
	if (rn.has(t.toLowerCase())) return 0;
	let n = e.match(sn(t));
	if (!n) return 0;
	let r = 0;
	for (let e of n) e.trimEnd().endsWith("/>") || (r += 1);
	return r;
}, un = (e, t) => {
	let n = e.match(cn(t));
	return n ? n.length : 0;
}, dn = (e) => {
	let t = 0;
	for (let n = 0; n < e.length - 1; n += 1) e[n] === "$" && e[n + 1] === "$" && (t += 1, n += 1);
	return t;
}, fn = (e) => {
	let t = en.test(e), n = tn.test(e);
	if (t || n) return [e];
	let r = m.lex(e, { gfm: !0 }), i = [], a = [], o = !1;
	for (let e of r) {
		let t = e.raw, n = i.length;
		if (a.length > 0) {
			i[n - 1] += t;
			let e = a.at(-1), r = ln(t, e), o = un(t, e);
			for (let t = 0; t < r; t += 1) a.push(e);
			for (let t = 0; t < o; t += 1) a.length > 0 && a.at(-1) === e && a.pop();
			continue;
		}
		if (e.type === "html" && e.block) {
			let e = t.match(nn);
			if (e) {
				let n = e[1];
				ln(t, n) > un(t, n) && a.push(n);
			}
		}
		if (n > 0 && !o) {
			let e = i[n - 1];
			if (dn(e) % 2 == 1) {
				i[n - 1] = e + t;
				continue;
			}
		}
		i.push(t), e.type !== "space" && (o = e.type === "code");
	}
	return i;
}, pn = (e, t) => {
	if (!t.length) return e;
	let n = e;
	for (let e of t) {
		let t = RegExp(`(<${e}(?=[\\s>/])[^>]*>)([\\s\\S]*?)(</${e}\\s*>)`, "gi");
		n = n.replace(t, (e, t, n, r) => {
			if (!n.includes("\n\n")) return t + n + r;
			let i = n.replace(/\n\n/g, "\n<!---->\n");
			return `${t}${(i.startsWith("\n") ? "" : "\n") + i + (i.endsWith("\n") ? "" : "\n")}${r}

`;
		});
	}
	return n;
}, mn = /([\\`*_~[\]|])/g, hn = (e) => e.replace(mn, "\\$1"), gn = (e, t) => {
	if (!t.length) return e;
	let n = e;
	for (let e of t) {
		let t = RegExp(`(<${e}(?=[\\s>/])[^>]*>)([\\s\\S]*?)(</${e}\\s*>)`, "gi");
		n = n.replace(t, (e, t, n, r) => t + hn(n).replace(/\n\n/g, "&#10;&#10;") + r);
	}
	return n;
}, _n = (e) => e.type === "text" ? e.value : "children" in e && Array.isArray(e.children) ? e.children.map(_n).join("") : "", vn = (e) => (t) => {
	if (!e || e.length === 0) return;
	let r = new Set(e.map((e) => e.toLowerCase()));
	n(t, "element", (e) => {
		if (r.has(e.tagName.toLowerCase())) {
			let t = _n(e);
			e.children = t ? [{
				type: "text",
				value: t
			}] : [];
		}
	});
}, yn = () => (e) => {
	n(e, "code", (e) => {
		e.meta && (e.data = e.data ?? {}, e.data.hProperties = {
			...e.data.hProperties ?? {},
			metastring: e.meta
		});
	});
}, bn = /^[ \t]*<[\w!/?-]/, xn = /(^|\n)[ \t]{4,}(?=<[\w!/?-])/g, Sn = (e) => typeof e != "string" || e.length === 0 || !bn.test(e) ? e : e.replace(xn, "$1"), Cn = {
	...o,
	protocols: {
		...o.protocols,
		href: [...o.protocols?.href ?? [], "tel"]
	},
	attributes: {
		...o.attributes,
		code: [...o.attributes?.code ?? [], "metastring"]
	}
}, wn = {
	raw: a,
	sanitize: [s, Cn],
	harden: [i, {
		allowedImagePrefixes: ["*"],
		allowedLinkPrefixes: ["*"],
		allowedProtocols: ["*"],
		defaultOrigin: void 0,
		allowDataImages: !0
	}]
}, Tn = {
	gfm: [r, {}],
	codeMeta: yn
}, En = Object.values(wn), Dn = Object.values(Tn), On = {
	block: " ▋",
	circle: " ●"
}, kn = ["github-light", "github-dark"], An = { enabled: !0 }, $ = _({
	shikiTheme: kn,
	controls: !0,
	isAnimating: !1,
	lineNumbers: !0,
	mode: "streaming",
	mermaid: void 0,
	linkSafety: An
}), jn = x(({ content: e, shouldParseIncompleteMarkdown: t, shouldNormalizeHtmlIndentation: n, index: r, isIncomplete: i, dir: a, animatePlugin: o, ...s }) => {
	if (o) {
		let e = o.getLastRenderCharCount();
		o.setPrevContentLength(e);
	}
	let c = typeof e == "string" && n ? Sn(e) : e, l = k(Gt, {
		...s,
		children: c
	});
	return k(ue.Provider, {
		value: i,
		children: a ? k("div", {
			dir: a,
			style: { display: "contents" },
			children: l
		}) : l
	});
}, (e, t) => {
	if (e.content !== t.content || e.shouldNormalizeHtmlIndentation !== t.shouldNormalizeHtmlIndentation || e.index !== t.index || e.isIncomplete !== t.isIncomplete || e.dir !== t.dir) return !1;
	if (e.components !== t.components) {
		let n = Object.keys(e.components || {}), r = Object.keys(t.components || {});
		if (n.length !== r.length || n.some((n) => e.components?.[n] !== t.components?.[n])) return !1;
	}
	return !(e.rehypePlugins !== t.rehypePlugins || e.remarkPlugins !== t.remarkPlugins);
});
jn.displayName = "Block";
var Mn = x(({ children: e, mode: t = "streaming", dir: n, parseIncompleteMarkdown: r = !0, normalizeHtmlIndentation: i = !1, components: a, rehypePlugins: o = En, remarkPlugins: l = Dn, className: u, shikiTheme: d = kn, mermaid: f, controls: p = !0, isAnimating: m = !1, animated: h, BlockComponent: g = jn, parseMarkdownIntoBlocksFn: _ = fn, caret: y, plugins: b, remend: x, linkSafety: S = An, lineNumbers: C = !0, allowedTags: O, literalTagContent: j, translations: M, icons: N, prefix: P, onAnimationStart: F, onAnimationEnd: ne, ...re }) => {
	let ie = ee(), [ae, oe] = te(), I = T(() => pe(P), [P]), se = E(null), L = E(F), ce = E(ne);
	L.current = F, ce.current = ne, w(() => {
		var e, n, r;
		if (t === "static") return;
		let i = se.current;
		if (se.current = m, i === null) {
			m && ((e = L.current) == null || e.call(L));
			return;
		}
		m && !i ? (n = L.current) == null || n.call(L) : !m && i && ((r = ce.current) == null || r.call(ce));
	}, [m, t]);
	let R = T(() => O ? Object.keys(O) : [], [O]), z = T(() => {
		if (typeof e != "string") return "";
		let n = t === "streaming" && r ? c(e, x) : e;
		return j && j.length > 0 && (n = gn(n, j)), R.length > 0 && (n = pn(n, R)), n;
	}, [
		e,
		t,
		r,
		x,
		R,
		j
	]), B = T(() => _(z), [z, _]), [ue, de] = D(B);
	w(() => {
		t === "streaming" && !W ? oe(() => {
			de(B);
		}) : de(B);
	}, [B, t]);
	let V = t === "streaming" ? ue : B, fe = T(() => n === "auto" ? V.map(Ft) : void 0, [V, n]), H = T(() => V.map((e, t) => `${ie}-${t}`), [V.length, ie]), U = T(() => h === !0 ? "true" : h ? JSON.stringify(h) : "", [h]), W = T(() => U ? U === "true" ? le() : le(h) : null, [U]), he = T(() => ({
		shikiTheme: (b?.code)?.getThemes() ?? d,
		controls: p,
		isAnimating: m,
		lineNumbers: C,
		mode: t,
		mermaid: f,
		linkSafety: S
	}), [
		d,
		p,
		m,
		C,
		t,
		f,
		S,
		b?.code
	]), G = T(() => ({
		...we,
		...M
	}), [T(() => M ? JSON.stringify(M) : "", [M])]), K = T(() => {
		let { inlineCode: e, ...t } = a ?? {}, n = {
			...Mt,
			...t
		};
		if (e) {
			let t = n.code;
			n.code = (n) => "data-block" in n ? t ? v(t, n) : null : v(e, n);
		}
		return n;
	}, [a]), ge = T(() => {
		let e = [];
		return b != null && b.cjk && (e = [...e, ...b.cjk.remarkPluginsBefore]), e = [...e, ...l], b != null && b.cjk && (e = [...e, ...b.cjk.remarkPluginsAfter]), b != null && b.math && (e = [...e, b.math.remarkPlugin]), e;
	}, [
		l,
		b?.math,
		b?.cjk
	]), _e = T(() => {
		let e = o;
		if (O && Object.keys(O).length > 0 && o === En) {
			let t = {
				...Cn,
				tagNames: [...Cn.tagNames ?? [], ...Object.keys(O)],
				attributes: {
					...Cn.attributes,
					...O
				}
			};
			e = [
				wn.raw,
				[s, t],
				wn.harden
			];
		}
		return j && j.length > 0 && (e = [...e, [vn, j]]), b != null && b.math && (e = [...e, b.math.rehypePlugin]), W && m && (e = [...e, W.rehypePlugin]), e;
	}, [
		o,
		b?.math,
		W,
		m,
		O,
		j
	]), q = T(() => {
		if (!m || V.length === 0) return !1;
		let e = V.at(-1);
		return Rt(e) || zt(e);
	}, [m, V]), ve = T(() => y && m && !q ? { "--streamdown-caret": `"${On[y]}"` } : void 0, [
		y,
		m,
		q
	]);
	return t === "static" ? k(Te.Provider, {
		value: G,
		children: k(Fe.Provider, {
			value: b ?? null,
			children: k($.Provider, {
				value: he,
				children: k(Ce, {
					icons: N,
					children: k(me.Provider, {
						value: I,
						children: k("div", {
							className: I("space-y-4 whitespace-normal [&>*:first-child]:mt-0 [&>*:last-child]:mb-0", u),
							dir: n === "auto" ? Ft(z) : n,
							children: k(Gt, {
								components: K,
								rehypePlugins: _e,
								remarkPlugins: ge,
								...re,
								children: z
							})
						})
					})
				})
			})
		})
	}) : k(Te.Provider, {
		value: G,
		children: k(Fe.Provider, {
			value: b ?? null,
			children: k($.Provider, {
				value: he,
				children: k(Ce, {
					icons: N,
					children: k(me.Provider, {
						value: I,
						children: A("div", {
							className: I("space-y-4 whitespace-normal [&>*:first-child]:mt-0 [&>*:last-child]:mb-0", y && !q ? "[&>*:last-child]:after:inline [&>*:last-child]:after:align-baseline [&>*:last-child]:after:content-[var(--streamdown-caret)]" : null, u),
							style: ve,
							children: [V.length === 0 && y && m && k("span", {}), V.map((e, t) => {
								let a = t === V.length - 1, o = m && a && Rt(e);
								return k(g, {
									animatePlugin: W,
									components: K,
									content: e,
									dir: fe?.[t] ?? (n === "auto" ? void 0 : n),
									index: t,
									isIncomplete: o,
									rehypePlugins: _e,
									remarkPlugins: ge,
									shouldNormalizeHtmlIndentation: i,
									shouldParseIncompleteMarkdown: r,
									...re
								}, H[t]);
							})]
						})
					})
				})
			})
		})
	});
}, (e, t) => e.children === t.children && e.shikiTheme === t.shikiTheme && e.isAnimating === t.isAnimating && e.animated === t.animated && e.mode === t.mode && e.plugins === t.plugins && e.className === t.className && e.linkSafety === t.linkSafety && e.lineNumbers === t.lineNumbers && e.normalizeHtmlIndentation === t.normalizeHtmlIndentation && e.literalTagContent === t.literalTagContent && JSON.stringify(e.translations) === JSON.stringify(t.translations) && e.prefix === t.prefix && e.dir === t.dir);
Mn.displayName = "Streamdown";
var Nn = ({ children: e, className: t, minZoom: n = .5, maxZoom: r = 3, zoomStep: i = .1, showControls: a = !0, initialZoom: o = 1, fullscreen: s = !1 }) => {
	let { RotateCcwIcon: c, ZoomInIcon: l, ZoomOutIcon: u } = Y(), d = U(), f = E(null), p = E(null), [m, h] = D(o), [g, _] = D({
		x: 0,
		y: 0
	}), [v, y] = D(!1), [b, x] = D({
		x: 0,
		y: 0
	}), [C, ee] = D({
		x: 0,
		y: 0
	}), T = S((e) => {
		h((t) => Math.max(n, Math.min(r, t + e)));
	}, [n, r]), te = S(() => {
		T(i);
	}, [T, i]), O = S(() => {
		T(-i);
	}, [T, i]), j = S(() => {
		h(o), _({
			x: 0,
			y: 0
		});
	}, [o]), M = S((e) => {
		e.preventDefault(), T(e.deltaY > 0 ? -i : i);
	}, [T, i]), N = S((e) => {
		if (e.button !== 0 || e.isPrimary === !1) return;
		y(!0), x({
			x: e.clientX,
			y: e.clientY
		}), ee(g);
		let t = e.currentTarget;
		t instanceof HTMLElement && t.setPointerCapture(e.pointerId);
	}, [g]), P = S((e) => {
		if (!v) return;
		e.preventDefault();
		let t = e.clientX - b.x, n = e.clientY - b.y;
		_({
			x: C.x + t,
			y: C.y + n
		});
	}, [
		v,
		b,
		C
	]), F = S((e) => {
		y(!1);
		let t = e.currentTarget;
		t instanceof HTMLElement && t.releasePointerCapture(e.pointerId);
	}, []);
	return w(() => {
		let e = f.current;
		if (e) return e.addEventListener("wheel", M, { passive: !1 }), () => {
			e.removeEventListener("wheel", M);
		};
	}, [M]), w(() => {
		let e = p.current;
		if (e && v) return document.body.style.userSelect = "none", e.addEventListener("pointermove", P, { passive: !1 }), e.addEventListener("pointerup", F), e.addEventListener("pointercancel", F), () => {
			document.body.style.userSelect = "", e.removeEventListener("pointermove", P), e.removeEventListener("pointerup", F), e.removeEventListener("pointercancel", F);
		};
	}, [
		v,
		P,
		F
	]), A("div", {
		className: d("relative flex flex-col", s ? "h-full w-full" : "min-h-28 w-full", t),
		ref: f,
		style: { cursor: v ? "grabbing" : "grab" },
		children: [a ? A("div", {
			className: d("absolute z-10 flex flex-col gap-1 rounded-md border border-border bg-background/80 p-1 supports-[backdrop-filter]:bg-background/70 supports-[backdrop-filter]:backdrop-blur-sm", s ? "bottom-4 left-4" : "bottom-2 left-2"),
			children: [
				k("button", {
					className: d("flex items-center justify-center rounded p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50"),
					disabled: m >= r,
					onClick: te,
					title: "Zoom in",
					type: "button",
					children: k(l, { size: 16 })
				}),
				k("button", {
					className: d("flex items-center justify-center rounded p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50"),
					disabled: m <= n,
					onClick: O,
					title: "Zoom out",
					type: "button",
					children: k(u, { size: 16 })
				}),
				k("button", {
					className: d("flex items-center justify-center rounded p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground"),
					onClick: j,
					title: "Reset zoom and pan",
					type: "button",
					children: k(c, { size: 16 })
				})
			]
		}) : null, k("div", {
			className: d("flex-1 origin-center transition-transform duration-150 ease-out", s ? "flex h-full w-full items-center justify-center" : "flex w-full items-center justify-center"),
			onPointerDown: N,
			ref: p,
			role: "application",
			style: {
				transform: `translate(${g.x}px, ${g.y}px) scale(${m})`,
				transformOrigin: "center center",
				touchAction: "none",
				willChange: "transform"
			},
			children: e
		})]
	});
}, Pn = ({ chart: e, className: t, config: n, fullscreen: r = !1, showControls: i = !0 }) => {
	let a = U(), [o, s] = D(null), [c, l] = D(!1), [u, d] = D(""), [f, p] = D(""), [m, h] = D(0), { mermaid: g } = C($), _ = Re(), v = g?.errorComponent, { shouldRender: y, containerRef: b } = re({ immediate: r });
	if (w(() => {
		if (y) {
			if (!_) {
				s("Mermaid plugin not available. Please add the mermaid plugin to enable diagram rendering.");
				return;
			}
			(async () => {
				try {
					s(null), l(!0);
					let t = _.getMermaid(n), r = e.split("").reduce((e, t) => (e << 5) - e + t.charCodeAt(0) | 0, 0), i = `mermaid-${Math.abs(r)}-${Date.now()}-${Math.random().toString(36).substring(2, 9)}`, { svg: a } = await t.render(i, e);
					d(a), p(a);
				} catch (e) {
					f || u || s(e instanceof Error ? e.message : "Failed to render Mermaid chart");
				} finally {
					l(!1);
				}
			})();
		}
	}, [
		e,
		n,
		m,
		y,
		_
	]), !(y || u || f)) return k("div", {
		className: a("my-4 min-h-[200px]", t),
		ref: b
	});
	if (c && !u && !f) return k("div", {
		className: a("my-4 flex justify-center p-4", t),
		ref: b,
		children: A("div", {
			className: a("flex items-center space-x-2 text-muted-foreground"),
			children: [k("div", { className: a("h-4 w-4 animate-spin rounded-full border-current border-b-2") }), k("span", {
				className: a("text-sm"),
				children: "Loading diagram..."
			})]
		})
	});
	if (o && !u && !f) return v ? k("div", {
		ref: b,
		children: k(v, {
			chart: e,
			error: o,
			retry: () => h((e) => e + 1)
		})
	}) : A("div", {
		className: a("rounded-md bg-red-50 p-4", t),
		ref: b,
		children: [A("p", {
			className: a("font-mono text-red-700 text-sm"),
			children: ["Mermaid Error: ", o]
		}), A("details", {
			className: a("mt-2"),
			children: [k("summary", {
				className: a("cursor-pointer text-red-600 text-xs"),
				children: "Show Code"
			}), k("pre", {
				className: a("mt-2 overflow-x-auto rounded bg-red-100 p-2 text-red-800 text-xs"),
				children: e
			})]
		})]
	});
	let x = u || f;
	return k("div", {
		className: a("size-full", t),
		"data-streamdown": "mermaid",
		ref: b,
		children: k(Nn, {
			className: a(r ? "size-full overflow-hidden" : "overflow-hidden", t),
			fullscreen: r,
			maxZoom: 3,
			minZoom: .5,
			showControls: i,
			zoomStep: .1,
			children: k("div", {
				"aria-label": "Mermaid chart",
				className: a("flex justify-center", r ? "size-full items-center" : null),
				dangerouslySetInnerHTML: { __html: x },
				role: "img"
			})
		})
	});
};
//#endregion
export { Ft as $e, Ee as Ae, G as At, we as De, Sn as Js, Tn as Ks, Le as Li, ke as Oe, Ye as Pe, Mn as Qs, $ as R, Je as Te, jn as Tn, le as be, Ge as dt, Oe as it, Ke as je, fn as kt, We as ne, Yt as on, K as ot, Pn as po, qe as re, q as rt, be as st, de as tt, Ue as ue, wn as xt };
