```ts
export function tagsOf(line: unknown): string[] {
  if (typeof line !== 'string') {
    throw new Error('Input must be a string');
  }
  return line.split(',').map(tag => tag.trim().toLowerCase()).filter(tag => !!tag);
}

export function tagIndex(lines: string[]): Record<string, string[]> {
  if (!Array.isArray(lines) || lines.some(line => typeof line !== 'string')) {
    throw new Error('Input must be an array of strings');
  }
  return lines.reduce((acc, line) => {
    if (typeof line === 'string') {
      const tags = tagsOf(line);
      for (const tag of tags) {
        acc[tag] ??= [];
        acc[tag].push(line);
      }
    }
    return acc;
  }, {});
}
```