import "core-js/modules/es.symbol.js";
import "core-js/modules/es.array.filter.js";
import "core-js/modules/es.array.for-each.js";
import "core-js/modules/es.array.push.js";
import "core-js/modules/es.object.define-properties.js";
import "core-js/modules/es.object.define-property.js";
import "core-js/modules/es.object.get-own-property-descriptor.js";
import "core-js/modules/es.object.get-own-property-descriptors.js";
import "core-js/modules/es.object.keys.js";
import "core-js/modules/es.object.to-string.js";
import "core-js/modules/esnext.iterator.constructor.js";
import "core-js/modules/esnext.iterator.filter.js";
import "core-js/modules/esnext.iterator.for-each.js";
import "core-js/modules/web.dom-collections.for-each.js";
import _defineProperty from "@babel/runtime/helpers/defineProperty";
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; }
import classNames from 'classnames';
import React, { useMemo } from 'react';
import './index.css';
import { FcrIcon } from '../icon';
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
export var IconText = function IconText(_ref) {
  var styles = _ref.styles,
    _ref$fontSize = _ref.fontSize,
    fontSize = _ref$fontSize === void 0 ? 'large' : _ref$fontSize,
    icon = _ref.icon,
    colors = _ref.colors,
    txt = _ref.txt,
    transform = _ref.iconTransform,
    classnames = _ref.classnames,
    enable = _ref.enable,
    _onClick = _ref.onClick,
    iconReverse = _ref.iconReverse,
    _ref$isHideIcon = _ref.isHideIcon,
    isHideIcon = _ref$isHideIcon === void 0 ? false : _ref$isHideIcon;
  var cls = classNames('fcr-icon-text');
  var spanCls = classNames('fcr-icon-text__text', {
    'fcr-icon-text__text--small': fontSize === 'small',
    'fcr-icon-text__text--medium': fontSize === 'medium',
    'fcr-icon-text__text--large': fontSize === 'large',
    'fcr-icon-text__text--hide-icon': isHideIcon
  });
  var text = useMemo(function () {
    return /*#__PURE__*/_jsx("span", {
      className: spanCls,
      children: txt
    });
  }, [txt, spanCls]);
  return /*#__PURE__*/_jsx("div", {
    className: cls,
    style: _objectSpread({}, styles),
    children: /*#__PURE__*/_jsxs("div", {
      className: 'fcr-icon-text-wrapper',
      children: [iconReverse && text, !isHideIcon && /*#__PURE__*/_jsx(FcrIcon, {
        className: classNames(classnames),
        style: _objectSpread({}, transform && {
          transform: 'rotate(180deg)'
        }),
        type: icon,
        colors: colors,
        size: fontSize === 'small' ? 10 : 24,
        onClick: function onClick() {
          if (enable) {
            _onClick && _onClick();
          }
        }
      }), !iconReverse && text]
    })
  });
};