export function stripAnsi(input) {
    let output = "";
    let mode = "text";
    for (const char of input) {
        if (mode === "text") {
            if (char === "\u001b") {
                mode = "escape";
                continue;
            }
            output += char;
            continue;
        }
        if (mode === "escape") {
            if (char === "[") {
                mode = "csi";
                continue;
            }
            if (char === "]") {
                mode = "osc";
                continue;
            }
            mode = "text";
            continue;
        }
        if (mode === "csi") {
            const code = char.charCodeAt(0);
            if (code >= 64 && code <= 126) {
                mode = "text";
            }
            continue;
        }
        if (mode === "osc") {
            if (char === "\u0007") {
                mode = "text";
            }
            else if (char === "\u001b") {
                mode = "osc_escape";
            }
            continue;
        }
        if (mode === "osc_escape") {
            mode = char === "\\" ? "text" : "osc";
        }
    }
    return output;
}
//# sourceMappingURL=output-utils.js.map