/* util.js — small shared helpers (ESM) */

// "#rrggbb" + alpha -> "rgba(...)"; passes through non-hex strings unchanged
export function hexA(hex, a) {
  if (typeof hex !== "string" || hex[0] !== "#") return hex;
  const n = parseInt(hex.slice(1), 16);
  const r = (n >> 16) & 255, g = (n >> 8) & 255, b = n & 255;
  return `rgba(${r},${g},${b},${a})`;
}
