import { setup } from "../setup/internal.js";
import { USERNAME_BLOCKLIST } from "./blocklist.js";
/**
 * Check if a username is available.
 */
export async function isUsernameAvailable(username) {
    const apiEndpoint = setup.getApiEndpoint();
    const resp = await fetch(`${apiEndpoint}/user/data/${username}`);
    return !resp.ok;
}
/**
 * Check if a username is valid.
 */
export function isUsernameValid(username) {
    return !username.startsWith("-") &&
        !username.endsWith("-") &&
        !username.startsWith("_") &&
        /^[a-zA-Z0-9_-]+$/.test(username) &&
        !USERNAME_BLOCKLIST.includes(username.toLowerCase());
}
//# sourceMappingURL=username.js.map