import { createVNode as _createVNode } from "vue";
import { isVNode as _isVNode } from "vue";

function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

import { Tag, Tooltip } from 'ant-design-vue';
import { PropTypes, withInstall } from '../utils';

function _isSlot(s) {
  return typeof s === 'function' || Object.prototype.toString.call(s) === '[object Object]' && !_isVNode(s);
}

export var EnvTagColor = {
  dev: '#ffa500',
  test: '#008000',
  pre: '#87d068'
};

var AppEnv = function AppEnv(_ref) {
  var _slot;

  var name = _ref.name,
      color = _ref.color,
      tips = _ref.tips,
      style = _ref.style,
      className = _ref.className;
  var styles = {
    marginRight: 0,
    borderRadius: '20px',
    fontWeight: 'bold',
    border: 'none',
    cursor: 'pointer'
  };

  var tag = _createVNode(Tag, {
    "style": _objectSpread(_objectSpread({}, styles), style),
    "color": color || EnvTagColor[String(name).toLowerCase()]
  }, _isSlot(_slot = String(name).toUpperCase()) ? _slot : {
    default: function _default() {
      return [_slot];
    }
  });

  if (name && tips) {
    return _createVNode(Tooltip, {
      "title": tips,
      "placement": 'bottom'
    }, _isSlot(tag) ? tag : {
      default: function _default() {
        return [tag];
      }
    });
  } else if (name) {
    return tag;
  }

  return null;
};

AppEnv.displayName = 'AppEnv';
AppEnv.props = {
  name: [Boolean, String],
  color: PropTypes.string,
  tips: PropTypes.string
};
export default withInstall(AppEnv);