var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/components/pisellTags/utils.ts
var utils_exports = {};
__export(utils_exports, {
  generateColorShades: () => generateColorShades
});
module.exports = __toCommonJS(utils_exports);
var hexToRgb = (hex) => {
  hex = hex.replace(/^#/, "");
  if (hex.length === 3) {
    hex = hex.split("").map((h) => h + h).join("");
  }
  const intVal = parseInt(hex, 16);
  return {
    r: intVal >> 16 & 255,
    // 提取红色分量
    g: intVal >> 8 & 255,
    // 提取绿色分量
    b: intVal & 255
    // 提取蓝色分量
  };
};
var rgbToHex = (r, g, b) => {
  return "#" + [r, g, b].map((x) => {
    const hex = x.toString(16);
    return hex.length === 1 ? "0" + hex : hex;
  }).join("");
};
var parseColor = (color) => {
  if (color.startsWith("#")) {
    return hexToRgb(color);
  } else if (color.startsWith("rgb")) {
    const rgba = color.replace(/rgba?\(|\s+|\)/g, "").split(",").map(Number);
    return { r: rgba[0], g: rgba[1], b: rgba[2], a: rgba[3] !== void 0 ? rgba[3] : 1 };
  } else {
    throw new Error("无效的颜色格式");
  }
};
var generateColorShades = (color) => {
  const { r, g, b, a } = parseColor(color);
  const max = 700;
  const gap = 1 / max;
  const ratios = {
    50: gap * 50,
    200: gap * 200,
    500: gap * 500,
    600: gap * 600,
    700: gap * 700
  };
  const adjustColorComponent = (component, ratio) => Math.round(component * ratio + 255 * (1 - ratio));
  const shades = {
    "color_50": rgbToHex(adjustColorComponent(r, ratios[50]), adjustColorComponent(g, ratios[50]), adjustColorComponent(b, ratios[50])),
    "color_200": rgbToHex(adjustColorComponent(r, ratios[200]), adjustColorComponent(g, ratios[200]), adjustColorComponent(b, ratios[200])),
    "color_500": rgbToHex(adjustColorComponent(r, ratios[500]), adjustColorComponent(g, ratios[500]), adjustColorComponent(b, ratios[500])),
    "color_600": rgbToHex(adjustColorComponent(r, ratios[600]), adjustColorComponent(g, ratios[600]), adjustColorComponent(b, ratios[600])),
    "color_700": color
  };
  if (a !== void 0) {
    shades["color_50"] = `rgba(${adjustColorComponent(r, ratios[50])}, ${adjustColorComponent(g, ratios[50])}, ${adjustColorComponent(b, ratios[50])}, ${a})`;
    shades["color_200"] = `rgba(${adjustColorComponent(r, ratios[200])}, ${adjustColorComponent(g, ratios[200])}, ${adjustColorComponent(b, ratios[200])}, ${a})`;
    shades["color_500"] = `rgba(${adjustColorComponent(r, ratios[500])}, ${adjustColorComponent(g, ratios[500])}, ${adjustColorComponent(b, ratios[500])}, ${a})`;
    shades["color_600"] = `rgba(${adjustColorComponent(r, ratios[600])}, ${adjustColorComponent(g, ratios[600])}, ${adjustColorComponent(b, ratios[600])}, ${a})`;
  }
  return shades;
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  generateColorShades
});
