var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/components/profileMenu/index.tsx
var profileMenu_exports = {};
__export(profileMenu_exports, {
  default: () => profileMenu_default
});
module.exports = __toCommonJS(profileMenu_exports);
var import_react = __toESM(require("react"));
var import_antd = require("antd");
var import_icons = require("@ant-design/icons");
var import_classnames = __toESM(require("classnames"));
var import_pisellAvatar = __toESM(require("../pisellAvatar"));
var import_index = require("./index.less");
var ProfileMenu = ({
  menuIcon,
  userName = "",
  email = "",
  isShowUserName = true,
  isShowEmail = true,
  isShowUserInfo = false,
  onClick,
  avatar,
  className,
  style,
  menuItems = [],
  placement = "bottomRight",
  trigger = ["click"],
  showBadge = false,
  badgeCount = 1
}) => {
  (0, import_react.useEffect)(() => {
    document.body.id = "body";
  }, []);
  const handleClick = (e) => {
    e.preventDefault();
    onClick == null ? void 0 : onClick();
  };
  const renderAvatar = (avatarProps) => /* @__PURE__ */ import_react.default.createElement(
    import_pisellAvatar.default,
    {
      style: { margin: "0 6px" },
      size: "md",
      src: (avatarProps == null ? void 0 : avatarProps.src) || "",
      alt: (avatarProps == null ? void 0 : avatarProps.alt) || "",
      icon: /* @__PURE__ */ import_react.default.createElement(import_icons.UserOutlined, { style: { fontSize: 24, color: "#475467" } })
    }
  );
  const finalMenuItems = (0, import_react.useMemo)(() => {
    if (!isShowUserInfo) return menuItems;
    const userInfoItem = {
      key: "user-info",
      label: /* @__PURE__ */ import_react.default.createElement("div", { className: "profile-menu-user-info-item" }, renderAvatar(avatar), /* @__PURE__ */ import_react.default.createElement("div", { className: "profile-menu-user-info" }, userName && /* @__PURE__ */ import_react.default.createElement("p", { className: "profile-menu-user-info-name" }, userName), email && /* @__PURE__ */ import_react.default.createElement("p", { className: "profile-menu-user-info-email" }, email)))
    };
    return [
      userInfoItem,
      { type: "divider" },
      ...menuItems || []
    ];
  }, [isShowUserInfo, menuItems, userName, email, avatar]);
  const showUserInfo = isShowUserName && userName || isShowEmail && email;
  return /* @__PURE__ */ import_react.default.createElement(
    import_antd.Dropdown,
    {
      menu: { items: finalMenuItems },
      placement,
      trigger,
      overlayClassName: "profile-menu-dropdown"
    },
    /* @__PURE__ */ import_react.default.createElement(
      "div",
      {
        className: (0, import_classnames.default)("profile-menu-wrap", className),
        style: {
          ...style,
          paddingRight: showUserInfo ? 16 : 0
        },
        onClick: handleClick
      },
      menuIcon && /* @__PURE__ */ import_react.default.createElement("div", { className: "profile-menu-icon" }, menuIcon),
      /* @__PURE__ */ import_react.default.createElement(import_antd.Badge, { count: showBadge ? badgeCount : 0, offset: [-6, 6] }, renderAvatar(avatar)),
      showUserInfo && /* @__PURE__ */ import_react.default.createElement("div", { className: "profile-menu-user-info" }, isShowUserName && userName && /* @__PURE__ */ import_react.default.createElement("p", { className: "profile-menu-user-info-name", title: userName }, userName), isShowEmail && email && /* @__PURE__ */ import_react.default.createElement("p", { className: "profile-menu-user-info-email", title: email }, email))
    )
  );
};
var profileMenu_default = ProfileMenu;
