var __assign = this && this.__assign || function () {
  __assign = Object.assign || function (t) {
    for (var s, i = 1, n = arguments.length; i < n; i++) {
      s = arguments[i];

      for (var p in s) {
        if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
      }
    }

    return t;
  };

  return __assign.apply(this, arguments);
};

var __rest = this && this.__rest || function (s, e) {
  var t = {};

  for (var p in s) {
    if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
  }

  if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
    if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
  }
  return t;
};

import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import * as React from 'react';
import classNames from 'classnames';
import Icon from "../icon";
import "./style/tag.css";
export var prefixCls = 'dmc-tag';
var Tag = /*#__PURE__*/React.forwardRef(function (props, ref) {
  var _a, _b, _c, _d;

  var type = props.type,
      size = props.size,
      color = props.color,
      className = props.className,
      closable = props.closable,
      disabled = props.disabled,
      tag = props.tag,
      onClickClose = props.onClickClose,
      onClickTag = props.onClickTag,
      icon = props.icon,
      restProps = __rest(props, ["type", "size", "color", "className", "closable", "disabled", "tag", "onClickClose", "onClickTag", "icon"]);

  var cls = classNames(prefixCls, (_a = {}, _a[prefixCls + "-" + type] = type, _a), (_b = {}, _b[prefixCls + "-" + size] = size, _b), (_c = {}, _c[prefixCls + "-color " + prefixCls + "-color-" + color] = color, _c), (_d = {}, _d[prefixCls + "-disabled"] = disabled, _d), className);
  var isAdd = type === 'new';

  var _onClickClose = function _onClickClose(e) {
    onClickClose && onClickClose(e, tag);
  };

  var _onClickTag = function _onClickTag(e) {
    onClickTag && onClickTag(e, tag);
  };

  return _jsxs("div", __assign({}, restProps, {
    ref: ref,
    className: cls,
    onClick: _onClickTag
  }, {
    children: [(isAdd || !!icon) && _jsx(Icon, {
      icon: icon || 'add',
      className: isAdd ? prefixCls + "-new-icon" : undefined
    }, void 0), _jsx("div", __assign({
      className: prefixCls + "-tag"
    }, {
      children: tag
    }), void 0), !disabled && closable && _jsx(Icon, {
      icon: 'close',
      className: prefixCls + "-close",
      onClick: _onClickClose
    }, void 0)]
  }), void 0);
});
Tag.displayName = 'Tag';
export default Tag;
var TagMemo = /*#__PURE__*/React.memo(Tag);
TagMemo.displayName = 'TagMemo';
export { TagMemo };

