'use strict';

/* This file is generated by vega-design 2.0.77 */ 
const Spacing = {
	"0": 0,
	"size-4": 4,
	"size-8": 8,
	"size-12": 12,
	"size-16": 16,
	"size-20": 20,
	"size-24": 24,
	"size-32": 32,
	"size-40": 40,
	"size-48": 48,
	"size-64": 64,
	"size-72": 72,
	"size-80": 80,
	"size-112": 112,
	"size-2": 2
};

/**
 * The function parses a string representing a pixel value to a number, or returns the input if it is already a number.
 *
 * @param {number | string} input - The input parameter can be either a number or a string. If it is a
 * string, it should be in the format of a CSS pixel value (e.g. "10px").
 * @returns {number} returns a number. If the input is already a number, it returns the input as is. If the input is a string, it attempts to extract a number from the
 * string by removing the 'px' suffix and converting the remaining string to a number. If the string
 * cannot be converted to a number, it returns 0.
 */
function parsePixelStringToNumber(input) {
  return typeof input === 'number'
    ? input
    : input && !isNaN(Number(input.replace('px', '')))
      ? Number(input.replace('px', ''))
      : 0;
}
/**
 * The function takes a number or string input and returns a string with 'px' appended if the input is a number.
 *
 * @param {number | string} input - The input parameter can be either a number or a string. If it is a
 * number, the function will convert it to a string and append the 'px' unit to it. If it is already a string, the function will simply return it as is.
 * @returns {string} returns a string that represents a CSS pixel value. If the input is a number, it concatenates the number with the string 'px'. If the input is already a
 * string, it returns the input string as is.
 */
function parseNumberToPixelString(input) {
  return typeof input === 'number' ? input + 'px' : input;
}
/**
 * This function takes an input parameter and returns a string.
 * - If the input is a number, it returns a string with 'px'.
 * - If the input is a string, it returns the input string as is.
 * - If the input is a {@link SpacingTokenType}, it returns a parsed value string with 'px'.
 *
 * @param {number | string | SpacingTokenType} input - The input parameter can be either a number or a string. If it is a
 * @returns {string} returns a string that represents a CSS pixel value
 */
function parseToPixelString(input) {
  if (!isNaN(Number(input))) {
    return `${input}px`;
  }
  else if (Object.keys(Spacing).includes(input)) {
    return `${Spacing[input]}px`;
  }
  else {
    return input;
  }
}

exports.parseNumberToPixelString = parseNumberToPixelString;
exports.parsePixelStringToNumber = parsePixelStringToNumber;
exports.parseToPixelString = parseToPixelString;
