import Hex from "./dist-color-hex.js";
import HSL from "./dist-color-hsl.js";
import Keyword from "./dist-color-keyword.js";
import RGB from "./dist-color-rgb.js";
import { TYPE } from "./dist-constants.js";
const Color = {
  /* VARIABLES */
  format: {
    keyword: Keyword,
    hex: Hex,
    rgb: RGB,
    rgba: RGB,
    hsl: HSL,
    hsla: HSL
  },
  /* API */
  parse: (color) => {
    if (typeof color !== "string")
      return color;
    const channels = Hex.parse(color) || RGB.parse(color) || HSL.parse(color) || Keyword.parse(color);
    if (channels)
      return channels;
    throw new Error(`Unsupported color format: "${color}"`);
  },
  stringify: (channels) => {
    if (!channels.changed && channels.color)
      return channels.color;
    if (channels.type.is(TYPE.HSL) || channels.data.r === void 0) {
      return HSL.stringify(channels);
    } else if (channels.a < 1 || !Number.isInteger(channels.r) || !Number.isInteger(channels.g) || !Number.isInteger(channels.b)) {
      return RGB.stringify(channels);
    } else {
      return Hex.stringify(channels);
    }
  }
};
export {
  Color as default
};
//# sourceMappingURL=dist-color-index.js.map
