import { Pipe, PipeTransform } from '@angular/core';
import { REIHE_PREFIX_PATTERN } from './reihe.constants';

@Pipe({
  name: 'lineType',
  standalone: true,
  pure: true,
})
export class LineTypePipe implements PipeTransform {
  transform(value: string, ...args: any[]): 'text' | 'reihe' {
    const REIHE_REGEX = new RegExp(`^${REIHE_PREFIX_PATTERN}:\\s*"(.+)"$`, 'g');
    const reihe = REIHE_REGEX.exec(value)?.[2];
    return reihe ? 'reihe' : 'text';
  }
}
