import { allLowerWordStyle, allUpperWordStyle, combineWords, escapeNonPrintableMapper, firstUpperWordStyle, isAscii, isDigit, isLetter, splitIntoWords, standardUnicodeHexEscape, utf16ConcatMap, utf16LegalizeCharacters, } from "../../support/Strings.js";
export const stringEscape = utf16ConcatMap(escapeNonPrintableMapper(isAscii, standardUnicodeHexEscape));
function isStartCharacter(codePoint) {
    if (codePoint === 0x5f)
        return true; // underscore
    return isAscii(codePoint) && isLetter(codePoint);
}
function isPartCharacter(codePoint) {
    return (isStartCharacter(codePoint) ||
        (isAscii(codePoint) && isDigit(codePoint)));
}
const legalizeName = utf16LegalizeCharacters(isPartCharacter);
export function phpNameStyle(startWithUpper, upperUnderscore, original, acronymsStyle = allUpperWordStyle) {
    const words = splitIntoWords(original);
    return combineWords(words, legalizeName, upperUnderscore
        ? allUpperWordStyle
        : startWithUpper
            ? firstUpperWordStyle
            : allLowerWordStyle, upperUnderscore ? allUpperWordStyle : firstUpperWordStyle, upperUnderscore || startWithUpper
        ? allUpperWordStyle
        : allLowerWordStyle, acronymsStyle, upperUnderscore ? "_" : "", isStartCharacter);
}
