import { ifElse , pipe , replace , startsWith , unless } from 'ramda' ; import { existsSync , mkdirSync , writeFileSync } from 'fs' ; import { dirname } from 'path' ; const open = `/* eslint-disable */
// file autogenerated by http://github.com/mathieutu/tailwind-ts
` ; const classesTemplate = `
/** Because of { exportClassesList: true } configuration. */
export const tailwindClasses = [
{TAILWIND_CLASSES}
] as const
` ; const classTemplate = `
/** Because of { exportClassesChoice: true } or { exportClassNamesHelper: true } configuration. */
export type TailwindClass = (
{TAILWIND_CLASS}
)
` ; const classNamesTemplate = `
/** Because of { exportClassNamesHelper: true } configuration. */
type ClassNamesValue = ClassNamesValue[] | TailwindClass | boolean | null | undefined | { [key in TailwindClass]: boolean};
type TailwindClassNamesFunction = (...classes: ClassNamesValue[]) => string
export const tw: TailwindClassNamesFunction = require('classnames')
` ; const constsTemplate = `
/** Because of { exportConstants: true } configuration. */
{TAILWIND_CONSTS}
` ; const toConst = ( { prefix = '' , separator = ':' } , value ) => pipe ( replace ( prefix , '' ) , replace ( '/' , '-on-' ) , replace ( '.' , '-dot-' ) , ifElse ( startsWith ( '-' ) , replace ( /^/ , 'neg-' ) , replace ( `${ separator }-` , '-neg-' ) ) , replace ( /\W/g , '-' ) , replace ( /^/ , 'tw-' ) , require ( 'camelcase' ) ) ( value ) ; export const getFile = ( config , { exportClassesList , exportClassesChoice , exportClassNamesHelper , exportConstants , } ) => classes => [ open , exportClassesList && ( classesTemplate . replace ( '{TAILWIND_CLASSES}' , classes . map ( className => `  '${ className }',` ) . join ( '\n' ) ) ) , ( exportClassesChoice || exportClassNamesHelper ) && ( classTemplate . replace ( '{TAILWIND_CLASS}' , classes . map ( className => `  | '${ className }'` ) . join ( '\n' ) ) ) , exportClassNamesHelper && ( classNamesTemplate ) , exportConstants && ( constsTemplate . replace ( '{TAILWIND_CONSTS}' , classes . map ( className => `export const ${ toConst ( config , className ) } = '${ className }' as const` ) . join ( '\n' ) ) ) , ] . filter ( Boolean ) . join ( '\n' ) ; export const createFile = ( path ) => ( source ) => { unless ( existsSync , mkdirSync , dirname ( path ) ) ; writeFileSync ( path , source ) ; } ;