import { Parser } from "@siteimprove/alfa-parser" ; import { Slice } from "@siteimprove/alfa-slice" ; import { Token } from "../syntax/token" ; import { Angle } from "./angle" ; import { Number } from "./number" ; import { Percentage } from "./percentage" ; import { Keyword } from "./keyword" ; import { Current } from "./color/current" ; import { Hex } from "./color/hex" ; import { HSL } from "./color/hsl" ; import { Named } from "./color/named" ; import { RGB } from "./color/rgb" ; import { System } from "./color/system" ; const { either } = Parser ; public export type Color = Hex | Named | HSL | RGB | Current | System ; public export namespace Color { export type JSON = Hex . JSON | Named . JSON | HSL . JSON | RGB . JSON | Keyword . JSON ; export const current = Keyword . of ( "currentcolor" ) ; export function hex ( value ) { return Hex . of ( value ) ; } export function hsl < H extends Number | Angle , A extends Number | Percentage > ( hue , saturation , lightness , alpha ) { return HSL . of ( hue , saturation , lightness , alpha ) ; } export function named < C extends Named . Color > ( color ) { return Named . of ( color ) ; } export function rgb < C extends Number | Percentage , A extends Number | Percentage > ( red , green , blue , alpha ) { return RGB . of ( red , green , blue , alpha ) ; } export function system ( keyword ) { return Keyword . of ( keyword ) ; } /**
     *  https export const parse = either ( Hex . parse , either ( Named . parse , either ( either ( RGB . parse , HSL . parse ) , either ( Current . parse , System . parse ) ) ) ) ; export function isTransparent ( color ) { switch ( color . type ) { case "keyword" : return false ; case "color" : return color . alpha . value === 0 ; } } }