/**
 * ldesign v0.4.2
 * (c) 2023 ldesign
 * @license MIT
 */

import { _ as _objectWithoutProperties } from '../_chunks/dep-b6a73f93.mjs';
import { _ as _slicedToArray } from '../_chunks/dep-55846619.mjs';
import { _ as _defineProperty } from '../_chunks/dep-eb20e23f.mjs';
import { c as camelCase_1 } from '../_chunks/dep-f6649a46.mjs';
import { i as isUndefined_1 } from '../_chunks/dep-30451c48.mjs';
import { i as isNull_1 } from '../_chunks/dep-6f89b77e.mjs';
import { i as isArray_1 } from '../_chunks/dep-e3b14d70.mjs';
import { i as isNumber_1 } from '../_chunks/dep-6eea369f.mjs';
import { i as isString_1 } from '../_chunks/dep-1cf2b129.mjs';
import '../_chunks/dep-cfcedf47.mjs';
import '../_chunks/dep-b4041200.mjs';
import '../_chunks/dep-a0b4a044.mjs';
import '../_chunks/dep-37ba476d.mjs';
import '../_chunks/dep-c959a6fb.mjs';
import '../_chunks/dep-66d6733b.mjs';
import '../_chunks/dep-be27d184.mjs';
import '../_chunks/dep-c31e1d9e.mjs';
import '../_chunks/dep-1fe0ad42.mjs';
import '../_chunks/dep-d54f2690.mjs';
import '../_chunks/dep-59c8420d.mjs';
import '../_chunks/dep-74848b92.mjs';

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), !0).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(function (key) {
    if (!isUndefined_1(obj[key]) || isNull_1(obj[key])) newObj[key] = obj[key];
  });
  return newObj;
}
function getTabElementByValue() {
  var tabs = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
  var value = arguments.length > 1 ? arguments[1] : undefined;
  var _tabs$filter = tabs.filter(function (item) {
      var id = item.id;
      return "".concat(id) === "".concat(value);
    }),
    _tabs$filter2 = _slicedToArray(_tabs$filter, 1),
    result = _tabs$filter2[0];
  return result || null;
}
function firstUpperCase(str) {
  return str.toLowerCase().replace(/( |^)[a-z]/g, function (_char) {
    return _char.toUpperCase();
  });
}
function getBackgroundColor(color) {
  if (isString_1(color)) return color;
  if (isArray_1(color)) {
    if (color[0] && color[0][0] === "#") color.unshift("90deg");
    return "linear-gradient( ".concat(color.join(","), " )");
  }
  var from = color.from,
    to = color.to,
    _color$direction = color.direction,
    direction = _color$direction === void 0 ? "to right" : _color$direction,
    rest = _objectWithoutProperties(color, _excluded);
  var keys = Object.keys(rest);
  if (keys.length) {
    keys = keys.sort(function (a, b) {
      return parseFloat(a.substr(0, a.length - 1)) - parseFloat(b.substr(0, b.length - 1));
    });
    var tempArr = keys.map(function (key) {
      return "".concat(rest[key], " ").concat(key);
    });
    return "linear-gradient(".concat(direction, ", ").concat(tempArr.join(","), ")");
  }
  return "linear-gradient(".concat(direction, ", ").concat(from, ", ").concat(to, ")");
}
function getPropsApiByEvent(eventName) {
  return camelCase_1("on-".concat(eventName));
}
function getCharacterLength(str, maxCharacter) {
  var hasMaxCharacter = isNumber_1(maxCharacter);
  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 pxCompat(param) {
  return isNumber_1(param) ? "".concat(param, "px") : param;
}

export { firstUpperCase, getBackgroundColor, getCharacterLength, getPropsApiByEvent, getTabElementByValue, omit, pxCompat, removeEmptyAttrs };
//# sourceMappingURL=helper.mjs.map
