```ts
/**
 * The KEY=VALUE pairs of a config file. Ignores blank lines and lines whose first non-space character is #,
 * trims whitespace around the key and the value, and splits on the FIRST = only so a value may contain one.
 * Throws an Error naming the line for a line with no = or for an empty key. When a key appears more than once,
 * the last occurrence wins. A key must never reach the prototype of the returned object:
 * parsing "__proto__=x" must produce a plain data key, leaving Object.prototype untouched.
 * Return the complete fixed file.
 */
export function parseConfig(text: string): Record<string, string> {
  const config: Record<string, string> = {};
  for (const line of text.split("\n")) {
    if (line.trim() === "" || line[0] === "#") continue;
    const parts = line.trim().split(/(?<!\\)=/);
    if (parts.length !== 2) throw new Error(`Invalid line format: ${line}`);
    const key = parts[0].trim();
    const value = parts[1].trim();
    config[key] = value;
  }
  return config;
}
```