"use strict";
const uni_modules_uviewPro_libs_function_queryParams = require("./function/queryParams.js");
const uni_modules_uviewPro_libs_function_route = require("./function/route.js");
const uni_modules_uviewPro_libs_function_timeFormat = require("./function/timeFormat.js");
const uni_modules_uviewPro_libs_function_timeFrom = require("./function/timeFrom.js");
const uni_modules_uviewPro_libs_function_colorGradient = require("./function/colorGradient.js");
const uni_modules_uviewPro_libs_function_guid = require("./function/guid.js");
const uni_modules_uviewPro_libs_config_color = require("./config/color.js");
const uni_modules_uviewPro_libs_function_color = require("./function/color.js");
const uni_modules_uviewPro_libs_function_type2icon = require("./function/type2icon.js");
const uni_modules_uviewPro_libs_function_randomArray = require("./function/randomArray.js");
const uni_modules_uviewPro_libs_function_deepClone = require("./function/deepClone.js");
const uni_modules_uviewPro_libs_function_deepMerge = require("./function/deepMerge.js");
const uni_modules_uviewPro_libs_function_addUnit = require("./function/addUnit.js");
const uni_modules_uviewPro_libs_function_test = require("./function/test.js");
const uni_modules_uviewPro_libs_function_random = require("./function/random.js");
const uni_modules_uviewPro_libs_function_trim = require("./function/trim.js");
const uni_modules_uviewPro_libs_function_toast = require("./function/toast.js");
const uni_modules_uviewPro_libs_function_getParent = require("./function/getParent.js");
const uni_modules_uviewPro_libs_function_$parent = require("./function/_parent.js");
const uni_modules_uviewPro_libs_function_sys = require("./function/sys.js");
const uni_modules_uviewPro_libs_function_debounce = require("./function/debounce.js");
const uni_modules_uviewPro_libs_function_throttle = require("./function/throttle.js");
const uni_modules_uviewPro_libs_function_getRect = require("./function/getRect.js");
const uni_modules_uviewPro_libs_function_clipboard = require("./function/clipboard.js");
const uni_modules_uviewPro_libs_config_config = require("./config/config.js");
const uni_modules_uviewPro_libs_config_zIndex = require("./config/zIndex.js");
const uni_modules_uviewPro_libs_util_mitt = require("./util/mitt.js");
const uni_modules_uviewPro_libs_request_index = require("./request/index.js");
require("../../../common/vendor.js");
require("./util/logger.js");
require("./hooks/useTheme.js");
require("./util/config-provider.js");
function formatPrice(number, decimals = 0, decimalPoint = ".", thousandsSeparator = ",") {
  function round(num, precision) {
    const factor = Math.pow(10, precision);
    return (Math.round(num * factor) / factor).toFixed(precision);
  }
  let numStr = String(number).replace(/[^0-9+\-Ee.]/g, "");
  const n = !isFinite(+numStr) ? 0 : +numStr;
  const prec = !isFinite(+decimals) ? 0 : Math.abs(decimals);
  const sep = thousandsSeparator ?? ",";
  const dec = decimalPoint ?? ".";
  let s = [];
  s = (prec ? round(n, prec) : Math.round(n).toString()).split(".");
  const re = /(-?\d+)(\d{3})/;
  while (re.test(s[0])) {
    s[0] = s[0].replace(re, `$1${sep}$2`);
  }
  if ((s[1] || "").length < prec) {
    s[1] = s[1] || "";
    s[1] += "0".repeat(prec - s[1].length);
  }
  return s.join(dec);
}
function formatName(name) {
  if (name.length === 2) {
    return name.charAt(0) + "*";
  } else if (name.length > 2) {
    const masked = "*".repeat(name.length - 2);
    return name.charAt(0) + masked + name.charAt(name.length - 1);
  } else {
    return name;
  }
}
function addStyle(customStyle, target = "object") {
  if (uni_modules_uviewPro_libs_function_test.test.empty(customStyle) || typeof customStyle === "object" && target === "object" || target === "string" && typeof customStyle === "string") {
    return customStyle;
  }
  if (target === "object") {
    const trimmedStyle = uni_modules_uviewPro_libs_function_trim.trim(customStyle);
    const styleArray = trimmedStyle.split(";");
    const style = {};
    for (let i = 0; i < styleArray.length; i++) {
      if (styleArray[i]) {
        const item = styleArray[i].split(":");
        if (item.length === 2) {
          style[uni_modules_uviewPro_libs_function_trim.trim(item[0])] = uni_modules_uviewPro_libs_function_trim.trim(item[1]);
        }
      }
    }
    return style;
  }
  let string = "";
  for (const i in customStyle) {
    if (Object.prototype.hasOwnProperty.call(customStyle, i)) {
      const key = i.replace(/([A-Z])/g, "-$1").toLowerCase();
      string += `${key}:${customStyle[i]};`;
    }
  }
  return uni_modules_uviewPro_libs_function_trim.trim(string);
}
function toStyle(...styles) {
  if (styles.length === 1 && Array.isArray(styles[0])) {
    styles = styles[0].slice();
  }
  const map = /* @__PURE__ */ new Map();
  const processString = (str) => {
    if (!str)
      return;
    const parts = str.split(";");
    for (let part of parts) {
      part = part.trim();
      if (!part)
        continue;
      const idx = part.indexOf(":");
      if (idx === -1)
        continue;
      const key = uni_modules_uviewPro_libs_function_trim.trim(part.slice(0, idx));
      const val = uni_modules_uviewPro_libs_function_trim.trim(part.slice(idx + 1));
      if (key === "" || val === "")
        continue;
      const k = kebabCase(key);
      map.set(k, val);
    }
  };
  const processObject = (obj) => {
    if (!obj)
      return;
    Object.keys(obj).forEach((key) => {
      const val = obj[key];
      if (val == null || val === "")
        return;
      const k = kebabCase(key);
      map.set(k, val);
    });
  };
  for (const item of styles) {
    if (item == null || item === "")
      continue;
    if (uni_modules_uviewPro_libs_function_test.test.string(item)) {
      processString(item);
    } else if (uni_modules_uviewPro_libs_function_test.test.array(item)) {
      item.forEach((el) => {
        if (uni_modules_uviewPro_libs_function_test.test.string(el))
          processString(el);
        else if (uni_modules_uviewPro_libs_function_test.test.object(el))
          processObject(el);
      });
    } else if (uni_modules_uviewPro_libs_function_test.test.object(item)) {
      processObject(item);
    }
  }
  if (map.size === 0)
    return "";
  const result = Array.from(map.entries()).map(([k, v]) => `${k}:${String(v)}`).join(";");
  return result ? result.endsWith(";") ? result : result + ";" : "";
}
function kebabCase(word) {
  const newWord = word.replace(/[A-Z]/g, function(match) {
    return "-" + match;
  }).toLowerCase();
  return newWord;
}
function sleep(value = 30) {
  return new Promise((resolve) => {
    setTimeout(() => {
      resolve(true);
    }, value);
  });
}
const $u = {
  queryParams: uni_modules_uviewPro_libs_function_queryParams.queryParams,
  route: uni_modules_uviewPro_libs_function_route.route,
  timeFormat: uni_modules_uviewPro_libs_function_timeFormat.timeFormat,
  date: uni_modules_uviewPro_libs_function_timeFormat.timeFormat,
  // 另名date
  timeFrom: uni_modules_uviewPro_libs_function_timeFrom.timeFrom,
  colorGradient: uni_modules_uviewPro_libs_function_colorGradient.colorGradients.colorGradient,
  colorToRgba: uni_modules_uviewPro_libs_function_colorGradient.colorGradients.colorToRgba,
  guid: uni_modules_uviewPro_libs_function_guid.guid,
  color: uni_modules_uviewPro_libs_config_color.color,
  getColor: uni_modules_uviewPro_libs_function_color.getColor,
  setColor: uni_modules_uviewPro_libs_function_color.setColor,
  sys: uni_modules_uviewPro_libs_function_sys.sys,
  os: uni_modules_uviewPro_libs_function_sys.os,
  type2icon: uni_modules_uviewPro_libs_function_type2icon.type2icon,
  randomArray: uni_modules_uviewPro_libs_function_randomArray.randomArray,
  hexToRgb: uni_modules_uviewPro_libs_function_colorGradient.colorGradients.hexToRgb,
  rgbToHex: uni_modules_uviewPro_libs_function_colorGradient.colorGradients.rgbToHex,
  test: uni_modules_uviewPro_libs_function_test.test,
  random: uni_modules_uviewPro_libs_function_random.random,
  deepClone: uni_modules_uviewPro_libs_function_deepClone.deepClone,
  deepMerge: uni_modules_uviewPro_libs_function_deepMerge.deepMerge,
  getParent: uni_modules_uviewPro_libs_function_getParent.getParent,
  $parent: uni_modules_uviewPro_libs_function_$parent.$parent,
  clipboard: uni_modules_uviewPro_libs_function_clipboard.clipboard,
  addUnit: uni_modules_uviewPro_libs_function_addUnit.addUnit,
  trim: uni_modules_uviewPro_libs_function_trim.trim,
  type: ["primary", "success", "error", "warning", "info"],
  http: uni_modules_uviewPro_libs_request_index.httpInstance,
  toast: uni_modules_uviewPro_libs_function_toast.toast,
  config: uni_modules_uviewPro_libs_config_config.config,
  // uView配置信息相关，比如版本号
  zIndex: uni_modules_uviewPro_libs_config_zIndex.zIndex,
  debounce: uni_modules_uviewPro_libs_function_debounce.debounce,
  throttle: uni_modules_uviewPro_libs_function_throttle.throttle,
  mitt: uni_modules_uviewPro_libs_util_mitt.mitt(),
  getRect: uni_modules_uviewPro_libs_function_getRect.getRect,
  formatPrice,
  formatName,
  addStyle,
  toStyle,
  kebabCase,
  sleep
};
exports.$u = $u;
//# sourceMappingURL=../../../../.sourcemap/mp-weixin/uni_modules/uview-pro/libs/index.js.map
