"use strict";

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

var _vue = _interopRequireWildcard(require("vue"));

var _vueTypes = _interopRequireDefault(require("../_util/vue-types"));

var _configProvider = require("../config-provider");

var _propsUtil = require("../_util/props-util");

var _LocaleReceiver = _interopRequireDefault(require("../locale-provider/LocaleReceiver"));

var _empty = _interopRequireDefault(require("./empty"));

var _simple = _interopRequireDefault(require("./simple"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }

function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }

function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }

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

var TransferLocale = function TransferLocale() {
  return {
    description: _vueTypes.default.string
  };
};

exports.TransferLocale = TransferLocale;

var EmptyProps = function EmptyProps() {
  return {
    prefixCls: _vueTypes.default.string,
    image: _vueTypes.default.any,
    description: _vueTypes.default.any,
    imageStyle: _vueTypes.default.object
  };
};

exports.EmptyProps = EmptyProps;
var Empty = {
  name: 'AEmpty',
  props: _objectSpread({}, EmptyProps()),
  methods: {
    renderEmpty: function renderEmpty(contentLocale) {
      var _image$type;

      var _this$$props = this.$props,
          customizePrefixCls = _this$$props.prefixCls,
          imageStyle = _this$$props.imageStyle;

      var prefixCls = _configProvider.ConfigConsumerProps.getPrefixCls('empty', customizePrefixCls);

      var image = (0, _propsUtil.getComponent)(this, 'image') || _vue.createVNode(_empty.default, null, null);

      var description = (0, _propsUtil.getComponent)(this, 'description');
      var des = typeof description !== 'undefined' ? description : contentLocale.description;
      var alt = typeof des === 'string' ? des : 'empty';

      var cls = _defineProperty({}, prefixCls, true);

      var imageNode = null;

      if (typeof image === 'string') {
        imageNode = _vue.createVNode("img", {
          "alt": alt,
          "src": image
        }, null);
      } else if (_typeof(image) === 'object' && ((_image$type = image.type) === null || _image$type === void 0 ? void 0 : _image$type.PRESENTED_IMAGE_SIMPLE)) {
        var Image = image;
        imageNode = _vue.createVNode(Image, null, null);
        cls["".concat(prefixCls, "-normal")] = true;
      } else {
        imageNode = image;
      }

      return _vue.createVNode("div", {
        "class": cls
      }, [_vue.createVNode("div", {
        "class": "".concat(prefixCls, "-image"),
        "style": imageStyle
      }, [imageNode]), des && _vue.createVNode("p", {
        "class": "".concat(prefixCls, "-description")
      }, [des]), this.$slots.default && _vue.createVNode("div", {
        "class": "".concat(prefixCls, "-footer")
      }, [this.$slots.default()])]);
    }
  },
  render: function render() {
    return _vue.createVNode(_LocaleReceiver.default, {
      "componentName": "Empty",
      "children": this.renderEmpty
    }, null);
  }
};
Empty.PRESENTED_IMAGE_DEFAULT = _empty.default;
Empty.PRESENTED_IMAGE_SIMPLE = _simple.default;
/* istanbul ignore next */

Empty.install = function (app) {
  app.component(Empty.name, Empty);
};

var _default = Empty;
exports.default = _default;