```ts
export function scanPairs(input: string): string[][] {
  if (typeof input !== 'string' || input === '') {
    throw new Error('Invalid input');
  }

  const pairs: string[][] = [];
  let inQuotes = false;
  let currentKey = '';
  let currentValue = '';
  let segmentStart = 0;

  for (let i = 0; i <= input.length; i++) {
    const char = input[i];

    if (char === '"' && !inQuotes) {
      inQuotes = true;
    } else if (char === '"' && inQuotes) {
      if (i + 1 < input.length && input[i + 1] !== ';') {
        throw new Error('Unbalanced quotes');
      }
      inQuotes = false;
    } else if (char === ';' && !inQuotes) {
      const segment = input.substring(segmentStart, i);
      const parsed = parseOption(segment);
      pairs.push(parsed);
      segmentStart = i + 1;
    } else if (!inQuotes) {
      if (i === 0 || char === '=') {
        if (char === '=') {
          currentKey += char;
        }
      } else if (char === ' ' && !currentKey) {
        throw new Error('Invalid segment');
      } else if (char.match(/[a-zA-Z_][a-zA-Z\d_]*/)) {
        currentKey += char;
      } else {
        currentValue = input.substring(segmentStart, i).trim();
        pairs.push([currentKey, currentValue]);
        currentKey = '';
        currentValue = '';
        segmentStart = i + 1;
      }
    }
  }

  return pairs;
}

export function parseOption(segment: string): string[] {
  const parts = segment.split('=');
  if (parts.length !== 2) {
    throw new Error('Invalid segment');
  }

  const key = parts[0].trim();
  if (!key.match(/[a-zA-Z_][a-zA-Z\d_]*/)) {
    throw new Error('Invalid key');
  }

  let value = parts[1].trim();
  if (value.startsWith('"') && value.endsWith('"')) {
    value = value.slice(1, -1);
  }

  return [key, value];
}
```