import Color from '../../Color.mjs';
import chroma from '../../chroma.mjs';
import type from '../../utils/type.mjs';
import input from '../input.mjs';
import hex2rgb from './hex2rgb.mjs';
import rgb2hex from './rgb2hex.mjs';

Color.prototype.hex = function (mode) {
    return rgb2hex(this._rgb, mode);
};

const hex = (...args) => new Color(...args, 'hex');
chroma.hex = hex;

input.format.hex = hex2rgb;
input.autodetect.push({
    p: 4,
    test: (h, ...rest) => {
        if (
            !rest.length &&
            type(h) === 'string' &&
            [3, 4, 5, 6, 7, 8, 9].indexOf(h.length) >= 0
        ) {
            return 'hex';
        }
    }
});

export { hex };
//# sourceMappingURL=index.mjs.map
