 ```ts
export function parseCsvLine(line: string): string[] {
    if (typeof line !== 'string' || line.trim().length === 0) {
        throw new Error('Invalid input');
    }

    const fields: string[] = [];
    let currentField = '';
    let inQuotes = false;

    for (let i = 0; i < line.length; i++) {
        if (line[i] === '"') {
            if (inQuotes) {
                // Check if the next character is not a quote or end of string
                if (i + 1 >= line.length || line[i + 1] !== '"') {
                    inQuotes = false;
                } else {
                    currentField += '"';
                    i++; // Skip the next quote since it's part of the field content
                }
            } else {
                inQuotes = true;
            }
        } else if (line[i] === ',' && !inQuotes) {
            fields.push(currentField.trim());
            currentField = '';
        } else {
            currentField += line[i];
        }
    }

    // Push the last field if any, after trimming spaces
    fields.push(currentField.trim());

    return fields;
}
```