import { Keyword , Token } from "@siteimprove/alfa-css" ; import { Parser } from "@siteimprove/alfa-parser" ; import { Result } from "@siteimprove/alfa-result" ; import { Slice } from "@siteimprove/alfa-slice" ; import { Property } from "../property" ; import * as Direction from "./flex-direction" ; import * as Wrap from "./flex-wrap" ; const { map } = Parser ; declare module "../property" { interface Shorthands { "flex-flow" : Property . Shorthand < "flex-direction" | "flex-wrap" > ; } } export const parse = ( input ) => { let direction ; let wrap ; while ( true ) { for ( const [ remainder ] of Token . parseWhitespace ( input ) ) { input = remainder ; } if ( direction === undefined ) { const result = Direction . parse ( input ) ; if ( result . isOk ( ) ) { [ input , direction ] = result . get ( ) ; continue ; } } if ( wrap === undefined ) { const result = Wrap . parse ( input ) ; if ( result . isOk ( ) ) { [ input , wrap ] = result . get ( ) ; continue ; } } break ; } return Result . of ( [ input , [ direction ?? Keyword . of ( "initial" ) , wrap ?? Keyword . of ( "initial" ) ] , ] ) ; } ; /**
 *  https internal export default Property . registerShorthand ( "flex-flow" , Property . shorthand ( [ "flex-direction" , "flex-wrap" ] , map ( parse , ( [ direction , wrap ] ) => [ [ "flex-direction" , direction ] , [ "flex-wrap" , wrap ] , ] ) ) ) ;