import chroma from 'chroma-js' ; import { symbolFor as S , createList as L , MalVal } from '@/mal/types' ; const Exports = [ [ 'color/mix' , function ( color1 , color2 , ratio , mode = 'lrgb' ) { return chroma . mix ( color1 , color2 , ratio , mode as any ) . css ( ) ; } , ] , [ 'color/brighten' , function ( color , value = 1 ) { return chroma ( color ) . brighten ( value as number ) . hex ( ) ; } , ] , [ 'color/darken' , function ( color , value = 1 ) { return chroma ( color ) . darken ( value as number ) . hex ( ) ; } , ] , [ 'color/invert' , function ( color , mode = 'rgb' ) { const c = chroma ( color ) ; const a = c . alpha ( ) ; if ( mode === 'rgb' ) { const [ r , g , b ] = c . rgb ( ) ; return chroma ( [ 255 - r , 255 - g , 255 - b , a ] ) . hex ( ) ; } else if ( mode === 'hsl' ) { const [ h , s , l ] = c . hsl ( ) ; return chroma ( ( h + 180 ) % 360 , 1 - s , 1 - l , 'hsl' ) . hex ( ) ; } } ] ] as [ string , MalVal ] [ ] ; const Exp = L ( S ( 'do' ) , ... Exports . map ( ( [ sym , body ] ) => L ( S ( 'def' ) , S ( sym ) , body ) ) ) ; ( globalThis as any ) [ 'glisp_library' ] = Exp ;