/**
 * tdesign v0.39.1-alpha.1
 * (c) 2022 tdesign
 * @license MIT
 */

'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var config = require('../config.js');

var UPLOAD_NAME = "".concat(config.prefix, "-upload");
function returnFileSize(number) {
  if (number < 1024) {
    return "".concat(number, " Bytes");
  }

  if (number >= 1024 && number < 1048576) {
    return "".concat((number / 1024).toFixed(1), " KB");
  }

  if (number >= 1048576) {
    return "".concat((number / 1048576).toFixed(1), " MB");
  }
}
function getCurrentDate() {
  var d = new Date();
  var month = d.getMonth() + 1;
  month = month < 10 ? "0".concat(month) : month;
  return "".concat(d.getFullYear(), "-").concat(month, "-").concat(d.getDate(), " ").concat(d.getHours(), ":").concat(d.getMinutes(), ":").concat(d.getSeconds());
}
function abridgeName(inputName) {
  var leftCount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 5;
  var rightcount = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 7;
  var name = inputName;
  var leftLength = 0;
  var rightLength = 0;

  for (var i = 0; i < name.length; i++) {
    var w = name[i];
    var isCn = escape(w).indexOf("%u") === 0;

    if (i < leftCount * 2 && leftLength < leftCount) {
      isCn ? leftLength += 1 : leftLength += 2;
    } else if (i > i - rightcount && rightLength < rightcount) {
      isCn ? rightLength += 1 : rightLength += 2;
    }
  }

  return name.replace(new RegExp("^(.{".concat(leftLength, "})(.+)(.{").concat(rightLength, "})$")), "$1\u2026$3");
}

exports.UPLOAD_NAME = UPLOAD_NAME;
exports.abridgeName = abridgeName;
exports.getCurrentDate = getCurrentDate;
exports.returnFileSize = returnFileSize;
//# sourceMappingURL=util.js.map
