import { jsx as e, jsxs as i } from "react/jsx-runtime";
import { Children as f } from "react";
import n from "prop-types";
import { Tooltip as u, tooltipClasses as c, Box as s } from "@mui/material";
import { styled as y } from "../Theme/index.js";
import "../ClickToCopy/index.js";
import d from "../ClickToCopy/copy-button.js";
const C = y(({ className: p, ...r }) => /* @__PURE__ */ e(u, { ...r, classes: { popper: p } }))({
  [`& .${c.tooltip}`]: {
    maxWidth: 360,
    wordBreak: "break-all"
  }
});
function l({ children: p, ...r }) {
  return f.map(p, (t) => typeof t == "string" ? /* @__PURE__ */ e(a, { ...r, children: t }) : t.props && t.props.children ? /* @__PURE__ */ e(t.type, { ...t.props, children: /* @__PURE__ */ e(l, { ...r, children: t.props.children }) }) : t);
}
function a({ startChars: p = 6, endChars: r = 6, children: o, showCopyButtonInTooltip: t = !1 }) {
  return typeof o != "string" ? /* @__PURE__ */ e(l, { startChars: p, endChars: r, showCopyButtonInTooltip: t, children: o }) : /* @__PURE__ */ e(C, { title: /* @__PURE__ */ i(
    s,
    {
      onClick: (m) => m.stopPropagation(),
      sx: {
        display: "flex",
        alignItems: "center",
        lineHeight: 1
      },
      children: [
        /* @__PURE__ */ e(s, { children: o }),
        t && /* @__PURE__ */ e(d, { content: o, showTooltip: !1, style: { fontSize: 16, marginLeft: 4 } })
      ]
    }
  ), placement: "top", children: /* @__PURE__ */ i("span", { children: [
    o.slice(0, p),
    "...",
    o.slice(o.length - r)
  ] }) });
}
a.propTypes = {
  startChars: n.number,
  endChars: n.number,
  children: n.node.isRequired,
  // 在 tooltip 中完整地址后显示复制按钮
  showCopyButtonInTooltip: n.bool
};
export {
  a as default
};
