"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

Object.defineProperty(exports, "__esModule", {
  value: !0
}), exports.undefined2default = exports.renderSimpleTime = exports.renderLongTime = exports.isEmptyObject = exports.generateTableFilterOrLike = exports.generateTableFilter = exports.filterPayload = exports.convertTree = exports.asyncAction = void 0;

var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof")), _moment = _interopRequireDefault(require("moment")), asyncAction = function(e) {
  return function(r) {
    e && r(e());
  };
};

exports.asyncAction = asyncAction;

var filterPayload = function(e) {
  return null !== e && "object" === (0, _typeof2.default)(e) && e.dataList ? e.dataList : e;
};

exports.filterPayload = filterPayload;

var generateTableFilter = function(e, r) {
  var t = [];
  return e.map((function(e) {
    var n = e.type, i = e.name, a = r[i];
    void 0 !== a && "" !== a && null !== a && t.push({
      name: i,
      type: n,
      value: a
    });
  })), t;
};

exports.generateTableFilter = generateTableFilter;

var convertTree = function() {
  var e = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : [], r = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : [];
  return function e(t) {
    return t.map((function(t) {
      r.map((function(e) {
        t[e.newKey] = t[e.oldKey];
      })), t.children && e(t.children);
    }));
  }(e), e;
};

exports.convertTree = convertTree;

var generateTableFilterOrLike = function(e, r) {
  var t = [];
  return e.map((function(e) {
    var n = e.type, i = e.name, a = r.multipleLike;
    void 0 !== a && t.push({
      name: i,
      type: n,
      value: a
    });
  })), t;
};

exports.generateTableFilterOrLike = generateTableFilterOrLike;

var isEmptyObject = function(e) {
  if (e) for (var r in e) if (r) return !1;
  return !0;
};

exports.isEmptyObject = isEmptyObject;

var undefined2default = function(e, r) {
  Array.isArray(e);
};

exports.undefined2default = undefined2default;

var renderSimpleTime = function(e, r) {
  return e ? (0, _moment.default)(e).format("YYYY-MM-DD") : "";
};

exports.renderSimpleTime = renderSimpleTime;

var renderLongTime = function(e, r) {
  return e ? (0, _moment.default)(e).format("YYYY-MM-DD HH:mm:ss") : "";
};

exports.renderLongTime = renderLongTime;