import type { SizeType, UnitSize } from '../types'

// Ensure size and units are correctly formatted
export function standardSize(value: number | string | undefined, unit: UnitSize = 'px') {
	if (value === undefined || value === '') { return '' }

	// Handle SizeType values
	if (typeof value === 'string') {
		const sizeTypeMap: Record<SizeType, number> = {
			xSmall: 16,
			small: 24,
			medium: 32,
			large: 48,
			xLarge: 64
		}

		if (value in sizeTypeMap) {
			return `${sizeTypeMap[value as SizeType]}${unit}`
		}

		// Handle existing string values with units
		return value.endsWith(unit) ? value : `${value}${unit}`
	}

	return `${value}${unit}`
}
