```ts
function parseCsvLine(line: string): string[] {
  const result: string[] = [];
  let currentField = '';
  let inQuotes = false;
  let quoteCount = 0;

  for (let i = 0; i < line.length; i++) {
    const char = line[i];
    if (char === '"') {
      inQuotes = !inQuotes;
      quoteCount++;
    } else if (char === ',' && !inQuotes) {
      if (quoteCount > 1) {
        throw new Error('Invalid CSV format: unbalanced quotes');
      }
      result.push(currentField.trim());
      currentField = '';
      quoteCount = 0;
    } else if (inQuotes) {
      currentField += char;
    } else {
      currentField += char;
    }
  }

  if (currentField.trim() !== '') {
    result.push(currentField.trim());
  }

  return result;
}
```