const GLOB_CHARS = /[*?[{]/;
export function normalizePathLikeInput(value) {
    let trimmed = value.trim();
    if ((trimmed.startsWith('"') && trimmed.endsWith('"')) || (trimmed.startsWith("'") && trimmed.endsWith("'"))) {
        trimmed = trimmed.slice(1, -1);
    }
    return trimmed;
}
export function pathLikeContainsGlob(value) {
    return GLOB_CHARS.test(value);
}
export function splitPathLikeGlob(input) {
    const value = normalizePathLikeInput(input);
    const normalized = value.replace(/\\/g, "/");
    const segments = normalized.split("/");
    const firstGlobSegment = segments.findIndex((segment) => pathLikeContainsGlob(segment));
    if (firstGlobSegment === -1)
        return { basePath: value };
    const basePath = segments.slice(0, firstGlobSegment).join("/") || ".";
    let glob = segments.slice(firstGlobSegment).join("/");
    if (firstGlobSegment === 0 && glob !== "**" && !glob.startsWith("**/")) {
        glob = `**/${glob}`;
    }
    return { basePath, glob };
}
//# sourceMappingURL=glob-path-utils.js.map