"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = exports.EnvTagColor = void 0;

var _vue = require("vue");

var _antDesignVue = require("ant-design-vue");

var _utils = require("../utils");

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; }

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

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

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 = (0, _vue.createVNode)(_antDesignVue.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 (0, _vue.createVNode)(_antDesignVue.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: _utils.PropTypes.string,
  tips: _utils.PropTypes.string
};

var _default2 = (0, _utils.withInstall)(AppEnv);

exports.default = _default2;