"use strict";
const uni_modules_tdesignUniapp_components_common_runtime_wxsPolyfill = require("./runtime/wxs-polyfill.js");
function addUnit(value) {
  const REGEXP = uni_modules_tdesignUniapp_components_common_runtime_wxsPolyfill.getRegExp("^-?\\d+(.\\d+)?$");
  if (value == null) {
    return void 0;
  }
  return REGEXP.test(`${value}`) ? `${value}px` : value;
}
function isString(string) {
  return typeof string === "string";
}
function isArray(array) {
  return Array.isArray(array);
}
function isObject(x) {
  const type = typeof x;
  return x !== null && (type === "object" || type === "function");
}
function isBoolean(value) {
  return typeof value === "boolean";
}
const isNoEmptyObj = function(obj) {
  return isObject(obj) && JSON.stringify(obj) !== "{}";
};
function includes(arr, value) {
  if (!arr || !isArray(arr))
    return false;
  let i = 0;
  const len = arr.length;
  for (; i < len; i++) {
    if (arr[i] === value)
      return true;
  }
  return false;
}
function cls(base, arr) {
  const res = [base];
  let i = 0;
  for (let size = arr.length; i < size; i++) {
    const item = arr[i];
    if (item && Array.isArray(item)) {
      const key = arr[i][0];
      const value = arr[i][1];
      if (value) {
        res.push(`${base}--${key}`);
      }
    } else if (typeof item === "string" || typeof item === "number") {
      if (item) {
        res.push(`${base}--${item}`);
      }
    }
  }
  return res.join(" ");
}
function getBadgeAriaLabel(options) {
  const maxCount = options.maxCount || 99;
  if (options.dot) {
    return "有新的消息";
  }
  if (options.count === "...") {
    return "有很多消息";
  }
  if (isNaN(options.count)) {
    return options.count;
  }
  const str1 = `有${maxCount}+条消息`;
  const str2 = `有${options.count}条消息`;
  return Number(options.count) > maxCount ? str1 : str2;
}
function endsWith(str, endStr) {
  return str.slice(-endStr.length) === endStr ? str : str + endStr;
}
function keys(obj) {
  return JSON.stringify(obj).replace(uni_modules_tdesignUniapp_components_common_runtime_wxsPolyfill.getRegExp('{|}|"', "g"), "").split(",").map((item) => item.split(":")[0]);
}
function kebabCase(str) {
  return str.replace(uni_modules_tdesignUniapp_components_common_runtime_wxsPolyfill.getRegExp("[A-Z]", "g"), (ele) => `-${ele}`).toLowerCase();
}
function _style(styles) {
  if (isArray(styles)) {
    return styles.filter((item) => item != null && item !== "").map((item) => isArray(item) || isObject(item) ? _style(item) : endsWith(item, ";")).join(" ");
  }
  if (isObject(styles)) {
    return keys(styles).filter((key) => styles[key] != null && styles[key] !== "").map((key) => [kebabCase(key), [styles[key]]].join(":")).join(";");
  }
  return styles;
}
function isValidIconName(str) {
  return uni_modules_tdesignUniapp_components_common_runtime_wxsPolyfill.getRegExp("^[A-Za-z0-9-_]+$").test(str);
}
const tools = {
  addUnit,
  isString,
  isArray,
  isObject,
  isBoolean,
  isNoEmptyObj,
  includes,
  cls,
  getBadgeAriaLabel,
  _style,
  isValidIconName
};
exports.tools = tools;
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/uni_modules/tdesign-uniapp/components/common/utils.wxs.js.map
