/**
 * ldesign v0.2.3
 * (c) 2022年9月24日 swimly
 * @license MIT
 */

import { _ as _defineProperty } from './defineProperty-56324511.js';

/**
 * LDesignUtility v0.2.1
 * (c) 2022 undefined
 * @license MIT
 */

function _objectWithoutPropertiesLoose(source, excluded) {
  if (source == null) return {};
  var target = {};
  var sourceKeys = Object.keys(source);
  var key, i;

  for (i = 0; i < sourceKeys.length; i++) {
    key = sourceKeys[i];
    if (excluded.indexOf(key) >= 0) continue;
    target[key] = source[key];
  }

  return target;
}

function _objectWithoutProperties(source, excluded) {
  if (source == null) return {};

  var target = _objectWithoutPropertiesLoose(source, excluded);

  var key, i;

  if (Object.getOwnPropertySymbols) {
    var sourceSymbolKeys = Object.getOwnPropertySymbols(source);

    for (i = 0; i < sourceSymbolKeys.length; i++) {
      key = sourceSymbolKeys[i];
      if (excluded.indexOf(key) >= 0) continue;
      if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
      target[key] = source[key];
    }
  }

  return target;
}

var _excluded = ["from", "to", "direction"];

function ownKeys(object, enumerableOnly) {
  var keys = Object.keys(object);

  if (Object.getOwnPropertySymbols) {
    var symbols = Object.getOwnPropertySymbols(object);
    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 = null != arguments[i] ? arguments[i] : {};
    i % 2 ? ownKeys(Object(source), true).forEach(function (key) {
      _defineProperty(target, key, source[key]);
    }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
      Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
    });
  }

  return target;
}

function omit(obj, fields) {
  var shallowCopy = _objectSpread({}, obj);

  for (var i = 0; i < fields.length; i++) {
    var key = fields[i];
    delete shallowCopy[key];
  }

  return shallowCopy;
}

function removeEmptyAttrs(obj) {
  var newObj = {};
  Object.keys(obj).forEach(key => {
    if (typeof obj[key] !== "undefined" || obj[key] === null) {
      newObj[key] = obj[key];
    }
  });
  return newObj;
}

function getTabElementByValue() {
  var tabs = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [];
  var value = arguments.length > 1 ? arguments[1] : void 0;
  var [result] = tabs.filter(item => {
    var {
      id
    } = item;
    return id === value;
  });
  return result || null;
}

function firstUpperCase(str) {
  return str.toLowerCase().replace(/( |^)[a-z]/g, char => char.toUpperCase());
}

function getBackgroundColor(color) {
  if (typeof color === "string") {
    return color;
  }

  if (Array.isArray(color)) {
    if (color[0] && color[0][0] === "#") {
      color.unshift("90deg");
    }

    return "linear-gradient( ".concat(color.join(","), " )");
  }

  var {
    from,
    to,
    direction = "to right"
  } = color,
      rest = _objectWithoutProperties(color, _excluded);

  var keys = Object.keys(rest);

  if (keys.length) {
    keys = keys.sort((a, b) => {
      var c = parseFloat(a.substr(0, a.length - 1)) - parseFloat(b.substr(0, b.length - 1));
      return c;
    });
    var tempArr = keys.map(key => "".concat(rest[key], " ").concat(key));
    return "linear-gradient(".concat(direction, ", ").concat(tempArr.join(","), ")");
  }

  return "linear-gradient(".concat(direction, ", ").concat(from, ", ").concat(to, ")");
}

function getIEVersion() {
  var {
    userAgent
  } = navigator;
  var isIE = userAgent.indexOf("compatible") > -1 && userAgent.indexOf("MSIE") > -1;
  var isIE11 = userAgent.indexOf("Trident") > -1 && userAgent.indexOf("rv:11.0") > -1;

  if (isIE) {
    var reIE = new RegExp("MSIE (\\d+\\.\\d+);");
    var match = userAgent.match(reIE);
    if (!match) return -1;
    var fIEVersion = parseFloat(match[1]);
    return fIEVersion < 7 ? 6 : fIEVersion;
  }

  if (isIE11) {
    return 11;
  }

  return Number.MAX_SAFE_INTEGER;
}

function getCharacterLength(str, maxCharacter) {
  var hasMaxCharacter = typeof maxCharacter === "number";

  if (!str || str.length === 0) {
    if (hasMaxCharacter) {
      return {
        length: 0,
        characters: str
      };
    }

    return 0;
  }

  var len = 0;

  for (var i = 0; i < str.length; i++) {
    var currentStringLength = 0;

    if (str.charCodeAt(i) > 127 || str.charCodeAt(i) === 94) {
      currentStringLength = 2;
    } else {
      currentStringLength = 1;
    }

    if (hasMaxCharacter && len + currentStringLength > maxCharacter) {
      return {
        length: len,
        characters: str.slice(0, i)
      };
    }

    len += currentStringLength;
  }

  if (hasMaxCharacter) {
    return {
      length: len,
      characters: str
    };
  }

  return len;
}

function getUnicodeLength(str) {
  return [...(str !== null && str !== void 0 ? str : "")].length;
}

function limitUnicodeMaxLength(str, maxLength) {
  return [...(str !== null && str !== void 0 ? str : "")].slice(0, maxLength).join("");
}

function pxCompat(param) {
  return typeof param === "number" ? "".concat(param, "px") : param;
}

var DOM_STYLE_PROPS = ["padding-top", "padding-bottom", "padding-left", "padding-right", "font-family", "font-weight", "font-size", "font-variant", "text-rendering", "text-transform", "width", "text-indent", "border-width", "box-sizing", "line-height", "letter-spacing"];

function calculateNodeSize(targetElement) {
  var style = window.getComputedStyle(targetElement);
  var boxSizing = style.getPropertyValue("box-sizing") || style.getPropertyValue("-moz-box-sizing") || style.getPropertyValue("-webkit-box-sizing");
  var paddingSize = parseFloat(style.getPropertyValue("padding-bottom")) + parseFloat(style.getPropertyValue("padding-top"));
  var borderSize = parseFloat(style.getPropertyValue("border-bottom-width")) + parseFloat(style.getPropertyValue("border-top-width"));
  var sizingStyle = DOM_STYLE_PROPS.map(name => "".concat(name, ":").concat(style.getPropertyValue(name))).join(";");
  return {
    paddingSize,
    borderSize,
    boxSizing,
    sizingStyle
  };
}

export { getUnicodeLength as a, calculateNodeSize as c, getIEVersion as g, limitUnicodeMaxLength as l };
//# sourceMappingURL=helper2.js.map
