import { arrayAt, arrayJoin, stringSplit } from "ts-extras";
import { splitIdentifierBlocks } from "./identifier-blocks.js";
const splitWords = (value) => splitIdentifierBlocks(value).map((word) => word.toLowerCase());
const toPascal = (value) => arrayJoin(splitWords(value).map((word) => `${word[0]?.toUpperCase() ?? ""}${word.slice(1)}`), "");
/**
 * Convert an input string into the requested casing format.
 */
export const toCasing = (value, format) => {
    switch (format) {
        case "camelCase": {
            const pascal = toPascal(value);
            return `${pascal[0]?.toLowerCase() ?? ""}${pascal.slice(1)}`;
        }
        case "kebab-case": {
            return arrayJoin(splitWords(value), "-");
        }
        case "PascalCase": {
            return toPascal(value);
        }
        default: {
            return value;
        }
    }
};
/**
 * Extract the final filename segment without extension.
 */
export const filenameStem = (filePath) => {
    const normalizedPath = filePath.replaceAll("\\", "/");
    const pathSegments = stringSplit(normalizedPath, "/");
    const lastPathSegment = arrayAt(pathSegments, -1) ?? filePath;
    return lastPathSegment.replace(/\.[^./\\]+$/u, "");
};
//# sourceMappingURL=casing.js.map