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: !0
    });
  },
  __copyProps = (to, from, except, desc) => {
    if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__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: !0
}), mod);
var color_exports = {};
__export(color_exports, {
  convertRgbToRgba: () => convertRgbToRgba,
  hexToRgb: () => hexToRgb,
  rgbToHex: () => rgbToHex,
  rgbToRgba: () => rgbToRgba
});
module.exports = __toCommonJS(color_exports);
var import_tamagui = require("tamagui");
function rgbToRgba(token, opacity = 1) {
  let val = (0, import_tamagui.getTokens)().color[token].val;
  val.startsWith("#") && (val = hexToRgb(val));
  const match = val.match(/\d+/g);
  if (!match) throw new Error("Invalid RGB format");
  const red = parseInt(match[0], 10),
    green = parseInt(match[1], 10),
    blue = parseInt(match[2], 10);
  if (opacity < 0 || opacity > 1) throw new Error("Opacity must be a value between 0 and 1");
  return `rgba(${red}, ${green}, ${blue}, ${opacity})`;
}
function convertRgbToRgba(rgb, opacity = 1) {
  const rgbValues = rgb.match(/\d+/g);
  if (rgbValues && rgbValues.length === 3) {
    const [r, g, b] = rgbValues.map(Number);
    return `rgba(${r}, ${g}, ${b}, ${opacity})`;
  } else return rgb;
}
function rgbToHex(rgb) {
  const result = rgb.match(/\d+/g);
  if (!result || result.length !== 3) throw new Error("Invalid RGB format");
  return `#${result.map(value => parseInt(value).toString(16).padStart(2, "0")).join("")}`;
}
function hexToRgb(hex) {
  var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
  return `rgb(${parseInt(result[1], 16)}, ${parseInt(result[2], 16)}, ${parseInt(result[3], 16)})`;
}