function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
import React from 'react';
import classNames from 'classnames';
import PisellImageCard from "../../PisellImageCard";
import Iconfont from "../../../../iconfont";
/**
 * GraphicArea 图形区域组件
 * 负责渲染图片或图标
 *
 * @component
 * @example
 * ```tsx
 * // 渲染图片
 * <GraphicArea
 *   image="https://example.com/image.png"
 *   config={{ width: 60, height: 60, borderRadius: 8 }}
 * />
 *
 * // 渲染图标
 * <GraphicArea
 *   icon={<SmileIcon />}
 *   config={{ width: 36, height: 36, iconSize: 24, iconColor: '#7F56D9' }}
 * />
 * ```
 */
var GraphicArea = function GraphicArea(props) {
  var _config$dataSource, _config$dataSource2, _config$dataSource3;
  var image = props.image,
    icon = props.icon,
    _props$config = props.config,
    config = _props$config === void 0 ? {} : _props$config,
    className = props.className;
  var width = config.width,
    height = config.height,
    borderRadius = config.borderRadius,
    background = config.background,
    border = config.border,
    boxShadow = config.boxShadow,
    padding = config.padding,
    iconSize = config.iconSize,
    iconColor = config.iconColor,
    customStyle = config.style,
    hidden = config.hidden,
    aliWidth = config.aliWidth;

  /**
   * 图形区域容器样式
   */
  var graphicStyle = _objectSpread({
    width: width,
    height: height,
    borderRadius: borderRadius,
    background: background,
    border: border,
    boxShadow: boxShadow,
    padding: padding
  }, customStyle);
  if (hidden) {
    return null;
  }

  /**
   * 图标样式
   */
  var iconStyle = {
    fontSize: iconSize,
    color: iconColor,
    width: iconSize,
    height: iconSize
  };

  // 其次渲染图标
  if (icon) {
    return /*#__PURE__*/React.createElement("div", {
      className: classNames('graphic-text-card__graphic', className),
      style: graphicStyle
    }, /*#__PURE__*/React.createElement(Iconfont, {
      style: iconStyle,
      type: icon
    }));
  }
  return /*#__PURE__*/React.createElement("div", {
    className: classNames('graphic-text-card__graphic', className),
    style: graphicStyle
  }, /*#__PURE__*/React.createElement(PisellImageCard, _extends({}, config, {
    dataSource: {
      src: image,
      alt: (_config$dataSource = config.dataSource) === null || _config$dataSource === void 0 ? void 0 : _config$dataSource.alt,
      errorSrc: (_config$dataSource2 = config.dataSource) === null || _config$dataSource2 === void 0 ? void 0 : _config$dataSource2.errorSrc,
      fallbackSrc: (_config$dataSource3 = config.dataSource) === null || _config$dataSource3 === void 0 ? void 0 : _config$dataSource3.fallbackSrc
    },
    width: '100%',
    height: '100%',
    aliWidth: aliWidth
  })));
};
export default GraphicArea;