import strToMachineName from './strToMachineName.js';
const componentNamePattern = /^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$/;
export default function deriveComponentNames(componentName) {
    const sanitizedName = componentName?.trim() ?? '';
    if (!sanitizedName || !/[A-Za-z0-9]/.test(sanitizedName)) {
        throw new Error('Component name must include at least one letter or number.');
    }
    if (!componentNamePattern.test(sanitizedName)) {
        throw new Error('Component name may only include letters, numbers, and single hyphens between words.');
    }
    const filename = strToMachineName(sanitizedName.replace(/([a-z])([A-Z])/g, '$1 $2').replace(/-/g, ' '));
    const className = filename;
    const camelName = filename.replace(/-([a-z])/g, (_, c) => c.toUpperCase());
    const snakeName = filename.replace(/-/g, '_');
    const humanName = filename
        .split('-')
        .map((word) => word.charAt(0).toUpperCase() + word.slice(1))
        .join(' ');
    return {
        filename,
        className,
        camelName,
        snakeName,
        humanName,
    };
}
