// Primitives
import chroma from "chroma-js";
import { tokens as webTokens, componentsList as webComponentList } from './web.index';
import { tokens as nativeMobileTokens, componentsList as nativeMobileComponentList } from './native_mobile.index';
import { getSelectorFromGroup, cleanSelector } from "./src/utils/style-dictionary-utils.js";
const getFactorFromFormula = (formula) => {
    const match = formula.match(/[\d\.]+/);
    return match ? parseFloat(match[0]) : 0; // Default to 0 if no value found
};
export const brighten = (value, formula) => {
    const factor = getFactorFromFormula(formula);
    return chroma(value).brighten(factor / 20).hex(); // Adjust brightness
};
export const darken = (value, formula) => {
    const factor = getFactorFromFormula(formula);
    return chroma(value).darken(factor / 20).hex(); // Adjust darkness
};
export const contrast = (value) => {
    return chroma.contrast(value, '#FFFFFF') > 4.5 ? "#ffffff" : '#000000';
};
export const getTokens = (platform) => {
    if (platform === 'native_mobile') {
        return nativeMobileTokens;
    }
    else {
        return webTokens;
    }
};
export async function getClassName(componentName, platform, appearance, variantName) {
    const module = await loadComponentTokens(componentName, platform);
    const componentJson = module.default;
    const componentRootKey = Object.keys(componentJson)[0];
    const variant = variantName ? variantName : "standard";
    const type = variantName ? "variant" : "mapping";
    const config = {
        component: componentRootKey,
        appearance: appearance,
        type: type,
        variant: variant,
        state: undefined,
        isRootMapping: false,
    };
    return cleanSelector(getSelectorFromGroup(config, { unfilteredTokens: componentJson }, platform));
}
export async function loadComponentTokens(componentName, platform = 'web') {
    const sanitizedComponentName = componentName.replace(/:\s*/g, '-');
    if (platform === 'native_mobile') {
        return import(`./src/tokens/mobile/components/${sanitizedComponentName}/${sanitizedComponentName}.json`);
    }
    else {
        return import(`./src/tokens/web/components/${sanitizedComponentName}/${sanitizedComponentName}.json`);
    }
}
export const getComponentsList = (platform) => {
    if (platform === 'native_mobile') {
        return nativeMobileComponentList;
    }
    else {
        return webComponentList;
    }
};
export * from "./src/utils/style-dictionary-utils.js";
export { default as validateTokenValue } from "./src/token-validation/validate-value.js";
//# sourceMappingURL=index.js.map