import { _objectSpread2 } from "../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js";
import { _objectWithoutProperties } from "../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectWithoutProperties.js";
import IconFont from "../iconfont/index.js";
import React, { useMemo } from "react";
import { Avatar } from "antd";
import classNames from "classnames";
import "./index.less";
//#region src/components/pisellAvatar/index.tsx
const _excluded = [
	"shape",
	"size",
	"src",
	"alt",
	"icon",
	"children",
	"className",
	"style",
	"useTextAvatar",
	"borderRadius",
	"onError"
];
const sizeMap = {
	xs: 24,
	sm: 32,
	md: 40,
	lg: 48,
	xl: 56,
	xxl: 64
};
const fontSizeMap = {
	xs: 12,
	sm: 14,
	md: 16,
	lg: 18,
	xl: 20,
	xxl: 24
};
const PisellAvatar = (_ref) => {
	let { shape = "circle", size = "xs", src, alt, icon, children, className, style, useTextAvatar, borderRadius = 4, onError } = _ref, restProps = _objectWithoutProperties(_ref, _excluded);
	const classes = classNames("pisell-avatar", `pisell-avatar-${size}`, `pisell-avatar-${shape}`, { "pisell-avatar-with-text": !src && !icon && children }, className);
	const mergedStyle = _objectSpread2(_objectSpread2({}, style), {}, {
		width: sizeMap[size],
		height: sizeMap[size],
		fontSize: fontSizeMap[size],
		lineHeight: `${sizeMap[size]}px`,
		borderRadius: shape === "square" ? `${borderRadius}px` : "50%"
	});
	/**
	* @title: 渲染头像内容
	* @description:
	* @param {*} useMemo
	* @return {*}
	* @Author: WangHan
	* @Date: 2025-01-07 11:58
	*/
	const renderChildren = useMemo(() => {
		if (useTextAvatar && children) return children;
		return /* @__PURE__ */ React.createElement(IconFont, {
			type: "pisell2-user-01",
			className: "pisell-avatar-icon"
		});
	}, [useTextAvatar, children]);
	return /* @__PURE__ */ React.createElement(Avatar, _objectSpread2(_objectSpread2({}, restProps), {}, {
		className: classes,
		shape,
		style: mergedStyle,
		src,
		alt,
		icon,
		onError
	}), renderChildren);
};
//#endregion
export { PisellAvatar as default };
