import { jsxs as i, jsx as e } from "react/jsx-runtime";
import { useTheme as y, Menu as I, MenuItem as c, Box as n } from "@mui/material";
import { useMemoizedFn as S } from "ahooks";
import { Icon as B } from "@iconify/react";
import { TwitterShareButton as w, XIcon as T, TelegramShareButton as L, TelegramIcon as C, RedditShareButton as F, RedditIcon as R, WeiboShareButton as j, WeiboIcon as z, FacebookShareButton as M, FacebookIcon as W, LinkedinShareButton as v, LinkedinIcon as O } from "react-share";
import P from "../Toast/index.js";
import { translate as X } from "../Locale/util.js";
const a = {
  display: "flex",
  alignItems: "center",
  width: "100%",
  "& > button": {
    display: "flex",
    alignItems: "center",
    width: "100%",
    justifyContent: "flex-start"
  }
}, H = {
  en: {
    copyLink: "Copy Link",
    x: "X (Twitter)",
    telegram: "Telegram",
    reddit: "Reddit",
    facebook: "Facebook",
    weiBo: "Weibo",
    linkedin: "LinkedIn",
    copySuccess: "Link copied to clipboard"
  },
  zh: {
    copyLink: "复制链接",
    x: "X (Twitter)",
    telegram: "Telegram",
    reddit: "Reddit",
    facebook: "Facebook",
    weiBo: "微博",
    linkedin: "LinkedIn",
    copySuccess: "链接已复制到剪贴板"
  }
}, l = {
  display: "flex",
  alignItems: "center",
  gap: 1.5,
  minWidth: 120,
  lineHeight: "1!important"
}, s = (h) => ({
  display: "flex",
  alignItems: "center",
  justifyContent: "center",
  width: 22,
  height: 22,
  border: 1,
  borderColor: h.palette.text.secondary,
  borderRadius: 0.75
});
function Q({
  anchorEl: h,
  onClose: t,
  sharedProps: u,
  locale: x = "en"
}) {
  const m = y(), k = !!h, o = S((f, g = {}) => X(H, f, x, "en", g)), d = {
    bgStyle: { fill: m.palette.background.paper },
    iconFillColor: m.palette.text.secondary
  }, { title: p, url: r } = u, b = () => {
    r && navigator.clipboard.writeText(r).then(() => {
      P.success(o("copySuccess"));
    });
  };
  return /* @__PURE__ */ i(
    I,
    {
      id: "basic-menu",
      anchorEl: h,
      open: k,
      onClose: t,
      anchorOrigin: {
        vertical: "top",
        horizontal: "right"
      },
      transformOrigin: {
        vertical: "top",
        horizontal: "left"
      },
      sx: {
        "& .MuiPaper-root": {
          marginTop: "-140px"
          // 向上移动菜单
        }
      },
      slotProps: {
        paper: {
          "aria-labelledby": "basic-button"
        }
      },
      children: [
        /* @__PURE__ */ e(
          c,
          {
            onClick: () => {
              b(), t();
            },
            sx: a,
            children: /* @__PURE__ */ i(n, { sx: l, children: [
              /* @__PURE__ */ e(n, { sx: s, children: /* @__PURE__ */ e(B, { icon: "tabler:link" }) }),
              /* @__PURE__ */ e("span", { children: o("copyLink") })
            ] })
          },
          "copy-to-clipboard"
        ),
        /* @__PURE__ */ e(c, { onClick: t, sx: a, children: /* @__PURE__ */ i(n, { component: w, url: r, title: p, sx: l, children: [
          /* @__PURE__ */ e(n, { component: T, sx: s, round: !0, ...d }),
          /* @__PURE__ */ e("span", { children: o("x") })
        ] }) }, "share-to-x"),
        /* @__PURE__ */ e(c, { onClick: t, sx: a, children: /* @__PURE__ */ i(n, { component: L, url: r, title: p, sx: l, children: [
          /* @__PURE__ */ e(n, { component: C, sx: s, round: !0, ...d }),
          /* @__PURE__ */ e("span", { children: o("telegram") })
        ] }) }, "share-to-telegram"),
        /* @__PURE__ */ e(c, { onClick: t, sx: a, children: /* @__PURE__ */ i(n, { component: F, url: r, title: p, sx: l, children: [
          /* @__PURE__ */ e(n, { component: R, sx: s, round: !0, ...d }),
          /* @__PURE__ */ e("span", { children: o("reddit") })
        ] }) }, "share-to-reddit"),
        /* @__PURE__ */ e(c, { onClick: t, sx: a, children: /* @__PURE__ */ i(n, { component: j, url: r, title: p, sx: l, children: [
          /* @__PURE__ */ e(n, { component: z, sx: s, round: !0, ...d }),
          /* @__PURE__ */ e("span", { children: o("weiBo") })
        ] }) }, "share-to-weibo"),
        /* @__PURE__ */ e(c, { onClick: t, sx: a, children: /* @__PURE__ */ i(n, { component: M, url: r, title: p, sx: l, children: [
          /* @__PURE__ */ e(n, { component: W, sx: s, round: !0, ...d }),
          /* @__PURE__ */ e("span", { children: o("facebook") })
        ] }) }, "share-to-facebook"),
        /* @__PURE__ */ e(c, { onClick: t, sx: a, children: /* @__PURE__ */ i(n, { component: v, url: r, title: p, sx: l, children: [
          /* @__PURE__ */ e(n, { component: O, sx: s, round: !0, ...d }),
          /* @__PURE__ */ e("span", { children: o("linkedin") })
        ] }) }, "share-to-linkedin")
      ]
    }
  );
}
export {
  Q as default
};
