"use strict";
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
const hex = require("./dist-color-hex.cjs");
const hsl = require("./dist-color-hsl.cjs");
const keyword = require("./dist-color-keyword.cjs");
const rgb = require("./dist-color-rgb.cjs");
const constants = require("./dist-constants.cjs");
const Color = {
  /* VARIABLES */
  format: {
    keyword: keyword.default,
    hex: hex.default,
    rgb: rgb.default,
    rgba: rgb.default,
    hsl: hsl.default,
    hsla: hsl.default
  },
  /* API */
  parse: (color) => {
    if (typeof color !== "string")
      return color;
    const channels = hex.default.parse(color) || rgb.default.parse(color) || hsl.default.parse(color) || keyword.default.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(constants.TYPE.HSL) || channels.data.r === void 0) {
      return hsl.default.stringify(channels);
    } else if (channels.a < 1 || !Number.isInteger(channels.r) || !Number.isInteger(channels.g) || !Number.isInteger(channels.b)) {
      return rgb.default.stringify(channels);
    } else {
      return hex.default.stringify(channels);
    }
  }
};
exports.default = Color;
//# sourceMappingURL=dist-color-index.cjs.map
