import { Hash } from "@siteimprove/alfa-hash" ; import { Parser } from "@siteimprove/alfa-parser" ; import { Slice } from "@siteimprove/alfa-slice" ; import { Token } from "../syntax/token" ; import { Value } from "../value" ; import { URL } from "./url" ; import { Gradient } from "./gradient" ; const { map , either } = Parser ; /**
 *  https public export class Image < I extends URL | Gradient = URL | Gradient > extends Value < "image" > { public static of < I extends URL | Gradient > ( image ) { return new Image ( image ) ; } private readonly _image : I ; private constructor ( image ) { super ( ) ; this . _image = image ; } public get type ( ) : "image" { return "image" ; } public get image ( ) : I { return this . _image ; } public equals ( value ) { return value instanceof Image && value . _image . equals ( this . _image ) ; } public hash ( hash ) { hash . writeHashable ( this . _image ) ; } public toJSON ( ) { return { type : "image" , image : this . _image . toJSON ( ) , } ; } public toString ( ) { return `${ this . _image }` ; } } public export namespace Image { export interface JSON extends Value . JSON < "image" > { image : URL . JSON | Gradient . JSON ; } export function isImage < I extends URL | Gradient > ( value ) { return value instanceof Image ; } /**
     *  https export const parse = map ( either ( URL . parse , Gradient . parse ) , ( image ) => Image . of ( image ) ) ; }