import i from "./hex.js";
import t from "./hsl.js";
import o from "./keyword.js";
import e from "./rgb.js";
import { TYPE as m } from "../constants.js";
const y = {
  /* VARIABLES */
  format: {
    keyword: o,
    hex: i,
    rgb: e,
    rgba: e,
    hsl: t,
    hsla: t
  },
  /* API */
  parse: (r) => {
    if (typeof r != "string")
      return r;
    const f = i.parse(r) || e.parse(r) || t.parse(r) || o.parse(r);
    if (f)
      return f;
    throw new Error(`Unsupported color format: "${r}"`);
  },
  stringify: (r) => !r.changed && r.color ? r.color : r.type.is(m.HSL) || r.data.r === void 0 ? t.stringify(r) : r.a < 1 || !Number.isInteger(r.r) || !Number.isInteger(r.g) || !Number.isInteger(r.b) ? e.stringify(r) : i.stringify(r)
};
export {
  y as default
};
