import { n as e } from "./theme-provider-fNhx9xK0.js";
import { a as t, c as n, d as r, f as i, i as a, l as o, m as s, o as c, p as l, r as u, s as d, t as f } from "./context-menu-BIQsQup7.js";
import { useCallback as p } from "react";
import { useLocation as m, useNavigate as h } from "react-router-dom";
import { Fragment as g, jsx as _, jsxs as v } from "react/jsx-runtime";
//#region src/components/GlobalContextMenu.tsx
var y = {
	"zh-cn": {
		page: "页面",
		copyUrl: "复制当前链接",
		copyTitle: "复制页面标题",
		copyMarkdownLink: "复制 Markdown 链接",
		copySelectedText: "复制",
		openInNewTab: "在新标签页打开",
		reload: "刷新",
		printPage: "打印页面",
		scrollToTop: "回到顶部",
		scrollToBottom: "滚动到底部",
		site: "站点",
		goHome: "返回首页",
		quickNav: "快速跳转",
		docsIndex: "文档首页",
		guide: "指南",
		introduction: "简介",
		installation: "安装",
		quickStart: "快速开始",
		configuration: "配置",
		language: "语言",
		appearance: "外观",
		theme: "主题",
		light: "浅色",
		dark: "深色",
		system: "跟随系统",
		resetThemePref: "重置主题偏好"
	},
	en: {
		page: "Page",
		copyUrl: "Copy Current URL",
		copyTitle: "Copy Page Title",
		copyMarkdownLink: "Copy Markdown Link",
		copySelectedText: "Copy",
		openInNewTab: "Open in New Tab",
		reload: "Reload",
		printPage: "Print Page",
		scrollToTop: "Scroll to Top",
		scrollToBottom: "Scroll to Bottom",
		site: "Site",
		goHome: "Go Home",
		quickNav: "Quick Navigation",
		docsIndex: "Docs Index",
		guide: "Guide",
		introduction: "Introduction",
		installation: "Installation",
		quickStart: "Quick Start",
		configuration: "Configuration",
		language: "Language",
		appearance: "Appearance",
		theme: "Theme",
		light: "Light",
		dark: "Dark",
		system: "System",
		resetThemePref: "Reset Theme Preference"
	}
}, b = {
	enabled: !0,
	page: {
		copyUrl: !0,
		copyTitle: !0,
		copyMarkdownLink: !0,
		copySelectedText: !0,
		openInNewTab: !0,
		reload: !0,
		printPage: !0,
		scrollToTop: !0,
		scrollToBottom: !0
	},
	site: {
		goHome: !0,
		quickNav: !0,
		language: !0
	},
	appearance: {
		theme: !0,
		resetThemePref: !0
	}
};
function x({ children: x, config: S }) {
	let C = h(), w = m(), { theme: T, setTheme: E } = e(), D = p(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);
			}
		}
	}, []), O = p(async () => {
		try {
			await D(window.location.href);
		} catch {}
	}, [D]), k = p(async () => {
		try {
			await D(document.title || "");
		} catch {}
	}, [D]), A = p(async () => {
		try {
			let e = document.title || "Docs", t = window.location.href;
			await D(`[${e}](${t})`);
		} catch {}
	}, [D]), j = p(async () => {
		try {
			let e = window.getSelection()?.toString() || "";
			e && await D(e);
		} catch {}
	}, [D]), M = p(() => {
		window.open(window.location.href, "_blank");
	}, []), N = p(() => {
		window.location.reload();
	}, []), P = p(() => C("/"), [C]), F = w.pathname.startsWith("/en") ? "en" : "zh-cn", I = y[F], L = p((e) => {
		let t = w.pathname.split("/").filter(Boolean);
		t.length > 0 && (t[0] === "en" || t[0] === "zh-cn") ? t[0] = e : t.unshift(e), C("/" + t.join("/"));
	}, [w.pathname, C]), R = p(() => window.scrollTo({
		top: 0,
		behavior: "smooth"
	}), []), z = p(() => window.scrollTo({
		top: document.documentElement.scrollHeight,
		behavior: "smooth"
	}), []), B = p(() => window.print(), []), V = p((e) => C(`/${F}/${e}`), [C, F]), H = p(() => {
		try {
			localStorage.removeItem("vite-ui-theme");
		} catch {}
	}, []), U = S?.enabled === !1 ? null : {
		...b,
		...S
	};
	if (!U) return /* @__PURE__ */ _("div", {
		className: "min-h-screen",
		children: x
	});
	let W = {
		...b.page,
		...U.page
	}, G = {
		...b.site,
		...U.site
	}, K = {
		...b.appearance,
		...U.appearance
	}, q = Object.values(W).some(Boolean), J = Object.values(G).some(Boolean), Y = Object.values(K).some(Boolean);
	return /* @__PURE__ */ v(f, { children: [/* @__PURE__ */ _(s, {
		asChild: !0,
		children: /* @__PURE__ */ _("div", {
			className: "min-h-screen",
			children: x
		})
	}), /* @__PURE__ */ v(u, { children: [
		q && /* @__PURE__ */ v(g, { children: [/* @__PURE__ */ _(c, { children: I.page }), /* @__PURE__ */ v(a, { children: [
			W.copyUrl && /* @__PURE__ */ _(t, {
				onClick: O,
				children: I.copyUrl
			}),
			W.copyTitle && /* @__PURE__ */ _(t, {
				onClick: k,
				children: I.copyTitle
			}),
			W.copyMarkdownLink && /* @__PURE__ */ _(t, {
				onClick: A,
				children: I.copyMarkdownLink
			}),
			W.copySelectedText && /* @__PURE__ */ _(t, {
				onClick: j,
				children: I.copySelectedText
			}),
			W.openInNewTab && /* @__PURE__ */ _(t, {
				onClick: M,
				children: I.openInNewTab
			}),
			W.reload && /* @__PURE__ */ _(t, {
				onClick: N,
				children: I.reload
			}),
			W.printPage && /* @__PURE__ */ _(t, {
				onClick: B,
				children: I.printPage
			}),
			(W.scrollToTop || W.scrollToBottom) && /* @__PURE__ */ v(g, { children: [
				/* @__PURE__ */ _(o, {}),
				W.scrollToTop && /* @__PURE__ */ _(t, {
					onClick: R,
					children: I.scrollToTop
				}),
				W.scrollToBottom && /* @__PURE__ */ _(t, {
					onClick: z,
					children: I.scrollToBottom
				})
			] })
		] })] }),
		J && /* @__PURE__ */ v(g, { children: [
			q && /* @__PURE__ */ _(o, {}),
			/* @__PURE__ */ _(c, { children: I.site }),
			/* @__PURE__ */ v(a, { children: [
				G.goHome && /* @__PURE__ */ _(t, {
					onClick: P,
					children: I.goHome
				}),
				G.quickNav && /* @__PURE__ */ v(r, { children: [/* @__PURE__ */ _(l, { children: I.quickNav }), /* @__PURE__ */ v(i, { children: [
					/* @__PURE__ */ _(t, {
						onClick: () => V("index"),
						children: I.docsIndex
					}),
					/* @__PURE__ */ _(t, {
						onClick: () => V("guide"),
						children: I.guide
					}),
					/* @__PURE__ */ _(t, {
						onClick: () => V("guide/introduction"),
						children: I.introduction
					}),
					/* @__PURE__ */ _(t, {
						onClick: () => V("guide/installation"),
						children: I.installation
					}),
					/* @__PURE__ */ _(t, {
						onClick: () => V("guide/quick-start"),
						children: I.quickStart
					}),
					/* @__PURE__ */ _(t, {
						onClick: () => V("guide/configuration"),
						children: I.configuration
					})
				] })] }),
				G.language && /* @__PURE__ */ v(r, { children: [/* @__PURE__ */ _(l, { children: I.language }), /* @__PURE__ */ _(i, { children: /* @__PURE__ */ v(d, {
					value: F,
					children: [/* @__PURE__ */ _(n, {
						value: "en",
						onClick: () => L("en"),
						children: "English"
					}), /* @__PURE__ */ _(n, {
						value: "zh-cn",
						onClick: () => L("zh-cn"),
						children: "简体中文"
					})]
				}) })] })
			] })
		] }),
		Y && /* @__PURE__ */ v(g, { children: [
			(q || J) && /* @__PURE__ */ _(o, {}),
			/* @__PURE__ */ _(c, { children: I.appearance }),
			/* @__PURE__ */ v(a, { children: [K.theme && /* @__PURE__ */ v(r, { children: [/* @__PURE__ */ _(l, { children: I.theme }), /* @__PURE__ */ _(i, { children: /* @__PURE__ */ v(d, {
				value: T,
				children: [
					/* @__PURE__ */ _(n, {
						value: "light",
						onClick: () => E("light"),
						children: I.light
					}),
					/* @__PURE__ */ _(n, {
						value: "dark",
						onClick: () => E("dark"),
						children: I.dark
					}),
					/* @__PURE__ */ _(n, {
						value: "system",
						onClick: () => E("system"),
						children: I.system
					})
				]
			}) })] }), K.resetThemePref && /* @__PURE__ */ _(t, {
				onClick: H,
				children: I.resetThemePref
			})] })
		] })
	] })] });
}
//#endregion
export { x as GlobalContextMenu };
